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(-)
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index 07dbda0..2635d76 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -25,6 +25,7 @@
#include <errno.h>
#include <stdio.h>
+#include <string.h>
#include <gdbus.h>
@@ -115,7 +116,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[] = {
--
1.7.11.7
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono