about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-03-24 17:40:46 +0000
committerJames Booth <boothj5@gmail.com>2013-03-24 17:40:46 +0000
commitef7aacc709f34f17a84829cded232e077753870a (patch)
tree4845900d1130fee7d2f5a151122cef9be87890e3 /src/xmpp
parent53eec32f2f168bab356d49ffb62cde4e893803d0 (diff)
downloadprofani-tty-ef7aacc709f34f17a84829cded232e077753870a.tar.gz
Respond to disco items query
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/iq.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index ccffcde2..b4e4283a 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -61,6 +61,8 @@ static int _iq_handle_version_result(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata);
 static int _iq_handle_discoitems_result(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata);
+static int _iq_handle_discoitems_get(xmpp_conn_t * const conn,
+    xmpp_stanza_t * const stanza, void * const userdata);
 
 void
 iq_add_handlers(void)
@@ -73,6 +75,7 @@ iq_add_handlers(void)
     HANDLE(XMPP_NS_DISCO_INFO,  STANZA_TYPE_GET,    _iq_handle_discoinfo_get);
     HANDLE(XMPP_NS_DISCO_INFO,  STANZA_TYPE_RESULT, _iq_handle_discoinfo_result);
     HANDLE(XMPP_NS_DISCO_ITEMS, STANZA_TYPE_RESULT, _iq_handle_discoitems_result);
+    HANDLE(XMPP_NS_DISCO_ITEMS, STANZA_TYPE_GET,    _iq_handle_discoitems_get);
     HANDLE(STANZA_NS_VERSION,   STANZA_TYPE_GET,    _iq_handle_version_get);
     HANDLE(STANZA_NS_VERSION,   STANZA_TYPE_RESULT, _iq_handle_version_result);
     HANDLE(STANZA_NS_PING,      STANZA_TYPE_GET,    _iq_handle_ping_get);
@@ -340,6 +343,32 @@ _iq_handle_version_get(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
 }
 
 static int
+_iq_handle_discoitems_get(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
+    void * const userdata)
+{
+    xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
+    const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
+
+    if (from != NULL) {
+        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_set_attribute(response, STANZA_ATTR_TO, 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);
+        xmpp_stanza_add_child(response, query);
+        xmpp_send(conn, response);
+
+        xmpp_stanza_release(response);
+    }
+
+    return 1;
+}
+
+
+static int
 _iq_handle_discoinfo_get(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
     void * const userdata)
 {