diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-02-16 10:14:23 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-02-16 10:18:04 -0600 |
commit | 1c3aaaacc6575f0cf7c3c507ea88b6f3d14461f9 (patch) | |
tree | f2512a0c37986f503b2ef89e36a4ff4ed367fafd | |
parent | d17b2d847114d149a7ff0a32bf65d808d997cb85 (diff) | |
download | ofono-1c3aaaacc6575f0cf7c3c507ea88b6f3d14461f9.tar.bz2 |
Refactor: ussd user response
When the user sends a response, the network can still continue the
dialog, it is not a final response and we cannot transition to an idle
state when the command finishes. Instead we set it back to a special
state and treat subsequent network responses as unsolicited.
-rw-r--r-- | src/ussd.c | 21 |
1 files changed, 7 insertions, 14 deletions
@@ -42,7 +42,8 @@ static GSList *g_drivers = NULL; enum ussd_state { USSD_STATE_IDLE = 0, USSD_STATE_ACTIVE = 1, - USSD_STATE_USER_ACTION = 2 + USSD_STATE_USER_ACTION = 2, + USSD_STATE_RESPONSE_SENT, }; struct ofono_ussd { @@ -278,6 +279,7 @@ static const char *ussd_get_state_string(struct ofono_ussd *ussd) case USSD_STATE_IDLE: return "idle"; case USSD_STATE_ACTIVE: + case USSD_STATE_RESPONSE_SENT: return "active"; case USSD_STATE_USER_ACTION: return "user-response"; @@ -358,7 +360,8 @@ 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) { + } else if (ussd->state == USSD_STATE_IDLE || + ussd->state == USSD_STATE_RESPONSE_SENT) { const char *signal_name; const char *path = __ofono_atom_get_path(ussd->atom); int new_state; @@ -457,26 +460,16 @@ static DBusMessage *ussd_initiate(DBusConnection *conn, DBusMessage *msg, static void ussd_response_callback(const struct ofono_error *error, void *data) { struct ofono_ussd *ussd = data; - DBusConnection *conn = ofono_dbus_get_connection(); DBusMessage *reply; - if (!ussd->pending) - return; - if (error->type == OFONO_ERROR_TYPE_NO_ERROR) { - ussd_change_state(ussd, USSD_STATE_IDLE); - + ussd_change_state(ussd, USSD_STATE_ACTIVE); reply = dbus_message_new_method_return(ussd->pending); } else { - DBG("ussd response failed with error: %s", - telephony_error_to_str(error)); - + ussd_change_state(ussd, USSD_STATE_IDLE); reply = __ofono_error_failed(ussd->pending); } - g_dbus_send_message(conn, reply); - - reply = __ofono_error_failed(ussd->pending); __ofono_dbus_pending_reply(&ussd->pending, reply); } |