All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] stk: Handle the Get Inkey proactive command.
@ 2010-06-30 15:24 Andrzej Zaborowski
  2010-06-30 15:24 ` [PATCH 2/6] stk: Handle the Get Input " Andrzej Zaborowski
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Andrzej Zaborowski @ 2010-06-30 15:24 UTC (permalink / raw)
  To: ofono

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

The SimApplication agent method signature is:
string/Back/Terminate/Help GetKey(string message, string charset,
		bool help_available, bool single_key)

	charset is one of:
		"yesno" - response needs to be "yes" or "no"
		"digit" - one of 0-9, *, #, +
		"gsm" - only characters from the GSM SMS charset
		"any"
	single_key indicates that only characters from the device's
	key faces are allowed (e.g. no "+" allowed if device only
	has a basic keypad), and that the key should be returned
	without being shown on screen or waiting for any kind of
	user confirmation.

These patches apply on top of the previous series.
---
 src/stk.c |  160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 159 insertions(+), 1 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index ff47649..a2649b1 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -31,6 +31,7 @@
 #include <glib.h>
 #include <gdbus.h>
 #include <errno.h>
+#include <sys/time.h>
 
 #include "ofono.h"
 
@@ -64,6 +65,7 @@ enum stk_agent_state {
 	STK_AGENT_MAIN_MENU,
 	STK_AGENT_SELECT_ITEM,
 	STK_AGENT_DISPLAY_TEXT,
+	STK_AGENT_GET_KEY,
 };
 
 struct ofono_stk {
@@ -83,6 +85,7 @@ struct ofono_stk {
 
 	struct stk_menu *main_menu;
 	struct stk_menu *select_item_menu;
+	struct timeval get_inkey_start_ts;
 
 	gboolean envelope_q_busy;
 	GQueue *envelope_q;
@@ -100,6 +103,7 @@ struct envelope_op {
 #define OFONO_NAVIGATION_PREFIX OFONO_SERVICE ".Navigation."
 #define OFONO_NAVIGATION_GOBACK OFONO_NAVIGATION_PREFIX "Back"
 #define OFONO_NAVIGATION_TERMINATED OFONO_NAVIGATION_PREFIX "Terminated"
+#define OFONO_NAVIGATION_GETHELP OFONO_NAVIGATION_PREFIX "Help"
 
 static void envelope_queue_run(struct ofono_stk *stk);
 static void display_idle(struct ofono_stk *stk);
@@ -1041,7 +1045,6 @@ out:
 	display_idle(stk);
 }
 
-
 static gboolean handle_command_display_text(const struct stk_command *cmd,
 						struct stk_response *rsp,
 						struct ofono_stk *stk)
@@ -1067,6 +1070,157 @@ static gboolean handle_command_display_text(const struct stk_command *cmd,
 	return cmd->display_text.immediate_response;
 }
 
+static void request_get_key_send(struct ofono_stk *stk, DBusMessage *call)
+{
+	struct stk_command_get_inkey *cmd = &stk->pending_cmd->get_inkey;
+	uint8_t qualifier = stk->pending_cmd->qualifier;
+	dbus_bool_t alphabet = (qualifier & (1 << 0)) != 0;
+	dbus_bool_t ucs2 = (qualifier & (1 << 1)) != 0;
+	dbus_bool_t yesno = (qualifier & (1 << 2)) != 0;
+	dbus_bool_t immediate = (qualifier & (1 << 3)) != 0;
+	dbus_bool_t help = (qualifier & (1 << 7)) != 0;
+	const char *charset =
+		yesno ? "yesno" :
+		(!alphabet ? "digit" :
+		 (ucs2 ? "any" : "gsm"));
+
+	dbus_message_set_member(call, "GetKey");
+
+	dbus_message_append_args(call,
+					DBUS_TYPE_STRING, &cmd->text,
+					DBUS_TYPE_STRING, &charset,
+					DBUS_TYPE_BOOLEAN, &help,
+					DBUS_TYPE_BOOLEAN, &immediate,
+					DBUS_TYPE_INVALID);
+}
+
+static void request_get_key_cb(struct ofono_stk *stk, DBusMessage *reply)
+{
+	struct stk_command_get_inkey *cmd = &stk->pending_cmd->get_inkey;
+	uint8_t qualifier = stk->pending_cmd->qualifier;
+	dbus_bool_t yesno = (qualifier & (1 << 2)) != 0;
+	dbus_bool_t help = (qualifier & (1 << 7)) != 0;
+	DBusError err;
+	enum stk_result_type type = STK_RESULT_TYPE_SUCCESS;
+	struct stk_response rsp;
+	struct ofono_error error = { .type = OFONO_ERROR_TYPE_FAILURE };
+	char *key;
+
+	if (!reply) {
+		if (stk->cmd_timeout) {
+			app_agent_request_cancel(stk);
+
+			display_idle(stk);
+			return;
+		}
+
+		type = STK_RESULT_TYPE_NO_RESPONSE;
+
+		goto send;
+	}
+
+	dbus_error_init(&err);
+	if (dbus_set_error_from_message(&err, reply)) {
+		if (g_str_equal(err.name, OFONO_NAVIGATION_TERMINATED))
+			type = STK_RESULT_TYPE_USER_TERMINATED;
+		else if (g_str_equal(err.name, OFONO_NAVIGATION_GOBACK))
+			type = STK_RESULT_TYPE_GO_BACK;
+		else if (g_str_equal(err.name, OFONO_NAVIGATION_GETHELP) &&
+				help)
+			type = STK_RESULT_TYPE_HELP_REQUESTED;
+		else {
+			type = STK_RESULT_TYPE_USER_TERMINATED;
+
+			ofono_error("Unknown reply %s", err.name);
+		}
+
+		dbus_error_free(&err);
+		goto send;
+	}
+
+	if (dbus_message_get_args(reply, NULL,
+					DBUS_TYPE_STRING, &key,
+					DBUS_TYPE_INVALID) == FALSE) {
+		type = STK_RESULT_TYPE_USER_TERMINATED;
+
+		ofono_error("Reply not understood");
+		goto send;
+	}
+
+	if (yesno && strcasecmp(key, "yes") && strcasecmp(key, "no")) {
+		type = STK_RESULT_TYPE_USER_TERMINATED;
+
+		ofono_error("Yes/No reply not understood");
+		goto send;
+	} else if (yesno && strcasecmp(key, "yes"))
+		key = NULL; /* NULL indicates No, non-NULL indicates Yes */
+
+send:
+	memset(&rsp, 0, sizeof(rsp));
+	rsp.result.type = type;
+
+	if (type == STK_RESULT_TYPE_SUCCESS) {
+		rsp.get_inkey.text.text = key;
+		rsp.get_inkey.text.packed = FALSE;
+		rsp.get_inkey.text.yesno = yesno;
+	}
+
+	if (cmd->duration.interval) {
+		struct timeval end_ts;
+		int interval;
+
+		gettimeofday(&end_ts, NULL);
+
+		interval = (end_ts.tv_usec + 1099999 -
+				stk->get_inkey_start_ts.tv_usec) / 100000;
+		interval += (end_ts.tv_sec -
+				stk->get_inkey_start_ts.tv_sec) * 10;
+		interval -= 10;
+
+		switch (cmd->duration.unit) {
+		case STK_DURATION_TYPE_MINUTES:
+			interval = (interval + 59) / 60;
+		case STK_DURATION_TYPE_SECONDS:
+			interval = (interval + 9) / 10;
+		case STK_DURATION_TYPE_SECOND_TENTHS:
+			break;
+		}
+
+		rsp.get_inkey.duration.unit = cmd->duration.unit;
+		rsp.get_inkey.duration.interval = interval;
+	}
+
+	if (stk_respond(stk, &rsp, display_command_cb))
+		display_command_cb(&error, stk);
+}
+
+static gboolean handle_command_get_inkey(const struct stk_command *cmd,
+						struct stk_response *rsp,
+						struct ofono_stk *stk)
+{
+	int timeout = 0;
+
+	if (cmd->get_inkey.duration.interval) {
+		timeout = cmd->get_inkey.duration.interval;
+		switch (cmd->get_inkey.duration.unit) {
+		case STK_DURATION_TYPE_MINUTES:
+			timeout *= 60;
+		case STK_DURATION_TYPE_SECONDS:
+			timeout *= 10;
+		case STK_DURATION_TYPE_SECOND_TENTHS:
+			timeout *= 100;
+		}
+	}
+
+	gettimeofday(&stk->get_inkey_start_ts, NULL);
+
+	stk->custom_timeout = timeout;
+	app_agent_request_start(stk, request_get_key_send, request_get_key_cb,
+				STK_AGENT_GET_KEY);
+
+	return FALSE;
+}
+
 void ofono_stk_proactive_command_cancel(struct ofono_stk *stk)
 {
 	if (!stk->pending_cmd)
@@ -1140,6 +1294,10 @@ void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
 		case STK_COMMAND_TYPE_DISPLAY_TEXT:
 			respond = handle_command_display_text(stk->pending_cmd,
 								&rsp, stk);
+			break;
+		case STK_COMMAND_TYPE_GET_INKEY:
+			respond = handle_command_get_inkey(stk->pending_cmd,
+								&rsp, stk);
 		}
 
 		if (respond)
-- 
1.7.1.86.g0e460.dirty


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

* [PATCH 2/6] stk: Handle the Get Input proactive command.
  2010-06-30 15:24 [PATCH 1/6] stk: Handle the Get Inkey proactive command Andrzej Zaborowski
@ 2010-06-30 15:24 ` Andrzej Zaborowski
  2010-06-30 15:24 ` [PATCH 3/6][RfC] stkutil: Move scaddr field to gsm_sms in stk_command_send_sms Andrzej Zaborowski
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Andrzej Zaborowski @ 2010-06-30 15:24 UTC (permalink / raw)
  To: ofono

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

The SimApplication agent method signature is:
string/Back/Terminate/Help GetText(string message, string default,
		string charset, byte min, byte max, bool help_available,
		bool password)

	charset is one of:
		"digit" - one of 0-9, *, #, +
		"gsm" - only characters from the GSM SMS charset
		"any"
	The returned string must be between min and max characters long.
	The default value should be used as the initial value of the
	text field being edited by user.  If password is True, individual
	characters entered must not be revealed on the screen, but
	indication of new characters can be given, for example by showing
	them as '*'.
---
 src/stk.c |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 107 insertions(+), 0 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index a2649b1..0ae74e6 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -66,6 +66,7 @@ enum stk_agent_state {
 	STK_AGENT_SELECT_ITEM,
 	STK_AGENT_DISPLAY_TEXT,
 	STK_AGENT_GET_KEY,
+	STK_AGENT_GET_TEXT,
 };
 
 struct ofono_stk {
@@ -1221,6 +1222,108 @@ static gboolean handle_command_get_inkey(const struct stk_command *cmd,
 	return FALSE;
 }
 
+static void request_get_text_send(struct ofono_stk *stk, DBusMessage *call)
+{
+	struct stk_command_get_input *cmd = &stk->pending_cmd->get_input;
+	uint8_t qualifier = stk->pending_cmd->qualifier;
+	dbus_bool_t alphabet = (qualifier & (1 << 0)) != 0;
+	dbus_bool_t ucs2 = (qualifier & (1 << 1)) != 0;
+	dbus_bool_t hidden = (qualifier & (1 << 2)) != 0;
+	dbus_bool_t help = (qualifier & (1 << 7)) != 0;
+	const char *charset =
+		!alphabet ? "digit" :
+		 (ucs2 ? "any" : "gsm");
+	const char *default_text = cmd->default_text ?: "";
+
+	dbus_message_set_member(call, "GetText");
+
+	dbus_message_append_args(call,
+					DBUS_TYPE_STRING, &cmd->text,
+					DBUS_TYPE_STRING, &default_text,
+					DBUS_TYPE_STRING, &charset,
+					DBUS_TYPE_BYTE, &cmd->resp_len.min,
+					DBUS_TYPE_BYTE, &cmd->resp_len.max,
+					DBUS_TYPE_BOOLEAN, &help,
+					DBUS_TYPE_BOOLEAN, &hidden,
+					DBUS_TYPE_INVALID);
+}
+
+static void request_get_text_cb(struct ofono_stk *stk, DBusMessage *reply)
+{
+	uint8_t qualifier = stk->pending_cmd->qualifier;
+	dbus_bool_t packed = (qualifier & (1 << 3)) != 0;
+	dbus_bool_t help = (qualifier & (1 << 7)) != 0;
+	DBusError err;
+	enum stk_result_type type = STK_RESULT_TYPE_SUCCESS;
+	struct stk_response rsp;
+	struct ofono_error error = { .type = OFONO_ERROR_TYPE_FAILURE };
+	char *text;
+
+	if (!reply) {
+		if (stk->cmd_timeout) {
+			app_agent_request_cancel(stk);
+
+			display_idle(stk);
+			return;
+		}
+
+		type = STK_RESULT_TYPE_NO_RESPONSE;
+
+		goto send;
+	}
+
+	dbus_error_init(&err);
+	if (dbus_set_error_from_message(&err, reply)) {
+		if (g_str_equal(err.name, OFONO_NAVIGATION_TERMINATED))
+			type = STK_RESULT_TYPE_USER_TERMINATED;
+		else if (g_str_equal(err.name, OFONO_NAVIGATION_GOBACK))
+			type = STK_RESULT_TYPE_GO_BACK;
+		else if (g_str_equal(err.name, OFONO_NAVIGATION_GETHELP) &&
+				help)
+			type = STK_RESULT_TYPE_HELP_REQUESTED;
+		else {
+			type = STK_RESULT_TYPE_USER_TERMINATED;
+
+			ofono_error("Unknown reply %s", err.name);
+		}
+
+		dbus_error_free(&err);
+		goto send;
+	}
+
+	if (dbus_message_get_args(reply, NULL,
+					DBUS_TYPE_STRING, &text,
+					DBUS_TYPE_INVALID) == FALSE) {
+		type = STK_RESULT_TYPE_USER_TERMINATED;
+
+		ofono_error("Reply not understood");
+		goto send;
+	}
+
+send:
+	memset(&rsp, 0, sizeof(rsp));
+	rsp.result.type = type;
+
+	if (type == STK_RESULT_TYPE_SUCCESS) {
+		rsp.get_input.text.text = text;
+		rsp.get_input.text.packed = packed;
+		rsp.get_input.text.yesno = FALSE;
+	}
+
+	if (stk_respond(stk, &rsp, display_command_cb))
+		display_command_cb(&error, stk);
+}
+
+static gboolean handle_command_get_input(const struct stk_command *cmd,
+						struct stk_response *rsp,
+						struct ofono_stk *stk)
+{
+	app_agent_request_start(stk, request_get_text_send, request_get_text_cb,
+				STK_AGENT_GET_TEXT);
+
+	return FALSE;
+}
+
 void ofono_stk_proactive_command_cancel(struct ofono_stk *stk)
 {
 	if (!stk->pending_cmd)
@@ -1298,6 +1401,10 @@ void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
 		case STK_COMMAND_TYPE_GET_INKEY:
 			respond = handle_command_get_inkey(stk->pending_cmd,
 								&rsp, stk);
+			break;
+		case STK_COMMAND_TYPE_GET_INPUT:
+			respond = handle_command_get_input(stk->pending_cmd,
+								&rsp, stk);
 		}
 
 		if (respond)
-- 
1.7.1.86.g0e460.dirty


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

* [PATCH 3/6][RfC] stkutil: Move scaddr field to gsm_sms in stk_command_send_sms
  2010-06-30 15:24 [PATCH 1/6] stk: Handle the Get Inkey proactive command Andrzej Zaborowski
  2010-06-30 15:24 ` [PATCH 2/6] stk: Handle the Get Input " Andrzej Zaborowski
