Commit 217bc731 authored by Maxime Buquet's avatar Maxime Buquet

core/commands: Use jid parameter instead of name where appropriate

Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <pep@bouah.net>
parent 05019c4f
...@@ -136,7 +136,7 @@ class CommandCore: ...@@ -136,7 +136,7 @@ class CommandCore:
current.send_chat_state('inactive') current.send_chat_state('inactive')
for tab in self.core.tabs: for tab in self.core.tabs:
if isinstance(tab, tabs.MucTab) and tab.joined: if isinstance(tab, tabs.MucTab) and tab.joined:
muc.change_show(self.core.xmpp, tab.name, tab.own_nick, show, muc.change_show(self.core.xmpp, tab.jid, tab.own_nick, show,
msg) msg)
if hasattr(tab, 'directed_presence'): if hasattr(tab, 'directed_presence'):
del tab.directed_presence del tab.directed_presence
...@@ -154,7 +154,7 @@ class CommandCore: ...@@ -154,7 +154,7 @@ class CommandCore:
jid, ptype, status = args[0], args[1], args[2] jid, ptype, status = args[0], args[1], args[2]
if jid == '.' and isinstance(self.core.tabs.current_tab, tabs.ChatTab): if jid == '.' and isinstance(self.core.tabs.current_tab, tabs.ChatTab):
jid = self.core.tabs.current_tab.name jid = self.core.tabs.current_tab.jid
if ptype == 'available': if ptype == 'available':
ptype = None ptype = None
try: try:
...@@ -306,7 +306,7 @@ class CommandCore: ...@@ -306,7 +306,7 @@ class CommandCore:
tab = self.core.tabs.current_tab tab = self.core.tabs.current_tab
if not isinstance(tab, (tabs.MucTab, tabs.PrivateTab)): if not isinstance(tab, (tabs.MucTab, tabs.PrivateTab)):
return (None, None) return (None, None)
room = safeJID(tab.name).bare room = tab.jid.bare
nick = tab.own_nick nick = tab.own_nick
return (room, nick) return (room, nick)
...@@ -344,10 +344,8 @@ class CommandCore: ...@@ -344,10 +344,8 @@ class CommandCore:
# check if the current room's name has a server # check if the current room's name has a server
if room.find('@') == -1 and not server_root: if room.find('@') == -1 and not server_root:
tab = self.core.tabs.current_tab tab = self.core.tabs.current_tab
if isinstance(tab, tabs.MucTab): if isinstance(tab, tabs.MucTab) and tab.domain:
if tab.name.find('@') != -1: room += '@%s' % tab.domain
domain = safeJID(tab.name).domain
room += '@%s' % domain
return (room, set_nick) return (room, set_nick)
@command_args_parser.quoted(0, 2) @command_args_parser.quoted(0, 2)
...@@ -437,7 +435,7 @@ class CommandCore: ...@@ -437,7 +435,7 @@ class CommandCore:
nick = None nick = None
if not jid: if not jid:
tab = self.core.tabs.current_tab tab = self.core.tabs.current_tab
roomname = tab.name roomname = tab.jid.bare
if tab.joined and tab.own_nick != self.core.own_nick: if tab.joined and tab.own_nick != self.core.own_nick:
nick = tab.own_nick nick = tab.own_nick
if password is None and tab.password is not None: if password is None and tab.password is not None:
...@@ -451,7 +449,7 @@ class CommandCore: ...@@ -451,7 +449,7 @@ class CommandCore:
tab = self.core.tabs.current_tab tab = self.core.tabs.current_tab
if not isinstance(tab, tabs.MucTab): if not isinstance(tab, tabs.MucTab):
return return
roomname = tab.name roomname = tab.jid.bare
bookmark = self.core.bookmarks[roomname] bookmark = self.core.bookmarks[roomname]
if bookmark is None: if bookmark is None:
bookmark = Bookmark(roomname) bookmark = Bookmark(roomname)
...@@ -470,9 +468,9 @@ class CommandCore: ...@@ -470,9 +468,9 @@ class CommandCore:
def _add_wildcard_bookmarks(self, method): def _add_wildcard_bookmarks(self, method):
new_bookmarks = [] new_bookmarks = []
for tab in self.core.get_tabs(tabs.MucTab): for tab in self.core.get_tabs(tabs.MucTab):
bookmark = self.core.bookmarks[tab.name] bookmark = self.core.bookmarks[tab.jid.bare]
if not bookmark: if not bookmark:
bookmark = Bookmark(tab.name, autojoin=True, method=method) bookmark = Bookmark(tab.jid.bare, autojoin=True, method=method)
new_bookmarks.append(bookmark) new_bookmarks.append(bookmark)
else: else:
bookmark.method = method bookmark.method = method
...@@ -509,8 +507,8 @@ class CommandCore: ...@@ -509,8 +507,8 @@ class CommandCore:
if not args: if not args:
tab = self.core.tabs.current_tab tab = self.core.tabs.current_tab
if isinstance(tab, tabs.MucTab) and self.core.bookmarks[tab.name]: if isinstance(tab, tabs.MucTab) and self.core.bookmarks[tab.jid.bare]:
self.core.bookmarks.remove(tab.name) self.core.bookmarks.remove(tab.jid.bare)
self.core.bookmarks.save(self.core.xmpp, callback=cb) self.core.bookmarks.save(self.core.xmpp, callback=cb)
else: else:
self.core.information('No bookmark to remove', 'Info') self.core.information('No bookmark to remove', 'Info')
...@@ -674,7 +672,7 @@ class CommandCore: ...@@ -674,7 +672,7 @@ class CommandCore:
info = plugin_config.set_and_save(option, value, section) info = plugin_config.set_and_save(option, value, section)
else: else:
if args[0] == '.': if args[0] == '.':
name = safeJID(self.core.tabs.current_tab.name).bare name = self.core.tabs.current_tab.jid.bare
if not name: if not name:
self.core.information( self.core.information(
'Invalid tab to use the "." argument.', 'Error') 'Invalid tab to use the "." argument.', 'Error')
...@@ -742,11 +740,11 @@ class CommandCore: ...@@ -742,11 +740,11 @@ class CommandCore:
message = args[1] message = args[1]
else: else:
if isinstance(tab, tabs.MucTab): if isinstance(tab, tabs.MucTab):
domain = safeJID(tab.name).domain domain = tab.jid.domain
else: else:
return self.core.information("No server specified", "Error") return self.core.information("No server specified", "Error")
for tab in self.core.get_tabs(tabs.MucTab): for tab in self.core.get_tabs(tabs.MucTab):
if JID(tab.name).domain == domain: if tab.jid.domain == domain:
tab.leave_room(message) tab.leave_room(message)
tab.join() tab.join()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment