about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-01-20 00:35:40 +0000
committerJames Booth <boothj5@gmail.com>2013-01-20 00:35:40 +0000
commit22589e879822a89212c49030dabee3db0c10f8e8 (patch)
tree002d8641a27093a892fe620ccecdf120ceb6feed
parent7920a9b2f17042c2181ffc9cb40af22b4645b9f5 (diff)
downloadprofani-tty-22589e879822a89212c49030dabee3db0c10f8e8.tar.gz
Initialise and free capabilities
-rw-r--r--src/capabilities.c17
-rw-r--r--src/capabilities.h2
-rw-r--r--src/profanity.c3
3 files changed, 22 insertions, 0 deletions
diff --git a/src/capabilities.c b/src/capabilities.c
index c3910025..7ed5c810 100644
--- a/src/capabilities.c
+++ b/src/capabilities.c
@@ -23,9 +23,20 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <glib.h>
+
 #include "common.h"
 #include "capabilities.h"
 
+GHashTable *capabilities;
+
+void
+caps_init(void)
+{
+    capabilities = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+        (GDestroyNotify)caps_destroy);
+}
+
 Capabilities *
 caps_create(const char * const client, const char * const version)
 {
@@ -55,3 +66,9 @@ caps_destroy(Capabilities *caps)
         FREE_SET_NULL(caps);
     }
 }
+
+void
+caps_close(void)
+{
+    g_hash_table_destroy(capabilities);
+}
diff --git a/src/capabilities.h b/src/capabilities.h
index f3c51396..430348a6 100644
--- a/src/capabilities.h
+++ b/src/capabilities.h
@@ -28,7 +28,9 @@ typedef struct capabilities_t {
     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_close(void);
 
 #endif
diff --git a/src/profanity.c b/src/profanity.c
index a8e80870..0eec13a5 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -30,6 +30,7 @@
 #include <glib.h>
 
 #include "accounts.h"
+#include "capabilities.h"
 #include "chat_log.h"
 #include "chat_session.h"
 #include "command.h"
@@ -541,6 +542,7 @@ _init(const int disable_tls, char *log_level)
     theme_init(theme);
     g_free(theme);
     ui_init();
+    caps_init();
     jabber_init(disable_tls);
     cmd_init();
     log_info("Initialising contact list");
@@ -553,6 +555,7 @@ _shutdown(void)
 {
     jabber_disconnect();
     contact_list_free();
+    caps_close();
     ui_close();
     chat_log_close();
     prefs_close();