[gnome-bluetooth/obexd: 2/3] WIP: build, need to fix removed device and discoverable



commit 858fd3ee045f8e85c4d6295322042c8958b32250
Author: Gustavo Padovan <gustavo padovan collabora co uk>
Date:   Wed May 8 20:19:35 2013 -0300

    WIP: build, need to fix removed device and discoverable

 lib/Makefile.am                |   11 +-
 lib/bluetooth-agent.c          |   97 ++----
 lib/bluetooth-client-private.h |    2 +-
 lib/bluetooth-client.c         |  776 +++++++++++++++++++++-------------------
 lib/bluetooth-client.xml       |  120 +++----
 lib/bluetooth-enums.h          |    2 +
 lib/bluetooth-fdo.xml          |   33 ++
 lib/gnome-bluetooth.symbols    |    2 +-
 wizard/main.c                  |    2 +-
 9 files changed, 529 insertions(+), 516 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 907d163..4fb813d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -17,6 +17,7 @@ libgnome_bluetooth_c_sources =                \
        bluetooth-chooser-button.c      \
        bluetooth-chooser-combo.c       \
        bluetooth-client-glue.c         \
+       bluetooth-fdo-glue.c            \
        bluetooth-plugin-manager.c      \
        rfkill-glib.c
 
@@ -26,6 +27,7 @@ libgnome_bluetooth_private_headers =  \
        gnome-bluetooth-enum-types.h    \
        bluetooth-chooser-private.h     \
        bluetooth-client-glue.h         \
+       bluetooth-fdo-glue.h            \
        rfkill-glib.h                   \
        rfkill.h
 
@@ -97,6 +99,8 @@ endif # HAVE_INTROSPECTION
 
 BUILT_SOURCES = bluetooth-client-glue.h \
                bluetooth-client-glue.c \
+               bluetooth-fdo-glue.h \
+               bluetooth-fdo-glue.c \
                gnome-bluetooth-enum-types.h \
                gnome-bluetooth-enum-types.c
 
@@ -116,7 +120,7 @@ test_class_LDADD = libgnome-bluetooth.la $(LIBGNOMEBT_LIBS)
 
 test_killswitch_LDADD = libgnome-bluetooth.la $(LIBGNOMEBT_LIBS)
 
-EXTRA_DIST += bluetooth-client.xml gnome-bluetooth.symbols
+EXTRA_DIST += bluetooth-client.xml bluetooth-fdo.xml gnome-bluetooth.symbols
 
 MAINTAINERCLEANFILES = Makefile.in
 
@@ -125,6 +129,11 @@ bluetooth-client-glue.c: bluetooth-client-glue.h
 bluetooth-client-glue.c bluetooth-client-glue.h: bluetooth-client.xml
        $(AM_V_GEN) $(GDBUS_CODEGEN) --c-namespace= --generate-c-code=bluetooth-client-glue 
--interface-prefix=org.bluez $<
 
+bluetooth-fdo-glue.c: bluetooth-fdo-glue.h
+
+bluetooth-fdo-glue.c bluetooth-fdo-glue.h: bluetooth-fdo.xml
+       $(AM_V_GEN) $(GDBUS_CODEGEN) --c-namespace= --generate-c-code=bluetooth-fdo-glue 
--interface-prefix=org.freedesktop.DBus $<
+
 gnome_bluetooth_headers_to_scan_for_enums = bluetooth-enums.h
 # Generate the enums source code, with glib-mkenums:
 # This is based on the same Makefile.am stuff in pango:
diff --git a/lib/bluetooth-agent.c b/lib/bluetooth-agent.c
index f8b5cd0..66b20f7 100644
--- a/lib/bluetooth-agent.c
+++ b/lib/bluetooth-agent.c
@@ -29,17 +29,18 @@
 #include <gio/gio.h>
 
 #include "bluetooth-client-glue.h"
+#include "bluetooth-fdo-glue.h"
 #include "bluetooth-agent.h"
 
 #define BLUEZ_SERVICE  "org.bluez"
 
 #define BLUEZ_MANAGER_PATH     "/"
-#define BLUEZ_MANAGER_INTERFACE        "org.bluez.Manager"
-#define BLUEZ_DEVICE_INTERFACE "org.bluez.Device"
+#define BLUEZ_MANAGER_INTERFACE        "org.bluez.Manager1"
+#define BLUEZ_DEVICE_INTERFACE "org.bluez.Device1"
 
 static const gchar introspection_xml[] =
 "<node name='/'>"
-"  <interface name='org.bluez.Agent'>"
+"  <interface name='org.bluez.Agent1'>"
 "    <method name='Release'/>"
 "    <method name='RequestPinCode'>"
 "      <arg type='o' name='device' direction='in'/>"
@@ -58,12 +59,12 @@ static const gchar introspection_xml[] =
 "      <arg type='o' name='device' direction='in'/>"
 "      <arg type='u' name='passkey' direction='in'/>"
 "    </method>"
-"    <method name='Authorize'>"
+"    <method name='RequestAuthorization'>"
 "      <arg type='o' name='device' direction='in'/>"
-"      <arg type='s' name='uuid' direction='in'/>"
 "    </method>"
-"    <method name='ConfirmMode'>"
-"      <arg type='s' name='mode'/>"
+"    <method name='AuthorizeService'>"
+"      <arg type='o' name='device' direction='in'/>"
+"      <arg type='s' name='uuid' direction='in'/>"
 "    </method>"
 "    <method name='Cancel'/>"
 "  </interface>"
@@ -78,7 +79,7 @@ struct _BluetoothAgentPrivate {
        GDBusConnection *conn;
        gchar *busname;
        gchar *path;
-       GDBusProxy *adapter;
+       GDBusProxy *agent_manager;
        GDBusNodeInfo *introspection_data;
        guint reg_id;
        guint watch_id;
@@ -109,7 +110,7 @@ get_device_from_adapter (BluetoothAgent *agent,
                         const char *path)
 {
        BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
-
+/*
        if (priv->adapter == NULL)
                return NULL;
 
@@ -121,6 +122,7 @@ get_device_from_adapter (BluetoothAgent *agent,
                                              BLUEZ_DEVICE_INTERFACE,
                                              NULL,
                                              NULL);
+                */
 }
 
 static gboolean bluetooth_agent_request_pin_code(BluetoothAgent *agent,
@@ -399,66 +401,25 @@ gboolean bluetooth_agent_setup(BluetoothAgent *agent, const char *path)
 }
 
 #define BLUEZ_SERVICE                  "org.bluez"
-#define BLUEZ_MANAGER_INTERFACE                "org.bluez.Manager"
-
-static GDBusProxy *
-get_default_adapter (void)
-{
-       Manager *manager;
-       char *adapter_path;
-       Adapter *adapter;
-
-       manager = manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
-                                                 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
-                                                 BLUEZ_SERVICE,
-                                                 BLUEZ_MANAGER_PATH,
-                                                 NULL,
-                                                 NULL);
-       if (manager == NULL)
-               return NULL;
-       if (manager_call_default_adapter_sync (manager, &adapter_path, NULL, NULL) == FALSE) {
-               g_object_unref (manager);
-               return NULL;
-       }
-       adapter = adapter_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
-                                                 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
-                                                 BLUEZ_SERVICE,
-                                                 adapter_path,
-                                                 NULL,
-                                                 NULL);
-       g_object_unref (manager);
-       g_free (adapter_path);
-
-       return G_DBUS_PROXY (adapter);
-}
+#define BLUEZ_AGENT_PATH "/org/bluez/agent/gnome"
 
 gboolean bluetooth_agent_register(BluetoothAgent *agent)
 {
        BluetoothAgentPrivate *priv;
        GError *error = NULL;
        char *path;
-       GVariant *r;
+       gboolean ret;
 
        g_return_val_if_fail (BLUETOOTH_IS_AGENT (agent), FALSE);
 
        priv = BLUETOOTH_AGENT_GET_PRIVATE (agent);
 
-       priv->adapter = get_default_adapter ();
-
-       if (priv->adapter == NULL)
-               return FALSE;
-
-       if (priv->path != NULL) {
-               g_warning ("Agent already setup on '%s'", priv->path);
-               return FALSE;
-       }
-
-       path = g_path_get_basename(g_dbus_proxy_get_object_path(priv->adapter));
-       priv->path = g_strdup_printf("/org/bluez/agent/%s", path);
-       g_free(path);
+  priv->agent_manager = agent_manager1_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
+                     G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+                     BLUEZ_SERVICE, "/org/bluez", NULL, NULL);
 
        priv->reg_id = g_dbus_connection_register_object (priv->conn,
-                                                     priv->path,
+                                                     BLUEZ_AGENT_PATH,
                                                      priv->introspection_data->interfaces[0],
                                                      &interface_vtable,
                                                      agent,
@@ -471,16 +432,15 @@ gboolean bluetooth_agent_register(BluetoothAgent *agent)
                return FALSE;
        }
 
