All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Add dial support for HFP emulator
@ 2011-05-12 14:40 =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-05-12 14:40 ` [PATCH 1/4] voicecall: create generic dial function =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-05-12 14:40 UTC (permalink / raw)
  To: ofono

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

Create a generic dial function that can be called by DBus or emulator
Add support of ATD and AT+BLDN
Save last dialed number in /var/lib/ofono/<modem>/voicecall to be used
by AT+BLDN

Frédéric Danis (4):
  voicecall: create generic dial function
  voicecall: add ATD support for HFP emulator
  voicecall: save last dialed number
  voicecall: add +BLDN support for HFP emulator

 src/voicecall.c |  274 +++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 247 insertions(+), 27 deletions(-)


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

* [PATCH 1/4] voicecall: create generic dial function
  2011-05-12 14:40 [PATCH 0/4] Add dial support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-05-12 14:40 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-05-18  4:46   ` Denis Kenzior
  2011-05-12 14:40 ` [PATCH 2/4] voicecall: add ATD support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-05-12 14:40 UTC (permalink / raw)
  To: ofono

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

split manager_dial between generic and dbus parts
---
 src/voicecall.c |  106 +++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 79 insertions(+), 27 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index d46f463..037caac 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -42,6 +42,17 @@
 
 #define VOICECALL_FLAG_SIM_ECC_READY 0x1
 
+enum dial_error {
+	DIAL_NO_ERROR,
+	DIAL_TOO_MANY_CALLS,
+	DIAL_INVALID_PHONE,
+	DIAL_NO_NETWORK,
+	DIAL_NOT_SUPPORTED,
+	DIAL_INCOMING,
+	DIAL_BUSY,
+	DIAL_ACTIVE
+};
+
 GSList *g_drivers = NULL;
 
 struct multi_release {
@@ -1437,59 +1448,100 @@ static void manager_dial_callback(const struct ofono_error *error, void *data)
 		voicecalls_emit_call_added(vc, v);
 }
 
-static DBusMessage *manager_dial(DBusConnection *conn,
-					DBusMessage *msg, void *data)
+static enum dial_error voicecall_dial(struct ofono_voicecall *vc,
+					const char *number,
+					enum ofono_clir_option clir,
+					ofono_voicecall_cb_t cb, void *data)
 {
-	struct ofono_voicecall *vc = data;
 	struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
-	const char *number;
 	struct ofono_phone_number ph;
-	const char *clirstr;
-	enum ofono_clir_option clir;
-
-	if (vc->pending)
-		return __ofono_error_busy(msg);
 
 	if (g_slist_length(vc->call_list) >= MAX_VOICE_CALLS)
-		return __ofono_error_failed(msg);
-
-	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &number,
-					DBUS_TYPE_STRING, &clirstr,
-					DBUS_TYPE_INVALID) == FALSE)
-		return __ofono_error_invalid_args(msg);
+		return DIAL_TOO_MANY_CALLS;
 
 	if (!valid_long_phone_number_format(number))
-		return __ofono_error_invalid_format(msg);
-
-	if (clir_string_to_clir(clirstr, &clir) == FALSE)
-		return __ofono_error_invalid_format(msg);
+		return DIAL_INVALID_PHONE;
 
 	if (ofono_modem_get_online(modem) == FALSE)
-		return __ofono_error_not_available(msg);
+		return DIAL_NO_NETWORK;
 
 	if (vc->driver->dial == NULL)
-		return __ofono_error_not_implemented(msg);
+		return DIAL_NOT_SUPPORTED;
 
 	if (voicecalls_have_incoming(vc))
-		return __ofono_error_failed(msg);
+		return DIAL_INCOMING;
 
 	/* We can't have two dialing/alerting calls, reject outright */
 	if (voicecalls_num_connecting(vc) > 0)
-		return __ofono_error_failed(msg);
+		return DIAL_BUSY;
 
 	if (voicecalls_have_active(vc) && voicecalls_have_held(vc))
-		return __ofono_error_failed(msg);
+		return DIAL_ACTIVE;
 
 	if (is_emergency_number(vc, number) == TRUE)
 		__ofono_modem_inc_emergency_mode(modem);
 
+	string_to_phone_number(number, &ph);
+
+	vc->driver->dial(vc, &ph, clir, cb, vc);
+
+	return DIAL_NO_ERROR;
+}
+
+static DBusMessage *manager_dial(DBusConnection *conn,
+					DBusMessage *msg, void *data)
+{
+	struct ofono_voicecall *vc = data;
+	const char *number;
+	const char *clirstr;
+	enum ofono_clir_option clir;
+	enum dial_error err;
+	DBusMessage *reply = NULL;
+
+	if (vc->pending)
+		return __ofono_error_busy(msg);
+
+	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &number,
+					DBUS_TYPE_STRING, &clirstr,
+					DBUS_TYPE_INVALID) == FALSE)
+		return __ofono_error_invalid_args(msg);
+
+	if (clir_string_to_clir(clirstr, &clir) == FALSE)
+		return __ofono_error_invalid_format(msg);
+
 	vc->pending = dbus_message_ref(msg);
 
-	string_to_phone_number(number, &ph);
+	err = voicecall_dial(vc, number, clir, manager_dial_callback, vc);
+	switch (err) {
+	case DIAL_NO_ERROR:
+		break;
+
+	case DIAL_INVALID_PHONE:
+		reply = __ofono_error_invalid_format(msg);
+		break;
 
-	vc->driver->dial(vc, &ph, clir, manager_dial_callback, vc);
+	case DIAL_NO_NETWORK:
+		reply = __ofono_error_not_available(msg);
+		break;
 
-	return NULL;
+	case DIAL_NOT_SUPPORTED:
+		reply = __ofono_error_not_implemented(msg);
+		break;
+
+	case DIAL_TOO_MANY_CALLS:
+	case DIAL_INCOMING:
+	case DIAL_BUSY:
+	case DIAL_ACTIVE:
+		reply = __ofono_error_failed(msg);
+		break;
+	}
+
+	if (reply != NULL) {
+		dbus_message_unref(msg);
+		vc->pending = NULL;
+	}
+
+	return reply;
 }
 
 static DBusMessage *manager_transfer(DBusConnection *conn,
-- 
1.7.1


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

* [PATCH 2/4] voicecall: add ATD support for HFP emulator
  2011-05-12 14:40 [PATCH 0/4] Add dial support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-05-12 14:40 ` [PATCH 1/4] voicecall: create generic dial function =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-05-12 14:40 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-05-18  4:53   ` Denis Kenzior
  2011-05-12 14:40 ` [PATCH 3/4] voicecall: save last dialed number =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-05-12 14:40 ` [PATCH 4/4] voicecall: add +BLDN support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  3 siblings, 1 reply; 11+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-05-12 14:40 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/src/voicecall.c b/src/voicecall.c
index 037caac..b98c858 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2473,6 +2473,10 @@ static void emulator_hfp_unregister(struct ofono_atom *atom)
 						OFONO_ATOM_TYPE_EMULATOR_HFP,
 						emulator_remove_handler,
 						"+CHLD");
+	__ofono_modem_foreach_registered_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						emulator_remove_handler,
+						"D");
 
 	__ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
 }
@@ -2918,6 +2922,93 @@ fail:
 	ofono_emulator_send_final(em, &result);
 }
 
+static void emulator_dial_callback(const struct ofono_error *error, void *data)
+{
+	struct ofono_voicecall *vc = data;
+	const char *number = NULL;
+	gboolean need_to_emit;
+	struct voicecall *v;
+
+	v = dial_handle_result(vc, error, number, &need_to_emit);
+
+	if (v == NULL) {
+		struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
+
+		if (is_emergency_number(vc, number) == TRUE)
+			__ofono_modem_dec_emergency_mode(modem);
+	}
+
+	if (need_to_emit)
+		voicecalls_emit_call_added(vc, v);
+}
+
+static void emulator_dial(struct ofono_emulator *em, struct ofono_voicecall *vc,
+				const char *number)
+{
+	enum ofono_clir_option clir;
+	struct ofono_error result;
+	enum dial_error err;
+
+	result.error = 0;
+
+	if (number == NULL || number[0] == '\0') {
+		result.type = OFONO_ERROR_TYPE_FAILURE;
+		goto send;
+	}
+
+	if (!strncmp(number, "*31#", 4)) {
+		number += 4;
+		clir = OFONO_CLIR_OPTION_INVOCATION;
+	} else if (!strncmp(number, "#31#", 4)) {
+		number += 4;
+		clir =  OFONO_CLIR_OPTION_SUPPRESSION;
+	} else
+		clir = OFONO_CLIR_OPTION_DEFAULT;
+
+	err = voicecall_dial(vc, number, clir, emulator_dial_callback, vc);
+	switch (err) {
+	case DIAL_NO_ERROR:
+		result.type = OFONO_ERROR_TYPE_NO_ERROR;
+		break;
+
+	case DIAL_NO_NETWORK:
+		result.error = 30;
+		result.type = OFONO_ERROR_TYPE_CME;
+		break;
+
+	case DIAL_INVALID_PHONE:
+	case DIAL_NOT_SUPPORTED:
+	case DIAL_TOO_MANY_CALLS:
+	case DIAL_INCOMING:
+	case DIAL_BUSY:
+	case DIAL_ACTIVE:
+		result.type = OFONO_ERROR_TYPE_FAILURE;
+	}
+
+send:
+	ofono_emulator_send_final(em, &result);
+}
+
+static void emulator_atd_cb(struct ofono_emulator *em,
+			struct ofono_emulator_request *req, void *userdata)
+{
+	struct ofono_voicecall *vc = userdata;
+	const char *str;
+	struct ofono_error result;
+
+	switch (ofono_emulator_request_get_type(req)) {
+	case OFONO_EMULATOR_REQUEST_TYPE_SET:
+		str = ofono_emulator_request_get_raw(req);
+		emulator_dial(em, vc, str);
+		break;
+
+	default:
+		result.error = 0;
+		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)
@@ -2933,6 +3024,7 @@ static void emulator_hfp_watch(struct ofono_atom *atom,
 	ofono_emulator_add_handler(em, "+CHUP", emulator_chup_cb, data, NULL);
 	ofono_emulator_add_handler(em, "+CLCC", emulator_clcc_cb, data, NULL);
 	ofono_emulator_add_handler(em, "+CHLD", emulator_chld_cb, data, NULL);
+	ofono_emulator_add_handler(em, "D", emulator_atd_cb, data, NULL);
 }
 
 void ofono_voicecall_register(struct ofono_voicecall *vc)
-- 
1.7.1


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

* [PATCH 3/4] voicecall: save last dialed number
  2011-05-12 14:40 [PATCH 0/4] Add dial support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-05-12 14:40 ` [PATCH 1/4] voicecall: create generic dial function =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-05-12 14:40 ` [PATCH 2/4] voicecall: add ATD support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-05-12 14:40 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-05-12 14:40 ` [PATCH 4/4] voicecall: add +BLDN support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  3 siblings, 0 replies; 11+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-05-12 14:40 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/src/voicecall.c b/src/voicecall.c