@ 2010-06-30 15:24 ` Andrzej Zaborowski
  2010-07-02 19:52   ` Denis Kenzior
  2010-06-30 15:24 ` [PATCH 4/6] test-stkutil: Fix always true condition Andrzej Zaborowski
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Andrzej Zaborowski @ 2010-06-30 15:24 UTC (permalink / raw)
  To: ofono

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

---
 src/stkutil.c       |   58 +++++++++++----
 src/stkutil.h       |    1 -
 unit/test-stkutil.c |  205 ++++++++++++++++++++++++++++-----------------------
 3 files changed, 156 insertions(+), 108 deletions(-)

diff --git a/src/stkutil.c b/src/stkutil.c
index 6f072e7..e92add3 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -2633,7 +2633,6 @@ static enum stk_command_parse_result parse_select_item(
 static void destroy_send_sms(struct stk_command *command)
 {
 	g_free(command->send_sms.alpha_id);
-	g_free(command->send_sms.address.number);
 	g_free(command->send_sms.cdma_sms.array);
 }
 
@@ -2644,6 +2643,7 @@ static enum stk_command_parse_result parse_send_sms(
 	struct stk_command_send_sms *obj = &command->send_sms;
 	enum stk_command_parse_result status;
 	struct gsm_sms_tpdu gsm_tpdu;
+	struct stk_address sc_address = { 0, NULL };
 
 	if (command->src != STK_DEVICE_IDENTITY_TYPE_UICC)
 		return STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
@@ -2655,7 +2655,7 @@ static enum stk_command_parse_result parse_send_sms(
 	status = parse_dataobj(iter, STK_DATA_OBJECT_TYPE_ALPHA_ID, 0,
 				&obj->alpha_id,
 				STK_DATA_OBJECT_TYPE_ADDRESS, 0,
-				&obj->address,
+				&sc_address,
 				STK_DATA_OBJECT_TYPE_GSM_SMS_TPDU, 0,
 				&gsm_tpdu,
 				STK_DATA_OBJECT_TYPE_CDMA_SMS_TPDU, 0,
@@ -2671,35 +2671,63 @@ static enum stk_command_parse_result parse_send_sms(
 	command->destructor = destroy_send_sms;
 
 	if (status != STK_PARSE_RESULT_OK)
-		return status;
+		goto out;
 
-	if (gsm_tpdu.len == 0 && obj->cdma_sms.len == 0)
-		return STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
+	if (gsm_tpdu.len == 0 && obj->cdma_sms.len == 0) {
+		status = STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
+		goto out;
+	}
 
-	if (gsm_tpdu.len > 0 && obj->cdma_sms.len > 0)
-		return STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
+	if (gsm_tpdu.len > 0 && obj->cdma_sms.len > 0) {
+		status = STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
+		goto out;
+	}
 
 	/* We don't process CDMA pdus for now */
 	if (obj->cdma_sms.len > 0)
-		return STK_PARSE_RESULT_OK;
+		goto out;
 
 	/* packing is needed */
 	if (command->qualifier & 0x01) {
 		if (sms_decode_unpacked_stk_pdu(gsm_tpdu.tpdu, gsm_tpdu.len,
-							&obj->gsm_sms) != TRUE)
+							&obj->gsm_sms) !=
+				TRUE) {
 			status = STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
-		return status;
+			goto out;
+		}
+
+		goto set_addr;
 	}
 
 	if (sms_decode(gsm_tpdu.tpdu, gsm_tpdu.len, TRUE,
-				gsm_tpdu.len, &obj->gsm_sms) == FALSE)
-		return STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
+				gsm_tpdu.len, &obj->gsm_sms) == FALSE) {
+		status = STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
+		goto out;
+	}
 
 	if (obj->gsm_sms.type != SMS_TYPE_SUBMIT &&
-			obj->gsm_sms.type != SMS_TYPE_COMMAND)
-		return STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
+			obj->gsm_sms.type != SMS_TYPE_COMMAND) {
+		status = STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
+		goto out;
+	}
 
-	return STK_PARSE_RESULT_OK;
+set_addr:
+	if (sc_address.number == NULL)
+		goto out;
+
+	if (strlen(sc_address.number) > 20) {
+		status = STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
+		goto out;
+	}
+
+	strcpy(obj->gsm_sms.sc_addr.address, sc_address.number);
+	obj->gsm_sms.sc_addr.numbering_plan = sc_address.ton_npi & 15;
+	obj->gsm_sms.sc_addr.number_type = (sc_address.ton_npi >> 4) & 7;
+
+out:
+	g_free(sc_address.number);
+
+	return status;
 }
 
 static void destroy_send_ss(struct stk_command *command)
diff --git a/src/stkutil.h b/src/stkutil.h
index ca4817e..978a229 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -1118,7 +1118,6 @@ struct stk_command_select_item {
 
 struct stk_command_send_sms {
 	char *alpha_id;
-	struct stk_address address;
 	struct sms gsm_sms;
 	struct stk_common_byte_array cdma_sms;
 	struct stk_icon_id icon_id;
diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index 8b7e254..7fa485b 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -207,6 +207,11 @@ static void check_response_length(const struct stk_response_length *command,
 static void check_gsm_sms(const struct sms *command,
 					const struct sms_test *test)
 {
+	g_assert(command->sc_addr.number_type == test->sc_addr.number_type);
+	g_assert(command->sc_addr.numbering_plan ==
+			test->sc_addr.numbering_plan);
+	g_assert(g_str_equal(command->sc_addr.address, test->sc_addr.address));
+
 	switch (test->type) {
 	case SMS_TYPE_SUBMIT: {
 		const struct sms_submit *cs = &command->submit;
@@ -7156,7 +7161,6 @@ struct send_sms_test {
 	unsigned int pdu_len;
 	unsigned char qualifier;
 	char *alpha_id;
-	struct stk_address address;
 	struct sms_test gsm_sms;
 	struct stk_common_byte_array cdma_sms;
 	struct stk_icon_id icon_id;
@@ -7781,12 +7785,13 @@ static struct send_sms_test send_sms_data_111 = {
 	.pdu_len = sizeof(send_sms_111),
 	.qualifier = 0x00,
 	.alpha_id = "Send SM",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -7803,12 +7808,13 @@ static struct send_sms_test send_sms_data_121 = {
 	.pdu_len = sizeof(send_sms_121),
 	.qualifier = 0x01,
 	.alpha_id = "Send SM",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -7825,12 +7831,13 @@ static struct send_sms_test send_sms_data_131 = {
 	.pdu_len = sizeof(send_sms_131),
 	.qualifier = 0x00,
 	.alpha_id = "Short Message",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -7847,12 +7854,13 @@ static struct send_sms_test send_sms_data_141 = {
 	.pdu_len = sizeof(send_sms_141),
 	.qualifier = 0x01,
 	.alpha_id = "The address data object holds the RP_Destination_Address",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -7872,12 +7880,13 @@ static struct send_sms_test send_sms_data_151 = {
 	.pdu_len = sizeof(send_sms_151),
 	.qualifier = 0x00,
 	.alpha_id = "The address data object holds the RP Destination Address",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -7919,12 +7928,13 @@ static struct send_sms_test send_sms_data_171 = {
 	.pdu = send_sms_171,
 	.pdu_len = sizeof(send_sms_171),
 	.qualifier = 0x00,
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -7940,12 +7950,13 @@ static struct send_sms_test send_sms_data_181 = {
 	.pdu = send_sms_181,
 	.pdu_len = sizeof(send_sms_181),
 	.qualifier = 0x00,
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -7962,12 +7973,13 @@ static struct send_sms_test send_sms_data_211 = {
 	.pdu_len = sizeof(send_sms_211),
 	.qualifier = 0x00,
 	.alpha_id = "ЗДРАВСТВУЙТЕ",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -7984,12 +7996,13 @@ static struct send_sms_test send_sms_data_212 = {
 	.pdu_len = sizeof(send_sms_212),
 	.qualifier = 0x00,
 	.alpha_id = "ЗДРАВСТВУЙТЕ",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -8006,12 +8019,13 @@ static struct send_sms_test send_sms_data_213 = {
 	.pdu_len = sizeof(send_sms_213),
 	.qualifier = 0x00,
 	.alpha_id = "ЗДРАВСТВУЙТЕ",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -8028,12 +8042,13 @@ static struct send_sms_test send_sms_data_311 = {
 	.pdu_len = sizeof(send_sms_311),
 	.qualifier = 0x00,
 	.alpha_id = "NO ICON",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -8054,12 +8069,13 @@ static struct send_sms_test send_sms_data_321 = {
 	.pdu_len = sizeof(send_sms_321),
 	.qualifier = 0x00,
 	.alpha_id = "Send SM",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -8613,12 +8629,13 @@ static struct send_sms_test send_sms_data_511 = {
 	.pdu_len = sizeof(send_sms_511),
 	.qualifier = 0x00,
 	.alpha_id = "中一",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -8636,12 +8653,13 @@ static struct send_sms_test send_sms_data_512 = {
 	.pdu_len = sizeof(send_sms_512),
 	.qualifier = 0x00,
 	.alpha_id = "中一",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -8659,12 +8677,13 @@ static struct send_sms_test send_sms_data_513 = {
 	.pdu_len = sizeof(send_sms_513),
 	.qualifier = 0x00,
 	.alpha_id = "中一",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -8681,12 +8700,13 @@ static struct send_sms_test send_sms_data_611 = {
 	.pdu_len = sizeof(send_sms_611),
 	.qualifier = 0x00,
 	.alpha_id = "80ル0",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -8703,12 +8723,13 @@ static struct send_sms_test send_sms_data_612 = {
 	.pdu_len = sizeof(send_sms_612),
 	.qualifier = 0x00,
 	.alpha_id = "81ル1",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -8725,12 +8746,13 @@ static struct send_sms_test send_sms_data_613 = {
 	.pdu_len = sizeof(send_sms_613),
 	.qualifier = 0x00,
 	.alpha_id = "82ル2",
-	.address = {
-		.ton_npi = 0x91,
-		.number = "112233445566778"
-	},
 	.gsm_sms = {
-		{}, SMS_TYPE_SUBMIT,
+		{
+			.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+			.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+			.address = "112233445566778",
+		},
+		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
 			.daddr.address = "012345678",
@@ -8760,7 +8782,6 @@ static void test_send_sms(gconstpointer data)
 	g_assert(command->dst == STK_DEVICE_IDENTITY_TYPE_NETWORK);
 
 	check_alpha_id(command->send_sms.alpha_id, test->alpha_id);
-	check_address(&command->send_sms.address, &test->address);
 	check_gsm_sms(&command->send_sms.gsm_sms, &test->gsm_sms);
 	check_cdma_sms_tpdu(&command->send_sms.cdma_sms, &test->cdma_sms);
 	check_icon_id(&command->send_sms.icon_id, &test->icon_id);
-- 
1.7.1.86.g0e460.dirty


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

* [PATCH 4/6] test-stkutil: Fix always true condition.
  2010-06-30 15:24 [PATCH 1/6] stk: Handle the Get Inkey proactive command Andrzej Zaborowski
  2010-06-30 15:24 ` [PATCH 2/6] stk: Handle the Get Input " Andrzej Zaborowski
  2010-06-30 15:24 ` [PATCH 3/6][RfC] stkutil: Move scaddr field to gsm_sms in stk_command_send_sms Andrzej Zaborowski
@ 2010-06-30 15:24 ` Andrzej Zaborowski
  2010-07-02 19:52   ` Denis Kenzior
  2010-06-30 15:24 ` [PATCH 5/6] stk: Separate Dbus request cancelling from command cancelling Andrzej Zaborowski
  2010-06-30 15:24 ` [PATCH 6/6][RfC] Implement the Send SMS proactive command Andrzej Zaborowski
  4 siblings, 1 reply; 8+ messages in thread
From: Andrzej Zaborowski @ 2010-06-30 15:24 UTC (permalink / raw)
  To: ofono

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

---
 unit/test-stkutil.c |  274 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 227 insertions(+), 47 deletions(-)

diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index 7fa485b..c489c8c 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -225,8 +225,8 @@ static void check_gsm_sms(const struct sms *command,
 		g_assert(cs->srr == ts->srr);
 		g_assert(cs->mr == ts->mr);
 
-		g_assert(cs->daddr.number_type == cs->daddr.number_type);
-		g_assert(cs->daddr.numbering_plan == cs->daddr.numbering_plan);
+		g_assert(cs->daddr.number_type == ts->daddr.number_type);
+		g_assert(cs->daddr.numbering_plan == ts->daddr.numbering_plan);
 		g_assert(g_str_equal(cs->daddr.address, ts->daddr.address));
 
 		g_assert(cs->pid == ts->pid);
@@ -7794,7 +7794,11 @@ static struct send_sms_test send_sms_data_111 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0xF4,
 			.udl = 12,
@@ -7817,7 +7821,11 @@ static struct send_sms_test send_sms_data_121 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 7,
@@ -7840,7 +7848,11 @@ static struct send_sms_test send_sms_data_131 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 13,
@@ -7863,7 +7875,11 @@ static struct send_sms_test send_sms_data_141 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 160,
@@ -7889,7 +7905,11 @@ static struct send_sms_test send_sms_data_151 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 160,
@@ -7915,7 +7935,11 @@ static struct send_sms_test send_sms_data_161 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -7937,7 +7961,11 @@ static struct send_sms_test send_sms_data_171 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0xF4,
 			.udl = 12,
@@ -7959,7 +7987,11 @@ static struct send_sms_test send_sms_data_181 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0xF4,
 			.udl = 12,
@@ -7982,7 +8014,11 @@ static struct send_sms_test send_sms_data_211 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0x08,
 			.udl = 24,
@@ -8005,7 +8041,11 @@ static struct send_sms_test send_sms_data_212 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0x08,
 			.udl = 24,
@@ -8028,7 +8068,11 @@ static struct send_sms_test send_sms_data_213 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0x08,
 			.udl = 24,
@@ -8051,7 +8095,11 @@ static struct send_sms_test send_sms_data_311 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0xF4,
 			.udl = 12,
@@ -8078,7 +8126,11 @@ static struct send_sms_test send_sms_data_321 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0xF4,
 			.udl = 12,
@@ -8100,7 +8152,11 @@ static struct send_sms_test send_sms_data_411 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8122,7 +8178,11 @@ static struct send_sms_test send_sms_data_412 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8140,7 +8200,11 @@ static struct send_sms_test send_sms_data_421 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8162,7 +8226,11 @@ static struct send_sms_test send_sms_data_422 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8180,7 +8248,11 @@ static struct send_sms_test send_sms_data_431 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8202,7 +8274,11 @@ static struct send_sms_test send_sms_data_432 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8220,7 +8296,11 @@ static struct send_sms_test send_sms_data_441 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8242,7 +8322,11 @@ static struct send_sms_test send_sms_data_442 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8264,7 +8348,11 @@ static struct send_sms_test send_sms_data_443 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8282,7 +8370,11 @@ static struct send_sms_test send_sms_data_451 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8304,7 +8396,11 @@ static struct send_sms_test send_sms_data_452 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8326,7 +8422,11 @@ static struct send_sms_test send_sms_data_453 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8344,7 +8444,11 @@ static struct send_sms_test send_sms_data_461 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8366,7 +8470,11 @@ static struct send_sms_test send_sms_data_462 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8388,7 +8496,11 @@ static struct send_sms_test send_sms_data_463 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8406,7 +8518,11 @@ static struct send_sms_test send_sms_data_471 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8428,7 +8544,11 @@ static struct send_sms_test send_sms_data_472 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8450,7 +8570,11 @@ static struct send_sms_test send_sms_data_473 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8468,7 +8592,11 @@ static struct send_sms_test send_sms_data_481 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8490,7 +8618,11 @@ static struct send_sms_test send_sms_data_482 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8512,7 +8644,11 @@ static struct send_sms_test send_sms_data_483 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8530,7 +8666,11 @@ static struct send_sms_test send_sms_data_491 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8552,7 +8692,11 @@ static struct send_sms_test send_sms_data_492 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8574,7 +8718,11 @@ static struct send_sms_test send_sms_data_493 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8592,7 +8740,11 @@ static struct send_sms_test send_sms_data_4101 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8614,7 +8766,11 @@ static struct send_sms_test send_sms_data_4102 = {
 		{}, SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "01",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "01",
+			},
 			.pid = 0x40,
 			.dcs = 0xF0,
 			.udl = 1,
@@ -8638,7 +8794,11 @@ static struct send_sms_test send_sms_data_511 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0x08,
 			.udl = 4,
@@ -8662,7 +8822,11 @@ static struct send_sms_test send_sms_data_512 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0x08,
 			.udl = 4,
@@ -8686,7 +8850,11 @@ static struct send_sms_test send_sms_data_513 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0x08,
 			.udl = 4,
@@ -8709,7 +8877,11 @@ static struct send_sms_test send_sms_data_611 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0x08,
 			.udl = 8,
@@ -8732,7 +8904,11 @@ static struct send_sms_test send_sms_data_612 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0x08,
 			.udl = 8,
@@ -8755,7 +8931,11 @@ static struct send_sms_test send_sms_data_613 = {
 		SMS_TYPE_SUBMIT,
 		{.submit = {
 			.mr = 0x00,
-			.daddr.address = "012345678",
+			.daddr = {
+				.number_type = SMS_NUMBER_TYPE_INTERNATIONAL,
+				.numbering_plan = SMS_NUMBERING_PLAN_ISDN,
+				.address = "012345678",
+			},
 			.pid = 0x40,
 			.dcs = 0x08,
 			.udl = 8,
-- 
1.7.1.86.g0e460.dirty


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

* [PATCH 5/6] stk: Separate Dbus request cancelling from command cancelling.
  2010-06-30 15:24 [PATCH 1/6] stk: Handle the Get Inkey proactive command Andrzej Zaborowski
                   ` (2 preceding siblings ...)
  2010-06-30 15:24 ` [PATCH 4/6] test-stkutil: Fix always true condition Andrzej Zaborowski
@ 2010-06-30 15:24 ` Andrzej Zaborowski
  2010-06-30 15:24 ` [PATCH 6/6][RfC] Implement the Send SMS proactive command Andrzej Zaborowski
  4 siblings, 0 replies; 8+ messages in thread
From: Andrzej Zaborowski @ 2010-06-30 15:24 UTC (permalink / raw)
  To: ofono

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

---
 src/stk.c |   38 ++++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index 0ae74e6..5ce0d2a 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -74,6 +74,8 @@ struct ofono_stk {
 	void *driver_data;
 	struct ofono_atom *atom;
 	struct stk_command *pending_cmd;
+	void (*cancel_cmd)(struct ofono_stk *stk);
+	gboolean cancelled;
 	struct stk_app_agent *app_agent;
 	enum stk_agent_state app_agent_state;
 	int timeout; /* Manufacturer defined timeout */
@@ -792,9 +794,7 @@ static void request_menu_cb(struct ofono_stk *stk, DBusMessage *reply)
 			goto out;
 		}
 
-		if (stk->cmd_timeout) {
-			app_agent_request_cancel(stk);
-
+		if (stk->cancelled) {
 			display_idle(stk);
 			goto out;
 		}
@@ -935,6 +935,8 @@ static gboolean handle_command_select_item(const struct stk_command *cmd,
 	app_agent_request_start(stk, request_menu_send, request_menu_cb,
 				STK_AGENT_SELECT_ITEM);
 
+	stk->cancel_cmd = app_agent_request_cancel;
+
 	return FALSE;
 }
 
@@ -997,11 +999,8 @@ static void request_text_cb(struct ofono_stk *stk, DBusMessage *reply)
 	struct ofono_error error = { .type = OFONO_ERROR_TYPE_FAILURE };
 
 	if (!reply) {
-		if (stk->cmd_timeout) {
-			app_agent_request_cancel(stk);
-
+		if (stk->cancelled)
 			goto out;
-		}
 
 		if (confirm)
 			type = STK_RESULT_TYPE_NO_RESPONSE;
@@ -1068,6 +1067,8 @@ static gboolean handle_command_display_text(const struct stk_command *cmd,
 	app_agent_request_start(stk, request_text_send, request_text_cb,
 				STK_AGENT_DISPLAY_TEXT);
 
+	stk->cancel_cmd = app_agent_request_cancel;
+
 	return cmd->display_text.immediate_response;
 }
 
@@ -1108,9 +1109,7 @@ static void request_get_key_cb(struct ofono_stk *stk, DBusMessage *reply)
 	char *key;
 
 	if (!reply) {
-		if (stk->cmd_timeout) {
-			app_agent_request_cancel(stk);
-
+		if (stk->cancelled) {
 			display_idle(stk);
 			return;
 		}
@@ -1219,6 +1218,8 @@ static gboolean handle_command_get_inkey(const struct stk_command *cmd,
 	app_agent_request_start(stk, request_get_key_send, request_get_key_cb,
 				STK_AGENT_GET_KEY);
 
+	stk->cancel_cmd = app_agent_request_cancel;
+
 	return FALSE;
 }
 
@@ -1260,9 +1261,7 @@ static void request_get_text_cb(struct ofono_stk *stk, DBusMessage *reply)
 	char *text;
 
 	if (!reply) {
-		if (stk->cmd_timeout) {
-			app_agent_request_cancel(stk);
-
+		if (stk->cancelled) {
 			display_idle(stk);
 			return;
 		}
@@ -1321,6 +1320,8 @@ static gboolean handle_command_get_input(const struct stk_command *cmd,
 	app_agent_request_start(stk, request_get_text_send, request_get_text_cb,
 				STK_AGENT_GET_TEXT);
 
+	stk->cancel_cmd = app_agent_request_cancel;
+
 	return FALSE;
 }
 
@@ -1329,7 +1330,14 @@ void ofono_stk_proactive_command_cancel(struct ofono_stk *stk)
 	if (!stk->pending_cmd)
 		return;
 
-	stk->cmd_cb(stk, NULL);
+	stk->cancelled = TRUE;
+
+	stk->cancel_cmd(stk);
+
+	if (stk->pending_cmd) {
+		stk_command_free(stk->pending_cmd);
+		stk->pending_cmd = NULL;
+	}
 }
 
 void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
@@ -1358,6 +1366,8 @@ void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
 	for (i = 0; i < length; i ++)
 		sprintf(buf + i * 2, "%02hhx", pdu[i]);
 
+	stk->cancelled = FALSE;
+
 	stk->pending_cmd = stk_command_new_from_pdu(pdu, length);
 	if (!stk->pending_cmd) {
 		ofono_error("Can't parse proactive command: %s", buf);
-- 
1.7.1.86.g0e460.dirty


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

* [PATCH 6/6][RfC] Implement the Send SMS proactive command.
  2010-06-30 15:24 [PATCH 1/6] stk: Handle the Get Inkey proactive command Andrzej Zaborowski
                   ` (3 preceding siblings ...)
  2010-06-30 15:24 ` [PATCH 5/6] stk: Separate Dbus request cancelling from command cancelling Andrzej Zaborowski
@ 2010-06-30 15:24 ` Andrzej Zaborowski
  4 siblings, 0 replies; 8+ messages in thread
