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
=== modified file '.bzrignore'
--- .bzrignore 2009-12-01 19:37:00 +0000
+++ .bzrignore 2009-12-07 19:09:09 +0000
@@ -135,5 +135,11 @@
135tests/session.conf135tests/session.conf
136tests/service-manager-connect.service136tests/service-manager-connect.service
137tools/indicator-loader137tools/indicator-loader
138tests/service-version-bad-service
139tests/service-version-bad.service
140tests/service-version-good-service
141tests/service-version-good.service
142tests/service-version-manager
143tests/service-version-tester
138tests/service-manager-connect-nostart-tester144tests/service-manager-connect-nostart-tester
139tests/service-manager-nostart-connect145tests/service-manager-nostart-connect
140146
=== modified file 'libindicator/Makefile.am'
--- libindicator/Makefile.am 2009-11-04 17:34:44 +0000
+++ libindicator/Makefile.am 2009-12-07 19:09:09 +0000
@@ -26,6 +26,7 @@
2626
27libindicator_la_CFLAGS = \27libindicator_la_CFLAGS = \
28 $(LIBINDICATOR_CFLAGS) \28 $(LIBINDICATOR_CFLAGS) \
29 -DG_LOG_DOMAIN=\"libindicator\" \
29 -Wall -Werror30 -Wall -Werror
3031
31libindicator_la_LIBADD = \32libindicator_la_LIBADD = \
3233
=== modified file 'libindicator/indicator-service-manager.c'
--- libindicator/indicator-service-manager.c 2009-12-01 22:07:26 +0000
+++ libindicator/indicator-service-manager.c 2009-12-07 19:09:09 +0000
@@ -16,6 +16,7 @@
16 DBusGProxy * dbus_proxy;16 DBusGProxy * dbus_proxy;
17 DBusGProxy * service_proxy;17 DBusGProxy * service_proxy;
18 gboolean connected;18 gboolean connected;
19 guint this_service_version;
19 DBusGConnection * bus;20 DBusGConnection * bus;
20};21};
2122
@@ -34,10 +35,12 @@
34enum {35enum {
35 PROP_0,36 PROP_0,
36 PROP_NAME,37 PROP_NAME,
38 PROP_VERSION
37};39};
3840
39/* The strings so that they can be slowly looked up. */41/* The strings so that they can be slowly looked up. */
40#define PROP_NAME_S "name"42#define PROP_NAME_S "name"
43#define PROP_VERSION_S "version"
4144
42/* GObject Stuff */45/* GObject Stuff */
43#define INDICATOR_SERVICE_MANAGER_GET_PRIVATE(o) \46#define INDICATOR_SERVICE_MANAGER_GET_PRIVATE(o) \
@@ -52,7 +55,6 @@
52static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec);55static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec);
53static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec);56static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec);
54static void start_service (IndicatorServiceManager * service);57static void start_service (IndicatorServiceManager * service);
55static void unwatch_cb (DBusGProxy *proxy, GError *error, gpointer userdata);
5658
57G_DEFINE_TYPE (IndicatorServiceManager, indicator_service_manager, G_TYPE_OBJECT);59G_DEFINE_TYPE (IndicatorServiceManager, indicator_service_manager, G_TYPE_OBJECT);
5860
@@ -93,6 +95,12 @@
93 "This is the name that should be used to start a service.",95 "This is the name that should be used to start a service.",
94 NULL,96 NULL,
95 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));97 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
98 g_object_class_install_property(object_class, PROP_VERSION,
99 g_param_spec_uint(PROP_VERSION_S,
100 "The version of the service that we're expecting.",
101 "A number to check and reject a service if it gives us the wrong number. This should match across the manager and the service",
102 0, G_MAXUINT, 0,
103 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
96104
97 return;105 return;
98}106}
@@ -107,13 +115,14 @@
107 priv->dbus_proxy = NULL;115 priv->dbus_proxy = NULL;
108 priv->service_proxy = NULL;116 priv->service_proxy = NULL;
109 priv->connected = FALSE;117 priv->connected = FALSE;
118 priv->this_service_version = 0;
110 priv->bus = NULL;119 priv->bus = NULL;
111120
112 /* Start talkin' dbus */121 /* Start talkin' dbus */
113 GError * error = NULL;122 GError * error = NULL;
114 priv->bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);123 priv->bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
115 if (error != NULL) {124 if (error != NULL) {
116 g_error("Unable to get session bus: %s", error->message);125 g_error("Unable to get session bus for manager: %s", error->message);
117 g_error_free(error);126 g_error_free(error);
118 return;127 return;
119 }128 }
@@ -153,7 +162,7 @@
153 /* If we have a proxy, tell it we're shutting down. Just162 /* If we have a proxy, tell it we're shutting down. Just
154 to be polite about it. */163 to be polite about it. */
155 if (priv->service_proxy != NULL) {164 if (priv->service_proxy != NULL) {
156 org_ayatana_indicator_service_un_watch_async(priv->service_proxy, unwatch_cb, NULL);165 dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID);
157 }166 }
158167
159 /* Destory our service proxy, we won't need it. */168 /* Destory our service proxy, we won't need it. */
@@ -205,6 +214,10 @@
205 }214 }
206 break;215 break;
207 /* *********************** */216 /* *********************** */
217 case PROP_VERSION:
218 priv->this_service_version = g_value_get_uint(value);
219 break;
220 /* *********************** */
208 default:221 default:
209 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);222 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
210 break;223 break;
@@ -232,6 +245,10 @@
232 }245 }
233 break;246 break;
234 /* *********************** */247 /* *********************** */
248 case PROP_VERSION:
249 g_value_set_uint(value, priv->this_service_version);
250 break;
251 /* *********************** */
235 default:252 default:
236 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);253 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
237 break;254 break;
@@ -241,13 +258,7 @@
241}258}
242259
243static void260static void
244unwatch_cb (DBusGProxy *proxy, GError *error, gpointer userdata)261watch_cb (DBusGProxy * proxy, guint service_api_version, guint this_service_version, GError * error, gpointer user_data)
245{
246 return;
247}
248
249static void
250watch_cb (DBusGProxy * proxy, gint service_version, GError * error, gpointer user_data)
251{262{
252 IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data);263 IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data);
253264
@@ -257,9 +268,15 @@
257 return;268 return;
258 }269 }
259270
260 if (service_version != INDICATOR_SERVICE_VERSION) {271 if (service_api_version != INDICATOR_SERVICE_VERSION) {
261 g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_version);272 g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_api_version);
262 org_ayatana_indicator_service_un_watch_async(priv->service_proxy, unwatch_cb, NULL);273 dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID);
274 return;
275 }
276
277 if (this_service_version != priv->this_service_version) {
278 g_warning("Service is using a different API version than the manager. Expecting %d and got %d.", priv->this_service_version, this_service_version);
279 dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID);
263 return;280 return;
264 }281 }
265282
@@ -292,6 +309,7 @@
292 INDICATOR_SERVICE_OBJECT,309 INDICATOR_SERVICE_OBJECT,
293 INDICATOR_SERVICE_INTERFACE,310 INDICATOR_SERVICE_INTERFACE,
294 &error);311 &error);
312 g_object_add_weak_pointer(G_OBJECT(priv->service_proxy), (gpointer *)&(priv->service_proxy));
295313
296 org_ayatana_indicator_service_watch_async(priv->service_proxy,314 org_ayatana_indicator_service_watch_async(priv->service_proxy,
297 watch_cb,315 watch_cb,
@@ -347,6 +365,17 @@
347 return INDICATOR_SERVICE_MANAGER(obj);365 return INDICATOR_SERVICE_MANAGER(obj);
348}366}
349367
368IndicatorServiceManager *
369indicator_service_manager_new_version (gchar * dbus_name, guint version)
370{
371 GObject * obj = g_object_new(INDICATOR_SERVICE_MANAGER_TYPE,
372 PROP_NAME_S, dbus_name,
373 PROP_VERSION_S, version,
374 NULL);
375
376 return INDICATOR_SERVICE_MANAGER(obj);
377}
378
350gboolean379gboolean
351indicator_service_manager_connected (IndicatorServiceManager * sm)380indicator_service_manager_connected (IndicatorServiceManager * sm)
352{381{
353382
=== modified file 'libindicator/indicator-service-manager.h'
--- libindicator/indicator-service-manager.h 2009-10-29 14:56:39 +0000
+++ libindicator/indicator-service-manager.h 2009-12-07 19:09:09 +0000
@@ -54,6 +54,8 @@
54GType indicator_service_manager_get_type (void);54GType indicator_service_manager_get_type (void);
5555
56IndicatorServiceManager * indicator_service_manager_new (gchar * dbus_name);56IndicatorServiceManager * indicator_service_manager_new (gchar * dbus_name);
57IndicatorServiceManager * indicator_service_manager_new_version (gchar * dbus_name,
58 guint version);
57gboolean indicator_service_manager_connected (IndicatorServiceManager * sm);59gboolean indicator_service_manager_connected (IndicatorServiceManager * sm);
58void indicator_service_manager_set_refresh (IndicatorServiceManager * sm,60void indicator_service_manager_set_refresh (IndicatorServiceManager * sm,
59 guint time_in_ms);61 guint time_in_ms);
6062
=== modified file 'libindicator/indicator-service.c'
--- libindicator/indicator-service.c 2009-12-01 16:12:51 +0000
+++ libindicator/indicator-service.c 2009-12-07 19:09:09 +0000
@@ -21,6 +21,7 @@
21 DBusGProxy * dbus_proxy;21 DBusGProxy * dbus_proxy;
22 guint timeout;22 guint timeout;
23 GList * watchers;23 GList * watchers;
24 guint this_service_version;
24};25};
2526
26/* Signals Stuff */27/* Signals Stuff */
@@ -37,10 +38,12 @@
37enum {38enum {
38 PROP_0,39 PROP_0,
39 PROP_NAME,40 PROP_NAME,
41 PROP_VERSION
40};42};
4143
42/* The strings so that they can be slowly looked up. */44/* The strings so that they can be slowly looked up. */
43#define PROP_NAME_S "name"45#define PROP_NAME_S "name"
46#define PROP_VERSION_S "version"
4447
45/* GObject Stuff */48/* GObject Stuff */
46#define INDICATOR_SERVICE_GET_PRIVATE(o) \49#define INDICATOR_SERVICE_GET_PRIVATE(o) \
@@ -79,6 +82,12 @@
79 "This is the name that should be used on DBus for this service.",82 "This is the name that should be used on DBus for this service.",
80 NULL,83 NULL,
81 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));84 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
85 g_object_class_install_property(object_class, PROP_VERSION,
86 g_param_spec_uint(PROP_VERSION_S,
87 "The version of the service that we're implementing.",
88 "A number to represent the version of the other APIs the service provides. This should match across the manager and the service",
89 0, G_MAXUINT, 0,
90 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
8291
83 /* Signals */92 /* Signals */
8493
@@ -114,6 +123,7 @@
114 priv->dbus_proxy = NULL;123 priv->dbus_proxy = NULL;
115 priv->timeout = 0;124 priv->timeout = 0;
116 priv->watchers = NULL;125 priv->watchers = NULL;
126 priv->this_service_version = 0;
117127
118 /* Start talkin' dbus */128 /* Start talkin' dbus */
119 GError * error = NULL;129 GError * error = NULL;
@@ -214,6 +224,10 @@
214 }224 }
215 break;225 break;
216 /* *********************** */226 /* *********************** */
227 case PROP_VERSION:
228 priv->this_service_version = g_value_get_uint(value);
229 break;
230 /* *********************** */
217 default:231 default:
218 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);232 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
219 break;233 break;
@@ -241,6 +255,10 @@
241 }255 }
242 break;256 break;
243 /* *********************** */257 /* *********************** */
258 case PROP_VERSION:
259 g_value_set_uint(value, priv->this_service_version);
260 break;
261 /* *********************** */
244 default:262 default:
245 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);263 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
246 break;264 break;
@@ -306,7 +324,7 @@
306 priv->timeout = 0;324 priv->timeout = 0;
307 }325 }
308326
309 dbus_g_method_return(method, INDICATOR_SERVICE_VERSION);327 dbus_g_method_return(method, INDICATOR_SERVICE_VERSION, priv->this_service_version);
310 return TRUE;328 return TRUE;
311}329}
312330
@@ -374,3 +392,28 @@
374392
375 return INDICATOR_SERVICE(obj);393 return INDICATOR_SERVICE(obj);
376}394}
395
396/**
397 indicator_service_new_version:
398 @name: The name for the service on dbus
399 @version: The version of the other interfaces provide
400 by the service.
401
402 This function creates the service on DBus and tries to
403 get a well-known name specified in @name. If the name
404 can't be estabilished then the #IndicatorService::shutdown
405 signal will be sent.
406
407 Return value: A brand new #IndicatorService object or #NULL
408 if there is an error.
409*/
410IndicatorService *
411indicator_service_new_version (gchar * name, guint version)
412{
413 GObject * obj = g_object_new(INDICATOR_SERVICE_TYPE,
414 PROP_NAME_S, name,
415 PROP_VERSION_S, version,
416 NULL);
417
418 return INDICATOR_SERVICE(obj);
419}
377420
=== modified file 'libindicator/indicator-service.h'
--- libindicator/indicator-service.h 2009-10-29 16:33:37 +0000
+++ libindicator/indicator-service.h 2009-12-07 19:09:09 +0000
@@ -53,7 +53,9 @@
5353
54GType indicator_service_get_type (void);54GType indicator_service_get_type (void);
5555
56IndicatorService * indicator_service_new (gchar * name);56IndicatorService * indicator_service_new (gchar * name);
57IndicatorService * indicator_service_new_version (gchar * name,
58 guint version);
5759
58G_END_DECLS60G_END_DECLS
5961
6062
=== modified file 'libindicator/indicator-service.xml'
--- libindicator/indicator-service.xml 2009-12-01 15:58:05 +0000
+++ libindicator/indicator-service.xml 2009-12-07 19:09:09 +0000
@@ -7,7 +7,8 @@
7<!-- Methods -->7<!-- Methods -->
8 <method name="Watch">8 <method name="Watch">
9 <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />9 <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
10 <arg type="i" name="version" direction="out" />10 <arg type="u" name="version" direction="out" />
11 <arg type="u" name="service_version" direction="out" />
11 </method>12 </method>
12 <method name="UnWatch">13 <method name="UnWatch">
13 <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />14 <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
1415
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2009-12-01 19:35:30 +0000
+++ tests/Makefile.am 2009-12-07 19:09:09 +0000
@@ -1,13 +1,7 @@
1TESTS =1TESTS =
2DISTCLEANFILES =2DISTCLEANFILES =
33
4check_PROGRAMS = \4check_PROGRAMS =
5 test-loader \
6 service-manager-no-connect \
7 service-manager-connect \
8 service-manager-connect-service \
9 service-manager-nostart-connect \
10 service-shutdown-timeout
115
12lib_LTLIBRARIES = \6lib_LTLIBRARIES = \
13 libdummy-indicator-blank.la \7 libdummy-indicator-blank.la \
@@ -21,6 +15,8 @@
21# Test Loader15# Test Loader
22#############################16#############################
2317
18check_PROGRAMS += test-loader
19
24test_loader_SOURCES = \20test_loader_SOURCES = \
25 test-loader.c21 test-loader.c
2622
@@ -118,6 +114,8 @@
118# Service Shutdown Timeout114# Service Shutdown Timeout
119#############################115#############################
120116
117check_PROGRAMS += service-shutdown-timeout
118
121service_shutdown_timeout_SOURCES = \119service_shutdown_timeout_SOURCES = \
122 service-shutdown-timeout.c120 service-shutdown-timeout.c
123121
@@ -141,6 +139,8 @@
141# Service Manager No Connect139# Service Manager No Connect
142#############################140#############################
143141
142check_PROGRAMS += service-manager-no-connect
143
144service_manager_no_connect_SOURCES = \144service_manager_no_connect_SOURCES = \
145 service-manager-no-connect.c145 service-manager-no-connect.c
146146
@@ -170,6 +170,8 @@
170service-manager-connect.service: $(srcdir)/service-manager-connect.service.in Makefile.am170service-manager-connect.service: $(srcdir)/service-manager-connect.service.in Makefile.am
171 sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@171 sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@
172172
173check_PROGRAMS += service-manager-connect
174
173service_manager_connect_SOURCES = \175service_manager_connect_SOURCES = \
174 service-manager-connect.c176 service-manager-connect.c
175177
@@ -181,6 +183,8 @@
181 $(LIBINDICATOR_LIBS) \183 $(LIBINDICATOR_LIBS) \
182 $(top_builddir)/libindicator/.libs/libindicator.a184 $(top_builddir)/libindicator/.libs/libindicator.a
183185
186check_PROGRAMS += service-manager-connect-service
187
184service_manager_connect_service_SOURCES = \188service_manager_connect_service_SOURCES = \
185 service-manager-connect-service.c189 service-manager-connect-service.c
186190
@@ -201,9 +205,71 @@
201DISTCLEANFILES += service-manager-connect-tester session.conf service-manager-connect.service205DISTCLEANFILES += service-manager-connect-tester session.conf service-manager-connect.service
202206
203#############################207#############################
208# Service Versions
209#############################
210
211service-version-good.service: $(srcdir)/service-version-good.service.in Makefile.am
212 sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@
213
214service-version-bad.service: $(srcdir)/service-version-bad.service.in Makefile.am
215 sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@
216
217check_PROGRAMS += service-version-manager
218
219service_version_manager_SOURCES = \
220 service-version-values.h \
221 service-version-manager.c
222
223service_version_manager_CFLAGS = \
224 -Wall -Werror \
225 $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
226
227service_version_manager_LDADD = \
228 $(LIBINDICATOR_LIBS) \
229 $(top_builddir)/libindicator/.libs/libindicator.a
230
231check_PROGRAMS += service-version-bad-service
232
233service_version_bad_service_SOURCES = \
234 service-version-values.h \
235 service-version-bad-service.c
236
237service_version_bad_service_CFLAGS = \
238 -Wall -Werror \
239 $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
240
241service_version_bad_service_LDADD = \
242 $(LIBINDICATOR_LIBS) \
243 $(top_builddir)/libindicator/.libs/libindicator.a
244
245check_PROGRAMS += service-version-good-service
246
247service_version_good_service_SOURCES = \
248 service-version-values.h \
249 service-version-good-service.c
250
251service_version_good_service_CFLAGS = \
252 -Wall -Werror \
253 $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
254
255service_version_good_service_LDADD = \
256 $(LIBINDICATOR_LIBS) \
257 $(top_builddir)/libindicator/.libs/libindicator.a
258
259service-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
260 @echo "#!/bin/sh" > $@
261 @echo dbus-test-runner --dbus-config $(builddir)/session.conf --task ./service-version-manager >> $@
262 @chmod +x $@
263
264TESTS += service-version-tester
265DISTCLEANFILES += service-version-tester service-version-bad.service service-version-good.service
266
267#############################
204# Service Manager Shutdown268# Service Manager Shutdown
205#############################269#############################
206270
271check_PROGRAMS += service-manager-nostart-connect
272
207service_manager_nostart_connect_SOURCES = \273service_manager_nostart_connect_SOURCES = \
208 service-manager-nostart-connect.c274 service-manager-nostart-connect.c
209275
210276
=== added file 'tests/service-version-bad-service.c'
--- tests/service-version-bad-service.c 1970-01-01 00:00:00 +0000
+++ tests/service-version-bad-service.c 2009-12-07 19:09:09 +0000
@@ -0,0 +1,47 @@
1
2#include <glib.h>
3#include "libindicator/indicator-service.h"
4#include "service-version-values.h"
5
6static GMainLoop * mainloop = NULL;
7static gboolean passed = FALSE;
8
9gboolean
10timeout (gpointer data)
11{
12 passed = FALSE;
13 g_debug("Timeout with no shutdown.");
14 g_main_loop_quit(mainloop);
15 return FALSE;
16}
17
18void
19shutdown (void)
20{
21 g_debug("Shutdown");
22 passed = TRUE;
23 g_main_loop_quit(mainloop);
24 return;
25}
26
27int
28main (int argc, char ** argv)
29{
30 g_type_init();
31
32 IndicatorService * is = indicator_service_new_version("org.ayatana.version.bad", SERVICE_VERSION_BAD);
33 g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL);
34
35 g_timeout_add_seconds(1, timeout, NULL);
36
37 mainloop = g_main_loop_new(NULL, FALSE);
38 g_main_loop_run(mainloop);
39
40 g_debug("Quiting");
41 if (passed) {
42 g_debug("Passed");
43 return 0;
44 }
45 g_debug("Failed");
46 return 1;
47}
048
=== added file 'tests/service-version-bad.service.in'
--- tests/service-version-bad.service.in 1970-01-01 00:00:00 +0000
+++ tests/service-version-bad.service.in 2009-12-07 19:09:09 +0000
@@ -0,0 +1,3 @@
1[D-BUS Service]
2Name=org.ayatana.version.bad
3Exec=@builddir@/service-version-bad-service
04
=== added file 'tests/service-version-good-service.c'
--- tests/service-version-good-service.c 1970-01-01 00:00:00 +0000
+++ tests/service-version-good-service.c 2009-12-07 19:09:09 +0000
@@ -0,0 +1,47 @@
1
2#include <glib.h>
3#include "libindicator/indicator-service.h"
4#include "service-version-values.h"
5
6static GMainLoop * mainloop = NULL;
7static gboolean passed = FALSE;
8
9gboolean
10timeout (gpointer data)
11{
12 passed = FALSE;
13 g_debug("Timeout with no shutdown.");
14 g_main_loop_quit(mainloop);
15 return FALSE;
16}
17
18void
19shutdown (void)
20{
21 g_debug("Shutdown");
22 passed = TRUE;
23 g_main_loop_quit(mainloop);
24 return;
25}
26
27int
28main (int argc, char ** argv)
29{
30 g_type_init();
31
32 IndicatorService * is = indicator_service_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD);
33 g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL);
34
35 g_timeout_add_seconds(1, timeout, NULL);
36
37 mainloop = g_main_loop_new(NULL, FALSE);
38 g_main_loop_run(mainloop);
39
40 g_debug("Quiting");
41 if (passed) {
42 g_debug("Passed");
43 return 0;
44 }
45 g_debug("Failed");
46 return 1;
47}
048
=== added file 'tests/service-version-good.service.in'
--- tests/service-version-good.service.in 1970-01-01 00:00:00 +0000
+++ tests/service-version-good.service.in 2009-12-07 19:09:09 +0000
@@ -0,0 +1,3 @@
1[D-BUS Service]
2Name=org.ayatana.version.good
3Exec=@builddir@/service-version-good-service
04
=== added file 'tests/service-version-manager.c'
--- tests/service-version-manager.c 1970-01-01 00:00:00 +0000
+++ tests/service-version-manager.c 2009-12-07 19:09:09 +0000
@@ -0,0 +1,64 @@
1
2#include <glib.h>
3#include "libindicator/indicator-service-manager.h"
4#include "service-version-values.h"
5
6static GMainLoop * mainloop = NULL;
7static gboolean con_good = FALSE;
8static gboolean con_bad = FALSE;
9
10gboolean
11timeout (gpointer data)
12{
13 g_debug("Timeout.");
14 g_main_loop_quit(mainloop);
15 return FALSE;
16}
17
18void
19connection_bad (IndicatorServiceManager * sm, gboolean connected, gpointer user_data)
20{
21 if (!connected) return;
22 g_debug("Connection From Bad!");
23 con_bad = TRUE;
24 return;
25}
26
27void
28connection_good (IndicatorServiceManager * sm, gboolean connected, gpointer user_data)
29{
30 if (!connected) return;
31 g_debug("Connection From Good.");
32 con_good = TRUE;
33 return;
34}
35
36int
37main (int argc, char ** argv)
38{
39 g_type_init();
40 g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
41 g_print("Manager: DBUS_SESSION_BUS_ADDRESS = %s\n", g_getenv("DBUS_SESSION_BUS_ADDRESS"));
42
43 IndicatorServiceManager * goodis = indicator_service_manager_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD);
44 g_signal_connect(G_OBJECT(goodis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_good), NULL);
45
46 IndicatorServiceManager * badis = indicator_service_manager_new_version("org.ayatana.version.bad", SERVICE_VERSION_GOOD);
47 g_signal_connect(G_OBJECT(badis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_bad), NULL);
48
49 g_timeout_add_seconds(1, timeout, NULL);
50
51 mainloop = g_main_loop_new(NULL, FALSE);
52 g_main_loop_run(mainloop);
53
54 g_object_unref(goodis);
55 g_object_unref(badis);
56
57 g_debug("Quiting");
58 if (con_good && !con_bad) {
59 g_debug("Passed");
60 return 0;
61 }
62 g_debug("Failed");
63 return 1;
64}
065
=== added file 'tests/service-version-values.h'
--- tests/service-version-values.h 1970-01-01 00:00:00 +0000
+++ tests/service-version-values.h 2009-12-07 19:09:09 +0000
@@ -0,0 +1,4 @@
1
2#define SERVICE_VERSION_GOOD 1342
3#define SERVICE_VERSION_BAD 543
4

Subscribers

People subscribed via source and target branches