mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Preserve Gajims minimize flag in bookmarks
Implement https://github.com/profanity-im/profanity/issues/1326
This commit is contained in:
parent
70db2a4b63
commit
36f2569e53
@ -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);
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user