diff options
author | Georg Lukas <georg@op-co.de> | 2019-03-26 14:29:50 +0100 |
---|---|---|
committer | Georg Lukas <georg@op-co.de> | 2019-03-26 14:29:50 +0100 |
commit | 90a5b3d352529d396088476d299950baf09cadf7 (patch) | |
tree | 7a030fbff4fe5973aeb22edb94184e176ce35054 | |
parent | 46e3dece5e04fd8854596f32266c43083141526b (diff) | |
download | poezio-90a5b3d352529d396088476d299950baf09cadf7.tar.gz poezio-90a5b3d352529d396088476d299950baf09cadf7.tar.bz2 poezio-90a5b3d352529d396088476d299950baf09cadf7.tar.xz poezio-90a5b3d352529d396088476d299950baf09cadf7.zip |
Refactor session_end actions out of on_disconnect
-rw-r--r-- | poezio/core/core.py | 2 | ||||
-rw-r--r-- | 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( |