changeset 21f968f95030 in /home/hg/repos/gajim

details:http://hg.gajim.org/gajim?cmd=changeset;node=21f968f95030
description: use NEC to handle insecure password events

diffstat:

 src/common/connection.py                 |   3 +-
 src/common/connection_handlers_events.py |   4 +++
 src/gui_interface.py                     |  37 ++++++++++++++++++-------------
 3 files changed, 27 insertions(+), 17 deletions(-)

diffs (102 lines):

diff -r 7092a5a21d9f -r 21f968f95030 src/common/connection.py
--- a/src/common/connection.py  Wed Nov 24 15:38:16 2010 +0100
+++ b/src/common/connection.py  Wed Nov 24 16:18:56 2010 +0100
@@ -2249,7 +2249,8 @@
             if self._current_type == 'plain' and type_ == 'PLAIN' and \
             gajim.config.get_per('accounts', self.name,
             'warn_when_insecure_password'):
-                self.dispatch('INSECURE_PASSWORD', None)
+                gajim.nec.push_incoming_event(InsecurePasswordEvent(None,
+                    conn=self))
                 return
             callback(password)
             self.pasword_callback = None
diff -r 7092a5a21d9f -r 21f968f95030 src/common/connection_handlers_events.py
--- a/src/common/connection_handlers_events.py  Wed Nov 24 15:38:16 2010 +0100
+++ b/src/common/connection_handlers_events.py  Wed Nov 24 16:18:56 2010 +0100
@@ -1435,3 +1435,7 @@
 class PlainConnectionEvent(nec.NetworkIncomingEvent):
     name = 'plain-connection'
     base_network_events = []
+
+class InsecurePasswordEvent(nec.NetworkIncomingEvent):
+    name = 'insecure-password'
+    base_network_events = []
diff -r 7092a5a21d9f -r 21f968f95030 src/gui_interface.py
--- a/src/gui_interface.py      Wed Nov 24 15:38:16 2010 +0100
+++ b/src/gui_interface.py      Wed Nov 24 16:18:56 2010 +0100
@@ -1564,38 +1564,43 @@
             checktext2, on_response_ok=on_ok, on_response_cancel=on_cancel,
             is_modal=False)
 
-    def handle_event_insecure_password(self, account, data):
+    def handle_event_insecure_password(self, obj):
         # ('INSECURE_PASSWORD', account, ())
         def on_ok(is_checked):
             if not is_checked[0]:
                 on_cancel()
                 return
-            del self.instances[account]['online_dialog']['insecure_password']
+            del self.instances[obj.conn.name]['online_dialog']\
+                ['insecure_password']
             if is_checked[1]:
-                gajim.config.set_per('accounts', account,
+                gajim.config.set_per('accounts', obj.conn.name,
                     'warn_when_insecure_password', False)
-            if gajim.connections[account].connected == 0:
+            if obj.conn.connected == 0:
                 # We have been disconnecting (too long time since window is
                 # opened)
                 # re-connect with auto-accept
-                gajim.connections[account].connection_auto_accepted = True
-                show, msg = 
gajim.connections[account].continue_connect_info[:2]
-                self.roster.send_status(account, show, msg)
+                obj.conn.connection_auto_accepted = True
+                show, msg = obj.conn.continue_connect_info[:2]
+                self.roster.send_status(obj.conn.name, show, msg)
                 return
-            gajim.connections[account].accept_insecure_password()
+            obj.conn.accept_insecure_password()
+
         def on_cancel():
-            del self.instances[account]['online_dialog']['insecure_password']
-            gajim.connections[account].disconnect(on_purpose=True)
-            self.handle_event_status(account, 'offline')
+            del self.instances[obj.conn.name]['online_dialog']\
+                ['insecure_password']
+            obj.conn.disconnect(on_purpose=True)
+            self.handle_event_status(obj.conn.name, 'offline')
+
         pritext = _('Insecure connection')
         sectext = _('You are about to send your password unencrypted on an '
             'insecure connection. Are you sure you want to do that?')
         checktext1 = _('Yes, I really want to connect insecurely')
         checktext2 = _('_Do not ask me again')
-        if 'insecure_password' in self.instances[account]['online_dialog']:
-            self.instances[account]['online_dialog']['insecure_password'].\
-                destroy()
-        self.instances[account]['online_dialog']['insecure_password'] = \
+        if 'insecure_password' in self.instances[obj.conn.name]\
+        ['online_dialog']:
+            self.instances[obj.conn.name]['online_dialog']\
+                ['insecure_password'].destroy()
+        self.instances[obj.conn.name]['online_dialog']['insecure_password'] = \
             dialogs.ConfirmationDialogDoubleCheck(pritext, sectext, checktext1,
             checktext2, on_response_ok=on_ok, on_response_cancel=on_cancel,
             is_modal=False)
@@ -1636,7 +1641,6 @@
             'FINGERPRINT_ERROR': [self.handle_event_fingerprint_error],
             'INSECURE_SSL_CONNECTION': \
                 [self.handle_event_insecure_ssl_connection],
-            'INSECURE_PASSWORD': [self.handle_event_insecure_password],
             'atom-entry-received': [self.handle_atom_entry],
             'bad-gpg-passphrase': [self.handle_event_bad_gpg_passphrase],
             'bookmarks-received': [self.handle_event_bookmarks],
@@ -1647,6 +1651,7 @@
             'gpg-password-required': [self.handle_event_gpg_password_required],
             'gpg-trust-key': [self.handle_event_gpg_trust_key],
             'http-auth-received': [self.handle_event_http_auth],
+            'insecure-password': [self.handle_event_insecure_password],
             'iq-error-received': [self.handle_event_iq_error],
             'jingle-connected-received': [self.handle_event_jingle_connected],
             'jingle-disconnected-received': [
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to