← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~ted/indicator-messages/new-dbusmenu into lp:indicator-messages

 

Ted Gould has proposed merging lp:~ted/indicator-messages/new-dbusmenu into lp:indicator-messages.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)

For more details, see:
https://code.launchpad.net/~ted/indicator-messages/new-dbusmenu/+merge/46319

Port to new everything and update to GDBus
-- 
https://code.launchpad.net/~ted/indicator-messages/new-dbusmenu/+merge/46319
Your team ayatana-commits is subscribed to branch lp:indicator-messages.
=== modified file 'configure.ac'
--- configure.ac	2010-10-06 18:58:05 +0000
+++ configure.ac	2011-01-14 19:37:35 +0000
@@ -38,15 +38,15 @@
 GTK_REQUIRED_VERSION=2.12
 GIO_UNIX_REQUIRED_VERSION=2.18
 PANEL_REQUIRED_VERSION=2.0.0
-INDICATE_REQUIRED_VERSION=0.3.0
+INDICATE_REQUIRED_VERSION=0.4.90
 INDICATOR_REQUIRED_VERSION=0.3.5
-DBUSMENUGTK_REQUIRED_VERSION=0.2.8
+DBUSMENUGTK_REQUIRED_VERSION=0.3.90
 
 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION
                           gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION
                           indicator >= $INDICATOR_REQUIRED_VERSION
-                          indicate >= $INDICATE_REQUIRED_VERSION
-                          dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION)
+                          indicate-0.5 >= $INDICATE_REQUIRED_VERSION
+                          dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION)
 AC_SUBST(APPLET_CFLAGS)
 AC_SUBST(APPLET_LIBS)
 

=== modified file 'src/Makefile.am'
--- src/Makefile.am	2010-03-25 01:26:43 +0000
+++ src/Makefile.am	2011-01-14 19:37:35 +0000
@@ -9,7 +9,8 @@
 messaginglib_LTLIBRARIES = libmessaging.la
 libmessaging_la_SOURCES = \
 	indicator-messages.c \
-	messages-service-client.h \
+	gen-messages-service.xml.h \
+	gen-messages-service.xml.c \
 	dbus-data.h
 libmessaging_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror
 libmessaging_la_LIBADD = $(APPLET_LIBS)
@@ -23,9 +24,10 @@
 	default-applications.h \
 	default-applications.c \
 	messages-service.c \
-	messages-service-server.h \
 	messages-service-dbus.c \
 	messages-service-dbus.h \
+	gen-messages-service.xml.h \
+	gen-messages-service.xml.c \
 	im-menu-item.c \
 	im-menu-item.h \
 	app-menu-item.c \
@@ -39,23 +41,19 @@
 indicator_messages_service_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror
 indicator_messages_service_LDADD = $(APPLET_LIBS)
 
-messages-service-client.h: $(srcdir)/messages-service.xml
-	dbus-binding-tool \
-		--prefix=_messages_service_client \
-		--mode=glib-client \
-		--output=messages-service-client.h \
-		$(srcdir)/messages-service.xml
+gen-%.xml.h: %.xml
+	@echo "Building $@ from $<"
+	@echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<))));" > $@
 
-messages-service-server.h: $(srcdir)/messages-service.xml
-	dbus-binding-tool \
-		--prefix=_messages_service_server \
-		--mode=glib-server \
-		--output=messages-service-server.h \
-		$(srcdir)/messages-service.xml
+gen-%.xml.c: %.xml
+	@echo "Building $@ from $<"
+	echo "const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<)))) = " > $@
+	@sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@
+	@echo ";" >> $@
 
 BUILT_SOURCES = \
-	messages-service-client.h \
-	messages-service-server.h
+	gen-messages-service.xml.h \
+	gen-messages-service.xml.c
 
 CLEANFILES = \
 	$(BUILT_SOURCES)

=== modified file 'src/app-menu-item.c'
--- src/app-menu-item.c	2010-08-26 19:31:18 +0000
+++ src/app-menu-item.c	2011-01-14 19:37:35 +0000
@@ -70,8 +70,8 @@
 static void activate_cb (AppMenuItem * self, guint timestamp, gpointer data);
 static void count_changed (IndicateListener * listener, IndicateListenerServer * server, guint count, gpointer data);
 static void count_cb (IndicateListener * listener, IndicateListenerServer * server, guint value, gpointer data);
