* [PATCH v0 01/11] hfp_audio: Adds initial plugin files
2013-02-19 20:44 [PATCH v0 00/11] Initial support for Handsfree Audio Manager Claudio Takahasi
@ 2013-02-19 20:44 ` Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 02/11] ofono: Add option for experimental interfaces Claudio Takahasi
` (10 subsequent siblings)
11 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-19 20:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1996 bytes --]
This patch adds a plugin related to a new experimental Handsfree Audio
interface. HF and AG will expose Handsfree Audio Cards to a Handfree
Audio Agent.
---
Makefile.am | 3 +++
plugins/hfp_audio.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
create mode 100644 plugins/hfp_audio.c
diff --git a/Makefile.am b/Makefile.am
index ef4d314..8fc6dca 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -434,6 +434,9 @@ builtin_sources += $(btio_sources)
builtin_cflags += @BLUEZ_CFLAGS@
builtin_libadd += @BLUEZ_LIBS@
else
+builtin_modules += hfp_audio
+builtin_sources += plugins/hfp_audio.c
+
builtin_modules += bluez5
builtin_sources += plugins/bluez5.c plugins/bluez5.h
diff --git a/plugins/hfp_audio.c b/plugins/hfp_audio.c
new file mode 100644
index 0000000..e90d35b
--- /dev/null
+++ b/plugins/hfp_audio.c
@@ -0,0 +1,32 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+
+OFONO_PLUGIN_DEFINE(hfp_audio, "Handsfree Audio Plugin", VERSION,
+ OFONO_PLUGIN_PRIORITY_DEFAULT, NULL, NULL)
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v0 02/11] ofono: Add option for experimental interfaces
2013-02-19 20:44 [PATCH v0 00/11] Initial support for Handsfree Audio Manager Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 01/11] hfp_audio: Adds initial plugin files Claudio Takahasi
@ 2013-02-19 20:44 ` Claudio Takahasi
2013-02-20 0:20 ` Denis Kenzior
2013-02-19 20:44 ` [PATCH v0 03/11] dbus: Move oFono error define to dbus.h Claudio Takahasi
` (9 subsequent siblings)
11 siblings, 1 reply; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-19 20:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1647 bytes --]
This patch adds a command line option for enabling experimental D-Bus
interfaces. --experimental/-E enables experimental interfaces.
---
src/main.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/main.c b/src/main.c
index 46bb90b..1e99b13 100644
--- a/src/main.c
+++ b/src/main.c
@@ -133,6 +133,7 @@ static gchar *option_plugin = NULL;
static gchar *option_noplugin = NULL;
static gboolean option_detach = TRUE;
static gboolean option_version = FALSE;
+static gboolean option_experimental = FALSE;
static gboolean parse_debug(const char *key, const char *value,
gpointer user_data, GError **error)
@@ -153,6 +154,8 @@ static GOptionEntry options[] = {
"Specify plugins to load", "NAME,..," },
{ "noplugin", 'P', 0, G_OPTION_ARG_STRING, &option_noplugin,
"Specify plugins not to load", "NAME,..." },
+ { "experimental", 'E', 0, G_OPTION_ARG_NONE, &option_experimental,
+ "Enable experimental interfaces" },
{ "nodetach", 'n', G_OPTION_FLAG_REVERSE,
G_OPTION_ARG_NONE, &option_detach,
"Don't run as daemon in background" },
@@ -168,6 +171,7 @@ int main(int argc, char **argv)
DBusConnection *conn;
DBusError error;
guint signal;
+ int gdbus_flags = 0;
#ifdef NEED_THREADS
if (g_thread_supported() == FALSE)
@@ -233,6 +237,11 @@ int main(int argc, char **argv)
g_dbus_set_disconnect_function(conn, system_bus_disconnected,
NULL, NULL);
+ if (option_experimental)
+ gdbus_flags = G_DBUS_FLAG_ENABLE_EXPERIMENTAL;
+
+ g_dbus_set_flags(gdbus_flags);
+
__ofono_dbus_init(conn);
__ofono_modemwatch_init();
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH v0 02/11] ofono: Add option for experimental interfaces
2013-02-19 20:44 ` [PATCH v0 02/11] ofono: Add option for experimental interfaces Claudio Takahasi
@ 2013-02-20 0:20 ` Denis Kenzior
2013-02-20 14:52 ` Claudio Takahasi
0 siblings, 1 reply; 28+ messages in thread
From: Denis Kenzior @ 2013-02-20 0:20 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 395 bytes --]
Hi Claudio,
On 02/19/2013 02:44 PM, Claudio Takahasi wrote:
> This patch adds a command line option for enabling experimental D-Bus
> interfaces. --experimental/-E enables experimental interfaces.
> ---
> src/main.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
Please drop this patch, there is no need. Interfaces labeled
experimental are just that.
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v0 02/11] ofono: Add option for experimental interfaces
2013-02-20 0:20 ` Denis Kenzior
@ 2013-02-20 14:52 ` Claudio Takahasi
0 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-20 14:52 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 648 bytes --]
Hi Denis:
On Tue, Feb 19, 2013 at 9:20 PM, Denis Kenzior <denkenz@gmail.com> wrote:
> Hi Claudio,
>
>
> On 02/19/2013 02:44 PM, Claudio Takahasi wrote:
>>
>> This patch adds a command line option for enabling experimental D-Bus
>> interfaces. --experimental/-E enables experimental interfaces.
>> ---
>> src/main.c | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>
> Please drop this patch, there is no need. Interfaces labeled experimental
> are just that.
>
> Regards,
> -Denis
ok. I will remove it.
I thought it was a standard procedure to not expose by default
experimental interfaces.
Regards,
Claudio
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v0 03/11] dbus: Move oFono error define to dbus.h
2013-02-19 20:44 [PATCH v0 00/11] Initial support for Handsfree Audio Manager Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 01/11] hfp_audio: Adds initial plugin files Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 02/11] ofono: Add option for experimental interfaces Claudio Takahasi
@ 2013-02-19 20:44 ` Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 04/11] hfp_audio: Add initial manager methods declaration Claudio Takahasi
` (8 subsequent siblings)
11 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-19 20:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 802 bytes --]
---
include/dbus.h | 1 +
src/dbus.c | 2 --
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/dbus.h b/include/dbus.h
index 44faa7f..8208125 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -29,6 +29,7 @@ extern "C" {
#include <dbus/dbus.h>
#define OFONO_SERVICE "org.ofono"
+#define OFONO_ERROR_INTERFACE "org.ofono.Error"
#define OFONO_MANAGER_INTERFACE "org.ofono.Manager"
#define OFONO_MANAGER_PATH "/"
#define OFONO_MODEM_INTERFACE "org.ofono.Modem"
diff --git a/src/dbus.c b/src/dbus.c
index 1558a51..c705b67 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -28,8 +28,6 @@
#include "ofono.h"
-#define OFONO_ERROR_INTERFACE "org.ofono.Error"
-
static DBusConnection *g_connection;
struct error_mapping_entry {
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v0 04/11] hfp_audio: Add initial manager methods declaration
2013-02-19 20:44 [PATCH v0 00/11] Initial support for Handsfree Audio Manager Claudio Takahasi
` (2 preceding siblings ...)
2013-02-19 20:44 ` [PATCH v0 03/11] dbus: Move oFono error define to dbus.h Claudio Takahasi
@ 2013-02-19 20:44 ` Claudio Takahasi
2013-02-20 0:44 ` Denis Kenzior
2013-02-19 20:44 ` [PATCH v0 05/11] hfp_audio: Add "Register" agent arguments parsing Claudio Takahasi
` (7 subsequent siblings)
11 siblings, 1 reply; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-19 20:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2456 bytes --]
This patch adds the initial Handsfree Audio Manager D-Bus methods
declaration.
---
plugins/hfp_audio.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 63 insertions(+), 1 deletion(-)
diff --git a/plugins/hfp_audio.c b/plugins/hfp_audio.c
index e90d35b..e3646e5 100644
--- a/plugins/hfp_audio.c
+++ b/plugins/hfp_audio.c
@@ -23,10 +23,72 @@
#include <config.h>
#endif
+#include <errno.h>
#include <stdio.h>
+#include <gdbus.h>
+
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
+#include <ofono/dbus.h>
+#include <ofono/log.h>
+
+#define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager"
+
+static DBusMessage *am_get_cards(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ return g_dbus_create_error(msg, OFONO_ERROR_INTERFACE
+ ".NotImplemented",
+ "Implementation not provided");
+}
+
+static DBusMessage *am_agent_register(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ return g_dbus_create_error(msg, OFONO_ERROR_INTERFACE
+ ".NotImplemented",
+ "Implementation not provided");
+}
+
+static DBusMessage *am_agent_unregister(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ return g_dbus_create_error(msg, OFONO_ERROR_INTERFACE
+ ".NotImplemented",
+ "Implementation not provided");
+}
+
+static const GDBusMethodTable am_methods[] = {
+ { GDBUS_EXPERIMENTAL_METHOD("GetCards",
+ NULL, GDBUS_ARGS({"cards", "a{oa{sv}}"}),
+ am_get_cards) } ,
+ { GDBUS_EXPERIMENTAL_METHOD("Register",
+ GDBUS_ARGS({"path", "o"}, {"codecs", "ay"}), NULL,
+ am_agent_register) },
+ { GDBUS_EXPERIMENTAL_METHOD("Unregister",
+ GDBUS_ARGS({"path", "o"}), NULL,
+ am_agent_unregister) },
+ { }
+};
+
+static int hfp_audio_init(void)
+{
+ if (!g_dbus_register_interface(ofono_dbus_get_connection(),
+ "/", HFP_AUDIO_MANAGER_INTERFACE,
+ am_methods, NULL, NULL, NULL, NULL)) {
+ ofono_error("Register Handsfree Audio Manager failed");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static void hfp_audio_exit(void)
+{
+ g_dbus_unregister_interface(ofono_dbus_get_connection(), "/",
+ HFP_AUDIO_MANAGER_INTERFACE);
+}
OFONO_PLUGIN_DEFINE(hfp_audio, "Handsfree Audio Plugin", VERSION,
- OFONO_PLUGIN_PRIORITY_DEFAULT, NULL, NULL)
+ OFONO_PLUGIN_PRIORITY_DEFAULT, hfp_audio_init, hfp_audio_exit)
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH v0 04/11] hfp_audio: Add initial manager methods declaration
2013-02-19 20:44 ` [PATCH v0 04/11] hfp_audio: Add initial manager methods declaration Claudio Takahasi
@ 2013-02-20 0:44 ` Denis Kenzior
2013-02-20 14:55 ` Claudio Takahasi
0 siblings, 1 reply; 28+ messages in thread
From: Denis Kenzior @ 2013-02-20 0:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 427 bytes --]
Hi Claudio,
On 02/19/2013 02:44 PM, Claudio Takahasi wrote:
> This patch adds the initial Handsfree Audio Manager D-Bus methods
> declaration.
> ---
> plugins/hfp_audio.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 63 insertions(+), 1 deletion(-)
>
Actually I'd like this to move into the core (e.g. src/) directory. It
should look similar to manager.c.
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v0 04/11] hfp_audio: Add initial manager methods declaration
2013-02-20 0:44 ` Denis Kenzior
@ 2013-02-20 14:55 ` Claudio Takahasi
0 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-20 14:55 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1030 bytes --]
Hi Denis:
On Tue, Feb 19, 2013 at 9:44 PM, Denis Kenzior <denkenz@gmail.com> wrote:
> Hi Claudio,
>
>
> On 02/19/2013 02:44 PM, Claudio Takahasi wrote:
>>
>> This patch adds the initial Handsfree Audio Manager D-Bus methods
>> declaration.
>> ---
>> plugins/hfp_audio.c | 64
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 63 insertions(+), 1 deletion(-)
>>
>
> Actually I'd like this to move into the core (e.g. src/) directory. It
> should look similar to manager.c.
>
> Regards,
> -Denis
Ok. I will move the Handsfree Audio Manager to src/handfree-audio.c
Another alternative is to put Audio Manager and Audio Cards inside the
existent src/handsfree.c
It is becoming a little bit confusing since there is a file
src/handsfree.c and include/handsfree.h
In the next patches we will need to add a function to create the Audio
Cards. For HF, we could hide the registration inside
ofono_handsfree_create, but this approach will not fit for AG.
Regards,
Claudio
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v0 05/11] hfp_audio: Add "Register" agent arguments parsing
2013-02-19 20:44 [PATCH v0 00/11] Initial support for Handsfree Audio Manager Claudio Takahasi
` (3 preceding siblings ...)
2013-02-19 20:44 ` [PATCH v0 04/11] hfp_audio: Add initial manager methods declaration Claudio Takahasi
@ 2013-02-19 20:44 ` Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 06/11] hfp_audio: Add codec array validation Claudio Takahasi
` (6 subsequent siblings)
11 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-19 20:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1369 bytes --]
This patch adds the D-Bus parsing of the arguments included in the
"Register" method of the Handsfree Audio Manager method.
---
plugins/hfp_audio.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/plugins/hfp_audio.c b/plugins/hfp_audio.c
index e3646e5..7b334e2 100644
--- a/plugins/hfp_audio.c
+++ b/plugins/hfp_audio.c
@@ -46,9 +46,28 @@ static DBusMessage *am_get_cards(DBusConnection *conn,
static DBusMessage *am_agent_register(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
- return g_dbus_create_error(msg, OFONO_ERROR_INTERFACE
- ".NotImplemented",
- "Implementation not provided");
+ const char *path;
+ unsigned char *codecs;
+ DBusMessageIter iter, array;
+ int length;
+
+ if (dbus_message_iter_init(msg, &iter) == FALSE)
+ goto invalid_args;
+
+ 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)
+ goto invalid_args;
+
+ return dbus_message_new_method_return(msg);
+
+invalid_args:
+ return g_dbus_create_error(msg, OFONO_ERROR_INTERFACE ".Rejected",
+ "Invalid arguments in method call");
}
static DBusMessage *am_agent_unregister(DBusConnection *conn,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v0 06/11] hfp_audio: Add codec array validation
2013-02-19 20:44 [PATCH v0 00/11] Initial support for Handsfree Audio Manager Claudio Takahasi
` (4 preceding siblings ...)
2013-02-19 20:44 ` [PATCH v0 05/11] hfp_audio: Add "Register" agent arguments parsing Claudio Takahasi
@ 2013-02-19 20:44 ` Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 07/11] hfp_audio: Add repeated Agent registration verification Claudio Takahasi
` (5 subsequent siblings)
11 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-19 20:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1337 bytes --]
From: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
This patch checks if the codec array included in the "Register" method
contains valid codec ID's.
---
plugins/hfp_audio.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/plugins/hfp_audio.c b/plugins/hfp_audio.c
index 7b334e2..db21a5d 100644
--- a/plugins/hfp_audio.c
+++ b/plugins/hfp_audio.c
@@ -35,6 +35,12 @@
#define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager"
+/* Supported agents codecs */
+enum hfp_codec {
+ HFP_CODEC_CVSD = 0x01,
+ HFP_CODEC_MSBC = 0x02,
+};
+
static DBusMessage *am_get_cards(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -49,7 +55,7 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
const char *path;
unsigned char *codecs;
DBusMessageIter iter, array;
- int length;
+ int length, i;
if (dbus_message_iter_init(msg, &iter) == FALSE)
goto invalid_args;
@@ -63,6 +69,12 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
if (length == 0)
goto invalid_args;
+ for (i = 0; i < length; i++) {
+ if (codecs[i] != HFP_CODEC_CVSD &&
+ codecs[i] != HFP_CODEC_MSBC)
+ goto invalid_args;
+ }
+
return dbus_message_new_method_return(msg);
invalid_args:
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v0 07/11] hfp_audio: Add repeated Agent registration verification
2013-02-19 20:44 [PATCH v0 00/11] Initial support for Handsfree Audio Manager Claudio Takahasi
` (5 preceding siblings ...)
2013-02-19 20:44 ` [PATCH v0 06/11] hfp_audio: Add codec array validation Claudio Takahasi
@ 2013-02-19 20:44 ` Claudio Takahasi
2013-02-20 0:39 ` Denis Kenzior
2013-02-19 20:44 ` [PATCH v0 08/11] hfp_audio: Free agents when exiting Claudio Takahasi
` (4 subsequent siblings)
11 siblings, 1 reply; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-19 20:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2332 bytes --]
From: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
This patch checks if the Handsfree Audio Manager already has an agent
registered for the same owner and object path.
---
plugins/hfp_audio.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/plugins/hfp_audio.c b/plugins/hfp_audio.c
index db21a5d..32ddebc 100644
--- a/plugins/hfp_audio.c
+++ b/plugins/hfp_audio.c
@@ -25,6 +25,7 @@
#include <errno.h>
#include <stdio.h>
+#include <string.h>
#include <gdbus.h>
@@ -35,12 +36,34 @@
#define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager"
+struct agent {
+ char *owner;
+ char *path;
+ unsigned char *codecs;
+ int codecs_len;
+};
+
/* Supported agents codecs */
enum hfp_codec {
HFP_CODEC_CVSD = 0x01,
HFP_CODEC_MSBC = 0x02,
};
+static GSList *agents = NULL;
+
+static int agent_cmp(gconstpointer a, gconstpointer b)
+{
+ const struct agent *agent = a;
+ const struct agent *match = b;
+ int ret;
+
+ ret = strcmp(agent->owner, match->owner);
+ if (ret != 0)
+ return ret;
+
+ return strcmp(agent->path, match->path);
+}
+
static DBusMessage *am_get_cards(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -52,11 +75,14 @@ static DBusMessage *am_get_cards(DBusConnection *conn,
static DBusMessage *am_agent_register(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
- const char *path;
+ struct agent match, *agent;
+ const char *sender, *path;
unsigned char *codecs;
DBusMessageIter iter, array;
int length, i;
+ sender = dbus_message_get_sender(msg);
+
if (dbus_message_iter_init(msg, &iter) == FALSE)
goto invalid_args;
@@ -75,6 +101,19 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
goto invalid_args;
}
+ match.owner = (char *) sender;
+ match.path = (char *) path;
+ if (g_slist_find_custom(agents, &match, agent_cmp))
+ goto invalid_args;
+
+ 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;
+
+ agents = g_slist_prepend(agents, agent);
+
return dbus_message_new_method_return(msg);
invalid_args:
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH v0 07/11] hfp_audio: Add repeated Agent registration verification
2013-02-19 20:44 ` [PATCH v0 07/11] hfp_audio: Add repeated Agent registration verification Claudio Takahasi
@ 2013-02-20 0:39 ` Denis Kenzior
2013-02-20 14:53 ` Claudio Takahasi
0 siblings, 1 reply; 28+ messages in thread
From: Denis Kenzior @ 2013-02-20 0:39 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2726 bytes --]
Hi Claudio / Vinicius,
On 02/19/2013 02:44 PM, Claudio Takahasi wrote:
> From: Vinicius Costa Gomes<vinicius.gomes@openbossa.org>
>
> This patch checks if the Handsfree Audio Manager already has an agent
> registered for the same owner and object path.
> ---
> plugins/hfp_audio.c | 41 ++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 40 insertions(+), 1 deletion(-)
>
> diff --git a/plugins/hfp_audio.c b/plugins/hfp_audio.c
> index db21a5d..32ddebc 100644
> --- a/plugins/hfp_audio.c
> +++ b/plugins/hfp_audio.c
> @@ -25,6 +25,7 @@
>
> #include<errno.h>
> #include<stdio.h>
> +#include<string.h>
>
> #include<gdbus.h>
>
> @@ -35,12 +36,34 @@
>
> #define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager"
>
> +struct agent {
> + char *owner;
> + char *path;
> + unsigned char *codecs;
> + int codecs_len;
> +};
> +
> /* Supported agents codecs */
> enum hfp_codec {
> HFP_CODEC_CVSD = 0x01,
> HFP_CODEC_MSBC = 0x02,
> };
>
> +static GSList *agents = NULL;
> +
> +static int agent_cmp(gconstpointer a, gconstpointer b)
> +{
> + const struct agent *agent = a;
> + const struct agent *match = b;
> + int ret;
> +
> + ret = strcmp(agent->owner, match->owner);
> + if (ret != 0)
> + return ret;
> +
> + return strcmp(agent->path, match->path);
> +}
> +
> static DBusMessage *am_get_cards(DBusConnection *conn,
> DBusMessage *msg, void *user_data)
> {
> @@ -52,11 +75,14 @@ static DBusMessage *am_get_cards(DBusConnection *conn,
> static DBusMessage *am_agent_register(DBusConnection *conn,
> DBusMessage *msg, void *user_data)
> {
> - const char *path;
> + struct agent match, *agent;
> + const char *sender, *path;
> unsigned char *codecs;
> DBusMessageIter iter, array;
> int length, i;
>
> + sender = dbus_message_get_sender(msg);
> +
> if (dbus_message_iter_init(msg,&iter) == FALSE)
> goto invalid_args;
>
> @@ -75,6 +101,19 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
> goto invalid_args;
> }
>
> + match.owner = (char *) sender;
> + match.path = (char *) path;
> + if (g_slist_find_custom(agents,&match, agent_cmp))
> + goto invalid_args;
> +
> + 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;
> +
> + agents = g_slist_prepend(agents, agent);
> +
How do you plan on using multiple agents? Unless there is dire need, I
suggest only allowing 1 agent to be registered at a time.
> return dbus_message_new_method_return(msg);
>
> invalid_args:
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH v0 07/11] hfp_audio: Add repeated Agent registration verification
2013-02-20 0:39 ` Denis Kenzior
@ 2013-02-20 14:53 ` Claudio Takahasi
0 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-20 14:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3366 bytes --]
Hi Denis:
On Tue, Feb 19, 2013 at 9:39 PM, Denis Kenzior <denkenz@gmail.com> wrote:
> Hi Claudio / Vinicius,
>
>
> On 02/19/2013 02:44 PM, Claudio Takahasi wrote:
>>
>> From: Vinicius Costa Gomes<vinicius.gomes@openbossa.org>
>>
>> This patch checks if the Handsfree Audio Manager already has an agent
>> registered for the same owner and object path.
>> ---
>> plugins/hfp_audio.c | 41 ++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 40 insertions(+), 1 deletion(-)
>>
>> diff --git a/plugins/hfp_audio.c b/plugins/hfp_audio.c
>> index db21a5d..32ddebc 100644
>> --- a/plugins/hfp_audio.c
>> +++ b/plugins/hfp_audio.c
>> @@ -25,6 +25,7 @@
>>
>> #include<errno.h>
>> #include<stdio.h>
>> +#include<string.h>
>>
>> #include<gdbus.h>
>>
>> @@ -35,12 +36,34 @@
>>
>> #define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE
>> ".HandsfreeAudioManager"
>>
>> +struct agent {
>> + char *owner;
>> + char *path;
>> + unsigned char *codecs;
>> + int codecs_len;
>> +};
>> +
>> /* Supported agents codecs */
>> enum hfp_codec {
>> HFP_CODEC_CVSD = 0x01,
>> HFP_CODEC_MSBC = 0x02,
>> };
>>
>> +static GSList *agents = NULL;
>> +
>> +static int agent_cmp(gconstpointer a, gconstpointer b)
>> +{
>> + const struct agent *agent = a;
>> + const struct agent *match = b;
>> + int ret;
>> +
>> + ret = strcmp(agent->owner, match->owner);
>> + if (ret != 0)
>> + return ret;
>> +
>> + return strcmp(agent->path, match->path);
>> +}
>> +
>> static DBusMessage *am_get_cards(DBusConnection *conn,
>> DBusMessage *msg, void *user_data)
>> {
>> @@ -52,11 +75,14 @@ static DBusMessage *am_get_cards(DBusConnection *conn,
>> static DBusMessage *am_agent_register(DBusConnection *conn,
>> DBusMessage *msg, void *user_data)
>> {
>> - const char *path;
>> + struct agent match, *agent;
>> + const char *sender, *path;
>> unsigned char *codecs;
>> DBusMessageIter iter, array;
>> int length, i;
>>
>> + sender = dbus_message_get_sender(msg);
>> +
>> if (dbus_message_iter_init(msg,&iter) == FALSE)
>>
>> goto invalid_args;
>>
>> @@ -75,6 +101,19 @@ static DBusMessage *am_agent_register(DBusConnection
>> *conn,
>> goto invalid_args;
>> }
>>
>> + match.owner = (char *) sender;
>> + match.path = (char *) path;
>> + if (g_slist_find_custom(agents,&match, agent_cmp))
>>
>> + goto invalid_args;
>> +
>> + 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;
>> +
>> + agents = g_slist_prepend(agents, agent);
>> +
>
>
> How do you plan on using multiple agents? Unless there is dire need, I
> suggest only allowing 1 agent to be registered at a time.
I will remove this multiple agents support. We suggested this approach
to allow agents registration from different sources or modules.
Anyway, we can extend it later since it is experimental.
Regards,
Claudio
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v0 08/11] hfp_audio: Free agents when exiting
2013-02-19 20:44 [PATCH v0 00/11] Initial support for Handsfree Audio Manager Claudio Takahasi
` (6 preceding siblings ...)
2013-02-19 20:44 ` [PATCH v0 07/11] hfp_audio: Add repeated Agent registration verification Claudio Takahasi
@ 2013-02-19 20:44 ` Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 09/11] hfp_audio: Call Agent "Release" " Claudio Takahasi
` (3 subsequent siblings)
11 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-19 20:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 931 bytes --]
Free agents allocated resources when hfp_audio plugin exits.
---
plugins/hfp_audio.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/plugins/hfp_audio.c b/plugins/hfp_audio.c
index 32ddebc..ffc3138 100644
--- a/plugins/hfp_audio.c
+++ b/plugins/hfp_audio.c
@@ -51,6 +51,16 @@ enum hfp_codec {
static GSList *agents = NULL;
+static void agent_free(gpointer data)
+{
+ struct agent *agent = data;
+
+ g_free(agent->owner);
+ g_free(agent->path);
+ g_free(agent->codecs);
+ g_free(agent);
+}
+
static int agent_cmp(gconstpointer a, gconstpointer b)
{
const struct agent *agent = a;
@@ -158,6 +168,8 @@ static void hfp_audio_exit(void)
{
g_dbus_unregister_interface(ofono_dbus_get_connection(), "/",
HFP_AUDIO_MANAGER_INTERFACE);
+
+ g_slist_free_full(agents, agent_free);
}
OFONO_PLUGIN_DEFINE(hfp_audio, "Handsfree Audio Plugin", VERSION,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v0 09/11] hfp_audio: Call Agent "Release" when exiting
2013-02-19 20:44 [PATCH v0 00/11] Initial support for Handsfree Audio Manager Claudio Takahasi
` (7 preceding siblings ...)
2013-02-19 20:44 ` [PATCH v0 08/11] hfp_audio: Free agents when exiting Claudio Takahasi
@ 2013-02-19 20:44 ` Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 10/11] hfp_audio: Add Agent "Unregister" Claudio Takahasi
` (2 subsequent siblings)
11 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-19 20:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]
This patch notifies the Agent implementation that it is no longer
registered to the service daemon.
---
plugins/hfp_audio.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/plugins/hfp_audio.c b/plugins/hfp_audio.c
index ffc3138..a8e365c 100644
--- a/plugins/hfp_audio.c
+++ b/plugins/hfp_audio.c
@@ -35,6 +35,7 @@
#include <ofono/log.h>
#define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager"
+#define HFP_AUDIO_AGENT_INTERFACE OFONO_SERVICE ".HandsfreeAudioAgent"
struct agent {
char *owner;
@@ -74,6 +75,17 @@ static int agent_cmp(gconstpointer a, gconstpointer b)
return strcmp(agent->path, match->path);
}
+static void agent_release(gpointer data, gpointer user_data)
+{
+ struct agent *agent = data;
+ DBusMessage *msg;
+
+ msg = dbus_message_new_method_call(agent->owner, agent->path,
+ HFP_AUDIO_AGENT_INTERFACE, "Release");
+
+ g_dbus_send_message(ofono_dbus_get_connection(), msg);
+}
+
static DBusMessage *am_get_cards(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -169,6 +181,7 @@ static void hfp_audio_exit(void)
g_dbus_unregister_interface(ofono_dbus_get_connection(), "/",
HFP_AUDIO_MANAGER_INTERFACE);
+ g_slist_foreach(agents, agent_release, NULL);
g_slist_free_full(agents, agent_free);
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v0 10/11] hfp_audio: Add Agent "Unregister"
2013-02-19 20:44 [PATCH v0 00/11] Initial support for Handsfree Audio Manager Claudio Takahasi
` (8 preceding siblings ...)
2013-02-19 20:44 ` [PATCH v0 09/11] hfp_audio: Call Agent "Release" " Claudio Takahasi
@ 2013-02-19 20:44 ` Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 11/11] hfp_audio: Add Agent tracking Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 0/7] Initial support for Handsfree Audio Manager Claudio Takahasi
11 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-19 20:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]
This patch implements the "Unregister" method of the Handsfree Audio
Manager. The agent is unregistered if sender and path match.
---
plugins/hfp_audio.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/plugins/hfp_audio.c b/plugins/hfp_audio.c
index a8e365c..f46d739 100644
--- a/plugins/hfp_audio.c
+++ b/plugins/hfp_audio.c
@@ -146,9 +146,33 @@ invalid_args:
static DBusMessage *am_agent_unregister(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
- return g_dbus_create_error(msg, OFONO_ERROR_INTERFACE
- ".NotImplemented",
- "Implementation not provided");
+ GSList *list;
+ const char *sender, *path;
+ struct agent match, *agent;
+ DBusMessageIter iter;
+
+ sender = dbus_message_get_sender(msg);
+
+ if (dbus_message_iter_init(msg, &iter) == FALSE)
+ goto invalid_args;
+
+ dbus_message_iter_get_basic(&iter, &path);
+
+ match.owner = (char *) sender;
+ match.path = (char *) path;
+ list = g_slist_find_custom(agents, &match, agent_cmp);
+ if (list == NULL)
+ goto invalid_args;
+
+ agent = list->data;
+ agents = g_slist_remove(agents, agent);
+ agent_free(agent);
+
+ return dbus_message_new_method_return(msg);
+
+invalid_args:
+ return g_dbus_create_error(msg, OFONO_ERROR_INTERFACE ".Rejected",
+ "Invalid arguments in method call");
}
static const GDBusMethodTable am_methods[] = {
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v0 11/11] hfp_audio: Add Agent tracking
2013-02-19 20:44 [PATCH v0 00/11] Initial support for Handsfree Audio Manager Claudio Takahasi
` (9 preceding siblings ...)
2013-02-19 20:44 ` [PATCH v0 10/11] hfp_audio: Add Agent "Unregister" Claudio Takahasi
@ 2013-02-19 20:44 ` Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 0/7] Initial support for Handsfree Audio Manager Claudio Takahasi
11 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-19 20:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1594 bytes --]
This patch tracks when the Handsfree Audio Agent leaves the system BUS,
and free agent allocated resources.
---
plugins/hfp_audio.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/plugins/hfp_audio.c b/plugins/hfp_audio.c
index f46d739..a553afa 100644
--- a/plugins/hfp_audio.c
+++ b/plugins/hfp_audio.c
@@ -42,6 +42,7 @@ struct agent {
char *path;
unsigned char *codecs;
int codecs_len;
+ guint watch;
};
/* Supported agents codecs */
@@ -56,6 +57,9 @@ static void agent_free(gpointer data)
{
struct agent *agent = data;
+ if (agent->watch > 0)
+ g_dbus_remove_watch(ofono_dbus_get_connection(), agent->watch);
+
g_free(agent->owner);
g_free(agent->path);
g_free(agent->codecs);
@@ -86,6 +90,16 @@ static void agent_release(gpointer data, gpointer user_data)
g_dbus_send_message(ofono_dbus_get_connection(), msg);
}
+static void agent_disconnect(DBusConnection *conn, void *user_data)
+{
+ struct agent *agent = user_data;
+
+ DBG("Agent %s disconnected", agent->owner);
+
+ agents = g_slist_remove(agents, agent);
+ agent_free(agent);
+}
+
static DBusMessage *am_get_cards(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -133,6 +147,8 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
agent->path = g_strdup(path);
agent->codecs = g_memdup(codecs, length);
agent->codecs_len = length;
+ agent->watch = g_dbus_add_disconnect_watch(conn, sender,
+ agent_disconnect, agent, NULL);
agents = g_slist_prepend(agents, agent);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v1 0/7] Initial support for Handsfree Audio Manager
2013-02-19 20:44 [PATCH v0 00/11] Initial support for Handsfree Audio Manager Claudio Takahasi
` (10 preceding siblings ...)
2013-02-19 20:44 ` [PATCH v0 11/11] hfp_audio: Add Agent tracking Claudio Takahasi
@ 2013-02-20 21:55 ` Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 1/7] handsfree-audio: Add Manager registration Claudio Takahasi
` (7 more replies)
11 siblings, 8 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-20 21:55 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1026 bytes --]
The following patches implement the initial functionality of the experimental
Handsfree Audio Manager interface defined in doc/handsfree-audio-api.txt
This series adds the Register and Unregister methods.
Changess between v0-v1:
* removed multiple agents support
* removed experimental command line option
* moved Handsfree Audio Manager to src/
Claudio Takahasi (6):
handsfree-audio: Add Manager registration
handsfree-audio: Add Agent "Register" method
handsfree-audio: Free agent when exiting
handsfree-audio: Call Agent "Release" when exiting
handsfree-audio: Add Agent "Unregister"
handsfree-audio: Add Agent tracking
Vinicius Costa Gomes (1):
handsfree-audio: Add codec array validation
Makefile.am | 3 +-
src/handsfree-audio.c | 191 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/main.c | 4 ++
src/ofono.h | 3 +
4 files changed, 200 insertions(+), 1 deletion(-)
create mode 100644 src/handsfree-audio.c
--
1.7.11.7
^ permalink raw reply [flat|nested] 28+ messages in thread* [PATCH v1 1/7] handsfree-audio: Add Manager registration
2013-02-20 21:55 ` [PATCH v1 0/7] Initial support for Handsfree Audio Manager Claudio Takahasi
@ 2013-02-20 21:55 ` Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 2/7] handsfree-audio: Add Agent "Register" method Claudio Takahasi
` (6 subsequent siblings)
7 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-20 21:55 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4413 bytes --]
Adds the initial implementation of new experimental Handsfree Audio
Manager interface. This patch adds the interface registration and
the declaration of it's methods.
---
Makefile.am | 3 +-
src/handsfree-audio.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/main.c | 4 +++
src/ofono.h | 3 ++
4 files changed, 90 insertions(+), 1 deletion(-)
create mode 100644 src/handsfree-audio.c
diff --git a/Makefile.am b/Makefile.am
index ef4d314..76d33b4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -507,7 +507,8 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \
src/gnssagent.c src/gnssagent.h \
src/cdma-smsutil.h src/cdma-smsutil.c \
src/cdma-sms.c src/private-network.c src/cdma-netreg.c \
- src/cdma-provision.c src/handsfree.c
+ src/cdma-provision.c src/handsfree.c \
+ src/handsfree-audio.c
src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ -ldl
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
new file mode 100644
index 0000000..e75c977
--- /dev/null
+++ b/src/handsfree-audio.c
@@ -0,0 +1,81 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+
+#include <gdbus.h>
+
+#include "ofono.h"
+
+#define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager"
+
+static DBusMessage *am_get_cards(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ return __ofono_error_not_implemented(msg);
+}
+
+static DBusMessage *am_agent_register(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ return __ofono_error_not_implemented(msg);
+}
+
+static DBusMessage *am_agent_unregister(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ return __ofono_error_not_implemented(msg);
+}
+
+static const GDBusMethodTable am_methods[] = {
+ { GDBUS_METHOD("GetCards",
+ NULL, GDBUS_ARGS({"cards", "a{oa{sv}}"}),
+ am_get_cards) } ,
+ { GDBUS_METHOD("Register",
+ GDBUS_ARGS({"path", "o"}, {"codecs", "ay"}), NULL,
+ am_agent_register) },
+ { GDBUS_METHOD("Unregister",
+ GDBUS_ARGS({"path", "o"}), NULL,
+ am_agent_unregister) },
+ { }
+};
+
+int __ofono_handsfree_audio_manager_init(void)
+{
+ if (!g_dbus_register_interface(ofono_dbus_get_connection(),
+ "/", HFP_AUDIO_MANAGER_INTERFACE,
+ am_methods, NULL, NULL, NULL, NULL)) {
+ return -EIO;
+ }
+
+ return 0;
+}
+
+void __ofono_handsfree_audio_manager_cleanup(void)
+{
+ g_dbus_unregister_interface(ofono_dbus_get_connection(), "/",
+ HFP_AUDIO_MANAGER_INTERFACE);
+}
diff --git a/src/main.c b/src/main.c
index 46bb90b..d6349cb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -239,6 +239,8 @@ int main(int argc, char **argv)
__ofono_manager_init();
+ __ofono_handsfree_audio_manager_init();
+
__ofono_plugin_init(option_plugin, option_noplugin);
g_free(option_plugin);
@@ -248,6 +250,8 @@ int main(int argc, char **argv)
__ofono_plugin_cleanup();
+ __ofono_handsfree_audio_manager_cleanup();
+
__ofono_manager_cleanup();
__ofono_modemwatch_cleanup();
diff --git a/src/ofono.h b/src/ofono.h
index 15c1dc5..8abaf1e 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -30,6 +30,9 @@ void __ofono_exit(void);
int __ofono_manager_init(void);
void __ofono_manager_cleanup(void);
+int __ofono_handsfree_audio_manager_init(void);
+void __ofono_handsfree_audio_manager_cleanup(void);
+
void __ofono_modem_shutdown(void);
#include <ofono/log.h>
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v1 2/7] handsfree-audio: Add Agent "Register" method
2013-02-20 21:55 ` [PATCH v1 0/7] Initial support for Handsfree Audio Manager Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 1/7] handsfree-audio: Add Manager registration Claudio Takahasi
@ 2013-02-20 21:55 ` Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 3/7] handsfree-audio: Add codec array validation Claudio Takahasi
` (5 subsequent siblings)
7 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-20 21:55 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1940 bytes --]
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.
---
src/handsfree-audio.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index e75c977..ee67f05 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,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v1 3/7] handsfree-audio: Add codec array validation
2013-02-20 21:55 ` [PATCH v1 0/7] Initial support for Handsfree Audio Manager Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 1/7] handsfree-audio: Add Manager registration Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 2/7] handsfree-audio: Add Agent "Register" method Claudio Takahasi
@ 2013-02-20 21:55 ` Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 4/7] handsfree-audio: Free agent when exiting Claudio Takahasi
` (4 subsequent siblings)
7 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-20 21:55 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1358 bytes --]
From: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
This patch checks if the codec array included in the "Register" method
contains valid codec ID's.
---
src/handsfree-audio.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index ee67f05..499e0de 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -32,6 +32,12 @@
#define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager"
+/* Supported agent codecs */
+enum hfp_codec {
+ HFP_CODEC_CVSD = 0x01,
+ HFP_CODEC_MSBC = 0x02,
+};
+
struct agent {
char *owner;
char *path;
@@ -53,7 +59,7 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
const char *sender, *path;
unsigned char *codecs;
DBusMessageIter iter, array;
- int length;
+ int length, i;
if (agent)
return __ofono_error_in_use(msg);
@@ -72,6 +78,12 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
if (length == 0)
return __ofono_error_invalid_args(msg);
+ for (i = 0; i < length; i++) {
+ if (codecs[i] != HFP_CODEC_CVSD &&
+ codecs[i] != HFP_CODEC_MSBC)
+ return __ofono_error_invalid_args(msg);
+ }
+
agent = g_new0(struct agent, 1);
agent->owner = g_strdup(sender);
agent->path = g_strdup(path);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v1 4/7] handsfree-audio: Free agent when exiting
2013-02-20 21:55 ` [PATCH v1 0/7] Initial support for Handsfree Audio Manager Claudio Takahasi
` (2 preceding siblings ...)
2013-02-20 21:55 ` [PATCH v1 3/7] handsfree-audio: Add codec array validation Claudio Takahasi
@ 2013-02-20 21:55 ` Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 5/7] handsfree-audio: Call Agent "Release" " Claudio Takahasi
` (3 subsequent siblings)
7 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-20 21:55 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 853 bytes --]
Free agent allocated resources when oFono exits.
---
src/handsfree-audio.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index 499e0de..28053b4 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -47,6 +47,14 @@ struct agent {
static struct agent *agent = NULL;
+static void agent_free(struct agent *agent)
+{
+ g_free(agent->owner);
+ g_free(agent->path);
+ g_free(agent->codecs);
+ g_free(agent);
+}
+
static DBusMessage *am_get_cards(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -127,4 +135,7 @@ void __ofono_handsfree_audio_manager_cleanup(void)
{
g_dbus_unregister_interface(ofono_dbus_get_connection(), "/",
HFP_AUDIO_MANAGER_INTERFACE);
+
+ if (agent)
+ agent_free(agent);
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v1 5/7] handsfree-audio: Call Agent "Release" when exiting
2013-02-20 21:55 ` [PATCH v1 0/7] Initial support for Handsfree Audio Manager Claudio Takahasi
` (3 preceding siblings ...)
2013-02-20 21:55 ` [PATCH v1 4/7] handsfree-audio: Free agent when exiting Claudio Takahasi
@ 2013-02-20 21:55 ` Claudio Takahasi
2013-02-21 3:29 ` Denis Kenzior
2013-02-20 21:55 ` [PATCH v1 6/7] handsfree-audio: Add Agent "Unregister" Claudio Takahasi
` (2 subsequent siblings)
7 siblings, 1 reply; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-20 21:55 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1332 bytes --]
This patch notifies the Agent implementation that it is no longer
registered to the service daemon.
---
src/handsfree-audio.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index 28053b4..07dbda0 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -31,6 +31,7 @@
#include "ofono.h"
#define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager"
+#define HFP_AUDIO_AGENT_INTERFACE OFONO_SERVICE ".HandsfreeAudioAgent"
/* Supported agent codecs */
enum hfp_codec {
@@ -55,6 +56,16 @@ static void agent_free(struct agent *agent)
g_free(agent);
}
+static void agent_release(struct agent *agent)
+{
+ DBusMessage *msg;
+
+ msg = dbus_message_new_method_call(agent->owner, agent->path,
+ HFP_AUDIO_AGENT_INTERFACE, "Release");
+
+ g_dbus_send_message(ofono_dbus_get_connection(), msg);
+}
+
static DBusMessage *am_get_cards(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -136,6 +147,8 @@ void __ofono_handsfree_audio_manager_cleanup(void)
g_dbus_unregister_interface(ofono_dbus_get_connection(), "/",
HFP_AUDIO_MANAGER_INTERFACE);
- if (agent)
+ if (agent) {
+ agent_release(agent);
agent_free(agent);
+ }
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH v1 5/7] handsfree-audio: Call Agent "Release" when exiting
2013-02-20 21:55 ` [PATCH v1 5/7] handsfree-audio: Call Agent "Release" " Claudio Takahasi
@ 2013-02-21 3:29 ` Denis Kenzior
0 siblings, 0 replies; 28+ messages in thread
From: Denis Kenzior @ 2013-02-21 3:29 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 733 bytes --]
Hi Claudio,
On 02/20/2013 03:55 PM, Claudio Takahasi wrote:
> This patch notifies the Agent implementation that it is no longer
> registered to the service daemon.
> ---
> src/handsfree-audio.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
<snip>
> @@ -136,6 +147,8 @@ void __ofono_handsfree_audio_manager_cleanup(void)
> g_dbus_unregister_interface(ofono_dbus_get_connection(), "/",
> HFP_AUDIO_MANAGER_INTERFACE);
>
> - if (agent)
> + if (agent) {
> + agent_release(agent);
> agent_free(agent);
> + }
> }
Please note that at this point the main loop has been stopped, so it is
unlikely for this message to ever reach the recipient.
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v1 6/7] handsfree-audio: Add Agent "Unregister"
2013-02-20 21:55 ` [PATCH v1 0/7] Initial support for Handsfree Audio Manager Claudio Takahasi
` (4 preceding siblings ...)
2013-02-20 21:55 ` [PATCH v1 5/7] handsfree-audio: Call Agent "Release" " Claudio Takahasi
@ 2013-02-20 21:55 ` Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 7/7] handsfree-audio: Add Agent tracking Claudio Takahasi
2013-02-21 3:29 ` [PATCH v1 0/7] Initial support for Handsfree Audio Manager Denis Kenzior
7 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-20 21:55 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]
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
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH v1 7/7] handsfree-audio: Add Agent tracking
2013-02-20 21:55 ` [PATCH v1 0/7] Initial support for Handsfree Audio Manager Claudio Takahasi
` (5 preceding siblings ...)
2013-02-20 21:55 ` [PATCH v1 6/7] handsfree-audio: Add Agent "Unregister" Claudio Takahasi
@ 2013-02-20 21:55 ` Claudio Takahasi
2013-02-21 3:29 ` [PATCH v1 0/7] Initial support for Handsfree Audio Manager Denis Kenzior
7 siblings, 0 replies; 28+ messages in thread
From: Claudio Takahasi @ 2013-02-20 21:55 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1491 bytes --]
This patch tracks when the Handsfree Audio Agent leaves the system BUS,
and free agent allocated resources.
---
src/handsfree-audio.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index 2635d76..f10aeb4 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -45,12 +45,16 @@ struct agent {
char *path;
unsigned char *codecs;
int codecs_len;
+ guint watch;
};
static struct agent *agent = NULL;
static void agent_free(struct agent *agent)
{
+ if (agent->watch > 0)
+ g_dbus_remove_watch(ofono_dbus_get_connection(), agent->watch);
+
g_free(agent->owner);
g_free(agent->path);
g_free(agent->codecs);
@@ -67,6 +71,14 @@ static void agent_release(struct agent *agent)
g_dbus_send_message(ofono_dbus_get_connection(), msg);
}
+static void agent_disconnect(DBusConnection *conn, void *user_data)
+{
+ DBG("Agent %s disconnected", agent->owner);
+
+ agent_free(agent);
+ agent = NULL;
+}
+
static DBusMessage *am_get_cards(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -109,6 +121,8 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
agent->path = g_strdup(path);
agent->codecs = g_memdup(codecs, length);
agent->codecs_len = length;
+ agent->watch = g_dbus_add_disconnect_watch(conn, sender,
+ agent_disconnect, NULL, NULL);
return dbus_message_new_method_return(msg);
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH v1 0/7] Initial support for Handsfree Audio Manager
2013-02-20 21:55 ` [PATCH v1 0/7] Initial support for Handsfree Audio Manager Claudio Takahasi
` (6 preceding siblings ...)
2013-02-20 21:55 ` [PATCH v1 7/7] handsfree-audio: Add Agent tracking Claudio Takahasi
@ 2013-02-21 3:29 ` Denis Kenzior
7 siblings, 0 replies; 28+ messages in thread
From: Denis Kenzior @ 2013-02-21 3:29 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 363 bytes --]
Hi Claudio,
On 02/20/2013 03:55 PM, Claudio Takahasi wrote:
> The following patches implement the initial functionality of the experimental
> Handsfree Audio Manager interface defined in doc/handsfree-audio-api.txt
>
> This series adds the Register and Unregister methods.
>
All patches in this series have been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 28+ messages in thread