From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH v0 07/11] hfp_audio: Add repeated Agent registration verification
Date: Tue, 19 Feb 2013 18:39:04 -0600 [thread overview]
Message-ID: <51241B28.4000001@gmail.com> (raw)
In-Reply-To: <1361306692-959-8-git-send-email-claudio.takahasi@openbossa.org>
[-- 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
next prev parent reply other threads:[~2013-02-20 0:39 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
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-20 0:20 ` Denis Kenzior
2013-02-20 14:52 ` Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 03/11] dbus: Move oFono error define to dbus.h Claudio Takahasi
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
2013-02-19 20:44 ` [PATCH v0 05/11] hfp_audio: Add "Register" agent arguments parsing Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 06/11] hfp_audio: Add codec array validation Claudio Takahasi
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 [this message]
2013-02-20 14:53 ` Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 08/11] hfp_audio: Free agents when exiting Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 09/11] hfp_audio: Call Agent "Release" " Claudio Takahasi
2013-02-19 20:44 ` [PATCH v0 10/11] hfp_audio: Add Agent "Unregister" 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
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 ` [PATCH v1 3/7] handsfree-audio: Add codec array validation Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 4/7] handsfree-audio: Free agent when exiting Claudio Takahasi
2013-02-20 21:55 ` [PATCH v1 5/7] handsfree-audio: Call Agent "Release" " 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
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51241B28.4000001@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox