Author: bct
Date: 2007-06-02 00:08:23 +0200 (Sat, 02 Jun 2007)
New Revision: 8193
Modified:
branches/e2e_encryption/src/gajim.py
branches/e2e_encryption/src/negotiation.py
Log:
can now accept a session negotiation
Modified: branches/e2e_encryption/src/gajim.py
===================================================================
--- branches/e2e_encryption/src/gajim.py 2007-06-01 20:17:13 UTC (rev 8192)
+++ branches/e2e_encryption/src/gajim.py 2007-06-01 22:08:23 UTC (rev 8193)
@@ -1658,10 +1658,24 @@
def handle_session_negotiation(self, account, data):
jid, thread_id, form = data
# XXX check negotiation state, etc.
+ # XXX check if we can autoaccept
- # XXX check if the user has chosen to autoaccept these values
- negotiation.FeatureNegotiationWindow(account, jid, thread_id, form)
+ if form.getType() == 'form':
+ ctrl = gajim.interface.msg_win_mgr.get_control(str(jid), account)
+ if not ctrl:
+ resource = jid.getResource()
+ contact = gajim.contacts.get_contact(account, str(jid), resource)
+ if not contact:
+ connection = gajim.connections[account]
+ contact = gajim.contacts.create_contact(jid = jid.getStripped(), resource = resource, show = connection.get_status())
+ self.roster.new_chat(contact, account, resource = resource)
+ ctrl = gajim.interface.msg_win_mgr.get_control(str(jid), account)
+
+ ctrl.set_thread_id(thread_id)
+
+ 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):
Modified: branches/e2e_encryption/src/negotiation.py
===================================================================
--- branches/e2e_encryption/src/negotiation.py 2007-06-01 20:17:13 UTC (rev 8192)
+++ branches/e2e_encryption/src/negotiation.py 2007-06-01 22:08:23 UTC (rev 8193)
@@ -25,6 +25,21 @@
self.xml.signal_autoconnect(self)
self.window.show_all()
+ def on_ok_button_clicked(self, widget):
+ acceptance = xmpp.Message(self.jid)
+ acceptance.setThread(self.thread_id)
+ 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()
+
def on_cancel_button_clicked(self, widget):
# XXX determine whether to reveal presence