1
0
Fork 0

Move xgd functions

This commit is contained in:
James Booth 2016-07-24 17:12:09 +01:00
parent 6cc4abedc5
commit 29452f8f1b
17 changed files with 56 additions and 52 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -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)) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -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");