DBUS_TYPE_STRING, "IPv4.Gateway" },
{ CONNMAN_PROPERTY_ID_IPV4_NAMESERVER,
DBUS_TYPE_STRING, "IPv4.Nameserver" },
+
+ { CONNMAN_PROPERTY_ID_WIFI_SECURITY,
+ DBUS_TYPE_STRING, "WiFi.Security" },
+ { CONNMAN_PROPERTY_ID_WIFI_PASSPHRASE,
+ DBUS_TYPE_STRING, "WiFi.Passphrase" },
+
{ }
};
connman_dbus_dict_append_variant(&dict, "IPv4.Gateway",
DBUS_TYPE_STRING, &element->ipv4.gateway);
+ if (element->wifi.security != NULL)
+ connman_dbus_dict_append_variant(&dict, "WiFi.Security",
+ DBUS_TYPE_STRING, &element->wifi.security);
+ if (element->wifi.passphrase != NULL)
+ connman_dbus_dict_append_variant(&dict, "WiFi.Passphrase",
+ DBUS_TYPE_STRING, &element->wifi.passphrase);
+
connman_element_lock(element);
for (list = element->properties; list; list = list->next) {
element->ipv4.nameserver = g_strdup(*((const char **) value));
connman_element_unlock(element);
break;
+ case CONNMAN_PROPERTY_ID_WIFI_SECURITY:
+ connman_element_lock(element);
+ g_free(element->wifi.security);
+ element->wifi.security = g_strdup(*((const char **) value));
+ connman_element_unlock(element);
+ break;
+ case CONNMAN_PROPERTY_ID_WIFI_PASSPHRASE:
+ connman_element_lock(element);
+ g_free(element->wifi.passphrase);
+ element->wifi.passphrase = g_strdup(*((const char **) value));
+ connman_element_unlock(element);
+ break;
default:
return -EINVAL;
}
*((char **) value) = element->ipv4.nameserver;
connman_element_unlock(element);
break;
+ case CONNMAN_PROPERTY_ID_WIFI_SECURITY:
+ if (element->wifi.security == NULL)
+ return connman_element_get_value(element->parent,
+ id, value);
+ connman_element_lock(element);
+ *((char **) value) = element->wifi.security;
+ connman_element_unlock(element);
+ break;
+ case CONNMAN_PROPERTY_ID_WIFI_PASSPHRASE:
+ if (element->wifi.passphrase == NULL)
+ return connman_element_get_value(element->parent,
+ id, value);
+ connman_element_lock(element);
+ *((char **) value) = element->wifi.passphrase;
+ connman_element_unlock(element);
+ break;
default:
return -EINVAL;
}
connman_element_lock(element);
- __connman_element_load(element);
-
if (element->name == NULL) {
element->name = g_strdup(type2string(element->type));
if (element->name == NULL) {
DBG("element %p path %s", element, element->path);
+ __connman_element_load(element);
+
g_node_append_data(node, element);
if (g_dbus_register_interface(connection, element->path,
DBG("");
}
+static int do_load(GKeyFile *keyfile, struct connman_element *element)
+{
+ const gchar *value;
+
+ DBG("element %p name %s", element, element->name);
+
+ value = g_key_file_get_string(keyfile, element->path,
+ "WiFi.Security", NULL);
+ if (value != NULL)
+ connman_element_set_property(element,
+ CONNMAN_PROPERTY_ID_WIFI_SECURITY, &value);
+
+ value = g_key_file_get_string(keyfile, element->path,
+ "WiFi.Passphrase", NULL);
+ if (value != NULL)
+ connman_element_set_property(element,
+ CONNMAN_PROPERTY_ID_WIFI_PASSPHRASE, &value);
+
+ return 0;
+}
+
int __connman_element_load(struct connman_element *element)
{
+ GKeyFile *keyfile;
+ gchar *pathname, *data = NULL;
+ gsize length;
+
DBG("element %p name %s", element, element->name);
+ pathname = g_strdup_printf("%s/elements.conf", STORAGEDIR);
+ if (pathname == NULL)
+ return -ENOMEM;
+
+ keyfile = g_key_file_new();
+
+ if (g_file_get_contents(pathname, &data, &length, NULL) == FALSE) {
+ g_free(pathname);
+ return -ENOENT;
+ }
+
+ g_free(pathname);
+
+ if (g_key_file_load_from_data(keyfile, data, length,
+ 0, NULL) == FALSE) {
+ g_free(data);
+ return -EILSEQ;
+ }
+
+ g_free(data);
+
+ do_load(keyfile, element);
+
+ g_key_file_free(keyfile);
+
return 0;
}
static void do_update(GKeyFile *keyfile, struct connman_element *element)
{
GSList *list;
+ char *value;
DBG("element %p name %s", element, element->name);
}
connman_element_unlock(element);
+
+ if (connman_element_get_value(element,
+ CONNMAN_PROPERTY_ID_WIFI_SECURITY, &value) == 0)
+ g_key_file_set_string(keyfile, element->path,
+ "WiFi.Security", value);
+
+ if (connman_element_get_value(element,
+ CONNMAN_PROPERTY_ID_WIFI_PASSPHRASE, &value) == 0)
+ g_key_file_set_string(keyfile, element->path,
+ "WiFi.Passphrase", value);
}
int __connman_element_store(struct connman_element *element)
DBG("element %p name %s", element, element->name);
+ if (element->type != CONNMAN_ELEMENT_TYPE_DEVICE &&
+ element->type != CONNMAN_ELEMENT_TYPE_NETWORK)
+ return -EINVAL;
+
pathname = g_strdup_printf("%s/elements.conf", STORAGEDIR);
if (pathname == NULL)
return -ENOMEM;