Fix: Use Manager's Adapters property instead

ListAdapters method on Manager interface is deprecated
This commit is contained in:
Denis Kenzior 2010-02-12 15:05:52 -06:00
parent 7a48b56ebb
commit 41a1dacae9
1 changed files with 32 additions and 20 deletions

View File

@ -760,11 +760,36 @@ static gboolean uuid_emitted(DBusConnection *connection, DBusMessage *message,
return TRUE;
}
static void list_adapters_cb(DBusPendingCall *call, gpointer user_data)
static void parse_adapters(DBusMessageIter *array, gpointer user_data)
{
DBusMessageIter value;
DBG("");
if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
return;
dbus_message_iter_recurse(array, &value);
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);
dbus_message_iter_next(&value);
}
}
static void manager_properties_cb(DBusPendingCall *call, gpointer user_data)
{
DBusMessage *reply;
char **adapter_list = NULL;
int num, ret, i;
reply = dbus_pending_call_steal_reply(call);
@ -773,21 +798,7 @@ static void list_adapters_cb(DBusPendingCall *call, gpointer user_data)
goto done;
}
if (dbus_message_get_args(reply, NULL, DBUS_TYPE_ARRAY,
DBUS_TYPE_OBJECT_PATH, &adapter_list,
&num, DBUS_TYPE_INVALID) == FALSE)
goto done;
for (i = 0 ; i < num ; i++) {
ret = send_method_call_with_reply(BLUEZ_SERVICE, adapter_list[i],
BLUEZ_ADAPTER_INTERFACE, "ListDevices",
list_devices_cb, NULL, -1, DBUS_TYPE_INVALID);
if (ret < 0)
ofono_error("ListDevices failed(%d)", ret);
}
g_strfreev(adapter_list);
parse_properties_reply(reply, "Adapters", parse_adapters, NULL, NULL);
done:
dbus_message_unref(reply);
@ -1011,8 +1022,9 @@ static int hfp_init()
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;