ofono: be proactive when connecting
authorPekka Pessi <Pekka.Pessi@nokia.com>
Wed, 26 Jan 2011 14:50:39 +0000 (16:50 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 27 Jan 2011 10:09:06 +0000 (11:09 +0100)
Return error immediately if connection attempts are known to fail.

plugins/ofono.c

index 90b579d..3afe0f8 100644 (file)
@@ -471,11 +471,25 @@ static void set_apn(struct connman_network *network)
 
 static int network_connect(struct connman_network *network)
 {
+       struct connman_device *device;
+       struct modem_data *modem;
+
        DBG("network %p", network);
 
        if (connman_network_get_index(network) >= 0)
                return -EISCONN;
 
+       device = connman_network_get_device(network);
+       if (device == NULL)
+               return -ENODEV;
+
+       modem = connman_device_get_data(device);
+       if (modem == NULL)
+               return -ENODEV;
+
+       if (modem->powered == FALSE)
+               return -ENOLINK;
+
        return set_network_active(network, TRUE);
 }