aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-08-24 20:10:19 -0500
committerTed Gould <ted@canonical.com>2009-08-24 20:10:19 -0500
commitfd8f49b1170f7e17aa050ad620296bb5315a8146 (patch)
tree458f7a97eccc18d47ae3322a967d678b8e55caf9
parentc8a0f5e7e5e674e8c20c9a1fe20d16fa436d9513 (diff)
downloadayatana-indicator-session-fd8f49b1170f7e17aa050ad620296bb5315a8146.tar.gz
ayatana-indicator-session-fd8f49b1170f7e17aa050ad620296bb5315a8146.tar.bz2
ayatana-indicator-session-fd8f49b1170f7e17aa050ad620296bb5315a8146.zip
Building up the proxy. We need one, it's important.
-rw-r--r--src/status-provider-telepathy.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/status-provider-telepathy.c b/src/status-provider-telepathy.c
index 60f34ef..334126b 100644
--- a/src/status-provider-telepathy.c
+++ b/src/status-provider-telepathy.c
@@ -76,6 +76,8 @@ static void status_provider_telepathy_finalize (GObject *object);
/* Internal Funcs */
static void set_status (StatusProvider * sp, StatusProviderStatus status);
static StatusProviderStatus get_status (StatusProvider * sp);
+static void changed_status (DBusGProxy * proxy, guint status, gchar * message, StatusProvider * sp);
+static void proxy_destroy (DBusGProxy * proxy, StatusProvider * sp);
G_DEFINE_TYPE (StatusProviderTelepathy, status_provider_telepathy, STATUS_PROVIDER_TYPE);
@@ -106,6 +108,44 @@ status_provider_telepathy_init (StatusProviderTelepathy *self)
priv->proxy = NULL;
priv->mc_status = MC_STATUS_OFFLINE;
+ GError * error = NULL;
+
+ DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+
+ priv->proxy = NULL;
+ priv->proxy = dbus_g_proxy_new_for_name_owner(session_bus,
+ "org.freedesktop.Telepathy.MissionControl",
+ "/org/freedesktop/Telepathy/MissionControl",
+ "org.freedesktop.Telepathy.MissionControl",
+ &error);
+
+ if (priv->proxy != NULL) {
+ g_object_add_weak_pointer (G_OBJECT(priv->proxy), (gpointer *)&priv->proxy);
+ g_signal_connect(G_OBJECT(priv->proxy), "destroy",
+ G_CALLBACK(proxy_destroy), self);
+
+ dbus_g_object_register_marshaller(_status_provider_telepathy_marshal_VOID__UINT_STRING,
+ G_TYPE_NONE,
+ G_TYPE_UINT,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (priv->proxy,
+ "PresenceChanged",
+ G_TYPE_UINT,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(priv->proxy,
+ "PresenceChanged",
+ G_CALLBACK(changed_status),
+ (void *)self,
+ NULL);
+ } else {
+ g_warning("Unable to connect to Mission Control");
+ if (error != NULL) {
+ g_error_free(error);
+ }
+ }
+
return;
}
@@ -156,5 +196,25 @@ static StatusProviderStatus
get_status (StatusProvider * sp)
{
StatusProviderTelepathyPrivate * priv = STATUS_PROVIDER_TELEPATHY_GET_PRIVATE(sp);
+
+ if (priv->proxy == NULL) {
+ return mc_to_sp_map[MC_STATUS_OFFLINE];
+ }
+
return mc_to_sp_map[priv->mc_status];
}
+
+static void
+changed_status (DBusGProxy * proxy, guint status, gchar * message, StatusProvider * sp)
+{
+ g_signal_emit(G_OBJECT(sp), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED_ID, 0, STATUS_PROVIDER_STATUS_OFFLINE, TRUE);
+}
+
+static void
+proxy_destroy (DBusGProxy * proxy, StatusProvider * sp)
+{
+ g_debug("Signal: Mission Control proxy destroyed");
+ g_signal_emit(G_OBJECT(sp), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED_ID, 0, STATUS_PROVIDER_STATUS_OFFLINE, TRUE);
+ return;
+}
+