summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core.py16
-rw-r--r--src/text_buffer.py3
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)