Merge lp:~ted/libindicate/messages-v2 into lp:libindicate/0.6
- messages-v2
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | not available | ||||||||
Proposed branch: | lp:~ted/libindicate/messages-v2 | ||||||||
Merge into: | lp:libindicate/0.6 | ||||||||
Diff against target: | None lines | ||||||||
To merge this branch: | bzr merge lp:~ted/libindicate/messages-v2 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Barth | Approve | ||
Aurélien Gâteau (community) | Needs Information | ||
Review via email: mp+10954@code.launchpad.net |
Commit message
Description of the change
Ted Gould (ted) wrote : | # |
Aurélien Gâteau (agateau) wrote : | # |
(I mostly reviewed the API, not much of the internal changes)
I see the server parameter has been removed from the IndicatorAdded and IndicatorRemoved signals. Does this mean the indicator id is now globally unique?
There is a missing word in doc for INDICATE_
indicate_
typo in doc: effects => affects
I would have called this function indicate_
indicate_
I would have called this function indicate_
Question: do we still need the concept of Interest?
And oh, indentation is really... creative
Ted Gould (ted) wrote : | # |
On Tue, 2009-09-01 at 15:13 +0000, Aurélien Gâteau wrote:
> I see the server parameter has been removed from the IndicatorAdded
> and IndicatorRemoved signals. Does this mean the indicator id is
> now globally unique?
It should be unique per server. So the combination of the server dbus
ID and the indicator ID should yield a unique combination.
> There is a missing word in doc for INDICATE_
Actually it was just really bad grammar :) (r385)
> indicate_
> typo in doc: effects => affects
Fixed. (r386)
> I would have called this function indicate_
>
> indicate_
> I would have called this function indicate_
Fixed. (r387)
> Question: do we still need the concept of Interest?
Yes, we do need it for the server interest items. It's less useful for
the items no for sure. But, in theory we're not requiring setting a max
number of indicators (even infinite) so you could say that you're
interested without setting a value. But, we could change that as well.
> And oh, indentation is really... creative
It's the only way to make tabstop be configurable :)
- 385. By Ted Gould
-
Fixing bad grammar in comment. From code review by Aurelien.
- 386. By Ted Gould
-
affects vs. effects. Code review comment by Aurelien.
- 387. By Ted Gould
-
Adding a _set_ in the function names for consistency with the rest of the API.
- 388. By Ted Gould
-
Adding bug lp:418661
- 389. By Ted Gould
-
Adding bug lp:418657
Aurélien Gâteau (agateau) wrote : | # |
Ted Gould wrote:
>> Question: do we still need the concept of Interest?
>
> Yes, we do need it for the server interest items. It's less useful for
> the items no for sure. But, in theory we're not requiring setting a max
> number of indicators (even infinite) so you could say that you're
> interested without setting a value. But, we could change that as well.
Not sure i get it, but it's not a problem I guess I can just bind it in
libindicate-qt and not use it :)
Aurelien
- 390. By Ted Gould
-
Merging in tests for the v2 features.
- 391. By Ted Gould
-
Moving the package config files back to the normal names. I don't see any reason to change them. It seems a little silly.
- 392. By Ted Gould
-
Setting version to 0.2.0
- 393. By Ted Gould
-
Who would be stupid enough to use all these casts and not the macros provided. 'bzr blame' Oh, it was me.
- 394. By Ted Gould
-
Error found in dbusmenu, but we just stole this code, so we should fix it here too ;)
- 395. By Ted Gould
-
Adding back in the indicator-messages header to store value for the values we're using to signal the messaging menu.
David Barth (dbarth) wrote : | # |
That's a huge merge. Letting it go in to unblock the process.
I think we still need an indicator-
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2009-08-07 15:06:32 +0000 |
3 | +++ .bzrignore 2009-08-31 13:23:29 +0000 |
4 | @@ -103,3 +103,40 @@ |
5 | data/GNOME_IndicatorAppletSUS.server |
6 | data/GNOME_IndicatorAppletSUS.server.in |
7 | src-sus/indicator-applet-no-sus |
8 | +docs/reference/libindicate-decl-list.txt.bak |
9 | +docs/reference/libindicate-decl.txt.bak |
10 | +INSTALL |
11 | +Makefile |
12 | +Makefile.in |
13 | +aclocal.m4 |
14 | +autom4te.cache |
15 | +config.guess |
16 | +config.h |
17 | +config.h.in |
18 | +config.log |
19 | +config.status |
20 | +config.sub |
21 | +configure |
22 | +depcomp |
23 | +gnome-doc-utils.make |
24 | +install-sh |
25 | +libtool |
26 | +ltmain.sh |
27 | +missing |
28 | +omf.make |
29 | +stamp-h1 |
30 | +xmldocs.make |
31 | +docs/Makefile |
32 | +docs/Makefile.in |
33 | +docs/reference/Makefile |
34 | +docs/reference/Makefile.in |
35 | +examples/Makefile |
36 | +examples/Makefile.in |
37 | +libindicate/Makefile |
38 | +libindicate/Makefile.in |
39 | +libindicate/indicate-0.2.pc |
40 | +libindicate-gtk/Makefile |
41 | +libindicate-gtk/Makefile.in |
42 | +libindicate-gtk/indicate-gtk-0.2.pc |
43 | +tests/Makefile |
44 | +tests/Makefile.in |
45 | |
46 | === modified file 'configure.ac' |
47 | --- configure.ac 2009-08-19 16:36:49 +0000 |
48 | +++ configure.ac 2009-08-28 21:23:15 +0000 |
49 | @@ -24,7 +24,7 @@ |
50 | # Libindicate versioning |
51 | ########################### |
52 | |
53 | -LIBINDICATE_CURRENT=2 |
54 | +LIBINDICATE_CURRENT=3 |
55 | LIBINDICATE_REVISION=0 |
56 | LIBINDICATE_AGE=0 |
57 | |
58 | @@ -36,7 +36,7 @@ |
59 | # Libindicate versioning |
60 | ########################### |
61 | |
62 | -LIBINDICATEGTK_CURRENT=0 |
63 | +LIBINDICATEGTK_CURRENT=1 |
64 | LIBINDICATEGTK_REVISION=0 |
65 | LIBINDICATEGTK_AGE=0 |
66 | |
67 | @@ -159,9 +159,9 @@ |
68 | AC_OUTPUT([ |
69 | Makefile |
70 | libindicate/Makefile |
71 | -libindicate/indicate.pc |
72 | +libindicate/indicate-0.2.pc |
73 | libindicate-gtk/Makefile |
74 | -libindicate-gtk/indicate-gtk.pc |
75 | +libindicate-gtk/indicate-gtk-0.2.pc |
76 | examples/Makefile |
77 | tests/Makefile |
78 | docs/Makefile |
79 | |
80 | === modified file 'docs/reference/libindicate-sections.txt' |
81 | --- docs/reference/libindicate-sections.txt 2009-05-01 03:30:04 +0000 |
82 | +++ docs/reference/libindicate-sections.txt 2009-08-31 20:06:58 +0000 |
83 | @@ -6,38 +6,24 @@ |
84 | IndicateIndicator |
85 | IndicateIndicatorClass |
86 | indicate_indicator_get_id |
87 | -indicate_indicator_get_indicator_type |
88 | indicate_indicator_get_property |
89 | indicate_indicator_hide |
90 | indicate_indicator_is_visible |
91 | indicate_indicator_list_properties |
92 | indicate_indicator_new |
93 | indicate_indicator_set_property |
94 | -indicate_indicator_set_property_icon |
95 | indicate_indicator_set_property_time |
96 | indicate_indicator_show |
97 | indicate_indicator_user_display |
98 | </SECTION> |
99 | |
100 | <SECTION> |
101 | -<FILE>indicator-message</FILE> |
102 | -<TITLE>IndicateIndicatorMessage</TITLE> |
103 | -IndicateIndicatorMessage |
104 | -IndicateIndicatorMessageClass |
105 | -indicate_indicator_message_new |
106 | -</SECTION> |
107 | - |
108 | -<SECTION> |
109 | <FILE>server</FILE> |
110 | <TITLE>IndicateServer</TITLE> |
111 | IndicateServer |
112 | IndicateServerClass |
113 | indicate_server_add_indicator |
114 | indicate_server_check_interest |
115 | -indicate_server_emit_indicator_added |
116 | -indicate_server_emit_indicator_modified |
117 | -indicate_server_emit_indicator_removed |
118 | -indicate_server_emit_server_display |
119 | indicate_server_get_next_id |
120 | indicate_server_hide |
121 | indicate_server_ref_default |
122 | |
123 | === modified file 'docs/reference/libindicate.types' |
124 | --- docs/reference/libindicate.types 2009-02-03 13:56:35 +0000 |
125 | +++ docs/reference/libindicate.types 2009-08-28 20:58:09 +0000 |
126 | @@ -1,9 +1,7 @@ |
127 | #include <libindicate/indicator.h> |
128 | -#include <libindicate/indicator-message.h> |
129 | #include <libindicate/server.h> |
130 | #include <libindicate/listener.h> |
131 | |
132 | indicate_indicator_get_type |
133 | -indicate_indicator_message_get_type |
134 | indicate_server_get_type |
135 | indicate_listener_get_type |
136 | |
137 | === modified file 'docs/reference/tmpl/libindicate-unused.sgml' |
138 | --- docs/reference/tmpl/libindicate-unused.sgml 2009-08-03 22:53:40 +0000 |
139 | +++ docs/reference/tmpl/libindicate-unused.sgml 2009-09-01 01:31:28 +0000 |
140 | @@ -1,3 +1,63 @@ |
141 | +<!-- ##### SECTION ./tmpl/indicator-message.sgml:Long_Description ##### --> |
142 | +<para> |
143 | + |
144 | +</para> |
145 | + |
146 | + |
147 | +<!-- ##### SECTION ./tmpl/indicator-message.sgml:See_Also ##### --> |
148 | +<para> |
149 | + |
150 | +</para> |
151 | + |
152 | + |
153 | +<!-- ##### SECTION ./tmpl/indicator-message.sgml:Short_Description ##### --> |
154 | + |
155 | + |
156 | + |
157 | +<!-- ##### SECTION ./tmpl/indicator-message.sgml:Stability_Level ##### --> |
158 | + |
159 | + |
160 | + |
161 | +<!-- ##### SECTION ./tmpl/indicator-message.sgml:Title ##### --> |
162 | +IndicateIndicatorMessage |
163 | + |
164 | + |
165 | +<!-- ##### STRUCT IndicateIndicatorMessage ##### --> |
166 | +<para> |
167 | + |
168 | +</para> |
169 | + |
170 | + |
171 | +<!-- ##### STRUCT IndicateIndicatorMessageClass ##### --> |
172 | +<para> |
173 | + |
174 | +</para> |
175 | + |
176 | +@parent_class: |
177 | + |
178 | +<!-- ##### SIGNAL IndicateServer::indicator-not-shown ##### --> |
179 | +<para> |
180 | + |
181 | +</para> |
182 | + |
183 | +@indicateserver: the object which received the signal. |
184 | +@arg1: |
185 | + |
186 | +<!-- ##### FUNCTION indicate_indicator_get_indicator_type ##### --> |
187 | +<para> |
188 | + |
189 | +</para> |
190 | + |
191 | +@indicator: |
192 | +@Returns: |
193 | + |
194 | +<!-- ##### FUNCTION indicate_indicator_message_new ##### --> |
195 | +<para> |
196 | + |
197 | +</para> |
198 | + |
199 | +@Returns: |
200 | + |
201 | <!-- ##### FUNCTION indicate_indicator_set_property_icon ##### --> |
202 | <para> |
203 | |
204 | @@ -7,6 +67,40 @@ |
205 | @key: |
206 | @data: |
207 | |
208 | +<!-- ##### FUNCTION indicate_server_emit_indicator_added ##### --> |
209 | +<para> |
210 | + |
211 | +</para> |
212 | + |
213 | +@server: |
214 | +@id: |
215 | +@type: |
216 | + |
217 | +<!-- ##### FUNCTION indicate_server_emit_indicator_modified ##### --> |
218 | +<para> |
219 | + |
220 | +</para> |
221 | + |
222 | +@server: |
223 | +@id: |
224 | +@property: |
225 | + |
226 | +<!-- ##### FUNCTION indicate_server_emit_indicator_removed ##### --> |
227 | +<para> |
228 | + |
229 | +</para> |
230 | + |
231 | +@server: |
232 | +@id: |
233 | +@type: |
234 | + |
235 | +<!-- ##### FUNCTION indicate_server_emit_server_display ##### --> |
236 | +<para> |
237 | + |
238 | +</para> |
239 | + |
240 | +@server: |
241 | + |
242 | <!-- ##### FUNCTION indicate_server_new ##### --> |
243 | <para> |
244 | |
245 | |
246 | === modified file 'examples/im-client.c' |
247 | --- examples/im-client.c 2009-08-03 22:49:42 +0000 |
248 | +++ examples/im-client.c 2009-08-28 19:40:56 +0000 |
249 | @@ -21,7 +21,7 @@ |
250 | |
251 | #include <glib.h> |
252 | #include "libindicate/server.h" |
253 | -#include "libindicate/indicator-message.h" |
254 | +#include "libindicate/indicator.h" |
255 | #include "libindicate-gtk/indicator.h" |
256 | |
257 | gchar * patha = "/usr/share/icons/hicolor/16x16/apps/empathy.png"; |
258 | @@ -69,7 +69,7 @@ |
259 | static void |
260 | interest_added (IndicateServer * server, IndicateInterests interest) |
261 | { |
262 | - g_debug("Oh, someone is interested in my for: %d", interest); |
263 | + g_debug("Oh, someone is interested in me for: %d", interest); |
264 | } |
265 | |
266 | void |
267 | @@ -90,9 +90,9 @@ |
268 | g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_INTEREST_ADDED, G_CALLBACK(interest_added), NULL); |
269 | g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_INTEREST_REMOVED, G_CALLBACK(interest_removed), NULL); |
270 | |
271 | - IndicateIndicatorMessage * indicator; |
272 | + IndicateIndicator * indicator; |
273 | |
274 | - indicator = indicate_indicator_message_new(); |
275 | + indicator = indicate_indicator_new(); |
276 | indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "subtype", "im"); |
277 | indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "sender", "IM Client Test"); |
278 | GTimeVal time; g_get_current_time(&time); |
279 | |
280 | === modified file 'examples/show-hide-server.c' |
281 | --- examples/show-hide-server.c 2009-04-07 22:34:45 +0000 |
282 | +++ examples/show-hide-server.c 2009-08-28 19:40:56 +0000 |
283 | @@ -2,7 +2,6 @@ |
284 | |
285 | #include <glib.h> |
286 | #include "libindicate/server.h" |
287 | -#include "libindicate/indicator-message.h" |
288 | |
289 | gboolean hidden = TRUE; |
290 | |
291 | @@ -12,14 +11,14 @@ |
292 | IndicateServer * server = INDICATE_SERVER(data); |
293 | |
294 | if (hidden) { |
295 | - printf("showing... "); |
296 | + g_debug("showing... "); |
297 | indicate_server_show(server); |
298 | - printf("ok\n"); |
299 | + g_debug("ok\n"); |
300 | hidden = FALSE; |
301 | } else { |
302 | - printf("hiding... "); |
303 | + g_debug("hiding... "); |
304 | indicate_server_hide(server); |
305 | - printf("ok\n"); |
306 | + g_debug("ok\n"); |
307 | hidden = TRUE; |
308 | } |
309 | |
310 | |
311 | === modified file 'libindicate-gtk/Makefile.am' |
312 | --- libindicate-gtk/Makefile.am 2009-08-04 00:26:10 +0000 |
313 | +++ libindicate-gtk/Makefile.am 2009-08-28 21:20:52 +0000 |
314 | @@ -3,12 +3,12 @@ |
315 | -DG_LOG_DOMAIN=\"libindicate-gtk\" |
316 | |
317 | EXTRA_DIST = \ |
318 | - indicate-gtk.pc.in |
319 | + indicate-gtk-0.2.pc.in |
320 | |
321 | lib_LTLIBRARIES = \ |
322 | libindicate-gtk.la |
323 | |
324 | -libindicate_gtkincludedir=$(includedir)/libindicate-0.1/libindicate-gtk |
325 | +libindicate_gtkincludedir=$(includedir)/libindicate-0.2/libindicate-gtk |
326 | |
327 | indicate_gtk_headers = \ |
328 | indicator.h \ |
329 | @@ -35,7 +35,7 @@ |
330 | ../libindicate/libindicate.la \ |
331 | $(LIBINDICATEGTK_LIBS) |
332 | |
333 | -pkgconfig_DATA = indicate-gtk.pc |
334 | +pkgconfig_DATA = indicate-gtk-0.2.pc |
335 | pkgconfigdir = $(libdir)/pkgconfig |
336 | |
337 | if USE_GIR |
338 | |
339 | === renamed file 'libindicate-gtk/indicate-gtk.pc.in' => 'libindicate-gtk/indicate-gtk-0.2.pc.in' |
340 | --- libindicate-gtk/indicate-gtk.pc.in 2009-08-03 18:10:34 +0000 |
341 | +++ libindicate-gtk/indicate-gtk-0.2.pc.in 2009-08-28 21:20:52 +0000 |
342 | @@ -4,7 +4,7 @@ |
343 | bindir=@bindir@ |
344 | includedir=@includedir@ |
345 | |
346 | -Cflags: -I${includedir}/libindicate-0.1 |
347 | +Cflags: -I${includedir}/libindicate-0.2 |
348 | Requires: gtk+-2.0 indicate |
349 | Libs: -L${libdir} -lindicate-gtk |
350 | |
351 | |
352 | === modified file 'libindicate/Makefile.am' |
353 | --- libindicate/Makefile.am 2009-08-03 22:31:00 +0000 |
354 | +++ libindicate/Makefile.am 2009-08-31 20:05:48 +0000 |
355 | @@ -10,7 +10,7 @@ |
356 | indicate-listener.xml \ |
357 | listener-marshal.list \ |
358 | server-marshal.list \ |
359 | - indicate.pc.in |
360 | + indicate-0.2.pc.in |
361 | |
362 | BUILT_SOURCES = \ |
363 | dbus-indicate-server.h \ |
364 | @@ -27,11 +27,10 @@ |
365 | lib_LTLIBRARIES = \ |
366 | libindicate.la |
367 | |
368 | -libindicateincludedir=$(includedir)/libindicate-0.1/libindicate |
369 | +libindicateincludedir=$(includedir)/libindicate-0.2/libindicate |
370 | |
371 | indicate_headers = \ |
372 | indicator.h \ |
373 | - indicator-message.h \ |
374 | listener.h \ |
375 | server.h \ |
376 | interests.h \ |
377 | @@ -55,7 +54,6 @@ |
378 | listener-marshal.h \ |
379 | listener-private.h \ |
380 | indicator.c \ |
381 | - indicator-message.c \ |
382 | interests-priv.h |
383 | |
384 | libindicate_la_LDFLAGS = \ |
385 | @@ -64,7 +62,8 @@ |
386 | -export-symbols-regex "^[^_d].*" |
387 | |
388 | libindicate_la_CFLAGS = \ |
389 | - $(LIBINDICATE_CFLAGS) |
390 | + $(LIBINDICATE_CFLAGS) \ |
391 | + -Wall -Werror |
392 | |
393 | libindicate_la_LIBADD = \ |
394 | $(LIBINDICATE_LIBS) |
395 | @@ -117,7 +116,7 @@ |
396 | --prefix=_indicate_server_marshal $(srcdir)/server-marshal.list \ |
397 | > server-marshal.c |
398 | |
399 | -pkgconfig_DATA = indicate.pc |
400 | +pkgconfig_DATA = indicate-0.2.pc |
401 | pkgconfigdir = $(libdir)/pkgconfig |
402 | |
403 | $(ENUM_FILE).h: s-enum-types-h |
404 | @@ -148,40 +147,39 @@ |
405 | && echo timestamp > $(@F) |
406 | |
407 | CLEANFILES = \ |
408 | - $(ENUM_FILE).c \ |
409 | - $(ENUM_FILE).h \ |
410 | + $(BUILT_SOURCES) \ |
411 | s-enum-types-c \ |
412 | s-enum-types-h |
413 | |
414 | if USE_GIR |
415 | |
416 | gobjectintrospection_gir_DATA = \ |
417 | - Indicate-0.1.gir |
418 | + Indicate-0.2.gir |
419 | gobjectintrospection_girdir = $(datadir)/gir |
420 | |
421 | gobjectintrospection_type_DATA = \ |
422 | - Indicate-0.1.typelib |
423 | + Indicate-0.2.typelib |
424 | gobjectintrospection_typedir = $(libdir)/girepository |
425 | |
426 | irscanner_headers = $(patsubst %,$(srcdir)/%,$(indicate_headers)) |
427 | -Indicate-0.1.gir: $(irscanner_headers) |
428 | +Indicate-0.2.gir: $(irscanner_headers) Makefile |
429 | $(G_IR_SCANNER) \ |
430 | -v --namespace Indicate \ |
431 | - --nsversion=0.1 \ |
432 | + --nsversion=0.2 \ |
433 | --add-include-path=$(srcdir) \ |
434 | --include=GObject-2.0 \ |
435 | --include=GLib-2.0 \ |
436 | --include=GdkPixbuf-2.0 \ |
437 | --library=indicate --pkg indicate \ |
438 | - --output Indicate-0.1.gir $(irscanner_headers) |
439 | + --output Indicate-0.2.gir $(irscanner_headers) |
440 | |
441 | -Indicate-0.1.typelib: Indicate-0.1.gir |
442 | +Indicate-0.2.typelib: Indicate-0.2.gir |
443 | $(G_IR_COMPILER) \ |
444 | - --includedir=$(srcdir) Indicate-0.1.gir \ |
445 | - -o Indicate-0.1.typelib |
446 | + --includedir=$(srcdir) Indicate-0.2.gir \ |
447 | + -o Indicate-0.2.typelib |
448 | |
449 | DISTCLEANFILES = \ |
450 | - Indicate-0.1.gir \ |
451 | - Indicate-0.1.typelib |
452 | + Indicate-0.2.gir \ |
453 | + Indicate-0.2.typelib |
454 | |
455 | endif |
456 | |
457 | === renamed file 'libindicate/indicate.pc.in' => 'libindicate/indicate-0.2.pc.in' |
458 | --- libindicate/indicate.pc.in 2009-08-04 11:25:24 +0000 |
459 | +++ libindicate/indicate-0.2.pc.in 2009-08-28 21:20:52 +0000 |
460 | @@ -4,7 +4,7 @@ |
461 | bindir=@bindir@ |
462 | includedir=@includedir@ |
463 | |
464 | -Cflags: -I${includedir}/libindicate-0.1 |
465 | +Cflags: -I${includedir}/libindicate-0.2 |
466 | Requires: gobject-2.0 glib-2.0 dbus-glib-1 |
467 | Libs: -L${libdir} -lindicate |
468 | |
469 | |
470 | === modified file 'libindicate/indicate-interface.xml' |
471 | --- libindicate/indicate-interface.xml 2009-04-02 15:49:35 +0000 |
472 | +++ libindicate/indicate-interface.xml 2009-09-01 02:21:31 +0000 |
473 | @@ -31,24 +31,17 @@ |
474 | <interface name="org.freedesktop.indicator"> |
475 | |
476 | <!-- Properties --> |
477 | - <property name="desktop" type="s" access="read"/> |
478 | - <property name="type" type="s" access="read"/> |
479 | + <property name="desktop" type="s" access="read" /> |
480 | + <property name="type" type="s" access="read" /> |
481 | + <property name="count" type="u" access="read" /> |
482 | |
483 | <!-- Functions --> |
484 | <method name="GetIndicatorCount"> |
485 | <arg type="u" name="indicator_count" direction="out" /> |
486 | </method> |
487 | - <method name="GetIndicatorCountByType"> |
488 | - <arg type="s" name="type" direction="in" /> |
489 | - <arg type="u" name="indicator_count" direction="out" /> |
490 | - </method> |
491 | <method name="GetIndicatorList"> |
492 | <arg type="ai" name="indicators" direction="out" /> |
493 | </method> |
494 | - <method name="GetIndicatorListByType"> |
495 | - <arg type="s" name="type" direction="in" /> |
496 | - <arg type="ai" name="indicators" direction="out" /> |
497 | - </method> |
498 | <method name="GetIndicatorProperty"> |
499 | <arg type="u" name="id" direction="in" /> |
500 | <arg type="s" name="property" direction="in" /> |
501 | @@ -66,6 +59,11 @@ |
502 | <method name="ShowIndicatorToUser"> |
503 | <arg type="u" name="id" direction="in" /> |
504 | </method> |
505 | + <method name="IndicatorDisplayed"> |
506 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true" /> |
507 | + <arg type="u" name="id" direction="in" /> |
508 | + <arg type="b" name="displayed" direction="in" /> |
509 | + </method> |
510 | <method name="ShowInterest"> |
511 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true" /> |
512 | <arg type="s" name="interest" direction="in" /> |
513 | @@ -74,16 +72,18 @@ |
514 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true" /> |
515 | <arg type="s" name="interest" direction="in" /> |
516 | </method> |
517 | + <method name="SetMaxIndicators"> |
518 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true" /> |
519 | + <arg type="i" name="max" direction="in" /> |
520 | + </method> |
521 | |
522 | |
523 | <!-- Signals --> |
524 | <signal name="IndicatorAdded"> |
525 | <arg type="u" name="id" direction="out" /> |
526 | - <arg type="s" name="type" direction="out" /> |
527 | </signal> |
528 | <signal name="IndicatorRemoved"> |
529 | <arg type="u" name="id" direction="out" /> |
530 | - <arg type="s" name="type" direction="out" /> |
531 | </signal> |
532 | <signal name="IndicatorModified"> |
533 | <arg type="u" name="id" direction="out" /> |
534 | @@ -95,6 +95,9 @@ |
535 | <signal name="ServerHide"> |
536 | <arg type="s" name="type" direction="out" /> |
537 | </signal> |
538 | + <signal name="ServerCountChanged"> |
539 | + <arg type="u" name="count" direction="out" /> |
540 | + </signal> |
541 | |
542 | |
543 | <!-- End of interesting stuff --> |
544 | |
545 | === removed file 'libindicate/indicator-message.c' |
546 | --- libindicate/indicator-message.c 2009-04-30 21:57:51 +0000 |
547 | +++ libindicate/indicator-message.c 1970-01-01 00:00:00 +0000 |
548 | @@ -1,105 +0,0 @@ |
549 | -/* |
550 | -A library to allow applictions to provide simple indications of |
551 | -information to be displayed to users of the application through the |
552 | -interface shell. |
553 | - |
554 | -Copyright 2009 Canonical Ltd. |
555 | - |
556 | -Authors: |
557 | - Ted Gould <ted@canonical.com> |
558 | - |
559 | -This program is free software: you can redistribute it and/or modify it |
560 | -under the terms of either or both of the following licenses: |
561 | - |
562 | -1) the GNU Lesser General Public License version 3, as published by the |
563 | -Free Software Foundation; and/or |
564 | -2) the GNU Lesser General Public License version 2.1, as published by |
565 | -the Free Software Foundation. |
566 | - |
567 | -This program is distributed in the hope that it will be useful, but |
568 | -WITHOUT ANY WARRANTY; without even the implied warranties of |
569 | -MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
570 | -PURPOSE. See the applicable version of the GNU Lesser General Public |
571 | -License for more details. |
572 | - |
573 | -You should have received a copy of both the GNU Lesser General Public |
574 | -License version 3 and version 2.1 along with this program. If not, see |
575 | -<http://www.gnu.org/licenses/> |
576 | -*/ |
577 | - |
578 | -#ifdef HAVE_CONFIG_H |
579 | -#include "config.h" |
580 | -#endif |
581 | - |
582 | -#include "indicator-message.h" |
583 | - |
584 | -typedef struct _IndicateIndicatorMessagePrivate IndicateIndicatorMessagePrivate; |
585 | - |
586 | -struct _IndicateIndicatorMessagePrivate |
587 | -{ |
588 | - gchar * subtype; |
589 | -}; |
590 | - |
591 | -#define INDICATE_INDICATOR_MESSAGE_GET_PRIVATE(o) \ |
592 | -(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATE_INDICATOR_MESSAGE_TYPE, IndicateIndicatorMessagePrivate)) |
593 | - |
594 | -static void indicate_indicator_message_class_init (IndicateIndicatorMessageClass *klass); |
595 | -static void indicate_indicator_message_init (IndicateIndicatorMessage *self); |
596 | -static void indicate_indicator_message_dispose (GObject *object); |
597 | -static void indicate_indicator_message_finalize (GObject *object); |
598 | -static const gchar * get_indicator_type (IndicateIndicator * indicator); |
599 | - |
600 | -G_DEFINE_TYPE (IndicateIndicatorMessage, indicate_indicator_message, INDICATE_TYPE_INDICATOR); |
601 | - |
602 | -static void |
603 | -indicate_indicator_message_class_init (IndicateIndicatorMessageClass *klass) |
604 | -{ |
605 | - GObjectClass *object_class = G_OBJECT_CLASS (klass); |
606 | - |
607 | - g_type_class_add_private (klass, sizeof (IndicateIndicatorMessagePrivate)); |
608 | - |
609 | - object_class->dispose = indicate_indicator_message_dispose; |
610 | - object_class->finalize = indicate_indicator_message_finalize; |
611 | - |
612 | - IndicateIndicatorClass * indicator_class = INDICATE_INDICATOR_CLASS(klass); |
613 | - |
614 | - indicator_class->get_type = get_indicator_type; |
615 | - |
616 | - return; |
617 | -} |
618 | - |
619 | -static void |
620 | -indicate_indicator_message_init (IndicateIndicatorMessage *self) |
621 | -{ |
622 | -} |
623 | - |
624 | -static void |
625 | -indicate_indicator_message_dispose (GObject *object) |
626 | -{ |
627 | -G_OBJECT_CLASS (indicate_indicator_message_parent_class)->dispose (object); |
628 | -} |
629 | - |
630 | -static void |
631 | -indicate_indicator_message_finalize (GObject *object) |
632 | -{ |
633 | -G_OBJECT_CLASS (indicate_indicator_message_parent_class)->finalize (object); |
634 | -} |
635 | - |
636 | -/** |
637 | - indicate_indicator_message_new: |
638 | - |
639 | - Builds a new indicator message object using #g_object_new. |
640 | - |
641 | - Return value: A pointer to a new #IndicateIndicatorMessage object. |
642 | -*/ |
643 | -static const gchar * |
644 | -get_indicator_type (IndicateIndicator * indicator) |
645 | -{ |
646 | - return "message"; |
647 | -} |
648 | - |
649 | -IndicateIndicatorMessage * |
650 | -indicate_indicator_message_new (void) |
651 | -{ |
652 | - return g_object_new(INDICATE_TYPE_INDICATOR_MESSAGE, NULL); |
653 | -} |
654 | |
655 | === removed file 'libindicate/indicator-message.h' |
656 | --- libindicate/indicator-message.h 2009-05-01 02:45:19 +0000 |
657 | +++ libindicate/indicator-message.h 1970-01-01 00:00:00 +0000 |
658 | @@ -1,92 +0,0 @@ |
659 | -/* |
660 | -A library to allow applictions to provide simple indications of |
661 | -information to be displayed to users of the application through the |
662 | -interface shell. |
663 | - |
664 | -Copyright 2009 Canonical Ltd. |
665 | - |
666 | -Authors: |
667 | - Ted Gould <ted@canonical.com> |
668 | - |
669 | -This program is free software: you can redistribute it and/or modify it |
670 | -under the terms of either or both of the following licenses: |
671 | - |
672 | -1) the GNU Lesser General Public License version 3, as published by the |
673 | -Free Software Foundation; and/or |
674 | -2) the GNU Lesser General Public License version 2.1, as published by |
675 | -the Free Software Foundation. |
676 | - |
677 | -This program is distributed in the hope that it will be useful, but |
678 | -WITHOUT ANY WARRANTY; without even the implied warranties of |
679 | -MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
680 | -PURPOSE. See the applicable version of the GNU Lesser General Public |
681 | -License for more details. |
682 | - |
683 | -You should have received a copy of both the GNU Lesser General Public |
684 | -License version 3 and version 2.1 along with this program. If not, see |
685 | -<http://www.gnu.org/licenses/> |
686 | -*/ |
687 | - |
688 | -#ifndef __INDICATE_INDICATOR_MESSAGE_H__ |
689 | -#define __INDICATE_INDICATOR_MESSAGE_H__ |
690 | - |
691 | -#include <glib.h> |
692 | -#include <glib-object.h> |
693 | - |
694 | -#include "indicator.h" |
695 | - |
696 | -G_BEGIN_DECLS |
697 | - |
698 | -#define INDICATE_TYPE_INDICATOR_MESSAGE (indicate_indicator_message_get_type ()) |
699 | -#define INDICATE_INDICATOR_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATE_TYPE_INDICATOR_MESSAGE, IndicateIndicatorMessage)) |
700 | -#define INDICATE_INDICATOR_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATE_TYPE_INDICATOR_MESSAGE, IndicateIndicatorMessageClass)) |
701 | -#define INDICATE_IS_INDICATOR_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATE_TYPE_INDICATOR_MESSAGE)) |
702 | -#define INDICATE_IS_INDICATOR_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATE_TYPE_INDICATOR_MESSAGE)) |
703 | -#define INDICATE_INDICATOR_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATE_TYPE_INDICATOR_MESSAGE, IndicateIndicatorMessageClass)) |
704 | - |
705 | -typedef struct _IndicateIndicatorMessage IndicateIndicatorMessage; |
706 | -typedef struct _IndicateIndicatorMessageClass IndicateIndicatorMessageClass; |
707 | - |
708 | -/** |
709 | - IndicateIndicatorMessageClass: |
710 | - @parent_class: Parent Class |
711 | - |
712 | - Subclass of #IndicateIndicator with no new functions or signals. |
713 | -*/ |
714 | -struct _IndicateIndicatorMessageClass { |
715 | - IndicateIndicatorClass parent_class; |
716 | -}; |
717 | - |
718 | -/** |
719 | - IndicateIndicatorMessage: |
720 | - |
721 | - A class to represent indicators who's 'type' is "message". These |
722 | - are basically indicators that represent messages from humans to |
723 | - humans via computers. Things like instance messages, micro blogging |
724 | - entries or e-mails. All of these qualify as messages. |
725 | - |
726 | - TODO: This should include a list of properties that are supported. |
727 | -*/ |
728 | -struct _IndicateIndicatorMessage { |
729 | - IndicateIndicator parent; |
730 | -}; |
731 | - |
732 | -GType indicate_indicator_message_get_type (void); |
733 | -IndicateIndicatorMessage * indicate_indicator_message_new (void); |
734 | - |
735 | -/** |
736 | - SECTION:indicator-message |
737 | - @short_description: A representation of human generated messages |
738 | - @stability: Unstable |
739 | - @include: libindicate/indicator-message.h |
740 | - |
741 | - The message indicators represent messages that come from humans |
742 | - to humans using computers. They come in all different forms with |
743 | - various different interaction protocols, but they all want the human |
744 | - at the computer to interact back with the human that sent the |
745 | - message. |
746 | -*/ |
747 | - |
748 | -G_END_DECLS |
749 | - |
750 | -#endif |
751 | |
752 | === modified file 'libindicate/indicator.c' |
753 | --- libindicate/indicator.c 2009-08-06 13:57:57 +0000 |
754 | +++ libindicate/indicator.c 2009-08-31 21:26:29 +0000 |
755 | @@ -38,6 +38,7 @@ |
756 | SHOW, |
757 | USER_DISPLAY, |
758 | MODIFIED, |
759 | + DISPLAYED, |
760 | LAST_SIGNAL |
761 | }; |
762 | |
763 | @@ -50,6 +51,7 @@ |
764 | gboolean is_visible; |
765 | IndicateServer * server; |
766 | GHashTable * properties; |
767 | + gboolean is_displayed; |
768 | }; |
769 | |
770 | #define INDICATE_INDICATOR_GET_PRIVATE(o) \ |
771 | @@ -140,8 +142,23 @@ |
772 | NULL, NULL, |
773 | g_cclosure_marshal_VOID__STRING, |
774 | G_TYPE_NONE, 1, G_TYPE_STRING); |
775 | - |
776 | - class->get_type = NULL; |
777 | + /** |
778 | + IndicateIndicator::displayed: |
779 | + @arg0: The #IndicateIndicator object |
780 | + @arg1: Whether the indicator has been displayed |
781 | + |
782 | + This is the signal that the indicator has been displayed, or |
783 | + hidden by a listener. In most cases, it'll be that it's |
784 | + been displayed as most folks don't go changing their mind. |
785 | + */ |
786 | + signals[DISPLAYED] = g_signal_new(INDICATE_INDICATOR_SIGNAL_DISPLAYED, |
787 | + G_TYPE_FROM_CLASS(class), |
788 | + G_SIGNAL_RUN_LAST, |
789 | + G_STRUCT_OFFSET(IndicateIndicatorClass, displayed), |
790 | + NULL, NULL, |
791 | + g_cclosure_marshal_VOID__BOOLEAN, |
792 | + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); |
793 | + |
794 | class->set_property = set_property; |
795 | class->get_property = get_property; |
796 | class->list_properties = list_properties; |
797 | @@ -156,6 +173,7 @@ |
798 | IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator); |
799 | |
800 | priv->is_visible = FALSE; |
801 | + priv->is_displayed = FALSE; |
802 | |
803 | priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
804 | |
805 | @@ -301,6 +319,8 @@ |
806 | |
807 | priv->is_visible = FALSE; |
808 | g_signal_emit(indicator, signals[HIDE], 0, TRUE); |
809 | + priv->is_displayed = FALSE; |
810 | + g_signal_emit(G_OBJECT(indicator), signals[DISPLAYED], 0, priv->is_displayed, TRUE); |
811 | |
812 | return; |
813 | } |
814 | @@ -339,28 +359,6 @@ |
815 | } |
816 | |
817 | /** |
818 | - indicate_indicator_get_indicator_type: |
819 | - @indicator: a #IndicateIndicator to act on |
820 | - |
821 | - Returns the type of @indicator. This is largely set by the subclass |
822 | - that the indicator was built with and should not be free'd. |
823 | - |
824 | - Return value: A string defining the type or NULL for no type. |
825 | -*/ |
826 | -const gchar * |
827 | -indicate_indicator_get_indicator_type (IndicateIndicator * indicator) |
828 | -{ |
829 | - g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), NULL); |
830 | - IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator); |
831 | - |
832 | - if (class->get_type != NULL) { |
833 | - return INDICATE_INDICATOR_GET_CLASS(indicator)->get_type(indicator); |
834 | - } |
835 | - |
836 | - return NULL; |
837 | -} |
838 | - |
839 | -/** |
840 | indicate_indicator_user_display: |
841 | @indicator: a #IndicateIndicator to act on |
842 | |
843 | @@ -451,8 +449,7 @@ |
844 | @indicator: a #IndicateIndicator to act on |
845 | |
846 | This function gets a list of all the properties that exist |
847 | - on a @indicator. The array may have zero entries but almost |
848 | - always at least has 'type' in it. |
849 | + on a @indicator. The array may have zero entries. |
850 | |
851 | Return value: An array of strings that is the keys of all |
852 | the properties on this indicator. |
853 | @@ -473,11 +470,6 @@ |
854 | { |
855 | g_return_if_fail(INDICATE_IS_INDICATOR(indicator)); |
856 | |
857 | - if (key != NULL && !g_strcmp0(key, "type")) { |
858 | - g_warning("Trying to set the 'type' of an indicator which should be done through subclassing."); |
859 | - return; |
860 | - } |
861 | - |
862 | IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator); |
863 | |
864 | gchar * current = g_hash_table_lookup(priv->properties, key); |
865 | @@ -500,10 +492,6 @@ |
866 | { |
867 | g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), NULL); |
868 | |
869 | - if (key != NULL && !g_strcmp0(key, "type")) { |
870 | - return indicate_indicator_get_indicator_type(indicator); |
871 | - } |
872 | - |
873 | IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator); |
874 | |
875 | // TODO: Think about whether we should be strdup'ing this. Seems like overkill, but might not be. |
876 | @@ -519,10 +507,50 @@ |
877 | GList * keys = g_hash_table_get_keys(priv->properties); |
878 | GPtrArray * properties = g_ptr_array_sized_new(g_list_length(keys) + 1); |
879 | |
880 | - g_ptr_array_add(properties, g_strdup("type")); |
881 | for (; keys != NULL; keys = keys->next) { |
882 | g_ptr_array_add(properties, g_strdup(keys->data)); |
883 | } |
884 | |
885 | return properties; |
886 | } |
887 | + |
888 | +/** |
889 | + indicate_indicator_set_displayed: |
890 | + @indicator: The #IndicateIndicator to configure |
891 | + @displayed: Whether or not the indicator is visible to users |
892 | + |
893 | + Sets whether or not the indicator is visible to the user from |
894 | + a listener. This does not include things like whether the menu |
895 | + is open, but more whether it's in the menu to be found. |
896 | +*/ |
897 | +void |
898 | +indicate_indicator_set_displayed (IndicateIndicator * indicator, gboolean displayed) |
899 | +{ |
900 | + g_return_if_fail(INDICATE_IS_INDICATOR(indicator)); |
901 | + IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator); |
902 | + |
903 | + if (priv->is_displayed != displayed) { |
904 | + priv->is_displayed = displayed; |
905 | + g_signal_emit(G_OBJECT(indicator), signals[DISPLAYED], 0, displayed, TRUE); |
906 | + } |
907 | + |
908 | + return; |
909 | +} |
910 | + |
911 | +/** |
912 | + indicate_indicator_get_displayed: |
913 | + @indicator: The #IndicateIndicator to query |
914 | + |
915 | + Checks to see if the indicator is visible to users in some way. |
916 | + |
917 | + Return value: Whether or not this indicator can be seen by a user |
918 | + or not. |
919 | +*/ |
920 | +gboolean |
921 | +indicate_indicator_get_displayed (IndicateIndicator * indicator) |
922 | +{ |
923 | + g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), FALSE); |
924 | + IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator); |
925 | + return priv->is_visible && priv->is_displayed; |
926 | +} |
927 | + |
928 | |
929 | === modified file 'libindicate/indicator.h' |
930 | --- libindicate/indicator.h 2009-08-05 13:51:59 +0000 |
931 | +++ libindicate/indicator.h 2009-08-31 21:26:29 +0000 |
932 | @@ -46,10 +46,11 @@ |
933 | /* This is a signal that signals to the indicator that the user |
934 | * has done an action where they'd like this indicator to be |
935 | * displayed. */ |
936 | -#define INDICATE_INDICATOR_SIGNAL_HIDE "hide" |
937 | -#define INDICATE_INDICATOR_SIGNAL_SHOW "show" |
938 | -#define INDICATE_INDICATOR_SIGNAL_DISPLAY "user-display" |
939 | +#define INDICATE_INDICATOR_SIGNAL_HIDE "hide" |
940 | +#define INDICATE_INDICATOR_SIGNAL_SHOW "show" |
941 | +#define INDICATE_INDICATOR_SIGNAL_DISPLAY "user-display" |
942 | #define INDICATE_INDICATOR_SIGNAL_MODIFIED "modified" |
943 | +#define INDICATE_INDICATOR_SIGNAL_DISPLAYED "displayed" |
944 | |
945 | typedef struct _IndicateIndicator IndicateIndicator; |
946 | typedef struct _IndicateIndicatorClass IndicateIndicatorClass; |
947 | @@ -75,9 +76,7 @@ |
948 | @show: Slot for #IndicateIndicator::show. |
949 | @user_display: Slot for #IndicateIndicator::user-display. |
950 | @modified: Slot for #IndicateIndicator::modified. |
951 | - @get_type: Returns a constant string for the type of this indicator. |
952 | - Typically gets overridden by subclasses and defines the type of |
953 | - the indicator. Is called by indicate_indicator_get_indicator_type(). |
954 | + @displayed: Slot for #IndicateIndicator::displayed. |
955 | @set_property: Called when indicate_indicator_set_property() is called |
956 | and should set the value. While typically it is overridden by |
957 | subclasses they usually handle special properties themselves and |
958 | @@ -87,6 +86,10 @@ |
959 | @list_properties: Called when indicate_indicator_list_properties() is called |
960 | and returns a list of the properties available. Again this can be |
961 | overridden by subclasses to handle special properties. |
962 | + @indicate_indicator_reserved1: Reserved for future use |
963 | + @indicate_indicator_reserved2: Reserved for future use |
964 | + @indicate_indicator_reserved3: Reserved for future use |
965 | + @indicate_indicator_reserved4: Reserved for future use |
966 | |
967 | All of the functions that are used to modify or change data that is |
968 | in the indicator. Typically gets subclassed by other types of |
969 | @@ -94,17 +97,26 @@ |
970 | |
971 | */ |
972 | struct _IndicateIndicatorClass { |
973 | + /* Parents */ |
974 | GObjectClass parent_class; |
975 | |
976 | + /* Signals */ |
977 | void (*hide) (IndicateIndicator * indicator, gpointer data); |
978 | void (*show) (IndicateIndicator * indicator, gpointer data); |
979 | void (*user_display) (IndicateIndicator * indicator, gpointer data); |
980 | void (*modified) (IndicateIndicator * indicator, gchar * property, gpointer data); |
981 | + void (*displayed) (IndicateIndicator * indicator, gboolean displayed); |
982 | |
983 | - const gchar * (*get_type) (IndicateIndicator * indicator); |
984 | + /* Subclassable functions */ |
985 | void (*set_property) (IndicateIndicator * indicator, const gchar * key, const gchar * data); |
986 | const gchar * (*get_property) (IndicateIndicator * indicator, const gchar * key); |
987 | GPtrArray * (*list_properties) (IndicateIndicator * indicator); |
988 | + |
989 | + /* Reserver for future use */ |
990 | + void (*indicate_indicator_reserved1)(void); |
991 | + void (*indicate_indicator_reserved2)(void); |
992 | + void (*indicate_indicator_reserved3)(void); |
993 | + void (*indicate_indicator_reserved4)(void); |
994 | }; |
995 | |
996 | GType indicate_indicator_get_type(void) G_GNUC_CONST; |
997 | @@ -125,10 +137,6 @@ |
998 | /* Every entry has an ID, here's how to get it */ |
999 | guint indicate_indicator_get_id (IndicateIndicator * indicator); |
1000 | |
1001 | -/* Every entry has a type. This should be created by the |
1002 | - * subclass and exported through this pretty function */ |
1003 | -const gchar * indicate_indicator_get_indicator_type (IndicateIndicator * indicator); |
1004 | - |
1005 | void indicate_indicator_user_display (IndicateIndicator * indicator); |
1006 | |
1007 | /* Properties handling */ |
1008 | @@ -137,6 +145,10 @@ |
1009 | const gchar * indicate_indicator_get_property (IndicateIndicator * indicator, const gchar * key); |
1010 | GPtrArray * indicate_indicator_list_properties (IndicateIndicator * indicator); |
1011 | |
1012 | +/* Controling whether it's displayed */ |
1013 | +void indicate_indicator_set_displayed (IndicateIndicator * indicator, gboolean displayed); |
1014 | +gboolean indicate_indicator_get_displayed (IndicateIndicator * indicator); |
1015 | + |
1016 | /** |
1017 | SECTION:indicator |
1018 | @short_description: A representation of state for applications |
1019 | @@ -144,7 +156,7 @@ |
1020 | @include: libindicate/indicator.h |
1021 | |
1022 | An indicator is designed to represent a single instance of something |
1023 | - in your application. So this might be an IM or Email using #IndicateIndicatorMessage |
1024 | + in your application. So this might be an IM or an e-mail mail box |
1025 | or any other thing that is a small unit of information to pass on |
1026 | to the user. |
1027 | |
1028 | @@ -154,12 +166,7 @@ |
1029 | on the indicator to provide enough information for the listener |
1030 | to do that. |
1031 | |
1032 | - Mostly this is done through properties. The only property that is |
1033 | - defined for the base indicator is the 'type' property. And this |
1034 | - is only available to set by creating a subclass of the |
1035 | - #IndicateIndicator object. It is assumed that you can look at the |
1036 | - definitions of the various subtypes to determine which properties |
1037 | - they support. |
1038 | + Mostly this is done through properties. |
1039 | |
1040 | It may be that some users don't want to create objects for every |
1041 | indicator as it could be a lot of overhead if there are large numbers |
1042 | |
1043 | === modified file 'libindicate/listener-marshal.list' |
1044 | --- libindicate/listener-marshal.list 2009-04-10 09:51:16 +0000 |
1045 | +++ libindicate/listener-marshal.list 2009-08-28 20:38:15 +0000 |
1046 | @@ -28,8 +28,8 @@ |
1047 | # IndicatorAdded, IndicatorRemoved, IndicatorModified |
1048 | VOID:UINT,STRING |
1049 | # Local indicator_added, indicator_removed |
1050 | +VOID:POINTER,POINTER |
1051 | +# Local indicator_modified |
1052 | VOID:POINTER,POINTER,STRING |
1053 | -# Local indicator_modified |
1054 | -VOID:POINTER,POINTER,STRING,STRING |
1055 | # Local server_added and server_removed |
1056 | VOID:POINTER,STRING |
1057 | |
1058 | === modified file 'libindicate/listener-private.h' |
1059 | --- libindicate/listener-private.h 2009-08-03 22:31:00 +0000 |
1060 | +++ libindicate/listener-private.h 2009-08-28 21:59:26 +0000 |
1061 | @@ -35,6 +35,7 @@ |
1062 | DBusGProxy * proxy; |
1063 | DBusGConnection * connection; |
1064 | gboolean interests[INDICATE_INTEREST_LAST]; |
1065 | + gint max_indicators; |
1066 | }; |
1067 | |
1068 | struct _IndicateListenerIndicator { |
1069 | @@ -55,6 +56,8 @@ |
1070 | |
1071 | GArray * proxy_todo; |
1072 | guint todo_idle; |
1073 | + |
1074 | + gint max_indicators; |
1075 | }; |
1076 | |
1077 | #define INDICATE_LISTENER_GET_PRIVATE(o) \ |
1078 | |
1079 | === modified file 'libindicate/listener.c' |
1080 | --- libindicate/listener.c 2009-08-03 22:31:00 +0000 |
1081 | +++ libindicate/listener.c 2009-08-31 21:43:49 +0000 |
1082 | @@ -99,12 +99,11 @@ |
1083 | static gboolean todo_idle (gpointer data); |
1084 | static void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data); |
1085 | static void proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt); |
1086 | -static void proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt); |
1087 | -static void proxy_indicator_removed (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt); |
1088 | -static void proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt); |
1089 | +static void proxy_indicator_added (DBusGProxy * proxy, guint id, proxy_t * proxyt); |
1090 | +static void proxy_indicator_removed (DBusGProxy * proxy, guint id, proxy_t * proxyt); |
1091 | +static void proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, proxy_t * proxyt); |
1092 | static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data); |
1093 | static void proxy_get_indicator_type (DBusGProxy * proxy, gchar * type, GError * error, gpointer data); |
1094 | -static void proxy_indicators_free (gpointer data); |
1095 | static void introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer data); |
1096 | |
1097 | /* DBus interface */ |
1098 | @@ -130,22 +129,22 @@ |
1099 | G_SIGNAL_RUN_LAST, |
1100 | G_STRUCT_OFFSET (IndicateListenerClass, indicator_added), |
1101 | NULL, NULL, |
1102 | - _indicate_listener_marshal_VOID__POINTER_POINTER_STRING, |
1103 | - G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, G_TYPE_STRING); |
1104 | + _indicate_listener_marshal_VOID__POINTER_POINTER, |
1105 | + G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR); |
1106 | signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED, |
1107 | G_TYPE_FROM_CLASS (class), |
1108 | G_SIGNAL_RUN_LAST, |
1109 | G_STRUCT_OFFSET (IndicateListenerClass, indicator_removed), |
1110 | NULL, NULL, |
1111 | - _indicate_listener_marshal_VOID__POINTER_POINTER_STRING, |
1112 | - G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, G_TYPE_STRING); |
1113 | + _indicate_listener_marshal_VOID__POINTER_POINTER, |
1114 | + G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR); |
1115 | signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED, |
1116 | G_TYPE_FROM_CLASS (class), |
1117 | G_SIGNAL_RUN_LAST, |
1118 | G_STRUCT_OFFSET (IndicateListenerClass, indicator_modified), |
1119 | NULL, NULL, |
1120 | - _indicate_listener_marshal_VOID__POINTER_POINTER_STRING_STRING, |
1121 | - G_TYPE_NONE, 4, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, G_TYPE_STRING, G_TYPE_STRING); |
1122 | + _indicate_listener_marshal_VOID__POINTER_POINTER_STRING, |
1123 | + G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, G_TYPE_STRING); |
1124 | signals[SERVER_ADDED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_ADDED, |
1125 | G_TYPE_FROM_CLASS (class), |
1126 | G_SIGNAL_RUN_LAST, |
1127 | @@ -235,6 +234,8 @@ |
1128 | priv->proxy_todo = g_array_new(FALSE, TRUE, sizeof(proxy_todo_t)); |
1129 | priv->todo_idle = 0; |
1130 | |
1131 | + priv->max_indicators = -1; |
1132 | + |
1133 | /* WARNING */ |
1134 | /* Starting massive asynchronisity */ |
1135 | /* */ |
1136 | @@ -334,19 +335,11 @@ |
1137 | static void |
1138 | proxy_struct_destroy_indicators (gpointer key, gpointer value, gpointer data) |
1139 | { |
1140 | - gchar * type = (gchar *)key; |
1141 | - GHashTable * indicators = (GHashTable *)value; |
1142 | - proxy_t * proxy_data = data; |
1143 | + proxy_t * proxy_data = (proxy_t *)data; |
1144 | |
1145 | - GList * keys = g_hash_table_get_keys(indicators); |
1146 | - GList * indicator; |
1147 | - for (indicator = keys; indicator != NULL; indicator = indicator->next) { |
1148 | - guint id = (guint)indicator->data; |
1149 | - g_signal_emit(proxy_data->listener, signals[INDICATOR_REMOVED], 0, &proxy_data->server, GUINT_TO_POINTER(id), type, TRUE); |
1150 | + if (value) { |
1151 | + g_signal_emit(proxy_data->listener, signals[INDICATOR_REMOVED], 0, &proxy_data->server, GUINT_TO_POINTER(key), TRUE); |
1152 | } |
1153 | - g_list_free(keys); |
1154 | - |
1155 | - g_hash_table_remove_all(indicators); |
1156 | return; |
1157 | } |
1158 | |
1159 | @@ -360,7 +353,7 @@ |
1160 | g_hash_table_foreach(proxy_data->indicators, |
1161 | proxy_struct_destroy_indicators, |
1162 | proxy_data); |
1163 | - g_hash_table_remove_all(proxy_data->indicators); |
1164 | + g_hash_table_destroy(proxy_data->indicators); |
1165 | |
1166 | g_signal_emit(proxy_data->listener, signals[SERVER_REMOVED], 0, &proxy_data->server, proxy_data->type, TRUE); |
1167 | proxy_data->indicators = NULL; |
1168 | @@ -470,6 +463,7 @@ |
1169 | proxyt->server.name = todo->name; |
1170 | proxyt->server.proxy = proxyt->proxy; |
1171 | proxyt->server.connection = proxyt->connection; |
1172 | + proxyt->server.max_indicators = priv->max_indicators; |
1173 | |
1174 | priv->proxy_todo = g_array_remove_index(priv->proxy_todo, priv->proxy_todo->len - 1); |
1175 | |
1176 | @@ -509,6 +503,18 @@ |
1177 | return; |
1178 | } |
1179 | |
1180 | +/* A call back from setting the max indicators. We really can't |
1181 | + do anything about it, so this function is kinda useless. */ |
1182 | +void |
1183 | +set_max_indicators_cb (DBusGProxy * proxy, GError * error, gpointer userdata) |
1184 | +{ |
1185 | + if (error != NULL) { |
1186 | + g_warning("Unable to set the max indicators on '%s': %s", (gchar *)userdata, error->message); |
1187 | + g_error_free(error); |
1188 | + } |
1189 | + return; |
1190 | +} |
1191 | + |
1192 | typedef struct { |
1193 | guint id; |
1194 | proxy_t * proxyt; |
1195 | @@ -549,15 +555,14 @@ |
1196 | |
1197 | g_free(itt); |
1198 | |
1199 | - return proxy_indicator_added(proxy, id, type, proxyt); |
1200 | + return proxy_indicator_added(proxy, id, proxyt); |
1201 | } |
1202 | |
1203 | static void |
1204 | proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt) |
1205 | { |
1206 | if (proxyt->indicators == NULL) { |
1207 | - proxyt->indicators = g_hash_table_new_full(g_str_hash, g_str_equal, |
1208 | - g_free, proxy_indicators_free); |
1209 | + proxyt->indicators = g_hash_table_new(g_direct_hash, g_direct_equal); |
1210 | /* Elevate to working */ |
1211 | IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(proxyt->listener); |
1212 | |
1213 | @@ -568,12 +573,14 @@ |
1214 | } |
1215 | priv->proxies_working = g_list_prepend(priv->proxies_working, proxyt); |
1216 | |
1217 | + /* Connect to all the indicator based signals |
1218 | + that are coming from this server */ |
1219 | dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorAdded", |
1220 | - G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID); |
1221 | + G_TYPE_UINT, G_TYPE_INVALID); |
1222 | dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorAdded", |
1223 | G_CALLBACK(proxy_indicator_added), proxyt, NULL); |
1224 | dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorRemoved", |
1225 | - G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID); |
1226 | + G_TYPE_UINT, G_TYPE_INVALID); |
1227 | dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorRemoved", |
1228 | G_CALLBACK(proxy_indicator_removed), proxyt, NULL); |
1229 | dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorModified", |
1230 | @@ -588,6 +595,16 @@ |
1231 | proxyt->type = g_strdup(type); |
1232 | } |
1233 | |
1234 | + /* We're setting the max number of indicators from the default |
1235 | + when we detect it. This should give a reasonable amount of |
1236 | + time for listeners to set the default if they want something |
1237 | + different from infinite. Otherwise it'd be easy to miss the |
1238 | + first couple. */ |
1239 | + proxyt->server.max_indicators = priv->max_indicators; |
1240 | + if (proxyt->server.max_indicators != -1) { |
1241 | + org_freedesktop_indicator_set_max_indicators_async(proxyt->proxy, proxyt->server.max_indicators, set_max_indicators_cb, proxyt->name); |
1242 | + } |
1243 | + |
1244 | g_signal_emit(proxyt->listener, signals[SERVER_ADDED], 0, &proxyt->server, proxyt->type, TRUE); |
1245 | } |
1246 | |
1247 | @@ -595,48 +612,35 @@ |
1248 | } |
1249 | |
1250 | static void |
1251 | -proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt) |
1252 | +proxy_indicator_added (DBusGProxy * proxy, guint id, proxy_t * proxyt) |
1253 | { |
1254 | if (proxyt->indicators == NULL) { |
1255 | proxy_server_added (proxy, NULL, proxyt); |
1256 | } |
1257 | |
1258 | - GHashTable * indicators = g_hash_table_lookup(proxyt->indicators, type); |
1259 | - |
1260 | - if (indicators == NULL) { |
1261 | - indicators = g_hash_table_new(g_direct_hash, g_direct_equal); |
1262 | - g_hash_table_insert(proxyt->indicators, g_strdup(type), indicators); |
1263 | - } |
1264 | - |
1265 | - if (!g_hash_table_lookup(indicators, (gpointer)id)) { |
1266 | - g_hash_table_insert(indicators, (gpointer)id, (gpointer)TRUE); |
1267 | - g_signal_emit(proxyt->listener, signals[INDICATOR_ADDED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, TRUE); |
1268 | + if (!g_hash_table_lookup(proxyt->indicators, (gpointer)id)) { |
1269 | + g_hash_table_insert(proxyt->indicators, (gpointer)id, (gpointer)TRUE); |
1270 | + g_signal_emit(proxyt->listener, signals[INDICATOR_ADDED], 0, &proxyt->server, GUINT_TO_POINTER(id), TRUE); |
1271 | } |
1272 | |
1273 | return; |
1274 | } |
1275 | |
1276 | static void |
1277 | -proxy_indicator_removed (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt) |
1278 | +proxy_indicator_removed (DBusGProxy * proxy, guint id, proxy_t * proxyt) |
1279 | { |
1280 | if (proxyt->indicators == NULL) { |
1281 | g_warning("Oddly we had an indicator removed from an interface that we didn't think had indicators."); |
1282 | return; |
1283 | } |
1284 | |
1285 | - GHashTable * indicators = g_hash_table_lookup(proxyt->indicators, type); |
1286 | - if (indicators == NULL) { |
1287 | - g_warning("Can not remove indicator %d of type '%s' as there are no indicators of that type on %s.", id, type, proxyt->name); |
1288 | - return; |
1289 | - } |
1290 | - |
1291 | - if (!g_hash_table_lookup(indicators, (gpointer)id)) { |
1292 | - g_warning("No indicator %d of type '%s' on '%s'.", id, type, proxyt->name); |
1293 | - return; |
1294 | - } |
1295 | - |
1296 | - g_hash_table_remove(indicators, (gpointer)id); |
1297 | - g_signal_emit(proxyt->listener, signals[INDICATOR_REMOVED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, TRUE); |
1298 | + if (!g_hash_table_lookup(proxyt->indicators, (gpointer)id)) { |
1299 | + g_warning("No indicator %d on '%s'.", id, proxyt->name); |
1300 | + return; |
1301 | + } |
1302 | + |
1303 | + g_hash_table_remove(proxyt->indicators, (gpointer)id); |
1304 | + g_signal_emit(proxyt->listener, signals[INDICATOR_REMOVED], 0, &proxyt->server, GUINT_TO_POINTER(id), TRUE); |
1305 | |
1306 | return; |
1307 | } |
1308 | @@ -649,41 +653,13 @@ |
1309 | return; |
1310 | } |
1311 | |
1312 | - GList * keys = g_hash_table_get_keys(proxyt->indicators); |
1313 | - GList * inc = NULL; |
1314 | - gchar * type; |
1315 | - |
1316 | - for (inc = g_list_first(keys); inc != NULL; inc = g_list_next(inc)) { |
1317 | - type = (gchar *)inc->data; |
1318 | - |
1319 | - GHashTable * indicators = g_hash_table_lookup(proxyt->indicators, type); |
1320 | - if (indicators == NULL) continue; /* no indicators for this type? Odd, but not an error */ |
1321 | - |
1322 | - if (g_hash_table_lookup(indicators, (gpointer)id)) { |
1323 | - break; |
1324 | - } |
1325 | - } |
1326 | - |
1327 | - if (inc == NULL) { |
1328 | + if (!g_hash_table_lookup(proxyt->indicators, (gpointer)id)) { |
1329 | g_warning("Can not modify indicator %d with property '%s' as there are no indicators with that id on %s.", id, property, proxyt->name); |
1330 | return; |
1331 | } |
1332 | |
1333 | - g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, property, TRUE); |
1334 | - |
1335 | - return; |
1336 | -} |
1337 | - |
1338 | -static void |
1339 | -proxy_indicators_free (gpointer data) |
1340 | -{ |
1341 | - GHashTable * table = (GHashTable *)data; |
1342 | - |
1343 | - if (g_hash_table_size(table) != 0) { |
1344 | - g_warning("Clearning a set of indicators that wasn't signaled!"); |
1345 | - } |
1346 | - |
1347 | - g_hash_table_unref(table); |
1348 | + g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, &proxyt->server, GUINT_TO_POINTER(id), property, TRUE); |
1349 | + |
1350 | return; |
1351 | } |
1352 | |
1353 | @@ -774,6 +750,8 @@ |
1354 | return TRUE; |
1355 | } |
1356 | |
1357 | +/* A callback for asking an indicator to be displayed, |
1358 | + which is unlikely to fail. So we're throwing a warning. */ |
1359 | static void |
1360 | listener_display_cb (DBusGProxy *proxy, GError *error, gpointer userdata) |
1361 | { |
1362 | @@ -791,6 +769,45 @@ |
1363 | return; |
1364 | } |
1365 | |
1366 | +/* A callback for saying an indicator is displayed, |
1367 | + which is unlikely to fail. So we're throwing a warning. */ |
1368 | +static void |
1369 | +listener_displayed_cb (DBusGProxy *proxy, GError *error, gpointer userdata) |
1370 | +{ |
1371 | + if (error != NULL) { |
1372 | + g_warning("Listener displayed caused an error: %s", error->message); |
1373 | + } |
1374 | + return; |
1375 | +} |
1376 | + |
1377 | +/** |
1378 | + indicate_listener_displayed: |
1379 | + @listener: The #IndicateListener representing the connection |
1380 | + @server: The server that the indicator is on |
1381 | + @indicator: Which indicator is being displayed |
1382 | + @displayed: Whether it's being displayed or hidden |
1383 | + |
1384 | + This function tells the client whether we're showing this indicator |
1385 | + to the user. This doesn't mean that it's necissarilly visible right |
1386 | + now, but more that there is a way for the user to get to this item |
1387 | + individually. |
1388 | +*/ |
1389 | +void |
1390 | +indicate_listener_displayed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gboolean displayed) |
1391 | +{ |
1392 | + org_freedesktop_indicator_indicator_displayed_async (server->proxy, |
1393 | + INDICATE_LISTENER_INDICATOR_ID(indicator), |
1394 | + displayed, |
1395 | + listener_displayed_cb, |
1396 | + NULL); |
1397 | + |
1398 | + if (!server->interests[INDICATE_INTEREST_INDICATOR_DISPLAY] && displayed) { |
1399 | + g_warning("It's awful odd that you said in the interest survey you weren't displaying indicators and then you displayed one. I'm just saying, you've probably confused someone besides me."); |
1400 | + } |
1401 | + |
1402 | + return; |
1403 | +} |
1404 | + |
1405 | typedef struct { |
1406 | IndicateListener * listener; |
1407 | IndicateListenerServer * server; |
1408 | @@ -1015,7 +1032,7 @@ |
1409 | |
1410 | /* Check for root being "node" */ |
1411 | xmlNodePtr root = xmlDocGetRootElement(xmldoc); |
1412 | - if (g_strcmp0(root->name, "node") != 0) { |
1413 | + if (g_strcmp0((gchar *)root->name, "node") != 0) { |
1414 | xmlFreeDoc(xmldoc); |
1415 | g_warning("Introspection data from %s is not valid: %s", server->name, OUT_data); |
1416 | return; |
1417 | @@ -1038,12 +1055,12 @@ |
1418 | xmlNodePtr children; |
1419 | for (children = root->children; children != NULL; children = children->next) { |
1420 | gchar * xmlnameval = NULL; |
1421 | - if (g_strcmp0(children->name, nodename) == 0) { |
1422 | + if (g_strcmp0((gchar *)children->name, nodename) == 0) { |
1423 | xmlAttrPtr attrib; |
1424 | for (attrib = children->properties; attrib != NULL; attrib = attrib->next) { |
1425 | - if (g_strcmp0(attrib->name, "name") == 0) { |
1426 | + if (g_strcmp0((gchar *)attrib->name, "name") == 0) { |
1427 | if (attrib->children != NULL) { |
1428 | - xmlnameval = attrib->children->content; |
1429 | + xmlnameval = (gchar *)attrib->children->content; |
1430 | } |
1431 | break; |
1432 | } |
1433 | @@ -1082,3 +1099,50 @@ |
1434 | |
1435 | return; |
1436 | } |
1437 | + |
1438 | +/** |
1439 | + indicate_listener_default_max_indicators: |
1440 | + @listener: Instance of #IndicateListener to set on. |
1441 | + @max: The new default number of max indicators. |
1442 | + |
1443 | + This function sets the number that is given to new servers |
1444 | + when they start for the max number of indicators that you want |
1445 | + to see. The client should enforce this number. |
1446 | + |
1447 | + Note: This function WILL NOT reconfigure already recognized |
1448 | + servers. It only effects new servers. |
1449 | +*/ |
1450 | +void |
1451 | +indicate_listener_default_max_indicators (IndicateListener * listener, gint max) |
1452 | +{ |
1453 | + g_return_if_fail(INDICATE_IS_LISTENER(listener)); |
1454 | + IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener); |
1455 | + priv->max_indicators = max; |
1456 | + return; |
1457 | +} |
1458 | + |
1459 | +/** |
1460 | + indicate_listener_server_max_indicators: |
1461 | + @listener: Instance of #IndicateListener to set on. |
1462 | + @server: Server that the new max should be set on. |
1463 | + @max: The new number of max indicators. |
1464 | + |
1465 | + This function changes the max number of indicators that |
1466 | + a server should send. If the number is different than the |
1467 | + previous number a signal will be sent to the application to |
1468 | + adjust then number of indicators that they have. This is |
1469 | + sent asynchronously. |
1470 | +*/ |
1471 | +void |
1472 | +indicate_listener_server_max_indicators (IndicateListener * listener, IndicateListenerServer * server, gint max) |
1473 | +{ |
1474 | + g_return_if_fail(INDICATE_IS_LISTENER(listener)); |
1475 | + g_return_if_fail(server != NULL); /* All we can really check :-/ */ |
1476 | + |
1477 | + if (server->max_indicators != max) { |
1478 | + server->max_indicators = max; |
1479 | + org_freedesktop_indicator_set_max_indicators_async(server->proxy, server->max_indicators, set_max_indicators_cb, server->name); |
1480 | + } |
1481 | + |
1482 | + return; |
1483 | +} |
1484 | |
1485 | === modified file 'libindicate/listener.h' |
1486 | --- libindicate/listener.h 2009-08-03 22:53:17 +0000 |
1487 | +++ libindicate/listener.h 2009-08-31 21:40:26 +0000 |
1488 | @@ -69,17 +69,40 @@ |
1489 | GObject parent; |
1490 | }; |
1491 | |
1492 | +/** |
1493 | + IndicateListenerClass: |
1494 | + @parent: Parent class #GObjectClass. |
1495 | + @indicator_added: Slot for IndicateListener::indicator-added. |
1496 | + @indicator_removed: Slot for IndicateListener::indicator-removed. |
1497 | + @indicator_modified: Slot for IndicateListener::indicator-modified. |
1498 | + @server_added: Slot for IndicateListener::server-added. |
1499 | + @server_removed: Slot for IndicateListener::server-removed. |
1500 | + @indicate_listener_reserved1: Reserved for future use |
1501 | + @indicate_listener_reserved2: Reserved for future use |
1502 | + @indicate_listener_reserved3: Reserved for future use |
1503 | + @indicate_listener_reserved4: Reserved for future use |
1504 | + |
1505 | + The class has all of the signals that are supplied by |
1506 | + the listener about what is happening on the server. |
1507 | +*/ |
1508 | typedef struct _IndicateListenerClass IndicateListenerClass; |
1509 | struct _IndicateListenerClass { |
1510 | + /* Parent */ |
1511 | GObjectClass parent; |
1512 | |
1513 | /* Signals */ |
1514 | - void (* indicator_added) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type); |
1515 | - void (* indicator_removed) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type); |
1516 | - void (* indicator_modified) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gchar * property); |
1517 | + void (* indicator_added) (IndicateListenerServer * server, IndicateListenerIndicator * indicator); |
1518 | + void (* indicator_removed) (IndicateListenerServer * server, IndicateListenerIndicator * indicator); |
1519 | + void (* indicator_modified) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property); |
1520 | |
1521 | void (* server_added) (IndicateListenerServer * server, gchar * type); |
1522 | void (* server_removed) (IndicateListenerServer * server, gchar * type); |
1523 | + |
1524 | + /* Future Use */ |
1525 | + void (*indicate_listener_reserved1)(void); |
1526 | + void (*indicate_listener_reserved2)(void); |
1527 | + void (*indicate_listener_reserved3)(void); |
1528 | + void (*indicate_listener_reserved4)(void); |
1529 | }; |
1530 | |
1531 | GType indicate_listener_get_type (void) G_GNUC_CONST; |
1532 | @@ -106,6 +129,10 @@ |
1533 | void indicate_listener_display (IndicateListener * listener, |
1534 | IndicateListenerServer * server, |
1535 | IndicateListenerIndicator * indicator); |
1536 | +void indicate_listener_displayed (IndicateListener * listener, |
1537 | + IndicateListenerServer * server, |
1538 | + IndicateListenerIndicator * indicator, |
1539 | + gboolean displayed); |
1540 | void indicate_listener_server_get_type (IndicateListener * listener, |
1541 | IndicateListenerServer * server, |
1542 | indicate_listener_get_server_property_cb callback, |
1543 | @@ -125,6 +152,11 @@ |
1544 | gboolean indicate_listener_server_check_interest (IndicateListener * listener, |
1545 | IndicateListenerServer * server, |
1546 | IndicateInterests interest); |
1547 | +void indicate_listener_default_max_indicators (IndicateListener * listener, |
1548 | + gint max); |
1549 | +void indicate_listener_server_max_indicators (IndicateListener * listener, |
1550 | + IndicateListenerServer * server, |
1551 | + gint max); |
1552 | |
1553 | G_END_DECLS |
1554 | |
1555 | |
1556 | === modified file 'libindicate/server-marshal.list' |
1557 | --- libindicate/server-marshal.list 2009-07-21 16:37:51 +0000 |
1558 | +++ libindicate/server-marshal.list 2009-08-28 19:55:12 +0000 |
1559 | @@ -26,4 +26,5 @@ |
1560 | # <http://www.gnu.org/licenses/> |
1561 | # |
1562 | # IndicatorAdded |
1563 | +VOID:UINT |
1564 | VOID:UINT,STRING |
1565 | |
1566 | === modified file 'libindicate/server.c' |
1567 | --- libindicate/server.c 2009-08-05 00:25:55 +0000 |
1568 | +++ libindicate/server.c 2009-09-01 02:49:11 +0000 |
1569 | @@ -37,18 +37,19 @@ |
1570 | enum { |
1571 | NO_GET_DESKTOP, |
1572 | NO_GET_INDICATOR_COUNT, |
1573 | - NO_GET_INDICATOR_COUNT_BY_TYPE, |
1574 | NO_GET_INDICATOR_LIST, |
1575 | - NO_GET_INDICATOR_LIST_BY_TYPE, |
1576 | NO_GET_INDICATOR_PROPERTY, |
1577 | NO_GET_INDICATOR_PROPERTY_GROUP, |
1578 | NO_GET_INDICATOR_PROPERTIES, |
1579 | NO_SHOW_INDICATOR_TO_USER, |
1580 | + NO_INDICATOR_DISPLAYED, |
1581 | INVALID_INDICATOR_ID, |
1582 | NO_SHOW_INTEREST, |
1583 | NO_REMOVE_INTEREST, |
1584 | SHOW_INTEREST_FAILED, |
1585 | REMOVE_INTEREST_FAILED, |
1586 | + NO_MAX_INDICATORS_SET, |
1587 | + MAX_INDICATORS_SET_FAILED, |
1588 | LAST_ERROR |
1589 | }; |
1590 | |
1591 | @@ -62,6 +63,9 @@ |
1592 | SERVER_DISPLAY, |
1593 | INTEREST_ADDED, |
1594 | INTEREST_REMOVED, |
1595 | + MAX_INDICATORS_CHANGED, |
1596 | + INDICATOR_NOT_SHOWN, |
1597 | + SERVER_COUNT_CHANGED, |
1598 | LAST_SIGNAL |
1599 | }; |
1600 | |
1601 | @@ -69,7 +73,8 @@ |
1602 | enum { |
1603 | PROP_0, |
1604 | PROP_DESKTOP, |
1605 | - PROP_TYPE |
1606 | + PROP_TYPE, |
1607 | + PROP_COUNT |
1608 | }; |
1609 | |
1610 | static guint signals[LAST_SIGNAL] = { 0 }; |
1611 | @@ -89,12 +94,17 @@ |
1612 | |
1613 | gchar * desktop; |
1614 | gchar * type; |
1615 | + guint count; |
1616 | |
1617 | // TODO: Should have a more robust way to track this, but this'll work for now |
1618 | guint num_hidden; |
1619 | |
1620 | - gboolean interests[INDICATE_INTEREST_LAST]; |
1621 | + /* Folks storage */ |
1622 | GList * interestedfolks; |
1623 | + |
1624 | + /* Folks caches */ |
1625 | + gint max_indicators; |
1626 | + gboolean interests[INDICATE_INTEREST_LAST]; |
1627 | }; |
1628 | |
1629 | #define INDICATE_SERVER_GET_PRIVATE(o) \ |
1630 | @@ -104,8 +114,12 @@ |
1631 | struct _IndicateServerInterestedFolk { |
1632 | gchar * sender; |
1633 | gboolean interests[INDICATE_INTEREST_LAST]; |
1634 | + gint max_indicators; |
1635 | + GHashTable * indicators_displayed; |
1636 | }; |
1637 | |
1638 | +static const gint MAX_INDICATORS_INFINITE = -1; |
1639 | +static const gint MAX_INDICATORS_UNSET = -2; |
1640 | |
1641 | /* Define Type */ |
1642 | G_DEFINE_TYPE (IndicateServer, indicate_server, G_TYPE_OBJECT); |
1643 | @@ -113,20 +127,25 @@ |
1644 | /* Prototypes */ |
1645 | static void indicate_server_finalize (GObject * obj); |
1646 | static gboolean get_indicator_count (IndicateServer * server, guint * count, GError **error); |
1647 | -static gboolean get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error); |
1648 | static gboolean get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); |
1649 | -static gboolean get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error); |
1650 | +static IndicateIndicator * get_indicator (IndicateServer * server, guint id, GError **error); |
1651 | static gboolean get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); |
1652 | static gboolean get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); |
1653 | static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); |
1654 | static gboolean show_indicator_to_user (IndicateServer * server, guint id, GError ** error); |
1655 | +static gboolean indicator_displayed (IndicateServer * server, gchar * sender, guint id, gboolean displayed, GError ** error); |
1656 | static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server); |
1657 | +static void indicator_display_check_recalc (gpointer key, gpointer value, gpointer userdata); |
1658 | +static void recalculate_indicator_displayed (IndicateServer * server, guint id); |
1659 | static guint get_next_id (IndicateServer * server); |
1660 | static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); |
1661 | static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); |
1662 | static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest); |
1663 | static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest); |
1664 | static gboolean check_interest (IndicateServer * server, IndicateInterests intrest); |
1665 | +static gint max_indicators_get (IndicateServer * server); |
1666 | +static gboolean max_indicators_set (IndicateServer * server, gchar * sender, gint max); |
1667 | +static void recalculate_max_indicators (IndicateServer * server); |
1668 | static gint indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b); |
1669 | static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender); |
1670 | static void indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value); |
1671 | @@ -135,15 +154,15 @@ |
1672 | |
1673 | /* DBus API */ |
1674 | gboolean _indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error); |
1675 | -gboolean _indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error); |
1676 | gboolean _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error); |
1677 | -gboolean _indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error); |
1678 | gboolean _indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); |
1679 | gboolean _indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); |
1680 | gboolean _indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error); |
1681 | gboolean _indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error); |
1682 | +gboolean _indicate_server_indicator_displayed (IndicateServer * server, guint id, gboolean displayed, DBusGMethodInvocation * method); |
1683 | gboolean _indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); |
1684 | gboolean _indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method); |
1685 | +gboolean _indicate_server_set_max_indicators (IndicateServer * server, gint max, DBusGMethodInvocation * method); |
1686 | |
1687 | /* Has to be after the dbus prototypes */ |
1688 | #include "dbus-indicate-server.h" |
1689 | @@ -168,38 +187,32 @@ |
1690 | IndicateServer::indicator-added: |
1691 | @arg0: The #IndicateServer object |
1692 | @arg1: The #IndicateIndicator ID number |
1693 | - @arg2: The type of the indicator |
1694 | |
1695 | Emitted every time that a new indicator is made visible to |
1696 | the world. This results in a signal on DBus. |
1697 | - |
1698 | - Can be emitted by subclasses using indicate_server_emit_indicator_added() |
1699 | */ |
1700 | signals[INDICATOR_ADDED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_ADDED, |
1701 | G_TYPE_FROM_CLASS (class), |
1702 | G_SIGNAL_RUN_LAST, |
1703 | G_STRUCT_OFFSET (IndicateServerClass, indicator_added), |
1704 | NULL, NULL, |
1705 | - _indicate_server_marshal_VOID__UINT_STRING, |
1706 | - G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING); |
1707 | + _indicate_server_marshal_VOID__UINT, |
1708 | + G_TYPE_NONE, 1, G_TYPE_UINT); |
1709 | /** |
1710 | IndicateServer::indicator-removed: |
1711 | @arg0: The #IndicateServer object |
1712 | @arg1: The #IndicateIndicator ID number |
1713 | - @arg2: The type of the indicator |
1714 | |
1715 | Emitted every time that a new indicator is made invisible to |
1716 | the world. This results in a signal on DBus. |
1717 | - |
1718 | - Can be emitted by subclasses using indicate_server_emit_indicator_removed() |
1719 | */ |
1720 | signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED, |
1721 | G_TYPE_FROM_CLASS (class), |
1722 | G_SIGNAL_RUN_LAST, |
1723 | G_STRUCT_OFFSET (IndicateServerClass, indicator_removed), |
1724 | NULL, NULL, |
1725 | - _indicate_server_marshal_VOID__UINT_STRING, |
1726 | - G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING); |
1727 | + _indicate_server_marshal_VOID__UINT, |
1728 | + G_TYPE_NONE, 1, G_TYPE_UINT); |
1729 | /** |
1730 | IndicateServer::indicator-modified: |
1731 | @arg0: The #IndicateServer object |
1732 | @@ -208,8 +221,6 @@ |
1733 | |
1734 | Emitted every time that a property on an indicator changes |
1735 | and it is visible to the world. This results in a signal on DBus. |
1736 | - |
1737 | - Can be emitted by subclasses using indicate_server_emit_indicator_modified() |
1738 | */ |
1739 | signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED, |
1740 | G_TYPE_FROM_CLASS (class), |
1741 | @@ -256,8 +267,6 @@ |
1742 | Emitted when a listener signals that the server itself should be |
1743 | displayed. This signal is caused by a user clicking on the application |
1744 | item in the Messaging Menu. This signal is emitted by DBus. |
1745 | - |
1746 | - Can be emitted by subclasses using indicate_server_emit_server_display() |
1747 | */ |
1748 | signals[SERVER_DISPLAY] = g_signal_new(INDICATE_SERVER_SIGNAL_SERVER_DISPLAY, |
1749 | G_TYPE_FROM_CLASS (class), |
1750 | @@ -296,6 +305,36 @@ |
1751 | NULL, NULL, |
1752 | g_cclosure_marshal_VOID__UINT, |
1753 | G_TYPE_NONE, 1, G_TYPE_UINT); |
1754 | + /** |
1755 | + IndicateServer::max-indicators-changed: |
1756 | + @arg0: The #IndicateServer object |
1757 | + @arg1: The new max number of indicators |
1758 | + |
1759 | + Emitted when a listener either specifies their max number |
1760 | + to be higher, or at all. The default is -1 or infinite. |
1761 | + */ |
1762 | + signals[MAX_INDICATORS_CHANGED] = g_signal_new(INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED, |
1763 | + G_TYPE_FROM_CLASS (class), |
1764 | + G_SIGNAL_RUN_LAST, |
1765 | + G_STRUCT_OFFSET (IndicateServerClass, max_indicators_changed), |
1766 | + NULL, NULL, |
1767 | + g_cclosure_marshal_VOID__INT, |
1768 | + G_TYPE_NONE, 1, G_TYPE_INT); |
1769 | + /** |
1770 | + IndicateServer::server-count-changed: |
1771 | + @arg0: The #IndicateServer object |
1772 | + @arg1: The count variable on the server changed. |
1773 | + |
1774 | + Emitted when the count property of the server changes |
1775 | + to a new value. |
1776 | + */ |
1777 | + signals[SERVER_COUNT_CHANGED] = g_signal_new(INDICATE_SERVER_SIGNAL_SERVER_COUNT_CHANGED, |
1778 | + G_TYPE_FROM_CLASS (class), |
1779 | + G_SIGNAL_RUN_LAST, |
1780 | + G_STRUCT_OFFSET (IndicateServerClass, server_count_changed), |
1781 | + NULL, NULL, |
1782 | + g_cclosure_marshal_VOID__UINT, |
1783 | + G_TYPE_NONE, 1, G_TYPE_UINT); |
1784 | |
1785 | g_object_class_install_property (gobj, PROP_DESKTOP, |
1786 | g_param_spec_string("desktop", "Desktop File", |
1787 | @@ -307,22 +346,28 @@ |
1788 | "The type of indicators that this server will provide", |
1789 | "", |
1790 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
1791 | + g_object_class_install_property (gobj, PROP_COUNT, |
1792 | + g_param_spec_uint("count", "Server Count", |
1793 | + "A number reprsenting the number of items in a server", |
1794 | + 0, G_MAXUINT, 0, |
1795 | + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
1796 | |
1797 | dbus_g_object_type_install_info(INDICATE_TYPE_SERVER, |
1798 | &dbus_glib__indicate_server_object_info); |
1799 | |
1800 | class->get_indicator_count = get_indicator_count; |
1801 | - class->get_indicator_count_by_type = get_indicator_count_by_type; |
1802 | class->get_indicator_list = get_indicator_list; |
1803 | - class->get_indicator_list_by_type = get_indicator_list_by_type; |
1804 | class->get_indicator_property = get_indicator_property; |
1805 | class->get_indicator_property_group = get_indicator_property_group; |
1806 | class->get_indicator_properties = get_indicator_properties; |
1807 | class->show_indicator_to_user = show_indicator_to_user; |
1808 | + class->indicator_displayed = indicator_displayed; |
1809 | class->get_next_id = get_next_id; |
1810 | class->show_interest = show_interest; |
1811 | class->remove_interest = remove_interest; |
1812 | class->check_interest = check_interest; |
1813 | + class->max_indicators_get = max_indicators_get; |
1814 | + class->max_indicators_set = max_indicators_set; |
1815 | |
1816 | return; |
1817 | } |
1818 | @@ -342,13 +387,14 @@ |
1819 | priv->current_id = 0; |
1820 | priv->type = NULL; |
1821 | priv->desktop = NULL; |
1822 | + priv->count = 0; |
1823 | |
1824 | guint i; |
1825 | for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { |
1826 | priv->interests[i] = FALSE; |
1827 | } |
1828 | priv->interestedfolks = NULL; |
1829 | - |
1830 | + priv->max_indicators = MAX_INDICATORS_UNSET; |
1831 | |
1832 | return; |
1833 | } |
1834 | @@ -385,54 +431,66 @@ |
1835 | g_return_if_fail(G_VALUE_HOLDS_STRING(value)); |
1836 | g_return_if_fail(id == PROP_DESKTOP || id == PROP_TYPE); |
1837 | |
1838 | - gchar ** outstr; |
1839 | - gchar * tempstr = NULL; |
1840 | - outstr = &tempstr; |
1841 | - |
1842 | IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(obj); |
1843 | switch (id) { |
1844 | case PROP_DESKTOP: |
1845 | - outstr = &(priv->desktop); |
1846 | + if (priv->desktop != NULL) { |
1847 | + g_free(priv->desktop); |
1848 | + } |
1849 | + priv->desktop = g_value_dup_string(value); |
1850 | break; |
1851 | case PROP_TYPE: |
1852 | - outstr = &(priv->type); |
1853 | - break; |
1854 | - } |
1855 | - |
1856 | - if (*outstr != NULL) { |
1857 | - g_free(*outstr); |
1858 | - } |
1859 | - |
1860 | - *outstr = g_strdup(g_value_get_string(value)); |
1861 | + if (priv->type != NULL) { |
1862 | + g_free(priv->type); |
1863 | + } |
1864 | + priv->type = g_value_dup_string(value); |
1865 | + break; |
1866 | + case PROP_COUNT: { |
1867 | + guint newval = g_value_get_uint(value); |
1868 | + if (newval != priv->count) { |
1869 | + priv->count = newval; |
1870 | + g_signal_emit(obj, signals[SERVER_COUNT_CHANGED], 0, newval, TRUE); |
1871 | + } |
1872 | + break; |
1873 | + } |
1874 | + } |
1875 | |
1876 | return; |
1877 | } |
1878 | |
1879 | +/* Gets the Gobject properties for the IndicateServer. Mostly |
1880 | + just copies strings and a whole uint! */ |
1881 | static void |
1882 | get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) |
1883 | { |
1884 | g_return_if_fail(id == PROP_DESKTOP || id == PROP_TYPE); |
1885 | |
1886 | - gchar * outstr = NULL; |
1887 | IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(obj); |
1888 | switch (id) { |
1889 | case PROP_DESKTOP: |
1890 | - outstr = priv->desktop; |
1891 | + if (priv->desktop == NULL) { |
1892 | + g_value_set_string(value, ""); |
1893 | + } else { |
1894 | + g_value_set_string(value, priv->desktop); |
1895 | + } |
1896 | break; |
1897 | case PROP_TYPE: |
1898 | - outstr = priv->type; |
1899 | - break; |
1900 | - } |
1901 | - |
1902 | - if (outstr != NULL) { |
1903 | - g_value_set_string(value, outstr); |
1904 | - } else { |
1905 | - g_value_set_static_string(value, ""); |
1906 | + if (priv->type == NULL) { |
1907 | + g_value_set_string(value, ""); |
1908 | + } else { |
1909 | + g_value_set_string(value, priv->type); |
1910 | + } |
1911 | + break; |
1912 | + case PROP_COUNT: |
1913 | + g_value_set_uint(value, priv->count); |
1914 | + break; |
1915 | } |
1916 | |
1917 | return; |
1918 | } |
1919 | |
1920 | +/* Small little function to get an error quark for usage |
1921 | + with the GError errors back across DBus */ |
1922 | static GQuark |
1923 | indicate_server_error_quark (void) |
1924 | { |
1925 | @@ -467,8 +525,8 @@ |
1926 | |
1927 | if (!priv->registered) { |
1928 | dbus_g_connection_register_g_object(priv->connection, |
1929 | - priv->path, |
1930 | - G_OBJECT(server)); |
1931 | + priv->path, |
1932 | + G_OBJECT(server)); |
1933 | priv->registered = TRUE; |
1934 | } |
1935 | |
1936 | @@ -525,6 +583,10 @@ |
1937 | priv->interests[i] = FALSE; |
1938 | } |
1939 | |
1940 | + /* Signal that we don't have a max */ |
1941 | + priv->max_indicators = MAX_INDICATORS_UNSET; |
1942 | + g_signal_emit(G_OBJECT(server), signals[MAX_INDICATORS_CHANGED], 0, MAX_INDICATORS_INFINITE, TRUE); |
1943 | + |
1944 | g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE); |
1945 | |
1946 | if (priv->dbus_proxy != NULL) { |
1947 | @@ -540,6 +602,11 @@ |
1948 | return; |
1949 | } |
1950 | |
1951 | +/* Watches the DBus owner change signals to see if any |
1952 | + of our folk disappear. If one of our folks goes away |
1953 | + then it deals with the repercussions of deleting that |
1954 | + entry in terms of interest, max indicators and which |
1955 | + indicators are being displayed. */ |
1956 | static void |
1957 | dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server) |
1958 | { |
1959 | @@ -586,11 +653,63 @@ |
1960 | } |
1961 | } |
1962 | |
1963 | - g_free(folk); |
1964 | - |
1965 | - return; |
1966 | -} |
1967 | - |
1968 | + /* If the retired folk has set it's max indicators |
1969 | + and it's the value we're using, we need to recalculate */ |
1970 | + if (folk->max_indicators != MAX_INDICATORS_UNSET && folk->max_indicators == priv->max_indicators) { |
1971 | + recalculate_max_indicators(server); |
1972 | + } |
1973 | + |
1974 | + g_hash_table_foreach(folk->indicators_displayed, indicator_display_check_recalc, server); |
1975 | + |
1976 | + /* Finally destory everything */ |
1977 | + indicate_server_interested_folks_destroy(folk); |
1978 | + return; |
1979 | +} |
1980 | + |
1981 | +/* Checks each value in the hash table to see if it's |
1982 | + been set. If it is, then we need to recalculate |
1983 | + the value of displayed. */ |
1984 | +static void |
1985 | +indicator_display_check_recalc (gpointer key, gpointer value, gpointer userdata) |
1986 | +{ |
1987 | + if (!GPOINTER_TO_UINT(value)) { |
1988 | + return; |
1989 | + } |
1990 | + |
1991 | + recalculate_indicator_displayed(INDICATE_SERVER(userdata), GPOINTER_TO_UINT(key)); |
1992 | + return; |
1993 | +} |
1994 | + |
1995 | +/* Look to see if a specific indicator ID has anyone watching |
1996 | + for it, and if not we need to set it to undisplayed. */ |
1997 | +static void |
1998 | +recalculate_indicator_displayed (IndicateServer * server, guint id) |
1999 | +{ |
2000 | + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); |
2001 | + GList * folkpointer; |
2002 | + |
2003 | + for (folkpointer = priv->interestedfolks; folkpointer != NULL; folkpointer = g_list_next(folkpointer)) { |
2004 | + IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)folkpointer->data; |
2005 | + if (g_hash_table_lookup(folk->indicators_displayed, GUINT_TO_POINTER(id))) { |
2006 | + break; |
2007 | + } |
2008 | + } |
2009 | + |
2010 | + if (folkpointer == NULL) { |
2011 | + /* We went through the list and no one cares about |
2012 | + this indicator. It's not displayed anymore. */ |
2013 | + IndicateIndicator * indicator = get_indicator(server, id, NULL); |
2014 | + if (indicator != NULL) { |
2015 | + indicate_indicator_set_displayed(indicator, FALSE); |
2016 | + } else { |
2017 | + g_warning("I'm removing a displayed set from an indicator that doesn't seem to exist."); |
2018 | + } |
2019 | + } |
2020 | + |
2021 | + return; |
2022 | +} |
2023 | + |
2024 | +/* Get the next ID from the server */ |
2025 | static guint |
2026 | get_next_id (IndicateServer * server) |
2027 | { |
2028 | @@ -599,6 +718,10 @@ |
2029 | return priv->current_id; |
2030 | } |
2031 | |
2032 | +/* Allows a listener to show interest. First we look to see |
2033 | + if we've talked to this listener before and if so we just |
2034 | + mark their folk listing. If it changes the overall setting |
2035 | + then we need to signal. */ |
2036 | static gboolean |
2037 | show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) |
2038 | { |
2039 | @@ -631,6 +754,9 @@ |
2040 | return TRUE; |
2041 | } |
2042 | |
2043 | +/* Removes an interest from a folk. It removes it from the |
2044 | + folk structure and then checks to see if that has global |
2045 | + effect, and handles it. */ |
2046 | static gboolean |
2047 | remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest) |
2048 | { |
2049 | @@ -643,6 +769,9 @@ |
2050 | |
2051 | IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); |
2052 | |
2053 | + /* Figure out the folk that we're talking to. If we |
2054 | + have an entry for them, use it, otherwise we need |
2055 | + to create one. */ |
2056 | GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal); |
2057 | IndicateServerInterestedFolk * folkpointer = NULL; |
2058 | if (entry == NULL) { |
2059 | @@ -653,8 +782,11 @@ |
2060 | folkpointer = (IndicateServerInterestedFolk *)entry->data; |
2061 | } |
2062 | |
2063 | + /* Set the interest for this guy */ |
2064 | indicate_server_interested_folks_set(folkpointer, interest, FALSE); |
2065 | |
2066 | + /* Check to see if the interest has changed as a result of |
2067 | + this an announce it to the world */ |
2068 | if (priv->interests[interest]) { |
2069 | guint i; |
2070 | for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { |
2071 | @@ -675,6 +807,8 @@ |
2072 | return TRUE; |
2073 | } |
2074 | |
2075 | +/* Checks to see if a particular interest value is |
2076 | + set. Uses the interest cache. */ |
2077 | static gboolean |
2078 | check_interest (IndicateServer * server, IndicateInterests interest) |
2079 | { |
2080 | @@ -682,12 +816,109 @@ |
2081 | return priv->interests[interest]; |
2082 | } |
2083 | |
2084 | +/* Internal function that can be subclassed to get |
2085 | + the value of the max number of indicators. */ |
2086 | +static gint |
2087 | +max_indicators_get (IndicateServer * server) |
2088 | +{ |
2089 | + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); |
2090 | + if (priv->max_indicators == MAX_INDICATORS_UNSET) { |
2091 | + return MAX_INDICATORS_INFINITE; |
2092 | + } else { |
2093 | + return priv->max_indicators; |
2094 | + } |
2095 | +} |
2096 | + |
2097 | +/* Internal function to set the number of max indicators |
2098 | + from a particular listener. */ |
2099 | +static gboolean |
2100 | +max_indicators_set (IndicateServer * server, gchar * sender, gint max) |
2101 | +{ |
2102 | + g_return_val_if_fail(max >= MAX_INDICATORS_INFINITE, FALSE); |
2103 | + |
2104 | + IndicateServerInterestedFolk localfolk; |
2105 | + localfolk.sender = sender; |
2106 | + |
2107 | + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); |
2108 | + |
2109 | + /* Figure out the folk that we're talking to. If we |
2110 | + have an entry for them, use it, otherwise we need |
2111 | + to create one. */ |
2112 | + GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal); |
2113 | + IndicateServerInterestedFolk * folkpointer = NULL; |
2114 | + if (entry == NULL) { |
2115 | + folkpointer = g_new(IndicateServerInterestedFolk, 1); |
2116 | + indicate_server_interested_folks_init(folkpointer, sender); |
2117 | + priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer); |
2118 | + } else { |
2119 | + folkpointer = (IndicateServerInterestedFolk *)entry->data; |
2120 | + } |
2121 | + |
2122 | + /* If there's a change going on... */ |
2123 | + if (max != folkpointer->max_indicators) { |
2124 | + gboolean recalculate = FALSE; |
2125 | + /* If this guy is setting it to infinite or is |
2126 | + increasing the number */ |
2127 | + if ((max == -1 && priv->max_indicators != -1) || max > priv->max_indicators) { |
2128 | + recalculate = TRUE; |
2129 | + } |
2130 | + |
2131 | + /* Or if potentially we were the ones setting the |
2132 | + value for everyone */ |
2133 | + if (priv->max_indicators == folkpointer->max_indicators) { |
2134 | + recalculate = TRUE; |
2135 | + } |
2136 | + |
2137 | + folkpointer->max_indicators = max; |
2138 | + if (recalculate) { |
2139 | + recalculate_max_indicators(server); |
2140 | + } |
2141 | + } |
2142 | + |
2143 | + return TRUE; |
2144 | +} |
2145 | + |
2146 | +/* Look through all the folks and trying to figure out |
2147 | + what the max should be. Signal if it changes. */ |
2148 | +static void |
2149 | +recalculate_max_indicators (IndicateServer * server) |
2150 | +{ |
2151 | + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); |
2152 | + |
2153 | + /* Let's talk to all the folks and see what they |
2154 | + think the max should be. */ |
2155 | + GList * folkitem; |
2156 | + gint newmax = MAX_INDICATORS_UNSET; |
2157 | + for (folkitem = priv->interestedfolks; folkitem != NULL; folkitem = g_list_next(folkitem)) { |
2158 | + IndicateServerInterestedFolk * thisfolk = (IndicateServerInterestedFolk *)folkitem->data; |
2159 | + if (thisfolk->max_indicators == MAX_INDICATORS_UNSET) { |
2160 | + continue; |
2161 | + } |
2162 | + if (thisfolk->max_indicators == MAX_INDICATORS_INFINITE) { |
2163 | + newmax = MAX_INDICATORS_INFINITE; |
2164 | + break; |
2165 | + } |
2166 | + if (thisfolk->max_indicators > newmax) { |
2167 | + newmax = thisfolk->max_indicators; |
2168 | + } |
2169 | + } |
2170 | + |
2171 | + /* Okay, what ever happened, now it's changing |
2172 | + things and we need to tell everyone. */ |
2173 | + if (priv->max_indicators != newmax) { |
2174 | + priv->max_indicators = newmax; |
2175 | + g_signal_emit(G_OBJECT(server), signals[MAX_INDICATORS_CHANGED], 0, newmax, TRUE); |
2176 | + } |
2177 | + |
2178 | + return; |
2179 | +} |
2180 | + |
2181 | static void |
2182 | indicator_show_cb (IndicateIndicator * indicator, IndicateServer * server) |
2183 | { |
2184 | IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); |
2185 | priv->num_hidden--; |
2186 | - g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE); |
2187 | + g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), TRUE); |
2188 | return; |
2189 | } |
2190 | |
2191 | @@ -696,7 +927,7 @@ |
2192 | { |
2193 | IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); |
2194 | priv->num_hidden++; |
2195 | - g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE); |
2196 | + g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), TRUE); |
2197 | return; |
2198 | } |
2199 | |
2200 | @@ -730,7 +961,7 @@ |
2201 | if (!indicate_indicator_is_visible(indicator)) { |
2202 | priv->num_hidden++; |
2203 | } else { |
2204 | - g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE); |
2205 | + g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), TRUE); |
2206 | } |
2207 | |
2208 | g_signal_connect(indicator, INDICATE_INDICATOR_SIGNAL_SHOW, G_CALLBACK(indicator_show_cb), server); |
2209 | @@ -758,7 +989,7 @@ |
2210 | |
2211 | priv->indicators = g_slist_remove(priv->indicators, indicator); |
2212 | if (indicate_indicator_is_visible(indicator)) { |
2213 | - g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE); |
2214 | + g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), TRUE); |
2215 | } else { |
2216 | priv->num_hidden--; |
2217 | } |
2218 | @@ -883,54 +1114,6 @@ |
2219 | return TRUE; |
2220 | } |
2221 | |
2222 | -typedef struct { |
2223 | - gchar * type; |
2224 | - guint count; |
2225 | -} count_by_t; |
2226 | - |
2227 | -static void |
2228 | -count_by_type (IndicateIndicator * indicator, count_by_t * cbt) |
2229 | -{ |
2230 | - g_return_if_fail(INDICATE_IS_INDICATOR(indicator)); |
2231 | - if (!indicate_indicator_is_visible(indicator)) { |
2232 | - return; |
2233 | - } |
2234 | - |
2235 | - const gchar * type = indicate_indicator_get_indicator_type(indicator); |
2236 | - /* g_debug("Looking for indicator of type '%s' and have type '%s'", cbt->type, type); */ |
2237 | - |
2238 | - if (type == NULL && cbt->type == NULL) { |
2239 | - cbt->count++; |
2240 | - } else if (type == NULL || cbt->type == NULL) { |
2241 | - } else if (!g_strcmp0(type, cbt->type)) { |
2242 | - cbt->count++; |
2243 | - } |
2244 | - |
2245 | - return; |
2246 | -} |
2247 | - |
2248 | -static gboolean |
2249 | -get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error) |
2250 | -{ |
2251 | - /* g_debug("get_indicator_count_by_type: '%s'", type); */ |
2252 | - count_by_t cbt; |
2253 | - cbt.type = type; |
2254 | - cbt.count = 0; |
2255 | - |
2256 | - /* Handle the NULL string case as NULL itself, we're a big |
2257 | - boy language; we have pointers. */ |
2258 | - if (cbt.type != NULL && cbt.type[0] == '\0') { |
2259 | - cbt.type = NULL; |
2260 | - } |
2261 | - |
2262 | - IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); |
2263 | - |
2264 | - g_slist_foreach(priv->indicators, (GFunc)count_by_type, &cbt); |
2265 | - *count = cbt.count; |
2266 | - |
2267 | - return TRUE; |
2268 | -} |
2269 | - |
2270 | static gboolean |
2271 | get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error) |
2272 | { |
2273 | @@ -956,44 +1139,6 @@ |
2274 | return TRUE; |
2275 | } |
2276 | |
2277 | -static gboolean |
2278 | -get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error) |
2279 | -{ |
2280 | - g_return_val_if_fail(INDICATE_IS_SERVER(server), TRUE); |
2281 | - |
2282 | - IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); |
2283 | - g_return_val_if_fail(class->get_indicator_count != NULL, TRUE); |
2284 | - |
2285 | - if (type != NULL && type[0] == '\0') { |
2286 | - type = NULL; |
2287 | - } |
2288 | - |
2289 | - IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); |
2290 | - |
2291 | - /* Can't be larger than this and it's not worth the reallocation |
2292 | - for the small number we have. The memory isn't worth the time. */ |
2293 | - *indicators = g_array_sized_new(FALSE, FALSE, sizeof(guint), g_slist_length(priv->indicators) - priv->num_hidden); |
2294 | - |
2295 | - GSList * iter; |
2296 | - int i; |
2297 | - for (iter = priv->indicators, i = 0; iter != NULL; iter = iter->next) { |
2298 | - IndicateIndicator * indicator = INDICATE_INDICATOR(iter->data); |
2299 | - if (indicate_indicator_is_visible(indicator)) { |
2300 | - const gchar * itype = indicate_indicator_get_indicator_type(indicator); |
2301 | - guint id = indicate_indicator_get_id(indicator); |
2302 | - |
2303 | - if (type == NULL && itype == NULL) { |
2304 | - g_array_insert_val(*indicators, i++, id); |
2305 | - } else if (type == NULL || itype == NULL) { |
2306 | - } else if (!g_strcmp0(type, itype)) { |
2307 | - g_array_insert_val(*indicators, i++, id); |
2308 | - } |
2309 | - } |
2310 | - } |
2311 | - |
2312 | - return TRUE; |
2313 | -} |
2314 | - |
2315 | static IndicateIndicator * |
2316 | get_indicator (IndicateServer * server, guint id, GError **error) |
2317 | { |
2318 | @@ -1087,6 +1232,45 @@ |
2319 | return TRUE; |
2320 | } |
2321 | |
2322 | +/* A function representing when an indicator is shown |
2323 | + to the user in some form. First it sees if we've talked |
2324 | + to this listener before and uses that entry. Otherwise, we |
2325 | + build one. If we're displaying it, things are good, we can |
2326 | + just set that. If we're not, then we need to check to see |
2327 | + if anyone else is before continuing. */ |
2328 | +static gboolean |
2329 | +indicator_displayed (IndicateServer * server, gchar * sender, guint id, gboolean displayed, GError ** error) |
2330 | +{ |
2331 | + IndicateServerInterestedFolk localfolk; |
2332 | + localfolk.sender = sender; |
2333 | + |
2334 | + IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server); |
2335 | + |
2336 | + GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal); |
2337 | + IndicateServerInterestedFolk * folkpointer = NULL; |
2338 | + if (entry == NULL) { |
2339 | + folkpointer = g_new(IndicateServerInterestedFolk, 1); |
2340 | + indicate_server_interested_folks_init(folkpointer, sender); |
2341 | + priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer); |
2342 | + } else { |
2343 | + folkpointer = (IndicateServerInterestedFolk *)entry->data; |
2344 | + } |
2345 | + |
2346 | + g_hash_table_insert(folkpointer->indicators_displayed, GUINT_TO_POINTER(id), GUINT_TO_POINTER(displayed)); |
2347 | + |
2348 | + if (displayed) { |
2349 | + IndicateIndicator * indicator = get_indicator(server, id, error); |
2350 | + if (indicator == NULL) { |
2351 | + return FALSE; |
2352 | + } |
2353 | + |
2354 | + indicate_indicator_set_displayed(indicator, displayed); |
2355 | + } else { |
2356 | + recalculate_indicator_displayed(server, id); |
2357 | + } |
2358 | + |
2359 | + return TRUE; |
2360 | +} |
2361 | |
2362 | /* Virtual Functions */ |
2363 | gboolean |
2364 | @@ -1111,27 +1295,6 @@ |
2365 | } |
2366 | |
2367 | gboolean |
2368 | -_indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error) |
2369 | -{ |
2370 | - IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); |
2371 | - |
2372 | - if (class != NULL && class->get_indicator_count_by_type != NULL) { |
2373 | - return class->get_indicator_count_by_type (server, type, count, error); |
2374 | - } |
2375 | - |
2376 | - if (error) { |
2377 | - g_set_error(error, |
2378 | - indicate_server_error_quark(), |
2379 | - NO_GET_INDICATOR_COUNT_BY_TYPE, |
2380 | - "get_indicator_count_by_type function doesn't exist for this server class: %s", |
2381 | - G_OBJECT_TYPE_NAME(server)); |
2382 | - return FALSE; |
2383 | - } |
2384 | - |
2385 | - return TRUE; |
2386 | -} |
2387 | - |
2388 | -gboolean |
2389 | _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error) |
2390 | { |
2391 | IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); |
2392 | @@ -1153,27 +1316,6 @@ |
2393 | } |
2394 | |
2395 | gboolean |
2396 | -_indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error) |
2397 | -{ |
2398 | - IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); |
2399 | - |
2400 | - if (class != NULL && class->get_indicator_list_by_type != NULL) { |
2401 | - return class->get_indicator_list_by_type (server, type, indicators, error); |
2402 | - } |
2403 | - |
2404 | - if (error) { |
2405 | - g_set_error(error, |
2406 | - indicate_server_error_quark(), |
2407 | - NO_GET_INDICATOR_LIST_BY_TYPE, |
2408 | - "get_indicator_list_by_type function doesn't exist for this server class: %s", |
2409 | - G_OBJECT_TYPE_NAME(server)); |
2410 | - return FALSE; |
2411 | - } |
2412 | - |
2413 | - return TRUE; |
2414 | -} |
2415 | - |
2416 | -gboolean |
2417 | _indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error) |
2418 | { |
2419 | IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); |
2420 | @@ -1257,6 +1399,36 @@ |
2421 | return TRUE; |
2422 | } |
2423 | |
2424 | +/* DBus function to wrap a virtual function call so that |
2425 | + it can be subclassed if someone so chooses */ |
2426 | +gboolean |
2427 | +_indicate_server_indicator_displayed (IndicateServer * server, guint id, gboolean displayed, DBusGMethodInvocation * method) |
2428 | +{ |
2429 | + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); |
2430 | + |
2431 | + if (class != NULL && class->indicator_displayed != NULL) { |
2432 | + GError * error = NULL; |
2433 | + if (class->indicator_displayed (server, dbus_g_method_get_sender(method), id, displayed, &error)) { |
2434 | + dbus_g_method_return(method); |
2435 | + return TRUE; |
2436 | + } else { |
2437 | + dbus_g_method_return_error(method, error); |
2438 | + g_error_free(error); |
2439 | + return FALSE; |
2440 | + } |
2441 | + } |
2442 | + |
2443 | + GError * error = NULL; |
2444 | + g_set_error(&error, |
2445 | + indicate_server_error_quark(), |
2446 | + NO_INDICATOR_DISPLAYED, |
2447 | + "indicator_displayed function doesn't exist for this server class: %s", |
2448 | + G_OBJECT_TYPE_NAME(server)); |
2449 | + dbus_g_method_return_error(method, error); |
2450 | + g_error_free(error); |
2451 | + return FALSE; |
2452 | +} |
2453 | + |
2454 | /** |
2455 | indicate_server_get_next_id: |
2456 | @server: The #IndicateServer the ID will be on |
2457 | @@ -1316,10 +1488,10 @@ |
2458 | } else { |
2459 | GError * error; |
2460 | g_set_error(&error, |
2461 | - indicate_server_error_quark(), |
2462 | - SHOW_INTEREST_FAILED, |
2463 | - "Unable to show interest: %s", |
2464 | - interest); |
2465 | + indicate_server_error_quark(), |
2466 | + SHOW_INTEREST_FAILED, |
2467 | + "Unable to show interest: %s", |
2468 | + interest); |
2469 | dbus_g_method_return_error(method, error); |
2470 | g_error_free(error); |
2471 | return FALSE; |
2472 | @@ -1328,10 +1500,10 @@ |
2473 | |
2474 | GError * error; |
2475 | g_set_error(&error, |
2476 | - indicate_server_error_quark(), |
2477 | - NO_SHOW_INTEREST, |
2478 | - "show_interest function doesn't exist for this server class: %s", |
2479 | - G_OBJECT_TYPE_NAME(server)); |
2480 | + indicate_server_error_quark(), |
2481 | + NO_SHOW_INTEREST, |
2482 | + "show_interest function doesn't exist for this server class: %s", |
2483 | + G_OBJECT_TYPE_NAME(server)); |
2484 | dbus_g_method_return_error(method, error); |
2485 | g_error_free(error); |
2486 | return FALSE; |
2487 | @@ -1370,6 +1542,39 @@ |
2488 | return FALSE; |
2489 | } |
2490 | |
2491 | +gboolean |
2492 | +_indicate_server_set_max_indicators (IndicateServer * server, gint max, DBusGMethodInvocation * method) |
2493 | +{ |
2494 | + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); |
2495 | + |
2496 | + if (class != NULL && class->max_indicators_set != NULL) { |
2497 | + if (class->max_indicators_set (server, dbus_g_method_get_sender(method), max)){ |
2498 | + dbus_g_method_return(method); |
2499 | + return TRUE; |
2500 | + } else { |
2501 | + GError * error; |
2502 | + g_set_error(&error, |
2503 | + indicate_server_error_quark(), |
2504 | + MAX_INDICATORS_SET_FAILED, |
2505 | + "Unable to set max indicators: %d", |
2506 | + max); |
2507 | + dbus_g_method_return_error(method, error); |
2508 | + g_error_free(error); |
2509 | + return FALSE; |
2510 | + } |
2511 | + } |
2512 | + |
2513 | + GError * error; |
2514 | + g_set_error(&error, |
2515 | + indicate_server_error_quark(), |
2516 | + NO_MAX_INDICATORS_SET, |
2517 | + "max_indicators_set function doesn't exist for this server class: %s", |
2518 | + G_OBJECT_TYPE_NAME(server)); |
2519 | + dbus_g_method_return_error(method, error); |
2520 | + g_error_free(error); |
2521 | + return FALSE; |
2522 | +} |
2523 | + |
2524 | /** |
2525 | indicate_server_check_interest: |
2526 | @server: The #IndicateServer being checked |
2527 | @@ -1394,85 +1599,40 @@ |
2528 | return FALSE; |
2529 | } |
2530 | |
2531 | -/* Signal emission functions for sub-classes of the server */ |
2532 | - |
2533 | -/** |
2534 | - indicate_server_emit_indicator_added: |
2535 | - @server: The #IndicateServer being represented |
2536 | - @id: The ID of the indicator being added |
2537 | - @type: The type of the indicator |
2538 | - |
2539 | - This function emits the #IndicateServer::indicator-added signal and is |
2540 | - used by subclasses. |
2541 | -*/ |
2542 | -void |
2543 | -indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type) |
2544 | -{ |
2545 | - g_return_if_fail (INDICATE_IS_SERVER (server)); |
2546 | - g_return_if_fail (type); |
2547 | - |
2548 | - g_signal_emit(server, signals[INDICATOR_ADDED], 0, id, type); |
2549 | -} |
2550 | - |
2551 | -/** |
2552 | - indicate_server_emit_indicator_removed: |
2553 | - @server: The #IndicateServer being represented |
2554 | - @id: The ID of the indicator being removed |
2555 | - @type: The type of the indicator |
2556 | - |
2557 | - This function emits the #IndicateServer::indicator-removed signal and is |
2558 | - used by subclasses. |
2559 | -*/ |
2560 | -void |
2561 | -indicate_server_emit_indicator_removed (IndicateServer *server, guint id, const gchar *type) |
2562 | -{ |
2563 | - g_return_if_fail (INDICATE_IS_SERVER (server)); |
2564 | - g_return_if_fail (type); |
2565 | - |
2566 | - g_signal_emit(server, signals[INDICATOR_REMOVED], 0, id, type); |
2567 | -} |
2568 | - |
2569 | -/** |
2570 | - indicate_server_emit_indicator_modified: |
2571 | - @server: The #IndicateServer being represented |
2572 | - @id: The ID of the indicator with the modified property |
2573 | - @property: The name of the property being modified |
2574 | - |
2575 | - This function emits the #IndicateServer::indicator-modified signal and is |
2576 | - used by subclasses. |
2577 | -*/ |
2578 | -void |
2579 | -indicate_server_emit_indicator_modified (IndicateServer *server, guint id, const gchar *property) |
2580 | -{ |
2581 | - g_return_if_fail (INDICATE_IS_SERVER (server)); |
2582 | - g_return_if_fail (property); |
2583 | - |
2584 | - g_signal_emit(server, signals[INDICATOR_MODIFIED], 0, id, property); |
2585 | -} |
2586 | - |
2587 | -/** |
2588 | - indicate_server_emit_server_display: |
2589 | - @server: The #IndicateServer being displayed |
2590 | - |
2591 | - This function emits the #IndicateServer::server-display signal and is |
2592 | - used by subclasses. |
2593 | -*/ |
2594 | -void |
2595 | -indicate_server_emit_server_display (IndicateServer *server) |
2596 | -{ |
2597 | - g_return_if_fail (INDICATE_IS_SERVER (server)); |
2598 | - |
2599 | - g_signal_emit(server, signals[SERVER_DISPLAY], 0, TRUE); |
2600 | +/** |
2601 | + indicate_server_get_max_indicators: |
2602 | + @server: The #IndicateServer being checked |
2603 | + |
2604 | + This function looks at everyone listening and determines |
2605 | + the max number of indicators that can be shown to anyone. |
2606 | + |
2607 | + Return value: A max number or -1 for unlimited. |
2608 | +*/ |
2609 | +gint |
2610 | +indicate_server_get_max_indicators (IndicateServer * server) |
2611 | +{ |
2612 | + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); |
2613 | + |
2614 | + if (class != NULL && class->max_indicators_get != NULL) { |
2615 | + return class->max_indicators_get (server); |
2616 | + } |
2617 | + |
2618 | + g_warning("get_max_indicators function not implemented in this server class: %s", G_OBJECT_TYPE_NAME(server)); |
2619 | + return -1; |
2620 | } |
2621 | |
2622 | /* *** Folks stuff *** */ |
2623 | |
2624 | +/* This checks for folk by looking at the sender value |
2625 | + and sees if we can find any that have the same sender. */ |
2626 | static gint |
2627 | indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b) |
2628 | { |
2629 | return g_strcmp0(((IndicateServerInterestedFolk *)a)->sender,((IndicateServerInterestedFolk *)b)->sender); |
2630 | } |
2631 | |
2632 | +/* Creates a IndicateServerInterestedFolk structure and |
2633 | + initializes the default values to reasonable defaults. */ |
2634 | static void |
2635 | indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender) |
2636 | { |
2637 | @@ -1483,9 +1643,14 @@ |
2638 | folk->interests[i] = FALSE; |
2639 | } |
2640 | |
2641 | + folk->max_indicators = MAX_INDICATORS_UNSET; |
2642 | + |
2643 | + folk->indicators_displayed = g_hash_table_new(g_direct_hash, g_direct_equal); |
2644 | + |
2645 | return; |
2646 | } |
2647 | |
2648 | +/* Identifies an interest in the folk. */ |
2649 | static void |
2650 | indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value) |
2651 | { |
2652 | @@ -1493,6 +1658,8 @@ |
2653 | return; |
2654 | } |
2655 | |
2656 | +/* Copies the interest table from a folk structure into a |
2657 | + generic gboolean array of length INDICATE_INTEREST_LAST */ |
2658 | static void |
2659 | indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests) |
2660 | { |
2661 | @@ -1506,11 +1673,15 @@ |
2662 | return; |
2663 | } |
2664 | |
2665 | +/* Destroys all the internal parts of the IndicateServerInterestedFolk |
2666 | + and then destroys the structure itself */ |
2667 | static void |
2668 | indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk) |
2669 | { |
2670 | g_free(folk->sender); |
2671 | + g_hash_table_destroy(folk->indicators_displayed); |
2672 | g_free(folk); |
2673 | return; |
2674 | } |
2675 | + |
2676 | /* *** End Folks *** */ |
2677 | |
2678 | === modified file 'libindicate/server.h' |
2679 | --- libindicate/server.h 2009-08-03 17:50:57 +0000 |
2680 | +++ libindicate/server.h 2009-09-01 02:36:52 +0000 |
2681 | @@ -47,14 +47,26 @@ |
2682 | |
2683 | #define INDICATE_SERVER_INDICATOR_NULL (0) |
2684 | |
2685 | -#define INDICATE_SERVER_SIGNAL_INDICATOR_ADDED "indicator-added" |
2686 | -#define INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED "indicator-removed" |
2687 | -#define INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED "indicator-modified" |
2688 | -#define INDICATE_SERVER_SIGNAL_SERVER_SHOW "server-show" |
2689 | -#define INDICATE_SERVER_SIGNAL_SERVER_HIDE "server-hide" |
2690 | -#define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY "server-display" |
2691 | -#define INDICATE_SERVER_SIGNAL_INTEREST_ADDED "interest-added" |
2692 | -#define INDICATE_SERVER_SIGNAL_INTEREST_REMOVED "interest-removed" |
2693 | +#define INDICATE_SERVER_SIGNAL_INDICATOR_ADDED "indicator-added" |
2694 | +#define INDICATE_SERVER_SIGNAL_INDICATOR_ADDED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_INDICATOR_ADDED, INDICATE_TYPE_SERVER)) |
2695 | +#define INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED "indicator-removed" |
2696 | +#define INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED, INDICATE_TYPE_SERVER)) |
2697 | +#define INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED "indicator-modified" |
2698 | +#define INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED, INDICATE_TYPE_SERVER)) |
2699 | +#define INDICATE_SERVER_SIGNAL_SERVER_SHOW "server-show" |
2700 | +#define INDICATE_SERVER_SIGNAL_SERVER_SHOW_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_SERVER_SHOW, INDICATE_TYPE_SERVER)) |
2701 | +#define INDICATE_SERVER_SIGNAL_SERVER_HIDE "server-hide" |
2702 | +#define INDICATE_SERVER_SIGNAL_SERVER_HIDE_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_SERVER_HIDE, INDICATE_TYPE_SERVER)) |
2703 | +#define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY "server-display" |
2704 | +#define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_SERVER_DISPLAY, INDICATE_TYPE_SERVER)) |
2705 | +#define INDICATE_SERVER_SIGNAL_INTEREST_ADDED "interest-added" |
2706 | +#define INDICATE_SERVER_SIGNAL_INTEREST_ADDED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_INTEREST_ADDED, INDICATE_TYPE_SERVER)) |
2707 | +#define INDICATE_SERVER_SIGNAL_INTEREST_REMOVED "interest-removed" |
2708 | +#define INDICATE_SERVER_SIGNAL_INTEREST_REMOVED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_INTEREST_REMOVED, INDICATE_TYPE_SERVER)) |
2709 | +#define INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED "max-indicators-changed" |
2710 | +#define INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED, INDICATE_TYPE_SERVER)) |
2711 | +#define INDICATE_SERVER_SIGNAL_SERVER_COUNT_CHANGED "server-count-changed" |
2712 | +#define INDICATE_SERVER_SIGNAL_SERVER_COUNT_CHANGED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_SERVER_COUNT_CHANGED, INDICATE_TYPE_SERVER)) |
2713 | |
2714 | /** |
2715 | IndicateServer: |
2716 | @@ -84,13 +96,11 @@ |
2717 | @server_display: Slot for #IndicateServer::server-display. |
2718 | @interest_added: Slot for #IndicateServer::interest-added. |
2719 | @interest_removed: Slot for #IndicateServer::interest-removed. |
2720 | + @max_indicators_changed: Slot for #IndicateServer::max-indicators-changed. |
2721 | + @server_count_changed: Slot for #IndicateServer::server-count-changed. |
2722 | @get_indicator_count: Returns the number of indicators that are visible |
2723 | on the bus. Hidden indicators should not be counted. |
2724 | - @get_indicator_count_by_type: Returns the number of indicators that are |
2725 | - of a given type and visible on the bus. |
2726 | @get_indicator_list: List all of the indicators that are visible. |
2727 | - @get_indicator_list_by_type: List all of the indicators of a given |
2728 | - type that are visible. |
2729 | @get_indicator_property: Get a property from a particular indicator. |
2730 | @get_indicator_property_group: Get the values for a set of properties |
2731 | as an array of entries, returning an array as well. |
2732 | @@ -98,6 +108,8 @@ |
2733 | on a particular indicator. |
2734 | @show_indicator_to_user: Respond to someone on the bus asking to show |
2735 | a particular indicator to the user. |
2736 | + @indicator_displayed: An indicator has been visualized by the listener |
2737 | + or it hasn't. This function tracks that. |
2738 | @get_next_id: Get the next unused indicator ID. |
2739 | @show_interest: React to someone signifying that they are interested |
2740 | in this server. |
2741 | @@ -105,6 +117,10 @@ |
2742 | server, remove it's interest. |
2743 | @check_interest: Check to see if anyone on the bus is interested in this |
2744 | server for a particular feature. |
2745 | + @max_indicators_set: Set the maximum number of indicators that a |
2746 | + given listener can display. |
2747 | + @max_indicators_get: Gets the maximum number of indicators from all |
2748 | + listeners that care about this server. |
2749 | @indicate_server_reserved1: Reserved for future use |
2750 | @indicate_server_reserved2: Reserved for future use |
2751 | @indicate_server_reserved3: Reserved for future use |
2752 | @@ -120,28 +136,31 @@ |
2753 | GObjectClass parent; |
2754 | |
2755 | /* Signals */ |
2756 | - void (* indicator_added) (IndicateServer * server, guint id, gchar * type); |
2757 | - void (* indicator_removed) (IndicateServer * server, guint id, gchar * type); |
2758 | + void (* indicator_added) (IndicateServer * server, guint id); |
2759 | + void (* indicator_removed) (IndicateServer * server, guint id); |
2760 | void (* indicator_modified) (IndicateServer * server, guint id, gchar * property); |
2761 | void (* server_show) (IndicateServer * server, gchar * type); |
2762 | void (* server_hide) (IndicateServer * server, gchar * type); |
2763 | void (* server_display) (IndicateServer * server); |
2764 | void (* interest_added) (IndicateServer * server, IndicateInterests interest); |
2765 | void (* interest_removed) (IndicateServer * server, IndicateInterests interest); |
2766 | + void (* max_indicators_changed) (IndicateServer * server, gint max); |
2767 | + void (* server_count_changed) (IndicateServer * server, guint count); |
2768 | |
2769 | /* Virtual Functions */ |
2770 | gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error); |
2771 | - gboolean (*get_indicator_count_by_type) (IndicateServer * server, gchar * type, guint * count, GError **error); |
2772 | gboolean (*get_indicator_list) (IndicateServer * server, GArray ** indicators, GError ** error); |
2773 | - gboolean (*get_indicator_list_by_type) (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error); |
2774 | gboolean (*get_indicator_property) (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error); |
2775 | gboolean (*get_indicator_property_group) (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error); |
2776 | gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error); |
2777 | gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, GError ** error); |
2778 | + gboolean (*indicator_displayed) (IndicateServer * server, gchar * sender, guint id, gboolean displayed, GError ** error); |
2779 | guint (*get_next_id) (IndicateServer * server); |
2780 | gboolean (*show_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest); |
2781 | gboolean (*remove_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest); |
2782 | gboolean (*check_interest) (IndicateServer * server, IndicateInterests interest); |
2783 | + gboolean (*max_indicators_set) (IndicateServer * server, gchar * sender, gint max); |
2784 | + gint (*max_indicators_get) (IndicateServer * server); |
2785 | |
2786 | /* Reserver for future use */ |
2787 | void (*indicate_server_reserved1)(void); |
2788 | @@ -159,6 +178,7 @@ |
2789 | * out of */ |
2790 | void indicate_server_set_desktop_file (IndicateServer * server, const gchar * path); |
2791 | void indicate_server_set_type (IndicateServer * server, const gchar * type); |
2792 | +void indicate_server_set_count (IndicateServer * server, guint count); |
2793 | |
2794 | /* Show and hide the server on DBus, this allows for the server to |
2795 | * be created, change the object, and then shown. If for some |
2796 | @@ -176,13 +196,8 @@ |
2797 | |
2798 | /* Check to see if there is someone, out there, who likes this */ |
2799 | gboolean indicate_server_check_interest (IndicateServer * server, IndicateInterests interest); |
2800 | - |
2801 | - |
2802 | -/* Signal emission functions for sub-classes of the server */ |
2803 | -void indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type); |
2804 | -void indicate_server_emit_indicator_removed (IndicateServer *server, guint id, const gchar *type); |
2805 | -void indicate_server_emit_indicator_modified (IndicateServer *server, guint id, const gchar *property); |
2806 | -void indicate_server_emit_server_display (IndicateServer *server); |
2807 | +/* See how many indicators we can show */ |
2808 | +gint indicate_server_get_max_indicators (IndicateServer * server); |
2809 | |
2810 | /** |
2811 | SECTION:server |
This is the changes that have often been referred to as the "V2 changes" to the API. While most of the V2 changes are based on the values that are passed there are a few that have had a surprisingly large impact in the libindicate library.
First the indicators themselves are not strongly typed. This means that the property type isn't protected except for subclasses, and that the signals to do with indicators can not use type in their parameters. This also changed some internal data structures as a result.
Secondly there needed to be a way for listeners to specify how many indicators they're willing to display and which ones they do if they start being choosy. This is accomplished with two APIs. The first is that a listener can specify a max number of indicators for a server. This is mostly informative, but a server signals to the application what this value is and when it changes. The second is that the listener should tell the server when an indicator is displayed to the user. This is a simple function call to the server. The server then tracks which listeners have signaled this, and handles the lifecycles of those listeners and their choices.
Lastly, and by far the simplest change. Servers can now have a count property. If they choose to not have any indicators shown they can just set a global count for the server.
Finally, the biggest thing lacking in this merge is a set of tests for this functionality. I decided to get more eyeballs rather than make it perfect with all of the testing required. :)