-static void menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data);
-static void desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data);
+static void menu_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * menupath, gpointer data);
+static void desktop_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data);
 static void update_label (AppMenuItem * self);
 
 /* GObject Boilerplate */
@@ -300,7 +300,7 @@
    app structure and start sucking data out of it.
    Mostly the name. */
 static void 
-desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data)
+desktop_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data)
 {
 	g_return_if_fail(IS_APP_MENU_ITEM(data));
 	AppMenuItem * self = APP_MENU_ITEM(data);
@@ -469,7 +469,7 @@
 /* Gets the path to menuitems if there are some.  Now we need to
    make them special. */
 static void
-menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data)
+menu_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * menupath, gpointer data)
 {
 	g_debug("Got Menu: %s", menupath);
 	g_return_if_fail(IS_APP_MENU_ITEM(data));

=== modified file 'src/im-menu-item.c'
--- src/im-menu-item.c	2010-08-12 14:25:35 +0000
+++ src/im-menu-item.c	2011-01-14 19:37:35 +0000
@@ -358,7 +358,7 @@
    this indicator should be calling for attention or not.  If we are,
    we need to signal that. */
 static void
-attention_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, const GValue * propertydata, gpointer data)
+attention_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GVariant * propertydata, gpointer data)
 {
 	g_debug("Got Attention Information");
 	ImMenuItem * self = IM_MENU_ITEM(data);
@@ -373,10 +373,10 @@
 	ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(self);
 
 	gboolean wantit;
-	if (G_VALUE_HOLDS_BOOLEAN(propertydata)) {
-		wantit = g_value_get_boolean(propertydata);
-	} else if (G_VALUE_HOLDS_STRING(propertydata)) {
-		const gchar * propstring = g_value_get_string(propertydata);
+	if (g_variant_is_of_type(propertydata, G_VARIANT_TYPE_BOOLEAN)) {
+		wantit = g_variant_get_boolean(propertydata);
+	} else if (g_variant_is_of_type(propertydata, G_VARIANT_TYPE_STRING)) {
+		const gchar * propstring = g_variant_get_string(propertydata, NULL);
 
 		if (propstring == NULL || propstring[0] == '\0' || !g_strcmp0(propstring, "false")) {
 			wantit = FALSE;
@@ -427,7 +427,7 @@
 	} else if (!g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_COUNT)) {
 		indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_COUNT, count_cb, self);	
 	} else if (!g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION)) {
-		indicate_listener_get_property_value(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self);	
+		indicate_listener_get_property_variant(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self);	
 	} else if (!g_strcmp0(property, "sender")) {
 		/* This is a compatibility string with v1 and should be removed */
 		g_debug("Indicator is using 'sender' property which is a v1 string.");
@@ -460,7 +460,7 @@
 	indicate_listener_get_property_time(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_TIME, time_cb, self);	
 	indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ICON, icon_cb, self);	
 	indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_COUNT, count_cb, self);	
-	indicate_listener_get_property_value(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self);	
+	indicate_listener_get_property_variant(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self);	
 	indicate_listener_get_property(listener, server, indicator, "sender", sender_cb, self);	
 
 	g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL);

=== modified file 'src/indicator-messages.c'
--- src/indicator-messages.c	2010-10-06 18:58:05 +0000
+++ src/indicator-messages.c	2011-01-14 19:37:35 +0000
@@ -26,8 +26,6 @@
 #include <gtk/gtk.h>
 #include <libdbusmenu-gtk/menu.h>
 #include <libdbusmenu-gtk/menuitem.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
 
 #include <libindicator/indicator.h>
 #include <libindicator/indicator-object.h>
@@ -35,7 +33,7 @@
 #include <libindicator/indicator-service-manager.h>
 
 #include "dbus-data.h"
-#include "messages-service-client.h"
+#include "gen-messages-service.xml.h"
 
 #define INDICATOR_MESSAGES_TYPE            (indicator_messages_get_type ())
 #define INDICATOR_MESSAGES(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_MESSAGES_TYPE, IndicatorMessages))
@@ -69,8 +67,10 @@
 
 /* Globals */
 static GtkWidget * main_image = NULL;
-static DBusGProxy * icon_proxy = NULL;
+static GDBusProxy * icon_proxy = NULL;
 static GtkSizeGroup * indicator_right_group = NULL;
