element: Remove IPv6
[framework/connectivity/connman.git] / src / storage.c
index 0472169..800acfa 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Connection Manager
  *
- *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License version 2 as
@@ -27,6 +27,9 @@
 
 #include "connman.h"
 
+#define PROFILE_SUFFIX "profile"
+#define CONFIG_SUFFIX  "config"
+
 static GSList *storage_list = NULL;
 
 static gint compare_priority(gconstpointer a, gconstpointer b)
@@ -68,16 +71,16 @@ void connman_storage_unregister(struct connman_storage *storage)
        storage_list = g_slist_remove(storage_list, storage);
 }
 
-GKeyFile *__connman_storage_open(const char *ident)
+GKeyFile *__connman_storage_open(const char *ident, const char *suffix)
 {
        GKeyFile *keyfile;
        gchar *pathname, *data = NULL;
        gboolean result;
        gsize length;
 
-       DBG("ident %s", ident);
+       DBG("ident %s suffix %s", ident, suffix);
 
-       pathname = g_strdup_printf("%s/%s.profile", STORAGEDIR, ident);
+       pathname = g_strdup_printf("%s/%s.%s", STORAGEDIR, ident, suffix);
        if (pathname == NULL)
                return NULL;
 
@@ -101,20 +104,21 @@ done:
        return keyfile;
 }
 
-void __connman_storage_close(const char *ident,
+void __connman_storage_close(const char *ident, const char *suffix,
                                        GKeyFile *keyfile, gboolean save)
 {
        gchar *pathname, *data = NULL;
        gsize length = 0;
 
-       DBG("ident %s keyfile %p save %d", ident, keyfile, save);
+       DBG("ident %s suffix %s keyfile %p save %d",
+                                       ident, suffix, keyfile, save);
 
        if (save == FALSE) {
                g_key_file_free(keyfile);
                return;
        }
 
-       pathname = g_strdup_printf("%s/%s.profile", STORAGEDIR, ident);
+       pathname = g_strdup_printf("%s/%s.%s", STORAGEDIR, ident, suffix);
        if (pathname == NULL)
                return;
 
@@ -130,13 +134,13 @@ void __connman_storage_close(const char *ident,
        g_key_file_free(keyfile);
 }
 
-void __connman_storage_delete(const char *ident)
+void __connman_storage_delete(const char *ident, const char *suffix)
 {
        gchar *pathname;
 
-       DBG("ident %s", ident);
+       DBG("ident %s suffix %s", ident, suffix);
 
-       pathname = g_strdup_printf("%s/%s.profile", STORAGEDIR, ident);
+       pathname = g_strdup_printf("%s/%s.%s", STORAGEDIR, ident, suffix);
        if (pathname == NULL)
                return;
 
@@ -144,6 +148,38 @@ void __connman_storage_delete(const char *ident)
                connman_error("Failed to remove %s", pathname);
 }
 
+GKeyFile *__connman_storage_open_profile(const char *ident)
+{
+       return __connman_storage_open(ident, PROFILE_SUFFIX);
+}
+
+void __connman_storage_close_profile(const char *ident,
+                                       GKeyFile *keyfile, gboolean save)
+{
+       __connman_storage_close(ident, PROFILE_SUFFIX, keyfile, save);
+}
+
+void __connman_storage_delete_profile(const char *ident)
+{
+       __connman_storage_delete(ident, PROFILE_SUFFIX);
+}
+
+GKeyFile *__connman_storage_open_config(const char *ident)
+{
+       return __connman_storage_open(ident, CONFIG_SUFFIX);
+}
+
+void __connman_storage_close_config(const char *ident,
+                                       GKeyFile *keyfile, gboolean save)
+{
+       __connman_storage_close(ident, CONFIG_SUFFIX, keyfile, save);
+}
+
+void __connman_storage_delete_config(const char *ident)
+{
+       __connman_storage_delete(ident, CONFIG_SUFFIX);
+}
+
 int __connman_storage_init_profile(void)
 {
        GSList *list;