]> git.0d.be Git - empathy.git/commitdiff
webcredentials-monitor: get a proxy on the D-Bus object
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 5 Sep 2012 08:47:41 +0000 (10:47 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 7 Sep 2012 07:14:13 +0000 (09:14 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=683409

ubuntu-online-accounts/mc-plugin/empathy-webcredentials-monitor.c

index e8911bc478bffb7292c799c74d5fcc231b3b7175..7e061368fa8b3c614a26394c39231e9bd7de4245 100644 (file)
@@ -1,9 +1,17 @@
 #include "config.h"
 
+#include <gio/gio.h>
+
+#include <telepathy-glib/telepathy-glib.h>
+
 #include "empathy-webcredentials-monitor.h"
 
 G_DEFINE_TYPE (EmpathyWebcredentialsMonitor, empathy_webcredentials_monitor, G_TYPE_OBJECT)
 
+#define WEBCRED_BUS_NAME "com.canonical.indicators.webcredentials"
+#define WEBCRED_PATH "/com/canonical/indicators/webcredentials"
+#define WEBCRED_IFACE "com.canonical.indicators.webcredentials"
+
 enum
 {
   FIRST_PROP = 1,
@@ -21,7 +29,7 @@ static guint signals[LAST_SIGNAL];
 
 struct _EmpathyWebcredentialsMonitorPriv
 {
-  gpointer badger;
+  GDBusProxy *proxy;
 };
 
 static void
@@ -69,10 +77,12 @@ empathy_webcredentials_monitor_constructed (GObject *object)
 static void
 empathy_webcredentials_monitor_dispose (GObject *object)
 {
-  //EmpathyWebcredentialsMonitor *self = EMPATHY_WEBCREDENTIALS_MONITOR (object);
+  EmpathyWebcredentialsMonitor *self = EMPATHY_WEBCREDENTIALS_MONITOR (object);
   void (*chain_up) (GObject *) =
       ((GObjectClass *) empathy_webcredentials_monitor_parent_class)->dispose;
 
+  g_clear_object (&self->priv->proxy);
+
   chain_up (object);
 }
 
@@ -101,11 +111,41 @@ empathy_webcredentials_monitor_class_init (
   g_type_class_add_private (klass, sizeof (EmpathyWebcredentialsMonitorPriv));
 }
 
+static void
+proxy_new_cb (GObject *source,
+    GAsyncResult *result,
+    gpointer user_data)
+{
+  EmpathyWebcredentialsMonitor *self;
+  TpWeakRef *wr = user_data;
+  GError *error = NULL;
+
+  self = tp_weak_ref_dup_object (wr);
+  if (self == NULL)
+    goto out;
+
+  self->priv->proxy = g_dbus_proxy_new_for_bus_finish (result, &error);
+  if (self->priv->proxy == NULL)
+    {
+      g_debug ("Failed to create webcredentials proxy: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+out:
+  tp_weak_ref_destroy (wr);
+  g_clear_object (&self);
+}
+
 static void
 empathy_webcredentials_monitor_init (EmpathyWebcredentialsMonitor *self)
 {
   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
       EMPATHY_TYPE_WEBCREDENTIALS_MONITOR, EmpathyWebcredentialsMonitorPriv);
+
+  g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL,
+      WEBCRED_BUS_NAME, WEBCRED_PATH, WEBCRED_IFACE,
+      NULL, proxy_new_cb, tp_weak_ref_new (self, NULL, NULL));
 }
 
 EmpathyWebcredentialsMonitor *