+static GDBusNodeInfo *            bus_node_info = NULL;
+static GDBusInterfaceInfo *       bus_interface_info = NULL;
 
 /* Prototypes */
 static void indicator_messages_class_init (IndicatorMessagesClass *klass);
@@ -99,6 +99,24 @@
 	io_class->get_image = get_icon;
 	io_class->get_menu = get_menu;
 
+	if (bus_node_info == NULL) {
+		GError * error = NULL;
+
+		bus_node_info = g_dbus_node_info_new_for_xml(_messages_service, &error);
+		if (error != NULL) {
+			g_error("Unable to parse Messaging Menu Interface description: %s", error->message);
+			g_error_free(error);
+		}
+	}
+
+	if (bus_interface_info == NULL) {
+		bus_interface_info = g_dbus_node_info_lookup_interface(bus_node_info, INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE);
+
+		if (bus_interface_info == NULL) {
+			g_error("Unable to find interface '" INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "'");
+		}
+	}
+
 	return;
 }
 
@@ -145,54 +163,77 @@
 
 /* Functions */
 
-/* Called everytime the attention changes in the service. */
-static void
-attention_changed_cb (DBusGProxy * proxy, gboolean dot, gpointer userdata)
-{
-	if (dot) {
-		indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new");
-	} else {
-		indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages");
-	}
-	return;
-}
-
-/* Change the icon to whether it should be visible or not */
-static void
-icon_changed_cb (DBusGProxy * proxy, gboolean hidden, gpointer userdata)
-{
-	if (hidden) {
-		gtk_widget_hide(main_image);
-	} else {
-		gtk_widget_show(main_image);
-	}
+/* Signal off of the proxy */
+static void
+proxy_signal (GDBusProxy * proxy, const gchar * sender, const gchar * signal, GVariant * params, gpointer user_data)
+{
+	gboolean prop = g_variant_get_boolean(g_variant_get_child_value(params, 0));
+
+	if (g_strcmp0("AttentionChanged", signal) == 0) {
+		if (prop) {
+			indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new");
+		} else {
+			indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages");
+		}
+	} else if (g_strcmp0("IconChanged", signal) == 0) {
+		if (prop) {
+			gtk_widget_hide(main_image);
+		} else {
+			gtk_widget_show(main_image);
+		}
+	} else {
+		g_warning("Unknown signal %s", signal);
+	}
+
 	return;
 }
 
 /* Callback from getting the attention status from the service. */
 static void
-attention_cb (DBusGProxy * proxy, gboolean dot, GError * error, gpointer userdata)
+attention_cb (GObject * object, GAsyncResult * ares, gpointer user_data)
 {
+	GError * error = NULL;
+	GVariant * res = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), ares, &error);
+
 	if (error != NULL) {
 		g_warning("Unable to get attention status: %s", error->message);
 		g_error_free(error);
 		return;
 	}
 
-	return attention_changed_cb(proxy, dot, userdata);
+	gboolean prop = g_variant_get_boolean(g_variant_get_child_value(res, 0));
+
+	if (prop) {
+		indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new");
+	} else {
+		indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages");
+	}
+
+	return;
 }
 
 /* Change from getting the icon visibility from the service */
 static void
-icon_cb (DBusGProxy * proxy, gboolean hidden, GError * error, gpointer userdata)
+icon_cb (GObject * object, GAsyncResult * ares, gpointer user_data)
 {
+	GError * error = NULL;
+	GVariant * res = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), ares, &error);
+
 	if (error != NULL) {
 		g_warning("Unable to get icon visibility: %s", error->message);
 		g_error_free(error);
 		return;
 	}
 
-	return icon_changed_cb(proxy, hidden, userdata);
+	gboolean prop = g_variant_get_boolean(g_variant_get_child_value(res, 0));
+	
+	if (prop) {
+		gtk_widget_hide(main_image);
+	} else {
+		gtk_widget_show(main_image);
+	}
+
+	return;
 }
 
 static guint connection_drop_timeout = 0;
@@ -209,6 +250,43 @@
 	return FALSE;
 }
 
+/* Proxy is setup now.. whoo! */
+static void
+proxy_ready_cb (GObject * obj, GAsyncResult * res, gpointer user_data)
+{
+	GError * error = NULL;
+	GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
+
+	if (error != NULL) {
+		g_warning("Unable to get proxy of service: %s", error->message);
+		g_error_free(error);
+		return;
+	}
+
+	icon_proxy = proxy;
+
+	g_signal_connect(G_OBJECT(proxy), "g-signal", G_CALLBACK(proxy_signal), user_data);
+
+	g_dbus_proxy_call(icon_proxy,
+	                  "AttentionRequested",
+	                  NULL, /* params */
+	                  G_DBUS_CALL_FLAGS_NONE,
+	                  -1, /* timeout */
+	                  NULL, /* cancel */
+	                  attention_cb,
+	                  user_data);
+	g_dbus_proxy_call(icon_proxy,
+	                  "IconShown",
+	                  NULL, /* params */
+	                  G_DBUS_CALL_FLAGS_NONE,
+	                  -1, /* timeout */
+	                  NULL, /* cancel */
+	                  icon_cb,
+	                  user_data);
+
+	return;
+}
+
 /* Sets up all the icon information in the proxy. */
 static void 
 connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer user_data)
@@ -225,51 +303,46 @@
 		return;
 	}
 
-	DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
-	if (connection == NULL) {
-		g_warning("Unable to get session bus");
-		return;
-	}
-
 	if (icon_proxy == NULL) {
-		icon_proxy = dbus_g_proxy_new_for_name(connection,
-		                                       INDICATOR_MESSAGES_DBUS_NAME,
-		                                       INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT,
-		                                       INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE);
-		if (icon_proxy == NULL) {
-			g_warning("Unable to get messages service interface.");
-			return;
-		}
-		
-		dbus_g_proxy_add_signal(icon_proxy, "AttentionChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID);
-		dbus_g_proxy_connect_signal(icon_proxy,
-		                            "AttentionChanged",
-		                            G_CALLBACK(attention_changed_cb),
-		                            NULL,
-		                            NULL);
-
-		dbus_g_proxy_add_signal(icon_proxy, "IconChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID);
-		dbus_g_proxy_connect_signal(icon_proxy,
-		                            "IconChanged",
-		                            G_CALLBACK(icon_changed_cb),
-		                            NULL,
-		                            NULL);
+		g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION,
+		                         G_DBUS_PROXY_FLAGS_NONE,
+		                         bus_interface_info,
+		                         INDICATOR_MESSAGES_DBUS_NAME,
+		                         INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT,
+		                         INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE,
+		                         NULL, /* cancel */
+		                         proxy_ready_cb,
+		                         sm);
+	} else {
+		g_dbus_proxy_call(icon_proxy,
+		                  "AttentionRequested",
+		                  NULL, /* params */
+		                  G_DBUS_CALL_FLAGS_NONE,
+		                  -1, /* timeout */
+		                  NULL, /* cancel */
+		                  attention_cb,
+		                  sm);
+		g_dbus_proxy_call(icon_proxy,
+		                  "IconShown",
+		                  NULL, /* params */
+		                  G_DBUS_CALL_FLAGS_NONE,
+		                  -1, /* timeout */
+		                  NULL, /* cancel */
+		                  icon_cb,
+		                  sm);
 	}
 
-	org_ayatana_indicator_messages_service_attention_requested_async(icon_proxy, attention_cb, NULL);
-	org_ayatana_indicator_messages_service_icon_shown_async(icon_proxy, icon_cb, NULL);
-
 	return;
 }
 
 /* Sets the icon when it changes. */
 static void
