summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-07-30 12:11:41 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-07-30 17:19:56 -0500
commitcf249c9fd715373edb609d39f30e5c8442309650 (patch)
treefd0ad07b3893c9794ca1fb26d5068a736dc39e76 /src
parent27e890cc4094622fff5f49adcea89ca32b73822c (diff)
downloadofono-cf249c9fd715373edb609d39f30e5c8442309650.tar.bz2
stk: Introduce destroy semantics to stkagent
Diffstat (limited to 'src')
-rw-r--r--src/stk.c24
-rw-r--r--src/stkagent.c20
-rw-r--r--src/stkagent.h10
3 files changed, 35 insertions, 19 deletions
diff --git a/src/stk.c b/src/stk.c
index 957f50af..a19405a9 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -955,8 +955,16 @@ static gboolean handle_command_set_up_menu(const struct stk_command *cmd,
return TRUE;
}
-static void request_menu_cb(enum stk_agent_result result, uint8_t id,
- void *user_data)
+static void request_selection_destroy(void *user_data)
+{
+ struct ofono_stk *stk = user_data;
+
+ stk_menu_free(stk->select_item_menu);
+ stk->select_item_menu = NULL;
+}
+
+static void request_selection_cb(enum stk_agent_result result, uint8_t id,
+ void *user_data)
{
struct ofono_stk *stk = user_data;
@@ -986,18 +994,11 @@ static void request_menu_cb(enum stk_agent_result result, uint8_t id,
send_simple_response(stk, STK_RESULT_TYPE_NO_RESPONSE);
break;
- case STK_AGENT_RESULT_CANCEL:
- goto out;
-
case STK_AGENT_RESULT_TERMINATE:
default:
send_simple_response(stk, STK_RESULT_TYPE_USER_TERMINATED);
break;
}
-
-out:
- stk_menu_free(stk->select_item_menu);
- stk->select_item_menu = NULL;
}
static gboolean handle_command_select_item(const struct stk_command *cmd,
@@ -1017,7 +1018,8 @@ static gboolean handle_command_select_item(const struct stk_command *cmd,
/* We most likely got an out of memory error, tell SIM to retry */
if (stk_agent_request_selection(stk->current_agent,
stk->select_item_menu,
- request_menu_cb, stk,
+ request_selection_cb, stk,
+ request_selection_destroy,
stk->timeout * 1000) < 0) {
rsp->result.type = STK_RESULT_TYPE_TERMINAL_BUSY;
return TRUE;
@@ -1098,7 +1100,7 @@ static gboolean handle_command_display_text(const struct stk_command *cmd,
/* We most likely got an out of memory error, tell SIM to retry */
if (stk_agent_display_text(stk->current_agent, dt->text, 0, priority,
- request_text_cb, stk, timeout) < 0) {
+ request_text_cb, stk, NULL, timeout) < 0) {
rsp->result.type = STK_RESULT_TYPE_TERMINAL_BUSY;
return TRUE;
}
diff --git a/src/stkagent.c b/src/stkagent.c
index 20d0d052..931e6697 100644
--- a/src/stkagent.c
+++ b/src/stkagent.c
@@ -51,6 +51,7 @@ struct stk_agent {
DBusPendingCall *call;
void *user_cb;
void *user_data;
+ ofono_destroy_func user_destroy;
const struct stk_menu *request_selection_menu;
};
@@ -96,6 +97,13 @@ static void stk_agent_request_end(struct stk_agent *agent)
dbus_pending_call_unref(agent->call);
agent->call = NULL;
}
+
+ if (agent->user_destroy)
+ agent->user_destroy(agent->user_data);
+
+ agent->user_destroy = NULL;
+ agent->user_data = NULL;
+ agent->user_cb = NULL;
}
ofono_bool_t stk_agent_busy(struct stk_agent *agent)
@@ -316,9 +324,10 @@ error:
}
int stk_agent_request_selection(struct stk_agent *agent,
- const struct stk_menu *menu,
- stk_agent_selection_cb cb,
- void *user_data, int timeout)
+ const struct stk_menu *menu,
+ stk_agent_selection_cb cb,
+ void *user_data, ofono_destroy_func destroy,
+ int timeout)
{
DBusConnection *conn = ofono_dbus_get_connection();
dbus_int16_t default_item = menu->default_item;
@@ -344,6 +353,7 @@ int stk_agent_request_selection(struct stk_agent *agent,
agent->user_cb = cb;
agent->user_data = user_data;
+ agent->user_destroy = destroy;
agent->request_selection_menu = menu;
@@ -393,7 +403,8 @@ error:
int stk_agent_display_text(struct stk_agent *agent, const char *text,
uint8_t icon_id, ofono_bool_t urgent,
stk_agent_display_text_cb cb,
- void *user_data, int timeout)
+ void *user_data, ofono_destroy_func destroy,
+ int timeout)
{
DBusConnection *conn = ofono_dbus_get_connection();
dbus_bool_t priority = urgent;
@@ -417,6 +428,7 @@ int stk_agent_display_text(struct stk_agent *agent, const char *text,
agent->user_cb = cb;
agent->user_data = user_data;
+ agent->user_destroy = destroy;
dbus_pending_call_set_notify(agent->call, display_text_cb,
agent, NULL);
diff --git a/src/stkagent.h b/src/stkagent.h
index 625217ad..e037fba0 100644
--- a/src/stkagent.h
+++ b/src/stkagent.h
@@ -67,14 +67,16 @@ ofono_bool_t stk_agent_matches(struct stk_agent *agent,
void stk_agent_request_cancel(struct stk_agent *agent);
int stk_agent_request_selection(struct stk_agent *agent,
- const struct stk_menu *menu,
- stk_agent_selection_cb cb,
- void *user_data, int timeout);
+ const struct stk_menu *menu,
+ stk_agent_selection_cb cb,
+ void *user_data, ofono_destroy_func destroy,
+ int timeout);
int stk_agent_display_text(struct stk_agent *agent, const char *text,
uint8_t icon_id, ofono_bool_t urgent,
stk_agent_display_text_cb cb,
- void *user_data, int timeout);
+ void *user_data, ofono_destroy_func destroy,
+ int timeout);
void append_menu_items_variant(DBusMessageIter *iter,
const struct stk_menu_item *items);