service: Fix calling Agent API request input function
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 9 Aug 2011 07:59:17 +0000 (10:59 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 9 Aug 2011 10:16:34 +0000 (12:16 +0200)
Requesting passphrases from the user has been done only when the
ConnectService D-Bus method has been called. As user input may be
needed every time a service is connected, input requesting moved to
__connman_service_connect() instead. Also to note is that the same
service can be retried after a failed connection attempt, for those
cases an already associated service->network needs to be disconnected
before an new connection is attempted.

src/service.c

index 7c0bf4d..154ddfa 100644 (file)
@@ -2813,13 +2813,6 @@ static DBusMessage *connect_service(DBusConnection *conn,
 
        err = __connman_service_connect(service);
        if (err < 0) {
-               if (err == -ENOKEY) {
-                       if (__connman_agent_request_input(service,
-                                                       request_input_cb,
-                                                       NULL) == 0)
-                               return NULL;
-               }
-
                if (service->pending == NULL)
                        return NULL;
 
@@ -3996,12 +3989,6 @@ int __connman_service_connect(struct connman_service *service)
                return -EINPROGRESS;
        }
 
-       if (err == -ENOKEY)
-               return -ENOKEY;
-
-       if (service->userconnect == TRUE)
-               reply_pending(service, err);
-
        __connman_service_ipconfig_indicate_state(service,
                                        CONNMAN_SERVICE_STATE_FAILURE,
                                        CONNMAN_IPCONFIG_TYPE_IPV4);
@@ -4009,6 +3996,18 @@ int __connman_service_connect(struct connman_service *service)
                                        CONNMAN_SERVICE_STATE_FAILURE,
                                        CONNMAN_IPCONFIG_TYPE_IPV6);
 
+       __connman_network_disconnect(service->network);
+
+       if (service->userconnect == TRUE) {
+               if (err == -ENOKEY) {
+                       if (__connman_agent_request_input(service,
+                                                       request_input_cb,
+                                                       NULL) == -EIO)
+                               return -EINPROGRESS;
+               }
+               reply_pending(service, err);
+       }
+
        return err;
 }