mcabber/mcabber/xmpp.c
changeset 2138 f063e36425a2
parent 2137 0bfc4bfc127c
child 2141 e702073612de
--- 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;