aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-11-06 12:25:29 -0600
committerTed Gould <ted@canonical.com>2009-11-06 12:25:29 -0600
commit10d1d2e0357629c137fa04c5436ab385eb46848b (patch)
tree66c9e081dc9148d16c4e0456d53351c82a2456df
parent7532947d4aabdee70733903cdd861a7c305ca987 (diff)
downloadayatana-indicator-application-10d1d2e0357629c137fa04c5436ab385eb46848b.tar.gz
ayatana-indicator-application-10d1d2e0357629c137fa04c5436ab385eb46848b.tar.bz2
ayatana-indicator-application-10d1d2e0357629c137fa04c5436ab385eb46848b.zip
Fleshing out connected to start bringing up the proxy.
-rw-r--r--src/dbus-shared.h4
-rw-r--r--src/indicator-custom.c39
2 files changed, 42 insertions, 1 deletions
diff --git a/src/dbus-shared.h b/src/dbus-shared.h
index 36436bd..6cec06b 100644
--- a/src/dbus-shared.h
+++ b/src/dbus-shared.h
@@ -1,3 +1,5 @@
-#define INDICATOR_CUSTOM_DBUS_ADDR "org.ayatana.indicator.custom"
+#define INDICATOR_CUSTOM_DBUS_ADDR "org.ayatana.indicator.custom"
+#define INDICATOR_CUSTOM_DBUS_OBJ "/org/ayatana/indicator/custom/service"
+#define INDICATOR_CUSTOM_DBUS_IFACE "org.ayatana.indicator.custom.service"
diff --git a/src/indicator-custom.c b/src/indicator-custom.c
index 8528a52..86eeffc 100644
--- a/src/indicator-custom.c
+++ b/src/indicator-custom.c
@@ -2,6 +2,8 @@
#include <glib.h>
#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+
#include <libindicator/indicator.h>
#include <libindicator/indicator-object.h>
#include <libindicator/indicator-service-manager.h>
@@ -41,6 +43,8 @@ typedef struct _IndicatorCustomPrivate IndicatorCustomPrivate;
struct _IndicatorCustomPrivate
{
IndicatorServiceManager * sm;
+ DBusGConnection * bus;
+ DBusGProxy * service_proxy;
};
#define INDICATOR_CUSTOM_GET_PRIVATE(o) \
@@ -77,9 +81,14 @@ indicator_custom_init (IndicatorCustom *self)
{
IndicatorCustomPrivate * priv = INDICATOR_CUSTOM_GET_PRIVATE(self);
+ /* These are built in the connection phase */
+ priv->bus = NULL;
+ priv->service_proxy = NULL;
+
priv->sm = indicator_service_manager_new(INDICATOR_CUSTOM_DBUS_ADDR);
g_signal_connect(G_OBJECT(priv->sm), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connected), self);
+
return;
}
@@ -93,6 +102,16 @@ indicator_custom_dispose (GObject *object)
priv->sm = NULL;
}
+ if (priv->bus != NULL) {
+ /* We're not incrementing the ref count on this one. */
+ priv->bus = NULL;
+ }
+
+ if (priv->service_proxy != NULL) {
+ g_object_unref(G_OBJECT(priv->service_proxy));
+ priv->service_proxy = NULL;
+ }
+
G_OBJECT_CLASS (indicator_custom_parent_class)->dispose (object);
return;
}
@@ -108,6 +127,26 @@ indicator_custom_finalize (GObject *object)
void
connected (IndicatorServiceManager * sm, gboolean connected, IndicatorCustom * custom)
{
+ IndicatorCustomPrivate * priv = INDICATOR_CUSTOM_GET_PRIVATE(custom);
+ g_debug("Connected to Custom Indicator Service.");
+
+ GError * error = NULL;
+
+ if (priv->bus == NULL) {
+ priv->bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+
+ if (error != NULL) {
+ g_error("Unable to get session bus: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+ }
+
+ priv->service_proxy = dbus_g_proxy_new_for_name_owner(priv->bus,
+ INDICATOR_CUSTOM_DBUS_ADDR,
+ INDICATOR_CUSTOM_DBUS_OBJ,
+ INDICATOR_CUSTOM_DBUS_IFACE,
+ &error);
return;
}