All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] Support of Network / Modem updated emergency numbers
@ 2011-04-06 14:26 Jeevaka Badrappan
  2011-04-06 14:26 ` [PATCH v4 1/4] include: Add ofono_voicecall_en_list_notify api Jeevaka Badrappan
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jeevaka Badrappan @ 2011-04-06 14:26 UTC (permalink / raw)
  To: ofono

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

Hi,

 Following set of patch adds the support for emergency number list update
from the network/modem in the oFono core.

Regards,
Jeevaka

Jeevaka Badrappan (4):
  include: Add ofono_voicecall_en_list_notify api
  voicecall: refactor emergency number list handling
  voicecall: network emergency number list support
  TODO: Mark Network/Modem EN update task as done

 TODO                |   11 ----
 doc/features.txt    |   18 +++---
 include/voicecall.h |    3 +
 src/voicecall.c     |  160 ++++++++++++++++++++++++++++----------------------
 4 files changed, 103 insertions(+), 89 deletions(-)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v4 1/4] include: Add ofono_voicecall_en_list_notify api
  2011-04-06 14:26 [PATCH v4 0/4] Support of Network / Modem updated emergency numbers Jeevaka Badrappan
@ 2011-04-06 14:26 ` Jeevaka Badrappan
  2011-04-06 14:26 ` [PATCH v4 2/4] voicecall: refactor emergency number list handling Jeevaka Badrappan
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jeevaka Badrappan @ 2011-04-06 14:26 UTC (permalink / raw)
  To: ofono

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

---
 include/voicecall.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/voicecall.h b/include/voicecall.h
index 6ae06a9..a373c64 100644
--- a/include/voicecall.h
+++ b/include/voicecall.h
@@ -135,6 +135,9 @@ struct ofono_voicecall_driver {
 			ofono_voicecall_cb_t cb, void *data);
 };
 
+void ofono_voicecall_en_list_notify(struct ofono_voicecall *vc,
+					char **nw_en_list);
+
 void ofono_voicecall_notify(struct ofono_voicecall *vc,
 				const struct ofono_call *call);
 void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id,
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v4 2/4] voicecall: refactor emergency number list handling
  2011-04-06 14:26 [PATCH v4 0/4] Support of Network / Modem updated emergency numbers Jeevaka Badrappan
  2011-04-06 14:26 ` [PATCH v4 1/4] include: Add ofono_voicecall_en_list_notify api Jeevaka Badrappan
@ 2011-04-06 14:26 ` Jeevaka Badrappan
  2011-04-06 14:26 ` [PATCH v4 3/4] voicecall: network emergency number list support Jeevaka Badrappan
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jeevaka Badrappan @ 2011-04-06 14:26 UTC (permalink / raw)
  To: ofono

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

---
 src/voicecall.c |  143 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 72 insertions(+), 71 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index 469b939..b0f15fd 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -46,8 +46,9 @@ struct ofono_voicecall {
 	GSList *call_list;
 	GSList *release_list;
 	GSList *multiparty_list;
-	GSList *en_list;  /* emergency number list */
-	GSList *new_en_list; /* Emergency numbers being read from SIM */
+	GHashTable *en_list; /* emergency number list */
+	GSList *sim_en_list; /* Emergency numbers being read from SIM */
+	ofono_bool_t sim_en_list_ready;
 	DBusMessage *pending;
 	struct ofono_sim *sim;
 	struct ofono_sim_context *sim_context;
@@ -130,11 +131,12 @@ static gint call_compare(gconstpointer a, gconstpointer b)
 	return 0;
 }
 
-static void add_to_en_list(GSList **l, const char **list)
+static void add_to_en_list(struct ofono_voicecall *vc, char **list)
 {
 	int i = 0;
+
 	while (list[i])
-		*l = g_slist_prepend(*l, g_strdup(list[i++]));
+		g_hash_table_insert(vc->en_list, g_strdup(list[i++]), NULL);
 }
 
 static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r)
@@ -331,17 +333,10 @@ static void tone_request_finish(struct ofono_voicecall *vc,
 	g_free(entry);
 }
 