From: Andrzej Zaborowski @ 2010-06-30 15:24 UTC (permalink / raw)
  To: ofono

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

---
 src/ofono.h |    7 ++++-
 src/sms.c   |   39 ++++++++++++++++++++++++++++++
 src/stk.c   |   75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 120 insertions(+), 1 deletions(-)

diff --git a/src/ofono.h b/src/ofono.h
index e2271e6..94e2715 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -168,12 +168,17 @@ void __ofono_atom_free(struct ofono_atom *atom);
 #include <ofono/cbs.h>
 #include <ofono/devinfo.h>
 #include <ofono/phonebook.h>
-#include <ofono/sms.h>
 #include <ofono/voicecall.h>
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
 #include <ofono/radio-settings.h>
 
+#include <ofono/sms.h>
+
+struct sms;
+void __ofono_sms_submit(struct ofono_sms *sms, const struct sms *msg,
+			ofono_sms_submit_cb_t cb, void *data);
+
 #include <ofono/sim.h>
 #include <ofono/stk.h>
 
diff --git a/src/sms.c b/src/sms.c
index c848007..54c46a5 100644
--- a/src/sms.c
+++ b/src/sms.c
@@ -87,6 +87,8 @@ struct tx_queue_entry {
 	DBusMessage *msg;
 	gboolean status_report;
 	struct sms_address receiver;
+	ofono_sms_submit_cb_t cb;
+	void *data;
 };
 
 static const char *sms_bearer_to_string(int bearer)
