mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -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");
|
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)) {
|
if (autojoin && (strcmp(autojoin, "1") == 0 || strcmp(autojoin, "true") == 0)) {
|
||||||
autojoin_val = TRUE;
|
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);
|
autocomplete_add(bookmark_ac, barejid);
|
||||||
Bookmark *bookmark = malloc(sizeof(Bookmark));
|
Bookmark *bookmark = malloc(sizeof(Bookmark));
|
||||||
bookmark->barejid = strdup(barejid);
|
bookmark->barejid = strdup(barejid);
|
||||||
@ -313,6 +325,7 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
|
|||||||
bookmark->password = password;
|
bookmark->password = password;
|
||||||
bookmark->name = room_name ? strdup(room_name) : NULL;
|
bookmark->name = room_name ? strdup(room_name) : NULL;
|
||||||
bookmark->autojoin = autojoin_val;
|
bookmark->autojoin = autojoin_val;
|
||||||
|
bookmark->ext_gajim_minimize = minimize;
|
||||||
g_hash_table_insert(bookmarks, strdup(barejid), bookmark);
|
g_hash_table_insert(bookmarks, strdup(barejid), bookmark);
|
||||||
|
|
||||||
if (autojoin_val) {
|
if (autojoin_val) {
|
||||||
@ -410,6 +423,26 @@ _send_bookmarks(void)
|
|||||||
xmpp_stanza_release(password_st);
|
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_add_child(storage, conference);
|
||||||
xmpp_stanza_release(conference);
|
xmpp_stanza_release(conference);
|
||||||
|
|
||||||
|
@ -104,6 +104,7 @@
|
|||||||
#define STANZA_NAME_COMMAND "command"
|
#define STANZA_NAME_COMMAND "command"
|
||||||
#define STANZA_NAME_CONFIGURE "configure"
|
#define STANZA_NAME_CONFIGURE "configure"
|
||||||
#define STANZA_NAME_ORIGIN_ID "origin-id"
|
#define STANZA_NAME_ORIGIN_ID "origin-id"
|
||||||
|
#define STANZA_NAME_MINIMIZE "minimize"
|
||||||
|
|
||||||
// error conditions
|
// error conditions
|
||||||
#define STANZA_NAME_BAD_REQUEST "bad-request"
|
#define STANZA_NAME_BAD_REQUEST "bad-request"
|
||||||
@ -203,6 +204,7 @@
|
|||||||
#define STANZA_NS_USER_AVATAR_METADATA "urn:xmpp:avatar:metadata"
|
#define STANZA_NS_USER_AVATAR_METADATA "urn:xmpp:avatar:metadata"
|
||||||
#define STANZA_NS_LAST_MESSAGE_CORRECTION "urn:xmpp:message-correct:0"
|
#define STANZA_NS_LAST_MESSAGE_CORRECTION "urn:xmpp:message-correct:0"
|
||||||
#define STANZA_NS_MAM2 "urn:xmpp:mam:2"
|
#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"
|
#define STANZA_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo"
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ typedef struct bookmark_t {
|
|||||||
char *password;
|
char *password;
|
||||||
char *name;
|
char *name;
|
||||||
gboolean autojoin;
|
gboolean autojoin;
|
||||||
|
int ext_gajim_minimize; //0 - non existant, 1 - true, 2 - false
|
||||||
} Bookmark;
|
} Bookmark;
|
||||||
|
|
||||||
typedef struct disco_identity_t {
|
typedef struct disco_identity_t {
|
||||||
|
Loading…
Reference in New Issue
Block a user