mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added debugging to presence and iq handlers
This commit is contained in:
parent
d327a0dd5a
commit
0b740bb355
@ -269,9 +269,11 @@ static int
|
||||
_iq_handle_discoinfo_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
void * const userdata)
|
||||
{
|
||||
log_debug("Recieved diso#info response");
|
||||
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
||||
|
||||
if ((id != NULL) && (g_str_has_prefix(id, "disco"))) {
|
||||
log_debug("Response to query: %s", id);
|
||||
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
||||
char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
|
||||
if (node == NULL) {
|
||||
@ -290,7 +292,9 @@ _iq_handle_discoinfo_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
|
||||
char *generated_sha1 = caps_create_sha1_str(query);
|
||||
|
||||
if (g_strcmp0(given_sha1, generated_sha1) != 0) {
|
||||
log_info("Invalid SHA1 recieved for caps.");
|
||||
log_info("Generated sha-1 does not match given:");
|
||||
log_info("Generated : %s", generated_sha1);
|
||||
log_info("Given : %s", given_sha1);
|
||||
FREE_SET_NULL(generated_sha1);
|
||||
g_strfreev(split);
|
||||
|
||||
|
@ -273,6 +273,7 @@ _presence_handler(xmpp_conn_t * const conn,
|
||||
|
||||
// handle regular presence
|
||||
} else {
|
||||
log_debug("Regular presence received from %s", from);
|
||||
char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
|
||||
char *show_str, *status_str;
|
||||
int idle_seconds = stanza_get_idle_time(stanza);
|
||||
@ -338,38 +339,54 @@ _handle_presence_caps(xmpp_stanza_t * const stanza)
|
||||
char *node = NULL;
|
||||
char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
if (stanza_contains_caps(stanza)) {
|
||||
log_debug("Presence contains capabilities.");
|
||||
char *hash_type = stanza_caps_get_hash(stanza);
|
||||
|
||||
// xep-0115
|
||||
if (hash_type != NULL) {
|
||||
log_debug("Hash type: %s", hash_type);
|
||||
|
||||
// supported hash
|
||||
if (strcmp(hash_type, "sha-1") == 0) {
|
||||
log_debug("Hash type supported.");
|
||||
node = stanza_get_caps_str(stanza);
|
||||
caps_key = node;
|
||||
|
||||
|
||||
if (node != NULL) {
|
||||
log_debug("Node string: %s.", node);
|
||||
if (!caps_contains(caps_key)) {
|
||||
log_debug("Capabilities not cached for '%s', sending discovery IQ.", caps_key);
|
||||
xmpp_stanza_t *iq = stanza_create_disco_iq(ctx, "disco", from, node);
|
||||
xmpp_send(conn, iq);
|
||||
xmpp_stanza_release(iq);
|
||||
} else {
|
||||
log_debug("Capabilities already cached, for %s", caps_key);
|
||||
}
|
||||
} else {
|
||||
log_debug("No node string, not sending discovery IQ.");
|
||||
}
|
||||
|
||||
// unsupported hash
|
||||
} else {
|
||||
log_debug("Hash type unsupported.");
|
||||
node = stanza_get_caps_str(stanza);
|
||||
caps_key = from;
|
||||
|
||||
if (node != NULL) {
|
||||
log_debug("Node string: %s.", node);
|
||||
if (!caps_contains(caps_key)) {
|
||||
log_debug("Capabilities not cached for '%s', sending discovery IQ.", caps_key);
|
||||
GString *id = g_string_new("disco_");
|
||||
g_string_append(id, from);
|
||||
xmpp_stanza_t *iq = stanza_create_disco_iq(ctx, id->str, from, node);
|
||||
xmpp_send(conn, iq);
|
||||
xmpp_stanza_release(iq);
|
||||
g_string_free(id, TRUE);
|
||||
} else {
|
||||
log_debug("Capabilities already cached, for %s", caps_key);
|
||||
}
|
||||
} else {
|
||||
log_debug("No node string, not sending discovery IQ.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -377,18 +394,25 @@ _handle_presence_caps(xmpp_stanza_t * const stanza)
|
||||
|
||||
//ignore or handle legacy caps
|
||||
} else {
|
||||
log_debug("No hash type, using legacy capabilities.");
|
||||
node = stanza_get_caps_str(stanza);
|
||||
caps_key = from;
|
||||
|
||||
if (node != NULL) {
|
||||
log_debug("Node string: %s.", node);
|
||||
if (!caps_contains(caps_key)) {
|
||||
log_debug("Capabilities not cached for '%s', sending discovery IQ.", caps_key);
|
||||
GString *id = g_string_new("disco_");
|
||||
g_string_append(id, from);
|
||||
xmpp_stanza_t *iq = stanza_create_disco_iq(ctx, id->str, from, node);
|
||||
xmpp_send(conn, iq);
|
||||
xmpp_stanza_release(iq);
|
||||
g_string_free(id, TRUE);
|
||||
} else {
|
||||
log_debug("Capabilities already cached, for %s", caps_key);
|
||||
}
|
||||
} else {
|
||||
log_debug("No node string, not sending discovery IQ.");
|
||||
}
|
||||
|
||||
return caps_key;
|
||||
@ -439,6 +463,8 @@ _room_presence_handler(const char * const jid, xmpp_stanza_t * const stanza)
|
||||
char *show_str, *status_str;
|
||||
char *caps_key = _handle_presence_caps(stanza);
|
||||
|
||||
log_debug("Room presence received from %s", jid);
|
||||
|
||||
xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_STATUS);
|
||||
if (status != NULL) {
|
||||
status_str = xmpp_stanza_get_text(status);
|
||||
|
Loading…
Reference in New Issue
Block a user