diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2013-02-20 18:55:46 -0300 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2013-02-20 21:22:17 -0600 |
commit | 16246e120e9c856999e46b2c1961c1f278835063 (patch) | |
tree | 5c82fdc5b5544c3d9440e3e110047046cbea060d /src | |
parent | 55a9b0411ea8e4cb4d98ab00d72dfbdd9ce5892d (diff) | |
download | ofono-16246e120e9c856999e46b2c1961c1f278835063.tar.bz2 |
handsfree-audio: Add Agent "Register" method
This patch adds the initial Handsfree Audio Manager "Register"
method implementation. It adds the parsing of the arguments included
in the message and checks if there is an agent registered already.
Diffstat (limited to 'src')
-rw-r--r-- | src/handsfree-audio.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c index e75c9774..ee67f05e 100644 --- a/src/handsfree-audio.c +++ b/src/handsfree-audio.c @@ -32,6 +32,15 @@ #define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager" +struct agent { + char *owner; + char *path; + unsigned char *codecs; + int codecs_len; +}; + +static struct agent *agent = NULL; + static DBusMessage *am_get_cards(DBusConnection *conn, DBusMessage *msg, void *user_data) { @@ -41,7 +50,35 @@ static DBusMessage *am_get_cards(DBusConnection *conn, static DBusMessage *am_agent_register(DBusConnection *conn, DBusMessage *msg, void *user_data) { - return __ofono_error_not_implemented(msg); + const char *sender, *path; + unsigned char *codecs; + DBusMessageIter iter, array; + int length; + + if (agent) + return __ofono_error_in_use(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); + + dbus_message_iter_next(&iter); + dbus_message_iter_recurse(&iter, &array); + dbus_message_iter_get_fixed_array(&array, &codecs, &length); + + if (length == 0) + return __ofono_error_invalid_args(msg); + + agent = g_new0(struct agent, 1); + agent->owner = g_strdup(sender); + agent->path = g_strdup(path); + agent->codecs = g_memdup(codecs, length); + agent->codecs_len = length; + + return dbus_message_new_method_return(msg); } static DBusMessage *am_agent_unregister(DBusConnection *conn, |