summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-12-20 18:50:34 +0100
committermathieui <mathieui@mathieui.net>2012-12-20 18:50:34 +0100
commit2a980838a9ccc576fe1699f047e00b783ccf7e7b (patch)
treed6fb04884173e63a6a3905343e9271602e069746
parent519f3afe06a8635b7471850a1c330604a14eb95e (diff)
downloadpoezio-2a980838a9ccc576fe1699f047e00b783ccf7e7b.tar.gz
poezio-2a980838a9ccc576fe1699f047e00b783ccf7e7b.tar.bz2
poezio-2a980838a9ccc576fe1699f047e00b783ccf7e7b.tar.xz
poezio-2a980838a9ccc576fe1699f047e00b783ccf7e7b.zip
Fix #2186 (muc password in the config file)
Also use the passwords on start, and automatically use a password with /join if there is one.
-rw-r--r--doc/en/configure.txt4
-rw-r--r--src/bookmark.py5
-rw-r--r--src/core.py12
3 files changed, 17 insertions, 4 deletions
diff --git a/doc/en/configure.txt b/doc/en/configure.txt
index 53b4cdb8..00a6a3c9 100644
--- a/doc/en/configure.txt
+++ b/doc/en/configure.txt
@@ -531,6 +531,10 @@ foo = true
loaded from the log files. 0 or a negative value here disable that option.
No value makes poezio fall back to the global value.
+*password:: [empty]
+
+ The password needed to join the room.
+
*private_auto_response*:: "Not in private, please."
The message you want to be sent when someone tries to message you.
diff --git a/src/bookmark.py b/src/bookmark.py
index 8d84022d..c9659cd2 100644
--- a/src/bookmark.py
+++ b/src/bookmark.py
@@ -73,6 +73,8 @@ class Bookmark(object):
if self.nick:
local += '/%s' % self.nick
local += ':'
+ if self.password:
+ config.set_and_save('password', self.password, section=self.jid)
return local
def parse_from_element(el, method=None):
@@ -211,6 +213,7 @@ def get_local():
nick = jid.resource
else:
nick = None
- b = Bookmark(jid.bare, autojoin=True, nick=nick, method='local')
+ passwd = config.get_by_tabname('password', '', jid.bare, fallback=False) or None
+ b = Bookmark(jid.bare, autojoin=True, nick=nick, password=passwd, method='local')
if not get_by_jid(b.jid):
bookmarks.append(b)
diff --git a/src/core.py b/src/core.py
index b0d8d832..93a52758 100644
--- a/src/core.py
+++ b/src/core.py
@@ -165,7 +165,7 @@ class Core(object):
'move_tab': (self.command_move_tab, _("Usage: /move_tab <source> <destination>\nMove Tab: Insert the <source> tab at the position of <destination>. This will make the following tabs shift in some cases (refer to the documentation). A tab can be designated by its number or by the beginning of its address."), self.completion_move_tab),
'show': (self.command_status, _('Usage: /show <availability> [status message]\nShow: Sets your availability and (optionally) your status message. The <availability> argument is one of \"available, chat, away, afk, dnd, busy, xa\" and the optional [status message] argument will be your status message.'), self.completion_status),
'status': (self.command_status, _('Usage: /status <availability> [status message]\nStatus: Sets your availability and (optionally) your status message. The <availability> argument is one of \"available, chat, away, afk, dnd, busy, xa\" and the optional [status message] argument will be your status message.'), self.completion_status),
- 'bookmark_local': (self.command_bookmark_local, _("Usage: /bookmark_local [roomname][/nick]\nBookmark Local: Bookmark locally the specified room (you will then auto-join it on each poezio start). This commands uses almost the same syntaxe as /join. Type /help join for syntaxe examples. Note that when typing \"/bookmark\" on its own, the room will be bookmarked with the nickname you\'re currently using in this room (instead of default_nick)"), self.completion_bookmark_local),
+ 'bookmark_local': (self.command_bookmark_local, _("Usage: /bookmark_local [roomname][/nick] [password]\nBookmark Local: Bookmark locally the specified room (you will then auto-join it on each poezio start). This commands uses almost the same syntaxe as /join. Type /help join for syntaxe examples. Note that when typing \"/bookmark\" on its own, the room will be bookmarked with the nickname you\'re currently using in this room (instead of default_nick)"), self.completion_bookmark_local),
'bookmark': (self.command_bookmark, _("Usage: /bookmark [roomname][/nick] [autojoin] [password]\nBookmark: Bookmark online the specified room (you will then auto-join it on each poezio start if autojoin is specified and is 'true'). This commands uses almost the same syntaxe as /join. Type /help join for syntaxe examples. Note that when typing \"/bookmark\" on its own, the room will be bookmarked with the nickname you\'re currently using in this room (instead of default_nick)"), self.completion_bookmark),
'set': (self.command_set, _("Usage: /set [plugin|][section] <option> [value]\nSet: Set the value of an option in your configuration file. You can, for example, change your default nickname by doing `/set default_nick toto` or your resource with `/set resource blabla`. You can also set options in specific sections with `/set bindings M-i ^i` or in specific plugin with `/set mpd_client| host 127.0.0.1`. `toggle` can be used as a special value to toggle a boolean option."), self.completion_set),
'theme': (self.command_theme, _('Usage: /theme [theme_name]\nTheme: Reload the theme defined in the config file. If theme_name is provided, set that theme before reloading it.'), self.completion_theme),
@@ -1695,6 +1695,8 @@ class Core(object):
histo_length= None
if histo_length is not None:
histo_length= str(histo_length)
+ if password is None: # try to use a saved password
+ password = config.get_by_tabname('password', None, room, fallback=False)
if tab and not tab.joined:
delta = datetime.now() - tab.last_connection
seconds = delta.seconds + delta.days * 24 * 3600 if tab.last_connection is not None else 0
@@ -1757,10 +1759,11 @@ class Core(object):
def command_bookmark_local(self, arg=''):
"""
- /bookmark_local [room][/nick]
+ /bookmark_local [room][/nick] [password]
"""
args = common.shell_split(arg)
nick = None
+ password = None
if len(args) == 0 and not isinstance(self.current_tab(), tabs.MucTab):
return
if len(args) == 0:
@@ -1790,6 +1793,8 @@ class Core(object):
if not isinstance(self.current_tab(), tabs.MucTab):
return
roomname = self.current_tab().get_name()
+ if len(args) > 1:
+ password = args[1]
bm = bookmark.get_by_jid(roomname)
if not bm:
@@ -1801,6 +1806,7 @@ class Core(object):
if nick:
bm.nick = nick
bm.autojoin = True
+ bm.password = password
bm.method = "local"
bookmark.save_local()
self.information(_('Your local bookmarks are now: %s') %
@@ -2778,7 +2784,7 @@ class Core(object):
histo_length= None
if histo_length is not None:
histo_length= str(histo_length)
- muc.join_groupchat(self.xmpp, bm.jid, nick, None, histo_length)
+ muc.join_groupchat(self.xmpp, bm.jid, nick, bm.password, histo_length)
### Other handlers ###