From 8d628ef7f4211e1bfb647d9129ed6ebbe1a61d0e Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 12 May 2009 17:30:38 -0500 Subject: [PATCH] Implement callback for the cancel function --- src/ussd.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/ussd.c b/src/ussd.c index 6c2712a9..c9796e55 100644 --- a/src/ussd.c +++ b/src/ussd.c @@ -335,9 +335,28 @@ static DBusMessage *ussd_initiate(DBusConnection *conn, DBusMessage *msg, return NULL; } -static void ussd_cancel_callback(const struct ofono_error *err, void *data) +static void ussd_cancel_callback(const struct ofono_error *error, void *data) { - //struct ussd_data *ussd = data; + struct ussd_data *ussd = data; + DBusMessage *reply; + + if (error->type != OFONO_ERROR_TYPE_NO_ERROR) + ofono_debug("ussd cancel failed with error: %s", + telephony_error_to_str(error)); + + ussd->flags &= ~USSD_FLAG_PENDING; + + if (!ussd->pending) + return; + + if (error->type == OFONO_ERROR_TYPE_NO_ERROR) { + ussd->state = USSD_STATE_IDLE; + + reply = dbus_message_new_method_return(ussd->pending); + } else + reply = dbus_gsm_failed(ussd->pending); + + dbus_gsm_pending_reply(&ussd->pending, reply); } static DBusMessage *ussd_cancel(DBusConnection *conn, DBusMessage *msg,