# HG changeset patch # User Mikael Berthe # Date 1404645846 -7200 # Node ID f063e36425a25f75655f0bbf90d9c17521cb76ca # Parent 0bfc4bfc127c6ac0b2ef22df38f1b7047c3b0caa Use bookmarked password (if any) when using "/room join" (The password was only used when auto-joining.) diff -r 0bfc4bfc127c -r f063e36425a2 mcabber/mcabber/commands.c --- a/mcabber/mcabber/commands.c Sun Jul 06 13:12:10 2014 +0200 +++ b/mcabber/mcabber/commands.c Sun Jul 06 13:24:06 2014 +0200 @@ -2608,6 +2608,12 @@ pass_utf8 = to_utf8(pass); + if (!pass) { + const char *roompass = xmpp_get_bookmark_password(roomname); + if (roompass) + pass_utf8 = g_strdup(roompass); + } + xmpp_room_join(roomname, nick, pass_utf8); scr_LogPrint(LPRINT_LOGNORM, "Sent a join request to <%s>...", roomname); diff -r 0bfc4bfc127c -r f063e36425a2 mcabber/mcabber/xmpp.c --- a/mcabber/mcabber/xmpp.c Sun Jul 06 13:12:10 2014 +0200 +++ b/mcabber/mcabber/xmpp.c Sun Jul 06 13:24:06 2014 +0200 @@ -2243,6 +2243,27 @@ return NULL; } +// xmpp_get_bookmark_password(roomjid) +// Return the room password if it is present in a bookmark. +const char *xmpp_get_bookmark_password(const char *bjid) +{ + LmMessageNode *x; + + if (!bookmarks || !bjid) + return NULL; + + // Walk through the storage bookmark tags + for (x = bookmarks->children ; x; x = x->next) { + // If the node is a conference item, check the jid. + if (x->name && !strcmp(x->name, "conference")) { + const char *fjid = lm_message_node_get_attribute(x, "jid"); + if (fjid && !strcasecmp(bjid, fjid)) + return lm_message_node_get_child_value(x, "password"); + } + } + return NULL; +} + int xmpp_get_bookmark_autojoin(const char *bjid) { LmMessageNode *x; diff -r 0bfc4bfc127c -r f063e36425a2 mcabber/mcabber/xmpp.h --- a/mcabber/mcabber/xmpp.h Sun Jul 06 13:12:10 2014 +0200 +++ b/mcabber/mcabber/xmpp.h Sun Jul 06 13:24:06 2014 +0200 @@ -80,6 +80,7 @@ void xmpp_set_storage_rosternotes(const char *barejid, const char *note); guint xmpp_is_bookmarked(const char *bjid); const char *xmpp_get_bookmark_nick(const char *bjid); +const char *xmpp_get_bookmark_password(const char *bjid); int xmpp_get_bookmark_autojoin(const char *bjid); void xmpp_request(const char *fjid, enum iqreq_type reqtype);