All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] HFP: add call, callsetup indicators and +COPS support
@ 2011-03-17 16:50 =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-03-17 16:50 ` [PATCH 1/4] emulator: add defines for call and callsetup indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-03-17 16:50 UTC (permalink / raw)
  To: ofono

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

AT+COPS support needs to be in emulator as HFP plugin should answer requests
even when oFono is not registered on network.

Frédéric Danis (4):
  emulator: add defines for call and callsetup indicators
  emulator: add call and callsetup indicators
  emulator: add API to set network mode and name
  emulator: add +COPS support

 include/emulator.h |   13 +++++++
 src/emulator.c     |   75 +++++++++++++++++++++++++++++++++++++++++++
 src/network.c      |   90 +++++++++++++++++++++++++++++++++++++++++++++++----
 src/voicecall.c    |   86 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 257 insertions(+), 7 deletions(-)


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

* [PATCH 1/4] emulator: add defines for call and callsetup indicators
  2011-03-17 16:50 [PATCH 0/4] HFP: add call, callsetup indicators and +COPS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-03-17 16:50 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-03-17 16:50 ` [PATCH 2/4] emulator: add " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-03-17 16:50 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/include/emulator.h b/include/emulator.h
index 71b7c24..701decd 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -36,6 +36,14 @@ extern "C" {
 #define OFONO_EMULATOR_IND_SERVICE "service"
 #define OFONO_EMULATOR_IND_SIGNAL "signal"
 
+#define OFONO_EMULATOR_CALL_INACTIVE 0
+#define OFONO_EMULATOR_CALL_ACTIVE 1
+
+#define OFONO_EMULATOR_CALLSETUP_INACTIVE 0
+#define OFONO_EMULATOR_CALLSETUP_INCOMING 1
+#define OFONO_EMULATOR_CALLSETUP_OUTGOING 2
+#define OFONO_EMULATOR_CALLSETUP_ALERTING 3
+
 struct ofono_emulator;
 struct ofono_emulator_request;
 
-- 
1.7.1


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

* [PATCH 2/4] emulator: add call and callsetup indicators
  2011-03-17 16:50 [PATCH 0/4] HFP: add call, callsetup indicators and +COPS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-03-17 16:50 ` [PATCH 1/4] emulator: add defines for call and callsetup indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-03-17 16:50 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-03-17 21:14   ` Denis Kenzior
  2011-03-17 16:50 ` [PATCH 3/4] emulator: add API to set network mode and name =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-03-17 16:50 ` [PATCH 4/4] emulator: add +COPS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  3 siblings, 1 reply; 9+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-03-17 16:50 UTC (permalink / raw)
  To: ofono

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

---
 src/emulator.c  |    3 ++
 src/voicecall.c |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+), 0 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index c84f0a9..864e50b 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -455,6 +455,9 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 
 	if (em->type == OFONO_EMULATOR_TYPE_HFP) {
 		emulator_add_indicator(em, OFONO_EMULATOR_IND_SERVICE, 0, 1, 0);
+		emulator_add_indicator(em, OFONO_EMULATOR_IND_CALL, 0, 1, 0);
+		emulator_add_indicator(em, OFONO_EMULATOR_IND_CALLSETUP, 0, 3,
+									0);
 		emulator_add_indicator(em, OFONO_EMULATOR_IND_SIGNAL, 0, 5, 0);
 		emulator_add_indicator(em, OFONO_EMULATOR_IND_ROAMING, 0, 1, 0);
 		emulator_add_indicator(em, OFONO_EMULATOR_IND_BATTERY, 0, 5, 5);
diff --git a/src/voicecall.c b/src/voicecall.c
index cb5258d..d0ddad6 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -59,6 +59,7 @@ struct ofono_voicecall {
 	struct dial_request *dial_req;
 	GQueue *toneq;
 	guint tone_source;
+	unsigned int hfp_watch;
 };
 
 struct voicecall {
@@ -692,6 +693,55 @@ static void voicecall_emit_multiparty(struct voicecall *call, gboolean mpty)
 						&val);
 }
 
