summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2013-02-20 18:55:50 -0300
committerDenis Kenzior <denkenz@gmail.com>2013-02-20 21:25:38 -0600
commit19f50c6a3ba4ba4c3cb6d8da6724ec0d2f2062c9 (patch)
treed3436ed5d4405427c3bf51709aa7923998f1375b
parenta76e4d71f5b3f7906bc3bd573f4db3dc7e152873 (diff)
downloadofono-19f50c6a3ba4ba4c3cb6d8da6724ec0d2f2062c9.tar.bz2
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.
-rw-r--r--src/handsfree-audio.c25
1 files changed, 24 insertions, 1 deletions
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 <errno.h>
#include <stdio.h>
+#include <string.h>
#include <gdbus.h>
@@ -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[] = {