Changeset 8711 for branches/gajim_0.11.1

Show
Ignore:
Timestamp:
09/04/07 21:01:00 (15 months ago)
Author:
asterix
Message:

request vcard, last_status_time and os_info to real jid if we know it. fixes #3304

Location:
branches/gajim_0.11.1/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/gajim_0.11.1/src/common/connection_handlers.py

    r8709 r8711  
    797797                self.vcard_shas = {} # sha of contacts 
    798798                self.room_jids = [] # list of gc jids so that vcard are saved in a folder 
    799                 self.groupchat_jids = {} # {ID : groupchat_jid} 
    800                  
     799 
    801800        def add_sha(self, p, send_caps = True): 
    802801                c = p.setTag('x', namespace = common.xmpp.NS_VCARD_UPDATE) 
     
    13001299                except: 
    13011300                        return 
    1302                 who = helpers.get_full_jid_from_iq(iq_obj) 
     1301                id = iq_obj.getID() 
     1302                if id in self.groupchat_jids: 
     1303                        who = self.groupchat_jids[id] 
     1304                        del self.groupchat_jids[id] 
     1305                else: 
     1306                        who = helpers.get_full_jid_from_iq(iq_obj) 
    13031307                jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who) 
    13041308                self.dispatch('LAST_STATUS_TIME', (jid_stripped, resource, seconds, status)) 
     
    13151319                if qp.getTag('os'): 
    13161320                        os_info += qp.getTag('os').getData() 
    1317                 who = helpers.get_full_jid_from_iq(iq_obj) 
     1321                id = iq_obj.getID() 
     1322                if id in self.groupchat_jids: 
     1323                        who = self.groupchat_jids[id] 
     1324                        del self.groupchat_jids[id] 
     1325                else: 
     1326                        who = helpers.get_full_jid_from_iq(iq_obj) 
    13181327                jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who) 
    13191328                self.dispatch('OS_INFO', (jid_stripped, resource, client_info, os_info)) 
  • branches/gajim_0.11.1/src/common/connection.py

    r8683 r8711  
    8080                # Do we continue connection when we get roster (send presence,get vcard...) 
    8181                self.continue_connect_info = None 
     82                # To know the groupchat jid associated with a sranza ID. Useful to 
     83                # request vcard or os info... to a real JID but act as if it comes from 
     84                # the fake jid 
     85                self.groupchat_jids = {} # {ID : groupchat_jid} 
    8286                if USE_GPG: 
    8387                        self.gpg = GnuPG.GnuPG(gajim.config.get('use_gpg_agent')) 
     
    905909                self.name = new_name 
    906910 
    907         def request_last_status_time(self, jid, resource): 
     911        def request_last_status_time(self, jid, resource, groupchat_jid=None): 
     912                '''groupchat_jid is used when we want to send a request to a real jid 
     913                and act as if the answer comes from the groupchat_jid''' 
    908914                if not self.connection: 
    909915                        return 
     
    913919                iq = common.xmpp.Iq(to = to_whom_jid, typ = 'get', queryNS =\ 
    914920                        common.xmpp.NS_LAST) 
    915                 self.connection.send(iq) 
    916  
    917         def request_os_info(self, jid, resource): 
     921                id = self.connection.getAnID() 
     922                iq.setID(id) 
     923                if groupchat_jid: 
     924                        self.groupchat_jids[id] = groupchat_jid 
     925                self.connection.send(iq) 
     926 
     927        def request_os_info(self, jid, resource, groupchat_jid=None): 
     928                '''groupchat_jid is used when we want to send a request to a real jid 
     929                and act as if the answer comes from the groupchat_jid''' 
    918930                if not self.connection: 
    919931                        return 
     
    927939                iq = common.xmpp.Iq(to = to_whom_jid, typ = 'get', queryNS =\ 
    928940                        common.xmpp.NS_VERSION) 
     941                id = self.connection.getAnID() 
     942                iq.setID(id) 
     943                if groupchat_jid: 
     944                        self.groupchat_jids[id] = groupchat_jid 
    929945                self.connection.send(iq) 
    930946 
  • branches/gajim_0.11.1/src/vcard.py

    r8709 r8711  
    6767                self.account = account 
    6868                self.gc_contact = gc_contact 
     69 
     70                # Get real jid 
     71                if gc_contact: 
     72                        if gc_contact.jid: 
     73                                self.real_jid = gc_contact.jid 
     74                                if gc_contact.resource: 
     75                                        self.real_jid += '/' + gc_contact.resource 
     76                        else: 
     77                                self.real_jid = gc_contact.get_full_jid() 
     78                else: 
     79                        self.real_jid = contact.get_full_jid() 
    6980 
    7081                self.avatar_mime_type = None 
     
    321332 
    322333                # Request list time status 
    323                 gajim.connections[self.account].request_last_status_time(self.contact.jid, 
    324                         self.contact.resource) 
     334                if self.gc_contact: 
     335                        j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) 
     336                        gajim.connections[self.account].request_last_status_time(j, r, 
     337                                self.contact.jid) 
     338                else: 
     339                        gajim.connections[self.account].request_last_status_time( 
     340                                self.contact.jid, self.contact.resource) 
    325341 
    326342                # do not wait for os_info if contact is not connected or has error 
     
    330346                        self.os_info_arrived = True 
    331347                else: # Request os info if contact is connected 
    332                         gobject.idle_add(gajim.connections[self.account].request_os_info, 
    333                                 self.contact.jid, self.contact.resource) 
     348                        if self.gc_contact: 
     349                                j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) 
     350                                gobject.idle_add(gajim.connections[self.account].request_os_info, 
     351                                        j, r, self.contact.jid) 
     352                        else: 
     353                                gobject.idle_add(gajim.connections[self.account].request_os_info, 
     354                                        self.contact.jid, self.contact.resource) 
    334355                self.os_info = {0: {'resource': self.contact.resource, 'client': '', 
    335356                        'os': ''}} 
     
    360381 
    361382                if self.gc_contact: 
    362                         gajim.connections[self.account].request_vcard(self.contact.jid, 
     383                        gajim.connections[self.account].request_vcard(self.real_jid, 
    363384                                self.gc_contact.get_full_jid()) 
    364385                else: