mirror of git://git.sysmocom.de/ofono
ussd: Properly handle cancellations
This commit is contained in:
parent
f86bc5ebde
commit
0699de64eb
28
src/ussd.c
28
src/ussd.c
|
@ -49,6 +49,7 @@ enum ussd_state {
|
||||||
struct ofono_ussd {
|
struct ofono_ussd {
|
||||||
int state;
|
int state;
|
||||||
DBusMessage *pending;
|
DBusMessage *pending;
|
||||||
|
DBusMessage *cancel;
|
||||||
int flags;
|
int flags;
|
||||||
GSList *ss_control_list;
|
GSList *ss_control_list;
|
||||||
GSList *ss_passwd_list;
|
GSList *ss_passwd_list;
|
||||||
|
@ -524,21 +525,25 @@ static void ussd_cancel_callback(const struct ofono_error *error, void *data)
|
||||||
struct ofono_ussd *ussd = data;
|
struct ofono_ussd *ussd = data;
|
||||||
DBusMessage *reply;
|
DBusMessage *reply;
|
||||||
|
|
||||||
ussd_change_state(ussd, USSD_STATE_IDLE);
|
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
|
||||||
|
|
||||||
if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
|
|
||||||
DBG("ussd cancel failed with error: %s",
|
DBG("ussd cancel failed with error: %s",
|
||||||
telephony_error_to_str(error));
|
telephony_error_to_str(error));
|
||||||
|
|
||||||
if (!ussd->pending)
|
reply = __ofono_error_failed(ussd->cancel);
|
||||||
|
__ofono_dbus_pending_reply(&ussd->cancel, reply);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
|
if (ussd->pending) {
|
||||||
reply = dbus_message_new_method_return(ussd->pending);
|
reply = __ofono_error_canceled(ussd->pending);
|
||||||
else
|
__ofono_dbus_pending_reply(&ussd->pending, reply);
|
||||||
reply = __ofono_error_failed(ussd->pending);
|
}
|
||||||
|
|
||||||
__ofono_dbus_pending_reply(&ussd->pending, reply);
|
reply = dbus_message_new_method_return(ussd->cancel);
|
||||||
|
__ofono_dbus_pending_reply(&ussd->cancel, reply);
|
||||||
|
|
||||||
|
ussd_change_state(ussd, USSD_STATE_IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DBusMessage *ussd_cancel(DBusConnection *conn, DBusMessage *msg,
|
static DBusMessage *ussd_cancel(DBusConnection *conn, DBusMessage *msg,
|
||||||
|
@ -546,16 +551,13 @@ static DBusMessage *ussd_cancel(DBusConnection *conn, DBusMessage *msg,
|
||||||
{
|
{
|
||||||
struct ofono_ussd *ussd = data;
|
struct ofono_ussd *ussd = data;
|
||||||
|
|
||||||
if (ussd->pending)
|
|
||||||
return __ofono_error_busy(msg);
|
|
||||||
|
|
||||||
if (ussd->state == USSD_STATE_IDLE)
|
if (ussd->state == USSD_STATE_IDLE)
|
||||||
return __ofono_error_not_active(msg);
|
return __ofono_error_not_active(msg);
|
||||||
|
|
||||||
if (!ussd->driver->cancel)
|
if (!ussd->driver->cancel)
|
||||||
return __ofono_error_not_implemented(msg);
|
return __ofono_error_not_implemented(msg);
|
||||||
|
|
||||||
ussd->pending = dbus_message_ref(msg);
|
ussd->cancel = dbus_message_ref(msg);
|
||||||
|
|
||||||
ussd->driver->cancel(ussd, ussd_cancel_callback, ussd);
|
ussd->driver->cancel(ussd, ussd_cancel_callback, ussd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue