pop up a (useless) DataFormWidget when someone initiates a session negotiation

This commit is contained in:
Brendan Taylor 2007-06-01 17:09:56 +00:00
parent 00209abaf9
commit 46bc373cc3
2 changed files with 29 additions and 0 deletions

View File

@ -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()

View File

@ -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