1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added check for caps in stanza

This commit is contained in:
James Booth 2013-01-20 21:01:30 +00:00
parent eeafd62716
commit dfeb884e9b
3 changed files with 36 additions and 12 deletions

View File

@ -1175,13 +1175,17 @@ _room_presence_handler(const char * const jid, xmpp_stanza_t * const stanza)
} else {
char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
char *show_str, *status_str;
char *caps_str = stanza_get_caps_str(stanza);
char *caps_str = NULL;
if (caps_str != NULL) {
if (!caps_contains(caps_str)) {
xmpp_stanza_t *iq = stanza_create_disco_iq(jabber_conn.ctx, jid, caps_str);
xmpp_send(jabber_conn.conn, iq);
xmpp_stanza_release(iq);
if (stanza_contains_caps(stanza)) {
caps_str = stanza_get_caps_str(stanza);
if (caps_str != NULL) {
if (!caps_contains(caps_str)) {
xmpp_stanza_t *iq = stanza_create_disco_iq(jabber_conn.ctx, jid, caps_str);
xmpp_send(jabber_conn.conn, iq);
xmpp_stanza_release(iq);
}
}
}
@ -1265,13 +1269,16 @@ _presence_handler(xmpp_conn_t * const conn,
g_date_time_unref(now);
}
char *caps_str = stanza_get_caps_str(stanza);
char *caps_str = NULL;
if (stanza_contains_caps(stanza)) {
caps_str = stanza_get_caps_str(stanza);
if (caps_str != NULL) {
if (!caps_contains(caps_str)) {
xmpp_stanza_t *iq = stanza_create_disco_iq(jabber_conn.ctx, from, caps_str);
xmpp_send(jabber_conn.conn, iq);
xmpp_stanza_release(iq);
if (caps_str != NULL) {
if (!caps_contains(caps_str)) {
xmpp_stanza_t *iq = stanza_create_disco_iq(jabber_conn.ctx, from, caps_str);
xmpp_send(jabber_conn.conn, iq);
xmpp_stanza_release(iq);
}
}
}

View File

@ -415,6 +415,22 @@ stanza_get_idle_time(xmpp_stanza_t * const stanza)
}
}
gboolean
stanza_contains_caps(xmpp_stanza_t * const stanza)
{
xmpp_stanza_t *caps = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_C);
if (caps == NULL) {
return FALSE;
}
if (strcmp(xmpp_stanza_get_ns(caps), STANZA_NS_CAPS) != 0) {
return FALSE;
}
return TRUE;
}
char *
stanza_get_caps_str(xmpp_stanza_t * const stanza)
{

View File

@ -138,6 +138,7 @@ char * stanza_get_new_nick(xmpp_stanza_t * const stanza);
int stanza_get_idle_time(xmpp_stanza_t * const stanza);
char * stanza_get_caps_str(xmpp_stanza_t * const stanza);
gboolean stanza_contains_caps(xmpp_stanza_t * const stanza);
DataForm * stanza_get_form(xmpp_stanza_t * const stanza);