[gnome-bluetooth] lib: add bluetooth_client_get_connectable()



commit e0a3511f7f3c5fcc7c128b0e1e37dc743351fcec
Author: Gustavo Padovan <gustavo padovan collabora co uk>
Date:   Tue Jun 11 18:28:36 2013 +0100

    lib: add bluetooth_client_get_connectable()
    
    tells if a device can be connected directly by the user or if only other
    components can trigger connections. The implementation for BlueZ 4 used to
    have the same information but based on D-Bus interface available. Now we
    just rely on the uuids to get the same behaviour.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=701399

 lib/bluetooth-client.c      |   27 +++++++++++++++++++++++++++
 lib/bluetooth-client.h      |    2 ++
 lib/gnome-bluetooth.symbols |    1 +
 3 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 8b0b1fa..019a52e 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -75,6 +75,18 @@ enum {
        PROP_DEFAULT_ADAPTER_DISCOVERING
 };
 
+static const char *connectable_uuids[] = {
+       "HSP",
+       "AudioSource",
+       "AudioSink",
+       "A/V_RemoteControlTarget",
+       "A/V_RemoteControl",
+       "Headset_-_AG",
+       "Handsfree",
+       "HandsfreeAudioGateway",
+       "HumanInterfaceDeviceService",
+};
+
 G_DEFINE_TYPE(BluetoothClient, bluetooth_client, G_TYPE_OBJECT)
 
 typedef gboolean (*IterSearchFunc) (GtkTreeStore *store,
@@ -214,6 +226,21 @@ device_list_uuids (GVariant *variant)
        return (char **) g_ptr_array_free (ret, FALSE);
 }
 
+gboolean
+bluetooth_client_get_connectable(const char **uuids)
+{
+       int i, j;
+
+       for (i = 0; uuids && uuids[i] != NULL; i++) {
+               for (j = 0; j < G_N_ELEMENTS (connectable_uuids); j++) {
+                       if (g_str_equal (connectable_uuids[j], uuids[i]))
+                               return TRUE;
+               }
+       }
+
+       return FALSE;
+}
+
 static void
 device_g_properties_changed (GDBusProxy      *device,
                             GVariant        *changed_p,
diff --git a/lib/bluetooth-client.h b/lib/bluetooth-client.h
index a3d0b35..d434bb9 100644
--- a/lib/bluetooth-client.h
+++ b/lib/bluetooth-client.h
@@ -76,6 +76,8 @@ gboolean bluetooth_client_connect_service_finish (BluetoothClient *client,
                                                  GAsyncResult    *res,
                                                  GError         **error);
 
+gboolean bluetooth_client_get_connectable(const char **uuids);
+
 G_END_DECLS
 
 #endif /* __BLUETOOTH_CLIENT_H */
diff --git a/lib/gnome-bluetooth.symbols b/lib/gnome-bluetooth.symbols
index f06e9fe..e2ff0c2 100644
--- a/lib/gnome-bluetooth.symbols
+++ b/lib/gnome-bluetooth.symbols
@@ -26,6 +26,7 @@ bluetooth_client_get_adapter_model
 bluetooth_client_get_device_model
 bluetooth_client_connect_service
 bluetooth_client_connect_service_finish
+bluetooth_client_get_connectable
 bluetooth_client_set_trusted
 bluetooth_client_get_device
 bluetooth_class_to_type


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