return TRUE;
}
-static void list_adapters_cb(DBusPendingCall *call, gpointer user_data)
+static void parse_adapters(DBusMessageIter *array, gpointer user_data)
{
- DBusMessage *reply;
- char **adapter_list = NULL;
- int num, ret, i;
+ DBusMessageIter value;
- reply = dbus_pending_call_steal_reply(call);
+ DBG("");
- if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
- DBG("Bluetooth daemon is apparently not available.");
- goto done;
- }
+ if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
+ return;
- if (dbus_message_get_args(reply, NULL, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH, &adapter_list,
- &num, DBUS_TYPE_INVALID) == FALSE)
- goto done;
+ dbus_message_iter_recurse(array, &value);
- for (i = 0 ; i < num ; i++) {
- ret = send_method_call_with_reply(BLUEZ_SERVICE, adapter_list[i],
+ while (dbus_message_iter_get_arg_type(&value)
+ == DBUS_TYPE_OBJECT_PATH) {
+ const char *path;
+
+ dbus_message_iter_get_basic(&value, &path);
+
+ DBG("Calling list devices on %s", path);
+
+ send_method_call_with_reply(BLUEZ_SERVICE, path,
BLUEZ_ADAPTER_INTERFACE, "ListDevices",
list_devices_cb, NULL, -1, DBUS_TYPE_INVALID);
- if (ret < 0)
- ofono_error("ListDevices failed(%d)", ret);
+ dbus_message_iter_next(&value);
+ }
+}
+
+static void manager_properties_cb(DBusPendingCall *call, gpointer user_data)
+{
+ DBusMessage *reply;
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
+ DBG("Bluetooth daemon is apparently not available.");
+ goto done;
}
- g_strfreev(adapter_list);
+ parse_properties_reply(reply, "Adapters", parse_adapters, NULL, NULL);
done:
dbus_message_unref(reply);
goto remove;
send_method_call_with_reply(BLUEZ_SERVICE, "/",
- BLUEZ_MANAGER_INTERFACE, "ListAdapters",
- list_adapters_cb, NULL, -1, DBUS_TYPE_INVALID);
+ BLUEZ_MANAGER_INTERFACE, "GetProperties",
+ manager_properties_cb, NULL, -1,
+ DBUS_TYPE_INVALID);
return 0;