summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2015-10-05 21:39:24 +0200
committermathieui <mathieui@mathieui.net>2015-10-05 21:39:24 +0200
commit62491a4caad2565ab81b62eedf053569976cbfe1 (patch)
tree58bf52a1449cd864d066abc6e14c7d083f41e6a4 /src
parentad107389815c2d943003350a66962e8491fb4c8d (diff)
downloadpoezio-62491a4caad2565ab81b62eedf053569976cbfe1.tar.gz
poezio-62491a4caad2565ab81b62eedf053569976cbfe1.tar.bz2
poezio-62491a4caad2565ab81b62eedf053569976cbfe1.tar.xz
poezio-62491a4caad2565ab81b62eedf053569976cbfe1.zip
Fix #3130 (self-ping & /cycle not using known room password)
Diffstat (limited to 'src')
-rw-r--r--src/core/commands.py46
-rw-r--r--src/core/core.py1
-rw-r--r--src/tabs/muctab.py18
3 files changed, 29 insertions, 36 deletions
diff --git a/src/core/commands.py b/src/core/commands.py
index f278e233..256668d6 100644
--- a/src/core/commands.py
+++ b/src/core/commands.py
@@ -355,9 +355,7 @@ def command_join(self, args, histo_length=None):
if room in self.pending_invites:
del self.pending_invites[room]
tab = self.get_tab_by_name(room, tabs.MucTab)
- if len(args) == 2: # a password is provided
- password = args[1]
- if tab and tab.joined: # if we are already in the room
+ if tab is not None and tab.joined: # if we are already in the room
self.focus_tab_named(tab.name)
if tab.own_nick == nick:
self.information('/join: Nothing to do.', 'Info')
@@ -368,47 +366,25 @@ def command_join(self, args, histo_length=None):
if room.startswith('@'):
room = room[1:]
- current_status = self.get_status()
if not histo_length:
histo_length = config.get('muc_history_length')
if histo_length == -1:
histo_length = None
if histo_length is not None:
histo_length = str(histo_length)
+ if len(args) == 2: # a password is provided
+ password = args[1]
if password is None: # try to use a saved password
password = config.get_by_tabname('password', room, fallback=False)
- if tab and not tab.joined:
- if tab.last_connection:
- if tab.last_connection is not None:
- delta = datetime.now() - tab.last_connection
- seconds = delta.seconds + delta.days * 24 * 3600
- else:
- seconds = 0
- seconds = int(seconds)
- else:
- seconds = 0
- # If we didn’t have a password by now (from a bookmark or the
- # explicit argument), just use the password that is stored in the
- # tab because of our last join
- if not password:
- password = tab.password
- muc.join_groupchat(self, room, nick, password,
- histo_length,
- current_status.message,
- current_status.show,
- seconds=seconds)
- # Store in the tab the password we used, for later use
- tab.password = password
- if not tab:
- self.open_new_room(room, nick, password=password)
- muc.join_groupchat(self, room, nick, password,
- histo_length,
- current_status.message,
- current_status.show)
+ if tab is not None:
+ if password:
+ tab.password = password
+ tab.join()
else:
- tab.own_nick = nick
- tab.users = []
- if tab and tab.joined:
+ tab = self.open_new_room(room, nick, password=password)
+ tab.join()
+
+ if tab.joined:
self.enable_private_tabs(room)
tab.state = "normal"
if tab == self.current_tab():
diff --git a/src/core/core.py b/src/core/core.py
index 38a13416..7b078569 100644
--- a/src/core/core.py
+++ b/src/core/core.py
@@ -1265,6 +1265,7 @@ class Core(object):
new_tab = tabs.MucTab(room, nick, password=password)
self.add_tab(new_tab, focus)
self.refresh_window()
+ return new_tab
def open_new_form(self, form, on_cancel, on_send, **kwargs):
"""
diff --git a/src/tabs/muctab.py b/src/tabs/muctab.py
index 02979f09..979d3ae4 100644
--- a/src/tabs/muctab.py
+++ b/src/tabs/muctab.py
@@ -421,7 +421,23 @@ class MucTab(ChatTab):
self.disconnect()
self.user_win.pos = 0
self.core.disable_private_tabs(self.name)
- self.core.command_join('"%s/%s"' % (self.name, self.own_nick))
+ self.join()
+
+ def join(self):
+ """
+ Join the room
+ """
+ status = self.core.get_status()
+ if self.last_connection:
+ delta = datetime.now() - self.last_connection
+ seconds = delta.seconds + delta.days * 24 * 3600
+ else:
+ seconds = 0
+ muc.join_groupchat(self.core, self.name, self.own_nick,
+ self.password,
+ status=status.message,
+ show=status.show,
+ seconds=seconds)
@command_args_parser.quoted(0, 1, [''])
def command_recolor(self, args):