about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/capabilities.c33
-rw-r--r--src/capabilities.h7
-rw-r--r--src/jabber.c7
3 files changed, 33 insertions, 14 deletions
diff --git a/src/capabilities.c b/src/capabilities.c
index 7ed5c810..e28112e7 100644
--- a/src/capabilities.c
+++ b/src/capabilities.c
@@ -28,17 +28,20 @@
 #include "common.h"
 #include "capabilities.h"
 
-GHashTable *capabilities;
+static GHashTable *capabilities;
+
+static void _caps_destroy(Capabilities *caps);
 
 void
 caps_init(void)
 {
     capabilities = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
-        (GDestroyNotify)caps_destroy);
+        (GDestroyNotify)_caps_destroy);
 }
 
-Capabilities *
-caps_create(const char * const client, const char * const version)
+void
+caps_add(const char * const caps_str, const char * const client,
+    const char * const version)
 {
     Capabilities *new_caps = malloc(sizeof(struct capabilities_t));
 
@@ -54,17 +57,13 @@ caps_create(const char * const client, const char * const version)
         new_caps->version = NULL;
     }
 
-    return new_caps;
+    g_hash_table_insert(capabilities, strdup(caps_str), new_caps);
 }
 
-void
-caps_destroy(Capabilities *caps)
+gboolean
+caps_contains(const char * const caps_str)
 {
-    if (caps != NULL) {
-        FREE_SET_NULL(caps->client);
-        FREE_SET_NULL(caps->version);
-        FREE_SET_NULL(caps);
-    }
+    return (g_hash_table_lookup(capabilities, caps_str) != NULL);
 }
 
 void
@@ -72,3 +71,13 @@ caps_close(void)
 {
     g_hash_table_destroy(capabilities);
 }
+
+static void
+_caps_destroy(Capabilities *caps)
+{
+    if (caps != NULL) {
+        FREE_SET_NULL(caps->client);
+        FREE_SET_NULL(caps->version);
+        FREE_SET_NULL(caps);
+    }
+}
diff --git a/src/capabilities.h b/src/capabilities.h
index 430348a6..128fb2e1 100644
--- a/src/capabilities.h
+++ b/src/capabilities.h
@@ -23,14 +23,17 @@
 #ifndef CAPABILITIES_H
 #define CAPABILITIES_H
 
+#include <glib.h>
+
 typedef struct capabilities_t {
     char *client;
     char *version;
 } Capabilities;
 
 void caps_init(void);
-Capabilities* caps_create(const char * const client, const char * const version);
-void caps_destroy(Capabilities *caps);
+void caps_add(const char * const caps_str, const char * const client,
+    const char * const version);
+gboolean caps_contains(const char * const caps_str);
 void caps_close(void);
 
 #endif
diff --git a/src/jabber.c b/src/jabber.c
index a85ecbed..d5fb23ce 100644
--- a/src/jabber.c
+++ b/src/jabber.c
@@ -26,6 +26,7 @@
 
 #include <strophe.h>
 
+#include "capabilities.h"
 #include "chat_session.h"
 #include "common.h"
 #include "contact_list.h"
@@ -1069,6 +1070,12 @@ _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 *status = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_STATUS);
         if (status != NULL)
             status_str = xmpp_stanza_get_text(status);