Merge lp:~ted/libindicate/gdbus-port-away into lp:libindicate/0.6

Proposed by Ted Gould
Status: Merged
Merged at revision: 396
Proposed branch: lp:~ted/libindicate/gdbus-port-away
Merge into: lp:libindicate/0.6
Diff against target: 3353 lines (+1293/-726)
20 files modified
bindings/mono/indicate-gtk/Makefile.am (+1/-2)
bindings/mono/indicate/Makefile.am (+1/-2)
bindings/mono/indicate/indicate-api.metadata (+1/-0)
configure.ac (+4/-4)
docs/reference/Makefile.am (+1/-1)
examples/listen-and-print.c (+2/-2)
libindicate-gtk/Makefile.am (+44/-41)
libindicate-gtk/listener.c (+21/-5)
libindicate/Makefile.am (+58/-55)
libindicate/dbus-properties.xml (+0/-23)
libindicate/dbus-shared.h (+1/-0)
libindicate/indicate.pc.in (+1/-1)
libindicate/indicator.c (+26/-30)
libindicate/indicator.h (+4/-4)
libindicate/listener-private.h (+5/-6)
libindicate/listener.c (+400/-259)
libindicate/listener.h (+7/-7)
libindicate/server.c (+704/-278)
libindicate/server.h (+6/-6)
m4/introspection.m4 (+6/-0)
To merge this branch: bzr merge lp:~ted/libindicate/gdbus-port-away
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+46200@code.launchpad.net
To post a comment you must log in.
lp:~ted/libindicate/gdbus-port-away updated
460. By Ted Gould

Changing signature to match the XML

461. By Ted Gould

Updating to current trunk

Revision history for this message
Conor Curran (cjcurran) wrote :

