From: Jukka Rissanen Date: Fri, 27 Apr 2012 13:01:51 +0000 (+0300) Subject: technology: Save technology state if entry is missing from file X-Git-Tag: 2.0_alpha~326 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99a186e4bf048e4095cd4bc75f0c7a89d98c0ac3;p=framework%2Fconnectivity%2Fconnman.git technology: Save technology state if entry is missing from file So we save the technology status if the settings file does not contain it. --- diff --git a/src/technology.c b/src/technology.c index 26a4cc9..9892e2b 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;