From cb242e2bbd917c5b86171965628f052725ec56ae Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Mon, 10 Apr 2006 08:24:55 +0000 Subject: [PATCH] remove contact from server list if it's useless (sub=ask=name=groups=None). Fixes #1821 --- src/common/connection_handlers.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index f4c0e6803..9212a61b5 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1564,18 +1564,21 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco) def _on_roster_set(self, roster): raw_roster = roster.getRaw() roster = {} + our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name)) for jid in raw_roster: try: j = helpers.parse_jid(jid) except: print >> sys.stderr, _('JID %s is not RFC compliant. It will not be added to your roster. Use roster management tools such as http://jru.jabberstudio.org/ to remove it') % jid else: - roster[j] = raw_roster[jid] - - # Remove or jid - our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name)) - if roster.has_key(our_jid): - del roster[our_jid] + infos = raw_roster[jid] + if jid != our_jid and (not infos['subscription'] or infos['subscription'] == \ + 'none') and (not infos['ask'] or infos['ask'] == 'none') and not infos['name'] \ + and not infos['groups']: + # remove this useless item, it won't be shown in roster anyway + self.connection.getRoster().delItem(jid) + elif jid != our_jid: # don't add our jid + roster[j] = raw_roster[jid] self.dispatch('ROSTER', roster)