ussd: Be extra pedantic trying to Cancel
authorDenis Kenzior <denkenz@gmail.com>
Mon, 16 Aug 2010 16:02:05 +0000 (11:02 -0500)
committerDenis Kenzior <denkenz@gmail.com>
Mon, 16 Aug 2010 16:02:05 +0000 (11:02 -0500)
If we initiated a Respond() transaction, but have not returned from the
callback.  Or if we already called Cancel and it hasn't returned yet.

src/ussd.c

index a2d6cf3..825d560 100644 (file)
@@ -554,6 +554,13 @@ static DBusMessage *ussd_cancel(DBusConnection *conn, DBusMessage *msg,
        if (ussd->state == USSD_STATE_IDLE)
                return __ofono_error_not_active(msg);
 
+       /* We have called Respond() but not returned from its callback yet */
+       if (ussd->state == USSD_STATE_USER_ACTION && ussd->pending)
+               return __ofono_error_busy(msg);
+
+       if (ussd->cancel)
+               return __ofono_error_busy(msg);
+
        if (!ussd->driver->cancel)
                return __ofono_error_not_implemented(msg);