-       r = g_dbus_proxy_call_sync (priv->adapter, "RegisterAgent",
-                                   g_variant_new ("(os)", priv->path, "DisplayYesNo"),
-                                   G_DBUS_CALL_FLAGS_NONE,
-                                   -1, NULL, &error);
-       if (r == NULL) {
+  ret = agent_manager1_call_register_agent_sync (G_DBUS_PROXY(priv->agent_manager),
+             BLUEZ_AGENT_PATH,
+                                   "DisplayYesNo",
+                                   NULL, &error);
+       if (ret == FALSE) {
                g_printerr ("Agent registration failed: %s\n", error->message);
                g_error_free (error);
                return FALSE;
        }
-       g_variant_unref (r);
 
        return TRUE;
 }
@@ -494,13 +454,12 @@ gboolean bluetooth_agent_unregister(BluetoothAgent *agent)
 
        priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
 
-       if (priv->adapter == NULL)
+       if (priv->agent_manager == NULL)
                return FALSE;
 
-       if (g_dbus_proxy_call_sync (priv->adapter, "UnregisterAgent",
-                                   g_variant_new ("(o)", priv->path),
-                                   G_DBUS_CALL_FLAGS_NONE,
-                                   -1, NULL, &error) == FALSE) {
+  if (agent_manager1_call_unregister_agent_sync (priv->agent_manager,
+                                                 BLUEZ_AGENT_PATH,
+                                                                        NULL, &error) == FALSE) {
                /* Ignore errors if the adapter is gone */
                if (g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD) == FALSE) {
                        g_printerr ("Agent unregistration failed: %s '%s'\n",
@@ -510,8 +469,8 @@ gboolean bluetooth_agent_unregister(BluetoothAgent *agent)
                g_error_free(error);
        }
 
-       g_object_unref(priv->adapter);
-       priv->adapter = NULL;
+       g_object_unref(priv->agent_manager);
+       priv->agent_manager = NULL;
 
        g_free(priv->path);
        priv->path = NULL;
diff --git a/lib/bluetooth-client-private.h b/lib/bluetooth-client-private.h
index 3897b6c..e39374b 100644
--- a/lib/bluetooth-client-private.h
+++ b/lib/bluetooth-client-private.h
@@ -35,7 +35,7 @@ typedef void (*BluetoothClientCreateDeviceFunc) (BluetoothClient *client,
                                                 const GError *error,
                                                 gpointer data);
 
-gboolean bluetooth_client_create_device(BluetoothClient *client,
+gboolean bluetooth_client_pair(BluetoothClient *client,
                        const char *address, const char *agent,
                        BluetoothClientCreateDeviceFunc func, gpointer data);
 
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 8bddb58..3f92f3e 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -43,14 +43,15 @@
 #include "bluetooth-client.h"
 #include "bluetooth-client-private.h"
 #include "bluetooth-client-glue.h"
+#include "bluetooth-fdo-glue.h"
 #include "bluetooth-utils.h"
 #include "gnome-bluetooth-enum-types.h"
 
 #define BLUEZ_SERVICE                  "org.bluez"
 #define BLUEZ_MANAGER_PATH             "/"
-#define BLUEZ_MANAGER_INTERFACE                "org.bluez.Manager"
-#define BLUEZ_ADAPTER_INTERFACE                "org.bluez.Adapter"
-#define BLUEZ_DEVICE_INTERFACE         "org.bluez.Device"
+#define BLUEZ_ADAPTER_INTERFACE                "org.bluez.Adapter1"
+#define BLUEZ_DEVICE_INTERFACE         "org.bluez.Device1"
+#define FDO_PROPERTIES_INTERFACE  "org.freedesktop.DBus.Properties"
 
 static char * detectable_interfaces[] = {
        "org.bluez.Headset",
@@ -77,7 +78,7 @@ typedef struct _BluetoothClientPrivate BluetoothClientPrivate;
 
 struct _BluetoothClientPrivate {
        guint owner_change_id;
-       Manager *manager;
+       ObjectManager *manager;
        GtkTreeStore *store;
        GtkTreeRowReference *default_adapter;
 };
@@ -168,6 +169,7 @@ get_iter_from_path (GtkTreeStore *store,
                    GtkTreeIter *iter,
                    const char *path)
 {
+
        return iter_search(store, iter, NULL, compare_path, (gpointer) path);
 }
 
@@ -270,7 +272,7 @@ end:
 }
 
 static GDBusProxy *
-get_proxy_for_iface (Device          *device,
+get_proxy_for_iface (Device1          *device,
                     const char      *interface,
                     BluetoothClient *client)
 {
@@ -321,7 +323,7 @@ get_properties_for_iface (GDBusProxy *proxy)
 }
 
 static GHashTable *
-device_list_nodes (Device *device, BluetoothClient *client)
+device_list_nodes (Device1 *device, BluetoothClient *client)
 {
        GHashTable *table;
        guint i;
@@ -426,62 +428,72 @@ device_list_uuids (GVariant *variant)
 }
 
 static void
-device_changed (Device          *device,
-               const char      *property,
-               GVariant        *variant,
-               BluetoothClient *client)
+device_changed (GDBusProxy          *device,
+                const char      *interface,
+                GVariant        *changed_p,
+                GVariant        *invalidated_p,
+                BluetoothClient *client)
 {
        BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+  GVariantIter i;
+  const char *property;
        GtkTreeIter iter;
+  GVariant *value, *v;
 
-       if (get_iter_from_proxy(priv->store, &iter, G_DBUS_PROXY (device)) == FALSE)
+       if (get_iter_from_proxy(priv->store, &iter, device) == FALSE)
                return;
 
-       if (g_str_equal(property, "Name") == TRUE) {
-               const gchar *name = g_variant_get_string (variant, NULL);
-
-               gtk_tree_store_set(priv->store, &iter,
-                                       BLUETOOTH_COLUMN_NAME, name, -1);
-       } else if (g_str_equal(property, "Alias") == TRUE) {
-               const gchar *alias = g_variant_get_string(variant, NULL);
-
-               gtk_tree_store_set(priv->store, &iter,
-                                       BLUETOOTH_COLUMN_ALIAS, alias, -1);
-       } else if (g_str_equal(property, "Icon") == TRUE) {
-               const gchar *icon = g_variant_get_string(variant, NULL);
-
-               gtk_tree_store_set(priv->store, &iter,
-                                       BLUETOOTH_COLUMN_ICON, icon, -1);
-       } else if (g_str_equal(property, "Paired") == TRUE) {
-               gboolean paired = g_variant_get_boolean(variant);
-
-               gtk_tree_store_set(priv->store, &iter,
-                               BLUETOOTH_COLUMN_PAIRED, paired, -1);
-       } else if (g_str_equal(property, "Trusted") == TRUE) {
-               gboolean trusted = g_variant_get_boolean(variant);
-
-               gtk_tree_store_set(priv->store, &iter,
-                               BLUETOOTH_COLUMN_TRUSTED, trusted, -1);
-       } else if (g_str_equal(property, "Connected") == TRUE) {
-               gboolean connected = g_variant_get_boolean(variant);
-
-               gtk_tree_store_set(priv->store, &iter,
-                               BLUETOOTH_COLUMN_CONNECTED, connected, -1);
-       } else if (g_str_equal (property, "UUIDs") == TRUE) {
-               GHashTable *services;
-               char **uuids;
-
-               uuids = device_list_uuids (variant);
-               services = device_list_nodes (device, client);
-               gtk_tree_store_set (priv->store, &iter,
-                                   BLUETOOTH_COLUMN_SERVICES, services,
-                                   BLUETOOTH_COLUMN_UUIDS, uuids, -1);
-               g_strfreev (uuids);
-               if (services != NULL)
-                       g_hash_table_unref (services);
-       } else {
-               g_debug ("Unhandled property: %s", property);
-       }
+  g_variant_iter_init (&i, changed_p);
+  while ((value = g_variant_iter_next_value (&i)))
+    {
+                 g_variant_get (value, "{sv}", &property, &v);
+
+      if (g_str_equal(property, "Name") == TRUE) {
+        const gchar *name = g_variant_get_string (v, NULL);
+
+        gtk_tree_store_set(priv->store, &iter,
+              BLUETOOTH_COLUMN_NAME, name, -1);
+      } else if (g_str_equal(property, "Alias") == TRUE) {
+        const gchar *alias = g_variant_get_string(v, NULL);
+
+        gtk_tree_store_set(priv->store, &iter,
+              BLUETOOTH_COLUMN_ALIAS, alias, -1);
+      } else if (g_str_equal(property, "Icon") == TRUE) {
+        const gchar *icon = g_variant_get_string(v, NULL);
+
+        gtk_tree_store_set(priv->store, &iter,
+              BLUETOOTH_COLUMN_ICON, icon, -1);
+      } else if (g_str_equal(property, "Paired") == TRUE) {
+        gboolean paired = g_variant_get_boolean(v);
+
+        gtk_tree_store_set(priv->store, &iter,
+            BLUETOOTH_COLUMN_PAIRED, paired, -1);
+      } else if (g_str_equal(property, "Trusted") == TRUE) {
+        gboolean trusted = g_variant_get_boolean(v);
+
+        gtk_tree_store_set(priv->store, &iter,
+            BLUETOOTH_COLUMN_TRUSTED, trusted, -1);
+      } else if (g_str_equal(property, "Connected") == TRUE) {
+        gboolean connected = g_variant_get_boolean(v);
+
+        gtk_tree_store_set(priv->store, &iter,
+            BLUETOOTH_COLUMN_CONNECTED, connected, -1);
+      } else if (g_str_equal (property, "UUIDs") == TRUE) {
+        GHashTable *services;
+        char **uuids;
+
+        uuids = device_list_uuids (v);
+        services = device_list_nodes (DEVICE1(device), client);
+        gtk_tree_store_set (priv->store, &iter,
+                BLUETOOTH_COLUMN_SERVICES, services,
+                BLUETOOTH_COLUMN_UUIDS, uuids, -1);
+        g_strfreev (uuids);
+        if (services != NULL)
+          g_hash_table_unref (services);
+      } else {
+        g_debug ("Unhandled property: %s", property);
+      }
+    }
 }
 
 static void
@@ -491,91 +503,90 @@ device_g_signal (GDBusProxy      *proxy,
                 GVariant        *parameters,
                 BluetoothClient *client)
 {
-       char *property;
-       GVariant *variant;
-
-       if (g_strcmp0 (signal_name, "PropertyChanged") != 0)
-               return;
-
-       g_variant_get (parameters, "(sv)", &property, &variant);
-       device_changed (DEVICE (proxy), property, variant, client);
-       g_free (property);
-       g_variant_unref (variant);
+       if (g_strcmp0 (signal_name, "PropertiesChanged") == 0) {
+               char *interface;
+               GVariant *changed_p, *invalidated_p;
+
+               g_variant_get (parameters, "(s**)", &interface, &changed_p, &invalidated_p);
+               device_changed (proxy, interface, changed_p, invalidated_p, client);
+               g_free (interface);
+               g_variant_unref (changed_p);
+               g_variant_unref (invalidated_p);
+       }
 }
 
 static void
-add_device (Adapter         *adapter,
-           GtkTreeIter     *parent,
+device_added (ObjectManager         *manager,
            BluetoothClient *client,
            const char      *path,
-           GVariant        *dict)
+           GVariant        *variant)
 {
        BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
-       Device *device;
-       GVariant *v;
-       const gchar *address, *alias, *name, *icon;
+  GDBusProxy *adapter;
+       Device1 *device;
+       GVariant *v, *dict;
+       const gchar *adapter_path, *address, *alias, *name, *icon;
        char **uuids;
        gboolean paired, trusted, connected;
        int legacypairing;
        guint type;
-       GtkTreeIter iter;
-       GVariant *ret;
-
-       if (path == NULL && dict == NULL)
-               return;
-
-       if (path != NULL) {
-               ret = NULL;
-               device = device_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
-                                                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
-                                                       BLUEZ_SERVICE,
-                                                       path,
-                                                       NULL,
-                                                       NULL);
-               if (device == NULL)
-                       return;
-               device_call_get_properties_sync (DEVICE (device), &ret, NULL, NULL);
-               if (ret == NULL) {
-                       g_object_unref (device);
-                       return;
-               }
-       } else {
-               device = NULL;
-               ret = g_variant_ref (dict);
-       }
-
-       v = g_variant_lookup_value (ret, "Address", G_VARIANT_TYPE_STRING);
+       GtkTreeIter iter, parent;
+  GHashTable *services;
+  GDBusProxy *proxy;
+
+  device = device1_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                           G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+                                           BLUEZ_SERVICE,
+                                           path,
+                                           NULL,
+                                           NULL);
+  if (device == NULL)
+    return;
+
+  dict = g_variant_lookup_value (variant, "org.bluez.Device1",
+                              G_VARIANT_TYPE_DICTIONARY);
+
+       v = g_variant_lookup_value (dict, "Adapter", G_VARIANT_TYPE_OBJECT_PATH);
+       adapter_path = v ? g_variant_get_string (v, NULL) : NULL;
+
+       v = g_variant_lookup_value (dict, "Address", G_VARIANT_TYPE_STRING);
        address = v ? g_variant_get_string (v, NULL) : NULL;
 
-       v = g_variant_lookup_value (ret, "Alias", G_VARIANT_TYPE_STRING);
+       v = g_variant_lookup_value (dict, "Alias", G_VARIANT_TYPE_STRING);
        alias = v ? g_variant_get_string (v, NULL) : NULL;
 
-       v = g_variant_lookup_value (ret, "Name", G_VARIANT_TYPE_STRING);
+       v = g_variant_lookup_value (dict, "Name", G_VARIANT_TYPE_STRING);
        name = v ? g_variant_get_string (v, NULL) : NULL;
 
-       v = g_variant_lookup_value (ret, "Class", G_VARIANT_TYPE_UINT32);
+       v = g_variant_lookup_value (dict, "Class", G_VARIANT_TYPE_UINT32);
        type = v ? bluetooth_class_to_type (g_variant_get_uint32 (v)) : BLUETOOTH_TYPE_ANY;
 
-       v = g_variant_lookup_value (ret, "Icon", G_VARIANT_TYPE_STRING);
+       v = g_variant_lookup_value (dict, "Icon", G_VARIANT_TYPE_STRING);
        icon = v ? g_variant_get_string (v, NULL) : "bluetooth";
 
-       v = g_variant_lookup_value (ret, "Paired", G_VARIANT_TYPE_BOOLEAN);
+       v = g_variant_lookup_value (dict, "Paired", G_VARIANT_TYPE_BOOLEAN);
        paired = v ? g_variant_get_boolean (v) : FALSE;
 
-       v = g_variant_lookup_value (ret, "Trusted", G_VARIANT_TYPE_BOOLEAN);
+       v = g_variant_lookup_value (dict, "Trusted", G_VARIANT_TYPE_BOOLEAN);
        trusted = v ? g_variant_get_boolean (v) : FALSE;
 
-       v = g_variant_lookup_value (ret, "Connected", G_VARIANT_TYPE_BOOLEAN);
+       v = g_variant_lookup_value (dict, "Connected", G_VARIANT_TYPE_BOOLEAN);
        connected = v ? g_variant_get_boolean (v) : FALSE;
 
-       v = g_variant_lookup_value (ret, "UUIDs", G_VARIANT_TYPE_STRING_ARRAY);
+       v = g_variant_lookup_value (dict, "UUIDs", G_VARIANT_TYPE_STRING_ARRAY);
        uuids = device_list_uuids (v);
 
-       v = g_variant_lookup_value (ret, "LegacyPairing", G_VARIANT_TYPE_BOOLEAN);
+       v = g_variant_lookup_value (dict, "LegacyPairing", G_VARIANT_TYPE_BOOLEAN);
        legacypairing = v ? g_variant_get_boolean (v) : -1;
 
-       if (get_iter_from_address (priv->store, &iter, address, G_DBUS_PROXY (adapter)) == FALSE)
-               gtk_tree_store_insert (priv->store, &iter, parent, -1);
+  if (get_iter_from_path (priv->store, &parent, adapter_path) == FALSE)
+    return;
+
+  gtk_tree_model_get (GTK_TREE_MODEL(priv->store), &parent,
+                     BLUETOOTH_COLUMN_PROXY, &adapter, -1);
+
+       if (get_iter_from_address (priv->store, &iter, address, adapter) == FALSE)
+               gtk_tree_store_insert (priv->store, &iter, &parent, -1);
 
        gtk_tree_store_set(priv->store, &iter,
                           BLUETOOTH_COLUMN_ADDRESS, address,
@@ -587,60 +598,37 @@ add_device (Adapter         *adapter,
                           BLUETOOTH_COLUMN_UUIDS, uuids,
                           BLUETOOTH_COLUMN_PAIRED, paired,
                           -1);
-       g_strfreev (uuids);
+  g_strfreev (uuids);
 
-       if (device != NULL) {
-               GHashTable *services;
+  services = device_list_nodes (device, client);
 
-               services = device_list_nodes (device, client);
+  gtk_tree_store_set(priv->store, &iter,
+                     BLUETOOTH_COLUMN_PROXY, device,
+                     BLUETOOTH_COLUMN_CONNECTED, connected,
+                     BLUETOOTH_COLUMN_TRUSTED, trusted,
+                     BLUETOOTH_COLUMN_SERVICES, services,
+                     -1);
 
-               gtk_tree_store_set(priv->store, &iter,
-                                  BLUETOOTH_COLUMN_PROXY, device,
-                                  BLUETOOTH_COLUMN_CONNECTED, connected,
-                                  BLUETOOTH_COLUMN_TRUSTED, trusted,
-                                  BLUETOOTH_COLUMN_SERVICES, services,
-                                  -1);
-
-               if (services != NULL)
-                       g_hash_table_unref (services);
-       }
-       g_variant_unref (ret);
-
-       if (device != NULL) {
-               g_signal_connect (G_OBJECT (device), "g-signal",
-                                 G_CALLBACK (device_g_signal), client);
-               g_object_unref (device);
-       }
-}
-
-static void
-device_found (Adapter         *adapter,
-             const char      *address,
-             GVariant        *dict,
-             BluetoothClient *client)
-{
-       BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
-       GtkTreeIter iter;
+  if (services != NULL)
+    g_hash_table_unref (services);
 
-       if (get_iter_from_proxy(priv->store, &iter, G_DBUS_PROXY (adapter)) == TRUE)
-               add_device(adapter, &iter, client, NULL, dict);
-}
-
-static void
-device_created (Adapter         *adapter,
-               const char      *path,
-               BluetoothClient *client)
-{
-       BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
-       GtkTreeIter iter;
+       proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                              G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+                                              NULL, BLUEZ_SERVICE, path, FDO_PROPERTIES_INTERFACE, NULL, 
NULL);
 
-       if (get_iter_from_proxy(priv->store, &iter, G_DBUS_PROXY (adapter)) == TRUE)
-               add_device(adapter, &iter, client, path, NULL);
+       if (proxy != NULL)
+    {
+      g_object_set_data_full (G_OBJECT (device), FDO_PROPERTIES_INTERFACE,
+                              proxy, g_object_unref);
+      g_signal_connect (G_OBJECT (proxy), "g-signal",
+                        G_CALLBACK (device_g_signal), client);
+    }
+
+  g_object_unref (device);
 }
 
 static void
-device_removed (GDBusProxy      *adapter,
-               const char      *path,
+device_removed (const char      *path,
                BluetoothClient *client)
 {
        BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
@@ -652,66 +640,128 @@ device_removed (GDBusProxy      *adapter,
 
 static void
 adapter_changed (GDBusProxy      *adapter,
-                const char      *property,
-                GVariant        *value,
+                const char      *interface,
+                GVariant        *changed_p,
+                GVariant        *invalidated_p,
                 BluetoothClient *client)
 {
        BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+  GVariantIter i;
+  const char *property;
        GtkTreeIter iter;
+  GVariant *value, *v;
        gboolean notify = FALSE;
 
        if (get_iter_from_proxy(priv->store, &iter, adapter) == FALSE)
                return;
 
-       if (g_str_equal(property, "Name") == TRUE) {
-               const gchar *name = g_variant_get_string (value, NULL);
-               gboolean is_default;
+  g_variant_iter_init (&i, changed_p);
+  while ((value = g_variant_iter_next_value (&i)))
+    {
+                 g_variant_get (value, "{sv}", &property, &v);
+
+      if (g_str_equal(property, "Name") == TRUE) {
+        const gchar *name = g_variant_get_string (v, NULL);
+        gboolean is_default;
+
+        gtk_tree_store_set(priv->store, &iter,
+              BLUETOOTH_COLUMN_NAME, name, -1);
+        gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+               BLUETOOTH_COLUMN_DEFAULT, &is_default, -1);
+        if (is_default != FALSE)
+          g_object_notify (G_OBJECT (client), "default-adapter-powered");
+        notify = TRUE;
+      } else if (g_str_equal(property, "Discovering") == TRUE) {
+        gboolean discovering = g_variant_get_boolean(v);
+
+        gtk_tree_store_set(priv->store, &iter,
+            BLUETOOTH_COLUMN_DISCOVERING, discovering, -1);
+        notify = TRUE;
+      } else if (g_str_equal(property, "Powered") == TRUE) {
+        gboolean powered = g_variant_get_boolean(v);
+        gboolean is_default;
+
+        gtk_tree_store_set(priv->store, &iter,
+               BLUETOOTH_COLUMN_POWERED, powered, -1);
+        gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+               BLUETOOTH_COLUMN_DEFAULT, &is_default, -1);
+        if (is_default != FALSE)
+          g_object_notify (G_OBJECT (client), "default-adapter-powered");
+        notify = TRUE;
+      } else if (g_str_equal(property, "Discoverable") == TRUE) {
+        gboolean discoverable = g_variant_get_boolean(v);
+        gboolean is_default;
+
+        gtk_tree_store_set(priv->store, &iter,
+               BLUETOOTH_COLUMN_DISCOVERABLE, discoverable, -1);
+        gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+               BLUETOOTH_COLUMN_DEFAULT, &is_default, -1);
+        if (is_default != FALSE)
+          g_object_notify (G_OBJECT (client), "default-adapter-discoverable");
+        notify = TRUE;
+      }
+
+      if (notify != FALSE) {
+        GtkTreePath *path;
+
+        /* Tell the world */
+        path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->store), &iter);
+        gtk_tree_model_row_changed (GTK_TREE_MODEL (priv->store), path, &iter);
+        gtk_tree_path_free (path);
+      }
+      g_variant_unref (value);
+    }
 
-               gtk_tree_store_set(priv->store, &iter,
-                                       BLUETOOTH_COLUMN_NAME, name, -1);
-               gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
-                                  BLUETOOTH_COLUMN_DEFAULT, &is_default, -1);
-               if (is_default != FALSE)
-                       g_object_notify (G_OBJECT (client), "default-adapter-powered");
-               notify = TRUE;
-       } else if (g_str_equal(property, "Discovering") == TRUE) {
-               gboolean discovering = g_variant_get_boolean(value);
+}
 
