diff options
author | James Booth <boothj5@gmail.com> | 2014-09-19 00:49:48 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-09-19 00:49:48 +0100 |
commit | 99c0b3f2cf9feb9dffa998feee97187c5b1ada14 (patch) | |
tree | c078e31f49f60c70dece4d5a5b6cbc8a155a38ec /src/xmpp/stanza.c | |
parent | 93058636ce92c67982386bd6c1c8751afce895f7 (diff) | |
download | profani-tty-99c0b3f2cf9feb9dffa998feee97187c5b1ada14.tar.gz |
wip - refactoring capabilities
Diffstat (limited to 'src/xmpp/stanza.c')
-rw-r--r-- | src/xmpp/stanza.c | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 118bffb7..cca07539 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -973,11 +973,12 @@ 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) { + if (!caps) { return FALSE; } - if (strcmp(xmpp_stanza_get_ns(caps), STANZA_NS_CAPS) != 0) { + char *ns = xmpp_stanza_get_ns(caps); + if (g_strcmp0(ns, STANZA_NS_CAPS) != 0) { return FALSE; } @@ -989,18 +990,50 @@ stanza_caps_get_hash(xmpp_stanza_t * const stanza) { xmpp_stanza_t *caps = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_C); - if (caps == NULL) { + if (!caps) { return NULL; } - if (strcmp(xmpp_stanza_get_ns(caps), STANZA_NS_CAPS) != 0) { + char *ns = xmpp_stanza_get_ns(caps); + if (g_strcmp0(ns, STANZA_NS_CAPS) != 0) { + return NULL; + } + + return xmpp_stanza_get_attribute(caps, STANZA_ATTR_HASH); +} + +char * +stanza_caps_get_node(xmpp_stanza_t * const stanza) +{ + xmpp_stanza_t *caps = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_C); + + if (!caps) { return NULL; } - char *result = xmpp_stanza_get_attribute(caps, STANZA_ATTR_HASH); + char *ns = xmpp_stanza_get_ns(caps); + if (g_strcmp0(ns, STANZA_NS_CAPS) != 0) { + return NULL; + } + + return xmpp_stanza_get_attribute(caps, STANZA_ATTR_NODE); +} - return result; +char * +stanza_get_caps_ver(xmpp_stanza_t * const stanza) +{ + xmpp_stanza_t *caps = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_C); + + if (!caps) { + return NULL; + } + + char *ns = xmpp_stanza_get_ns(caps); + if (g_strcmp0(ns, STANZA_NS_CAPS) != 0) { + return NULL; + } + return xmpp_stanza_get_attribute(caps, STANZA_ATTR_VER); } char * |