Imported Upstream connman version 1.38
[platform/upstream/connman.git] / src / storage.c
index 2da54d6..9be60de 100755 (executable)
 #include <config.h>
 #endif
 
-#include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
 #include <sys/stat.h>
 #include <dirent.h>
+#include <stdio.h>
 
 #include <connman/storage.h>
 
@@ -35,6 +35,9 @@
 
 #define SETTINGS       "settings"
 #define DEFAULT                "default.profile"
+#if defined TIZEN_EXT
+#define INS_SETTINGS   "settings.ins"
+#endif
 
 #define MODE           (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | \
                        S_IXGRP | S_IROTH | S_IXOTH)
@@ -44,8 +47,6 @@ static GKeyFile *storage_load(const char *pathname)
        GKeyFile *keyfile = NULL;
        GError *error = NULL;
 
-       DBG("Loading %s", pathname);
-
        keyfile = g_key_file_new();
 
        if (!g_key_file_load_from_file(keyfile, pathname, 0, &error)) {
@@ -132,41 +133,59 @@ int __connman_storage_save_global(GKeyFile *keyfile)
        return ret;
 }
 
-void __connman_storage_delete_global(void)
+#if defined TIZEN_EXT
+GKeyFile *__connman_storage_load_ins(void)
 {
        gchar *pathname;
+       GKeyFile *keyfile = NULL;
 
-       pathname = g_strdup_printf("%s/%s", STORAGEDIR, SETTINGS);
+       pathname = g_strdup_printf("%s/%s", STORAGEDIR, INS_SETTINGS);
        if (!pathname)
-               return;
+               return NULL;
 
-       storage_delete(pathname);
+       keyfile = storage_load(pathname);
 
        g_free(pathname);
+
+       return keyfile;
 }
 
-GKeyFile *__connman_storage_load_config(const char *ident)
+int __connman_storage_save_ins(GKeyFile *keyfile)
 {
        gchar *pathname;
-       GKeyFile *keyfile = NULL;
+       int ret;
 
-       pathname = g_strdup_printf("%s/%s.config", STORAGEDIR, ident);
+       pathname = g_strdup_printf("%s/%s", STORAGEDIR, INS_SETTINGS);
        if (!pathname)
-               return NULL;
+               return -ENOMEM;
 
-       keyfile = storage_load(pathname);
+       ret = storage_save(keyfile, pathname);
 
        g_free(pathname);
 
-       return keyfile;
+       return ret;
 }
+#endif
 
-GKeyFile *__connman_storage_load_provider_config(const char *ident)
+void __connman_storage_delete_global(void)
+{
+       gchar *pathname;
+
+       pathname = g_strdup_printf("%s/%s", STORAGEDIR, SETTINGS);
+       if (!pathname)
+               return;
+
+       storage_delete(pathname);
+
+       g_free(pathname);
+}
+
+GKeyFile *__connman_storage_load_config(const char *ident)
 {
        gchar *pathname;
        GKeyFile *keyfile = NULL;
 
-       pathname = g_strdup_printf("%s/%s.config", VPN_STORAGEDIR, ident);
+       pathname = g_strdup_printf("%s/%s.config", STORAGEDIR, ident);
        if (!pathname)
                return NULL;
 
@@ -177,25 +196,19 @@ GKeyFile *__connman_storage_load_provider_config(const char *ident)
        return keyfile;
 }
 
-GKeyFile *__connman_storage_open_service(const char *service_id)
+GKeyFile *__connman_storage_load_provider_config(const char *ident)
 {
        gchar *pathname;
        GKeyFile *keyfile = NULL;
 
-       pathname = g_strdup_printf("%s/%s/%s", STORAGEDIR, service_id, SETTINGS);
+       pathname = g_strdup_printf("%s/%s.config", VPN_STORAGEDIR, ident);
        if (!pathname)
                return NULL;
 
-       keyfile =  storage_load(pathname);
-       if (keyfile) {
-               g_free(pathname);
-               return keyfile;
-       }
+       keyfile = storage_load(pathname);
 
        g_free(pathname);
 
-       keyfile = g_key_file_new();
-
        return keyfile;
 }