From 19f50c6a3ba4ba4c3cb6d8da6724ec0d2f2062c9 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Wed, 20 Feb 2013 18:55:50 -0300 Subject: handsfree-audio: Add Agent "Unregister" This patch implements the "Unregister" method of the Handsfree Audio Manager. The agent is unregistered if sender and path match. --- src/handsfree-audio.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c index 28053b49..7bb59f08 100644 --- a/src/handsfree-audio.c +++ b/src/handsfree-audio.c @@ -25,6 +25,7 @@ #include #include +#include #include @@ -104,7 +105,29 @@ static DBusMessage *am_agent_register(DBusConnection *conn, static DBusMessage *am_agent_unregister(DBusConnection *conn, DBusMessage *msg, void *user_data) { - return __ofono_error_not_implemented(msg); + const char *sender, *path; + DBusMessageIter iter; + + if (agent == NULL) + return __ofono_error_not_found(msg); + + sender = dbus_message_get_sender(msg); + + if (dbus_message_iter_init(msg, &iter) == FALSE) + return __ofono_error_invalid_args(msg); + + dbus_message_iter_get_basic(&iter, &path); + + if (strcmp(sender, agent->owner) != 0) + return __ofono_error_not_allowed(msg); + + if (strcmp(path, agent->path) != 0) + return __ofono_error_not_found(msg); + + agent_free(agent); + agent = NULL; + + return dbus_message_new_method_return(msg); } static const GDBusMethodTable am_methods[] = { -- cgit v1.2.3