2008-08-15 19:31:51 +02:00
|
|
|
# -*- coding:utf-8 -*-
|
2008-08-15 05:20:23 +02:00
|
|
|
## src/negotiation.py
|
|
|
|
##
|
|
|
|
## Copyright (C) 2007 Yann Leboulanger <asterix AT lagaule.org>
|
|
|
|
## Copyright (C) 2007-2008 Brendan Taylor <whateley AT gmail.com>
|
|
|
|
##
|
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published
|
|
|
|
## by the Free Software Foundation; version 3 only.
|
|
|
|
##
|
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
|
|
|
|
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
|
|
|
|
2007-07-02 18:53:19 +02:00
|
|
|
def describe_features(features):
|
2009-11-25 21:59:43 +01:00
|
|
|
"""
|
|
|
|
A human-readable description of the features that have been negotiated
|
|
|
|
"""
|
2007-07-02 18:53:19 +02:00
|
|
|
if features['logging'] == 'may':
|
2007-07-04 20:55:53 +02:00
|
|
|
return _('- messages will be logged')
|
2007-07-02 18:53:19 +02:00
|
|
|
elif features['logging'] == 'mustnot':
|
2007-07-04 20:55:53 +02:00
|
|
|
return _('- messages will not be logged')
|
|
|
|
|
2007-06-01 19:12:49 +02:00
|
|
|
class FeatureNegotiationWindow:
|
2007-06-05 23:26:45 +02:00
|
|
|
def __init__(self, account, jid, session, form):
|
2007-06-01 19:12:49 +02:00
|
|
|
self.account = account
|
|
|
|
self.jid = jid
|
|
|
|
self.form = form
|
2007-06-05 23:26:45 +02:00
|
|
|
self.session = session
|
2007-06-01 19:12:49 +02:00
|
|
|
|
2010-01-22 19:57:59 +01:00
|
|
|
self.xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui', 'data_form_window')
|
|
|
|
self.window = self.xml.get_object('data_form_window')
|
2007-06-01 19:12:49 +02:00
|
|
|
|
2010-01-22 19:57:59 +01:00
|
|
|
config_vbox = self.xml.get_object('config_vbox')
|
2007-06-01 19:12:49 +02:00
|
|
|
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)
|
|
|
|
|
2010-01-22 19:57:59 +01:00
|
|
|
self.xml.connect_signals(self)
|
2007-06-01 19:12:49 +02:00
|
|
|
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)
|
2007-06-05 23:26:45 +02:00
|
|
|
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):
|
|
|
|
rejection = xmpp.Message(self.jid)
|
2007-06-05 23:26:45 +02:00
|
|
|
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)
|
|
|
|
|
|
|
|
gajim.connections[self.account].send_stanza(rejection)
|
|
|
|
|
|
|
|
self.window.destroy()
|
2008-07-29 21:49:31 +02:00
|
|
|
|
2008-08-15 05:20:23 +02:00
|
|
|
# vim: se ts=3:
|