device: Remove device persistent code
authorAlok Barsode <alok.barsode@linux.intel.com>
Wed, 24 Aug 2011 19:31:22 +0000 (21:31 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 25 Aug 2011 09:14:23 +0000 (11:14 +0200)
Connman now stores technology states persistently. Hence
there is no reason to store device states persistently.

include/storage.h
src/connman.h
src/device.c
src/storage.c
src/technology.c

index a612feb..cf5d359 100644 (file)
@@ -50,9 +50,6 @@ struct connman_storage {
        enum connman_service_type service_type;
        int (*service_load) (struct connman_service *service);
        int (*service_save) (struct connman_service *service);
-       enum connman_device_type device_type;
-       int (*device_load) (struct connman_device *device);
-       int (*device_save) (struct connman_device *device);
        int (*tech_load) (struct connman_technology *technology);
        int (*tech_save) (struct connman_technology *technology);
 };
index 699291b..be8d423 100644 (file)
@@ -167,8 +167,6 @@ int __connman_storage_load_profile(struct connman_profile *profile);
 int __connman_storage_save_profile(struct connman_profile *profile);
 int __connman_storage_load_service(struct connman_service *service);
 int __connman_storage_save_service(struct connman_service *service);
-int __connman_storage_load_device(struct connman_device *device);
-int __connman_storage_save_device(struct connman_device *device);
 int __connman_storage_load_technology(struct connman_technology *technology);
 int __connman_storage_save_technology(struct connman_technology *technology);
 
@@ -358,9 +356,7 @@ void __connman_device_set_network(struct connman_device *device,
 void __connman_device_cleanup_networks(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);
index 6ccd477..cdd9118 100644 (file)
@@ -44,7 +44,6 @@ struct connman_device {
        enum connman_pending_type powered_pending;      /* Indicates a pending
                                                        enable/disable request */
        connman_bool_t powered;
-       connman_bool_t powered_persistent;
        connman_bool_t scanning;
        connman_bool_t disconnected;
        connman_bool_t reconnect;
@@ -487,8 +486,6 @@ struct connman_device *connman_device_create(const char *node,
        device->type = type;
        device->name = g_strdup(type2description(device->type));
 
-       device->powered_persistent = TRUE;
-
        device->phyindex = -1;
 
        device->backoff_interval = SCAN_INITIAL_DELAY;
@@ -709,28 +706,6 @@ static int device_scan(struct connman_device *device)
        return device->driver->scan(device);
 }
 
-int __connman_device_enable_persistent(struct connman_device *device)
-{
-       DBG("device %p", device);
-
-       device->powered_persistent = TRUE;
-
-       __connman_storage_save_device(device);
-
-       return __connman_device_enable(device);
-}
-
-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;
@@ -1134,8 +1109,6 @@ static void device_remove(struct connman_device *device)
  */
 int connman_device_register(struct connman_device *device)
 {
-       __connman_storage_load_device(device);
-
        return device_probe(device);
 }
 
@@ -1147,8 +1120,6 @@ int connman_device_register(struct connman_device *device)
  */
 void connman_device_unregister(struct connman_device *device)
 {
-       __connman_storage_save_device(device);
-
        device_remove(device);
 }
 
@@ -1268,72 +1239,6 @@ nodevice:
        return FALSE;
 }
 
-static int device_load(struct connman_device *device)
-{
-       const char *ident = __connman_profile_active_ident();
-       GKeyFile *keyfile;
-       GError *error = NULL;
-       gchar *identifier;
-       connman_bool_t powered;
-
-       DBG("device %p", device);
-
-       keyfile = __connman_storage_open_profile(ident);
-       if (keyfile == NULL)
-               return 0;
-
-       identifier = g_strdup_printf("device_%s", device->name);
-       if (identifier == NULL)
-               goto done;
-
-       powered = g_key_file_get_boolean(keyfile, identifier,
-                                               "Powered", &error);
-       if (error == NULL)
-               device->powered_persistent = powered;
-       g_clear_error(&error);
-
-done:
-       g_free(identifier);
-
-       __connman_storage_close_profile(ident, keyfile, FALSE);
-
-       return 0;
-}
-
-static int device_save(struct connman_device *device)
-{
-       const char *ident = __connman_profile_active_ident();
-       GKeyFile *keyfile;
-       gchar *identifier;
-
-       DBG("device %p", device);
-
-       keyfile = __connman_storage_open_profile(ident);
-       if (keyfile == NULL)
-               return 0;
-
-       identifier = g_strdup_printf("device_%s", device->name);
-       if (identifier == NULL)
-               goto done;
-
-       g_key_file_set_boolean(keyfile, identifier,
-                                       "Powered", device->powered_persistent);
-
-done:
-       g_free(identifier);
-
-       __connman_storage_close_profile(ident, keyfile, TRUE);
-
-       return 0;
-}
-
-static struct connman_storage device_storage = {
-       .name           = "device",
-       .priority       = CONNMAN_STORAGE_PRIORITY_LOW,
-       .device_load    = device_load,
-       .device_save    = device_save,
-};
-
 int __connman_device_init(const char *device, const char *nodevice)
 {
        DBG("");
@@ -1344,7 +1249,7 @@ int __connman_device_init(const char *device, const char *nodevice)
        if (nodevice != NULL)
                nodevice_filter = g_strsplit(nodevice, ",", -1);
 
-       return connman_storage_register(&device_storage);
+       return 0;
 }
 
 void __connman_device_cleanup(void)
@@ -1353,6 +1258,4 @@ void __connman_device_cleanup(void)
 
        g_strfreev(nodevice_filter);
        g_strfreev(device_filter);
-
-       connman_storage_unregister(&device_storage);
 }
index 274997b..53ba237 100644 (file)
@@ -271,42 +271,6 @@ int __connman_storage_save_service(struct connman_service *service)
        return -ENOENT;
 }
 
-int __connman_storage_load_device(struct connman_device *device)
-{
-       GSList *list;
-
-       DBG("device %p", device);
-
-       for (list = storage_list; list; list = list->next) {
-               struct connman_storage *storage = list->data;
-
-               if (storage->device_load) {
-                       if (storage->device_load(device) == 0)
-                               return 0;
-               }
-       }
-
-       return -ENOENT;
-}
-
-int __connman_storage_save_device(struct connman_device *device)
-{
-       GSList *list;
-
-       DBG("device %p", device);
-
-       for (list = storage_list; list; list = list->next) {
-               struct connman_storage *storage = list->data;
-
-               if (storage->device_save) {
-                       if (storage->device_save(device) == 0)
-                               return 0;
-               }
-       }
-
-       return -ENOENT;
-}
-
 int __connman_storage_load_technology(struct connman_technology *technology)
 {
        GSList *list;
index b62ee31..e71bed5 100644 (file)
@@ -744,7 +744,7 @@ int __connman_technology_enable(enum connman_service_type type, DBusMessage *msg
        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.
                 * If atleast one device gets enabled, we consider
@@ -827,7 +827,7 @@ int __connman_technology_disable(enum connman_service_type type, DBusMessage *ms
        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)
                        ret = 0;
        }