diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2011-01-05 01:41:19 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2011-01-05 01:41:19 +0000 |
commit | 1f2959d96e53679ccc4fe7e9ecf04a7320cb2a53 (patch) | |
tree | 8f0f366fcc85ef4772bd0bc751cd77d209c7610d /src | |
parent | 6de2673c8f2a124a844906d5cf26bec7e8643e00 (diff) | |
download | poezio-1f2959d96e53679ccc4fe7e9ecf04a7320cb2a53.tar.gz poezio-1f2959d96e53679ccc4fe7e9ecf04a7320cb2a53.tar.bz2 poezio-1f2959d96e53679ccc4fe7e9ecf04a7320cb2a53.tar.xz poezio-1f2959d96e53679ccc4fe7e9ecf04a7320cb2a53.zip |
correctly displays a message in ConversationTabs when a resource goes offline
Diffstat (limited to 'src')
-rw-r--r-- | src/core.py | 16 | ||||
-rw-r--r-- | src/text_buffer.py | 3 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/core.py b/src/core.py index 39d72b6c..2c631a00 100644 --- a/src/core.py +++ b/src/core.py @@ -164,9 +164,9 @@ class Core(object): make a bug report. """ try: - tb_tab = tabs.SimpleTextTab(self, "/!\ Oups, an error occured (this may not be fatal). /!\\\n\nPlease report this bug (by copying the present error message and explaining what you were doing) on the page http://codingteam.net/project/poezio/bugs/add\n\n%s\n\nIf Poezio does not respond anymore, kill it with Ctrl+\\, and sorry about that :(" % ''.join(traceback.format_exception(typ, value, trace))) + tb_tab = tabs.SimpleTextTab(self, "/!\ Oups, an error occured (this may not be fatal). /!\\\nPlease report this bug (by copying the present error message and explaining what you were doing) on the page http://codingteam.net/project/poezio/bugs/add\n\n%s\n\nIf Poezio does not respond anymore, kill it with Ctrl+\\, and sorry about that :(" % ''.join(traceback.format_exception(typ, value, trace))) self.add_tab(tb_tab, focus=True) - except Exception: # If an exception is raised in this code, this is + except Exception: # If an exception is raised in this code, # this is fatal, so we exit cleanly and display the traceback curses.endwin() raise @@ -199,12 +199,18 @@ class Core(object): resource = contact.get_resource_by_fulljid(jid.full) assert resource self.information('%s is offline' % (resource.get_jid()), "Roster") - # Search all opened tab with this fulljid or the bare jid and add - # an information message in all of them + # If a resource got offline, display the message in the conversation with this + # precise resource. tab = self.get_tab_by_name(jid.full) if tab and isinstance(tab, tabs.ConversationTab): - self.add_message_to_text_buffer(tab.get_room(), '%s is offline' % (resource.get_jid())) + self.add_message_to_text_buffer(tab.get_room(), '%s is offline' % (resource.get_jid().full)) contact.remove_resource(resource) + # Display the message in the conversation with the bare JID only if that was + # the only resource online (i.e. now the contact is completely disconnected) + if not contact.get_highest_priority_resource(): # No resource left: that was the last one + tab = self.get_tab_by_name(jid.bare) + if tab and isinstance(tab, tabs.ConversationTab): + self.add_message_to_text_buffer(tab.get_room(), '%s is offline' % (jid.bare)) if isinstance(self.current_tab(), tabs.RosterInfoTab): self.refresh_window() diff --git a/src/text_buffer.py b/src/text_buffer.py index 8e46bcad..828b344c 100644 --- a/src/text_buffer.py +++ b/src/text_buffer.py @@ -32,7 +32,6 @@ class TextBuffer(object): This class just keep trace of messages, in a list with various informations and attributes. """ - def __init__(self): self.messages = [] # Message objects self.windows = [] # we keep track of one or more windows @@ -43,7 +42,7 @@ class TextBuffer(object): self.windows.append(win) def add_message(self, txt, time=None, nickname=None, colorized=False, nick_color=None): - color = theme.COLOR_NORMAL_TEXT + color = theme.COLOR_NORMAL_TEXT if nickname is not None else theme.COLOR_INFORMATION_TEXT nick_color = nick_color time = time or datetime.now() msg = Message(txt, time, nickname, nick_color, color, colorized) |