All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] emulator: add simple incoming call support
@ 2011-04-05 15:40 =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-04-05 15:40 ` [PATCH 1/7] emulator: add defines for call, callsetup and callheld indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-05 15:40 UTC (permalink / raw)
  To: ofono

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

Add call related indicators, +CLIP, RING to signal incoming call,
ATA to allow reception and AT+CHUP to reject or finish
of an incoming call in HFP AG

Frédéric Danis (7):
  emulator: add defines for call, callsetup and callheld indicators
  emulator: add call, callsetup and callheld indicators
  emulator: add RING for HFP AG
  emulator: add incoming call API
  emulator: add +CLIP support for HFP AG
  voicecall: add ATA support for HFP emulator
  voicecall: add +CHUP support for HFP emulator

 include/emulator.h |   15 +++
 src/emulator.c     |  106 ++++++++++++++++++
 src/voicecall.c    |  306 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 427 insertions(+), 0 deletions(-)


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

* [PATCH 1/7] emulator: add defines for call, callsetup and callheld indicators
  2011-04-05 15:40 [PATCH 0/7] emulator: add simple incoming call support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-05 15:40 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-04-05 15:40 ` [PATCH 2/7] emulator: add " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-05 15:40 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/include/emulator.h b/include/emulator.h
index 71b7c24..5cd894b 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -36,6 +36,18 @@ 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
+
+#define OFONO_EMULATOR_CALLHELD_NONE 0
+#define OFONO_EMULATOR_CALLHELD_MULTIPLE 1
+#define OFONO_EMULATOR_CALLHELD_ON_HOLD 2
+
 struct ofono_emulator;
 struct ofono_emulator_request;
 
-- 
1.7.1


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

* [PATCH 2/7] emulator: add call, callsetup and callheld indicators
  2011-04-05 15:40 [PATCH 0/7] emulator: add simple incoming call support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-04-05 15:40 ` [PATCH 1/7] emulator: add defines for call, callsetup and callheld indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-05 15:40 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-04-05 15:40 ` [PATCH 3/7] emulator: add RING for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-05 15:40 UTC (permalink / raw)
  To: ofono

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

---
 src/emulator.c  |    5 ++
 src/voicecall.c |  131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 136 insertions(+), 0 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index c84f0a9..2707592 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -455,6 +455,11 @@ 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_CALLHELD, 0, 2,
+									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 469b939..a3ea6de 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 {
@@ -689,6 +690,107 @@ static void voicecall_emit_multiparty(struct voicecall *call, gboolean mpty)
 						&val);
 }
 
+static void emulator_call_status_cb(struct ofono_atom *atom, void *data)
+{
+	struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+	ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALL,
+						GPOINTER_TO_INT(data));
+}
+
+static void emulator_callsetup_status_cb(struct ofono_atom *atom, void *data)
+{
+	struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+	ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
+						GPOINTER_TO_INT(data));
+}
+
+static void emulator_callheld_status_cb(struct ofono_atom *atom, void *data)
+{
+	struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+	ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLHELD,
+						GPOINTER_TO_INT(data));
+}
+
+static void notify_emulator_call_status(struct ofono_voicecall *vc)
+{
+	struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
+	int status;
+	gboolean call = FALSE;
+	gboolean held = FALSE;
+	gboolean incoming = FALSE;
+	gboolean dialing = FALSE;
+	gboolean alerting = FALSE;
+	gboolean waiting = FALSE;
+	GSList *l;
+	struct voicecall *v;
+
+	for (l = vc->call_list; l; l = l->next) {
+		v = l->data;
+
+		switch (v->call->status) {
+		case CALL_STATUS_ACTIVE:
+			call = TRUE;
+			break;
+
+		case CALL_STATUS_HELD:
+			held = TRUE;
+			break;
+
+		case CALL_STATUS_DIALING:
+			dialing = TRUE;
+			break;
+
+		case CALL_STATUS_ALERTING:
+			alerting = TRUE;
+			break;
+
+		case CALL_STATUS_INCOMING:
+			incoming = TRUE;
+			break;
+
+		case CALL_STATUS_WAITING:
+			waiting = TRUE;
+			break;
+		}
+	}
+
+	status = call || held ? OFONO_EMULATOR_CALL_ACTIVE :
+					OFONO_EMULATOR_CALL_INACTIVE;
+
+	__ofono_modem_foreach_registered_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						emulator_call_status_cb,
+						GINT_TO_POINTER(status));
+
+	if (incoming || waiting)
+		status = OFONO_EMULATOR_CALLSETUP_INCOMING;
+	else if (dialing)
+		status = OFONO_EMULATOR_CALLSETUP_OUTGOING;
+	else if (alerting)
+		status = OFONO_EMULATOR_CALLSETUP_ALERTING;
+	else
+		status = OFONO_EMULATOR_CALLSETUP_INACTIVE;
+
+	__ofono_modem_foreach_registered_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						emulator_callsetup_status_cb,
+						GINT_TO_POINTER(status));
+
+	if (held)
+		status = call ? OFONO_EMULATOR_CALLHELD_MULTIPLE :
+					OFONO_EMULATOR_CALLHELD_ON_HOLD;
+	else
+		status = OFONO_EMULATOR_CALLHELD_NONE;
+
+	__ofono_modem_foreach_registered_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						emulator_callheld_status_cb,
+						GINT_TO_POINTER(status));
+}
+
 static void voicecall_set_call_status(struct voicecall *call, int status)
 {
 	DBusConnection *conn = ofono_dbus_get_connection();
@@ -711,6 +813,8 @@ static void voicecall_set_call_status(struct voicecall *call, int status)
 						"State", DBUS_TYPE_STRING,
 						&status_str);
 
