summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-12-19 14:51:10 -0800
committerMarcel Holtmann <marcel@holtmann.org>2009-12-19 14:51:10 -0800
commit9906db093ef4156a97bbb0d82e2666b34563af29 (patch)
tree5390a62f03460d61bbab3549b93ae448eadb3960
parentf5b31a03d2bdc743510ed96a314e60a9899ac986 (diff)
downloadconnman-9906db093ef4156a97bbb0d82e2666b34563af29.tar.gz
connman-9906db093ef4156a97bbb0d82e2666b34563af29.tar.bz2
connman-9906db093ef4156a97bbb0d82e2666b34563af29.zip
Use D-Bus property helpers for network list details
-rw-r--r--src/device.c27
-rw-r--r--src/network.c27
2 files changed, 13 insertions, 41 deletions
diff --git a/src/device.c b/src/device.c
index 41b131b0..45152459 100644
--- a/src/device.c
+++ b/src/device.c
@@ -266,24 +266,11 @@ static void append_path(gpointer key, gpointer value, gpointer user_data)
&element->path);
}
-static void append_networks(struct connman_device *device,
- DBusMessageIter *entry)
+static void append_networks(DBusMessageIter *iter, void *user_data)
{
- DBusMessageIter value, iter;
- const char *key = "Networks";
-
- dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
- g_hash_table_foreach(device->networks, append_path, &iter);
- dbus_message_iter_close_container(&value, &iter);
+ struct connman_device *device = user_data;
- dbus_message_iter_close_container(entry, &value);
+ g_hash_table_foreach(device->networks, append_path, iter);
}
static DBusMessage *get_properties(DBusConnection *conn,
@@ -291,7 +278,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
{
struct connman_device *device = data;
DBusMessage *reply;
- DBusMessageIter array, dict, entry;
+ DBusMessageIter array, dict;
const char *str;
DBG("conn %p", conn);
@@ -341,10 +328,8 @@ static DBusMessage *get_properties(DBusConnection *conn,
connman_dbus_dict_append_basic(&dict, "ScanInterval",
DBUS_TYPE_UINT16, &device->scan_interval);
- dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
- append_networks(device, &entry);
- dbus_message_iter_close_container(&dict, &entry);
+ connman_dbus_dict_append_variable_array(&dict, "Networks",
+ DBUS_TYPE_OBJECT_PATH, append_networks, device);
break;
}
diff --git a/src/network.c b/src/network.c
index 138783b9..81be9be7 100644
--- a/src/network.c
+++ b/src/network.c
@@ -179,41 +179,28 @@ static GDBusSignalTable network_signals[] = {
static DBusConnection *connection;
-static void append_networks(struct connman_device *device,
- DBusMessageIter *entry)
+static void append_networks(DBusMessageIter *iter, void *user_data)
{
- DBusMessageIter value, iter;
- const char *key = "Networks";
+ struct connman_device *device = user_data;
- dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
__connman_element_list((struct connman_element *) device,
- CONNMAN_ELEMENT_TYPE_NETWORK, &iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(entry, &value);
+ CONNMAN_ELEMENT_TYPE_NETWORK, iter);
}
static void emit_networks_signal(struct connman_device *device)
{
const char *path = connman_device_get_path(device);
DBusMessage *signal;
- DBusMessageIter entry;
+ DBusMessageIter iter;
signal = dbus_message_new_signal(path,
CONNMAN_DEVICE_INTERFACE, "PropertyChanged");
if (signal == NULL)
return;
- dbus_message_iter_init_append(signal, &entry);
-
- append_networks(device, &entry);
+ dbus_message_iter_init_append(signal, &iter);
+ connman_dbus_property_append_variable_array(&iter, "Networks",
+ DBUS_TYPE_OBJECT_PATH, append_networks, device);
g_dbus_send_message(connection, signal);
}