Blame SOURCES/0162-lib-introduce-a-new-function-returning-base-user-con.patch

562801
From b429af7c61bb1abe791ceb34fb6b6cf7382f832b Mon Sep 17 00:00:00 2001
562801
From: Matej Habrnal <mhabrnal@redhat.com>
562801
Date: Fri, 12 Feb 2016 14:25:05 +0100
562801
Subject: [PATCH] lib: introduce a new function returning base user conf
562801
 directory
562801
562801
Signed-off-by: Jakub Filak <jfilak@redhat.com>
562801
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
562801
---
562801
 src/include/internal_libreport.h |  3 +++
562801
 src/lib/configuration_files.c    |  9 +++++++++
562801
 src/lib/user_settings.c          | 12 +++++-------
562801
 3 files changed, 17 insertions(+), 7 deletions(-)
562801
562801
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
562801
index b36cbd9..38d75a1 100644
562801
--- a/src/include/internal_libreport.h
562801
+++ b/src/include/internal_libreport.h
562801
@@ -738,6 +738,9 @@ bool load_conf_file(const char *pPath, map_string_t *settings, bool skipKeysWith
562801
 #define load_plugin_conf_file libreport_load_plugin_conf_file
562801
 bool load_plugin_conf_file(const char *name, map_string_t *settings, bool skipKeysWithoutValue);
562801
 
562801
+#define get_user_conf_base_dir libreport_get_user_conf_base_dir
562801
+const char *get_user_conf_base_dir(void);
562801
+
562801
 #define load_conf_file_from_dirs libreport_load_conf_file_from_dirs
562801
 bool load_conf_file_from_dirs(const char *base_name, const char *const *directories, map_string_t *settings, bool skipKeysWithoutValue);
562801
 
562801
diff --git a/src/lib/configuration_files.c b/src/lib/configuration_files.c
562801
index 4975d62..b145b9f 100644
562801
--- a/src/lib/configuration_files.c
562801
+++ b/src/lib/configuration_files.c
562801
@@ -318,6 +318,15 @@ finalize:
562801
     return retval;
562801
 }
562801
 
562801
+const char *get_user_conf_base_dir(void)
562801
+{
562801
+    static char *base_dir = NULL;
562801
+    if (base_dir == NULL)
562801
+        base_dir = concat_path_file(g_get_user_config_dir(), "abrt/settings/");
562801
+
562801
+    return base_dir;
562801
+}
562801
+
562801
 bool load_conf_file_from_dirs(const char *base_name, const char *const *directories, map_string_t *settings, bool skipKeysWithoutValue)
562801
 {
562801
     if (NULL == directories || NULL == *directories)
562801
diff --git a/src/lib/user_settings.c b/src/lib/user_settings.c
562801
index 4cd87ff..cdc8482 100644
562801
--- a/src/lib/user_settings.c
562801
+++ b/src/lib/user_settings.c
562801
@@ -18,21 +18,19 @@
562801
 #include "internal_libreport.h"
562801
 #include <augeas.h>
562801
 
562801
-#define BASE_DIR_FOR_USER_CONFIG_FILE "abrt/settings/"
562801
-
562801
 static map_string_t *user_settings;
562801
 static char *conf_path;
562801
 
562801
 static char *get_user_config_file_path(const char *name, const char *suffix)
562801
 {
562801
-    char *s, *conf;
562801
+    char *s = NULL;
562801
+    char *conf;
562801
 
562801
     if (suffix != NULL)
562801
-        s = xasprintf(BASE_DIR_FOR_USER_CONFIG_FILE"%s.%s", name, suffix);
562801
-    else
562801
-        s = xasprintf(BASE_DIR_FOR_USER_CONFIG_FILE"%s", name);
562801
+        s = xasprintf("%s.%s", name, suffix);
562801
+
562801
+    conf = concat_path_file(get_user_conf_base_dir(), s != NULL ? s : name);
562801
 
562801
-    conf = concat_path_file(g_get_user_config_dir(), s);
562801
     free(s);
562801
     return conf;
562801
 }
562801
-- 
562801
1.8.3.1
562801