storage: Remove storage migration code
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 4 Jan 2013 11:12:53 +0000 (13:12 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 4 Jan 2013 11:29:34 +0000 (13:29 +0200)
src/connman.h
src/main.c
src/storage.c

index 70178d8..95e5c8a 100644 (file)
@@ -200,7 +200,6 @@ int __connman_resolvfile_append(int index, const char *domain, const char *serve
 int __connman_resolvfile_remove(int index, const char *domain, const char *server);
 int __connman_resolver_redo_servers(int index);
 
-void __connman_storage_migrate(void);
 GKeyFile *__connman_storage_open_global(void);
 GKeyFile *__connman_storage_load_global(void);
 int __connman_storage_save_global(GKeyFile *keyfile);
index 350d43b..e21d056 100644 (file)
@@ -622,7 +622,6 @@ int main(int argc, char *argv[])
        else
                config_init(option_config);
 
-       __connman_storage_migrate();
        __connman_inotify_init();
        __connman_technology_init();
        __connman_notifier_init();
index 3c99795..47822da 100644 (file)
@@ -460,178 +460,3 @@ gchar **__connman_storage_get_providers(void)
 
        return providers;
 }
-
-/*
- * This function migrates keys from default.profile to settings file.
- * This can be removed once the migration is over.
-*/
-void __connman_storage_migrate(void)
-{
-       gchar *pathname;
-       GKeyFile *keyfile_def = NULL;
-       GKeyFile *keyfile = NULL;
-       GError *error = NULL;
-       connman_bool_t delete_old_config = TRUE;
-       char **services, **keys, *value;
-       int i, k, err;
-       connman_bool_t val;
-
-       pathname = g_strdup_printf("%s/%s", STORAGEDIR, DEFAULT);
-       if (pathname == NULL)
-               return;
-
-       /* If setting file exists, migration has been done. */
-       keyfile = __connman_storage_load_global();
-       if (keyfile) {
-               g_key_file_free(keyfile);
-               unlink(pathname);
-               g_free(pathname);
-               return;
-       }
-
-       /* If default.profile exists, create new settings file */
-       keyfile_def = storage_load(pathname);
-       if (keyfile_def == NULL)
-               goto done;
-
-       services = g_key_file_get_groups(keyfile_def, NULL);
-       for (i = 0; services != NULL && services[i] != NULL; i++) {
-               if (strncmp(services[i], "wifi_", 5) != 0 &&
-                               strncmp(services[i], "ethernet_", 9) != 0 &&
-                               strncmp(services[i], "cellular_", 9) != 0 &&
-                               strncmp(services[i], "bluetooth_", 10) != 0 &&
-                               strncmp(services[i], "vpn_", 4) != 0)
-                       continue;
-
-               keyfile = connman_storage_load_service(services[i]);
-               if (keyfile != NULL) {
-                       g_key_file_free(keyfile);
-                       DBG("already exists %s", services[i]);
-                       continue;
-               }
-
-               keyfile = g_key_file_new();
-               if (keyfile == NULL) {
-                       connman_warn("Migrating %s failed", services[i]);
-                       delete_old_config = FALSE;
-                       continue;
-               }
-
-               keys = g_key_file_get_keys(keyfile_def, services[i],
-                               NULL, NULL);
-
-               for (k = 0; keys != NULL && keys[k] != NULL; k++) {
-                       value = g_key_file_get_value(keyfile_def, services[i],
-                                       keys[k], NULL);
-                       g_key_file_set_value(keyfile, services[i],
-                                       keys[k], value);
-                       g_free(value);
-               }
-
-               if (keys != NULL && keys[0] != NULL) {
-                       err = __connman_storage_save_service(keyfile,
-                                       services[i]);
-                       if (err >= 0)
-                               DBG("migrated %s", services[i]);
-                       else {
-                               connman_warn("Migrating %s failed %s",
-                                               services[i], strerror(-err));
-                               delete_old_config = FALSE;
-                       }
-               } else
-                       DBG("no keys in %s", services[i]);
-
-               g_strfreev(keys);
-               g_key_file_free(keyfile);
-       }
-       g_strfreev(services);
-
-       /* Copy global settings from default.profile to settings. */
-       keyfile = g_key_file_new();
-
-       val = g_key_file_get_boolean(keyfile_def, "global",
-                                       "OfflineMode", &error);
-       if (error != NULL) {
-               g_clear_error(&error);
-               val = FALSE;
-       }
-
-       g_key_file_set_boolean(keyfile, "global",
-                                       "OfflineMode", val);
-
-       /* Migrate Powered/Enable state key/value pairs from legacy
-        * settings
-        */
-
-       val = g_key_file_get_boolean(keyfile_def, "WiFi",
-                                       "Enable", &error);
-       if (error != NULL) {
-               g_clear_error(&error);
-               val = g_key_file_get_boolean(keyfile_def, "device_Wireless", "Powered", &error);
-               if (error != NULL) {
-                       g_clear_error(&error);
-                       val = FALSE;
-               }
-       }
-
-       g_key_file_set_boolean(keyfile, "WiFi",
-                                       "Enable", val);
-
-       val = g_key_file_get_boolean(keyfile_def, "Bluetooth",
-                                       "Enable", &error);
-       if (error != NULL) {
-               g_clear_error(&error);
-               val = g_key_file_get_boolean(keyfile_def, "device_Bluetooth", "Powered", &error);
-               if (error != NULL) {
-                       g_clear_error(&error);
-                       val = FALSE;
-               }
-       }
-
-       g_key_file_set_boolean(keyfile, "Bluetooth",
-                                       "Enable", val);
-
-       val = g_key_file_get_boolean(keyfile_def, "Wired",
-                                       "Enable", &error);
-       if (error != NULL) {
-               g_clear_error(&error);
-               val = g_key_file_get_boolean(keyfile_def, "device_Ethernet", "Powered", &error);
-               if (error != NULL) {
-                       g_clear_error(&error);
-                       val = FALSE;
-               }
-       }
-
-       g_key_file_set_boolean(keyfile, "Wired",
-                                       "Enable", val);
-
-       val = g_key_file_get_boolean(keyfile_def, "Cellular",
-                                       "Enable", &error);
-       if (error != NULL) {
-               g_clear_error(&error);
-               val = g_key_file_get_boolean(keyfile_def, "device_Cellular", "Powered", &error);
-               if (error != NULL) {
-                       g_clear_error(&error);
-                       val = FALSE;
-               }
-       }
-
-       g_key_file_set_boolean(keyfile, "Cellular",
-                                       "Enable", val);
-
-       if (__connman_storage_save_global(keyfile) < 0) {
-               connman_warn("Migrating global config failed");
-               delete_old_config = FALSE;
-       }
-
-       g_key_file_free(keyfile);
-
-       g_key_file_free(keyfile_def);
-
-       if (delete_old_config == TRUE) {
-               DBG("migration done for %s", pathname);
-               unlink(pathname);
-       }
-done:
-       g_free(pathname);
-}