1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Handle unsupported hash, and legacy caps

This commit is contained in:
James Booth 2013-01-20 23:10:59 +00:00
parent 3d5f04ee80
commit 5c04adde2b

View File

@ -39,6 +39,8 @@
#include "muc.h" #include "muc.h"
#include "stanza.h" #include "stanza.h"
#include "ui.h"
static struct _jabber_conn_t { static struct _jabber_conn_t {
xmpp_log_t *log; xmpp_log_t *log;
xmpp_ctx_t *ctx; xmpp_ctx_t *ctx;
@ -922,7 +924,7 @@ _iq_handler(xmpp_conn_t * const conn,
return _roster_handler(conn, stanza, userdata); return _roster_handler(conn, stanza, userdata);
// handle diso requests // handle diso requests
} else if ((g_strcmp0(id, "disco") == 0) && (g_strcmp0(type, "result") == 0)) { } else if ((g_str_has_prefix(id, "disco")) && (g_strcmp0(type, "result") == 0)) {
return _disco_handler(conn, stanza, userdata); return _disco_handler(conn, stanza, userdata);
// handle iq // handle iq
@ -1075,6 +1077,8 @@ _disco_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
} }
char *caps_key = NULL; char *caps_key = NULL;
// xep-0115
if (g_strcmp0(id, "disco") == 0) { if (g_strcmp0(id, "disco") == 0) {
caps_key = node; caps_key = node;
@ -1087,8 +1091,10 @@ _disco_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
log_info("Invalid SHA1 recieved for caps."); log_info("Invalid SHA1 recieved for caps.");
return 1; return 1;
} }
// non supported hash, or legacy caps
} else { } else {
caps_key = id; caps_key = id + 6;
cons_show(caps_key);
} }
// already cached // already cached
@ -1259,9 +1265,12 @@ _handle_presence_caps(xmpp_stanza_t * const stanza)
if (node != NULL) { if (node != NULL) {
if (!caps_contains(caps_key)) { if (!caps_contains(caps_key)) {
xmpp_stanza_t *iq = stanza_create_disco_iq(jabber_conn.ctx, from, from, node); GString *id = g_string_new("disco_");
g_string_append(id, from);
xmpp_stanza_t *iq = stanza_create_disco_iq(jabber_conn.ctx, id->str, from, node);
xmpp_send(jabber_conn.conn, iq); xmpp_send(jabber_conn.conn, iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
g_string_free(id, TRUE);
} }
} }
} }
@ -1270,7 +1279,21 @@ _handle_presence_caps(xmpp_stanza_t * const stanza)
//ignore or handle legacy caps //ignore or handle legacy caps
} else { } else {
return NULL; node = stanza_get_caps_str(stanza);
caps_key = from;
if (node != NULL) {
if (!caps_contains(caps_key)) {
GString *id = g_string_new("disco_");
g_string_append(id, from);
xmpp_stanza_t *iq = stanza_create_disco_iq(jabber_conn.ctx, id->str, from, node);
xmpp_send(jabber_conn.conn, iq);
xmpp_stanza_release(iq);
g_string_free(id, TRUE);
}
}
return caps_key;
} }
} }
return NULL; return NULL;