-               gtk_tree_store_set(priv->store, &iter,
-                               BLUETOOTH_COLUMN_DISCOVERING, discovering, -1);
-               notify = TRUE;
-       } else if (g_str_equal(property, "Powered") == TRUE) {
-               gboolean powered = g_variant_get_boolean(value);
-               gboolean is_default;
+static void
+default_adapter_changed (ObjectManager         *manager,
+                        const char      *path,
+                        BluetoothClient *client)
+{
+       BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+       GtkTreeIter iter;
+       gboolean cont;
 
-               gtk_tree_store_set(priv->store, &iter,
-                                  BLUETOOTH_COLUMN_POWERED, powered, -1);
-               gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
-                                  BLUETOOTH_COLUMN_DEFAULT, &is_default, -1);
-               if (is_default != FALSE)
-                       g_object_notify (G_OBJECT (client), "default-adapter-powered");
-               notify = TRUE;
-       } else if (g_str_equal(property, "Discoverable") == TRUE) {
-               gboolean discoverable = g_variant_get_boolean(value);
-               gboolean is_default;
+       cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store),
+                                                                       &iter);
+       if (priv->default_adapter) {
+               gtk_tree_row_reference_free (priv->default_adapter);
+               priv->default_adapter = NULL;
+       }
+
+       while (cont == TRUE) {
+               GDBusProxy *adapter;
+               const char *adapter_path;
+               gboolean found, powered;
 
-               gtk_tree_store_set(priv->store, &iter,
-                                  BLUETOOTH_COLUMN_DISCOVERABLE, discoverable, -1);
                gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
-                                  BLUETOOTH_COLUMN_DEFAULT, &is_default, -1);
-               if (is_default != FALSE)
-                       g_object_notify (G_OBJECT (client), "default-adapter-discoverable");
-               notify = TRUE;
-       }
+                                  BLUETOOTH_COLUMN_PROXY, &adapter,
+                                  BLUETOOTH_COLUMN_POWERED, &powered, -1);
+
+               adapter_path = g_dbus_proxy_get_object_path(adapter);
 
