changeset 1379:74b7621537d7

MUC: Store room settings (print_status, auto_whois) in private storage
author Mikael Berthe <mikael@lilotux.net>
date Thu, 29 Nov 2007 20:54:38 +0100
parents 61fc9eddf763
children 605f9e1f9f76
files mcabber/src/commands.c mcabber/src/jab_iq.c mcabber/src/jabglue.c mcabber/src/jabglue.h
diffstat 4 files changed, 40 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/commands.c	Wed Nov 28 22:42:48 2007 +0100
+++ b/mcabber/src/commands.c	Thu Nov 29 20:54:38 2007 +0100
@@ -2590,6 +2590,8 @@
 {
   const char *roomid;
   const char *name = NULL, *nick = NULL;
+  enum room_autowhois autowhois = 0;
+  enum room_printstatus printstatus = 0;
   enum { bm_add = 0, bm_del = 1 } action = 0;
   int autojoin = 0;
 
@@ -2617,9 +2619,12 @@
   if (action == bm_add) {
     name = buddy_getname(bud);
     nick = buddy_getnickname(bud);
+    printstatus = buddy_getprintstatus(bud);
+    autowhois   = buddy_getautowhois(bud);
   }
 
-  jb_set_storage_bookmark(roomid, name, nick, NULL, autojoin);
+  jb_set_storage_bookmark(roomid, name, nick, NULL, autojoin,
+                          printstatus, autowhois);
 }
 
 static void display_all_bookmarks(void)
--- a/mcabber/src/jab_iq.c	Wed Nov 28 22:42:48 2007 +0100
+++ b/mcabber/src/jab_iq.c	Thu Nov 29 20:54:38 2007 +0100
@@ -739,6 +739,7 @@
 static void storage_bookmarks_parse_conference(xmlnode xmldata)
 {
   const char *fjid, *name, *autojoin;
+  const char *pstatus, *awhois;
   char *bjid;
   GSList *room_elt;
 
@@ -747,6 +748,8 @@
     return;
   name = xmlnode_get_attrib(xmldata, "name");
   autojoin = xmlnode_get_attrib(xmldata, "autojoin");
+  awhois = xmlnode_get_attrib(xmldata, "autowhois");
+  pstatus = xmlnode_get_tag_data(xmldata, "print_status");
 
   bjid = jidtodisp(fjid); // Bare jid
 
@@ -766,6 +769,25 @@
     */
   }
 
+  // Set the print_status and auto_whois values
+  if (pstatus) {
+    enum room_printstatus i;
+    for (i = status_none; i <= status_all; i++)
+      if (!strcasecmp(pstatus, strprintstatus[i]))
+        break;
+    if (i <= status_all)
+      buddy_setprintstatus(room_elt->data, i);
+  }
+  if (awhois) {
+    enum room_autowhois i = autowhois_default;
+    if (!strcmp(awhois, "1"))
+      i = autowhois_on;
+    else if (!strcmp(awhois, "0"))
+      i = autowhois_off;
+    if (i != autowhois_default)
+      buddy_setautowhois(room_elt->data, i);
+  }
+
   // Is autojoin set?
   // If it is, we'll look up for more information (nick? password?) and
   // try to join the room.
--- a/mcabber/src/jabglue.c	Wed Nov 28 22:42:48 2007 +0100
+++ b/mcabber/src/jabglue.c	Thu Nov 29 20:54:38 2007 +0100
@@ -1405,11 +1405,14 @@
   return sl_bookmarks;
 }
 
-//  jb_set_storage_bookmark(roomid, name, nick, passwd, autojoin)
+//  jb_set_storage_bookmark(roomid, name, nick, passwd, autojoin,
+//                          printstatus, autowhois)
 // Update the private storage bookmarks: add a conference room.
 // If name is nil, we remove the bookmark.
 void jb_set_storage_bookmark(const char *roomid, const char *name,
-                             const char *nick, const char *passwd, int autojoin)
+                             const char *nick, const char *passwd,
+                             int autojoin, enum room_printstatus pstatus,
+                             enum room_autowhois awhois)
 {
   xmlnode x;
   bool changed = FALSE;
@@ -1456,6 +1459,11 @@
       xmlnode_insert_cdata(xmlnode_insert_tag(x, "nick"), nick, -1);
     if (passwd)
       xmlnode_insert_cdata(xmlnode_insert_tag(x, "password"), passwd, -1);
+    if (pstatus)
+      xmlnode_insert_cdata(xmlnode_insert_tag(x, "print_status"),
+                           strprintstatus[pstatus], -1);
+    if (awhois)
+      xmlnode_put_attrib(x, "autowhois", (awhois == autowhois_on ? "1" : "0"));
     changed = TRUE;
     scr_LogPrint(LPRINT_LOGNORM, "Updating bookmarks...");
   }
--- a/mcabber/src/jabglue.h	Wed Nov 28 22:42:48 2007 +0100
+++ b/mcabber/src/jabglue.h	Thu Nov 29 20:54:38 2007 +0100
@@ -81,7 +81,8 @@
 GSList *jb_get_all_storage_bookmarks(void);
 void jb_set_storage_bookmark(const char *roomid, const char *name,
                              const char *nick, const char *passwd,
-                             int autojoin);
+                             int autojoin, enum room_printstatus pstatus,
+                             enum room_autowhois awhois);
 struct annotation *jb_get_storage_rosternotes(const char *barejid, int silent);
 GSList *jb_get_all_storage_rosternotes(void);
 void jb_set_storage_rosternotes(const char *barejid, const char *note);