changeset 1525:68580b6be895

Display more information in /room bookmark (autojoin, nick...) With this patch /room bookmark adds a '*' prefix when autojoin is set in the bookmark list. It also displays the nick and the room name contained in the bookmarks.
author Mikael Berthe <mikael@lilotux.net>
date Thu, 02 Oct 2008 20:00:11 +0200
parents 935289bf02ea
children eefa0ae248d8
files mcabber/src/commands.c mcabber/src/jabglue.c mcabber/src/jabglue.h
diffstat 3 files changed, 36 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/commands.c	Wed Oct 01 20:36:22 2008 +0200
+++ b/mcabber/src/commands.c	Thu Oct 02 20:00:11 2008 +0200
@@ -2810,6 +2810,7 @@
 {
   GSList *bm, *bmp;
   GString *sbuf;
+  struct bookmark *bm_elt;
 
   bm = jb_get_all_storage_bookmarks();
 
@@ -2822,7 +2823,17 @@
                            0, HBB_PREFIX_INFO, 0);
 
   for (bmp = bm; bmp; bmp = g_slist_next(bmp)) {
-    g_string_printf(sbuf, "<%s>", (char*)bmp->data);
+    bm_elt = bmp->data;
+    g_string_printf(sbuf, "%c <%s>",
+                    (bm_elt->autojoin ? '*' : ' '), bm_elt->roomjid);
+    if (bm_elt->nick)
+      g_string_append_printf(sbuf, " (%s)", bm_elt->nick);
+    if (bm_elt->name)
+      g_string_append_printf(sbuf, " %s", bm_elt->name);
+    g_free(bm_elt->roomjid);
+    g_free(bm_elt->name);
+    g_free(bm_elt->nick);
+    g_free(bm_elt);
     scr_WriteIncomingMessage(NULL, sbuf->str,
                              0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0);
   }
--- a/mcabber/src/jabglue.c	Wed Oct 01 20:36:22 2008 +0200
+++ b/mcabber/src/jabglue.c	Thu Oct 02 20:00:11 2008 +0200
@@ -1428,7 +1428,7 @@
 
 //  jb_get_all_storage_bookmarks()
 // Return a GSList with all storage bookmarks.
-// The caller should g_free the list (not the MUC jids).
+// The caller should g_free the list and its contents.
 GSList *jb_get_all_storage_bookmarks(void)
 {
   xmlnode x;
@@ -1444,10 +1444,23 @@
     const char *p = xmlnode_get_name(x);
     // If the node is a conference item, let's add the note to our list.
     if (p && !strcmp(p, "conference")) {
+      struct bookmark *bm_elt;
+      const char *autojoin, *name, *nick;
       const char *fjid = xmlnode_get_attrib(x, "jid");
       if (!fjid)
         continue;
-      sl_bookmarks = g_slist_append(sl_bookmarks, (char*)fjid);
+      bm_elt = g_new0(struct bookmark, 1);
+      bm_elt->roomjid = g_strdup(fjid);
+      autojoin = xmlnode_get_attrib(x, "autojoin");
+      nick = xmlnode_get_attrib(x, "nick");
+      name = xmlnode_get_attrib(x, "name");
+      if (autojoin && !strcmp(autojoin, "1"))
+        bm_elt->autojoin = 1;
+      if (nick)
+        bm_elt->nick = g_strdup(nick);
+      if (name)
+        bm_elt->name = g_strdup(name);
+      sl_bookmarks = g_slist_append(sl_bookmarks, bm_elt);
     }
   }
   return sl_bookmarks;
--- a/mcabber/src/jabglue.h	Wed Oct 01 20:36:22 2008 +0200
+++ b/mcabber/src/jabglue.h	Thu Oct 02 20:00:11 2008 +0200
@@ -42,6 +42,15 @@
   gchar *text;
 };
 
+struct bookmark {
+  gchar *roomjid;
+  gchar *name;
+  gchar *nick;
+  guint autojoin;
+  /* enum room_printstatus pstatus; */
+  /* enum room_autowhois awhois; */
+};
+
 char *jidtodisp(const char *fjid);
 char *compose_jid(const char *username, const char *servername,
                   const char *resource);