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

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: 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
Index: src/device.c
diff --git a/src/device.c b/src/device.c
index 755d341142366c256e879b44a48cb26494c6e4ec..3ecc36412c32f7d7fb4ab814c6be45adcafa30b5 100644
--- a/src/device.c
+++ b/src/device.c
@@ -250,7 +250,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;
}
@@ -625,7 +625,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);
@@ -655,7 +655,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)
@@ -672,7 +672,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) {
@@ -685,7 +685,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) {
@@ -698,7 +698,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
@@ -1523,7 +1523,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);
}
@@ -1546,7 +1546,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);
}
@@ -2045,7 +2045,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();
@@ -2062,7 +2062,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);
}
@@ -2193,10 +2193,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;
@@ -2204,16 +2202,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);
@@ -2268,15 +2270,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;
@@ -2284,10 +2282,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;
@@ -2326,8 +2320,6 @@ static int device_save(struct connman_device *device)
done:
g_free(identifier);
- __connman_storage_close(ident, keyfile, TRUE);
-
return 0;
}

Powered by Google App Engine
This is Rietveld 408576698