@@ -413,6 +415,9 @@ static void tx_finished(const struct ofono_error *error, int mr, void *data)
 	DBG("tx_finished");
 
 	if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+		if (entry->cb)
+			goto callback;
+
 		entry->retry += 1;
 
 		if (entry->retry != TXQ_MAX_RETRIES) {
@@ -459,6 +464,9 @@ static void tx_finished(const struct ofono_error *error, int mr, void *data)
 		return;
 	}
 
+	if (entry->cb)
+		goto callback;
+
 	entry = g_queue_pop_head(sms->txq);
 	__ofono_dbus_pending_reply(&entry->msg,
 				dbus_message_new_method_return(entry->msg));
@@ -473,6 +481,19 @@ static void tx_finished(const struct ofono_error *error, int mr, void *data)
 		DBG("Scheduling next");
 		sms->tx_source = g_timeout_add(0, tx_next, sms);
 	}
+
+	return;
+
+callback:
+	entry = g_queue_pop_head(sms->txq);
+
+	entry->cb(error, mr, entry->data);
+
+	g_free(entry->pdus);
+	g_free(entry);
+
+	if (g_queue_peek_head(sms->txq))
+		sms->tx_source = g_timeout_add(0, tx_next, sms);
 }
 
 static gboolean tx_next(gpointer user_data)
