summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-07-21 12:08:12 +0200
committerMarcel Holtmann <marcel@holtmann.org>2009-07-21 12:08:12 +0200
commit47eab9ed1e78e901e83507bafe946cf1fab3ab50 (patch)
tree84def4e053465f17780be7272ce8cf21cb76677d
parentb4bbbe6e9c7e5e0b6c2f57676fe05417a3e471db (diff)
downloadconnman-47eab9ed1e78e901e83507bafe946cf1fab3ab50.tar.gz
connman-47eab9ed1e78e901e83507bafe946cf1fab3ab50.tar.bz2
connman-47eab9ed1e78e901e83507bafe946cf1fab3ab50.zip
Handle the async notification of scan requests
-rw-r--r--plugins/supplicant.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/plugins/supplicant.c b/plugins/supplicant.c
index 5b23d921..50d08bd3 100644
--- a/plugins/supplicant.c
+++ b/plugins/supplicant.c
@@ -901,6 +901,30 @@ static int set_network(struct supplicant_task *task,
return 0;
}
+static void scan_reply(DBusPendingCall *call, void *user_data)
+{
+ struct supplicant_task *task = user_data;
+ DBusMessage *reply;
+
+ DBG("task %p", task);
+
+ reply = dbus_pending_call_steal_reply(call);
+ if (reply == NULL)
+ return;
+
+ if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
+ connman_device_set_scanning(task->device, FALSE);
+ goto done;
+ }
+
+ if (task->scanning == TRUE)
+ connman_device_set_scanning(task->device, TRUE);
+
+done:
+ dbus_message_unref(reply);
+}
+
+
static int initiate_scan(struct supplicant_task *task)
{
DBusMessage *message;
@@ -922,9 +946,17 @@ static int initiate_scan(struct supplicant_task *task)
return -EIO;
}
+ if (call == NULL) {
+ connman_error("D-Bus connection not available");
+ dbus_message_unref(message);
+ return -EIO;
+ }
+
+ dbus_pending_call_set_notify(call, scan_reply, task, NULL);
+
dbus_message_unref(message);
- return 0;
+ return -EINPROGRESS;
}
static struct {
@@ -1753,6 +1785,9 @@ int supplicant_scan(struct connman_device *device)
err = initiate_scan(task);
if (err < 0) {
+ if (err == -EINPROGRESS)
+ return 0;
+
task->scanning = FALSE;
return err;
}