connman_dbus_dict_open(&array, &dict);
- str = __connman_profile_active_path();
- if (str != NULL)
- connman_dbus_dict_append_basic(&dict, "ActiveProfile",
- DBUS_TYPE_OBJECT_PATH, &str);
-
connman_dbus_dict_append_array(&dict, "Services",
DBUS_TYPE_OBJECT_PATH, __connman_service_list, NULL);
connman_dbus_dict_append_array(&dict, "Technologies",
connman_dbus_dict_append_basic(&dict, "State",
DBUS_TYPE_STRING, &str);
- offlinemode = __connman_profile_get_offlinemode();
+ offlinemode = __connman_technology_get_offlinemode();
connman_dbus_dict_append_basic(&dict, "OfflineMode",
DBUS_TYPE_BOOLEAN, &offlinemode);
dbus_message_iter_get_basic(&value, &offlinemode);
__connman_technology_set_offlinemode(offlinemode);
- } else if (g_str_equal(name, "ActiveProfile") == TRUE) {
- const char *str;
-
- dbus_message_iter_get_basic(&value, &str);
-
- return __connman_error_not_supported(msg);
} else if (g_str_equal(name, "SessionMode") == TRUE) {
connman_bool_t sessionmode;
static GSList *technology_list = NULL;
+static connman_bool_t global_offlinemode;
+
struct connman_rfkill {
unsigned int index;
enum connman_service_type type;
return NULL;
}
+connman_bool_t __connman_technology_get_offlinemode(void)
+{
+ return global_offlinemode;
+}
+
+static int connman_technology_save_offlinemode()
+{
+ GKeyFile *keyfile;
+
+ keyfile = __connman_storage_open_profile("default");
+ if (keyfile == NULL)
+ return -EIO;
+
+ g_key_file_set_boolean(keyfile, "global",
+ "OfflineMode", global_offlinemode);
+
+ __connman_storage_close_profile("default", keyfile, TRUE);
+
+ return 0;
+}
+
+static connman_bool_t connman_technology_load_offlinemode()
+{
+ GKeyFile *keyfile;
+ GError *error = NULL;
+ connman_bool_t offlinemode;
+
+ /* If there is a error, we enable offlinemode */
+ keyfile = __connman_storage_open_profile("default");
+ if (keyfile == NULL)
+ return TRUE;
+
+ offlinemode = g_key_file_get_boolean(keyfile, "global",
+ "OfflineMode", &error);
+ if (error != NULL) {
+ offlinemode = TRUE;
+ g_clear_error(&error);
+ }
+ __connman_storage_close_profile("default", keyfile, FALSE);
+
+ return offlinemode;
+}
+
static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *message, void *user_data)
{
{
struct connman_technology *technology;
enum connman_service_type type;
- connman_bool_t offlinemode = __connman_profile_get_offlinemode();
DBG("device %p", device);
if (technology == NULL)
return -ENXIO;
- if (technology->enable_persistent && !offlinemode)
+ if (technology->enable_persistent && !global_offlinemode)
__connman_device_enable(device);
/* if technology persistent state is offline */
if (!technology->enable_persistent)
GSList *list;
int err = -EINVAL;
+ if (global_offlinemode == offlinemode)
+ return 0;
+
DBG("offlinemode %s", offlinemode ? "On" : "Off");
+
/*
* This is a bit tricky. When you set offlinemode, there is no
* way to differentiate between attempting offline mode and
* technology's persistent state. Hence we set the offline mode here
* but save it & call the notifier only if its successful.
*/
- __connman_profile_set_offlinemode(offlinemode);
+
+ global_offlinemode = offlinemode;
/* Traverse technology list, enable/disable each technology. */
for (list = technology_list; list; list = list->next) {
}
if (err == 0 || err == -EINPROGRESS || err == -EALREADY) {
- __connman_profile_save_default();
+ connman_technology_save_offlinemode();
__connman_notifier_offlinemode(offlinemode);
- }
+ } else
+ global_offlinemode = connman_technology_load_offlinemode();
return err;
}
{
struct connman_technology *technology;
struct connman_rfkill *rfkill;
- connman_bool_t offlinemode = __connman_profile_get_offlinemode();
DBG("index %u type %d soft %u hard %u", index, type,
softblock, hardblock);
* If Offline mode is on, we softblock the device if it isnt already.
* If Offline mode is off, we rely on the persistent state of tech.
*/
- if (offlinemode) {
+ if (global_offlinemode) {
if (!softblock)
return __connman_rfkill_block(type, TRUE);
} else {
{
struct connman_technology *technology;
struct connman_rfkill *rfkill;
- connman_bool_t offlinemode = __connman_profile_get_offlinemode();
DBG("index %u soft %u hard %u", index, softblock, hardblock);
return 0;
}
- if (!offlinemode) {
+ if (!global_offlinemode) {
if (technology->enable_persistent && softblock)
return __connman_rfkill_block(type, FALSE);
if (!technology->enable_persistent && !softblock)
static int technology_load(struct connman_technology *technology)
{
- const char *ident = __connman_profile_active_ident();
GKeyFile *keyfile;
gchar *identifier;
GError *error = NULL;
DBG("technology %p", technology);
- keyfile = __connman_storage_open_profile(ident);
+ keyfile = __connman_storage_open_profile("default");
if (keyfile == NULL)
return 0;
done:
g_free(identifier);
- __connman_storage_close_profile(ident, keyfile, FALSE);
+ __connman_storage_close_profile("default", keyfile, FALSE);
return 0;
}
static int technology_save(struct connman_technology *technology)
{
- const char *ident = __connman_profile_active_ident();
GKeyFile *keyfile;
gchar *identifier;
DBG("technology %p", technology);
- keyfile = __connman_storage_open_profile(ident);
+ keyfile = __connman_storage_open_profile("default");
if (keyfile == NULL)
return 0;
done:
g_free(identifier);
- __connman_storage_close_profile(ident, keyfile, TRUE);
+ __connman_storage_close_profile("default", keyfile, TRUE);
return 0;
}
connection = connman_dbus_get_connection();
+ global_offlinemode = connman_technology_load_offlinemode();
+
return connman_storage_register(&tech_storage);
}