From 1a0533998f6ccef00f94812ae54f138581ee3d6a Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sun, 7 Nov 2010 22:45:01 +0100 Subject: [PATCH] use NEC to handle connection type events --- src/common/connection.py | 4 +++- src/common/connection_handlers_events.py | 4 ++++ src/gui_interface.py | 6 ------ src/roster_window.py | 7 ++++++- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index 71b50f569..6cd61ea9d 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -1287,8 +1287,10 @@ class Connection(CommonConnection, ConnectionHandlers): def _register_handlers(self, con, con_type): self.peerhost = con.get_peerhost() + gajim.con_types[self.name] = con_type # notify the gui about con_type - self.dispatch('CON_TYPE', con_type) + gajim.nec.push_incoming_event(ConnectionTypeEvent(None, + conn=self, connection_type=con_type)) ConnectionHandlers._register_handlers(self, con, con_type) def __on_auth(self, con, auth): diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py index 770ee542c..ef8281f32 100644 --- a/src/common/connection_handlers_events.py +++ b/src/common/connection_handlers_events.py @@ -1267,4 +1267,8 @@ class NewAccountConnectedEvent(nec.NetworkIncomingEvent): class NewAccountNotConnectedEvent(nec.NetworkIncomingEvent): name = 'new-account-not-connected' + base_network_events = [] + +class ConnectionTypeEvent(nec.NetworkIncomingEvent): + name = 'connection-type' base_network_events = [] \ No newline at end of file diff --git a/src/gui_interface.py b/src/gui_interface.py index 12863235f..bdd2afb4d 100644 --- a/src/gui_interface.py +++ b/src/gui_interface.py @@ -188,11 +188,6 @@ class Interface: if ctrl and ctrl.type_id == message_control.TYPE_GC: ctrl.print_conversation('Error %s: %s' % (obj.errcode, obj.errmsg)) - def handle_event_con_type(self, account, con_type): - # ('CON_TYPE', account, con_type) which can be 'ssl', 'tls', 'plain' - gajim.con_types[account] = con_type - self.roster.draw_account(account) - def handle_event_connection_lost(self, account, array): # ('CONNECTION_LOST', account, [title, text]) path = gtkgui_helpers.get_icon_path('gajim-connection_lost', 48) @@ -1812,7 +1807,6 @@ class Interface: 'GC_SUBJECT': [self.handle_event_gc_subject], 'GC_CONFIG_CHANGE': [self.handle_event_gc_config_change], 'BAD_PASSPHRASE': [self.handle_event_bad_passphrase], - 'CON_TYPE': [self.handle_event_con_type], 'CONNECTION_LOST': [self.handle_event_connection_lost], 'FILE_REQUEST': [self.handle_event_file_request], 'FILE_REQUEST_ERROR': [self.handle_event_file_request_error], diff --git a/src/roster_window.py b/src/roster_window.py index 53e99a26c..c8cb5d8d5 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2495,6 +2495,9 @@ class RosterWindow: model[self.status_message_menuitem_iter][3] = True self.on_status_changed(obj.conn.name, obj.show) + def _nec_connection_type(self, obj): + self.draw_account(obj.conn.name) + ################################################################################ ### Menu and GUI callbacks ### FIXME: order callbacks in itself... @@ -6228,4 +6231,6 @@ class RosterWindow: gajim.ged.register_event_handler('anonymous-auth', ged.GUI1, self._nec_anonymous_auth) gajim.ged.register_event_handler('our-show', ged.GUI1, - self._nec_our_show) \ No newline at end of file + self._nec_our_show) + gajim.ged.register_event_handler('connection-type', ged.GUI1, + self._nec_connection_type) \ No newline at end of file