Open Source Telephony
 help / color / mirror / Atom feed
From: Ronald Tessier <ronald.tessier@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 1/4] store: Add utilities for mms settings file access
Date: Mon, 06 Aug 2012 17:30:57 +0200	[thread overview]
Message-ID: <1344267060-5541-2-git-send-email-ronald.tessier@linux.intel.com> (raw)
In-Reply-To: <1344267060-5541-1-git-send-email-ronald.tessier@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2126 bytes --]

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


  reply	other threads:[~2012-08-06 15:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-06 15:30 [PATCH 0/4] mmsd: delivery-report flag Ronald Tessier
2012-08-06 15:30 ` Ronald Tessier [this message]
2012-08-07  7:17   ` [PATCH 1/4] store: Add utilities for mms settings file access Denis Kenzior
2012-08-06 15:30 ` [PATCH 2/4] service: Load delivery-report from mms settings Ronald Tessier
2012-08-07  7:18   ` Denis Kenzior
2012-08-06 15:30 ` [PATCH 3/4] service: Add DBus method to set delivery-report Ronald Tessier
2012-08-07  7:21   ` Denis Kenzior
2012-08-06 15:31 ` [PATCH 4/4] test: Add a script to set the delivery-report flag Ronald Tessier
2012-08-07  7:22   ` Denis Kenzior
  -- strict thread matches above, loose matches on Subject: below --
2012-07-23 14:18 [PATCH 0/4] mmsd: " Ronald Tessier
2012-07-23 14:18 ` [PATCH 1/4] store: Add utilities for mms settings file access Ronald Tessier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1344267060-5541-2-git-send-email-ronald.tessier@linux.intel.com \
    --to=ronald.tessier@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox