---
 src/stk.c |   42 ++++++++++++++++++++++++++++++++----------
 1 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index 87208d1..a107403 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -875,11 +875,17 @@ static gboolean handle_command_set_idle_text(const struct 
stk_command *cmd,
        const char *path = __ofono_atom_get_path(stk->atom);
        char *idle_mode_text;
 
+       if (cmd->setup_idle_mode_text.text == NULL &&
+                       cmd->setup_idle_mode_text.icon_id.id != 0) {
+               rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+               return TRUE;
+       }
+
        idle_mode_text = dbus_apply_text_attributes(
                                        cmd->setup_idle_mode_text.text,
                                        &cmd->setup_idle_mode_text.text_attr);
 
-       if (idle_mode_text == NULL) {
+       if (cmd->setup_idle_mode_text.text && idle_mode_text == NULL) {
                rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
                return TRUE;
        }
@@ -889,6 +895,7 @@ static gboolean handle_command_set_idle_text(const struct 
stk_command *cmd,
 
        stk->idle_mode_text = 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,
@@ -1275,10 +1282,17 @@ 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);
+       char *text;
        int err;
 
-       if (text == NULL) {
+       if (dt->text == NULL && dt->icon_id.id != 0) {
+               rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+               return TRUE;
+       }
+
+       text = dt->text ? dbus_apply_text_attributes(dt->text, &dt->text_attr) 
: "";
+
+       if (dt->text && text == NULL) {
                rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
                return TRUE;
        }
@@ -1292,7 +1306,9 @@ static gboolean handle_command_display_text(const struct 
stk_command *cmd,
        err = stk_agent_display_text(stk->current_agent, text, &dt->icon_id,
                                        priority, display_text_cb, stk,
                                        display_text_destroy, timeout);
-       g_free(text);
+
+       if (dt->text)
+               g_free(text);
 
        /* We most likely got an out of memory error, tell SIM to retry */
        if (err < 0) {
@@ -1431,7 +1447,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);
+       char *text;
        uint8_t qualifier = stk->pending_cmd->qualifier;
        gboolean alphabet = (qualifier & (1 << 0)) != 0;
        gboolean ucs2 = (qualifier & (1 << 1)) != 0;
@@ -1442,7 +1458,9 @@ static gboolean handle_command_get_inkey(const struct 
stk_command *cmd,
         */
        int err;
 
-       if (text == NULL) {
+       text = gi->text ? dbus_apply_text_attributes(gi->text, &gi->text_attr) 
: "";
+
+       if (gi->text && text == NULL) {
                rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
                return TRUE;
        }
@@ -1467,7 +1485,8 @@ static gboolean handle_command_get_inkey(const struct 
stk_command *cmd,
                                                &gi->icon_id, request_key_cb,
                                                stk, NULL, timeout);
 
-       g_free(text);
+       if (gi->text)
+               g_free(text);
 
        if (err < 0) {
                /*
@@ -1529,14 +1548,16 @@ 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);
+       char *text;
        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 == NULL) {
+       text = gi->text ? dbus_apply_text_attributes(gi->text, &gi->text_attr) 
: "";
+
+       if (gi->text && text == NULL) {
                rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
                return TRUE;
        }
@@ -1556,7 +1577,8 @@ static gboolean handle_command_get_input(const struct 
stk_command *cmd,
                                                request_string_cb,
                                                stk, NULL, timeout);
 
-       g_free(text);
+       if (gi->text)
+               g_free(text);
 
        if (err < 0) {
                /*
-- 
1.7.0.4

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to