Include device details within the profile storage
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 17 May 2009 00:24:49 +0000 (17:24 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 17 May 2009 00:24:49 +0000 (17:24 -0700)
src/detect.c
src/device.c
src/element.c

index 9b5abdf..c8247ee 100644 (file)
@@ -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:
index 0af3ccd..3d15d77 100644 (file)
@@ -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;
 }
 
index e4fd6f3..2010f45 100644 (file)
@@ -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);