diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-01-24 10:10:08 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-01-24 10:10:08 +0000 |
commit | 48b5467e20216455a6b9683694cfd31968aa5543 (patch) | |
tree | 4169e150c450fcce5de4a7d704d2dc7f5aa8bc31 /hcid/dbus-manager.c | |
parent | c442974bf9e0261c80d06f91a3761ef82fcf590a (diff) |
Move service registration to the manager interface
Diffstat (limited to 'hcid/dbus-manager.c')
-rw-r--r-- | hcid/dbus-manager.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c index a81cbc8e..432e3ac5 100644 --- a/hcid/dbus-manager.c +++ b/hcid/dbus-manager.c @@ -50,6 +50,7 @@ #include "dbus-security.h" #include "dbus-service.h" #include "dbus-manager.h" +#include "dbus-service.h" #include "dbus-hci.h" #include "sdp-xml.h" @@ -284,6 +285,54 @@ static DBusHandlerResult activate_service(DBusConnection *conn, return DBUS_HANDLER_RESULT_HANDLED; } +static DBusHandlerResult register_service(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessage *reply; + const char *sender, *ident, *name, *desc; + + if (!hcid_dbus_use_experimental()) + return error_unknown_method(conn, msg); + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &ident, + DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &desc, + DBUS_TYPE_INVALID) == FALSE) + return error_invalid_arguments(conn, msg); + + sender = dbus_message_get_sender(msg); + + if (service_register(sender, ident, name, desc) < 0) + return error_failed(conn, msg, EIO); + + reply = dbus_message_new_method_return(msg); + if (!reply) + return DBUS_HANDLER_RESULT_NEED_MEMORY; + + return send_message_and_unref(conn, reply); +} + +static DBusHandlerResult unregister_service(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessage *reply; + const char *sender, *ident; + + if (!hcid_dbus_use_experimental()) + return error_unknown_method(conn, msg); + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &ident, + DBUS_TYPE_INVALID) == FALSE) + return error_invalid_arguments(conn, msg); + + sender = dbus_message_get_sender(msg); + + reply = dbus_message_new_method_return(msg); + if (!reply) + return DBUS_HANDLER_RESULT_NEED_MEMORY; + + return send_message_and_unref(conn, reply); +} + static struct service_data methods[] = { { "InterfaceVersion", interface_version }, { "DefaultAdapter", default_adapter }, @@ -292,6 +341,8 @@ static struct service_data methods[] = { { "FindService", find_service }, { "ListServices", list_services }, { "ActivateService", activate_service }, + { "RegisterService", register_service }, + { "UnregisterService", unregister_service }, { NULL, NULL } }; |