summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-10-27 17:45:53 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-10-27 17:45:53 +0000
commitf6b3297c6123445d3db8111eb4bcbc17d24fd132 (patch)
tree1693bdaa29884734002a461c29df8501b1610cf3 /hcid
parentccd3b42688143a3c0bcf3fae5daa23b4544aac13 (diff)
Added SetTrusted in the Service interface
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-service.c26
-rw-r--r--hcid/dbus.h1
2 files changed, 26 insertions, 1 deletions
diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c
index 1d268280..865e3f36 100644
--- a/hcid/dbus-service.c
+++ b/hcid/dbus-service.c
@@ -110,6 +110,8 @@ static void service_agent_free(struct service_agent *agent)
if (agent->description)
free(agent->description);
+ slist_foreach(agent->trusted_devices, (slist_func_t) free, NULL);
+
free(agent);
}
@@ -471,7 +473,29 @@ static DBusHandlerResult remove_user(DBusConnection *conn,
static DBusHandlerResult set_trusted(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ struct service_agent *agent = data;
+ struct slist *l;
+ DBusMessage *reply;
+ const char *address;
+
+ /* FIXME: Missing define security policy */
+
+ if (!dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_INVALID))
+ return error_invalid_arguments(conn, msg);
+
+ l = slist_find(agent->trusted_devices, address, (cmp_func_t) strcmp);
+ if (l)
+ return error_failed(conn, msg, EINVAL);
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ agent->trusted_devices = slist_append(agent->trusted_devices, strdup(address));
+
+ return send_message_and_unref(conn, reply);
}
static DBusHandlerResult is_trusted(DBusConnection *conn,
diff --git a/hcid/dbus.h b/hcid/dbus.h
index f0f58493..49c6c6c6 100644
--- a/hcid/dbus.h
+++ b/hcid/dbus.h
@@ -162,6 +162,7 @@ struct service_agent {
char *name;
char *description;
int running;
+ struct slist *trusted_devices;
};
typedef int register_function_t(DBusConnection *conn, uint16_t id);