summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Lukas <georg@op-co.de>2018-11-26 16:22:49 +0100
committerGeorg Lukas <georg@op-co.de>2018-12-16 19:02:06 +0100
commitb0a19bb0198259812773e3e26ce9f37519c75367 (patch)
tree22387b3a7089f86215012aa8eec7f6dc33ac5e18
parent8a23706b72a0f19405581e20c132fb442a960250 (diff)
downloadpoezio-b0a19bb0198259812773e3e26ce9f37519c75367.tar.gz
poezio-b0a19bb0198259812773e3e26ce9f37519c75367.tar.bz2
poezio-b0a19bb0198259812773e3e26ce9f37519c75367.tar.xz
poezio-b0a19bb0198259812773e3e26ce9f37519c75367.zip
self-ping: do not /cycle on timeout, log only
-rw-r--r--poezio/tabs/muctab.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index 54795bc3..d533f817 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -53,6 +53,7 @@ class MucTab(ChatTab):
plugin_commands = {} # type: Dict[str, Command]
plugin_keys = {} # type: Dict[str, Callable]
additional_information = {} # type: Dict[str, Callable[[str], str]]
+ lagged = False
def __init__(self, core, jid, nick, password=None):
ChatTab.__init__(self, core, jid)
@@ -411,6 +412,8 @@ class MucTab(ChatTab):
if self.joined:
if self.input.text:
self.state = 'nonempty'
+ elif self.lagged:
+ self.state = 'disconnected'
else:
self.state = 'normal'
else:
@@ -436,6 +439,7 @@ class MucTab(ChatTab):
"""
Handle MUC presence
"""
+ self.reset_lag()
status_codes = set()
for status_code in presence.xml.findall(STATUS_XPATH):
status_codes.add(status_code.attrib['code'])
@@ -1143,6 +1147,7 @@ class MucTab(ChatTab):
self.command_cycle(iq["error"]["text"] or "not in this room")
self.core.refresh_window()
else: # Re-send a self-ping in a few seconds
+ self.reset_lag()
self.enable_self_ping_event()
def search_for_color(self, nick):
@@ -1162,8 +1167,26 @@ class MucTab(ChatTab):
return color
def on_self_ping_failed(self, iq):
- self.command_cycle("the MUC server is not responding")
- self.core.refresh_window()
+ if not self.lagged:
+ self.lagged = True
+ info_text = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
+ self._text_buffer.add_message(
+ "\x19%s}MUC service not responding." % info_text)
+ self._state = 'disconnected'
+ self.core.refresh_window()
+ self.enable_self_ping_event()
+
+ def reset_lag(self):
+ if self.lagged:
+ self.lagged = False
+ info_text = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
+ self._text_buffer.add_message(
+ "\x19%s}MUC service is responding again." % info_text)
+ if self != self.core.tabs.current_tab:
+ self._state = 'joined'
+ else:
+ self._state = 'normal'
+ self.core.refresh_window()
########################## UI ONLY #####################################