From 39a960f3e71530e819ff38a70abe39965f9eca89 Mon Sep 17 00:00:00 2001 From: Jefry Lagrange Date: Tue, 7 Jun 2011 23:50:45 -0400 Subject: [PATCH] keeps old status after disconnection --- src/common/connection.py | 11 ++++++++++- src/common/xmpp/dispatcher_nb.py | 7 ++++--- src/common/xmpp/smacks.py | 3 ++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index bbb2cb974..46daadfa0 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -784,7 +784,16 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.disconnect() self.last_connection = None self.connection = None - + def set_oldst(self): # Set old state + if self.old_show: + self.connected = gajim.SHOW_LIST.index(self.old_show) + gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + show=self.connected)) + else: # we default to online + self.connected = 2 + gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + show=gajim.SHOW_LIST[self.connected])) + def _disconnectedReconnCB(self): """ Called when we are disconnected diff --git a/src/common/xmpp/dispatcher_nb.py b/src/common/xmpp/dispatcher_nb.py index ca321e878..0f84c196a 100644 --- a/src/common/xmpp/dispatcher_nb.py +++ b/src/common/xmpp/dispatcher_nb.py @@ -421,9 +421,10 @@ class XMPPDispatcher(PlugIn): stanza.props = stanza.getProperties() ID = stanza.getID() # If server supports stream management - if self.sm != None and (stanza.getName() != 'r' and - stanza.getName() != 'a' and - stanza.getName() != 'enabled') : + if self.sm and self.sm.enabled and (stanza.getName() != 'r' or + stanza.getName() != 'a' or + stanza.getName() != 'enabled' or + stanza.getName() != 'resumed'): # increments the number of stanzas that has been handled self.sm.in_h = self.sm.in_h + 1 list_ = ['default'] # we will use all handlers: diff --git a/src/common/xmpp/smacks.py b/src/common/xmpp/smacks.py index c0fa77c0e..b1b6dac03 100644 --- a/src/common/xmpp/smacks.py +++ b/src/common/xmpp/smacks.py @@ -72,7 +72,7 @@ class Smacks(): log.error('Attempted to resume without a valid session id ') return resume = Acks() - resume.buildResume(self.in_h, None)#self.session_id) + resume.buildResume(self.in_h, self.session_id) self._owner.Connection.send(resume, True) def send_ack(self, disp, stanza): @@ -104,6 +104,7 @@ class Smacks(): if stanza.getName() == 'resumed': self.resuming = True + self.con.set_oldst() if self.uqueue != []: for i in self.uqueue: self._owner.Connection.send(i, False)