Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: src/device.c

Issue 6659006: flimflam: add support for multiple profiles (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/flimflam.git@master
Patch Set: more ers comments Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/crypto.c ('k') | src/ipconfig.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/device.c
diff --git a/src/device.c b/src/device.c
index 2109f9b25845227d1324515c12ec4c61e7f8c94a..e1f16b954e8ed885a4f6d49aad22252a3a210814 100644
--- a/src/device.c
+++ b/src/device.c
@@ -254,7 +254,7 @@ struct connman_ipconfig *connman_device_add_ipconfig(
connman_ipconfig_register(ipconfig, &device->element);
device->configmask |= 1<<(ix-1);
- __connman_storage_save_device(device);
+ __connman_profile_save_device(device);
return ipconfig;
}
@@ -636,7 +636,7 @@ static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg,
device->powered_persistent = powered;
- __connman_storage_save_device(device);
+ __connman_profile_save_device(device);
if (device->powered == powered)
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
@@ -666,7 +666,7 @@ static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg,
if (device->scan_interval != interval) {
device->scan_interval = interval;
device->scan_parameters_nondefault = TRUE;
- __connman_storage_save_device(device);
+ __connman_profile_save_device(device);
connman_element_update(&device->element);
if (device->scan_timeout != 0)
@@ -683,7 +683,7 @@ static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg,
g_free(device->scan_method);
device->scan_method = g_strdup(method);
device->scan_parameters_nondefault = TRUE;
- __connman_storage_save_device(device);
+ __connman_profile_save_device(device);
connman_element_update(&device->element);
}
} else if (g_str_equal(name, "BgscanShortInterval") == TRUE) {
@@ -696,7 +696,7 @@ static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg,
if (device->scan_short != interval) {
device->scan_short = interval;
device->scan_parameters_nondefault = TRUE;
- __connman_storage_save_device(device);
+ __connman_profile_save_device(device);
connman_element_update(&device->element);
}
} else if (g_str_equal(name, "BgscanSignalThreshold") == TRUE) {
@@ -709,7 +709,7 @@ static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg,
if (device->signal_threshold != threshold) {
device->signal_threshold = threshold;
device->scan_parameters_nondefault = TRUE;
- __connman_storage_save_device(device);
+ __connman_profile_save_device(device);
connman_element_update(&device->element);
}
} else
@@ -1536,7 +1536,7 @@ int __connman_device_enable_persistent(struct connman_device *device)
device->powered_persistent = TRUE;
- __connman_storage_save_device(device);
+ __connman_profile_save_device(device);
return __connman_device_enable(device);
}
@@ -1559,7 +1559,7 @@ int __connman_device_disable_persistent(struct connman_device *device)
device->powered_persistent = FALSE;
- __connman_storage_save_device(device);
+ __connman_profile_save_device(device);
return __connman_device_disable(device);
}
@@ -2068,7 +2068,7 @@ int connman_device_register(struct connman_device *device)
{
_DBG_DEVICE("device %p", device);
- __connman_storage_load_device(device);
+ __connman_profile_load_device(device);
device->offlinemode = __connman_profile_get_offlinemode();
@@ -2085,7 +2085,7 @@ void connman_device_unregister(struct connman_device *device)
{
_DBG_DEVICE("device %p", device);
- __connman_storage_save_device(device);
+ __connman_profile_save_device(device);
connman_element_unregister(&device->element);
}
@@ -2216,10 +2216,8 @@ static connman_bool_t device_load_ipconfigs(struct connman_device *device,
return TRUE;
}
-static int device_load(struct connman_device *device)
+static int device_load(struct connman_device *device, GKeyFile *keyfile)
{
- const char *ident = __connman_profile_active_ident();
- GKeyFile *keyfile;
GError *error = NULL;
gchar *identifier;
gchar *method;
@@ -2227,16 +2225,20 @@ static int device_load(struct connman_device *device)
int val;
gchar **configs;
gsize nconfigs;
+ int err = 0;
_DBG_DEVICE("device %p", device);
- keyfile = __connman_storage_open(ident);
- if (keyfile == NULL)
- return 0;
-
identifier = g_strdup_printf("device_%s", device->element.name);
- if (identifier == NULL)
+ if (identifier == NULL) {
+ err = -ENOMEM;
goto done;
+ }
+
+ if (g_key_file_has_group(keyfile, identifier) == FALSE) {
+ err = -ESRCH;
+ goto done;
+ }
powered = g_key_file_get_boolean(keyfile, identifier,
"Powered", &error);
@@ -2291,15 +2293,11 @@ static int device_load(struct connman_device *device)
done:
g_free(identifier);
- __connman_storage_close(ident, keyfile, FALSE);
-
- return 0;
+ return err;
}
-static int device_save(struct connman_device *device)
+static int device_save(struct connman_device *device, GKeyFile *keyfile)
{
- const char *ident = __connman_profile_active_ident();
- GKeyFile *keyfile;
gchar *identifier;
const char const *paths[32];
int npaths;
@@ -2307,10 +2305,6 @@ static int device_save(struct connman_device *device)
_DBG_DEVICE("device %p", device);
- keyfile = __connman_storage_open(ident);
- if (keyfile == NULL)
- return 0;
-
identifier = g_strdup_printf("device_%s", device->element.name);
if (identifier == NULL)
goto done;
@@ -2349,8 +2343,6 @@ static int device_save(struct connman_device *device)
done:
g_free(identifier);
- __connman_storage_close(ident, keyfile, TRUE);
-
return 0;
}
« no previous file with comments | « src/crypto.c ('k') | src/ipconfig.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698