diff options
-rw-r--r-- | ubuntu-online-accounts/mc-plugin/empathy-webcredentials-monitor.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/ubuntu-online-accounts/mc-plugin/empathy-webcredentials-monitor.c b/ubuntu-online-accounts/mc-plugin/empathy-webcredentials-monitor.c index e8911bc47..7e061368f 100644 --- a/ubuntu-online-accounts/mc-plugin/empathy-webcredentials-monitor.c +++ b/ubuntu-online-accounts/mc-plugin/empathy-webcredentials-monitor.c @@ -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); } @@ -102,10 +112,40 @@ empathy_webcredentials_monitor_class_init ( } 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 * |