ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #02714
[Merge] lp:~ted/libindicate/gdbus-port-away into lp:libindicate
Ted Gould has proposed merging lp:~ted/libindicate/gdbus-port-away into lp:libindicate.
Requested reviews:
Indicator Applet Developers (indicator-applet-developers)
For more details, see:
https://code.launchpad.net/~ted/libindicate/gdbus-port-away/+merge/46200
--
https://code.launchpad.net/~ted/libindicate/gdbus-port-away/+merge/46200
Your team ayatana-commits is subscribed to branch lp:libindicate.
=== modified file 'bindings/mono/indicate-gtk/Makefile.am'
--- bindings/mono/indicate-gtk/Makefile.am 2010-06-02 13:33:49 +0000
+++ bindings/mono/indicate-gtk/Makefile.am 2011-01-13 22:41:52 +0000
@@ -20,8 +20,7 @@
$(API) \
$(MIDDLE_API) \
$(RAW_API) \
- $(ASSEMBLY_NAME)-sharp-0.1.pc \
- AssemblyInfo.cs
+ $(ASSEMBLY_NAME)-sharp-0.1.pc
DISTCLEANFILES = $(ASSEMBLY).config
customs = Indicate.custom
EXTRA_DIST = \
=== modified file 'bindings/mono/indicate/Makefile.am'
--- bindings/mono/indicate/Makefile.am 2010-06-02 13:33:49 +0000
+++ bindings/mono/indicate/Makefile.am 2011-01-13 22:41:52 +0000
@@ -20,8 +20,7 @@
$(API) \
$(MIDDLE_API) \
$(RAW_API) \
- $(ASSEMBLY_NAME)-sharp-0.1.pc \
- AssemblyInfo.cs
+ $(ASSEMBLY_NAME)-sharp-0.1.pc
DISTCLEANFILES = $(ASSEMBLY).config
customs = Indicate.custom
=== modified file 'bindings/mono/indicate/indicate-api.metadata'
--- bindings/mono/indicate/indicate-api.metadata 2010-06-02 13:33:49 +0000
+++ bindings/mono/indicate/indicate-api.metadata 2011-01-13 22:41:52 +0000
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<metadata>
<remove-node path="/api/namespace/object[@cname='IndicateIndicator']/method[@name='UserDisplay']" />
+ <remove-node path="/api/namespace/object[@cname='IndicateListener']/method[@cname='indicate_listener_get_property_variant']" />
<attr path="/api/namespace/object[@cname='IndicateServer']/method[@name='SetDesktopFile']" name="name">DesktopFile</attr>
<add-node path="/api/namespace/object[@cname='IndicateIndicator']">
<signal when="LAST" field_name="user_display" name="UserDisplay" cname="user_display">
=== modified file 'configure.ac'
--- configure.ac 2010-12-15 11:34:49 +0000
+++ configure.ac 2011-01-13 22:41:52 +0000
@@ -55,11 +55,11 @@
DBUS_REQUIRED_VERSION=0.76
GLIB_REQUIRED_VERSION=2.18
GIO_REQUIRED_VERSION=2.18
-DBUSMENU_REQUIRED_VERSION=0.2.2
+DBUSMENU_REQUIRED_VERSION=0.3.90
PKG_CHECK_MODULES(LIBINDICATE, glib-2.0 >= $GLIB_REQUIRED_VERSION
gio-2.0 >= $GIO_REQUIRED_VERSION
- dbusmenu-glib >= $DBUSMENU_REQUIRED_VERSION
+ dbusmenu-glib-0.4 >= $DBUSMENU_REQUIRED_VERSION
dbus-glib-1 >= $DBUS_REQUIRED_VERSION)
AC_SUBST(LIBINDICATE_CFLAGS)
AC_SUBST(LIBINDICATE_LIBS)
@@ -70,7 +70,7 @@
gio-2.0 >= $GIO_REQUIRED_VERSION
gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED_VERSION
gtk+-2.0 >= $GTK_REQUIRED_VERSION
- dbusmenu-glib >= $DBUSMENU_REQUIRED_VERSION
+ dbusmenu-glib-0.4 >= $DBUSMENU_REQUIRED_VERSION
dbus-glib-1 >= $DBUS_REQUIRED_VERSION)
AC_SUBST(LIBINDICATEGTK_CFLAGS)
AC_SUBST(LIBINDICATEGTK_LIBS)
@@ -79,7 +79,7 @@
# GObject Introspection
###########################
-GOBJECT_INTROSPECTION_CHECK([0.6.3])
+GOBJECT_INTROSPECTION_CHECK([0.6.7])
###########################
# Vala API Generation
=== modified file 'docs/reference/Makefile.am'
--- docs/reference/Makefile.am 2009-12-10 14:59:20 +0000
+++ docs/reference/Makefile.am 2011-01-13 22:41:52 +0000
@@ -68,7 +68,7 @@
# e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
INCLUDES=-I$(top_srcdir) $(LIBINDICATE_CFLAGS)
-GTKDOC_LIBS=$(top_builddir)/libindicate/libindicate.la
+GTKDOC_LIBS=$(top_builddir)/libindicate/libindicate.la $(LIBINDICATEGTK_LIBS)
# This includes the standard gtk-doc make rules, copied by gtkdocize.
include $(top_srcdir)/gtk-doc.local.make
=== modified file 'examples/listen-and-print.c'
--- examples/listen-and-print.c 2010-02-04 22:48:26 +0000
+++ examples/listen-and-print.c 2011-01-13 22:41:52 +0000
@@ -95,13 +95,13 @@
}
static void
-type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data)
+type_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data)
{
g_debug("Indicator Server Type: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), value);
}
static void
-desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data)
+desktop_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data)
{
g_debug("Indicator Server Desktop: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), value);
}
=== modified file 'libindicate-gtk/Makefile.am'
--- libindicate-gtk/Makefile.am 2010-05-21 19:06:12 +0000
+++ libindicate-gtk/Makefile.am 2011-01-13 22:41:52 +0000
@@ -41,47 +41,50 @@
CLEANFILES =
+#########################
+# GObject Introsepction
+#########################
+
+-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = \
+ --add-include-path=$(top_builddir)/libindicate \
+ $(introspection_sources) \
+ --symbol-prefix=indicate \
+ --warn-all \
+ --identifier-prefix=Indicate
+INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) --includedir=$(top_builddir)/libindicate
+
if HAVE_INTROSPECTION
-BUILT_GIRSOURCES =
-
-irscanner_headers = $(patsubst %,$(srcdir)/%,$(indicate_gtk_headers))
-
-Indicate-Gtk-0.2.gir: $(INTROSPECTION_SCANNER) $(irscanner_headers) Makefile.am
- $(INTROSPECTION_SCANNER) \
- -v --namespace Indicate \
- --nsversion=0.2 \
- --add-include-path=$(srcdir) \
- --include=GObject-2.0 \
- --include=GLib-2.0 \
- --include=GdkPixbuf-2.0 \
- --include=Indicate-0.2 \
- --library=indicate-gtk \
- --add-include-path=$(top_builddir)/libindicate \
- $(LIBINDICATEGTK_CFLAGS) -I$(srcdir) -I$(top_srcdir) \
- --output Indicate-Gtk-0.2.gir $(irscanner_headers) \
- $(addprefix --c-include=libindicate-gtk/, $(indicate_gtk_headers))
-
-BUILT_GIRSOURCES += Indicate-Gtk-0.2.gir
+introspection_sources = \
+ $(addprefix $(srcdir)/,$(indicate_gtk_headers))
+
+Indicate-Gtk-0.4.gir: libindicate-gtk.la
+Indicate_Gtk_0_4_gir_INCLUDES = \
+ GObject-2.0 \
+ Gtk-2.0 \
+ GLib-2.0 \
+ GdkPixbuf-2.0 \
+ Indicate-0.4
+Indicate_Gtk_0_4_gir_CFLAGS = $(LIBINDICATEGTK_CFLAGS) -I$(top_builddir) -I$(top_srcdir) -I$(top_builddir)/libindicate
+Indicate_Gtk_0_4_gir_LIBS = libindicate-gtk.la
+Indicate_Gtk_0_4_gir_SCANNERFLAGS = $(INTROSPECTION_SCANNER_ARGS)
+Indicate_Gtk_0_4_gir_FILES = $(introspection_sources)
+
+INTROSPECTION_GIRS += Indicate-Gtk-0.4.gir
girdir = $(datadir)/gir-1.0
-gir_DATA = $(BUILT_GIRSOURCES)
-
-typelibsdir = $(libdir)/girepository-1.0
-typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
-
-%.typelib: %.gir $(INTROSPECTION_COMPILER)
- $(INTROSPECTION_COMPILER) \
- --includedir=$(srcdir) \
- --includedir=. \
- --includedir=$(top_builddir)/libindicate \
- $(INTROSPECTION_COMPILER_OPTS) \
- $< -o $(@F)
-
-CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA)
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+CLEANFILES += $(gir_DATA) $(typelib_DATA)
endif
+
#########################
# VAPI Files
#########################
@@ -89,23 +92,23 @@
if HAVE_INTROSPECTION
vapidir = $(datadir)/vala/vapi
-vapi_DATA = Indicate-Gtk-0.2.vapi
+vapi_DATA = Indicate-Gtk-0.4.vapi
-Indicate-Gtk-0.2.vapi: Indicate-Gtk-0.2.tmp.gir Makefile.am
- $(VALA_API_GEN) --library=Indicate-Gtk-0.2 \
+Indicate-Gtk-0.4.vapi: Indicate-Gtk-0.4.tmp.gir Makefile.am
+ $(VALA_API_GEN) --library=Indicate-Gtk-0.4 \
--pkg gtk+-2.0 \
- --pkg Dbusmenu-Glib-0.2 \
- --pkg Indicate-0.2 \
+ --pkg Dbusmenu-Glib-0.4 \
+ --pkg Indicate-0.4 \
--vapidir=$(top_builddir)/libindicate \
$<
-Indicate-Gtk-0.2.tmp.gir: Indicate-Gtk-0.2.gir
+Indicate-Gtk-0.4.tmp.gir: Indicate-Gtk-0.4.gir
$(SED) \
-e "s|GdkPixbuf.Pixbuf|Gdk.Pixbuf|g" \
-e "s|Atk.ImplementorIface|Atk.Implementor|g" \
$< > $@
-CLEANFILES += $(vapi_DATA) Indicate-Gtk-0.2.tmp.gir
+CLEANFILES += $(vapi_DATA) Indicate-Gtk-0.4.tmp.gir
endif
=== modified file 'libindicate-gtk/listener.c'
--- libindicate-gtk/listener.c 2010-02-04 22:37:39 +0000
+++ libindicate-gtk/listener.c 2011-01-13 22:41:52 +0000
@@ -30,7 +30,6 @@
#include "listener.h"
#include <dbus/dbus-glib-bindings.h>
-#include "../libindicate/indicate-interface-client.h"
#include "../libindicate/listener-private.h"
typedef enum _get_property_type get_property_type;
@@ -50,9 +49,11 @@
};
static void
-get_property_cb (DBusGProxy *proxy, GValue OUT_vvalue, GError *error, gpointer userdata)
+get_property_cb (GObject * object, GAsyncResult * res, gpointer user_data)
{
- get_property_t * get_property_data = (get_property_t *)userdata;
+ get_property_t * get_property_data = (get_property_t *)user_data;
+ GError * error = NULL;
+ GVariant * retvalue = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
if (error != NULL) {
g_warning("Unable to get property data: %s", error->message);
@@ -60,10 +61,12 @@
return;
}
+ GVariant * value = g_variant_get_child_value(retvalue, 0);
+
switch (get_property_data->type) {
case PROPERTY_TYPE_ICON: {
indicate_listener_get_property_icon_cb cb = (indicate_listener_get_property_icon_cb)get_property_data->cb;
- const gchar * OUT_value = g_value_get_string(&OUT_vvalue);
+ const gchar * OUT_value = g_variant_get_string(value, NULL);
/* There is no icon */
if (OUT_value == NULL || OUT_value[0] == '\0') {
@@ -102,12 +105,16 @@
}
}
+ g_variant_unref(value);
g_free(get_property_data->property);
g_free(get_property_data);
return;
};
+/* A small function to take the common list of parameters and
+ build a callback structure to hold them all. Eventually we
+ get the data and unwind this structure. */
static void
get_property_helper (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GCallback callback, gpointer data, get_property_type prop_type)
{
@@ -122,7 +129,16 @@
get_property_data->property = g_strdup(property);
get_property_data->type = prop_type;
- org_ayatana_indicate_get_indicator_property_async (server->proxy , INDICATE_LISTENER_INDICATOR_ID(indicator), property, get_property_cb, get_property_data);
+ g_dbus_proxy_call(server->proxy,
+ "GetIndicatorProperty",
+ g_variant_new("(us)",
+ INDICATE_LISTENER_INDICATOR_ID(indicator), property),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL, /* cancel */
+ get_property_cb,
+ get_property_data);
+
return;
}
=== modified file 'libindicate/Makefile.am'
--- libindicate/Makefile.am 2010-06-02 16:19:59 +0000
+++ libindicate/Makefile.am 2011-01-13 22:41:52 +0000
@@ -39,11 +39,11 @@
libindicateincludedir=$(includedir)/libindicate-0.2/libindicate
indicate_headers = \
- $(srcdir)/indicator.h \
- $(srcdir)/indicator-messages.h \
- $(srcdir)/listener.h \
- $(srcdir)/server.h \
- $(srcdir)/interests.h
+ $(top_srcdir)/libindicate/indicator.h \
+ $(top_srcdir)/libindicate/indicator-messages.h \
+ $(top_srcdir)/libindicate/listener.h \
+ $(top_srcdir)/libindicate/server.h \
+ $(top_srcdir)/libindicate/interests.h
libindicateinclude_HEADERS = \
$(indicate_headers) \
@@ -51,6 +51,10 @@
libindicate_la_SOURCES = \
$(indicate_headers) \
+ gen-indicate-interface.xml.h \
+ gen-indicate-interface.xml.c \
+ gen-indicate-listener.xml.h \
+ gen-indicate-listener.xml.c \
dbus-shared.h \
indicate-enum-types.c \
server.c \
@@ -77,27 +81,24 @@
##################################
DBUS_SPECS = \
- dbus-properties.xml \
indicate-interface.xml \
indicate-listener.xml
-%-client.h: %.xml
- dbus-binding-tool \
- --prefix=_$(notdir $(subst -,_,$(<:.xml=)))_client \
- --mode=glib-client \
- --output=$@ \
- $<
+gen-%.xml.h: %.xml
+ @echo "Building $@ from $<"
+ @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $<)));" > $@
-%-server.h: %.xml
- dbus-binding-tool \
- --prefix=_$(notdir $(subst -,_,$(<:.xml=)))_server \
- --mode=glib-server \
- --output=$@ \
- $<
+gen-%.xml.c: %.xml
+ @echo "Building $@ from $<"
+ @echo "const char * _$(subst -,_,$(subst .,_,$(basename $<))) = " > $@
+ @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@
+ @echo ";" >> $@
BUILT_SOURCES += \
- $(DBUS_SPECS:.xml=-client.h) \
- $(DBUS_SPECS:.xml=-server.h)
+ gen-indicate-interface.xml.h \
+ gen-indicate-interface.xml.c \
+ gen-indicate-listener.xml.h \
+ gen-indicate-listener.xml.c
pkgconfig_DATA = indicate.pc
pkgconfigdir = $(libdir)/pkgconfig
@@ -105,41 +106,43 @@
CLEANFILES += \
$(BUILT_SOURCES)
+#########################
+# GObject Introsepction
+#########################
+
+-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = \
+ --add-include-path=$(srcdir) \
+ --add-include-path=$(top_srcdir)/libindicate \
+ $(introspection_sources) \
+ --symbol-prefix=indicate \
+ --warn-all \
+ --identifier-prefix=Indicate
+INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) --includedir=$(top_srcdir)/libindicate
+
if HAVE_INTROSPECTION
-BUILT_GIRSOURCES =
-
-irscanner_headers = $(patsubst %,$(srcdir)/%,$(indicate_headers))
-
-Indicate-0.2.gir: $(INTROSPECTION_SCANNER) $(irscanner_headers) Makefile.am
- $(INTROSPECTION_SCANNER) \
- -v --namespace Indicate \
- --nsversion=0.2 \
- --add-include-path=$(srcdir) \
- --include=GObject-2.0 \
- --include=GLib-2.0 \
- --include=Dbusmenu-Glib-0.2 \
- --library=indicate \
- $(LIBINDICATE_CFLAGS) -I $(srcdir) -I $(top_srcdir) \
- --output Indicate-0.2.gir $(irscanner_headers) \
- $(addprefix --c-include=libindicate/, $(indicate_headers))
-
-BUILT_GIRSOURCES += Indicate-0.2.gir
+introspection_sources = $(indicate_headers)
+
+Indicate-0.4.gir: libindicate.la
+Indicate_0_4_gir_INCLUDES = \
+ GObject-2.0 \
+ GLib-2.0 \
+ Dbusmenu-Glib-0.4
+Indicate_0_4_gir_CFLAGS = $(LIBINDICATE_CFLAGS) -I$(srcdir)
+Indicate_0_4_gir_LIBS = libindicate.la
+Indicate_0_4_gir_FILES = $(introspection_sources)
+
+INTROSPECTION_GIRS += Indicate-0.4.gir
girdir = $(datadir)/gir-1.0
-gir_DATA = $(BUILT_GIRSOURCES)
-
-typelibsdir = $(libdir)/girepository-1.0
-typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
-
-%.typelib: %.gir $(INTROSPECTION_COMPILER)
- $(INTROSPECTION_COMPILER) \
- --includedir=$(srcdir) \
- --includedir=. \
- $(INTROSPECTION_COMPILER_OPTS) \
- $< -o $(@F)
-
-CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA)
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+CLEANFILES += $(gir_DATA) $(typelib_DATA)
endif
@@ -150,12 +153,12 @@
if HAVE_INTROSPECTION
vapidir = $(datadir)/vala/vapi
-vapi_DATA = Indicate-0.2.vapi
+vapi_DATA = Indicate-0.4.vapi
-Indicate-0.2.vapi: Indicate-0.2.gir Makefile.am
- $(VALA_API_GEN) --library=Indicate-0.2 \
+Indicate-0.4.vapi: Indicate-0.4.gir Makefile.am
+ $(VALA_API_GEN) --library=Indicate-0.4 \
--pkg glib-2.0 \
- --pkg Dbusmenu-Glib-0.2 \
+ --pkg Dbusmenu-Glib-0.4 \
--vapidir=$(top_builddir)/src \
$<
=== removed file 'libindicate/dbus-properties.xml'
--- libindicate/dbus-properties.xml 2010-02-03 23:15:33 +0000
+++ libindicate/dbus-properties.xml 1970-01-01 00:00:00 +0000
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<node name="/">
- <interface name="org.freedesktop.DBus.Properties">
-
- <method name="Get">
- <arg direction="in" type="s" name="Interface_Name"/>
- <arg direction="in" type="s" name="Property_Name"/>
- <arg direction="out" type="v" name="Value"/>
- </method>
-
- <method name="Set">
- <arg direction="in" type="s" name="Interface_Name"/>
- <arg direction="in" type="s" name="Property_Name"/>
- <arg direction="in" type="v" name="Value"/>
- </method>
-
- <method name="GetAll">
- <arg direction="in" type="s" name="Interface_Name"/>
- <arg direction="out" type="a{sv}" name="Properties"/>
- </method>
-
- </interface>
-</node>
=== modified file 'libindicate/dbus-shared.h'
--- libindicate/dbus-shared.h 2010-02-03 17:54:41 +0000
+++ libindicate/dbus-shared.h 2011-01-13 22:41:52 +0000
@@ -30,5 +30,6 @@
#define INDICATE_DBUS_IFACE "org.ayatana.indicate"
#define INDICATE_LISTENER_DBUS_IFACE "org.ayatana.indicate.listener"
+#define INDICATE_LISTENER_OBJ_PATH "/org/ayatana/indicate/listener"
#endif /* INDICATE_DBUS_SHARED */
=== modified file 'libindicate/indicate.pc.in'
--- libindicate/indicate.pc.in 2010-02-04 23:45:52 +0000
+++ libindicate/indicate.pc.in 2011-01-13 22:41:52 +0000
@@ -5,7 +5,7 @@
includedir=@includedir@
Cflags: -I${includedir}/libindicate-0.2
-Requires: gobject-2.0 glib-2.0 dbus-glib-1 dbusmenu-glib
+Requires: gobject-2.0 glib-2.0 dbusmenu-glib-0.4
Libs: -L${libdir} -lindicate
Name: libindicate
=== modified file 'libindicate/indicator.c'
--- libindicate/indicator.c 2010-06-04 18:42:01 +0000
+++ libindicate/indicator.c 2011-01-13 22:41:52 +0000
@@ -60,8 +60,8 @@
G_DEFINE_TYPE (IndicateIndicator, indicate_indicator, G_TYPE_OBJECT);
static void indicate_indicator_finalize (GObject * object);
-static void set_property (IndicateIndicator * indicator, const gchar * key, const GValue * data);
-static const GValue * get_property (IndicateIndicator * indicator, const gchar * key);
+static void set_property (IndicateIndicator * indicator, const gchar * key, GVariant * data);
+static GVariant * get_property (IndicateIndicator * indicator, const gchar * key);
static GPtrArray * list_properties (IndicateIndicator * indicator);
@@ -169,12 +169,11 @@
/* A small little function to both clear the insides of a
value as well as the memory it itself uses. */
static void
-_g_value_free (gpointer data)
+_g_variant_unref (gpointer data)
{
if (data == NULL) return;
- GValue * value = (GValue*)data;
- g_value_unset(value);
- g_free(data);
+ GVariant * value = (GVariant*)data;
+ g_variant_unref(value);
return;
}
@@ -187,7 +186,7 @@
priv->is_visible = FALSE;
priv->is_displayed = FALSE;
- priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_value_free);
+ priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_variant_unref);
priv->server = indicate_server_ref_default();
priv->id = indicate_server_get_next_id(priv->server);
@@ -428,11 +427,8 @@
return;
}
- GValue strval = {0};
- g_value_init(&strval, G_TYPE_STRING);
- g_value_set_static_string(&strval, data);
-
- return class->set_property(indicator, key, &strval);
+ GVariant * variant = g_variant_new_string(data);
+ return class->set_property(indicator, key, variant);
}
/**
@@ -479,7 +475,8 @@
g_value_init(&intval, G_TYPE_INT);
g_value_set_int(&intval, value);
- return class->set_property(indicator, key, &intval);
+ GVariant * variant = g_variant_new_int32(value);
+ return class->set_property(indicator, key, variant);
}
/**
@@ -500,15 +497,12 @@
return;
}
- GValue boolval = {0};
- g_value_init(&boolval, G_TYPE_BOOLEAN);
- g_value_set_boolean(&boolval, value);
-
- return class->set_property(indicator, key, &boolval);
+ GVariant * variant = g_variant_new_boolean(value);
+ return class->set_property(indicator, key, variant);
}
void
-indicate_indicator_set_property_value (IndicateIndicator * indicator, const gchar * key, GValue * value)
+indicate_indicator_set_property_variant (IndicateIndicator * indicator, const gchar * key, GVariant * value)
{
IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
if (class->set_property == NULL) {
@@ -536,12 +530,16 @@
return NULL;
}
- const GValue * val = class->get_property(indicator, key);
- return g_value_get_string(val);
+ GVariant * val = class->get_property(indicator, key);
+ if (val == NULL) {
+ return NULL;
+ } else {
+ return g_variant_get_string(val, NULL);
+ }
}
-const GValue *
-indicate_indicator_get_property_value (IndicateIndicator * indicator, const gchar * key)
+GVariant *
+indicate_indicator_get_property_variant (IndicateIndicator * indicator, const gchar * key)
{
IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
if (class->get_property == NULL) {
@@ -563,18 +561,16 @@
}
static void
-set_property (IndicateIndicator * indicator, const gchar * key, const GValue * data)
+set_property (IndicateIndicator * indicator, const gchar * key, GVariant * data)
{
g_return_if_fail(INDICATE_IS_INDICATOR(indicator));
IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
gchar * newkey = g_strdup(key);
- GValue * newval = g_new0(GValue, 1);
- g_value_init(newval, G_VALUE_TYPE(data));
- g_value_copy(data, newval);
+ g_variant_ref(data);
- g_hash_table_replace(priv->properties, newkey, newval);
+ g_hash_table_replace(priv->properties, newkey, data);
if (indicate_indicator_is_visible(indicator)) {
/* g_debug("Indicator property modified: %s", key); */
@@ -584,14 +580,14 @@
return;
}
-static const GValue *
+static GVariant *
get_property (IndicateIndicator * indicator, const gchar * key)
{
g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), NULL);
IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
- return (const GValue *)g_hash_table_lookup(priv->properties, key);
+ return (GVariant *)g_hash_table_lookup(priv->properties, key);
}
static GPtrArray *
=== modified file 'libindicate/indicator.h'
--- libindicate/indicator.h 2010-06-04 18:42:01 +0000
+++ libindicate/indicator.h 2011-01-13 22:41:52 +0000
@@ -124,8 +124,8 @@
void (*displayed) (IndicateIndicator * indicator, gboolean displayed);
/* Subclassable functions */
- void (*set_property) (IndicateIndicator * indicator, const gchar * key, const GValue * data);
- const GValue * (*get_property) (IndicateIndicator * indicator, const gchar * key);
+ void (*set_property) (IndicateIndicator * indicator, const gchar * key, GVariant * data);
+ GVariant * (*get_property) (IndicateIndicator * indicator, const gchar * key);
indicate_indicator_list_properties_slot_t list_properties;
/* Reserver for future use */
@@ -161,10 +161,10 @@
void indicate_indicator_set_property_time (IndicateIndicator * indicator, const gchar * key, GTimeVal * time);
void indicate_indicator_set_property_int (IndicateIndicator * indicator, const gchar * key, gint value);
void indicate_indicator_set_property_bool (IndicateIndicator * indicator, const gchar * key, gboolean value);
-void indicate_indicator_set_property_value (IndicateIndicator * indicator, const gchar * key, GValue * value);
+void indicate_indicator_set_property_variant (IndicateIndicator * indicator, const gchar * key, GVariant * value);
const gchar * indicate_indicator_get_property (IndicateIndicator * indicator, const gchar * key);
-const GValue * indicate_indicator_get_property_value (IndicateIndicator * indicator, const gchar * key);
+GVariant * indicate_indicator_get_property_variant (IndicateIndicator * indicator, const gchar * key);
/**
* indicate_indicator_list_properties:
=== modified file 'libindicate/listener-private.h'
--- libindicate/listener-private.h 2010-06-04 18:40:15 +0000
+++ libindicate/listener-private.h 2011-01-13 22:41:52 +0000
@@ -30,12 +30,10 @@
#ifndef INDICATE_LISTENER_PRIVATE_H__
#define INDICATE_LISTENER_PRIVATE_H__ 1
-#include <dbus/dbus-glib.h>
-
struct _IndicateListenerServer {
gchar * name;
- DBusGProxy * proxy;
- DBusGConnection * connection;
+ GDBusProxy * proxy;
+ GDBusConnection * connection;
gboolean interests[INDICATE_INTEREST_LAST];
gint max_indicators;
};
@@ -47,8 +45,9 @@
typedef struct _IndicateListenerPrivate IndicateListenerPrivate;
struct _IndicateListenerPrivate
{
- DBusGConnection * session_bus;
- DBusGConnection * system_bus;
+ GDBusConnection * session_bus;
+ guint object_registration;
+ guint signal_subscription;
GList * proxies;
=== modified file 'libindicate/listener.c'
--- libindicate/listener.c 2010-02-18 22:15:49 +0000
+++ libindicate/listener.c 2011-01-13 22:41:52 +0000
@@ -28,14 +28,13 @@
*/
#include <stdlib.h>
+#include <gio/gio.h>
#include "listener.h"
-#include "indicate-marshal.h"
-#include <dbus/dbus-glib-bindings.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include "interests-priv.h"
#include "dbus-shared.h"
-#include "indicate-interface-client.h"
-#include "dbus-properties-client.h"
+#include "gen-indicate-interface.xml.h"
+#include "gen-indicate-listener.xml.h"
+#include "indicate-marshal.h"
/* Errors */
enum {
@@ -59,9 +58,9 @@
#include "listener-private.h"
typedef struct {
- DBusGProxy * proxy;
- DBusGProxy * property_proxy;
- DBusGConnection * connection;
+ GDBusProxy * proxy;
+ GDBusProxy * property_proxy;
+ GDBusConnection * connection;
gchar * name;
gchar * path;
gchar * type;
@@ -87,7 +86,7 @@
}
typedef struct {
- DBusGConnection * bus;
+ GDBusConnection * bus;
gchar * name;
gchar * path;
} proxy_todo_t;
@@ -96,27 +95,38 @@
/* Prototypes */
static void indicate_listener_finalize (GObject * obj);
-static DBusHandlerResult dbus_filter_show_server (DBusConnection * connection, DBusMessage * message, void * user_data);
+static void indicate_listener_dispose (GObject * obj);
static void proxy_struct_destroy (gpointer data);
static void todo_list_add (const gchar * name, const gchar * path, IndicateListener * listener);
static gboolean todo_idle (gpointer data);
-void set_max_indicators_cb (DBusGProxy * proxy, GError * error, gpointer userdata);
-static void get_type_initial_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data);
-static void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data);
-static void proxy_indicator_added_legacy (DBusGProxy * proxy, guint id, gchar * type, proxy_t * proxyt);
-static void proxy_indicator_added (DBusGProxy * proxy, guint id, proxy_t * proxyt);
-static void proxy_indicator_removed_legacy (DBusGProxy * proxy, guint id, gchar * type, proxy_t * proxyt);
-static void proxy_indicator_removed (DBusGProxy * proxy, guint id, proxy_t * proxyt);
-static void proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, proxy_t * proxyt);
-static void proxy_server_count_changed (DBusGProxy * proxy, guint count, proxy_t * proxyt);
-static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data);
+static void set_max_indicators_cb (GObject * object, GAsyncResult * res, gpointer user_data);
+static void get_type_initial_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * type, gpointer data);
+static void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * type, gpointer data);
+static void proxy_indicator_added_legacy (guint id, gchar * type, proxy_t * proxyt);
+static void proxy_indicator_added (guint id, proxy_t * proxyt);
+static void proxy_indicator_removed_legacy (guint id, gchar * type, proxy_t * proxyt);
+static void proxy_indicator_removed (guint id, proxy_t * proxyt);
+static void proxy_indicator_modified (guint id, const gchar * property, proxy_t * proxyt);
+static void proxy_server_count_changed (guint count, proxy_t * proxyt);
+static void proxy_get_indicator_list (GObject * object, GAsyncResult * res, gpointer data);
static void proxy_destroyed (GObject * proxy, gpointer user_data);
-
-/* DBus interface */
-gboolean _indicate_listener_server_get_indicator_servers (IndicateListener * listener, GList * servers);
-
-/* Need the above prototypes */
-#include "indicate-listener-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 void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data);
+static void bus_filter_show_server (GDBusConnection * connection, const gchar * sender, const gchar * object, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data);
+static void prox_ready_cb (GObject * object, GAsyncResult * res, gpointer user_data);
+static void proxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVariant * params, gpointer user_data);
+
+/* Bus Stuff */
+static GDBusNodeInfo * bus_indicate_node_info = NULL;
+static GDBusInterfaceInfo * bus_indicate_interface_info = NULL;
+static GDBusNodeInfo * bus_listener_node_info = NULL;
+static GDBusInterfaceInfo * bus_listener_interface_info = NULL;
+static const GDBusInterfaceVTable bus_interface_table = {
+ method_call: bus_method_call,
+ get_property: NULL, /* No properties that can be get */
+ set_property: NULL /* No properties that can be set */
+};
+
/* Code */
static void
@@ -128,6 +138,7 @@
g_type_class_add_private (class, sizeof (IndicateListenerPrivate));
+ gobj->dispose = indicate_listener_dispose;
gobj->finalize = indicate_listener_finalize;
signals[INDICATOR_ADDED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED,
@@ -180,14 +191,42 @@
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0, G_TYPE_NONE);
- dbus_g_object_register_marshaller(_indicate_marshal_VOID__UINT_STRING,
- G_TYPE_NONE,
- G_TYPE_UINT,
- G_TYPE_STRING,
- G_TYPE_INVALID);
-
- dbus_g_object_type_install_info(INDICATE_TYPE_LISTENER,
- &dbus_glib__indicate_listener_server_object_info);
+ /* DBus interfaces */
+ if (bus_indicate_node_info == NULL) {
+ GError * error = NULL;
+
+ bus_indicate_node_info = g_dbus_node_info_new_for_xml(_indicate_interface, &error);
+ if (error != NULL) {
+ g_error("Unable to parse Indicate Interface description: %s", error->message);
+ g_error_free(error);
+ }
+ }
+
+ if (bus_indicate_interface_info == NULL) {
+ bus_indicate_interface_info = g_dbus_node_info_lookup_interface(bus_indicate_node_info, INDICATE_DBUS_IFACE);
+
+ if (bus_indicate_interface_info == NULL) {
+ g_error("Unable to find interface '" INDICATE_DBUS_IFACE "'");
+ }
+ }
+
+ if (bus_listener_node_info == NULL) {
+ GError * error = NULL;
+
+ bus_listener_node_info = g_dbus_node_info_new_for_xml(_indicate_listener, &error);
+ if (error != NULL) {
+ g_error("Unable to parse Listener Interface description: %s", error->message);
+ g_error_free(error);
+ }
+ }
+
+ if (bus_listener_interface_info == NULL) {
+ bus_listener_interface_info = g_dbus_node_info_lookup_interface(bus_listener_node_info, INDICATE_LISTENER_DBUS_IFACE);
+
+ if (bus_listener_interface_info == NULL) {
+ g_error("Unable to find interface '" INDICATE_LISTENER_DBUS_IFACE "'");
+ }
+ }
return;
}
@@ -197,15 +236,12 @@
{
/* g_debug("Listener Object Initialized"); */
IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
- GError *error = NULL;
/* Get the buses */
- priv->session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
- if (error != NULL) {
- g_error("Unable to get session bus: %s", error->message);
- g_error_free(error);
- return;
- }
+ g_bus_get(G_BUS_TYPE_SESSION,
+ NULL, /* TODO: Cancelable */
+ bus_get_cb,
+ listener);
/* Initialize Data structures */
priv->proxies = NULL;
@@ -216,22 +252,31 @@
priv->max_indicators = -1;
- dbus_g_connection_register_g_object(priv->session_bus,
- "/org/ayatana/indicate/listener",
- G_OBJECT(listener));
-
- /* WARNING */
- /* Starting massive asynchronisity */
- /* */
-
- dbus_connection_add_filter(dbus_g_connection_get_connection(priv->session_bus), dbus_filter_show_server, listener, NULL);
- dbus_bus_add_match(dbus_g_connection_get_connection(priv->session_bus), "type='signal',interface='" INDICATE_DBUS_IFACE "',member='ServerShow'", NULL);
-
- g_signal_emit(G_OBJECT(listener), signals[INDICATOR_SERVERS_REPORT], 0, TRUE);
-
- return;
-}
-
+ return;
+}
+
+/* Remove references to objects */
+static void
+indicate_listener_dispose (GObject * obj)
+{
+ IndicateListener * listener = INDICATE_LISTENER(obj);
+ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
+
+ if (priv->signal_subscription != 0) {
+ g_dbus_connection_signal_unsubscribe(priv->session_bus, priv->signal_subscription);
+ priv->signal_subscription = 0;
+ }
+
+ if (priv->object_registration != 0) {
+ g_dbus_connection_signal_unsubscribe(priv->session_bus, priv->object_registration);
+ priv->object_registration = 0;
+ }
+
+ G_OBJECT_CLASS (indicate_listener_parent_class)->dispose (obj);
+ return;
+}
+
+/* Free memory */
static void
indicate_listener_finalize (GObject * obj)
{
@@ -241,18 +286,86 @@
if (priv->todo_idle != 0) {
g_idle_remove_by_data(obj);
}
+
/* Hack: proxy_struct_destroy() lacks a user_data parameter, but since the
* caller is responsible for handling params on the stack, it works
*/
g_list_foreach(priv->proxies, (GFunc)proxy_struct_destroy, NULL);
g_list_free(priv->proxies);
- dbus_connection_remove_filter(dbus_g_connection_get_connection(priv->session_bus), dbus_filter_show_server, listener);
-
G_OBJECT_CLASS (indicate_listener_parent_class)->finalize (obj);
return;
}
+/* Response to connecting to the session bus */
+static void
+bus_get_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 get session bus: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(user_data);
+ priv->session_bus = connection;
+
+ /* Export this object onto the bus */
+ priv->object_registration = g_dbus_connection_register_object(priv->session_bus,
+ INDICATE_LISTENER_OBJ_PATH,
+ bus_listener_interface_info,
+ &bus_interface_table,
+ user_data,
+ NULL,
+ &error);
+
+ if (error != NULL) {
+ g_error("Unable to register listener on the bus: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ /* Watch for servers starting up */
+ priv->signal_subscription = g_dbus_connection_signal_subscribe(priv->session_bus,
+ NULL, /* sender */
+ INDICATE_DBUS_IFACE,
+ "ServerShow",
+ NULL, /* path */
+ NULL, /* arg0 */
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ bus_filter_show_server,
+ user_data,
+ NULL); /* destroy notify */
+
+ /* Tell that we're here! */
+ g_dbus_connection_emit_signal(priv->session_bus,
+ NULL, /* dest */
+ INDICATE_LISTENER_OBJ_PATH,
+ INDICATE_LISTENER_DBUS_IFACE,
+ "IndicatorServersReport",
+ NULL, /* params */
+ &error);
+
+ if (error != NULL) {
+ g_warning("Unable to send the 'IndicatorServersReport' signal: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ return;
+}
+
+/* Handle a metho call from dbus */
+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)
+{
+
+ /* TODO: We should do this, in the future though */
+}
+
/**
indicate_listener_new:
@@ -302,19 +415,16 @@
/* A small filter function that notices when someone sends
a ServerShow signal and creates an entry for us to investigate
them more in an idle loop lookup. */
-static DBusHandlerResult
-dbus_filter_show_server (DBusConnection * connection, DBusMessage * message, void * user_data)
+static void
+bus_filter_show_server (GDBusConnection * connection, const gchar * sender, const gchar * object, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data)
{
- if (!dbus_message_is_signal(message, INDICATE_DBUS_IFACE, "ServerShow")) {
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ if (g_strcmp0(signal, "ServerShow") != 0) {
+ return;
}
- const char * sender = dbus_message_get_sender(message);
- const char * path = dbus_message_get_path(message);
-
- todo_list_add(sender, path, INDICATE_LISTENER(user_data));
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ todo_list_add(sender, object, INDICATE_LISTENER(user_data));
+
+ return;
}
/* A hashtable for each function to look at all of the indicators
@@ -347,12 +457,7 @@
proxy_data->indicators = NULL;
}
- if (DBUS_IS_G_PROXY(proxy_data->property_proxy)) {
- g_object_unref(G_OBJECT(proxy_data->property_proxy));
- }
-
- if (DBUS_IS_G_PROXY(proxy_data->proxy)) {
- g_signal_handlers_disconnect_by_func(proxy_data->proxy, proxy_destroyed, proxy_data);
+ if (proxy_data->proxy != NULL) {
g_object_unref(G_OBJECT(proxy_data->proxy));
}
@@ -473,54 +578,45 @@
/* Build the proxy and ensure that it gets created. If
it gets created we're all happy. */
+ g_dbus_proxy_new(priv->session_bus,
+ G_DBUS_PROXY_FLAGS_NONE,
+ bus_indicate_interface_info,
+ proxyt->name,
+ todo->path,
+ INDICATE_DBUS_IFACE,
+ NULL, /* cancel */
+ prox_ready_cb,
+ proxyt);
+
+ return TRUE; /* do the next entry */
+}
+
+/* Async result of building a proxy */
+static void
+prox_ready_cb (GObject * object, GAsyncResult * res, gpointer user_data)
+{
+ proxy_t * proxyt = (proxy_t *)user_data;
GError * error = NULL;
- proxyt->proxy = dbus_g_proxy_new_for_name_owner(todo->bus,
- proxyt->name,
- todo->path,
- INDICATE_DBUS_IFACE,
- &error);
+ GDBusProxy * proxy = g_dbus_proxy_new_finish(res, &error);
if (error != NULL) {
g_warning("Unable to create proxy for %s", proxyt->name);
g_error_free(error);
- return TRUE;
+ return;
}
- g_signal_connect(G_OBJECT(proxyt->proxy), "destroy", G_CALLBACK(proxy_destroyed), proxyt);
+ proxyt->proxy = proxy;
+
+ g_signal_connect(G_OBJECT(proxyt->proxy), "notify::g-name-owner", G_CALLBACK(proxy_destroyed), proxyt);
+ g_signal_connect(G_OBJECT(proxyt->proxy), "g-signal", G_CALLBACK(proxy_signal_cb), proxyt);
/* Making sure the server has the proxy as well */
proxyt->server.proxy = proxyt->proxy;
+ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(proxyt->listener);
/* Adding into the list of proxies */
priv->proxies = g_list_prepend(priv->proxies, proxyt);
- /* Setup all the signals that we need off of this
- proxy. Lot's of fun signals. */
- dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorAdded",
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorAdded",
- G_CALLBACK(proxy_indicator_added_legacy), proxyt, NULL);
- dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorNew",
- G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorNew",
- G_CALLBACK(proxy_indicator_added), proxyt, NULL);
- dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorRemoved",
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorRemoved",
- G_CALLBACK(proxy_indicator_removed_legacy), proxyt, NULL);
- dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorDelete",
- G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorDelete",
- G_CALLBACK(proxy_indicator_removed), proxyt, NULL);
- dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorModified",
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorModified",
- G_CALLBACK(proxy_indicator_modified), proxyt, NULL);
- dbus_g_proxy_add_signal(proxyt->proxy, "ServerCountChanged",
- G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(proxyt->proxy, "ServerCountChanged",
- G_CALLBACK(proxy_server_count_changed), proxyt, NULL);
-
/* We're setting the max number of indicators from the default
when we detect it. This should give a reasonable amount of
time for listeners to set the default if they want something
@@ -528,20 +624,77 @@
first couple. */
proxyt->server.max_indicators = priv->max_indicators;
if (proxyt->server.max_indicators != -1) {
- org_ayatana_indicate_set_max_indicators_async(proxyt->proxy, proxyt->server.max_indicators, set_max_indicators_cb, proxyt->name);
+ g_dbus_proxy_call(proxyt->proxy,
+ "SetMaxIndicators",
+ g_variant_new("(u)", proxyt->server.max_indicators),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL,
+ set_max_indicators_cb,
+ proxyt->server.name);
}
indicate_listener_server_get_type(proxyt->listener, &proxyt->server, get_type_initial_cb, proxyt);
- org_ayatana_indicate_get_indicator_list_async(proxyt->proxy, proxy_get_indicator_list, proxyt);
-
- return TRUE;
+
+
+ g_dbus_proxy_call(proxyt->proxy,
+ "GetIndicatorList",
+ NULL, /* params */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL,
+ proxy_get_indicator_list,
+ proxyt);
+
+ return;
+}
+
+/* We need to do the right signal now */
+static void
+proxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVariant * params, gpointer user_data)
+{
+ proxy_t * proxyt = (proxy_t *)user_data;
+
+ if (g_strcmp0(signal, "IndicatorAdded") == 0) {
+ guint id; gchar * type;
+ g_variant_get(params, "(us)", &id, &type);
+ proxy_indicator_added_legacy(id, type, proxyt);
+ } else if (g_strcmp0(signal, "IndicatorNew") == 0) {
+ guint id;
+ g_variant_get(params, "(u)", &id);
+ proxy_indicator_added(id, proxyt);
+ } else if (g_strcmp0(signal, "IndicatorRemoved") == 0) {
+ guint id; gchar * type;
+ g_variant_get(params, "(us)", &id, &type);
+ proxy_indicator_removed_legacy(id, type, proxyt);
+ } else if (g_strcmp0(signal, "IndicatorDelete") == 0) {
+ guint id;
+ g_variant_get(params, "(u)", &id);
+ proxy_indicator_removed(id, proxyt);
+ } else if (g_strcmp0(signal, "IndicatorModified") == 0) {
+ guint id; gchar * property;
+ g_variant_get(params, "(us)", &id, &property);
+ proxy_indicator_modified(id, property, proxyt);
+ } else if (g_strcmp0(signal, "ServerCountChanged") == 0) {
+ guint count;
+ g_variant_get(params, "(u)", &count);
+ proxy_server_count_changed(count, proxyt);
+ } else if (g_strcmp0(signal, "ServerShow") == 0) {
+ /* Unused here */
+ } else if (g_strcmp0(signal, "ServerHide") == 0) {
+ /* Unused here */
+ } else {
+ g_warning("Unknown signal from server '%s'", signal);
+ }
+
+ return;
}
/* A callback function for the getting the type when it is looked
at initially. So that we'll send a signal that the server has
been added so that everyone knows. */
static void
-get_type_initial_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
+get_type_initial_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * type, gpointer data)
{
get_type_cb(listener, server, type, data);
@@ -558,7 +711,7 @@
this directly now, only through get_type_initial_cb right now
though we might use it more directly later. */
static void
-get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
+get_type_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * type, gpointer data)
{
if (type == NULL) {
/* This is usually caused by an error getting the type,
@@ -579,13 +732,17 @@
/* A call back from setting the max indicators. We really can't
do anything about it, so this function is kinda useless. */
-void
-set_max_indicators_cb (DBusGProxy * proxy, GError * error, gpointer userdata)
+static void
+set_max_indicators_cb (GObject * object, GAsyncResult * res, gpointer user_data)
{
+ GError * error = NULL;
+ g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
+
if (error != NULL) {
- g_warning("Unable to set the max indicators on '%s': %s", (gchar *)userdata, error->message);
+ g_warning("Unable to set the max indicators on '%s': %s", (gchar *)user_data, error->message);
g_error_free(error);
}
+
return;
}
@@ -593,20 +750,30 @@
servers that we've found through introspection. It takes
the list and then calls indicator_added on each one. */
static void
-proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data)
+proxy_get_indicator_list (GObject * object, GAsyncResult * res, gpointer data)
{
+ GError * error = NULL;
+ GVariant * retval = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
+
if (error != NULL) {
+ g_warning("Unable to get indicator list");
+ g_error_free(error);
return;
}
proxy_t * proxyt = (proxy_t *)data;
- int i;
- for (i = 0; i < indicators->len; i++) {
- guint id = g_array_index(indicators, guint, i);
- proxy_indicator_added(proxy, id, proxyt);
+ GVariant * list = g_variant_get_child_value(retval, 0);
+ GVariantIter iter;
+ g_variant_iter_init(&iter, list);
+ gint id;
+
+ while (g_variant_iter_next(&iter, "i", &id)) {
+ proxy_indicator_added(id, proxyt);
}
+ g_variant_unref(retval);
+
return;
}
@@ -615,9 +782,9 @@
signals on the indicator v1 interface. It just drops
the type and calls the new function. */
static void
-proxy_indicator_added_legacy (DBusGProxy * proxy, guint id, gchar * type, proxy_t * proxyt)
+proxy_indicator_added_legacy (guint id, gchar * type, proxy_t * proxyt)
{
- return proxy_indicator_added(proxy, id, proxyt);
+ return proxy_indicator_added(id, proxyt);
}
/* Gets called when we get a signal from the server that
@@ -626,7 +793,7 @@
been known about before, we create the appropriate
structures for it. */
static void
-proxy_indicator_added (DBusGProxy * proxy, guint id, proxy_t * proxyt)
+proxy_indicator_added (guint id, proxy_t * proxyt)
{
g_debug("Proxy Indicator Added");
g_return_if_fail(proxyt != NULL);
@@ -643,16 +810,16 @@
signals on the indicator v1 interface. It just drops
the type and calls the new function. */
static void
-proxy_indicator_removed_legacy (DBusGProxy * proxy, guint id, gchar * type, proxy_t * proxyt)
+proxy_indicator_removed_legacy (guint id, gchar * type, proxy_t * proxyt)
{
- return proxy_indicator_removed(proxy, id, proxyt);
+ return proxy_indicator_removed(id, proxyt);
}
/* A server removed an indicator. This function removes all the
local data structures and then passes the signal up the stack.
*/
static void
-proxy_indicator_removed (DBusGProxy * proxy, guint id, proxy_t * proxyt)
+proxy_indicator_removed (guint id, proxy_t * proxyt)
{
g_debug("Proxy Indicator Removed");
g_return_if_fail(proxyt != NULL);
@@ -677,7 +844,7 @@
has been modified. We try and find the indicator, convert all
the parameters to the local ones, and then pass up the signal. */
static void
-proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, proxy_t * proxyt)
+proxy_indicator_modified (guint id, const gchar * property, proxy_t * proxyt)
{
g_debug("Proxy Indicator Modified");
g_return_if_fail(proxyt != NULL);
@@ -702,7 +869,7 @@
it into a local signal with the appropraite parameters
and structures. */
static void
-proxy_server_count_changed (DBusGProxy * proxy, guint count, proxy_t * proxyt)
+proxy_server_count_changed (guint count, proxy_t * proxyt)
{
g_debug("Proxy Server Count Changed");
g_return_if_fail(proxyt != NULL);
@@ -712,7 +879,7 @@
typedef enum _get_property_type get_property_type;
enum _get_property_type {
- PROPERTY_TYPE_VALUE,
+ PROPERTY_TYPE_VARIANT,
PROPERTY_TYPE_STRING,
PROPERTY_TYPE_TIME,
PROPERTY_TYPE_INT,
@@ -739,9 +906,11 @@
it nice to work with properties and the listener.
*/
static void
-get_property_cb (DBusGProxy *proxy, GValue OUT_value, GError *error, gpointer userdata)
+get_property_cb (GObject * object, GAsyncResult * res, gpointer user_data)
{
- get_property_t * get_property_data = (get_property_t *)userdata;
+ get_property_t * get_property_data = (get_property_t *)user_data;
+ GError * error = NULL;
+ GVariant * retvalue = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
if (error != NULL) {
g_warning("Unable to get property data: %s", error->message);
@@ -749,24 +918,29 @@
return;
}
+ GVariant * value = g_variant_get_child_value(retvalue, 0);
+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_VARIANT)) {
+ value = g_variant_get_variant(value);
+ }
+
switch (get_property_data->type) {
- case PROPERTY_TYPE_VALUE: {
- /* Just pass the GValue along. */
- indicate_listener_get_property_value_cb cb =(indicate_listener_get_property_value_cb)get_property_data->cb;
- cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, &OUT_value, get_property_data->data);
+ case PROPERTY_TYPE_VARIANT: {
+ /* Just pass the GVariant along. */
+ indicate_listener_get_property_variant_cb cb =(indicate_listener_get_property_variant_cb)get_property_data->cb;
+ cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, value, get_property_data->data);
break;
}
case PROPERTY_TYPE_STRING: {
/* Just pass the string along. */
indicate_listener_get_property_cb cb = (indicate_listener_get_property_cb)get_property_data->cb;
- cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, g_value_get_string(&OUT_value), get_property_data->data);
+ cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, g_variant_get_string(value, NULL), get_property_data->data);
break;
}
case PROPERTY_TYPE_TIME: {
/* Convert it to a time val */
indicate_listener_get_property_time_cb cb = (indicate_listener_get_property_time_cb)get_property_data->cb;
GTimeVal time;
- if (g_time_val_from_iso8601(g_value_get_string(&OUT_value), &time)) {
+ if (g_time_val_from_iso8601(g_variant_get_string(value, NULL), &time)) {
cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, &time, get_property_data->data);
}
break;
@@ -774,18 +948,19 @@
case PROPERTY_TYPE_INT: {
/* Take the string and convert it to an integer */
indicate_listener_get_property_int_cb cb = (indicate_listener_get_property_int_cb)get_property_data->cb;
- cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, g_value_get_int(&OUT_value), get_property_data->data);
+ cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, g_variant_get_int32(value), get_property_data->data);
break;
}
case PROPERTY_TYPE_BOOL: {
/* Check to see if it's 'true', if not assume that
it's false */
indicate_listener_get_property_bool_cb cb = (indicate_listener_get_property_bool_cb)get_property_data->cb;
- cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, g_value_get_boolean(&OUT_value), get_property_data->data);
+ cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, g_variant_get_boolean(value), get_property_data->data);
break;
}
}
+ g_variant_unref(retvalue);
g_free(get_property_data->property);
g_free(get_property_data);
@@ -809,12 +984,21 @@
get_property_data->property = g_strdup(property);
get_property_data->type = prop_type;
- org_ayatana_indicate_get_indicator_property_async (server->proxy , INDICATE_LISTENER_INDICATOR_ID(indicator), property, get_property_cb, get_property_data);
+ g_dbus_proxy_call(server->proxy,
+ "GetIndicatorProperty",
+ g_variant_new("(us)",
+ INDICATE_LISTENER_INDICATOR_ID(indicator), property),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL, /* cancel */
+ get_property_cb,
+ get_property_data);
+
return;
}
/**
- indicate_listener_get_property_value:
+ indicate_listener_get_property_variant:
@listener: The #IndicateListener representing the connection
@server: The server that the indicator is on
@indicator: Which indicator is being queried
@@ -826,12 +1010,12 @@
and bring it back locally. This wraps all the hassle of using
the DBus API and makes it pretty easy to get properties.
- This function gets the raw gvalue data, without any conversion.
+ This function gets the raw GVariant data, without any conversion.
*/
void
-indicate_listener_get_property_value (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_value_cb callback, gpointer data)
+indicate_listener_get_property_variant (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_variant_cb callback, gpointer data)
{
- return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_VALUE);
+ return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_VARIANT);
}
/**
@@ -922,19 +1106,14 @@
return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_BOOL);
}
-
-gboolean
-_indicate_listener_server_get_indicator_servers (IndicateListener * listener, GList * servers)
-{
-
- return TRUE;
-}
-
/* A callback for asking an indicator to be displayed,
which is unlikely to fail. So we're throwing a warning. */
static void
-listener_display_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
+listener_display_cb (GObject * object, GAsyncResult * res, gpointer user_data)
{
+ GError * error = NULL;
+ g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
+
if (error != NULL) {
g_warning("Listener display caused an error: %s", error->message);
}
@@ -944,7 +1123,14 @@
void
indicate_listener_display (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, guint timestamp)
{
- org_ayatana_indicate_show_indicator_to_user_async (server->proxy, INDICATE_LISTENER_INDICATOR_ID(indicator), timestamp, listener_display_cb, NULL);
+ g_dbus_proxy_call(server->proxy,
+ "ShowIndicatorToUser",
+ g_variant_new("(uu)", INDICATE_LISTENER_INDICATOR_ID(indicator), timestamp),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL, /* cancel */
+ listener_display_cb,
+ NULL);
return;
}
@@ -952,8 +1138,11 @@
/* A callback for saying an indicator is displayed,
which is unlikely to fail. So we're throwing a warning. */
static void
-listener_displayed_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
+listener_displayed_cb (GObject * object, GAsyncResult * res, gpointer user_data)
{
+ GError * error = NULL;
+ g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
+
if (error != NULL) {
g_warning("Listener displayed caused an error: %s", error->message);
}
@@ -975,11 +1164,14 @@
void
indicate_listener_displayed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gboolean displayed)
{
- org_ayatana_indicate_indicator_displayed_async (server->proxy,
- INDICATE_LISTENER_INDICATOR_ID(indicator),
- displayed,
- listener_displayed_cb,
- NULL);
+ g_dbus_proxy_call(server->proxy,
+ "IndicatorDisplayed",
+ g_variant_new("(ub)", INDICATE_LISTENER_INDICATOR_ID(indicator), displayed),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL, /* cancel */
+ listener_displayed_cb,
+ NULL);
if (!server->interests[INDICATE_INTEREST_INDICATOR_DISPLAY] && displayed) {
g_warning("It's awful odd that you said in the interest survey you weren't displaying indicators and then you displayed one. I'm just saying, you've probably confused someone besides me.");
@@ -988,68 +1180,6 @@
return;
}
-typedef struct {
- IndicateListener * listener;
- IndicateListenerServer * server;
- indicate_listener_get_server_property_cb cb;
- indicate_listener_get_server_uint_property_cb cb_uint;
- gpointer data;
-} property_cb_t;
-
-/* A callback from getting the property off of the server
- which unravels the property_cb_t structure that was passed
- as data and calls back the call back that was in it with
- the appropriate data, also unrolled. */
-static void
-property_cb (DBusGProxy * proxy, GValue property, GError * error, gpointer data)
-{
- /* g_debug("Callback for property %s %s %s", dbus_g_proxy_get_bus_name(proxy), dbus_g_proxy_get_path(proxy), dbus_g_proxy_get_interface(proxy)); */
- property_cb_t * propertyt = data;
-
- if (error != NULL) {
- /* g_warning("Unable to get property: %s", error->message); */
- g_free(propertyt);
- return;
- }
-
- /* Dup all the values and make them local so that
- we can free up the data structure to make the
- rest of the code easier to read. */
- IndicateListener * listener = propertyt->listener;
- IndicateListenerServer * server = propertyt->server;
- indicate_listener_get_server_property_cb cb = propertyt->cb;
- indicate_listener_get_server_uint_property_cb cb_uint = propertyt->cb_uint;
- gpointer cb_data = propertyt->data;
-
- g_free(propertyt);
-
- if (G_VALUE_HOLDS_STRING(&property) && cb != NULL) {
- /* If it's got a string, and we have a value for that
- we'll get the string out and call the call back */
- gchar * propstr = g_value_dup_string(&property);
- return cb(listener, server, propstr, cb_data);
- } else if (G_VALUE_HOLDS_UINT(&property) && cb_uint != NULL) {
- /* If it's got a UINT and we have a callback for that
- let's grab the value and call the callback. */
- guint val = g_value_get_uint(&property);
- return cb_uint(listener, server, val, cb_data);
- } else if (G_VALUE_TYPE(&property) == DBUS_TYPE_G_OBJECT_PATH && cb != NULL) {
- const gchar * val = (const gchar *)g_value_get_boxed(&property);
- if (val != NULL && val[0] != '\0' && val[1] != '\0') {
- /* If the string is NULL or if there is just a
- root item we're going to look at that as an
- error and not call the callback */
- gchar * propstr = g_strdup(val);
- return cb(listener, server, propstr, cb_data);
- }
- } else {
- /* WTF!?!?!?! */
- g_warning("Property back from server that we didn't understand.");
- }
-
- return;
-}
-
/* This is a helper function for all the functions that
get properties from the server. They all need to have
a callback setup with an intermediary data structure
@@ -1058,41 +1188,27 @@
static void
get_server_property (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, indicate_listener_get_server_uint_property_cb callback_uint, const gchar * property_name, gpointer data)
{
- /* g_debug("Setting up callback for property %s on %s", property_name, INDICATE_LISTENER_SERVER_DBUS_NAME(server)); */
- IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
-
- proxy_t searchitem;
- searchitem.name = server->name;
- searchitem.connection = server->connection;
-
- GList * proxyitem = g_list_find_custom(priv->proxies, &searchitem, proxy_t_equal);
- if (proxyitem == NULL) {
- g_warning("Can not find a proxy for the server at all.");
+ GVariant * prop = g_dbus_proxy_get_cached_property(server->proxy, property_name);
+
+ if (prop == NULL) {
+ if (callback == NULL) {
+ callback_uint(listener, server, 0, data);
+ } else {
+ callback(listener, server, NULL, data);
+ }
return;
}
- proxy_t * proxyt = (proxy_t *)proxyitem->data;
-
- if (proxyt->property_proxy == NULL) {
- proxyt->property_proxy = dbus_g_proxy_new_for_name(proxyt->connection,
- proxyt->name,
- proxyt->path,
- DBUS_INTERFACE_PROPERTIES);
+ if (g_variant_is_of_type(prop, G_VARIANT_TYPE_STRING) && callback != NULL) {
+ callback(listener, server, g_variant_get_string(prop, NULL), data);
+ } else if (g_variant_is_of_type(prop, G_VARIANT_TYPE_OBJECT_PATH) && callback != NULL) {
+ callback(listener, server, g_variant_get_string(prop, NULL), data);
+ } else if (g_variant_is_of_type(prop, G_VARIANT_TYPE_UINT32) && callback_uint != NULL) {
+ callback_uint(listener, server, g_variant_get_uint32(prop), data);
+ } else {
+ g_warning("Really? This can't happen. WTF! %s", g_variant_get_type_string(prop));
}
- property_cb_t * localdata = g_new0(property_cb_t, 1);
- localdata->listener = listener;
- localdata->server = server;
- localdata->cb = callback;
- localdata->cb_uint = callback_uint;
- localdata->data = data;
-
- org_freedesktop_DBus_Properties_get_async(proxyt->property_proxy,
- INDICATE_DBUS_IFACE,
- property_name,
- property_cb,
- localdata);
-
return;
}
@@ -1154,10 +1270,14 @@
}
static void
-interest_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
+interest_cb (GObject * object, GAsyncResult * res, gpointer user_data)
{
+ GError * error = NULL;
+ g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
+
if (error != NULL) {
g_warning("Unable to configure interest.");
+ g_error_free(error);
}
return;
@@ -1171,7 +1291,14 @@
}
if (!server->interests[interest]) {
- org_ayatana_indicate_show_interest_async (server->proxy, interest_to_string(interest), interest_cb, server);
+ g_dbus_proxy_call(server->proxy,
+ "ShowInterest",
+ g_variant_new("(s)", interest_to_string(interest)),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL, /* cancel */
+ interest_cb,
+ server);
server->interests[interest] = TRUE;
}
return;
@@ -1181,7 +1308,14 @@
indicate_listener_server_remove_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest)
{
if (server->interests[interest]) {
- org_ayatana_indicate_remove_interest_async (server->proxy, interest_to_string(interest), interest_cb, server);
+ g_dbus_proxy_call(server->proxy,
+ "RemoveInterest",
+ g_variant_new("(s)", interest_to_string(interest)),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL, /* cancel */
+ interest_cb,
+ server);
server->interests[interest] = FALSE;
}
return;
@@ -1256,7 +1390,14 @@
if (server->max_indicators != max) {
server->max_indicators = max;
- org_ayatana_indicate_set_max_indicators_async(server->proxy, server->max_indicators, set_max_indicators_cb, server->name);
+ g_dbus_proxy_call(server->proxy,
+ "SetMaxIndicators",
+ g_variant_new("(u)", server->max_indicators),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL,
+ set_max_indicators_cb,
+ server->name);
}
return;
=== modified file 'libindicate/listener.h'
--- libindicate/listener.h 2010-09-27 15:18:45 +0000
+++ libindicate/listener.h 2011-01-13 22:41:52 +0000
@@ -111,22 +111,22 @@
GType indicate_listener_get_type (void) G_GNUC_CONST;
-typedef void (*indicate_listener_get_property_value_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, const GValue * propertydata, gpointer data);
+typedef void (*indicate_listener_get_property_variant_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GVariant * propertydata, gpointer data);
typedef void (*indicate_listener_get_property_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, const gchar * propertydata, gpointer data);
typedef void (*indicate_listener_get_property_time_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, const GTimeVal * propertydata, gpointer data);
typedef void (*indicate_listener_get_property_int_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gint propertydata, gpointer data);
typedef void (*indicate_listener_get_property_bool_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gboolean propertydata, gpointer data);
-typedef void (*indicate_listener_get_server_property_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data);
+typedef void (*indicate_listener_get_server_property_cb) (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data);
typedef void (*indicate_listener_get_server_uint_property_cb) (IndicateListener * listener, IndicateListenerServer * server, guint value, gpointer data);
/* Create a new listener */
IndicateListener * indicate_listener_new (void);
IndicateListener * indicate_listener_ref_default (void);
-void indicate_listener_get_property_value (IndicateListener * listener,
+void indicate_listener_get_property_variant (IndicateListener * listener,
IndicateListenerServer * server,
IndicateListenerIndicator * indicator,
gchar * property,
- void (*callback) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, const GValue * propertydata, gpointer data),
+ void (*callback) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GVariant * propertydata, gpointer data),
gpointer data);
void indicate_listener_get_property (IndicateListener * listener,
IndicateListenerServer * server,
@@ -162,11 +162,11 @@
gboolean displayed);
void indicate_listener_server_get_type (IndicateListener * listener,
IndicateListenerServer * server,
- void (*callback) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data),
+ void (*callback) (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data),
gpointer data);
void indicate_listener_server_get_desktop (IndicateListener * listener,
IndicateListenerServer * server,
- void (*callback) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data),
+ void (*callback) (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data),
gpointer data);
void indicate_listener_server_get_count (IndicateListener * listener,
IndicateListenerServer * server,
@@ -174,7 +174,7 @@
gpointer data);
void indicate_listener_server_get_menu (IndicateListener * listener,
IndicateListenerServer * server,
- void (*callback) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data),
+ void (*callback) (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data),
gpointer data);
const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server);
guint indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator);
=== modified file 'libindicate/server.c'
--- libindicate/server.c 2010-09-16 15:45:20 +0000
+++ libindicate/server.c 2011-01-13 22:41:52 +0000
@@ -30,10 +30,10 @@
#include "server.h"
#include "interests-priv.h"
#include "indicate-marshal.h"
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
#include <libdbusmenu-glib/server.h>
#include "dbus-shared.h"
+#include "gen-indicate-interface.xml.h"
/* Errors */
enum {
@@ -53,6 +53,7 @@
NO_MAX_INDICATORS_SET,
MAX_INDICATORS_SET_FAILED,
NO_SUCH_PROPERTY,
+ NOT_IMPLEMENTED,
LAST_ERROR
};
@@ -87,14 +88,15 @@
typedef struct _IndicateServerPrivate IndicateServerPrivate;
struct _IndicateServerPrivate
{
- DBusGConnection *connection;
- DBusGProxy * dbus_proxy;
+ GCancellable * connection_cancel;
+ GDBusConnection *connection;
+ guint broadcast_signal;
gchar * path;
GSList * indicators;
gboolean visible;
guint current_id;
- gboolean registered;
+ guint registered;
gchar * desktop;
gchar * type;
@@ -123,6 +125,7 @@
gboolean interests[INDICATE_INTEREST_LAST];
gint max_indicators;
GHashTable * indicators_displayed;
+ GDBusProxy * proxy;
};
static const gint MAX_INDICATORS_INFINITE = -1;
@@ -132,34 +135,33 @@
G_DEFINE_TYPE (IndicateServer, indicate_server, G_TYPE_OBJECT);
/* Prototypes */
-static DBusHandlerResult dbus_filter_new_listener (DBusConnection * connection, DBusMessage * message, void * user_data);
static void indicate_server_dispose (GObject * obj);
static void indicate_server_finalize (GObject * obj);
static gboolean get_indicator_count (IndicateServer * server, guint * count, GError **error);
static gboolean get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error);
static IndicateIndicator * get_indicator (IndicateServer * server, guint id, GError **error);
-static gboolean get_indicator_property (IndicateServer * server, guint id, gchar * property, GValue * value, GError **error);
-static gboolean get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);
+static gboolean get_indicator_property (IndicateServer * server, guint id, gchar * property, GVariant ** value, GError **error);
+static gboolean get_indicator_property_group (IndicateServer * server, guint id, const gchar ** properties, GVariant ** output, GError **error);
static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error);
static gboolean show_indicator_to_user (IndicateServer * server, guint id, guint timestamp, GError ** error);
-static gboolean indicator_displayed (IndicateServer * server, gchar * sender, guint id, gboolean displayed, GError ** error);
-static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server);
+static gboolean indicator_displayed (IndicateServer * server, const gchar * sender, guint id, gboolean displayed, GError ** error);
static void indicator_display_check_recalc (gpointer key, gpointer value, gpointer userdata);
static void recalculate_indicator_displayed (IndicateServer * server, guint id);
static guint get_next_id (IndicateServer * server);
static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec);
static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec);
-static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest);
-static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest);
+static gboolean show_interest (IndicateServer * server, const gchar * sender, IndicateInterests interest);
+static gboolean remove_interest (IndicateServer * server, const gchar * sender, IndicateInterests interest);
static gboolean check_interest (IndicateServer * server, IndicateInterests intrest);
static gint max_indicators_get (IndicateServer * server);
-static gboolean max_indicators_set (IndicateServer * server, gchar * sender, gint max);
+static gboolean max_indicators_set (IndicateServer * server, const gchar * sender, gint max);
static void recalculate_max_indicators (IndicateServer * server);
static gint indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b);
-static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender);
+static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, const gchar * sender, const gchar * path, GDBusConnection * connection);
static void indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value);
static void indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests);
static void indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk);
+<<<<<<< TREE
static gboolean interest_timer (gpointer user_data);
/* DBus API */
@@ -177,6 +179,58 @@
/* Has to be after the dbus prototypes */
#include "indicate-interface-server.h"
+=======
+static void bus_connection_cb (GObject * obj, GAsyncResult * res, gpointer user_data);
+static void bus_broadcast_cb (GDBusConnection * connection, const gchar * sender, const gchar * object_path, const gchar * interface_name, const gchar * signal_name, GVariant * parameters, gpointer user_data);
+static void folk_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);
+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 GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data);
+static void bus_get_indicator_count (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
+static void bus_get_indicator_list (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
+static void bus_get_indicator_property (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
+static void bus_get_indicator_property_group (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
+static void bus_get_indicator_properties (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
+static void bus_show_indicator_to_user (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
+static void bus_indicator_displayed (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
+static void bus_show_interest (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
+static void bus_remove_interest (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
+static void bus_set_max_indicators (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
+static GQuark indicate_server_error_quark (void);
+
+/* Method Table */
+typedef void (*MethodTableFunc) (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
+
+typedef struct _method_table_t method_table_t;
+struct _method_table_t {
+ const gchar * interned_name;
+ MethodTableFunc func;
+};
+
+enum {
+ METHOD_GET_INDICATOR_COUNT = 0,
+ METHOD_GET_INDICATOR_LIST,
+ METHOD_GET_INDICATOR_PROPERTY,
+ METHOD_GET_INDICATOR_PROPERTY_GROUP,
+ METHOD_GET_INDICATOR_PROPERTIES,
+ METHOD_SHOW_INDICATOR_TO_USER,
+ METHOD_INDICATOR_DISPLAYED,
+ METHOD_SHOW_INTEREST,
+ METHOD_REMOVE_INTEREST,
+ METHOD_SET_MAX_INDICATORS,
+ /* Counter, do not remove! */
+ METHOD_COUNT
+};
+
+/* Bus Stuff */
+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: bus_get_prop,
+ set_property: NULL /* No properties that can be set */
+};
+static method_table_t bus_method_table[METHOD_COUNT];
+>>>>>>> MERGE-SOURCE
/* Code */
@@ -368,14 +422,11 @@
0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobj, PROP_MENU,
- g_param_spec_boxed("menu", "DBus Menu Object Path",
+ g_param_spec_string("menu", "DBus Menu Object Path",
"The DBus Object path to an object with a dbusmenu interface on it.",
- DBUS_TYPE_G_OBJECT_PATH,
+ "",
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- dbus_g_object_type_install_info(INDICATE_TYPE_SERVER,
- &dbus_glib__indicate_interface_server_object_info);
-
class->get_indicator_count = get_indicator_count;
class->get_indicator_list = get_indicator_list;
class->get_indicator_property = get_indicator_property;
@@ -390,6 +441,57 @@
class->max_indicators_get = max_indicators_get;
class->max_indicators_set = max_indicators_set;
+ /* DBus interfaces */
+ if (bus_node_info == NULL) {
+ GError * error = NULL;
+
+ bus_node_info = g_dbus_node_info_new_for_xml(_indicate_interface, &error);
+ if (error != NULL) {
+ g_error("Unable to parse Indicate 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, INDICATE_DBUS_IFACE);
+
+ if (bus_interface_info == NULL) {
+ g_error("Unable to find interface '" INDICATE_DBUS_IFACE "'");
+ }
+ }
+
+ /* Building our Method table :( */
+ bus_method_table[METHOD_GET_INDICATOR_COUNT].interned_name = g_intern_static_string("GetIndicatorCount");
+ bus_method_table[METHOD_GET_INDICATOR_COUNT].func = bus_get_indicator_count;
+
+ bus_method_table[METHOD_GET_INDICATOR_LIST].interned_name = g_intern_static_string("GetIndicatorList");
+ bus_method_table[METHOD_GET_INDICATOR_LIST].func = bus_get_indicator_list;
+
+ bus_method_table[METHOD_GET_INDICATOR_PROPERTY].interned_name = g_intern_static_string("GetIndicatorProperty");
+ bus_method_table[METHOD_GET_INDICATOR_PROPERTY].func = bus_get_indicator_property;
+
+ bus_method_table[METHOD_GET_INDICATOR_PROPERTY_GROUP].interned_name = g_intern_static_string("GetIndicatorPropertyGroup");
+ bus_method_table[METHOD_GET_INDICATOR_PROPERTY_GROUP].func = bus_get_indicator_property_group;
+
+ bus_method_table[METHOD_GET_INDICATOR_PROPERTIES].interned_name = g_intern_static_string("GetIndicatorProperties");
+ bus_method_table[METHOD_GET_INDICATOR_PROPERTIES].func = bus_get_indicator_properties;
+
+ bus_method_table[METHOD_SHOW_INDICATOR_TO_USER].interned_name = g_intern_static_string("ShowIndicatorToUser");
+ bus_method_table[METHOD_SHOW_INDICATOR_TO_USER].func = bus_show_indicator_to_user;
+
+ bus_method_table[METHOD_INDICATOR_DISPLAYED].interned_name = g_intern_static_string("IndicatorDisplayed");
+ bus_method_table[METHOD_INDICATOR_DISPLAYED].func = bus_indicator_displayed;
+
+ bus_method_table[METHOD_SHOW_INTEREST].interned_name = g_intern_static_string("ShowInterest");
+ bus_method_table[METHOD_SHOW_INTEREST].func = bus_show_interest;
+
+ bus_method_table[METHOD_REMOVE_INTEREST].interned_name = g_intern_static_string("RemoveInterest");
+ bus_method_table[METHOD_REMOVE_INTEREST].func = bus_remove_interest;
+
+ bus_method_table[METHOD_SET_MAX_INDICATORS].interned_name = g_intern_static_string("SetMaxIndicators");
+ bus_method_table[METHOD_SET_MAX_INDICATORS].func = bus_set_max_indicators;
+
+
return;
}
@@ -404,7 +506,7 @@
priv->indicators = NULL;
priv->num_hidden = 0;
priv->visible = FALSE;
- priv->registered = FALSE;
+ priv->registered = 0;
priv->current_id = 0;
priv->type = NULL;
priv->desktop = NULL;
@@ -418,10 +520,13 @@
priv->interestedfolks = NULL;
priv->max_indicators = MAX_INDICATORS_UNSET;
- priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
-
- dbus_connection_add_filter(dbus_g_connection_get_connection(priv->connection), dbus_filter_new_listener, server, NULL);
- dbus_bus_add_match(dbus_g_connection_get_connection(priv->connection), "type='signal',interface='" INDICATE_LISTENER_DBUS_IFACE "',member='IndicatorServersReport'", NULL);
+ priv->broadcast_signal = 0;
+ priv->connection = NULL;
+ priv->connection_cancel = g_cancellable_new();
+ g_bus_get(G_BUS_TYPE_SESSION,
+ priv->connection_cancel, /* cancel */
+ bus_connection_cb,
+ server);
priv->interest_timer = g_timeout_add(500, interest_timer, server);
@@ -434,18 +539,42 @@
IndicateServer * server = INDICATE_SERVER(obj);
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
+ if (priv->broadcast_signal != 0) {
+ g_dbus_connection_signal_unsubscribe(priv->connection, priv->broadcast_signal);
+ priv->broadcast_signal = 0;
+ }
+
+ if (priv->connection_cancel != NULL) {
+ g_cancellable_cancel(priv->connection_cancel);
+ g_object_unref(priv->connection_cancel);
+ priv->connection_cancel = NULL;
+ }
+
if (priv->dbusmenu != NULL) {
g_object_unref(priv->dbusmenu);
priv->dbusmenu = NULL;
}
if (priv->visible) {
+ if (priv->registered != 0) {
+ g_dbus_connection_emit_signal(priv->connection,
+ NULL, /* dest */
+ priv->path,
+ INDICATE_DBUS_IFACE,
+ "ServerHide",
+ g_variant_new("(s)", priv->type ? priv-> type : ""),
+ NULL); /* error */
+ }
g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE);
}
- if (priv->dbus_proxy != NULL) {
- g_object_unref(priv->dbus_proxy);
- priv->dbus_proxy = NULL;
+ if (priv->registered != 0) {
+ g_dbus_connection_unregister_object(priv->connection, priv->registered);
+ }
+
+ if (priv->connection != NULL) {
+ g_object_unref(priv->connection);
+ priv->connection = NULL;
}
if (priv->interest_timer != 0) {
@@ -472,8 +601,6 @@
g_free(priv->type);
}
- dbus_connection_remove_filter(dbus_g_connection_get_connection(priv->connection), dbus_filter_new_listener, server);
-
G_OBJECT_CLASS (indicate_server_parent_class)->finalize (obj);
return;
@@ -502,6 +629,15 @@
guint newval = g_value_get_uint(value);
if (newval != priv->count) {
priv->count = newval;
+ if (priv->registered != 0) {
+ g_dbus_connection_emit_signal(priv->connection,
+ NULL, /* dest */
+ priv->path,
+ INDICATE_DBUS_IFACE,
+ "ServerCountChanged",
+ g_variant_new("(u)", newval),
+ NULL); /* error */
+ }
g_signal_emit(obj, signals[SERVER_COUNT_CHANGED], 0, newval, TRUE);
}
break;
@@ -561,25 +697,155 @@
return;
}
+/************************
+ DBUS STUFF
+ ************************/
+
+/* Response to trying to get on the session bus */
+static void
+bus_connection_cb (GObject * obj, GAsyncResult * res, gpointer user_data)
+{
+ GError * error = NULL;
+
+ GDBusConnection * connection = g_bus_get_finish(res, &error);
+ if (error != NULL) {
+ g_error("Unable to get session bus: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ IndicateServer * server = INDICATE_SERVER(user_data);
+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
+
+ if (priv->connection_cancel != NULL) {
+ g_object_unref(priv->connection_cancel);
+ priv->connection_cancel = NULL;
+ }
+
+ if (priv->connection != NULL) {
+ g_warning("Getting a second connection?");
+ g_object_unref(priv->connection);
+ priv->connection = NULL;
+ }
+ priv->connection = connection;
+
+ priv->broadcast_signal = g_dbus_connection_signal_subscribe(priv->connection,
+ NULL, /* sender */
+ INDICATE_LISTENER_DBUS_IFACE,
+ "IndicatorServersReport",
+ NULL, /* object */
+ NULL, /* arg0 */
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ bus_broadcast_cb,
+ server,
+ NULL); /* destroy notify */
+
+ if (priv->visible) {
+ priv->visible = FALSE;
+ indicate_server_show(server);
+ }
+
+ return;
+}
+
/* A small dbus filter that waits on the IndicatorServersReport
signal and sends the Show signal if this server is not hidden. */
-static DBusHandlerResult
-dbus_filter_new_listener (DBusConnection * connection, DBusMessage * message, void * user_data)
+static void
+bus_broadcast_cb (GDBusConnection * connection, const gchar * sender, const gchar * object_path, const gchar * interface_name, const gchar * signal_name, GVariant * parameters, gpointer user_data)
{
- if (!dbus_message_is_signal(message, INDICATE_LISTENER_DBUS_IFACE, "IndicatorServersReport")) {
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
+ g_return_if_fail(g_strcmp0(signal_name, "IndicatorServersReport") == 0);
IndicateServer * server = INDICATE_SERVER(user_data);
if (server != NULL) {
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
if (priv->visible) {
+ if (priv->registered != 0) {
+ g_dbus_connection_emit_signal(priv->connection,
+ NULL, /* dest */
+ priv->path,
+ INDICATE_DBUS_IFACE,
+ "ServerShow",
+ g_variant_new("(s)", priv->type ? priv-> type : ""),
+ NULL); /* error */
+ }
g_signal_emit(server, signals[SERVER_SHOW], 0, priv->type ? priv->type : "", TRUE);
}
}
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ return;
+}
+
+/* A method call has come from DBus */
+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)
+{
+ int i;
+ const gchar * interned_method = g_intern_string(method);
+
+ for (i = 0; i < METHOD_COUNT; i++) {
+ if (bus_method_table[i].interned_name == interned_method) {
+ if (bus_method_table[i].func != NULL) {
+ return bus_method_table[i].func(INDICATE_SERVER(user_data), params, invocation);
+ } else {
+ /* If we have a null function we're responding but nothing else. */
+ g_warning("Invalid function call for '%s' with parameters: %s", method, g_variant_print(params, TRUE));
+ g_dbus_method_invocation_return_value(invocation, NULL);
+ return;
+ }
+ }
+ }
+
+ /* We're here because there's an error */
+ g_dbus_method_invocation_return_error(invocation,
+ indicate_server_error_quark(),
+ NOT_IMPLEMENTED,
+ "Unable to find method '%s'",
+ method);
+ return;
+}
+
+/* Dbus have asked for properties, let's talk to it. */
+static GVariant *
+bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data)
+{
+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(user_data);
+ GVariant * retvariant = NULL;
+
+ if (g_strcmp0(property, "desktop") == 0) {
+ if (priv->desktop != NULL) {
+ retvariant = g_variant_new_string(priv->desktop);
+ } else {
+ retvariant = g_variant_new_string("");
+ }
+ } else if (g_strcmp0(property, "type") == 0) {
+ if (priv->type != NULL) {
+ retvariant = g_variant_new_string(priv->type);
+ } else {
+ retvariant = g_variant_new_string("");
+ }
+ } else if (g_strcmp0(property, "count") == 0) {
+ retvariant = g_variant_new_uint32(priv->count);
+ } else if (g_strcmp0(property, "menu") == 0) {
+ if (priv->dbusmenu != NULL) {
+ GValue strvalue = {0};
+ g_value_init(&strvalue, G_TYPE_STRING);
+ g_object_get_property(G_OBJECT(priv->dbusmenu), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strvalue);
+ if (g_value_get_string(&strvalue) != NULL) {
+ retvariant = g_variant_new_string(g_value_get_string(&strvalue));
+ } else {
+ retvariant = g_variant_new_string("/");
+ }
+ g_value_unset(&strvalue);
+ } else {
+ retvariant = g_variant_new_string("/");
+ }
+
+ } else {
+ g_warning("Unknown property");
+ }
+
+ return retvariant;
}
/* Small little function to get an error quark for usage
@@ -590,6 +856,25 @@
static GQuark quark = 0;
if (quark == 0) {
quark = g_quark_from_static_string (G_LOG_DOMAIN);
+
+ /* Register our dbus error codes as well */
+ g_dbus_error_register_error(quark, NO_GET_DESKTOP, "NO_GET_DESKTOP");
+ g_dbus_error_register_error(quark, NO_GET_INDICATOR_COUNT, "NO_GET_INDICATOR_COUNT");
+ g_dbus_error_register_error(quark, NO_GET_INDICATOR_LIST, "NO_GET_INDICATOR_LIST");
+ g_dbus_error_register_error(quark, NO_GET_INDICATOR_PROPERTY, "NO_GET_INDICATOR_PROPERTY");
+ g_dbus_error_register_error(quark, NO_GET_INDICATOR_PROPERTY_GROUP, "NO_GET_INDICATOR_PROPERTY_GROUP");
+ g_dbus_error_register_error(quark, NO_GET_INDICATOR_PROPERTIES, "NO_GET_INDICATOR_PROPERTIES");
+ g_dbus_error_register_error(quark, NO_SHOW_INDICATOR_TO_USER, "NO_SHOW_INDICATOR_TO_USER");
+ g_dbus_error_register_error(quark, NO_INDICATOR_DISPLAYED, "NO_INDICATOR_DISPLAYED");
+ g_dbus_error_register_error(quark, INVALID_INDICATOR_ID, "INVALID_INDICATOR_ID");
+ g_dbus_error_register_error(quark, NO_SHOW_INTEREST, "NO_SHOW_INTEREST");
+ g_dbus_error_register_error(quark, NO_REMOVE_INTEREST, "NO_REMOVE_INTEREST");
+ g_dbus_error_register_error(quark, SHOW_INTEREST_FAILED, "SHOW_INTEREST_FAILED");
+ g_dbus_error_register_error(quark, REMOVE_INTEREST_FAILED, "REMOVE_INTEREST_FAILED");
+ g_dbus_error_register_error(quark, NO_MAX_INDICATORS_SET, "NO_MAX_INDICATORS_SET");
+ g_dbus_error_register_error(quark, MAX_INDICATORS_SET_FAILED, "MAX_INDICATORS_SET_FAILED");
+ g_dbus_error_register_error(quark, NO_SUCH_PROPERTY, "NO_SUCH_PROPERTY");
+ g_dbus_error_register_error(quark, NOT_IMPLEMENTED, "NOT_IMPLEMENTED");
}
return quark;
}
@@ -611,33 +896,45 @@
g_return_if_fail(INDICATE_IS_SERVER(server));
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
- if (priv->visible)
+ if (priv->visible) {
return;
-
- priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
-
- if (!priv->registered) {
- dbus_g_connection_register_g_object(priv->connection,
- priv->path,
- G_OBJECT(server));
- priv->registered = TRUE;
}
priv->visible = TRUE;
+ if (priv->connection == NULL) {
+ return;
+ }
+
+ if (priv->registered == 0) {
+ GError * error = NULL;
+ priv->registered = g_dbus_connection_register_object(priv->connection,
+ priv->path,
+ bus_interface_info,
+ &bus_interface_table,
+ server,
+ NULL,
+ &error);
+
+ if (error != NULL) {
+ g_warning("Unable to export object '%s' with interface '" INDICATE_DBUS_IFACE "' on dbus: %s", priv->path, error->message);
+ g_error_free(error);
+ priv->registered = 0; /* Just to be sure */
+ return;
+ }
+ }
+
+ if (priv->registered != 0) {
+ g_dbus_connection_emit_signal(priv->connection,
+ NULL, /* dest */
+ priv->path,
+ INDICATE_DBUS_IFACE,
+ "ServerShow",
+ g_variant_new("(s)", priv->type ? priv-> type : ""),
+ NULL); /* error */
+ }
g_signal_emit(server, signals[SERVER_SHOW], 0, priv->type ? priv->type : "", TRUE);
- priv->dbus_proxy = dbus_g_proxy_new_for_name_owner (priv->connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- NULL);
- 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_owner_change), server, NULL);
-
return;
}
@@ -680,77 +977,17 @@
priv->max_indicators = MAX_INDICATORS_UNSET;
g_signal_emit(G_OBJECT(server), signals[MAX_INDICATORS_CHANGED], 0, MAX_INDICATORS_INFINITE, TRUE);
+ if (priv->registered != 0) {
+ g_dbus_connection_emit_signal(priv->connection,
+ NULL, /* dest */
+ priv->path,
+ INDICATE_DBUS_IFACE,
+ "ServerHide",
+ g_variant_new("(s)", priv->type ? priv-> type : ""),
+ NULL); /* error */
+ }
g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE);
- if (priv->dbus_proxy != NULL) {
- g_object_unref(G_OBJECT(priv->dbus_proxy));
- priv->dbus_proxy = NULL;
- }
-
- return;
-}
-
-/* Watches the DBus owner change signals to see if any
- of our folk disappear. If one of our folks goes away
- then it deals with the repercussions of deleting that
- entry in terms of interest, max indicators and which
- indicators are being displayed. */
-static void
-dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server)
-{
- /* g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); */
- if (prev == NULL || prev[0] == '\0') {
- /* We only care about people leaving the bus */
- return;
- }
-
- /* g_debug("\tBeing removed, interesting"); */
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
-
- IndicateServerInterestedFolk searchitem;
- searchitem.sender = (gchar *)name;
- GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal);
-
- if (entry == NULL) {
- /* g_debug("\tWe don't have it, not interesting"); */
- return;
- }
-
- IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)entry->data;
- priv->interestedfolks = g_list_remove(priv->interestedfolks, entry->data);
-
- guint i;
- for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
- priv->interests[i] = FALSE;
- }
-
- GList * listi = NULL;
- for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) {
- IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data;
- /* g_debug("\tRebuild list from folk: %s", folkpointer->sender); */
- indicate_server_interested_folks_copy(folkpointer, priv->interests);
- }
-
- for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
- /* g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); */
- if (folk->interests[i] && !priv->interests[i]) {
- /* We can only remove interest here. Think about it for a
- moment and I think you'll be cool with it. */
- /* g_debug("\tOh, and it was interested in %d. Not anymore.", i); */
- g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE);
- }
- }
-
- /* If the retired folk has set it's max indicators
- and it's the value we're using, we need to recalculate */
- if (folk->max_indicators != MAX_INDICATORS_UNSET && folk->max_indicators == priv->max_indicators) {
- recalculate_max_indicators(server);
- }
-
- g_hash_table_foreach(folk->indicators_displayed, indicator_display_check_recalc, server);
-
- /* Finally destory everything */
- indicate_server_interested_folks_destroy(folk);
return;
}
@@ -811,7 +1048,7 @@
mark their folk listing. If it changes the overall setting
then we need to signal. */
static gboolean
-show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest)
+show_interest (IndicateServer * server, const gchar * sender, IndicateInterests interest)
{
if (!(interest > INDICATE_INTEREST_NONE && interest < INDICATE_INTEREST_LAST)) {
return FALSE;
@@ -819,7 +1056,7 @@
/* g_debug("Someone is showing interest. %s in %d", sender, interest); */
IndicateServerInterestedFolk localfolk;
- localfolk.sender = sender;
+ localfolk.sender = (gchar *)sender; /* Okay to drop the const as we're only using this for searching */
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
@@ -832,7 +1069,7 @@
IndicateServerInterestedFolk * folkpointer = NULL;
if (entry == NULL) {
folkpointer = g_new0(IndicateServerInterestedFolk, 1);
- indicate_server_interested_folks_init(folkpointer, sender);
+ indicate_server_interested_folks_init(folkpointer, sender, INDICATE_LISTENER_OBJ_PATH, priv->connection);
priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
} else {
folkpointer = (IndicateServerInterestedFolk *)entry->data;
@@ -851,14 +1088,14 @@
folk structure and then checks to see if that has global
effect, and handles it. */
static gboolean
-remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest)
+remove_interest (IndicateServer * server, const gchar * sender, IndicateInterests interest)
{
if (!(interest > INDICATE_INTEREST_NONE && interest < INDICATE_INTEREST_LAST)) {
return FALSE;
}
IndicateServerInterestedFolk localfolk;
- localfolk.sender = sender;
+ localfolk.sender = (gchar *)sender; /* Okay to drop the const as we're only using this for searching */
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
@@ -874,7 +1111,7 @@
IndicateServerInterestedFolk * folkpointer = NULL;
if (entry == NULL) {
folkpointer = g_new0(IndicateServerInterestedFolk, 1);
- indicate_server_interested_folks_init(folkpointer, sender);
+ indicate_server_interested_folks_init(folkpointer, sender, INDICATE_LISTENER_OBJ_PATH, priv->connection);
priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
} else {
folkpointer = (IndicateServerInterestedFolk *)entry->data;
@@ -944,12 +1181,12 @@
/* Internal function to set the number of max indicators
from a particular listener. */
static gboolean
-max_indicators_set (IndicateServer * server, gchar * sender, gint max)
+max_indicators_set (IndicateServer * server, const gchar * sender, gint max)
{
g_return_val_if_fail(max >= MAX_INDICATORS_INFINITE, FALSE);
IndicateServerInterestedFolk localfolk;
- localfolk.sender = sender;
+ localfolk.sender = (gchar *)sender; /* Okay to drop the const as we're only using this for searching */
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
@@ -960,7 +1197,7 @@
IndicateServerInterestedFolk * folkpointer = NULL;
if (entry == NULL) {
folkpointer = g_new0(IndicateServerInterestedFolk, 1);
- indicate_server_interested_folks_init(folkpointer, sender);
+ indicate_server_interested_folks_init(folkpointer, sender, INDICATE_LISTENER_OBJ_PATH, priv->connection);
priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
} else {
folkpointer = (IndicateServerInterestedFolk *)entry->data;
@@ -1030,6 +1267,15 @@
{
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
priv->num_hidden--;
+ if (priv->registered != 0) {
+ g_dbus_connection_emit_signal(priv->connection,
+ NULL, /* dest */
+ priv->path,
+ INDICATE_DBUS_IFACE,
+ "IndicatorNew",
+ g_variant_new("(u)", indicate_indicator_get_id(indicator)),
+ NULL); /* error */
+ }
g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), TRUE);
return;
}
@@ -1039,6 +1285,15 @@
{
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
priv->num_hidden++;
+ if (priv->registered != 0) {
+ g_dbus_connection_emit_signal(priv->connection,
+ NULL, /* dest */
+ priv->path,
+ INDICATE_DBUS_IFACE,
+ "IndicatorDelete",
+ g_variant_new("(u)", indicate_indicator_get_id(indicator)),
+ NULL); /* error */
+ }
g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), TRUE);
return;
}
@@ -1047,6 +1302,16 @@
indicator_modified_cb (IndicateIndicator * indicator, gchar * property, IndicateServer * server)
{
/* g_debug("Indicator Modified: %d %s", indicate_indicator_get_id(indicator), property); */
+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
+ if (priv->registered != 0) {
+ g_dbus_connection_emit_signal(priv->connection,
+ NULL, /* dest */
+ priv->path,
+ INDICATE_DBUS_IFACE,
+ "IndicatorModified",
+ g_variant_new("(us)", indicate_indicator_get_id(indicator), property),
+ NULL); /* error */
+ }
g_signal_emit(server, signals[INDICATOR_MODIFIED], 0, indicate_indicator_get_id(indicator), property, TRUE);
}
@@ -1073,6 +1338,15 @@
if (!indicate_indicator_is_visible(indicator)) {
priv->num_hidden++;
} else {
+ if (priv->registered != 0) {
+ g_dbus_connection_emit_signal(priv->connection,
+ NULL, /* dest */
+ priv->path,
+ INDICATE_DBUS_IFACE,
+ "IndicatorNew",
+ g_variant_new("(u)", indicate_indicator_get_id(indicator)),
+ NULL); /* error */
+ }
g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), TRUE);
}
@@ -1101,6 +1375,15 @@
priv->indicators = g_slist_remove(priv->indicators, indicator);
if (indicate_indicator_is_visible(indicator)) {
+ if (priv->registered != 0) {
+ g_dbus_connection_emit_signal(priv->connection,
+ NULL, /* dest */
+ priv->path,
+ INDICATE_DBUS_IFACE,
+ "IndicatorDelete",
+ g_variant_new("(u)", indicate_indicator_get_id(indicator)),
+ NULL); /* error */
+ }
g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), TRUE);
} else {
priv->num_hidden--;
@@ -1299,14 +1582,14 @@
}
static gboolean
-get_indicator_property (IndicateServer * server, guint id, gchar * property, GValue * value, GError **error)
+get_indicator_property (IndicateServer * server, guint id, gchar * property, GVariant ** variant, GError **error)
{
IndicateIndicator * indicator = get_indicator(server, id, error);
if (indicator == NULL) {
return FALSE;
}
- const GValue * ind_property = indicate_indicator_get_property_value(indicator, property);
+ GVariant * ind_property = indicate_indicator_get_property_variant(indicator, property);
if (ind_property == NULL) {
if (error != NULL) {
g_set_error(error,
@@ -1318,36 +1601,33 @@
return FALSE;
}
- g_value_init(value, G_VALUE_TYPE(ind_property));
- g_value_copy(ind_property, value);
+ *variant = ind_property;
return TRUE;
}
static gboolean
-get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error)
+get_indicator_property_group (IndicateServer * server, guint id, const gchar ** properties, GVariant ** output, GError **error)
{
IndicateIndicator * indicator = get_indicator(server, id, error);
if (indicator == NULL) {
return FALSE;
}
- GPtrArray * array = g_ptr_array_new();
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_DICTIONARY);
int i;
- for (i = 0; i < properties->len; i++) {
- const GValue * ind_property = indicate_indicator_get_property_value(indicator, g_ptr_array_index(properties, i));
+ for (i = 0; properties[i] != NULL; i++) {
+ GVariant * ind_property = indicate_indicator_get_property_variant(indicator, properties[i]);
if (ind_property == NULL) {
continue;
}
- GValue * value = g_new0(GValue, 1);
- g_value_init(value, G_VALUE_TYPE(ind_property));
- g_value_copy(ind_property, value);
-
- g_ptr_array_add(array, value);
+ GVariant * dictentry = g_variant_new_dict_entry(g_variant_new_string(properties[i]), ind_property);
+ g_variant_builder_add_value(&builder, dictentry);
}
- g_ptr_array_add(array, NULL);
- *value = (gchar **)g_ptr_array_free(array, FALSE);
+
+ *output = g_variant_builder_end(&builder);
return TRUE;
}
@@ -1392,10 +1672,10 @@
just set that. If we're not, then we need to check to see
if anyone else is before continuing. */
static gboolean
-indicator_displayed (IndicateServer * server, gchar * sender, guint id, gboolean displayed, GError ** error)
+indicator_displayed (IndicateServer * server, const gchar * sender, guint id, gboolean displayed, GError ** error)
{
IndicateServerInterestedFolk localfolk;
- localfolk.sender = sender;
+ localfolk.sender = (gchar *)sender; /* Okay to drop the const as we're only using this for searching */
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
@@ -1403,7 +1683,7 @@
IndicateServerInterestedFolk * folkpointer = NULL;
if (entry == NULL) {
folkpointer = g_new0(IndicateServerInterestedFolk, 1);
- indicate_server_interested_folks_init(folkpointer, sender);
+ indicate_server_interested_folks_init(folkpointer, sender, INDICATE_LISTENER_OBJ_PATH, priv->connection);
priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
} else {
folkpointer = (IndicateServerInterestedFolk *)entry->data;
@@ -1426,160 +1706,232 @@
}
/* Virtual Functions */
-gboolean
-_indicate_interface_server_get_indicator_count (IndicateServer * server, guint * count, GError **error)
+static void
+bus_get_indicator_count (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
if (class != NULL && class->get_indicator_count != NULL) {
- return class->get_indicator_count (server, count, error);
+ guint count = 0;
+ GError * error = NULL;
+
+ class->get_indicator_count (server, &count, &error);
+
+ if (error != NULL) {
+ g_dbus_method_invocation_return_gerror(invocation, error);
+ g_error_free(error);
+ } else {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(u)", count));
+ }
+
+ return;
}
- if (error) {
- g_set_error(error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
NO_GET_INDICATOR_COUNT,
"get_indicator_count function doesn't exist for this server class: %s",
G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
+ return;
}
-gboolean
-_indicate_interface_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error)
+static void
+bus_get_indicator_list (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
if (class != NULL && class->get_indicator_list != NULL) {
- return class->get_indicator_list (server, indicators, error);
+ GArray * array = NULL;
+ GError * error = NULL;
+
+ class->get_indicator_list (server, &array, &error);
+
+ if (error != NULL) {
+ g_dbus_method_invocation_return_gerror(invocation, error);
+ g_error_free(error);
+ } else {
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
+
+ int i;
+ for (i = 0; array != NULL && i < array->len; i++) {
+ g_variant_builder_add_value(&builder, g_variant_new_int32(g_array_index(array, gint, i)));
+ }
+
+ GVariant * retval = g_variant_builder_end(&builder);
+ g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(&retval, 1));
+
+ g_array_free(array, TRUE);
+ }
+
+ return;
}
- if (error) {
- g_set_error(error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
NO_GET_INDICATOR_LIST,
"get_indicator_list function doesn't exist for this server class: %s",
G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
+ return;
}
-gboolean
-_indicate_interface_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, GValue * value, GError **error)
+static void
+bus_get_indicator_property (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
if (class != NULL && class->get_indicator_property != NULL) {
- return class->get_indicator_property (server, id, property, value, error);
+ guint id;
+ gchar * property;
+ GVariant * variant;
+ GError * error = NULL;
+
+ g_variant_get(params, "(us)", &id, &property);
+
+ class->get_indicator_property (server, id, property, &variant, &error);
+
+ g_free(property);
+ if (error != NULL) {
+ g_dbus_method_invocation_return_gerror(invocation, error);
+ } else {
+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(v)", variant));
+ }
+
+ return;
}
- if (error) {
- g_set_error(error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
NO_GET_INDICATOR_PROPERTY,
"get_indicator_property function doesn't exist for this server class: %s",
G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
+ return;
}
-gboolean
-_indicate_interface_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error)
+static void
+bus_get_indicator_property_group (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
if (class != NULL && class->get_indicator_property_group != NULL) {
- return class->get_indicator_property_group (server, id, properties, value, error);
+ guint id = g_variant_get_uint32(g_variant_get_child_value(params, 0));;
+ const gchar ** props = g_variant_get_strv(g_variant_get_child_value(params, 1), NULL);
+ GVariant * output;
+ GError * error = NULL;
+
+ class->get_indicator_property_group (server, id, props, &output, &error);
+
+ if (error != NULL) {
+ g_dbus_method_invocation_return_gerror(invocation, error);
+ g_error_free(error);
+ } else {
+ g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(&output, 1));
+ }
+
+ return;
}
- if (error) {
- g_set_error(error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
NO_GET_INDICATOR_PROPERTY_GROUP,
"get_indicator_property_group function doesn't exist for this server class: %s",
G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
+ return;
}
-gboolean
-_indicate_interface_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error)
+static void
+bus_get_indicator_properties (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
if (class != NULL && class->get_indicator_properties != NULL) {
- return class->get_indicator_properties (server, id, properties, error);
+ guint id = g_variant_get_uint32(g_variant_get_child_value(params, 0));
+ gchar ** props = NULL;
+ GError * error = NULL;
+
+ class->get_indicator_properties (server, id, &props, &error);
+
+ if (error != NULL) {
+ g_dbus_method_invocation_return_gerror(invocation, error);
+ g_error_free(error);
+ } else {
+ GVariant * retvals = g_variant_new_strv((const gchar * const *)props, -1);
+ g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(&retvals, 1));
+ g_strfreev(props);
+ }
+
+ return;
}
- if (error) {
- g_set_error(error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
NO_GET_INDICATOR_PROPERTIES,
"get_indicator_properties function doesn't exist for this server class: %s",
G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
+ return;
}
-gboolean
-_indicate_interface_server_show_indicator_to_user (IndicateServer * server, guint id, guint timestamp, GError ** error)
+static void
+bus_show_indicator_to_user (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
if (class != NULL && class->show_indicator_to_user != NULL) {
- return class->show_indicator_to_user (server, id, timestamp, error);
+ GError * error = NULL;
+ guint id, timestamp;
+ g_variant_get(params, "(uu)", &id, ×tamp);
+
+ class->show_indicator_to_user (server, id, timestamp, &error);
+
+ if (error != NULL) {
+ g_dbus_method_invocation_return_gerror(invocation, error);
+ g_error_free(error);
+ } else {
+ g_dbus_method_invocation_return_value(invocation, NULL);
+ }
+
+ return;
}
- if (error) {
- g_set_error(error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
NO_SHOW_INDICATOR_TO_USER,
"show_indicator_to_user function doesn't exist for this server class: %s",
G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
+ return;
}
/* DBus function to wrap a virtual function call so that
it can be subclassed if someone so chooses */
-gboolean
-_indicate_interface_server_indicator_displayed (IndicateServer * server, guint id, gboolean displayed, DBusGMethodInvocation * method)
+static void
+bus_indicator_displayed (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
if (class != NULL && class->indicator_displayed != NULL) {
GError * error = NULL;
- if (class->indicator_displayed (server, dbus_g_method_get_sender(method), id, displayed, &error)) {
- dbus_g_method_return(method);
- return TRUE;
+ guint id;
+ gboolean displayed;
+
+ g_variant_get(params, "(ub)", &id, &displayed);
+
+ if (class->indicator_displayed (server, g_dbus_method_invocation_get_sender(invocation), id, displayed, &error)) {
+ g_dbus_method_invocation_return_value(invocation, NULL);
} else {
- dbus_g_method_return_error(method, error);
+ g_dbus_method_invocation_return_gerror(invocation, error);
g_error_free(error);
- return FALSE;
}
+
+ return;
}
- GError * error = NULL;
- g_set_error(&error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
NO_INDICATOR_DISPLAYED,
"indicator_displayed function doesn't exist for this server class: %s",
G_OBJECT_TYPE_NAME(server));
- dbus_g_method_return_error(method, error);
- g_error_free(error);
- return FALSE;
+ return;
}
/**
@@ -1604,7 +1956,7 @@
}
static IndicateInterests
-interest_string_to_enum (gchar * interest_string)
+interest_string_to_enum (const gchar * interest_string)
{
if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_SERVER_DISPLAY)) {
return INDICATE_INTEREST_SERVER_DISPLAY;
@@ -1629,103 +1981,95 @@
return INDICATE_INTEREST_NONE;
}
-gboolean
-_indicate_interface_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method)
+static void
+bus_show_interest (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
if (class != NULL && class->show_interest != NULL) {
- if (class->show_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){
- dbus_g_method_return(method);
- return TRUE;
+ const gchar * interest = NULL;
+
+ interest = g_variant_get_string(g_variant_get_child_value(params, 0), NULL);
+
+ if (class->show_interest (server, g_dbus_method_invocation_get_sender(invocation), interest_string_to_enum(interest))){
+ g_dbus_method_invocation_return_value(invocation, NULL);
} else {
- GError * error;
- g_set_error(&error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
SHOW_INTEREST_FAILED,
"Unable to show interest: %s",
interest);
- dbus_g_method_return_error(method, error);
- g_error_free(error);
- return FALSE;
}
+
+ return;
}
- GError * error;
- g_set_error(&error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
NO_SHOW_INTEREST,
"show_interest function doesn't exist for this server class: %s",
G_OBJECT_TYPE_NAME(server));
- dbus_g_method_return_error(method, error);
- g_error_free(error);
- return FALSE;
+ return;
}
-gboolean
-_indicate_interface_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method)
+static void
+bus_remove_interest (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
if (class != NULL && class->remove_interest != NULL) {
- if (class->remove_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){
- dbus_g_method_return(method);
- return TRUE;
+ const gchar * interest = NULL;
+
+ interest = g_variant_get_string(g_variant_get_child_value(params, 0), NULL);
+
+ if (class->remove_interest (server, g_dbus_method_invocation_get_sender(invocation), interest_string_to_enum(interest))){
+ g_dbus_method_invocation_return_value(invocation, NULL);
} else {
- GError * error;
- g_set_error(&error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
REMOVE_INTEREST_FAILED,
"Unable to remove interest: %s",
interest);
- dbus_g_method_return_error(method, error);
- g_error_free(error);
- return FALSE;
}
+
+ return;
}
- GError * error;
- g_set_error(&error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
NO_REMOVE_INTEREST,
"remove_interest function doesn't exist for this server class: %s",
G_OBJECT_TYPE_NAME(server));
- dbus_g_method_return_error(method, error);
- g_error_free(error);
- return FALSE;
+ return;
}
-gboolean
-_indicate_interface_server_set_max_indicators (IndicateServer * server, gint max, DBusGMethodInvocation * method)
+static void
+bus_set_max_indicators (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
if (class != NULL && class->max_indicators_set != NULL) {
- if (class->max_indicators_set (server, dbus_g_method_get_sender(method), max)){
- dbus_g_method_return(method);
- return TRUE;
+ gint max = g_variant_get_int32(g_variant_get_child_value(params, 0));
+
+ if (class->max_indicators_set (server, g_dbus_method_invocation_get_sender(invocation), max)){
+ g_dbus_method_invocation_return_value(invocation, NULL);
} else {
- GError * error;
- g_set_error(&error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
MAX_INDICATORS_SET_FAILED,
"Unable to set max indicators: %d",
max);
- dbus_g_method_return_error(method, error);
- g_error_free(error);
- return FALSE;
}
+
+ return;
}
- GError * error;
- g_set_error(&error,
+ g_dbus_method_invocation_return_error(invocation,
indicate_server_error_quark(),
NO_MAX_INDICATORS_SET,
"max_indicators_set function doesn't exist for this server class: %s",
G_OBJECT_TYPE_NAME(server));
- dbus_g_method_return_error(method, error);
- g_error_free(error);
- return FALSE;
+ return;
}
/**
@@ -1824,7 +2168,7 @@
/* Creates a IndicateServerInterestedFolk structure and
initializes the default values to reasonable defaults. */
static void
-indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender)
+indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, const gchar * sender, const gchar * path, GDBusConnection * connection)
{
folk->sender = g_strdup(sender);
@@ -1837,6 +2181,101 @@
folk->indicators_displayed = g_hash_table_new(g_direct_hash, g_direct_equal);
+ g_dbus_proxy_new(connection,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
+ bus_interface_info,
+ sender,
+ path,
+ INDICATE_LISTENER_DBUS_IFACE,
+ NULL, /* TODO: cancelable */
+ folk_proxy_cb,
+ folk);
+
+ return;
+}
+
+/* Look at when the name owner changes so that we can figure out
+ if we need to delete the folks item */
+static void
+folks_name_owner_change (GObject * object, GParamSpec * pspec, gpointer user_data)
+{
+ gchar * name = g_dbus_proxy_get_name_owner(G_DBUS_PROXY(object));
+ if (name != NULL) {
+ /* What? Well, no matter, we don't care if it's there, we'll
+ just ignore this signal and move on. */
+ g_free(name);
+ return;
+ }
+
+ /* g_debug("\tBeing removed, interesting"); */
+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(user_data);
+
+ IndicateServerInterestedFolk searchitem;
+ searchitem.sender = (gchar *)name;
+ GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal);
+
+ if (entry == NULL) {
+ /* g_debug("\tWe don't have it, not interesting"); */
+ return;
+ }
+
+ IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)entry->data;
+ priv->interestedfolks = g_list_remove(priv->interestedfolks, entry->data);
+
+ guint i;
+ for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
+ priv->interests[i] = FALSE;
+ }
+
+ GList * listi = NULL;
+ for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) {
+ IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data;
+ /* g_debug("\tRebuild list from folk: %s", folkpointer->sender); */
+ indicate_server_interested_folks_copy(folkpointer, priv->interests);
+ }
+
+ for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
+ /* g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); */
+ if (folk->interests[i] && !priv->interests[i]) {
+ /* We can only remove interest here. Think about it for a
+ moment and I think you'll be cool with it. */
+ /* g_debug("\tOh, and it was interested in %d. Not anymore.", i); */
+ g_signal_emit(G_OBJECT(user_data), signals[INTEREST_REMOVED], 0, i, TRUE);
+ }
+ }
+
+ /* If the retired folk has set it's max indicators
+ and it's the value we're using, we need to recalculate */
+ if (folk->max_indicators != MAX_INDICATORS_UNSET && folk->max_indicators == priv->max_indicators) {
+ recalculate_max_indicators(user_data);
+ }
+
+ g_hash_table_foreach(folk->indicators_displayed, indicator_display_check_recalc, INDICATE_SERVER(user_data));
+
+ /* Finally destory everything */
+ indicate_server_interested_folks_destroy(folk);
+ return;
+
+}
+
+/* Callback for creating the proxy on the folks object */
+static void
+folk_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
+{
+ GError * error = NULL;
+
+ GDBusProxy * proxy = g_dbus_proxy_new_finish(res, &error);
+ if (error != NULL) {
+ g_warning("Unable to get folks proxy!");
+ g_error_free(error);
+ return;
+ }
+
+ IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)user_data;
+ folk->proxy = proxy;
+
+ g_signal_connect(G_OBJECT(proxy), "notify::g-name-owner", G_CALLBACK(folks_name_owner_change), folk);
+
return;
}
@@ -1870,6 +2309,11 @@
{
g_free(folk->sender);
g_hash_table_destroy(folk->indicators_displayed);
+
+ if (folk->proxy != NULL) {
+ g_object_unref(folk->proxy);
+ }
+
g_free(folk);
return;
}
=== modified file 'libindicate/server.h'
--- libindicate/server.h 2010-06-04 19:28:17 +0000
+++ libindicate/server.h 2011-01-13 22:41:52 +0000
@@ -112,7 +112,7 @@
* Return value: Whether the call was successful in getting the
* properties requested.
*/
-typedef gboolean (*indicate_server_get_indicator_property_group_slot_t) (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);
+typedef gboolean (*indicate_server_get_indicator_property_group_slot_t) (IndicateServer * server, guint id, const gchar ** properties, GVariant ** value, GError **error);
/**
* indicate_server_get_indicator_properties_slot_t:
@@ -192,16 +192,16 @@
/* Virtual Functions */
gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error);
indicate_server_get_indicator_list_slot_t get_indicator_list;
- gboolean (*get_indicator_property) (IndicateServer * server, guint id, gchar * property, GValue * value, GError **error);
+ gboolean (*get_indicator_property) (IndicateServer * server, guint id, gchar * property, GVariant ** value, GError **error);
indicate_server_get_indicator_property_group_slot_t get_indicator_property_group;
indicate_server_get_indicator_properties_slot_t get_indicator_properties;
gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, guint timestamp, GError ** error);
- gboolean (*indicator_displayed) (IndicateServer * server, gchar * sender, guint id, gboolean displayed, GError ** error);
+ gboolean (*indicator_displayed) (IndicateServer * server, const gchar * sender, guint id, gboolean displayed, GError ** error);
guint (*get_next_id) (IndicateServer * server);
- gboolean (*show_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest);
- gboolean (*remove_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest);
+ gboolean (*show_interest) (IndicateServer * server, const gchar * sender, IndicateInterests interest);
+ gboolean (*remove_interest) (IndicateServer * server, const gchar * sender, IndicateInterests interest);
gboolean (*check_interest) (IndicateServer * server, IndicateInterests interest);
- gboolean (*max_indicators_set) (IndicateServer * server, gchar * sender, gint max);
+ gboolean (*max_indicators_set) (IndicateServer * server, const gchar * sender, gint max);
gint (*max_indicators_get) (IndicateServer * server);
/* Reserver for future use */
=== modified file 'm4/introspection.m4'
--- m4/introspection.m4 2009-10-11 15:05:13 +0000
+++ m4/introspection.m4 2011-01-13 22:41:52 +0000
@@ -59,12 +59,18 @@
INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+ INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+ INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+ INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
fi
AC_SUBST(INTROSPECTION_SCANNER)
AC_SUBST(INTROSPECTION_COMPILER)
AC_SUBST(INTROSPECTION_GENERATE)
AC_SUBST(INTROSPECTION_GIRDIR)
AC_SUBST(INTROSPECTION_TYPELIBDIR)
+ AC_SUBST(INTROSPECTION_CFLAGS)
+ AC_SUBST(INTROSPECTION_LIBS)
+ AC_SUBST(INTROSPECTION_MAKEFILE)
AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
])
Follow ups