summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-08-19 14:04:58 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-08-19 14:04:58 +0000
commit4a94c79e4ae397d3c4b4ec9e8c6a76b0938dab59 (patch)
treec6e3a1ad6472866dff865a025f0a2295585f4535
parentfa6a550673f30e6da10c0c4b62d5fedc1ebac787 (diff)
Fix the listing of service based trusts
-rw-r--r--hcid/dbus-api.txt11
-rw-r--r--hcid/dbus-service.c46
2 files changed, 35 insertions, 22 deletions
diff --git a/hcid/dbus-api.txt b/hcid/dbus-api.txt
index b1389bd0..be6116ac 100644
--- a/hcid/dbus-api.txt
+++ b/hcid/dbus-api.txt
@@ -1193,15 +1193,10 @@ Methods dict GetInfo()
file. The Start and Stop methods are not applicable to
external services and will return an error.
- array{string} ListUsers() [experimental]
+ array{string} ListTrusts() [experimental]
- Returns list of current users (device addresses)
- of the service.
-
- void RemoveUser(string address) [experimental]
-
- Removes a user of the service. The address parameter
- must match one of the current users of the service.
+ Returns a list of remote devices that are trusted
+ for the service.
void SetTrusted(string address) [experimental]
diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c
index 6e488612..87807c6f 100644
--- a/hcid/dbus-service.c
+++ b/hcid/dbus-service.c
@@ -528,18 +528,6 @@ static DBusHandlerResult is_external(DBusConnection *conn,
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult list_users(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-static DBusHandlerResult remove_user(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
static DBusHandlerResult set_trusted(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -569,6 +557,37 @@ static DBusHandlerResult set_trusted(DBusConnection *conn,
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)
{
@@ -637,11 +656,10 @@ static DBusMethodVTable service_methods[] = {
{ "Stop", stop, "", "" },
{ "IsRunning", is_running, "", "b" },
{ "IsExternal", is_external, "", "b" },
- { "ListUsers", list_users, "", "as" },
- { "RemoveUser", remove_user, "s", "" },
{ "SetTrusted", set_trusted, "s", "" },
{ "IsTrusted", is_trusted, "s", "b" },
{ "RemoveTrust", remove_trust, "s", "" },
+ { "ListTrusts", list_trusted, "", "as" },
{ NULL, NULL, NULL, NULL }
};