Author: bct Date: 2007-08-18 10:59:36 +0200 (Sat, 18 Aug 2007) New Revision: 8503
Modified: branches/e2e_encryption/src/common/connection_handlers.py branches/e2e_encryption/src/common/stanza_session.py Log: bugfixes, send not-acceptable for fields with only unsupported options
Modified: branches/e2e_encryption/src/common/connection_handlers.py =================================================================== --- branches/e2e_encryption/src/common/connection_handlers.py 2007-08-17 17:26:05 UTC (rev 8502) +++ branches/e2e_encryption/src/common/connection_handlers.py 2007-08-18 08:59:36 UTC (rev 8503) @@ -1584,6 +1584,9 @@ if bare_jid != jid: session = self.find_session(bare_jid, thread_id, type) if session: + if not session.received_thread_id: + thread_id = session.thread_id + self.move_session(bare_jid, thread_id, jid.split("/")[1]) return session
Modified: branches/e2e_encryption/src/common/stanza_session.py =================================================================== --- branches/e2e_encryption/src/common/stanza_session.py 2007-08-17 17:26:05 UTC (rev 8502) +++ branches/e2e_encryption/src/common/stanza_session.py 2007-08-18 08:59:36 UTC (rev 8503) @@ -48,8 +48,8 @@ return "".join([random.choice(string.letters) for x in xrange(0,32)])
def send(self, msg): - if self.thread_id and isinstance(msg, xmpp.Message): - msg.setThread(self.thread_id) + if self.thread_id: + msg.NT.thread = self.thread_id
msg.setAttr('to', self.jid) self.conn.send_stanza(msg) @@ -530,10 +530,10 @@ elif name == 'logging': my_prefs = self.logging_preference()
- if my_prefs[0] in options: + if my_prefs[0] in options: # our first choice is offered, select it pref = my_prefs[0] negotiated['logging'] = pref - else: + else: # see if other acceptable choices are offered for pref in my_prefs: if pref in options: ask_user['logging'] = pref @@ -572,7 +572,9 @@ x.addChild(node=xmpp.DataField(name='accept', value='true'))
for name in negotiated: - x.addChild(node=xmpp.DataField(name=name, value=negotiated[name])) + # some fields are internal and should not be sent + if not name in ('send_pubkey', 'recv_pubkey'): + x.addChild(node=xmpp.DataField(name=name, value=negotiated[name]))
self.negotiated = negotiated
@@ -616,15 +618,17 @@ feature.addChild(node=x) if not_acceptable: - pass -# XXX -# <error code='406' type='modify'> -# <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> -# <feature xmlns='http://jabber.org/protocol/feature-neg'> -# <field var='security'/> -# </feature> -# </error> + response = xmpp.Error(response, xmpp.ERR_NOT_ACCEPTABLE)
+ feature = xmpp.Node(xmpp.NS_FEATURE + ' feature') + + for f in not_acceptable: + n = xmpp.Node('field') + n['var'] = f + feature.addChild(node=n) + + response.T.error.addChild(node=feature) + self.send(response)
# 'Alice Accepts'