technology: Add bridge name to the tethering hook
[platform/upstream/connman.git] / src / technology.c
index 0a58512..37d3974 100644 (file)
@@ -177,7 +177,7 @@ void __connman_technology_remove_interface(enum connman_service_type type,
        }
 }
 
-static int set_tethering(connman_bool_t enabled)
+static int set_tethering(const char *bridge, connman_bool_t enabled)
 {
        GSList *list;
 
@@ -188,20 +188,20 @@ static int set_tethering(connman_bool_t enabled)
                        continue;
 
                if (technology->driver->set_tethering)
-                       technology->driver->set_tethering(technology, enabled);
+                       technology->driver->set_tethering(technology, bridge, enabled);
        }
 
        return 0;
 }
 
-int __connman_technology_enable_tethering(void)
+int __connman_technology_enable_tethering(const char *bridge)
 {
-       return set_tethering(TRUE);
+       return set_tethering(bridge, TRUE);
 }
 
-int __connman_technology_disable_tethering(void)
+int __connman_technology_disable_tethering(const char *bridge)
 {
-       return set_tethering(FALSE);
+       return set_tethering(bridge, FALSE);
 }
 
 static void free_rfkill(gpointer data)
@@ -233,31 +233,6 @@ static void technologies_changed(void)
                        DBUS_TYPE_OBJECT_PATH, __connman_technology_list, NULL);
 }
 
-static void device_list(DBusMessageIter *iter, void *user_data)
-{
-       struct connman_technology *technology = user_data;
-       GSList *list;
-
-       for (list = technology->device_list; list; list = list->next) {
-               struct connman_device *device = list->data;
-               const char *path;
-
-               path = connman_device_get_path(device);
-               if (path == NULL)
-                       continue;
-
-               dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH,
-                                                                       &path);
-       }
-}
-
-static void devices_changed(struct connman_technology *technology)
-{
-       connman_dbus_property_changed_array(technology->path,
-                       CONNMAN_TECHNOLOGY_INTERFACE, "Devices",
-                       DBUS_TYPE_OBJECT_PATH, device_list, technology);
-}
-
 static const char *state2string(enum connman_technology_state state)
 {
        switch (state) {
@@ -345,9 +320,6 @@ static DBusMessage *get_properties(DBusConnection *conn,
                connman_dbus_dict_append_basic(&dict, "Type",
                                                DBUS_TYPE_STRING, &str);
 
-       connman_dbus_dict_append_array(&dict, "Devices",
-                       DBUS_TYPE_OBJECT_PATH, device_list, technology);
-
        connman_dbus_dict_close(&array, &dict);
 
        return reply;
@@ -509,7 +481,6 @@ done:
 
        technology->device_list = g_slist_append(technology->device_list,
                                                                device);
-       devices_changed(technology);
 
        return 0;
 }
@@ -530,8 +501,6 @@ int __connman_technology_remove_device(struct connman_device *device)
 
        technology->device_list = g_slist_remove(technology->device_list,
                                                                device);
-       devices_changed(technology);
-
        if (technology->device_list == NULL) {
                technology->state = CONNMAN_TECHNOLOGY_STATE_OFFLINE;
                state_changed(technology);
@@ -661,7 +630,7 @@ int __connman_technology_update_rfkill(unsigned int index,
 {
        struct connman_technology *technology;
        struct connman_rfkill *rfkill;
-       connman_bool_t blocked;
+       connman_bool_t blocked, old_blocked;
 
        DBG("index %u soft %u hard %u", index, softblock, hardblock);
 
@@ -673,10 +642,14 @@ int __connman_technology_update_rfkill(unsigned int index,
        if (rfkill == NULL)
                return -ENXIO;
 
+       old_blocked = (rfkill->softblock || rfkill->hardblock) ? TRUE : FALSE;
+       blocked = (softblock || hardblock) ? TRUE : FALSE;
+
        rfkill->softblock = softblock;
        rfkill->hardblock = hardblock;
 
-       blocked = (softblock || hardblock) ? TRUE : FALSE;
+       if (blocked == old_blocked)
+               return 0;
 
        if (blocked) {
                guint n_blocked;
@@ -724,6 +697,20 @@ int __connman_technology_remove_rfkill(unsigned int index)
        return 0;
 }
 
+connman_bool_t __connman_technology_get_blocked(enum connman_service_type type)
+{
+       struct connman_technology *technology;
+
+       technology = technology_get(type);
+       if (technology == NULL)
+               return FALSE;
+
+       if (g_atomic_int_get(&technology->blocked))
+               return TRUE;
+
+       return FALSE;
+}
+
 int __connman_technology_init(void)
 {
        DBG("");