summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-01-24 15:15:05 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-01-24 15:15:05 +0000
commit138df419579f4a02b63f1055a436bc721b02ca2f (patch)
treedbec7ec251c7e2f48fe07d10712c6770f90cab53 /hcid
parente1ebd6405afaed4d83308fbfe06f5c487038df62 (diff)
Fully implement Database.UnregisterService
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-database.c11
-rw-r--r--hcid/dbus-service.c6
-rw-r--r--hcid/dbus-service.h2
3 files changed, 19 insertions, 0 deletions
diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c
index 695970f8..423d117b 100644
--- a/hcid/dbus-database.c
+++ b/hcid/dbus-database.c
@@ -297,6 +297,7 @@ static DBusHandlerResult unregister_service(DBusConnection *conn,
{
DBusMessage *reply;
const char *sender, *ident;
+ struct service *service;
if (!hcid_dbus_use_experimental())
return error_unknown_method(conn, msg);
@@ -307,6 +308,16 @@ static DBusHandlerResult unregister_service(DBusConnection *conn,
sender = dbus_message_get_sender(msg);
+ service = search_service(conn, ident);
+ if (!service)
+ return error_service_does_not_exist(conn, msg);
+
+ if (!service->internal || strcmp(sender, service->bus_name))
+ return error_not_authorized(conn, msg);
+
+ if (service_unregister(service) < 0)
+ return error_failed(conn, msg, EIO);
+
reply = dbus_message_new_method_return(msg);
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c
index e9e6d09b..e277e604 100644
--- a/hcid/dbus-service.c
+++ b/hcid/dbus-service.c
@@ -963,3 +963,9 @@ int service_register(const char *bus_name, const char *ident,
return 0;
}
+
+int service_unregister(struct service *service)
+{
+ return unregister_service(service);
+}
+
diff --git a/hcid/dbus-service.h b/hcid/dbus-service.h
index 33e7e056..68a53b2c 100644
--- a/hcid/dbus-service.h
+++ b/hcid/dbus-service.h
@@ -64,4 +64,6 @@ int init_services(const char *path);
int service_register(const char *bus_name, const char *ident,
const char *name, const char *description);
+int service_unregister(struct service *service);
+
#endif /* __BLUEZ_DBUS_SERVICE_H */