@@ -1285,3 +1306,21 @@ void *ofono_sms_get_data(struct ofono_sms *sms)
 {
 	return sms->driver_data;
 }
+
+void __ofono_sms_submit(struct ofono_sms *sms, const struct sms *msg,
+			ofono_sms_submit_cb_t cb, void *data)
+{
+	GSList msg_list = {
+		.data = (void *) msg,
+		.next = NULL,
+	};
+	struct tx_queue_entry *entry = create_tx_queue_entry(&msg_list);
+
+	entry->cb = cb;
+	entry->data = data;
+
+	g_queue_push_tail(sms->txq, entry);
+
+	if (g_queue_get_length(sms->txq) == 1)
+		sms->tx_source = g_timeout_add(0, tx_next, sms);
+}
diff --git a/src/stk.c b/src/stk.c
index 5ce0d2a..af91b7d 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -89,6 +89,7 @@ struct ofono_stk {
 	struct stk_menu *main_menu;
 	struct stk_menu *select_item_menu;
 	struct timeval get_inkey_start_ts;
+	struct sms_submit_req *sms_submit_req;
 
 	gboolean envelope_q_busy;
 	GQueue *envelope_q;
@@ -101,6 +102,11 @@ struct envelope_op {
 			const unsigned char *data, int length);
 };
 
