diff mcabber/src/jabglue.c @ 1363:32077249de77

Warn if a MUC room without bookmark is renamed
author Mikael Berthe <mikael@lilotux.net>
date Sun, 11 Nov 2007 18:49:43 +0100
parents 9716cf8a0726
children c7e709719c43
line wrap: on
line diff
--- a/mcabber/src/jabglue.c	Sun Nov 11 16:07:32 2007 +0100
+++ b/mcabber/src/jabglue.c	Sun Nov 11 18:49:43 2007 +0100
@@ -1353,6 +1353,31 @@
   jb_reset_keepalive();
 }
 
+//  jb_is_bookmarked()
+// Return TRUE if there's a bookmark for the given jid.
+guint jb_is_bookmarked(const char *bjid)
+{
+  xmlnode x;
+
+  if (!bookmarks)
+    return FALSE;
+
+  // Walk through the storage bookmark tags
+  x = xmlnode_get_firstchild(bookmarks);
+  for ( ; x; x = xmlnode_get_nextsibling(x)) {
+    const char *fjid;
+    const char *p;
+    p = xmlnode_get_name(x);
+    // If the node is a conference item, check the jid.
+    if (p && !strcmp(p, "conference")) {
+      fjid = xmlnode_get_attrib(x, "jid");
+      if (fjid && !strcasecmp(bjid, fjid))
+        return TRUE;
+    }
+  }
+  return FALSE;
+}
+
 //  jb_get_all_storage_bookmarks()
 // Return a GSList with all storage bookmarks.
 // The caller should g_free the list (not the MUC jids).