Fix service lookup for WiFi and WiMAX devices
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 12 May 2009 23:18:49 +0000 (16:18 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 12 May 2009 23:18:49 +0000 (16:18 -0700)
src/element.c

index 9dd566a..ecdf4bf 100644 (file)
@@ -272,9 +272,22 @@ int __connman_element_count(struct connman_element *element,
        return data.count;
 }
 
+static struct connman_network *__connman_element_get_network(struct connman_element *element)
+{
+       if (element->type == CONNMAN_ELEMENT_TYPE_NETWORK &&
+                                               element->network != NULL)
+               return element->network;
+
+       if (element->parent == NULL)
+               return NULL;
+
+       return __connman_element_get_network(element->parent);
+}
+
 struct connman_service *__connman_element_get_service(struct connman_element *element)
 {
        struct connman_service *service;
+       struct connman_network *network;
        struct connman_device *device;
        enum connman_device_type type;
 
@@ -287,8 +300,6 @@ struct connman_service *__connman_element_get_service(struct connman_element *el
        switch (type) {
        case CONNMAN_DEVICE_TYPE_UNKNOWN:
        case CONNMAN_DEVICE_TYPE_VENDOR:
-       case CONNMAN_DEVICE_TYPE_WIFI:
-       case CONNMAN_DEVICE_TYPE_WIMAX:
        case CONNMAN_DEVICE_TYPE_BLUETOOTH:
        case CONNMAN_DEVICE_TYPE_GPS:
        case CONNMAN_DEVICE_TYPE_HSO:
@@ -299,6 +310,13 @@ struct connman_service *__connman_element_get_service(struct connman_element *el
        case CONNMAN_DEVICE_TYPE_ETHERNET:
                service = __connman_service_lookup_from_device(device);
                break;
+       case CONNMAN_DEVICE_TYPE_WIFI:
+       case CONNMAN_DEVICE_TYPE_WIMAX:
+               network = __connman_element_get_network(element);
+               if (network == NULL)
+                       return NULL;
+               service = __connman_service_lookup_from_network(network);
+               break;
        }
 
        return service;