Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/connection.py9
-rw-r--r--src/common/connection_handlers.py1
-rw-r--r--src/common/pep.py49
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})