diff options
author | Yann Leboulanger <asterix@lagaule.org> | 2010-01-20 14:23:46 +0300 |
---|---|---|
committer | Yann Leboulanger <asterix@lagaule.org> | 2010-01-20 14:23:46 +0300 |
commit | db575a25f6f459bf19125ccb3eb0a1715152a007 (patch) | |
tree | be8e913b3bf13df25ab492c76f993b2949e92127 | |
parent | 5488cb930785d0792d910c0bbf883c6446a12ffc (diff) |
send pep info only once we are connected. Fixes #5567
-rw-r--r-- | src/common/connection.py | 9 | ||||
-rw-r--r-- | src/common/connection_handlers.py | 1 | ||||
-rw-r--r-- | src/common/pep.py | 49 |
3 files changed, 55 insertions, 4 deletions
diff --git a/src/common/connection.py b/src/common/connection.py index bd85abd91..767daba3a 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -708,6 +708,7 @@ class Connection(CommonConnection, ConnectionHandlers): # We are doing disconnect at so many places, better use one function in all def disconnect(self, on_purpose=False): gajim.interface.music_track_changed(None, None, self.name) + self.reset_awaiting_pep() self.on_purpose = on_purpose self.connected = 0 self.time_to_reconnect = None @@ -1474,16 +1475,16 @@ class Connection(CommonConnection, ConnectionHandlers): self.priority = priority self.dispatch('STATUS', 'invisible') if initial: - #ask our VCard + # ask our VCard self.request_vcard(None) - #Get bookmarks from private namespace + # Get bookmarks from private namespace self.get_bookmarks() - #Get annotations + # Get annotations self.get_annotations() - #Inform GUI we just signed in + # Inform GUI we just signed in self.dispatch('SIGNED_IN', ()) def get_signed_presence(self, msg, callback = None): diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index d9ee21a4f..17cebac4d 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -2163,6 +2163,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, # Inform GUI we just signed in self.dispatch('SIGNED_IN', ()) + self.send_awaiting_pep() self.continue_connect_info = None def request_gmail_notifications(self): diff --git a/src/common/pep.py b/src/common/pep.py index e85e7021e..16d2f3f60 100644 --- a/src/common/pep.py +++ b/src/common/pep.py @@ -500,6 +500,30 @@ class ConnectionPEP(object): self._account = account self._dispatcher = dispatcher self._pubsub_connection = pubsub_connection + self.reset_awaiting_pep() + + def reset_awaiting_pep(self): + self.to_be_sent_activity = None + self.to_be_sent_mood = None + self.to_be_sent_tune = None + self.to_be_sent_nick = None + self.to_be_sent_location = None + + def send_awaiting_pep(self): + """ + Send pep info that were waiting for connection + """ + if self.to_be_sent_activity: + self.send_activity(*self.to_be_sent_activity) + if self.to_be_sent_mood: + self.send_mood(*self.to_be_sent_mood) + if self.to_be_sent_tune: + self.send_tune(*self.to_be_sent_tune) + if self.to_be_sent_nick: + self.send_nick(self.to_be_sent_nick) + if self.to_be_sent_location: + self.send_location(self.to_be_sent_location) + self.reset_awaiting_pep() def _pubsubEventCB(self, xmpp_dispatcher, msg): ''' Called when we receive <message /> with pubsub event. ''' @@ -530,6 +554,11 @@ class ConnectionPEP(object): raise xmpp.NodeProcessed def send_activity(self, activity, subactivity=None, message=None): + if self.connected == 1: + # We are connecting, keep activity in mem and send it when we'll be + # conencted + self.to_be_sent_activity = (activity, subactivity, message) + return if not self.pep_supported: return item = xmpp.Node('activity', {'xmlns': xmpp.NS_ACTIVITY}) @@ -550,6 +579,11 @@ class ConnectionPEP(object): self._pubsub_connection.send_pb_retract('', xmpp.NS_ACTIVITY, '0') def send_mood(self, mood, message=None): + if self.connected == 1: + # We are connecting, keep mood in mem and send it when we'll be + # conencted + self.to_be_sent_mood = (mood, message) + return if not self.pep_supported: return item = xmpp.Node('mood', {'xmlns': xmpp.NS_MOOD}) @@ -569,6 +603,11 @@ class ConnectionPEP(object): def send_tune(self, artist='', title='', source='', track=0, length=0, items=None): + if self.connected == 1: + # We are connecting, keep tune in mem and send it when we'll be + # conencted + self.to_be_sent_tune = (artist, title, source, track, length, items) + return if not self.pep_supported: return item = xmpp.Node('tune', {'xmlns': xmpp.NS_TUNE}) @@ -599,6 +638,11 @@ class ConnectionPEP(object): self._pubsub_connection.send_pb_retract('', xmpp.NS_TUNE, '0') def send_nickname(self, nick): + if self.connected == 1: + # We are connecting, keep nick in mem and send it when we'll be + # conencted + self.to_be_sent_nick = nick + return if not self.pep_supported: return item = xmpp.Node('nick', {'xmlns': xmpp.NS_NICK}) @@ -613,6 +657,11 @@ class ConnectionPEP(object): self._pubsub_connection.send_pb_retract('', xmpp.NS_NICK, '0') def send_location(self, info): + if self.connected == 1: + # We are connecting, keep location in mem and send it when we'll be + # conencted + self.to_be_sent_location = info + return if not self.pep_supported: return item = xmpp.Node('geoloc', {'xmlns': xmpp.NS_LOCATION}) |