summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-10 15:26:34 +0100
committermathieui <mathieui@mathieui.net>2011-11-10 15:26:34 +0100
commiteaced10c1667d0ddf8cf41aebf060a6c2be7173b (patch)
tree22cbe50b6b4ea3e1f6ac16407da7d9393b5bb372
parent5c122163921fd6baef67e7a40afefdd83f9ef9ca (diff)
downloadpoezio-eaced10c1667d0ddf8cf41aebf060a6c2be7173b.tar.gz
poezio-eaced10c1667d0ddf8cf41aebf060a6c2be7173b.tar.bz2
poezio-eaced10c1667d0ddf8cf41aebf060a6c2be7173b.tar.xz
poezio-eaced10c1667d0ddf8cf41aebf060a6c2be7173b.zip
Also, do not crash when receiving a message from someone who is not a
contact
-rw-r--r--src/tabs.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/tabs.py b/src/tabs.py
index f037a368..5b9c9fe8 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -2000,10 +2000,13 @@ class ConversationTab(ChatTab):
def on_lose_focus(self):
contact = roster.get_contact_by_jid(self.get_name())
jid = JID(self.get_name())
- if jid.resource:
- resource = contact.get_resource_by_fulljid(jid.full)
+ if contact:
+ if jid.resource:
+ resource = contact.get_resource_by_fulljid(jid.full)
+ else:
+ resource = contact.get_highest_priority_resource()
else:
- resource = contact.get_highest_priority_resource()
+ resource = None
self.state = 'normal'
self.text_win.remove_line_separator()
self.text_win.add_line_separator()
@@ -2014,10 +2017,14 @@ class ConversationTab(ChatTab):
def on_gain_focus(self):
contact = roster.get_contact_by_jid(self.get_name())
jid = JID(self.get_name())
- if jid.resource:
- resource = contact.get_resource_by_fulljid(jid.full)
+ if contact:
+ if jid.resource:
+ resource = contact.get_resource_by_fulljid(jid.full)
+ else:
+ resource = contact.get_highest_priority_resource()
else:
- resource = contact.get_highest_priority_resource()
+ resource = None
+
self.state = 'current'
curses.curs_set(1)
if config.get('send_chat_states', 'true') == 'true' and not self.input.get_text() or not self.input.get_text().startswith('//'):