+	notify_emulator_call_status(call->vc);
+
 	if (status == CALL_STATUS_ACTIVE &&
 		(old_status == CALL_STATUS_INCOMING ||
 			old_status == CALL_STATUS_DIALING ||
@@ -1040,6 +1144,8 @@ static void voicecalls_emit_call_added(struct ofono_voicecall *vc,
 	DBusMessageIter dict;
 	const char *path;
 
+	notify_emulator_call_status(vc);
+
 	path = __ofono_atom_get_path(vc->atom);
 
 	signal = dbus_message_new_signal(path,
@@ -2203,6 +2309,19 @@ static void voicecall_unregister(struct ofono_atom *atom)
 	const char *path = __ofono_atom_get_path(atom);
 	GSList *l;
 
+	__ofono_modem_foreach_registered_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						emulator_call_status_cb, 0);
+	__ofono_modem_foreach_registered_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						emulator_callsetup_status_cb,
+						0);
+	__ofono_modem_foreach_registered_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						emulator_callheld_status_cb, 0);
+
+	__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;
@@ -2378,6 +2497,14 @@ 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)
+{
+	if (cond == OFONO_ATOM_WATCH_CONDITION_REGISTERED)
+		notify_emulator_call_status(data);
+}
+
 void ofono_voicecall_register(struct ofono_voicecall *vc)
 {
 	DBusConnection *conn = ofono_dbus_get_connection();
@@ -2408,6 +2535,10 @@ void ofono_voicecall_register(struct ofono_voicecall *vc)
 						sim_watch, vc, NULL);
 
 	__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] 10+ messages in thread