+struct sms_submit_req {
+	struct ofono_stk *stk;
+	gboolean cancelled;
+};
+
 #define ENVELOPE_RETRIES_DEFAULT 5
 
 #define OFONO_NAVIGATION_PREFIX OFONO_SERVICE ".Navigation."
@@ -1325,6 +1331,71 @@ static gboolean handle_command_get_input(const struct stk_command *cmd,
 	return FALSE;
 }
 
+static void send_sms_cancel(struct ofono_stk *stk)
+{
+	stk->sms_submit_req->cancelled = TRUE;
+}
+
+static void send_sms_submit_cb(const struct ofono_error *error, int mr,
+				void *data)
+{
+	struct stk_response rsp;
+	struct sms_submit_req *req = data;
+	struct ofono_stk *stk = req->stk;
+	struct ofono_error failure = { .type = OFONO_ERROR_TYPE_FAILURE };
+
+	if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
+		ofono_debug("SMS submission returned errors: %s",
+				telephony_error_to_str(error));
+	else
+		ofono_debug("SMS submission successful");
+
+	if (req->cancelled) {
+		ofono_debug("Received an SMS submitted callback after the "
+				"proactive command was cancelled");
+		goto out;
+	}
+
+	memset(&rsp, 0, sizeof(rsp));
+
+	if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
+		rsp.result.type = STK_RESULT_TYPE_NETWORK_UNAVAILABLE;
+
+	if (stk_respond(stk, &rsp, stk_command_cb))
+		stk_command_cb(&failure, stk);
+
+out:
+	g_free(req);
+}
+
+static gboolean handle_command_send_sms(const struct stk_command *cmd,
+					struct stk_response *rsp,
+					struct ofono_stk *stk)
+{
+	struct ofono_modem *modem = __ofono_atom_get_modem(stk->atom);
+	struct ofono_atom *sms_atom;
+	struct ofono_sms *sms;
+
+	sms_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SMS);
+
+	if (!sms_atom || !__ofono_atom_get_registered(sms_atom)) {
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+	}
+
+	sms = __ofono_atom_get_data(sms_atom);
+
+	stk->sms_submit_req = g_new0(struct sms_submit_req, 1);
+	stk->sms_submit_req->stk = stk;
+
+	__ofono_sms_submit(sms, &cmd->send_sms.gsm_sms,
+				send_sms_submit_cb, stk->sms_submit_req);
+
+	stk->cancel_cmd = send_sms_cancel;
+
+	return FALSE;
+}
+
 void ofono_stk_proactive_command_cancel(struct ofono_stk *stk)
 {
 	if (!stk->pending_cmd)
@@ -1415,6 +1486,10 @@ void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
 		case STK_COMMAND_TYPE_GET_INPUT:
 			respond = handle_command_get_input(stk->pending_cmd,
 								&rsp, stk);
+			break;
+		case STK_COMMAND_TYPE_SEND_SMS:
+			respond = handle_command_send_sms(stk->pending_cmd,
+								&rsp, stk);
 		}
 
 		if (respond)
