summaryrefslogtreecommitdiff
path: root/src/technology.c
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-04-27 16:01:51 +0300
committerMarcel Holtmann <marcel@holtmann.org>2012-04-27 15:14:16 +0200
commit99a186e4bf048e4095cd4bc75f0c7a89d98c0ac3 (patch)
treebbe2b0545803975bb2098892d6bec20c62100929 /src/technology.c
parent9448c0e72f8d3187ae7dcedcad35313acbe95f09 (diff)
downloadconnman-99a186e4bf048e4095cd4bc75f0c7a89d98c0ac3.tar.gz
connman-99a186e4bf048e4095cd4bc75f0c7a89d98c0ac3.tar.bz2
connman-99a186e4bf048e4095cd4bc75f0c7a89d98c0ac3.zip
technology: Save technology state if entry is missing from file
So we save the technology status if the settings file does not contain it.
Diffstat (limited to 'src/technology.c')
-rw-r--r--src/technology.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/src/technology.c b/src/technology.c
index 26a4cc92..9892e2b7 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -292,6 +292,34 @@ static const char *get_name(enum connman_service_type type)
return NULL;
}
+static void save_state(struct connman_technology *technology)
+{
+ GKeyFile *keyfile;
+ gchar *identifier;
+
+ DBG("technology %p", technology);
+
+ keyfile = __connman_storage_load_global();
+ if (keyfile == NULL)
+ keyfile = g_key_file_new();
+
+ identifier = g_strdup_printf("%s", get_name(technology->type));
+ if (identifier == NULL)
+ goto done;
+
+ g_key_file_set_boolean(keyfile, identifier, "Enable",
+ technology->enable_persistent);
+
+done:
+ g_free(identifier);
+
+ __connman_storage_save_global(keyfile);
+
+ g_key_file_free(keyfile);
+
+ return;
+}
+
static void load_state(struct connman_technology *technology)
{
GKeyFile *keyfile;
@@ -324,6 +352,8 @@ static void load_state(struct connman_technology *technology)
technology->enable_persistent = TRUE;
else
technology->enable_persistent = FALSE;
+
+ save_state(technology);
g_clear_error(&error);
}
done:
@@ -334,34 +364,6 @@ done:
return;
}
-static void save_state(struct connman_technology *technology)
-{
- GKeyFile *keyfile;
- gchar *identifier;
-
- DBG("technology %p", technology);
-
- keyfile = __connman_storage_load_global();
- if (keyfile == NULL)
- keyfile = g_key_file_new();
-
- identifier = g_strdup_printf("%s", get_name(technology->type));
- if (identifier == NULL)
- goto done;
-
- g_key_file_set_boolean(keyfile, identifier, "Enable",
- technology->enable_persistent);
-
-done:
- g_free(identifier);
-
- __connman_storage_save_global(keyfile);
-
- g_key_file_free(keyfile);
-
- return;
-}
-
connman_bool_t __connman_technology_get_offlinemode(void)
{
return global_offlinemode;