* [PATCH 3/7] emulator: add RING for HFP AG
  2011-04-05 15:40 [PATCH 0/7] emulator: add simple incoming call support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-04-05 15:40 ` [PATCH 1/7] emulator: add defines for call, callsetup and callheld indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-04-05 15:40 ` [PATCH 2/7] emulator: add " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-05 15:40 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-04-05 15:49   ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau
  2011-04-05 15:40 ` [PATCH 4/7] emulator: add incoming call API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 10+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-05 15:40 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/src/emulator.c b/src/emulator.c
index 2707592..104693d 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -37,6 +37,8 @@
 #define DUN_DNS_SERVER_1       "10.10.10.10"
 #define DUN_DNS_SERVER_2       "10.10.10.11"
 
+#define RING_TIMEOUT 3
+
 struct ofono_emulator {
 	struct ofono_atom *atom;
 	enum ofono_emulator_type type;
@@ -49,6 +51,8 @@ struct ofono_emulator {
 	int events_mode;
 	gboolean events_ind;
 	GSList *indicators;
+	guint ring;
+	gboolean active_call;
 };
 
 struct indicator {
@@ -177,6 +181,18 @@ error:
 	g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
 }
 
+static gboolean ring_cb(gpointer user_data)
+{
+	struct ofono_emulator *em = user_data;
+
+	if (em->type == OFONO_EMULATOR_TYPE_HFP && em->slc == FALSE)
+		return TRUE;
+
+	g_at_server_send_unsolicited(em->server, "RING");
+
+	return TRUE;
+}
+
 static void brsf_cb(GAtServer *server, GAtServerRequestType type,
 			GAtResult *result, gpointer user_data)
 {
@@ -418,6 +434,11 @@ static void emulator_unregister(struct ofono_atom *atom)
 		em->source = 0;
 	}
 
+	if (em->ring) {
+		g_source_remove(em->ring);
+		em->ring = 0;
+	}
+
 	for (l = em->indicators; l; l = l->next) {
 		struct indicator *ind = l->data;
 
@@ -697,11 +718,35 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 
 		ind->value = value;
 
+		if (g_str_equal(name, OFONO_EMULATOR_IND_CALL) == TRUE)
+			em->active_call = value;
+
 		if (em->events_mode == 3 && em->events_ind && em->slc) {
 			sprintf(buf, "+CIEV: %d,%d", i, ind->value);
 			g_at_server_send_info(em->server, buf, TRUE);
 		}
 
+		/*
+		 * Ring timer should be started when callsetup indicator
+		 * is set to Incoming, but only if there is no active or held
+		 * call (active indicator set to 1)
+		 * It should be stopped for all other values of callsetup
+		 */
+		if (g_str_equal(name, OFONO_EMULATOR_IND_CALLSETUP) == TRUE) {
+			if (value == OFONO_EMULATOR_CALLSETUP_INCOMING &&
+					!em->active_call && em->ring == 0) {
+				ring_cb(em);
+				em->ring = g_timeout_add_seconds(RING_TIMEOUT,
+								ring_cb, em);
+			}
+
+			if (value != OFONO_EMULATOR_CALLSETUP_INCOMING &&
+					em->ring) {
+				g_source_remove(em->ring);
+				em->ring = 0;
+			}
+		}
+
 		return;
 	}
 }
-- 
1.7.1


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

* [PATCH 4/7] emulator: add incoming call API
  2011-04-05 15:40 [PATCH 0/7] emulator: add simple incoming call support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (2 preceding siblings ...)
  2011-04-05 15:40 ` [PATCH 3/7] emulator: add RING for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-05 15:40 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-04-05 15:40 ` [PATCH 5/7] emulator: add +CLIP support for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-05 15:40 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/include/emulator.h b/include/emulator.h
index 5cd894b..55e3b9c 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -105,6 +105,9 @@ 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_incoming_call(struct ofono_emulator *em,
+					struct ofono_call *call);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.1


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

* [PATCH 5/7] emulator: add +CLIP support for HFP AG
  2011-04-05 15:40 [PATCH 0/7] emulator: add simple incoming call support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (3 preceding siblings ...)
  2011-04-05 15:40 ` [PATCH 4/7] emulator: add incoming call API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-05 15:40 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-04-05 15:40 ` [PATCH 6/7] voicecall: add ATA support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-04-05 15:40 ` [PATCH 7/7] voicecall: add +CHUP " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  6 siblings, 0 replies; 10+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-05 15:40 UTC (permalink / raw)
  To: ofono

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

---
 src/emulator.c  |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/voicecall.c |   17 ++++++++++++++-
 2 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index 104693d..5a1e509 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -29,6 +29,7 @@
 #include <glib.h>
 
 #include "ofono.h"
+#include "common.h"
 #include "gatserver.h"
 #include "gatppp.h"
 
