about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-02-17 01:04:10 +0000
committerJames Booth <boothj5@gmail.com>2013-02-17 01:04:10 +0000
commit44d2f8da7a235997049bac68fea746682ae49e9f (patch)
tree084d2440cdb88815e532e5e6c526d04611bde8a0 /src/xmpp
parentab591b41b2535f454d35d7524c454dccea1b2cc5 (diff)
downloadprofani-tty-44d2f8da7a235997049bac68fea746682ae49e9f.tar.gz
Added /caps command
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/capabilities.c12
-rw-r--r--src/xmpp/capabilities.h2
-rw-r--r--src/xmpp/iq.c12
-rw-r--r--src/xmpp/xmpp.h1
4 files changed, 24 insertions, 3 deletions
diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c
index e8e45b97..a5d99633 100644
--- a/src/xmpp/capabilities.c
+++ b/src/xmpp/capabilities.c
@@ -48,7 +48,8 @@ void
 caps_add(const char * const caps_str, const char * const category,
     const char * const type, const char * const name,
     const char * const software, const char * const software_version,
-    const char * const os, const char * const os_version)
+    const char * const os, const char * const os_version,
+    GSList *features)
 {
     Capabilities *new_caps = malloc(sizeof(struct capabilities_t));
 
@@ -87,6 +88,11 @@ caps_add(const char * const caps_str, const char * const category,
     } else {
         new_caps->os_version = NULL;
     }
+    if (features != NULL) {
+        new_caps->features = features;
+    } else {
+        new_caps->features = NULL;
+    }
 
     g_hash_table_insert(capabilities, strdup(caps_str), new_caps);
 }
@@ -284,6 +290,10 @@ _caps_destroy(Capabilities *caps)
         FREE_SET_NULL(caps->software_version);
         FREE_SET_NULL(caps->os);
         FREE_SET_NULL(caps->os_version);
+        if (caps->features != NULL) {
+            g_slist_free_full(caps->features, free);
+            caps->features = NULL;
+        }
         FREE_SET_NULL(caps);
     }
 }
diff --git a/src/xmpp/capabilities.h b/src/xmpp/capabilities.h
index f2729adc..d97b84b2 100644
--- a/src/xmpp/capabilities.h
+++ b/src/xmpp/capabilities.h
@@ -31,7 +31,7 @@ void caps_init(void);
 void caps_add(const char * const caps_str, const char * const category,
     const char * const type, const char * const name,
     const char * const software, const char * const software_version,
-    const char * const os, const char * const os_version);
+    const char * const os, const char * const os_version, GSList *features);
 gboolean caps_contains(const char * const caps_str);
 char* caps_create_sha1_str(xmpp_stanza_t * const query);
 xmpp_stanza_t* caps_create_query_response_stanza(xmpp_ctx_t * const ctx);
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 9d0b43e9..070fefba 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -324,6 +324,7 @@ _iq_handle_discoinfo_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
         const char *software_version = NULL;
         const char *os = NULL;
         const char *os_version = NULL;
+        GSList *features = NULL;
 
         xmpp_stanza_t *identity = xmpp_stanza_get_child_by_name(query, "identity");
         if (identity != NULL) {
@@ -356,8 +357,17 @@ _iq_handle_discoinfo_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
             }
         }
 
+        xmpp_stanza_t *child = xmpp_stanza_get_children(query);
+        while (child != NULL) {
+            if (g_strcmp0(xmpp_stanza_get_name(child), "feature") == 0) {
+                features = g_slist_append(features, strdup(xmpp_stanza_get_attribute(child, "var")));
+            }
+
+            child = xmpp_stanza_get_next(child);
+        }
+
         caps_add(caps_key, category, type, name, software, software_version,
-            os, os_version);
+            os, os_version, features);
 
         //stanza_destroy_form(form);
         free(caps_key);
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 2b5cce92..5edd253e 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -54,6 +54,7 @@ typedef struct capabilities_t {
     char *software_version;
     char *os;
     char *os_version;
+    GSList *features;
 } Capabilities;
 
 // connection functions