Skip to contentSkip to conversation

__ofono_voicecall_dial internal api for making calls.

PATCH In review Andrzej Zaborowski 2 participants 4 messages Aug 26, 2010 – Aug 28, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 __ofono_voicecall_dial internal api for making calls.

The callback is only invoked when the call is CONNECTED (becomes active). Cancel ensures that the callback will not be called and does nothing more in this version, it's an open question if we want to release the call.

---
 src/ofono.h     |   19 +++-
 src/voicecall.c |  328 ++++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 296 insertions(+), 51 deletions(-)
src/ofono.h +18 -1
index 4a42f0c..656d0d7 100644
@@ -169,11 +169,28 @@ void __ofono_atom_free(struct ofono_atom *atom);
 #include <ofono/cbs.h>
 #include <ofono/devinfo.h>
 #include <ofono/phonebook.h>
-#include <ofono/voicecall.h>
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
 #include <ofono/radio-settings.h>
 
+#include <ofono/voicecall.h>
+
+enum ofono_voicecall_interaction {
+	OFONO_VOICECALL_INTERACTION_NONE	= 0,
+	OFONO_VOICECALL_INTERACTION_PUT_ON_HOLD	= 1,
+	OFONO_VOICECALL_INTERACTION_DISCONNECT	= 2,
+};
+
+typedef void (*ofono_voicecall_dial_cb_t)(struct ofono_call *call, void *data);
+
+ofono_bool_t __ofono_voicecall_busy(struct ofono_voicecall *vc);
+int __ofono_voicecall_dial(struct ofono_voicecall *vc,
+				const char *addr, int addr_type,
+				const char *message, unsigned char icon_id,
+				enum ofono_voicecall_interaction interaction,
+				ofono_voicecall_dial_cb_t cb, void *user_data);
+void __ofono_voicecall_dial_cancel(struct ofono_voicecall *vc);
+
 #include <ofono/sms.h>
 
 struct sms;
src/voicecall.c +278 -50

420 lines not on this page · raw message

Signature · 1 line
1.7.1.86.g0e460.dirty
#1 lore raw

PATCH 2/2 stk: Handle the Set Up Call proactive command.

---
 src/stk.c |  188 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 188 insertions(+), 0 deletions(-)
src/stk.c +188 -0
index a7e594e..eb31b0f 100644
@@ -1399,6 +1399,188 @@ static gboolean handle_command_get_input(const struct stk_command *cmd,
 	return FALSE;
 }
 
