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