From bf2225468e8f496a45db477b596eb7d233cb813f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Mon, 8 Apr 2019 13:49:57 +0100 Subject: Revert work on tabs module to change tab.name to JID. This reverts commits: d693479d05f1ada999c0e29a9d9e2f021dd59e50 2d0cc092fcd154b2d14be0c5ac0ff338607824a0 89a61b84bdb29d3df8c08436c3484fddba8d2ef1 8194d9afbdec2daa1377e07ebb26bb99406473d0 e256c31875c8b67d85fe30d3e2c14c896066657a a21335ac171a827a613dcce744898e822689c9d3 c96e528a8fd1313f75cb792a8e4826fbcfde1bec 0551867bfdb8dfa7dbd5964a15a1a950510e2c71 6ab49c188a6e5bb95773165f0bdbd672b41c8c81 --- poezio/core/commands.py | 14 +++++--------- poezio/core/core.py | 20 +++++--------------- 2 files changed, 10 insertions(+), 24 deletions(-) (limited to 'poezio/core') diff --git a/poezio/core/commands.py b/poezio/core/commands.py index 5b990091..e785a93b 100644 --- a/poezio/core/commands.py +++ b/poezio/core/commands.py @@ -335,7 +335,7 @@ class CommandCore: if room.find('@') == -1 and not server_root: tab = self.core.tabs.current_tab if isinstance(tab, tabs.MucTab): - if tab.name.full.find('@') != -1: + if tab.name.find('@') != -1: domain = safeJID(tab.name).domain room += '@%s' % domain return (room, set_nick) @@ -369,8 +369,7 @@ class CommandCore: # New tab if tab is None: tab = self.core.open_new_room(room, nick, password=password) - if tab is not None: - tab.join() + tab.join() else: self.core.focus_tab(tab) if tab.own_nick == nick and tab.joined: @@ -1024,17 +1023,14 @@ class CommandCore: """ if args is None: return self.help('message') - try: - jid = JID(args[0]) - except InvalidJID: - return self.core.information('Invalid JID.', 'Error') - if not jid.bare: + jid = safeJID(args[0]) + if not jid.user and not jid.domain and not jid.resource: return self.core.information('Invalid JID.', 'Error') tab = self.core.get_conversation_by_jid( jid.full, False, fallback_barejid=False) muc = self.core.tabs.by_name_and_class(jid.bare, tabs.MucTab) if not tab and not muc: - tab = self.core.open_conversation_window(jid, focus=True) + tab = self.core.open_conversation_window(jid.full, focus=True) elif muc: if jid.resource: tab = self.core.tabs.by_name_and_class(jid.full, diff --git a/poezio/core/core.py b/poezio/core/core.py index 5e3e912b..7553c57d 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -1164,7 +1164,7 @@ class Core: provided, we open a StaticConversationTab, else a DynamicConversationTab """ - if jid.resource: + if safeJID(jid).resource: new_tab = tabs.StaticConversationTab(self, jid) else: new_tab = tabs.DynamicConversationTab(self, jid) @@ -1179,12 +1179,7 @@ class Core: """ Open a Private conversation in a MUC and focus if needed. """ - try: - complete_jid_str = room_name + '/' + user_nick - complete_jid = JID(complete_jid_str) - except InvalidJID: - self.information('Invalid XMPP address %r for chat tab.', complete_jid_str) - return None + complete_jid = room_name + '/' + user_nick # if the room exists, focus it and return for tab in self.get_tabs(tabs.PrivateTab): if tab.name == complete_jid: @@ -1210,15 +1205,10 @@ class Core: nick: str, *, password: Optional[str] = None, - focus=True) -> Optional[tabs.MucTab]: + focus=True) -> tabs.MucTab: """ Open a new tab.MucTab containing a muc Room, using the specified nick """ - try: - room = JID(room) - except InvalidJID: - self.information('Invalid XMPP address %r for chat tab.', room) - return None new_tab = tabs.MucTab(self, room, nick, password=password) self.add_tab(new_tab, focus) self.refresh_window() @@ -1277,7 +1267,7 @@ class Core: if reason is None: reason = '\x195}You left the room\x193}' for tab in self.get_tabs(tabs.PrivateTab): - if tab.name.full.startswith(room_name): + if tab.name.startswith(room_name): tab.deactivate(reason=reason) def enable_private_tabs(self, room_name: str, @@ -1288,7 +1278,7 @@ class Core: if reason is None: reason = '\x195}You joined the room\x193}' for tab in self.get_tabs(tabs.PrivateTab): - if tab.name.full.startswith(room_name): + if tab.name.startswith(room_name): tab.activate(reason=reason) def on_user_changed_status_in_private(self, jid: JID, status: str) -> None: -- cgit v1.2.3