+static void notify_emulator_call_status_cb(struct ofono_atom *atom, void *data)
+{
+	struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+	switch (GPOINTER_TO_INT(data)) {
+	case CALL_STATUS_ACTIVE:
+		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALL,
+						OFONO_EMULATOR_CALL_ACTIVE);
+		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
+					OFONO_EMULATOR_CALLSETUP_INACTIVE);
+		break;
+
+	case CALL_STATUS_DIALING:
+		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
+					OFONO_EMULATOR_CALLSETUP_OUTGOING);
+		break;
+
+	case CALL_STATUS_ALERTING:
+		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
+					OFONO_EMULATOR_CALLSETUP_ALERTING);
+		break;
+
+	case CALL_STATUS_INCOMING:
+		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
+					OFONO_EMULATOR_CALLSETUP_INCOMING);
+		break;
+
+	case CALL_STATUS_DISCONNECTED:
+		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALL,
+						OFONO_EMULATOR_CALL_INACTIVE);
+		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
+					OFONO_EMULATOR_CALLSETUP_INACTIVE);
+		break;
+
+	case CALL_STATUS_WAITING:
+	case CALL_STATUS_HELD:
+		break;
+	}
+}
+
+static void notify_emulator_call_status(struct ofono_voicecall *vc, int status)
+{
+	struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
+
+	__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
+					notify_emulator_call_status_cb,
+					GINT_TO_POINTER(status));
+}
+
 static void voicecall_set_call_status(struct voicecall *call, int status)
 {
 	DBusConnection *conn = ofono_dbus_get_connection();
@@ -714,6 +764,8 @@ static void voicecall_set_call_status(struct voicecall *call, int status)
 						"State", DBUS_TYPE_STRING,
 						&status_str);
 
