return NULL;
}
+static int load_state(struct connman_technology *technology)
+{
+ GKeyFile *keyfile;
+ gchar *identifier;
+ GError *error = NULL;
+ connman_bool_t enable;
+
+ DBG("technology %p", technology);
+
+ keyfile = __connman_storage_open_profile("default");
+ if (keyfile == NULL)
+ return 0;
+
+ identifier = g_strdup_printf("%s", get_name(technology->type));
+ if (identifier == NULL)
+ goto done;
+
+ enable = g_key_file_get_boolean(keyfile, identifier, "Enable", &error);
+ if (error == NULL)
+ technology->enable_persistent = enable;
+ else
+ technology->enable_persistent = FALSE;
+
+ g_clear_error(&error);
+done:
+ g_free(identifier);
+
+ __connman_storage_close_profile("default", keyfile, FALSE);
+
+ return 0;
+}
+
+static int save_state(struct connman_technology *technology)
+{
+ GKeyFile *keyfile;
+ gchar *identifier;
+
+ DBG("technology %p", technology);
+
+ keyfile = __connman_storage_open_profile("default");
+ if (keyfile == NULL)
+ return 0;
+
+ 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_close_profile("default", keyfile, TRUE);
+
+ return 0;
+}
+
connman_bool_t __connman_technology_get_offlinemode(void)
{
return global_offlinemode;
technology->pending_reply = NULL;
technology->state = CONNMAN_TECHNOLOGY_STATE_OFFLINE;
- __connman_storage_load_technology(technology);
+ load_state(technology);
if (g_dbus_register_interface(connection, technology->path,
CONNMAN_TECHNOLOGY_INTERFACE,
* the state here.
*/
technology->enable_persistent = TRUE;
- __connman_storage_save_technology(technology);
+ save_state(technology);
}
__connman_rfkill_block(technology->type, FALSE);
if (msg != NULL) {
technology->pending_reply = dbus_message_ref(msg);
technology->enable_persistent = FALSE;
- __connman_storage_save_technology(technology);
+ save_state(technology);
}
__connman_rfkill_block(technology->type, TRUE);
return 0;
}
-static int technology_load(struct connman_technology *technology)
-{
- GKeyFile *keyfile;
- gchar *identifier;
- GError *error = NULL;
- connman_bool_t enable;
-
- DBG("technology %p", technology);
-
- keyfile = __connman_storage_open_profile("default");
- if (keyfile == NULL)
- return 0;
-
- identifier = g_strdup_printf("%s", get_name(technology->type));
- if (identifier == NULL)
- goto done;
-
- enable = g_key_file_get_boolean(keyfile, identifier, "Enable", &error);
- if (error == NULL)
- technology->enable_persistent = enable;
- else
- technology->enable_persistent = FALSE;
-
- g_clear_error(&error);
-done:
- g_free(identifier);
-
- __connman_storage_close_profile("default", keyfile, FALSE);
-
- return 0;
-}
-
-static int technology_save(struct connman_technology *technology)
-{
- GKeyFile *keyfile;
- gchar *identifier;
-
- DBG("technology %p", technology);
-
- keyfile = __connman_storage_open_profile("default");
- if (keyfile == NULL)
- return 0;
-
- 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_close_profile("default", keyfile, TRUE);
-
- return 0;
-}
-
-static struct connman_storage tech_storage = {
- .name = "technology",
- .priority = CONNMAN_STORAGE_PRIORITY_LOW,
- .tech_load = technology_load,
- .tech_save = technology_save,
-};
-
int __connman_technology_init(void)
{
DBG("");
global_offlinemode = connman_technology_load_offlinemode();
- return connman_storage_register(&tech_storage);
+ return 0;
}
void __connman_technology_cleanup(void)
DBG("");
dbus_connection_unref(connection);
-
- connman_storage_unregister(&tech_storage);
}