gajim-plural/src/negotiation.py

62 lines
1.7 KiB
Python
Raw Normal View History

2007-06-01 19:12:49 +02:00
import gtkgui_helpers
import dataforms_widget
from common import dataforms
2007-06-01 20:19:19 +02:00
from common import gajim
from common import xmpp
2007-06-01 19:12:49 +02:00
class FeatureNegotiationWindow:
'''FeatureNegotiotionWindow class'''
def __init__(self, account, jid, session, form):
2007-06-01 19:12:49 +02:00
self.account = account
self.jid = jid
self.form = form
self.session = session
2007-06-01 19:12:49 +02:00
self.xml = gtkgui_helpers.get_glade('data_form_window.glade', 'data_form_window')
self.window = self.xml.get_widget('data_form_window')
config_vbox = self.xml.get_widget('config_vbox')
dataform = dataforms.ExtendForm(node = self.form)
self.data_form_widget = dataforms_widget.DataFormWidget(dataform)
self.data_form_widget.show()
config_vbox.pack_start(self.data_form_widget)
self.xml.signal_autoconnect(self)
self.window.show_all()
2007-06-01 20:19:19 +02:00
2007-06-02 00:08:23 +02:00
def on_ok_button_clicked(self, widget):
acceptance = xmpp.Message(self.jid)
acceptance.setThread(self.session.thread_id)
2007-06-02 00:08:23 +02:00
feature = acceptance.NT.feature
feature.setNamespace(xmpp.NS_FEATURE)
form = self.data_form_widget.data_form
form.setAttr('type', 'submit')
feature.addChild(node=form)
gajim.connections[self.account].send_stanza(acceptance)
self.window.destroy()
2007-06-01 20:19:19 +02:00
def on_cancel_button_clicked(self, widget):
# XXX determine whether to reveal presence
rejection = xmpp.Message(self.jid)
rejection.setThread(self.session.thread_id)
2007-06-01 20:19:19 +02:00
feature = rejection.NT.feature
feature.setNamespace(xmpp.NS_FEATURE)
x = xmpp.DataForm(typ='submit')
x.addChild(node=xmpp.DataField('FORM_TYPE', value='urn:xmpp:ssn'))
x.addChild(node=xmpp.DataField('accept', value='false', typ='boolean'))
feature.addChild(node=x)
# XXX optional <body/>
gajim.connections[self.account].send_stanza(rejection)
self.window.destroy()