summaryrefslogtreecommitdiffstats
path: root/src/ussd.c
diff options
context:
space:
mode:
authorAndrzej Zaborowski <andrew.zaborowski@intel.com>2010-03-31 06:57:07 +0200
committerDenis Kenzior <denkenz@gmail.com>2010-03-31 13:49:31 -0500
commitb6d4dd78c4e3a08e8a427f11952d4cb05c8bf6a5 (patch)
tree518b199a11113cf79a1fec50c98131c1a154998e /src/ussd.c
parent27d0bc6ccf75176b22b417b554d00a5580fc87d7 (diff)
downloadofono-b6d4dd78c4e3a08e8a427f11952d4cb05c8bf6a5.tar.bz2
Refactor: Return a string from USSD Respond method
Return network's USSD reponses from the Respond method instead of signaling over D-Bus. This should make the UI writer's job a little easier.
Diffstat (limited to 'src/ussd.c')
-rw-r--r--src/ussd.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/ussd.c b/src/ussd.c
index a2a4f5d3..9ec7600d 100644
--- a/src/ussd.c
+++ b/src/ussd.c
@@ -360,8 +360,20 @@ void ofono_ussd_notify(struct ofono_ussd *ussd, int status, const char *str)
else
ussd_change_state(ussd, USSD_STATE_IDLE);
- } else if (ussd->state == USSD_STATE_IDLE ||
- ussd->state == USSD_STATE_RESPONSE_SENT) {
+ } else if (ussd->state == USSD_STATE_RESPONSE_SENT) {
+ reply = dbus_message_new_method_return(ussd->pending);
+
+ if (!str)
+ str = "";
+
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &str,
+ DBUS_TYPE_INVALID);
+
+ if (status == OFONO_USSD_STATUS_ACTION_REQUIRED)
+ ussd_change_state(ussd, USSD_STATE_USER_ACTION);
+ else
+ ussd_change_state(ussd, USSD_STATE_IDLE);
+ } else if (ussd->state == USSD_STATE_IDLE) {
const char *signal_name;
const char *path = __ofono_atom_get_path(ussd->atom);
int new_state;
@@ -462,14 +474,19 @@ static void ussd_response_callback(const struct ofono_error *error, void *data)
struct ofono_ussd *ussd = data;
DBusMessage *reply;
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
+ DBG("ussd response failed with error: %s",
+ telephony_error_to_str(error));
+
if (error->type == OFONO_ERROR_TYPE_NO_ERROR) {
ussd_change_state(ussd, USSD_STATE_RESPONSE_SENT);
- reply = dbus_message_new_method_return(ussd->pending);
- } else {
- ussd_change_state(ussd, USSD_STATE_IDLE);
- reply = __ofono_error_failed(ussd->pending);
+ return;
}
+ if (!ussd->pending)
+ return;
+
+ reply = __ofono_error_failed(ussd->pending);
__ofono_dbus_pending_reply(&ussd->pending, reply);
}
@@ -575,7 +592,7 @@ static DBusMessage *ussd_get_properties(DBusConnection *conn,
static GDBusMethodTable ussd_methods[] = {
{ "Initiate", "s", "sv", ussd_initiate,
G_DBUS_METHOD_FLAG_ASYNC },
- { "Respond", "s", "", ussd_respond,
+ { "Respond", "s", "s", ussd_respond,
G_DBUS_METHOD_FLAG_ASYNC },
{ "Cancel", "", "", ussd_cancel,
G_DBUS_METHOD_FLAG_ASYNC },