diff --git a/gajim/chat_control_base.py b/gajim/chat_control_base.py index 66ebb5ffcb0848814779fa4d24deade0af11eae3..a805d892065b8994cc9f3bddad2a504576360c02 100644 --- a/gajim/chat_control_base.py +++ b/gajim/chat_control_base.py @@ -42,6 +42,7 @@ from gajim.common.i18n import _ from gajim.common.nec import EventHelper from gajim.common.helpers import AdditionalDataDict +from gajim.common.helpers import event_filter from gajim.common.contacts import GC_Contact from gajim.common.const import Chatstate from gajim.common.structs import OutgoingMessage @@ -434,14 +435,12 @@ def remove_session(self, session): self.session.control = None self.session = None - def _nec_our_status(self, obj): - if self.account != obj.conn.name: + @event_filter(['account']) + def _nec_our_status(self, event): + if event.show == 'connecting': return - if obj.show == 'connecting': - return - - if obj.show == 'offline': + if event.show == 'offline': self.got_disconnected() else: self.got_connected() diff --git a/gajim/common/client.py b/gajim/common/client.py index 347cbf22cad589cd39a9b37c48923c54a3533518..84ff0d3c6287a747fd7aa295bce16e36e0ae595d 100644 --- a/gajim/common/client.py +++ b/gajim/common/client.py @@ -216,7 +216,7 @@ def process_ssl_errors(self): def _on_resume_failed(self, _client, _signal_name): log.info('Resume failed') app.nec.push_incoming_event(NetworkEvent( - 'our-show', conn=self, show='offline')) + 'our-show', account=self._account, show='offline')) self.get_module('Chatstate').enabled = False def _on_resume_successful(self, _client, _signal_name): @@ -260,7 +260,7 @@ def _on_disconnected(self, _client, _signal_name): self._reconnect = False self._after_disconnect() app.nec.push_incoming_event(NetworkEvent( - 'our-show', conn=self, show='offline')) + 'our-show', account=self._account, show='offline')) self.process_ssl_errors() elif domain in (StreamError.STREAM, StreamError.BIND): @@ -292,12 +292,12 @@ def _on_password(password): self._after_disconnect() self._schedule_reconnect() app.nec.push_incoming_event( - NetworkEvent('our-show', conn=self, show='error')) + NetworkEvent('our-show', account=self._account, show='error')) else: self.get_module('Chatstate').enabled = False app.nec.push_incoming_event(NetworkEvent( - 'our-show', conn=self, show='offline')) + 'our-show', account=self._account, show='offline')) self._after_disconnect() def _after_disconnect(self): @@ -535,7 +535,7 @@ def _abort_reconnect(self): self._set_state(ClientState.DISCONNECTED) self._disable_reconnect_timer() app.nec.push_incoming_event( - NetworkEvent('our-show', conn=self, show='offline')) + NetworkEvent('our-show', account=self._account, show='offline')) if self._destroy_client: self._client.destroy() diff --git a/gajim/common/modules/presence.py b/gajim/common/modules/presence.py index 13d55ef5988f9e8577e8e3cd70b3e3ba17d87f7b..0b25818f73e5e567ea2e060e4453670efc64aa44 100644 --- a/gajim/common/modules/presence.py +++ b/gajim/common/modules/presence.py @@ -90,7 +90,7 @@ def _presence_received(self, _con, stanza, properties): if properties.is_self_presence: app.nec.push_incoming_event( NetworkEvent('our-show', - conn=self._con, + account=self._account, show=properties.show.value)) return diff --git a/gajim/groupchat_control.py b/gajim/groupchat_control.py index 8327ab9a8fb45ef6c8fd75c2596f3202c7330e11..933f7f14c7227e18b180bbcf9e75241c79b3250e 100644 --- a/gajim/groupchat_control.py +++ b/gajim/groupchat_control.py @@ -1128,12 +1128,11 @@ def _on_decrypted_message_received(self, event): msg_log_id=event.msg_log_id, displaymarking=event.displaymarking) + @event_filter(['account']) def _nec_our_status(self, event): - if self.account != event.conn.name: - return - + client = app.get_client(event.account) if (event.show == 'offline' and - not event.conn.state.is_reconnect_scheduled): + not client.state.is_reconnect_scheduled): self.got_disconnected() if self.parent_win: diff --git a/gajim/gtk/notification.py b/gajim/gtk/notification.py index 32fe8afb44113e3057f8533f76395168922fb3b6..58edacc4c864caf1563e749ecf8dce877539ee21 100644 --- a/gajim/gtk/notification.py +++ b/gajim/gtk/notification.py @@ -132,9 +132,9 @@ def _on_event_removed(self, event_list): 'printed_gc_msg'): self._withdraw('new-message', event.account, event.jid) - def _nec_our_status(self, obj): - if app.account_is_connected(obj.conn.name): - self._withdraw('connection-failed', obj.conn.name) + def _nec_our_status(self, event): + if app.account_is_connected(event.account): + self._withdraw('connection-failed', event.account) @staticmethod def _get_icon_name(obj): diff --git a/gajim/gui_interface.py b/gajim/gui_interface.py index 22bb42584ebec627511cc0b05a45541d4557c10a..f5ddfbed4776d258a6c89e97a4dcbec308e087fa 100644 --- a/gajim/gui_interface.py +++ b/gajim/gui_interface.py @@ -201,28 +201,27 @@ def handle_event_connection_lost(obj): def unblock_signed_in_notifications(account): app.block_signed_in_notifications[account] = False - def handle_event_status(self, obj): # OUR status - #('STATUS', account, show) - account = obj.conn.name - if obj.show in ('offline', 'error'): + def handle_event_status(self, event): + if event.show in ('offline', 'error'): # TODO: Close all account windows pass - if obj.show == 'offline': - app.block_signed_in_notifications[account] = True + if event.show == 'offline': + app.block_signed_in_notifications[event.account] = True else: # 30 seconds after we change our status to sth else than offline # we stop blocking notifications of any kind # this prevents from getting the roster items as 'just signed in' # contacts. 30 seconds should be enough time - GLib.timeout_add_seconds(30, self.unblock_signed_in_notifications, - account) - - if account in self.show_vcard_when_connect and obj.show not in ( - 'offline', 'error'): - action = '%s-profile' % account - app.app.activate_action(action, GLib.Variant('s', account)) - self.show_vcard_when_connect.remove(account) + GLib.timeout_add_seconds(30, + self.unblock_signed_in_notifications, + event.account) + + if (event.account in self.show_vcard_when_connect and + event.show not in ('offline', 'error')): + action = '%s-profile' % event.account + app.app.activate_action(action, GLib.Variant('s', event.account)) + self.show_vcard_when_connect.remove(event.account) @staticmethod def handle_gc_error(gc_control, pritext, sectext): diff --git a/gajim/remote_control.py b/gajim/remote_control.py index 6623416bb6474d12f3c666972974285061d94da6..ffb69ddbc3d9f02317cbbb01d340729126a26c9e 100644 --- a/gajim/remote_control.py +++ b/gajim/remote_control.py @@ -382,8 +382,8 @@ def _nec_decrypted_message_received(self, obj): event_type, obj.properties.subject, obj.msg_log_id, obj.properties.nickname])) - def on_our_status(self, obj): - self.raise_signal('AccountPresence', (obj.show, obj.conn.name)) + def on_our_status(self, event): + self.raise_signal('AccountPresence', (event.show, event.account)) def on_account_created(self, obj): self.raise_signal('NewAccount', (obj.conn.name, obj.account_info)) diff --git a/gajim/roster_window.py b/gajim/roster_window.py index 7362453dd9fece834482308fd79b215e85c59828..42a96d9d142f67643e2e60ab8c387061786937b5 100644 --- a/gajim/roster_window.py +++ b/gajim/roster_window.py @@ -2568,19 +2568,19 @@ def _nec_anonymous_auth(self, obj): """ self.rename_self_contact(obj.old_jid, obj.new_jid, obj.conn.name) - def _nec_our_show(self, obj): + def _nec_our_show(self, event): model = self.status_combobox.get_model() iter_ = model.get_iter_from_string('6') - if obj.show == 'offline': + if event.show == 'offline': # sensitivity for this menuitem if app.get_number_of_connected_accounts() == 0: model[iter_][3] = False - self.application.set_account_actions_state(obj.conn.name) + self.application.set_account_actions_state(event.account) self.application.update_app_actions_state() else: # sensitivity for this menuitem model[iter_][3] = True - self.on_status_changed(obj.conn.name, obj.show) + self.on_status_changed(event.account, event.show) def _nec_connection_type(self, obj): self.draw_account(obj.conn.name)