diff options
author | mathieui <mathieui@mathieui.net> | 2012-08-07 11:05:28 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2012-08-07 11:05:28 +0200 |
commit | e8dce570eac86cb9b888a61776ca5c858c03a1aa (patch) | |
tree | 97853826c89cbf17d41f0e413bb68b216654886d | |
parent | 7a485ef4d0d74313bff8c9c7b2ee2dcb5c4a75e9 (diff) | |
download | poezio-e8dce570eac86cb9b888a61776ca5c858c03a1aa.tar.gz poezio-e8dce570eac86cb9b888a61776ca5c858c03a1aa.tar.bz2 poezio-e8dce570eac86cb9b888a61776ca5c858c03a1aa.tar.xz poezio-e8dce570eac86cb9b888a61776ca5c858c03a1aa.zip |
Take care of the race condition "node@groupchat_server is now online/offline"
- get rid of the ugly blacklist thing that didn’t work sometimes
-rw-r--r-- | src/core.py | 12 | ||||
-rw-r--r-- | src/roster.py | 8 | ||||
-rw-r--r-- | src/tabs.py | 1 |
3 files changed, 11 insertions, 10 deletions
diff --git a/src/core.py b/src/core.py index 5368ff93..519e82a3 100644 --- a/src/core.py +++ b/src/core.py @@ -2409,6 +2409,8 @@ class Core(object): ### Presence-related handlers ### def on_presence(self, presence): + if presence.match('presence/muc') or presence.xml.find('{http://jabber.org/protocol/muc#user}x'): + return jid = presence['from'] contact = roster[jid.bare] if contact is None: @@ -2425,20 +2427,25 @@ class Core(object): """ A JID got offline """ + if presence.match('presence/muc') or presence.xml.find('{http://jabber.org/protocol/muc#user}x'): + return jid = presence['from'] logger.log_roster_change(jid.bare, 'got offline') # If a resource got offline, display the message in the conversation with this # precise resource. if jid.resource: self.add_information_message_to_conversation_tab(jid.full, '\x195}%s is \x191}offline' % (jid.full)) - if jid.server in roster.blacklist: - return self.add_information_message_to_conversation_tab(jid.bare, '\x195}%s is \x191}offline' % (jid.bare)) self.information('\x193}%s \x195}is \x191}offline' % (jid.bare), 'Roster') if isinstance(self.current_tab(), tabs.RosterInfoTab): self.refresh_window() def on_got_online(self, presence): + """ + A JID got online + """ + if presence.match('presence/muc') or presence.xml.find('{http://jabber.org/protocol/muc#user}x'): + return jid = presence['from'] contact = roster[jid.bare] if contact is None: @@ -2700,7 +2707,6 @@ class Core(object): - class KeyDict(dict): """ A dict, with a wrapper for get() that will return a custom value diff --git a/src/roster.py b/src/roster.py index adf0fd2a..3458d5b5 100644 --- a/src/roster.py +++ b/src/roster.py @@ -25,13 +25,9 @@ from sleekxmpp.exceptions import IqError class Roster(object): """ The proxy class to get the roster from SleekXMPP. - Adds a blacklist for the MUC domains (or else they would show here), - and caches Contact and RosterGroup objects. + Caches Contact and RosterGroup objects. """ - # MUC domains to blacklist from the contacts roster - blacklist = set() - def __init__(self): """ node: the RosterSingle from SleekXMPP @@ -121,7 +117,7 @@ class Roster(object): def jids(self): """List of the contact JIDS""" - return [key for key in self.__node.keys() if safeJID(key).server not in self.blacklist and key != self.jid] + return [key for key in self.__node.keys() if key != self.jid] def get_contacts(self): """ diff --git a/src/tabs.py b/src/tabs.py index 9e9e55ba..ecfa3e40 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1198,7 +1198,6 @@ class MucTab(ChatTab): self.core.events.trigger('muc_join', presence, self) if from_nick == self.own_nick: self.joined = True - roster.blacklist.add(safeJID(from_room).server) if self.get_name() in self.core.initial_joins: self.core.initial_joins.remove(self.get_name()) self._state = 'normal' |