-- 
1.7.1.86.g0e460.dirty


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

* Re: [PATCH 3/6][RfC] stkutil: Move scaddr field to gsm_sms in stk_command_send_sms
  2010-06-30 15:24 ` [PATCH 3/6][RfC] stkutil: Move scaddr field to gsm_sms in stk_command_send_sms Andrzej Zaborowski
@ 2010-07-02 19:52   ` Denis Kenzior
  0 siblings, 0 replies; 8+ messages in thread
From: Denis Kenzior @ 2010-07-02 19:52 UTC (permalink / raw)
  To: ofono

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

On 06/30/2010 10:24 AM, Andrzej Zaborowski wrote:
> ---
>  src/stkutil.c       |   58 +++++++++++----
>  src/stkutil.h       |    1 -
>  unit/test-stkutil.c |  205 ++++++++++++++++++++++++++++-----------------------
>  3 files changed, 156 insertions(+), 108 deletions(-)
> 

Patch looks good to me.  Applied thanks.

Regards,
-Denis

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

* Re: [PATCH 4/6] test-stkutil: Fix always true condition.
  2010-06-30 15:24 ` [PATCH 4/6] test-stkutil: Fix always true condition Andrzej Zaborowski
@ 2010-07-02 19:52   ` Denis Kenzior
  0 siblings, 0 replies; 8+ messages in thread
