diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-01-24 14:18:50 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-01-24 14:18:50 +0000 |
commit | 45d7f9ac3228a3b27ef3374e8cec13af1dd4f1fa (patch) | |
tree | bce1a4a7d32b7213ba962e76864c8a06dee92f33 /hcid/dbus-database.c | |
parent | e0e5d97ac34119a2cf91d096f20e203d5ffe676d (diff) |
Move service registration/authorization methods to database interface
Diffstat (limited to 'hcid/dbus-database.c')
-rw-r--r-- | hcid/dbus-database.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c index 1e0cee3e..695970f8 100644 --- a/hcid/dbus-database.c +++ b/hcid/dbus-database.c @@ -41,8 +41,10 @@ #include "hcid.h" #include "sdpd.h" #include "sdp-xml.h" +#include "dbus-hci.h" #include "dbus-common.h" #include "dbus-error.h" +#include "dbus-service.h" #include "dbus-database.h" static int sdp_server_enable = 0; @@ -264,10 +266,106 @@ 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 *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 DBusHandlerResult request_authorization(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessage *reply; + const char *sender, *address, *path; + + if (!hcid_dbus_use_experimental()) + return error_unknown_method(conn, msg); + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address, + DBUS_TYPE_STRING, &path, 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 DBusHandlerResult cancel_authorization_request(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessage *reply; + const char *sender, *address, *path; + + if (!hcid_dbus_use_experimental()) + return error_unknown_method(conn, msg); + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address, + DBUS_TYPE_STRING, &path, 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 database_services[] = { { "AddServiceRecord", add_service_record }, { "AddServiceRecordFromXML", add_service_record_from_xml }, { "RemoveServiceRecord", remove_service_record }, + { "RegisterService", register_service }, + { "UnregisterService", unregister_service }, + { "RequestAuthorization", request_authorization }, + { "CancelAuthorizationRequest", cancel_authorization_request }, { NULL, NULL } }; |