aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--debian/changelog33
-rw-r--r--debian/control3
-rw-r--r--debian/patches/01_locking_on_autologin.patch15
-rw-r--r--debian/patches/02_mc5-fixes.patch182
-rwxr-xr-xdebian/rules1
-rw-r--r--src/indicator-session.c97
-rw-r--r--src/lock-helper.c2
-rw-r--r--src/status-provider-mc5.c103
-rw-r--r--src/status-provider-mc5.h4
10 files changed, 224 insertions, 218 deletions
diff --git a/configure.ac b/configure.ac
index 340177e..536b5af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
###########################
GTK_REQUIRED_VERSION=2.12
-INDICATOR_REQUIRED_VERSION=0.2.0
+INDICATOR_REQUIRED_VERSION=0.3.0
DBUSMENUGTK_REQUIRED_VERSION=0.1.1
POLKIT_REQUIRED_VERSION=0.92
diff --git a/debian/changelog b/debian/changelog
index 69760fd..148871c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+indicator-session (0.2.0~dev-0ubuntu1~ppa2) karmic; urgency=low
+
+ * debian/control
+ - build depend on libtelepathy-glib-dev instead of libempathy-dev
+
+ -- Ken VanDine <ken.vandine@canonical.com> Thu, 10 Dec 2009 10:42:21 -0500
+
indicator-session (0.1.7-0ubuntu5) lucid; urgency=low
* debian/patches/03_tp_glib.patch
@@ -18,6 +25,32 @@ indicator-session (0.1.7-0ubuntu4) lucid; urgency=low
-- Ken VanDine <ken.vandine@canonical.com> Tue, 08 Dec 2009 08:58:06 -0500
+indicator-session (0.2.0~dev-0ubuntu1~ppa2) karmic; urgency=low
+
+ * debian/rules
+ - removed the extra disable-scrollkeeper arg to configure (LP: #418772)
+ * debian/control
+ - removed the build dep for scrollkeeper
+
+ -- Ken VanDine <ken.vandine@canonical.com> Fri, 06 Nov 2009 10:24:06 -0500
+
+indicator-session (0.2.0~dev-0ubuntu1~ppa1) karmic; urgency=low
+
+ * Updating to the libindicate 0.3.0 API
+ * debian/control: Upping the libindicator-dev version to >= 0.3.0~dev
+ * debian/patches/01_locking_on_autologin.patch as it doesn't
+ apply.
+
+ -- Ted Gould <ted@ubuntu.com> Thu, 05 Nov 2009 09:26:56 -0600
+
+indicator-session (0.1.7-0ubuntu3~ppa1) karmic; urgency=low
+
+ * Listen on DBus for MissionControl coming on and off the bus
+ as EmpathyAccountManager used to do that for us before.
+ * Remove debian/patches/mc5-fixes.patch
+
+ -- Ted Gould <ted@ubuntu.com> Sat, 10 Oct 2009 08:44:16 -0400
+
indicator-session (0.1.7-0ubuntu3) karmic; urgency=low
* debian/patches/01_locking_on_autologin.patch:
diff --git a/debian/control b/debian/control
index 01507a5..61be553 100644
--- a/debian/control
+++ b/debian/control
@@ -8,8 +8,7 @@ Build-Depends: debhelper (>= 5.0),
libgconf2-dev,
libdbus-glib-1-dev,
gnome-doc-utils,
- scrollkeeper,
- libindicator-dev,
+ libindicator-dev (>= 0.3.0~dev),
libdbusmenu-glib-dev (>= 0.1.2),
libdbusmenu-gtk-dev (>= 0.1.2),
libpolkit-gobject-1-dev,
diff --git a/debian/patches/01_locking_on_autologin.patch b/debian/patches/01_locking_on_autologin.patch
deleted file mode 100644
index 88b255f..0000000
--- a/debian/patches/01_locking_on_autologin.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff -Nur -x '*.orig' -x '*~' indicator-session-0.1.7/src/lock-helper.c indicator-session-0.1.7.new/src/lock-helper.c
---- indicator-session-0.1.7/src/lock-helper.c 2009-10-14 19:15:55.000000000 +0200
-+++ indicator-session-0.1.7.new/src/lock-helper.c 2009-10-14 19:16:16.000000000 +0200
-@@ -130,9 +130,11 @@
- gboolean
- will_lock_screen (void)
- {
-+/*
- if (gdm_auto_login) {
- return FALSE;
- }
-+*/
- if (is_guest) {
- return FALSE;
- }
diff --git a/debian/patches/02_mc5-fixes.patch b/debian/patches/02_mc5-fixes.patch
deleted file mode 100644
index 4f66923..0000000
--- a/debian/patches/02_mc5-fixes.patch
+++ /dev/null
@@ -1,182 +0,0 @@
-=== modified file 'src/status-provider-mc5.c'
---- src/status-provider-mc5.c 2009-10-06 19:01:54 +0000
-+++ src/status-provider-mc5.c 2009-10-08 20:23:50 +0000
-@@ -31,6 +31,7 @@
- #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",
-@@ -66,10 +67,12 @@
- struct _StatusProviderMC5Private {
- EmpathyAccountManager * manager;
- StatusProviderStatus status;
-+ DBusGProxy * dbus_proxy;
- };
-
- #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 */
-@@ -81,6 +84,8 @@
- 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);
-
-@@ -104,6 +109,23 @@
- return;
- }
-
-+/* Build our empathy account manager instance if we don't
-+ have one. */
-+static void
-+build_eam (StatusProviderMC5 * self)
-+{
-+ StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(self);
-+
-+ if (priv->manager != NULL) {
-+ return;
-+ }
-+
-+ priv->manager = EMPATHY_ACCOUNT_MANAGER(g_object_new(EMPATHY_TYPE_ACCOUNT_MANAGER, NULL));
-+ g_signal_connect(G_OBJECT(priv->manager), "global-presence-changed", G_CALLBACK(presence_changed), self);
-+
-+ return;
-+}
-+
- /* Creating an instance of the status provider. We set the variables
- and create an EmpathyAccountManager object. It does all the hard
- work in this module of tracking MissionControl and enumerating the
-@@ -116,7 +138,33 @@
- priv->status = STATUS_PROVIDER_STATUS_DISCONNECTED;
- priv->manager = NULL;
-
-- g_signal_connect(G_OBJECT(priv->manager), "global-presence-changed", G_CALLBACK(presence_changed), self);
-+ 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 dbus Proxy */
-+ priv->dbus_proxy = dbus_g_proxy_new_for_name_owner (bus,
-+ DBUS_SERVICE_DBUS,
-+ DBUS_PATH_DBUS,
-+ DBUS_INTERFACE_DBUS,
-+ &error);
-+ if (error != NULL) {
-+ g_warning("Unable to connect to DBus events: %s", error->message);
-+ g_error_free(error);
-+ return;
-+ }
-+
-+ /* Configure the name owner changing */
-+ dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged",
-+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
-+ G_TYPE_INVALID);
-+ dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged",
-+ 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;
- }
-@@ -133,6 +181,11 @@
- priv->manager = NULL;
- }
-
-+ if (priv->dbus_proxy != NULL) {
-+ g_object_unref(priv->dbus_proxy);
-+ priv->dbus_proxy = NULL;
-+ }
-+
- G_OBJECT_CLASS (status_provider_mc5_parent_class)->dispose (object);
- return;
- }
-@@ -146,6 +199,49 @@
- return;
- }
-
-+/* 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)
-+{
-+ /* g_debug("DBUS NAMECHANGE: %s %s %s", name, prev, new); */
-+
-+ if (prev[0] == '\0' && g_strcmp0(name, MC5_WELL_KNOWN_NAME) == 0) {
-+ g_debug("MC5 Coming online");
-+ build_eam(self);
-+ }
-+ if (new[0] == '\0' && g_strcmp0(name, MC5_WELL_KNOWN_NAME) == 0) {
-+ g_debug("MC5 going offline");
-+ StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(self);
-+ if (priv->manager != NULL) {
-+ g_object_unref(priv->manager);
-+ priv->manager = NULL;
-+ }
-+
-+ priv->status = STATUS_PROVIDER_STATUS_DISCONNECTED;
-+ g_signal_emit(G_OBJECT(self), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED_ID, 0, priv->status, TRUE);
-+ }
-+
-+ 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:
-
-@@ -168,9 +264,8 @@
- set_status (StatusProvider * sp, StatusProviderStatus status)
- {
- StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(sp);
-- if (priv->manager == NULL) {
-- priv->manager = EMPATHY_ACCOUNT_MANAGER(g_object_new(EMPATHY_TYPE_ACCOUNT_MANAGER, NULL));
-- }
-+
-+ build_eam(STATUS_PROVIDER_MC5(sp));
-
- empathy_account_manager_request_global_presence(priv->manager, sp_to_tp_map[status], sp_to_mc_map[status], "");
-
-
-=== modified file 'src/status-provider-mc5.h'
---- src/status-provider-mc5.h 2009-09-16 22:08:31 +0000
-+++ src/status-provider-mc5.h 2009-10-08 20:23:50 +0000
-@@ -31,8 +31,8 @@
- G_BEGIN_DECLS
-
- #define STATUS_PROVIDER_MC5_TYPE (status_provider_mc5_get_type ())
--#define STATUS_PROVIDER_MC5(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STATUS_PROVIDER_MC5_TYPE, StatusProviderTelepathy))
--#define STATUS_PROVIDER_MC5_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STATUS_PROVIDER_MC5_TYPE, StatusProviderTelepathyClass))
-+#define STATUS_PROVIDER_MC5(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STATUS_PROVIDER_MC5_TYPE, StatusProviderMC5))
-+#define STATUS_PROVIDER_MC5_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STATUS_PROVIDER_MC5_TYPE, StatusProviderMC5Class))
- #define IS_STATUS_PROVIDER_MC5(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), STATUS_PROVIDER_MC5_TYPE))
- #define IS_STATUS_PROVIDER_MC5_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), STATUS_PROVIDER_MC5_TYPE))
- #define STATUS_PROVIDER_MC5_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), STATUS_PROVIDER_MC5_TYPE, StatusProviderMC5Class))
-
diff --git a/debian/rules b/debian/rules
index b632517..8db591a 100755
--- a/debian/rules
+++ b/debian/rules
@@ -4,7 +4,6 @@ include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/gnome.mk
include /usr/share/cdbs/1/rules/simple-patchsys.mk
-DEB_CONFIGURE_EXTRA_FLAGS += --disable-scrollkeeper
LDFLAGS += -Wl,-z,defs -Wl,--as-needed
DEB_DH_MAKESHLIBS_ARGS = -Xusr/lib/indicators
diff --git a/src/indicator-session.c b/src/indicator-session.c
index c22aa1c..410ad12 100644
--- a/src/indicator-session.c
+++ b/src/indicator-session.c
@@ -20,7 +20,8 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+#include <glib.h>
+#include <glib-object.h>
#include <gtk/gtk.h>
#include <libdbusmenu-gtk/client.h>
@@ -28,12 +29,36 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <dbus/dbus-glib-bindings.h>
#include <libindicator/indicator.h>
-INDICATOR_SET_VERSION
-INDICATOR_SET_NAME("users-status-session")
+#include <libindicator/indicator-object.h>
#include "dbus-shared-names.h"
#include "status-service-client.h"
+#define INDICATOR_SESSION_TYPE (indicator_session_get_type ())
+#define INDICATOR_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SESSION_TYPE, IndicatorSession))
+#define INDICATOR_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATOR_SESSION_TYPE, IndicatorSessionClass))
+#define IS_INDICATOR_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_SESSION_TYPE))
+#define IS_INDICATOR_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_SESSION_TYPE))
+#define INDICATOR_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_SESSION_TYPE, IndicatorSessionClass))
+
+typedef struct _IndicatorSession IndicatorSession;
+typedef struct _IndicatorSessionClass IndicatorSessionClass;
+
+struct _IndicatorSessionClass {
+ IndicatorObjectClass parent_class;
+};
+
+struct _IndicatorSession {
+ IndicatorObject parent;
+};
+
+GType indicator_session_get_type (void);
+
+/* Indicator stuff */
+INDICATOR_SET_VERSION
+INDICATOR_SET_TYPE(INDICATOR_SESSION_TYPE)
+
+/* Globals */
static DbusmenuGtkClient * status_client = NULL;
static DbusmenuGtkClient * users_client = NULL;
static DbusmenuGtkClient * session_client = NULL;
@@ -57,6 +82,7 @@ typedef enum {
END_OF_SECTIONS
} section_t;
+/* Prototypes */
static void child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position, gpointer section);
static guint status_menu_pos_offset (void);
static guint users_menu_pos_offset (void);
@@ -64,17 +90,66 @@ static guint session_menu_pos_offset (void);
static void child_realized (DbusmenuMenuitem * child, gpointer userdata);
static gboolean start_service (gpointer userdata);
static void start_service_phase2 (DBusGProxy * proxy, guint status, GError * error, gpointer data);
+static GtkLabel * get_label (IndicatorObject * io);
+static GtkImage * get_icon (IndicatorObject * io);
+static GtkMenu * get_menu (IndicatorObject * io);
-GtkLabel *
-get_label (void)
+static void indicator_session_class_init (IndicatorSessionClass *klass);
+static void indicator_session_init (IndicatorSession *self);
+static void indicator_session_dispose (GObject *object);
+static void indicator_session_finalize (GObject *object);
+
+G_DEFINE_TYPE (IndicatorSession, indicator_session, INDICATOR_OBJECT_TYPE);
+
+static void
+indicator_session_class_init (IndicatorSessionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = indicator_session_dispose;
+ object_class->finalize = indicator_session_finalize;
+
+ IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass);
+ io_class->get_label = get_label;
+ io_class->get_image = get_icon;
+ io_class->get_menu = get_menu;
+
+ return;
+}
+
+static void
+indicator_session_init (IndicatorSession *self)
+{
+
+ return;
+}
+
+static void
+indicator_session_dispose (GObject *object)
+{
+
+ G_OBJECT_CLASS (indicator_session_parent_class)->dispose (object);
+ return;
+}
+
+static void
+indicator_session_finalize (GObject *object)
+{
+
+ G_OBJECT_CLASS (indicator_session_parent_class)->finalize (object);
+ return;
+}
+
+static GtkLabel *
+get_label (IndicatorObject * io)
{
GtkLabel * returnval = GTK_LABEL(gtk_label_new(g_get_user_name()));
gtk_widget_show(GTK_WIDGET(returnval));
return returnval;
}
-GtkImage *
-get_icon (void)
+static GtkImage *
+get_icon (IndicatorObject * io)
{
g_debug("Changing status icon: '%s'", "system-shutdown-panel");
status_image = GTK_IMAGE(gtk_image_new_from_icon_name("system-shutdown-panel", GTK_ICON_SIZE_MENU));
@@ -260,7 +335,7 @@ status_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot,
return;
}
-void
+static void
status_icon_cb (DBusGProxy * proxy, char * icons, GError *error, gpointer userdata)
{
g_return_if_fail(status_image != NULL);
@@ -273,7 +348,7 @@ status_icon_cb (DBusGProxy * proxy, char * icons, GError *error, gpointer userda
return;
}
-void
+static void
status_icon_changed (DBusGProxy * proxy, gchar * icon, gpointer userdata)
{
return status_icon_cb(proxy, icon, NULL, NULL);
@@ -540,8 +615,8 @@ start_service (gpointer userdata)
/* Indicator based function to get the menu for the whole
applet. This starts up asking for the parts of the menu
from the various services. */
-GtkMenu *
-get_menu (void)
+static GtkMenu *
+get_menu (IndicatorObject * io)
{
connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
diff --git a/src/lock-helper.c b/src/lock-helper.c
index 0bdec6c..02d0f96 100644
--- a/src/lock-helper.c
+++ b/src/lock-helper.c
@@ -130,9 +130,11 @@ lock_screen_gdm_cb_set (gdm_autologin_cb_t cb)
gboolean
will_lock_screen (void)
{
+/*
if (gdm_auto_login) {
return FALSE;
}
+*/
if (is_guest) {
return FALSE;
}
diff --git a/src/status-provider-mc5.c b/src/status-provider-mc5.c
index 671e459..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",
@@ -66,10 +67,12 @@ typedef struct _StatusProviderMC5Private StatusProviderMC5Private;
struct _StatusProviderMC5Private {
EmpathyAccountManager * manager;
StatusProviderStatus status;
+ DBusGProxy * dbus_proxy;
};
#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 */
@@ -81,6 +84,8 @@ static void status_provider_mc5_finalize (GObject *object);
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);
@@ -104,6 +109,23 @@ status_provider_mc5_class_init (StatusProviderMC5Class *klass)
return;
}
+/* Build our empathy account manager instance if we don't
+ have one. */
+static void
+build_eam (StatusProviderMC5 * self)
+{
+ StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(self);
+
+ if (priv->manager != NULL) {
+ return;
+ }
+
+ priv->manager = EMPATHY_ACCOUNT_MANAGER(g_object_new(EMPATHY_TYPE_ACCOUNT_MANAGER, NULL));
+ g_signal_connect(G_OBJECT(priv->manager), "global-presence-changed", G_CALLBACK(presence_changed), self);
+
+ return;
+}
+
/* Creating an instance of the status provider. We set the variables
and create an EmpathyAccountManager object. It does all the hard
work in this module of tracking MissionControl and enumerating the
@@ -116,7 +138,33 @@ status_provider_mc5_init (StatusProviderMC5 *self)
priv->status = STATUS_PROVIDER_STATUS_DISCONNECTED;
priv->manager = NULL;
- g_signal_connect(G_OBJECT(priv->manager), "global-presence-changed", G_CALLBACK(presence_changed), self);
+ 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 dbus Proxy */
+ priv->dbus_proxy = dbus_g_proxy_new_for_name_owner (bus,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ &error);
+ if (error != NULL) {
+ g_warning("Unable to connect to DBus events: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ /* Configure the name owner changing */
+ dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged",
+ 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;
}
@@ -133,6 +181,11 @@ status_provider_mc5_dispose (GObject *object)
priv->manager = NULL;
}
+ if (priv->dbus_proxy != NULL) {
+ g_object_unref(priv->dbus_proxy);
+ priv->dbus_proxy = NULL;
+ }
+
G_OBJECT_CLASS (status_provider_mc5_parent_class)->dispose (object);
return;
}
@@ -146,6 +199,49 @@ status_provider_mc5_finalize (GObject *object)
return;
}
+/* 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)
+{
+ /* g_debug("DBUS NAMECHANGE: %s %s %s", name, prev, new); */
+
+ if (prev[0] == '\0' && g_strcmp0(name, MC5_WELL_KNOWN_NAME) == 0) {
+ g_debug("MC5 Coming online");
+ build_eam(self);
+ }
+ if (new[0] == '\0' && g_strcmp0(name, MC5_WELL_KNOWN_NAME) == 0) {
+ g_debug("MC5 going offline");
+ StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(self);
+ if (priv->manager != NULL) {
+ g_object_unref(priv->manager);
+ priv->manager = NULL;
+ }
+
+ priv->status = STATUS_PROVIDER_STATUS_DISCONNECTED;
+ g_signal_emit(G_OBJECT(self), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED_ID, 0, priv->status, TRUE);
+ }
+
+ 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:
@@ -168,9 +264,8 @@ static void
set_status (StatusProvider * sp, StatusProviderStatus status)
{
StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(sp);
- if (priv->manager == NULL) {
- priv->manager = EMPATHY_ACCOUNT_MANAGER(g_object_new(EMPATHY_TYPE_ACCOUNT_MANAGER, NULL));
- }
+
+ build_eam(STATUS_PROVIDER_MC5(sp));
empathy_account_manager_request_global_presence(priv->manager, sp_to_tp_map[status], sp_to_mc_map[status], "");
diff --git a/src/status-provider-mc5.h b/src/status-provider-mc5.h
index 2c03729..4d5659d 100644
--- a/src/status-provider-mc5.h
+++ b/src/status-provider-mc5.h
@@ -31,8 +31,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
G_BEGIN_DECLS
#define STATUS_PROVIDER_MC5_TYPE (status_provider_mc5_get_type ())
-#define STATUS_PROVIDER_MC5(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STATUS_PROVIDER_MC5_TYPE, StatusProviderTelepathy))
-#define STATUS_PROVIDER_MC5_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STATUS_PROVIDER_MC5_TYPE, StatusProviderTelepathyClass))
+#define STATUS_PROVIDER_MC5(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STATUS_PROVIDER_MC5_TYPE, StatusProviderMC5))
+#define STATUS_PROVIDER_MC5_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STATUS_PROVIDER_MC5_TYPE, StatusProviderMC5Class))
#define IS_STATUS_PROVIDER_MC5(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), STATUS_PROVIDER_MC5_TYPE))
#define IS_STATUS_PROVIDER_MC5_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), STATUS_PROVIDER_MC5_TYPE))
#define STATUS_PROVIDER_MC5_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), STATUS_PROVIDER_MC5_TYPE, StatusProviderMC5Class))