aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-10-08 16:12:42 -0400
committerTed Gould <ted@canonical.com>2009-10-08 16:12:42 -0400
commitba6b4a7919e681385be9e412cfd63e488a0fb10b (patch)
tree1213dd70d70fdd6b11dcf5264bf7b2c235b58b51
parent15705bea73cbf6d8a657cb72113bc8bcc1d78816 (diff)
downloadayatana-indicator-session-ba6b4a7919e681385be9e412cfd63e488a0fb10b.tar.gz
ayatana-indicator-session-ba6b4a7919e681385be9e412cfd63e488a0fb10b.tar.bz2
ayatana-indicator-session-ba6b4a7919e681385be9e412cfd63e488a0fb10b.zip
Checking to see if there is an MC5 there when we start.
-rw-r--r--src/status-provider-mc5.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/status-provider-mc5.c b/src/status-provider-mc5.c
index 613c3df..6154fb7 100644
--- a/src/status-provider-mc5.c
+++ b/src/status-provider-mc5.c
@@ -31,6 +31,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "status-provider-mc5-marshal.h"
#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
static gchar * sp_to_mc_map[STATUS_PROVIDER_STATUS_LAST] = {
/* STATUS_PROVIDER_STATUS_ONLINE, */ "available",
@@ -71,6 +72,7 @@ struct _StatusProviderMC5Private {
#define STATUS_PROVIDER_MC5_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), STATUS_PROVIDER_MC5_TYPE, StatusProviderMC5Private))
+#define MC5_WELL_KNOWN_NAME "org.freedesktop.Telepathy.MissionControl5"
/* Prototypes */
/* GObject stuff */
@@ -83,6 +85,7 @@ static void set_status (StatusProvider * sp, StatusProviderStatus status);
static StatusProviderStatus get_status (StatusProvider * sp);
static void presence_changed (EmpathyAccountManager * eam, guint type, const gchar * type_str, const gchar * message, StatusProviderMC5 * sp);
static void dbus_namechange (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, StatusProviderMC5 * self);
+static void mc5_exists_cb (DBusGProxy * proxy, gboolean exists, GError * error, gpointer userdata);
G_DEFINE_TYPE (StatusProviderMC5, status_provider_mc5, STATUS_PROVIDER_TYPE);
@@ -161,6 +164,8 @@ status_provider_mc5_init (StatusProviderMC5 *self)
G_CALLBACK(dbus_namechange),
self, NULL);
+ org_freedesktop_DBus_name_has_owner_async(priv->dbus_proxy, MC5_WELL_KNOWN_NAME, mc5_exists_cb, self);
+
return;
}
@@ -194,7 +199,6 @@ status_provider_mc5_finalize (GObject *object)
return;
}
-#define MC5_WELL_KNOWN_NAME "org.freedesktop.Telepathy.MissionControl5"
/* Watch for MC5 Coming on and off the bus. */
static void
dbus_namechange (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, StatusProviderMC5 * self)
@@ -220,6 +224,24 @@ dbus_namechange (DBusGProxy * proxy, const gchar * name, const gchar * prev, con
return;
}
+/* Callback for the Dbus command to do HasOwner on
+ the MC5 service. If it exists, we want to have an
+ account manager. */
+static void
+mc5_exists_cb (DBusGProxy * proxy, gboolean exists, GError * error, gpointer userdata)
+{
+ if (error) {
+ g_warning("Unable to check if MC5 is running: %s", error->message);
+ return;
+ }
+
+ if (exists) {
+ build_eam(STATUS_PROVIDER_MC5(userdata));
+ }
+
+ return;
+}
+
/**
status_provider_mc5_new: