service: Send D-Bus reply for Manager.ConnectService when service is ready
authorSamuel Ortiz <sameo@linux.intel.com>
Wed, 23 Mar 2011 11:04:14 +0000 (12:04 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Wed, 23 Mar 2011 11:04:14 +0000 (12:04 +0100)
The D-Bus reply for Manager.ConnectService is currently immediatly
returning the service path. It should still return it, but only after the
service is ready or failed to connect.

Fixes BMC#14798
Fixes BMC#14808

src/service.c
test/connect-service

index 8758b92..f4b15f0 100644 (file)
@@ -2537,9 +2537,21 @@ static void reply_pending(struct connman_service *service, int error)
                                                                error);
                        if (reply != NULL)
                                g_dbus_send_message(connection, reply);
-               } else
-                       g_dbus_send_reply(connection, service->pending,
+               } else {
+                       const char *sender;
+
+                       sender = dbus_message_get_interface(service->pending);
+
+                       DBG("sender %s", sender);
+
+                       if (g_strcmp0(sender, CONNMAN_MANAGER_INTERFACE) == 0)
+                               g_dbus_send_reply(connection, service->pending,
+                                       DBUS_TYPE_OBJECT_PATH, &service->path,
                                                        DBUS_TYPE_INVALID);
+                       else
+                               g_dbus_send_reply(connection, service->pending,
+                                                       DBUS_TYPE_INVALID);
+               }
 
                dbus_message_unref(service->pending);
                service->pending = NULL;
@@ -4128,9 +4140,7 @@ done:
        if (err < 0 && err != -EINPROGRESS)
                goto failed;
 
-       g_dbus_send_reply(connection, msg,
-                               DBUS_TYPE_OBJECT_PATH, &service->path,
-                                                       DBUS_TYPE_INVALID);
+       service->pending = dbus_message_ref(msg);
 
        return 0;
 
index 2d88cb5..8621602 100755 (executable)
@@ -27,5 +27,6 @@ else:
 path = manager.ConnectService(({ "Type": "wifi", "Mode": "managed",
                                        "SSID": sys.argv[1],
                                        "Security": security,
-                                       "Passphrase": passphrase }));
+                                       "Passphrase": passphrase }),
+                                               timeout=60000);
 print "Service path is %s" %(path)