index b98c858..25d8506 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 VOICECALL_STORE "voicecall"
+#define LASTDIAL_GROUP "LastDial"
+
 enum dial_error {
 	DIAL_NO_ERROR,
 	DIAL_TOO_MANY_CALLS,
@@ -82,6 +86,8 @@ struct ofono_voicecall {
 	GQueue *toneq;
 	guint tone_source;
 	unsigned int hfp_watch;
+	GKeyFile *settings;
+	char *imsi;
 };
 
 struct voicecall {
@@ -1485,6 +1491,12 @@ static enum dial_error voicecall_dial(struct ofono_voicecall *vc,
 
 	vc->driver->dial(vc, &ph, clir, cb, vc);
 
+	if (vc->settings) {
+		g_key_file_set_string(vc->settings, LASTDIAL_GROUP,
+					"Number", number);
+		storage_sync(vc->imsi, VOICECALL_STORE, vc->settings);
+	}
+
 	return DIAL_NO_ERROR;
 }
 
@@ -2481,6 +2493,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, VOICECALL_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, VOICECALL_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();
@@ -2491,6 +2530,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;
@@ -2630,6 +2671,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;
 	}
@@ -2642,6 +2686,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


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

* [PATCH 4/4] voicecall: add +BLDN support for HFP emulator
  2011-05-12 14:40 [PATCH 0/4] Add dial support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (2 preceding siblings ...)
  2011-05-12 14:40 ` [PATCH 3/4] voicecall: save last dialed number =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-05-12 14:40 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  3 siblings, 0 replies; 11+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-05-12 14:40 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/src/voicecall.c b/src/voicecall.c
index 25d8506..d72a889 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2489,6 +2489,10 @@ static void emulator_hfp_unregister(struct ofono_atom *atom)
 						OFONO_ATOM_TYPE_EMULATOR_HFP,
 						emulator_remove_handler,
 						"D");
+	__ofono_modem_foreach_registered_atom(modem,
+						OFONO_ATOM_TYPE_EMULATOR_HFP,
+						emulator_remove_handler,
+						"+BLDN");
 
 	__ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
 }
@@ -3054,6 +3058,32 @@ static void emulator_atd_cb(struct ofono_emulator *em,
 	};
 }
 
+static void emulator_bldn_cb(struct ofono_emulator *em,
+			struct ofono_emulator_request *req, void *userdata)
+{
+	struct ofono_voicecall *vc = userdata;
+	const char *str;
+	struct ofono_error result;
+	GError *error = NULL;
+
+	switch (ofono_emulator_request_get_type(req)) {
+	case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY:
+		if (vc->settings == NULL)
+			goto fail;
+
+		str = g_key_file_get_string(vc->settings, LASTDIAL_GROUP,
+						"Number", &error);
+		emulator_dial(em, vc, str);
+		break;
+
+	default:
+fail:
+		result.error = 0;
+		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)
@@ -3070,6 +3100,7 @@ static void emulator_hfp_watch(struct ofono_atom *atom,
 	ofono_emulator_add_handler(em, "+CLCC", emulator_clcc_cb, data, NULL);
 	ofono_emulator_add_handler(em, "+CHLD", emulator_chld_cb, data, NULL);
 	ofono_emulator_add_handler(em, "D", emulator_atd_cb, data, NULL);
+	ofono_emulator_add_handler(em, "+BLDN", emulator_bldn_cb, data, NULL);
 }
 
 void ofono_voicecall_register(struct ofono_voicecall *vc)
-- 
1.7.1


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

* Re: [PATCH 1/4] voicecall: create generic dial function
  2011-05-12 14:40 ` [PATCH 1/4] voicecall: create generic dial function =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-05-18  4:46   ` Denis Kenzior
  0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2011-05-18  4:46 UTC (permalink / raw)
  To: ofono

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

Hi Frédéric,

On 05/12/2011 09:40 AM, Frédéric Danis wrote:
> split manager_dial between generic and dbus parts
> ---
>  src/voicecall.c |  106 +++++++++++++++++++++++++++++++++++++++++--------------
>  1 files changed, 79 insertions(+), 27 deletions(-)
> 
> diff --git a/src/voicecall.c b/src/voicecall.c
> index d46f463..037caac 100644
> --- a/src/voicecall.c
> +++ b/src/voicecall.c
> @@ -42,6 +42,17 @@
>  
>  #define VOICECALL_FLAG_SIM_ECC_READY 0x1
>  
> +enum dial_error {
> +	DIAL_NO_ERROR,
> +	DIAL_TOO_MANY_CALLS,
> +	DIAL_INVALID_PHONE,
> +	DIAL_NO_NETWORK,
> +	DIAL_NOT_SUPPORTED,
> +	DIAL_INCOMING,
> +	DIAL_BUSY,
> +	DIAL_ACTIVE
> +};
> +

Lets try to re-use errno.h for this.

e.g. NO_ERROR -> 0

TOO_MANY_CALLS -> -EPERM

INVALID_PHONE -> -EINVAL

NO_NETWORK -> -ENETDOWN

NOT_SUPPORTED -> -ENOTSUP

INCOMING, BUSY, ACTIVE -> -EBUSY or -EPERM

Regards,
-Denis

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

* Re: [PATCH 2/4] voicecall: add ATD support for HFP emulator
  2011-05-12 14:40 ` [PATCH 2/4] voicecall: add ATD support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-05-18  4:53   ` Denis Kenzior
  2011-05-18 15:33     ` Frederic Danis
  0 siblings, 1 reply; 11+ messages in thread
From: Denis Kenzior @ 2011-05-18  4:53 UTC (permalink / raw)
  To: ofono

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

Hi Frédéric,

On 05/12/2011 09:40 AM, Frédéric Danis wrote:
> ---
>  src/voicecall.c |   92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 92 insertions(+), 0 deletions(-)
> 
> diff --git a/src/voicecall.c b/src/voicecall.c
> index 037caac..b98c858 100644
> --- a/src/voicecall.c
> +++ b/src/voicecall.c
> @@ -2473,6 +2473,10 @@ static void emulator_hfp_unregister(struct ofono_atom *atom)
>  						OFONO_ATOM_TYPE_EMULATOR_HFP,
>  						emulator_remove_handler,
>  						"+CHLD");
> +	__ofono_modem_foreach_registered_atom(modem,
> +						OFONO_ATOM_TYPE_EMULATOR_HFP,
> +						emulator_remove_handler,
> +						"D");
>  
>  	__ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
>  }
> @@ -2918,6 +2922,93 @@ fail:
>  	ofono_emulator_send_final(em, &result);
>  }
>  
> +static void emulator_dial_callback(const struct ofono_error *error, void *data)
> +{
> +	struct ofono_voicecall *vc = data;
> +	const char *number = NULL;
> +	gboolean need_to_emit;
> +	struct voicecall *v;
> +
> +	v = dial_handle_result(vc, error, number, &need_to_emit);
> +
> +	if (v == NULL) {
> +		struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
> +
> +		if (is_emergency_number(vc, number) == TRUE)
> +			__ofono_modem_dec_emergency_mode(modem);
> +	}
> +
> +	if (need_to_emit)
> +		voicecalls_emit_call_added(vc, v);
> +}
> +
> +static void emulator_dial(struct ofono_emulator *em, struct ofono_voicecall *vc,
> +				const char *number)
> +{
> +	enum ofono_clir_option clir;
> +	struct ofono_error result;
> +	enum dial_error err;
> +
> +	result.error = 0;
> +
> +	if (number == NULL || number[0] == '\0') {
> +		result.type = OFONO_ERROR_TYPE_FAILURE;
> +		goto send;
> +	}
> +
> +	if (!strncmp(number, "*31#", 4)) {
> +		number += 4;
> +		clir = OFONO_CLIR_OPTION_INVOCATION;
> +	} else if (!strncmp(number, "#31#", 4)) {
> +		number += 4;
> +		clir =  OFONO_CLIR_OPTION_SUPPRESSION;
> +	} else
> +		clir = OFONO_CLIR_OPTION_DEFAULT;
> +

Actually this is not quite right.  The clir option is determined by the
presence of 'I'/'i' characters at the end of the dial string.  Refer to
27.007 for more details.

oFono does not actually recognize temporary forms of *31/#31 invocation yet.

> +	err = voicecall_dial(vc, number, clir, emulator_dial_callback, vc);
> +	switch (err) {
> +	case DIAL_NO_ERROR:
> +		result.type = OFONO_ERROR_TYPE_NO_ERROR;
> +		break;
> +
> +	case DIAL_NO_NETWORK:
> +		result.error = 30;
> +		result.type = OFONO_ERROR_TYPE_CME;
> +		break;

This might need to be NO CARRIER

> +
> +	case DIAL_INVALID_PHONE:
> +	case DIAL_NOT_SUPPORTED:
> +	case DIAL_TOO_MANY_CALLS:
> +	case DIAL_INCOMING:
> +	case DIAL_BUSY:
> +	case DIAL_ACTIVE:
> +		result.type = OFONO_ERROR_TYPE_FAILURE;
> +	}
> +
> +send:
> +	ofono_emulator_send_final(em, &result);
> +}
> +
> +static void emulator_atd_cb(struct ofono_emulator *em,
> +			struct ofono_emulator_request *req, void *userdata)
> +{
> +	struct ofono_voicecall *vc = userdata;
> +	const char *str;
> +	struct ofono_error result;
> +
> +	switch (ofono_emulator_request_get_type(req)) {
> +	case OFONO_EMULATOR_REQUEST_TYPE_SET:
> +		str = ofono_emulator_request_get_raw(req);
> +		emulator_dial(em, vc, str);
> +		break;
> +
> +	default:
> +		result.error = 0;
> +		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)
> @@ -2933,6 +3024,7 @@ static void emulator_hfp_watch(struct ofono_atom *atom,
>  	ofono_emulator_add_handler(em, "+CHUP", emulator_chup_cb, data, NULL);
>  	ofono_emulator_add_handler(em, "+CLCC", emulator_clcc_cb, data, NULL);
>  	ofono_emulator_add_handler(em, "+CHLD", emulator_chld_cb, data, NULL);
> +	ofono_emulator_add_handler(em, "D", emulator_atd_cb, data, NULL);
>  }
>  
>  void ofono_voicecall_register(struct ofono_voicecall *vc)

Regards,
-Denis

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

* Re: [PATCH 2/4] voicecall: add ATD support for HFP emulator
  2011-05-18  4:53   ` Denis Kenzior
@ 2011-05-18 15:33     ` Frederic Danis
  2011-05-18 16:13       ` Denis Kenzior
  0 siblings, 1 reply; 11+ messages in thread
From: Frederic Danis @ 2011-05-18 15:33 UTC (permalink / raw)
  To: ofono

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

Hello Denis,

Le 18/05/2011 06:53, Denis Kenzior a écrit :
> Hi Frédéric,
>
> On 05/12/2011 09:40 AM, Frédéric Danis wrote:
>> ---
>>   src/voicecall.c |   92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 files changed, 92 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/voicecall.c b/src/voicecall.c
>> index 037caac..b98c858 100644
>> --- a/src/voicecall.c
>> +++ b/src/voicecall.c
>> @@ -2473,6 +2473,10 @@ static void emulator_hfp_unregister(struct ofono_atom *atom)
>>   						OFONO_ATOM_TYPE_EMULATOR_HFP,
>>   						emulator_remove_handler,
>>   						"+CHLD");
>> +	__ofono_modem_foreach_registered_atom(modem,
>> +						OFONO_ATOM_TYPE_EMULATOR_HFP,
>> +						emulator_remove_handler,
>> +						"D");
>>
>>   	__ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
>>   }
>> @@ -2918,6 +2922,93 @@ fail:
>>   	ofono_emulator_send_final(em,&result);
>>   }
>>
>> +static void emulator_dial_callback(const struct ofono_error *error, void *data)
>> +{
>> +	struct ofono_voicecall *vc = data;
>> +	const char *number = NULL;
>> +	gboolean need_to_emit;
>> +	struct voicecall *v;
>> +
>> +	v = dial_handle_result(vc, error, number,&need_to_emit);
>> +
>> +	if (v == NULL) {
>> +		struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
>> +
>> +		if (is_emergency_number(vc, number) == TRUE)
>> +			__ofono_modem_dec_emergency_mode(modem);
>> +	}
>> +
>> +	if (need_to_emit)
>> +		voicecalls_emit_call_added(vc, v);
>> +}
>> +
>> +static void emulator_dial(struct ofono_emulator *em, struct ofono_voicecall *vc,
>> +				const char *number)
>> +{
>> +	enum ofono_clir_option clir;
>> +	struct ofono_error result;
>> +	enum dial_error err;
>> +
>> +	result.error = 0;
>> +
>> +	if (number == NULL || number[0] == '\0') {
>> +		result.type = OFONO_ERROR_TYPE_FAILURE;
>> +		goto send;
>> +	}
>> +
>> +	if (!strncmp(number, "*31#", 4)) {
>> +		number += 4;
>> +		clir = OFONO_CLIR_OPTION_INVOCATION;
>> +	} else if (!strncmp(number, "#31#", 4)) {
>> +		number += 4;
>> +		clir =  OFONO_CLIR_OPTION_SUPPRESSION;
>> +	} else
>> +		clir = OFONO_CLIR_OPTION_DEFAULT;
>> +
>
> Actually this is not quite right.  The clir option is determined by the
> presence of 'I'/'i' characters at the end of the dial string.  Refer to
> 27.007 for more details.
>
> oFono does not actually recognize temporary forms of *31/#31 invocation yet.
>
I added *31/#31 as I found them in telephony-ofono implementation of 
BlueZ HFP AG,
but 27.007 uses I/i,
and HFP 1.5 does not seem to support clir option (ATDdd...dd;)

Should I remove this part of code and only be compatible with HFP specs ?

>> +	err = voicecall_dial(vc, number, clir, emulator_dial_callback, vc);
>> +	switch (err) {
>> +	case DIAL_NO_ERROR:
>> +		result.type = OFONO_ERROR_TYPE_NO_ERROR;
>> +		break;
>> +
>> +	case DIAL_NO_NETWORK:
>> +		result.error = 30;
>> +		result.type = OFONO_ERROR_TYPE_CME;
>> +		break;
>
> This might need to be NO CARRIER
>
As far as I understand, when there is no network, ATD should reply NO 
CARRIER if CMEE error mode is set to 0, or +CME ERROR: 30 if it is set to 1.
So, I think that voicecall should return an OFONO_ERROR_TYPE_CME 30, and 
ofono_emulator_send_final should take care of replying the right string.

Something like :

void ofono_emulator_send_final(struct ofono_emulator *em,
				const struct ofono_error *final)
{
	char buf[256];

	/*
	 * TODO: Handle various CMEE modes and report error strings from
	 * common.c
	 */
	switch (final->type) {
	case OFONO_ERROR_TYPE_CMS:
		sprintf(buf, "+CMS ERROR: %d", final->error);
		g_at_server_send_ext_final(em->server, buf);
		break;

	case OFONO_ERROR_TYPE_CME:
		switch (em->cmee_mode) {
		case 1:
			sprintf(buf, "+CME ERROR: %d", final->error);
			break;

		case 2:
			sprintf(buf, "+CME ERROR: %s",
					telephony_error_to_str(final));
			break;

		default:
			if (final->error == 30) {
				g_at_server_send_final(em->server,
					G_AT_SERVER_RESULT_NO_CARRIER);
				break;
			}

			goto failure;
		}

		g_at_server_send_ext_final(em->server, buf);
		break;

	case OFONO_ERROR_TYPE_NO_ERROR:
		g_at_server_send_final(em->server,
					G_AT_SERVER_RESULT_OK);
		break;

	case OFONO_ERROR_TYPE_CEER:
	case OFONO_ERROR_TYPE_SIM:
	case OFONO_ERROR_TYPE_FAILURE:
failure:
		g_at_server_send_final(em->server,
					G_AT_SERVER_RESULT_ERROR);
		break;
	};
}

Is it Ok ?

Regards

Fred

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


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

* Re: [PATCH 2/4] voicecall: add ATD support for HFP emulator
  2011-05-18 15:33     ` Frederic Danis
@ 2011-05-18 16:13       ` Denis Kenzior
  2011-05-19 16:16         ` Frederic Danis
  0 siblings, 1 reply; 11+ messages in thread
From: Denis Kenzior @ 2011-05-18 16:13 UTC (permalink / raw)
  To: ofono

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

Hi Frederic,

>>> +    if (!strncmp(number, "*31#", 4)) {
>>> +        number += 4;
>>> +        clir = OFONO_CLIR_OPTION_INVOCATION;
>>> +    } else if (!strncmp(number, "#31#", 4)) {
>>> +        number += 4;
>>> +        clir =  OFONO_CLIR_OPTION_SUPPRESSION;
>>> +    } else
>>> +        clir = OFONO_CLIR_OPTION_DEFAULT;
>>> +
>>
>> Actually this is not quite right.  The clir option is determined by the
>> presence of 'I'/'i' characters at the end of the dial string.  Refer to
>> 27.007 for more details.
>>
>> oFono does not actually recognize temporary forms of *31/#31
>> invocation yet.
>>
> I added *31/#31 as I found them in telephony-ofono implementation of
> BlueZ HFP AG,
> but 27.007 uses I/i,
> and HFP 1.5 does not seem to support clir option (ATDdd...dd;)
> 
> Should I remove this part of code and only be compatible with HFP specs ?
> 

Might as well handle the I/i and G/g part according to 27.007 since that
is pretty easy and we'll have to do it anyway.  *31/#31 is really an MMI
code, it should never be sent to the modem, so please remove that for now.

>>> +    err = voicecall_dial(vc, number, clir, emulator_dial_callback, vc);
>>> +    switch (err) {
>>> +    case DIAL_NO_ERROR:
>>> +        result.type = OFONO_ERROR_TYPE_NO_ERROR;
>>> +        break;
>>> +
>>> +    case DIAL_NO_NETWORK:
>>> +        result.error = 30;
>>> +        result.type = OFONO_ERROR_TYPE_CME;
>>> +        break;
>>
>> This might need to be NO CARRIER
>>
> As far as I understand, when there is no network, ATD should reply NO
> CARRIER if CMEE error mode is set to 0, or +CME ERROR: 30 if it is set
> to 1.

Not quite.  CMEE controls the presentation of 'extended' CME ERROR code.
 Either as ERROR, CME ERROR: <num> or CME ERROR: <str>.  NO CARRIER is
not an extended error code at all, and so is only affected by ATV
setting, not CMEE.

> So, I think that voicecall should return an OFONO_ERROR_TYPE_CME 30, and
> ofono_emulator_send_final should take care of replying the right string.
> 

Nope, you have to take your pick, either CME ERROR: 30, or NO CARRIER.
I'd expect most implementations to reply with a NO CARRIER in this case,
but can you check what other implementations do in reality?

Regards,
-Denis

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

* Re: [PATCH 2/4] voicecall: add ATD support for HFP emulator
  2011-05-18 16:13       ` Denis Kenzior
@ 2011-05-19 16:16         ` Frederic Danis
  2011-05-19 16:39           ` Denis Kenzior
  0 siblings, 1 reply; 11+ messages in thread
From: Frederic Danis @ 2011-05-19 16:16 UTC (permalink / raw)
  To: ofono

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

Hello Denis,

Le 18/05/2011 18:13, Denis Kenzior a écrit :
> Hi Frederic,
>
>>>> +    if (!strncmp(number, "*31#", 4)) {
>>>> +        number += 4;
>>>> +        clir = OFONO_CLIR_OPTION_INVOCATION;
>>>> +    } else if (!strncmp(number, "#31#", 4)) {
>>>> +        number += 4;
>>>> +        clir =  OFONO_CLIR_OPTION_SUPPRESSION;
>>>> +    } else
>>>> +        clir = OFONO_CLIR_OPTION_DEFAULT;
>>>> +
>>>
>>> Actually this is not quite right.  The clir option is determined by the
>>> presence of 'I'/'i' characters at the end of the dial string.  Refer to
>>> 27.007 for more details.
>>>
>>> oFono does not actually recognize temporary forms of *31/#31
>>> invocation yet.
>>>
>> I added *31/#31 as I found them in telephony-ofono implementation of
>> BlueZ HFP AG,
>> but 27.007 uses I/i,
>> and HFP 1.5 does not seem to support clir option (ATDdd...dd;)
>>
>> Should I remove this part of code and only be compatible with HFP specs ?
>>
>
> Might as well handle the I/i and G/g part according to 27.007 since that
> is pretty easy and we'll have to do it anyway.  *31/#31 is really an MMI
> code, it should never be sent to the modem, so please remove that for now.
>
OK, so I will remove this part and will send a patch on I/i,G/g support 
later.

>>>> +    err = voicecall_dial(vc, number, clir, emulator_dial_callback, vc);
>>>> +    switch (err) {
>>>> +    case DIAL_NO_ERROR:
>>>> +        result.type = OFONO_ERROR_TYPE_NO_ERROR;
>>>> +        break;
>>>> +
>>>> +    case DIAL_NO_NETWORK:
>>>> +        result.error = 30;
>>>> +        result.type = OFONO_ERROR_TYPE_CME;
>>>> +        break;
>>>
>>> This might need to be NO CARRIER
>>>
>> As far as I understand, when there is no network, ATD should reply NO
>> CARRIER if CMEE error mode is set to 0, or +CME ERROR: 30 if it is set
>> to 1.
>
> Not quite.  CMEE controls the presentation of 'extended' CME ERROR code.
>   Either as ERROR, CME ERROR:<num>  or CME ERROR:<str>.  NO CARRIER is
> not an extended error code at all, and so is only affected by ATV
> setting, not CMEE.
>
OK, thanks for your explanation.

>> So, I think that voicecall should return an OFONO_ERROR_TYPE_CME 30, and
>> ofono_emulator_send_final should take care of replying the right string.
>>
>
> Nope, you have to take your pick, either CME ERROR: 30, or NO CARRIER.
> I'd expect most implementations to reply with a NO CARRIER in this case,
> but can you check what other implementations do in reality?
>

In paragraph 6.2.13.11 of tr002v15, in reply to ATD command without 
network, the flowchart shows usage of +CME ERROR: 30 or ERROR reply (no 
usage of NO CARRIER).

Paragraph 4.33.2 of HFP 1.5 specification said that NO CARRIER (and 
BUSY, NO ANSWER, ...) "are in addition to the +CME ERROR: reponses".

My understanding of specs is that we should send the CME ERROR and, if 
we want, NO CARRIER in addition.

Regards

Fred

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


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

* Re: [PATCH 2/4] voicecall: add ATD support for HFP emulator
  2011-05-19 16:16         ` Frederic Danis
@ 2011-05-19 16:39           ` Denis Kenzior
  0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2011-05-19 16:39 UTC (permalink / raw)
  To: ofono

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

Hi Frederic,

>>> So, I think that voicecall should return an OFONO_ERROR_TYPE_CME 30, and
>>> ofono_emulator_send_final should take care of replying the right string.
>>>
>>
>> Nope, you have to take your pick, either CME ERROR: 30, or NO CARRIER.
>> I'd expect most implementations to reply with a NO CARRIER in this case,
>> but can you check what other implementations do in reality?
>>
> 
> In paragraph 6.2.13.11 of tr002v15, in reply to ATD command without
> network, the flowchart shows usage of +CME ERROR: 30 or ERROR reply (no
> usage of NO CARRIER).
> 

If that is what tr002 recommends, then lets do that for now.

> Paragraph 4.33.2 of HFP 1.5 specification said that NO CARRIER (and
> BUSY, NO ANSWER, ...) "are in addition to the +CME ERROR: reponses".
> 
> My understanding of specs is that we should send the CME ERROR and, if
> we want, NO CARRIER in addition.

Yeah, I never understood that particular statement.  +CME ERROR and NO
CARRIER are both final responses, you should not send both.

Regards,
-Denis

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

end of thread, other threads:[~2011-05-19 16:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-12 14:40 [PATCH 0/4] Add dial support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-05-12 14:40 ` [PATCH 1/4] voicecall: create generic dial function =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-05-18  4:46   ` Denis Kenzior
2011-05-12 14:40 ` [PATCH 2/4] voicecall: add ATD support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-05-18  4:53   ` Denis Kenzior
2011-05-18 15:33     ` Frederic Danis
2011-05-18 16:13       ` Denis Kenzior
2011-05-19 16:16         ` Frederic Danis
2011-05-19 16:39           ` Denis Kenzior
2011-05-12 14:40 ` [PATCH 3/4] voicecall: save last dialed number =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-05-12 14:40 ` [PATCH 4/4] voicecall: add +BLDN support for HFP emulator =?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.