Author: asterix Date: 2007-05-12 22:30:26 +0200 (Sat, 12 May 2007) New Revision: 8143
Modified: trunk/src/common/connection_handlers.py trunk/src/common/contacts.py trunk/src/gajim.py Log: show transport nickname if there is one and user hasn't set a nickname. fixes #3094
Modified: trunk/src/common/connection_handlers.py =================================================================== --- trunk/src/common/connection_handlers.py 2007-05-09 20:59:29 UTC (rev 8142) +++ trunk/src/common/connection_handlers.py 2007-05-12 20:30:26 UTC (rev 8143) @@ -1569,6 +1569,7 @@ user_nick = prs.getTagData('nick') if not user_nick: user_nick = '' + contact_nickname = None transport_auto_auth = False xtags = prs.getTags('x') for x in xtags: @@ -1581,6 +1582,7 @@ sigTag = x elif namespace == common.xmpp.NS_VCARD_UPDATE: avatar_sha = x.getTagData('photo') + contact_nickname = x.getTagData('nickname') elif namespace == common.xmpp.NS_DELAY: # JEP-0091 tim = prs.getTimestamp() @@ -1620,7 +1622,7 @@ errcode = prs.getErrorCode() if errcode == '502': # Internal Timeout: self.dispatch('NOTIFY', (jid_stripped, 'error', errmsg, resource, - prio, keyID, timestamp)) + prio, keyID, timestamp, None)) elif errcode == '401': # password required to join self.dispatch('ERROR', (_('Unable to join group chat'), _('A password is required to join this group chat.'))) @@ -1716,7 +1718,7 @@ self.connection.send(p) if who.find("@") <= 0 or transport_auto_auth: self.dispatch('NOTIFY', (jid_stripped, 'offline', 'offline', - resource, prio, keyID, timestamp)) + resource, prio, keyID, timestamp, None)) if transport_auto_auth: self.automatically_added.append(jid_stripped) self.request_subscription(jid_stripped, name = user_nick) @@ -1767,7 +1769,7 @@ errcode = prs.getErrorCode() if errcode == '502': # Internal Timeout: self.dispatch('NOTIFY', (jid_stripped, 'error', errmsg, resource, - prio, keyID, timestamp)) + prio, keyID, timestamp, None)) else: # print in the window the error self.dispatch('ERROR_ANSWER', ('', jid_stripped, errmsg, errcode)) @@ -1788,7 +1790,7 @@ not in no_log_for and jid_stripped not in no_log_for: gajim.logger.write('status', jid_stripped, status, show) self.dispatch('NOTIFY', (jid_stripped, show, status, resource, prio, - keyID, timestamp)) + keyID, timestamp, contact_nickname)) # END presenceCB
def _StanzaArrivedCB(self, con, obj):
Modified: trunk/src/common/contacts.py =================================================================== --- trunk/src/common/contacts.py 2007-05-09 20:59:29 UTC (rev 8142) +++ trunk/src/common/contacts.py 2007-05-12 20:30:26 UTC (rev 8143) @@ -23,6 +23,7 @@ chatstate=None, last_status_time=None, msg_id = None, composing_jep = None): self.jid = jid self.name = name + self.contact_name = '' # nick choosen by contact self.groups = groups self.show = show self.status = status @@ -57,6 +58,8 @@ def get_shown_name(self): if self.name: return self.name + if self.contact_name: + return self.contact_name return self.jid.split('@')[0]
def is_hidden_from_roster(self):
Modified: trunk/src/gajim.py =================================================================== --- trunk/src/gajim.py 2007-05-09 20:59:29 UTC (rev 8142) +++ trunk/src/gajim.py 2007-05-12 20:30:26 UTC (rev 8143) @@ -505,7 +505,7 @@
def handle_event_notify(self, account, array): # 'NOTIFY' (account, (jid, status, status message, resource, priority, - # keyID, timestamp)) + # keyID, timestamp, contact_nickname)) # if we're here it means contact changed show statuss = ['offline', 'error', 'online', 'chat', 'away', 'xa', 'dnd', 'invisible'] @@ -517,6 +517,7 @@ status_message = array[2] jid = array[0].split('/')[0] keyID = array[5] + contact_nickname = array[7] attached_keys = gajim.config.get_per('accounts', account, 'attached_gpg_keys').split() if jid in attached_keys: @@ -545,6 +546,10 @@ if contact1: if contact1.show in statuss: old_show = statuss.index(contact1.show) + if contact_nickname is not None and \ + contact1.contact_name != contact_nickname: + contact1.contact_name = contact_nickname + self.roster.draw_contact(jid, account) if old_show == new_show and contact1.status == status_message and \ contact1.priority == priority: # no change return @@ -599,6 +604,7 @@ elif not gajim.block_signed_in_notifications[account]: # We're connected since more that 30 seconds contact1.last_status_time = time.localtime() + contact1.contact_nickname = contact_nickname if gajim.jid_is_transport(jid): # It must be an agent if ji in jid_list: