technology: trigger technology creation by new interface
authorGuillaume Lucas <guillaumex.lucas@intel.com>
Fri, 4 Feb 2011 08:04:05 +0000 (08:04 +0000)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 4 Feb 2011 10:37:21 +0000 (11:37 +0100)
src/technology.c

index 7d89b2e..5ef3d10 100644 (file)
@@ -139,81 +139,6 @@ void connman_technology_driver_unregister(struct connman_technology_driver *driv
        driver_list = g_slist_remove(driver_list, driver);
 }
 
-void __connman_technology_add_interface(enum connman_service_type type,
-                               int index, const char *name, const char *ident)
-{
-       GSList *list;
-
-       switch (type) {
-       case CONNMAN_SERVICE_TYPE_UNKNOWN:
-       case CONNMAN_SERVICE_TYPE_SYSTEM:
-               return;
-       case CONNMAN_SERVICE_TYPE_ETHERNET:
-       case CONNMAN_SERVICE_TYPE_WIFI:
-       case CONNMAN_SERVICE_TYPE_WIMAX:
-       case CONNMAN_SERVICE_TYPE_BLUETOOTH:
-       case CONNMAN_SERVICE_TYPE_CELLULAR:
-       case CONNMAN_SERVICE_TYPE_GPS:
-       case CONNMAN_SERVICE_TYPE_VPN:
-       case CONNMAN_SERVICE_TYPE_GADGET:
-               break;
-       }
-
-       connman_info("Create interface %s [ %s ]", name,
-                               __connman_service_type2string(type));
-
-       for (list = technology_list; list; list = list->next) {
-               struct connman_technology *technology = list->data;
-
-               if (technology->type != type)
-                       continue;
-
-               if (technology->driver == NULL)
-                       continue;
-
-               if (technology->driver->add_interface)
-                       technology->driver->add_interface(technology,
-                                                       index, name, ident);
-       }
-}
-
-void __connman_technology_remove_interface(enum connman_service_type type,
-                               int index, const char *name, const char *ident)
-{
-       GSList *list;
-
-       switch (type) {
-       case CONNMAN_SERVICE_TYPE_UNKNOWN:
-       case CONNMAN_SERVICE_TYPE_SYSTEM:
-               return;
-       case CONNMAN_SERVICE_TYPE_ETHERNET:
-       case CONNMAN_SERVICE_TYPE_WIFI:
-       case CONNMAN_SERVICE_TYPE_WIMAX:
-       case CONNMAN_SERVICE_TYPE_BLUETOOTH:
-       case CONNMAN_SERVICE_TYPE_CELLULAR:
-       case CONNMAN_SERVICE_TYPE_GPS:
-       case CONNMAN_SERVICE_TYPE_VPN:
-       case CONNMAN_SERVICE_TYPE_GADGET:
-               break;
-       }
-
-       connman_info("Remove interface %s [ %s ]", name,
-                               __connman_service_type2string(type));
-
-       for (list = technology_list; list; list = list->next) {
-               struct connman_technology *technology = list->data;
-
-               if (technology->type != type)
-                       continue;
-
-               if (technology->driver == NULL)
-                       continue;
-
-               if (technology->driver->remove_interface)
-                       technology->driver->remove_interface(technology, index);
-       }
-}
-
 static void tethering_changed(struct connman_technology *technology)
 {
        connman_bool_t tethering = technology->tethering;
@@ -619,6 +544,85 @@ static void technology_put(struct connman_technology *technology)
        g_free(technology);
 }
 
+void __connman_technology_add_interface(enum connman_service_type type,
+                               int index, const char *name, const char *ident)
+{
+       GSList *list;
+
+       switch (type) {
+       case CONNMAN_SERVICE_TYPE_UNKNOWN:
+       case CONNMAN_SERVICE_TYPE_SYSTEM:
+               return;
+       case CONNMAN_SERVICE_TYPE_ETHERNET:
+       case CONNMAN_SERVICE_TYPE_WIFI:
+       case CONNMAN_SERVICE_TYPE_WIMAX:
+       case CONNMAN_SERVICE_TYPE_BLUETOOTH:
+       case CONNMAN_SERVICE_TYPE_CELLULAR:
+       case CONNMAN_SERVICE_TYPE_GPS:
+       case CONNMAN_SERVICE_TYPE_VPN:
+       case CONNMAN_SERVICE_TYPE_GADGET:
+               break;
+       }
+
+       connman_info("Create interface %s [ %s ]", name,
+                               __connman_service_type2string(type));
+
+       technology_get(type);
+
+       for (list = technology_list; list; list = list->next) {
+               struct connman_technology *technology = list->data;
+
+               if (technology->type != type)
+                       continue;
+
+               if (technology->driver == NULL)
+                       continue;
+
+               if (technology->driver->add_interface)
+                       technology->driver->add_interface(technology,
+                                                       index, name, ident);
+       }
+}
+
+void __connman_technology_remove_interface(enum connman_service_type type,
+                               int index, const char *name, const char *ident)
+{
+       GSList *list;
+
+       switch (type) {
+       case CONNMAN_SERVICE_TYPE_UNKNOWN:
+       case CONNMAN_SERVICE_TYPE_SYSTEM:
+               return;
+       case CONNMAN_SERVICE_TYPE_ETHERNET:
+       case CONNMAN_SERVICE_TYPE_WIFI:
+       case CONNMAN_SERVICE_TYPE_WIMAX:
+       case CONNMAN_SERVICE_TYPE_BLUETOOTH:
+       case CONNMAN_SERVICE_TYPE_CELLULAR:
+       case CONNMAN_SERVICE_TYPE_GPS:
+       case CONNMAN_SERVICE_TYPE_VPN:
+       case CONNMAN_SERVICE_TYPE_GADGET:
+               break;
+       }
+
+       connman_info("Remove interface %s [ %s ]", name,
+                               __connman_service_type2string(type));
+
+       for (list = technology_list; list; list = list->next) {
+               struct connman_technology *technology = list->data;
+
+               if (technology->type != type)
+                       continue;
+
+               if (technology->driver == NULL)
+                       continue;
+
+               if (technology->driver->remove_interface)
+                       technology->driver->remove_interface(technology, index);
+
+               technology_put(technology);
+       }
+}
+
 static void unregister_technology(gpointer data)
 {
        struct connman_technology *technology = data;