storage: Create settings file only when migrating
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Fri, 27 Apr 2012 13:01:50 +0000 (16:01 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 27 Apr 2012 13:14:16 +0000 (15:14 +0200)
The settings file is created only when migrating
from default.profile. This means that technology
default values are used if settings file does not
exists.

src/storage.c

index 75a1b0b..d01b77e 100644 (file)
@@ -400,32 +400,13 @@ void __connman_storage_migrate()
        if(pathname == NULL)
                return;
 
-       /* Copy global settings from default.profile to settings. */
-       keyfile = g_key_file_new();
-
-       /* If default.profile doesn't exists, create settings with defaults. */
+       /* If default.profile exists, create new settings file */
        keyfile_def = storage_load(pathname);
-       if (keyfile_def == NULL) {
-               g_key_file_set_boolean(keyfile, "global",
-                                       "OfflineMode", FALSE);
-
-               g_key_file_set_boolean(keyfile, "WiFi",
-                                       "Enable", FALSE);
-
-               g_key_file_set_boolean(keyfile, "Bluetooth",
-                                       "Enable", FALSE);
-
-               g_key_file_set_boolean(keyfile, "Wired",
-                                       "Enable", FALSE);
-
-               g_key_file_set_boolean(keyfile, "Cellular",
-                                       "Enable", FALSE);
-
-               g_key_file_set_boolean(keyfile, "WiMAX",
-                                       "Enable", FALSE);
-
+       if (keyfile_def == NULL)
                goto done;
-       }
+
+       /* Copy global settings from default.profile to settings. */
+       keyfile = g_key_file_new();
 
        val = g_key_file_get_boolean(keyfile_def, "global",
                                        "OfflineMode", &error);
@@ -487,13 +468,12 @@ void __connman_storage_migrate()
        g_key_file_set_boolean(keyfile, "WiMAX",
                                        "Enable", val);
 
-done:
        __connman_storage_save_global(keyfile);
 
        g_key_file_free(keyfile);
 
-       if (keyfile_def)
-               g_key_file_free(keyfile_def);
+       g_key_file_free(keyfile_def);
 
+done:
        g_free(pathname);
 }