diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-03-13 19:09:43 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2006-03-13 19:09:43 +0000 |
commit | 054fe368560b0cdd9ca60e9e8acfb25e925b7b78 (patch) | |
tree | 4d7d41935ad433b18e78d92988f163214f9e61e2 | |
parent | e904071252acf524571b39b721e468a64e37f57e (diff) |
Add support for Release method callback
-rw-r--r-- | hcid/passkey-agent.c | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/hcid/passkey-agent.c b/hcid/passkey-agent.c index 8fa27186..267b08b3 100644 --- a/hcid/passkey-agent.c +++ b/hcid/passkey-agent.c @@ -70,14 +70,11 @@ static DBusHandlerResult agent_filter(DBusConnection *conn, DBusMessage *msg, vo return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -static DBusHandlerResult agent_message(DBusConnection *conn, DBusMessage *msg, void *data) +static DBusHandlerResult request_message(DBusConnection *conn, DBusMessage *msg, void *data) { DBusMessage *reply; const char *path, *address; - if (!dbus_message_is_method_call(msg, INTERFACE, "Request")) - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - if (!passkey) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -105,6 +102,48 @@ static DBusHandlerResult agent_message(DBusConnection *conn, DBusMessage *msg, v return DBUS_HANDLER_RESULT_HANDLED; } +static DBusHandlerResult release_message(DBusConnection *conn, DBusMessage *msg, void *data) +{ + DBusMessage *reply; + + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_INVALID)) { + fprintf(stderr, "Invalid arguments for passkey Release method"); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + reply = dbus_message_new_method_return(msg); + if (!reply) { + fprintf(stderr, "Can't create reply message\n"); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + dbus_message_append_args(reply, DBUS_TYPE_INVALID); + + dbus_connection_send(conn, reply, NULL); + + dbus_connection_flush(conn); + + dbus_message_unref(reply); + + if (!__io_canceled) + fprintf(stderr, "Passkey service has been released\n"); + + __io_terminated = 1; + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult agent_message(DBusConnection *conn, DBusMessage *msg, void *data) +{ + if (dbus_message_is_method_call(msg, INTERFACE, "Request")) + return request_message(conn, msg, data); + + if (dbus_message_is_method_call(msg, INTERFACE, "Release")) + return release_message(conn, msg, data); + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + static const DBusObjectPathVTable agent_table = { .message_function = agent_message, }; |