aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am30
-rw-r--r--src/Makefile.in60
-rw-r--r--src/app-menu-item.c8
-rw-r--r--src/dbus-data.h8
-rw-r--r--src/gen-messages-service.xml.c27
-rw-r--r--src/gen-messages-service.xml.h1
-rw-r--r--src/im-menu-item.c14
-rw-r--r--src/indicator-messages.c217
-rw-r--r--src/messages-service-client.h139
-rw-r--r--src/messages-service-dbus.c144
-rw-r--r--src/messages-service-server.h126
-rw-r--r--src/messages-service.c1
-rw-r--r--src/messages-service.xml2
13 files changed, 358 insertions, 419 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7c9842a..dd09b8a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,7 +9,8 @@ messaginglibdir = $(INDICATORDIR)
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 @@ indicator_messages_service_SOURCES = \
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_SOURCES = \
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)
diff --git a/src/Makefile.in b/src/Makefile.in
index d0cd1eb..acc459e 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -72,7 +72,8 @@ am__installdirs = "$(DESTDIR)$(messaginglibdir)" \
LTLIBRARIES = $(messaginglib_LTLIBRARIES)
am__DEPENDENCIES_1 =
libmessaging_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am_libmessaging_la_OBJECTS = libmessaging_la-indicator-messages.lo
+am_libmessaging_la_OBJECTS = libmessaging_la-indicator-messages.lo \
+ libmessaging_la-gen-messages-service.xml.lo
libmessaging_la_OBJECTS = $(am_libmessaging_la_OBJECTS)
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
@@ -86,6 +87,7 @@ am_indicator_messages_service_OBJECTS = \
indicator_messages_service-default-applications.$(OBJEXT) \
indicator_messages_service-messages-service.$(OBJEXT) \
indicator_messages_service-messages-service-dbus.$(OBJEXT) \
+ indicator_messages_service-gen-messages-service.xml.$(OBJEXT) \
indicator_messages_service-im-menu-item.$(OBJEXT) \
indicator_messages_service-app-menu-item.$(OBJEXT) \
indicator_messages_service-launcher-menu-item.$(OBJEXT) \
@@ -283,7 +285,8 @@ messaginglibdir = $(INDICATORDIR)
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
@@ -297,9 +300,10 @@ indicator_messages_service_SOURCES = \
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 \
@@ -314,8 +318,8 @@ indicator_messages_service_SOURCES = \
indicator_messages_service_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror
indicator_messages_service_LDADD = $(APPLET_LIBS)
BUILT_SOURCES = \
- messages-service-client.h \
- messages-service-server.h
+ gen-messages-service.xml.h \
+ gen-messages-service.xml.c
CLEANFILES = \
$(BUILT_SOURCES)
@@ -446,11 +450,13 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-app-menu-item.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-default-applications.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-im-menu-item.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-launcher-menu-item.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-messages-service-dbus.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-messages-service.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-seen-db.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmessaging_la-gen-messages-service.xml.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmessaging_la-indicator-messages.Plo@am__quote@
.c.o:
@@ -485,6 +491,14 @@ libmessaging_la-indicator-messages.lo: indicator-messages.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmessaging_la_CFLAGS) $(CFLAGS) -c -o libmessaging_la-indicator-messages.lo `test -f 'indicator-messages.c' || echo '$(srcdir)/'`indicator-messages.c
+libmessaging_la-gen-messages-service.xml.lo: gen-messages-service.xml.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmessaging_la_CFLAGS) $(CFLAGS) -MT libmessaging_la-gen-messages-service.xml.lo -MD -MP -MF $(DEPDIR)/libmessaging_la-gen-messages-service.xml.Tpo -c -o libmessaging_la-gen-messages-service.xml.lo `test -f 'gen-messages-service.xml.c' || echo '$(srcdir)/'`gen-messages-service.xml.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmessaging_la-gen-messages-service.xml.Tpo $(DEPDIR)/libmessaging_la-gen-messages-service.xml.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gen-messages-service.xml.c' object='libmessaging_la-gen-messages-service.xml.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmessaging_la_CFLAGS) $(CFLAGS) -c -o libmessaging_la-gen-messages-service.xml.lo `test -f 'gen-messages-service.xml.c' || echo '$(srcdir)/'`gen-messages-service.xml.c
+
indicator_messages_service-default-applications.o: default-applications.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -MT indicator_messages_service-default-applications.o -MD -MP -MF $(DEPDIR)/indicator_messages_service-default-applications.Tpo -c -o indicator_messages_service-default-applications.o `test -f 'default-applications.c' || echo '$(srcdir)/'`default-applications.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_messages_service-default-applications.Tpo $(DEPDIR)/indicator_messages_service-default-applications.Po
@@ -533,6 +547,22 @@ indicator_messages_service-messages-service-dbus.obj: messages-service-dbus.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -c -o indicator_messages_service-messages-service-dbus.obj `if test -f 'messages-service-dbus.c'; then $(CYGPATH_W) 'messages-service-dbus.c'; else $(CYGPATH_W) '$(srcdir)/messages-service-dbus.c'; fi`
+indicator_messages_service-gen-messages-service.xml.o: gen-messages-service.xml.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -MT indicator_messages_service-gen-messages-service.xml.o -MD -MP -MF $(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Tpo -c -o indicator_messages_service-gen-messages-service.xml.o `test -f 'gen-messages-service.xml.c' || echo '$(srcdir)/'`gen-messages-service.xml.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Tpo $(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gen-messages-service.xml.c' object='indicator_messages_service-gen-messages-service.xml.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -c -o indicator_messages_service-gen-messages-service.xml.o `test -f 'gen-messages-service.xml.c' || echo '$(srcdir)/'`gen-messages-service.xml.c
+
+indicator_messages_service-gen-messages-service.xml.obj: gen-messages-service.xml.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -MT indicator_messages_service-gen-messages-service.xml.obj -MD -MP -MF $(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Tpo -c -o indicator_messages_service-gen-messages-service.xml.obj `if test -f 'gen-messages-service.xml.c'; then $(CYGPATH_W) 'gen-messages-service.xml.c'; else $(CYGPATH_W) '$(srcdir)/gen-messages-service.xml.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Tpo $(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gen-messages-service.xml.c' object='indicator_messages_service-gen-messages-service.xml.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -c -o indicator_messages_service-gen-messages-service.xml.obj `if test -f 'gen-messages-service.xml.c'; then $(CYGPATH_W) 'gen-messages-service.xml.c'; else $(CYGPATH_W) '$(srcdir)/gen-messages-service.xml.c'; fi`
+
indicator_messages_service-im-menu-item.o: im-menu-item.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -MT indicator_messages_service-im-menu-item.o -MD -MP -MF $(DEPDIR)/indicator_messages_service-im-menu-item.Tpo -c -o indicator_messages_service-im-menu-item.o `test -f 'im-menu-item.c' || echo '$(srcdir)/'`im-menu-item.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_messages_service-im-menu-item.Tpo $(DEPDIR)/indicator_messages_service-im-menu-item.Po
@@ -813,19 +843,15 @@ uninstall-am: uninstall-libexecPROGRAMS \
uninstall-messaginglibLTLIBRARIES
-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 ";" >> $@
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/src/app-menu-item.c b/src/app-menu-item.c
index 0b0588e..e846914 100644
--- a/src/app-menu-item.c
+++ b/src/app-menu-item.c
@@ -70,8 +70,8 @@ static void app_menu_item_finalize (GObject *object);
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 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, guint va
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 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data
/* 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));
diff --git a/src/dbus-data.h b/src/dbus-data.h
index 100ac0a..abff3aa 100644
--- a/src/dbus-data.h
+++ b/src/dbus-data.h
@@ -2,11 +2,11 @@
#ifndef __DBUS_DATA_H__
#define __DBUS_DATA_H__ 1
-#define INDICATOR_MESSAGES_DBUS_NAME "org.ayatana.indicator.messages"
-#define INDICATOR_MESSAGES_DBUS_OBJECT "/org/ayatana/indicator/messages/menu"
+#define INDICATOR_MESSAGES_DBUS_NAME "com.canonical.indicator.messages"
+#define INDICATOR_MESSAGES_DBUS_OBJECT "/com/canonical/indicator/messages/menu"
-#define INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT "/org/ayatana/indicator/messages/service"
-#define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "org.ayatana.indicator.messages.service"
+#define INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT "/com/canonical/indicator/messages/service"
+#define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "com.canonical.indicator.messages.service"
#define APPLICATION_MENUITEM_TYPE "application-item"
#define APPLICATION_MENUITEM_PROP_NAME "label"
diff --git a/src/gen-messages-service.xml.c b/src/gen-messages-service.xml.c
new file mode 100644
index 0000000..0a1c0d1
--- /dev/null
+++ b/src/gen-messages-service.xml.c
@@ -0,0 +1,27 @@
+const char * _messages_service =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<node name=\"/\">\n"
+" <interface name=\"com.canonical.indicator.messages.service\">\n"
+"\n"
+"<!-- Methods -->\n"
+" <method name=\"Watch\">\n"
+" <annotation name=\"org.freedesktop.DBus.GLib.Async\" value=\"true\" />\n"
+" </method>\n"
+" <method name=\"AttentionRequested\">\n"
+" <arg type=\"b\" name=\"dot\" direction=\"out\" />\n"
+" </method>\n"
+" <method name=\"IconShown\">\n"
+" <arg type=\"b\" name=\"hidden\" direction=\"out\" />\n"
+" </method>\n"
+"\n"
+"<!-- Signals -->\n"
+" <signal name=\"AttentionChanged\">\n"
+" <arg type=\"b\" name=\"dot\" direction=\"out\" />\n"
+" </signal>\n"
+" <signal name=\"IconChanged\">\n"
+" <arg type=\"b\" name=\"hidden\" direction=\"out\" />\n"
+" </signal>\n"
+"\n"
+" </interface>\n"
+"</node>\n"
+;
diff --git a/src/gen-messages-service.xml.h b/src/gen-messages-service.xml.h
new file mode 100644
index 0000000..7884498
--- /dev/null
+++ b/src/gen-messages-service.xml.h
@@ -0,0 +1 @@
+extern const char * _messages_service;
diff --git a/src/im-menu-item.c b/src/im-menu-item.c
index b8b3709..25fea52 100644
--- a/src/im-menu-item.c
+++ b/src/im-menu-item.c
@@ -358,7 +358,7 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, Indicate
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 @@ attention_cb (IndicateListener * listener, IndicateListenerServer * server, Indi
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 @@ indicator_modified_cb (IndicateListener * listener, IndicateListenerServer * ser
} 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 @@ im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server,
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);
diff --git a/src/indicator-messages.c b/src/indicator-messages.c
index b29edce..6fd6c5c 100644
--- a/src/indicator-messages.c
+++ b/src/indicator-messages.c
@@ -26,8 +26,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#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 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#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 @@ INDICATOR_SET_TYPE(INDICATOR_MESSAGES_TYPE)
/* 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 @@ indicator_messages_class_init (IndicatorMessagesClass *klass)
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 @@ indicator_messages_finalize (GObject *object)
/* Functions */
-/* Called everytime the attention changes in the service. */
+/* Signal off of the proxy */
static void
-attention_changed_cb (DBusGProxy * proxy, gboolean dot, gpointer userdata)
+proxy_signal (GDBusProxy * proxy, const gchar * sender, const gchar * signal, GVariant * params, gpointer user_data)
{
- 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;
-}
+ gboolean prop = g_variant_get_boolean(g_variant_get_child_value(params, 0));
-/* 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);
+ 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 {
- gtk_widget_show(main_image);
+ 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 @@ connection_drop_cb (gpointer user_data)
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 @@ connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer us
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 @@ application_icon_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value,
/* 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));
}
}
@@ -299,6 +372,7 @@ application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value,
static gboolean
application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
+ GtkAllocation allocation;
GtkStyle *style;
cairo_t *cr;
int x, y, arrow_width, arrow_height;
@@ -316,11 +390,12 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer
/* set arrow position / dimensions */
arrow_width = 5; /* the pixel-based reference triangle is 5x9 */
arrow_height = 9;
- x = widget->allocation.x;
- y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0;
+ gtk_widget_get_allocation (widget, &allocation);
+ x = allocation.x;
+ y = allocation.y + allocation.height/2.0 - (double)arrow_height/2.0;
/* initialize cairo drawing area */
- cr = (cairo_t*) gdk_cairo_create (widget->window);
+ cr = (cairo_t*) gdk_cairo_create (gtk_widget_get_window (widget));
/* set line width */
cairo_set_line_width (cr, 1.0);
@@ -359,6 +434,7 @@ custom_cairo_rounded_rectangle (cairo_t *cr,
static gboolean
numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
+ GtkAllocation allocation;
GtkStyle *style;
cairo_t *cr;
double x, y, w, h;
@@ -371,10 +447,11 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
style = gtk_widget_get_style (widget);
/* set arrow position / dimensions */
- w = widget->allocation.width;
- h = widget->allocation.height;
- x = widget->allocation.x;
- y = widget->allocation.y;
+ gtk_widget_get_allocation (widget, &allocation);
+ w = allocation.width;
+ h = allocation.height;
+ x = allocation.x;
+ y = allocation.y;
layout = gtk_label_get_layout (GTK_LABEL(widget));
@@ -385,7 +462,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
font_size = pango_font_description_get_size (font_description); */
/* initialize cairo drawing area */
- cr = (cairo_t*) gdk_cairo_create (widget->window);
+ cr = (cairo_t*) gdk_cairo_create (gtk_widget_get_window (widget));
/* set line width */
cairo_set_line_width (cr, 1.0);
@@ -468,14 +545,14 @@ struct _indicator_item_t {
/* 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
diff --git a/src/messages-service-client.h b/src/messages-service-client.h
deleted file mode 100644
index 2a858e8..0000000
--- a/src/messages-service-client.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Generated by dbus-binding-tool; do not edit! */
-
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-
-G_BEGIN_DECLS
-
-#ifndef _DBUS_GLIB_ASYNC_DATA_FREE
-#define _DBUS_GLIB_ASYNC_DATA_FREE
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-void
-_dbus_glib_async_data_free (gpointer stuff)
-{
- g_slice_free (DBusGAsyncData, stuff);
-}
-#endif
-
-#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_ayatana_indicator_messages_service
-#define DBUS_GLIB_CLIENT_WRAPPERS_org_ayatana_indicator_messages_service
-
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-gboolean
-org_ayatana_indicator_messages_service_watch (DBusGProxy *proxy, GError **error)
-
-{
- return dbus_g_proxy_call (proxy, "Watch", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-typedef void (*org_ayatana_indicator_messages_service_watch_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
-
-static void
-org_ayatana_indicator_messages_service_watch_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
-{
- DBusGAsyncData *data = (DBusGAsyncData*) user_data;
- GError *error = NULL;
- dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
- (*(org_ayatana_indicator_messages_service_watch_reply)data->cb) (proxy, error, data->userdata);
- return;
-}
-
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-DBusGProxyCall*
-org_ayatana_indicator_messages_service_watch_async (DBusGProxy *proxy, org_ayatana_indicator_messages_service_watch_reply callback, gpointer userdata)
-
-{
- DBusGAsyncData *stuff;
- stuff = g_slice_new (DBusGAsyncData);
- stuff->cb = G_CALLBACK (callback);
- stuff->userdata = userdata;
- return dbus_g_proxy_begin_call (proxy, "Watch", org_ayatana_indicator_messages_service_watch_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID);
-}
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-gboolean
-org_ayatana_indicator_messages_service_attention_requested (DBusGProxy *proxy, gboolean* OUT_dot, GError **error)
-
-{
- return dbus_g_proxy_call (proxy, "AttentionRequested", error, G_TYPE_INVALID, G_TYPE_BOOLEAN, OUT_dot, G_TYPE_INVALID);
-}
-
-typedef void (*org_ayatana_indicator_messages_service_attention_requested_reply) (DBusGProxy *proxy, gboolean OUT_dot, GError *error, gpointer userdata);
-
-static void
-org_ayatana_indicator_messages_service_attention_requested_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
-{
- DBusGAsyncData *data = (DBusGAsyncData*) user_data;
- GError *error = NULL;
- gboolean OUT_dot;
- dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &OUT_dot, G_TYPE_INVALID);
- (*(org_ayatana_indicator_messages_service_attention_requested_reply)data->cb) (proxy, OUT_dot, error, data->userdata);
- return;
-}
-
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-DBusGProxyCall*
-org_ayatana_indicator_messages_service_attention_requested_async (DBusGProxy *proxy, org_ayatana_indicator_messages_service_attention_requested_reply callback, gpointer userdata)
-
-{
- DBusGAsyncData *stuff;
- stuff = g_slice_new (DBusGAsyncData);
- stuff->cb = G_CALLBACK (callback);
- stuff->userdata = userdata;
- return dbus_g_proxy_begin_call (proxy, "AttentionRequested", org_ayatana_indicator_messages_service_attention_requested_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID);
-}
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-gboolean
-org_ayatana_indicator_messages_service_icon_shown (DBusGProxy *proxy, gboolean* OUT_hidden, GError **error)
-
-{
- return dbus_g_proxy_call (proxy, "IconShown", error, G_TYPE_INVALID, G_TYPE_BOOLEAN, OUT_hidden, G_TYPE_INVALID);
-}
-
-typedef void (*org_ayatana_indicator_messages_service_icon_shown_reply) (DBusGProxy *proxy, gboolean OUT_hidden, GError *error, gpointer userdata);
-
-static void
-org_ayatana_indicator_messages_service_icon_shown_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
-{
- DBusGAsyncData *data = (DBusGAsyncData*) user_data;
- GError *error = NULL;
- gboolean OUT_hidden;
- dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &OUT_hidden, G_TYPE_INVALID);
- (*(org_ayatana_indicator_messages_service_icon_shown_reply)data->cb) (proxy, OUT_hidden, error, data->userdata);
- return;
-}
-
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-DBusGProxyCall*
-org_ayatana_indicator_messages_service_icon_shown_async (DBusGProxy *proxy, org_ayatana_indicator_messages_service_icon_shown_reply callback, gpointer userdata)
-
-{
- DBusGAsyncData *stuff;
- stuff = g_slice_new (DBusGAsyncData);
- stuff->cb = G_CALLBACK (callback);
- stuff->userdata = userdata;
- return dbus_g_proxy_begin_call (proxy, "IconShown", org_ayatana_indicator_messages_service_icon_shown_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID);
-}
-#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_ayatana_indicator_messages_service */
-
-G_END_DECLS
diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c
index d9c0e8d..6cc33e0 100644
--- a/src/messages-service-dbus.c
+++ b/src/messages-service-dbus.c
@@ -24,9 +24,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#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 @@ typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate;
struct _MessageServiceDbusPrivate
{
+ GDBusConnection * connection;
gboolean dot;
gboolean hidden;
};
@@ -51,15 +53,26 @@ static void message_service_dbus_class_init (MessageServiceDbusClass *klass);
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 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass)
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ 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;
+ }
- dbus_g_object_type_install_info(MESSAGE_SERVICE_DBUS_TYPE, &dbus_glib__messages_service_server_object_info);
+ g_debug("Service on session bus");
return;
}
@@ -95,10 +157,7 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass)
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 @@ message_service_dbus_init (MessageServiceDbus *self)
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 @@ message_service_dbus_new (void)
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)
+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(self);
- *dot = priv->dot;
- return TRUE;
-}
+ 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);
+ }
-/* 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;
+ return;
}
void
@@ -167,6 +223,16 @@ message_service_dbus_set_attention (MessageServiceDbus * self, gboolean attentio
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 @@ message_service_dbus_set_icon (MessageServiceDbus * self, gboolean hidden)
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;
}
diff --git a/src/messages-service-server.h b/src/messages-service-server.h
deleted file mode 100644
index 61921f9..0000000
--- a/src/messages-service-server.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Generated by dbus-binding-tool; do not edit! */
-
-
-#ifndef __dbus_glib_marshal__messages_service_server_MARSHAL_H__
-#define __dbus_glib_marshal__messages_service_server_MARSHAL_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#ifdef G_ENABLE_DEBUG
-#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
-#define g_marshal_value_peek_char(v) g_value_get_char (v)
-#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
-#define g_marshal_value_peek_int(v) g_value_get_int (v)
-#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
-#define g_marshal_value_peek_long(v) g_value_get_long (v)
-#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
-#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
-#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
-#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
-#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
-#define g_marshal_value_peek_float(v) g_value_get_float (v)
-#define g_marshal_value_peek_double(v) g_value_get_double (v)
-#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
-#define g_marshal_value_peek_param(v) g_value_get_param (v)
-#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
-#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
-#define g_marshal_value_peek_object(v) g_value_get_object (v)
-#else /* !G_ENABLE_DEBUG */
-/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
- * Do not access GValues directly in your code. Instead, use the
- * g_value_get_*() functions
- */
-#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
-#define g_marshal_value_peek_char(v) (v)->data[0].v_int
-#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
-#define g_marshal_value_peek_int(v) (v)->data[0].v_int
-#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
-#define g_marshal_value_peek_long(v) (v)->data[0].v_long
-#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
-#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
-#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
-#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
-#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
-#define g_marshal_value_peek_float(v) (v)->data[0].v_float
-#define g_marshal_value_peek_double(v) (v)->data[0].v_double
-#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
-#endif /* !G_ENABLE_DEBUG */
-
-
-/* NONE:POINTER */
-#define dbus_glib_marshal__messages_service_server_VOID__POINTER g_cclosure_marshal_VOID__POINTER
-#define dbus_glib_marshal__messages_service_server_NONE__POINTER dbus_glib_marshal__messages_service_server_VOID__POINTER
-
-/* BOOLEAN:POINTER,POINTER */
-extern void dbus_glib_marshal__messages_service_server_BOOLEAN__POINTER_POINTER (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-void
-dbus_glib_marshal__messages_service_server_BOOLEAN__POINTER_POINTER (GClosure *closure,
- GValue *return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data)
-{
- typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- gpointer data2);
- register GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
- gboolean v_return;
-
- g_return_if_fail (return_value != NULL);
- g_return_if_fail (n_param_values == 3);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
-
- v_return = callback (data1,
- g_marshal_value_peek_pointer (param_values + 1),
- g_marshal_value_peek_pointer (param_values + 2),
- data2);
-
- g_value_set_boolean (return_value, v_return);
-}
-
-G_END_DECLS
-
-#endif /* __dbus_glib_marshal__messages_service_server_MARSHAL_H__ */
-
-#include <dbus/dbus-glib.h>
-static const DBusGMethodInfo dbus_glib__messages_service_server_methods[] = {
- { (GCallback) _messages_service_server_watch, dbus_glib_marshal__messages_service_server_NONE__POINTER, 0 },
- { (GCallback) _messages_service_server_attention_requested, dbus_glib_marshal__messages_service_server_BOOLEAN__POINTER_POINTER, 48 },
- { (GCallback) _messages_service_server_icon_shown, dbus_glib_marshal__messages_service_server_BOOLEAN__POINTER_POINTER, 121 },
-};
-
-const DBusGObjectInfo dbus_glib__messages_service_server_object_info = {
- 0,
- dbus_glib__messages_service_server_methods,
- 3,
-"org.ayatana.indicator.messages.service\0Watch\0A\0\0org.ayatana.indicator.messages.service\0AttentionRequested\0S\0dot\0O\0F\0N\0b\0\0org.ayatana.indicator.messages.service\0IconShown\0S\0hidden\0O\0F\0N\0b\0\0\0",
-"org.ayatana.indicator.messages.service\0AttentionChanged\0org.ayatana.indicator.messages.service\0IconChanged\0\0",
-"\0"
-};
-
diff --git a/src/messages-service.c b/src/messages-service.c
index b87c2ff..e3352e8 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -25,7 +25,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#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>
diff --git a/src/messages-service.xml b/src/messages-service.xml
index f991179..8a592db 100644
--- a/src/messages-service.xml
+++ b/src/messages-service.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/">
- <interface name="org.ayatana.indicator.messages.service">
+ <interface name="com.canonical.indicator.messages.service">
<!-- Methods -->
<method name="Watch">