Skip to contentSkip to conversation

stk: Handle user termination for Send DTMF.

PATCH In review Philippe Nunes 2 participants 2 messages Mar 28, 2011 – Mar 30, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 2/4 stk: Handle user termination for Send DTMF.

---
 src/stk.c |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)
src/stk.c +24 -6
index 94ad396..907d6b5 100644
@@ -473,6 +473,16 @@ static void emit_menu_changed(struct ofono_stk *stk)
 	g_dbus_send_message(conn, signal);
 }
 
+static void user_termination_cb(enum stk_agent_result result, void *user_data)
+{
+	struct ofono_stk *stk = user_data;
+
+	if (result == STK_AGENT_RESULT_TERMINATE) {
+		stk->respond_on_exit = FALSE;
+		send_simple_response(stk, STK_RESULT_TYPE_USER_TERMINATED);
+	}
+}
+
 static void stk_alpha_id_set(struct ofono_stk *stk,
 		const char *text, const struct stk_text_attribute *attr,
 		const struct stk_icon_id *icon)
@@ -484,8 +494,16 @@ static void stk_alpha_id_set(struct ofono_stk *stk,
 	 * and no alpha identifier cases equally. This may be changed once
 	 * better idea is found out.
 	 */
-	if (alpha != NULL)
-		stk_agent_display_action_info(stk->current_agent, alpha, icon);
+	if (alpha != NULL) {
+		if (stk->respond_on_exit) {
+			stk_agent_display_abortable_action_info(
+					stk->current_agent, alpha, icon,
+					user_termination_cb, stk, NULL);
+		}
+		else
+			stk_agent_display_action_info(stk->current_agent,
+								alpha, icon);
+	}
 
 	g_free(alpha);
 }
@@ -2329,10 +2347,6 @@ static gboolean handle_command_send_dtmf(const struct stk_command *cmd,
 		return TRUE;
 	}
 
-	stk_alpha_id_set(stk, cmd->send_dtmf.alpha_id,
-				&cmd->send_dtmf.text_attr,
-				&cmd->send_dtmf.icon_id);
-
 	/*
 	 * Note that we don't strictly require an agent to be connected,
 	 * but to comply with 6.4.24 we need to send a End Session when
@@ -2342,6 +2356,10 @@ static gboolean handle_command_send_dtmf(const struct stk_command *cmd,
 	stk->cancel_cmd = send_dtmf_cancel;
 	stk->dtmf_id = err;
 
+	stk_alpha_id_set(stk, cmd->send_dtmf.alpha_id,
+				&cmd->send_dtmf.text_attr,
+				&cmd->send_dtmf.icon_id);
+
 	return FALSE;
 }
 
Signature · 1 line
1.7.1
#1 lore raw

Hi Philippe,

Quoted 28 lines · Philippe Nunes
---
 src/stk.c |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)
src/stk.c +10 -0
index 94ad396..907d6b5 100644
@@ -473,6 +473,16 @@ static void emit_menu_changed(struct ofono_stk *stk)
 	g_dbus_send_message(conn, signal);
 }
 
+static void user_termination_cb(enum stk_agent_result result, void *user_data)
+{
+	struct ofono_stk *stk = user_data;
+
+	if (result == STK_AGENT_RESULT_TERMINATE) {
+		stk->respond_on_exit = FALSE;
+		send_simple_response(stk, STK_RESULT_TYPE_USER_TERMINATED);
+	}
+}
+
 static void stk_alpha_id_set(struct ofono_stk *stk,
 		const char *text, const struct stk_text_attribute *attr,
 		const struct stk_icon_id *icon)
@@ -484,8 +494,16 @@ static void stk_alpha_id_set(struct ofono_stk *stk,
 	 * and no alpha identifier cases equally. This may be changed once
 	 * better idea is found out.

src/stk.c static void stk_alpha_id_set(struct ofono_stk *stk, · line 503

Quoted 10 lines
src/stk.c +7 -2
 	 */
-	if (alpha != NULL)
-		stk_agent_display_action_info(stk->current_agent, alpha, icon);
+	if (alpha != NULL) {
+		if (stk->respond_on_exit) {
+			stk_agent_display_abortable_action_info(
+					stk->current_agent, alpha, icon,
+					user_termination_cb, stk, NULL);
+		}
+		else

We use the kernel coding style, so the closing bracket and the else should be on the same line. We're pretty consistent throughout the codebase, so please watch out for this.

src/stk.c static void stk_alpha_id_set(struct ofono_stk *stk, · line 506

Quoted 3 lines
src/stk.c +3 -0
+			stk_agent_display_action_info(stk->current_agent,
+								alpha, icon);
+	}

Try not to introduce gratuitous nesting if you can avoid it. This code is better rewritten as:

if (alpha == NULL)

	return;

if (stk->respond_on_exit)

	...
else
	...

...

Quoted 15 lines
src/stk.c +0 -4
 	g_free(alpha);
 }
@@ -2329,10 +2347,6 @@ static gboolean handle_command_send_dtmf(const struct stk_command *cmd,
 		return TRUE;
 	}
 
-	stk_alpha_id_set(stk, cmd->send_dtmf.alpha_id,
-				&cmd->send_dtmf.text_attr,
-				&cmd->send_dtmf.icon_id);
-
 	/*
 	 * Note that we don't strictly require an agent to be connected,
 	 * but to comply with 6.4.24 we need to send a End Session when

src/stk.c static gboolean handle_command_send_dtmf(const struct stk_command *cmd, · line 2365

Quoted 10 lines
src/stk.c +4 -0
@@ -2342,6 +2356,10 @@ static gboolean handle_command_send_dtmf(const struct stk_command *cmd,
 	stk->cancel_cmd = send_dtmf_cancel;
 	stk->dtmf_id = err;
 
+	stk_alpha_id_set(stk, cmd->send_dtmf.alpha_id,
+				&cmd->send_dtmf.text_attr,
+				&cmd->send_dtmf.icon_id);
+
 	return FALSE;
 }
 

Regards,
-Denis