From: Alok Barsode <[email protected]>

Merge __connman_device_[enable/disable]_persistent and
__connman_device_[enable/disable].
---
 src/connman.h    |    4 ++--
 src/device.c     |   40 ++++++----------------------------------
 src/technology.c |    9 +++++++--
 3 files changed, 15 insertions(+), 38 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 17ca39f..a5d435a 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -356,10 +356,10 @@ void __connman_device_set_network(struct connman_device 
*device,
 void __connman_device_cleanup_networks(struct connman_device *device);
 
 int __connman_device_scan(struct connman_device *device);
+
 int __connman_device_enable(struct connman_device *device);
-int __connman_device_enable_persistent(struct connman_device *device);
 int __connman_device_disable(struct connman_device *device);
-int __connman_device_disable_persistent(struct connman_device *device);
+
 int __connman_device_disconnect(struct connman_device *device);
 
 connman_bool_t __connman_device_scanning(struct connman_device *device);
diff --git a/src/device.c b/src/device.c
index a51f7a4..5e537e7 100644
--- a/src/device.c
+++ b/src/device.c
@@ -228,6 +228,9 @@ int __connman_device_enable(struct connman_device *device)
        connman_device_set_disconnected(device, FALSE);
        device->scanning = FALSE;
 
+       device->powered_persistent = TRUE;
+       __connman_storage_save_device(device);
+
        err = device->driver->enable(device);
        if (err < 0 && err != -EALREADY) {
                if (err == -EINPROGRESS) {
@@ -273,6 +276,9 @@ int __connman_device_disable(struct connman_device *device)
 
        g_hash_table_remove_all(device->networks);
 
+       device->powered_persistent = FALSE;
+       __connman_storage_save_device(device);
+
        err = device->driver->disable(device);
        if (err < 0 && err != -EALREADY) {
                if (err == -EINPROGRESS)
@@ -739,40 +745,6 @@ int __connman_device_scan(struct connman_device *device)
        return device->driver->scan(device);
 }
 
-int __connman_device_enable_persistent(struct connman_device *device)
-{
-       int err;
-
-       DBG("device %p", device);
-
-       device->powered_persistent = TRUE;
-
-       __connman_storage_save_device(device);
-
-       err = __connman_device_enable(device);
-       if (err == 0 || err == -EINPROGRESS) {
-               device->offlinemode = FALSE;
-               if (__connman_profile_get_offlinemode() == TRUE) {
-                       __connman_profile_set_offlinemode(FALSE, FALSE);
-
-                       __connman_profile_save_default();
-               }
-       }
-
-       return err;
-}
-
-int __connman_device_disable_persistent(struct connman_device *device)
-{
-       DBG("device %p", device);
-
-       device->powered_persistent = FALSE;
-
-       __connman_storage_save_device(device);
-
-       return __connman_device_disable(device);
-}
-
 int __connman_device_disconnect(struct connman_device *device)
 {
        GHashTableIter iter;
diff --git a/src/technology.c b/src/technology.c
index cb065e2..b258293 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -693,6 +693,11 @@ int __connman_technology_enabled(enum connman_service_type 
type)
                state_changed(technology);
        }
 
+       if (__connman_profile_get_offlinemode() == TRUE) {
+               __connman_profile_set_offlinemode(FALSE, FALSE);
+               __connman_profile_save_default();
+       }
+
        return 0;
 }
 
@@ -712,7 +717,7 @@ int __connman_technology_enable(enum connman_service_type 
type)
        for (list = technology->device_list; list; list = list->next) {
                struct connman_device *device = list->data;
 
-               err = __connman_device_enable_persistent(device);
+               err = __connman_device_enable(device);
                /*
                 * err = 0 : Device was enabled right away.
                 * err = -EINPROGRESS : DBus call was successful.
@@ -771,7 +776,7 @@ int __connman_technology_disable(enum connman_service_type 
type)
        for (list = technology->device_list; list; list = list->next) {
                struct connman_device *device = list->data;
 
-               err = __connman_device_disable_persistent(device);
+               err = __connman_device_disable(device);
                if (err == 0 || err == -EINPROGRESS)
                        ret = 0;
        }
-- 
1.7.1

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to