aboutsummaryrefslogtreecommitdiff
path: root/libindicator
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-10-29 21:28:48 -0500
committerTed Gould <ted@canonical.com>2009-10-29 21:28:48 -0500
commit02ce4f5c45f255c4058f1f2c8d5545569b498e64 (patch)
tree9c63270ad7edb70d521b5f054a7687c63d0efabc /libindicator
parentc87569c1ac75b5a97318587df4d913e4841a913c (diff)
downloadlibayatana-indicator-02ce4f5c45f255c4058f1f2c8d5545569b498e64.tar.gz
libayatana-indicator-02ce4f5c45f255c4058f1f2c8d5545569b498e64.tar.bz2
libayatana-indicator-02ce4f5c45f255c4058f1f2c8d5545569b498e64.zip
Building the dbus proxy and using it a little bit.
Diffstat (limited to 'libindicator')
-rw-r--r--libindicator/indicator-service-manager.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c
index b15aaa8..011f9c6 100644
--- a/libindicator/indicator-service-manager.c
+++ b/libindicator/indicator-service-manager.c
@@ -2,12 +2,16 @@
#include "config.h"
#endif
+#include <dbus/dbus-glib-bindings.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
#include "indicator-service-manager.h"
/* Private Stuff */
typedef struct _IndicatorServiceManagerPrivate IndicatorServiceManagerPrivate;
struct _IndicatorServiceManagerPrivate {
gchar * name;
+ DBusGProxy * dbus_proxy;
};
/* Signals Stuff */
@@ -90,6 +94,31 @@ indicator_service_manager_class_init (IndicatorServiceManagerClass *klass)
static void
indicator_service_manager_init (IndicatorServiceManager *self)
{
+ IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(self);
+
+ /* Get the private variables in a decent state */
+ priv->name = NULL;
+ priv->dbus_proxy = NULL;
+
+ /* Start talkin' dbus */
+ GError * error = NULL;
+ DBusGConnection * session_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->dbus_proxy = dbus_g_proxy_new_for_name_owner(session_bus,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ &error);
+ if (error != NULL) {
+ g_error("Unable to get the proxy to DBus: %s", error->message);
+ g_error_free(error);
+ return;
+ }
return;
}
@@ -97,6 +126,12 @@ indicator_service_manager_init (IndicatorServiceManager *self)
static void
indicator_service_manager_dispose (GObject *object)
{
+ IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(object);
+
+ if (priv->dbus_proxy != NULL) {
+ g_object_unref(G_OBJECT(priv->dbus_proxy));
+ priv->dbus_proxy = NULL;
+ }
G_OBJECT_CLASS (indicator_service_manager_parent_class)->dispose (object);
return;
@@ -176,9 +211,36 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe
}
static void
+start_service_cb (DBusGProxy * proxy, guint status, GError * error, gpointer user_data)
+{
+ IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data);
+
+ if (error != NULL) {
+ g_error("Unable to start service '%s': %s", priv->name, error->message);
+ return;
+ }
+
+ if (status != DBUS_START_REPLY_SUCCESS && status != DBUS_START_REPLY_ALREADY_RUNNING) {
+ g_error("Status of starting the process '%s' was an error: %d", priv->name, status);
+ return;
+ }
+
+ return;
+}
+
+static void
start_service (IndicatorServiceManager * service)
{
+ IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(service);
+
+ g_return_if_fail(priv->dbus_proxy != NULL);
+ g_return_if_fail(priv->name != NULL);
+ org_freedesktop_DBus_start_service_by_name_async (priv->dbus_proxy,
+ priv->name,
+ 0,
+ start_service_cb,
+ service);
return;
}