From 3ea295f8c78d74c7ce94db3271f0ce3464e4e0cb Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Mon, 27 Sep 2010 22:53:25 +0000 Subject: avoid a crash when receiving a message from someone not in our roster --- src/gui.py | 3 +-- src/window.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui.py b/src/gui.py index d3d76596..4f647930 100644 --- a/src/gui.py +++ b/src/gui.py @@ -928,8 +928,7 @@ class Gui(object): is_jid(self.current_tab().get_name()): room += '@%s' % jid_get_domain(self.current_tab().get_name()) else: # no server could be found, print a message and return - # self.add_message_to_text_buffer(self.current_room(), _("You didn't specify a server for the room you want to join")) - # TODO INFO + self.information(_("You didn't specify a server for the room you want to join"), 'Error') return r = self.get_room_by_name(room) if len(args) == 2: # a password is provided diff --git a/src/window.py b/src/window.py index bef3bc9c..c10d3388 100644 --- a/src/window.py +++ b/src/window.py @@ -257,16 +257,22 @@ class ConversationInfoWin(InfoWin): def refresh(self, room, contact): if not self.visible: return + # contact can be None, if we receive a message + # from someone not in our roster. In this case, we display + # only the maximum information from the message we can get. g_lock.acquire() self.win.erase() - self.write_room_name(contact) + self.write_room_name(contact, room) self.print_scroll_position(room) self.finish_line(theme.COLOR_INFORMATION_BAR) self.win.refresh() g_lock.release() - def write_room_name(self, contact): - txt = '%s' % contact.get_jid().bare + def write_room_name(self, contact, room): + if not contact: + txt = '%s' % room.name + else: + txt = '%s' % contact.get_jid().bare self.addnstr(txt, len(txt), curses.color_pair(theme.COLOR_INFORMATION_BAR)) class MucInfoWin(InfoWin): -- cgit v1.2.3