-       if (notify != FALSE) {
-               GtkTreePath *path;
+               found = g_str_equal(path, adapter_path);
 
-               /* Tell the world */
-               path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->store), &iter);
-               gtk_tree_model_row_changed (GTK_TREE_MODEL (priv->store), path, &iter);
-               gtk_tree_path_free (path);
+               g_object_unref(adapter);
+
+               if (found != FALSE) {
+                       GtkTreePath *tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->store), 
&iter);
+                       priv->default_adapter = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->store), 
tree_path);
+                       gtk_tree_path_free (tree_path);
+               }
+
+               gtk_tree_store_set(priv->store, &iter,
+                                       BLUETOOTH_COLUMN_DEFAULT, found, -1);
+
+               cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store),
+                                                                       &iter);
        }
+
+       /* Record the new default adapter */
+       g_object_notify (G_OBJECT (client), "default-adapter");
+       g_object_notify (G_OBJECT (client), "default-adapter-powered");
+       g_object_notify (G_OBJECT (client), "default-adapter-discoverable");
 }
 
 static void
@@ -721,85 +771,54 @@ adapter_g_signal (GDBusProxy      *proxy,
                  GVariant        *parameters,
                  BluetoothClient *client)
 {
-       if (g_strcmp0 (signal_name, "PropertyChanged") == 0) {
-               char *property;
-               GVariant *variant;
-
-               g_variant_get (parameters, "(sv)", &property, &variant);
-               adapter_changed (proxy, property, variant, client);
-               g_free (property);
-               g_variant_unref (variant);
-       } else if (g_strcmp0 (signal_name, "DeviceCreated") == 0) {
-               char *object_path;
-               g_variant_get (parameters, "(o)", &object_path);
-               device_created (ADAPTER (proxy), object_path, client);
-               g_free (object_path);
-       } else if (g_strcmp0 (signal_name, "DeviceRemoved") == 0) {
-               char *object_path;
-               g_variant_get (parameters, "(o)", &object_path);
-               device_removed (proxy, object_path, client);
-               g_free (object_path);
-       } else if (g_strcmp0 (signal_name, "DeviceFound") == 0) {
-               char *address;
-               GVariant *dict;
-               g_variant_get (parameters, "(s a{sv})", &address, &dict);
-               device_found (ADAPTER (proxy), address, dict, client);
-               g_free (address);
-               g_variant_unref (dict);
+       if (g_strcmp0 (signal_name, "PropertiesChanged") == 0) {
+               char *interface;
+               GVariant *changed_p, *invalidated_p;
+
+               g_variant_get (parameters, "(s**)", &interface, &changed_p, &invalidated_p);
+               adapter_changed (proxy, interface, changed_p, invalidated_p, client);
+               g_free (interface);
+               g_variant_unref (changed_p);
+               g_variant_unref (invalidated_p);
        }
 }
 
 static void
-adapter_added (Manager         *manager,
-              const char      *path,
+adapter_added (ObjectManager         *manager,
+         const char            *path,
+         GVariant        *variant,
               BluetoothClient *client)
 {
        BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
        GtkTreeIter iter;
-       Adapter *adapter;
-       const char **devices;
-       GVariant *variant;
+       Adapter1 *adapter;
        const gchar *address, *name;
+  GVariant *v, *dict;
        gboolean discovering, discoverable, powered;
+       GDBusProxy *proxy;
 
-       variant = NULL;
-       adapter = adapter_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
-                                                 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
-                                                 BLUEZ_SERVICE,
-                                                 path,
-                                                 NULL,
-                                                 NULL);
-
-       if (adapter_call_get_properties_sync (adapter, &variant, NULL, NULL) == TRUE) {
-               GVariant *v;
 
-               v = g_variant_lookup_value (variant, "Address", G_VARIANT_TYPE_STRING);
-               address = v ? g_variant_get_string (v, NULL) : NULL;
+       adapter = adapter1_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                                 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+                                                 BLUEZ_SERVICE, path, NULL, NULL);
 
-               v = g_variant_lookup_value (variant, "Name", G_VARIANT_TYPE_STRING);
-               name = v ? g_variant_get_string (v, NULL) : NULL;
+  dict = g_variant_lookup_value (variant, "org.bluez.Adapter1",
+                              G_VARIANT_TYPE_DICTIONARY);
 
-               v = g_variant_lookup_value (variant, "Discovering", G_VARIANT_TYPE_BOOLEAN);
-               discovering = v ? g_variant_get_boolean (v) : FALSE;
+  v = g_variant_lookup_value (dict, "Address", G_VARIANT_TYPE_STRING);
+  address = v ? g_variant_get_string (v, NULL) : NULL;
 
-               v = g_variant_lookup_value (variant, "Powered", G_VARIANT_TYPE_BOOLEAN);
-               powered = v ? g_variant_get_boolean (v) : FALSE;
+  v = g_variant_lookup_value (dict, "Name", G_VARIANT_TYPE_STRING);
+  name = v ? g_variant_get_string (v, NULL) : NULL;
 
-               v = g_variant_lookup_value (variant, "Devices", G_VARIANT_TYPE_OBJECT_PATH_ARRAY);
-               devices = v ? g_variant_get_objv (v, NULL) : NULL;
+  v = g_variant_lookup_value (dict, "Discovering", G_VARIANT_TYPE_BOOLEAN);
+  discovering = v ? g_variant_get_boolean (v) : FALSE;
 
-               v = g_variant_lookup_value (variant, "Discoverable", G_VARIANT_TYPE_BOOLEAN);
-               discoverable = v ? g_variant_get_boolean (v) : FALSE;
+  v = g_variant_lookup_value (dict, "Powered", G_VARIANT_TYPE_BOOLEAN);
+  powered = v ? g_variant_get_boolean (v) : FALSE;
 
-               g_variant_unref (variant);
-       } else {
-               address = NULL;
-               name = NULL;
-               discovering = FALSE;
-               discoverable = FALSE;
-               powered = FALSE;
-               devices = NULL;
-       }
+  v = g_variant_lookup_value (dict, "Discoverable", G_VARIANT_TYPE_BOOLEAN);
+  discoverable = v ? g_variant_get_boolean (v) : FALSE;
 
        gtk_tree_store_insert_with_values(priv->store, &iter, NULL, -1,
                                          BLUETOOTH_COLUMN_PROXY, adapter,
@@ -810,23 +829,26 @@ adapter_added (Manager         *manager,
                                          BLUETOOTH_COLUMN_POWERED, powered,
                                          -1);
 
-       g_signal_connect (G_OBJECT (adapter), "g-signal",
-                         G_CALLBACK (adapter_g_signal), client);
+       proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                              G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+                                              NULL, BLUEZ_SERVICE, path, FDO_PROPERTIES_INTERFACE, NULL,
+                                              NULL);
 
-       if (devices != NULL) {
-               guint i;
+       if (proxy != NULL)
+    {
+      g_object_set_data_full (G_OBJECT (adapter), FDO_PROPERTIES_INTERFACE,
+                              proxy, g_object_unref);
+      g_signal_connect (G_OBJECT (proxy), "g-signal",
+                        G_CALLBACK (adapter_g_signal), client);
+    }
 
-               for (i = 0; devices[i] != NULL; i++) {
-                       device_created (adapter, devices[i], client);
-               }
-               g_free (devices);
-       }
+       default_adapter_changed(manager, path, client);
 
        g_object_unref (adapter);
 }
 
 static void