-application_icon_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, gpointer user_data)
+application_icon_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value, gpointer user_data)
 {
 	if (!g_strcmp0(prop, APPLICATION_MENUITEM_PROP_ICON)) {
 		/* Set the main icon */
 		if (GTK_IS_IMAGE(user_data)) {
-			gtk_image_set_from_icon_name(GTK_IMAGE(user_data), g_value_get_string(value), GTK_ICON_SIZE_MENU);
+			gtk_image_set_from_icon_name(GTK_IMAGE(user_data), g_variant_get_string(value, NULL), GTK_ICON_SIZE_MENU);
 		}
 	}
 
@@ -278,12 +351,12 @@
 
 /* Sets the label when it changes. */
 static void
-application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, gpointer user_data)
+application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value, gpointer user_data)
 {
 	if (!g_strcmp0(prop, APPLICATION_MENUITEM_PROP_NAME)) {
 		/* Set the main label */
 		if (GTK_IS_LABEL(user_data)) {
-			gtk_label_set_text(GTK_LABEL(user_data), g_value_get_string(value));
+			gtk_label_set_text(GTK_LABEL(user_data), g_variant_get_string(value, NULL));
 		}
 	}
 
@@ -472,14 +545,14 @@
 /* Whenever we have a property change on a DbusmenuMenuitem
    we need to be responsive to that. */
 static void
-indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, indicator_item_t * mi_data)
+indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value, indicator_item_t * mi_data)
 {
 	if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_LABEL)) {
 		/* Set the main label */
-		gtk_label_set_text(GTK_LABEL(mi_data->label), g_value_get_string(value));
+		gtk_label_set_text(GTK_LABEL(mi_data->label), g_variant_get_string(value, NULL));
 	} else if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_RIGHT)) {
 		/* Set the right label */
-		gtk_label_set_text(GTK_LABEL(mi_data->right), g_value_get_string(value));
+		gtk_label_set_text(GTK_LABEL(mi_data->right), g_variant_get_string(value, NULL));
 	} else if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_ICON)) {
 		/* We don't use the value here, which is probably less efficient, 
 		   but it's easier to use the easy function.  And since th value

=== modified file 'src/messages-service-dbus.c'
--- src/messages-service-dbus.c	2009-08-26 15:35:56 +0000
+++ src/messages-service-dbus.c	2011-01-14 19:37:35 +0000
@@ -24,9 +24,10 @@
 #include "config.h"
 #endif
 
-#include <dbus/dbus-glib.h>
+#include <gio/gio.h>
 #include "messages-service-dbus.h"
 #include "dbus-data.h"
+#include "gen-messages-service.xml.h"
 
 enum {
 	ATTENTION_CHANGED,
@@ -40,6 +41,7 @@
 
 struct _MessageServiceDbusPrivate
 {
+	GDBusConnection * connection;
 	gboolean dot;
 	gboolean hidden;
 };
@@ -51,15 +53,26 @@
 static void message_service_dbus_init       (MessageServiceDbus *self);
 static void message_service_dbus_dispose    (GObject *object);
 static void message_service_dbus_finalize   (GObject *object);
-
-static void _messages_service_server_watch  (void);
-static gboolean _messages_service_server_attention_requested (MessageServiceDbus * self, gboolean * dot, GError ** error);
-static gboolean _messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidden, GError ** error);
-
-#include "messages-service-server.h"
+static void     bus_method_call             (GDBusConnection * connection,
+                                             const gchar * sender,
+                                             const gchar * path,
+                                             const gchar * interface,
+                                             const gchar * method,
+                                             GVariant * params,
+                                             GDBusMethodInvocation * invocation,
+                                             gpointer user_data);
+
+static GDBusNodeInfo *            bus_node_info = NULL;
+static GDBusInterfaceInfo *       bus_interface_info = NULL;
+static const GDBusInterfaceVTable bus_interface_table = {
+	method_call:    bus_method_call,
+	get_property:   NULL,  /* No properties */
+	set_property:   NULL   /* No properties */
+};
 
 G_DEFINE_TYPE (MessageServiceDbus, message_service_dbus, G_TYPE_OBJECT);
 
+
 static void
 message_service_dbus_class_init (MessageServiceDbusClass *klass)
 {
@@ -86,8 +99,57 @@
 	                                      g_cclosure_marshal_VOID__BOOLEAN,
 	                                      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
 
-
-	dbus_g_object_type_install_info(MESSAGE_SERVICE_DBUS_TYPE, &dbus_glib__messages_service_server_object_info);
+	if (bus_node_info == NULL) {
+		GError * error = NULL;
+
+		bus_node_info = g_dbus_node_info_new_for_xml(_messages_service, &error);
+		if (error != NULL) {
+			g_error("Unable to parse Messaging Menu Interface description: %s", error->message);
+			g_error_free(error);
+		}
+	}
+
+	if (bus_interface_info == NULL) {
+		bus_interface_info = g_dbus_node_info_lookup_interface(bus_node_info, INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE);
+
+		if (bus_interface_info == NULL) {
+			g_error("Unable to find interface '" INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "'");
+		}
+	}
+
+	return;
+}
+
+static void
+connection_cb (GObject * object, GAsyncResult * res, gpointer user_data)
+{
+	GError * error = NULL;
+	GDBusConnection * connection = g_bus_get_finish(res, &error);
+
+	if (error != NULL) {
+		g_error("Unable to connect to the session bus: %s", error->message);
+		g_error_free(error);
+		return;
+	}
+
+	MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
+	priv->connection = connection;
+
+	g_dbus_connection_register_object(connection,
+	                                  INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT,
+	                                  bus_interface_info,
+	                                  &bus_interface_table,
+	                                  user_data,
+	                                  NULL, /* destroy */
+	                                  &error);
+
+	if (error != NULL) {
+		g_error("Unable to register on session bus: %s", error->message);
+		g_error_free(error);
+		return;
+	}
+
+	g_debug("Service on session bus");
 
 	return;
 }
