From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH] hfp: create modem for new devices paired on runtime
Date: Mon, 01 Feb 2010 11:49:47 -0600 [thread overview]
Message-ID: <201002011149.48212.denkenz@gmail.com> (raw)
In-Reply-To: <1265045427-14794-1-git-send-email-padovan@profusion.mobi>
[-- Attachment #1: Type: text/plain, Size: 1989 bytes --]
Hi Gustavo,
> It listens the Paired property to create a modem to the recently paired
> devices.
> ---
> plugins/hfp.c | 60
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files
changed,
> 59 insertions(+), 1 deletions(-)
>
> diff --git a/plugins/hfp.c b/plugins/hfp.c
> index 0e2e359..2141078 100644
> --- a/plugins/hfp.c
> +++ b/plugins/hfp.c
> @@ -594,6 +594,55 @@ static gboolean adapter_added(DBusConnection
> *connection, DBusMessage *message, return TRUE;
> }
>
> +static gboolean paired_added(DBusConnection *connection, DBusMessage
> *message, + void *user_data)
> +{
> + DBusError err;
> + const char *device, *paired;
> + DBusMessageIter iter, variant;
> + int ret, value;
> +
> + dbus_error_init(&err);
> +
> + if (dbus_message_get_args(message, &err, DBUS_TYPE_STRING,
> + &paired, DBUS_TYPE_INVALID) == FALSE) {
> + if (dbus_error_is_set(&err) == TRUE) {
> + ofono_error("%s", err.message);
> + dbus_error_free(&err);
> + }
> +
> + return FALSE;
> + }
> +
> + if (strcmp(paired, "Paired"))
> + return TRUE;
> +
> + dbus_message_iter_init(message, &iter);
Why can't we do something like?
dbus_message_iter_init();
if (dbus_message_iter_get_arg_type(&iter) != STRING)
return;
dbus_message_iter_get_basic(&iter, &property);
if (g_str_equal(property, "Paired") == FALSE)
return;
I really don't like mixing the two ways of parsing the message and this way
seems cleaner.
> + if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING) {
> +
> + if (!dbus_message_iter_next(&iter))
> + return FALSE;
> +
> + dbus_message_iter_recurse(&iter, &variant);
> + dbus_message_iter_get_basic(&variant, &value);
> +
> + if (!value)
> + return TRUE;
> + }
You might want to check the second argument is indeed a DBUS_TYPE_VARIANT and
the value of the variant is what you're expecting.
We really need to make a function for this in gdbus.
Regards,
-Denis
next prev parent reply other threads:[~2010-02-01 17:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-01 17:30 [PATCH] hfp: create modem for new devices paired on runtime Gustavo F. Padovan
2010-02-01 17:49 ` Denis Kenzior [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-02-01 18:17 Gustavo F. Padovan
2010-02-01 18:35 ` Gustavo F. Padovan
2010-02-02 21:42 Gustavo F. Padovan
2010-02-03 22:18 Gustavo F. Padovan
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=201002011149.48212.denkenz@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