-adapter_removed (Manager         *manager,
+adapter_removed (ObjectManager         *manager,
                 const char      *path,
                 BluetoothClient *client)
 {
@@ -869,75 +891,73 @@ adapter_removed (Manager         *manager,
 }
 
 static void
-default_adapter_changed (Manager         *manager,
-                        const char      *path,
-                        BluetoothClient *client)
+interface_added(BluetoothClient *client,
+                const char *path,
+                GVariant   *variant)
 {
        BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
-       GtkTreeIter iter;
-       gboolean cont;
-
-       cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store),
-                                                                       &iter);
-       if (priv->default_adapter) {
-               gtk_tree_row_reference_free (priv->default_adapter);
-               priv->default_adapter = NULL;
-       }
-
-       while (cont == TRUE) {
-               GDBusProxy *adapter;
-               const char *adapter_path;
-               gboolean found, powered;
-
-               gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
-                                  BLUETOOTH_COLUMN_PROXY, &adapter,
-                                  BLUETOOTH_COLUMN_POWERED, &powered, -1);
-
-               adapter_path = g_dbus_proxy_get_object_path(adapter);
-
-               found = g_str_equal(path, adapter_path);
-
-               g_object_unref(adapter);
-
-               if (found != FALSE) {
-                       GtkTreePath *tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->store), 
&iter);
-                       priv->default_adapter = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->store), 
tree_path);
-                       gtk_tree_path_free (tree_path);
-               }
 