-static gint number_compare(gconstpointer a, gconstpointer b)
-{
-	const char *s1 = a, *s2 = b;
-	return strcmp(s1, s2);
-}
-
 static gboolean is_emergency_number(struct ofono_voicecall *vc,
 					const char *number)
 {
-	return g_slist_find_custom(vc->en_list, number,
-						number_compare) ? TRUE : FALSE;
+	return g_hash_table_lookup_extended(vc->en_list, number, NULL, NULL);
 }
 
 static void append_voicecall_properties(struct voicecall *v,
@@ -1120,9 +1115,10 @@ static DBusMessage *manager_get_properties(DBusConnection *conn,
 	DBusMessage *reply;
 	DBusMessageIter iter;
 	DBusMessageIter dict;
-	int i;
-	GSList *l;
+	int i = 0;
 	char **list;
+	GHashTableIter ht_iter;
+	gpointer key, value;
 
 	reply = dbus_message_new_method_return(msg);
 	if (reply == NULL)
@@ -1135,14 +1131,16 @@ static DBusMessage *manager_get_properties(DBusConnection *conn,
 					&dict);
 
 	/* property EmergencyNumbers */
-	list = g_new0(char *, g_slist_length(vc->en_list) + 1);
+	list = g_new0(char *, g_hash_table_size(vc->en_list) + 1);
+
+	g_hash_table_iter_init(&ht_iter, vc->en_list);
 
-	for (i = 0, l = vc->en_list; l; l = l->next, i++)
-		list[i] = g_strdup(l->data);
+	while (g_hash_table_iter_next(&ht_iter, &key, &value))
+		list[i++] = key;
 
 	ofono_dbus_dict_append_array(&dict, "EmergencyNumbers",
 					DBUS_TYPE_STRING, &list);
-	g_strfreev(list);
+	g_free(list);
 
 	dbus_message_iter_close_container(&iter, &dict);
 
@@ -2068,46 +2066,43 @@ static void emit_en_list_changed(struct ofono_voicecall *vc)
 	DBusConnection *conn = ofono_dbus_get_connection();
 	const char *path = __ofono_atom_get_path(vc->atom);
 	char **list;
-	GSList *l;
-	int i;
+	int i = 0;
+	GHashTableIter iter;
+	gpointer key, value;
 
-	list = g_new0(char *, g_slist_length(vc->en_list) + 1);
-	for (i = 0, l = vc->en_list; l; l = l->next, i++)
-		list[i] = g_strdup(l->data);
+	list = g_new0(char *, g_hash_table_size(vc->en_list) + 1);
+
+	g_hash_table_iter_init(&iter, vc->en_list);
+
+	while (g_hash_table_iter_next(&iter, &key, &value))
+		list[i++] = key;
 
 	ofono_dbus_signal_array_property_changed(conn, path,
 				OFONO_VOICECALL_MANAGER_INTERFACE,
 				"EmergencyNumbers", DBUS_TYPE_STRING, &list);
 
-	g_strfreev(list);
+	g_free(list);
 }
 
 static void set_new_ecc(struct ofono_voicecall *vc)
 {
-	int i = 0;
-
-	g_slist_foreach(vc->en_list, (GFunc) g_free, NULL);
-	g_slist_free(vc->en_list);
-	vc->en_list = NULL;
-
-	vc->en_list = vc->new_en_list;
-	vc->new_en_list = NULL;
+	GSList *l;
 
-	while (default_en_list[i]) {
-		GSList *l;
+	g_hash_table_destroy(vc->en_list);
 
-		for (l = vc->en_list; l; l = l->next)
-			if (!strcmp(l->data, default_en_list[i]))
-				break;
+	vc->en_list = g_hash_table_new_full(g_str_hash, g_str_equal,
+							g_free, NULL);
 
-		if (l == NULL)
-			vc->en_list = g_slist_prepend(vc->en_list,
-						g_strdup(default_en_list[i]));
-
-		i++;
+	/* Emergency numbers read from SIM */
+	if (vc->sim_en_list_ready == TRUE && vc->sim_en_list) {
+		for (l = vc->sim_en_list; l; l = l->next)
+			g_hash_table_insert(vc->en_list, g_strdup(l->data),
+							NULL);
 	}
 
-	vc->en_list = g_slist_reverse(vc->en_list);
+	/* Default emergency numbers */
+	add_to_en_list(vc, (char **) default_en_list);
+
 	emit_en_list_changed(vc);
 }
 
@@ -2134,10 +2129,12 @@ static void ecc_g2_read_cb(int ok, int total_length, int record,
 		data += 3;
 
 		if (en[0] != '\0')
-			vc->new_en_list = g_slist_prepend(vc->new_en_list,
+			vc->sim_en_list = g_slist_prepend(vc->sim_en_list,
 								g_strdup(en));
 	}
 
+	vc->sim_en_list = g_slist_reverse(vc->sim_en_list);
+	vc->sim_en_list_ready = TRUE;
 	set_new_ecc(vc);
 }
 
@@ -2163,16 +2160,18 @@ static void ecc_g3_read_cb(int ok, int total_length, int record,
 	extract_bcd_number(data, 3, en);
 
 	if (en[0] != '\0')
-		vc->new_en_list = g_slist_prepend(vc->new_en_list,
+		vc->sim_en_list = g_slist_prepend(vc->sim_en_list,
 							g_strdup(en));
 
 	if (record != total)
 		return;
 
 check:
-	if (!ok && vc->new_en_list == NULL)
+	if (!ok && vc->sim_en_list == NULL)
 		return;
 
+	vc->sim_en_list = g_slist_reverse(vc->sim_en_list);
+	vc->sim_en_list_ready = TRUE;
 	set_new_ecc(vc);
 }
 
@@ -2203,11 +2202,27 @@ static void voicecall_unregister(struct ofono_atom *atom)
 	const char *path = __ofono_atom_get_path(atom);
 	GSList *l;
 
+	if (vc->sim_state_watch) {
+		ofono_sim_remove_state_watch(vc->sim, vc->sim_state_watch);
+		vc->sim_state_watch = 0;
+	}
+
 	if (vc->sim_watch) {
 		__ofono_modem_remove_atom_watch(modem, vc->sim_watch);
 		vc->sim_watch = 0;
 	}
 
+	vc->sim = NULL;
+
+	if (vc->sim_en_list) {
+		g_slist_foreach(vc->sim_en_list, (GFunc) g_free, NULL);
+		g_slist_free(vc->sim_en_list);
+		vc->sim_en_list = NULL;
+	}
+
+	g_hash_table_destroy(vc->en_list);
+	vc->en_list = NULL;
+
 	if (vc->dial_req)
 		dial_request_finish(vc);
 
@@ -2234,24 +2249,6 @@ static void voicecall_remove(struct ofono_atom *atom)
 	if (vc->driver && vc->driver->remove)
 		vc->driver->remove(vc);
 
-	if (vc->en_list) {
-		g_slist_foreach(vc->en_list, (GFunc) g_free, NULL);
-		g_slist_free(vc->en_list);
-		vc->en_list = NULL;
-	}
-
-	if (vc->new_en_list) {
-		g_slist_foreach(vc->new_en_list, (GFunc) g_free, NULL);
-		g_slist_free(vc->new_en_list);
-		vc->new_en_list = NULL;
-	}
-
-	if (vc->sim_state_watch) {
-		ofono_sim_remove_state_watch(vc->sim, vc->sim_state_watch);
-		vc->sim_state_watch = 0;
-		vc->sim = NULL;
-	}
-
 	if (vc->tone_source) {
 		g_source_remove(vc->tone_source);
 		vc->tone_source = 0;
@@ -2345,14 +2342,15 @@ static void sim_state_watch(enum ofono_sim_state new_state, void *user)
 		 * Free the currently being read EN list, just in case the
 		 * SIM is removed when we're still reading them
 		 */
-		if (vc->new_en_list) {
-			g_slist_foreach(vc->new_en_list, (GFunc) g_free, NULL);
-			g_slist_free(vc->new_en_list);
-			vc->new_en_list = NULL;
+		if (vc->sim_en_list) {
+			g_slist_foreach(vc->sim_en_list, (GFunc) g_free, NULL);
+			g_slist_free(vc->sim_en_list);
+			vc->sim_en_list = NULL;
 		}
 
-		add_to_en_list(&vc->new_en_list, default_en_list_no_sim);
+		vc->sim_en_list_ready = FALSE;
 		set_new_ecc(vc);
+		add_to_en_list(vc, (char **) default_en_list_no_sim);
 	default:
 		break;
 	}
@@ -2396,12 +2394,15 @@ void ofono_voicecall_register(struct ofono_voicecall *vc)
 
 	ofono_modem_add_interface(modem, OFONO_VOICECALL_MANAGER_INTERFACE);
 
+	vc->en_list = g_hash_table_new_full(g_str_hash, g_str_equal,
+							g_free, NULL);
+
 	/*
 	 * Start out with the 22.101 mandated numbers, if we have a SIM and
 	 * the SIM contains EFecc, then we update the list once we've read them
 	 */
-	add_to_en_list(&vc->en_list, default_en_list_no_sim);
-	add_to_en_list(&vc->en_list, default_en_list);
+	add_to_en_list(vc, (char **) default_en_list_no_sim);
+	add_to_en_list(vc, (char **) default_en_list);
 
 	vc->sim_watch = __ofono_modem_add_atom_watch(modem,
 						OFONO_ATOM_TYPE_SIM,
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v4 3/4] voicecall: network emergency number list support
  2011-04-06 14:26 [PATCH v4 0/4] Support of Network / Modem updated emergency numbers Jeevaka Badrappan
  2011-04-06 14:26 ` [PATCH v4 1/4] include: Add ofono_voicecall_en_list_notify api Jeevaka Badrappan
  2011-04-06 14:26 ` [PATCH v4 2/4] voicecall: refactor emergency number list handling Jeevaka Badrappan
@ 2011-04-06 14:26 ` Jeevaka Badrappan
  2011-04-06 14:26 ` [PATCH v4 4/4] TODO: Mark Network/Modem EN update task as done Jeevaka Badrappan
  2011-04-08  3:20 ` [PATCH v4 0/4] Support of Network / Modem updated emergency numbers Denis Kenzior
  4 siblings, 0 replies; 6+ messages in thread
From: Jeevaka Badrappan @ 2011-04-06 14:26 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/src/voicecall.c b/src/voicecall.c
index b0f15fd..19ef479 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -49,6 +49,7 @@ struct ofono_voicecall {
 	GHashTable *en_list; /* emergency number list */
 	GSList *sim_en_list; /* Emergency numbers being read from SIM */
 	ofono_bool_t sim_en_list_ready;
+	char **nw_en_list; /* Emergency numbers from modem/network */
 	DBusMessage *pending;
 	struct ofono_sim *sim;
 	struct ofono_sim_context *sim_context;
@@ -2093,6 +2094,10 @@ static void set_new_ecc(struct ofono_voicecall *vc)
 	vc->en_list = g_hash_table_new_full(g_str_hash, g_str_equal,
 							g_free, NULL);
 
+	/* Emergency numbers from modem/network */
+	if (vc->nw_en_list)
+		add_to_en_list(vc, vc->nw_en_list);
+
 	/* Emergency numbers read from SIM */
 	if (vc->sim_en_list_ready == TRUE && vc->sim_en_list) {
 		for (l = vc->sim_en_list; l; l = l->next)
@@ -2175,6 +2180,15 @@ check:
 	set_new_ecc(vc);
 }
 
+void ofono_voicecall_en_list_notify(struct ofono_voicecall *vc,
+						char **nw_en_list)
+{
+	g_strfreev(vc->nw_en_list);
+
+	vc->nw_en_list = g_strdupv(nw_en_list);
+	set_new_ecc(vc);
+}
+
 int ofono_voicecall_driver_register(const struct ofono_voicecall_driver *d)
 {
 	DBG("driver: %p, name: %s", d, d->name);
@@ -2220,6 +2234,11 @@ static void voicecall_unregister(struct ofono_atom *atom)
 		vc->sim_en_list = NULL;
 	}
 
+	if (vc->nw_en_list) {
+		g_strfreev(vc->nw_en_list);
+		vc->nw_en_list = NULL;
+	}
+
 	g_hash_table_destroy(vc->en_list);
 	vc->en_list = NULL;
 
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v4 4/4] TODO: Mark Network/Modem EN update task as done
  2011-04-06 14:26 [PATCH v4 0/4] Support of Network / Modem updated emergency numbers Jeevaka Badrappan
                   ` (2 preceding siblings ...)
  2011-04-06 14:26 ` [PATCH v4 3/4] voicecall: network emergency number list support Jeevaka Badrappan
@ 2011-04-06 14:26 ` Jeevaka Badrappan
  2011-04-08  3:20 ` [PATCH v4 0/4] Support of Network / Modem updated emergency numbers Denis Kenzior
  4 siblings, 0 replies; 6+ messages in thread
From: Jeevaka Badrappan @ 2011-04-06 14:26 UTC (permalink / raw)
  To: ofono

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

---
 TODO             |   11 -----------
 doc/features.txt |   18 ++++++++++--------
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/TODO b/TODO
index 85c5ad1..3491436 100644
--- a/TODO
+++ b/TODO
@@ -289,17 +289,6 @@ Sim Toolkit
   Complexity: C2
   Owner: Philippe Nunes <philippe.nunes@linux.intel.com>
 
-Emergency Calls
-===============
-
-- Network / Modem updating of the emergency number list. Support the list of
-  emergency numbers dynamically updated by the network or by the modem (e.g.
-  additional numbers burned into modem ROM).
-
-  Priority: High
-  Complexity: C2
-
-
 Miscellaneous
 =============
 
diff --git a/doc/features.txt b/doc/features.txt
index eb945c3..68d0676 100644
--- a/doc/features.txt
+++ b/doc/features.txt
@@ -583,14 +583,16 @@ Text Telephony
 Emergency Calls
 ===============
 
-- EFecc support.  During SIM initialization phase oFono reads EFecc in order
-  to bootstrap the emergency calling codes provides by the SIM.  If the SIM is
-  not present or EFecc has not been read yet, the default set of emergency
-  calling codes is used.
-
-- Emergency number reporting.  The current known list of emergency calling
-  codes is reported by oFono in the EmergencyNumbers property on the
-  VoicecallManager interface.  When a voicecall is made to a number present
+- Emergency number reporting.  During SIM initialization phase oFono reads
+  EFecc in order to bootstrap the emergency calling codes provided by the SIM.
+  Emergency number list is exposed via the EmergencyNumbers property on the
+  VoicecallManager interface.  If SIM is present, list is the union of default
+  emergency numbers(112, 911), numbers in EFecc and Network / Modem reported
+  emergency numbers.  If SIM is not present or EFecc has not been read yet,
+  list is the union of default emergency numbers(112, 911) and emergency
+  numbers without SIM(119, 118, 999, 110, 08 and 000).
+
+- Emergency call reporting.  When a voicecall is made to a number present
   on the EmergencyNumbers list it is automatically flagged as an emergency
   call.  This is done by setting the Emergency property on the Voicecall
   interface to TRUE.
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v4 0/4] Support of Network / Modem updated emergency numbers
  2011-04-06 14:26 [PATCH v4 0/4] Support of Network / Modem updated emergency numbers Jeevaka Badrappan
                   ` (3 preceding siblings ...)
  2011-04-06 14:26 ` [PATCH v4 4/4] TODO: Mark Network/Modem EN update task as done Jeevaka Badrappan
@ 2011-04-08  3:20 ` Denis Kenzior
  4 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2011-04-08  3:20 UTC (permalink / raw)
  To: ofono

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

Hi Jeevaka,

On 04/06/2011 09:26 AM, Jeevaka Badrappan wrote:
> Hi,
> 
>  Following set of patch adds the support for emergency number list update
> from the network/modem in the oFono core.
> 
> Regards,
> Jeevaka
> 

I applied all of the patches in this series, but did split patch 2 into
two commits.  Thanks for that.

I also did some minor refactoring after the fact to take care of some
really corner cases.  Can you please review and make sure I didn't screw
anything up.

I believe this should complete emergency call related tasks.  Can we
make sure to test this really well in the coming weeks?

Regards,
-Denis

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-04-08  3:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-06 14:26 [PATCH v4 0/4] Support of Network / Modem updated emergency numbers Jeevaka Badrappan
2011-04-06 14:26 ` [PATCH v4 1/4] include: Add ofono_voicecall_en_list_notify api Jeevaka Badrappan
2011-04-06 14:26 ` [PATCH v4 2/4] voicecall: refactor emergency number list handling Jeevaka Badrappan
2011-04-06 14:26 ` [PATCH v4 3/4] voicecall: network emergency number list support Jeevaka Badrappan
2011-04-06 14:26 ` [PATCH v4 4/4] TODO: Mark Network/Modem EN update task as done Jeevaka Badrappan
2011-04-08  3:20 ` [PATCH v4 0/4] Support of Network / Modem updated emergency numbers Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.