---
 src/store.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/store.h |    4 ++++
 2 files changed, 60 insertions(+)

diff --git a/src/store.c b/src/store.c
index 88d9e77..b09c17b 100644
--- a/src/store.c
+++ b/src/store.c
@@ -358,3 +358,59 @@ void mms_store_meta_close(const char *service_id, const 
char *uuid,
 
        g_key_file_free(keyfile);
 }
+
+GKeyFile *mms_settings_open(const char *service_id, const char *store)
+{
+       GKeyFile *keyfile;
+       char *path;
+
+       if (store == NULL)
+               return NULL;
+
+       path = mms_store_get_path(service_id, store);
+       if (path == NULL)
+               return NULL;
+
+       if (create_dirs(path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
+               mms_error("Failed to create path %s", path);
+
+               g_free(path);
+               return NULL;
+       }
+
+       keyfile = g_key_file_new();
+
+       g_key_file_load_from_file(keyfile, path, 0, NULL);
+
+       g_free(path);
+
+       return keyfile;
+}
+
+static void settings_sync(const char *service_id, const char *store,
+                                                       GKeyFile *keyfile)
+{
+       char *path;
+       char *data;
+       gsize length = 0;
+
+       path = mms_store_get_path(service_id, store);
+       if (path == NULL)
+               return;
+
+       data = g_key_file_to_data(keyfile, &length, NULL);
+
+       g_file_set_contents(path, data, length, NULL);
+
+       g_free(data);
+       g_free(path);
+}
+
+void mms_settings_close(const char *service_id, const char *store,
+                                       GKeyFile *keyfile, gboolean save)
+{
+       if (save == TRUE)
+               settings_sync(service_id, store, keyfile);
+
+       g_key_file_free(keyfile);
+}
diff --git a/src/store.h b/src/store.h
index 21f11be..ba2c080 100644
--- a/src/store.h
+++ b/src/store.h
@@ -28,3 +28,7 @@ char *mms_store_get_path(const char *service_id, const char 
*uuid);
 GKeyFile *mms_store_meta_open(const char *service_id, const char *uuid);
 void mms_store_meta_close(const char *service_id, const char *uuid,
                                        GKeyFile *keyfile, gboolean save);
+
+GKeyFile *mms_settings_open(const char *service_id, const char *store);
+void mms_settings_close(const char *service_id, const char *store,
+                                       GKeyFile *keyfile, gboolean save);
-- 
1.7.9.5

_______________________________________________
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono

Reply via email to