-               gtk_tree_store_set(priv->store, &iter,
-                                       BLUETOOTH_COLUMN_DEFAULT, found, -1);
-
-               cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store),
-                                                                       &iter);
-       }
+  if (g_variant_lookup_value (variant, "org.bluez.Adapter1",
+                              G_VARIANT_TYPE_DICTIONARY))
+  {
+    g_print("new adapter\n");
+    adapter_added(priv->manager, path, variant, client);
+    return;
+  }
+
+  if (g_variant_lookup_value (variant, "org.bluez.Device1",
+                              G_VARIANT_TYPE_DICTIONARY))
+  {
+    g_print("new device\n");
+    device_added(priv->manager, client, path, variant);
+    return;
+  }
+}
 
-       /* Record the new default adapter */
-       g_object_notify (G_OBJECT (client), "default-adapter");
-       g_object_notify (G_OBJECT (client), "default-adapter-powered");
-       g_object_notify (G_OBJECT (client), "default-adapter-discoverable");
+static void
+interface_removed(BluetoothClient *client,
+                const char *path,
+                GVariant   *variant)
+{
+       BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+  const char **ifaces;
+  int i;
+
+       ifaces = g_variant_get_strv (variant, NULL);
+
+  for (i = 0 ; ifaces[i] != NULL ; i++)
+    {
+      if (g_strcmp0(ifaces[i], "org.bluez.Adapter1") == 0)
+        {
+          adapter_removed(priv->manager, path, client);
+          return;
+        }
+
+      if (g_strcmp0(ifaces[i], "org.bluez.Device1") == 0)
+        {
+          device_removed (path, client);
+          return;
+        }
+
+    }
 }
 
 static void
