detect jabber:iq:last and jabber:iq:version errors by IDs. fixes #3711
This commit is contained in:
parent
e409a04789
commit
e8b7778521
|
@ -1257,6 +1257,7 @@ class Connection(ConnectionHandlers):
|
|||
iq.setID(id)
|
||||
if groupchat_jid:
|
||||
self.groupchat_jids[id] = groupchat_jid
|
||||
self.last_ids.append(id)
|
||||
self.connection.send(iq)
|
||||
|
||||
def request_os_info(self, jid, resource, groupchat_jid=None):
|
||||
|
@ -1277,6 +1278,7 @@ class Connection(ConnectionHandlers):
|
|||
iq.setID(id)
|
||||
if groupchat_jid:
|
||||
self.groupchat_jids[id] = groupchat_jid
|
||||
self.version_ids.append(id)
|
||||
self.connection.send(iq)
|
||||
|
||||
def get_settings(self):
|
||||
|
|
|
@ -1239,6 +1239,10 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
# keep the latest subscribed event for each jid to prevent loop when we
|
||||
# acknoledge presences
|
||||
self.subscribed_events = {}
|
||||
# IDs of jabber:iq:last requests
|
||||
self.last_ids = []
|
||||
# IDs of jabber:iq:version requests
|
||||
self.version_ids = []
|
||||
|
||||
# keep track of sessions this connection has with other JIDs
|
||||
self.sessions = {}
|
||||
|
@ -1297,15 +1301,19 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
|
||||
def _ErrorCB(self, con, iq_obj):
|
||||
gajim.log.debug('ErrorCB')
|
||||
if iq_obj.getQueryNS() == common.xmpp.NS_VERSION:
|
||||
who = helpers.get_full_jid_from_iq(iq_obj)
|
||||
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
|
||||
jid_from = helpers.get_full_jid_from_iq(iq_obj)
|
||||
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(jid_from)
|
||||
id = unicode(iq_obj.getID())
|
||||
if id in self.version_ids:
|
||||
self.dispatch('OS_INFO', (jid_stripped, resource, '', ''))
|
||||
self.version_ids.remove(id)
|
||||
return
|
||||
if id in self.last_ids:
|
||||
self.dispatch('LAST_STATUS_TIME', (jid_stripped, resource, -1, ''))
|
||||
self.last_ids.remove(id)
|
||||
return
|
||||
errmsg = iq_obj.getErrorMsg()
|
||||
errcode = iq_obj.getErrorCode()
|
||||
jid_from = helpers.get_full_jid_from_iq(iq_obj)
|
||||
id = unicode(iq_obj.getID())
|
||||
self.dispatch('ERROR_ANSWER', (id, jid_from, errmsg, errcode))
|
||||
|
||||
def _PrivateCB(self, con, iq_obj):
|
||||
|
@ -1420,6 +1428,8 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
del self.groupchat_jids[id]
|
||||
else:
|
||||
who = helpers.get_full_jid_from_iq(iq_obj)
|
||||
if id in self.last_ids:
|
||||
self.last_ids.remove(id)
|
||||
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
|
||||
self.dispatch('LAST_STATUS_TIME', (jid_stripped, resource, seconds, status))
|
||||
|
||||
|
@ -1441,6 +1451,8 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
else:
|
||||
who = helpers.get_full_jid_from_iq(iq_obj)
|
||||
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
|
||||
if id in self.version_ids:
|
||||
self.version_ids.remove(id)
|
||||
self.dispatch('OS_INFO', (jid_stripped, resource, client_info, os_info))
|
||||
|
||||
def _TimeCB(self, con, iq_obj):
|
||||
|
|
|
@ -1124,6 +1124,10 @@ class Interface:
|
|||
|
||||
def handle_event_last_status_time(self, account, array):
|
||||
# ('LAST_STATUS_TIME', account, (jid, resource, seconds, status))
|
||||
tim = array[2]
|
||||
if tim < 0:
|
||||
# Ann error occured
|
||||
return
|
||||
win = None
|
||||
if self.instances[account]['infos'].has_key(array[0]):
|
||||
win = self.instances[account]['infos'][array[0]]
|
||||
|
@ -1132,7 +1136,7 @@ class Interface:
|
|||
if win:
|
||||
c = gajim.contacts.get_contact(account, array[0], array[1])
|
||||
if c: # c can be none if it's a gc contact
|
||||
c.last_status_time = time.localtime(time.time() - array[2])
|
||||
c.last_status_time = time.localtime(time.time() - tim)
|
||||
if array[3]:
|
||||
c.status = array[3]
|
||||
win.set_last_status_time()
|
||||
|
|
Loading…
Reference in New Issue