summaryrefslogtreecommitdiff
path: root/tools/supplicant-dbus.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-12-30 02:38:37 -0800
committerMarcel Holtmann <marcel@holtmann.org>2009-12-30 02:38:37 -0800
commita6b51d4e45f15c0eca7e5cfce377e4883ceae8e0 (patch)
treeeb1a37741585ccac83a619db1c446a73ded25599 /tools/supplicant-dbus.c
parent44730d1b724320894d1d7ec0b5717eeafbbb5408 (diff)
downloadconnman-a6b51d4e45f15c0eca7e5cfce377e4883ceae8e0.tar.gz
connman-a6b51d4e45f15c0eca7e5cfce377e4883ceae8e0.tar.bz2
connman-a6b51d4e45f15c0eca7e5cfce377e4883ceae8e0.zip
Add support for debug settings in supplicant test program
Diffstat (limited to 'tools/supplicant-dbus.c')
-rw-r--r--tools/supplicant-dbus.c81
1 files changed, 78 insertions, 3 deletions
diff --git a/tools/supplicant-dbus.c b/tools/supplicant-dbus.c
index 3f1c9af9..e6378c32 100644
--- a/tools/supplicant-dbus.c
+++ b/tools/supplicant-dbus.c
@@ -98,14 +98,14 @@ void supplicant_dbus_property_foreach(DBusMessageIter *iter,
}
}
-struct property_data {
+struct property_get_data {
supplicant_dbus_property_function function;
void *user_data;
};
static void property_get_all_reply(DBusPendingCall *call, void *user_data)
{
- struct property_data *data = user_data;
+ struct property_get_data *data = user_data;
DBusMessage *reply;
DBusMessageIter iter;
@@ -133,7 +133,7 @@ int supplicant_dbus_property_get_all(const char *path, const char *interface,
supplicant_dbus_property_function function,
void *user_data)
{
- struct property_data *data;
+ struct property_get_data *data;
DBusMessage *message;
DBusPendingCall *call;
@@ -178,3 +178,78 @@ int supplicant_dbus_property_get_all(const char *path, const char *interface,
return 0;
}
+
+struct property_set_data {
+ void *user_data;
+};
+
+static void property_set_reply(DBusPendingCall *call, void *user_data)
+{
+ //struct property_set_data *data = user_data;
+ DBusMessage *reply;
+
+ reply = dbus_pending_call_steal_reply(call);
+ if (reply == NULL)
+ return;
+
+ dbus_message_unref(reply);
+}
+
+int supplicant_dbus_property_set(const char *path, const char *interface,
+ const char *key, const char *signature,
+ supplicant_dbus_value_function function,
+ void *user_data)
+{
+ struct property_set_data *data;
+ DBusMessage *message;
+ DBusMessageIter iter, value;
+ DBusPendingCall *call;
+
+ if (path == NULL || interface == NULL)
+ return -EINVAL;
+
+ data = dbus_malloc0(sizeof(*data));
+ if (data == NULL)
+ return -ENOMEM;
+
+ message = dbus_message_new_method_call(SUPPLICANT_SERVICE, path,
+ DBUS_INTERFACE_PROPERTIES, "Set");
+ if (message == NULL) {
+ dbus_free(data);
+ return -ENOMEM;
+ }
+
+ dbus_message_set_auto_start(message, FALSE);
+
+ dbus_message_iter_init_append(message, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &interface);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
+ signature, &value);
+ if (function != NULL)
+ function(&value, user_data);
+ dbus_message_iter_close_container(&iter, &value);
+
+ if (dbus_connection_send_with_reply(connection, message,
+ &call, TIMEOUT) == FALSE) {
+ dbus_message_unref(message);
+ dbus_free(data);
+ return -EIO;
+ }
+
+ if (call == NULL) {
+ dbus_message_unref(message);
+ dbus_free(data);
+ return -EIO;
+ }
+
+ data->user_data = user_data;
+
+ dbus_pending_call_set_notify(call, property_set_reply,
+ data, dbus_free);
+
+ dbus_message_unref(message);
+
+ return 0;
+}