@@ -95,10 +157,7 @@
 static void
 message_service_dbus_init (MessageServiceDbus *self)
 {
-	DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
-	dbus_g_connection_register_g_object(connection,
-										INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT,
-										G_OBJECT(self));
+	g_bus_get(G_BUS_TYPE_SESSION, NULL, connection_cb, self);
 
 	MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
 
@@ -111,7 +170,12 @@
 static void
 message_service_dbus_dispose (GObject *object)
 {
+	MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(object);
 
+	if (priv->connection != NULL) {
+		g_object_unref(priv->connection);
+		priv->connection = NULL;
+	}
 
 	G_OBJECT_CLASS (message_service_dbus_parent_class)->dispose (object);
 	return;
@@ -132,31 +196,23 @@
 	return MESSAGE_SERVICE_DBUS(g_object_new(MESSAGE_SERVICE_DBUS_TYPE, NULL));
 }
 
-/* DBus function to say that someone is watching */
+/* Method request off of DBus */
 static void
-_messages_service_server_watch  (void)
-{
-
-}
-
-/* DBus interface to request the private variable to know
-   whether there is a green dot. */
-static gboolean
-_messages_service_server_attention_requested (MessageServiceDbus * self, gboolean * dot, GError ** error)
-{
-	MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
-	*dot = priv->dot;
-	return TRUE;
-}
-
-/* DBus interface to request the private variable to know
-   whether the icon is hidden. */
-static gboolean
-_messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidden, GError ** error)
-{
-	MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
-	*hidden = priv->hidden;
-	return TRUE;
+bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data)
+{
+	MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
+
+	if (g_strcmp0("AttentionRequested", method) == 0) {
+		g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", priv->dot));
+		return;
+	} else if (g_strcmp0("IconShown", method) == 0) {
+		g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", priv->hidden));
+		return;
+	} else {
+		g_warning("Unknown function call '%s'", method);
+	}
+
+	return;
 }
 
 void
@@ -167,6 +223,16 @@
 	if (attention != priv->dot) {
 		priv->dot = attention;
 		g_signal_emit(G_OBJECT(self), signals[ATTENTION_CHANGED], 0, priv->dot, TRUE);
+
+		if (priv->connection != NULL) {
+			g_dbus_connection_emit_signal(priv->connection,
+			                              NULL,
+			                              INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT,
+			                              INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE,
+			                              "AttentionChanged",
+			                              g_variant_new("(b)", priv->dot),
+			                              NULL);
+		}
 	}
 	return;
 }
@@ -179,6 +245,16 @@
 	if (hidden != priv->hidden) {
 		priv->hidden = hidden;
 		g_signal_emit(G_OBJECT(self), signals[ICON_CHANGED], 0, priv->hidden, TRUE);
+
+		if (priv->connection != NULL) {
+			g_dbus_connection_emit_signal(priv->connection,
+			                              NULL,
+			                              INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT,
+			                              INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE,
+			                              "IconChanged",
+			                              g_variant_new("(b)", priv->hidden),
+			                              NULL);
+		}
 	}
 	return;
 }

=== modified file 'src/messages-service.c'
--- src/messages-service.c	2010-08-26 19:31:18 +0000
+++ src/messages-service.c	2011-01-14 19:37:35 +0000
@@ -25,7 +25,6 @@
 #include <libintl.h>
 #include <config.h>
 #include <pango/pango-utils.h>
-#include <dbus/dbus-glib-bindings.h>
 #include <libindicate/listener.h>
 #include <libindicator/indicator-service.h>
 #include <gio/gio.h>


Follow ups