diff options
-rw-r--r-- | hcid/dbus-database.c | 30 | ||||
-rw-r--r-- | hcid/dbus-manager.c | 51 |
2 files changed, 51 insertions, 30 deletions
diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c index f0b13abb..1e0cee3e 100644 --- a/hcid/dbus-database.c +++ b/hcid/dbus-database.c @@ -43,8 +43,6 @@ #include "sdp-xml.h" #include "dbus-common.h" #include "dbus-error.h" -#include "dbus-hci.h" -#include "dbus-service.h" #include "dbus-database.h" static int sdp_server_enable = 0; @@ -266,38 +264,10 @@ static DBusHandlerResult remove_service_record(DBusConnection *conn, return send_message_and_unref(conn, reply); } -static DBusHandlerResult register_service(DBusConnection *conn, - DBusMessage *msg, void *data) -{ - DBusMessage *reply; - const char *ident, *name, *desc; - const char *sender; - - 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 struct service_data database_services[] = { { "AddServiceRecord", add_service_record }, { "AddServiceRecordFromXML", add_service_record_from_xml }, { "RemoveServiceRecord", remove_service_record }, - { "RegisterService", register_service }, { NULL, NULL } }; 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 } }; |