Re: [PATCH BlueZ 5/8] gdbus: Introduce g_dbus_proxy_path_lookup()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Eramoto,

On Wed, Dec 27, 2017 at 4:51 PM, Luiz Augusto von Dentz
<luiz.dentz@xxxxxxxxx> wrote:
> Hi Eramoto,
>
> On Fri, Dec 22, 2017 at 5:35 AM, ERAMOTO Masaya
> <eramoto.masaya@xxxxxxxxxxxxxx> wrote:
>> g_dbus_proxy_path_lookup() returns the path of the proxy that matches the
>> passed text. It also returns the index of the proxy coming next to the
>> matched proxy in the passed list.
>> ---
>>  gdbus/client.c | 19 +++++++++++++++++++
>>  gdbus/gdbus.h  |  1 +
>>  2 files changed, 20 insertions(+)
>>
>> diff --git a/gdbus/client.c b/gdbus/client.c
>> index 6ec611455..bb13709be 100644
>> --- a/gdbus/client.c
>> +++ b/gdbus/client.c
>> @@ -26,6 +26,7 @@
>>  #endif
>>
>>  #include <stdio.h>
>> +#include <string.h>
>>  #include <glib.h>
>>  #include <dbus/dbus.h>
>>
>> @@ -371,6 +372,24 @@ GDBusProxy *g_dbus_proxy_lookup(GList *list, const char *path,
>>         return NULL;
>>  }
>>
>> +char *g_dbus_proxy_path_lookup(GList *source, int *index, const char *text)
>> +{
>> +       GList *l;
>> +
>> +       for (l = g_list_nth(source, *index); l; l = g_list_next(l)) {
>> +               GDBusProxy *proxy = l->data;
>> +               const char *path;
>> +
>> +               (*index)++;
>> +
>> +               path = g_dbus_proxy_get_path(proxy);
>> +               if (!strncasecmp(path, text, strlen(text)))
>
> We better move out the strlen(text) portion outside of the for loop.
>
>> +                       return strdup(path);
>> +       }
>> +
>> +       return NULL;
>> +}
>> +
>>  static gboolean properties_changed(DBusConnection *conn, DBusMessage *msg,
>>                                                         void *user_data)
>>  {
>> diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
>> index 930aa5f77..99f21b3ce 100644
>> --- a/gdbus/gdbus.h
>> +++ b/gdbus/gdbus.h
>> @@ -341,6 +341,7 @@ gboolean g_dbus_proxy_get_property(GDBusProxy *proxy, const char *name,
>>
>>  GDBusProxy *g_dbus_proxy_lookup(GList *list, const char *path,
>>                                                 const char *interface);
>> +char *g_dbus_proxy_path_lookup(GList *source, int *index, const char *text);

I second thought here, why don't we add the index to
g_dbus_proxy_lookup and make it check for NULL interface?

>>  gboolean g_dbus_proxy_refresh_property(GDBusProxy *proxy, const char *name);
>>
>> --
>> 2.14.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to majordomo@xxxxxxxxxxxxxxx
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>
> --
> Luiz Augusto von Dentz



-- 
Luiz Augusto von Dentz
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux