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

Moved processing of caps str to stanza.c

This commit is contained in:
James Booth 2013-01-20 13:56:50 +00:00
parent 3386ba3a1e
commit 4ecb69bfab
3 changed files with 20 additions and 34 deletions

View File

@ -1054,21 +1054,7 @@ _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 = NULL;
xmpp_stanza_t *caps = stanza_get_caps(stanza);
if (caps != NULL) {
char *node = xmpp_stanza_get_attribute(caps, STANZA_ATTR_NODE);
char *ver = xmpp_stanza_get_attribute(caps, STANZA_ATTR_VER);
if ((node != NULL) && (ver != NULL)) {
GString *caps_gstr = g_string_new(node);
g_string_append(caps_gstr, "#");
g_string_append(caps_gstr, ver);
caps_str = caps_gstr->str;
g_string_free(caps_gstr, FALSE);
}
}
char *caps_str = stanza_get_caps_str(stanza);
if (caps_str != NULL) {
if (!caps_contains(caps_str)) {
@ -1158,20 +1144,7 @@ _presence_handler(xmpp_conn_t * const conn,
g_date_time_unref(now);
}
char *caps_str = NULL;
xmpp_stanza_t *caps = stanza_get_caps(stanza);
if (caps != NULL) {
char *node = xmpp_stanza_get_attribute(caps, STANZA_ATTR_NODE);
char *ver = xmpp_stanza_get_attribute(caps, STANZA_ATTR_VER);
if ((node != NULL) && (ver != NULL)) {
GString *caps_gstr = g_string_new(node);
g_string_append(caps_gstr, "#");
g_string_append(caps_gstr, ver);
caps_str = caps_gstr->str;
g_string_free(caps_gstr, FALSE);
}
}
char *caps_str = stanza_get_caps_str(stanza);
if (caps_str != NULL) {
if (!caps_contains(caps_str)) {

View File

@ -413,8 +413,8 @@ stanza_get_idle_time(xmpp_stanza_t * const stanza)
}
}
xmpp_stanza_t *
stanza_get_caps(xmpp_stanza_t * const stanza)
char *
stanza_get_caps_str(xmpp_stanza_t * const stanza)
{
xmpp_stanza_t *caps = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_C);
@ -426,5 +426,18 @@ stanza_get_caps(xmpp_stanza_t * const stanza)
return NULL;
}
return caps;
char *node = xmpp_stanza_get_attribute(caps, STANZA_ATTR_NODE);
char *ver = xmpp_stanza_get_attribute(caps, STANZA_ATTR_VER);
if ((node == NULL) || (ver == NULL)) {
return NULL;
}
GString *caps_gstr = g_string_new(node);
g_string_append(caps_gstr, "#");
g_string_append(caps_gstr, ver);
char *caps_str = caps_gstr->str;
g_string_free(caps_gstr, FALSE);
return caps_str;
}

View File

@ -121,9 +121,9 @@ gboolean stanza_is_muc_self_presence(xmpp_stanza_t * const stanza,
const char * const self_jid);
gboolean stanza_is_room_nick_change(xmpp_stanza_t * const stanza);
char* stanza_get_new_nick(xmpp_stanza_t * const stanza);
char * stanza_get_new_nick(xmpp_stanza_t * const stanza);
int stanza_get_idle_time(xmpp_stanza_t * const stanza);
xmpp_stanza_t * stanza_get_caps(xmpp_stanza_t * const stanza);
char * stanza_get_caps_str(xmpp_stanza_t * const stanza);
#endif