Merge lp://qastaging/~ted/libindicator/service-version-number into lp://qastaging/libindicator/0.4

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~ted/libindicator/service-version-number
Merge into: lp://qastaging/libindicator/0.4
Diff against target: 662 lines (+341/-23)
14 files modified
.bzrignore (+6/-0)
libindicator/Makefile.am (+1/-0)
libindicator/indicator-service-manager.c (+42/-13)
libindicator/indicator-service-manager.h (+2/-0)
libindicator/indicator-service.c (+44/-1)
libindicator/indicator-service.h (+3/-1)
libindicator/indicator-service.xml (+2/-1)
tests/Makefile.am (+73/-7)
tests/service-version-bad-service.c (+47/-0)
tests/service-version-bad.service.in (+3/-0)
tests/service-version-good-service.c (+47/-0)
tests/service-version-good.service.in (+3/-0)
tests/service-version-manager.c (+64/-0)
tests/service-version-values.h (+4/-0)
To merge this branch: bzr merge lp://qastaging/~ted/libindicator/service-version-number
Reviewer Review Type Date Requested Status
David Barth Approve
Review via email: mp+15631@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

Adding in the ability to have a service API version independent of just the service API version. This will make upgrades cleaner.

Note: The tests won't pass unless you have the latest version of dbus-test-runner installed. It has some fixes that were discovered by this test suite :)

Revision history for this message
David Barth (dbarth) wrote :

LGTM.

There is a small typo around
@@ -257,9 +268,15 @@
...
+ g_warning("Service is using a API version than the manager. Expecting %d and got %d.", priv->this_service_version, this_service_version);

should read "... is using a /different/ API..."

review: Approve
351. By Ted Gould

Fixing a typo in the error message -- noticed by David Barth.

Revision history for this message
Ted Gould (ted) wrote :

On Mon, 2009-12-07 at 08:38 +0000, David Barth wrote:
> There is a small typo around
> @@ -257,9 +268,15 @@
> ....
> + g_warning("Service is using a API version than the manager. Expecting %d and got %d.", priv->this_service_version, this_service_version);
>
> should read "... is using a /different/ API..."

