From 900b67c01d86a44b75dbcde41ce82ecf46d82001 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sat, 31 May 2014 17:29:29 +0200 Subject: [PATCH] get_tab_by_name() should specify a tab type whenever possible For example, a tab can be named muc.example.com, if you do /list muc.example.com. If you then do /join muc.example.com, the error handler needs to get the correct tab (the MucTab, not the MucListTab previously opened). This commit fixes the above issue (a traceback), and maybe some others like that. --- src/core/core.py | 2 +- src/core/handlers.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/core.py b/src/core/core.py index 2e7a3c64..75f914f8 100644 --- a/src/core/core.py +++ b/src/core/core.py @@ -1219,7 +1219,7 @@ class Core(object): tab.activate(reason=reason) def on_user_changed_status_in_private(self, jid, msg): - tab = self.get_tab_by_name(jid) + tab = self.get_tab_by_name(jid, tabs.ChatTab) if tab: # display the message in private tab.add_message(msg, typ=2) diff --git a/src/core/handlers.py b/src/core/handlers.py index 4ec56a0b..56239274 100644 --- a/src/core/handlers.py +++ b/src/core/handlers.py @@ -41,7 +41,7 @@ def on_session_start_features(self, _): if not iq: return features = iq['disco_info']['features'] - rostertab = self.get_tab_by_name('Roster') + rostertab = self.get_tab_by_name('Roster', tabs.RosterInfoTab) rostertab.check_blocking(features) if (config.get('enable_carbons', True) and 'urn:xmpp:carbons:2' in features): @@ -984,8 +984,8 @@ def on_receipt(self, message): if not msg_id: return - conversation = self.get_tab_by_name(jid) - conversation = conversation or self.get_tab_by_name(jid.bare) + conversation = self.get_tab_by_name(jid, tabs.ChatTab) + conversation = conversation or self.get_tab_by_name(jid.bare, tabs.ChatTab) if not conversation: return @@ -1019,7 +1019,7 @@ def room_error(self, error, room_name): """ Display the error in the tab """ - tab = self.get_tab_by_name(room_name) + tab = self.get_tab_by_name(room_name, tabs.MucTab) error_message = self.get_error_message(error) tab.add_message(error_message, highlight=True, nickname='Error', nick_color=get_theme().COLOR_ERROR_MSG, typ=2)