Enable USSD_STATE_USER_ACTION
authorAki Niemi <aki.niemi@nokia.com>
Tue, 9 Feb 2010 21:19:11 +0000 (23:19 +0200)
committerAki Niemi <aki.niemi@nokia.com>
Tue, 9 Feb 2010 21:19:11 +0000 (23:19 +0200)
If the network requests user action in the response to an MO USSD, we
cannot immediately return to USSD_STATE_USER_IDLE. Instead,
USSD_STATE_USER_ACTION is entered.

Note that it is left up to the driver to notify() when the USSD
transaction is closed by the network due to inactivity. Another way to
return to USSD_STATE_IDLE is for the user to cancel() the transaction.

src/ussd.c

index e5b53ff..4221dfa 100644 (file)
@@ -285,22 +285,26 @@ void ofono_ussd_notify(struct ofono_ussd *ussd, int status, const char *str)
 
        if (status == OFONO_USSD_STATUS_NOT_SUPPORTED) {
                ussd->state = USSD_STATE_IDLE;
+
+               if (!ussd->pending)
+                       return;
+
                reply = __ofono_error_not_supported(ussd->pending);
                goto out;
        }
 
        if (status == OFONO_USSD_STATUS_TIMED_OUT) {
                ussd->state = USSD_STATE_IDLE;
+
+               if (!ussd->pending)
+                       return;
+
                reply = __ofono_error_timed_out(ussd->pending);
                goto out;
        }
 
        /* TODO: Rework this in the Agent framework */
        if (ussd->state == USSD_STATE_ACTIVE) {
-               if (status == OFONO_USSD_STATUS_ACTION_REQUIRED) {
-                       ofono_error("Unable to handle action required ussd");
-                       return;
-               }
 
                reply = dbus_message_new_method_return(ussd->pending);
 
@@ -320,7 +324,11 @@ void ofono_ussd_notify(struct ofono_ussd *ussd, int status, const char *str)
 
                dbus_message_iter_close_container(&iter, &variant);
 
-               ussd->state = USSD_STATE_IDLE;
+               if (status == OFONO_USSD_STATUS_ACTION_REQUIRED)
+                       ussd->state = USSD_STATE_USER_ACTION;
+               else
+                       ussd->state = USSD_STATE_IDLE;
+
        } else {
                ofono_error("Received an unsolicited USSD, ignoring for now...");
                DBG("USSD is: status: %d, %s", status, str);