From 46bc373cc3c921064600d49090c1b985a5262c87 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Fri, 1 Jun 2007 17:09:56 +0000 Subject: [PATCH] pop up a (useless) DataFormWidget when someone initiates a session negotiation --- src/common/connection_handlers.py | 21 +++++++++++++++++++++ src/gajim.py | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 98e7f892a..fa392b71b 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1197,6 +1197,22 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, self.dispatch('HTTP_AUTH', (method, url, id, iq_obj, msg)); raise common.xmpp.NodeProcessed + def _FeatureNegCB(self, con, stanza): + gajim.log.debug('FeatureNegCB') + feature = stanza.getTag('feature') + form = common.xmpp.DataForm(node=feature.getTag('x')) + + if form['FORM_TYPE'] == 'urn:xmpp:ssn': + self.dispatch('SESSION_NEG', (stanza.getFrom(), stanza.getThread(), form)) + else: + reply = stanza.buildReply() + reply.setType('error') + + reply.addChild(feature) + reply.addChild(node=xmpp.ErrorNode('service-unavailable', typ='cancel')) + + con.send(reply) + def _ErrorCB(self, con, iq_obj): gajim.log.debug('ErrorCB') if iq_obj.getQueryNS() == common.xmpp.NS_VERSION: @@ -1403,6 +1419,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, common.xmpp.NS_HTTP_AUTH: self._HttpAuthCB(con, msg) return + if msg.getTag('feature') and msg.getTag('feature').namespace == \ + common.xmpp.NS_FEATURE: + self._FeatureNegCB(con, msg) + return + msgtxt = msg.getBody() msghtml = msg.getXHTML() mtype = msg.getType() diff --git a/src/gajim.py b/src/gajim.py index 738d98962..2607b6b86 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -103,6 +103,8 @@ import message_control from chat_control import ChatControlBase from atom_window import AtomWindow +import negotiation + from common import exceptions from common.zeroconf import connection_zeroconf from common import dbus_support @@ -1653,6 +1655,11 @@ class Interface: atom_entry, = data AtomWindow.newAtomEntry(atom_entry) + def handle_session_negotiation(self, account, data): + jid, thread_id, form = data + # XXX check negotiation state, etc. + negotiation.FeatureNegotiationWindow(account, jid, thread_id, form) + def handle_event_privacy_lists_received(self, account, data): # ('PRIVACY_LISTS_RECEIVED', account, list) if not self.instances.has_key(account): @@ -2090,6 +2097,7 @@ class Interface: 'SEARCH_FORM': self.handle_event_search_form, 'SEARCH_RESULT': self.handle_event_search_result, 'RESOURCE_CONFLICT': self.handle_event_resource_conflict, + 'SESSION_NEG': self.handle_session_negotiation, } gajim.handlers = self.handlers