about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-07-24 17:12:09 +0100
committerJames Booth <boothj5@gmail.com>2016-07-24 17:12:09 +0100
commit29452f8f1b8f7a61773905169b3883f1b494c786 (patch)
treeaf43bbb2007b9a69f03c38503d9e612156408839
parent6cc4abedc58f294ccb36632cb86464c247687288 (diff)
downloadprofani-tty-29452f8f1b8f7a61773905169b3883f1b494c786.tar.gz
Move xgd functions
-rw-r--r--src/config/accounts.c4
-rw-r--r--src/config/files.c29
-rw-r--r--src/config/files.h7
-rw-r--r--src/config/preferences.c25
-rw-r--r--src/config/scripts.c8
-rw-r--r--src/config/theme.c2
-rw-r--r--src/config/tlscerts.c2
-rw-r--r--src/log.c4
-rw-r--r--src/otr/otr.c6
-rw-r--r--src/pgp/gpg.c2
-rw-r--r--src/plugins/plugins.c2
-rw-r--r--src/plugins/settings.c4
-rw-r--r--src/plugins/themes.c2
-rw-r--r--src/ui/inputwin.c3
-rw-r--r--src/ui/tray.c2
-rw-r--r--src/xmpp/capabilities.c2
-rw-r--r--tests/unittests/helpers.c4
17 files changed, 56 insertions, 52 deletions
diff --git a/src/config/accounts.c b/src/config/accounts.c
index 84671b74..d087bbb9 100644
--- a/src/config/accounts.c
+++ b/src/config/accounts.c
@@ -858,7 +858,7 @@ _save_accounts(void)
 {
     gsize g_data_size;
     gchar *g_accounts_data = g_key_file_to_data(accounts, &g_data_size, NULL);
-    gchar *xdg_data = xdg_get_data_home();
+    gchar *xdg_data = files_get_xdg_data_home();
     GString *base_str = g_string_new(xdg_data);
     g_string_append(base_str, "/profanity/");
     gchar *true_loc = get_file_or_linked(accounts_loc, base_str->str);
@@ -873,7 +873,7 @@ _save_accounts(void)
 static gchar*
 _get_accounts_file(void)
 {
-    gchar *xdg_data = xdg_get_data_home();
+    gchar *xdg_data = files_get_xdg_data_home();
     GString *logfile = g_string_new(xdg_data);
     g_string_append(logfile, "/profanity/accounts");
     gchar *result = strdup(logfile->str);
diff --git a/src/config/files.c b/src/config/files.c
index 5f57f691..7b8759b1 100644
--- a/src/config/files.c
+++ b/src/config/files.c
@@ -45,8 +45,8 @@
 void
 files_create_directories(void)
 {
-    gchar *xdg_config = xdg_get_config_home();
-    gchar *xdg_data = xdg_get_data_home();
+    gchar *xdg_config = files_get_xdg_config_home();
+    gchar *xdg_data = files_get_xdg_data_home();
 
     GString *themes_dir = g_string_new(xdg_config);
     g_string_append(themes_dir, "/profanity/themes");
@@ -86,7 +86,28 @@ files_create_directories(void)
 }
 
 gchar*
-xdg_get_config_home(void)
+files_get_inputrc_path(void)
+{
+    gchar *xdg_config = files_get_xdg_config_home();
+    GString *inputrc_file = g_string_new(xdg_config);
+    g_free(xdg_config);
+
+    g_string_append(inputrc_file, "/profanity/inputrc");
+
+    if (g_file_test(inputrc_file->str, G_FILE_TEST_IS_REGULAR)) {
+        gchar *result = strdup(inputrc_file->str);
+        g_string_free(inputrc_file, TRUE);
+
+        return result;
+    }
+
+    g_string_free(inputrc_file, TRUE);
+
+    return NULL;
+}
+
+gchar*
+files_get_xdg_config_home(void)
 {
     gchar *xdg_config_home = getenv("XDG_CONFIG_HOME");
     if (xdg_config_home)
@@ -105,7 +126,7 @@ xdg_get_config_home(void)
 }
 
 gchar*
-xdg_get_data_home(void)
+files_get_xdg_data_home(void)
 {
     gchar *xdg_data_home = getenv("XDG_DATA_HOME");
     if (xdg_data_home)
diff --git a/src/config/files.h b/src/config/files.h
index 431229f7..ff50cc1d 100644
--- a/src/config/files.h
+++ b/src/config/files.h
@@ -37,8 +37,11 @@
 
 #include <glib.h>
 
-gchar* xdg_get_config_home(void);
-gchar* xdg_get_data_home(void);
 void files_create_directories(void);
 
+gchar* files_get_inputrc_path(void);
+
+gchar* files_get_xdg_config_home(void);
+gchar* files_get_xdg_data_home(void);
+
 #endif
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 3fd32586..d2d3b8ce 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -1121,27 +1121,6 @@ prefs_get_aliases(void)
     }
 }
 
-gchar*
-prefs_get_inputrc(void)
-{
-    gchar *xdg_config = xdg_get_config_home();
-    GString *inputrc_file = g_string_new(xdg_config);
-    g_free(xdg_config);
-
-    g_string_append(inputrc_file, "/profanity/inputrc");
-
-    if (g_file_test(inputrc_file->str, G_FILE_TEST_IS_REGULAR)) {
-        gchar *result = strdup(inputrc_file->str);
-        g_string_free(inputrc_file, TRUE);
-
-        return result;
-    }
-
-    g_string_free(inputrc_file, TRUE);
-
-    return NULL;
-}
-
 void
 _free_alias(ProfAlias *alias)
 {
@@ -1161,7 +1140,7 @@ _save_prefs(void)
 {
     gsize g_data_size;
     gchar *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL);
-    gchar *xdg_config = xdg_get_config_home();
+    gchar *xdg_config = files_get_xdg_config_home();
     GString *base_str = g_string_new(xdg_config);
     g_string_append(base_str, "/profanity/");
     gchar *true_loc = get_file_or_linked(prefs_loc, base_str->str);
@@ -1176,7 +1155,7 @@ _save_prefs(void)
 static gchar*
 _get_preferences_file(void)
 {
-    gchar *xdg_config = xdg_get_config_home();
+    gchar *xdg_config = files_get_xdg_config_home();
     GString *prefs_file = g_string_new(xdg_config);
     g_string_append(prefs_file, "/profanity/profrc");
     gchar *result = strdup(prefs_file->str);
diff --git a/src/config/scripts.c b/src/config/scripts.c
index 91dbe4df..8ab2684c 100644
--- a/src/config/scripts.c
+++ b/src/config/scripts.c
@@ -51,7 +51,7 @@
 void
 scripts_init(void)
 {
-    gchar *data_home = xdg_get_data_home();
+    gchar *data_home = files_get_xdg_data_home();
     GString *scriptsdir = g_string_new(data_home);
     free(data_home);
 
@@ -75,7 +75,7 @@ scripts_init(void)
 GSList*
 scripts_list(void)
 {
-    gchar *data_home = xdg_get_data_home();
+    gchar *data_home = files_get_xdg_data_home();
     GString *scriptsdir = g_string_new(data_home);
     free(data_home);
     g_string_append(scriptsdir, "/profanity/scripts");
@@ -99,7 +99,7 @@ scripts_list(void)
 GSList*
 scripts_read(const char *const script)
 {
-    gchar *data_home = xdg_get_data_home();
+    gchar *data_home = files_get_xdg_data_home();
     GString *scriptpath = g_string_new(data_home);
     free(data_home);
 
@@ -137,7 +137,7 @@ scripts_read(const char *const script)
 gboolean
 scripts_exec(const char *const script)
 {
-    gchar *data_home = xdg_get_data_home();
+    gchar *data_home = files_get_xdg_data_home();
     GString *scriptpath = g_string_new(data_home);
     free(data_home);
 
diff --git a/src/config/theme.c b/src/config/theme.c
index fb208279..55698ed6 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -535,7 +535,7 @@ _load_preferences(void)
 static gchar*
 _get_themes_dir(void)
 {
-    gchar *xdg_config = xdg_get_config_home();
+    gchar *xdg_config = files_get_xdg_config_home();
     GString *themes_dir = g_string_new(xdg_config);
     g_free(xdg_config);
     g_string_append(themes_dir, "/profanity/themes");
diff --git a/src/config/tlscerts.c b/src/config/tlscerts.c
index 03a8bd97..8a93ed51 100644
--- a/src/config/tlscerts.c
+++ b/src/config/tlscerts.c
@@ -432,7 +432,7 @@ tlscerts_close(void)
 static gchar*
 _get_tlscerts_file(void)
 {
-    gchar *xdg_data = xdg_get_data_home();
+    gchar *xdg_data = files_get_xdg_data_home();
     GString *tlscerts_file = g_string_new(xdg_data);
     g_string_append(tlscerts_file, "/profanity/tlscerts");
     gchar *result = strdup(tlscerts_file->str);
diff --git a/src/log.c b/src/log.c
index 7fcef45f..0e014947 100644
--- a/src/log.c
+++ b/src/log.c
@@ -639,7 +639,7 @@ _get_groupchat_log_filename(const char *const room, const char *const login, GDa
 static gchar*
 _get_chatlog_dir(void)
 {
-    gchar *xdg_data = xdg_get_data_home();
+    gchar *xdg_data = files_get_xdg_data_home();
     GString *chatlogs_dir = g_string_new(xdg_data);
     g_string_append(chatlogs_dir, "/profanity/chatlogs");
     gchar *result = strdup(chatlogs_dir->str);
@@ -652,7 +652,7 @@ _get_chatlog_dir(void)
 static gchar*
 _get_main_log_file(void)
 {
-    gchar *xdg_data = xdg_get_data_home();
+    gchar *xdg_data = files_get_xdg_data_home();
     GString *logfile = g_string_new(xdg_data);
     g_string_append(logfile, "/profanity/logs/profanity");
     if (!prefs_get_boolean(PREF_LOG_SHARED)) {
diff --git a/src/otr/otr.c b/src/otr/otr.c
index 3e4a90fc..955e60fa 100644
--- a/src/otr/otr.c
+++ b/src/otr/otr.c
@@ -126,7 +126,7 @@ cb_write_fingerprints(void *opdata)
 {
     gcry_error_t err = 0;
 
-    gchar *data_home = xdg_get_data_home();
+    gchar *data_home = files_get_xdg_data_home();
     GString *basedir = g_string_new(data_home);
     free(data_home);
 
@@ -215,7 +215,7 @@ otr_on_connect(ProfAccount *account)
     jid = strdup(account->jid);
     log_info("Loading OTR key for %s", jid);
 
-    gchar *data_home = xdg_get_data_home();
+    gchar *data_home = files_get_xdg_data_home();
     GString *basedir = g_string_new(data_home);
     free(data_home);
 
@@ -393,7 +393,7 @@ otr_keygen(ProfAccount *account)
     jid = strdup(account->jid);
     log_info("Generating OTR key for %s", jid);
 
-    gchar *data_home = xdg_get_data_home();
+    gchar *data_home = files_get_xdg_data_home();
     GString *basedir = g_string_new(data_home);
     free(data_home);
 
diff --git a/src/pgp/gpg.c b/src/pgp/gpg.c
index c2b81c67..6be3aaaa 100644
--- a/src/pgp/gpg.c
+++ b/src/pgp/gpg.c
@@ -157,7 +157,7 @@ p_gpg_close(void)
 void
 p_gpg_on_connect(const char *const barejid)
 {
-    gchar *data_home = xdg_get_data_home();
+    gchar *data_home = files_get_xdg_data_home();
     GString *pubsfile = g_string_new(data_home);
     free(data_home);
 
diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c
index 2f176ac7..2308e7f3 100644
--- a/src/plugins/plugins.c
+++ b/src/plugins/plugins.c
@@ -834,7 +834,7 @@ plugins_shutdown(void)
 char*
 plugins_get_dir(void)
 {
-    gchar *xdg_data = xdg_get_data_home();
+    gchar *xdg_data = files_get_xdg_data_home();
     GString *plugins_dir = g_string_new(xdg_data);
     g_string_append(plugins_dir, "/profanity/plugins");
     char *result = strdup(plugins_dir->str);
diff --git a/src/plugins/settings.c b/src/plugins/settings.c
index 4ffe85e5..418451ff 100644
--- a/src/plugins/settings.c
+++ b/src/plugins/settings.c
@@ -49,7 +49,7 @@ static void _save_settings(void);
 void
 plugin_settings_init(void)
 {
-    gchar *xdg_data = xdg_get_data_home();
+    gchar *xdg_data = files_get_xdg_data_home();
     GString *fileloc = g_string_new(xdg_data);
     g_string_append(fileloc, "/profanity/plugin_settings");
     g_free(xdg_data);
@@ -135,7 +135,7 @@ _save_settings(void)
     gsize g_data_size;
     gchar *g_data = g_key_file_to_data(settings, &g_data_size, NULL);
 
-    gchar *xdg_data = xdg_get_data_home();
+    gchar *xdg_data = files_get_xdg_data_home();
     GString *fileloc = g_string_new(xdg_data);
     g_free(xdg_data);
 
diff --git a/src/plugins/themes.c b/src/plugins/themes.c
index d41ba283..061638e9 100644
--- a/src/plugins/themes.c
+++ b/src/plugins/themes.c
@@ -44,7 +44,7 @@ static GKeyFile *themes;
 void
 plugin_themes_init(void)
 {
-    gchar *xdg_data = xdg_get_data_home();
+    gchar *xdg_data = files_get_xdg_data_home();
     GString *fileloc = g_string_new(xdg_data);
     g_string_append(fileloc, "/profanity/plugin_themes");
     g_free(xdg_data);
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index fdfdb0ac..6a4093e1 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -57,6 +57,7 @@
 #include "log.h"
 #include "common.h"
 #include "command/cmd_ac.h"
+#include "config/files.h"
 #include "config/accounts.h"
 #include "config/preferences.h"
 #include "config/theme.h"
@@ -427,7 +428,7 @@ _inp_rl_startup_hook(void)
     rl_variable_bind("disable-completion", "on");
 
     // check for and load ~/.config/profanity/inputrc
-    char *inputrc = prefs_get_inputrc();
+    char *inputrc = files_get_inputrc_path();
     if (inputrc) {
         rl_read_init_file(inputrc);
         free(inputrc);
diff --git a/src/ui/tray.c b/src/ui/tray.c
index 94408dae..ab0d26e0 100644
--- a/src/ui/tray.c
+++ b/src/ui/tray.c
@@ -79,7 +79,7 @@ _get_icons(void)
 
 #endif /* ICONS_PATH */
 
-    gchar *xdg_config = xdg_get_config_home();
+    gchar *xdg_config = files_get_xdg_config_home();
     icons_dir = g_string_new(xdg_config);
     g_free(xdg_config);
     g_string_append(icons_dir, "/profanity/icons");
diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c
index bfc22120..b477b5f8 100644
--- a/src/xmpp/capabilities.c
+++ b/src/xmpp/capabilities.c
@@ -701,7 +701,7 @@ caps_destroy(Capabilities *caps)
 static gchar*
 _get_cache_file(void)
 {
-    gchar *xdg_data = xdg_get_data_home();
+    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);
diff --git a/tests/unittests/helpers.c b/tests/unittests/helpers.c
index 1494d803..60f36839 100644
--- a/tests/unittests/helpers.c
+++ b/tests/unittests/helpers.c
@@ -15,7 +15,7 @@
 void create_config_dir(void **state)
 {
     setenv("XDG_CONFIG_HOME", "./tests/files/xdg_config_home", 1);
-    gchar *xdg_config = xdg_get_config_home();
+    gchar *xdg_config = files_get_xdg_config_home();
 
     GString *profanity_dir = g_string_new(xdg_config);
     g_string_append(profanity_dir, "/profanity");
@@ -37,7 +37,7 @@ void remove_config_dir(void **state)
 void create_data_dir(void **state)
 {
     setenv("XDG_DATA_HOME", "./tests/files/xdg_data_home", 1);
-    gchar *xdg_data = xdg_get_data_home();
+    gchar *xdg_data = files_get_xdg_data_home();
 
     GString *profanity_dir = g_string_new(xdg_data);
     g_string_append(profanity_dir, "/profanity");