Fixed r351.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2009-12-01 19:37:00 +0000
3+++ .bzrignore 2009-12-07 19:09:09 +0000
4@@ -135,5 +135,11 @@
5 tests/session.conf
6 tests/service-manager-connect.service
7 tools/indicator-loader
8+tests/service-version-bad-service
9+tests/service-version-bad.service
10+tests/service-version-good-service
11+tests/service-version-good.service
12+tests/service-version-manager
13+tests/service-version-tester
14 tests/service-manager-connect-nostart-tester
15 tests/service-manager-nostart-connect
16
17=== modified file 'libindicator/Makefile.am'
18--- libindicator/Makefile.am 2009-11-04 17:34:44 +0000
19+++ libindicator/Makefile.am 2009-12-07 19:09:09 +0000
20@@ -26,6 +26,7 @@
21
22 libindicator_la_CFLAGS = \
23 $(LIBINDICATOR_CFLAGS) \
24+ -DG_LOG_DOMAIN=\"libindicator\" \
25 -Wall -Werror
26
27 libindicator_la_LIBADD = \
28
29=== modified file 'libindicator/indicator-service-manager.c'
30--- libindicator/indicator-service-manager.c 2009-12-01 22:07:26 +0000
31+++ libindicator/indicator-service-manager.c 2009-12-07 19:09:09 +0000
32@@ -16,6 +16,7 @@
33 DBusGProxy * dbus_proxy;
34 DBusGProxy * service_proxy;
35 gboolean connected;
36+ guint this_service_version;
37 DBusGConnection * bus;
38 };
39
40@@ -34,10 +35,12 @@
41 enum {
42 PROP_0,
43 PROP_NAME,
44+ PROP_VERSION
45 };
46
47 /* The strings so that they can be slowly looked up. */
48 #define PROP_NAME_S "name"
49+#define PROP_VERSION_S "version"
50
51 /* GObject Stuff */
52 #define INDICATOR_SERVICE_MANAGER_GET_PRIVATE(o) \
53@@ -52,7 +55,6 @@
54 static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec);
55 static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec);
56 static void start_service (IndicatorServiceManager * service);
57-static void unwatch_cb (DBusGProxy *proxy, GError *error, gpointer userdata);
58
59 G_DEFINE_TYPE (IndicatorServiceManager, indicator_service_manager, G_TYPE_OBJECT);
60
61@@ -93,6 +95,12 @@
62 "This is the name that should be used to start a service.",
63 NULL,
64 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
65+ g_object_class_install_property(object_class, PROP_VERSION,
66+ g_param_spec_uint(PROP_VERSION_S,
67+ "The version of the service that we're expecting.",
68+ "A number to check and reject a service if it gives us the wrong number. This should match across the manager and the service",
69+ 0, G_MAXUINT, 0,
70+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
71
72 return;
73 }
74@@ -107,13 +115,14 @@
75 priv->dbus_proxy = NULL;
76 priv->service_proxy = NULL;
77 priv->connected = FALSE;
78+ priv->this_service_version = 0;
79 priv->bus = NULL;
80
81 /* Start talkin' dbus */
82 GError * error = NULL;
83 priv->bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
84 if (error != NULL) {
85- g_error("Unable to get session bus: %s", error->message);
86+ g_error("Unable to get session bus for manager: %s", error->message);
87 g_error_free(error);
88 return;
89 }
90@@ -153,7 +162,7 @@
91 /* If we have a proxy, tell it we're shutting down. Just
92 to be polite about it. */
93 if (priv->service_proxy != NULL) {
94- org_ayatana_indicator_service_un_watch_async(priv->service_proxy, unwatch_cb, NULL);
95+ dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID);
96 }
97
98 /* Destory our service proxy, we won't need it. */
99@@ -205,6 +214,10 @@
100 }
101 break;
102 /* *********************** */
103+ case PROP_VERSION:
104+ priv->this_service_version = g_value_get_uint(value);
105+ break;
106+ /* *********************** */
107 default:
108 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
109 break;
110@@ -232,6 +245,10 @@
111 }
112 break;
113 /* *********************** */
114+ case PROP_VERSION:
115+ g_value_set_uint(value, priv->this_service_version);
116+ break;
117+ /* *********************** */
118 default:
119 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
120 break;
121@@ -241,13 +258,7 @@
122 }
123
124 static void
125-unwatch_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
126-{
127- return;
128-}
129-
130-static void
131-watch_cb (DBusGProxy * proxy, gint service_version, GError * error, gpointer user_data)
132+watch_cb (DBusGProxy * proxy, guint service_api_version, guint this_service_version, GError * error, gpointer user_data)
133 {
134 IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data);
135
136@@ -257,9 +268,15 @@
137 return;
138 }
139
140- if (service_version != INDICATOR_SERVICE_VERSION) {
141- g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_version);
142- org_ayatana_indicator_service_un_watch_async(priv->service_proxy, unwatch_cb, NULL);
143+ if (service_api_version != INDICATOR_SERVICE_VERSION) {
144+ g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_api_version);
145+ dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID);
146+ return;
147+ }
148+
149+ if (this_service_version != priv->this_service_version) {
150+ g_warning("Service is using a different API version than the manager. Expecting %d and got %d.", priv->this_service_version, this_service_version);
151+ dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID);
152 return;
153 }
154
155@@ -292,6 +309,7 @@
156 INDICATOR_SERVICE_OBJECT,
157 INDICATOR_SERVICE_INTERFACE,
158 &error);
159+ g_object_add_weak_pointer(G_OBJECT(priv->service_proxy), (gpointer *)&(priv->service_proxy));
160
161 org_ayatana_indicator_service_watch_async(priv->service_proxy,
162 watch_cb,
163@@ -347,6 +365,17 @@
164 return INDICATOR_SERVICE_MANAGER(obj);
165 }
166
167+IndicatorServiceManager *
168+indicator_service_manager_new_version (gchar * dbus_name, guint version)
169+{
170+ GObject * obj = g_object_new(INDICATOR_SERVICE_MANAGER_TYPE,
171+ PROP_NAME_S, dbus_name,
172+ PROP_VERSION_S, version,
173+ NULL);
174+
175+ return INDICATOR_SERVICE_MANAGER(obj);
176+}
177+
178 gboolean
179 indicator_service_manager_connected (IndicatorServiceManager * sm)
180 {
181
182=== modified file 'libindicator/indicator-service-manager.h'
183--- libindicator/indicator-service-manager.h 2009-10-29 14:56:39 +0000
184+++ libindicator/indicator-service-manager.h 2009-12-07 19:09:09 +0000
185@@ -54,6 +54,8 @@
186 GType indicator_service_manager_get_type (void);
187
188 IndicatorServiceManager * indicator_service_manager_new (gchar * dbus_name);
189+IndicatorServiceManager * indicator_service_manager_new_version (gchar * dbus_name,
190+ guint version);
191 gboolean indicator_service_manager_connected (IndicatorServiceManager * sm);
192 void indicator_service_manager_set_refresh (IndicatorServiceManager * sm,
193 guint time_in_ms);
194
195=== modified file 'libindicator/indicator-service.c'
196--- libindicator/indicator-service.c 2009-12-01 16:12:51 +0000
197+++ libindicator/indicator-service.c 2009-12-07 19:09:09 +0000
198@@ -21,6 +21,7 @@
199 DBusGProxy * dbus_proxy;
200 guint timeout;
201 GList * watchers;
202+ guint this_service_version;
203 };
204
205 /* Signals Stuff */
206@@ -37,10 +38,12 @@
207 enum {
208 PROP_0,
209 PROP_NAME,
210+ PROP_VERSION
211 };
212
213 /* The strings so that they can be slowly looked up. */
214 #define PROP_NAME_S "name"
215+#define PROP_VERSION_S "version"
216
217 /* GObject Stuff */
218 #define INDICATOR_SERVICE_GET_PRIVATE(o) \
219@@ -79,6 +82,12 @@
220 "This is the name that should be used on DBus for this service.",
221 NULL,
222 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
223+ g_object_class_install_property(object_class, PROP_VERSION,
224+ g_param_spec_uint(PROP_VERSION_S,
225+ "The version of the service that we're implementing.",
226+ "A number to represent the version of the other APIs the service provides. This should match across the manager and the service",
227+ 0, G_MAXUINT, 0,
228+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
229
230 /* Signals */
231
232@@ -114,6 +123,7 @@
233 priv->dbus_proxy = NULL;
234 priv->timeout = 0;
235 priv->watchers = NULL;
236+ priv->this_service_version = 0;
237
238 /* Start talkin' dbus */
239 GError * error = NULL;
240@@ -214,6 +224,10 @@
241 }
242 break;
243 /* *********************** */
244+ case PROP_VERSION:
245+ priv->this_service_version = g_value_get_uint(value);
246+ break;
247+ /* *********************** */
248 default:
249 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
250 break;
251@@ -241,6 +255,10 @@
252 }
253 break;
254 /* *********************** */
255+ case PROP_VERSION:
256+ g_value_set_uint(value, priv->this_service_version);
257+ break;
258+ /* *********************** */
259 default:
260 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
261 break;
262@@ -306,7 +324,7 @@
263 priv->timeout = 0;
264 }
265
266- dbus_g_method_return(method, INDICATOR_SERVICE_VERSION);
267+ dbus_g_method_return(method, INDICATOR_SERVICE_VERSION, priv->this_service_version);
268 return TRUE;
269 }
270
271@@ -374,3 +392,28 @@
272
273 return INDICATOR_SERVICE(obj);
274 }
275+
276+/**
277+ indicator_service_new_version:
278+ @name: The name for the service on dbus
279+ @version: The version of the other interfaces provide
280+ by the service.
281+
282+ This function creates the service on DBus and tries to
283+ get a well-known name specified in @name. If the name
284+ can't be estabilished then the #IndicatorService::shutdown
285+ signal will be sent.
286+
287+ Return value: A brand new #IndicatorService object or #NULL
288+ if there is an error.
289+*/
290+IndicatorService *
291+indicator_service_new_version (gchar * name, guint version)
292+{
293+ GObject * obj = g_object_new(INDICATOR_SERVICE_TYPE,
294+ PROP_NAME_S, name,
295+ PROP_VERSION_S, version,
296+ NULL);
297+
298+ return INDICATOR_SERVICE(obj);
299+}
300
301=== modified file 'libindicator/indicator-service.h'
302--- libindicator/indicator-service.h 2009-10-29 16:33:37 +0000
303+++ libindicator/indicator-service.h 2009-12-07 19:09:09 +0000
304@@ -53,7 +53,9 @@
305
306 GType indicator_service_get_type (void);
307
308-IndicatorService * indicator_service_new (gchar * name);
309+IndicatorService * indicator_service_new (gchar * name);
310+IndicatorService * indicator_service_new_version (gchar * name,
311+ guint version);
312
313 G_END_DECLS
314
315
316=== modified file 'libindicator/indicator-service.xml'
317--- libindicator/indicator-service.xml 2009-12-01 15:58:05 +0000
318+++ libindicator/indicator-service.xml 2009-12-07 19:09:09 +0000
319@@ -7,7 +7,8 @@
320 <!-- Methods -->
321 <method name="Watch">
322 <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
323- <arg type="i" name="version" direction="out" />
324+ <arg type="u" name="version" direction="out" />
325+ <arg type="u" name="service_version" direction="out" />
326 </method>
327 <method name="UnWatch">
328 <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
329
330=== modified file 'tests/Makefile.am'
331--- tests/Makefile.am 2009-12-01 19:35:30 +0000
332+++ tests/Makefile.am 2009-12-07 19:09:09 +0000
333@@ -1,13 +1,7 @@
334 TESTS =
335 DISTCLEANFILES =
336
337-check_PROGRAMS = \
338- test-loader \
339- service-manager-no-connect \
340- service-manager-connect \
341- service-manager-connect-service \
342- service-manager-nostart-connect \
343- service-shutdown-timeout
344+check_PROGRAMS =
345
346 lib_LTLIBRARIES = \
347 libdummy-indicator-blank.la \
348@@ -21,6 +15,8 @@
349 # Test Loader
350 #############################
351
352+check_PROGRAMS += test-loader
353+
354 test_loader_SOURCES = \
355 test-loader.c
356
357@@ -118,6 +114,8 @@
358 # Service Shutdown Timeout
359 #############################
360
361+check_PROGRAMS += service-shutdown-timeout
362+
363 service_shutdown_timeout_SOURCES = \
364 service-shutdown-timeout.c
365
366@@ -141,6 +139,8 @@
367 # Service Manager No Connect
368 #############################
369
370+check_PROGRAMS += service-manager-no-connect
371+
372 service_manager_no_connect_SOURCES = \
373 service-manager-no-connect.c
374
375@@ -170,6 +170,8 @@
376 service-manager-connect.service: $(srcdir)/service-manager-connect.service.in Makefile.am
377 sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@
378
379+check_PROGRAMS += service-manager-connect
380+
381 service_manager_connect_SOURCES = \
382 service-manager-connect.c
383
384@@ -181,6 +183,8 @@
385 $(LIBINDICATOR_LIBS) \
386 $(top_builddir)/libindicator/.libs/libindicator.a
387
388+check_PROGRAMS += service-manager-connect-service
389+
390 service_manager_connect_service_SOURCES = \
391 service-manager-connect-service.c
392
393@@ -201,9 +205,71 @@
394 DISTCLEANFILES += service-manager-connect-tester session.conf service-manager-connect.service
395
396 #############################
397+# Service Versions
398+#############################
399+
400+service-version-good.service: $(srcdir)/service-version-good.service.in Makefile.am
401+ sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@
402+
403+service-version-bad.service: $(srcdir)/service-version-bad.service.in Makefile.am
404+ sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@
405+
406+check_PROGRAMS += service-version-manager
407+
408+service_version_manager_SOURCES = \
409+ service-version-values.h \
410+ service-version-manager.c
411+
412+service_version_manager_CFLAGS = \
413+ -Wall -Werror \
414+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
415+
416+service_version_manager_LDADD = \
417+ $(LIBINDICATOR_LIBS) \
418+ $(top_builddir)/libindicator/.libs/libindicator.a
419+
420+check_PROGRAMS += service-version-bad-service
421+
422+service_version_bad_service_SOURCES = \
423+ service-version-values.h \
424+ service-version-bad-service.c
425+
426+service_version_bad_service_CFLAGS = \
427+ -Wall -Werror \
428+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
429+
430+service_version_bad_service_LDADD = \
431+ $(LIBINDICATOR_LIBS) \
432+ $(top_builddir)/libindicator/.libs/libindicator.a
433+
434+check_PROGRAMS += service-version-good-service
435+
436+service_version_good_service_SOURCES = \
437+ service-version-values.h \
438+ service-version-good-service.c
439+
440+service_version_good_service_CFLAGS = \
441+ -Wall -Werror \
442+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
443+
444+service_version_good_service_LDADD = \
445+ $(LIBINDICATOR_LIBS) \
446+ $(top_builddir)/libindicator/.libs/libindicator.a
447+
448+service-version-tester: service-version-manager service-version-bad-service service-version-good-service session.conf service-version-bad.service service-version-good.service Makefile.am
449+ @echo "#!/bin/sh" > $@
450+ @echo dbus-test-runner --dbus-config $(builddir)/session.conf --task ./service-version-manager >> $@
451+ @chmod +x $@
452+
453+TESTS += service-version-tester
454+DISTCLEANFILES += service-version-tester service-version-bad.service service-version-good.service
455+
456+#############################
457 # Service Manager Shutdown
458 #############################
459
460+check_PROGRAMS += service-manager-nostart-connect
461+
462 service_manager_nostart_connect_SOURCES = \
463 service-manager-nostart-connect.c
464
465
466=== added file 'tests/service-version-bad-service.c'
467--- tests/service-version-bad-service.c 1970-01-01 00:00:00 +0000
468+++ tests/service-version-bad-service.c 2009-12-07 19:09:09 +0000
469@@ -0,0 +1,47 @@
470+
471+#include <glib.h>
472+#include "libindicator/indicator-service.h"
473+#include "service-version-values.h"
474+
475+static GMainLoop * mainloop = NULL;
476+static gboolean passed = FALSE;
477+
478+gboolean
479+timeout (gpointer data)
480+{
481+ passed = FALSE;
482+ g_debug("Timeout with no shutdown.");
483+ g_main_loop_quit(mainloop);
484+ return FALSE;
485+}
486+
487+void
488+shutdown (void)
489+{
490+ g_debug("Shutdown");
491+ passed = TRUE;
492+ g_main_loop_quit(mainloop);
493+ return;
494+}
495+
496+int
497+main (int argc, char ** argv)
498+{
499+ g_type_init();
500+
501+ IndicatorService * is = indicator_service_new_version("org.ayatana.version.bad", SERVICE_VERSION_BAD);
502+ g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL);
503+
504+ g_timeout_add_seconds(1, timeout, NULL);
505+
506+ mainloop = g_main_loop_new(NULL, FALSE);
507+ g_main_loop_run(mainloop);
508+
509+ g_debug("Quiting");
510+ if (passed) {
511+ g_debug("Passed");
512+ return 0;
513+ }
514+ g_debug("Failed");
515+ return 1;
516+}
517
518=== added file 'tests/service-version-bad.service.in'
519--- tests/service-version-bad.service.in 1970-01-01 00:00:00 +0000
520+++ tests/service-version-bad.service.in 2009-12-07 19:09:09 +0000
521@@ -0,0 +1,3 @@
522+[D-BUS Service]
523+Name=org.ayatana.version.bad
524+Exec=@builddir@/service-version-bad-service
525
526=== added file 'tests/service-version-good-service.c'
527--- tests/service-version-good-service.c 1970-01-01 00:00:00 +0000
528+++ tests/service-version-good-service.c 2009-12-07 19:09:09 +0000
529@@ -0,0 +1,47 @@
530+
531+#include <glib.h>
532+#include "libindicator/indicator-service.h"
533+#include "service-version-values.h"
534+
535+static GMainLoop * mainloop = NULL;
536+static gboolean passed = FALSE;
537+
538+gboolean
539+timeout (gpointer data)
540+{
541+ passed = FALSE;
542+ g_debug("Timeout with no shutdown.");
543+ g_main_loop_quit(mainloop);
544+ return FALSE;
545+}
546+
547+void
548+shutdown (void)
549+{
550+ g_debug("Shutdown");
551+ passed = TRUE;
552+ g_main_loop_quit(mainloop);
553+ return;
554+}
555+
556+int
557+main (int argc, char ** argv)
558+{
559+ g_type_init();
560+
561+ IndicatorService * is = indicator_service_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD);
562+ g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL);
563+
564+ g_timeout_add_seconds(1, timeout, NULL);
565+
566+ mainloop = g_main_loop_new(NULL, FALSE);
567+ g_main_loop_run(mainloop);
568+
569+ g_debug("Quiting");
570+ if (passed) {
571+ g_debug("Passed");
572+ return 0;
573+ }
574+ g_debug("Failed");
575+ return 1;
576+}
577
578=== added file 'tests/service-version-good.service.in'
579--- tests/service-version-good.service.in 1970-01-01 00:00:00 +0000
580+++ tests/service-version-good.service.in 2009-12-07 19:09:09 +0000
581@@ -0,0 +1,3 @@
582+[D-BUS Service]
583+Name=org.ayatana.version.good
584+Exec=@builddir@/service-version-good-service
585
586=== added file 'tests/service-version-manager.c'
587--- tests/service-version-manager.c 1970-01-01 00:00:00 +0000
588+++ tests/service-version-manager.c 2009-12-07 19:09:09 +0000
589@@ -0,0 +1,64 @@
590+
591+#include <glib.h>
592+#include "libindicator/indicator-service-manager.h"
593+#include "service-version-values.h"
594+
595+static GMainLoop * mainloop = NULL;
596+static gboolean con_good = FALSE;
597+static gboolean con_bad = FALSE;
598+
599+gboolean
600+timeout (gpointer data)
601+{
602+ g_debug("Timeout.");
603+ g_main_loop_quit(mainloop);
604+ return FALSE;
605+}
606+
607+void
608+connection_bad (IndicatorServiceManager * sm, gboolean connected, gpointer user_data)
609+{
610+ if (!connected) return;
611+ g_debug("Connection From Bad!");
612+ con_bad = TRUE;
613+ return;
614+}
615+
616+void
617+connection_good (IndicatorServiceManager * sm, gboolean connected, gpointer user_data)
618+{
619+ if (!connected) return;
620+ g_debug("Connection From Good.");
621+ con_good = TRUE;
622+ return;
623+}
624+
625+int
626+main (int argc, char ** argv)
627+{
628+ g_type_init();
629+ g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
630+ g_print("Manager: DBUS_SESSION_BUS_ADDRESS = %s\n", g_getenv("DBUS_SESSION_BUS_ADDRESS"));
631+
632+ IndicatorServiceManager * goodis = indicator_service_manager_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD);
633+ g_signal_connect(G_OBJECT(goodis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_good), NULL);
634+
635+ IndicatorServiceManager * badis = indicator_service_manager_new_version("org.ayatana.version.bad", SERVICE_VERSION_GOOD);
636+ g_signal_connect(G_OBJECT(badis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_bad), NULL);
637+
638+ g_timeout_add_seconds(1, timeout, NULL);
639+
640+ mainloop = g_main_loop_new(NULL, FALSE);
641+ g_main_loop_run(mainloop);
642+
643+ g_object_unref(goodis);
644+ g_object_unref(badis);
645+
646+ g_debug("Quiting");
647+ if (con_good && !con_bad) {
648+ g_debug("Passed");
649+ return 0;
650+ }
651+ g_debug("Failed");
652+ return 1;
653+}
654
655=== added file 'tests/service-version-values.h'
656--- tests/service-version-values.h 1970-01-01 00:00:00 +0000
657+++ tests/service-version-values.h 2009-12-07 19:09:09 +0000
658@@ -0,0 +1,4 @@
659+
660+#define SERVICE_VERSION_GOOD 1342
661+#define SERVICE_VERSION_BAD 543
662+

Subscribers

People subscribed via source and target branches