aboutsummaryrefslogtreecommitdiff
path: root/libindicator
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2009-12-01 13:44:30 -0600
committerTed Gould <ted@gould.cx>2009-12-01 13:44:30 -0600
commit4ba1af342c78aefdf5dc163163c80de6b25f85ec (patch)
tree70b942874aa7a724effc65a8ddbfb60aed56f222 /libindicator
parent5757cfb41340a7bc73bd5a4f13de5447121d4d6d (diff)
downloadlibayatana-indicator-4ba1af342c78aefdf5dc163163c80de6b25f85ec.tar.gz
libayatana-indicator-4ba1af342c78aefdf5dc163163c80de6b25f85ec.tar.bz2
libayatana-indicator-4ba1af342c78aefdf5dc163163c80de6b25f85ec.zip
Trying to get a proxy before starting the service every time. If it exists, let's use it.
Diffstat (limited to 'libindicator')
-rw-r--r--libindicator/indicator-service-manager.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c
index d7e54bd..4dcc200 100644
--- a/libindicator/indicator-service-manager.c
+++ b/libindicator/indicator-service-manager.c
@@ -308,16 +308,43 @@ start_service_cb (DBusGProxy * proxy, guint status, GError * error, gpointer use
static void
start_service (IndicatorServiceManager * service)
{
+ GError * error = NULL;
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);
+ /* Check to see if we can get a proxy to it first. */
+ 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;
+ }
+
+ /* Tries to get the proxy first. */
+ priv->service_proxy = dbus_g_proxy_new_for_name_owner(session_bus,
+ priv->name,
+ INDICATOR_SERVICE_OBJECT,
+ INDICATOR_SERVICE_INTERFACE,
+ &error);
+
+ if (error != NULL) {
+ /* We don't care about the error, just start the service anyway. */
+ g_error_free(error);
+ org_freedesktop_DBus_start_service_by_name_async (priv->dbus_proxy,
+ priv->name,
+ 0,
+ start_service_cb,
+ service);
+ } else {
+ /* If we got a proxy just because we're good people then
+ we need to call watch on it just like 'start_service_cb'
+ does. */
+ org_ayatana_indicator_service_watch_async(priv->service_proxy,
+ watch_cb,
+ service);
+ }
return;
}