Author: asterix Date: 2007-09-04 21:01:00 +0200 (Tue, 04 Sep 2007) New Revision: 8711
Modified: branches/gajim_0.11.1/src/common/connection.py branches/gajim_0.11.1/src/common/connection_handlers.py branches/gajim_0.11.1/src/vcard.py Log: request vcard, last_status_time and os_info to real jid if we know it. fixes #3304
Modified: branches/gajim_0.11.1/src/common/connection.py =================================================================== --- branches/gajim_0.11.1/src/common/connection.py 2007-09-04 18:38:33 UTC (rev 8710) +++ branches/gajim_0.11.1/src/common/connection.py 2007-09-04 19:01:00 UTC (rev 8711) @@ -79,6 +79,10 @@ self.privacy_rules_supported = False # Do we continue connection when we get roster (send presence,get vcard...) 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: self.gpg = GnuPG.GnuPG(gajim.config.get('use_gpg_agent')) gajim.config.set('usegpg', True) @@ -904,7 +908,9 @@ def account_changed(self, 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: return to_whom_jid = jid @@ -912,9 +918,15 @@ to_whom_jid += '/' + resource iq = common.xmpp.Iq(to = to_whom_jid, typ = 'get', queryNS =\ common.xmpp.NS_LAST) + id = self.connection.getAnID() + iq.setID(id) + if groupchat_jid: + self.groupchat_jids[id] = groupchat_jid 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: return # If we are invisible, do not request @@ -926,6 +938,10 @@ to_whom_jid += '/' + resource iq = common.xmpp.Iq(to = to_whom_jid, typ = 'get', queryNS =\ common.xmpp.NS_VERSION) + id = self.connection.getAnID() + iq.setID(id) + if groupchat_jid: + self.groupchat_jids[id] = groupchat_jid self.connection.send(iq)
def get_settings(self):
Modified: branches/gajim_0.11.1/src/common/connection_handlers.py =================================================================== --- branches/gajim_0.11.1/src/common/connection_handlers.py 2007-09-04 18:38:33 UTC (rev 8710) +++ branches/gajim_0.11.1/src/common/connection_handlers.py 2007-09-04 19:01:00 UTC (rev 8711) @@ -796,8 +796,7 @@ self.vcard_sha = None self.vcard_shas = {} # sha of contacts 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): c = p.setTag('x', namespace = common.xmpp.NS_VCARD_UPDATE) if self.vcard_sha is not None: @@ -1299,7 +1298,12 @@ seconds = int(seconds) except: 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) self.dispatch('LAST_STATUS_TIME', (jid_stripped, resource, seconds, status)) @@ -1314,7 +1318,12 @@ client_info += ' ' + qp.getTag('version').getData() if qp.getTag('os'): 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) self.dispatch('OS_INFO', (jid_stripped, resource, client_info, os_info))
Modified: branches/gajim_0.11.1/src/vcard.py =================================================================== --- branches/gajim_0.11.1/src/vcard.py 2007-09-04 18:38:33 UTC (rev 8710) +++ branches/gajim_0.11.1/src/vcard.py 2007-09-04 19:01:00 UTC (rev 8711) @@ -67,6 +67,17 @@ self.account = account self.gc_contact = gc_contact
+ # Get real jid + if gc_contact: + if gc_contact.jid: + self.real_jid = gc_contact.jid + if gc_contact.resource: + self.real_jid += '/' + gc_contact.resource + else: + self.real_jid = gc_contact.get_full_jid() + else: + self.real_jid = contact.get_full_jid() + self.avatar_mime_type = None self.avatar_encoded = None self.vcard_arrived = False @@ -320,8 +331,13 @@ self.contact.status = ''
# Request list time status - gajim.connections[self.account].request_last_status_time(self.contact.jid, - self.contact.resource) + if self.gc_contact: + 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 # additional check for observer is needed, as show is offline for him @@ -329,8 +345,13 @@ and not self.contact.is_observer(): self.os_info_arrived = True else: # Request os info if contact is connected - gobject.idle_add(gajim.connections[self.account].request_os_info, - self.contact.jid, self.contact.resource) + if self.gc_contact: + 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': '', 'os': ''}} i = 1 @@ -359,7 +380,7 @@ self.fill_status_label()
if self.gc_contact: - gajim.connections[self.account].request_vcard(self.contact.jid, + gajim.connections[self.account].request_vcard(self.real_jid, self.gc_contact.get_full_jid()) else: gajim.connections[self.account].request_vcard(self.contact.jid)