diff options
author | mathieui <mathieui@mathieui.net> | 2013-07-24 21:34:14 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2013-07-24 21:34:14 +0200 |
commit | 33a9f1434f1fe85db4bf78b8524037356079d5c3 (patch) | |
tree | d59d1a26dc4a3ebcada94ff66896315587203b2e /src/roster.py | |
parent | 9b51377185be5049e29c8824949fad98db25ca91 (diff) | |
download | poezio-33a9f1434f1fe85db4bf78b8524037356079d5c3.tar.gz poezio-33a9f1434f1fe85db4bf78b8524037356079d5c3.tar.bz2 poezio-33a9f1434f1fe85db4bf78b8524037356079d5c3.tar.xz poezio-33a9f1434f1fe85db4bf78b8524037356079d5c3.zip |
Fix contact removal
Diffstat (limited to 'src/roster.py')
-rw-r--r-- | src/roster.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/roster.py b/src/roster.py index d6fed94f..5a068909 100644 --- a/src/roster.py +++ b/src/roster.py @@ -69,24 +69,30 @@ class Roster(object): """Set the a Contact value for the bare jid key""" self.contacts[key] = value + def remove(self, jid): + """Send a removal iq to the server""" + jid = safeJID(jid).bare + if self.__node[jid]: + try: + self.__node[jid].send_presence(ptype='unavailable') + self.__node.remove(jid) + except (IqError, IqTimeout): + import traceback + log.debug('IqError when removing %s:\n%s', jid, traceback.format_exc()) + def __delitem__(self, jid): - """Remove a contact from the roster""" + """Remove a contact from the roster view""" jid = safeJID(jid).bare contact = self[jid] if not contact: return + del self.contacts[contact.bare_jid] + for group in list(self.groups.values()): group.remove(contact) if not group: del self.groups[group.name] - del self.contacts[contact.bare_jid] - if jid in self.jids(): - try: - self.__node[jid].send_presence(ptype='unavailable') - self.__node.remove(jid) - except (IqError, IqTimeout): - import traceback - log.debug('IqError when removing %s:\n%s', jid, traceback.format_exc()) + self.modified() def __iter__(self): """Iterate over the jids of the contacts""" |