diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2010-01-26 08:30:31 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-01-26 08:30:31 +0100 |
commit | f54325fafc4b085ae2924ed141b1e8d519b52034 (patch) | |
tree | 79842a77493dafce01e092ce4a2a146dacff72ee /src/technology.c | |
parent | 03cd2c324472088e5dbd2d7e7998cefabe15335a (diff) | |
download | connman-f54325fafc4b085ae2924ed141b1e8d519b52034.tar.gz connman-f54325fafc4b085ae2924ed141b1e8d519b52034.tar.bz2 connman-f54325fafc4b085ae2924ed141b1e8d519b52034.zip |
Handle enabled/disabled cases for technology interface
Diffstat (limited to 'src/technology.c')
-rw-r--r-- | src/technology.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/technology.c b/src/technology.c index fcfd9d8f..8b06a77e 100644 --- a/src/technology.c +++ b/src/technology.c @@ -53,6 +53,7 @@ struct connman_technology { char *path; GHashTable *rfkill_list; GSList *device_list; + gint enabled; }; static void free_rfkill(gpointer data) @@ -316,6 +317,7 @@ int __connman_technology_add_device(struct connman_device *device) DBG("device %p", device); type = __connman_device_get_service_type(device); + __connman_notifier_register(type); technology = technology_get(type); if (technology == NULL) @@ -338,9 +340,13 @@ int __connman_technology_add_device(struct connman_device *device) int __connman_technology_remove_device(struct connman_device *device) { struct connman_technology *technology; + enum connman_service_type type; DBG("device %p", device); + type = __connman_device_get_service_type(device); + __connman_notifier_unregister(type); + technology = g_hash_table_lookup(device_table, device); if (technology == NULL) return -ENXIO; @@ -359,6 +365,50 @@ int __connman_technology_remove_device(struct connman_device *device) return 0; } +int __connman_technology_enable_device(struct connman_device *device) +{ + struct connman_technology *technology; + enum connman_service_type type; + + DBG("device %p", device); + + type = __connman_device_get_service_type(device); + __connman_notifier_enable(type); + + technology = g_hash_table_lookup(device_table, device); + if (technology == NULL) + return -ENXIO; + + if (g_atomic_int_exchange_and_add(&technology->enabled, 1) == 0) { + technology->state = CONNMAN_TECHNOLOGY_STATE_ENABLED; + state_changed(technology); + } + + return 0; +} + +int __connman_technology_disable_device(struct connman_device *device) +{ + struct connman_technology *technology; + enum connman_service_type type; + + DBG("device %p", device); + + type = __connman_device_get_service_type(device); + __connman_notifier_disable(type); + + technology = g_hash_table_lookup(device_table, device); + if (technology == NULL) + return -ENXIO; + + if (g_atomic_int_dec_and_test(&technology->enabled) == TRUE) { + technology->state = CONNMAN_TECHNOLOGY_STATE_AVAILABLE; + state_changed(technology); + } + + return 0; +} + int __connman_technology_add_rfkill(unsigned int index, enum connman_service_type type, connman_bool_t softblock, |