From 90a5b3d352529d396088476d299950baf09cadf7 Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Tue, 26 Mar 2019 14:29:50 +0100 Subject: Refactor session_end actions out of on_disconnect --- poezio/core/core.py | 2 ++ poezio/core/handlers.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/poezio/core/core.py b/poezio/core/core.py index cc838541..1f02c3d8 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -256,6 +256,8 @@ class Core: ('roster_update', self.handler.on_roster_update), ('session_start', self.handler.on_session_start), ('session_start', self.handler.on_session_start_features), + ('session_end', self.handler.on_session_end), + ('sm_failed', self.handler.on_session_end), ('ssl_cert', self.handler.validate_ssl), ('ssl_invalid_chain', self.handler.ssl_invalid_chain), ('stream_error', self.handler.on_stream_error), diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py index 9cb9358e..955f8f58 100644 --- a/poezio/core/handlers.py +++ b/poezio/core/handlers.py @@ -1152,18 +1152,23 @@ class HandlerCore: self.core.information( "Connection to remote server failed: %s" % (error, ), 'Error') + def on_session_end(self, event): + """ + Called when a session is terminated (e.g. due to a manual disconnect or a 0198 resume fail) + """ + roster.connected = 0 + roster.modified() + for tab in self.core.get_tabs(tabs.MucTab): + tab.disconnect() + async def on_disconnected(self, event): """ When we are disconnected from remote server """ if 'disconnect' in config.get('beep_on').split(): curses.beep() - roster.connected = 0 # Stop the ping plugin. It would try to send stanza on regular basis self.core.xmpp.plugin['xep_0199'].disable_keepalive() - roster.modified() - for tab in self.core.get_tabs(tabs.MucTab): - tab.disconnect() msg_typ = 'Error' if not self.core.legitimate_disconnect else 'Info' self.core.information("Disconnected from server%s." % (event and ": %s" % event or ""), msg_typ) if self.core.legitimate_disconnect or not config.get( -- cgit v1.2.3