From: Denis Kenzior @ 2010-07-02 19:52 UTC (permalink / raw)
  To: ofono

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

Hi Andrew,

> -		g_assert(cs->daddr.number_type == cs->daddr.number_type);
> -		g_assert(cs->daddr.numbering_plan == cs->daddr.numbering_plan);
> +		g_assert(cs->daddr.number_type == ts->daddr.number_type);
> +		g_assert(cs->daddr.numbering_plan == ts->daddr.numbering_plan);

Very nice catch.  Applied thanks.

Regards,
-Denis

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

end of thread, other threads:[~2010-07-02 19:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-30 15:24 [PATCH 1/6] stk: Handle the Get Inkey proactive command Andrzej Zaborowski
2010-06-30 15:24 ` [PATCH 2/6] stk: Handle the Get Input " Andrzej Zaborowski
2010-06-30 15:24 ` [PATCH 3/6][RfC] stkutil: Move scaddr field to gsm_sms in stk_command_send_sms Andrzej Zaborowski
2010-07-02 19:52   ` Denis Kenzior
2010-06-30 15:24 ` [PATCH 4/6] test-stkutil: Fix always true condition Andrzej Zaborowski
2010-07-02 19:52   ` Denis Kenzior
2010-06-30 15:24 ` [PATCH 5/6] stk: Separate Dbus request cancelling from command cancelling Andrzej Zaborowski
2010-06-30 15:24 ` [PATCH 6/6][RfC] Implement the Send SMS proactive command Andrzej Zaborowski

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.