def __on_contact_added(self, protocol, account, identifier=None, nick=None, message=None, _status=status.OFFLINE, alias=None, blocked=False): '''callback called when a new contact is added''' if _status in status.MSN_TO_STATUS: _status = status.MSN_TO_STATUS[_status] elif not status.is_valid(_status): debug("Invalid status '%s', setting offline" % (_status,)) _status = status.OFFLINE self._on_contact_added(account, identifier, nick, message, _status, alias, blocked)
def _on_contact_status_changed(self, account, new_status): """callback called when an user change his status""" if not self.exists(account): debug("contact '%s' not in self.contacts" % (account,)) return if status.is_valid(new_status): contact = self.contacts[account] old = contact.status contact._on_status_changed(new_status) self.signal_emit("contact-changed", contact, "status", old) self.signal_emit("contact-status-changed", contact, old) else: debug("invalid status '%s'" % (new_status,))
def set_status(self, new_status): '''set the status to status, the status should be one of the constants on status.py, consider calling status.is_valid. Also you should convert it to the values on the library''' if not self.protocol: return if status.is_valid(new_status): # direct self.me.status = status.STATUS_TO_MSN[new_status] self.protocol.changeStatus(status.STATUS_TO_MSN[new_status]) elif new_status in status.STATUS_TO_MSN.values(): # HDN self.me.status = new_status self.protocol.changeStatus(new_status) else: debug('not a valid status"' + new_status + '"')
def _on_contact_status_changed(self, account, new_status): '''callback called when an user change his status''' if not self.exists(account): debug("contact '%s' not in self.contacts" % (account, )) return if status.is_valid(new_status): contact = self.contacts[account] old = contact.status contact._on_status_changed(new_status) self.signal_emit('contact-changed', contact, 'status', old) self.signal_emit('contact-status-changed', contact, old) else: debug("invalid status '%s'" % (new_status, ))
def __on_contact_added(self, protocol, account, identifier=None, nick=None, message=None, _status=status.OFFLINE, alias=None, blocked=False): '''callback called when a new contact is added''' if _status in status.MSN_TO_STATUS: _status = status.MSN_TO_STATUS[_status] elif not status.is_valid(_status): debug("Invalid status '%s', setting offline" % (_status, )) _status = status.OFFLINE self._on_contact_added(account, identifier, nick, message, _status, alias, blocked)