+	notify_emulator_call_status(call->vc, status);
+
 	if (status == CALL_STATUS_ACTIVE &&
 		(old_status == CALL_STATUS_INCOMING ||
 			old_status == CALL_STATUS_DIALING ||
@@ -1043,6 +1095,8 @@ static void voicecalls_emit_call_added(struct ofono_voicecall *vc,
 	DBusMessageIter dict;
 	const char *path;
 
+	notify_emulator_call_status(vc, v->call->status);
+
 	path = __ofono_atom_get_path(vc->atom);
 
 	signal = dbus_message_new_signal(path,
@@ -2188,6 +2242,10 @@ static void voicecall_unregister(struct ofono_atom *atom)
 	const char *path = __ofono_atom_get_path(atom);
 	GSList *l;
 
+	notify_emulator_call_status(vc, CALL_STATUS_DISCONNECTED);
+
+	__ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
+
 	if (vc->sim_watch) {
 		__ofono_modem_remove_atom_watch(modem, vc->sim_watch);
 		vc->sim_watch = 0;
@@ -2362,6 +2420,30 @@ static void sim_watch(struct ofono_atom *atom,
 	sim_state_watch(ofono_sim_get_state(sim), vc);
 }
 
+static void emulator_hfp_watch(struct ofono_atom *atom,
+				enum ofono_atom_watch_condition cond,
+				void *data)
+{
+	struct ofono_voicecall *vc = data;
+
+	if (cond == OFONO_ATOM_WATCH_CONDITION_REGISTERED) {
+		if (voicecalls_have_with_status(vc, CALL_STATUS_ACTIVE))
+			notify_emulator_call_status(vc, CALL_STATUS_ACTIVE);
+
+		if (voicecalls_have_with_status(vc, CALL_STATUS_DIALING))
+			notify_emulator_call_status(vc, CALL_STATUS_DIALING);
+		else if (voicecalls_have_with_status(vc, CALL_STATUS_ALERTING))
+			notify_emulator_call_status(vc, CALL_STATUS_ALERTING);
+		else if (voicecalls_have_with_status(vc, CALL_STATUS_INCOMING))
+			notify_emulator_call_status(vc, CALL_STATUS_INCOMING);
+		else if (voicecalls_have_with_status(vc, CALL_STATUS_WAITING))
+			notify_emulator_call_status(vc, CALL_STATUS_WAITING);
+
+		if (voicecalls_have_with_status(vc, CALL_STATUS_HELD))
+			notify_emulator_call_status(vc, CALL_STATUS_HELD);
+	}
+}
+
 void ofono_voicecall_register(struct ofono_voicecall *vc)
 {
 	DBusConnection *conn = ofono_dbus_get_connection();
@@ -2398,6 +2480,10 @@ void ofono_voicecall_register(struct ofono_voicecall *vc)
 		sim_watch(sim_atom, OFONO_ATOM_WATCH_CONDITION_REGISTERED, vc);
 
 	__ofono_atom_register(vc->atom, voicecall_unregister);
+
+	vc->hfp_watch = __ofono_modem_add_atom_watch(modem,
+					OFONO_ATOM_TYPE_EMULATOR_HFP,
+					emulator_hfp_watch, vc, NULL);
 }
 
 void ofono_voicecall_remove(struct ofono_voicecall *vc)
-- 
1.7.1


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

* [PATCH 3/4] emulator: add API to set network mode and name
  2011-03-17 16:50 [PATCH 0/4] HFP: add call, callsetup indicators and +COPS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-03-17 16:50 ` [PATCH 1/4] emulator: add defines for call and callsetup indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-03-17 16:50 ` [PATCH 2/4] emulator: add " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-03-17 16:50 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-03-17 21:15   ` Denis Kenzior
  2011-03-17 16:50 ` [PATCH 4/4] emulator: add +COPS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  3 siblings, 1 reply; 9+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-03-17 16:50 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/include/emulator.h b/include/emulator.h
index 701decd..509ec71 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -101,6 +101,11 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(
 void ofono_emulator_set_indicator(struct ofono_emulator *em,
 					const char *name, int value);
 
+void ofono_emulator_set_network_name(struct ofono_emulator *em,
+					const char *name);
+
+void ofono_emulator_set_network_mode(struct ofono_emulator *em, int mode);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.1


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

* [PATCH 4/4] emulator: add +COPS support
  2011-03-17 16:50 [PATCH 0/4] HFP: add call, callsetup indicators and +COPS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (2 preceding siblings ...)
  2011-03-17 16:50 ` [PATCH 3/4] emulator: add API to set network mode and name =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-03-17 16:50 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-03-17 21:18   ` Denis Kenzior
  3 siblings, 1 reply; 9+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-03-17 16:50 UTC (permalink / raw)
  To: ofono

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

This needs to be in emulator as HFP plugin should answer AT+COPS requests
even when oFono is not registered on network.
---
 src/emulator.c |   72 ++++++++++++++++++++++++++++++++++++++++++++
 src/network.c  |   90 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 155 insertions(+), 7 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index 864e50b..eb4f49e 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -49,6 +49,8 @@ struct ofono_emulator {
 	int events_mode;
 	gboolean events_ind;
 	GSList *indicators;
+	char op_name[17];
+	int net_mode;
 };
 
 struct indicator {
@@ -387,6 +389,59 @@ fail:
 	}
 }
 
+static void cops_cb(GAtServer *server, GAtServerRequestType type,
+			GAtResult *result, gpointer user_data)
+{
+	struct ofono_emulator *em = user_data;
+	char buf[32];
+
+	if (em->type == OFONO_EMULATOR_TYPE_HFP && em->slc == FALSE) {
+		g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
+		return;
+	}
+
+	switch (type) {
+	case G_AT_SERVER_REQUEST_TYPE_QUERY:
+		sprintf(buf, "+COPS: %d,0,\"%s\"", em->net_mode, em->op_name);
+		g_at_server_send_info(em->server, buf, TRUE);
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		break;
+
+	case G_AT_SERVER_REQUEST_TYPE_SET:
+	{
+		GAtResultIter iter;
+		int val;
+
+		g_at_result_iter_init(&iter, result);
+		g_at_result_iter_next(&iter, "");
+
+		if (!g_at_result_iter_next_number(&iter, &val))
+			goto fail;
+
+		if (val != 3)
+			goto fail;
+
+		if (!g_at_result_iter_next_number(&iter, &val))
+			goto fail;
+
+		if (val != 0)
+			goto fail;
+
+		/* check there is no more parameter */
+		if (g_at_result_iter_skip_next(&iter))
+			goto fail;
+
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		break;
+	}
+
+	default:
+fail:
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+		break;
+	}
+}
+
 static void emulator_add_indicator(struct ofono_emulator *em, const char* name,
 					int min, int max, int dflt)
 {
@@ -465,6 +520,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 		g_at_server_register(em->server, "+BRSF", brsf_cb, em, NULL);
 		g_at_server_register(em->server, "+CIND", cind_cb, em, NULL);
 		g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL);
+		g_at_server_register(em->server, "+COPS", cops_cb, em, NULL);
 	}
 
 	__ofono_atom_register(em->atom, emulator_unregister);
@@ -508,6 +564,7 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
 	/* TODO: Check real local features */
 	em->l_features = 32;
 	em->events_mode = 3;	/* default mode is forwarding events */
+	em->op_name[0] = '\0';
 
 	em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
 							emulator_remove, em);
@@ -703,3 +760,18 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 		return;
 	}
 }
+
+void ofono_emulator_set_network_name(struct ofono_emulator *em,
+					const char *name)
+{
+	if (name == NULL)
+		return;
+
+	strncpy(em->op_name, name, 16);
+	em->op_name[16] = '\0';
+}
+
+void ofono_emulator_set_network_mode(struct ofono_emulator *em, int mode)
+{
+	em->net_mode = mode;
+}
diff --git a/src/network.c b/src/network.c
index 2d0a9f8..d529431 100644
--- a/src/network.c
+++ b/src/network.c
@@ -145,11 +145,19 @@ static char **network_operator_technologies(struct network_operator_data *opd)
 	return techs;
 }
 
+static void notify_emulator_mode(struct ofono_atom *atom, void *data)
+{
+	struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+	ofono_emulator_set_network_mode(em, GPOINTER_TO_INT(data));
+}
+
 static void set_registration_mode(struct ofono_netreg *netreg, int mode)
 {
 	DBusConnection *conn;
 	const char *strmode;
 	const char *path;
+	struct ofono_modem *modem;
 
 	if (netreg->mode == mode)
 		return;
@@ -170,6 +178,10 @@ static void set_registration_mode(struct ofono_netreg *netreg, int mode)
 	ofono_dbus_signal_property_changed(conn, path,
 					OFONO_NETWORK_REGISTRATION_INTERFACE,
 					"Mode", DBUS_TYPE_STRING, &strmode);
+
+	modem = __ofono_atom_get_modem(netreg->atom);
+	__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
+				notify_emulator_mode, GINT_TO_POINTER(mode));
 }
 
 static void registration_status_callback(const struct ofono_error *error,
@@ -400,13 +412,20 @@ static char *get_operator_display_name(struct ofono_netreg *netreg)
 	return name;
 }
 
+static void notify_emulator_operator_name(struct ofono_atom *atom, void *data)
+{
+	struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+	ofono_emulator_set_network_name(em, data);
+}
+
 static void set_network_operator_name(struct network_operator_data *opd,
 					const char *name)
 {
 	DBusConnection *conn = ofono_dbus_get_connection();
 	struct ofono_netreg *netreg = opd->netreg;
 	const char *path;
-	const char *operator;
+	char *operator;
 
 	if (name[0] == '\0')
 		return;
@@ -426,6 +445,7 @@ static void set_network_operator_name(struct network_operator_data *opd,
 
 	if (opd == netreg->current_operator) {
 		const char *path = __ofono_atom_get_path(netreg->atom);
+		struct ofono_modem *modem;
 
 		operator = get_operator_display_name(netreg);
 
@@ -433,6 +453,11 @@ static void set_network_operator_name(struct network_operator_data *opd,
 					OFONO_NETWORK_REGISTRATION_INTERFACE,
 					"Name", DBUS_TYPE_STRING,
 					&operator);
+
+		modem = __ofono_atom_get_modem(netreg->atom);
+		__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
+						notify_emulator_operator_name,
+						operator);
 	}
 
 	/* Don't emit when only operator name is reported */
@@ -481,13 +506,19 @@ static void set_network_operator_eons_info(struct network_operator_data *opd,
 
 		if (opd == netreg->current_operator) {
 			const char *npath = __ofono_atom_get_path(netreg->atom);
-			const char *operator =
-				get_operator_display_name(netreg);
+			char *operator = get_operator_display_name(netreg);
+			struct ofono_modem *modem;
 
 			ofono_dbus_signal_property_changed(conn, npath,
 					OFONO_NETWORK_REGISTRATION_INTERFACE,
 					"Name", DBUS_TYPE_STRING,
 					&operator);
+
+			modem = __ofono_atom_get_modem(netreg->atom);
+			__ofono_modem_foreach_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						notify_emulator_operator_name,
+						operator);
 		}
 	}
 
@@ -1178,7 +1209,8 @@ static void current_operator_callback(const struct ofono_error *error,
 	struct ofono_netreg *netreg = data;
 	const char *path = __ofono_atom_get_path(netreg->atom);
 	GSList *op = NULL;
-	const char *operator;
+	char *operator;
+	struct ofono_modem *modem;
 
 	DBG("%p, %p", netreg, netreg->current_operator);
 
@@ -1254,6 +1286,11 @@ emit:
 					"Name", DBUS_TYPE_STRING,
 					&operator);
 
+	modem = __ofono_atom_get_modem(netreg->atom);
+	__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
+					notify_emulator_operator_name,
+					operator);
+
 	if (netreg->current_operator) {
 		if (netreg->current_operator->mcc[0] != '\0') {
 			const char *mcc = netreg->current_operator->mcc;
@@ -1540,7 +1577,8 @@ static void sim_spdi_read_cb(int ok, int length, int record,
 	if (netreg->status == NETWORK_REGISTRATION_STATUS_ROAMING) {
 		DBusConnection *conn = ofono_dbus_get_connection();
 		const char *path = __ofono_atom_get_path(netreg->atom);
-		const char *operator;
+		char *operator;
+		struct ofono_modem *modem;
 
 		if (!sim_spdi_lookup(netreg->spdi,
 					current->mcc, current->mnc))
@@ -1552,6 +1590,11 @@ static void sim_spdi_read_cb(int ok, int length, int record,
 					OFONO_NETWORK_REGISTRATION_INTERFACE,
 					"Name", DBUS_TYPE_STRING,
 					&operator);
+
+		modem = __ofono_atom_get_modem(netreg->atom);
+		__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
+						notify_emulator_operator_name,
+						operator);
 	}
 }
 
@@ -1609,7 +1652,8 @@ static void sim_spn_read_cb(int ok, int length, int record,
 	if (netreg->current_operator) {
 		DBusConnection *conn = ofono_dbus_get_connection();
 		const char *path = __ofono_atom_get_path(netreg->atom);
-		const char *operator;
+		char *operator;
+		struct ofono_modem *modem;
 
 		operator = get_operator_display_name(netreg);
 
@@ -1617,6 +1661,11 @@ static void sim_spn_read_cb(int ok, int length, int record,
 					OFONO_NETWORK_REGISTRATION_INTERFACE,
 					"Name", DBUS_TYPE_STRING,
 					&operator);
+
+		modem = __ofono_atom_get_modem(netreg->atom);
+		__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
+						notify_emulator_operator_name,
+						operator);
 	}
 }
 
@@ -1704,9 +1753,16 @@ static void netreg_unregister(struct ofono_atom *atom)
 	__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
 				notify_emulator_status,
 				GINT_TO_POINTER(0));
+
 	__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
 				notify_emulator_strength, GINT_TO_POINTER(0));
 
+	__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
+				notify_emulator_mode, GINT_TO_POINTER(0));
+
+	__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
+				notify_emulator_operator_name, "");
+
 	__ofono_modem_remove_atom_watch(modem, netreg->hfp_watch);
 
 	__ofono_watchlist_free(netreg->status_watches);
@@ -1875,7 +1931,8 @@ static void sim_spn_spdi_changed(int id, void *userdata)
 	if (netreg->current_operator) {
 		DBusConnection *conn = ofono_dbus_get_connection();
 		const char *path = __ofono_atom_get_path(netreg->atom);
-		const char *operator;
+		char *operator;
+		struct ofono_modem *modem;
 
 		operator = get_operator_display_name(netreg);
 
@@ -1883,6 +1940,11 @@ static void sim_spn_spdi_changed(int id, void *userdata)
 					OFONO_NETWORK_REGISTRATION_INTERFACE,
 					"Name", DBUS_TYPE_STRING,
 					&operator);
+
+		modem = __ofono_atom_get_modem(netreg->atom);
+		__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
+						notify_emulator_operator_name,
+						operator);
 	}
 
 	ofono_sim_read(netreg->sim_context, SIM_EFSPN_FILEID,
@@ -1901,9 +1963,23 @@ static void emulator_hfp_watch(struct ofono_atom *atom,
 		__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
 				notify_emulator_status,
 				GINT_TO_POINTER(netreg->status));
+
 		__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
 				notify_emulator_strength,
 				GINT_TO_POINTER(netreg->signal_strength));
+
+		__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
+				notify_emulator_mode,
+				GINT_TO_POINTER(netreg->mode));
+
+		if (netreg->current_operator) {
+			char *operator = get_operator_display_name(netreg);
+
+			__ofono_modem_foreach_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						notify_emulator_operator_name,
+						operator);
+		}
 	}
 }
 
-- 
1.7.1


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

* Re: [PATCH 2/4] emulator: add call and callsetup indicators
  2011-03-17 16:50 ` [PATCH 2/4] emulator: add " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-03-17 21:14   ` Denis Kenzior
  0 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2011-03-17 21:14 UTC (permalink / raw)
  To: ofono

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

Hi Frédéric,

On 03/17/2011 11:50 AM, Frédéric Danis wrote:
> ---
>  src/emulator.c  |    3 ++
>  src/voicecall.c |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 89 insertions(+), 0 deletions(-)
> 
> diff --git a/src/emulator.c b/src/emulator.c
> index c84f0a9..864e50b 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -455,6 +455,9 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
>  
>  	if (em->type == OFONO_EMULATOR_TYPE_HFP) {
>  		emulator_add_indicator(em, OFONO_EMULATOR_IND_SERVICE, 0, 1, 0);
> +		emulator_add_indicator(em, OFONO_EMULATOR_IND_CALL, 0, 1, 0);
> +		emulator_add_indicator(em, OFONO_EMULATOR_IND_CALLSETUP, 0, 3,
> +									0);
>  		emulator_add_indicator(em, OFONO_EMULATOR_IND_SIGNAL, 0, 5, 0);
>  		emulator_add_indicator(em, OFONO_EMULATOR_IND_ROAMING, 0, 1, 0);
>  		emulator_add_indicator(em, OFONO_EMULATOR_IND_BATTERY, 0, 5, 5);
> diff --git a/src/voicecall.c b/src/voicecall.c
> index cb5258d..d0ddad6 100644
> --- a/src/voicecall.c
> +++ b/src/voicecall.c
> @@ -59,6 +59,7 @@ struct ofono_voicecall {
>  	struct dial_request *dial_req;
>  	GQueue *toneq;
>  	guint tone_source;
> +	unsigned int hfp_watch;
>  };
>  
>  struct voicecall {
> @@ -692,6 +693,55 @@ static void voicecall_emit_multiparty(struct voicecall *call, gboolean mpty)
>  						&val);
>  }
>  
> +static void notify_emulator_call_status_cb(struct ofono_atom *atom, void *data)
> +{
> +	struct ofono_emulator *em = __ofono_atom_get_data(atom);
> +
> +	switch (GPOINTER_TO_INT(data)) {
> +	case CALL_STATUS_ACTIVE:
> +		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALL,
> +						OFONO_EMULATOR_CALL_ACTIVE);
> +		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
> +					OFONO_EMULATOR_CALLSETUP_INACTIVE);
> +		break;
> +
> +	case CALL_STATUS_DIALING:
> +		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
> +					OFONO_EMULATOR_CALLSETUP_OUTGOING);
> +		break;
> +
> +	case CALL_STATUS_ALERTING:
> +		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
> +					OFONO_EMULATOR_CALLSETUP_ALERTING);
> +		break;
> +
> +	case CALL_STATUS_INCOMING:
> +		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
> +					OFONO_EMULATOR_CALLSETUP_INCOMING);
> +		break;
> +
> +	case CALL_STATUS_DISCONNECTED:
> +		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALL,
> +						OFONO_EMULATOR_CALL_INACTIVE);
> +		ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
> +					OFONO_EMULATOR_CALLSETUP_INACTIVE);
> +		break;
> +
> +	case CALL_STATUS_WAITING:
> +	case CALL_STATUS_HELD:
> +		break;
> +	}
> +}
> +

