aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-09-10 13:08:56 -0500
committerTed Gould <ted@canonical.com>2009-09-10 13:08:56 -0500
commitec17d0a7bae74ab2f276b73e03b7d60877d3bcfa (patch)
treeec1dbbb85993cb6b6f3f5bcd47c3abcfa337257e
parent2ad97fd722286b1e9780c10efc3a87e42a0796c4 (diff)
downloadayatana-indicator-session-ec17d0a7bae74ab2f276b73e03b7d60877d3bcfa.tar.gz
ayatana-indicator-session-ec17d0a7bae74ab2f276b73e03b7d60877d3bcfa.tar.bz2
ayatana-indicator-session-ec17d0a7bae74ab2f276b73e03b7d60877d3bcfa.zip
Splitting out the building of the Pidgin proxy into it's own function.
-rw-r--r--src/status-provider-pidgin.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/status-provider-pidgin.c b/src/status-provider-pidgin.c
index e65dc54..f4704db 100644
--- a/src/status-provider-pidgin.c
+++ b/src/status-provider-pidgin.c
@@ -66,6 +66,7 @@ static const pg_status_t sp_to_pg_map[STATUS_PROVIDER_STATUS_LAST] = {
typedef struct _StatusProviderPidginPrivate StatusProviderPidginPrivate;
struct _StatusProviderPidginPrivate {
DBusGProxy * proxy;
+ DBusGProxy * dbus_proxy;
pg_status_t pg_status;
};
@@ -81,6 +82,7 @@ static void status_provider_pidgin_finalize (GObject *object);
/* Internal Funcs */
static void set_status (StatusProvider * sp, StatusProviderStatus status);
static StatusProviderStatus get_status (StatusProvider * sp);
+static void setup_pidgin_proxy (StatusProviderPidgin * self);
G_DEFINE_TYPE (StatusProviderPidgin, status_provider_pidgin, STATUS_PROVIDER_TYPE);
@@ -183,23 +185,51 @@ status_provider_pidgin_init (StatusProviderPidgin *self)
g_return_if_fail(bus != NULL); /* Can't do anymore DBus stuff without this,
all non-DBus stuff should be done */
+ /* GError * error = NULL; */
+
+ setup_pidgin_proxy(self);
+
+ return;
+}
+
+static void
+setup_pidgin_proxy (StatusProviderPidgin * self)
+{
+ StatusProviderPidginPrivate * priv = STATUS_PROVIDER_PIDGIN_GET_PRIVATE(self);
+
+ if (priv->proxy != NULL) {
+ g_debug("Odd, we were asked to set up a Pidgin proxy when we already had one.");
+ return;
+ }
+
+ DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
+ g_return_if_fail(bus != NULL); /* Can't do anymore DBus stuff without this,
+ all non-DBus stuff should be done */
+
GError * error = NULL;
+
+ /* Set up the Pidgin Proxy */
priv->proxy = dbus_g_proxy_new_for_name_owner (bus,
"im.pidgin.purple.PurpleService",
"/im/pidgin/purple/PurpleObject",
"im.pidgin.purple.PurpleInterface",
&error);
+ /* Report any errors */
if (error != NULL) {
g_debug("Unable to get Pidgin proxy: %s", error->message);
g_error_free(error);
- return;
}
+ /* If we have a proxy, let's start using it */
if (priv->proxy != NULL) {
+ /* Set the proxy to NULL if it's destroyed */
g_object_add_weak_pointer (G_OBJECT(priv->proxy), (gpointer *)&priv->proxy);
+ /* If it's destroyed, let's clean up as well */
g_signal_connect(G_OBJECT(priv->proxy), "destroy",
G_CALLBACK(proxy_destroy), self);
+ /* Watching for the status change coming from the
+ Pidgin side of things. */
g_debug("Adding Pidgin Signals");
dbus_g_object_register_marshaller(_status_provider_pidgin_marshal_VOID__INT_INT,
G_TYPE_NONE,
@@ -217,6 +247,8 @@ status_provider_pidgin_init (StatusProviderPidgin *self)
(void *)self,
NULL);
+ /* Get the current status to update our cached
+ value of the status. */
dbus_g_proxy_begin_call(priv->proxy,
"PurpleSavedstatusGetCurrent",
savedstatus_cb,