request last_status_time and os_info to real jid if we know it. fixes #3304
This commit is contained in:
parent
56afa7012f
commit
c131a04df8
|
@ -133,6 +133,10 @@ class Connection(ConnectionHandlers):
|
||||||
self.pep_supported = False
|
self.pep_supported = False
|
||||||
# Do we continue connection when we get roster (send presence,get vcard...)
|
# Do we continue connection when we get roster (send presence,get vcard...)
|
||||||
self.continue_connect_info = None
|
self.continue_connect_info = None
|
||||||
|
# To know the groupchat jid associated with a sranza ID. Useful to
|
||||||
|
# request vcard or os info... to a real JID but act as if it comes from
|
||||||
|
# the fake jid
|
||||||
|
self.groupchat_jids = {} # {ID : groupchat_jid}
|
||||||
if USE_GPG:
|
if USE_GPG:
|
||||||
self.gpg = GnuPG.GnuPG(gajim.config.get('use_gpg_agent'))
|
self.gpg = GnuPG.GnuPG(gajim.config.get('use_gpg_agent'))
|
||||||
gajim.config.set('usegpg', True)
|
gajim.config.set('usegpg', True)
|
||||||
|
@ -1058,7 +1062,9 @@ class Connection(ConnectionHandlers):
|
||||||
def account_changed(self, new_name):
|
def account_changed(self, new_name):
|
||||||
self.name = new_name
|
self.name = new_name
|
||||||
|
|
||||||
def request_last_status_time(self, jid, resource):
|
def request_last_status_time(self, jid, resource, groupchat_jid=None):
|
||||||
|
'''groupchat_jid is used when we want to send a request to a real jid
|
||||||
|
and act as if the answer comes from the groupchat_jid'''
|
||||||
if not self.connection:
|
if not self.connection:
|
||||||
return
|
return
|
||||||
to_whom_jid = jid
|
to_whom_jid = jid
|
||||||
|
@ -1066,9 +1072,15 @@ class Connection(ConnectionHandlers):
|
||||||
to_whom_jid += '/' + resource
|
to_whom_jid += '/' + resource
|
||||||
iq = common.xmpp.Iq(to = to_whom_jid, typ = 'get', queryNS =\
|
iq = common.xmpp.Iq(to = to_whom_jid, typ = 'get', queryNS =\
|
||||||
common.xmpp.NS_LAST)
|
common.xmpp.NS_LAST)
|
||||||
|
id = self.connection.getAnID()
|
||||||
|
iq.setID(id)
|
||||||
|
if groupchat_jid:
|
||||||
|
self.groupchat_jids[id] = groupchat_jid
|
||||||
self.connection.send(iq)
|
self.connection.send(iq)
|
||||||
|
|
||||||
def request_os_info(self, jid, resource):
|
def request_os_info(self, jid, resource, groupchat_jid=None):
|
||||||
|
'''groupchat_jid is used when we want to send a request to a real jid
|
||||||
|
and act as if the answer comes from the groupchat_jid'''
|
||||||
if not self.connection:
|
if not self.connection:
|
||||||
return
|
return
|
||||||
# If we are invisible, do not request
|
# If we are invisible, do not request
|
||||||
|
@ -1080,6 +1092,10 @@ class Connection(ConnectionHandlers):
|
||||||
to_whom_jid += '/' + resource
|
to_whom_jid += '/' + resource
|
||||||
iq = common.xmpp.Iq(to = to_whom_jid, typ = 'get', queryNS =\
|
iq = common.xmpp.Iq(to = to_whom_jid, typ = 'get', queryNS =\
|
||||||
common.xmpp.NS_VERSION)
|
common.xmpp.NS_VERSION)
|
||||||
|
id = self.connection.getAnID()
|
||||||
|
iq.setID(id)
|
||||||
|
if groupchat_jid:
|
||||||
|
self.groupchat_jids[id] = groupchat_jid
|
||||||
self.connection.send(iq)
|
self.connection.send(iq)
|
||||||
|
|
||||||
def get_settings(self):
|
def get_settings(self):
|
||||||
|
|
|
@ -828,8 +828,7 @@ class ConnectionVcard:
|
||||||
self.vcard_sha = None
|
self.vcard_sha = None
|
||||||
self.vcard_shas = {} # sha of contacts
|
self.vcard_shas = {} # sha of contacts
|
||||||
self.room_jids = [] # list of gc jids so that vcard are saved in a folder
|
self.room_jids = [] # list of gc jids so that vcard are saved in a folder
|
||||||
self.groupchat_jids = {} # {ID : groupchat_jid}
|
|
||||||
|
|
||||||
def add_sha(self, p, send_caps = True):
|
def add_sha(self, p, send_caps = True):
|
||||||
c = p.setTag('x', namespace = common.xmpp.NS_VCARD_UPDATE)
|
c = p.setTag('x', namespace = common.xmpp.NS_VCARD_UPDATE)
|
||||||
if self.vcard_sha is not None:
|
if self.vcard_sha is not None:
|
||||||
|
@ -1337,7 +1336,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
seconds = int(seconds)
|
seconds = int(seconds)
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
who = helpers.get_full_jid_from_iq(iq_obj)
|
id = iq_obj.getID()
|
||||||
|
if id in self.groupchat_jids:
|
||||||
|
who = self.groupchat_jids[id]
|
||||||
|
del self.groupchat_jids[id]
|
||||||
|
else:
|
||||||
|
who = helpers.get_full_jid_from_iq(iq_obj)
|
||||||
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
|
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
|
||||||
self.dispatch('LAST_STATUS_TIME', (jid_stripped, resource, seconds, status))
|
self.dispatch('LAST_STATUS_TIME', (jid_stripped, resource, seconds, status))
|
||||||
|
|
||||||
|
@ -1352,7 +1356,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
client_info += ' ' + qp.getTag('version').getData()
|
client_info += ' ' + qp.getTag('version').getData()
|
||||||
if qp.getTag('os'):
|
if qp.getTag('os'):
|
||||||
os_info += qp.getTag('os').getData()
|
os_info += qp.getTag('os').getData()
|
||||||
who = helpers.get_full_jid_from_iq(iq_obj)
|
id = iq_obj.getID()
|
||||||
|
if id in self.groupchat_jids:
|
||||||
|
who = self.groupchat_jids[id]
|
||||||
|
del self.groupchat_jids[id]
|
||||||
|
else:
|
||||||
|
who = helpers.get_full_jid_from_iq(iq_obj)
|
||||||
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
|
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
|
||||||
self.dispatch('OS_INFO', (jid_stripped, resource, client_info, os_info))
|
self.dispatch('OS_INFO', (jid_stripped, resource, client_info, os_info))
|
||||||
|
|
||||||
|
|
18
src/vcard.py
18
src/vcard.py
|
@ -329,8 +329,13 @@ class VcardWindow:
|
||||||
self.contact.status = ''
|
self.contact.status = ''
|
||||||
|
|
||||||
# Request list time status
|
# Request list time status
|
||||||
gajim.connections[self.account].request_last_status_time(self.contact.jid,
|
if self.gc_contact:
|
||||||
self.contact.resource)
|
j, r = gajim.get_room_and_nick_from_fjid(self.real_jid)
|
||||||
|
gajim.connections[self.account].request_last_status_time(j, r,
|
||||||
|
self.contact.jid)
|
||||||
|
else:
|
||||||
|
gajim.connections[self.account].request_last_status_time(
|
||||||
|
self.contact.jid, self.contact.resource)
|
||||||
|
|
||||||
# do not wait for os_info if contact is not connected or has error
|
# do not wait for os_info if contact is not connected or has error
|
||||||
# additional check for observer is needed, as show is offline for him
|
# additional check for observer is needed, as show is offline for him
|
||||||
|
@ -338,8 +343,13 @@ class VcardWindow:
|
||||||
and not self.contact.is_observer():
|
and not self.contact.is_observer():
|
||||||
self.os_info_arrived = True
|
self.os_info_arrived = True
|
||||||
else: # Request os info if contact is connected
|
else: # Request os info if contact is connected
|
||||||
gobject.idle_add(gajim.connections[self.account].request_os_info,
|
if self.gc_contact:
|
||||||
self.contact.jid, self.contact.resource)
|
j, r = gajim.get_room_and_nick_from_fjid(self.real_jid)
|
||||||
|
gobject.idle_add(gajim.connections[self.account].request_os_info,
|
||||||
|
j, r, self.contact.jid)
|
||||||
|
else:
|
||||||
|
gobject.idle_add(gajim.connections[self.account].request_os_info,
|
||||||
|
self.contact.jid, self.contact.resource)
|
||||||
self.os_info = {0: {'resource': self.contact.resource, 'client': '',
|
self.os_info = {0: {'resource': self.contact.resource, 'client': '',
|
||||||
'os': ''}}
|
'os': ''}}
|
||||||
i = 1
|
i = 1
|
||||||
|
|
Loading…
Reference in New Issue