So I don't think this will really work once you introduce multiparty
calls.  The indicators depend on the state of all calls, not just one
particular call.  As an example, you can have one party of an active
mpty drop which would cause 'call' to go to inactive, even though you
still have other calls active.

In addition, waiting calls should trigger a callsetup=1.  See 4.22.1.

You might have to put the logic into voicecall.c itself.  Something like:

if (have_dialing)
	callsetup = 2
elif (have_alerting)
	callsetup = 3
elif (have_incoming || have_waiting)
	callsetup = 1
else
	callsetup = 0

And you have to pay very close attention to the order in which the
indicators are reported.  Look at the logic inside
drivers/hfpmodem/voicecall.c for what we expect, the BT HFP1.5 diagrams and

> +static void notify_emulator_call_status(struct ofono_voicecall *vc, int status)
> +{
> +	struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
> +
> +	__ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_EMULATOR_HFP,
> +					notify_emulator_call_status_cb,
> +					GINT_TO_POINTER(status));
> +}
> +
>  static void voicecall_set_call_status(struct voicecall *call, int status)
>  {
>  	DBusConnection *conn = ofono_dbus_get_connection();
> @@ -714,6 +764,8 @@ static void voicecall_set_call_status(struct voicecall *call, int status)
>  						"State", DBUS_TYPE_STRING,
>  						&status_str);
>  
> +	notify_emulator_call_status(call->vc, status);
> +
>  	if (status == CALL_STATUS_ACTIVE &&
>  		(old_status == CALL_STATUS_INCOMING ||
>  			old_status == CALL_STATUS_DIALING ||
> @@ -1043,6 +1095,8 @@ static void voicecalls_emit_call_added(struct ofono_voicecall *vc,
>  	DBusMessageIter dict;
>  	const char *path;
>  
> +	notify_emulator_call_status(vc, v->call->status);
> +
>  	path = __ofono_atom_get_path(vc->atom);
>  
>  	signal = dbus_message_new_signal(path,
> @@ -2188,6 +2242,10 @@ static void voicecall_unregister(struct ofono_atom *atom)
>  	const char *path = __ofono_atom_get_path(atom);
>  	GSList *l;
>  
> +	notify_emulator_call_status(vc, CALL_STATUS_DISCONNECTED);
> +
> +	__ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
> +
>  	if (vc->sim_watch) {
>  		__ofono_modem_remove_atom_watch(modem, vc->sim_watch);
>  		vc->sim_watch = 0;
> @@ -2362,6 +2420,30 @@ static void sim_watch(struct ofono_atom *atom,
>  	sim_state_watch(ofono_sim_get_state(sim), vc);
>  }
>  
> +static void emulator_hfp_watch(struct ofono_atom *atom,
> +				enum ofono_atom_watch_condition cond,
> +				void *data)
> +{
> +	struct ofono_voicecall *vc = data;
> +
> +	if (cond == OFONO_ATOM_WATCH_CONDITION_REGISTERED) {
> +		if (voicecalls_have_with_status(vc, CALL_STATUS_ACTIVE))
> +			notify_emulator_call_status(vc, CALL_STATUS_ACTIVE);
> +
> +		if (voicecalls_have_with_status(vc, CALL_STATUS_DIALING))
> +			notify_emulator_call_status(vc, CALL_STATUS_DIALING);
> +		else if (voicecalls_have_with_status(vc, CALL_STATUS_ALERTING))
> +			notify_emulator_call_status(vc, CALL_STATUS_ALERTING);
> +		else if (voicecalls_have_with_status(vc, CALL_STATUS_INCOMING))
> +			notify_emulator_call_status(vc, CALL_STATUS_INCOMING);
> +		else if (voicecalls_have_with_status(vc, CALL_STATUS_WAITING))
> +			notify_emulator_call_status(vc, CALL_STATUS_WAITING);
> +
> +		if (voicecalls_have_with_status(vc, CALL_STATUS_HELD))
> +			notify_emulator_call_status(vc, CALL_STATUS_HELD);
> +	}
> +}
> +
>  void ofono_voicecall_register(struct ofono_voicecall *vc)
>  {
>  	DBusConnection *conn = ofono_dbus_get_connection();
> @@ -2398,6 +2480,10 @@ void ofono_voicecall_register(struct ofono_voicecall *vc)
>  		sim_watch(sim_atom, OFONO_ATOM_WATCH_CONDITION_REGISTERED, vc);
>  
>  	__ofono_atom_register(vc->atom, voicecall_unregister);
> +
> +	vc->hfp_watch = __ofono_modem_add_atom_watch(modem,
> +					OFONO_ATOM_TYPE_EMULATOR_HFP,
> +					emulator_hfp_watch, vc, NULL);
>  }
>  
>  void ofono_voicecall_remove(struct ofono_voicecall *vc)

Regards,
-Denis

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

* Re: [PATCH 3/4] emulator: add API to set network mode and name
  2011-03-17 16:50 ` [PATCH 3/4] emulator: add API to set network mode and name =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-03-17 21:15   ` Denis Kenzior
  0 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2011-03-17 21:15 UTC (permalink / raw)
  To: ofono

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

Hi Frédéric,

On 03/17/2011 11:50 AM, Frédéric Danis wrote:
> ---
>  include/emulator.h |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/include/emulator.h b/include/emulator.h
> index 701decd..509ec71 100644
> --- a/include/emulator.h
> +++ b/include/emulator.h
> @@ -101,6 +101,11 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(
>  void ofono_emulator_set_indicator(struct ofono_emulator *em,
>  					const char *name, int value);
>  
> +void ofono_emulator_set_network_name(struct ofono_emulator *em,
> +					const char *name);
> +
> +void ofono_emulator_set_network_mode(struct ofono_emulator *em, int mode);
> +

I'd really rather do this inside netreg.c itself.

>  #ifdef __cplusplus
>  }
>  #endif

Regards,
-Denis

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

* Re: [PATCH 4/4] emulator: add +COPS support
  2011-03-17 16:50 ` [PATCH 4/4] emulator: add +COPS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-03-17 21:18   ` Denis Kenzior
  2011-03-18  9:13     ` Frederic Danis
  0 siblings, 1 reply; 9+ messages in thread
From: Denis Kenzior @ 2011-03-17 21:18 UTC (permalink / raw)
  To: ofono

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

Hi Frédéric,

On 03/17/2011 11:50 AM, Frédéric Danis wrote:
> This needs to be in emulator as HFP plugin should answer AT+COPS requests
> even when oFono is not registered on network.
> ---
>  src/emulator.c |   72 ++++++++++++++++++++++++++++++++++++++++++++
>  src/network.c  |   90 +++++++++++++++++++++++++++++++++++++++++++++++++++----
>  2 files changed, 155 insertions(+), 7 deletions(-)
> 
> diff --git a/src/emulator.c b/src/emulator.c
> index 864e50b..eb4f49e 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -49,6 +49,8 @@ struct ofono_emulator {
>  	int events_mode;
>  	gboolean events_ind;
>  	GSList *indicators;
> +	char op_name[17];
> +	int net_mode;
>  };
>  
>  struct indicator {
> @@ -387,6 +389,59 @@ fail:
>  	}
>  }
>  
> +static void cops_cb(GAtServer *server, GAtServerRequestType type,
> +			GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_emulator *em = user_data;
> +	char buf[32];
> +
> +	if (em->type == OFONO_EMULATOR_TYPE_HFP && em->slc == FALSE) {
> +		g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
> +		return;
> +	}
> +

There's no need for this if you use ofono_emulator_add_handler since the
handler_proxy will take care of this detail.

> +	switch (type) {
> +	case G_AT_SERVER_REQUEST_TYPE_QUERY:
> +		sprintf(buf, "+COPS: %d,0,\"%s\"", em->net_mode, em->op_name);
> +		g_at_server_send_info(em->server, buf, TRUE);
> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
> +		break;
> +
> +	case G_AT_SERVER_REQUEST_TYPE_SET:
> +	{
> +		GAtResultIter iter;
> +		int val;
> +
> +		g_at_result_iter_init(&iter, result);
> +		g_at_result_iter_next(&iter, "");
> +
> +		if (!g_at_result_iter_next_number(&iter, &val))
> +			goto fail;
> +
> +		if (val != 3)
> +			goto fail;
> +
> +		if (!g_at_result_iter_next_number(&iter, &val))
> +			goto fail;
> +
> +		if (val != 0)
> +			goto fail;
> +
> +		/* check there is no more parameter */
> +		if (g_at_result_iter_skip_next(&iter))
> +			goto fail;
> +
> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
> +		break;
> +	}
> +
> +	default:
> +fail:
> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
> +		break;
> +	}
> +}
> +

Please move this function to netreg.c.  This should make this patch
quite a bit simpler.

<snip>

Regards,
-Denis

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

* Re: [PATCH 4/4] emulator: add +COPS support
  2011-03-17 21:18   ` Denis Kenzior
@ 2011-03-18  9:13     ` Frederic Danis
  0 siblings, 0 replies; 9+ messages in thread
From: Frederic Danis @ 2011-03-18  9:13 UTC (permalink / raw)
  To: ofono

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

Hello Denis,

Le 17/03/2011 22:18, Denis Kenzior a écrit :
> Hi Frédéric,
>
> On 03/17/2011 11:50 AM, Frédéric Danis wrote:
>> This needs to be in emulator as HFP plugin should answer AT+COPS requests
>> even when oFono is not registered on network.
>> ---
>>   src/emulator.c |   72 ++++++++++++++++++++++++++++++++++++++++++++
>>   src/network.c  |   90 +++++++++++++++++++++++++++++++++++++++++++++++++++----
>>   2 files changed, 155 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/emulator.c b/src/emulator.c
>> index 864e50b..eb4f49e 100644
>> --- a/src/emulator.c
>> +++ b/src/emulator.c
>> @@ -49,6 +49,8 @@ struct ofono_emulator {
>>   	int events_mode;
>>   	gboolean events_ind;
>>   	GSList *indicators;
>> +	char op_name[17];
>> +	int net_mode;
>>   };
>>
>>   struct indicator {
>> @@ -387,6 +389,59 @@ fail:
>>   	}
>>   }
>>
>> +static void cops_cb(GAtServer *server, GAtServerRequestType type,
>> +			GAtResult *result, gpointer user_data)
>> +{
>> +	struct ofono_emulator *em = user_data;
>> +	char buf[32];
>> +
>> +	if (em->type == OFONO_EMULATOR_TYPE_HFP&&  em->slc == FALSE) {
>> +		g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
>> +		return;
>> +	}
>> +
>
> There's no need for this if you use ofono_emulator_add_handler since the
> handler_proxy will take care of this detail.
>
>> +	switch (type) {
>> +	case G_AT_SERVER_REQUEST_TYPE_QUERY:
>> +		sprintf(buf, "+COPS: %d,0,\"%s\"", em->net_mode, em->op_name);
>> +		g_at_server_send_info(em->server, buf, TRUE);
>> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
>> +		break;
>> +
>> +	case G_AT_SERVER_REQUEST_TYPE_SET:
>> +	{
>> +		GAtResultIter iter;
>> +		int val;
>> +
>> +		g_at_result_iter_init(&iter, result);
>> +		g_at_result_iter_next(&iter, "");
>> +
>> +		if (!g_at_result_iter_next_number(&iter,&val))
>> +			goto fail;
>> +
>> +		if (val != 3)
>> +			goto fail;
>> +
>> +		if (!g_at_result_iter_next_number(&iter,&val))
>> +			goto fail;
>> +
>> +		if (val != 0)
>> +			goto fail;
>> +
>> +		/* check there is no more parameter */
>> +		if (g_at_result_iter_skip_next(&iter))
>> +			goto fail;
>> +
>> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
>> +		break;
>> +	}
>> +
>> +	default:
>> +fail:
>> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
>> +		break;
>> +	}
>> +}
>> +
>
> Please move this function to netreg.c.  This should make this patch
> quite a bit simpler.
>
> <snip>
>
> Regards,
> -Denis

If this is moved to netreg.c, AT+COPS requests will not be handled when 
oFono modem is not online.
I understand that there is no problem to reply ERROR to AT+COPS?, but I 
think this is wrong for AT+COPS=3,0.
This is why I do this in emulator.c.

-- 
Frederic Danis                            Open Source Technology Centre
frederic.danis(a)intel.com                              Intel Corporation


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

end of thread, other threads:[~2011-03-18  9:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-17 16:50 [PATCH 0/4] HFP: add call, callsetup indicators and +COPS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-03-17 16:50 ` [PATCH 1/4] emulator: add defines for call and callsetup indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-03-17 16:50 ` [PATCH 2/4] emulator: add " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-03-17 21:14   ` Denis Kenzior
2011-03-17 16:50 ` [PATCH 3/4] emulator: add API to set network mode and name =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-03-17 21:15   ` Denis Kenzior
2011-03-17 16:50 ` [PATCH 4/4] emulator: add +COPS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-03-17 21:18   ` Denis Kenzior
2011-03-18  9:13     ` Frederic Danis

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.