summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-05-16 17:24:49 -0700
committerMarcel Holtmann <marcel@holtmann.org>2009-05-16 17:24:49 -0700
commitb1b69605d5884188f53c86b0f1e3ca699398ec39 (patch)
tree00650347e38f2068cadae38a82e9eadc94fcbe00 /src
parent1d9651d72842ab02c6cc9360c61857ae810ff4b7 (diff)
downloadconnman-b1b69605d5884188f53c86b0f1e3ca699398ec39.tar.gz
connman-b1b69605d5884188f53c86b0f1e3ca699398ec39.tar.bz2
connman-b1b69605d5884188f53c86b0f1e3ca699398ec39.zip
Include device details within the profile storage
Diffstat (limited to 'src')
-rw-r--r--src/detect.c2
-rw-r--r--src/device.c51
-rw-r--r--src/element.c2
3 files changed, 22 insertions, 33 deletions
diff --git a/src/detect.c b/src/detect.c
index 9b5abdfa..c8247eec 100644
--- a/src/detect.c
+++ b/src/detect.c
@@ -233,7 +233,7 @@ static void detect_newlink(unsigned short type, int index,
case CONNMAN_DEVICE_TYPE_ETHERNET:
case CONNMAN_DEVICE_TYPE_WIFI:
case CONNMAN_DEVICE_TYPE_WIMAX:
- name = index2ident(index, "dev_");
+ name = index2ident(index, "");
addr = index2addr(index);
break;
case CONNMAN_DEVICE_TYPE_BLUETOOTH:
diff --git a/src/device.c b/src/device.c
index 0af3ccd9..3d15d775 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1865,7 +1865,7 @@ static struct connman_driver device_driver = {
static int device_load(struct connman_device *device)
{
GKeyFile *keyfile;
- gchar *pathname, *data = NULL;
+ gchar *pathname, *identifier, *data = NULL;
gsize length;
char *str;
int val;
@@ -1873,7 +1873,7 @@ static int device_load(struct connman_device *device)
DBG("device %p", device);
pathname = g_strdup_printf("%s/%s.conf", STORAGEDIR,
- device->element.name);
+ __connman_profile_active_ident());
if (pathname == NULL)
return -ENOMEM;
@@ -1894,53 +1894,48 @@ static int device_load(struct connman_device *device)
g_free(data);
- str = g_key_file_get_string(keyfile, "Configuration", "Policy", NULL);
+ identifier = g_strdup_printf("device_%s", device->element.name);
+ if (identifier == NULL)
+ goto done;
+
+ str = g_key_file_get_string(keyfile, identifier, "Policy", NULL);
if (str != NULL) {
device->policy = string2policy(str);
g_free(str);
}
- val = g_key_file_get_integer(keyfile, "Configuration",
- "Priority", NULL);
- if (val > 0)
- device->priority = val;
-
switch (device->mode) {
case CONNMAN_DEVICE_MODE_UNKNOWN:
case CONNMAN_DEVICE_MODE_TRANSPORT_IP:
break;
case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
case CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE:
- val = g_key_file_get_integer(keyfile, "Configuration",
+ val = g_key_file_get_integer(keyfile, identifier,
"ScanInterval", NULL);
if (val > 0)
device->scan_interval = val;
break;
}
-#if 0
- str = g_key_file_get_string(keyfile, "Configuration",
- "LastNetwork", NULL);
- if (str != NULL)
- device->last_network = str;
-#endif
-
+done:
g_key_file_free(keyfile);
+ g_free(identifier);
+
return 0;
}
static int device_save(struct connman_device *device)
{
GKeyFile *keyfile;
- gchar *pathname, *data = NULL;
+ gchar *pathname, *identifier = NULL, *data = NULL;
gsize length;
const char *str;
DBG("device %p", device);
pathname = g_strdup_printf("%s/%s.conf", STORAGEDIR,
- device->element.name);
+ __connman_profile_active_ident());
if (pathname == NULL)
return -ENOMEM;
@@ -1958,13 +1953,13 @@ static int device_save(struct connman_device *device)
g_free(data);
update:
+ identifier = g_strdup_printf("device_%s", device->element.name);
+ if (identifier == NULL)
+ goto done;
+
str = policy2string(device->policy);
if (str != NULL)
- g_key_file_set_string(keyfile, "Configuration", "Policy", str);
-
- if (device->priority > 0)
- g_key_file_set_integer(keyfile, "Configuration",
- "Priority", device->priority);
+ g_key_file_set_string(keyfile, identifier, "Policy", str);
switch (device->mode) {
case CONNMAN_DEVICE_MODE_UNKNOWN:
@@ -1973,15 +1968,11 @@ update:
case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
case CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE:
if (device->scan_interval > 0)
- g_key_file_set_integer(keyfile, "Configuration",
+ g_key_file_set_integer(keyfile, identifier,
"ScanInterval", device->scan_interval);
break;
}
- if (device->last_network != NULL)
- g_key_file_set_string(keyfile, "Configuration",
- "LastNetwork", device->last_network);
-
data = g_key_file_to_data(keyfile, &length, NULL);
if (g_file_set_contents(pathname, data, length, NULL) == FALSE)
@@ -1992,11 +1983,9 @@ done:
g_key_file_free(keyfile);
+ g_free(identifier);
g_free(pathname);
- if (device->network != NULL)
- __connman_storage_save_network(device->network);
-
return 0;
}
diff --git a/src/element.c b/src/element.c
index e4fd6f3c..2010f452 100644
--- a/src/element.c
+++ b/src/element.c
@@ -1116,7 +1116,7 @@ static void register_element(gpointer data, gpointer user_data)
element->parent = element_root->data;
node = element_root;
- basepath = "";
+ basepath = "/device";
}
element->path = g_strdup_printf("%s/%s", basepath, element->name);