diff options
Diffstat (limited to 'src/technology.c')
-rwxr-xr-x[-rw-r--r--] | src/technology.c | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/src/technology.c b/src/technology.c index 15bb395d..9e00a293 100644..100755 --- a/src/technology.c +++ b/src/technology.c @@ -85,6 +85,9 @@ struct connman_technology { static GSList *driver_list = NULL; +static int technology_enabled(struct connman_technology *technology); +static int technology_disabled(struct connman_technology *technology); + static gint compare_priority(gconstpointer a, gconstpointer b) { const struct connman_technology_driver *driver1 = a; @@ -625,19 +628,27 @@ static gboolean technology_pending_reply(gpointer user_data) static int technology_affect_devices(struct connman_technology *technology, bool enable_device) { + int err = 0, err_dev; GSList *list; - int err = -ENXIO; - if (technology->type == CONNMAN_SERVICE_TYPE_P2P) + if (technology->type == CONNMAN_SERVICE_TYPE_P2P) { + if (enable_device) + __connman_technology_enabled(technology->type); + else + __connman_technology_disabled(technology->type); return 0; + } for (list = technology->device_list; list; list = list->next) { struct connman_device *device = list->data; if (enable_device) - err = __connman_device_enable(device); + err_dev = __connman_device_enable(device); else - err = __connman_device_disable(device); + err_dev = __connman_device_disable(device); + + if (err_dev < 0 && err_dev != -EALREADY) + err = err_dev; } return err; @@ -1252,13 +1263,6 @@ static struct connman_technology *technology_get(enum connman_service_type type) technology->tethering_hidden = FALSE; technology->path = g_strdup_printf("%s/technology/%s", CONNMAN_PATH, str); - if (type == CONNMAN_SERVICE_TYPE_P2P) { - struct connman_technology *wifi; - - wifi = technology_find(CONNMAN_SERVICE_TYPE_WIFI); - if (wifi) - technology->enabled = wifi->enabled; - } technology_load(technology); technology_list = g_slist_prepend(technology_list, technology); @@ -1277,7 +1281,20 @@ static struct connman_technology *technology_get(enum connman_service_type type) return NULL; } - DBG("technology %p", technology); + if (type == CONNMAN_SERVICE_TYPE_P2P) { + struct connman_technology *wifi; + bool enable; + + enable = technology->enable_persistent; + + wifi = technology_find(CONNMAN_SERVICE_TYPE_WIFI); + if (enable && wifi) + enable = wifi->enabled; + + technology_affect_devices(technology, enable); + } + + DBG("technology %p %s", technology, get_name(technology->type)); return technology; } @@ -1865,6 +1882,12 @@ void __connman_technology_cleanup(void) { DBG(""); + while (technology_list) { + struct connman_technology *technology = technology_list->data; + technology_list = g_slist_remove(technology_list, technology); + technology_put(technology); + } + g_hash_table_destroy(rfkill_list); dbus_connection_unref(connection); |