+static void call_setup_connected(struct ofono_call *call, void *data)
+{
+	struct ofono_stk *stk = data;
+	struct stk_response rsp;
+	static struct ofono_error error = { .type = OFONO_ERROR_TYPE_FAILURE };
+	static unsigned char facility_rejected_result[] = { 0x9d };
+
+	if (!call) {
+		memset(&rsp, 0, sizeof(rsp));
+
+		rsp.result.type = STK_RESULT_TYPE_NETWORK_UNAVAILABLE;
+		rsp.result.additional_len = sizeof(facility_rejected_result);
+		rsp.result.additional = facility_rejected_result;
+
+		if (stk_respond(stk, &rsp, stk_command_cb))
+			stk_command_cb(&error, stk);
+
+		return;
+	}
+
+	if (call->status == CALL_STATUS_ACTIVE)
+		send_simple_response(stk, STK_RESULT_TYPE_SUCCESS);
+	else
+		send_simple_response(stk, STK_RESULT_TYPE_USER_CANCEL);
+}
+
+static void call_setup_cancel(struct ofono_stk *stk)
+{
+	struct ofono_voicecall *vc;
+	struct ofono_atom *vc_atom;
+
+	vc_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk->atom),
+						OFONO_ATOM_TYPE_VOICECALL);
+	if (!vc_atom)
+		return;
+
+	vc = __ofono_atom_get_data(vc_atom);
+	if (vc)
+		__ofono_voicecall_dial_cancel(vc);
+}
+
+static void confirm_call_cb(enum stk_agent_result result, gboolean confirm,
+				void *user_data)
+{
+	struct ofono_stk *stk = user_data;
+	static struct ofono_error error = { .type = OFONO_ERROR_TYPE_FAILURE };
+	const struct stk_command_setup_call *sc = &stk->pending_cmd->setup_call;
+	uint8_t qualifier = stk->pending_cmd->qualifier;
+	static unsigned char busy_on_call_result[] = { 0x02 };
+	static unsigned char no_cause_result[] = { 0x00 };
+	struct ofono_voicecall *vc = NULL;
+	struct ofono_atom *vc_atom;
+	struct stk_response rsp;
+	int err;
+
+	switch (result) {
+	case STK_AGENT_RESULT_TIMEOUT:
+		confirm = FALSE;
+		/* Fall through */
+
+	case STK_AGENT_RESULT_OK:
+		if (confirm)
+			break;
+
+		send_simple_response(stk, STK_RESULT_TYPE_USER_REJECT);
+		return;
+
+	case STK_AGENT_RESULT_TERMINATE:
+	default:
+		send_simple_response(stk, STK_RESULT_TYPE_USER_TERMINATED);
+		return;
+	}
+
+	vc_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk->atom),
+						OFONO_ATOM_TYPE_VOICECALL);
+	if (vc_atom)
+		vc = __ofono_atom_get_data(vc_atom);
+
+	if (!vc) {
+		send_simple_response(stk, STK_RESULT_TYPE_NOT_CAPABLE);
+		return;
+	}
+
+	err = __ofono_voicecall_dial(vc, sc->addr.number, sc->addr.ton_npi,
+					sc->alpha_id_call_setup, 0,
+					qualifier >> 1, call_setup_connected,
+					stk);
+	if (err >= 0) {
+		stk->cancel_cmd = call_setup_cancel;
+
+		return;
+	}
+
+	if (err == -EBUSY) {
+		memset(&rsp, 0, sizeof(rsp));
+
+		rsp.result.type = STK_RESULT_TYPE_TERMINAL_BUSY;
+		rsp.result.additional_len = sizeof(busy_on_call_result);
+		rsp.result.additional = busy_on_call_result;
+
+		if (stk_respond(stk, &rsp, stk_command_cb))
+			stk_command_cb(&error, stk);
+
+		return;
+	}
+
+	if (err == -ENOSYS) {
+		send_simple_response(stk, STK_RESULT_TYPE_NOT_CAPABLE);
+
+		return;
+	}
+
+	memset(&rsp, 0, sizeof(rsp));
+
+	rsp.result.type = STK_RESULT_TYPE_NETWORK_UNAVAILABLE;
+	rsp.result.additional_len = sizeof(no_cause_result);
+	rsp.result.additional = no_cause_result;
+
+	if (stk_respond(stk, &rsp, stk_command_cb))
+		stk_command_cb(&error, stk);
+}
+
+static gboolean handle_command_set_up_call(const struct stk_command *cmd,
+						struct stk_response *rsp,
+						struct ofono_stk *stk)
+{
+	const struct stk_command_setup_call *sc = &cmd->setup_call;
+	uint8_t qualifier = cmd->qualifier;
+	static unsigned char busy_on_call_result[] = { 0x02 };
+	struct ofono_voicecall *vc = NULL;
+	struct ofono_atom *vc_atom;
+	int err;
+
+	if (qualifier > 5) {
+		rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+		return TRUE;
+	}
+
+	/*
+	 * Passing called party subaddress and establishing non-speech
+	 * calls are not supported.
+	 */
+	if (sc->ccp.len || sc->subaddr.len) {
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+	}
+
+	vc_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk->atom),
+						OFONO_ATOM_TYPE_VOICECALL);
+	if (vc_atom)
+		vc = __ofono_atom_get_data(vc_atom);
+
+	if (!vc) {
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+	}
+
+	if (__ofono_voicecall_busy(vc) && (qualifier == 0 || qualifier == 1)) {
+		rsp->result.type = STK_RESULT_TYPE_TERMINAL_BUSY;
+		rsp->result.additional_len = sizeof(busy_on_call_result);
+		rsp->result.additional = busy_on_call_result;
+		return TRUE;
+	}
+
+	stk->cancel_cmd = stk_request_cancel;
+
+	err = stk_agent_confirm_call(stk->current_agent, sc->alpha_id_usr_cfm,
+					0, confirm_call_cb, stk, NULL,
+					stk->timeout * 1000);
+
+	if (err < 0) {
+		/*
+		 * We most likely got an out of memory error, tell SIM
+		 * to retry
+		 */
+		rsp->result.type = STK_RESULT_TYPE_TERMINAL_BUSY;
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
 static void stk_proactive_command_cancel(struct ofono_stk *stk)
 {
 	if (stk->immediate_response)
@@ -1482,6 +1664,7 @@ void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
 		case STK_COMMAND_TYPE_GET_INKEY:
 		case STK_COMMAND_TYPE_GET_INPUT:
 		case STK_COMMAND_TYPE_PLAY_TONE:
+		case STK_COMMAND_TYPE_SETUP_CALL:
 			send_simple_response(stk, STK_RESULT_TYPE_NOT_CAPABLE);
 			return;
 
@@ -1543,6 +1726,11 @@ void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
 							&rsp, stk);
 		break;
 
+	case STK_COMMAND_TYPE_SETUP_CALL:
+		respond = handle_command_set_up_call(stk->pending_cmd,
+							&rsp, stk);
+		break;
+
 	default:
 		rsp.result.type = STK_RESULT_TYPE_COMMAND_NOT_UNDERSTOOD;
 		break;
Signature · 1 line
1.7.1.86.g0e460.dirty
#3 lore raw
In reply to Andrzej Zaborowski

Hi Andrew,

Quoted 5 lines · Andrzej Zaborowski

The callback is only invoked when the call is CONNECTED (becomes active). Cancel ensures that the callback will not be called and does nothing more in this version, it's an open question if we want to release the call.
---

Patch has been applied, thanks.

Regards,
-Denis

#2 lore raw

Re: [PATCH 2/2] stk: Handle the Set Up Call proactive command.

In reply to Andrzej Zaborowski

Hi Andrew,

Quoted 4 lines · Andrzej Zaborowski
---
 src/stk.c |  188 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 188 insertions(+), 0 deletions(-)

Patch has been applied, thanks.

Regards,
-Denis