diff --git a/src/common/connection.py b/src/common/connection.py index 8d18b50cd..6803ba037 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -90,16 +90,6 @@ class Connection(ConnectionHandlers): self.vcard_supported = True # END __init__ - def build_user_nick(self, user_nick): - df = common.xmpp.DataForm(typ = 'result') - field = df.setField('FORM_TYPE') - field.setType('hidden') - field.setValue(common.xmpp.NS_PROFILE) - field = df.setField('nickname') - field.delAttr('type') - field.setValue(user_nick) - return df - def put_event(self, ev): if gajim.handlers.has_key(ev[0]): gajim.handlers[ev[0]](self.name, ev[1]) @@ -716,8 +706,8 @@ class Connection(ConnectionHandlers): # JEP-0172: user_nickname if user_nick: - df = self.build_user_nick(user_nick) - msg_iq.addChild(node = df) + msg_iq.setTag('nick', namespace = common.xmpp.NS_NICK).setData( + user_nick) # chatstates - if peer supports jep85 or jep22, send chatstates # please note that the only valid tag inside a message containing a @@ -792,8 +782,8 @@ class Connection(ConnectionHandlers): p = common.xmpp.Presence(jid, 'subscribe') if user_nick: - df = self.build_user_nick(user_nick) - p.addChild(node = df) + msg_iq.setTag('nick', namespace = common.xmpp.NS_NICK).setData( + user_nick) p = self.add_sha(p) if msg: p.setStatus(msg) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 16e30b097..c877d0d76 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1353,15 +1353,9 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco) if not msgtxt and chatstate_child.getTag('composing'): chatstate = 'composing' # JEP-0172 User Nickname - user_nick = '' - xtags = msg.getTags('x', attrs = {'type': 'result'}, - namespace = common.xmpp.NS_DATA) - for xtag in xtags: - df = common.xmpp.DataForm(node = xtag) - field = df.getField('FORM_TYPE') - if not field or field.getValue() != common.xmpp.NS_PROFILE: - continue - user_nick = df.getField('nickname').getValue() + user_nick = msg.getTagData('nick') + if not user_nick: + user_nick = '' if encTag and GnuPG.USE_GPG: #decrypt @@ -1443,7 +1437,10 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco) is_gc = False # is it a GC presence ? sigTag = None avatar_sha = None - user_nick = '' # for JEP-0172 + # JEP-0172 User Nickname + user_nick = prs.getTagData('nick') + if not user_nick: + user_nick = '' transport_auto_auth = False xtags = prs.getTags('x') for x in xtags: @@ -1464,15 +1461,6 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco) agent = gajim.get_server_from_jid(jid_stripped) if self.connection.getRoster().getItem(agent): # to be sure it's a transport contact transport_auto_auth = True - if namespace == common.xmpp.NS_DATA: - # JEP-0172 - df = common.xmpp.DataForm(node = x) - if df.getType() != 'result': - continue - field = df.getField('FORM_TYPE') - if not field or field.getValue() != common.xmpp.NS_PROFILE: - continue - user_nick = df.getField('nickname').getValue() no_log_for = gajim.config.get_per('accounts', self.name, 'no_log_for').split() diff --git a/src/common/xmpp/protocol.py b/src/common/xmpp/protocol.py index c1e57ebb3..1add2a8e4 100644 --- a/src/common/xmpp/protocol.py +++ b/src/common/xmpp/protocol.py @@ -62,6 +62,7 @@ NS_MUC ='http://jabber.org/protocol/muc' NS_MUC_USER =NS_MUC+'#user' NS_MUC_ADMIN =NS_MUC+'#admin' NS_MUC_OWNER =NS_MUC+'#owner' +NS_NICK ='http://jabber.org/protocol/nick' # JEP-0172 NS_OFFLINE ='http://www.jabber.org/jeps/jep-0030.html' # JEP-0013 NS_PHYSLOC ='http://jabber.org/protocol/physloc' # JEP-0112 NS_PRESENCE ='presence' # Jabberd2