Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Adding paired-devices cmd to the bluetoothctl
@ 2013-11-20 20:21 Sebastian
  2013-11-25 12:56 ` Johan Hedberg
  2013-11-25 13:08 ` Szymon Janc
  0 siblings, 2 replies; 4+ messages in thread
From: Sebastian @ 2013-11-20 20:21 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sebastian Chlad

From: Sebastian Chlad <sebastian.chlad@tieto.com>

Paired-devices command lists only paired devices
---
 client/main.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/client/main.c b/client/main.c
index 0dd1510..c39ebf8 100644
--- a/client/main.c
+++ b/client/main.c
@@ -538,6 +538,26 @@ static void cmd_devices(const char *arg)
 	}
 }
 
+static void cmd_devices_paired(const char *arg)
+{
+	GList *list;
+
+	for (list = g_list_first(dev_list); list; list = g_list_next(list)) {
+		DBusMessageIter iter;
+		GDBusProxy *proxy = list->data;
+		dbus_bool_t paired;
+
+		if (g_dbus_proxy_get_property(proxy, "Paired", &iter) == FALSE)
+			return;
+		dbus_message_iter_get_basic(&iter, &paired);
+
+		if (!paired)
+			break;
+
+		print_device(proxy, NULL);
+	}
+}
+
 static void generic_callback(const DBusError *error, void *user_data)
 {
 	char *str = user_data;
@@ -1047,6 +1067,8 @@ static const struct {
 	{ "select",       "<ctrl>",   cmd_select, "Select default controller",
 							ctrl_generator },
 	{ "devices",      NULL,       cmd_devices, "List available devices" },
+	{ "paired-devices", NULL,     cmd_devices_paired,
+					"List paired devices"},
 	{ "system-alias", "<name>",   cmd_system_alias },
 	{ "reset-alias",  NULL,       cmd_reset_alias },
 	{ "power",        "<on/off>", cmd_power, "Set controller power" },
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Adding paired-devices cmd to the bluetoothctl
  2013-11-20 20:21 [PATCH] Adding paired-devices cmd to the bluetoothctl Sebastian
@ 2013-11-25 12:56 ` Johan Hedberg
  2013-11-25 13:08 ` Szymon Janc
  1 sibling, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2013-11-25 12:56 UTC (permalink / raw)
  To: Sebastian; +Cc: linux-bluetooth, Sebastian Chlad

Hi Sebastian,

On Wed, Nov 20, 2013, Sebastian wrote:
> From: Sebastian Chlad <sebastian.chlad@tieto.com>
> 
> Paired-devices command lists only paired devices
> ---
>  client/main.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)

Applied (after a couple of minor tweaks). Thanks.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Adding paired-devices cmd to the bluetoothctl
  2013-11-20 20:21 [PATCH] Adding paired-devices cmd to the bluetoothctl Sebastian
  2013-11-25 12:56 ` Johan Hedberg
@ 2013-11-25 13:08 ` Szymon Janc
  2013-11-25 13:24   ` Johan Hedberg
  1 sibling, 1 reply; 4+ messages in thread
From: Szymon Janc @ 2013-11-25 13:08 UTC (permalink / raw)
  To: Sebastian; +Cc: linux-bluetooth, Sebastian Chlad

Hi,

> From: Sebastian Chlad <sebastian.chlad@tieto.com>
> 
> Paired-devices command lists only paired devices
> ---
>  client/main.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/client/main.c b/client/main.c
> index 0dd1510..c39ebf8 100644
> --- a/client/main.c
> +++ b/client/main.c
> @@ -538,6 +538,26 @@ static void cmd_devices(const char *arg)
>  	}
>  }
>  
> +static void cmd_devices_paired(const char *arg)
> +{
> +	GList *list;
> +
> +	for (list = g_list_first(dev_list); list; list = g_list_next(list)) {
> +		DBusMessageIter iter;
> +		GDBusProxy *proxy = list->data;
> +		dbus_bool_t paired;
> +
> +		if (g_dbus_proxy_get_property(proxy, "Paired", &iter) == FALSE)
> +			return;
> +		dbus_message_iter_get_basic(&iter, &paired);
> +
> +		if (!paired)
> +			break;

Shouldn't this be
  if (!paired)
      continue;

? Or paired devices are guaranteed to be first on list?

> +
> +		print_device(proxy, NULL);
> +	}
> +}
> +
>  static void generic_callback(const DBusError *error, void *user_data)
>  {
>  	char *str = user_data;
> @@ -1047,6 +1067,8 @@ static const struct {
>  	{ "select",       "<ctrl>",   cmd_select, "Select default controller",
>  							ctrl_generator },
>  	{ "devices",      NULL,       cmd_devices, "List available devices" },
> +	{ "paired-devices", NULL,     cmd_devices_paired,
> +					"List paired devices"},
>  	{ "system-alias", "<name>",   cmd_system_alias },
>  	{ "reset-alias",  NULL,       cmd_reset_alias },
>  	{ "power",        "<on/off>", cmd_power, "Set controller power" },
> 

-- 
BR
Szymon Janc


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Adding paired-devices cmd to the bluetoothctl
  2013-11-25 13:08 ` Szymon Janc
@ 2013-11-25 13:24   ` Johan Hedberg
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2013-11-25 13:24 UTC (permalink / raw)
  To: Szymon Janc; +Cc: Sebastian, linux-bluetooth, Sebastian Chlad

Hi Szymon,

On Mon, Nov 25, 2013, Szymon Janc wrote:
> > Paired-devices command lists only paired devices
> > ---
> >  client/main.c | 22 ++++++++++++++++++++++
> >  1 file changed, 22 insertions(+)
> > 
> > diff --git a/client/main.c b/client/main.c
> > index 0dd1510..c39ebf8 100644
> > --- a/client/main.c
> > +++ b/client/main.c
> > @@ -538,6 +538,26 @@ static void cmd_devices(const char *arg)
> >  	}
> >  }
> >  
> > +static void cmd_devices_paired(const char *arg)
> > +{
> > +	GList *list;
> > +
> > +	for (list = g_list_first(dev_list); list; list = g_list_next(list)) {
> > +		DBusMessageIter iter;
> > +		GDBusProxy *proxy = list->data;
> > +		dbus_bool_t paired;
> > +
> > +		if (g_dbus_proxy_get_property(proxy, "Paired", &iter) == FALSE)
> > +			return;
> > +		dbus_message_iter_get_basic(&iter, &paired);
> > +
> > +		if (!paired)
> > +			break;
> 
> Shouldn't this be
>   if (!paired)
>       continue;
> 
> ? Or paired devices are guaranteed to be first on list?

They're not, and the same goes the for return statement in case
g_dbus_proxy_get_property fails. Since this was the last patch pushed I
did a git commit --amend + git push --force to avoid a fixup patch.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-11-25 13:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-20 20:21 [PATCH] Adding paired-devices cmd to the bluetoothctl Sebastian
2013-11-25 12:56 ` Johan Hedberg
2013-11-25 13:08 ` Szymon Janc
2013-11-25 13:24   ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox