about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-01-20 01:29:15 +0000
committerJames Booth <boothj5@gmail.com>2013-01-20 01:29:15 +0000
commit8ff283d44dc38ae10be089412292b738afcdbeb2 (patch)
treee01d683379e05c9663e25dda833ebd5f99877120
parentf967395f0f99a7eba7aa6ea1c006b39b142f56d5 (diff)
downloadprofani-tty-8ff283d44dc38ae10be089412292b738afcdbeb2.tar.gz
Send diso#info request if capabilities not cached
-rw-r--r--src/jabber.c5
-rw-r--r--src/stanza.c21
-rw-r--r--src/stanza.h2
3 files changed, 27 insertions, 1 deletions
diff --git a/src/jabber.c b/src/jabber.c
index d5fb23ce..cab8aaf6 100644
--- a/src/jabber.c
+++ b/src/jabber.c
@@ -1064,6 +1064,7 @@ _presence_handler(xmpp_conn_t * const conn,
 
             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);
@@ -1072,7 +1073,9 @@ _presence_handler(xmpp_conn_t * const conn,
 
         if (caps_str != NULL) {
             if (!caps_contains(caps_str)) {
-                // send iq request for caps info
+                xmpp_stanza_t *iq = stanza_create_disco_iq(jabber_conn.ctx, from, caps_str);
+                xmpp_send(jabber_conn.conn, iq);
+                xmpp_stanza_release(iq);
             }
         }
 
diff --git a/src/stanza.c b/src/stanza.c
index aa75abe3..9ea9df31 100644
--- a/src/stanza.c
+++ b/src/stanza.c
@@ -178,6 +178,27 @@ stanza_create_roster_iq(xmpp_ctx_t *ctx)
     return iq;
 }
 
+xmpp_stanza_t *
+stanza_create_disco_iq(xmpp_ctx_t *ctx, const char * const to,
+    const char * const node)
+{
+    xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
+    xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
+    xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
+    xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, to);
+    xmpp_stanza_set_id(iq, "disco");
+
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
+    xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
+    xmpp_stanza_set_ns(query, XMPP_NS_DISCO_INFO);
+    xmpp_stanza_set_attribute(query, STANZA_ATTR_NODE, node);
+
+    xmpp_stanza_add_child(iq, query);
+    xmpp_stanza_release(query);
+
+    return iq;
+}
+
 gboolean
 stanza_contains_chat_state(xmpp_stanza_t *stanza)
 {
diff --git a/src/stanza.h b/src/stanza.h
index 98383293..c5cec333 100644
--- a/src/stanza.h
+++ b/src/stanza.h
@@ -110,6 +110,8 @@ xmpp_stanza_t* stanza_create_presence(xmpp_ctx_t *ctx, const char * const show,
 
 xmpp_stanza_t* stanza_create_roster_iq(xmpp_ctx_t *ctx);
 xmpp_stanza_t* stanza_create_ping_iq(xmpp_ctx_t *ctx);
+xmpp_stanza_t* stanza_create_disco_iq(xmpp_ctx_t *ctx, const char * const to,
+    const char * const node);
 
 gboolean stanza_contains_chat_state(xmpp_stanza_t *stanza);