Open Source Telephony
 help / color / mirror / Atom feed
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis <frederic.danis@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH V3 3/4] voicecall: save last dialed number
Date: Wed, 01 Jun 2011 13:24:22 +0200	[thread overview]
Message-ID: <1306927463-10642-4-git-send-email-frederic.danis@linux.intel.com> (raw)
In-Reply-To: <1306927463-10642-1-git-send-email-frederic.danis@linux.intel.com>

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

---
 src/voicecall.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index a6ccddd..f176e25 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -37,11 +37,15 @@
 #include "common.h"
 #include "simutil.h"
 #include "smsutil.h"
+#include "storage.h"
 
 #define MAX_VOICE_CALLS 16
 
 #define VOICECALL_FLAG_SIM_ECC_READY 0x1
 
+#define SETTINGS_STORE "voicecall"
+#define SETTINGS_GROUP "Settings"
+
 GSList *g_drivers = NULL;
 
 struct multi_release {
@@ -72,6 +76,8 @@ struct ofono_voicecall {
 	guint tone_source;
 	unsigned int hfp_watch;
 	struct ofono_emulator *pending_em;
+	GKeyFile *settings;
+	char *imsi;
 };
 
 struct voicecall {
@@ -1478,6 +1484,12 @@ static int voicecall_dial(struct ofono_voicecall *vc, const char *number,
 
 	vc->driver->dial(vc, &ph, clir, cb, vc);
 
+	if (vc->settings) {
+		g_key_file_set_string(vc->settings, SETTINGS_GROUP,
+					"Number", number);
+		storage_sync(vc->imsi, SETTINGS_STORE, vc->settings);
+	}
+
 	return 0;
 }
 
@@ -2466,6 +2478,33 @@ static void emulator_hfp_unregister(struct ofono_atom *atom)
 	__ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
 }
 
+static void voicecall_load_settings(struct ofono_voicecall *vc)
+{
+	const char *imsi;
+
+	imsi = ofono_sim_get_imsi(vc->sim);
+	if (imsi == NULL)
+		return;
+
+	vc->settings = storage_open(imsi, SETTINGS_STORE);
+
+	if (vc->settings == NULL)
+		return;
+
+	vc->imsi = g_strdup(imsi);
+}
+
+static void voicecall_close_settings(struct ofono_voicecall *vc)
+{
+	if (vc->settings) {
+		storage_close(vc->imsi, SETTINGS_STORE, vc->settings, TRUE);
+
+		g_free(vc->imsi);
+		vc->imsi = NULL;
+		vc->settings = NULL;
+	}
+}
+
 static void voicecall_unregister(struct ofono_atom *atom)
 {
 	DBusConnection *conn = ofono_dbus_get_connection();
@@ -2476,6 +2515,8 @@ static void voicecall_unregister(struct ofono_atom *atom)
 
 	emulator_hfp_unregister(atom);
 
+	voicecall_close_settings(vc);
+
 	if (vc->sim_state_watch) {
 		ofono_sim_remove_state_watch(vc->sim, vc->sim_state_watch);
 		vc->sim_state_watch = 0;
@@ -2615,6 +2656,9 @@ static void sim_state_watch(enum ofono_sim_state new_state, void *user)
 
 		free_sim_ecc_numbers(vc, FALSE);
 		set_new_ecc(vc);
+	case OFONO_SIM_STATE_READY:
+		voicecall_load_settings(vc);
+		break;
 	default:
 		break;
 	}
@@ -2627,6 +2671,7 @@ static void sim_watch(struct ofono_atom *atom,
 	struct ofono_sim *sim = __ofono_atom_get_data(atom);
 
 	if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
+		voicecall_close_settings(vc);
 		vc->sim_state_watch = 0;
 		vc->sim = NULL;
 		return;
-- 
1.7.1


  parent reply	other threads:[~2011-06-01 11:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-01 11:24 [PATCH V3 0/4] Add dial support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-06-01 11:24 ` [PATCH V3 1/4] voicecall: create generic dial function =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-06-02  1:27   ` Denis Kenzior
2011-06-01 11:24 ` [PATCH V3 2/4] voicecall: add ATD support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-06-02  2:08   ` Denis Kenzior
2011-06-07 12:58     ` Frederic Danis
2011-06-06  2:09       ` Denis Kenzior
2011-06-07 15:01         ` Frederic Danis
2011-06-01 11:24 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis [this message]
2011-06-02  1:28   ` [PATCH V3 3/4] voicecall: save last dialed number Denis Kenzior
2011-06-01 11:24 ` [PATCH V3 4/4] voicecall: add +BLDN support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis

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=1306927463-10642-4-git-send-email-frederic.danis@linux.intel.com \
    --to=frederic.danis@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