All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Wagner <wagi@monom.org>
To: ofono@ofono.org
Subject: Re: [PATCH v2 07/13] dundee: Listen to devices property changes
Date: Tue, 19 Mar 2013 22:10:48 +0100	[thread overview]
Message-ID: <5148D458.5030403@monom.org> (raw)
In-Reply-To: <1363267974-13518-8-git-send-email-paulo.borges@openbossa.org>

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

Hi Paulo,

I talked to Denis and he pointed out that this property_changed() 
function looks suspicious.

On 03/14/2013 02:32 PM, Paulo Borges wrote:
> When a bluetooth device property change and this property is Alias
> or UUIDs, we need to refresh our representation of this device.
> ---
>   dundee/bluez5.c |   28 +++++++++++++++++++++++++++-
>   1 file changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/dundee/bluez5.c b/dundee/bluez5.c
> index ca44656..d48aadf 100644
> --- a/dundee/bluez5.c
> +++ b/dundee/bluez5.c
> @@ -169,11 +169,37 @@ static void property_changed(GDBusProxy *proxy, const char *name,
>   {
>   	const char *path = g_dbus_proxy_get_path(proxy);
>   	const char *interface = g_dbus_proxy_get_interface(proxy);
> +	const char *alias;
> +	struct bluetooth_device *bt_device;
> +	gboolean uuid;
>
>   	if (!g_str_equal(BLUEZ_DEVICE_INTERFACE, interface))
>   		return;
>
> -	DBG("%s %s.%s", path, interface, name);
> +	bt_device = g_hash_table_lookup(registered_devices, path);
> +
> +	if (g_str_equal(name, "Alias")) {
> +		if (bt_device == NULL)
> +			return;
> +
> +		dbus_message_iter_get_basic(iter, &alias);
> +
> +		DBG("%s alias changed: %s", path, alias);
> +
> +		bt_device->name = g_strdup(alias);
> +	} else if (g_str_equal(name, "UUIDs")) {
> +		DBG("%s uuids changed", path);
> +
> +		uuid = has_dun_uuid(iter);
> +
> +		if (uuid) {
> +			if (bt_device == NULL)
> +				bluetooth_device_register(proxy);
> +		} else {
> +			if (bt_device != NULL)
> +				bluetooth_device_unregister(path);
> +		}
> +	}

So first thing, the nesting is should be avoided. Sorry, that's my bad.

	if (uuid && bt_device == NULL) register

	if (!uuid && bt_device) unregister

is what is an the ofono style.

>   }
>
>   static void connect_handler(DBusConnection *conn, void *user_data)
>

The next thing is why don't you use g_dbus_proxy_set_property_watch() 
for the property change. Then it might also be worth to split out the
the property handling into individual function. So one for Alias change
and one for UUID change.

See how Alias is handled in plugins/hfp_hf_bluez5.c

And there is the question came up, why it is necessary to handle UUID 
changes. Is this because a phone can enable/disable tethering?

cheers,
daniel


  reply	other threads:[~2013-03-19 21:10 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-04 19:33 [PATCH 00/13] Add support for BlueZ 5 Profile1 API to dundee Paulo Borges
2013-03-04 19:33 ` [PATCH 01/13] dundee: Rename dundee BlueZ 4 support Paulo Borges
2013-03-04 19:33 ` [PATCH 02/13] dundee: Start BlueZ 5 support Paulo Borges
2013-03-11 17:01   ` Daniel Wagner
2013-03-04 19:33 ` [PATCH 03/13] bluez5: Add DUN_UUID Paulo Borges
2013-03-04 19:33 ` [PATCH 04/13] dundee: Initial GDBusClient for BlueZ 5 Paulo Borges
2013-03-11 17:08   ` Daniel Wagner
2013-03-04 19:33 ` [PATCH 05/13] dundee: Add mechanism to store bluetooth devices Paulo Borges
2013-03-04 19:33 ` [PATCH 06/13] dundee: Add tracking of " Paulo Borges
2013-03-04 19:33 ` [PATCH 07/13] dundee: Listen to devices property changes Paulo Borges
2013-03-11 17:17   ` Daniel Wagner
2013-03-12  9:56     ` Daniel Wagner
2013-03-04 19:33 ` [PATCH 08/13] dundee: Add dundee device driver skeleton Paulo Borges
2013-03-04 19:33 ` [PATCH 09/13] dundee: Register/unregister dundee device Paulo Borges
2013-03-04 19:37 ` [PATCH 10/13] dundee: Add BlueZ Profile handler Paulo Borges
2013-03-04 19:38 ` [PATCH 11/13] dundee: Add support for driver connect Paulo Borges
2013-03-04 19:38 ` [PATCH 12/13] dundee: Add dundee disconnect function Paulo Borges
2013-03-04 19:39 ` [PATCH 13/13] dundee: Handle Profile connect and disconnect Paulo Borges
2013-03-11 17:23 ` [PATCH 00/13] Add support for BlueZ 5 Profile1 API to dundee Daniel Wagner
2013-03-11 20:41   ` Paulo Borges
2013-03-14 13:32 ` [PATCH v2 " Paulo Borges
2013-03-14 13:32   ` [PATCH v2 01/13] dundee: Rename dundee BlueZ 4 support Paulo Borges
2013-03-14 13:32   ` [PATCH v2 02/13] dundee: Start BlueZ 5 support Paulo Borges
2013-03-14 13:32   ` [PATCH v2 03/13] bluez5: Add DUN_UUID Paulo Borges
2013-03-14 13:32   ` [PATCH v2 04/13] dundee: Initial GDBusClient for BlueZ 5 Paulo Borges
2013-03-14 13:32   ` [PATCH v2 05/13] dundee: Add mechanism to store bluetooth devices Paulo Borges
2013-03-14 13:32   ` [PATCH v2 06/13] dundee: Add tracking of " Paulo Borges
2013-03-14 13:32   ` [PATCH v2 07/13] dundee: Listen to devices property changes Paulo Borges
2013-03-19 21:10     ` Daniel Wagner [this message]
2013-03-14 13:32   ` [PATCH v2 08/13] dundee: Add dundee device driver skeleton Paulo Borges
2013-03-14 13:32   ` [PATCH v2 09/13] dundee: Register/unregister dundee device Paulo Borges
2013-03-14 13:32   ` [PATCH v2 10/13] dundee: Add BlueZ Profile handler Paulo Borges
2013-03-14 13:32   ` [PATCH v2 11/13] dundee: Add support for driver connect Paulo Borges
2013-03-18  8:38     ` Daniel Wagner
2013-03-14 13:32   ` [PATCH v2 12/13] dundee: Add dundee disconnect function Paulo Borges
2013-03-14 13:32   ` [PATCH v2 13/13] dundee: Handle Profile connect and disconnect Paulo Borges
2013-03-18  9:55   ` [PATCH v2 00/13] Add support for BlueZ 5 Profile1 API to dundee Daniel Wagner
2013-03-19 17:11     ` Vinicius Costa Gomes
2013-03-20 22:26 ` [PATCH v3 " Paulo Borges
2013-03-20 22:26   ` [PATCH v3 01/13] dundee: Rename dundee BlueZ 4 support Paulo Borges
2013-03-20 22:26   ` [PATCH v3 02/13] dundee: Start BlueZ 5 support Paulo Borges
2013-03-20 22:26   ` [PATCH v3 03/13] bluez5: Add DUN_UUID Paulo Borges
2013-03-20 22:26   ` [PATCH v3 04/13] dundee: Initial GDBusClient for BlueZ 5 Paulo Borges
2013-03-20 22:26   ` [PATCH v3 05/13] dundee: Add mechanism to store bluetooth devices Paulo Borges
2013-03-20 22:26   ` [PATCH v3 06/13] dundee: Add tracking of " Paulo Borges
2013-03-20 22:26   ` [PATCH v3 07/13] dundee: Listen to devices property changes Paulo Borges
2013-03-20 22:26   ` [PATCH v3 08/13] dundee: Add dundee device driver skeleton Paulo Borges
2013-03-20 22:26   ` [PATCH v3 09/13] dundee: Register/unregister dundee device Paulo Borges
2013-03-20 22:26   ` [PATCH v3 10/13] dundee: Add BlueZ Profile handler Paulo Borges
2013-03-20 22:26   ` [PATCH v3 11/13] dundee: Add support for driver connect Paulo Borges
2013-03-20 22:26   ` [PATCH v3 12/13] dundee: Add dundee disconnect function Paulo Borges
2013-03-20 22:26   ` [PATCH v3 13/13] dundee: Handle Profile connect and disconnect Paulo Borges
2013-03-24 12:31   ` [PATCH v3 00/13] Add support for BlueZ 5 Profile1 API to dundee Daniel Wagner
2013-03-25 14:43     ` Paulo Borges
2013-04-02 13:12       ` Daniel Wagner

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=5148D458.5030403@monom.org \
    --to=wagi@monom.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.