summaryrefslogtreecommitdiff
path: root/src/core.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2011-01-05 01:46:19 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2011-01-05 01:46:19 +0000
commit98c32b05e80ee34822afe3ed37624bb3d0656bdf (patch)
tree53d65c2222e7153babeab61be0bf9eec0a6406e9 /src/core.py
parent1f2959d96e53679ccc4fe7e9ecf04a7320cb2a53 (diff)
downloadpoezio-98c32b05e80ee34822afe3ed37624bb3d0656bdf.tar.gz
poezio-98c32b05e80ee34822afe3ed37624bb3d0656bdf.tar.bz2
poezio-98c32b05e80ee34822afe3ed37624bb3d0656bdf.tar.xz
poezio-98c32b05e80ee34822afe3ed37624bb3d0656bdf.zip
same thing, but nicer code
Diffstat (limited to 'src/core.py')
-rw-r--r--src/core.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/core.py b/src/core.py
index 2c631a00..745f24d5 100644
--- a/src/core.py
+++ b/src/core.py
@@ -201,16 +201,12 @@ class Core(object):
self.information('%s is offline' % (resource.get_jid()), "Roster")
# 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().full))
+ self.add_information_message_to_conversation_tab(jid.full, '%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))
+ self.add_information_message_to_conversation_tab(jid.bare, '%s is offline' % (jid.bare))
if isinstance(self.current_tab(), tabs.RosterInfoTab):
self.refresh_window()
@@ -231,6 +227,19 @@ class Core(object):
resource.set_priority(priority)
contact.add_resource(resource)
self.information("%s is online (%s)" % (resource.get_jid().full, status), "Roster")
+ 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().full))
+
+ def add_information_message_to_conversation_tab(self, jid, msg):
+ """
+ Search for a ConversationTab with the given jid (full or bare), if yes, add
+ the given message to it
+ """
+ tab = self.get_tab_by_name(jid)
+ if tab and isinstance(tab, tabs.ConversationTab):
+ self.add_message_to_text_buffer(tab.get_room(), msg)
+
def on_connected(self, event):
"""