about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-07-24 21:35:12 +0100
committerJames Booth <boothj5@gmail.com>2016-07-24 21:49:35 +0100
commita3a73cf0031fef7b4012b27bc1955c406175f0fe (patch)
treea9bfba0b9899eff139a9a8e5436468e35d6b7e91 /src/xmpp
parent29452f8f1b8f7a61773905169b3883f1b494c786 (diff)
downloadprofani-tty-a3a73cf0031fef7b4012b27bc1955c406175f0fe.tar.gz
Move all filepath handling to files.c
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/capabilities.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c
index b477b5f8..218ed2a2 100644
--- a/src/xmpp/capabilities.c
+++ b/src/xmpp/capabilities.c
@@ -61,7 +61,7 @@
 #include "xmpp/form.h"
 #include "xmpp/capabilities.h"
 
-static gchar *cache_loc;
+static char *cache_loc;
 static GKeyFile *cache;
 
 static GHashTable *jid_to_ver;
@@ -69,7 +69,6 @@ static GHashTable *jid_to_caps;
 
 static char *my_sha1;
 
-static gchar* _get_cache_file(void);
 static void _save_cache(void);
 static Capabilities* _caps_by_ver(const char *const ver);
 static Capabilities* _caps_by_jid(const char *const jid);
@@ -79,15 +78,14 @@ void
 caps_init(void)
 {
     log_info("Loading capabilities cache");
-    cache_loc = _get_cache_file();
+    cache_loc = files_get_data_path(FILE_CAPSCACHE);
 
     if (g_file_test(cache_loc, G_FILE_TEST_EXISTS)) {
         g_chmod(cache_loc, S_IRUSR | S_IWUSR);
     }
 
     cache = g_key_file_new();
-    g_key_file_load_from_file(cache, cache_loc, G_KEY_FILE_KEEP_COMMENTS,
-        NULL);
+    g_key_file_load_from_file(cache, cache_loc, G_KEY_FILE_KEEP_COMMENTS, NULL);
 
     jid_to_ver = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
     jid_to_caps = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)caps_destroy);
@@ -678,6 +676,8 @@ caps_close(void)
     cache = NULL;
     g_hash_table_destroy(jid_to_ver);
     g_hash_table_destroy(jid_to_caps);
+    free(cache_loc);
+    cache_loc = NULL;
 }
 
 void
@@ -698,19 +698,6 @@ caps_destroy(Capabilities *caps)
     }
 }
 
-static gchar*
-_get_cache_file(void)
-{
-    gchar *xdg_data = files_get_xdg_data_home();
-    GString *cache_file = g_string_new(xdg_data);
-    g_string_append(cache_file, "/profanity/capscache");
-    gchar *result = strdup(cache_file->str);
-    g_free(xdg_data);
-    g_string_free(cache_file, TRUE);
-
-    return result;
-}
-
 static void
 _save_cache(void)
 {