* [PATCH 1/2] stk: Expose icon IDs on D-Bus.
@ 2010-10-07 14:20 Andrzej Zaborowski
2010-10-07 14:20 ` [PATCH 2/2] stk: Apply STK text attributes as html Andrzej Zaborowski
2010-10-13 14:34 ` [PATCH 1/2] stk: Expose icon IDs on D-Bus Denis Kenzior
0 siblings, 2 replies; 3+ messages in thread
From: Andrzej Zaborowski @ 2010-10-07 14:20 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 21301 bytes --]
Update the docs to match the properties in stk.c.
---
doc/stk-api.txt | 16 ++++++-
src/stk.c | 112 ++++++++++++++++++++++++++++++++++---------------------
src/stkagent.c | 41 ++++++++++++--------
src/stkagent.h | 34 +++++++++-------
4 files changed, 125 insertions(+), 78 deletions(-)
diff --git a/doc/stk-api.txt b/doc/stk-api.txt
index f5b9ebc..c29872a 100644
--- a/doc/stk-api.txt
+++ b/doc/stk-api.txt
@@ -55,23 +55,33 @@ Signals PropertyChanged(string property, variant value)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.
-Properties string IdleText
+Properties string IdleModeText
Contains the text to be used when the home screen is
- idle. This text is set by the SIM and can be changed
+ idle. This text is set by the SIM and can change
at any time.
+ byte IdleModeIcon
+
+ Contains the identifier of the icon accompanying
+ the idle mode text.
+
array{struct{string, byte}} MainMenu
Contains the items that make up the main menu. This
is populated by the SIM when it sends the Setup Menu
Proactive Command. The main menu is always available,
- but its contents can be changed at any time.
+ but its contents can be changed at any time. Each
+ item contains the item label and icon identifier.
string MainMenuTitle
Contains the title of the main menu.
+ string MainMenuIcon
+
+ Contains the identifier of the icon for the main menu.
+
array{byte} Icons
Contains the identifiers of all available icons for
diff --git a/src/stk.c b/src/stk.c
index 84a22c9..7aa2ea6 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -72,6 +72,7 @@ struct ofono_stk {
guint remove_agent_source;
struct extern_req *extern_req;
char *idle_mode_text;
+ struct stk_icon_id idle_mode_icon;
struct timeval get_inkey_start_ts;
};
@@ -256,19 +257,28 @@ void __ofono_cbs_sim_download(struct ofono_stk *stk, const struct cbs *msg)
}
static struct stk_menu *stk_menu_create(const char *title,
- const struct stk_text_attribute *title_attr, GSList *items,
+ const struct stk_text_attribute *title_attr,
+ const struct stk_icon_id *icon, GSList *items,
const struct stk_item_text_attribute_list *item_attrs,
+ const struct stk_item_icon_id_list *item_icon_ids,
int default_id, gboolean soft_key, gboolean has_help)
{
struct stk_menu *ret = g_new(struct stk_menu, 1);
+ unsigned int len = g_slist_length(items);
GSList *l;
int i;
DBG("");
+ if (item_attrs && item_attrs->len && item_attrs->len != len * 4)
+ goto error;
+
+ if (item_icon_ids && item_icon_ids->len && item_icon_ids->len != len)
+ goto error;
+
ret->title = g_strdup(title ? title : "");
- ret->icon_id = 0;
- ret->items = g_new0(struct stk_menu_item, g_slist_length(items) + 1);
+ memcpy(&ret->icon, icon, sizeof(ret->icon));
+ ret->items = g_new0(struct stk_menu_item, len + 1);
ret->default_item = -1;
ret->soft_key = soft_key;
ret->has_help = has_help;
@@ -278,12 +288,18 @@ static struct stk_menu *stk_menu_create(const char *title,
ret->items[i].text = g_strdup(item->text);
ret->items[i].item_id = item->id;
+ if (item_icon_ids && item_icon_ids->len)
+ ret->items[i].icon_id = item_icon_ids->list[i];
if (item->id == default_id)
ret->default_item = i;
}
return ret;
+
+error:
+ g_free(ret);
+ return NULL;
}
static struct stk_menu *stk_menu_create_from_set_up_menu(
@@ -294,8 +310,10 @@ static struct stk_menu *stk_menu_create_from_set_up_menu(
return stk_menu_create(cmd->setup_menu.alpha_id,
&cmd->setup_menu.text_attr,
+ &cmd->setup_menu.icon_id,
cmd->setup_menu.items,
&cmd->setup_menu.item_text_attr_list,
+ &cmd->setup_menu.item_icon_id_list,
0, soft_key, has_help);
}
@@ -307,8 +325,10 @@ static struct stk_menu *stk_menu_create_from_select_item(
return stk_menu_create(cmd->select_item.alpha_id,
&cmd->select_item.text_attr,
+ &cmd->select_item.icon_id,
cmd->select_item.items,
&cmd->select_item.item_text_attr_list,
+ &cmd->select_item.item_icon_id_list,
cmd->select_item.item_id, soft_key, has_help);
}
@@ -345,6 +365,11 @@ static void emit_menu_changed(struct ofono_stk *stk)
"MainMenuTitle",
DBUS_TYPE_STRING, &menu->title);
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_STK_INTERFACE,
+ "MainMenuIcon",
+ DBUS_TYPE_BYTE, &menu->icon.id);
+
signal = dbus_message_new_signal(path, OFONO_STK_INTERFACE,
"PropertyChanged");
if (!signal) {
@@ -371,6 +396,9 @@ static void dict_append_menu(DBusMessageIter *dict, struct stk_menu *menu)
ofono_dbus_dict_append(dict, "MainMenuTitle",
DBUS_TYPE_STRING, &menu->title);
+ ofono_dbus_dict_append(dict, "MainMenuIcon",
+ DBUS_TYPE_BYTE, &menu->icon.id);
+
dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
NULL, &entry);
@@ -381,7 +409,8 @@ static void dict_append_menu(DBusMessageIter *dict, struct stk_menu *menu)
dbus_message_iter_close_container(dict, &entry);
}
-static void stk_alpha_id_set(struct ofono_stk *stk, const char *text)
+static void stk_alpha_id_set(struct ofono_stk *stk, const char *text,
+ const struct stk_icon_id *icon)
{
/* TODO */
}
@@ -414,6 +443,10 @@ static DBusMessage *stk_get_properties(DBusConnection *conn,
ofono_dbus_dict_append(&dict, "IdleModeText",
DBUS_TYPE_STRING, &idle_mode_text);
+ if (stk->idle_mode_icon.id)
+ ofono_dbus_dict_append(&dict, "IdleModeIcon", DBUS_TYPE_BYTE,
+ &stk->idle_mode_icon.id);
+
if (stk->main_menu)
dict_append_menu(&dict, stk->main_menu);
@@ -662,10 +695,6 @@ static void send_sms_cancel(struct ofono_stk *stk)
{
stk->extern_req->cancelled = TRUE;
- if (!stk->pending_cmd->send_sms.alpha_id ||
- !stk->pending_cmd->send_sms.alpha_id[0])
- return;
-
stk_alpha_id_unset(stk);
}
@@ -684,9 +713,7 @@ static void send_sms_submit_cb(gboolean ok, void *data)
return;
}
- if (stk->pending_cmd->send_sms.alpha_id &&
- stk->pending_cmd->send_sms.alpha_id[0])
- stk_alpha_id_unset(stk);
+ stk_alpha_id_unset(stk);
memset(&rsp, 0, sizeof(rsp));
@@ -735,8 +762,7 @@ static gboolean handle_command_send_sms(const struct stk_command *cmd,
stk->cancel_cmd = send_sms_cancel;
- if (cmd->send_sms.alpha_id && cmd->send_sms.alpha_id[0])
- stk_alpha_id_set(stk, cmd->send_sms.alpha_id);
+ stk_alpha_id_set(stk, cmd->send_sms.alpha_id, &cmd->send_sms.icon_id);
return FALSE;
}
@@ -763,6 +789,16 @@ static gboolean handle_command_set_idle_text(const struct stk_command *cmd,
DBUS_TYPE_STRING,
&idle_mode_text);
+ if (stk->idle_mode_icon.id != cmd->setup_idle_mode_text.icon_id.id) {
+ memcpy(&stk->idle_mode_icon, &cmd->setup_idle_mode_text.icon_id,
+ sizeof(stk->idle_mode_icon));
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_STK_INTERFACE,
+ "IdleModeIcon", DBUS_TYPE_BYTE,
+ &stk->idle_mode_icon.id);
+ }
+
return TRUE;
}
@@ -1144,8 +1180,8 @@ 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,
- display_text_cb, stk,
+ if (stk_agent_display_text(stk->current_agent, dt->text, &dt->icon_id,
+ priority, display_text_cb, stk,
display_text_destroy, timeout) < 0) {
rsp->result.type = STK_RESULT_TYPE_TERMINAL_BUSY;
return TRUE;
@@ -1288,7 +1324,6 @@ static gboolean handle_command_get_inkey(const struct stk_command *cmd,
* Note: immediate response and help parameter values are not
* provided by current api.
*/
- uint8_t icon_id = 0;
int err;
if (gi->duration.interval) {
@@ -1307,16 +1342,17 @@ static gboolean handle_command_get_inkey(const struct stk_command *cmd,
if (yesno)
err = stk_agent_request_confirmation(stk->current_agent,
- gi->text, icon_id,
+ gi->text, &gi->icon_id,
request_confirmation_cb,
stk, NULL, timeout);
else if (alphabet)
err = stk_agent_request_key(stk->current_agent, gi->text,
- icon_id, ucs2, request_key_cb,
- stk, NULL, timeout);
+ &gi->icon_id, ucs2,
+ request_key_cb, stk, NULL,
+ timeout);
else
err = stk_agent_request_digit(stk->current_agent, gi->text,
- icon_id, request_key_cb,
+ &gi->icon_id, request_key_cb,
stk, NULL, timeout);
if (err < 0) {
@@ -1382,19 +1418,18 @@ static gboolean handle_command_get_input(const struct stk_command *cmd,
gboolean alphabet = (qualifier & (1 << 0)) != 0;
gboolean ucs2 = (qualifier & (1 << 1)) != 0;
gboolean hidden = (qualifier & (1 << 2)) != 0;
- uint8_t icon_id = 0;
int err;
if (alphabet)
err = stk_agent_request_input(stk->current_agent, gi->text,
- icon_id, gi->default_text, ucs2,
- gi->resp_len.min,
+ &gi->icon_id, gi->default_text,
+ ucs2, gi->resp_len.min,
gi->resp_len.max, hidden,
request_string_cb,
stk, NULL, timeout);
else
err = stk_agent_request_digits(stk->current_agent, gi->text,
- icon_id, gi->default_text,
+ &gi->icon_id, gi->default_text,
gi->resp_len.min,
gi->resp_len.max, hidden,
request_string_cb,
@@ -1501,7 +1536,8 @@ static void confirm_call_cb(enum stk_agent_result result, gboolean confirm,
}
err = __ofono_voicecall_dial(vc, sc->addr.number, sc->addr.ton_npi,
- sc->alpha_id_call_setup, 0,
+ sc->alpha_id_call_setup,
+ sc->icon_id_call_setup.id,
qualifier >> 1, call_setup_connected,
stk);
if (err >= 0) {
@@ -1582,8 +1618,8 @@ static gboolean handle_command_set_up_call(const struct stk_command *cmd,
}
err = stk_agent_confirm_call(stk->current_agent, sc->alpha_id_usr_cfm,
- 0, confirm_call_cb, stk, NULL,
- stk->timeout * 1000);
+ &sc->icon_id_usr_cfm, confirm_call_cb,
+ stk, NULL, stk->timeout * 1000);
if (err < 0) {
/*
@@ -1614,9 +1650,7 @@ static void send_ussd_cancel(struct ofono_stk *stk)
if (ussd)
__ofono_ussd_initiate_cancel(ussd);
- if (stk->pending_cmd->send_ussd.alpha_id &&
- stk->pending_cmd->send_ussd.alpha_id[0])
- stk_alpha_id_unset(stk);
+ stk_alpha_id_unset(stk);
}
static void send_ussd_callback(int error, int dcs, const unsigned char *msg,
@@ -1628,9 +1662,7 @@ static void send_ussd_callback(int error, int dcs, const unsigned char *msg,
enum sms_charset charset;
unsigned char no_cause[] = { 0x00 };
- if (stk->pending_cmd->send_ussd.alpha_id &&
- stk->pending_cmd->send_ussd.alpha_id[0])
- stk_alpha_id_unset(stk);
+ stk_alpha_id_unset(stk);
memset(&rsp, 0, sizeof(rsp));
@@ -1762,8 +1794,7 @@ static gboolean handle_command_send_ussd(const struct stk_command *cmd,
return TRUE;
}
- if (cmd->send_ussd.alpha_id && cmd->send_ussd.alpha_id[0])
- stk_alpha_id_set(stk, cmd->send_ussd.alpha_id);
+ stk_alpha_id_set(stk, cmd->send_ussd.alpha_id, &cmd->send_ussd.icon_id);
return FALSE;
}
@@ -1834,9 +1865,7 @@ static void send_dtmf_cancel(struct ofono_stk *stk)
stk->respond_on_exit = FALSE;
stk->extern_req->cancelled = TRUE;
- if (stk->pending_cmd->send_dtmf.alpha_id &&
- stk->pending_cmd->send_dtmf.alpha_id[0])
- stk_alpha_id_unset(stk);
+ stk_alpha_id_unset(stk);
}
static void dtmf_sent_cb(const struct ofono_error *error, void *user_data)
@@ -1855,9 +1884,7 @@ static void dtmf_sent_cb(const struct ofono_error *error, void *user_data)
stk->respond_on_exit = FALSE;
- if (stk->pending_cmd->send_dtmf.alpha_id &&
- stk->pending_cmd->send_dtmf.alpha_id[0])
- stk_alpha_id_unset(stk);
+ stk_alpha_id_unset(stk);
if (error->type == OFONO_ERROR_TYPE_FAILURE &&
error->error == ENOENT) {
@@ -1957,8 +1984,7 @@ static gboolean handle_command_send_dtmf(const struct stk_command *cmd,
return TRUE;
}
- if (cmd->send_dtmf.alpha_id && cmd->send_dtmf.alpha_id[0])
- stk_alpha_id_set(stk, cmd->send_dtmf.alpha_id);
+ stk_alpha_id_set(stk, cmd->send_dtmf.alpha_id, &cmd->send_dtmf.icon_id);
/*
* Note that we don't strictly require an agent to be connected,
diff --git a/src/stkagent.c b/src/stkagent.c
index f62c2bd..354b87d 100644
--- a/src/stkagent.c
+++ b/src/stkagent.c
@@ -34,6 +34,8 @@
#include "ofono.h"
#include "common.h"
+#include "smsutil.h"
+#include "stkutil.h"
#include "stkagent.h"
enum allowed_error {
@@ -343,7 +345,7 @@ int stk_agent_request_selection(struct stk_agent *agent,
dbus_message_iter_init_append(agent->msg, &iter);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &menu->title);
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_BYTE, &menu->icon_id);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_BYTE, &menu->icon.id);
append_menu_items(&iter, menu->items);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT16, &default_item);
@@ -396,7 +398,8 @@ static void display_text_cb(DBusPendingCall *call, void *data)
}
int stk_agent_display_text(struct stk_agent *agent, const char *text,
- uint8_t icon_id, ofono_bool_t urgent,
+ const struct stk_icon_id *icon,
+ ofono_bool_t urgent,
stk_agent_display_text_cb cb,
void *user_data, ofono_destroy_func destroy,
int timeout)
@@ -412,7 +415,7 @@ int stk_agent_display_text(struct stk_agent *agent, const char *text,
dbus_message_append_args(agent->msg,
DBUS_TYPE_STRING, &text,
- DBUS_TYPE_BYTE, &icon_id,
+ DBUS_TYPE_BYTE, &icon->id,
DBUS_TYPE_BOOLEAN, &priority,
DBUS_TYPE_INVALID);
@@ -465,8 +468,8 @@ static void get_confirmation_cb(DBusPendingCall *call, void *data)
CALLBACK_END();
}
-int stk_agent_request_confirmation(struct stk_agent *agent,
- const char *text, uint8_t icon_id,
+int stk_agent_request_confirmation(struct stk_agent *agent, const char *text,
+ const struct stk_icon_id *icon,
stk_agent_confirmation_cb cb,
void *user_data,
ofono_destroy_func destroy,
@@ -482,7 +485,7 @@ int stk_agent_request_confirmation(struct stk_agent *agent,
dbus_message_append_args(agent->msg,
DBUS_TYPE_STRING, &text,
- DBUS_TYPE_BYTE, &icon_id,
+ DBUS_TYPE_BYTE, &icon->id,
DBUS_TYPE_INVALID);
if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call,
@@ -536,8 +539,8 @@ static void get_digit_cb(DBusPendingCall *call, void *data)
CALLBACK_END();
}
-int stk_agent_request_digit(struct stk_agent *agent,
- const char *text, uint8_t icon_id,
+int stk_agent_request_digit(struct stk_agent *agent, const char *text,
+ const struct stk_icon_id *icon,
stk_agent_string_cb cb, void *user_data,
ofono_destroy_func destroy, int timeout)
{
@@ -551,7 +554,7 @@ int stk_agent_request_digit(struct stk_agent *agent,
dbus_message_append_args(agent->msg,
DBUS_TYPE_STRING, &text,
- DBUS_TYPE_BYTE, &icon_id,
+ DBUS_TYPE_BYTE, &icon->id,
DBUS_TYPE_INVALID);
if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call,
@@ -604,7 +607,8 @@ static void get_key_cb(DBusPendingCall *call, void *data)
}
int stk_agent_request_key(struct stk_agent *agent, const char *text,
- uint8_t icon_id, ofono_bool_t unicode_charset,
+ const struct stk_icon_id *icon,
+ ofono_bool_t unicode_charset,
stk_agent_string_cb cb, void *user_data,
ofono_destroy_func destroy, int timeout)
{
@@ -618,7 +622,7 @@ int stk_agent_request_key(struct stk_agent *agent, const char *text,
dbus_message_append_args(agent->msg,
DBUS_TYPE_STRING, &text,
- DBUS_TYPE_BYTE, &icon_id,
+ DBUS_TYPE_BYTE, &icon->id,
DBUS_TYPE_INVALID);
if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call,
@@ -670,7 +674,8 @@ static void get_digits_cb(DBusPendingCall *call, void *data)
}
int stk_agent_request_digits(struct stk_agent *agent, const char *text,
- uint8_t icon_id, const char *default_text,
+ const struct stk_icon_id *icon,
+ const char *default_text,
int min, int max, ofono_bool_t hidden,
stk_agent_string_cb cb, void *user_data,
ofono_destroy_func destroy, int timeout)
@@ -691,7 +696,7 @@ int stk_agent_request_digits(struct stk_agent *agent, const char *text,
dbus_message_append_args(agent->msg,
DBUS_TYPE_STRING, &text,
- DBUS_TYPE_BYTE, &icon_id,
+ DBUS_TYPE_BYTE, &icon->id,
DBUS_TYPE_STRING, &default_text,
DBUS_TYPE_BYTE, &min_val,
DBUS_TYPE_BYTE, &max_val,
@@ -747,7 +752,8 @@ static void get_input_cb(DBusPendingCall *call, void *data)
}
int stk_agent_request_input(struct stk_agent *agent, const char *text,
- uint8_t icon_id, const char *default_text,
+ const struct stk_icon_id *icon,
+ const char *default_text,
ofono_bool_t unicode_charset, int min, int max,
ofono_bool_t hidden, stk_agent_string_cb cb,
void *user_data, ofono_destroy_func destroy,
@@ -769,7 +775,7 @@ int stk_agent_request_input(struct stk_agent *agent, const char *text,
dbus_message_append_args(agent->msg,
DBUS_TYPE_STRING, &text,
- DBUS_TYPE_BYTE, &icon_id,
+ DBUS_TYPE_BYTE, &icon->id,
DBUS_TYPE_STRING, &default_text,
DBUS_TYPE_BYTE, &min_val,
DBUS_TYPE_BYTE, &max_val,
@@ -824,7 +830,8 @@ static void confirm_call_cb(DBusPendingCall *call, void *data)
}
int stk_agent_confirm_call(struct stk_agent *agent, const char *text,
- uint8_t icon_id, stk_agent_confirmation_cb cb,
+ const struct stk_icon_id *icon,
+ stk_agent_confirmation_cb cb,
void *user_data, ofono_destroy_func destroy,
int timeout)
{
@@ -838,7 +845,7 @@ int stk_agent_confirm_call(struct stk_agent *agent, const char *text,
dbus_message_append_args(agent->msg,
DBUS_TYPE_STRING, &text,
- DBUS_TYPE_BYTE, &icon_id,
+ DBUS_TYPE_BYTE, &icon->id,
DBUS_TYPE_INVALID);
if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call,
diff --git a/src/stkagent.h b/src/stkagent.h
index c644210..97c4eca 100644
--- a/src/stkagent.h
+++ b/src/stkagent.h
@@ -36,7 +36,7 @@ struct stk_menu_item {
struct stk_menu {
char *title;
- uint8_t icon_id;
+ struct stk_icon_id icon;
struct stk_menu_item *items;
int default_item;
gboolean soft_key;
@@ -77,45 +77,49 @@ int stk_agent_request_selection(struct stk_agent *agent,
int timeout);
int stk_agent_display_text(struct stk_agent *agent, const char *text,
- uint8_t icon_id, ofono_bool_t urgent,
+ const struct stk_icon_id *icon,
+ ofono_bool_t urgent,
stk_agent_display_text_cb cb,
void *user_data, ofono_destroy_func destroy,
int timeout);
-int stk_agent_request_confirmation(struct stk_agent *agent,
- const char *text, uint8_t icon_id,
+int stk_agent_request_confirmation(struct stk_agent *agent, const char *text,
+ const struct stk_icon_id *icon,
stk_agent_confirmation_cb cb,
void *user_data,
ofono_destroy_func destroy,
int timeout);
-int stk_agent_request_digit(struct stk_agent *agent,
- const char *text, uint8_t icon_id,
+int stk_agent_request_digit(struct stk_agent *agent, const char *text,
+ const struct stk_icon_id *icon,
stk_agent_string_cb cb, void *user_data,
ofono_destroy_func destroy, int timeout);
int stk_agent_request_key(struct stk_agent *agent, const char *text,
- uint8_t icon_id, ofono_bool_t unicode_charset,
+ const struct stk_icon_id *icon,
+ ofono_bool_t unicode_charset,
stk_agent_string_cb cb, void *user_data,
ofono_destroy_func destroy, int timeout);
int stk_agent_request_digits(struct stk_agent *agent, const char *text,
- uint8_t icon_id, const char *default_text,
- int min, int max, ofono_bool_t hidden,
- stk_agent_string_cb cb, void *user_data,
- ofono_destroy_func destroy, int timeout);
+ const struct stk_icon_id *icon,
+ const char *default_text, int min, int max,
+ ofono_bool_t hidden, stk_agent_string_cb cb,
+ void *user_data, ofono_destroy_func destroy,
+ int timeout);
int stk_agent_request_input(struct stk_agent *agent, const char *text,
- uint8_t icon_id, const char *default_text,
+ const struct stk_icon_id *icon,
+ const char *default_text,
ofono_bool_t unicode_charset, int min, int max,
ofono_bool_t hidden, stk_agent_string_cb cb,
void *user_data, ofono_destroy_func destroy,
int timeout);
int stk_agent_confirm_call(struct stk_agent *agent, const char *text,
- uint8_t icon_id, stk_agent_confirmation_cb cb,
- void *user_data, ofono_destroy_func destroy,
- int timeout);
+ const struct stk_icon_id *icon,
+ stk_agent_confirmation_cb cb, void *user_data,
+ ofono_destroy_func destroy, int timeout);
void append_menu_items_variant(DBusMessageIter *iter,
const struct stk_menu_item *items);
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] stk: Apply STK text attributes as html.
2010-10-07 14:20 [PATCH 1/2] stk: Expose icon IDs on D-Bus Andrzej Zaborowski
@ 2010-10-07 14:20 ` Andrzej Zaborowski
2010-10-13 14:34 ` [PATCH 1/2] stk: Expose icon IDs on D-Bus Denis Kenzior
1 sibling, 0 replies; 3+ messages in thread
From: Andrzej Zaborowski @ 2010-10-07 14:20 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 10610 bytes --]
---
src/stk.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 120 insertions(+), 22 deletions(-)
diff --git a/src/stk.c b/src/stk.c
index 7aa2ea6..22b5270 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -256,6 +256,22 @@ void __ofono_cbs_sim_download(struct ofono_stk *stk, const struct cbs *msg)
stk_cbs_download_cb(stk, FALSE, NULL, -1);
}
+static char *dbus_apply_text_attributes(const char *text,
+ const struct stk_text_attribute *attr)
+{
+ uint16_t buf[256], *i = buf;
+ const uint8_t *j = attr->attributes;
+ const uint8_t *end = j + attr->len;
+
+ if (attr->len & 3)
+ return NULL;
+
+ while (j < end)
+ *i++ = *j++;
+
+ return stk_text_to_html(text, buf, attr->len / 4);
+}
+
static struct stk_menu *stk_menu_create(const char *title,
const struct stk_text_attribute *title_attr,
const struct stk_icon_id *icon, GSList *items,
@@ -267,6 +283,7 @@ static struct stk_menu *stk_menu_create(const char *title,
unsigned int len = g_slist_length(items);
GSList *l;
int i;
+ struct stk_text_attribute attr;
DBG("");
@@ -276,7 +293,11 @@ static struct stk_menu *stk_menu_create(const char *title,
if (item_icon_ids && item_icon_ids->len && item_icon_ids->len != len)
goto error;
- ret->title = g_strdup(title ? title : "");
+ ret->title = dbus_apply_text_attributes(title ? title : "",
+ title_attr);
+ if (!ret->title)
+ goto error;
+
memcpy(&ret->icon, icon, sizeof(ret->icon));
ret->items = g_new0(struct stk_menu_item, len + 1);
ret->default_item = -1;
@@ -285,9 +306,21 @@ static struct stk_menu *stk_menu_create(const char *title,
for (l = items, i = 0; l; l = l->next, i++) {
struct stk_item *item = l->data;
+ char *text;
- ret->items[i].text = g_strdup(item->text);
ret->items[i].item_id = item->id;
+
+ text = NULL;
+ if (item_attrs && item_attrs->len) {
+ memcpy(attr.attributes, &item_attrs->list[i * 4], 4);
+ attr.len = 4;
+
+ text = dbus_apply_text_attributes(item->text, &attr);
+ }
+ if (!text)
+ text = strdup(item->text);
+ ret->items[i].text = text;
+
if (item_icon_ids && item_icon_ids->len)
ret->items[i].icon_id = item_icon_ids->list[i];
@@ -409,7 +442,8 @@ static void dict_append_menu(DBusMessageIter *dict, struct stk_menu *menu)
dbus_message_iter_close_container(dict, &entry);
}
-static void stk_alpha_id_set(struct ofono_stk *stk, const char *text,
+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)
{
/* TODO */
@@ -762,7 +796,8 @@ static gboolean handle_command_send_sms(const struct stk_command *cmd,
stk->cancel_cmd = send_sms_cancel;
- stk_alpha_id_set(stk, cmd->send_sms.alpha_id, &cmd->send_sms.icon_id);
+ stk_alpha_id_set(stk, cmd->send_sms.alpha_id, &cmd->send_sms.text_attr,
+ &cmd->send_sms.icon_id);
return FALSE;
}
@@ -773,17 +808,26 @@ static gboolean handle_command_set_idle_text(const struct stk_command *cmd,
{
DBusConnection *conn = ofono_dbus_get_connection();
const char *path = __ofono_atom_get_path(stk->atom);
- const char *idle_mode_text;
+ char *idle_mode_text = NULL;
- if (stk->idle_mode_text) {
- g_free(stk->idle_mode_text);
- stk->idle_mode_text = NULL;
+ if (cmd->setup_idle_mode_text.text) {
+ idle_mode_text = dbus_apply_text_attributes(
+ cmd->setup_idle_mode_text.text,
+ &cmd->setup_idle_mode_text.text_attr);
+
+ if (!idle_mode_text) {
+ rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+
+ return TRUE;
+ }
}
- if (cmd->setup_idle_mode_text.text)
- stk->idle_mode_text = g_strdup(cmd->setup_idle_mode_text.text);
+ if (stk->idle_mode_text)
+ g_free(stk->idle_mode_text);
+
+ stk->idle_mode_text = idle_mode_text;
- idle_mode_text = stk->idle_mode_text ? stk->idle_mode_text : "";
+ idle_mode_text = idle_mode_text ? idle_mode_text : "";
ofono_dbus_signal_property_changed(conn, path, OFONO_STK_INTERFACE,
"IdleModeText",
DBUS_TYPE_STRING,
@@ -1166,6 +1210,14 @@ static gboolean handle_command_display_text(const struct stk_command *cmd,
struct stk_command_display_text *dt = &stk->pending_cmd->display_text;
uint8_t qualifier = stk->pending_cmd->qualifier;
ofono_bool_t priority = (qualifier & (1 << 0)) != 0;
+ char *text = dbus_apply_text_attributes(dt->text, &dt->text_attr);
+ int err;
+
+ if (!text) {
+ rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+
+ return TRUE;
+ }
if (dt->duration.interval) {
timeout = dt->duration.interval;
@@ -1179,10 +1231,13 @@ 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, &dt->icon_id,
+ err = stk_agent_display_text(stk->current_agent, text, &dt->icon_id,
priority, display_text_cb, stk,
- display_text_destroy, timeout) < 0) {
+ display_text_destroy, timeout);
+ g_free(text);
+
+ /* We most likely got an out of memory error, tell SIM to retry */
+ if (err < 0) {
rsp->result.type = STK_RESULT_TYPE_TERMINAL_BUSY;
return TRUE;
}
@@ -1316,6 +1371,7 @@ static gboolean handle_command_get_inkey(const struct stk_command *cmd,
{
int timeout = stk->timeout * 1000;
const struct stk_command_get_inkey *gi = &cmd->get_inkey;
+ char *text = dbus_apply_text_attributes(gi->text, &gi->text_attr);
uint8_t qualifier = stk->pending_cmd->qualifier;
gboolean alphabet = (qualifier & (1 << 0)) != 0;
gboolean ucs2 = (qualifier & (1 << 1)) != 0;
@@ -1326,6 +1382,12 @@ static gboolean handle_command_get_inkey(const struct stk_command *cmd,
*/
int err;
+ if (!text) {
+ rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+
+ return TRUE;
+ }
+
if (gi->duration.interval) {
timeout = gi->duration.interval;
switch (gi->duration.unit) {
@@ -1342,18 +1404,19 @@ static gboolean handle_command_get_inkey(const struct stk_command *cmd,
if (yesno)
err = stk_agent_request_confirmation(stk->current_agent,
- gi->text, &gi->icon_id,
+ text, &gi->icon_id,
request_confirmation_cb,
stk, NULL, timeout);
else if (alphabet)
- err = stk_agent_request_key(stk->current_agent, gi->text,
+ err = stk_agent_request_key(stk->current_agent, text,
&gi->icon_id, ucs2,
request_key_cb, stk, NULL,
timeout);
else
- err = stk_agent_request_digit(stk->current_agent, gi->text,
+ err = stk_agent_request_digit(stk->current_agent, text,
&gi->icon_id, request_key_cb,
stk, NULL, timeout);
+ g_free(text);
if (err < 0) {
/*
@@ -1414,12 +1477,19 @@ static gboolean handle_command_get_input(const struct stk_command *cmd,
{
int timeout = stk->timeout * 1000;
const struct stk_command_get_input *gi = &cmd->get_input;
+ char *text = dbus_apply_text_attributes(gi->text, &gi->text_attr);
uint8_t qualifier = stk->pending_cmd->qualifier;
gboolean alphabet = (qualifier & (1 << 0)) != 0;
gboolean ucs2 = (qualifier & (1 << 1)) != 0;
gboolean hidden = (qualifier & (1 << 2)) != 0;
int err;
+ if (!text) {
+ rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+
+ return TRUE;
+ }
+
if (alphabet)
err = stk_agent_request_input(stk->current_agent, gi->text,
&gi->icon_id, gi->default_text,
@@ -1434,6 +1504,7 @@ static gboolean handle_command_get_input(const struct stk_command *cmd,
gi->resp_len.max, hidden,
request_string_cb,
stk, NULL, timeout);
+ g_free(text);
if (err < 0) {
/*
@@ -1500,6 +1571,7 @@ static void confirm_call_cb(enum stk_agent_result result, gboolean confirm,
uint8_t qualifier = stk->pending_cmd->qualifier;
static unsigned char busy_on_call_result[] = { 0x02 };
static unsigned char no_cause_result[] = { 0x00 };
+ char *alpha_id = NULL;
struct ofono_voicecall *vc = NULL;
struct ofono_atom *vc_atom;
struct stk_response rsp;
@@ -1535,11 +1607,22 @@ static void confirm_call_cb(enum stk_agent_result result, gboolean confirm,
return;
}
+ if (sc->alpha_id_call_setup) {
+ alpha_id = dbus_apply_text_attributes(sc->alpha_id_call_setup,
+ &sc->text_attr_call_setup);
+ if (!alpha_id) {
+ send_simple_response(stk,
+ STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD);
+ return;
+ }
+ }
+
err = __ofono_voicecall_dial(vc, sc->addr.number, sc->addr.ton_npi,
- sc->alpha_id_call_setup,
- sc->icon_id_call_setup.id,
+ alpha_id, sc->icon_id_call_setup.id,
qualifier >> 1, call_setup_connected,
stk);
+ g_free(alpha_id);
+
if (err >= 0) {
stk->cancel_cmd = call_setup_cancel;
@@ -1582,6 +1665,7 @@ static gboolean handle_command_set_up_call(const struct stk_command *cmd,
const struct stk_command_setup_call *sc = &cmd->setup_call;
uint8_t qualifier = cmd->qualifier;
static unsigned char busy_on_call_result[] = { 0x02 };
+ char *alpha_id = NULL;
struct ofono_voicecall *vc = NULL;
struct ofono_atom *vc_atom;
int err;
@@ -1617,9 +1701,19 @@ static gboolean handle_command_set_up_call(const struct stk_command *cmd,
return TRUE;
}
- err = stk_agent_confirm_call(stk->current_agent, sc->alpha_id_usr_cfm,
+ if (sc->alpha_id_usr_cfm) {
+ alpha_id = dbus_apply_text_attributes(sc->alpha_id_usr_cfm,
+ &sc->text_attr_usr_cfm);
+ if (!alpha_id) {
+ rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+ return TRUE;
+ }
+ }
+
+ err = stk_agent_confirm_call(stk->current_agent, alpha_id,
&sc->icon_id_usr_cfm, confirm_call_cb,
stk, NULL, stk->timeout * 1000);
+ g_free(alpha_id);
if (err < 0) {
/*
@@ -1794,7 +1888,9 @@ static gboolean handle_command_send_ussd(const struct stk_command *cmd,
return TRUE;
}
- stk_alpha_id_set(stk, cmd->send_ussd.alpha_id, &cmd->send_ussd.icon_id);
+ stk_alpha_id_set(stk, cmd->send_ussd.alpha_id,
+ &cmd->send_ussd.text_attr,
+ &cmd->send_ussd.icon_id);
return FALSE;
}
@@ -1984,7 +2080,9 @@ 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.icon_id);
+ 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,
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] stk: Expose icon IDs on D-Bus.
2010-10-07 14:20 [PATCH 1/2] stk: Expose icon IDs on D-Bus Andrzej Zaborowski
2010-10-07 14:20 ` [PATCH 2/2] stk: Apply STK text attributes as html Andrzej Zaborowski
@ 2010-10-13 14:34 ` Denis Kenzior
1 sibling, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2010-10-13 14:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6875 bytes --]
Hi Andrew,
On 10/07/2010 09:20 AM, Andrzej Zaborowski wrote:
> Update the docs to match the properties in stk.c.
> ---
> doc/stk-api.txt | 16 ++++++-
> src/stk.c | 112 ++++++++++++++++++++++++++++++++++---------------------
> src/stkagent.c | 41 ++++++++++++--------
> src/stkagent.h | 34 +++++++++-------
> 4 files changed, 125 insertions(+), 78 deletions(-)
This patch no longer applies, can you please rebase it?
Also, please split up this patch up some more.
>
> diff --git a/doc/stk-api.txt b/doc/stk-api.txt
> index f5b9ebc..c29872a 100644
> --- a/doc/stk-api.txt
> +++ b/doc/stk-api.txt
> @@ -55,23 +55,33 @@ Signals PropertyChanged(string property, variant value)
> Signal is emitted whenever a property has changed.
> The new value is passed as the signal argument.
>
> -Properties string IdleText
> +Properties string IdleModeText
This is a bug fix, and should be in a separate patch.
>
> Contains the text to be used when the home screen is
> - idle. This text is set by the SIM and can be changed
> + idle. This text is set by the SIM and can change
> at any time.
Squash this into the patch above.
>
> + byte IdleModeIcon
> +
> + Contains the identifier of the icon accompanying
> + the idle mode text.
> +
> array{struct{string, byte}} MainMenu
>
> Contains the items that make up the main menu. This
> is populated by the SIM when it sends the Setup Menu
> Proactive Command. The main menu is always available,
> - but its contents can be changed at any time.
> + but its contents can be changed at any time. Each
> + item contains the item label and icon identifier.
>
> string MainMenuTitle
>
> Contains the title of the main menu.
>
> + string MainMenuIcon
> +
> + Contains the identifier of the icon for the main menu.
> +
> array{byte} Icons
>
Rest should be in a separate doc update patch.
> Contains the identifiers of all available icons for
> diff --git a/src/stk.c b/src/stk.c
> index 84a22c9..7aa2ea6 100644
> --- a/src/stk.c
> +++ b/src/stk.c
> @@ -72,6 +72,7 @@ struct ofono_stk {
> guint remove_agent_source;
> struct extern_req *extern_req;
> char *idle_mode_text;
> + struct stk_icon_id idle_mode_icon;
Idle Mode Icon and Main Menu Icon support should be in a separate patch.
> struct timeval get_inkey_start_ts;
> };
>
> @@ -256,19 +257,28 @@ void __ofono_cbs_sim_download(struct ofono_stk *stk, const struct cbs *msg)
> }
>
> static struct stk_menu *stk_menu_create(const char *title,
> - const struct stk_text_attribute *title_attr, GSList *items,
> + const struct stk_text_attribute *title_attr,
> + const struct stk_icon_id *icon, GSList *items,
> const struct stk_item_text_attribute_list *item_attrs,
> + const struct stk_item_icon_id_list *item_icon_ids,
> int default_id, gboolean soft_key, gboolean has_help)
> {
> struct stk_menu *ret = g_new(struct stk_menu, 1);
> + unsigned int len = g_slist_length(items);
> GSList *l;
> int i;
>
> DBG("");
>
> + if (item_attrs && item_attrs->len && item_attrs->len != len * 4)
> + goto error;
> +
> + if (item_icon_ids && item_icon_ids->len && item_icon_ids->len != len)
> + goto error;
> +
> ret->title = g_strdup(title ? title : "");
> - ret->icon_id = 0;
> - ret->items = g_new0(struct stk_menu_item, g_slist_length(items) + 1);
> + memcpy(&ret->icon, icon, sizeof(ret->icon));
> + ret->items = g_new0(struct stk_menu_item, len + 1);
> ret->default_item = -1;
> ret->soft_key = soft_key;
> ret->has_help = has_help;
> @@ -278,12 +288,18 @@ static struct stk_menu *stk_menu_create(const char *title,
>
> ret->items[i].text = g_strdup(item->text);
> ret->items[i].item_id = item->id;
> + if (item_icon_ids && item_icon_ids->len)
> + ret->items[i].icon_id = item_icon_ids->list[i];
>
> if (item->id == default_id)
> ret->default_item = i;
> }
>
> return ret;
> +
> +error:
> + g_free(ret);
> + return NULL;
> }
This part should be in a separate patch
<snip>
> @@ -381,7 +409,8 @@ static void dict_append_menu(DBusMessageIter *dict, struct stk_menu *menu)
> dbus_message_iter_close_container(dict, &entry);
> }
>
> -static void stk_alpha_id_set(struct ofono_stk *stk, const char *text)
> +static void stk_alpha_id_set(struct ofono_stk *stk, const char *text,
> + const struct stk_icon_id *icon)
stk_alpha_id_set changes should be in a separate patch ;)
<snip>
>
> - if (!stk->pending_cmd->send_sms.alpha_id ||
> - !stk->pending_cmd->send_sms.alpha_id[0])
> - return;
> -
This part does not look related to icon ids at all. Please break it out
into a separate patch.
> stk_alpha_id_unset(stk);
> }
>
> @@ -684,9 +713,7 @@ static void send_sms_submit_cb(gboolean ok, void *data)
> return;
> }
>
> - if (stk->pending_cmd->send_sms.alpha_id &&
> - stk->pending_cmd->send_sms.alpha_id[0])
> - stk_alpha_id_unset(stk);
> + stk_alpha_id_unset(stk);
Same comment as above.
<snip>
> @@ -1628,9 +1662,7 @@ static void send_ussd_callback(int error, int dcs, const unsigned char *msg,
> enum sms_charset charset;
> unsigned char no_cause[] = { 0x00 };
>
> - if (stk->pending_cmd->send_ussd.alpha_id &&
> - stk->pending_cmd->send_ussd.alpha_id[0])
> - stk_alpha_id_unset(stk);
> + stk_alpha_id_unset(stk);
And here as well.
> @@ -1834,9 +1865,7 @@ static void send_dtmf_cancel(struct ofono_stk *stk)
> stk->respond_on_exit = FALSE;
> stk->extern_req->cancelled = TRUE;
>
> - if (stk->pending_cmd->send_dtmf.alpha_id &&
> - stk->pending_cmd->send_dtmf.alpha_id[0])
> - stk_alpha_id_unset(stk);
> + stk_alpha_id_unset(stk);
And here
> }
>
> static void dtmf_sent_cb(const struct ofono_error *error, void *user_data)
> @@ -1855,9 +1884,7 @@ static void dtmf_sent_cb(const struct ofono_error *error, void *user_data)
>
> stk->respond_on_exit = FALSE;
>
> - if (stk->pending_cmd->send_dtmf.alpha_id &&
> - stk->pending_cmd->send_dtmf.alpha_id[0])
> - stk_alpha_id_unset(stk);
> + stk_alpha_id_unset(stk);
And here
<snip>
> struct stk_menu {
> char *title;
> - uint8_t icon_id;
> + struct stk_icon_id icon;
> struct stk_menu_item *items;
> int default_item;
> gboolean soft_key;
The stk menu patches should be in a separate patch.
> @@ -77,45 +77,49 @@ int stk_agent_request_selection(struct stk_agent *agent,
> int timeout);
>
> int stk_agent_display_text(struct stk_agent *agent, const char *text,
> - uint8_t icon_id, ofono_bool_t urgent,
> + const struct stk_icon_id *icon,
> + ofono_bool_t urgent,
<snip>
The stkagent changes should be in a separate patch...
Regards,
-Denis
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-10-13 14:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-07 14:20 [PATCH 1/2] stk: Expose icon IDs on D-Bus Andrzej Zaborowski
2010-10-07 14:20 ` [PATCH 2/2] stk: Apply STK text attributes as html Andrzej Zaborowski
2010-10-13 14:34 ` [PATCH 1/2] stk: Expose icon IDs on D-Bus Denis Kenzior
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.