From 1cd5b3da39b41cb11fe36f856bfcc216d42fc28d Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Wed, 28 Nov 2007 19:26:40 +0000 Subject: [PATCH] fixed use of common.xmpp namespace in a place it wasn't imported --- src/common/stanza_session.py | 23 +++++++++++++++++++---- src/gajim.py | 11 +---------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/common/stanza_session.py b/src/common/stanza_session.py index e27c9b529..9b5b5ea63 100644 --- a/src/common/stanza_session.py +++ b/src/common/stanza_session.py @@ -584,7 +584,7 @@ class EncryptedStanzaSession(StanzaSession): self.status = 'responded-e2e' feature.addChild(node=x) - + if not_acceptable: response = xmpp.Error(response, xmpp.ERR_NOT_ACCEPTABLE) @@ -853,14 +853,29 @@ class EncryptedStanzaSession(StanzaSession): def acknowledge_termination(self): StanzaSession.acknowledge_termination(self) - + self.enable_encryption = False - def fail_bad_negotiation(self, reason): - '''they've tried to feed us a bogus value, send an error and cancel everything.''' + def fail_bad_negotiation(self, reason, fields = None): + '''sends an error and cancels everything. + +if fields == None, the remote party has given us a bad cryptographic value of some kind + +otherwise, list the fields we haven't implemented''' err = xmpp.Error(xmpp.Message(), xmpp.ERR_FEATURE_NOT_IMPLEMENTED) err.T.error.T.text.setData(reason) + + if fields: + feature = xmpp.Node(xmpp.NS_FEATURE + ' feature') + + for field in fields: + fn = xmpp.Node('field') + fn['var'] = field + feature.addChild(node=feature) + + err.addChild(node=feature) + self.send(err) self.status = None diff --git a/src/gajim.py b/src/gajim.py index f124a872f..6ca85d454 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1898,16 +1898,7 @@ class Interface: # we don't support 3-message negotiation as the responder if 'dhkeys' in form.asDict(): - err = xmpp.Error(xmpp.Message(), xmpp.ERR_FEATURE_NOT_IMPLEMENTED) - - feature = xmpp.Node(xmpp.NS_FEATURE + ' feature') - field = xmpp.Node('field') - field['var'] = 'dhkeys' - - feature.addChild(node=field) - err.addChild(node=feature) - - session.send(err) + session.fail_bad_negotiation('3 message negotiation not supported when responding', ('dhkeys',)) return negotiated, not_acceptable, ask_user = session.verify_options_bob(form)