Merge lp:~indicator-applet-developers/libindicator/ubuntu into lp:~ubuntu-desktop/libindicator/ubuntu
- ubuntu
- Merge into ubuntu
Proposed by
Ted Gould
Status: | Merged | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Merged at revision: | not available | ||||||||||||||||||||||||||||
Proposed branch: | lp:~indicator-applet-developers/libindicator/ubuntu | ||||||||||||||||||||||||||||
Merge into: | lp:~ubuntu-desktop/libindicator/ubuntu | ||||||||||||||||||||||||||||
Diff against target: |
606 lines (+271/-15) 11 files modified
.bzrignore (+4/-0) Makefile.am.marshal (+45/-0) configure.ac (+4/-2) debian/changelog (+8/-0) libindicator/Makefile.am (+8/-0) libindicator/indicator-object-marshal.list (+1/-0) libindicator/indicator-object.c (+52/-2) libindicator/indicator-object.h (+9/-4) libindicator/indicator-service-manager.c (+106/-0) tests/dummy-indicator-signaler.c (+1/-0) tests/test-loader.c (+33/-7) |
||||||||||||||||||||||||||||
To merge this branch: | bzr merge lp:~indicator-applet-developers/libindicator/ubuntu | ||||||||||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Indicator Applet Developers | Pending | ||
Review via email: mp+17836@code.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 : | # |
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-02 21:58:52 +0000 | |||
3 | +++ .bzrignore 2010-01-21 19:20:24 +0000 | |||
4 | @@ -143,3 +143,7 @@ | |||
5 | 143 | tests/service-version-tester | 143 | tests/service-version-tester |
6 | 144 | tests/service-manager-connect-nostart-tester | 144 | tests/service-manager-connect-nostart-tester |
7 | 145 | tests/service-manager-nostart-connect | 145 | tests/service-manager-nostart-connect |
8 | 146 | libindicator/indicator-object-marshal.c | ||
9 | 147 | libindicator/indicator-object-marshal.h | ||
10 | 148 | libindicator/libindicator_la-indicator-object-marshal.lo | ||
11 | 149 | libindicator/stamp-marshal | ||
12 | 146 | 150 | ||
13 | === added file 'Makefile.am.marshal' | |||
14 | --- Makefile.am.marshal 1970-01-01 00:00:00 +0000 | |||
15 | +++ Makefile.am.marshal 2010-01-21 19:20:25 +0000 | |||
16 | @@ -0,0 +1,45 @@ | |||
17 | 1 | # Rules for generating marshal files using glib-genmarshal | ||
18 | 2 | # | ||
19 | 3 | # Define: | ||
20 | 4 | # glib_marshal_list = marshal list file | ||
21 | 5 | # glib_marshal_prefix = prefix for marshal functions | ||
22 | 6 | # | ||
23 | 7 | # before including Makefile.am.marshal. You will also need to have | ||
24 | 8 | # the following targets already defined: | ||
25 | 9 | # | ||
26 | 10 | # CLEANFILES | ||
27 | 11 | # DISTCLEANFILES | ||
28 | 12 | # BUILT_SOURCES | ||
29 | 13 | # EXTRA_DIST | ||
30 | 14 | # | ||
31 | 15 | # Author: Emmanuele Bassi <ebassi@linux.intel.com> | ||
32 | 16 | |||
33 | 17 | marshal_h = $(glib_marshal_list:.list=.h) | ||
34 | 18 | marshal_c = $(glib_marshal_list:.list=.c) | ||
35 | 19 | |||
36 | 20 | CLEANFILES += stamp-marshal | ||
37 | 21 | DISTCLEANFILES += $(marshal_h) $(marshal_c) | ||
38 | 22 | BUILT_SOURCES += $(marshal_h) $(marshal_c) | ||
39 | 23 | EXTRA_DIST += $(glib_marshal_list) | ||
40 | 24 | |||
41 | 25 | stamp-marshal: $(glib_marshal_list) | ||
42 | 26 | $(QUIET_GEN)$(GLIB_GENMARSHAL) \ | ||
43 | 27 | --prefix=$(glib_marshal_prefix) \ | ||
44 | 28 | --header \ | ||
45 | 29 | $(srcdir)/$(glib_marshal_list) > xgen-mh \ | ||
46 | 30 | && (cmp -s xgen-mh $(marshal_h) || cp -f xgen-mh $(marshal_h)) \ | ||
47 | 31 | && rm -f xgen-mh \ | ||
48 | 32 | && echo timestamp > $(@F) | ||
49 | 33 | |||
50 | 34 | $(marshal_h): stamp-marshal | ||
51 | 35 | @true | ||
52 | 36 | |||
53 | 37 | $(marshal_c): $(marshal_h) | ||
54 | 38 | $(QUIET_GEN)(echo "#include \"$(marshal_h)\"" ; \ | ||
55 | 39 | $(GLIB_GENMARSHAL) \ | ||
56 | 40 | --prefix=$(glib_marshal_prefix) \ | ||
57 | 41 | --body \ | ||
58 | 42 | $(srcdir)/$(glib_marshal_list)) > xgen-mc \ | ||
59 | 43 | && cp xgen-mc $(marshal_c) \ | ||
60 | 44 | && rm -f xgen-mc | ||
61 | 45 | |||
62 | 0 | 46 | ||
63 | === modified file 'configure.ac' | |||
64 | --- configure.ac 2009-11-04 19:07:37 +0000 | |||
65 | +++ configure.ac 2010-01-21 19:20:25 +0000 | |||
66 | @@ -1,10 +1,10 @@ | |||
67 | 1 | 1 | ||
69 | 2 | AC_INIT(libindicator, 0.3.0, ted@canonical.com) | 2 | AC_INIT(libindicator, 0.3.1, ted@canonical.com) |
70 | 3 | 3 | ||
71 | 4 | AC_PREREQ(2.53) | 4 | AC_PREREQ(2.53) |
72 | 5 | 5 | ||
73 | 6 | AM_CONFIG_HEADER(config.h) | 6 | AM_CONFIG_HEADER(config.h) |
75 | 7 | AM_INIT_AUTOMAKE(libindicator, 0.3.0) | 7 | AM_INIT_AUTOMAKE(libindicator, 0.3.1) |
76 | 8 | 8 | ||
77 | 9 | AM_MAINTAINER_MODE | 9 | AM_MAINTAINER_MODE |
78 | 10 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES]) | 10 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES]) |
79 | @@ -15,6 +15,8 @@ | |||
80 | 15 | AC_STDC_HEADERS | 15 | AC_STDC_HEADERS |
81 | 16 | AC_PROG_LIBTOOL | 16 | AC_PROG_LIBTOOL |
82 | 17 | 17 | ||
83 | 18 | AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal]) | ||
84 | 19 | |||
85 | 18 | AC_SUBST(VERSION) | 20 | AC_SUBST(VERSION) |
86 | 19 | AC_CONFIG_MACRO_DIR([m4]) | 21 | AC_CONFIG_MACRO_DIR([m4]) |
87 | 20 | 22 | ||
88 | 21 | 23 | ||
89 | === modified file 'debian/changelog' | |||
90 | --- debian/changelog 2009-12-10 17:18:01 +0000 | |||
91 | +++ debian/changelog 2010-01-21 19:20:25 +0000 | |||
92 | @@ -1,3 +1,11 @@ | |||
93 | 1 | libindicator (0.3.1-0ubuntu1~ppa1) karmic; urgency=low | ||
94 | 2 | |||
95 | 3 | * Upstream release 0.3.1 | ||
96 | 4 | * Adding in entry ordering. | ||
97 | 5 | * Adding in the code to restart services | ||
98 | 6 | |||
99 | 7 | -- Ted Gould <ted@ubuntu.com> Thu, 21 Jan 2010 13:15:07 -0600 | ||
100 | 8 | |||
101 | 1 | libindicator (0.3.0-0ubuntu1) lucid; urgency=low | 9 | libindicator (0.3.0-0ubuntu1) lucid; urgency=low |
102 | 2 | 10 | ||
103 | 3 | * debian/control: | 11 | * debian/control: |
104 | 4 | 12 | ||
105 | === modified file 'libindicator/Makefile.am' | |||
106 | --- libindicator/Makefile.am 2009-12-02 19:56:44 +0000 | |||
107 | +++ libindicator/Makefile.am 2010-01-21 19:20:25 +0000 | |||
108 | @@ -1,8 +1,11 @@ | |||
109 | 1 | BUILT_SOURCES = | 1 | BUILT_SOURCES = |
110 | 2 | CLEANFILES = | 2 | CLEANFILES = |
111 | 3 | DISTCLEANFILES = | ||
112 | 3 | EXTRA_DIST = \ | 4 | EXTRA_DIST = \ |
113 | 4 | indicator.pc.in | 5 | indicator.pc.in |
114 | 5 | 6 | ||
115 | 7 | include $(top_srcdir)/Makefile.am.marshal | ||
116 | 8 | |||
117 | 6 | libindicatorincludedir=$(includedir)/libindicator-0.3/libindicator | 9 | libindicatorincludedir=$(includedir)/libindicator-0.3/libindicator |
118 | 7 | 10 | ||
119 | 8 | indicator_headers = \ | 11 | indicator_headers = \ |
120 | @@ -21,6 +24,8 @@ | |||
121 | 21 | $(indicator_headers) \ | 24 | $(indicator_headers) \ |
122 | 22 | dbus-shared.h \ | 25 | dbus-shared.h \ |
123 | 23 | indicator-object.c \ | 26 | indicator-object.c \ |
124 | 27 | indicator-object-marshal.h \ | ||
125 | 28 | indicator-object-marshal.c \ | ||
126 | 24 | indicator-service.c \ | 29 | indicator-service.c \ |
127 | 25 | indicator-service-manager.c | 30 | indicator-service-manager.c |
128 | 26 | 31 | ||
129 | @@ -35,6 +40,9 @@ | |||
130 | 35 | pkgconfig_DATA = indicator.pc | 40 | pkgconfig_DATA = indicator.pc |
131 | 36 | pkgconfigdir = $(libdir)/pkgconfig | 41 | pkgconfigdir = $(libdir)/pkgconfig |
132 | 37 | 42 | ||
133 | 43 | glib_marshal_list = indicator-object-marshal.list | ||
134 | 44 | glib_marshal_prefix = _indicator_object_marshal | ||
135 | 45 | |||
136 | 38 | ################################## | 46 | ################################## |
137 | 39 | # DBus Specs | 47 | # DBus Specs |
138 | 40 | ################################## | 48 | ################################## |
139 | 41 | 49 | ||
140 | === added file 'libindicator/indicator-object-marshal.list' | |||
141 | --- libindicator/indicator-object-marshal.list 1970-01-01 00:00:00 +0000 | |||
142 | +++ libindicator/indicator-object-marshal.list 2010-01-21 19:20:25 +0000 | |||
143 | @@ -0,0 +1,1 @@ | |||
144 | 1 | VOID: POINTER, UINT, UINT | ||
145 | 0 | 2 | ||
146 | === modified file 'libindicator/indicator-object.c' | |||
147 | --- libindicator/indicator-object.c 2009-11-05 16:56:41 +0000 | |||
148 | +++ libindicator/indicator-object.c 2010-01-21 19:20:25 +0000 | |||
149 | @@ -27,6 +27,7 @@ | |||
150 | 27 | 27 | ||
151 | 28 | #include "indicator.h" | 28 | #include "indicator.h" |
152 | 29 | #include "indicator-object.h" | 29 | #include "indicator-object.h" |
153 | 30 | #include "indicator-object-marshal.h" | ||
154 | 30 | 31 | ||
155 | 31 | /** | 32 | /** |
156 | 32 | IndicatorObjectPrivate: | 33 | IndicatorObjectPrivate: |
157 | @@ -54,6 +55,7 @@ | |||
158 | 54 | enum { | 55 | enum { |
159 | 55 | ENTRY_ADDED, | 56 | ENTRY_ADDED, |
160 | 56 | ENTRY_REMOVED, | 57 | ENTRY_REMOVED, |
161 | 58 | ENTRY_MOVED, | ||
162 | 57 | LAST_SIGNAL | 59 | LAST_SIGNAL |
163 | 58 | }; | 60 | }; |
164 | 59 | 61 | ||
165 | @@ -86,11 +88,14 @@ | |||
166 | 86 | klass->get_image = NULL; | 88 | klass->get_image = NULL; |
167 | 87 | 89 | ||
168 | 88 | klass->get_entries = get_entries_default; | 90 | klass->get_entries = get_entries_default; |
169 | 91 | klass->get_location = NULL; | ||
170 | 89 | 92 | ||
171 | 90 | /** | 93 | /** |
172 | 91 | IndicatorObject::entry-added: | 94 | IndicatorObject::entry-added: |
173 | 92 | @arg0: The #IndicatorObject object | 95 | @arg0: The #IndicatorObject object |
175 | 93 | 96 | @arg1: A pointer to the #IndicatorObjectEntry that | |
176 | 97 | is being added. | ||
177 | 98 | |||
178 | 94 | Signaled when a new entry is added and should | 99 | Signaled when a new entry is added and should |
179 | 95 | be shown by the person using this object. | 100 | be shown by the person using this object. |
180 | 96 | */ | 101 | */ |
181 | @@ -105,7 +110,9 @@ | |||
182 | 105 | /** | 110 | /** |
183 | 106 | IndicatorObject::entry-removed: | 111 | IndicatorObject::entry-removed: |
184 | 107 | @arg0: The #IndicatorObject object | 112 | @arg0: The #IndicatorObject object |
186 | 108 | 113 | @arg1: A pointer to the #IndicatorObjectEntry that | |
187 | 114 | is being removed. | ||
188 | 115 | |||
189 | 109 | Signaled when an entry is removed and should | 116 | Signaled when an entry is removed and should |
190 | 110 | be removed by the person using this object. | 117 | be removed by the person using this object. |
191 | 111 | */ | 118 | */ |
192 | @@ -116,6 +123,24 @@ | |||
193 | 116 | NULL, NULL, | 123 | NULL, NULL, |
194 | 117 | g_cclosure_marshal_VOID__POINTER, | 124 | g_cclosure_marshal_VOID__POINTER, |
195 | 118 | G_TYPE_NONE, 1, G_TYPE_POINTER, G_TYPE_NONE); | 125 | G_TYPE_NONE, 1, G_TYPE_POINTER, G_TYPE_NONE); |
196 | 126 | /** | ||
197 | 127 | IndicatorObject::entry-moved: | ||
198 | 128 | @arg0: The #IndicatorObject object | ||
199 | 129 | @arg1: A pointer to the #IndicatorObjectEntry that | ||
200 | 130 | is being moved. | ||
201 | 131 | @arg2: The old location of the entry | ||
202 | 132 | @arg3: The new location of the entry | ||
203 | 133 | |||
204 | 134 | When the order of the entries change, then this signal | ||
205 | 135 | is sent to tell the new location. | ||
206 | 136 | */ | ||
207 | 137 | signals[ENTRY_MOVED] = g_signal_new (INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, | ||
208 | 138 | G_TYPE_FROM_CLASS(klass), | ||
209 | 139 | G_SIGNAL_RUN_LAST, | ||
210 | 140 | G_STRUCT_OFFSET (IndicatorObjectClass, entry_moved), | ||
211 | 141 | NULL, NULL, | ||
212 | 142 | _indicator_object_marshal_VOID__POINTER_UINT_UINT, | ||
213 | 143 | G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_NONE); | ||
214 | 119 | 144 | ||
215 | 120 | return; | 145 | return; |
216 | 121 | } | 146 | } |
217 | @@ -342,3 +367,28 @@ | |||
218 | 342 | g_error("No get_entries function on object. It must have been deleted?!?!"); | 367 | g_error("No get_entries function on object. It must have been deleted?!?!"); |
219 | 343 | return NULL; | 368 | return NULL; |
220 | 344 | } | 369 | } |
221 | 370 | |||
222 | 371 | /** | ||
223 | 372 | indicator_object_get_location: | ||
224 | 373 | @io: #IndicatorObject to query | ||
225 | 374 | @entry: The #IndicatorObjectEntry to look for. | ||
226 | 375 | |||
227 | 376 | This function looks on the class for the object and calls | ||
228 | 377 | it's #IndicatorObjectClass::get_location function. If the | ||
229 | 378 | function doesn't exist it returns zero. | ||
230 | 379 | |||
231 | 380 | Return value: Location of the @entry in the display or | ||
232 | 381 | zero if no location is specified. | ||
233 | 382 | */ | ||
234 | 383 | guint | ||
235 | 384 | indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry) | ||
236 | 385 | { | ||
237 | 386 | g_return_val_if_fail(INDICATOR_IS_OBJECT(io), 0); | ||
238 | 387 | IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io); | ||
239 | 388 | |||
240 | 389 | if (class->get_location) { | ||
241 | 390 | return class->get_location(io, entry); | ||
242 | 391 | } | ||
243 | 392 | |||
244 | 393 | return 0; | ||
245 | 394 | } | ||
246 | 345 | 395 | ||
247 | === modified file 'libindicator/indicator-object.h' | |||
248 | --- libindicator/indicator-object.h 2009-11-04 17:24:25 +0000 | |||
249 | +++ libindicator/indicator-object.h 2010-01-21 19:20:25 +0000 | |||
250 | @@ -40,6 +40,8 @@ | |||
251 | 40 | #define INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, INDICATOR_OBJECT_TYPE)) | 40 | #define INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, INDICATOR_OBJECT_TYPE)) |
252 | 41 | #define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED "entry-removed" | 41 | #define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED "entry-removed" |
253 | 42 | #define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, INDICATOR_OBJECT_TYPE)) | 42 | #define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, INDICATOR_OBJECT_TYPE)) |
254 | 43 | #define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED "entry-moved" | ||
255 | 44 | #define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, INDICATOR_OBJECT_TYPE)) | ||
256 | 43 | 45 | ||
257 | 44 | typedef struct _IndicatorObject IndicatorObject; | 46 | typedef struct _IndicatorObject IndicatorObject; |
258 | 45 | typedef struct _IndicatorObjectClass IndicatorObjectClass; | 47 | typedef struct _IndicatorObjectClass IndicatorObjectClass; |
259 | @@ -62,12 +64,14 @@ | |||
260 | 62 | a #GList of #IndicatorObjectEntries. The list should be | 64 | a #GList of #IndicatorObjectEntries. The list should be |
261 | 63 | under the ownership of the caller but the entires will | 65 | under the ownership of the caller but the entires will |
262 | 64 | not be. | 66 | not be. |
263 | 67 | @get_location: Returns the location that a particular entry | ||
264 | 68 | should be placed in. This is really only relevant for | ||
265 | 69 | indicators that have more than one entry. | ||
266 | 65 | @entry_added: Slot for #IndicatorObject::entry-added | 70 | @entry_added: Slot for #IndicatorObject::entry-added |
267 | 66 | @entry_removed: Slot for #IndicatorObject::entry-removed | 71 | @entry_removed: Slot for #IndicatorObject::entry-removed |
268 | 72 | @entry_moved: Slot for #IndicatorObject::entry-moved | ||
269 | 67 | @indicator_object_reserved_1: Reserved for future use | 73 | @indicator_object_reserved_1: Reserved for future use |
270 | 68 | @indicator_object_reserved_2: Reserved for future use | 74 | @indicator_object_reserved_2: Reserved for future use |
271 | 69 | @indicator_object_reserved_3: Reserved for future use | ||
272 | 70 | @indicator_object_reserved_4: Reserved for future use | ||
273 | 71 | */ | 75 | */ |
274 | 72 | struct _IndicatorObjectClass { | 76 | struct _IndicatorObjectClass { |
275 | 73 | GObjectClass parent_class; | 77 | GObjectClass parent_class; |
276 | @@ -78,16 +82,16 @@ | |||
277 | 78 | GtkMenu * (*get_menu) (IndicatorObject * io); | 82 | GtkMenu * (*get_menu) (IndicatorObject * io); |
278 | 79 | 83 | ||
279 | 80 | GList * (*get_entries) (IndicatorObject * io); | 84 | GList * (*get_entries) (IndicatorObject * io); |
280 | 85 | guint (*get_location) (IndicatorObject * io, IndicatorObjectEntry * entry); | ||
281 | 81 | 86 | ||
282 | 82 | /* Signals */ | 87 | /* Signals */ |
283 | 83 | void (*entry_added) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data); | 88 | void (*entry_added) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data); |
284 | 84 | void (*entry_removed) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data); | 89 | void (*entry_removed) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data); |
285 | 90 | void (*entry_moved) (IndicatorObject * io, IndicatorObjectEntry * entry, guint old_pos, guint new_pos, gpointer user_data); | ||
286 | 85 | 91 | ||
287 | 86 | /* Reserved */ | 92 | /* Reserved */ |
288 | 87 | void (* indicator_object_reserved_1) (void); | 93 | void (* indicator_object_reserved_1) (void); |
289 | 88 | void (* indicator_object_reserved_2) (void); | 94 | void (* indicator_object_reserved_2) (void); |
290 | 89 | void (* indicator_object_reserved_3) (void); | ||
291 | 90 | void (* indicator_object_reserved_4) (void); | ||
292 | 91 | }; | 95 | }; |
293 | 92 | 96 | ||
294 | 93 | /** | 97 | /** |
295 | @@ -117,6 +121,7 @@ | |||
296 | 117 | IndicatorObject * indicator_object_new_from_file (const gchar * file); | 121 | IndicatorObject * indicator_object_new_from_file (const gchar * file); |
297 | 118 | 122 | ||
298 | 119 | GList * indicator_object_get_entries (IndicatorObject * io); | 123 | GList * indicator_object_get_entries (IndicatorObject * io); |
299 | 124 | guint indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry); | ||
300 | 120 | 125 | ||
301 | 121 | G_END_DECLS | 126 | G_END_DECLS |
302 | 122 | 127 | ||
303 | 123 | 128 | ||
304 | === modified file 'libindicator/indicator-service-manager.c' | |||
305 | --- libindicator/indicator-service-manager.c 2009-12-07 20:22:35 +0000 | |||
306 | +++ libindicator/indicator-service-manager.c 2010-01-21 19:20:25 +0000 | |||
307 | @@ -25,6 +25,8 @@ | |||
308 | 25 | #include "config.h" | 25 | #include "config.h" |
309 | 26 | #endif | 26 | #endif |
310 | 27 | 27 | ||
311 | 28 | #include <stdlib.h> | ||
312 | 29 | |||
313 | 28 | #include <dbus/dbus-glib-bindings.h> | 30 | #include <dbus/dbus-glib-bindings.h> |
314 | 29 | #include <dbus/dbus-glib-lowlevel.h> | 31 | #include <dbus/dbus-glib-lowlevel.h> |
315 | 30 | 32 | ||
316 | @@ -41,6 +43,7 @@ | |||
317 | 41 | @connected: Whether we're connected to the service or not. | 43 | @connected: Whether we're connected to the service or not. |
318 | 42 | @this_service_version: The version of the service that we're looking for. | 44 | @this_service_version: The version of the service that we're looking for. |
319 | 43 | @bus: A reference to the bus so we don't have to keep getting it. | 45 | @bus: A reference to the bus so we don't have to keep getting it. |
320 | 46 | @restart_count: The number of times we've restarted this service. | ||
321 | 44 | */ | 47 | */ |
322 | 45 | typedef struct _IndicatorServiceManagerPrivate IndicatorServiceManagerPrivate; | 48 | typedef struct _IndicatorServiceManagerPrivate IndicatorServiceManagerPrivate; |
323 | 46 | struct _IndicatorServiceManagerPrivate { | 49 | struct _IndicatorServiceManagerPrivate { |
324 | @@ -50,6 +53,8 @@ | |||
325 | 50 | gboolean connected; | 53 | gboolean connected; |
326 | 51 | guint this_service_version; | 54 | guint this_service_version; |
327 | 52 | DBusGConnection * bus; | 55 | DBusGConnection * bus; |
328 | 56 | guint restart_count; | ||
329 | 57 | gint restart_source; | ||
330 | 53 | }; | 58 | }; |
331 | 54 | 59 | ||
332 | 55 | /* Signals Stuff */ | 60 | /* Signals Stuff */ |
333 | @@ -60,6 +65,13 @@ | |||
334 | 60 | 65 | ||
335 | 61 | static guint signals[LAST_SIGNAL] = { 0 }; | 66 | static guint signals[LAST_SIGNAL] = { 0 }; |
336 | 62 | 67 | ||
337 | 68 | /* If this env variable is set, we don't restart */ | ||
338 | 69 | #define TIMEOUT_ENV_NAME "INDICATOR_SERVICE_RESTART_DISABLE" | ||
339 | 70 | #define TIMEOUT_MULTIPLIER 100 /* In ms */ | ||
340 | 71 | /* What to reset the restart_count to if we know that we're | ||
341 | 72 | in a recoverable error condition, but waiting a little bit | ||
342 | 73 | will probably make things better. 5 ~= 3 sec. */ | ||
343 | 74 | #define TIMEOUT_A_LITTLE_WHILE 5 | ||
344 | 63 | 75 | ||
345 | 64 | /* Properties */ | 76 | /* Properties */ |
346 | 65 | /* Enum for the properties so that they can be quickly | 77 | /* Enum for the properties so that they can be quickly |
347 | @@ -86,7 +98,9 @@ | |||
348 | 86 | /* Prototypes */ | 98 | /* Prototypes */ |
349 | 87 | static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); | 99 | static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); |
350 | 88 | static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); | 100 | static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); |
351 | 101 | static void service_proxy_destroyed (DBusGProxy * proxy, gpointer user_data); | ||
352 | 89 | static void start_service (IndicatorServiceManager * service); | 102 | static void start_service (IndicatorServiceManager * service); |
353 | 103 | static void start_service_again (IndicatorServiceManager * manager); | ||
354 | 90 | 104 | ||
355 | 91 | G_DEFINE_TYPE (IndicatorServiceManager, indicator_service_manager, G_TYPE_OBJECT); | 105 | G_DEFINE_TYPE (IndicatorServiceManager, indicator_service_manager, G_TYPE_OBJECT); |
356 | 92 | 106 | ||
357 | @@ -154,6 +168,8 @@ | |||
358 | 154 | priv->connected = FALSE; | 168 | priv->connected = FALSE; |
359 | 155 | priv->this_service_version = 0; | 169 | priv->this_service_version = 0; |
360 | 156 | priv->bus = NULL; | 170 | priv->bus = NULL; |
361 | 171 | priv->restart_count = 0; | ||
362 | 172 | priv->restart_source = 0; | ||
363 | 157 | 173 | ||
364 | 158 | /* Start talkin' dbus */ | 174 | /* Start talkin' dbus */ |
365 | 159 | GError * error = NULL; | 175 | GError * error = NULL; |
366 | @@ -187,6 +203,13 @@ | |||
367 | 187 | { | 203 | { |
368 | 188 | IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(object); | 204 | IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(object); |
369 | 189 | 205 | ||
370 | 206 | /* Removing the idle task to restart if it exists. */ | ||
371 | 207 | if (priv->restart_source != 0) { | ||
372 | 208 | g_source_remove(priv->restart_source); | ||
373 | 209 | } | ||
374 | 210 | /* Block any restart calls */ | ||
375 | 211 | priv->restart_source = -1; | ||
376 | 212 | |||
377 | 190 | /* If we were connected we need to make sure to | 213 | /* If we were connected we need to make sure to |
378 | 191 | tell people that it's no longer the case. */ | 214 | tell people that it's no longer the case. */ |
379 | 192 | if (priv->connected) { | 215 | if (priv->connected) { |
380 | @@ -309,18 +332,33 @@ | |||
381 | 309 | if (error != NULL) { | 332 | if (error != NULL) { |
382 | 310 | g_warning("Unable to set watch on '%s': '%s'", priv->name, error->message); | 333 | g_warning("Unable to set watch on '%s': '%s'", priv->name, error->message); |
383 | 311 | g_error_free(error); | 334 | g_error_free(error); |
384 | 335 | start_service_again(INDICATOR_SERVICE_MANAGER(user_data)); | ||
385 | 312 | return; | 336 | return; |
386 | 313 | } | 337 | } |
387 | 314 | 338 | ||
388 | 339 | /* We've done it, now let's stop counting. */ | ||
389 | 340 | /* Note: we're not checking versions. Because, the hope is that | ||
390 | 341 | the guy holding the name we want with the wrong version will | ||
391 | 342 | drop and we can start another service quickly. */ | ||
392 | 343 | priv->restart_count = 0; | ||
393 | 344 | |||
394 | 315 | if (service_api_version != INDICATOR_SERVICE_VERSION) { | 345 | if (service_api_version != INDICATOR_SERVICE_VERSION) { |
395 | 316 | g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_api_version); | 346 | g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_api_version); |
396 | 317 | dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID); | 347 | dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID); |
397 | 348 | |||
398 | 349 | /* Let's make us wait a little while, then try again */ | ||
399 | 350 | priv->restart_count = TIMEOUT_A_LITTLE_WHILE; | ||
400 | 351 | start_service_again(INDICATOR_SERVICE_MANAGER(user_data)); | ||
401 | 318 | return; | 352 | return; |
402 | 319 | } | 353 | } |
403 | 320 | 354 | ||
404 | 321 | if (this_service_version != priv->this_service_version) { | 355 | if (this_service_version != priv->this_service_version) { |
405 | 322 | g_warning("Service is using a different API version than the manager. Expecting %d and got %d.", priv->this_service_version, this_service_version); | 356 | g_warning("Service is using a different API version than the manager. Expecting %d and got %d.", priv->this_service_version, this_service_version); |
406 | 323 | dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID); | 357 | dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID); |
407 | 358 | |||
408 | 359 | /* Let's make us wait a little while, then try again */ | ||
409 | 360 | priv->restart_count = TIMEOUT_A_LITTLE_WHILE; | ||
410 | 361 | start_service_again(INDICATOR_SERVICE_MANAGER(user_data)); | ||
411 | 324 | return; | 362 | return; |
412 | 325 | } | 363 | } |
413 | 326 | 364 | ||
414 | @@ -343,11 +381,13 @@ | |||
415 | 343 | 381 | ||
416 | 344 | if (error != NULL) { | 382 | if (error != NULL) { |
417 | 345 | g_warning("Unable to start service '%s': %s", priv->name, error->message); | 383 | g_warning("Unable to start service '%s': %s", priv->name, error->message); |
418 | 384 | start_service_again(INDICATOR_SERVICE_MANAGER(user_data)); | ||
419 | 346 | return; | 385 | return; |
420 | 347 | } | 386 | } |
421 | 348 | 387 | ||
422 | 349 | if (status != DBUS_START_REPLY_SUCCESS && status != DBUS_START_REPLY_ALREADY_RUNNING) { | 388 | if (status != DBUS_START_REPLY_SUCCESS && status != DBUS_START_REPLY_ALREADY_RUNNING) { |
423 | 350 | g_warning("Status of starting the process '%s' was an error: %d", priv->name, status); | 389 | g_warning("Status of starting the process '%s' was an error: %d", priv->name, status); |
424 | 390 | start_service_again(INDICATOR_SERVICE_MANAGER(user_data)); | ||
425 | 351 | return; | 391 | return; |
426 | 352 | } | 392 | } |
427 | 353 | 393 | ||
428 | @@ -358,6 +398,7 @@ | |||
429 | 358 | INDICATOR_SERVICE_INTERFACE, | 398 | INDICATOR_SERVICE_INTERFACE, |
430 | 359 | &error); | 399 | &error); |
431 | 360 | g_object_add_weak_pointer(G_OBJECT(priv->service_proxy), (gpointer *)&(priv->service_proxy)); | 400 | g_object_add_weak_pointer(G_OBJECT(priv->service_proxy), (gpointer *)&(priv->service_proxy)); |
432 | 401 | g_signal_connect(G_OBJECT(priv->service_proxy), "destroy", G_CALLBACK(service_proxy_destroyed), user_data); | ||
433 | 361 | 402 | ||
434 | 362 | org_ayatana_indicator_service_watch_async(priv->service_proxy, | 403 | org_ayatana_indicator_service_watch_async(priv->service_proxy, |
435 | 363 | watch_cb, | 404 | watch_cb, |
436 | @@ -379,6 +420,11 @@ | |||
437 | 379 | g_return_if_fail(priv->dbus_proxy != NULL); | 420 | g_return_if_fail(priv->dbus_proxy != NULL); |
438 | 380 | g_return_if_fail(priv->name != NULL); | 421 | g_return_if_fail(priv->name != NULL); |
439 | 381 | 422 | ||
440 | 423 | if (priv->service_proxy != NULL) { | ||
441 | 424 | g_object_unref(priv->service_proxy); | ||
442 | 425 | priv->service_proxy = NULL; | ||
443 | 426 | } | ||
444 | 427 | |||
445 | 382 | /* Check to see if we can get a proxy to it first. */ | 428 | /* Check to see if we can get a proxy to it first. */ |
446 | 383 | priv->service_proxy = dbus_g_proxy_new_for_name_owner(priv->bus, | 429 | priv->service_proxy = dbus_g_proxy_new_for_name_owner(priv->bus, |
447 | 384 | priv->name, | 430 | priv->name, |
448 | @@ -396,6 +442,7 @@ | |||
449 | 396 | service); | 442 | service); |
450 | 397 | } else { | 443 | } else { |
451 | 398 | g_object_add_weak_pointer(G_OBJECT(priv->service_proxy), (gpointer *)&(priv->service_proxy)); | 444 | g_object_add_weak_pointer(G_OBJECT(priv->service_proxy), (gpointer *)&(priv->service_proxy)); |
452 | 445 | g_signal_connect(G_OBJECT(priv->service_proxy), "destroy", G_CALLBACK(service_proxy_destroyed), service); | ||
453 | 399 | 446 | ||
454 | 400 | /* If we got a proxy just because we're good people then | 447 | /* If we got a proxy just because we're good people then |
455 | 401 | we need to call watch on it just like 'start_service_cb' | 448 | we need to call watch on it just like 'start_service_cb' |
456 | @@ -408,6 +455,65 @@ | |||
457 | 408 | return; | 455 | return; |
458 | 409 | } | 456 | } |
459 | 410 | 457 | ||
460 | 458 | /* Responds to the destory event of the proxy and starts | ||
461 | 459 | setting up to restart the service. */ | ||
462 | 460 | static void | ||
463 | 461 | service_proxy_destroyed (DBusGProxy * proxy, gpointer user_data) | ||
464 | 462 | { | ||
465 | 463 | IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data); | ||
466 | 464 | if (priv->connected) { | ||
467 | 465 | priv->connected = FALSE; | ||
468 | 466 | g_signal_emit(G_OBJECT(user_data), signals[CONNECTION_CHANGE], 0, FALSE, TRUE); | ||
469 | 467 | } | ||
470 | 468 | return start_service_again(INDICATOR_SERVICE_MANAGER(user_data)); | ||
471 | 469 | } | ||
472 | 470 | |||
473 | 471 | /* The callback that starts the service for real after | ||
474 | 472 | the timeout as determined in 'start_service_again'. | ||
475 | 473 | This could be in the idle or a timer. */ | ||
476 | 474 | static gboolean | ||
477 | 475 | start_service_again_cb (gpointer data) | ||
478 | 476 | { | ||
479 | 477 | IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(data); | ||
480 | 478 | priv->restart_count++; | ||
481 | 479 | start_service(INDICATOR_SERVICE_MANAGER(data)); | ||
482 | 480 | priv->restart_source = 0; | ||
483 | 481 | return FALSE; | ||
484 | 482 | } | ||
485 | 483 | |||
486 | 484 | /* This function tries to start a new service, perhaps | ||
487 | 485 | after a timeout that it determines. The real issue | ||
488 | 486 | here is that it throttles restarting if we're not | ||
489 | 487 | being successful. */ | ||
490 | 488 | static void | ||
491 | 489 | start_service_again (IndicatorServiceManager * manager) | ||
492 | 490 | { | ||
493 | 491 | IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(manager); | ||
494 | 492 | |||
495 | 493 | /* If we've already got a restart source running then | ||
496 | 494 | let's not do this again. */ | ||
497 | 495 | if (priv->restart_source != 0) { | ||
498 | 496 | return; | ||
499 | 497 | } | ||
500 | 498 | |||
501 | 499 | /* Allow the restarting to be disabled */ | ||
502 | 500 | if (g_getenv(TIMEOUT_ENV_NAME)) { | ||
503 | 501 | return; | ||
504 | 502 | } | ||
505 | 503 | |||
506 | 504 | if (priv->restart_count == 0) { | ||
507 | 505 | /* First time, do it in idle */ | ||
508 | 506 | g_idle_add(start_service_again_cb, manager); | ||
509 | 507 | } else { | ||
510 | 508 | /* Not our first time 'round the block. Let's slow this down. */ | ||
511 | 509 | if (priv->restart_count > 16) | ||
512 | 510 | priv->restart_count = 16; /* Not more than 1024x */ | ||
513 | 511 | priv->restart_source = g_timeout_add((1 << priv->restart_count) * TIMEOUT_MULTIPLIER, start_service_again_cb, manager); | ||
514 | 512 | } | ||
515 | 513 | |||
516 | 514 | return; | ||
517 | 515 | } | ||
518 | 516 | |||
519 | 411 | /* API */ | 517 | /* API */ |
520 | 412 | 518 | ||
521 | 413 | /** | 519 | /** |
522 | 414 | 520 | ||
523 | === modified file 'tests/dummy-indicator-signaler.c' | |||
524 | --- tests/dummy-indicator-signaler.c 2009-11-04 17:14:22 +0000 | |||
525 | +++ tests/dummy-indicator-signaler.c 2010-01-21 19:20:25 +0000 | |||
526 | @@ -81,6 +81,7 @@ | |||
527 | 81 | 81 | ||
528 | 82 | g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, GUINT_TO_POINTER(5), TRUE); | 82 | g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, GUINT_TO_POINTER(5), TRUE); |
529 | 83 | g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, GUINT_TO_POINTER(5), TRUE); | 83 | g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, GUINT_TO_POINTER(5), TRUE); |
530 | 84 | g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID, 0, GUINT_TO_POINTER(5), 0, 1, TRUE); | ||
531 | 84 | 85 | ||
532 | 85 | return FALSE; /* Don't queue again */ | 86 | return FALSE; /* Don't queue again */ |
533 | 86 | } | 87 | } |
534 | 87 | 88 | ||
535 | === modified file 'tests/test-loader.c' | |||
536 | --- tests/test-loader.c 2009-11-04 17:14:22 +0000 | |||
537 | +++ tests/test-loader.c 2010-01-21 19:20:25 +0000 | |||
538 | @@ -12,15 +12,22 @@ | |||
539 | 12 | } | 12 | } |
540 | 13 | 13 | ||
541 | 14 | void | 14 | void |
542 | 15 | entry_move_cb (IndicatorObject * io, IndicatorObjectEntry * entry, gint old, gint new, gpointer data) | ||
543 | 16 | { | ||
544 | 17 | return entry_change_cb(io, entry, data); | ||
545 | 18 | } | ||
546 | 19 | |||
547 | 20 | void | ||
548 | 15 | test_loader_filename_dummy_signaler (void) | 21 | test_loader_filename_dummy_signaler (void) |
549 | 16 | { | 22 | { |
550 | 17 | IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-signaler.so"); | 23 | IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-signaler.so"); |
551 | 18 | g_assert(object != NULL); | 24 | g_assert(object != NULL); |
552 | 19 | 25 | ||
554 | 20 | gpointer added_value = NULL, removed_value = NULL; | 26 | gpointer added_value = NULL, removed_value = NULL, moved_value = NULL; |
555 | 21 | 27 | ||
556 | 22 | g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_change_cb), &added_value); | 28 | g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_change_cb), &added_value); |
557 | 23 | g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_change_cb), &removed_value); | 29 | g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_change_cb), &removed_value); |
558 | 30 | g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_move_cb), &moved_value); | ||
559 | 24 | 31 | ||
560 | 25 | GList * list = indicator_object_get_entries(object); | 32 | GList * list = indicator_object_get_entries(object); |
561 | 26 | g_assert(list != NULL); | 33 | g_assert(list != NULL); |
562 | @@ -32,12 +39,30 @@ | |||
563 | 32 | 39 | ||
564 | 33 | g_assert(GPOINTER_TO_UINT(added_value) == 5); | 40 | g_assert(GPOINTER_TO_UINT(added_value) == 5); |
565 | 34 | g_assert(GPOINTER_TO_UINT(removed_value) == 5); | 41 | g_assert(GPOINTER_TO_UINT(removed_value) == 5); |
572 | 35 | 42 | g_assert(GPOINTER_TO_UINT(moved_value) == 5); | |
573 | 36 | g_object_unref(object); | 43 | |
574 | 37 | 44 | g_object_unref(object); | |
575 | 38 | return; | 45 | |
576 | 39 | } | 46 | return; |
577 | 40 | 47 | } | |
578 | 48 | |||
579 | 49 | void | ||
580 | 50 | test_loader_filename_dummy_simple_location (void) | ||
581 | 51 | { | ||
582 | 52 | IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-simple.so"); | ||
583 | 53 | g_assert(object != NULL); | ||
584 | 54 | |||
585 | 55 | GList * entries = indicator_object_get_entries(object); | ||
586 | 56 | g_assert(entries != NULL); | ||
587 | 57 | g_assert(g_list_length(entries) == 1); | ||
588 | 58 | |||
589 | 59 | g_assert(indicator_object_get_location(object, (IndicatorObjectEntry *)entries->data) == 0); | ||
590 | 60 | g_assert(indicator_object_get_location(object, NULL) == 0); | ||
591 | 61 | |||
592 | 62 | g_object_unref(object); | ||
593 | 63 | |||
594 | 64 | return; | ||
595 | 65 | } | ||
596 | 41 | 66 | ||
597 | 42 | void | 67 | void |
598 | 43 | test_loader_filename_dummy_simple_accessors (void) | 68 | test_loader_filename_dummy_simple_accessors (void) |
599 | @@ -125,6 +150,7 @@ | |||
600 | 125 | g_test_add_func ("/libindicator/loader/dummy/blank_load", test_loader_filename_dummy_null); | 150 | g_test_add_func ("/libindicator/loader/dummy/blank_load", test_loader_filename_dummy_null); |
601 | 126 | g_test_add_func ("/libindicator/loader/dummy/simple_load", test_loader_filename_dummy_simple); | 151 | g_test_add_func ("/libindicator/loader/dummy/simple_load", test_loader_filename_dummy_simple); |
602 | 127 | g_test_add_func ("/libindicator/loader/dummy/simple_accessors", test_loader_filename_dummy_simple_accessors); | 152 | g_test_add_func ("/libindicator/loader/dummy/simple_accessors", test_loader_filename_dummy_simple_accessors); |
603 | 153 | g_test_add_func ("/libindicator/loader/dummy/simple_location", test_loader_filename_dummy_simple_location); | ||
604 | 128 | g_test_add_func ("/libindicator/loader/dummy/signaler", test_loader_filename_dummy_signaler); | 154 | g_test_add_func ("/libindicator/loader/dummy/signaler", test_loader_filename_dummy_signaler); |
605 | 129 | 155 | ||
606 | 130 | return; | 156 | return; |
0.3.1