perfect ! :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bindings/mono/indicate-gtk/Makefile.am'
2--- bindings/mono/indicate-gtk/Makefile.am 2010-06-02 13:33:49 +0000
3+++ bindings/mono/indicate-gtk/Makefile.am 2011-01-13 22:48:19 +0000
4@@ -20,8 +20,7 @@
5 $(API) \
6 $(MIDDLE_API) \
7 $(RAW_API) \
8- $(ASSEMBLY_NAME)-sharp-0.1.pc \
9- AssemblyInfo.cs
10+ $(ASSEMBLY_NAME)-sharp-0.1.pc
11 DISTCLEANFILES = $(ASSEMBLY).config
12 customs = Indicate.custom
13 EXTRA_DIST = \
14
15=== modified file 'bindings/mono/indicate/Makefile.am'
16--- bindings/mono/indicate/Makefile.am 2010-06-02 13:33:49 +0000
17+++ bindings/mono/indicate/Makefile.am 2011-01-13 22:48:19 +0000
18@@ -20,8 +20,7 @@
19 $(API) \
20 $(MIDDLE_API) \
21 $(RAW_API) \
22- $(ASSEMBLY_NAME)-sharp-0.1.pc \
23- AssemblyInfo.cs
24+ $(ASSEMBLY_NAME)-sharp-0.1.pc
25
26 DISTCLEANFILES = $(ASSEMBLY).config
27 customs = Indicate.custom
28
29=== modified file 'bindings/mono/indicate/indicate-api.metadata'
30--- bindings/mono/indicate/indicate-api.metadata 2010-06-02 13:33:49 +0000
31+++ bindings/mono/indicate/indicate-api.metadata 2011-01-13 22:48:19 +0000
32@@ -1,6 +1,7 @@
33 <?xml version="1.0"?>
34 <metadata>
35 <remove-node path="/api/namespace/object[@cname='IndicateIndicator']/method[@name='UserDisplay']" />
36+ <remove-node path="/api/namespace/object[@cname='IndicateListener']/method[@cname='indicate_listener_get_property_variant']" />
37 <attr path="/api/namespace/object[@cname='IndicateServer']/method[@name='SetDesktopFile']" name="name">DesktopFile</attr>
38 <add-node path="/api/namespace/object[@cname='IndicateIndicator']">
39 <signal when="LAST" field_name="user_display" name="UserDisplay" cname="user_display">
40
41=== modified file 'configure.ac'
42--- configure.ac 2010-12-15 11:34:49 +0000
43+++ configure.ac 2011-01-13 22:48:19 +0000
44@@ -55,11 +55,11 @@
45 DBUS_REQUIRED_VERSION=0.76
46 GLIB_REQUIRED_VERSION=2.18
47 GIO_REQUIRED_VERSION=2.18
48-DBUSMENU_REQUIRED_VERSION=0.2.2
49+DBUSMENU_REQUIRED_VERSION=0.3.90
50
51 PKG_CHECK_MODULES(LIBINDICATE, glib-2.0 >= $GLIB_REQUIRED_VERSION
52 gio-2.0 >= $GIO_REQUIRED_VERSION
53- dbusmenu-glib >= $DBUSMENU_REQUIRED_VERSION
54+ dbusmenu-glib-0.4 >= $DBUSMENU_REQUIRED_VERSION
55 dbus-glib-1 >= $DBUS_REQUIRED_VERSION)
56 AC_SUBST(LIBINDICATE_CFLAGS)
57 AC_SUBST(LIBINDICATE_LIBS)
58@@ -70,7 +70,7 @@
59 gio-2.0 >= $GIO_REQUIRED_VERSION
60 gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED_VERSION
61 gtk+-2.0 >= $GTK_REQUIRED_VERSION
62- dbusmenu-glib >= $DBUSMENU_REQUIRED_VERSION
63+ dbusmenu-glib-0.4 >= $DBUSMENU_REQUIRED_VERSION
64 dbus-glib-1 >= $DBUS_REQUIRED_VERSION)
65 AC_SUBST(LIBINDICATEGTK_CFLAGS)
66 AC_SUBST(LIBINDICATEGTK_LIBS)
67@@ -79,7 +79,7 @@
68 # GObject Introspection
69 ###########################
70
71-GOBJECT_INTROSPECTION_CHECK([0.6.3])
72+GOBJECT_INTROSPECTION_CHECK([0.6.7])
73
74 ###########################
75 # Vala API Generation
76
77=== modified file 'docs/reference/Makefile.am'
78--- docs/reference/Makefile.am 2009-12-10 14:59:20 +0000
79+++ docs/reference/Makefile.am 2011-01-13 22:48:19 +0000
80@@ -68,7 +68,7 @@
81 # e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
82 # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
83 INCLUDES=-I$(top_srcdir) $(LIBINDICATE_CFLAGS)
84-GTKDOC_LIBS=$(top_builddir)/libindicate/libindicate.la
85+GTKDOC_LIBS=$(top_builddir)/libindicate/libindicate.la $(LIBINDICATEGTK_LIBS)
86
87 # This includes the standard gtk-doc make rules, copied by gtkdocize.
88 include $(top_srcdir)/gtk-doc.local.make
89
90=== modified file 'examples/listen-and-print.c'
91--- examples/listen-and-print.c 2010-02-04 22:48:26 +0000
92+++ examples/listen-and-print.c 2011-01-13 22:48:19 +0000
93@@ -95,13 +95,13 @@
94 }
95
96 static void
97-type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data)
98+type_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data)
99 {
100 g_debug("Indicator Server Type: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), value);
101 }
102
103 static void
104-desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data)
105+desktop_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data)
106 {
107 g_debug("Indicator Server Desktop: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), value);
108 }
109
110=== modified file 'libindicate-gtk/Makefile.am'
111--- libindicate-gtk/Makefile.am 2010-05-21 19:06:12 +0000
112+++ libindicate-gtk/Makefile.am 2011-01-13 22:48:19 +0000
113@@ -41,47 +41,50 @@
114
115 CLEANFILES =
116
117+#########################
118+# GObject Introsepction
119+#########################
120+
121+-include $(INTROSPECTION_MAKEFILE)
122+INTROSPECTION_GIRS =
123+INTROSPECTION_SCANNER_ARGS = \
124+ --add-include-path=$(top_builddir)/libindicate \
125+ $(introspection_sources) \
126+ --symbol-prefix=indicate \
127+ --warn-all \
128+ --identifier-prefix=Indicate
129+INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) --includedir=$(top_builddir)/libindicate
130+
131 if HAVE_INTROSPECTION
132
133-BUILT_GIRSOURCES =
134-
135-irscanner_headers = $(patsubst %,$(srcdir)/%,$(indicate_gtk_headers))
136-
137-Indicate-Gtk-0.2.gir: $(INTROSPECTION_SCANNER) $(irscanner_headers) Makefile.am
138- $(INTROSPECTION_SCANNER) \
139- -v --namespace Indicate \
140- --nsversion=0.2 \
141- --add-include-path=$(srcdir) \
142- --include=GObject-2.0 \
143- --include=GLib-2.0 \
144- --include=GdkPixbuf-2.0 \
145- --include=Indicate-0.2 \
146- --library=indicate-gtk \
147- --add-include-path=$(top_builddir)/libindicate \
148- $(LIBINDICATEGTK_CFLAGS) -I$(srcdir) -I$(top_srcdir) \
149- --output Indicate-Gtk-0.2.gir $(irscanner_headers) \
150- $(addprefix --c-include=libindicate-gtk/, $(indicate_gtk_headers))
151-
152-BUILT_GIRSOURCES += Indicate-Gtk-0.2.gir
153+introspection_sources = \
154+ $(addprefix $(srcdir)/,$(indicate_gtk_headers))
155+
156+Indicate-Gtk-0.4.gir: libindicate-gtk.la
157+Indicate_Gtk_0_4_gir_INCLUDES = \
158+ GObject-2.0 \
159+ Gtk-2.0 \
160+ GLib-2.0 \
161+ GdkPixbuf-2.0 \
162+ Indicate-0.4
163+Indicate_Gtk_0_4_gir_CFLAGS = $(LIBINDICATEGTK_CFLAGS) -I$(top_builddir) -I$(top_srcdir) -I$(top_builddir)/libindicate
164+Indicate_Gtk_0_4_gir_LIBS = libindicate-gtk.la
165+Indicate_Gtk_0_4_gir_SCANNERFLAGS = $(INTROSPECTION_SCANNER_ARGS)
166+Indicate_Gtk_0_4_gir_FILES = $(introspection_sources)
167+
168+INTROSPECTION_GIRS += Indicate-Gtk-0.4.gir
169
170 girdir = $(datadir)/gir-1.0
171-gir_DATA = $(BUILT_GIRSOURCES)
172-
173-typelibsdir = $(libdir)/girepository-1.0
174-typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
175-
176-%.typelib: %.gir $(INTROSPECTION_COMPILER)
177- $(INTROSPECTION_COMPILER) \
178- --includedir=$(srcdir) \
179- --includedir=. \
180- --includedir=$(top_builddir)/libindicate \
181- $(INTROSPECTION_COMPILER_OPTS) \
182- $< -o $(@F)
183-
184-CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA)
185+gir_DATA = $(INTROSPECTION_GIRS)
186+
187+typelibdir = $(libdir)/girepository-1.0
188+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
189+
190+CLEANFILES += $(gir_DATA) $(typelib_DATA)
191
192 endif
193
194+
195 #########################
196 # VAPI Files
197 #########################
198@@ -89,23 +92,23 @@
199 if HAVE_INTROSPECTION
200
201 vapidir = $(datadir)/vala/vapi
202-vapi_DATA = Indicate-Gtk-0.2.vapi
203+vapi_DATA = Indicate-Gtk-0.4.vapi
204
205-Indicate-Gtk-0.2.vapi: Indicate-Gtk-0.2.tmp.gir Makefile.am
206- $(VALA_API_GEN) --library=Indicate-Gtk-0.2 \
207+Indicate-Gtk-0.4.vapi: Indicate-Gtk-0.4.tmp.gir Makefile.am
208+ $(VALA_API_GEN) --library=Indicate-Gtk-0.4 \
209 --pkg gtk+-2.0 \
210- --pkg Dbusmenu-Glib-0.2 \
211- --pkg Indicate-0.2 \
212+ --pkg Dbusmenu-Glib-0.4 \
213+ --pkg Indicate-0.4 \
214 --vapidir=$(top_builddir)/libindicate \
215 $<
216
217-Indicate-Gtk-0.2.tmp.gir: Indicate-Gtk-0.2.gir
218+Indicate-Gtk-0.4.tmp.gir: Indicate-Gtk-0.4.gir
219 $(SED) \
220 -e "s|GdkPixbuf.Pixbuf|Gdk.Pixbuf|g" \
221 -e "s|Atk.ImplementorIface|Atk.Implementor|g" \
222 $< > $@
223
224-CLEANFILES += $(vapi_DATA) Indicate-Gtk-0.2.tmp.gir
225+CLEANFILES += $(vapi_DATA) Indicate-Gtk-0.4.tmp.gir
226
227 endif
228
229
230=== modified file 'libindicate-gtk/listener.c'
231--- libindicate-gtk/listener.c 2010-02-04 22:37:39 +0000
232+++ libindicate-gtk/listener.c 2011-01-13 22:48:19 +0000
233@@ -30,7 +30,6 @@
234 #include "listener.h"
235 #include <dbus/dbus-glib-bindings.h>
236
237-#include "../libindicate/indicate-interface-client.h"
238 #include "../libindicate/listener-private.h"
239
240 typedef enum _get_property_type get_property_type;
241@@ -50,9 +49,11 @@
242 };
243
244 static void
245-get_property_cb (DBusGProxy *proxy, GValue OUT_vvalue, GError *error, gpointer userdata)
246+get_property_cb (GObject * object, GAsyncResult * res, gpointer user_data)
247 {
248- get_property_t * get_property_data = (get_property_t *)userdata;
249+ get_property_t * get_property_data = (get_property_t *)user_data;
250+ GError * error = NULL;
251+ GVariant * retvalue = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
252
253 if (error != NULL) {
254 g_warning("Unable to get property data: %s", error->message);
255@@ -60,10 +61,12 @@
256 return;
257 }
258
259+ GVariant * value = g_variant_get_child_value(retvalue, 0);
260+
261 switch (get_property_data->type) {
262 case PROPERTY_TYPE_ICON: {
263 indicate_listener_get_property_icon_cb cb = (indicate_listener_get_property_icon_cb)get_property_data->cb;
264- const gchar * OUT_value = g_value_get_string(&OUT_vvalue);
265+ const gchar * OUT_value = g_variant_get_string(value, NULL);
266
267 /* There is no icon */
268 if (OUT_value == NULL || OUT_value[0] == '\0') {
269@@ -102,12 +105,16 @@
270 }
271 }
272
273+ g_variant_unref(value);
274 g_free(get_property_data->property);
275 g_free(get_property_data);
276
277 return;
278 };
279
280+/* A small function to take the common list of parameters and
281+ build a callback structure to hold them all. Eventually we
282+ get the data and unwind this structure. */
283 static void
284 get_property_helper (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GCallback callback, gpointer data, get_property_type prop_type)
285 {
286@@ -122,7 +129,16 @@
287 get_property_data->property = g_strdup(property);
288 get_property_data->type = prop_type;
289
290- org_ayatana_indicate_get_indicator_property_async (server->proxy , INDICATE_LISTENER_INDICATOR_ID(indicator), property, get_property_cb, get_property_data);
291+ g_dbus_proxy_call(server->proxy,
292+ "GetIndicatorProperty",
293+ g_variant_new("(us)",
294+ INDICATE_LISTENER_INDICATOR_ID(indicator), property),
295+ G_DBUS_CALL_FLAGS_NONE,
296+ -1, /* timeout */
297+ NULL, /* cancel */
298+ get_property_cb,
299+ get_property_data);
300+
301 return;
302 }
303
304
305=== modified file 'libindicate/Makefile.am'
306--- libindicate/Makefile.am 2010-06-02 16:19:59 +0000
307+++ libindicate/Makefile.am 2011-01-13 22:48:19 +0000
308@@ -39,11 +39,11 @@
309 libindicateincludedir=$(includedir)/libindicate-0.2/libindicate
310
311 indicate_headers = \
312- $(srcdir)/indicator.h \
313- $(srcdir)/indicator-messages.h \
314- $(srcdir)/listener.h \
315- $(srcdir)/server.h \
316- $(srcdir)/interests.h
317+ $(top_srcdir)/libindicate/indicator.h \
318+ $(top_srcdir)/libindicate/indicator-messages.h \
319+ $(top_srcdir)/libindicate/listener.h \
320+ $(top_srcdir)/libindicate/server.h \
321+ $(top_srcdir)/libindicate/interests.h
322
323 libindicateinclude_HEADERS = \
324 $(indicate_headers) \
325@@ -51,6 +51,10 @@
326
327 libindicate_la_SOURCES = \
328 $(indicate_headers) \
329+ gen-indicate-interface.xml.h \
330+ gen-indicate-interface.xml.c \
331+ gen-indicate-listener.xml.h \
332+ gen-indicate-listener.xml.c \
333 dbus-shared.h \
334 indicate-enum-types.c \
335 server.c \
336@@ -77,27 +81,24 @@
337 ##################################
338
339 DBUS_SPECS = \
340- dbus-properties.xml \
341 indicate-interface.xml \
342 indicate-listener.xml
343
344-%-client.h: %.xml
345- dbus-binding-tool \
346- --prefix=_$(notdir $(subst -,_,$(<:.xml=)))_client \
347- --mode=glib-client \
348- --output=$@ \
349- $<
350+gen-%.xml.h: %.xml
351+ @echo "Building $@ from $<"
352+ @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $<)));" > $@
353
354-%-server.h: %.xml
355- dbus-binding-tool \
356- --prefix=_$(notdir $(subst -,_,$(<:.xml=)))_server \
357- --mode=glib-server \
358- --output=$@ \
359- $<
360+gen-%.xml.c: %.xml
361+ @echo "Building $@ from $<"
362+ @echo "const char * _$(subst -,_,$(subst .,_,$(basename $<))) = " > $@
363+ @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@
364+ @echo ";" >> $@
365
366 BUILT_SOURCES += \
367- $(DBUS_SPECS:.xml=-client.h) \
368- $(DBUS_SPECS:.xml=-server.h)
369+ gen-indicate-interface.xml.h \
370+ gen-indicate-interface.xml.c \
371+ gen-indicate-listener.xml.h \
372+ gen-indicate-listener.xml.c
373
374 pkgconfig_DATA = indicate.pc
375 pkgconfigdir = $(libdir)/pkgconfig
376@@ -105,41 +106,43 @@
377 CLEANFILES += \
378 $(BUILT_SOURCES)
379
380+#########################
381+# GObject Introsepction
382+#########################
383+
384+-include $(INTROSPECTION_MAKEFILE)
385+INTROSPECTION_GIRS =
386+INTROSPECTION_SCANNER_ARGS = \
387+ --add-include-path=$(srcdir) \
388+ --add-include-path=$(top_srcdir)/libindicate \
389+ $(introspection_sources) \
390+ --symbol-prefix=indicate \
391+ --warn-all \
392+ --identifier-prefix=Indicate
393+INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) --includedir=$(top_srcdir)/libindicate
394+
395 if HAVE_INTROSPECTION
396
397-BUILT_GIRSOURCES =
398-
399-irscanner_headers = $(patsubst %,$(srcdir)/%,$(indicate_headers))
400-
401-Indicate-0.2.gir: $(INTROSPECTION_SCANNER) $(irscanner_headers) Makefile.am
402- $(INTROSPECTION_SCANNER) \
403- -v --namespace Indicate \
404- --nsversion=0.2 \
405- --add-include-path=$(srcdir) \
406- --include=GObject-2.0 \
407- --include=GLib-2.0 \
408- --include=Dbusmenu-Glib-0.2 \
409- --library=indicate \
410- $(LIBINDICATE_CFLAGS) -I $(srcdir) -I $(top_srcdir) \
411- --output Indicate-0.2.gir $(irscanner_headers) \
412- $(addprefix --c-include=libindicate/, $(indicate_headers))
413-
414-BUILT_GIRSOURCES += Indicate-0.2.gir
415+introspection_sources = $(indicate_headers)
416+
417+Indicate-0.4.gir: libindicate.la
418+Indicate_0_4_gir_INCLUDES = \
419+ GObject-2.0 \
420+ GLib-2.0 \
421+ Dbusmenu-Glib-0.4
422+Indicate_0_4_gir_CFLAGS = $(LIBINDICATE_CFLAGS) -I$(srcdir)
423+Indicate_0_4_gir_LIBS = libindicate.la
424+Indicate_0_4_gir_FILES = $(introspection_sources)
425+
426+INTROSPECTION_GIRS += Indicate-0.4.gir
427
428 girdir = $(datadir)/gir-1.0
429-gir_DATA = $(BUILT_GIRSOURCES)
430-
431-typelibsdir = $(libdir)/girepository-1.0
432-typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
433-
434-%.typelib: %.gir $(INTROSPECTION_COMPILER)
435- $(INTROSPECTION_COMPILER) \
436- --includedir=$(srcdir) \
437- --includedir=. \
438- $(INTROSPECTION_COMPILER_OPTS) \
439- $< -o $(@F)
440-
441-CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA)
442+gir_DATA = $(INTROSPECTION_GIRS)
443+
444+typelibdir = $(libdir)/girepository-1.0
445+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
446+
447+CLEANFILES += $(gir_DATA) $(typelib_DATA)
448
449 endif
450
451@@ -150,12 +153,12 @@
452 if HAVE_INTROSPECTION
453
454 vapidir = $(datadir)/vala/vapi
455-vapi_DATA = Indicate-0.2.vapi
456+vapi_DATA = Indicate-0.4.vapi
457
458-Indicate-0.2.vapi: Indicate-0.2.gir Makefile.am
459- $(VALA_API_GEN) --library=Indicate-0.2 \
460+Indicate-0.4.vapi: Indicate-0.4.gir Makefile.am
461+ $(VALA_API_GEN) --library=Indicate-0.4 \
462 --pkg glib-2.0 \
463- --pkg Dbusmenu-Glib-0.2 \
464+ --pkg Dbusmenu-Glib-0.4 \
465 --vapidir=$(top_builddir)/src \
466 $<
467
468
469=== removed file 'libindicate/dbus-properties.xml'
470--- libindicate/dbus-properties.xml 2010-02-03 23:15:33 +0000
471+++ libindicate/dbus-properties.xml 1970-01-01 00:00:00 +0000
472@@ -1,23 +0,0 @@
473-<?xml version="1.0" encoding="UTF-8"?>
474-<node name="/">
475- <interface name="org.freedesktop.DBus.Properties">
476-
477- <method name="Get">
478- <arg direction="in" type="s" name="Interface_Name"/>
479- <arg direction="in" type="s" name="Property_Name"/>
480- <arg direction="out" type="v" name="Value"/>
481- </method>
482-
483- <method name="Set">
484- <arg direction="in" type="s" name="Interface_Name"/>
485- <arg direction="in" type="s" name="Property_Name"/>
486- <arg direction="in" type="v" name="Value"/>
487- </method>
488-
489- <method name="GetAll">
490- <arg direction="in" type="s" name="Interface_Name"/>
491- <arg direction="out" type="a{sv}" name="Properties"/>
492- </method>
493-
494- </interface>
495-</node>
496
497=== modified file 'libindicate/dbus-shared.h'
498--- libindicate/dbus-shared.h 2010-02-03 17:54:41 +0000
499+++ libindicate/dbus-shared.h 2011-01-13 22:48:19 +0000
500@@ -30,5 +30,6 @@
501
502 #define INDICATE_DBUS_IFACE "org.ayatana.indicate"
503 #define INDICATE_LISTENER_DBUS_IFACE "org.ayatana.indicate.listener"
504+#define INDICATE_LISTENER_OBJ_PATH "/org/ayatana/indicate/listener"
505
506 #endif /* INDICATE_DBUS_SHARED */
507
508=== modified file 'libindicate/indicate.pc.in'
509--- libindicate/indicate.pc.in 2010-02-04 23:45:52 +0000
510+++ libindicate/indicate.pc.in 2011-01-13 22:48:19 +0000
511@@ -5,7 +5,7 @@
512 includedir=@includedir@
513
514 Cflags: -I${includedir}/libindicate-0.2
515-Requires: gobject-2.0 glib-2.0 dbus-glib-1 dbusmenu-glib
516+Requires: gobject-2.0 glib-2.0 dbusmenu-glib-0.4
517 Libs: -L${libdir} -lindicate
518
519 Name: libindicate
520
521=== modified file 'libindicate/indicator.c'
522--- libindicate/indicator.c 2010-06-04 18:42:01 +0000
523+++ libindicate/indicator.c 2011-01-13 22:48:19 +0000
524@@ -60,8 +60,8 @@
525 G_DEFINE_TYPE (IndicateIndicator, indicate_indicator, G_TYPE_OBJECT);
526
527 static void indicate_indicator_finalize (GObject * object);
528-static void set_property (IndicateIndicator * indicator, const gchar * key, const GValue * data);
529-static const GValue * get_property (IndicateIndicator * indicator, const gchar * key);
530+static void set_property (IndicateIndicator * indicator, const gchar * key, GVariant * data);
531+static GVariant * get_property (IndicateIndicator * indicator, const gchar * key);
532 static GPtrArray * list_properties (IndicateIndicator * indicator);
533
534
535@@ -169,12 +169,11 @@
536 /* A small little function to both clear the insides of a
537 value as well as the memory it itself uses. */
538 static void
539-_g_value_free (gpointer data)
540+_g_variant_unref (gpointer data)
541 {
542 if (data == NULL) return;
543- GValue * value = (GValue*)data;
544- g_value_unset(value);
545- g_free(data);
546+ GVariant * value = (GVariant*)data;
547+ g_variant_unref(value);
548 return;
549 }
550
551@@ -187,7 +186,7 @@
552 priv->is_visible = FALSE;
553 priv->is_displayed = FALSE;
554
555- priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_value_free);
556+ priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_variant_unref);
557
558 priv->server = indicate_server_ref_default();
559 priv->id = indicate_server_get_next_id(priv->server);
560@@ -428,11 +427,8 @@
561 return;
562 }
563
564- GValue strval = {0};
565- g_value_init(&strval, G_TYPE_STRING);
566- g_value_set_static_string(&strval, data);
567-
568- return class->set_property(indicator, key, &strval);
569+ GVariant * variant = g_variant_new_string(data);
570+ return class->set_property(indicator, key, variant);
571 }
572
573 /**
574@@ -479,7 +475,8 @@
575 g_value_init(&intval, G_TYPE_INT);
576 g_value_set_int(&intval, value);
577
578- return class->set_property(indicator, key, &intval);
579+ GVariant * variant = g_variant_new_int32(value);
580+ return class->set_property(indicator, key, variant);
581 }
582
583 /**
584@@ -500,15 +497,12 @@
585 return;
586 }
587
588- GValue boolval = {0};
589- g_value_init(&boolval, G_TYPE_BOOLEAN);
590- g_value_set_boolean(&boolval, value);
591-
592- return class->set_property(indicator, key, &boolval);
593+ GVariant * variant = g_variant_new_boolean(value);
594+ return class->set_property(indicator, key, variant);
595 }
596
597 void
598-indicate_indicator_set_property_value (IndicateIndicator * indicator, const gchar * key, GValue * value)
599+indicate_indicator_set_property_variant (IndicateIndicator * indicator, const gchar * key, GVariant * value)
600 {
601 IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
602 if (class->set_property == NULL) {
603@@ -536,12 +530,16 @@
604 return NULL;
605 }
606
607- const GValue * val = class->get_property(indicator, key);
608- return g_value_get_string(val);
609+ GVariant * val = class->get_property(indicator, key);
610+ if (val == NULL) {
611+ return NULL;
612+ } else {
613+ return g_variant_get_string(val, NULL);
614+ }
615 }
616
617-const GValue *
618-indicate_indicator_get_property_value (IndicateIndicator * indicator, const gchar * key)
619+GVariant *
620+indicate_indicator_get_property_variant (IndicateIndicator * indicator, const gchar * key)
621 {
622 IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
623 if (class->get_property == NULL) {
624@@ -563,18 +561,16 @@
625 }
626
627 static void
628-set_property (IndicateIndicator * indicator, const gchar * key, const GValue * data)
629+set_property (IndicateIndicator * indicator, const gchar * key, GVariant * data)
630 {
631 g_return_if_fail(INDICATE_IS_INDICATOR(indicator));
632
633 IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
634
635 gchar * newkey = g_strdup(key);
636- GValue * newval = g_new0(GValue, 1);
637- g_value_init(newval, G_VALUE_TYPE(data));
638- g_value_copy(data, newval);
639+ g_variant_ref(data);
640
641- g_hash_table_replace(priv->properties, newkey, newval);
642+ g_hash_table_replace(priv->properties, newkey, data);
643
644 if (indicate_indicator_is_visible(indicator)) {
645 /* g_debug("Indicator property modified: %s", key); */
646@@ -584,14 +580,14 @@
647 return;
648 }
649
650-static const GValue *
651+static GVariant *
652 get_property (IndicateIndicator * indicator, const gchar * key)
653 {
654 g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), NULL);
655
656 IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
657
658- return (const GValue *)g_hash_table_lookup(priv->properties, key);
659+ return (GVariant *)g_hash_table_lookup(priv->properties, key);
660 }
661
662 static GPtrArray *
663
664=== modified file 'libindicate/indicator.h'
665--- libindicate/indicator.h 2010-06-04 18:42:01 +0000
666+++ libindicate/indicator.h 2011-01-13 22:48:19 +0000
667@@ -124,8 +124,8 @@
668 void (*displayed) (IndicateIndicator * indicator, gboolean displayed);
669
670 /* Subclassable functions */
671- void (*set_property) (IndicateIndicator * indicator, const gchar * key, const GValue * data);
672- const GValue * (*get_property) (IndicateIndicator * indicator, const gchar * key);
673+ void (*set_property) (IndicateIndicator * indicator, const gchar * key, GVariant * data);
674+ GVariant * (*get_property) (IndicateIndicator * indicator, const gchar * key);
675 indicate_indicator_list_properties_slot_t list_properties;
676
677 /* Reserver for future use */
678@@ -161,10 +161,10 @@
679 void indicate_indicator_set_property_time (IndicateIndicator * indicator, const gchar * key, GTimeVal * time);
680 void indicate_indicator_set_property_int (IndicateIndicator * indicator, const gchar * key, gint value);
681 void indicate_indicator_set_property_bool (IndicateIndicator * indicator, const gchar * key, gboolean value);
682-void indicate_indicator_set_property_value (IndicateIndicator * indicator, const gchar * key, GValue * value);
683+void indicate_indicator_set_property_variant (IndicateIndicator * indicator, const gchar * key, GVariant * value);
684
685 const gchar * indicate_indicator_get_property (IndicateIndicator * indicator, const gchar * key);
686-const GValue * indicate_indicator_get_property_value (IndicateIndicator * indicator, const gchar * key);
687+GVariant * indicate_indicator_get_property_variant (IndicateIndicator * indicator, const gchar * key);
688
689 /**
690 * indicate_indicator_list_properties:
691
692=== modified file 'libindicate/listener-private.h'
693--- libindicate/listener-private.h 2010-06-04 18:40:15 +0000
694+++ libindicate/listener-private.h 2011-01-13 22:48:19 +0000
695@@ -30,12 +30,10 @@
696 #ifndef INDICATE_LISTENER_PRIVATE_H__
697 #define INDICATE_LISTENER_PRIVATE_H__ 1
698
699-#include <dbus/dbus-glib.h>
700-
701 struct _IndicateListenerServer {
702 gchar * name;
703- DBusGProxy * proxy;
704- DBusGConnection * connection;
705+ GDBusProxy * proxy;
706+ GDBusConnection * connection;
707 gboolean interests[INDICATE_INTEREST_LAST];
708 gint max_indicators;
709 };
710@@ -47,8 +45,9 @@
711 typedef struct _IndicateListenerPrivate IndicateListenerPrivate;
712 struct _IndicateListenerPrivate
713 {
714- DBusGConnection * session_bus;
715- DBusGConnection * system_bus;
716+ GDBusConnection * session_bus;
717+ guint object_registration;
718+ guint signal_subscription;
719
720 GList * proxies;
721
722
723=== modified file 'libindicate/listener.c'
724--- libindicate/listener.c 2010-02-18 22:15:49 +0000
725+++ libindicate/listener.c 2011-01-13 22:48:19 +0000
726@@ -28,14 +28,13 @@
727 */
728
729 #include <stdlib.h>
730+#include <gio/gio.h>
731 #include "listener.h"
732-#include "indicate-marshal.h"
733-#include <dbus/dbus-glib-bindings.h>
734-#include <dbus/dbus-glib-lowlevel.h>
735 #include "interests-priv.h"
736 #include "dbus-shared.h"
737-#include "indicate-interface-client.h"
738-#include "dbus-properties-client.h"
739+#include "gen-indicate-interface.xml.h"
740+#include "gen-indicate-listener.xml.h"
741+#include "indicate-marshal.h"
742
743 /* Errors */
744 enum {
745@@ -59,9 +58,9 @@
746 #include "listener-private.h"
747
748 typedef struct {
749- DBusGProxy * proxy;
750- DBusGProxy * property_proxy;
751- DBusGConnection * connection;
752+ GDBusProxy * proxy;
753+ GDBusProxy * property_proxy;
754+ GDBusConnection * connection;
755 gchar * name;
756 gchar * path;
757 gchar * type;
758@@ -87,7 +86,7 @@
759 }
760
761 typedef struct {
762- DBusGConnection * bus;
763+ GDBusConnection * bus;
764 gchar * name;
765 gchar * path;
766 } proxy_todo_t;
767@@ -96,27 +95,38 @@
768
769 /* Prototypes */
770 static void indicate_listener_finalize (GObject * obj);
771-static DBusHandlerResult dbus_filter_show_server (DBusConnection * connection, DBusMessage * message, void * user_data);
772+static void indicate_listener_dispose (GObject * obj);
773 static void proxy_struct_destroy (gpointer data);
774 static void todo_list_add (const gchar * name, const gchar * path, IndicateListener * listener);
775 static gboolean todo_idle (gpointer data);
776-void set_max_indicators_cb (DBusGProxy * proxy, GError * error, gpointer userdata);
777-static void get_type_initial_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data);
778-static void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data);
779-static void proxy_indicator_added_legacy (DBusGProxy * proxy, guint id, gchar * type, proxy_t * proxyt);
780-static void proxy_indicator_added (DBusGProxy * proxy, guint id, proxy_t * proxyt);
781-static void proxy_indicator_removed_legacy (DBusGProxy * proxy, guint id, gchar * type, proxy_t * proxyt);
782-static void proxy_indicator_removed (DBusGProxy * proxy, guint id, proxy_t * proxyt);
783-static void proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, proxy_t * proxyt);
784-static void proxy_server_count_changed (DBusGProxy * proxy, guint count, proxy_t * proxyt);
785-static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data);
786+static void set_max_indicators_cb (GObject * object, GAsyncResult * res, gpointer user_data);
787+static void get_type_initial_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * type, gpointer data);
788+static void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * type, gpointer data);
789+static void proxy_indicator_added_legacy (guint id, gchar * type, proxy_t * proxyt);
790+static void proxy_indicator_added (guint id, proxy_t * proxyt);
791+static void proxy_indicator_removed_legacy (guint id, gchar * type, proxy_t * proxyt);
792+static void proxy_indicator_removed (guint id, proxy_t * proxyt);
793+static void proxy_indicator_modified (guint id, const gchar * property, proxy_t * proxyt);
794+static void proxy_server_count_changed (guint count, proxy_t * proxyt);
795+static void proxy_get_indicator_list (GObject * object, GAsyncResult * res, gpointer data);
796 static void proxy_destroyed (GObject * proxy, gpointer user_data);
797-
798-/* DBus interface */
799-gboolean _indicate_listener_server_get_indicator_servers (IndicateListener * listener, GList * servers);
800-
801-/* Need the above prototypes */
802-#include "indicate-listener-server.h"
803+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);
804+static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data);
805+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);
806+static void prox_ready_cb (GObject * object, GAsyncResult * res, gpointer user_data);
807+static void proxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVariant * params, gpointer user_data);
808+
809+/* Bus Stuff */
810+static GDBusNodeInfo * bus_indicate_node_info = NULL;
811+static GDBusInterfaceInfo * bus_indicate_interface_info = NULL;
812+static GDBusNodeInfo * bus_listener_node_info = NULL;
813+static GDBusInterfaceInfo * bus_listener_interface_info = NULL;
814+static const GDBusInterfaceVTable bus_interface_table = {
815+ method_call: bus_method_call,
816+ get_property: NULL, /* No properties that can be get */
817+ set_property: NULL /* No properties that can be set */
818+};
819+
820
821 /* Code */
822 static void
823@@ -128,6 +138,7 @@
824
825 g_type_class_add_private (class, sizeof (IndicateListenerPrivate));
826
827+ gobj->dispose = indicate_listener_dispose;
828 gobj->finalize = indicate_listener_finalize;
829
830 signals[INDICATOR_ADDED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED,
831@@ -180,14 +191,42 @@
832 g_cclosure_marshal_VOID__VOID,
833 G_TYPE_NONE, 0, G_TYPE_NONE);
834
835- dbus_g_object_register_marshaller(_indicate_marshal_VOID__UINT_STRING,
836- G_TYPE_NONE,
837- G_TYPE_UINT,
838- G_TYPE_STRING,
839- G_TYPE_INVALID);
840-
841- dbus_g_object_type_install_info(INDICATE_TYPE_LISTENER,
842- &dbus_glib__indicate_listener_server_object_info);
843+ /* DBus interfaces */
844+ if (bus_indicate_node_info == NULL) {
845+ GError * error = NULL;
846+
847+ bus_indicate_node_info = g_dbus_node_info_new_for_xml(_indicate_interface, &error);
848+ if (error != NULL) {
849+ g_error("Unable to parse Indicate Interface description: %s", error->message);
850+ g_error_free(error);
851+ }
852+ }
853+
854+ if (bus_indicate_interface_info == NULL) {
855+ bus_indicate_interface_info = g_dbus_node_info_lookup_interface(bus_indicate_node_info, INDICATE_DBUS_IFACE);
856+
857+ if (bus_indicate_interface_info == NULL) {
858+ g_error("Unable to find interface '" INDICATE_DBUS_IFACE "'");
859+ }
860+ }
861+
862+ if (bus_listener_node_info == NULL) {
863+ GError * error = NULL;
864+
865+ bus_listener_node_info = g_dbus_node_info_new_for_xml(_indicate_listener, &error);
866+ if (error != NULL) {
867+ g_error("Unable to parse Listener Interface description: %s", error->message);
868+ g_error_free(error);
869+ }
870+ }
871+
872+ if (bus_listener_interface_info == NULL) {
873+ bus_listener_interface_info = g_dbus_node_info_lookup_interface(bus_listener_node_info, INDICATE_LISTENER_DBUS_IFACE);
874+
875+ if (bus_listener_interface_info == NULL) {
876+ g_error("Unable to find interface '" INDICATE_LISTENER_DBUS_IFACE "'");
877+ }
878+ }
879
880 return;
881 }
882@@ -197,15 +236,12 @@
883 {
884 /* g_debug("Listener Object Initialized"); */
885 IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
886- GError *error = NULL;
887
888 /* Get the buses */
889- priv->session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
890- if (error != NULL) {
891- g_error("Unable to get session bus: %s", error->message);
892- g_error_free(error);
893- return;
894- }
895+ g_bus_get(G_BUS_TYPE_SESSION,
896+ NULL, /* TODO: Cancelable */
897+ bus_get_cb,
898+ listener);
899
900 /* Initialize Data structures */
901 priv->proxies = NULL;
902@@ -216,22 +252,31 @@
903
904 priv->max_indicators = -1;
905
906- dbus_g_connection_register_g_object(priv->session_bus,
907- "/org/ayatana/indicate/listener",
908- G_OBJECT(listener));
909-
910- /* WARNING */
911- /* Starting massive asynchronisity */
912- /* */
913-
914- dbus_connection_add_filter(dbus_g_connection_get_connection(priv->session_bus), dbus_filter_show_server, listener, NULL);
915- dbus_bus_add_match(dbus_g_connection_get_connection(priv->session_bus), "type='signal',interface='" INDICATE_DBUS_IFACE "',member='ServerShow'", NULL);
916-
917- g_signal_emit(G_OBJECT(listener), signals[INDICATOR_SERVERS_REPORT], 0, TRUE);
918-
919- return;
920-}
921-
922+ return;
923+}
924+
925+/* Remove references to objects */
926+static void
927+indicate_listener_dispose (GObject * obj)
928+{
929+ IndicateListener * listener = INDICATE_LISTENER(obj);
930+ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
931+
932+ if (priv->signal_subscription != 0) {
933+ g_dbus_connection_signal_unsubscribe(priv->session_bus, priv->signal_subscription);
934+ priv->signal_subscription = 0;
935+ }
936+
937+ if (priv->object_registration != 0) {
938+ g_dbus_connection_signal_unsubscribe(priv->session_bus, priv->object_registration);
939+ priv->object_registration = 0;
940+ }
941+
942+ G_OBJECT_CLASS (indicate_listener_parent_class)->dispose (obj);
943+ return;
944+}
945+
946+/* Free memory */
947 static void
948 indicate_listener_finalize (GObject * obj)
949 {
950@@ -241,18 +286,86 @@
951 if (priv->todo_idle != 0) {
952 g_idle_remove_by_data(obj);
953 }
954+
955 /* Hack: proxy_struct_destroy() lacks a user_data parameter, but since the
956 * caller is responsible for handling params on the stack, it works
957 */
958 g_list_foreach(priv->proxies, (GFunc)proxy_struct_destroy, NULL);
959 g_list_free(priv->proxies);
960
961- dbus_connection_remove_filter(dbus_g_connection_get_connection(priv->session_bus), dbus_filter_show_server, listener);
962-
963 G_OBJECT_CLASS (indicate_listener_parent_class)->finalize (obj);
964 return;
965 }
966
967+/* Response to connecting to the session bus */
968+static void
969+bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data)
970+{
971+ GError * error = NULL;
972+ GDBusConnection * connection = g_bus_get_finish(res, &error);
973+
974+ if (error != NULL) {
975+ g_error("Unable to get session bus: %s", error->message);
976+ g_error_free(error);
977+ return;
978+ }
979+
980+ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(user_data);
981+ priv->session_bus = connection;
982+
983+ /* Export this object onto the bus */
984+ priv->object_registration = g_dbus_connection_register_object(priv->session_bus,
985+ INDICATE_LISTENER_OBJ_PATH,
986+ bus_listener_interface_info,
987+ &bus_interface_table,
988+ user_data,
989+ NULL,
990+ &error);
991+
992+ if (error != NULL) {
993+ g_error("Unable to register listener on the bus: %s", error->message);
994+ g_error_free(error);
995+ return;
996+ }
997+
998+ /* Watch for servers starting up */
999+ priv->signal_subscription = g_dbus_connection_signal_subscribe(priv->session_bus,
1000+ NULL, /* sender */
1001+ INDICATE_DBUS_IFACE,
1002+ "ServerShow",
1003+ NULL, /* path */
1004+ NULL, /* arg0 */
1005+ G_DBUS_SIGNAL_FLAGS_NONE,
1006+ bus_filter_show_server,
1007+ user_data,
1008+ NULL); /* destroy notify */
1009+
1010+ /* Tell that we're here! */
1011+ g_dbus_connection_emit_signal(priv->session_bus,
1012+ NULL, /* dest */
1013+ INDICATE_LISTENER_OBJ_PATH,
1014+ INDICATE_LISTENER_DBUS_IFACE,
1015+ "IndicatorServersReport",
1016+ NULL, /* params */
1017+ &error);
1018+
1019+ if (error != NULL) {
1020+ g_warning("Unable to send the 'IndicatorServersReport' signal: %s", error->message);
1021+ g_error_free(error);
1022+ return;
1023+ }
1024+
1025+ return;
1026+}
1027+
1028+/* Handle a metho call from dbus */
1029+static void
1030+bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data)
1031+{
1032+
1033+ /* TODO: We should do this, in the future though */
1034+}
1035+
1036 /**
1037 indicate_listener_new:
1038
1039@@ -302,19 +415,16 @@
1040 /* A small filter function that notices when someone sends
1041 a ServerShow signal and creates an entry for us to investigate
1042 them more in an idle loop lookup. */
1043-static DBusHandlerResult
1044-dbus_filter_show_server (DBusConnection * connection, DBusMessage * message, void * user_data)
1045+static void
1046+bus_filter_show_server (GDBusConnection * connection, const gchar * sender, const gchar * object, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data)
1047 {
1048- if (!dbus_message_is_signal(message, INDICATE_DBUS_IFACE, "ServerShow")) {
1049- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
1050+ if (g_strcmp0(signal, "ServerShow") != 0) {
1051+ return;
1052 }
1053
1054- const char * sender = dbus_message_get_sender(message);
1055- const char * path = dbus_message_get_path(message);
1056-
1057- todo_list_add(sender, path, INDICATE_LISTENER(user_data));
1058-
1059- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
1060+ todo_list_add(sender, object, INDICATE_LISTENER(user_data));
1061+
1062+ return;
1063 }
1064
1065 /* A hashtable for each function to look at all of the indicators
1066@@ -347,12 +457,7 @@
1067 proxy_data->indicators = NULL;
1068 }
1069
1070- if (DBUS_IS_G_PROXY(proxy_data->property_proxy)) {
1071- g_object_unref(G_OBJECT(proxy_data->property_proxy));
1072- }
1073-
1074- if (DBUS_IS_G_PROXY(proxy_data->proxy)) {
1075- g_signal_handlers_disconnect_by_func(proxy_data->proxy, proxy_destroyed, proxy_data);
1076+ if (proxy_data->proxy != NULL) {
1077 g_object_unref(G_OBJECT(proxy_data->proxy));
1078 }
1079
1080@@ -473,54 +578,45 @@
1081
1082 /* Build the proxy and ensure that it gets created. If
1083 it gets created we're all happy. */
1084+ g_dbus_proxy_new(priv->session_bus,
1085+ G_DBUS_PROXY_FLAGS_NONE,
1086+ bus_indicate_interface_info,
1087+ proxyt->name,
1088+ todo->path,
1089+ INDICATE_DBUS_IFACE,
1090+ NULL, /* cancel */
1091+ prox_ready_cb,
1092+ proxyt);
1093+
1094+ return TRUE; /* do the next entry */
1095+}
1096+
1097+/* Async result of building a proxy */
1098+static void
1099+prox_ready_cb (GObject * object, GAsyncResult * res, gpointer user_data)
1100+{
1101+ proxy_t * proxyt = (proxy_t *)user_data;
1102 GError * error = NULL;
1103- proxyt->proxy = dbus_g_proxy_new_for_name_owner(todo->bus,
1104- proxyt->name,
1105- todo->path,
1106- INDICATE_DBUS_IFACE,
1107- &error);
1108+ GDBusProxy * proxy = g_dbus_proxy_new_finish(res, &error);
1109
1110 if (error != NULL) {
1111 g_warning("Unable to create proxy for %s", proxyt->name);
1112 g_error_free(error);
1113- return TRUE;
1114+ return;
1115 }
1116
1117- g_signal_connect(G_OBJECT(proxyt->proxy), "destroy", G_CALLBACK(proxy_destroyed), proxyt);
1118+ proxyt->proxy = proxy;
1119+
1120+ g_signal_connect(G_OBJECT(proxyt->proxy), "notify::g-name-owner", G_CALLBACK(proxy_destroyed), proxyt);
1121+ g_signal_connect(G_OBJECT(proxyt->proxy), "g-signal", G_CALLBACK(proxy_signal_cb), proxyt);
1122
1123 /* Making sure the server has the proxy as well */
1124 proxyt->server.proxy = proxyt->proxy;
1125
1126+ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(proxyt->listener);
1127 /* Adding into the list of proxies */
1128 priv->proxies = g_list_prepend(priv->proxies, proxyt);
1129
1130- /* Setup all the signals that we need off of this
1131- proxy. Lot's of fun signals. */
1132- dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorAdded",
1133- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
1134- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorAdded",
1135- G_CALLBACK(proxy_indicator_added_legacy), proxyt, NULL);
1136- dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorNew",
1137- G_TYPE_UINT, G_TYPE_INVALID);
1138- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorNew",
1139- G_CALLBACK(proxy_indicator_added), proxyt, NULL);
1140- dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorRemoved",
1141- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
1142- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorRemoved",
1143- G_CALLBACK(proxy_indicator_removed_legacy), proxyt, NULL);
1144- dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorDelete",
1145- G_TYPE_UINT, G_TYPE_INVALID);
1146- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorDelete",
1147- G_CALLBACK(proxy_indicator_removed), proxyt, NULL);
1148- dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorModified",
1149- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
1150- dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorModified",
1151- G_CALLBACK(proxy_indicator_modified), proxyt, NULL);
1152- dbus_g_proxy_add_signal(proxyt->proxy, "ServerCountChanged",
1153- G_TYPE_UINT, G_TYPE_INVALID);
1154- dbus_g_proxy_connect_signal(proxyt->proxy, "ServerCountChanged",
1155- G_CALLBACK(proxy_server_count_changed), proxyt, NULL);
1156-
1157 /* We're setting the max number of indicators from the default
1158 when we detect it. This should give a reasonable amount of
1159 time for listeners to set the default if they want something
1160@@ -528,20 +624,77 @@
1161 first couple. */
1162 proxyt->server.max_indicators = priv->max_indicators;
1163 if (proxyt->server.max_indicators != -1) {
1164- org_ayatana_indicate_set_max_indicators_async(proxyt->proxy, proxyt->server.max_indicators, set_max_indicators_cb, proxyt->name);
1165+ g_dbus_proxy_call(proxyt->proxy,
1166+ "SetMaxIndicators",
1167+ g_variant_new("(i)", proxyt->server.max_indicators),
1168+ G_DBUS_CALL_FLAGS_NONE,
1169+ -1, /* timeout */
1170+ NULL,
1171+ set_max_indicators_cb,
1172+ proxyt->server.name);
1173 }
1174
1175 indicate_listener_server_get_type(proxyt->listener, &proxyt->server, get_type_initial_cb, proxyt);
1176- org_ayatana_indicate_get_indicator_list_async(proxyt->proxy, proxy_get_indicator_list, proxyt);
1177-
1178- return TRUE;
1179+
1180+
1181+ g_dbus_proxy_call(proxyt->proxy,
1182+ "GetIndicatorList",
1183+ NULL, /* params */
1184+ G_DBUS_CALL_FLAGS_NONE,
1185+ -1, /* timeout */
1186+ NULL,
1187+ proxy_get_indicator_list,
1188+ proxyt);
1189+
1190+ return;
1191+}
1192+
1193+/* We need to do the right signal now */
1194+static void
1195+proxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVariant * params, gpointer user_data)
1196+{
1197+ proxy_t * proxyt = (proxy_t *)user_data;
1198+
1199+ if (g_strcmp0(signal, "IndicatorAdded") == 0) {
1200+ guint id; gchar * type;
1201+ g_variant_get(params, "(us)", &id, &type);
1202+ proxy_indicator_added_legacy(id, type, proxyt);
1203+ } else if (g_strcmp0(signal, "IndicatorNew") == 0) {
1204+ guint id;
1205+ g_variant_get(params, "(u)", &id);
1206+ proxy_indicator_added(id, proxyt);
1207+ } else if (g_strcmp0(signal, "IndicatorRemoved") == 0) {
1208+ guint id; gchar * type;
1209+ g_variant_get(params, "(us)", &id, &type);
1210+ proxy_indicator_removed_legacy(id, type, proxyt);
1211+ } else if (g_strcmp0(signal, "IndicatorDelete") == 0) {
1212+ guint id;
1213+ g_variant_get(params, "(u)", &id);
1214+ proxy_indicator_removed(id, proxyt);
1215+ } else if (g_strcmp0(signal, "IndicatorModified") == 0) {
1216+ guint id; gchar * property;
1217+ g_variant_get(params, "(us)", &id, &property);
1218+ proxy_indicator_modified(id, property, proxyt);
1219+ } else if (g_strcmp0(signal, "ServerCountChanged") == 0) {
1220+ guint count;
1221+ g_variant_get(params, "(u)", &count);
1222+ proxy_server_count_changed(count, proxyt);
1223+ } else if (g_strcmp0(signal, "ServerShow") == 0) {
1224+ /* Unused here */
1225+ } else if (g_strcmp0(signal, "ServerHide") == 0) {
1226+ /* Unused here */
1227+ } else {
1228+ g_warning("Unknown signal from server '%s'", signal);
1229+ }
1230+
1231+ return;
1232 }
1233
1234 /* A callback function for the getting the type when it is looked
1235 at initially. So that we'll send a signal that the server has
1236 been added so that everyone knows. */
1237 static void
1238-get_type_initial_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
1239+get_type_initial_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * type, gpointer data)
1240 {
1241 get_type_cb(listener, server, type, data);
1242
1243@@ -558,7 +711,7 @@
1244 this directly now, only through get_type_initial_cb right now
1245 though we might use it more directly later. */
1246 static void
1247-get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
1248+get_type_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * type, gpointer data)
1249 {
1250 if (type == NULL) {
1251 /* This is usually caused by an error getting the type,
1252@@ -579,13 +732,17 @@
1253
1254 /* A call back from setting the max indicators. We really can't
1255 do anything about it, so this function is kinda useless. */
1256-void
1257-set_max_indicators_cb (DBusGProxy * proxy, GError * error, gpointer userdata)
1258+static void
1259+set_max_indicators_cb (GObject * object, GAsyncResult * res, gpointer user_data)
1260 {
1261+ GError * error = NULL;
1262+ g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
1263+
1264 if (error != NULL) {
1265- g_warning("Unable to set the max indicators on '%s': %s", (gchar *)userdata, error->message);
1266+ g_warning("Unable to set the max indicators on '%s': %s", (gchar *)user_data, error->message);
1267 g_error_free(error);
1268 }
1269+
1270 return;
1271 }
1272
1273@@ -593,20 +750,30 @@
1274 servers that we've found through introspection. It takes
1275 the list and then calls indicator_added on each one. */
1276 static void
1277-proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data)
1278+proxy_get_indicator_list (GObject * object, GAsyncResult * res, gpointer data)
1279 {
1280+ GError * error = NULL;
1281+ GVariant * retval = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
1282+
1283 if (error != NULL) {
1284+ g_warning("Unable to get indicator list");
1285+ g_error_free(error);
1286 return;
1287 }
1288
1289 proxy_t * proxyt = (proxy_t *)data;
1290
1291- int i;
1292- for (i = 0; i < indicators->len; i++) {
1293- guint id = g_array_index(indicators, guint, i);
1294- proxy_indicator_added(proxy, id, proxyt);
1295+ GVariant * list = g_variant_get_child_value(retval, 0);
1296+ GVariantIter iter;
1297+ g_variant_iter_init(&iter, list);
1298+ gint id;
1299+
1300+ while (g_variant_iter_next(&iter, "i", &id)) {
1301+ proxy_indicator_added(id, proxyt);
1302 }
1303
1304+ g_variant_unref(retval);
1305+
1306 return;
1307 }
1308
1309@@ -615,9 +782,9 @@
1310 signals on the indicator v1 interface. It just drops
1311 the type and calls the new function. */
1312 static void
1313-proxy_indicator_added_legacy (DBusGProxy * proxy, guint id, gchar * type, proxy_t * proxyt)
1314+proxy_indicator_added_legacy (guint id, gchar * type, proxy_t * proxyt)
1315 {
1316- return proxy_indicator_added(proxy, id, proxyt);
1317+ return proxy_indicator_added(id, proxyt);
1318 }
1319
1320 /* Gets called when we get a signal from the server that
1321@@ -626,7 +793,7 @@
1322 been known about before, we create the appropriate
1323 structures for it. */
1324 static void
1325-proxy_indicator_added (DBusGProxy * proxy, guint id, proxy_t * proxyt)
1326+proxy_indicator_added (guint id, proxy_t * proxyt)
1327 {
1328 g_debug("Proxy Indicator Added");
1329 g_return_if_fail(proxyt != NULL);
1330@@ -643,16 +810,16 @@
1331 signals on the indicator v1 interface. It just drops
1332 the type and calls the new function. */
1333 static void
1334-proxy_indicator_removed_legacy (DBusGProxy * proxy, guint id, gchar * type, proxy_t * proxyt)
1335+proxy_indicator_removed_legacy (guint id, gchar * type, proxy_t * proxyt)
1336 {
1337- return proxy_indicator_removed(proxy, id, proxyt);
1338+ return proxy_indicator_removed(id, proxyt);
1339 }
1340
1341 /* A server removed an indicator. This function removes all the
1342 local data structures and then passes the signal up the stack.
1343 */
1344 static void
1345-proxy_indicator_removed (DBusGProxy * proxy, guint id, proxy_t * proxyt)
1346+proxy_indicator_removed (guint id, proxy_t * proxyt)
1347 {
1348 g_debug("Proxy Indicator Removed");
1349 g_return_if_fail(proxyt != NULL);
1350@@ -677,7 +844,7 @@
1351 has been modified. We try and find the indicator, convert all
1352 the parameters to the local ones, and then pass up the signal. */
1353 static void
1354-proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, proxy_t * proxyt)
1355+proxy_indicator_modified (guint id, const gchar * property, proxy_t * proxyt)
1356 {
1357 g_debug("Proxy Indicator Modified");
1358 g_return_if_fail(proxyt != NULL);
1359@@ -702,7 +869,7 @@
1360 it into a local signal with the appropraite parameters
1361 and structures. */
1362 static void
1363-proxy_server_count_changed (DBusGProxy * proxy, guint count, proxy_t * proxyt)
1364+proxy_server_count_changed (guint count, proxy_t * proxyt)
1365 {
1366 g_debug("Proxy Server Count Changed");
1367 g_return_if_fail(proxyt != NULL);
1368@@ -712,7 +879,7 @@
1369
1370 typedef enum _get_property_type get_property_type;
1371 enum _get_property_type {
1372- PROPERTY_TYPE_VALUE,
1373+ PROPERTY_TYPE_VARIANT,
1374 PROPERTY_TYPE_STRING,
1375 PROPERTY_TYPE_TIME,
1376 PROPERTY_TYPE_INT,
1377@@ -739,9 +906,11 @@
1378 it nice to work with properties and the listener.
1379 */
1380 static void
1381-get_property_cb (DBusGProxy *proxy, GValue OUT_value, GError *error, gpointer userdata)
1382+get_property_cb (GObject * object, GAsyncResult * res, gpointer user_data)
1383 {
1384- get_property_t * get_property_data = (get_property_t *)userdata;
1385+ get_property_t * get_property_data = (get_property_t *)user_data;
1386+ GError * error = NULL;
1387+ GVariant * retvalue = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
1388
1389 if (error != NULL) {
1390 g_warning("Unable to get property data: %s", error->message);
1391@@ -749,24 +918,29 @@
1392 return;
1393 }
1394
1395+ GVariant * value = g_variant_get_child_value(retvalue, 0);
1396+ if (g_variant_is_of_type(value, G_VARIANT_TYPE_VARIANT)) {
1397+ value = g_variant_get_variant(value);
1398+ }
1399+
1400 switch (get_property_data->type) {
1401- case PROPERTY_TYPE_VALUE: {
1402- /* Just pass the GValue along. */
1403- indicate_listener_get_property_value_cb cb =(indicate_listener_get_property_value_cb)get_property_data->cb;
1404- cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, &OUT_value, get_property_data->data);
1405+ case PROPERTY_TYPE_VARIANT: {
1406+ /* Just pass the GVariant along. */
1407+ indicate_listener_get_property_variant_cb cb =(indicate_listener_get_property_variant_cb)get_property_data->cb;
1408+ cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, value, get_property_data->data);
1409 break;
1410 }
1411 case PROPERTY_TYPE_STRING: {
1412 /* Just pass the string along. */
1413 indicate_listener_get_property_cb cb = (indicate_listener_get_property_cb)get_property_data->cb;
1414- 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);
1415+ 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);
1416 break;
1417 }
1418 case PROPERTY_TYPE_TIME: {
1419 /* Convert it to a time val */
1420 indicate_listener_get_property_time_cb cb = (indicate_listener_get_property_time_cb)get_property_data->cb;
1421 GTimeVal time;
1422- if (g_time_val_from_iso8601(g_value_get_string(&OUT_value), &time)) {
1423+ if (g_time_val_from_iso8601(g_variant_get_string(value, NULL), &time)) {
1424 cb(get_property_data->listener, get_property_data->server, get_property_data->indicator, get_property_data->property, &time, get_property_data->data);
1425 }
1426 break;
1427@@ -774,18 +948,19 @@
1428 case PROPERTY_TYPE_INT: {
1429 /* Take the string and convert it to an integer */
1430 indicate_listener_get_property_int_cb cb = (indicate_listener_get_property_int_cb)get_property_data->cb;
1431- 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);
1432+ 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);
1433 break;
1434 }
1435 case PROPERTY_TYPE_BOOL: {
1436 /* Check to see if it's 'true', if not assume that
1437 it's false */
1438 indicate_listener_get_property_bool_cb cb = (indicate_listener_get_property_bool_cb)get_property_data->cb;
1439- 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);
1440+ 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);
1441 break;
1442 }
1443 }
1444
1445+ g_variant_unref(retvalue);
1446 g_free(get_property_data->property);
1447 g_free(get_property_data);
1448
1449@@ -809,12 +984,21 @@
1450 get_property_data->property = g_strdup(property);
1451 get_property_data->type = prop_type;
1452
1453- org_ayatana_indicate_get_indicator_property_async (server->proxy , INDICATE_LISTENER_INDICATOR_ID(indicator), property, get_property_cb, get_property_data);
1454+ g_dbus_proxy_call(server->proxy,
1455+ "GetIndicatorProperty",
1456+ g_variant_new("(us)",
1457+ INDICATE_LISTENER_INDICATOR_ID(indicator), property),
1458+ G_DBUS_CALL_FLAGS_NONE,
1459+ -1, /* timeout */
1460+ NULL, /* cancel */
1461+ get_property_cb,
1462+ get_property_data);
1463+
1464 return;
1465 }
1466
1467 /**
1468- indicate_listener_get_property_value:
1469+ indicate_listener_get_property_variant:
1470 @listener: The #IndicateListener representing the connection
1471 @server: The server that the indicator is on
1472 @indicator: Which indicator is being queried
1473@@ -826,12 +1010,12 @@
1474 and bring it back locally. This wraps all the hassle of using
1475 the DBus API and makes it pretty easy to get properties.
1476
1477- This function gets the raw gvalue data, without any conversion.
1478+ This function gets the raw GVariant data, without any conversion.
1479 */
1480 void
1481-indicate_listener_get_property_value (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_value_cb callback, gpointer data)
1482+indicate_listener_get_property_variant (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, indicate_listener_get_property_variant_cb callback, gpointer data)
1483 {
1484- return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_VALUE);
1485+ return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_VARIANT);
1486 }
1487
1488 /**
1489@@ -922,19 +1106,14 @@
1490 return get_property_helper(listener, server, indicator, property, G_CALLBACK(callback), data, PROPERTY_TYPE_BOOL);
1491 }
1492
1493-
1494-gboolean
1495-_indicate_listener_server_get_indicator_servers (IndicateListener * listener, GList * servers)
1496-{
1497-
1498- return TRUE;
1499-}
1500-
1501 /* A callback for asking an indicator to be displayed,
1502 which is unlikely to fail. So we're throwing a warning. */
1503 static void
1504-listener_display_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
1505+listener_display_cb (GObject * object, GAsyncResult * res, gpointer user_data)
1506 {
1507+ GError * error = NULL;
1508+ g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
1509+
1510 if (error != NULL) {
1511 g_warning("Listener display caused an error: %s", error->message);
1512 }
1513@@ -944,7 +1123,14 @@
1514 void
1515 indicate_listener_display (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, guint timestamp)
1516 {
1517- org_ayatana_indicate_show_indicator_to_user_async (server->proxy, INDICATE_LISTENER_INDICATOR_ID(indicator), timestamp, listener_display_cb, NULL);
1518+ g_dbus_proxy_call(server->proxy,
1519+ "ShowIndicatorToUser",
1520+ g_variant_new("(uu)", INDICATE_LISTENER_INDICATOR_ID(indicator), timestamp),
1521+ G_DBUS_CALL_FLAGS_NONE,
1522+ -1, /* timeout */
1523+ NULL, /* cancel */
1524+ listener_display_cb,
1525+ NULL);
1526
1527 return;
1528 }
1529@@ -952,8 +1138,11 @@
1530 /* A callback for saying an indicator is displayed,
1531 which is unlikely to fail. So we're throwing a warning. */
1532 static void
1533-listener_displayed_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
1534+listener_displayed_cb (GObject * object, GAsyncResult * res, gpointer user_data)
1535 {
1536+ GError * error = NULL;
1537+ g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
1538+
1539 if (error != NULL) {
1540 g_warning("Listener displayed caused an error: %s", error->message);
1541 }
1542@@ -975,11 +1164,14 @@
1543 void
1544 indicate_listener_displayed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gboolean displayed)
1545 {
1546- org_ayatana_indicate_indicator_displayed_async (server->proxy,
1547- INDICATE_LISTENER_INDICATOR_ID(indicator),
1548- displayed,
1549- listener_displayed_cb,
1550- NULL);
1551+ g_dbus_proxy_call(server->proxy,
1552+ "IndicatorDisplayed",
1553+ g_variant_new("(ub)", INDICATE_LISTENER_INDICATOR_ID(indicator), displayed),
1554+ G_DBUS_CALL_FLAGS_NONE,
1555+ -1, /* timeout */
1556+ NULL, /* cancel */
1557+ listener_displayed_cb,
1558+ NULL);
1559
1560 if (!server->interests[INDICATE_INTEREST_INDICATOR_DISPLAY] && displayed) {
1561 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.");
1562@@ -988,68 +1180,6 @@
1563 return;
1564 }
1565
1566-typedef struct {
1567- IndicateListener * listener;
1568- IndicateListenerServer * server;
1569- indicate_listener_get_server_property_cb cb;
1570- indicate_listener_get_server_uint_property_cb cb_uint;
1571- gpointer data;
1572-} property_cb_t;
1573-
1574-/* A callback from getting the property off of the server
1575- which unravels the property_cb_t structure that was passed
1576- as data and calls back the call back that was in it with
1577- the appropriate data, also unrolled. */
1578-static void
1579-property_cb (DBusGProxy * proxy, GValue property, GError * error, gpointer data)
1580-{
1581- /* 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)); */
1582- property_cb_t * propertyt = data;
1583-
1584- if (error != NULL) {
1585- /* g_warning("Unable to get property: %s", error->message); */
1586- g_free(propertyt);
1587- return;
1588- }
1589-
1590- /* Dup all the values and make them local so that
1591- we can free up the data structure to make the
1592- rest of the code easier to read. */
1593- IndicateListener * listener = propertyt->listener;
1594- IndicateListenerServer * server = propertyt->server;
1595- indicate_listener_get_server_property_cb cb = propertyt->cb;
1596- indicate_listener_get_server_uint_property_cb cb_uint = propertyt->cb_uint;
1597- gpointer cb_data = propertyt->data;
1598-
1599- g_free(propertyt);
1600-
1601- if (G_VALUE_HOLDS_STRING(&property) && cb != NULL) {
1602- /* If it's got a string, and we have a value for that
1603- we'll get the string out and call the call back */
1604- gchar * propstr = g_value_dup_string(&property);
1605- return cb(listener, server, propstr, cb_data);
1606- } else if (G_VALUE_HOLDS_UINT(&property) && cb_uint != NULL) {
1607- /* If it's got a UINT and we have a callback for that
1608- let's grab the value and call the callback. */
1609- guint val = g_value_get_uint(&property);
1610- return cb_uint(listener, server, val, cb_data);
1611- } else if (G_VALUE_TYPE(&property) == DBUS_TYPE_G_OBJECT_PATH && cb != NULL) {
1612- const gchar * val = (const gchar *)g_value_get_boxed(&property);
1613- if (val != NULL && val[0] != '\0' && val[1] != '\0') {
1614- /* If the string is NULL or if there is just a
1615- root item we're going to look at that as an
1616- error and not call the callback */
1617- gchar * propstr = g_strdup(val);
1618- return cb(listener, server, propstr, cb_data);
1619- }
1620- } else {
1621- /* WTF!?!?!?! */
1622- g_warning("Property back from server that we didn't understand.");
1623- }
1624-
1625- return;
1626-}
1627-
1628 /* This is a helper function for all the functions that
1629 get properties from the server. They all need to have
1630 a callback setup with an intermediary data structure
1631@@ -1058,41 +1188,27 @@
1632 static void
1633 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)
1634 {
1635- /* g_debug("Setting up callback for property %s on %s", property_name, INDICATE_LISTENER_SERVER_DBUS_NAME(server)); */
1636- IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
1637-
1638- proxy_t searchitem;
1639- searchitem.name = server->name;
1640- searchitem.connection = server->connection;
1641-
1642- GList * proxyitem = g_list_find_custom(priv->proxies, &searchitem, proxy_t_equal);
1643- if (proxyitem == NULL) {
1644- g_warning("Can not find a proxy for the server at all.");
1645+ GVariant * prop = g_dbus_proxy_get_cached_property(server->proxy, property_name);
1646+
1647+ if (prop == NULL) {
1648+ if (callback == NULL) {
1649+ callback_uint(listener, server, 0, data);
1650+ } else {
1651+ callback(listener, server, NULL, data);
1652+ }
1653 return;
1654 }
1655
1656- proxy_t * proxyt = (proxy_t *)proxyitem->data;
1657-
1658- if (proxyt->property_proxy == NULL) {
1659- proxyt->property_proxy = dbus_g_proxy_new_for_name(proxyt->connection,
1660- proxyt->name,
1661- proxyt->path,
1662- DBUS_INTERFACE_PROPERTIES);
1663+ if (g_variant_is_of_type(prop, G_VARIANT_TYPE_STRING) && callback != NULL) {
1664+ callback(listener, server, g_variant_get_string(prop, NULL), data);
1665+ } else if (g_variant_is_of_type(prop, G_VARIANT_TYPE_OBJECT_PATH) && callback != NULL) {
1666+ callback(listener, server, g_variant_get_string(prop, NULL), data);
1667+ } else if (g_variant_is_of_type(prop, G_VARIANT_TYPE_UINT32) && callback_uint != NULL) {
1668+ callback_uint(listener, server, g_variant_get_uint32(prop), data);
1669+ } else {
1670+ g_warning("Really? This can't happen. WTF! %s", g_variant_get_type_string(prop));
1671 }
1672
1673- property_cb_t * localdata = g_new0(property_cb_t, 1);
1674- localdata->listener = listener;
1675- localdata->server = server;
1676- localdata->cb = callback;
1677- localdata->cb_uint = callback_uint;
1678- localdata->data = data;
1679-
1680- org_freedesktop_DBus_Properties_get_async(proxyt->property_proxy,
1681- INDICATE_DBUS_IFACE,
1682- property_name,
1683- property_cb,
1684- localdata);
1685-
1686 return;
1687 }
1688
1689@@ -1154,10 +1270,14 @@
1690 }
1691
1692 static void
1693-interest_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
1694+interest_cb (GObject * object, GAsyncResult * res, gpointer user_data)
1695 {
1696+ GError * error = NULL;
1697+ g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
1698+
1699 if (error != NULL) {
1700 g_warning("Unable to configure interest.");
1701+ g_error_free(error);
1702 }
1703
1704 return;
1705@@ -1171,7 +1291,14 @@
1706 }
1707
1708 if (!server->interests[interest]) {
1709- org_ayatana_indicate_show_interest_async (server->proxy, interest_to_string(interest), interest_cb, server);
1710+ g_dbus_proxy_call(server->proxy,
1711+ "ShowInterest",
1712+ g_variant_new("(s)", interest_to_string(interest)),
1713+ G_DBUS_CALL_FLAGS_NONE,
1714+ -1, /* timeout */
1715+ NULL, /* cancel */
1716+ interest_cb,
1717+ server);
1718 server->interests[interest] = TRUE;
1719 }
1720 return;
1721@@ -1181,7 +1308,14 @@
1722 indicate_listener_server_remove_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest)
1723 {
1724 if (server->interests[interest]) {
1725- org_ayatana_indicate_remove_interest_async (server->proxy, interest_to_string(interest), interest_cb, server);
1726+ g_dbus_proxy_call(server->proxy,
1727+ "RemoveInterest",
1728+ g_variant_new("(s)", interest_to_string(interest)),
1729+ G_DBUS_CALL_FLAGS_NONE,
1730+ -1, /* timeout */
1731+ NULL, /* cancel */
1732+ interest_cb,
1733+ server);
1734 server->interests[interest] = FALSE;
1735 }
1736 return;
1737@@ -1256,7 +1390,14 @@
1738
1739 if (server->max_indicators != max) {
1740 server->max_indicators = max;
1741- org_ayatana_indicate_set_max_indicators_async(server->proxy, server->max_indicators, set_max_indicators_cb, server->name);
1742+ g_dbus_proxy_call(server->proxy,
1743+ "SetMaxIndicators",
1744+ g_variant_new("(i)", server->max_indicators),
1745+ G_DBUS_CALL_FLAGS_NONE,
1746+ -1, /* timeout */
1747+ NULL,
1748+ set_max_indicators_cb,
1749+ server->name);
1750 }
1751
1752 return;
1753
1754=== modified file 'libindicate/listener.h'
1755--- libindicate/listener.h 2010-09-27 15:18:45 +0000
1756+++ libindicate/listener.h 2011-01-13 22:48:19 +0000
1757@@ -111,22 +111,22 @@
1758
1759 GType indicate_listener_get_type (void) G_GNUC_CONST;
1760
1761-typedef void (*indicate_listener_get_property_value_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, const GValue * propertydata, gpointer data);
1762+typedef void (*indicate_listener_get_property_variant_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GVariant * propertydata, gpointer data);
1763 typedef void (*indicate_listener_get_property_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, const gchar * propertydata, gpointer data);
1764 typedef void (*indicate_listener_get_property_time_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, const GTimeVal * propertydata, gpointer data);
1765 typedef void (*indicate_listener_get_property_int_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gint propertydata, gpointer data);
1766 typedef void (*indicate_listener_get_property_bool_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gboolean propertydata, gpointer data);
1767-typedef void (*indicate_listener_get_server_property_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data);
1768+typedef void (*indicate_listener_get_server_property_cb) (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data);
1769 typedef void (*indicate_listener_get_server_uint_property_cb) (IndicateListener * listener, IndicateListenerServer * server, guint value, gpointer data);
1770
1771 /* Create a new listener */
1772 IndicateListener * indicate_listener_new (void);
1773 IndicateListener * indicate_listener_ref_default (void);
1774-void indicate_listener_get_property_value (IndicateListener * listener,
1775+void indicate_listener_get_property_variant (IndicateListener * listener,
1776 IndicateListenerServer * server,
1777 IndicateListenerIndicator * indicator,
1778 gchar * property,
1779- void (*callback) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, const GValue * propertydata, gpointer data),
1780+ void (*callback) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GVariant * propertydata, gpointer data),
1781 gpointer data);
1782 void indicate_listener_get_property (IndicateListener * listener,
1783 IndicateListenerServer * server,
1784@@ -162,11 +162,11 @@
1785 gboolean displayed);
1786 void indicate_listener_server_get_type (IndicateListener * listener,
1787 IndicateListenerServer * server,
1788- void (*callback) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data),
1789+ void (*callback) (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data),
1790 gpointer data);
1791 void indicate_listener_server_get_desktop (IndicateListener * listener,
1792 IndicateListenerServer * server,
1793- void (*callback) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data),
1794+ void (*callback) (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data),
1795 gpointer data);
1796 void indicate_listener_server_get_count (IndicateListener * listener,
1797 IndicateListenerServer * server,
1798@@ -174,7 +174,7 @@
1799 gpointer data);
1800 void indicate_listener_server_get_menu (IndicateListener * listener,
1801 IndicateListenerServer * server,
1802- void (*callback) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data),
1803+ void (*callback) (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data),
1804 gpointer data);
1805 const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server);
1806 guint indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator);
1807
1808=== modified file 'libindicate/server.c'
1809--- libindicate/server.c 2010-09-16 15:45:20 +0000
1810+++ libindicate/server.c 2011-01-13 22:48:19 +0000
1811@@ -30,10 +30,10 @@
1812 #include "server.h"
1813 #include "interests-priv.h"
1814 #include "indicate-marshal.h"
1815-#include <dbus/dbus-glib.h>
1816-#include <dbus/dbus-glib-lowlevel.h>
1817+#include <gio/gio.h>
1818 #include <libdbusmenu-glib/server.h>
1819 #include "dbus-shared.h"
1820+#include "gen-indicate-interface.xml.h"
1821
1822 /* Errors */
1823 enum {
1824@@ -53,6 +53,7 @@
1825 NO_MAX_INDICATORS_SET,
1826 MAX_INDICATORS_SET_FAILED,
1827 NO_SUCH_PROPERTY,
1828+ NOT_IMPLEMENTED,
1829 LAST_ERROR
1830 };
1831
1832@@ -87,14 +88,15 @@
1833 typedef struct _IndicateServerPrivate IndicateServerPrivate;
1834 struct _IndicateServerPrivate
1835 {
1836- DBusGConnection *connection;
1837- DBusGProxy * dbus_proxy;
1838+ GCancellable * connection_cancel;
1839+ GDBusConnection *connection;
1840+ guint broadcast_signal;
1841
1842 gchar * path;
1843 GSList * indicators;
1844 gboolean visible;
1845 guint current_id;
1846- gboolean registered;
1847+ guint registered;
1848
1849 gchar * desktop;
1850 gchar * type;
1851@@ -123,6 +125,7 @@
1852 gboolean interests[INDICATE_INTEREST_LAST];
1853 gint max_indicators;
1854 GHashTable * indicators_displayed;
1855+ GDBusProxy * proxy;
1856 };
1857
1858 static const gint MAX_INDICATORS_INFINITE = -1;
1859@@ -132,50 +135,83 @@
1860 G_DEFINE_TYPE (IndicateServer, indicate_server, G_TYPE_OBJECT);
1861
1862 /* Prototypes */
1863-static DBusHandlerResult dbus_filter_new_listener (DBusConnection * connection, DBusMessage * message, void * user_data);
1864 static void indicate_server_dispose (GObject * obj);
1865 static void indicate_server_finalize (GObject * obj);
1866 static gboolean get_indicator_count (IndicateServer * server, guint * count, GError **error);
1867 static gboolean get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error);
1868 static IndicateIndicator * get_indicator (IndicateServer * server, guint id, GError **error);
1869-static gboolean get_indicator_property (IndicateServer * server, guint id, gchar * property, GValue * value, GError **error);
1870-static gboolean get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);
1871+static gboolean get_indicator_property (IndicateServer * server, guint id, gchar * property, GVariant ** value, GError **error);
1872+static gboolean get_indicator_property_group (IndicateServer * server, guint id, const gchar ** properties, GVariant ** output, GError **error);
1873 static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error);
1874 static gboolean show_indicator_to_user (IndicateServer * server, guint id, guint timestamp, GError ** error);
1875-static gboolean indicator_displayed (IndicateServer * server, gchar * sender, guint id, gboolean displayed, GError ** error);
1876-static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server);
1877+static gboolean indicator_displayed (IndicateServer * server, const gchar * sender, guint id, gboolean displayed, GError ** error);
1878 static void indicator_display_check_recalc (gpointer key, gpointer value, gpointer userdata);
1879 static void recalculate_indicator_displayed (IndicateServer * server, guint id);
1880 static guint get_next_id (IndicateServer * server);
1881 static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec);
1882 static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec);
1883-static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest);
1884-static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest);
1885+static gboolean show_interest (IndicateServer * server, const gchar * sender, IndicateInterests interest);
1886+static gboolean remove_interest (IndicateServer * server, const gchar * sender, IndicateInterests interest);
1887 static gboolean check_interest (IndicateServer * server, IndicateInterests intrest);
1888 static gint max_indicators_get (IndicateServer * server);
1889-static gboolean max_indicators_set (IndicateServer * server, gchar * sender, gint max);
1890+static gboolean max_indicators_set (IndicateServer * server, const gchar * sender, gint max);
1891 static void recalculate_max_indicators (IndicateServer * server);
1892 static gint indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b);
1893-static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender);
1894+static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, const gchar * sender, const gchar * path, GDBusConnection * connection);
1895 static void indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value);
1896 static void indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests);
1897 static void indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk);
1898+static void bus_connection_cb (GObject * obj, GAsyncResult * res, gpointer user_data);
1899+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);
1900+static void folk_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);
1901+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);
1902+static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data);
1903+static void bus_get_indicator_count (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
1904+static void bus_get_indicator_list (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
1905+static void bus_get_indicator_property (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
1906+static void bus_get_indicator_property_group (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
1907+static void bus_get_indicator_properties (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
1908+static void bus_show_indicator_to_user (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
1909+static void bus_indicator_displayed (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
1910+static void bus_show_interest (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
1911+static void bus_remove_interest (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
1912+static void bus_set_max_indicators (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
1913+static GQuark indicate_server_error_quark (void);
1914 static gboolean interest_timer (gpointer user_data);
1915
1916-/* DBus API */
1917-gboolean _indicate_interface_server_get_indicator_count (IndicateServer * server, guint * count, GError **error);
1918-gboolean _indicate_interface_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error);
1919-gboolean _indicate_interface_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, GValue * value, GError **error);
1920-gboolean _indicate_interface_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);
1921-gboolean _indicate_interface_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error);
1922-gboolean _indicate_interface_server_show_indicator_to_user (IndicateServer * server, guint id, guint timestamp, GError ** error);
1923-gboolean _indicate_interface_server_indicator_displayed (IndicateServer * server, guint id, gboolean displayed, DBusGMethodInvocation * method);
1924-gboolean _indicate_interface_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method);
1925-gboolean _indicate_interface_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method);
1926-gboolean _indicate_interface_server_set_max_indicators (IndicateServer * server, gint max, DBusGMethodInvocation * method);
1927-
1928-/* Has to be after the dbus prototypes */
1929-#include "indicate-interface-server.h"
1930+/* Method Table */
1931+typedef void (*MethodTableFunc) (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation);
1932+
1933+typedef struct _method_table_t method_table_t;
1934+struct _method_table_t {
1935+ const gchar * interned_name;
1936+ MethodTableFunc func;
1937+};
1938+
1939+enum {
1940+ METHOD_GET_INDICATOR_COUNT = 0,
1941+ METHOD_GET_INDICATOR_LIST,
1942+ METHOD_GET_INDICATOR_PROPERTY,
1943+ METHOD_GET_INDICATOR_PROPERTY_GROUP,
1944+ METHOD_GET_INDICATOR_PROPERTIES,
1945+ METHOD_SHOW_INDICATOR_TO_USER,
1946+ METHOD_INDICATOR_DISPLAYED,
1947+ METHOD_SHOW_INTEREST,
1948+ METHOD_REMOVE_INTEREST,
1949+ METHOD_SET_MAX_INDICATORS,
1950+ /* Counter, do not remove! */
1951+ METHOD_COUNT
1952+};
1953+
1954+/* Bus Stuff */
1955+static GDBusNodeInfo * bus_node_info = NULL;
1956+static GDBusInterfaceInfo * bus_interface_info = NULL;
1957+static const GDBusInterfaceVTable bus_interface_table = {
1958+ method_call: bus_method_call,
1959+ get_property: bus_get_prop,
1960+ set_property: NULL /* No properties that can be set */
1961+};
1962+static method_table_t bus_method_table[METHOD_COUNT];
1963
1964
1965
1966@@ -368,14 +404,11 @@
1967 0, G_MAXUINT, 0,
1968 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1969 g_object_class_install_property (gobj, PROP_MENU,
1970- g_param_spec_boxed("menu", "DBus Menu Object Path",
1971+ g_param_spec_string("menu", "DBus Menu Object Path",
1972 "The DBus Object path to an object with a dbusmenu interface on it.",
1973- DBUS_TYPE_G_OBJECT_PATH,
1974+ "",
1975 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
1976
1977- dbus_g_object_type_install_info(INDICATE_TYPE_SERVER,
1978- &dbus_glib__indicate_interface_server_object_info);
1979-
1980 class->get_indicator_count = get_indicator_count;
1981 class->get_indicator_list = get_indicator_list;
1982 class->get_indicator_property = get_indicator_property;
1983@@ -390,6 +423,57 @@
1984 class->max_indicators_get = max_indicators_get;
1985 class->max_indicators_set = max_indicators_set;
1986
1987+ /* DBus interfaces */
1988+ if (bus_node_info == NULL) {
1989+ GError * error = NULL;
1990+
1991+ bus_node_info = g_dbus_node_info_new_for_xml(_indicate_interface, &error);
1992+ if (error != NULL) {
1993+ g_error("Unable to parse Indicate Interface description: %s", error->message);
1994+ g_error_free(error);
1995+ }
1996+ }
1997+
1998+ if (bus_interface_info == NULL) {
1999+ bus_interface_info = g_dbus_node_info_lookup_interface(bus_node_info, INDICATE_DBUS_IFACE);
2000+
2001+ if (bus_interface_info == NULL) {
2002+ g_error("Unable to find interface '" INDICATE_DBUS_IFACE "'");
2003+ }
2004+ }
2005+
2006+ /* Building our Method table :( */
2007+ bus_method_table[METHOD_GET_INDICATOR_COUNT].interned_name = g_intern_static_string("GetIndicatorCount");
2008+ bus_method_table[METHOD_GET_INDICATOR_COUNT].func = bus_get_indicator_count;
2009+
2010+ bus_method_table[METHOD_GET_INDICATOR_LIST].interned_name = g_intern_static_string("GetIndicatorList");
2011+ bus_method_table[METHOD_GET_INDICATOR_LIST].func = bus_get_indicator_list;
2012+
2013+ bus_method_table[METHOD_GET_INDICATOR_PROPERTY].interned_name = g_intern_static_string("GetIndicatorProperty");
2014+ bus_method_table[METHOD_GET_INDICATOR_PROPERTY].func = bus_get_indicator_property;
2015+
2016+ bus_method_table[METHOD_GET_INDICATOR_PROPERTY_GROUP].interned_name = g_intern_static_string("GetIndicatorPropertyGroup");
2017+ bus_method_table[METHOD_GET_INDICATOR_PROPERTY_GROUP].func = bus_get_indicator_property_group;
2018+
2019+ bus_method_table[METHOD_GET_INDICATOR_PROPERTIES].interned_name = g_intern_static_string("GetIndicatorProperties");
2020+ bus_method_table[METHOD_GET_INDICATOR_PROPERTIES].func = bus_get_indicator_properties;
2021+
2022+ bus_method_table[METHOD_SHOW_INDICATOR_TO_USER].interned_name = g_intern_static_string("ShowIndicatorToUser");
2023+ bus_method_table[METHOD_SHOW_INDICATOR_TO_USER].func = bus_show_indicator_to_user;
2024+
2025+ bus_method_table[METHOD_INDICATOR_DISPLAYED].interned_name = g_intern_static_string("IndicatorDisplayed");
2026+ bus_method_table[METHOD_INDICATOR_DISPLAYED].func = bus_indicator_displayed;
2027+
2028+ bus_method_table[METHOD_SHOW_INTEREST].interned_name = g_intern_static_string("ShowInterest");
2029+ bus_method_table[METHOD_SHOW_INTEREST].func = bus_show_interest;
2030+
2031+ bus_method_table[METHOD_REMOVE_INTEREST].interned_name = g_intern_static_string("RemoveInterest");
2032+ bus_method_table[METHOD_REMOVE_INTEREST].func = bus_remove_interest;
2033+
2034+ bus_method_table[METHOD_SET_MAX_INDICATORS].interned_name = g_intern_static_string("SetMaxIndicators");
2035+ bus_method_table[METHOD_SET_MAX_INDICATORS].func = bus_set_max_indicators;
2036+
2037+
2038 return;
2039 }
2040
2041@@ -404,7 +488,7 @@
2042 priv->indicators = NULL;
2043 priv->num_hidden = 0;
2044 priv->visible = FALSE;
2045- priv->registered = FALSE;
2046+ priv->registered = 0;
2047 priv->current_id = 0;
2048 priv->type = NULL;
2049 priv->desktop = NULL;
2050@@ -418,10 +502,13 @@
2051 priv->interestedfolks = NULL;
2052 priv->max_indicators = MAX_INDICATORS_UNSET;
2053
2054- priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
2055-
2056- dbus_connection_add_filter(dbus_g_connection_get_connection(priv->connection), dbus_filter_new_listener, server, NULL);
2057- dbus_bus_add_match(dbus_g_connection_get_connection(priv->connection), "type='signal',interface='" INDICATE_LISTENER_DBUS_IFACE "',member='IndicatorServersReport'", NULL);
2058+ priv->broadcast_signal = 0;
2059+ priv->connection = NULL;
2060+ priv->connection_cancel = g_cancellable_new();
2061+ g_bus_get(G_BUS_TYPE_SESSION,
2062+ priv->connection_cancel, /* cancel */
2063+ bus_connection_cb,
2064+ server);
2065
2066 priv->interest_timer = g_timeout_add(500, interest_timer, server);
2067
2068@@ -434,18 +521,42 @@
2069 IndicateServer * server = INDICATE_SERVER(obj);
2070 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
2071
2072+ if (priv->broadcast_signal != 0) {
2073+ g_dbus_connection_signal_unsubscribe(priv->connection, priv->broadcast_signal);
2074+ priv->broadcast_signal = 0;
2075+ }
2076+
2077+ if (priv->connection_cancel != NULL) {
2078+ g_cancellable_cancel(priv->connection_cancel);
2079+ g_object_unref(priv->connection_cancel);
2080+ priv->connection_cancel = NULL;
2081+ }
2082+
2083 if (priv->dbusmenu != NULL) {
2084 g_object_unref(priv->dbusmenu);
2085 priv->dbusmenu = NULL;
2086 }
2087
2088 if (priv->visible) {
2089+ if (priv->registered != 0) {
2090+ g_dbus_connection_emit_signal(priv->connection,
2091+ NULL, /* dest */
2092+ priv->path,
2093+ INDICATE_DBUS_IFACE,
2094+ "ServerHide",
2095+ g_variant_new("(s)", priv->type ? priv-> type : ""),
2096+ NULL); /* error */
2097+ }
2098 g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE);
2099 }
2100
2101- if (priv->dbus_proxy != NULL) {
2102- g_object_unref(priv->dbus_proxy);
2103- priv->dbus_proxy = NULL;
2104+ if (priv->registered != 0) {
2105+ g_dbus_connection_unregister_object(priv->connection, priv->registered);
2106+ }
2107+
2108+ if (priv->connection != NULL) {
2109+ g_object_unref(priv->connection);
2110+ priv->connection = NULL;
2111 }
2112
2113 if (priv->interest_timer != 0) {
2114@@ -472,8 +583,6 @@
2115 g_free(priv->type);
2116 }
2117
2118- dbus_connection_remove_filter(dbus_g_connection_get_connection(priv->connection), dbus_filter_new_listener, server);
2119-
2120 G_OBJECT_CLASS (indicate_server_parent_class)->finalize (obj);
2121
2122 return;
2123@@ -502,6 +611,15 @@
2124 guint newval = g_value_get_uint(value);
2125 if (newval != priv->count) {
2126 priv->count = newval;
2127+ if (priv->registered != 0) {
2128+ g_dbus_connection_emit_signal(priv->connection,
2129+ NULL, /* dest */
2130+ priv->path,
2131+ INDICATE_DBUS_IFACE,
2132+ "ServerCountChanged",
2133+ g_variant_new("(u)", newval),
2134+ NULL); /* error */
2135+ }
2136 g_signal_emit(obj, signals[SERVER_COUNT_CHANGED], 0, newval, TRUE);
2137 }
2138 break;
2139@@ -561,25 +679,155 @@
2140 return;
2141 }
2142
2143+/************************
2144+ DBUS STUFF
2145+ ************************/
2146+
2147+/* Response to trying to get on the session bus */
2148+static void
2149+bus_connection_cb (GObject * obj, GAsyncResult * res, gpointer user_data)
2150+{
2151+ GError * error = NULL;
2152+
2153+ GDBusConnection * connection = g_bus_get_finish(res, &error);
2154+ if (error != NULL) {
2155+ g_error("Unable to get session bus: %s", error->message);
2156+ g_error_free(error);
2157+ return;
2158+ }
2159+
2160+ IndicateServer * server = INDICATE_SERVER(user_data);
2161+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
2162+
2163+ if (priv->connection_cancel != NULL) {
2164+ g_object_unref(priv->connection_cancel);
2165+ priv->connection_cancel = NULL;
2166+ }
2167+
2168+ if (priv->connection != NULL) {
2169+ g_warning("Getting a second connection?");
2170+ g_object_unref(priv->connection);
2171+ priv->connection = NULL;
2172+ }
2173+ priv->connection = connection;
2174+
2175+ priv->broadcast_signal = g_dbus_connection_signal_subscribe(priv->connection,
2176+ NULL, /* sender */
2177+ INDICATE_LISTENER_DBUS_IFACE,
2178+ "IndicatorServersReport",
2179+ NULL, /* object */
2180+ NULL, /* arg0 */
2181+ G_DBUS_SIGNAL_FLAGS_NONE,
2182+ bus_broadcast_cb,
2183+ server,
2184+ NULL); /* destroy notify */
2185+
2186+ if (priv->visible) {
2187+ priv->visible = FALSE;
2188+ indicate_server_show(server);
2189+ }
2190+
2191+ return;
2192+}
2193+
2194 /* A small dbus filter that waits on the IndicatorServersReport
2195 signal and sends the Show signal if this server is not hidden. */
2196-static DBusHandlerResult
2197-dbus_filter_new_listener (DBusConnection * connection, DBusMessage * message, void * user_data)
2198+static void
2199+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)
2200 {
2201- if (!dbus_message_is_signal(message, INDICATE_LISTENER_DBUS_IFACE, "IndicatorServersReport")) {
2202- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
2203- }
2204+ g_return_if_fail(g_strcmp0(signal_name, "IndicatorServersReport") == 0);
2205
2206 IndicateServer * server = INDICATE_SERVER(user_data);
2207
2208 if (server != NULL) {
2209 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
2210 if (priv->visible) {
2211+ if (priv->registered != 0) {
2212+ g_dbus_connection_emit_signal(priv->connection,
2213+ NULL, /* dest */
2214+ priv->path,
2215+ INDICATE_DBUS_IFACE,
2216+ "ServerShow",
2217+ g_variant_new("(s)", priv->type ? priv-> type : ""),
2218+ NULL); /* error */
2219+ }
2220 g_signal_emit(server, signals[SERVER_SHOW], 0, priv->type ? priv->type : "", TRUE);
2221 }
2222 }
2223
2224- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
2225+ return;
2226+}
2227+
2228+/* A method call has come from DBus */
2229+static void
2230+bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data)
2231+{
2232+ int i;
2233+ const gchar * interned_method = g_intern_string(method);
2234+
2235+ for (i = 0; i < METHOD_COUNT; i++) {
2236+ if (bus_method_table[i].interned_name == interned_method) {
2237+ if (bus_method_table[i].func != NULL) {
2238+ return bus_method_table[i].func(INDICATE_SERVER(user_data), params, invocation);
2239+ } else {
2240+ /* If we have a null function we're responding but nothing else. */
2241+ g_warning("Invalid function call for '%s' with parameters: %s", method, g_variant_print(params, TRUE));
2242+ g_dbus_method_invocation_return_value(invocation, NULL);
2243+ return;
2244+ }
2245+ }
2246+ }
2247+
2248+ /* We're here because there's an error */
2249+ g_dbus_method_invocation_return_error(invocation,
2250+ indicate_server_error_quark(),
2251+ NOT_IMPLEMENTED,
2252+ "Unable to find method '%s'",
2253+ method);
2254+ return;
2255+}
2256+
2257+/* Dbus have asked for properties, let's talk to it. */
2258+static GVariant *
2259+bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data)
2260+{
2261+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(user_data);
2262+ GVariant * retvariant = NULL;
2263+
2264+ if (g_strcmp0(property, "desktop") == 0) {
2265+ if (priv->desktop != NULL) {
2266+ retvariant = g_variant_new_string(priv->desktop);
2267+ } else {
2268+ retvariant = g_variant_new_string("");
2269+ }
2270+ } else if (g_strcmp0(property, "type") == 0) {
2271+ if (priv->type != NULL) {
2272+ retvariant = g_variant_new_string(priv->type);
2273+ } else {
2274+ retvariant = g_variant_new_string("");
2275+ }
2276+ } else if (g_strcmp0(property, "count") == 0) {
2277+ retvariant = g_variant_new_uint32(priv->count);
2278+ } else if (g_strcmp0(property, "menu") == 0) {
2279+ if (priv->dbusmenu != NULL) {
2280+ GValue strvalue = {0};
2281+ g_value_init(&strvalue, G_TYPE_STRING);
2282+ g_object_get_property(G_OBJECT(priv->dbusmenu), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strvalue);
2283+ if (g_value_get_string(&strvalue) != NULL) {
2284+ retvariant = g_variant_new_string(g_value_get_string(&strvalue));
2285+ } else {
2286+ retvariant = g_variant_new_string("/");
2287+ }
2288+ g_value_unset(&strvalue);
2289+ } else {
2290+ retvariant = g_variant_new_string("/");
2291+ }
2292+
2293+ } else {
2294+ g_warning("Unknown property");
2295+ }
2296+
2297+ return retvariant;
2298 }
2299
2300 /* Small little function to get an error quark for usage
2301@@ -590,6 +838,25 @@
2302 static GQuark quark = 0;
2303 if (quark == 0) {
2304 quark = g_quark_from_static_string (G_LOG_DOMAIN);
2305+
2306+ /* Register our dbus error codes as well */
2307+ g_dbus_error_register_error(quark, NO_GET_DESKTOP, "NO_GET_DESKTOP");
2308+ g_dbus_error_register_error(quark, NO_GET_INDICATOR_COUNT, "NO_GET_INDICATOR_COUNT");
2309+ g_dbus_error_register_error(quark, NO_GET_INDICATOR_LIST, "NO_GET_INDICATOR_LIST");
2310+ g_dbus_error_register_error(quark, NO_GET_INDICATOR_PROPERTY, "NO_GET_INDICATOR_PROPERTY");
2311+ g_dbus_error_register_error(quark, NO_GET_INDICATOR_PROPERTY_GROUP, "NO_GET_INDICATOR_PROPERTY_GROUP");
2312+ g_dbus_error_register_error(quark, NO_GET_INDICATOR_PROPERTIES, "NO_GET_INDICATOR_PROPERTIES");
2313+ g_dbus_error_register_error(quark, NO_SHOW_INDICATOR_TO_USER, "NO_SHOW_INDICATOR_TO_USER");
2314+ g_dbus_error_register_error(quark, NO_INDICATOR_DISPLAYED, "NO_INDICATOR_DISPLAYED");
2315+ g_dbus_error_register_error(quark, INVALID_INDICATOR_ID, "INVALID_INDICATOR_ID");
2316+ g_dbus_error_register_error(quark, NO_SHOW_INTEREST, "NO_SHOW_INTEREST");
2317+ g_dbus_error_register_error(quark, NO_REMOVE_INTEREST, "NO_REMOVE_INTEREST");
2318+ g_dbus_error_register_error(quark, SHOW_INTEREST_FAILED, "SHOW_INTEREST_FAILED");
2319+ g_dbus_error_register_error(quark, REMOVE_INTEREST_FAILED, "REMOVE_INTEREST_FAILED");
2320+ g_dbus_error_register_error(quark, NO_MAX_INDICATORS_SET, "NO_MAX_INDICATORS_SET");
2321+ g_dbus_error_register_error(quark, MAX_INDICATORS_SET_FAILED, "MAX_INDICATORS_SET_FAILED");
2322+ g_dbus_error_register_error(quark, NO_SUCH_PROPERTY, "NO_SUCH_PROPERTY");
2323+ g_dbus_error_register_error(quark, NOT_IMPLEMENTED, "NOT_IMPLEMENTED");
2324 }
2325 return quark;
2326 }
2327@@ -611,33 +878,45 @@
2328 g_return_if_fail(INDICATE_IS_SERVER(server));
2329 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
2330
2331- if (priv->visible)
2332+ if (priv->visible) {
2333 return;
2334-
2335- priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
2336-
2337- if (!priv->registered) {
2338- dbus_g_connection_register_g_object(priv->connection,
2339- priv->path,
2340- G_OBJECT(server));
2341- priv->registered = TRUE;
2342 }
2343
2344 priv->visible = TRUE;
2345
2346+ if (priv->connection == NULL) {
2347+ return;
2348+ }
2349+
2350+ if (priv->registered == 0) {
2351+ GError * error = NULL;
2352+ priv->registered = g_dbus_connection_register_object(priv->connection,
2353+ priv->path,
2354+ bus_interface_info,
2355+ &bus_interface_table,
2356+ server,
2357+ NULL,
2358+ &error);
2359+
2360+ if (error != NULL) {
2361+ g_warning("Unable to export object '%s' with interface '" INDICATE_DBUS_IFACE "' on dbus: %s", priv->path, error->message);
2362+ g_error_free(error);
2363+ priv->registered = 0; /* Just to be sure */
2364+ return;
2365+ }
2366+ }
2367+
2368+ if (priv->registered != 0) {
2369+ g_dbus_connection_emit_signal(priv->connection,
2370+ NULL, /* dest */
2371+ priv->path,
2372+ INDICATE_DBUS_IFACE,
2373+ "ServerShow",
2374+ g_variant_new("(s)", priv->type ? priv-> type : ""),
2375+ NULL); /* error */
2376+ }
2377 g_signal_emit(server, signals[SERVER_SHOW], 0, priv->type ? priv->type : "", TRUE);
2378
2379- priv->dbus_proxy = dbus_g_proxy_new_for_name_owner (priv->connection,
2380- DBUS_SERVICE_DBUS,
2381- DBUS_PATH_DBUS,
2382- DBUS_INTERFACE_DBUS,
2383- NULL);
2384- dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged",
2385- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
2386- G_TYPE_INVALID);
2387- dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged",
2388- G_CALLBACK(dbus_owner_change), server, NULL);
2389-
2390 return;
2391 }
2392
2393@@ -680,77 +959,17 @@
2394 priv->max_indicators = MAX_INDICATORS_UNSET;
2395 g_signal_emit(G_OBJECT(server), signals[MAX_INDICATORS_CHANGED], 0, MAX_INDICATORS_INFINITE, TRUE);
2396
2397+ if (priv->registered != 0) {
2398+ g_dbus_connection_emit_signal(priv->connection,
2399+ NULL, /* dest */
2400+ priv->path,
2401+ INDICATE_DBUS_IFACE,
2402+ "ServerHide",
2403+ g_variant_new("(s)", priv->type ? priv-> type : ""),
2404+ NULL); /* error */
2405+ }
2406 g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE);
2407
2408- if (priv->dbus_proxy != NULL) {
2409- g_object_unref(G_OBJECT(priv->dbus_proxy));
2410- priv->dbus_proxy = NULL;
2411- }
2412-
2413- return;
2414-}
2415-
2416-/* Watches the DBus owner change signals to see if any
2417- of our folk disappear. If one of our folks goes away
2418- then it deals with the repercussions of deleting that
2419- entry in terms of interest, max indicators and which
2420- indicators are being displayed. */
2421-static void
2422-dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server)
2423-{
2424- /* g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); */
2425- if (prev == NULL || prev[0] == '\0') {
2426- /* We only care about people leaving the bus */
2427- return;
2428- }
2429-
2430- /* g_debug("\tBeing removed, interesting"); */
2431- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
2432-
2433- IndicateServerInterestedFolk searchitem;
2434- searchitem.sender = (gchar *)name;
2435- GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal);
2436-
2437- if (entry == NULL) {
2438- /* g_debug("\tWe don't have it, not interesting"); */
2439- return;
2440- }
2441-
2442- IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)entry->data;
2443- priv->interestedfolks = g_list_remove(priv->interestedfolks, entry->data);
2444-
2445- guint i;
2446- for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
2447- priv->interests[i] = FALSE;
2448- }
2449-
2450- GList * listi = NULL;
2451- for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) {
2452- IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data;
2453- /* g_debug("\tRebuild list from folk: %s", folkpointer->sender); */
2454- indicate_server_interested_folks_copy(folkpointer, priv->interests);
2455- }
2456-
2457- for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
2458- /* g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); */
2459- if (folk->interests[i] && !priv->interests[i]) {
2460- /* We can only remove interest here. Think about it for a
2461- moment and I think you'll be cool with it. */
2462- /* g_debug("\tOh, and it was interested in %d. Not anymore.", i); */
2463- g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE);
2464- }
2465- }
2466-
2467- /* If the retired folk has set it's max indicators
2468- and it's the value we're using, we need to recalculate */
2469- if (folk->max_indicators != MAX_INDICATORS_UNSET && folk->max_indicators == priv->max_indicators) {
2470- recalculate_max_indicators(server);
2471- }
2472-
2473- g_hash_table_foreach(folk->indicators_displayed, indicator_display_check_recalc, server);
2474-
2475- /* Finally destory everything */
2476- indicate_server_interested_folks_destroy(folk);
2477 return;
2478 }
2479
2480@@ -811,7 +1030,7 @@
2481 mark their folk listing. If it changes the overall setting
2482 then we need to signal. */
2483 static gboolean
2484-show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest)
2485+show_interest (IndicateServer * server, const gchar * sender, IndicateInterests interest)
2486 {
2487 if (!(interest > INDICATE_INTEREST_NONE && interest < INDICATE_INTEREST_LAST)) {
2488 return FALSE;
2489@@ -819,7 +1038,7 @@
2490
2491 /* g_debug("Someone is showing interest. %s in %d", sender, interest); */
2492 IndicateServerInterestedFolk localfolk;
2493- localfolk.sender = sender;
2494+ localfolk.sender = (gchar *)sender; /* Okay to drop the const as we're only using this for searching */
2495
2496 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
2497
2498@@ -832,7 +1051,7 @@
2499 IndicateServerInterestedFolk * folkpointer = NULL;
2500 if (entry == NULL) {
2501 folkpointer = g_new0(IndicateServerInterestedFolk, 1);
2502- indicate_server_interested_folks_init(folkpointer, sender);
2503+ indicate_server_interested_folks_init(folkpointer, sender, INDICATE_LISTENER_OBJ_PATH, priv->connection);
2504 priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
2505 } else {
2506 folkpointer = (IndicateServerInterestedFolk *)entry->data;
2507@@ -851,14 +1070,14 @@
2508 folk structure and then checks to see if that has global
2509 effect, and handles it. */
2510 static gboolean
2511-remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest)
2512+remove_interest (IndicateServer * server, const gchar * sender, IndicateInterests interest)
2513 {
2514 if (!(interest > INDICATE_INTEREST_NONE && interest < INDICATE_INTEREST_LAST)) {
2515 return FALSE;
2516 }
2517
2518 IndicateServerInterestedFolk localfolk;
2519- localfolk.sender = sender;
2520+ localfolk.sender = (gchar *)sender; /* Okay to drop the const as we're only using this for searching */
2521
2522 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
2523
2524@@ -874,7 +1093,7 @@
2525 IndicateServerInterestedFolk * folkpointer = NULL;
2526 if (entry == NULL) {
2527 folkpointer = g_new0(IndicateServerInterestedFolk, 1);
2528- indicate_server_interested_folks_init(folkpointer, sender);
2529+ indicate_server_interested_folks_init(folkpointer, sender, INDICATE_LISTENER_OBJ_PATH, priv->connection);
2530 priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
2531 } else {
2532 folkpointer = (IndicateServerInterestedFolk *)entry->data;
2533@@ -944,12 +1163,12 @@
2534 /* Internal function to set the number of max indicators
2535 from a particular listener. */
2536 static gboolean
2537-max_indicators_set (IndicateServer * server, gchar * sender, gint max)
2538+max_indicators_set (IndicateServer * server, const gchar * sender, gint max)
2539 {
2540 g_return_val_if_fail(max >= MAX_INDICATORS_INFINITE, FALSE);
2541
2542 IndicateServerInterestedFolk localfolk;
2543- localfolk.sender = sender;
2544+ localfolk.sender = (gchar *)sender; /* Okay to drop the const as we're only using this for searching */
2545
2546 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
2547
2548@@ -960,7 +1179,7 @@
2549 IndicateServerInterestedFolk * folkpointer = NULL;
2550 if (entry == NULL) {
2551 folkpointer = g_new0(IndicateServerInterestedFolk, 1);
2552- indicate_server_interested_folks_init(folkpointer, sender);
2553+ indicate_server_interested_folks_init(folkpointer, sender, INDICATE_LISTENER_OBJ_PATH, priv->connection);
2554 priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
2555 } else {
2556 folkpointer = (IndicateServerInterestedFolk *)entry->data;
2557@@ -1030,6 +1249,15 @@
2558 {
2559 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
2560 priv->num_hidden--;
2561+ if (priv->registered != 0) {
2562+ g_dbus_connection_emit_signal(priv->connection,
2563+ NULL, /* dest */
2564+ priv->path,
2565+ INDICATE_DBUS_IFACE,
2566+ "IndicatorNew",
2567+ g_variant_new("(u)", indicate_indicator_get_id(indicator)),
2568+ NULL); /* error */
2569+ }
2570 g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), TRUE);
2571 return;
2572 }
2573@@ -1039,6 +1267,15 @@
2574 {
2575 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
2576 priv->num_hidden++;
2577+ if (priv->registered != 0) {
2578+ g_dbus_connection_emit_signal(priv->connection,
2579+ NULL, /* dest */
2580+ priv->path,
2581+ INDICATE_DBUS_IFACE,
2582+ "IndicatorDelete",
2583+ g_variant_new("(u)", indicate_indicator_get_id(indicator)),
2584+ NULL); /* error */
2585+ }
2586 g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), TRUE);
2587 return;
2588 }
2589@@ -1047,6 +1284,16 @@
2590 indicator_modified_cb (IndicateIndicator * indicator, gchar * property, IndicateServer * server)
2591 {
2592 /* g_debug("Indicator Modified: %d %s", indicate_indicator_get_id(indicator), property); */
2593+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
2594+ if (priv->registered != 0) {
2595+ g_dbus_connection_emit_signal(priv->connection,
2596+ NULL, /* dest */
2597+ priv->path,
2598+ INDICATE_DBUS_IFACE,
2599+ "IndicatorModified",
2600+ g_variant_new("(us)", indicate_indicator_get_id(indicator), property),
2601+ NULL); /* error */
2602+ }
2603 g_signal_emit(server, signals[INDICATOR_MODIFIED], 0, indicate_indicator_get_id(indicator), property, TRUE);
2604 }
2605
2606@@ -1073,6 +1320,15 @@
2607 if (!indicate_indicator_is_visible(indicator)) {
2608 priv->num_hidden++;
2609 } else {
2610+ if (priv->registered != 0) {
2611+ g_dbus_connection_emit_signal(priv->connection,
2612+ NULL, /* dest */
2613+ priv->path,
2614+ INDICATE_DBUS_IFACE,
2615+ "IndicatorNew",
2616+ g_variant_new("(u)", indicate_indicator_get_id(indicator)),
2617+ NULL); /* error */
2618+ }
2619 g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), TRUE);
2620 }
2621
2622@@ -1101,6 +1357,15 @@
2623
2624 priv->indicators = g_slist_remove(priv->indicators, indicator);
2625 if (indicate_indicator_is_visible(indicator)) {
2626+ if (priv->registered != 0) {
2627+ g_dbus_connection_emit_signal(priv->connection,
2628+ NULL, /* dest */
2629+ priv->path,
2630+ INDICATE_DBUS_IFACE,
2631+ "IndicatorDelete",
2632+ g_variant_new("(u)", indicate_indicator_get_id(indicator)),
2633+ NULL); /* error */
2634+ }
2635 g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), TRUE);
2636 } else {
2637 priv->num_hidden--;
2638@@ -1299,14 +1564,14 @@
2639 }
2640
2641 static gboolean
2642-get_indicator_property (IndicateServer * server, guint id, gchar * property, GValue * value, GError **error)
2643+get_indicator_property (IndicateServer * server, guint id, gchar * property, GVariant ** variant, GError **error)
2644 {
2645 IndicateIndicator * indicator = get_indicator(server, id, error);
2646 if (indicator == NULL) {
2647 return FALSE;
2648 }
2649
2650- const GValue * ind_property = indicate_indicator_get_property_value(indicator, property);
2651+ GVariant * ind_property = indicate_indicator_get_property_variant(indicator, property);
2652 if (ind_property == NULL) {
2653 if (error != NULL) {
2654 g_set_error(error,
2655@@ -1318,36 +1583,33 @@
2656 return FALSE;
2657 }
2658
2659- g_value_init(value, G_VALUE_TYPE(ind_property));
2660- g_value_copy(ind_property, value);
2661+ *variant = ind_property;
2662 return TRUE;
2663 }
2664
2665 static gboolean
2666-get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error)
2667+get_indicator_property_group (IndicateServer * server, guint id, const gchar ** properties, GVariant ** output, GError **error)
2668 {
2669 IndicateIndicator * indicator = get_indicator(server, id, error);
2670 if (indicator == NULL) {
2671 return FALSE;
2672 }
2673
2674- GPtrArray * array = g_ptr_array_new();
2675+ GVariantBuilder builder;
2676+ g_variant_builder_init(&builder, G_VARIANT_TYPE_DICTIONARY);
2677 int i;
2678- for (i = 0; i < properties->len; i++) {
2679- const GValue * ind_property = indicate_indicator_get_property_value(indicator, g_ptr_array_index(properties, i));
2680+ for (i = 0; properties[i] != NULL; i++) {
2681+ GVariant * ind_property = indicate_indicator_get_property_variant(indicator, properties[i]);
2682
2683 if (ind_property == NULL) {
2684 continue;
2685 }
2686
2687- GValue * value = g_new0(GValue, 1);
2688- g_value_init(value, G_VALUE_TYPE(ind_property));
2689- g_value_copy(ind_property, value);
2690-
2691- g_ptr_array_add(array, value);
2692+ GVariant * dictentry = g_variant_new_dict_entry(g_variant_new_string(properties[i]), ind_property);
2693+ g_variant_builder_add_value(&builder, dictentry);
2694 }
2695- g_ptr_array_add(array, NULL);
2696- *value = (gchar **)g_ptr_array_free(array, FALSE);
2697+
2698+ *output = g_variant_builder_end(&builder);
2699
2700 return TRUE;
2701 }
2702@@ -1392,10 +1654,10 @@
2703 just set that. If we're not, then we need to check to see
2704 if anyone else is before continuing. */
2705 static gboolean
2706-indicator_displayed (IndicateServer * server, gchar * sender, guint id, gboolean displayed, GError ** error)
2707+indicator_displayed (IndicateServer * server, const gchar * sender, guint id, gboolean displayed, GError ** error)
2708 {
2709 IndicateServerInterestedFolk localfolk;
2710- localfolk.sender = sender;
2711+ localfolk.sender = (gchar *)sender; /* Okay to drop the const as we're only using this for searching */
2712
2713 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
2714
2715@@ -1403,7 +1665,7 @@
2716 IndicateServerInterestedFolk * folkpointer = NULL;
2717 if (entry == NULL) {
2718 folkpointer = g_new0(IndicateServerInterestedFolk, 1);
2719- indicate_server_interested_folks_init(folkpointer, sender);
2720+ indicate_server_interested_folks_init(folkpointer, sender, INDICATE_LISTENER_OBJ_PATH, priv->connection);
2721 priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
2722 } else {
2723 folkpointer = (IndicateServerInterestedFolk *)entry->data;
2724@@ -1426,160 +1688,232 @@
2725 }
2726
2727 /* Virtual Functions */
2728-gboolean
2729-_indicate_interface_server_get_indicator_count (IndicateServer * server, guint * count, GError **error)
2730+static void
2731+bus_get_indicator_count (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
2732 {
2733 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
2734
2735 if (class != NULL && class->get_indicator_count != NULL) {
2736- return class->get_indicator_count (server, count, error);
2737+ guint count = 0;
2738+ GError * error = NULL;
2739+
2740+ class->get_indicator_count (server, &count, &error);
2741+
2742+ if (error != NULL) {
2743+ g_dbus_method_invocation_return_gerror(invocation, error);
2744+ g_error_free(error);
2745+ } else {
2746+ g_dbus_method_invocation_return_value(invocation,
2747+ g_variant_new("(u)", count));
2748+ }
2749+
2750+ return;
2751 }
2752
2753- if (error) {
2754- g_set_error(error,
2755+ g_dbus_method_invocation_return_error(invocation,
2756 indicate_server_error_quark(),
2757 NO_GET_INDICATOR_COUNT,
2758 "get_indicator_count function doesn't exist for this server class: %s",
2759 G_OBJECT_TYPE_NAME(server));
2760- return FALSE;
2761- }
2762-
2763- return TRUE;
2764+ return;
2765 }
2766
2767-gboolean
2768-_indicate_interface_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error)
2769+static void
2770+bus_get_indicator_list (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
2771 {
2772 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
2773
2774 if (class != NULL && class->get_indicator_list != NULL) {
2775- return class->get_indicator_list (server, indicators, error);
2776+ GArray * array = NULL;
2777+ GError * error = NULL;
2778+
2779+ class->get_indicator_list (server, &array, &error);
2780+
2781+ if (error != NULL) {
2782+ g_dbus_method_invocation_return_gerror(invocation, error);
2783+ g_error_free(error);
2784+ } else {
2785+ GVariantBuilder builder;
2786+ g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
2787+
2788+ int i;
2789+ for (i = 0; array != NULL && i < array->len; i++) {
2790+ g_variant_builder_add_value(&builder, g_variant_new_int32(g_array_index(array, gint, i)));
2791+ }
2792+
2793+ GVariant * retval = g_variant_builder_end(&builder);
2794+ g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(&retval, 1));
2795+
2796+ g_array_free(array, TRUE);
2797+ }
2798+
2799+ return;
2800 }
2801
2802- if (error) {
2803- g_set_error(error,
2804+ g_dbus_method_invocation_return_error(invocation,
2805 indicate_server_error_quark(),
2806 NO_GET_INDICATOR_LIST,
2807 "get_indicator_list function doesn't exist for this server class: %s",
2808 G_OBJECT_TYPE_NAME(server));
2809- return FALSE;
2810- }
2811-
2812- return TRUE;
2813+ return;
2814 }
2815
2816-gboolean
2817-_indicate_interface_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, GValue * value, GError **error)
2818+static void
2819+bus_get_indicator_property (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
2820 {
2821 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
2822
2823 if (class != NULL && class->get_indicator_property != NULL) {
2824- return class->get_indicator_property (server, id, property, value, error);
2825+ guint id;
2826+ gchar * property;
2827+ GVariant * variant;
2828+ GError * error = NULL;
2829+
2830+ g_variant_get(params, "(us)", &id, &property);
2831+
2832+ class->get_indicator_property (server, id, property, &variant, &error);
2833+
2834+ g_free(property);
2835+ if (error != NULL) {
2836+ g_dbus_method_invocation_return_gerror(invocation, error);
2837+ } else {
2838+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(v)", variant));
2839+ }
2840+
2841+ return;
2842 }
2843
2844- if (error) {
2845- g_set_error(error,
2846+ g_dbus_method_invocation_return_error(invocation,
2847 indicate_server_error_quark(),
2848 NO_GET_INDICATOR_PROPERTY,
2849 "get_indicator_property function doesn't exist for this server class: %s",
2850 G_OBJECT_TYPE_NAME(server));
2851- return FALSE;
2852- }
2853-
2854- return TRUE;
2855+ return;
2856 }
2857
2858-gboolean
2859-_indicate_interface_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error)
2860+static void
2861+bus_get_indicator_property_group (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
2862 {
2863 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
2864
2865 if (class != NULL && class->get_indicator_property_group != NULL) {
2866- return class->get_indicator_property_group (server, id, properties, value, error);
2867+ guint id = g_variant_get_uint32(g_variant_get_child_value(params, 0));;
2868+ const gchar ** props = g_variant_get_strv(g_variant_get_child_value(params, 1), NULL);
2869+ GVariant * output;
2870+ GError * error = NULL;
2871+
2872+ class->get_indicator_property_group (server, id, props, &output, &error);
2873+
2874+ if (error != NULL) {
2875+ g_dbus_method_invocation_return_gerror(invocation, error);
2876+ g_error_free(error);
2877+ } else {
2878+ g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(&output, 1));
2879+ }
2880+
2881+ return;
2882 }
2883
2884- if (error) {
2885- g_set_error(error,
2886+ g_dbus_method_invocation_return_error(invocation,
2887 indicate_server_error_quark(),
2888 NO_GET_INDICATOR_PROPERTY_GROUP,
2889 "get_indicator_property_group function doesn't exist for this server class: %s",
2890 G_OBJECT_TYPE_NAME(server));
2891- return FALSE;
2892- }
2893-
2894- return TRUE;
2895+ return;
2896 }
2897
2898-gboolean
2899-_indicate_interface_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error)
2900+static void
2901+bus_get_indicator_properties (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
2902 {
2903 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
2904
2905 if (class != NULL && class->get_indicator_properties != NULL) {
2906- return class->get_indicator_properties (server, id, properties, error);
2907+ guint id = g_variant_get_uint32(g_variant_get_child_value(params, 0));
2908+ gchar ** props = NULL;
2909+ GError * error = NULL;
2910+
2911+ class->get_indicator_properties (server, id, &props, &error);
2912+
2913+ if (error != NULL) {
2914+ g_dbus_method_invocation_return_gerror(invocation, error);
2915+ g_error_free(error);
2916+ } else {
2917+ GVariant * retvals = g_variant_new_strv((const gchar * const *)props, -1);
2918+ g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(&retvals, 1));
2919+ g_strfreev(props);
2920+ }
2921+
2922+ return;
2923 }
2924
2925- if (error) {
2926- g_set_error(error,
2927+ g_dbus_method_invocation_return_error(invocation,
2928 indicate_server_error_quark(),
2929 NO_GET_INDICATOR_PROPERTIES,
2930 "get_indicator_properties function doesn't exist for this server class: %s",
2931 G_OBJECT_TYPE_NAME(server));
2932- return FALSE;
2933- }
2934-
2935- return TRUE;
2936+ return;
2937 }
2938
2939-gboolean
2940-_indicate_interface_server_show_indicator_to_user (IndicateServer * server, guint id, guint timestamp, GError ** error)
2941+static void
2942+bus_show_indicator_to_user (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
2943 {
2944 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
2945
2946 if (class != NULL && class->show_indicator_to_user != NULL) {
2947- return class->show_indicator_to_user (server, id, timestamp, error);
2948+ GError * error = NULL;
2949+ guint id, timestamp;
2950+ g_variant_get(params, "(uu)", &id, &timestamp);
2951+
2952+ class->show_indicator_to_user (server, id, timestamp, &error);
2953+
2954+ if (error != NULL) {
2955+ g_dbus_method_invocation_return_gerror(invocation, error);
2956+ g_error_free(error);
2957+ } else {
2958+ g_dbus_method_invocation_return_value(invocation, NULL);
2959+ }
2960+
2961+ return;
2962 }
2963
2964- if (error) {
2965- g_set_error(error,
2966+ g_dbus_method_invocation_return_error(invocation,
2967 indicate_server_error_quark(),
2968 NO_SHOW_INDICATOR_TO_USER,
2969 "show_indicator_to_user function doesn't exist for this server class: %s",
2970 G_OBJECT_TYPE_NAME(server));
2971- return FALSE;
2972- }
2973-
2974- return TRUE;
2975+ return;
2976 }
2977
2978 /* DBus function to wrap a virtual function call so that
2979 it can be subclassed if someone so chooses */
2980-gboolean
2981-_indicate_interface_server_indicator_displayed (IndicateServer * server, guint id, gboolean displayed, DBusGMethodInvocation * method)
2982+static void
2983+bus_indicator_displayed (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
2984 {
2985 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
2986
2987 if (class != NULL && class->indicator_displayed != NULL) {
2988 GError * error = NULL;
2989- if (class->indicator_displayed (server, dbus_g_method_get_sender(method), id, displayed, &error)) {
2990- dbus_g_method_return(method);
2991- return TRUE;
2992+ guint id;
2993+ gboolean displayed;
2994+
2995+ g_variant_get(params, "(ub)", &id, &displayed);
2996+
2997+ if (class->indicator_displayed (server, g_dbus_method_invocation_get_sender(invocation), id, displayed, &error)) {
2998+ g_dbus_method_invocation_return_value(invocation, NULL);
2999 } else {
3000- dbus_g_method_return_error(method, error);
3001+ g_dbus_method_invocation_return_gerror(invocation, error);
3002 g_error_free(error);
3003- return FALSE;
3004 }
3005+
3006+ return;
3007 }
3008
3009- GError * error = NULL;
3010- g_set_error(&error,
3011+ g_dbus_method_invocation_return_error(invocation,
3012 indicate_server_error_quark(),
3013 NO_INDICATOR_DISPLAYED,
3014 "indicator_displayed function doesn't exist for this server class: %s",
3015 G_OBJECT_TYPE_NAME(server));
3016- dbus_g_method_return_error(method, error);
3017- g_error_free(error);
3018- return FALSE;
3019+ return;
3020 }
3021
3022 /**
3023@@ -1604,7 +1938,7 @@
3024 }
3025
3026 static IndicateInterests
3027-interest_string_to_enum (gchar * interest_string)
3028+interest_string_to_enum (const gchar * interest_string)
3029 {
3030 if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_SERVER_DISPLAY)) {
3031 return INDICATE_INTEREST_SERVER_DISPLAY;
3032@@ -1629,103 +1963,95 @@
3033 return INDICATE_INTEREST_NONE;
3034 }
3035
3036-gboolean
3037-_indicate_interface_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method)
3038+static void
3039+bus_show_interest (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
3040 {
3041 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
3042
3043 if (class != NULL && class->show_interest != NULL) {
3044- if (class->show_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){
3045- dbus_g_method_return(method);
3046- return TRUE;
3047+ const gchar * interest = NULL;
3048+
3049+ interest = g_variant_get_string(g_variant_get_child_value(params, 0), NULL);
3050+
3051+ if (class->show_interest (server, g_dbus_method_invocation_get_sender(invocation), interest_string_to_enum(interest))){
3052+ g_dbus_method_invocation_return_value(invocation, NULL);
3053 } else {
3054- GError * error;
3055- g_set_error(&error,
3056+ g_dbus_method_invocation_return_error(invocation,
3057 indicate_server_error_quark(),
3058 SHOW_INTEREST_FAILED,
3059 "Unable to show interest: %s",
3060 interest);
3061- dbus_g_method_return_error(method, error);
3062- g_error_free(error);
3063- return FALSE;
3064 }
3065+
3066+ return;
3067 }
3068
3069- GError * error;
3070- g_set_error(&error,
3071+ g_dbus_method_invocation_return_error(invocation,
3072 indicate_server_error_quark(),
3073 NO_SHOW_INTEREST,
3074 "show_interest function doesn't exist for this server class: %s",
3075 G_OBJECT_TYPE_NAME(server));
3076- dbus_g_method_return_error(method, error);
3077- g_error_free(error);
3078- return FALSE;
3079+ return;
3080 }
3081
3082-gboolean
3083-_indicate_interface_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method)
3084+static void
3085+bus_remove_interest (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
3086 {
3087 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
3088
3089 if (class != NULL && class->remove_interest != NULL) {
3090- if (class->remove_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){
3091- dbus_g_method_return(method);
3092- return TRUE;
3093+ const gchar * interest = NULL;
3094+
3095+ interest = g_variant_get_string(g_variant_get_child_value(params, 0), NULL);
3096+
3097+ if (class->remove_interest (server, g_dbus_method_invocation_get_sender(invocation), interest_string_to_enum(interest))){
3098+ g_dbus_method_invocation_return_value(invocation, NULL);
3099 } else {
3100- GError * error;
3101- g_set_error(&error,
3102+ g_dbus_method_invocation_return_error(invocation,
3103 indicate_server_error_quark(),
3104 REMOVE_INTEREST_FAILED,
3105 "Unable to remove interest: %s",
3106 interest);
3107- dbus_g_method_return_error(method, error);
3108- g_error_free(error);
3109- return FALSE;
3110 }
3111+
3112+ return;
3113 }
3114
3115- GError * error;
3116- g_set_error(&error,
3117+ g_dbus_method_invocation_return_error(invocation,
3118 indicate_server_error_quark(),
3119 NO_REMOVE_INTEREST,
3120 "remove_interest function doesn't exist for this server class: %s",
3121 G_OBJECT_TYPE_NAME(server));
3122- dbus_g_method_return_error(method, error);
3123- g_error_free(error);
3124- return FALSE;
3125+ return;
3126 }
3127
3128-gboolean
3129-_indicate_interface_server_set_max_indicators (IndicateServer * server, gint max, DBusGMethodInvocation * method)
3130+static void
3131+bus_set_max_indicators (IndicateServer * server, GVariant * params, GDBusMethodInvocation * invocation)
3132 {
3133 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
3134
3135 if (class != NULL && class->max_indicators_set != NULL) {
3136- if (class->max_indicators_set (server, dbus_g_method_get_sender(method), max)){
3137- dbus_g_method_return(method);
3138- return TRUE;
3139+ gint max = g_variant_get_int32(g_variant_get_child_value(params, 0));
3140+
3141+ if (class->max_indicators_set (server, g_dbus_method_invocation_get_sender(invocation), max)){
3142+ g_dbus_method_invocation_return_value(invocation, NULL);
3143 } else {
3144- GError * error;
3145- g_set_error(&error,
3146+ g_dbus_method_invocation_return_error(invocation,
3147 indicate_server_error_quark(),
3148 MAX_INDICATORS_SET_FAILED,
3149 "Unable to set max indicators: %d",
3150 max);
3151- dbus_g_method_return_error(method, error);
3152- g_error_free(error);
3153- return FALSE;
3154 }
3155+
3156+ return;
3157 }
3158
3159- GError * error;
3160- g_set_error(&error,
3161+ g_dbus_method_invocation_return_error(invocation,
3162 indicate_server_error_quark(),
3163 NO_MAX_INDICATORS_SET,
3164 "max_indicators_set function doesn't exist for this server class: %s",
3165 G_OBJECT_TYPE_NAME(server));
3166- dbus_g_method_return_error(method, error);
3167- g_error_free(error);
3168- return FALSE;
3169+ return;
3170 }
3171
3172 /**
3173@@ -1824,7 +2150,7 @@
3174 /* Creates a IndicateServerInterestedFolk structure and
3175 initializes the default values to reasonable defaults. */
3176 static void
3177-indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender)
3178+indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, const gchar * sender, const gchar * path, GDBusConnection * connection)
3179 {
3180 folk->sender = g_strdup(sender);
3181
3182@@ -1837,6 +2163,101 @@
3183
3184 folk->indicators_displayed = g_hash_table_new(g_direct_hash, g_direct_equal);
3185
3186+ g_dbus_proxy_new(connection,
3187+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
3188+ bus_interface_info,
3189+ sender,
3190+ path,
3191+ INDICATE_LISTENER_DBUS_IFACE,
3192+ NULL, /* TODO: cancelable */
3193+ folk_proxy_cb,
3194+ folk);
3195+
3196+ return;
3197+}
3198+
3199+/* Look at when the name owner changes so that we can figure out
3200+ if we need to delete the folks item */
3201+static void
3202+folks_name_owner_change (GObject * object, GParamSpec * pspec, gpointer user_data)
3203+{
3204+ gchar * name = g_dbus_proxy_get_name_owner(G_DBUS_PROXY(object));
3205+ if (name != NULL) {
3206+ /* What? Well, no matter, we don't care if it's there, we'll
3207+ just ignore this signal and move on. */
3208+ g_free(name);
3209+ return;
3210+ }
3211+
3212+ /* g_debug("\tBeing removed, interesting"); */
3213+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(user_data);
3214+
3215+ IndicateServerInterestedFolk searchitem;
3216+ searchitem.sender = (gchar *)name;
3217+ GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal);
3218+
3219+ if (entry == NULL) {
3220+ /* g_debug("\tWe don't have it, not interesting"); */
3221+ return;
3222+ }
3223+
3224+ IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)entry->data;
3225+ priv->interestedfolks = g_list_remove(priv->interestedfolks, entry->data);
3226+
3227+ guint i;
3228+ for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
3229+ priv->interests[i] = FALSE;
3230+ }
3231+
3232+ GList * listi = NULL;
3233+ for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) {
3234+ IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data;
3235+ /* g_debug("\tRebuild list from folk: %s", folkpointer->sender); */
3236+ indicate_server_interested_folks_copy(folkpointer, priv->interests);
3237+ }
3238+
3239+ for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
3240+ /* g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); */
3241+ if (folk->interests[i] && !priv->interests[i]) {
3242+ /* We can only remove interest here. Think about it for a
3243+ moment and I think you'll be cool with it. */
3244+ /* g_debug("\tOh, and it was interested in %d. Not anymore.", i); */
3245+ g_signal_emit(G_OBJECT(user_data), signals[INTEREST_REMOVED], 0, i, TRUE);
3246+ }
3247+ }
3248+
3249+ /* If the retired folk has set it's max indicators
3250+ and it's the value we're using, we need to recalculate */
3251+ if (folk->max_indicators != MAX_INDICATORS_UNSET && folk->max_indicators == priv->max_indicators) {
3252+ recalculate_max_indicators(user_data);
3253+ }
3254+
3255+ g_hash_table_foreach(folk->indicators_displayed, indicator_display_check_recalc, INDICATE_SERVER(user_data));
3256+
3257+ /* Finally destory everything */
3258+ indicate_server_interested_folks_destroy(folk);
3259+ return;
3260+
3261+}
3262+
3263+/* Callback for creating the proxy on the folks object */
3264+static void
3265+folk_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
3266+{
3267+ GError * error = NULL;
3268+
3269+ GDBusProxy * proxy = g_dbus_proxy_new_finish(res, &error);
3270+ if (error != NULL) {
3271+ g_warning("Unable to get folks proxy!");
3272+ g_error_free(error);
3273+ return;
3274+ }
3275+
3276+ IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)user_data;
3277+ folk->proxy = proxy;
3278+
3279+ g_signal_connect(G_OBJECT(proxy), "notify::g-name-owner", G_CALLBACK(folks_name_owner_change), folk);
3280+
3281 return;
3282 }
3283
3284@@ -1870,6 +2291,11 @@
3285 {
3286 g_free(folk->sender);
3287 g_hash_table_destroy(folk->indicators_displayed);
3288+
3289+ if (folk->proxy != NULL) {
3290+ g_object_unref(folk->proxy);
3291+ }
3292+
3293 g_free(folk);
3294 return;
3295 }
3296
3297=== modified file 'libindicate/server.h'
3298--- libindicate/server.h 2010-06-04 19:28:17 +0000
3299+++ libindicate/server.h 2011-01-13 22:48:19 +0000
3300@@ -112,7 +112,7 @@
3301 * Return value: Whether the call was successful in getting the
3302 * properties requested.
3303 */
3304-typedef gboolean (*indicate_server_get_indicator_property_group_slot_t) (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);
3305+typedef gboolean (*indicate_server_get_indicator_property_group_slot_t) (IndicateServer * server, guint id, const gchar ** properties, GVariant ** value, GError **error);
3306
3307 /**
3308 * indicate_server_get_indicator_properties_slot_t:
3309@@ -192,16 +192,16 @@
3310 /* Virtual Functions */
3311 gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error);
3312 indicate_server_get_indicator_list_slot_t get_indicator_list;
3313- gboolean (*get_indicator_property) (IndicateServer * server, guint id, gchar * property, GValue * value, GError **error);
3314+ gboolean (*get_indicator_property) (IndicateServer * server, guint id, gchar * property, GVariant ** value, GError **error);
3315 indicate_server_get_indicator_property_group_slot_t get_indicator_property_group;
3316 indicate_server_get_indicator_properties_slot_t get_indicator_properties;
3317 gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, guint timestamp, GError ** error);
3318- gboolean (*indicator_displayed) (IndicateServer * server, gchar * sender, guint id, gboolean displayed, GError ** error);
3319+ gboolean (*indicator_displayed) (IndicateServer * server, const gchar * sender, guint id, gboolean displayed, GError ** error);
3320 guint (*get_next_id) (IndicateServer * server);
3321- gboolean (*show_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest);
3322- gboolean (*remove_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest);
3323+ gboolean (*show_interest) (IndicateServer * server, const gchar * sender, IndicateInterests interest);
3324+ gboolean (*remove_interest) (IndicateServer * server, const gchar * sender, IndicateInterests interest);
3325 gboolean (*check_interest) (IndicateServer * server, IndicateInterests interest);
3326- gboolean (*max_indicators_set) (IndicateServer * server, gchar * sender, gint max);
3327+ gboolean (*max_indicators_set) (IndicateServer * server, const gchar * sender, gint max);
3328 gint (*max_indicators_get) (IndicateServer * server);
3329
3330 /* Reserver for future use */
3331
3332=== modified file 'm4/introspection.m4'
3333--- m4/introspection.m4 2009-10-11 15:05:13 +0000
3334+++ m4/introspection.m4 2011-01-13 22:48:19 +0000
3335@@ -59,12 +59,18 @@
3336 INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
3337 INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
3338 INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
3339+ INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
3340+ INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
3341+ INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
3342 fi
3343 AC_SUBST(INTROSPECTION_SCANNER)
3344 AC_SUBST(INTROSPECTION_COMPILER)
3345 AC_SUBST(INTROSPECTION_GENERATE)
3346 AC_SUBST(INTROSPECTION_GIRDIR)
3347 AC_SUBST(INTROSPECTION_TYPELIBDIR)
3348+ AC_SUBST(INTROSPECTION_CFLAGS)
3349+ AC_SUBST(INTROSPECTION_LIBS)
3350+ AC_SUBST(INTROSPECTION_MAKEFILE)
3351
3352 AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
3353 ])

Subscribers

People subscribed via source and target branches

to all changes: