summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-12-17 04:54:01 +0100
committerMarcel Holtmann <marcel@holtmann.org>2008-12-17 04:54:01 +0100
commit9328a63c330a64982d2a9bc060d8985c2228d3e5 (patch)
tree4a923c626bcbd51448aff42ad548598f7f741f56 /plugins
parent19adbb63c30ca07cc9999d54503fad03072617b6 (diff)
downloadconnman-9328a63c330a64982d2a9bc060d8985c2228d3e5.tar.gz
connman-9328a63c330a64982d2a9bc060d8985c2228d3e5.tar.bz2
connman-9328a63c330a64982d2a9bc060d8985c2228d3e5.zip
Retrieve list of Bluetooth devices
Diffstat (limited to 'plugins')
-rw-r--r--plugins/bluetooth.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 94c8649c..2b33c3ae 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -175,6 +175,45 @@ done:
dbus_message_unref(reply);
}
+static void devices_reply(DBusPendingCall *call, void *user_data)
+{
+ DBusMessage *message = user_data;
+ const char *path = dbus_message_get_path(message);
+ DBusMessage *reply;
+ DBusError error;
+ char **devices;
+ int i, num_devices;
+
+ DBG("path %s", path);
+
+ dbus_message_unref(message);
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ dbus_error_init(&error);
+
+ if (dbus_message_get_args(reply, &error,
+ DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH,
+ &devices, &num_devices,
+ DBUS_TYPE_INVALID) == FALSE) {
+ if (dbus_error_is_set(&error) == TRUE) {
+ connman_error("%s", error.message);
+ dbus_error_free(&error);
+ } else
+ connman_error("Wrong arguments for device list");
+ goto done;
+ }
+
+ for (i = 0; i < num_devices; i++) {
+ DBG("device %s", devices[i]);
+ }
+
+ g_strfreev(devices);
+
+done:
+ dbus_message_unref(reply);
+}
+
static void add_adapter(DBusConnection *connection, const char *path)
{
struct connman_element *device;
@@ -210,6 +249,20 @@ static void add_adapter(DBusConnection *connection, const char *path)
}
dbus_pending_call_set_notify(call, properties_reply, message, NULL);
+
+ message = dbus_message_new_method_call(BLUEZ_SERVICE, path,
+ BLUEZ_ADAPTER_INTERFACE, "ListDevices");
+ if (message == NULL)
+ return;
+
+ if (dbus_connection_send_with_reply(connection, message,
+ &call, TIMEOUT) == FALSE) {
+ connman_error("Failed to get Bluetooth devices");
+ dbus_message_unref(message);
+ return;
+ }
+
+ dbus_pending_call_set_notify(call, devices_reply, message, NULL);
}
static void remove_adapter(DBusConnection *connection, const char *path)