4 ## Copyright (C) 2007-2010 Yann Leboulanger <asterix AT lagaule.org>
5 ## Copyright (C) 2007-2008 Brendan Taylor <whateley AT gmail.com>
7 ## This file is part of Gajim.
9 ## Gajim is free software; you can redistribute it and/or modify
10 ## it under the terms of the GNU General Public License as published
11 ## by the Free Software Foundation; version 3 only.
13 ## Gajim is distributed in the hope that it will be useful,
14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ## GNU General Public License for more details.
18 ## You should have received a copy of the GNU General Public License
19 ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
23 import dataforms_widget
25 from common
import dataforms
26 from common
import gajim
27 from common
import xmpp
29 def describe_features(features
):
31 A human-readable description of the features that have been negotiated
33 if features
['logging'] == 'may':
34 return _('- messages will be logged')
35 elif features
['logging'] == 'mustnot':
36 return _('- messages will not be logged')
38 class FeatureNegotiationWindow
:
39 def __init__(self
, account
, jid
, session
, form
):
40 self
.account
= account
43 self
.session
= session
45 self
.xml
= gtkgui_helpers
.get_gtk_builder('data_form_window.ui', 'data_form_window')
46 self
.window
= self
.xml
.get_object('data_form_window')
48 config_vbox
= self
.xml
.get_object('config_vbox')
49 dataform
= dataforms
.ExtendForm(node
= self
.form
)
50 self
.data_form_widget
= dataforms_widget
.DataFormWidget(dataform
)
51 self
.data_form_widget
.show()
52 config_vbox
.pack_start(self
.data_form_widget
)
54 self
.xml
.connect_signals(self
)
55 self
.window
.show_all()
57 def on_ok_button_clicked(self
, widget
):
58 acceptance
= xmpp
.Message(self
.jid
)
59 acceptance
.setThread(self
.session
.thread_id
)
60 feature
= acceptance
.NT
.feature
61 feature
.setNamespace(xmpp
.NS_FEATURE
)
63 form
= self
.data_form_widget
.data_form
64 form
.setAttr('type', 'submit')
66 feature
.addChild(node
=form
)
68 gajim
.connections
[self
.account
].send_stanza(acceptance
)
72 def on_cancel_button_clicked(self
, widget
):
73 rejection
= xmpp
.Message(self
.jid
)
74 rejection
.setThread(self
.session
.thread_id
)
75 feature
= rejection
.NT
.feature
76 feature
.setNamespace(xmpp
.NS_FEATURE
)
78 x
= xmpp
.DataForm(typ
='submit')
79 x
.addChild(node
=xmpp
.DataField('FORM_TYPE', value
='urn:xmpp:ssn'))
80 x
.addChild(node
=xmpp
.DataField('accept', value
='false', typ
='boolean'))
82 feature
.addChild(node
=x
)
84 gajim
.connections
[self
.account
].send_stanza(rejection
)