-manager_g_signal (GDBusProxy      *proxy,
+object_manager_g_signal (GDBusProxy      *proxy,
                  gchar           *sender_name,
                  gchar           *signal_name,
                  GVariant        *parameters,
                  BluetoothClient *client)
 {
        char *object_path;
+  GVariant *variant;
 
-       if (g_strcmp0 (signal_name, "PropertyChanged") == 0)
-               return;
-
-       g_variant_get (parameters, "(o)", &object_path);
+       g_variant_get (parameters, "(o*)", &object_path, &variant);
 
-       if (g_strcmp0 (signal_name, "AdapterAdded") == 0) {
-               adapter_added (MANAGER (proxy), object_path, client);
-       } else if (g_strcmp0 (signal_name, "AdapterRemoved") == 0) {
-               adapter_removed (MANAGER (proxy), object_path, client);
-       } else if (g_strcmp0 (signal_name, "DefaultAdapterChanged") == 0) {
-               default_adapter_changed (MANAGER (proxy), object_path, client);
+       if (g_strcmp0 (signal_name, "InterfacesAdded") == 0) {
+               interface_added (client, object_path, variant);
+       } else if (g_strcmp0 (signal_name, "InterfacesRemoved") == 0) {
+               interface_removed (client, object_path, variant);
        } else {
                g_assert_not_reached ();
        }
@@ -952,11 +972,12 @@ bluez_appeared_cb (GDBusConnection *connection,
                   BluetoothClient *client)
 {
        BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
-       GVariant *variant;
-       const char **array;
-       gchar *default_path = NULL;
+  GVariantIter iter;
+       GVariant *variant, *v, *ifaces;
+  char *key;
 
-       priv->manager = manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+       priv->manager = object_manager_proxy_new_for_bus_sync (
+              G_BUS_TYPE_SYSTEM,
                                                        G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
                                                        BLUEZ_SERVICE,
                                                        BLUEZ_MANAGER_PATH,
@@ -964,31 +985,23 @@ bluez_appeared_cb (GDBusConnection *connection,
                                                        NULL);
 
        g_signal_connect (G_OBJECT (priv->manager), "g-signal",
-                         G_CALLBACK (manager_g_signal), client);
+                         G_CALLBACK (object_manager_g_signal), client);
 
        variant = NULL;
-       manager_call_get_properties_sync (MANAGER (priv->manager), &variant, NULL, NULL);
-       if (variant != NULL) {
-               GVariant *v;
-               guint i;
-
-               v = g_variant_lookup_value (variant, "Adapters", G_VARIANT_TYPE_OBJECT_PATH_ARRAY);
-               array = v ? g_variant_get_objv (v, NULL) : NULL;
-
-               if (array != NULL) {
-                       for (i = 0; array[i] != NULL; i++)
-                               adapter_added(priv->manager, array[i], client);
-                       g_free (array);
-               }
+  object_manager_call_get_managed_objects_sync (OBJECT_MANAGER (priv->manager),
+                                                &variant, NULL, NULL);
+       if (variant == NULL)
+    return;
 
-               g_variant_unref (variant);
-       }
+  g_variant_iter_init (&iter, variant);
+  while ((v = g_variant_iter_next_value(&iter)))
+    {
+      g_variant_get(v, "{o*}", &key, &ifaces);
 
-       manager_call_default_adapter_sync (priv->manager, &default_path, NULL, NULL);
-       if (default_path != NULL) {
-               default_adapter_changed (priv->manager, default_path, client);
-               g_free(default_path);
-       }
+      interface_added(client, key, ifaces);
+    }
+
+  g_variant_unref (variant);
 }
 
 static void
@@ -1152,6 +1165,8 @@ _bluetooth_client_set_discoverable (BluetoothClient *client,
 {
        GError *error = NULL;
        GDBusProxy *adapter;
+  Properties *properties;
+  const char *path;
        gboolean ret;
 
        g_return_val_if_fail (BLUETOOTH_IS_CLIENT (client), FALSE);
@@ -1160,8 +1175,31 @@ _bluetooth_client_set_discoverable (BluetoothClient *client,
        if (adapter == NULL)
                return FALSE;
 
+  path = g_dbus_proxy_get_object_path(adapter);
+
+       properties = properties_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                              G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+                                              BLUEZ_SERVICE, path, NULL, NULL);
+
+       if (properties == NULL)
+    return FALSE;
+
+  ret =properties_call_set_sync(properties, BLUEZ_ADAPTER_INTERFACE, "Discoverable",
+                                              g_variant_new_variant (g_variant_new_boolean (discoverable)),
+                                                    NULL, &error);
+       if (ret == FALSE) {
+
+               g_warning ("Failed to set Discoverable to %d: %s", discoverable, error->message);
+               g_error_free (error);
+       }
+
+       g_object_unref(adapter);
+
+       return ret;
+
+  /*
        if (discoverable) {
-               ret = adapter_call_set_property_sync (ADAPTER (adapter),
+               ret = adapter_call_set_property_sync (ADAPTER1 (adapter),
                                                      "DiscoverableTimeout",
                                                      g_variant_new_variant (g_variant_new_uint32 (timeout)),
                                                      NULL, &error);
@@ -1172,19 +1210,7 @@ _bluetooth_client_set_discoverable (BluetoothClient *client,
                        return ret;
                }
        }
-
-       ret = adapter_call_set_property_sync (ADAPTER (adapter),
-                                             "Discoverable",
-                                             g_variant_new_variant (g_variant_new_boolean (discoverable)),
-                                             NULL, &error);
-       if (ret == FALSE) {
-               g_warning ("Failed to set Discoverable to %d: %s", discoverable, error->message);
-               g_error_free (error);
-       }
-
-       g_object_unref(adapter);
-
-       return ret;
+  */
 }
 
 static void
@@ -1198,9 +1224,9 @@ _bluetooth_client_set_default_adapter_discovering (BluetoothClient *client,
                return;
 
        if (discover)
-               adapter_call_start_discovery_sync (ADAPTER (adapter), NULL, NULL);
+               adapter1_call_start_discovery_sync (ADAPTER1 (adapter), NULL, NULL);
        else
-               adapter_call_stop_discovery_sync (ADAPTER (adapter), NULL, NULL);
+               adapter1_call_stop_discovery_sync (ADAPTER1 (adapter), NULL, NULL);
 
        g_object_unref(adapter);
 }
@@ -1547,7 +1573,7 @@ create_device_callback (GDBusProxy       *proxy,
        g_free (devdata);
 }
 
-gboolean bluetooth_client_create_device (BluetoothClient *client,
+gboolean bluetooth_client_pair (BluetoothClient *client,
                                         const char *address,
                                         const char *agent,
                                         BluetoothClientCreateDeviceFunc func,
@@ -1577,7 +1603,7 @@ gboolean bluetooth_client_create_device (BluetoothClient *client,
                                    BLUETOOTH_COLUMN_PAIRED, &paired, -1);
                if (device != NULL &&
                    paired != FALSE &&
-                   adapter_call_remove_device_sync (ADAPTER (adapter),
+                   adapter1_call_remove_device_sync (ADAPTER1 (adapter),
                                                     g_dbus_proxy_get_object_path (device),
                                                     NULL, &err) == FALSE) {
                        g_warning ("Failed to remove device '%s': %s", address,
@@ -1638,10 +1664,12 @@ bluetooth_client_set_trusted (BluetoothClient *client,
        if (proxy == NULL)
                return FALSE;
 
-       device_call_set_property_sync (DEVICE (proxy),
+  /*
+       device_call_set_property_sync (DEVICE1 (proxy),
                                       "Trusted",
                                       g_variant_new_variant (g_variant_new_boolean (trusted)),
                                       NULL, NULL);
+  */
 
        g_object_unref(proxy);
 
@@ -1652,7 +1680,7 @@ typedef struct {
        GSimpleAsyncResult *simple;
        /* used for disconnect */
        GList *services;
-       Device *device;
+       Device1 *device;
 } ConnectData;
 
 static void
@@ -1694,7 +1722,7 @@ disconnect_callback (GDBusProxy   *proxy,
        GError *error = NULL;
 
        if (conndata->services == NULL) {
-               retval = device_call_disconnect_finish (conndata->device, res, &error);
+               retval = device1_call_disconnect_finish (conndata->device, res, &error);
                if (retval == FALSE) {
                        g_debug ("Disconnect failed for %s: %s",
                                 g_dbus_proxy_get_object_path (G_DBUS_PROXY (conndata->device)),
@@ -1727,7 +1755,7 @@ disconnect_callback (GDBusProxy   *proxy,
                g_object_unref (proxy);
 
                client = (BluetoothClient *) g_async_result_get_source_object (G_ASYNC_RESULT 
(conndata->simple));
-               service = get_proxy_for_iface (DEVICE (conndata->device), conndata->services->data, client);
+               service = get_proxy_for_iface (DEVICE1 (conndata->device), conndata->services->data, client);
                g_object_unref (client);
 
                conndata->services = g_list_remove (conndata->services, conndata->services->data);
@@ -1879,7 +1907,7 @@ bluetooth_client_connect_service (BluetoothClient     *client,
                        goto bail;
                }
 
-               service = get_proxy_for_iface (DEVICE (proxy), iface_name, client);
+               service = get_proxy_for_iface (DEVICE1 (proxy), iface_name, client);
 
                g_debug ("Calling 'Connect' on interface %s for %s",
                         iface_name, g_dbus_proxy_get_object_path (service));
@@ -1895,7 +1923,7 @@ bluetooth_client_connect_service (BluetoothClient     *client,
        } else if (table != NULL) {
                GDBusProxy *service;
 
-               conndata->device = g_object_ref (DEVICE (proxy));
+               conndata->device = g_object_ref (DEVICE1 (proxy));
                conndata->services = g_hash_table_get_keys (table);
                g_hash_table_unref (table);
                conndata->services = g_list_sort (conndata->services, (GCompareFunc) rev_sort_services);
@@ -1918,7 +1946,7 @@ bluetooth_client_connect_service (BluetoothClient     *client,
        } else if (table == NULL) {
                g_debug ("Calling device_call_disconnect() for %s",
                         g_dbus_proxy_get_object_path (proxy));
-               device_call_disconnect (DEVICE (proxy),
+               device1_call_disconnect (DEVICE1 (proxy),
                                        NULL,
                                        (GAsyncReadyCallback) disconnect_callback,
                                        conndata);
diff --git a/lib/bluetooth-client.xml b/lib/bluetooth-client.xml
index 32d183e..04bfa5a 100644
--- a/lib/bluetooth-client.xml
+++ b/lib/bluetooth-client.xml
@@ -1,77 +1,59 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node name="/">
-  <interface name="org.bluez.Manager">
-    <method name="DefaultAdapter">
-      <arg type="o" direction="out"/>
-    </method>
-
-    <method name="GetProperties">
-      <arg type="a{sv}" direction="out"/>
-    </method>
-
-    <signal name="AdapterAdded">
-      <arg type="o"/>
-    </signal>
-    <signal name="AdapterRemoved">
-      <arg type="o"/>
-    </signal>
-    <signal name="DefaultAdapterChanged">
-      <arg type="o"/>
-    </signal>
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
+
+<node>
+  <interface name="org.bluez.Adapter1">
+    <method name="StartDiscovery"></method>
+    <method name="StopDiscovery"></method>
+    <method name="RemoveDevice"><arg name="device" type="o" direction="in"/></method>
+    <property name="Address" type="s" access="read"></property>
+    <property name="Name" type="s" access="read"></property>
+    <property name="Alias" type="s" access="readwrite"></property>
+    <property name="Class" type="u" access="read"></property>
+    <property name="Powered" type="b" access="readwrite"></property>
+    <property name="Discoverable" type="b" access="readwrite"></property>
+    <property name="DiscoverableTimeout" type="u" access="readwrite"></property>
+    <property name="Pairable" type="b" access="readwrite"></property>
+    <property name="PairableTimeout" type="u" access="readwrite"></property>
+    <property name="Discovering" type="b" access="read"></property>
+    <property name="UUIDs" type="as" access="read"></property>
+    <property name="Modalias" type="s" access="read"></property>
   </interface>
 
-  <interface name="org.bluez.Adapter">
-    <method name="GetProperties">
-      <arg type="a{sv}" direction="out"/>
-    </method>
-
-    <method name="SetProperty">
-      <arg type="s" direction="in"/>
-      <arg type="v" direction="in"/>
-    </method>
-
-    <method name="StartDiscovery">
-    </method>
-
-    <method name="StopDiscovery">
-    </method>
-
-    <method name="RemoveDevice">
-      <arg type="o" name="device" direction="in"/>
-    </method>
-
-    <signal name="PropertyChanged">
-      <arg type="s"/>
-      <arg type="v"/>
-    </signal>
-    <signal name="DeviceCreated">
-      <arg type="o"/>
-    </signal>
-    <signal name="DeviceRemoved">
-      <arg type="o"/>
-    </signal>
-    <signal name="DeviceFound">
-      <arg type="s"/>
-      <arg type="a{sv}"/>
-    </signal>
+  <interface name="org.bluez.Device1">
+    <method name="Disconnect"></method>
+    <method name="Connect"></method>
+    <method name="ConnectProfile"><arg name="UUID" type="s" direction="in"/> </method>
+    <method name="DisconnectProfile"><arg name="UUID" type="s" direction="in"/> </method>
+    <method name="Pair"></method>
+    <method name="CancelPairing"></method>
+    <property name="Address" type="s" access="read"></property>
+    <property name="Name" type="s" access="read"></property>
+    <property name="Alias" type="s" access="readwrite"></property>
+    <property name="Class" type="u" access="read"></property>
+    <property name="Appearance" type="q" access="read"></property>
+    <property name="Icon" type="s" access="read"></property>
+    <property name="Paired" type="b" access="read"></property>
+    <property name="Trusted" type="b" access="readwrite"></property>
+    <property name="Blocked" type="b" access="readwrite"></property>
+    <property name="LegacyPairing" type="b" access="read"></property>
+    <property name="RSSI" type="n" access="read"></property>
+    <property name="Connected" type="b" access="read"></property>
+    <property name="UUIDs" type="as" access="read"></property>
+    <property name="Modalias" type="s" access="read"></property>
+    <property name="Adapter" type="o" access="read"></property>
   </interface>
 
-  <interface name="org.bluez.Device">
-    <method name="GetProperties">
-      <arg type="a{sv}" direction="out"/>
+  <interface name="org.bluez.AgentManager1">
+    <method name="RegisterAgent">
+      <arg name="agent" type="o" direction="in"/>
+      <arg name="capability" type="s" direction="in"/>
     </method>
-
-    <method name="SetProperty">
-      <arg type="s" direction="in"/>
-      <arg type="v" direction="in"/>
+    <method name="UnregisterAgent">
+      <arg name="agent" type="o" direction="in"/>
+    </method>
+    <method name="RequestDefaultAgent">
+      <arg name="agent" type="o" direction="in"/>
     </method>
-
-    <method name="Disconnect"/>
-
-    <signal name="PropertyChanged">
-      <arg type="s"/>
-      <arg type="v"/>
-    </signal>
   </interface>
 </node>
diff --git a/lib/bluetooth-enums.h b/lib/bluetooth-enums.h
index 5874037..53fc882 100644
--- a/lib/bluetooth-enums.h
+++ b/lib/bluetooth-enums.h
@@ -128,6 +128,7 @@ typedef enum {
  * @BLUETOOTH_COLUMN_POWERED: whether the adapter is powered. Only available for adapters.
  * @BLUETOOTH_COLUMN_SERVICES: an array of service names and #BluetoothStatus connection statuses.
  * @BLUETOOTH_COLUMN_UUIDS: a string array of human-readable UUIDs.
+ * @BLUETOOTH_COLUMN_ADAPTER: a string representing a Adapter object path
  *
  * A column identifier to pass to bluetooth_chooser_get_selected_device_info().
  **/
@@ -148,6 +149,7 @@ typedef enum {
        BLUETOOTH_COLUMN_POWERED,
        BLUETOOTH_COLUMN_SERVICES,
        BLUETOOTH_COLUMN_UUIDS,
+       BLUETOOTH_COLUMN_PATH,
        /* < private > */
        _BLUETOOTH_NUM_COLUMNS /*< skip >*/
 } BluetoothColumn;
diff --git a/lib/bluetooth-fdo.xml b/lib/bluetooth-fdo.xml
new file mode 100644
index 0000000..398d613
--- /dev/null
+++ b/lib/bluetooth-fdo.xml
@@ -0,0 +1,33 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
+
+<node>
+  <interface name="org.freedesktop.DBus.ObjectManager">
+    <method name="GetManagedObjects"><arg name="objects" type="a{oa{sa{sv}}}" direction="out"/>
+    </method>
+    <signal name="InterfacesAdded"><arg name="object" type="o"/>
+      <arg name="interfaces" type="a{sa{sv}}"/>
+    </signal>
+    <signal name="InterfacesRemoved"><arg name="object" type="o"/>
+      <arg name="interfaces" type="as"/>
+    </signal>
+  </interface>
+
+  <interface name="org.freedesktop.DBus.Properties"><method name="Get"><arg name="interface" type="s" 
direction="in"/>
+      <arg name="name" type="s" direction="in"/>
+      <arg name="value" type="v" direction="out"/>
+    </method>
+    <method name="Set"><arg name="interface" type="s" direction="in"/>
+      <arg name="name" type="s" direction="in"/>
+      <arg name="value" type="v" direction="in"/>
+    </method>
+    <method name="GetAll"><arg name="interface" type="s" direction="in"/>
+      <arg name="properties" type="a{sv}" direction="out"/>
+    </method>
+    <signal name="PropertiesChanged"><arg name="interface" type="s"/>
+      <arg name="changed_properties" type="a{sv}"/>
+      <arg name="invalidated_properties" type="as"/>
+    </signal>
+  </interface>
+</node>
+
diff --git a/lib/gnome-bluetooth.symbols b/lib/gnome-bluetooth.symbols
index c78e4a8..3532028 100644
--- a/lib/gnome-bluetooth.symbols
+++ b/lib/gnome-bluetooth.symbols
@@ -16,7 +16,7 @@ bluetooth_chooser_stop_discovery
 bluetooth_chooser_button_get_type
 bluetooth_chooser_button_new
 bluetooth_chooser_button_available
-bluetooth_client_create_device
+bluetooth_client_pair
 bluetooth_client_dump_device
 bluetooth_client_get_type
 bluetooth_client_new
diff --git a/wizard/main.c b/wizard/main.c
index e5e252a..baaff65 100644
--- a/wizard/main.c
+++ b/wizard/main.c
@@ -501,7 +501,7 @@ void prepare_callback (GtkWidget *assistant,
                }
 
                g_object_ref(agent);
-               bluetooth_client_create_device (client, target_address,
+               bluetooth_client_pair (client, target_address,
                                                path, create_callback, assistant);
                create_started = TRUE;
        }


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