summaryrefslogtreecommitdiffstats
path: root/src/ussd.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-02-15 10:39:29 -0600
committerDenis Kenzior <denkenz@gmail.com>2010-02-15 11:04:08 -0600
commit1ab40c469b59e0a6f52951c817feaa88424126c3 (patch)
treeeecd9f063e4ce5ba536654b91afaa66a18710b4a /src/ussd.c
parent4126c581f9cdee0549c1d7ca8e292b2150bf72e5 (diff)
downloadofono-1ab40c469b59e0a6f52951c817feaa88424126c3.tar.bz2
Cleanup: Get rid of USSD_FLAG_PENDING
Diffstat (limited to 'src/ussd.c')
-rw-r--r--src/ussd.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/ussd.c b/src/ussd.c
index 4221dfa6..470634a9 100644
--- a/src/ussd.c
+++ b/src/ussd.c
@@ -37,8 +37,6 @@
#define SUPPLEMENTARY_SERVICES_INTERFACE "org.ofono.SupplementaryServices"
-#define USSD_FLAG_PENDING 0x1
-
static GSList *g_drivers = NULL;
enum ussd_state {
@@ -346,29 +344,22 @@ out:
static void ussd_callback(const struct ofono_error *error, void *data)
{
struct ofono_ussd *ussd = data;
- DBusConnection *conn = ofono_dbus_get_connection();
DBusMessage *reply;
if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
DBG("ussd request 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_ACTIVE;
return;
}
- reply = __ofono_error_failed(ussd->pending);
-
- g_dbus_send_message(conn, reply);
+ if (!ussd->pending)
+ return;
- dbus_message_unref(ussd->pending);
- ussd->pending = NULL;
+ reply = __ofono_error_failed(ussd->pending);
+ __ofono_dbus_pending_reply(&ussd->pending, reply);
}
static DBusMessage *ussd_initiate(DBusConnection *conn, DBusMessage *msg,
@@ -377,7 +368,7 @@ static DBusMessage *ussd_initiate(DBusConnection *conn, DBusMessage *msg,
struct ofono_ussd *ussd = data;
const char *str;
- if (ussd->flags & USSD_FLAG_PENDING)
+ if (ussd->pending)
return __ofono_error_busy(msg);
if (ussd->state == USSD_STATE_ACTIVE)
@@ -403,7 +394,6 @@ static DBusMessage *ussd_initiate(DBusConnection *conn, DBusMessage *msg,
if (!ussd->driver->request)
return __ofono_error_not_implemented(msg);
- ussd->flags |= USSD_FLAG_PENDING;
ussd->pending = dbus_message_ref(msg);
ussd->driver->request(ussd, str, ussd_callback, ussd);
@@ -416,22 +406,19 @@ static void ussd_cancel_callback(const struct ofono_error *error, void *data)
struct ofono_ussd *ussd = data;
DBusMessage *reply;
+ ussd->state = USSD_STATE_IDLE;
+
if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
DBG("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;
-
+ if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
reply = dbus_message_new_method_return(ussd->pending);
- } else {
+ else
reply = __ofono_error_failed(ussd->pending);
- }
__ofono_dbus_pending_reply(&ussd->pending, reply);
}
@@ -441,7 +428,7 @@ static DBusMessage *ussd_cancel(DBusConnection *conn, DBusMessage *msg,
{
struct ofono_ussd *ussd = data;
- if (ussd->flags & USSD_FLAG_PENDING)
+ if (ussd->pending)
return __ofono_error_busy(msg);
if (ussd->state == USSD_STATE_IDLE)
@@ -450,7 +437,6 @@ static DBusMessage *ussd_cancel(DBusConnection *conn, DBusMessage *msg,
if (!ussd->driver->cancel)
return __ofono_error_not_implemented(msg);
- ussd->flags |= USSD_FLAG_PENDING;
ussd->pending = dbus_message_ref(msg);
ussd->driver->cancel(ussd, ussd_cancel_callback, ussd);