about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/bookmark.c35
-rw-r--r--src/xmpp/stanza.h2
-rw-r--r--src/xmpp/xmpp.h1
3 files changed, 37 insertions, 1 deletions
diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c
index e546ef18..a4ca6309 100644
--- a/src/xmpp/bookmark.c
+++ b/src/xmpp/bookmark.c
@@ -301,11 +301,23 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
         }
 
         const char *autojoin = xmpp_stanza_get_attribute(child, "autojoin");
-        gboolean autojoin_val = FALSE;;
+        gboolean autojoin_val = FALSE;
         if (autojoin && (strcmp(autojoin, "1") == 0 || strcmp(autojoin, "true") == 0)) {
             autojoin_val = TRUE;
         }
 
+        // we save minimize, which is not standard, so that we don't remove it if it was set by gajim
+        int minimize = 0;
+        xmpp_stanza_t *minimize_st = stanza_get_child_by_name_and_ns(child, STANZA_NAME_MINIMIZE, STANZA_NS_EXT_GAJIM_BOOKMARKS);
+        if (minimize_st) {
+            char *min_str = xmpp_stanza_get_text(minimize_st);
+            if (strcmp(min_str, "true") == 0) {
+                minimize = 1;
+            } else if (strcmp(min_str, "false") == 0) {
+                minimize = 2;
+            }
+        }
+
         autocomplete_add(bookmark_ac, barejid);
         Bookmark *bookmark = malloc(sizeof(Bookmark));
         bookmark->barejid = strdup(barejid);
@@ -313,6 +325,7 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
         bookmark->password = password;
         bookmark->name = room_name ? strdup(room_name) : NULL;
         bookmark->autojoin = autojoin_val;
+        bookmark->ext_gajim_minimize = minimize;
         g_hash_table_insert(bookmarks, strdup(barejid), bookmark);
 
         if (autojoin_val) {
@@ -410,6 +423,26 @@ _send_bookmarks(void)
             xmpp_stanza_release(password_st);
         }
 
+        if (bookmark->ext_gajim_minimize == 1 ||
+                bookmark->ext_gajim_minimize == 2) {
+            xmpp_stanza_t *minimize_st = xmpp_stanza_new(ctx);
+            xmpp_stanza_set_name(minimize_st, STANZA_NAME_MINIMIZE);
+            xmpp_stanza_set_ns(minimize_st, STANZA_NS_EXT_GAJIM_BOOKMARKS);
+
+            xmpp_stanza_t *minimize_text = xmpp_stanza_new(ctx);
+            if (bookmark->ext_gajim_minimize == 1) {
+                xmpp_stanza_set_text(minimize_text, "true");
+            } else {
+                xmpp_stanza_set_text(minimize_text, "false");
+            }
+
+            xmpp_stanza_add_child(minimize_st, minimize_text);
+            xmpp_stanza_add_child(conference, minimize_st);
+
+            xmpp_stanza_release(minimize_text);
+            xmpp_stanza_release(minimize_st);
+        }
+
         xmpp_stanza_add_child(storage, conference);
         xmpp_stanza_release(conference);
 
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index 80bebba5..b20af1cd 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -104,6 +104,7 @@
 #define STANZA_NAME_COMMAND "command"
 #define STANZA_NAME_CONFIGURE "configure"
 #define STANZA_NAME_ORIGIN_ID "origin-id"
+#define STANZA_NAME_MINIMIZE "minimize"
 
 // error conditions
 #define STANZA_NAME_BAD_REQUEST "bad-request"
@@ -203,6 +204,7 @@
 #define STANZA_NS_USER_AVATAR_METADATA "urn:xmpp:avatar:metadata"
 #define STANZA_NS_LAST_MESSAGE_CORRECTION "urn:xmpp:message-correct:0"
 #define STANZA_NS_MAM2 "urn:xmpp:mam:2"
+#define STANZA_NS_EXT_GAJIM_BOOKMARKS "xmpp:gajim.org/bookmarks"
 
 #define STANZA_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo"
 
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 9254ac6b..235df25d 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -95,6 +95,7 @@ typedef struct bookmark_t {
     char *password;
     char *name;
     gboolean autojoin;
+    int ext_gajim_minimize; //0 - non existant, 1 - true, 2 - false
 } Bookmark;
 
 typedef struct disco_identity_t {