service: Return connecting status while idle
authorMohamed Abbas <mabbas@linux.intel.com>
Thu, 23 Dec 2010 09:24:25 +0000 (10:24 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 23 Dec 2010 11:45:38 +0000 (12:45 +0100)
The auto connection decision is then all let to service_auto_connect() as
it can now handle the connecting while idle decision.

src/network.c
src/service.c

index 57d873a..81f963e 100644 (file)
@@ -896,10 +896,10 @@ int __connman_network_connect(struct connman_network *network)
        if (network->device == NULL)
                return -ENODEV;
 
-       __connman_device_disconnect(network->device);
-
        network->connecting = TRUE;
 
+       __connman_device_disconnect(network->device);
+
        service = __connman_service_lookup_from_network(network);
 
        err = network->driver->connect(network);
index c7aed25..f7fa76c 100644 (file)
@@ -308,6 +308,9 @@ static connman_bool_t is_connecting(struct connman_service *service)
        case CONNMAN_SERVICE_STATE_UNKNOWN:
        case CONNMAN_SERVICE_STATE_IDLE:
        case CONNMAN_SERVICE_STATE_FAILURE:
+               if (service->network != NULL)
+                       return __connman_network_get_connecting(
+                                                       service->network);
        case CONNMAN_SERVICE_STATE_DISCONNECT:
        case CONNMAN_SERVICE_STATE_READY:
        case CONNMAN_SERVICE_STATE_ONLINE:
@@ -2798,6 +2801,11 @@ static gint service_compare(gconstpointer a, gconstpointer b,
                        return -1;
                if (is_connected(service_b) == TRUE)
                        return 1;
+
+               if (is_connecting(service_a) == TRUE)
+                       return -1;
+               if (is_connecting(service_b) == TRUE)
+                       return 1;
        }
 
        if (service_a->order > service_b->order)