Commit 90a5b3d3 authored by ge0rg's avatar ge0rg

Refactor session_end actions out of on_disconnect

parent 46e3dece
......@@ -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),
......
......@@ -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(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment