Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH v0 03/15] hfp_hf_bluez5: Add extracting version
Date: Mon, 18 Mar 2013 13:55:41 -0500	[thread overview]
Message-ID: <5147632D.8040406@gmail.com> (raw)
In-Reply-To: <1363092133-1092-4-git-send-email-claudio.takahasi@openbossa.org>

[-- Attachment #1: Type: text/plain, Size: 2466 bytes --]

Hi Claudio,

On 03/12/2013 07:42 AM, Claudio Takahasi wrote:
> This patch parses and reads the profile "Version" that comes in the fd
> dictionary of the NewConnection method. "Version" is input for Audio Card
> registration.
> ---
>   plugins/hfp_hf_bluez5.c | 37 +++++++++++++++++++++++++++++++++++++
>   1 file changed, 37 insertions(+)
>
> diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
> index 2020e63..a8d8277 100644
> --- a/plugins/hfp_hf_bluez5.c
> +++ b/plugins/hfp_hf_bluez5.c
> @@ -343,6 +343,37 @@ static ofono_bool_t device_path_compare(struct ofono_modem *modem,
>   	return g_str_equal(path, value);
>   }
>
> +static int get_version(DBusMessageIter *iter, uint16_t *version)
> +{
> +	DBusMessageIter dict, entry, valiter;
> +	const char *key;
> +	uint16_t value;
> +
> +	dbus_message_iter_recurse(iter,&dict);
> +
> +	/* Dict entry key */
> +	dbus_message_iter_recurse(&dict,&entry);
> +	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
> +		return -EINVAL;
> +
> +	dbus_message_iter_get_basic(&entry,&key);
> +	if (g_str_equal("Version", key) == FALSE)
> +		return -EINVAL;
> +
> +	/* Dict entry value */
> +	dbus_message_iter_next(&entry);
> +	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
> +		return -EINVAL;
> +
> +	dbus_message_iter_recurse(&entry,&valiter);
> +	dbus_message_iter_get_basic(&valiter,&value);
> +
> +	if (version)
> +		*version = value;
> +
> +	return 0;
> +}
> +
>   static DBusMessage *profile_new_connection(DBusConnection *conn,
>   					DBusMessage *msg, void *user_data)
>   {
> @@ -353,6 +384,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
>   	DBusMessageIter entry;
>   	const char *device;
>   	char local[18], remote[18];
> +	uint16_t version;
>   	int fd, err;
>
>   	DBG("Profile handler NewConnection");
> @@ -373,6 +405,11 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
>   	if (fd<  0)
>   		goto invalid;
>
> +	dbus_message_iter_next(&entry);
> +

I would not mind extra sanity checking here, e.g. argument type checking

> +	if (get_version(&entry,&version)<  0)
> +		goto invalid;
> +

I don't like this.  The fd_properties is a dictionary, you cannot assume 
that Version will be always the first one.

>   	modem = ofono_modem_find(device_path_compare, (void *) device);
>   	if (modem == NULL) {
>   		close(fd);

Regards,
-Denis

  reply	other threads:[~2013-03-18 18:55 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-08 23:11 [RFC v0 00/13] Add handsfree audio card driver Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 01/13] handsfree-audio: Add " Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 02/13] hfp_hf_bluez5: Register handsfree audio driver Claudio Takahasi
2013-03-11 14:30   ` Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 03/13] hfp_hf_bluez5: Add extracting version Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 04/13] handsfree-audio: Add version to card driver Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 05/13] hfp_hf_bluez5: Pass version to card registration Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 06/13] hfp_hf_bluez5: Add version to HFP 1.5 card driver Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 07/13] core: Add bt_str2ba() to bluetooth.h Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 08/13] hfp_hf_bluez5: Add HFP 1.5 card connect callback Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 09/13] handsfree-audio: Add calling " Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 10/13] handsfree-audio: Add connect GIOChannel watch Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 11/13] handsfree-audio: Add sending SCO fd Claudio Takahasi
2013-03-11 14:55   ` Johan Hedberg
2013-03-11 16:36     ` Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 12/13] handsfree-audio: Return an error on Card Connect Claudio Takahasi
2013-03-08 23:11 ` [RFC v0 13/13] handsfree-audio: Check agent before sending fd Claudio Takahasi
2013-03-12 12:41 ` [PATCH v0 00/15] Add handsfree audio card driver Claudio Takahasi
2013-03-12 12:41   ` [PATCH v0 01/15] handsfree-audio: Add " Claudio Takahasi
2013-03-13 16:53     ` Frederic Danis
2013-03-13 17:46       ` Denis Kenzior
2013-03-14  9:59         ` Frederic Danis
2013-03-18 18:58     ` Denis Kenzior
2013-03-12 12:42   ` [PATCH v0 02/15] hfp_hf_bluez5: Register handsfree audio driver Claudio Takahasi
2013-03-18 18:59     ` Denis Kenzior
2013-03-12 12:42   ` [PATCH v0 03/15] hfp_hf_bluez5: Add extracting version Claudio Takahasi
2013-03-18 18:55     ` Denis Kenzior [this message]
2013-03-12 12:42   ` [PATCH v0 04/15] handsfree-audio: Add version to card driver Claudio Takahasi
2013-03-18 18:59     ` Denis Kenzior
2013-03-12 12:42   ` [PATCH v0 05/15] hfp_hf_bluez5: Pass version to card registration Claudio Takahasi
2013-03-12 12:42   ` [PATCH v0 06/15] hfp_hf_bluez5: Add version to HFP 1.5 card driver Claudio Takahasi
2013-03-12 12:42   ` [PATCH v0 07/15] core: Add bt_str2ba() to bluetooth.h Claudio Takahasi
2013-03-18 19:00     ` Denis Kenzior
2013-03-12 12:42   ` [PATCH v0 08/15] hfp_hf_bluez5: Add HFP 1.5 connect implementation Claudio Takahasi
2013-03-12 12:42   ` [PATCH v0 09/15] handsfree-audio: Add calling connect callback Claudio Takahasi
2013-03-12 12:42   ` [PATCH v0 10/15] handsfree-audio: Add connect GIOChannel watch Claudio Takahasi
2013-03-12 12:42   ` [PATCH v0 11/15] handsfree-audio: Add sending SCO fd Claudio Takahasi
2013-03-12 12:42   ` [PATCH v0 12/15] handsfree-audio: Return NotAvailable on "Connect" Claudio Takahasi
2013-03-12 12:42   ` [PATCH v0 13/15] handsfree-audio: Return InProgress on Connect Claudio Takahasi
2013-03-12 15:26     ` Frederic Danis
2013-03-12 17:26       ` Claudio Takahasi
2013-03-12 12:42   ` [PATCH v0 14/15] handsfree-audio: Check agent before sending fd Claudio Takahasi
2013-03-12 12:42   ` [PATCH v0 15/15] doc: Add Handsfree Audio Card "Connect" errors Claudio Takahasi

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=5147632D.8040406@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