@@ -53,6 +54,9 @@ struct ofono_emulator {
 	GSList *indicators;
 	guint ring;
 	gboolean active_call;
+	struct ofono_call *incoming;
+	gboolean clip;
+	char clip_str[OFONO_MAX_PHONE_NUMBER_LENGTH + 13 + 1];
 };
 
 struct indicator {
@@ -184,12 +188,25 @@ error:
 static gboolean ring_cb(gpointer user_data)
 {
 	struct ofono_emulator *em = user_data;
+	const char *phone;
 
 	if (em->type == OFONO_EMULATOR_TYPE_HFP && em->slc == FALSE)
 		return TRUE;
 
 	g_at_server_send_unsolicited(em->server, "RING");
 
+	if (!em->clip || !em->incoming ||
+			em->incoming->clip_validity != CLIP_VALIDITY_VALID)
+		return TRUE;
+
+	if (em->clip_str[0] == '\0') {
+		phone = phone_number_to_string(&em->incoming->phone_number);
+		sprintf(em->clip_str, "+CLIP: \"%s\",%d", phone,
+				em->incoming->phone_number.type);
+	}
+
+	g_at_server_send_unsolicited(em->server, em->clip_str);
+
 	return TRUE;
 }
 
@@ -403,6 +420,35 @@ fail:
 	}
 }
 
+static void clip_cb(GAtServer *server, GAtServerRequestType type,
+			GAtResult *result, gpointer user_data)
+{
+	struct ofono_emulator *em = user_data;
+	GAtResultIter iter;
+	int val;
+
+	switch (type) {
+	case G_AT_SERVER_REQUEST_TYPE_SET:
+		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 != 0 && val != 1)
+			goto fail;
+
+		em->clip = val;
+
+		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);
+	};
+}
+
 static void emulator_add_indicator(struct ofono_emulator *em, const char* name,
 					int min, int max, int dflt)
 {
@@ -488,6 +534,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, "+CLIP", clip_cb, em, NULL);
 	}
 
 	__ofono_atom_register(em->atom, emulator_unregister);
@@ -531,6 +578,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->clip_str[0] = '\0';
 
 	em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
 							emulator_remove, em);
@@ -744,9 +792,17 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 					em->ring) {
 				g_source_remove(em->ring);
 				em->ring = 0;
+				em->incoming = NULL;
+				em->clip_str[0] = '\0';
 			}
 		}
 
 		return;
 	}
 }
+
+void ofono_emulator_incoming_call(struct ofono_emulator *em,
+					struct ofono_call *call)
+{
+	em->incoming = call;
+}
diff --git a/src/voicecall.c b/src/voicecall.c
index a3ea6de..8e68243 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -714,6 +714,13 @@ static void emulator_callheld_status_cb(struct ofono_atom *atom, void *data)
 						GPOINTER_TO_INT(data));
 }
 
+static void emulator_incoming_cb(struct ofono_atom *atom, void *data)
+{
+	struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+	ofono_emulator_incoming_call(em, data);
+}
+
 static void notify_emulator_call_status(struct ofono_voicecall *vc)
 {
 	struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
@@ -726,6 +733,7 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)
 	gboolean waiting = FALSE;
 	GSList *l;
 	struct voicecall *v;
+	struct ofono_call *caller = NULL;
 
 	for (l = vc->call_list; l; l = l->next) {
 		v = l->data;
@@ -749,10 +757,12 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)
 
 		case CALL_STATUS_INCOMING:
 			incoming = TRUE;
+			caller = v->call;
 			break;
 
 		case CALL_STATUS_WAITING:
 			waiting = TRUE;
+			caller = v->call;
 			break;
 		}
 	}
@@ -765,9 +775,12 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)
 						emulator_call_status_cb,
 						GINT_TO_POINTER(status));
 
-	if (incoming || waiting)
+	if (incoming || waiting) {
 		status = OFONO_EMULATOR_CALLSETUP_INCOMING;
-	else if (dialing)
+		__ofono_modem_foreach_registered_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						emulator_incoming_cb, caller);
+	} else if (dialing)
 		status = OFONO_EMULATOR_CALLSETUP_OUTGOING;
 	else if (alerting)
 		status = OFONO_EMULATOR_CALLSETUP_ALERTING;
-- 
1.7.1


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

* [PATCH 6/7] voicecall: add ATA support for HFP emulator
  2011-04-05 15:40 [PATCH 0/7] emulator: add simple incoming call support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (4 preceding siblings ...)
  2011-04-05 15:40 ` [PATCH 5/7] emulator: add +CLIP support for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-05 15:40 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-04-05 15:40 ` [PATCH 7/7] voicecall: add +CHUP " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  6 siblings, 0 replies; 10+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-05 15:40 UTC (permalink / raw)
  To: ofono

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

---
 src/voicecall.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index 8e68243..cf02bb6 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2314,6 +2314,13 @@ void ofono_voicecall_driver_unregister(const struct ofono_voicecall_driver *d)
 	g_drivers = g_slist_remove(g_drivers, (void *) d);
 }
 
+static void emulator_remove_handler(struct ofono_atom *atom, void *data)
+{
+	struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+	ofono_emulator_remove_handler(em, data);
+}
+
 static void voicecall_unregister(struct ofono_atom *atom)
 {
 	DBusConnection *conn = ofono_dbus_get_connection();
@@ -2333,6 +2340,11 @@ static void voicecall_unregister(struct ofono_atom *atom)
 						OFONO_ATOM_TYPE_EMULATOR_HFP,
 						emulator_callheld_status_cb, 0);
 
+	__ofono_modem_foreach_registered_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						emulator_remove_handler,
+						"A");
+
 	__ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
 
 	if (vc->sim_watch) {
@@ -2510,12 +2522,54 @@ static void sim_watch(struct ofono_atom *atom,
 	sim_state_watch(ofono_sim_get_state(sim), vc);
 }
 
+static void emulator_generic_cb(const struct ofono_error *error, void *data)
+{
+	struct ofono_emulator *em = data;
+	struct ofono_error result;
+
+	result.type = error->type;
+
+	ofono_emulator_send_final(em, &result);
+}
+
+static void emulator_ata_cb(struct ofono_emulator *em,
+			struct ofono_emulator_request *req, void *userdata)
+{
+	struct ofono_voicecall *vc = userdata;
+	struct ofono_error result;
+
+	result.error = 0;
+
+	switch (ofono_emulator_request_get_type(req)) {
+	case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY:
+		if (!voicecalls_have_incoming(vc))
+			goto fail;
+
+		if (vc->driver->answer == NULL)
+			goto fail;
+
+		vc->driver->answer(vc, emulator_generic_cb, em);
+		break;
+
+	default:
+fail:
+		result.type = OFONO_ERROR_TYPE_FAILURE;
+		ofono_emulator_send_final(em, &result);
+	};
+}
+
 static void emulator_hfp_watch(struct ofono_atom *atom,
 				enum ofono_atom_watch_condition cond,
 				void *data)
 {
-	if (cond == OFONO_ATOM_WATCH_CONDITION_REGISTERED)
-		notify_emulator_call_status(data);
+	struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+	if (cond != OFONO_ATOM_WATCH_CONDITION_REGISTERED)
+		return;
+
+	notify_emulator_call_status(data);
+
+	ofono_emulator_add_handler(em, "A", emulator_ata_cb, data, NULL);
 }
 
 void ofono_voicecall_register(struct ofono_voicecall *vc)
-- 
1.7.1


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

* [PATCH 7/7] voicecall: add +CHUP support for HFP emulator
  2011-04-05 15:40 [PATCH 0/7] emulator: add simple incoming call support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (5 preceding siblings ...)
  2011-04-05 15:40 ` [PATCH 6/7] voicecall: add ATA support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-05 15:40 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  6 siblings, 0 replies; 10+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-05 15:40 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/src/voicecall.c b/src/voicecall.c
index cf02bb6..8aec0a0 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -60,6 +60,7 @@ struct ofono_voicecall {
 	GQueue *toneq;
 	guint tone_source;
 	unsigned int hfp_watch;
+	GSList *hfp_release_list;
 };
 
 struct voicecall {
@@ -95,6 +96,11 @@ struct tone_queue_entry {
 	int id;
 };
 
+struct emulator_release {
+	struct ofono_voicecall *vc;
+	struct ofono_emulator *em;
+};
+
 static const char *default_en_list[] = { "911", "112", NULL };
 static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",
 						"08", "000", NULL };
@@ -102,6 +108,7 @@ static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",
 static void generic_callback(const struct ofono_error *error, void *data);
 static void multirelease_callback(const struct ofono_error *err, void *data);
 static gboolean tone_request_run(gpointer user_data);
+static void emulator_release_next(struct emulator_release *er);
 
 static gint call_compare_by_id(gconstpointer a, gconstpointer b)
 {
@@ -2344,6 +2351,10 @@ static void voicecall_unregister(struct ofono_atom *atom)
 						OFONO_ATOM_TYPE_EMULATOR_HFP,
 						emulator_remove_handler,
 						"A");
+	__ofono_modem_foreach_registered_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						emulator_remove_handler,
+						"+CHUP");
 
 	__ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
 
@@ -2558,6 +2569,102 @@ fail:
 	};
 }
 
+static void emulator_multirelease_callback(const struct ofono_error *error,
+						void *data)
+{
+	struct emulator_release *er = data;
+	struct ofono_voicecall *vc = er->vc;
+
+	if (vc->hfp_release_list != NULL) {
+		emulator_release_next(er);
+		return;
+	}
+
+	emulator_generic_cb(error, er->em);
+
+	g_free(er);
+}
+
+static void emulator_release_next(struct emulator_release *er)
+{
+	struct ofono_voicecall *vc;
+	struct voicecall *call;
+
+	vc = er->vc;
+
+	call = vc->hfp_release_list->data;
+
+	vc->hfp_release_list = g_slist_remove(vc->hfp_release_list, call);
+
+	vc->driver->release_specific(vc, call->call->id,
+				emulator_multirelease_callback, er);
+}
+
+static void emulator_chup_cb(struct ofono_emulator *em,
+			struct ofono_emulator_request *req, void *userdata)
+{
+	struct ofono_voicecall *vc = userdata;
+	struct ofono_error result;
+	struct emulator_release *er;
+	GSList *l;
+	struct voicecall *call;
+
+	result.error = 0;
+
+	switch (ofono_emulator_request_get_type(req)) {
+	case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY:
+		if (vc->driver->release_specific == NULL &&
+				vc->driver->hangup_active == NULL)
+			goto fail;
+
+		if (vc->driver->hangup_active) {
+			vc->driver->hangup_active(vc, emulator_generic_cb, em);
+			goto done;
+		}
+
+		/* if there is already a CHUP pending we return an error */
+		if (vc->hfp_release_list)
+			goto fail;
+
+		er = g_try_new0(struct emulator_release, 1);
+		if (er == NULL) {
+			ofono_error("Unable to allocate release structure");
+			goto fail;
+		}
+
+		er->vc = vc;
+		er->em = em;
+
+		for (l = vc->call_list; l; l = l->next) {
+			call = l->data;
+
+			if (call->call->status == CALL_STATUS_WAITING ||
+					call->call->status == CALL_STATUS_HELD)
+				continue;
+
+			vc->hfp_release_list = g_slist_prepend(
+						vc->hfp_release_list,
+						l->data);
+		}
+
+		if (vc->hfp_release_list == NULL) {
+			g_free(er);
+			goto fail;
+		}
+
+		emulator_release_next(er);
+
+done:
+		dial_request_user_cancel(vc, NULL);
+		break;
+
+	default:
+fail:
+		result.type = OFONO_ERROR_TYPE_FAILURE;
+		ofono_emulator_send_final(em, &result);
+	};
+}
+
 static void emulator_hfp_watch(struct ofono_atom *atom,
 				enum ofono_atom_watch_condition cond,
 				void *data)
@@ -2570,6 +2677,7 @@ static void emulator_hfp_watch(struct ofono_atom *atom,
 	notify_emulator_call_status(data);
 
 	ofono_emulator_add_handler(em, "A", emulator_ata_cb, data, NULL);
+	ofono_emulator_add_handler(em, "+CHUP", emulator_chup_cb, data, NULL);
 }
 
 void ofono_voicecall_register(struct ofono_voicecall *vc)
-- 
1.7.1


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

* Re: [PATCH 3/7] emulator: add RING for HFP AG
  2011-04-05 15:40 ` [PATCH 3/7] emulator: add RING for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-05 15:49   ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau
  2011-04-05 15:54     ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau
  0 siblings, 1 reply; 10+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau @ 2011-04-05 15:49 UTC (permalink / raw)
  To: ofono

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

j'aime pas cette variable

+	gboolean active_call;

d'autant plus que call est le premier indicateur de la liste, c'est donc 
une copie de ((struct indicator*)indicators->data)->value

On 04/05/2011 05:40 PM, Frédéric Danis wrote:
> ---
>   src/emulator.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
>   1 files changed, 45 insertions(+), 0 deletions(-)
>
> diff --git a/src/emulator.c b/src/emulator.c
> index 2707592..104693d 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -37,6 +37,8 @@
>   #define DUN_DNS_SERVER_1       "10.10.10.10"
>   #define DUN_DNS_SERVER_2       "10.10.10.11"
>
> +#define RING_TIMEOUT 3
> +
>   struct ofono_emulator {
>   	struct ofono_atom *atom;
>   	enum ofono_emulator_type type;
> @@ -49,6 +51,8 @@ struct ofono_emulator {
>   	int events_mode;
>   	gboolean events_ind;
>   	GSList *indicators;
> +	guint ring;
> +	gboolean active_call;
>   };
>
>   struct indicator {
> @@ -177,6 +181,18 @@ error:
>   	g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
>   }
>
> +static gboolean ring_cb(gpointer user_data)
> +{
> +	struct ofono_emulator *em = user_data;
> +
> +	if (em->type == OFONO_EMULATOR_TYPE_HFP&&  em->slc == FALSE)
> +		return TRUE;
> +
> +	g_at_server_send_unsolicited(em->server, "RING");
> +
> +	return TRUE;
> +}
> +
>   static void brsf_cb(GAtServer *server, GAtServerRequestType type,
>   			GAtResult *result, gpointer user_data)
>   {
> @@ -418,6 +434,11 @@ static void emulator_unregister(struct ofono_atom *atom)
>   		em->source = 0;
>   	}
>
> +	if (em->ring) {
> +		g_source_remove(em->ring);
> +		em->ring = 0;
> +	}
> +
>   	for (l = em->indicators; l; l = l->next) {
>   		struct indicator *ind = l->data;
>
> @@ -697,11 +718,35 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
>
>   		ind->value = value;
>
> +		if (g_str_equal(name, OFONO_EMULATOR_IND_CALL) == TRUE)
> +			em->active_call = value;
> +
>   		if (em->events_mode == 3&&  em->events_ind&&  em->slc) {
>   			sprintf(buf, "+CIEV: %d,%d", i, ind->value);
>   			g_at_server_send_info(em->server, buf, TRUE);
>   		}
>
> +		/*
> +		 * Ring timer should be started when callsetup indicator
> +		 * is set to Incoming, but only if there is no active or held
> +		 * call (active indicator set to 1)
> +		 * It should be stopped for all other values of callsetup
> +		 */
> +		if (g_str_equal(name, OFONO_EMULATOR_IND_CALLSETUP) == TRUE) {
> +			if (value == OFONO_EMULATOR_CALLSETUP_INCOMING&&
> +					!em->active_call&&  em->ring == 0) {
> +				ring_cb(em);
> +				em->ring = g_timeout_add_seconds(RING_TIMEOUT,
> +								ring_cb, em);
> +			}
> +
> +			if (value != OFONO_EMULATOR_CALLSETUP_INCOMING&&
> +					em->ring) {
> +				g_source_remove(em->ring);
> +				em->ring = 0;
> +			}
> +		}
> +
>   		return;
>   	}
>   }


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

* Re: [PATCH 3/7] emulator: add RING for HFP AG
  2011-04-05 15:49   ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau
@ 2011-04-05 15:54     ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau
  0 siblings, 0 replies; 10+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau @ 2011-04-05 15:54 UTC (permalink / raw)
  To: ofono

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

Dear list,

On 04/05/2011 05:49 PM, Frédéric Dalleau wrote:
> j'aime pas cette variable
>
> +    gboolean active_call;
>
> d'autant plus que call est le premier indicateur de la liste, c'est 
> donc une copie de ((struct indicator*)indicators->data)->value
>
Sorry for the spam,

Frederic Dalleau


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

end of thread, other threads:[~2011-04-05 15:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-05 15:40 [PATCH 0/7] emulator: add simple incoming call support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-05 15:40 ` [PATCH 1/7] emulator: add defines for call, callsetup and callheld indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-05 15:40 ` [PATCH 2/7] emulator: add " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-05 15:40 ` [PATCH 3/7] emulator: add RING for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-05 15:49   ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau
2011-04-05 15:54     ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau
2011-04-05 15:40 ` [PATCH 4/7] emulator: add incoming call API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-05 15:40 ` [PATCH 5/7] emulator: add +CLIP support for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-05 15:40 ` [PATCH 6/7] voicecall: add ATA support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-05 15:40 ` [PATCH 7/7] voicecall: add +CHUP " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= 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.