diff options
author | Alok Barsode <alok.barsode@linux.intel.com> | 2011-08-24 16:44:07 +0300 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-08-25 11:14:20 +0200 |
commit | 16a3c81f6e336ebc5aed1e1462002833aaebc4fa (patch) | |
tree | 1ffd4137722e05dd1f9c105dd451181d1886b080 /src/technology.c | |
parent | ef9c42ac21606bed83eb51c91f110a3aa228690d (diff) | |
download | connman-16a3c81f6e336ebc5aed1e1462002833aaebc4fa.tar.gz connman-16a3c81f6e336ebc5aed1e1462002833aaebc4fa.tar.bz2 connman-16a3c81f6e336ebc5aed1e1462002833aaebc4fa.zip |
technology: Refactor enable/disable APIs
connman_technology_enable: Enable a technology. Enables all the
devices in the device_list of the technology.
connman_technology_enabled: Callback for connman_technology_enable.
Changes the state of the technology to ENABLED.
Ditto for connman_technology_disable/connman_technology_disabled.
Diffstat (limited to 'src/technology.c')
-rw-r--r-- | src/technology.c | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/src/technology.c b/src/technology.c index c68a649a..cb065e2b 100644 --- a/src/technology.c +++ b/src/technology.c @@ -675,7 +675,7 @@ int __connman_technology_remove_device(struct connman_device *device) return 0; } -int __connman_technology_enable(enum connman_service_type type) +int __connman_technology_enabled(enum connman_service_type type) { struct connman_technology *technology; @@ -696,7 +696,37 @@ int __connman_technology_enable(enum connman_service_type type) return 0; } -int __connman_technology_disable(enum connman_service_type type) +int __connman_technology_enable(enum connman_service_type type) +{ + struct connman_technology *technology; + GSList *list; + int err; + int ret = -ENODEV; + + DBG("type %d enable", type); + + technology = technology_find(type); + if (technology == NULL) + return -ENXIO; + + for (list = technology->device_list; list; list = list->next) { + struct connman_device *device = list->data; + + err = __connman_device_enable_persistent(device); + /* + * err = 0 : Device was enabled right away. + * err = -EINPROGRESS : DBus call was successful. + * If atleast one device gets enabled, we consider + * the technology to be enabled. + */ + if (err == 0 || err == -EINPROGRESS) + ret = 0; + } + + return ret; +} + +int __connman_technology_disabled(enum connman_service_type type) { struct connman_technology *technology; GSList *list; @@ -725,6 +755,30 @@ int __connman_technology_disable(enum connman_service_type type) return 0; } +int __connman_technology_disable(enum connman_service_type type) +{ + struct connman_technology *technology; + GSList *list; + int err; + int ret = -ENODEV; + + DBG("type %d disable", type); + + technology = technology_find(type); + if (technology == NULL) + return -ENXIO; + + for (list = technology->device_list; list; list = list->next) { + struct connman_device *device = list->data; + + err = __connman_device_disable_persistent(device); + if (err == 0 || err == -EINPROGRESS) + ret = 0; + } + + return ret; +} + static void technology_blocked(struct connman_technology *technology, connman_bool_t blocked) { |