--- hcid/dbus-service.c +++ hcid/dbus-service.c @@ -566,6 +566,39 @@ return send_message_and_unref(conn, reply); } +static DBusHandlerResult list_trusted(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct service *service = data; + DBusMessage *reply; + GSList *trusts, *l; + char **addrs; + int len; + + reply = dbus_message_new_method_return(msg); + if (!reply) + return DBUS_HANDLER_RESULT_NEED_MEMORY; + trusts = list_trusts(BDADDR_ANY, service->ident); + + addrs = g_new(char *, g_slist_length(trusts)); + + for (l = trusts, len = 0; l; l = l->next, len++) + addrs[len] = l->data; + + dbus_message_append_args(reply, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, + &addrs, len, + DBUS_TYPE_INVALID); + + g_free(addrs); + g_slist_foreach(trusts, (GFunc) g_free, NULL); + g_slist_free(trusts); + + return send_message_and_unref(conn, reply); + + +} + static DBusHandlerResult is_trusted(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -639,6 +672,7 @@ { "SetTrusted", set_trusted, "s", "" }, { "IsTrusted", is_trusted, "s", "b" }, { "RemoveTrust", remove_trust, "s", "" }, + { "ListTrust", list_trusted, "", "as" }, { NULL, NULL, NULL, NULL } };