diff options
-rw-r--r-- | src/command/cmd_defs.c | 2 | ||||
-rw-r--r-- | src/xmpp/iq.c | 7 | ||||
-rw-r--r-- | src/xmpp/message.c | 45 | ||||
-rw-r--r-- | src/xmpp/ox.c | 13 | ||||
-rw-r--r-- | src/xmpp/presence.c | 2 |
5 files changed, 56 insertions, 13 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 599262c1..57d90226 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2722,7 +2722,7 @@ static struct cmd_t command_defs[] = { CMD_DESC( "Set your mood (XEP-0107).") CMD_ARGS( - { "set <mood> <", "Set user mood to <mood> with an optional [text]. Use /mood set <tab> to toggle through predfined moods." }, + { "set <mood> [text]", "Set user mood to <mood> with an optional [text]. Use /mood set <tab> to toggle through predfined moods." }, { "clear", "Clear your user mood." }) CMD_EXAMPLES( "/mood set happy \"So happy to use Profanity!\"", diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index c97fcbad..8d40a86f 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -892,13 +892,6 @@ _caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata) log_debug("Capabilities not cached: %s, storing", given_sha1); EntityCapabilities* capabilities = stanza_create_caps_from_query_element(query); - // Update window name - ProfMucWin* win = wins_get_muc(from); - if (win != NULL) { - free(win->room_name); - win->room_name = strdup(capabilities->identity->name); - } - caps_add_by_ver(given_sha1, capabilities); caps_destroy(capabilities); } diff --git a/src/xmpp/message.c b/src/xmpp/message.c index dc3bc14f..be7ceccf 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -59,6 +59,7 @@ #include "xmpp/connection.h" #include "xmpp/xmpp.h" #include "xmpp/form.h" +#include "xmpp/iq.h" #ifdef HAVE_OMEMO #include "xmpp/omemo.h" @@ -1006,6 +1007,28 @@ _handle_captcha(xmpp_stanza_t* const stanza) xmpp_free(ctx, message); } +// Handle changes to muc configuration +static int +_room_config_handler(xmpp_stanza_t* const stanza, void* const userdata) +{ + const char* from = xmpp_stanza_get_from(stanza); + xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); + EntityCapabilities* capabilities = stanza_create_caps_from_query_element(query); + + // Update window name + ProfMucWin* win = wins_get_muc(from); + if (win != NULL) { + free(win->room_name); + win->room_name = strdup(capabilities->identity->name); + + // Update features + muc_set_features(from, capabilities->features); + } + caps_destroy(capabilities); + + return 0; +} + static void _handle_groupchat(xmpp_stanza_t* const stanza) { @@ -1037,6 +1060,28 @@ _handle_groupchat(xmpp_stanza_t* const stanza) char* broadcast; broadcast = xmpp_message_get_body(stanza); if (!broadcast) { + xmpp_stanza_t* x = xmpp_stanza_get_child_by_name(stanza, "x"); + + if (x) { + xmpp_stanza_t* status = xmpp_stanza_get_child_by_name(x, "status"); + + if (status) { + const char* code = xmpp_stanza_get_attribute(status, "code"); + + if (code) { + // If configuration change notification send disco info to get updated info of the muc + char* disqo_info_id = connection_create_stanza_id(); + xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, disqo_info_id, room_jid, NULL); + iq_id_handler_add(disqo_info_id, _room_config_handler, NULL, NULL); + free(disqo_info_id); + iq_send_stanza(iq); + xmpp_stanza_release(iq); + + return; + } + } + } + jid_destroy(from_jid); return; } diff --git a/src/xmpp/ox.c b/src/xmpp/ox.c index da05af89..7f0304f5 100644 --- a/src/xmpp/ox.c +++ b/src/xmpp/ox.c @@ -325,11 +325,14 @@ _ox_metadata_result(xmpp_stanza_t* const stanza, void* const userdata) while (pubkeymetadata) { const char* fingerprint = xmpp_stanza_get_attribute(pubkeymetadata, STANZA_ATTR_V4_FINGERPRINT); - if (strlen(fingerprint) == KEYID_LENGTH) { - cons_show(fingerprint); - } else { - cons_show("OX: Wrong char size of public key"); - log_error("[OX] Wrong chat size of public key %s", fingerprint); + + if (fingerprint) { + if (strlen(fingerprint) == KEYID_LENGTH) { + cons_show(fingerprint); + } else { + cons_show("OX: Wrong char size of public key"); + log_error("[OX] Wrong chat size of public key %s", fingerprint); + } } pubkeymetadata = xmpp_stanza_get_next(pubkeymetadata); } diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index b5cb1803..17e30d75 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -752,6 +752,8 @@ _muc_user_self_handler(xmpp_stanza_t* stanza) log_warning("presence: jid without resource"); return; } + + muc_nick_change_complete(room, nick); char* reason = stanza_get_reason(stanza); char* show_str = stanza_get_show(stanza, "online"); char* status_str = stanza_get_status(stanza, NULL); |