diff options
author | James Booth <boothj5@gmail.com> | 2016-08-20 20:20:38 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-08-20 20:20:38 +0100 |
commit | 27263508c769474f26010ba638872a027d229020 (patch) | |
tree | a95709ab582a116cc3f2363c4a7e7dab4bb08ebe /src/xmpp/iq.c | |
parent | d61abd35776e2dd448ce9a0cd6576d6ef2c0336e (diff) | |
download | profani-tty-27263508c769474f26010ba638872a027d229020.tar.gz |
Use libstrophe xmpp_iq_new convenience function
Diffstat (limited to 'src/xmpp/iq.c')
-rw-r--r-- | src/xmpp/iq.c | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 3863e209..260c062e 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -1158,15 +1158,9 @@ _ping_get_handler(xmpp_stanza_t *const stanza) return; } - xmpp_stanza_t *pong = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(pong, STANZA_NAME_IQ); + xmpp_stanza_t *pong = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, id); xmpp_stanza_set_to(pong, from); xmpp_stanza_set_from(pong, to); - xmpp_stanza_set_type(pong, STANZA_TYPE_RESULT); - - if (id) { - xmpp_stanza_set_id(pong, id); - } iq_send_stanza(pong); xmpp_stanza_release(pong); @@ -1186,13 +1180,8 @@ _version_get_handler(xmpp_stanza_t *const stanza) } if (from) { - xmpp_stanza_t *response = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(response, STANZA_NAME_IQ); - if (id) { - xmpp_stanza_set_id(response, id); - } + xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, id); xmpp_stanza_set_to(response, from); - xmpp_stanza_set_type(response, STANZA_TYPE_RESULT); xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); @@ -1251,11 +1240,9 @@ _disco_items_get_handler(xmpp_stanza_t *const stanza) } if (from) { - xmpp_stanza_t *response = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(response, STANZA_NAME_IQ); - xmpp_stanza_set_id(response, xmpp_stanza_get_id(stanza)); + xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza)); xmpp_stanza_set_to(response, from); - xmpp_stanza_set_type(response, STANZA_TYPE_RESULT); + xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_ns(query, XMPP_NS_DISCO_ITEMS); @@ -1282,11 +1269,8 @@ _last_activity_get_handler(xmpp_stanza_t *const stanza) char str[50]; sprintf(str, "%d", idls_secs); - xmpp_stanza_t *response = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(response, STANZA_NAME_IQ); - xmpp_stanza_set_id(response, xmpp_stanza_get_id(stanza)); + xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza)); xmpp_stanza_set_to(response, from); - xmpp_stanza_set_type(response, STANZA_TYPE_RESULT); xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_set_name(query, STANZA_NAME_QUERY); @@ -1300,11 +1284,8 @@ _last_activity_get_handler(xmpp_stanza_t *const stanza) xmpp_stanza_release(response); } else { - xmpp_stanza_t *response = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(response, STANZA_NAME_IQ); - xmpp_stanza_set_id(response, xmpp_stanza_get_id(stanza)); + xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_ERROR, xmpp_stanza_get_id(stanza)); xmpp_stanza_set_to(response, from); - xmpp_stanza_set_type(response, STANZA_TYPE_ERROR); xmpp_stanza_t *error = xmpp_stanza_new(ctx); xmpp_stanza_set_name(error, STANZA_NAME_ERROR); @@ -1344,11 +1325,9 @@ _disco_info_get_handler(xmpp_stanza_t *const stanza) } if (from) { - xmpp_stanza_t *response = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(response, STANZA_NAME_IQ); - xmpp_stanza_set_id(response, xmpp_stanza_get_id(stanza)); + xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza)); xmpp_stanza_set_to(response, from); - xmpp_stanza_set_type(response, STANZA_TYPE_RESULT); + xmpp_stanza_t *query = stanza_create_caps_query_element(ctx); if (node_str) { xmpp_stanza_set_attribute(query, STANZA_ATTR_NODE, node_str); |