From e78ed92ba36829b89007fe390e8b19b2b59514e3 Mon Sep 17 00:00:00 2001
From: mathieui <mathieui@mathieui.net>
Date: Tue, 14 Apr 2015 01:34:24 +0200
Subject: Fix #2714 (make bare /bookmark use the current room password if there
 is one)

---
 src/core/commands.py | 6 +++++-
 src/core/core.py     | 4 ++--
 src/core/handlers.py | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

(limited to 'src/core')

diff --git a/src/core/commands.py b/src/core/commands.py
index 338590f1..e0e426b2 100644
--- a/src/core/commands.py
+++ b/src/core/commands.py
@@ -388,13 +388,15 @@ def command_join(self, args, histo_length=None):
             seconds = int(seconds)
         else:
             seconds = 0
+        if password:
+            tab.password = password
         muc.join_groupchat(self, room, nick, password,
                            histo_length,
                            current_status.message,
                            current_status.show,
                            seconds=seconds)
     if not tab:
-        self.open_new_room(room, nick)
+        self.open_new_room(room, nick, password=password)
         muc.join_groupchat(self, room, nick, password,
                            histo_length,
                            current_status.message,
@@ -448,6 +450,8 @@ def _add_bookmark(self, jid, autojoin, password, method):
         roomname = tab.name
         if tab.joined and tab.own_nick != self.own_nick:
             nick = tab.own_nick
+        if password is None and tab.password is not None:
+            password = tab.password
     elif jid == '*':
         return _add_wildcard_bookmarks(self, method)
     else:
diff --git a/src/core/core.py b/src/core/core.py
index dc4439fd..e5a6a970 100644
--- a/src/core/core.py
+++ b/src/core/core.py
@@ -1242,11 +1242,11 @@ class Core(object):
         tab.privates.append(new_tab)
         return new_tab
 
-    def open_new_room(self, room, nick, focus=True):
+    def open_new_room(self, room, nick, *, password=None, focus=True):
         """
         Open a new tab.MucTab containing a muc Room, using the specified nick
         """
-        new_tab = tabs.MucTab(room, nick)
+        new_tab = tabs.MucTab(room, nick, password=password)
         self.add_tab(new_tab, focus)
         self.refresh_window()
 
diff --git a/src/core/handlers.py b/src/core/handlers.py
index c7b91bfb..d6bb15c1 100644
--- a/src/core/handlers.py
+++ b/src/core/handlers.py
@@ -54,7 +54,7 @@ def _join_initial_rooms(self, bookmarks):
         tab = self.get_tab_by_name(bm.jid, tabs.MucTab)
         nick = bm.nick if bm.nick else self.own_nick
         if not tab:
-            self.open_new_room(bm.jid, nick, False)
+            self.open_new_room(bm.jid, nick, focus=False)
         self.initial_joins.append(bm.jid)
         histo_length = config.get('muc_history_length')
         if histo_length == -1:
-- 
cgit v1.2.3