summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-04-11 13:31:25 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-04-11 13:31:25 +0000
commitc1c8c6366c341a90c2f22741e52b225171a1d3c5 (patch)
treeb9b197e2000e418a89be3e77eb72a367f6e0f65a /hcid
parente0a2f55119eae4b8670a748205525ecff9bda5ae (diff)
Add signals for adding and removing trust
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-adapter.c20
-rw-r--r--hcid/dbus-api.txt8
-rw-r--r--hcid/dbus-service.c26
3 files changed, 45 insertions, 9 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index efbb0ac0..272f6d35 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -2815,7 +2815,7 @@ static DBusHandlerResult adapter_set_trusted(DBusConnection *conn,
void *data)
{
struct adapter *adapter = data;
- DBusMessage *reply;
+ DBusMessage *reply, *signal;
bdaddr_t local;
const char *address;
@@ -2835,6 +2835,11 @@ static DBusHandlerResult adapter_set_trusted(DBusConnection *conn,
write_trust(&local, address, GLOBAL_TRUST, TRUE);
+ signal = dev_signal_factory(adapter->dev_id, "TrustAdded",
+ DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_INVALID);
+ send_message_and_unref(conn, signal);
+
return send_message_and_unref(conn, reply);
}
@@ -2876,7 +2881,7 @@ static DBusHandlerResult adapter_remove_trust(DBusConnection *conn,
void *data)
{
struct adapter *adapter = data;
- DBusMessage *reply;
+ DBusMessage *reply, *signal;
const char *address;
bdaddr_t local;
@@ -2888,13 +2893,18 @@ static DBusHandlerResult adapter_remove_trust(DBusConnection *conn,
if (check_address(address) < 0)
return error_invalid_arguments(conn, msg);
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
str2ba(adapter->address, &local);
write_trust(&local, address, GLOBAL_TRUST, FALSE);
- reply = dbus_message_new_method_return(msg);
- if (!reply)
- return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ signal = dev_signal_factory(adapter->dev_id, "TrustRemoved",
+ DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_INVALID);
+ send_message_and_unref(conn, signal);
return send_message_and_unref(conn, reply);
}
diff --git a/hcid/dbus-api.txt b/hcid/dbus-api.txt
index 5a30898f..b76c86c6 100644
--- a/hcid/dbus-api.txt
+++ b/hcid/dbus-api.txt
@@ -1152,6 +1152,14 @@ Signals void Started()
The object path of this signal contains which service
was stopped.
+ void TrustAdded(string address)
+
+ Sent when SetTrusted() is called.
+
+ void TrustRemoved(string address)
+
+ Sent when RemoveTrust() is called.
+
Security hierarchy
==================
diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c
index d9ce3536..803bef13 100644
--- a/hcid/dbus-service.c
+++ b/hcid/dbus-service.c
@@ -511,7 +511,7 @@ static DBusHandlerResult set_trusted(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct service *service = data;
- DBusMessage *reply;
+ DBusMessage *reply, *signal;
const char *address;
if (!dbus_message_get_args(msg, NULL,
@@ -526,8 +526,17 @@ static DBusHandlerResult set_trusted(DBusConnection *conn,
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ signal = dbus_message_new_signal(service->object_path,
+ SERVICE_INTERFACE, "TrustAdded");
+ if (!signal)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
write_trust(BDADDR_ANY, address, service->ident, TRUE);
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_INVALID);
+ send_message_and_unref(conn, signal);
+
return send_message_and_unref(conn, reply);
}
@@ -564,7 +573,7 @@ static DBusHandlerResult remove_trust(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct service *service = data;
- DBusMessage *reply;
+ DBusMessage *reply, *signal;
const char *address;
if (!dbus_message_get_args(msg, NULL,
@@ -575,12 +584,21 @@ static DBusHandlerResult remove_trust(DBusConnection *conn,
if (check_address(address) < 0)
return error_invalid_arguments(conn, msg);
- write_trust(BDADDR_ANY, address, service->ident, FALSE);
-
reply = dbus_message_new_method_return(msg);
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ signal = dbus_message_new_signal(service->object_path,
+ SERVICE_INTERFACE, "TrustRemoved");
+ if (!signal)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ write_trust(BDADDR_ANY, address, service->ident, FALSE);
+
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_INVALID);
+ send_message_and_unref(conn, signal);
+
return send_message_and_unref(conn, reply);
}