Merge lp:~indicator-applet-developers/libindicate/ubuntu into lp:~ubuntu-desktop/libindicate/ubuntu

Proposed by Ted Gould
Status: Merged
Merge reported by: Ken VanDine
Merged at revision: not available
Proposed branch: lp:~indicator-applet-developers/libindicate/ubuntu
Merge into: lp:~ubuntu-desktop/libindicate/ubuntu
Diff against target: None lines
To merge this branch: bzr merge lp:~indicator-applet-developers/libindicate/ubuntu
Reviewer Review Type Date Requested Status
Ken VanDine Approve
Review via email: mp+11529@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ken VanDine (ken-vandine) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2009-08-07 15:06:32 +0000
+++ .bzrignore 2009-09-03 21:57:34 +0000
@@ -103,3 +103,47 @@
103data/GNOME_IndicatorAppletSUS.server103data/GNOME_IndicatorAppletSUS.server
104data/GNOME_IndicatorAppletSUS.server.in104data/GNOME_IndicatorAppletSUS.server.in
105src-sus/indicator-applet-no-sus105src-sus/indicator-applet-no-sus
106docs/reference/libindicate-decl-list.txt.bak
107docs/reference/libindicate-decl.txt.bak
108INSTALL
109Makefile
110Makefile.in
111aclocal.m4
112autom4te.cache
113config.guess
114config.h
115config.h.in
116config.log
117config.status
118config.sub
119configure
120depcomp
121gnome-doc-utils.make
122install-sh
123libtool
124ltmain.sh
125missing
126omf.make
127stamp-h1
128xmldocs.make
129docs/Makefile
130docs/Makefile.in
131docs/reference/Makefile
132docs/reference/Makefile.in
133examples/Makefile
134examples/Makefile.in
135libindicate/Makefile
136libindicate/Makefile.in
137libindicate/indicate-0.2.pc
138libindicate-gtk/Makefile
139libindicate-gtk/Makefile.in
140libindicate-gtk/indicate-gtk-0.2.pc
141tests/Makefile
142tests/Makefile.in
143tests/test-max-indicators-client
144tests/test-max-indicators-server
145tests/test-max-indicators-server-repeat
146tests/test-indicator-display-client
147tests/test-indicator-display-server
148tests/test-indicator-display-half-server
149tests/test-indicator-display-half-client
106150
=== modified file 'configure.ac'
--- configure.ac 2009-08-18 18:10:11 +0000
+++ configure.ac 2009-09-03 22:33:32 +0000
@@ -1,10 +1,10 @@
11
2AC_INIT(libindicate, 0.2.0dev, ted@canonical.com)2AC_INIT(libindicate, 0.2.0, ted@canonical.com)
33
4AC_PREREQ(2.53)4AC_PREREQ(2.53)
55
6AM_CONFIG_HEADER(config.h)6AM_CONFIG_HEADER(config.h)
7AM_INIT_AUTOMAKE(libindicate, 0.2.0dev)7AM_INIT_AUTOMAKE(libindicate, 0.2.0)
88
9AM_MAINTAINER_MODE9AM_MAINTAINER_MODE
10m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES])10m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES])
@@ -18,11 +18,13 @@
18AC_SUBST(VERSION)18AC_SUBST(VERSION)
19AC_CONFIG_MACRO_DIR([m4])19AC_CONFIG_MACRO_DIR([m4])
2020
21m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
22
21###########################23###########################
22# Libindicate versioning 24# Libindicate versioning
23###########################25###########################
2426
25LIBINDICATE_CURRENT=227LIBINDICATE_CURRENT=3
26LIBINDICATE_REVISION=028LIBINDICATE_REVISION=0
27LIBINDICATE_AGE=029LIBINDICATE_AGE=0
2830
@@ -34,7 +36,7 @@
34# Libindicate versioning 36# Libindicate versioning
35###########################37###########################
3638
37LIBINDICATEGTK_CURRENT=039LIBINDICATEGTK_CURRENT=1
38LIBINDICATEGTK_REVISION=040LIBINDICATEGTK_REVISION=0
39LIBINDICATEGTK_AGE=041LIBINDICATEGTK_AGE=0
4042
4143
=== modified file 'debian/changelog'
--- debian/changelog 2009-08-25 06:30:03 +0000
+++ debian/changelog 2009-09-09 13:42:06 +0000
@@ -1,3 +1,47 @@
1libindicate (0.2.0-0ubuntu1~ppa6) karmic; urgency=low
2
3 * Merge from the extra funcs branch
4 * Big change is renaming some signal names. :(
5 * Bug fixes in getting properties.
6 * Removing looking at the type on indicator lists.
7 * Fixing the count callback.
8
9 -- Ted Gould <ted@ubuntu.com> Wed, 09 Sep 2009 08:42:01 -0500
10
11libindicate (0.2.0-0ubuntu1~ppa5) karmic; urgency=low
12
13 * Merging with ~ubuntu-desktop
14
15 -- Ted Gould <ted@ubuntu.com> Fri, 04 Sep 2009 14:08:34 -0500
16
17libindicate (0.2.0-0ubuntu1~ppa4) karmic; urgency=low
18
19 * Merging things onto a trunk branch.
20
21 -- Ted Gould <ted@ubuntu.com> Fri, 04 Sep 2009 14:04:30 -0500
22
23libindicate (0.2.0-0ubuntu1~ppa3) karmic; urgency=low
24
25 * Adding back indicator-messages.h for some defines.
26
27 -- Ted Gould <ted@ubuntu.com> Fri, 04 Sep 2009 12:47:52 -0500
28
29libindicate (0.2.0-0ubuntu1~ppa2) karmic; urgency=low
30
31 * 64-bit build fixes.
32
33 -- Ted Gould <ted@ubuntu.com> Thu, 03 Sep 2009 22:01:57 -0500
34
35libindicate (0.2.0-0ubuntu1~ppa1) karmic; urgency=low
36
37 * Upstream merge
38 * debian/control: Increasing library versions to libindicate3
39 and libindicate-gtk1. Moving .install files as well.
40 * libindicate-dev and libindicate-gtk-dev.install change to
41 /usr/include/libindicate-0.2 from 0.1
42
43 -- Ted Gould <ted@ubuntu.com> Thu, 03 Sep 2009 17:34:56 -0500
44
1libindicate (0.2.0~bzr325-0ubuntu1) karmic; urgency=low45libindicate (0.2.0~bzr325-0ubuntu1) karmic; urgency=low
246
3 [ Ken VanDine ]47 [ Ken VanDine ]
@@ -8,10 +52,5 @@
8 * Setting the icon path in the .pc file.52 * Setting the icon path in the .pc file.
9 * debian/control:53 * debian/control:
10 - Set both Vcs-Bzr and Vcs-Bzr-Browser54 - Set both Vcs-Bzr and Vcs-Bzr-Browser
11 - Changed branch to ~ubuntu-desktop55
1256 -- Ted Gould <ted@ubuntu.com> Thu, 03 Sep 2009 17:16:51 -0500
13 [ Martin Pitt ]
14 * Flush changelog, the packaging changed pretty much completely.
15 * Fix Vcs-* links.
16
17 -- Ken VanDine <ken.vandine@canonical.com> Tue, 25 Aug 2009 08:29:59 +0200
1857
=== modified file 'debian/control'
--- debian/control 2009-08-25 06:23:53 +0000
+++ debian/control 2009-09-04 19:08:30 +0000
@@ -16,7 +16,7 @@
16Vcs-Bzr: https://code.launchpad.net/~ubuntu-desktop/libindicate/ubuntu16Vcs-Bzr: https://code.launchpad.net/~ubuntu-desktop/libindicate/ubuntu
17Vcs-Browser: http://bazaar.launchpad.net/~ubuntu-desktop/libindicate/ubuntu17Vcs-Browser: http://bazaar.launchpad.net/~ubuntu-desktop/libindicate/ubuntu
1818
19Package: libindicate219Package: libindicate3
20Section: libs20Section: libs
21Conflicts: libindicate21Conflicts: libindicate
22Replaces: libindicate22Replaces: libindicate
@@ -34,7 +34,7 @@
34Architecture: any34Architecture: any
35Depends: ${shlibs:Depends},35Depends: ${shlibs:Depends},
36 ${misc:Depends},36 ${misc:Depends},
37 libindicate2 (= ${binary:Version}),37 libindicate3 (= ${binary:Version}),
38 libdbus-glib-1-dev (>= 0.76)38 libdbus-glib-1-dev (>= 0.76)
39Description: GNOME panel indicator applet - shared library39Description: GNOME panel indicator applet - shared library
40 indicator-applet is an applet to display information from40 indicator-applet is an applet to display information from
@@ -42,7 +42,7 @@
42 .42 .
43 This package contains files that are needed to build applications.43 This package contains files that are needed to build applications.
4444
45Package: libindicate-gtk045Package: libindicate-gtk1
46Section: libs46Section: libs
47Architecture: any47Architecture: any
48Depends: ${shlibs:Depends},48Depends: ${shlibs:Depends},
@@ -58,7 +58,7 @@
58Architecture: any58Architecture: any
59Depends: ${shlibs:Depends},59Depends: ${shlibs:Depends},
60 ${misc:Depends},60 ${misc:Depends},
61 libindicate-gtk0 (= ${binary:Version}),61 libindicate-gtk1 (= ${binary:Version}),
62 libindicate-dev (= ${binary:Version}),62 libindicate-dev (= ${binary:Version}),
63 libdbus-glib-1-dev (>= 0.76),63 libdbus-glib-1-dev (>= 0.76),
64 libgtk2.0-dev (>= 2.12.0)64 libgtk2.0-dev (>= 2.12.0)
@@ -73,8 +73,8 @@
73Architecture: any73Architecture: any
74Depends: ${shlibs:Depends},74Depends: ${shlibs:Depends},
75 ${misc:Depends},75 ${misc:Depends},
76 libindicate2 (= ${binary:Version}),76 libindicate3 (= ${binary:Version}),
77 libindicate-gtk0 (= ${binary:Version}),77 libindicate-gtk1 (= ${binary:Version}),
78 libdbus-glib-1-dev (>= 0.76),78 libdbus-glib-1-dev (>= 0.76),
79 libgtk2.0-dev (>= 2.12.0)79 libgtk2.0-dev (>= 2.12.0)
80Description: GNOME panel indicator applet - shared library80Description: GNOME panel indicator applet - shared library
8181
=== modified file 'debian/libindicate-dev.install'
--- debian/libindicate-dev.install 2009-08-03 23:32:09 +0000
+++ debian/libindicate-dev.install 2009-09-03 22:27:49 +0000
@@ -1,4 +1,4 @@
1debian/tmp/usr/include/libindicate-0.1/libindicate/*1debian/tmp/usr/include/libindicate-0.2/libindicate/*
2debian/tmp/usr/lib/pkgconfig/indicate.pc2debian/tmp/usr/lib/pkgconfig/indicate.pc
3debian/tmp/usr/lib/libindicate.a3debian/tmp/usr/lib/libindicate.a
4debian/tmp/usr/lib/libindicate.so4debian/tmp/usr/lib/libindicate.so
55
=== modified file 'debian/libindicate-gtk-dev.install'
--- debian/libindicate-gtk-dev.install 2009-08-03 23:32:09 +0000
+++ debian/libindicate-gtk-dev.install 2009-09-03 22:27:49 +0000
@@ -1,4 +1,4 @@
1debian/tmp/usr/include/libindicate-0.1/libindicate-gtk/*1debian/tmp/usr/include/libindicate-0.2/libindicate-gtk/*
2debian/tmp/usr/lib/pkgconfig/indicate-gtk.pc2debian/tmp/usr/lib/pkgconfig/indicate-gtk.pc
3debian/tmp/usr/lib/libindicate-gtk.a3debian/tmp/usr/lib/libindicate-gtk.a
4debian/tmp/usr/lib/libindicate-gtk.so4debian/tmp/usr/lib/libindicate-gtk.so
55
=== renamed file 'debian/libindicate-gtk0.install' => 'debian/libindicate-gtk1.install'
=== renamed file 'debian/libindicate2.install' => 'debian/libindicate3.install'
=== modified file 'docs/reference/libindicate-sections.txt'
--- docs/reference/libindicate-sections.txt 2009-05-01 03:30:04 +0000
+++ docs/reference/libindicate-sections.txt 2009-08-31 20:06:58 +0000
@@ -6,38 +6,24 @@
6IndicateIndicator6IndicateIndicator
7IndicateIndicatorClass7IndicateIndicatorClass
8indicate_indicator_get_id8indicate_indicator_get_id
9indicate_indicator_get_indicator_type
10indicate_indicator_get_property9indicate_indicator_get_property
11indicate_indicator_hide10indicate_indicator_hide
12indicate_indicator_is_visible11indicate_indicator_is_visible
13indicate_indicator_list_properties12indicate_indicator_list_properties
14indicate_indicator_new13indicate_indicator_new
15indicate_indicator_set_property14indicate_indicator_set_property
16indicate_indicator_set_property_icon
17indicate_indicator_set_property_time15indicate_indicator_set_property_time
18indicate_indicator_show16indicate_indicator_show
19indicate_indicator_user_display17indicate_indicator_user_display
20</SECTION>18</SECTION>
2119
22<SECTION>20<SECTION>
23<FILE>indicator-message</FILE>
24<TITLE>IndicateIndicatorMessage</TITLE>
25IndicateIndicatorMessage
26IndicateIndicatorMessageClass
27indicate_indicator_message_new
28</SECTION>
29
30<SECTION>
31<FILE>server</FILE>21<FILE>server</FILE>
32<TITLE>IndicateServer</TITLE>22<TITLE>IndicateServer</TITLE>
33IndicateServer23IndicateServer
34IndicateServerClass24IndicateServerClass
35indicate_server_add_indicator25indicate_server_add_indicator
36indicate_server_check_interest26indicate_server_check_interest
37indicate_server_emit_indicator_added
38indicate_server_emit_indicator_modified
39indicate_server_emit_indicator_removed
40indicate_server_emit_server_display
41indicate_server_get_next_id27indicate_server_get_next_id
42indicate_server_hide28indicate_server_hide
43indicate_server_ref_default29indicate_server_ref_default
4430
=== modified file 'docs/reference/libindicate.types'
--- docs/reference/libindicate.types 2009-02-03 13:56:35 +0000
+++ docs/reference/libindicate.types 2009-08-28 20:58:09 +0000
@@ -1,9 +1,7 @@
1#include <libindicate/indicator.h>1#include <libindicate/indicator.h>
2#include <libindicate/indicator-message.h>
3#include <libindicate/server.h>2#include <libindicate/server.h>
4#include <libindicate/listener.h>3#include <libindicate/listener.h>
54
6indicate_indicator_get_type5indicate_indicator_get_type
7indicate_indicator_message_get_type
8indicate_server_get_type6indicate_server_get_type
9indicate_listener_get_type7indicate_listener_get_type
108
=== modified file 'docs/reference/tmpl/libindicate-unused.sgml'
--- docs/reference/tmpl/libindicate-unused.sgml 2009-08-04 11:30:59 +0000
+++ docs/reference/tmpl/libindicate-unused.sgml 2009-09-08 22:03:55 +0000
@@ -1,377 +1,73 @@
1<!-- ##### MACRO INDICATE_INDICATOR ##### -->1<!-- ##### SECTION ./tmpl/indicator-message.sgml:Long_Description ##### -->
2<para>2<para>
33
4</para>4</para>
55
6@object: 6
77<!-- ##### SECTION ./tmpl/indicator-message.sgml:See_Also ##### -->
8<!-- ##### MACRO INDICATE_INDICATOR_CLASS ##### -->8<para>
9<para>9
1010</para>
11</para>11
1212
13@klass: 13<!-- ##### SECTION ./tmpl/indicator-message.sgml:Short_Description ##### -->
1414
15<!-- ##### MACRO INDICATE_INDICATOR_GET_CLASS ##### -->15
16<para>16
1717<!-- ##### SECTION ./tmpl/indicator-message.sgml:Stability_Level ##### -->
18</para>18
1919
20@object: 20
2121<!-- ##### SECTION ./tmpl/indicator-message.sgml:Title ##### -->
22<!-- ##### MACRO INDICATE_INDICATOR_MESSAGE ##### -->22IndicateIndicatorMessage
23<para>23
2424
25</para>25<!-- ##### STRUCT IndicateIndicatorMessage ##### -->
2626<para>
27@obj: 27
2828</para>
29<!-- ##### MACRO INDICATE_INDICATOR_MESSAGE_CLASS ##### -->29
30<para>30
3131<!-- ##### STRUCT IndicateIndicatorMessageClass ##### -->
32</para>32<para>
3333
34@klass: 34</para>
3535
36<!-- ##### MACRO INDICATE_INDICATOR_MESSAGE_GET_CLASS ##### -->36@parent_class:
37<para>37
3838<!-- ##### SIGNAL IndicateServer::indicator-added ##### -->
39</para>39<para>
4040
41@obj: 41</para>
4242
43<!-- ##### MACRO INDICATE_INDICATOR_SIGNAL_DISPLAY ##### -->43@indicateserver: the object which received the signal.
44<para>44@arg1:
4545
46</para>46<!-- ##### SIGNAL IndicateServer::indicator-not-shown ##### -->
4747<para>
4848
49<!-- ##### MACRO INDICATE_INDICATOR_SIGNAL_HIDE ##### -->49</para>
50<para>50
5151@indicateserver: the object which received the signal.
52</para>52@arg1:
5353
5454<!-- ##### SIGNAL IndicateServer::indicator-removed ##### -->
55<!-- ##### MACRO INDICATE_INDICATOR_SIGNAL_MODIFIED ##### -->55<para>
56<para>56
5757</para>
58</para>58
5959@indicateserver: the object which received the signal.
6060@arg1:
61<!-- ##### MACRO INDICATE_INDICATOR_SIGNAL_SHOW ##### -->61
62<para>62<!-- ##### FUNCTION indicate_indicator_get_indicator_type ##### -->
63
64</para>
65
66
67<!-- ##### MACRO INDICATE_IS_INDICATOR ##### -->
68<para>
69
70</para>
71
72@object:
73
74<!-- ##### MACRO INDICATE_IS_INDICATOR_CLASS ##### -->
75<para>
76
77</para>
78
79@klass:
80
81<!-- ##### MACRO INDICATE_IS_INDICATOR_MESSAGE ##### -->
82<para>
83
84</para>
85
86@obj:
87
88<!-- ##### MACRO INDICATE_IS_INDICATOR_MESSAGE_CLASS ##### -->
89<para>
90
91</para>
92
93@klass:
94
95<!-- ##### MACRO INDICATE_IS_LISTENER ##### -->
96<para>
97
98</para>
99
100@object:
101
102<!-- ##### MACRO INDICATE_IS_LISTENER_CLASS ##### -->
103<para>
104
105</para>
106
107@klass:
108
109<!-- ##### MACRO INDICATE_IS_SERVER ##### -->
110<para>
111
112</para>
113
114@object:
115
116<!-- ##### MACRO INDICATE_IS_SERVER_CLASS ##### -->
117<para>
118
119</para>
120
121@klass:
122
123<!-- ##### MACRO INDICATE_LISTENER ##### -->
124<para>
125
126</para>
127
128@object:
129
130<!-- ##### MACRO INDICATE_LISTENER_CLASS ##### -->
131<para>
132
133</para>
134
135@klass:
136
137<!-- ##### MACRO INDICATE_LISTENER_GET_CLASS ##### -->
138<para>
139
140</para>
141
142@object:
143
144<!-- ##### MACRO INDICATE_LISTENER_INDICATOR_ID ##### -->
145<para>63<para>
14664
147</para>65</para>
14866
149@indicator: 67@indicator:
15068@Returns:
151<!-- ##### MACRO INDICATE_LISTENER_SERVER_DBUS_NAME ##### -->69
152<para>70<!-- ##### FUNCTION indicate_indicator_message_new ##### -->
153
154</para>
155
156@server:
157
158<!-- ##### MACRO INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED ##### -->
159<para>
160
161</para>
162
163
164<!-- ##### MACRO INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED ##### -->
165<para>
166
167</para>
168
169
170<!-- ##### MACRO INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED ##### -->
171<para>
172
173</para>
174
175
176<!-- ##### MACRO INDICATE_LISTENER_SIGNAL_SERVER_ADDED ##### -->
177<para>
178
179</para>
180
181
182<!-- ##### MACRO INDICATE_LISTENER_SIGNAL_SERVER_REMOVED ##### -->
183<para>
184
185</para>
186
187
188<!-- ##### MACRO INDICATE_SERVER ##### -->
189<para>
190
191</para>
192
193@object:
194
195<!-- ##### MACRO INDICATE_SERVER_CLASS ##### -->
196<para>
197
198</para>
199
200@klass:
201
202<!-- ##### MACRO INDICATE_SERVER_GET_CLASS ##### -->
203<para>
204
205</para>
206
207@object:
208
209<!-- ##### MACRO INDICATE_TYPE_INDICATOR ##### -->
210<para>
211
212</para>
213
214
215<!-- ##### MACRO INDICATE_TYPE_INDICATOR_MESSAGE ##### -->
216<para>
217
218</para>
219
220
221<!-- ##### MACRO INDICATE_TYPE_LISTENER ##### -->
222<para>
223
224</para>
225
226
227<!-- ##### MACRO INDICATE_TYPE_SERVER ##### -->
228<para>
229
230</para>
231
232
233<!-- ##### FUNCTION dbus_g_proxy_begin_call ##### -->
234<para>
235
236</para>
237
238@Param1:
239@Returns:
240
241<!-- ##### MACRO g_marshal_value_peek_boolean ##### -->
242<para>
243
244</para>
245
246@v:
247
248<!-- ##### MACRO g_marshal_value_peek_boxed ##### -->
249<para>
250
251</para>
252
253@v:
254
255<!-- ##### MACRO g_marshal_value_peek_char ##### -->
256<para>
257
258</para>
259
260@v:
261
262<!-- ##### MACRO g_marshal_value_peek_double ##### -->
263<para>
264
265</para>
266
267@v:
268
269<!-- ##### MACRO g_marshal_value_peek_enum ##### -->
270<para>
271
272</para>
273
274@v:
275
276<!-- ##### MACRO g_marshal_value_peek_flags ##### -->
277<para>
278
279</para>
280
281@v:
282
283<!-- ##### MACRO g_marshal_value_peek_float ##### -->
284<para>
285
286</para>
287
288@v:
289
290<!-- ##### MACRO g_marshal_value_peek_int ##### -->
291<para>
292
293</para>
294
295@v:
296
297<!-- ##### MACRO g_marshal_value_peek_int64 ##### -->
298<para>
299
300</para>
301
302@v:
303
304<!-- ##### MACRO g_marshal_value_peek_long ##### -->
305<para>
306
307</para>
308
309@v:
310
311<!-- ##### MACRO g_marshal_value_peek_object ##### -->
312<para>
313
314</para>
315
316@v:
317
318<!-- ##### MACRO g_marshal_value_peek_param ##### -->
319<para>
320
321</para>
322
323@v:
324
325<!-- ##### MACRO g_marshal_value_peek_pointer ##### -->
326<para>
327
328</para>
329
330@v:
331
332<!-- ##### MACRO g_marshal_value_peek_string ##### -->
333<para>
334
335</para>
336
337@v:
338
339<!-- ##### MACRO g_marshal_value_peek_uchar ##### -->
340<para>
341
342</para>
343
344@v:
345
346<!-- ##### MACRO g_marshal_value_peek_uint ##### -->
347<para>
348
349</para>
350
351@v:
352
353<!-- ##### MACRO g_marshal_value_peek_uint64 ##### -->
354<para>
355
356</para>
357
358@v:
359
360<!-- ##### MACRO g_marshal_value_peek_ulong ##### -->
361<para>
362
363</para>
364
365@v:
366
367<!-- ##### FUNCTION indicate_indicator_get_type ##### -->
368<para>
369
370</para>
371
372@Returns:
373
374<!-- ##### FUNCTION indicate_indicator_message_get_type ##### -->
375<para>71<para>
37672
377</para>73</para>
@@ -387,19 +83,39 @@
387@key: 83@key:
388@data: 84@data:
38985
390<!-- ##### FUNCTION indicate_listener_get_type ##### -->86<!-- ##### FUNCTION indicate_server_emit_indicator_added ##### -->
391<para>87<para>
39288
393</para>89</para>
39490
395@Returns: 91@server:
39692@id:
397<!-- ##### FUNCTION indicate_server_get_type ##### -->93@type:
398<para>94
39995<!-- ##### FUNCTION indicate_server_emit_indicator_modified ##### -->
400</para>96<para>
40197
402@Returns: 98</para>
99
100@server:
101@id:
102@property:
103
104<!-- ##### FUNCTION indicate_server_emit_indicator_removed ##### -->
105<para>
106
107</para>
108
109@server:
110@id:
111@type:
112
113<!-- ##### FUNCTION indicate_server_emit_server_display ##### -->
114<para>
115
116</para>
117
118@server:
403119
404<!-- ##### FUNCTION indicate_server_new ##### -->120<!-- ##### FUNCTION indicate_server_new ##### -->
405<para>121<para>
@@ -415,241 +131,3 @@
415131
416@obj: 132@obj:
417133
418<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_count ##### -->
419<para>
420
421</para>
422
423@proxy:
424@OUT_indicator_count:
425@Returns:
426
427<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_count_async ##### -->
428<para>
429
430</para>
431
432@proxy:
433@callback:
434@Returns:
435
436<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_count_by_type ##### -->
437<para>
438
439</para>
440
441@proxy:
442@IN_type:
443@OUT_indicator_count:
444@Returns:
445
446<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_count_by_type_async ##### -->
447<para>
448
449</para>
450
451@proxy:
452@IN_type:
453@callback:
454@Returns:
455
456<!-- ##### USER_FUNCTION org_freedesktop_indicator_get_indicator_count_by_type_reply ##### -->
457<para>
458
459</para>
460
461@proxy:
462@OUT_indicator_count:
463@error:
464@userdata:
465
466<!-- ##### USER_FUNCTION org_freedesktop_indicator_get_indicator_count_reply ##### -->
467<para>
468
469</para>
470
471@proxy:
472@OUT_indicator_count:
473@error:
474@userdata:
475
476<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_list ##### -->
477<para>
478
479</para>
480
481@proxy:
482@OUT_indicators:
483@Returns:
484
485<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_list_async ##### -->
486<para>
487
488</para>
489
490@proxy:
491@callback:
492@Returns:
493
494<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_list_by_type ##### -->
495<para>
496
497</para>
498
499@proxy:
500@IN_type:
501@OUT_indicators:
502@Returns:
503
504<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_list_by_type_async ##### -->
505<para>
506
507</para>
508
509@proxy:
510@IN_type:
511@callback:
512@Returns:
513
514<!-- ##### USER_FUNCTION org_freedesktop_indicator_get_indicator_list_by_type_reply ##### -->
515<para>
516
517</para>
518
519@proxy:
520@OUT_indicators:
521@error:
522@userdata:
523
524<!-- ##### USER_FUNCTION org_freedesktop_indicator_get_indicator_list_reply ##### -->
525<para>
526
527</para>
528
529@proxy:
530@OUT_indicators:
531@error:
532@userdata:
533
534<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_properties ##### -->
535<para>
536
537</para>
538
539@proxy:
540@IN_id:
541@OUT_properties:
542@Returns:
543
544<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_properties_async ##### -->
545<para>
546
547</para>
548
549@proxy:
550@IN_id:
551@callback:
552@Returns:
553
554<!-- ##### USER_FUNCTION org_freedesktop_indicator_get_indicator_properties_reply ##### -->
555<para>
556
557</para>
558
559@proxy:
560@OUT_properties:
561@error:
562@userdata:
563
564<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_property ##### -->
565<para>
566
567</para>
568
569@proxy:
570@IN_id:
571@IN_property:
572@OUT_value:
573@Returns:
574
575<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_property_async ##### -->
576<para>
577
578</para>
579
580@proxy:
581@IN_id:
582@IN_property:
583@callback:
584@Returns:
585
586<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_property_group ##### -->
587<para>
588
589</para>
590
591@proxy:
592@IN_id:
593@IN_properties:
594@OUT_values:
595@Returns:
596
597<!-- ##### FUNCTION org_freedesktop_indicator_get_indicator_property_group_async ##### -->
598<para>
599
600</para>
601
602@proxy:
603@IN_id:
604@IN_properties:
605@callback:
606@Returns:
607
608<!-- ##### USER_FUNCTION org_freedesktop_indicator_get_indicator_property_group_reply ##### -->
609<para>
610
611</para>
612
613@proxy:
614@OUT_values:
615@error:
616@userdata:
617
618<!-- ##### USER_FUNCTION org_freedesktop_indicator_get_indicator_property_reply ##### -->
619<para>
620
621</para>
622
623@proxy:
624@OUT_value:
625@error:
626@userdata:
627
628<!-- ##### FUNCTION org_freedesktop_indicator_show_indicator_to_user ##### -->
629<para>
630
631</para>
632
633@proxy:
634@IN_id:
635@Returns:
636
637<!-- ##### FUNCTION org_freedesktop_indicator_show_indicator_to_user_async ##### -->
638<para>
639
640</para>
641
642@proxy:
643@IN_id:
644@callback:
645@Returns:
646
647<!-- ##### USER_FUNCTION org_freedesktop_indicator_show_indicator_to_user_reply ##### -->
648<para>
649
650</para>
651
652@proxy:
653@error:
654@userdata:
655
656134
=== modified file 'examples/im-client.c'
--- examples/im-client.c 2009-08-03 22:49:42 +0000
+++ examples/im-client.c 2009-08-28 19:40:56 +0000
@@ -21,7 +21,7 @@
2121
22#include <glib.h>22#include <glib.h>
23#include "libindicate/server.h"23#include "libindicate/server.h"
24#include "libindicate/indicator-message.h"24#include "libindicate/indicator.h"
25#include "libindicate-gtk/indicator.h"25#include "libindicate-gtk/indicator.h"
2626
27gchar * patha = "/usr/share/icons/hicolor/16x16/apps/empathy.png";27gchar * patha = "/usr/share/icons/hicolor/16x16/apps/empathy.png";
@@ -69,7 +69,7 @@
69static void69static void
70interest_added (IndicateServer * server, IndicateInterests interest)70interest_added (IndicateServer * server, IndicateInterests interest)
71{71{
72 g_debug("Oh, someone is interested in my for: %d", interest);72 g_debug("Oh, someone is interested in me for: %d", interest);
73}73}
7474
75void75void
@@ -90,9 +90,9 @@
90 g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_INTEREST_ADDED, G_CALLBACK(interest_added), NULL);90 g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_INTEREST_ADDED, G_CALLBACK(interest_added), NULL);
91 g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_INTEREST_REMOVED, G_CALLBACK(interest_removed), NULL);91 g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_INTEREST_REMOVED, G_CALLBACK(interest_removed), NULL);
9292
93 IndicateIndicatorMessage * indicator;93 IndicateIndicator * indicator;
9494
95 indicator = indicate_indicator_message_new();95 indicator = indicate_indicator_new();
96 indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "subtype", "im");96 indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "subtype", "im");
97 indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "sender", "IM Client Test");97 indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "sender", "IM Client Test");
98 GTimeVal time; g_get_current_time(&time);98 GTimeVal time; g_get_current_time(&time);
9999
=== modified file 'examples/show-hide-server.c'
--- examples/show-hide-server.c 2009-04-07 22:34:45 +0000
+++ examples/show-hide-server.c 2009-08-28 19:40:56 +0000
@@ -2,7 +2,6 @@
22
3#include <glib.h>3#include <glib.h>
4#include "libindicate/server.h"4#include "libindicate/server.h"
5#include "libindicate/indicator-message.h"
65
7gboolean hidden = TRUE;6gboolean hidden = TRUE;
87
@@ -12,14 +11,14 @@
12 IndicateServer * server = INDICATE_SERVER(data);11 IndicateServer * server = INDICATE_SERVER(data);
1312
14 if (hidden) {13 if (hidden) {
15 printf("showing... ");14 g_debug("showing... ");
16 indicate_server_show(server);15 indicate_server_show(server);
17 printf("ok\n");16 g_debug("ok\n");
18 hidden = FALSE;17 hidden = FALSE;
19 } else {18 } else {
20 printf("hiding... ");19 g_debug("hiding... ");
21 indicate_server_hide(server);20 indicate_server_hide(server);
22 printf("ok\n");21 g_debug("ok\n");
23 hidden = TRUE;22 hidden = TRUE;
24 }23 }
2524
2625
=== modified file 'libindicate-gtk/Makefile.am'
--- libindicate-gtk/Makefile.am 2009-08-04 00:26:10 +0000
+++ libindicate-gtk/Makefile.am 2009-09-03 22:32:17 +0000
@@ -8,7 +8,7 @@
8lib_LTLIBRARIES = \8lib_LTLIBRARIES = \
9 libindicate-gtk.la9 libindicate-gtk.la
1010
11libindicate_gtkincludedir=$(includedir)/libindicate-0.1/libindicate-gtk11libindicate_gtkincludedir=$(includedir)/libindicate-0.2/libindicate-gtk
1212
13indicate_gtk_headers = \13indicate_gtk_headers = \
14 indicator.h \14 indicator.h \
1515
=== modified file 'libindicate-gtk/indicate-gtk.pc.in'
--- libindicate-gtk/indicate-gtk.pc.in 2009-08-03 18:10:34 +0000
+++ libindicate-gtk/indicate-gtk.pc.in 2009-09-03 22:32:17 +0000
@@ -4,7 +4,7 @@
4bindir=@bindir@4bindir=@bindir@
5includedir=@includedir@5includedir=@includedir@
66
7Cflags: -I${includedir}/libindicate-0.17Cflags: -I${includedir}/libindicate-0.2
8Requires: gtk+-2.0 indicate8Requires: gtk+-2.0 indicate
9Libs: -L${libdir} -lindicate-gtk9Libs: -L${libdir} -lindicate-gtk
1010
1111
=== modified file 'libindicate-gtk/indicator.c'
--- libindicate-gtk/indicator.c 2009-08-03 18:25:05 +0000
+++ libindicate-gtk/indicator.c 2009-09-04 03:00:22 +0000
@@ -54,7 +54,7 @@
5454
55 if (!gdk_pixbuf_save_to_buffer((GdkPixbuf *)data, &png_data, &png_data_len, "png", &error, NULL)) {55 if (!gdk_pixbuf_save_to_buffer((GdkPixbuf *)data, &png_data, &png_data_len, "png", &error, NULL)) {
56 if (error == NULL) {56 if (error == NULL) {
57 g_warning("Unable to create pixbuf data stream: %d", png_data_len);57 g_warning("Unable to create pixbuf data stream: %d", (gint)png_data_len);
58 } else {58 } else {
59 g_warning("Unable to create pixbuf data stream: %s", error->message);59 g_warning("Unable to create pixbuf data stream: %s", error->message);
60 g_error_free(error);60 g_error_free(error);
6161
=== modified file 'libindicate-gtk/listener.c'
--- libindicate-gtk/listener.c 2009-08-03 22:43:37 +0000
+++ libindicate-gtk/listener.c 2009-09-08 20:59:59 +0000
@@ -127,7 +127,7 @@
127{127{
128 /* g_debug("get_property_helper: %s %d", property, prop_type); */128 /* g_debug("get_property_helper: %s %d", property, prop_type); */
129 /* TODO: Do we need to somehow refcount the server/indicator while we're waiting on this? */129 /* TODO: Do we need to somehow refcount the server/indicator while we're waiting on this? */
130 get_property_t * get_property_data = g_new(get_property_t, 1);130 get_property_t * get_property_data = g_new0(get_property_t, 1);
131 get_property_data->cb = callback;131 get_property_data->cb = callback;
132 get_property_data->data = data;132 get_property_data->data = data;
133 get_property_data->listener = listener;133 get_property_data->listener = listener;
134134
=== modified file 'libindicate/Makefile.am'
--- libindicate/Makefile.am 2009-08-03 22:31:00 +0000
+++ libindicate/Makefile.am 2009-09-04 17:44:23 +0000
@@ -27,11 +27,11 @@
27lib_LTLIBRARIES = \27lib_LTLIBRARIES = \
28 libindicate.la28 libindicate.la
2929
30libindicateincludedir=$(includedir)/libindicate-0.1/libindicate30libindicateincludedir=$(includedir)/libindicate-0.2/libindicate
3131
32indicate_headers = \32indicate_headers = \
33 indicator.h \33 indicator.h \
34 indicator-message.h \34 indicator-messages.h \
35 listener.h \35 listener.h \
36 server.h \36 server.h \
37 interests.h \37 interests.h \
@@ -55,7 +55,6 @@
55 listener-marshal.h \55 listener-marshal.h \
56 listener-private.h \56 listener-private.h \
57 indicator.c \57 indicator.c \
58 indicator-message.c \
59 interests-priv.h58 interests-priv.h
6059
61libindicate_la_LDFLAGS = \60libindicate_la_LDFLAGS = \
@@ -64,7 +63,8 @@
64 -export-symbols-regex "^[^_d].*"63 -export-symbols-regex "^[^_d].*"
6564
66libindicate_la_CFLAGS = \65libindicate_la_CFLAGS = \
67 $(LIBINDICATE_CFLAGS)66 $(LIBINDICATE_CFLAGS) \
67 -Wall -Werror
6868
69libindicate_la_LIBADD = \69libindicate_la_LIBADD = \
70 $(LIBINDICATE_LIBS)70 $(LIBINDICATE_LIBS)
@@ -148,40 +148,39 @@
148 && echo timestamp > $(@F)148 && echo timestamp > $(@F)
149149
150CLEANFILES = \150CLEANFILES = \
151 $(ENUM_FILE).c \151 $(BUILT_SOURCES) \
152 $(ENUM_FILE).h \
153 s-enum-types-c \152 s-enum-types-c \
154 s-enum-types-h153 s-enum-types-h
155154
156if USE_GIR155if USE_GIR
157156
158gobjectintrospection_gir_DATA = \157gobjectintrospection_gir_DATA = \
159 Indicate-0.1.gir158 Indicate-0.2.gir
160gobjectintrospection_girdir = $(datadir)/gir159gobjectintrospection_girdir = $(datadir)/gir
161160
162gobjectintrospection_type_DATA = \161gobjectintrospection_type_DATA = \
163 Indicate-0.1.typelib162 Indicate-0.2.typelib
164gobjectintrospection_typedir = $(libdir)/girepository163gobjectintrospection_typedir = $(libdir)/girepository
165164
166irscanner_headers = $(patsubst %,$(srcdir)/%,$(indicate_headers))165irscanner_headers = $(patsubst %,$(srcdir)/%,$(indicate_headers))
167Indicate-0.1.gir: $(irscanner_headers)166Indicate-0.2.gir: $(irscanner_headers) Makefile
168 $(G_IR_SCANNER) \167 $(G_IR_SCANNER) \
169 -v --namespace Indicate \168 -v --namespace Indicate \
170 --nsversion=0.1 \169 --nsversion=0.2 \
171 --add-include-path=$(srcdir) \170 --add-include-path=$(srcdir) \
172 --include=GObject-2.0 \171 --include=GObject-2.0 \
173 --include=GLib-2.0 \172 --include=GLib-2.0 \
174 --include=GdkPixbuf-2.0 \173 --include=GdkPixbuf-2.0 \
175 --library=indicate --pkg indicate \174 --library=indicate --pkg indicate \
176 --output Indicate-0.1.gir $(irscanner_headers)175 --output Indicate-0.2.gir $(irscanner_headers)
177176
178Indicate-0.1.typelib: Indicate-0.1.gir177Indicate-0.2.typelib: Indicate-0.2.gir
179 $(G_IR_COMPILER) \178 $(G_IR_COMPILER) \
180 --includedir=$(srcdir) Indicate-0.1.gir \179 --includedir=$(srcdir) Indicate-0.2.gir \
181 -o Indicate-0.1.typelib180 -o Indicate-0.2.typelib
182181
183DISTCLEANFILES = \182DISTCLEANFILES = \
184 Indicate-0.1.gir \183 Indicate-0.2.gir \
185 Indicate-0.1.typelib184 Indicate-0.2.typelib
186185
187endif186endif
188187
=== modified file 'libindicate/indicate-interface.xml'
--- libindicate/indicate-interface.xml 2009-04-02 15:49:35 +0000
+++ libindicate/indicate-interface.xml 2009-09-08 21:56:49 +0000
@@ -31,24 +31,17 @@
31 <interface name="org.freedesktop.indicator">31 <interface name="org.freedesktop.indicator">
3232
33<!-- Properties -->33<!-- Properties -->
34 <property name="desktop" type="s" access="read"/>34 <property name="desktop" type="s" access="read" />
35 <property name="type" type="s" access="read"/>35 <property name="type" type="s" access="read" />
36 <property name="count" type="u" access="read" />
3637
37<!-- Functions -->38<!-- Functions -->
38 <method name="GetIndicatorCount">39 <method name="GetIndicatorCount">
39 <arg type="u" name="indicator_count" direction="out" />40 <arg type="u" name="indicator_count" direction="out" />
40 </method>41 </method>
41 <method name="GetIndicatorCountByType">
42 <arg type="s" name="type" direction="in" />
43 <arg type="u" name="indicator_count" direction="out" />
44 </method>
45 <method name="GetIndicatorList">42 <method name="GetIndicatorList">
46 <arg type="ai" name="indicators" direction="out" />43 <arg type="ai" name="indicators" direction="out" />
47 </method>44 </method>
48 <method name="GetIndicatorListByType">
49 <arg type="s" name="type" direction="in" />
50 <arg type="ai" name="indicators" direction="out" />
51 </method>
52 <method name="GetIndicatorProperty">45 <method name="GetIndicatorProperty">
53 <arg type="u" name="id" direction="in" />46 <arg type="u" name="id" direction="in" />
54 <arg type="s" name="property" direction="in" />47 <arg type="s" name="property" direction="in" />
@@ -66,6 +59,11 @@
66 <method name="ShowIndicatorToUser">59 <method name="ShowIndicatorToUser">
67 <arg type="u" name="id" direction="in" />60 <arg type="u" name="id" direction="in" />
68 </method>61 </method>
62 <method name="IndicatorDisplayed">
63 <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
64 <arg type="u" name="id" direction="in" />
65 <arg type="b" name="displayed" direction="in" />
66 </method>
69 <method name="ShowInterest">67 <method name="ShowInterest">
70 <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />68 <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
71 <arg type="s" name="interest" direction="in" />69 <arg type="s" name="interest" direction="in" />
@@ -74,16 +72,18 @@
74 <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />72 <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
75 <arg type="s" name="interest" direction="in" />73 <arg type="s" name="interest" direction="in" />
76 </method>74 </method>
75 <method name="SetMaxIndicators">
76 <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
77 <arg type="i" name="max" direction="in" />
78 </method>
7779
7880
79<!-- Signals -->81<!-- Signals -->
80 <signal name="IndicatorAdded">82 <signal name="IndicatorNew">
81 <arg type="u" name="id" direction="out" />83 <arg type="u" name="id" direction="out" />
82 <arg type="s" name="type" direction="out" />
83 </signal>84 </signal>
84 <signal name="IndicatorRemoved">85 <signal name="IndicatorDelete">
85 <arg type="u" name="id" direction="out" />86 <arg type="u" name="id" direction="out" />
86 <arg type="s" name="type" direction="out" />
87 </signal>87 </signal>
88 <signal name="IndicatorModified">88 <signal name="IndicatorModified">
89 <arg type="u" name="id" direction="out" />89 <arg type="u" name="id" direction="out" />
@@ -95,6 +95,9 @@
95 <signal name="ServerHide">95 <signal name="ServerHide">
96 <arg type="s" name="type" direction="out" />96 <arg type="s" name="type" direction="out" />
97 </signal>97 </signal>
98 <signal name="ServerCountChanged">
99 <arg type="u" name="count" direction="out" />
100 </signal>
98101
99102
100<!-- End of interesting stuff -->103<!-- End of interesting stuff -->
101104
=== modified file 'libindicate/indicate.pc.in'
--- libindicate/indicate.pc.in 2009-08-04 11:25:24 +0000
+++ libindicate/indicate.pc.in 2009-09-03 22:32:17 +0000
@@ -4,7 +4,7 @@
4bindir=@bindir@4bindir=@bindir@
5includedir=@includedir@5includedir=@includedir@
66
7Cflags: -I${includedir}/libindicate-0.17Cflags: -I${includedir}/libindicate-0.2
8Requires: gobject-2.0 glib-2.0 dbus-glib-18Requires: gobject-2.0 glib-2.0 dbus-glib-1
9Libs: -L${libdir} -lindicate9Libs: -L${libdir} -lindicate
1010
1111
=== removed file 'libindicate/indicator-message.c'
--- libindicate/indicator-message.c 2009-04-30 21:57:51 +0000
+++ libindicate/indicator-message.c 1970-01-01 00:00:00 +0000
@@ -1,105 +0,0 @@
1/*
2A library to allow applictions to provide simple indications of
3information to be displayed to users of the application through the
4interface shell.
5
6Copyright 2009 Canonical Ltd.
7
8Authors:
9 Ted Gould <ted@canonical.com>
10
11This program is free software: you can redistribute it and/or modify it
12under the terms of either or both of the following licenses:
13
141) the GNU Lesser General Public License version 3, as published by the
15Free Software Foundation; and/or
162) the GNU Lesser General Public License version 2.1, as published by
17the Free Software Foundation.
18
19This program is distributed in the hope that it will be useful, but
20WITHOUT ANY WARRANTY; without even the implied warranties of
21MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
22PURPOSE. See the applicable version of the GNU Lesser General Public
23License for more details.
24
25You should have received a copy of both the GNU Lesser General Public
26License version 3 and version 2.1 along with this program. If not, see
27<http://www.gnu.org/licenses/>
28*/
29
30#ifdef HAVE_CONFIG_H
31#include "config.h"
32#endif
33
34#include "indicator-message.h"
35
36typedef struct _IndicateIndicatorMessagePrivate IndicateIndicatorMessagePrivate;
37
38struct _IndicateIndicatorMessagePrivate
39{
40 gchar * subtype;
41};
42
43#define INDICATE_INDICATOR_MESSAGE_GET_PRIVATE(o) \
44(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATE_INDICATOR_MESSAGE_TYPE, IndicateIndicatorMessagePrivate))
45
46static void indicate_indicator_message_class_init (IndicateIndicatorMessageClass *klass);
47static void indicate_indicator_message_init (IndicateIndicatorMessage *self);
48static void indicate_indicator_message_dispose (GObject *object);
49static void indicate_indicator_message_finalize (GObject *object);
50static const gchar * get_indicator_type (IndicateIndicator * indicator);
51
52G_DEFINE_TYPE (IndicateIndicatorMessage, indicate_indicator_message, INDICATE_TYPE_INDICATOR);
53
54static void
55indicate_indicator_message_class_init (IndicateIndicatorMessageClass *klass)
56{
57 GObjectClass *object_class = G_OBJECT_CLASS (klass);
58
59 g_type_class_add_private (klass, sizeof (IndicateIndicatorMessagePrivate));
60
61 object_class->dispose = indicate_indicator_message_dispose;
62 object_class->finalize = indicate_indicator_message_finalize;
63
64 IndicateIndicatorClass * indicator_class = INDICATE_INDICATOR_CLASS(klass);
65
66 indicator_class->get_type = get_indicator_type;
67
68 return;
69}
70
71static void
72indicate_indicator_message_init (IndicateIndicatorMessage *self)
73{
74}
75
76static void
77indicate_indicator_message_dispose (GObject *object)
78{
79G_OBJECT_CLASS (indicate_indicator_message_parent_class)->dispose (object);
80}
81
82static void
83indicate_indicator_message_finalize (GObject *object)
84{
85G_OBJECT_CLASS (indicate_indicator_message_parent_class)->finalize (object);
86}
87
88/**
89 indicate_indicator_message_new:
90
91 Builds a new indicator message object using #g_object_new.
92
93 Return value: A pointer to a new #IndicateIndicatorMessage object.
94*/
95static const gchar *
96get_indicator_type (IndicateIndicator * indicator)
97{
98 return "message";
99}
100
101IndicateIndicatorMessage *
102indicate_indicator_message_new (void)
103{
104 return g_object_new(INDICATE_TYPE_INDICATOR_MESSAGE, NULL);
105}
1060
=== removed file 'libindicate/indicator-message.h'
--- libindicate/indicator-message.h 2009-05-01 02:45:19 +0000
+++ libindicate/indicator-message.h 1970-01-01 00:00:00 +0000
@@ -1,92 +0,0 @@
1/*
2A library to allow applictions to provide simple indications of
3information to be displayed to users of the application through the
4interface shell.
5
6Copyright 2009 Canonical Ltd.
7
8Authors:
9 Ted Gould <ted@canonical.com>
10
11This program is free software: you can redistribute it and/or modify it
12under the terms of either or both of the following licenses:
13
141) the GNU Lesser General Public License version 3, as published by the
15Free Software Foundation; and/or
162) the GNU Lesser General Public License version 2.1, as published by
17the Free Software Foundation.
18
19This program is distributed in the hope that it will be useful, but
20WITHOUT ANY WARRANTY; without even the implied warranties of
21MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
22PURPOSE. See the applicable version of the GNU Lesser General Public
23License for more details.
24
25You should have received a copy of both the GNU Lesser General Public
26License version 3 and version 2.1 along with this program. If not, see
27<http://www.gnu.org/licenses/>
28*/
29
30#ifndef __INDICATE_INDICATOR_MESSAGE_H__
31#define __INDICATE_INDICATOR_MESSAGE_H__
32
33#include <glib.h>
34#include <glib-object.h>
35
36#include "indicator.h"
37
38G_BEGIN_DECLS
39
40#define INDICATE_TYPE_INDICATOR_MESSAGE (indicate_indicator_message_get_type ())
41#define INDICATE_INDICATOR_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATE_TYPE_INDICATOR_MESSAGE, IndicateIndicatorMessage))
42#define INDICATE_INDICATOR_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATE_TYPE_INDICATOR_MESSAGE, IndicateIndicatorMessageClass))
43#define INDICATE_IS_INDICATOR_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATE_TYPE_INDICATOR_MESSAGE))
44#define INDICATE_IS_INDICATOR_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATE_TYPE_INDICATOR_MESSAGE))
45#define INDICATE_INDICATOR_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATE_TYPE_INDICATOR_MESSAGE, IndicateIndicatorMessageClass))
46
47typedef struct _IndicateIndicatorMessage IndicateIndicatorMessage;
48typedef struct _IndicateIndicatorMessageClass IndicateIndicatorMessageClass;
49
50/**
51 IndicateIndicatorMessageClass:
52 @parent_class: Parent Class
53
54 Subclass of #IndicateIndicator with no new functions or signals.
55*/
56struct _IndicateIndicatorMessageClass {
57 IndicateIndicatorClass parent_class;
58};
59
60/**
61 IndicateIndicatorMessage:
62
63 A class to represent indicators who's 'type' is "message". These
64 are basically indicators that represent messages from humans to
65 humans via computers. Things like instance messages, micro blogging
66 entries or e-mails. All of these qualify as messages.
67
68 TODO: This should include a list of properties that are supported.
69*/
70struct _IndicateIndicatorMessage {
71 IndicateIndicator parent;
72};
73
74GType indicate_indicator_message_get_type (void);
75IndicateIndicatorMessage * indicate_indicator_message_new (void);
76
77/**
78 SECTION:indicator-message
79 @short_description: A representation of human generated messages
80 @stability: Unstable
81 @include: libindicate/indicator-message.h
82
83 The message indicators represent messages that come from humans
84 to humans using computers. They come in all different forms with
85 various different interaction protocols, but they all want the human
86 at the computer to interact back with the human that sent the
87 message.
88*/
89
90G_END_DECLS
91
92#endif
930
=== added file 'libindicate/indicator-messages.h'
--- libindicate/indicator-messages.h 1970-01-01 00:00:00 +0000
+++ libindicate/indicator-messages.h 2009-09-04 17:44:23 +0000
@@ -0,0 +1,40 @@
1/*
2A library to allow applictions to provide simple indications of
3information to be displayed to users of the application through the
4interface shell.
5
6Copyright 2009 Canonical Ltd.
7
8Authors:
9 Ted Gould <ted@canonical.com>
10
11This program is free software: you can redistribute it and/or modify it
12under the terms of either or both of the following licenses:
13
141) the GNU Lesser General Public License version 3, as published by the
15Free Software Foundation; and/or
162) the GNU Lesser General Public License version 2.1, as published by
17the Free Software Foundation.
18
19This program is distributed in the hope that it will be useful, but
20WITHOUT ANY WARRANTY; without even the implied warranties of
21MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
22PURPOSE. See the applicable version of the GNU Lesser General Public
23License for more details.
24
25You should have received a copy of both the GNU Lesser General Public
26License version 3 and version 2.1 along with this program. If not, see
27<http://www.gnu.org/licenses/>
28*/
29
30#ifndef INDICATE_INDICATOR_MESSAGES_H_INCLUDED__
31#define INDICATE_INDICATOR_MESSAGES_H_INCLUDED__ 1
32
33#define INDICATE_INDICATOR_MESSAGES_PROP_NAME "name"
34#define INDICATE_INDICATOR_MESSAGES_PROP_ICON "icon"
35#define INDICATE_INDICATOR_MESSAGES_PROP_COUNT "count"
36#define INDICATE_INDICATOR_MESSAGES_PROP_TIME "time"
37#define INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION "draw-attention"
38
39
40#endif /* INDICATE_INDICATOR_MESSAGES_H_INCLUDED__ */
041
=== modified file 'libindicate/indicator.c'
--- libindicate/indicator.c 2009-08-06 13:57:57 +0000
+++ libindicate/indicator.c 2009-09-01 17:05:33 +0000
@@ -38,6 +38,7 @@
38 SHOW,38 SHOW,
39 USER_DISPLAY,39 USER_DISPLAY,
40 MODIFIED,40 MODIFIED,
41 DISPLAYED,
41 LAST_SIGNAL42 LAST_SIGNAL
42};43};
4344
@@ -50,6 +51,7 @@
50 gboolean is_visible;51 gboolean is_visible;
51 IndicateServer * server;52 IndicateServer * server;
52 GHashTable * properties;53 GHashTable * properties;
54 gboolean is_displayed;
53};55};
5456
55#define INDICATE_INDICATOR_GET_PRIVATE(o) \57#define INDICATE_INDICATOR_GET_PRIVATE(o) \
@@ -140,8 +142,23 @@
140 NULL, NULL,142 NULL, NULL,
141 g_cclosure_marshal_VOID__STRING,143 g_cclosure_marshal_VOID__STRING,
142 G_TYPE_NONE, 1, G_TYPE_STRING);144 G_TYPE_NONE, 1, G_TYPE_STRING);
143145 /**
144 class->get_type = NULL;146 IndicateIndicator::displayed:
147 @arg0: The #IndicateIndicator object
148 @arg1: Whether the indicator has been displayed
149
150 This is the signal that the indicator has been displayed, or
151 hidden by a listener. In most cases, the signal will be that it
152 has been displayed as most folks don't go hiding it later.
153 */
154 signals[DISPLAYED] = g_signal_new(INDICATE_INDICATOR_SIGNAL_DISPLAYED,
155 G_TYPE_FROM_CLASS(class),
156 G_SIGNAL_RUN_LAST,
157 G_STRUCT_OFFSET(IndicateIndicatorClass, displayed),
158 NULL, NULL,
159 g_cclosure_marshal_VOID__BOOLEAN,
160 G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
161
145 class->set_property = set_property;162 class->set_property = set_property;
146 class->get_property = get_property;163 class->get_property = get_property;
147 class->list_properties = list_properties;164 class->list_properties = list_properties;
@@ -156,6 +173,7 @@
156 IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);173 IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
157174
158 priv->is_visible = FALSE;175 priv->is_visible = FALSE;
176 priv->is_displayed = FALSE;
159177
160 priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);178 priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
161179
@@ -301,6 +319,8 @@
301319
302 priv->is_visible = FALSE;320 priv->is_visible = FALSE;
303 g_signal_emit(indicator, signals[HIDE], 0, TRUE);321 g_signal_emit(indicator, signals[HIDE], 0, TRUE);
322 priv->is_displayed = FALSE;
323 g_signal_emit(G_OBJECT(indicator), signals[DISPLAYED], 0, priv->is_displayed, TRUE);
304324
305 return;325 return;
306}326}
@@ -339,28 +359,6 @@
339}359}
340360
341/**361/**
342 indicate_indicator_get_indicator_type:
343 @indicator: a #IndicateIndicator to act on
344
345 Returns the type of @indicator. This is largely set by the subclass
346 that the indicator was built with and should not be free'd.
347
348 Return value: A string defining the type or NULL for no type.
349*/
350const gchar *
351indicate_indicator_get_indicator_type (IndicateIndicator * indicator)
352{
353 g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), NULL);
354 IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator);
355
356 if (class->get_type != NULL) {
357 return INDICATE_INDICATOR_GET_CLASS(indicator)->get_type(indicator);
358 }
359
360 return NULL;
361}
362
363/**
364 indicate_indicator_user_display:362 indicate_indicator_user_display:
365 @indicator: a #IndicateIndicator to act on363 @indicator: a #IndicateIndicator to act on
366364
@@ -451,8 +449,7 @@
451 @indicator: a #IndicateIndicator to act on449 @indicator: a #IndicateIndicator to act on
452450
453 This function gets a list of all the properties that exist451 This function gets a list of all the properties that exist
454 on a @indicator. The array may have zero entries but almost452 on a @indicator. The array may have zero entries.
455 always at least has 'type' in it.
456453
457 Return value: An array of strings that is the keys of all454 Return value: An array of strings that is the keys of all
458 the properties on this indicator.455 the properties on this indicator.
@@ -473,11 +470,6 @@
473{470{
474 g_return_if_fail(INDICATE_IS_INDICATOR(indicator));471 g_return_if_fail(INDICATE_IS_INDICATOR(indicator));
475472
476 if (key != NULL && !g_strcmp0(key, "type")) {
477 g_warning("Trying to set the 'type' of an indicator which should be done through subclassing.");
478 return;
479 }
480
481 IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);473 IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
482474
483 gchar * current = g_hash_table_lookup(priv->properties, key);475 gchar * current = g_hash_table_lookup(priv->properties, key);
@@ -500,10 +492,6 @@
500{492{
501 g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), NULL);493 g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), NULL);
502494
503 if (key != NULL && !g_strcmp0(key, "type")) {
504 return indicate_indicator_get_indicator_type(indicator);
505 }
506
507 IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);495 IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
508496
509 // TODO: Think about whether we should be strdup'ing this. Seems like overkill, but might not be.497 // TODO: Think about whether we should be strdup'ing this. Seems like overkill, but might not be.
@@ -519,10 +507,50 @@
519 GList * keys = g_hash_table_get_keys(priv->properties);507 GList * keys = g_hash_table_get_keys(priv->properties);
520 GPtrArray * properties = g_ptr_array_sized_new(g_list_length(keys) + 1);508 GPtrArray * properties = g_ptr_array_sized_new(g_list_length(keys) + 1);
521509
522 g_ptr_array_add(properties, g_strdup("type"));
523 for (; keys != NULL; keys = keys->next) {510 for (; keys != NULL; keys = keys->next) {
524 g_ptr_array_add(properties, g_strdup(keys->data));511 g_ptr_array_add(properties, g_strdup(keys->data));
525 }512 }
526513
527 return properties;514 return properties;
528}515}
516
517/**
518 indicate_indicator_set_displayed:
519 @indicator: The #IndicateIndicator to configure
520 @displayed: Whether or not the indicator is visible to users
521
522 Sets whether or not the indicator is visible to the user from
523 a listener. This does not include things like whether the menu
524 is open, but more whether it's in the menu to be found.
525*/
526void
527indicate_indicator_set_displayed (IndicateIndicator * indicator, gboolean displayed)
528{
529 g_return_if_fail(INDICATE_IS_INDICATOR(indicator));
530 IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
531
532 if (priv->is_displayed != displayed) {
533 priv->is_displayed = displayed;
534 g_signal_emit(G_OBJECT(indicator), signals[DISPLAYED], 0, displayed, TRUE);
535 }
536
537 return;
538}
539
540/**
541 indicate_indicator_get_displayed:
542 @indicator: The #IndicateIndicator to query
543
544 Checks to see if the indicator is visible to users in some way.
545
546 Return value: Whether or not this indicator can be seen by a user
547 or not.
548*/
549gboolean
550indicate_indicator_get_displayed (IndicateIndicator * indicator)
551{
552 g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), FALSE);
553 IndicateIndicatorPrivate * priv = INDICATE_INDICATOR_GET_PRIVATE(indicator);
554 return priv->is_visible && priv->is_displayed;
555}
556
529557
=== modified file 'libindicate/indicator.h'
--- libindicate/indicator.h 2009-08-05 13:51:59 +0000
+++ libindicate/indicator.h 2009-08-31 21:26:29 +0000
@@ -46,10 +46,11 @@
46/* This is a signal that signals to the indicator that the user46/* This is a signal that signals to the indicator that the user
47 * has done an action where they'd like this indicator to be47 * has done an action where they'd like this indicator to be
48 * displayed. */48 * displayed. */
49#define INDICATE_INDICATOR_SIGNAL_HIDE "hide"49#define INDICATE_INDICATOR_SIGNAL_HIDE "hide"
50#define INDICATE_INDICATOR_SIGNAL_SHOW "show"50#define INDICATE_INDICATOR_SIGNAL_SHOW "show"
51#define INDICATE_INDICATOR_SIGNAL_DISPLAY "user-display"51#define INDICATE_INDICATOR_SIGNAL_DISPLAY "user-display"
52#define INDICATE_INDICATOR_SIGNAL_MODIFIED "modified"52#define INDICATE_INDICATOR_SIGNAL_MODIFIED "modified"
53#define INDICATE_INDICATOR_SIGNAL_DISPLAYED "displayed"
5354
54typedef struct _IndicateIndicator IndicateIndicator;55typedef struct _IndicateIndicator IndicateIndicator;
55typedef struct _IndicateIndicatorClass IndicateIndicatorClass;56typedef struct _IndicateIndicatorClass IndicateIndicatorClass;
@@ -75,9 +76,7 @@
75 @show: Slot for #IndicateIndicator::show.76 @show: Slot for #IndicateIndicator::show.
76 @user_display: Slot for #IndicateIndicator::user-display.77 @user_display: Slot for #IndicateIndicator::user-display.
77 @modified: Slot for #IndicateIndicator::modified.78 @modified: Slot for #IndicateIndicator::modified.
78 @get_type: Returns a constant string for the type of this indicator.79 @displayed: Slot for #IndicateIndicator::displayed.
79 Typically gets overridden by subclasses and defines the type of
80 the indicator. Is called by indicate_indicator_get_indicator_type().
81 @set_property: Called when indicate_indicator_set_property() is called80 @set_property: Called when indicate_indicator_set_property() is called
82 and should set the value. While typically it is overridden by81 and should set the value. While typically it is overridden by
83 subclasses they usually handle special properties themselves and82 subclasses they usually handle special properties themselves and
@@ -87,6 +86,10 @@
87 @list_properties: Called when indicate_indicator_list_properties() is called86 @list_properties: Called when indicate_indicator_list_properties() is called
88 and returns a list of the properties available. Again this can be87 and returns a list of the properties available. Again this can be
89 overridden by subclasses to handle special properties.88 overridden by subclasses to handle special properties.
89 @indicate_indicator_reserved1: Reserved for future use
90 @indicate_indicator_reserved2: Reserved for future use
91 @indicate_indicator_reserved3: Reserved for future use
92 @indicate_indicator_reserved4: Reserved for future use
9093
91 All of the functions that are used to modify or change data that is94 All of the functions that are used to modify or change data that is
92 in the indicator. Typically gets subclassed by other types of 95 in the indicator. Typically gets subclassed by other types of
@@ -94,17 +97,26 @@
9497
95*/98*/
96struct _IndicateIndicatorClass {99struct _IndicateIndicatorClass {
100 /* Parents */
97 GObjectClass parent_class;101 GObjectClass parent_class;
98102
103 /* Signals */
99 void (*hide) (IndicateIndicator * indicator, gpointer data);104 void (*hide) (IndicateIndicator * indicator, gpointer data);
100 void (*show) (IndicateIndicator * indicator, gpointer data);105 void (*show) (IndicateIndicator * indicator, gpointer data);
101 void (*user_display) (IndicateIndicator * indicator, gpointer data);106 void (*user_display) (IndicateIndicator * indicator, gpointer data);
102 void (*modified) (IndicateIndicator * indicator, gchar * property, gpointer data);107 void (*modified) (IndicateIndicator * indicator, gchar * property, gpointer data);
108 void (*displayed) (IndicateIndicator * indicator, gboolean displayed);
103109
104 const gchar * (*get_type) (IndicateIndicator * indicator);110 /* Subclassable functions */
105 void (*set_property) (IndicateIndicator * indicator, const gchar * key, const gchar * data);111 void (*set_property) (IndicateIndicator * indicator, const gchar * key, const gchar * data);
106 const gchar * (*get_property) (IndicateIndicator * indicator, const gchar * key);112 const gchar * (*get_property) (IndicateIndicator * indicator, const gchar * key);
107 GPtrArray * (*list_properties) (IndicateIndicator * indicator);113 GPtrArray * (*list_properties) (IndicateIndicator * indicator);
114
115 /* Reserver for future use */
116 void (*indicate_indicator_reserved1)(void);
117 void (*indicate_indicator_reserved2)(void);
118 void (*indicate_indicator_reserved3)(void);
119 void (*indicate_indicator_reserved4)(void);
108};120};
109121
110GType indicate_indicator_get_type(void) G_GNUC_CONST;122GType indicate_indicator_get_type(void) G_GNUC_CONST;
@@ -125,10 +137,6 @@
125/* Every entry has an ID, here's how to get it */137/* Every entry has an ID, here's how to get it */
126guint indicate_indicator_get_id (IndicateIndicator * indicator);138guint indicate_indicator_get_id (IndicateIndicator * indicator);
127139
128/* Every entry has a type. This should be created by the
129 * subclass and exported through this pretty function */
130const gchar * indicate_indicator_get_indicator_type (IndicateIndicator * indicator);
131
132void indicate_indicator_user_display (IndicateIndicator * indicator);140void indicate_indicator_user_display (IndicateIndicator * indicator);
133141
134/* Properties handling */142/* Properties handling */
@@ -137,6 +145,10 @@
137const gchar * indicate_indicator_get_property (IndicateIndicator * indicator, const gchar * key);145const gchar * indicate_indicator_get_property (IndicateIndicator * indicator, const gchar * key);
138GPtrArray * indicate_indicator_list_properties (IndicateIndicator * indicator);146GPtrArray * indicate_indicator_list_properties (IndicateIndicator * indicator);
139147
148/* Controling whether it's displayed */
149void indicate_indicator_set_displayed (IndicateIndicator * indicator, gboolean displayed);
150gboolean indicate_indicator_get_displayed (IndicateIndicator * indicator);
151
140/**152/**
141 SECTION:indicator153 SECTION:indicator
142 @short_description: A representation of state for applications154 @short_description: A representation of state for applications
@@ -144,7 +156,7 @@
144 @include: libindicate/indicator.h156 @include: libindicate/indicator.h
145157
146 An indicator is designed to represent a single instance of something158 An indicator is designed to represent a single instance of something
147 in your application. So this might be an IM or Email using #IndicateIndicatorMessage159 in your application. So this might be an IM or an e-mail mail box
148 or any other thing that is a small unit of information to pass on160 or any other thing that is a small unit of information to pass on
149 to the user.161 to the user.
150162
@@ -154,12 +166,7 @@
154 on the indicator to provide enough information for the listener166 on the indicator to provide enough information for the listener
155 to do that.167 to do that.
156168
157 Mostly this is done through properties. The only property that is169 Mostly this is done through properties.
158 defined for the base indicator is the 'type' property. And this
159 is only available to set by creating a subclass of the
160 #IndicateIndicator object. It is assumed that you can look at the
161 definitions of the various subtypes to determine which properties
162 they support.
163170
164 It may be that some users don't want to create objects for every171 It may be that some users don't want to create objects for every
165 indicator as it could be a lot of overhead if there are large numbers172 indicator as it could be a lot of overhead if there are large numbers
166173
=== modified file 'libindicate/listener-marshal.list'
--- libindicate/listener-marshal.list 2009-04-10 09:51:16 +0000
+++ libindicate/listener-marshal.list 2009-09-05 04:24:47 +0000
@@ -28,8 +28,10 @@
28# IndicatorAdded, IndicatorRemoved, IndicatorModified28# IndicatorAdded, IndicatorRemoved, IndicatorModified
29VOID:UINT,STRING29VOID:UINT,STRING
30# Local indicator_added, indicator_removed30# Local indicator_added, indicator_removed
31VOID:POINTER,POINTER
32# Local indicator_modified
31VOID:POINTER,POINTER,STRING33VOID:POINTER,POINTER,STRING
32# Local indicator_modified
33VOID:POINTER,POINTER,STRING,STRING
34# Local server_added and server_removed34# Local server_added and server_removed
35VOID:POINTER,STRING35VOID:POINTER,STRING
36# Local server_count_changed
37VOID:POINTER,UINT
3638
=== modified file 'libindicate/listener-private.h'
--- libindicate/listener-private.h 2009-08-03 22:31:00 +0000
+++ libindicate/listener-private.h 2009-08-28 21:59:26 +0000
@@ -35,6 +35,7 @@
35 DBusGProxy * proxy;35 DBusGProxy * proxy;
36 DBusGConnection * connection;36 DBusGConnection * connection;
37 gboolean interests[INDICATE_INTEREST_LAST];37 gboolean interests[INDICATE_INTEREST_LAST];
38 gint max_indicators;
38};39};
3940
40struct _IndicateListenerIndicator {41struct _IndicateListenerIndicator {
@@ -55,6 +56,8 @@
5556
56 GArray * proxy_todo;57 GArray * proxy_todo;
57 guint todo_idle;58 guint todo_idle;
59
60 gint max_indicators;
58};61};
5962
60#define INDICATE_LISTENER_GET_PRIVATE(o) \63#define INDICATE_LISTENER_GET_PRIVATE(o) \
6164
=== modified file 'libindicate/listener.c'
--- libindicate/listener.c 2009-08-03 22:31:00 +0000
+++ libindicate/listener.c 2009-09-08 22:01:57 +0000
@@ -49,6 +49,7 @@
49 INDICATOR_MODIFIED,49 INDICATOR_MODIFIED,
50 SERVER_ADDED,50 SERVER_ADDED,
51 SERVER_REMOVED,51 SERVER_REMOVED,
52 SERVER_COUNT_CHANGED,
52 LAST_SIGNAL53 LAST_SIGNAL
53};54};
5455
@@ -98,13 +99,14 @@
98static void todo_list_add (const gchar * name, DBusGProxy * proxy, IndicateListener * listener, gboolean startup);99static void todo_list_add (const gchar * name, DBusGProxy * proxy, IndicateListener * listener, gboolean startup);
99static gboolean todo_idle (gpointer data);100static gboolean todo_idle (gpointer data);
100static void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data);101static void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data);
102static void proxy_indicator_added_legacy (DBusGProxy * proxy, guint id, gchar * type, proxy_t * proxyt);
101static void proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt);103static void proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt);
102static void proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt);104static void proxy_indicator_added (DBusGProxy * proxy, guint id, proxy_t * proxyt);
103static void proxy_indicator_removed (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt);105static void proxy_indicator_removed_legacy (DBusGProxy * proxy, guint id, gchar * type, proxy_t * proxyt);
104static void proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt);106static void proxy_indicator_removed (DBusGProxy * proxy, guint id, proxy_t * proxyt);
107static void proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, proxy_t * proxyt);
108static void proxy_server_count_changed (DBusGProxy * proxy, guint count, proxy_t * proxyt);
105static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data);109static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data);
106static void proxy_get_indicator_type (DBusGProxy * proxy, gchar * type, GError * error, gpointer data);
107static void proxy_indicators_free (gpointer data);
108static void introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer data);110static void introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer data);
109111
110/* DBus interface */112/* DBus interface */
@@ -130,22 +132,22 @@
130 G_SIGNAL_RUN_LAST,132 G_SIGNAL_RUN_LAST,
131 G_STRUCT_OFFSET (IndicateListenerClass, indicator_added),133 G_STRUCT_OFFSET (IndicateListenerClass, indicator_added),
132 NULL, NULL,134 NULL, NULL,
133 _indicate_listener_marshal_VOID__POINTER_POINTER_STRING,135 _indicate_listener_marshal_VOID__POINTER_POINTER,
134 G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, G_TYPE_STRING);136 G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR);
135 signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED,137 signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED,
136 G_TYPE_FROM_CLASS (class),138 G_TYPE_FROM_CLASS (class),
137 G_SIGNAL_RUN_LAST,139 G_SIGNAL_RUN_LAST,
138 G_STRUCT_OFFSET (IndicateListenerClass, indicator_removed),140 G_STRUCT_OFFSET (IndicateListenerClass, indicator_removed),
139 NULL, NULL,141 NULL, NULL,
140 _indicate_listener_marshal_VOID__POINTER_POINTER_STRING,142 _indicate_listener_marshal_VOID__POINTER_POINTER,
141 G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, G_TYPE_STRING);143 G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR);
142 signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED,144 signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED,
143 G_TYPE_FROM_CLASS (class),145 G_TYPE_FROM_CLASS (class),
144 G_SIGNAL_RUN_LAST,146 G_SIGNAL_RUN_LAST,
145 G_STRUCT_OFFSET (IndicateListenerClass, indicator_modified),147 G_STRUCT_OFFSET (IndicateListenerClass, indicator_modified),
146 NULL, NULL,148 NULL, NULL,
147 _indicate_listener_marshal_VOID__POINTER_POINTER_STRING_STRING,149 _indicate_listener_marshal_VOID__POINTER_POINTER_STRING,
148 G_TYPE_NONE, 4, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, G_TYPE_STRING, G_TYPE_STRING);150 G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, G_TYPE_STRING);
149 signals[SERVER_ADDED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_ADDED,151 signals[SERVER_ADDED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_ADDED,
150 G_TYPE_FROM_CLASS (class),152 G_TYPE_FROM_CLASS (class),
151 G_SIGNAL_RUN_LAST,153 G_SIGNAL_RUN_LAST,
@@ -160,6 +162,13 @@
160 NULL, NULL,162 NULL, NULL,
161 _indicate_listener_marshal_VOID__POINTER_STRING,163 _indicate_listener_marshal_VOID__POINTER_STRING,
162 G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_STRING);164 G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_STRING);
165 signals[SERVER_COUNT_CHANGED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_COUNT_CHANGED,
166 G_TYPE_FROM_CLASS (class),
167 G_SIGNAL_RUN_LAST,
168 G_STRUCT_OFFSET (IndicateListenerClass, server_count_changed),
169 NULL, NULL,
170 _indicate_listener_marshal_VOID__POINTER_UINT,
171 G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_UINT);
163172
164 dbus_g_object_register_marshaller(_indicate_listener_marshal_VOID__UINT_STRING,173 dbus_g_object_register_marshaller(_indicate_listener_marshal_VOID__UINT_STRING,
165 G_TYPE_NONE,174 G_TYPE_NONE,
@@ -235,6 +244,8 @@
235 priv->proxy_todo = g_array_new(FALSE, TRUE, sizeof(proxy_todo_t));244 priv->proxy_todo = g_array_new(FALSE, TRUE, sizeof(proxy_todo_t));
236 priv->todo_idle = 0;245 priv->todo_idle = 0;
237246
247 priv->max_indicators = -1;
248
238 /* WARNING */249 /* WARNING */
239 /* Starting massive asynchronisity */250 /* Starting massive asynchronisity */
240 /* */251 /* */
@@ -290,11 +301,15 @@
290 return default_indicate_listener;301 return default_indicate_listener;
291}302}
292303
304/* Function to track when people get on and off the bus. It's the
305 same function for both system and session buses so it needs to
306 figure which one it's on. */
293static void307static void
294dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateListener * listener)308dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateListener * listener)
295{309{
296 IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);310 IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
297311
312 /* Figure out which bus we are. */
298 DBusGConnection * bus;313 DBusGConnection * bus;
299 gchar * bus_name;314 gchar * bus_name;
300 if (proxy == priv->dbus_proxy_system) {315 if (proxy == priv->dbus_proxy_system) {
@@ -307,9 +322,15 @@
307322
308 /* g_debug("Name change on %s bus: '%s' from '%s' to '%s'", bus_name, name, prev, new); */323 /* g_debug("Name change on %s bus: '%s' from '%s' to '%s'", bus_name, name, prev, new); */
309324
325 /* If someone is getting on the bus we add them to the
326 todo list to see if they come up with something interesting */
310 if (prev != NULL && prev[0] == '\0') {327 if (prev != NULL && prev[0] == '\0') {
311 todo_list_add(name, proxy, listener, FALSE);328 todo_list_add(name, proxy, listener, FALSE);
312 }329 }
330
331 /* If they're leaving the bus we need to figure out if we
332 were tracking them or not, and remove them from the
333 appropriate lists. */
313 if (new != NULL && new[0] == '\0') {334 if (new != NULL && new[0] == '\0') {
314 proxy_t searchitem;335 proxy_t searchitem;
315 searchitem.connection = bus;336 searchitem.connection = bus;
@@ -334,19 +355,11 @@
334static void355static void
335proxy_struct_destroy_indicators (gpointer key, gpointer value, gpointer data)356proxy_struct_destroy_indicators (gpointer key, gpointer value, gpointer data)
336{357{
337 gchar * type = (gchar *)key;358 proxy_t * proxy_data = (proxy_t *)data;
338 GHashTable * indicators = (GHashTable *)value;
339 proxy_t * proxy_data = data;
340359
341 GList * keys = g_hash_table_get_keys(indicators);360 if (value) {
342 GList * indicator;361 g_signal_emit(proxy_data->listener, signals[INDICATOR_REMOVED], 0, &proxy_data->server, GUINT_TO_POINTER(key), TRUE);
343 for (indicator = keys; indicator != NULL; indicator = indicator->next) {
344 guint id = (guint)indicator->data;
345 g_signal_emit(proxy_data->listener, signals[INDICATOR_REMOVED], 0, &proxy_data->server, GUINT_TO_POINTER(id), type, TRUE);
346 }362 }
347 g_list_free(keys);
348
349 g_hash_table_remove_all(indicators);
350 return;363 return;
351}364}
352365
@@ -360,7 +373,7 @@
360 g_hash_table_foreach(proxy_data->indicators,373 g_hash_table_foreach(proxy_data->indicators,
361 proxy_struct_destroy_indicators,374 proxy_struct_destroy_indicators,
362 proxy_data);375 proxy_data);
363 g_hash_table_remove_all(proxy_data->indicators);376 g_hash_table_destroy(proxy_data->indicators);
364377
365 g_signal_emit(proxy_data->listener, signals[SERVER_REMOVED], 0, &proxy_data->server, proxy_data->type, TRUE);378 g_signal_emit(proxy_data->listener, signals[SERVER_REMOVED], 0, &proxy_data->server, proxy_data->type, TRUE);
366 proxy_data->indicators = NULL;379 proxy_data->indicators = NULL;
@@ -470,6 +483,7 @@
470 proxyt->server.name = todo->name;483 proxyt->server.name = todo->name;
471 proxyt->server.proxy = proxyt->proxy;484 proxyt->server.proxy = proxyt->proxy;
472 proxyt->server.connection = proxyt->connection;485 proxyt->server.connection = proxyt->connection;
486 proxyt->server.max_indicators = priv->max_indicators;
473487
474 priv->proxy_todo = g_array_remove_index(priv->proxy_todo, priv->proxy_todo->len - 1);488 priv->proxy_todo = g_array_remove_index(priv->proxy_todo, priv->proxy_todo->len - 1);
475489
@@ -509,11 +523,21 @@
509 return;523 return;
510}524}
511525
512typedef struct {526/* A call back from setting the max indicators. We really can't
513 guint id;527 do anything about it, so this function is kinda useless. */
514 proxy_t * proxyt;528void
515} indicator_type_t;529set_max_indicators_cb (DBusGProxy * proxy, GError * error, gpointer userdata)
530{
531 if (error != NULL) {
532 g_warning("Unable to set the max indicators on '%s': %s", (gchar *)userdata, error->message);
533 g_error_free(error);
534 }
535 return;
536}
516537
538/* Callback from the call to get the indicator list on new
539 servers that we've found through introspection. It takes
540 the list and then calls indicator_added on each one. */
517static void541static void
518proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data)542proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data)
519{543{
@@ -525,42 +549,31 @@
525549
526 int i;550 int i;
527 for (i = 0; i < indicators->len; i++) {551 for (i = 0; i < indicators->len; i++) {
528 indicator_type_t * itt = g_new(indicator_type_t, 1);552 guint id = g_array_index(indicators, guint, i);
529 itt->id = g_array_index(indicators, guint, i);553 proxy_indicator_added(proxy, id, proxyt);
530 itt->proxyt = proxyt;
531
532 org_freedesktop_indicator_get_indicator_property_async(proxyt->proxy, itt->id, "type", proxy_get_indicator_type, itt);
533 }554 }
534555
535 return;556 return;
536}557}
537558
538static void559/* Function called on the ServerShow signal from the bus, which is
539proxy_get_indicator_type (DBusGProxy * proxy, gchar * type, GError * error, gpointer data)560 usually when a DBus client says that they have some indicators
540{561 that we could be interested in. Also, this function is called
541 if (error != NULL) {562 in the discovery phase of starting up a new listener if we find
542 g_warning("Get Indicator Type returned error: %s", error->message);563 some indicators on the client. */
543 return;
544 }
545
546 indicator_type_t * itt = (indicator_type_t *)data;
547 guint id = itt->id;
548 proxy_t * proxyt = itt->proxyt;
549
550 g_free(itt);
551
552 return proxy_indicator_added(proxy, id, type, proxyt);
553}
554
555static void564static void
556proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt)565proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt)
557{566{
567 g_debug("Proxy Server Added");
568 /* Check to see if we have an indicators table. If we
569 do this function's probably already been run. If not
570 we need to trick this server out. */
558 if (proxyt->indicators == NULL) {571 if (proxyt->indicators == NULL) {
559 proxyt->indicators = g_hash_table_new_full(g_str_hash, g_str_equal,572 proxyt->indicators = g_hash_table_new(g_direct_hash, g_direct_equal);
560 g_free, proxy_indicators_free);573
561 /* Elevate to working */
562 IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(proxyt->listener);574 IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(proxyt->listener);
563575
576 /* Move the proxy from 'possible' to 'working'. */
564 GList * proxyt_item;577 GList * proxyt_item;
565 proxyt_item = g_list_find_custom(priv->proxies_possible, proxyt, proxy_t_equal);578 proxyt_item = g_list_find_custom(priv->proxies_possible, proxyt, proxy_t_equal);
566 if (proxyt_item != NULL) {579 if (proxyt_item != NULL) {
@@ -568,19 +581,35 @@
568 }581 }
569 priv->proxies_working = g_list_prepend(priv->proxies_working, proxyt);582 priv->proxies_working = g_list_prepend(priv->proxies_working, proxyt);
570583
584 /* Connect to all the indicator based signals
585 that are coming from this server */
571 dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorAdded",586 dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorAdded",
572 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);587 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
573 dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorAdded",588 dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorAdded",
589 G_CALLBACK(proxy_indicator_added_legacy), proxyt, NULL);
590 dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorNew",
591 G_TYPE_UINT, G_TYPE_INVALID);
592 dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorNew",
574 G_CALLBACK(proxy_indicator_added), proxyt, NULL);593 G_CALLBACK(proxy_indicator_added), proxyt, NULL);
575 dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorRemoved",594 dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorRemoved",
576 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);595 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
577 dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorRemoved",596 dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorRemoved",
597 G_CALLBACK(proxy_indicator_removed_legacy), proxyt, NULL);
598 dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorDelete",
599 G_TYPE_UINT, G_TYPE_INVALID);
600 dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorDelete",
578 G_CALLBACK(proxy_indicator_removed), proxyt, NULL);601 G_CALLBACK(proxy_indicator_removed), proxyt, NULL);
579 dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorModified",602 dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorModified",
580 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);603 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
581 dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorModified",604 dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorModified",
582 G_CALLBACK(proxy_indicator_modified), proxyt, NULL);605 G_CALLBACK(proxy_indicator_modified), proxyt, NULL);
606 dbus_g_proxy_add_signal(proxyt->proxy, "ServerCountChanged",
607 G_TYPE_UINT, G_TYPE_INVALID);
608 dbus_g_proxy_connect_signal(proxyt->proxy, "ServerCountChanged",
609 G_CALLBACK(proxy_server_count_changed), proxyt, NULL);
583610
611 /* If we've got a type let it override the type
612 we had here before */
584 if (type != NULL) {613 if (type != NULL) {
585 if (proxyt->type != NULL) {614 if (proxyt->type != NULL) {
586 g_free(proxyt->type);615 g_free(proxyt->type);
@@ -588,102 +617,125 @@
588 proxyt->type = g_strdup(type);617 proxyt->type = g_strdup(type);
589 }618 }
590619
620 /* We're setting the max number of indicators from the default
621 when we detect it. This should give a reasonable amount of
622 time for listeners to set the default if they want something
623 different from infinite. Otherwise it'd be easy to miss the
624 first couple. */
625 proxyt->server.max_indicators = priv->max_indicators;
626 if (proxyt->server.max_indicators != -1) {
627 org_freedesktop_indicator_set_max_indicators_async(proxyt->proxy, proxyt->server.max_indicators, set_max_indicators_cb, proxyt->name);
628 }
629
630 /* Signal to clients of the listener that there's a new
631 server. Note the server parameter here is the pointer
632 to the server struct in the proxy data structure. */
591 g_signal_emit(proxyt->listener, signals[SERVER_ADDED], 0, &proxyt->server, proxyt->type, TRUE);633 g_signal_emit(proxyt->listener, signals[SERVER_ADDED], 0, &proxyt->server, proxyt->type, TRUE);
592 }634 }
593635
594 return;636 return;
595}637}
596638
597static void639/* A fun little wrapper so that we can support the
598proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt)640 signals on the indicator v1 interface. It just drops
599{641 the type and calls the new function. */
642static void
643proxy_indicator_added_legacy (DBusGProxy * proxy, guint id, gchar * type, proxy_t * proxyt)
644{
645 return proxy_indicator_added(proxy, id, proxyt);
646}
647
648/* Gets called when we get a signal from the server that
649 there is a new indicator. We put it into our list of
650 indicators and pass the signal up. If the server hasn't
651 been known about before, we create the appropriate
652 structures for it. */
653static void
654proxy_indicator_added (DBusGProxy * proxy, guint id, proxy_t * proxyt)
655{
656 g_debug("Proxy Indicator Added");
657 g_return_if_fail(proxyt != NULL);
658
600 if (proxyt->indicators == NULL) {659 if (proxyt->indicators == NULL) {
601 proxy_server_added (proxy, NULL, proxyt);660 proxy_server_added (proxy, NULL, proxyt);
602 }661 }
603662
604 GHashTable * indicators = g_hash_table_lookup(proxyt->indicators, type);663 if (!g_hash_table_lookup(proxyt->indicators, GUINT_TO_POINTER(id))) {
605664 g_hash_table_insert(proxyt->indicators, GUINT_TO_POINTER(id), GUINT_TO_POINTER(TRUE));
606 if (indicators == NULL) {665 g_signal_emit(proxyt->listener, signals[INDICATOR_ADDED], 0, &proxyt->server, GUINT_TO_POINTER(id), TRUE);
607 indicators = g_hash_table_new(g_direct_hash, g_direct_equal);
608 g_hash_table_insert(proxyt->indicators, g_strdup(type), indicators);
609 }
610
611 if (!g_hash_table_lookup(indicators, (gpointer)id)) {
612 g_hash_table_insert(indicators, (gpointer)id, (gpointer)TRUE);
613 g_signal_emit(proxyt->listener, signals[INDICATOR_ADDED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, TRUE);
614 }666 }
615667
616 return;668 return;
617}669}
618670
619static void671/* A fun little wrapper so that we can support the
620proxy_indicator_removed (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt)672 signals on the indicator v1 interface. It just drops
621{673 the type and calls the new function. */
674static void
675proxy_indicator_removed_legacy (DBusGProxy * proxy, guint id, gchar * type, proxy_t * proxyt)
676{
677 return proxy_indicator_removed(proxy, id, proxyt);
678}
679
680/* A server removed an indicator. This function removes all the
681 local data structures and then passes the signal up the stack.
682 */
683static void
684proxy_indicator_removed (DBusGProxy * proxy, guint id, proxy_t * proxyt)
685{
686 g_debug("Proxy Indicator Removed");
687 g_return_if_fail(proxyt != NULL);
688
622 if (proxyt->indicators == NULL) {689 if (proxyt->indicators == NULL) {
623 g_warning("Oddly we had an indicator removed from an interface that we didn't think had indicators.");690 g_warning("Oddly we had an indicator removed from an interface that we didn't think had indicators.");
624 return;691 return;
625 }692 }
626693
627 GHashTable * indicators = g_hash_table_lookup(proxyt->indicators, type);694 if (!g_hash_table_lookup(proxyt->indicators, GUINT_TO_POINTER(id))) {
628 if (indicators == NULL) {695 g_warning("No indicator %d on '%s'.", id, proxyt->name);
629 g_warning("Can not remove indicator %d of type '%s' as there are no indicators of that type on %s.", id, type, proxyt->name);696 return;
630 return;697 }
631 }698
632699 g_hash_table_remove(proxyt->indicators, GUINT_TO_POINTER(id));
633 if (!g_hash_table_lookup(indicators, (gpointer)id)) {700 g_signal_emit(proxyt->listener, signals[INDICATOR_REMOVED], 0, &proxyt->server, GUINT_TO_POINTER(id), TRUE);
634 g_warning("No indicator %d of type '%s' on '%s'.", id, type, proxyt->name);
635 return;
636 }
637
638 g_hash_table_remove(indicators, (gpointer)id);
639 g_signal_emit(proxyt->listener, signals[INDICATOR_REMOVED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, TRUE);
640701
641 return;702 return;
642}703}
643704
705/* This is a signal from the server that a property on an indicator
706 has been modified. We try and find the indicator, convert all
707 the parameters to the local ones, and then pass up the signal. */
644static void708static void
645proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, proxy_t * proxyt)709proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, proxy_t * proxyt)
646{710{
711 g_debug("Proxy Indicator Modified");
712 g_return_if_fail(proxyt != NULL);
713
647 if (proxyt->indicators == NULL) {714 if (proxyt->indicators == NULL) {
648 g_warning("Oddly we had an indicator modified from an interface that we didn't think had indicators.");715 g_warning("Oddly we had an indicator modified from an interface that we didn't think had indicators.");
649 return;716 return;
650 }717 }
651718
652 GList * keys = g_hash_table_get_keys(proxyt->indicators);719 if (!g_hash_table_lookup(proxyt->indicators, GUINT_TO_POINTER(id))) {
653 GList * inc = NULL;
654 gchar * type;
655
656 for (inc = g_list_first(keys); inc != NULL; inc = g_list_next(inc)) {
657 type = (gchar *)inc->data;
658
659 GHashTable * indicators = g_hash_table_lookup(proxyt->indicators, type);
660 if (indicators == NULL) continue; /* no indicators for this type? Odd, but not an error */
661
662 if (g_hash_table_lookup(indicators, (gpointer)id)) {
663 break;
664 }
665 }
666
667 if (inc == NULL) {
668 g_warning("Can not modify indicator %d with property '%s' as there are no indicators with that id on %s.", id, property, proxyt->name);720 g_warning("Can not modify indicator %d with property '%s' as there are no indicators with that id on %s.", id, property, proxyt->name);
669 return;721 return;
670 }722 }
671723
672 g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, property, TRUE);724 g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, &proxyt->server, GUINT_TO_POINTER(id), property, TRUE);
673725
674 return;726 return;
675}727}
676728
729/* This function gets called when the dbus count
730 signal comes it. Basically we're just translating
731 it into a local signal with the appropraite parameters
732 and structures. */
677static void733static void
678proxy_indicators_free (gpointer data)734proxy_server_count_changed (DBusGProxy * proxy, guint count, proxy_t * proxyt)
679{735{
680 GHashTable * table = (GHashTable *)data;736 g_debug("Proxy Server Count Changed");
681737 g_return_if_fail(proxyt != NULL);
682 if (g_hash_table_size(table) != 0) {738 g_signal_emit(proxyt->listener, signals[SERVER_COUNT_CHANGED], 0, &proxyt->server, count, TRUE);
683 g_warning("Clearning a set of indicators that wasn't signaled!");
684 }
685
686 g_hash_table_unref(table);
687 return;739 return;
688}740}
689741
@@ -742,7 +794,7 @@
742{794{
743 /* g_debug("get_property_helper: %s %d", property, prop_type); */795 /* g_debug("get_property_helper: %s %d", property, prop_type); */
744 /* TODO: Do we need to somehow refcount the server/indicator while we're waiting on this? */796 /* TODO: Do we need to somehow refcount the server/indicator while we're waiting on this? */
745 get_property_t * get_property_data = g_new(get_property_t, 1);797 get_property_t * get_property_data = g_new0(get_property_t, 1);
746 get_property_data->cb = callback;798 get_property_data->cb = callback;
747 get_property_data->data = data;799 get_property_data->data = data;
748 get_property_data->listener = listener;800 get_property_data->listener = listener;
@@ -774,6 +826,8 @@
774 return TRUE;826 return TRUE;
775}827}
776828
829/* A callback for asking an indicator to be displayed,
830 which is unlikely to fail. So we're throwing a warning. */
777static void 831static void
778listener_display_cb (DBusGProxy *proxy, GError *error, gpointer userdata)832listener_display_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
779{833{
@@ -791,13 +845,57 @@
791 return;845 return;
792}846}
793847
848/* A callback for saying an indicator is displayed,
849 which is unlikely to fail. So we're throwing a warning. */
850static void
851listener_displayed_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
852{
853 if (error != NULL) {
854 g_warning("Listener displayed caused an error: %s", error->message);
855 }
856 return;
857}
858
859/**
860 indicate_listener_displayed:
861 @listener: The #IndicateListener representing the connection
862 @server: The server that the indicator is on
863 @indicator: Which indicator is being displayed
864 @displayed: Whether it's being displayed or hidden
865
866 This function tells the client whether we're showing this indicator
867 to the user. This doesn't mean that it's necissarilly visible right
868 now, but more that there is a way for the user to get to this item
869 individually.
870*/
871void
872indicate_listener_displayed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gboolean displayed)
873{
874 org_freedesktop_indicator_indicator_displayed_async (server->proxy,
875 INDICATE_LISTENER_INDICATOR_ID(indicator),
876 displayed,
877 listener_displayed_cb,
878 NULL);
879
880 if (!server->interests[INDICATE_INTEREST_INDICATOR_DISPLAY] && displayed) {
881 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.");
882 }
883
884 return;
885}
886
794typedef struct {887typedef struct {
795 IndicateListener * listener;888 IndicateListener * listener;
796 IndicateListenerServer * server;889 IndicateListenerServer * server;
797 indicate_listener_get_server_property_cb cb;890 indicate_listener_get_server_property_cb cb;
891 indicate_listener_get_server_uint_property_cb cb_uint;
798 gpointer data;892 gpointer data;
799} property_cb_t;893} property_cb_t;
800894
895/* A callback from getting the property off of the server
896 which unravels the property_cb_t structure that was passed
897 as data and calls back the call back that was in it with
898 the appropriate data, also unrolled. */
801static void899static void
802property_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data)900property_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data)
803{901{
@@ -807,6 +905,9 @@
807905
808 GValue property = {0};906 GValue property = {0};
809907
908 /* Finish the call and get our value. There might
909 be an error as if someone was using v1 API and
910 not v2. Let's handle that early. */
810 dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &property, G_TYPE_INVALID);911 dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &property, G_TYPE_INVALID);
811 if (error != NULL) {912 if (error != NULL) {
812 /* g_warning("Unable to get property: %s", error->message); */913 /* g_warning("Unable to get property: %s", error->message); */
@@ -815,28 +916,42 @@
815 return;916 return;
816 }917 }
817918
818 if (!G_VALUE_HOLDS_STRING(&property)) {919 /* Dup all the values and make them local so that
819 g_warning("Property returned is not a string!");920 we can free up the data structure to make the
820 g_free(propertyt);921 rest of the code easier to read. */
821 return;
822 }
823
824 IndicateListener * listener = propertyt->listener;922 IndicateListener * listener = propertyt->listener;
825 IndicateListenerServer * server = propertyt->server;923 IndicateListenerServer * server = propertyt->server;
826 indicate_listener_get_server_property_cb cb = propertyt->cb;924 indicate_listener_get_server_property_cb cb = propertyt->cb;
925 indicate_listener_get_server_uint_property_cb cb_uint = propertyt->cb_uint;
827 gpointer cb_data = propertyt->data;926 gpointer cb_data = propertyt->data;
828927
829 g_free(propertyt);928 g_free(propertyt);
830929
831 gchar * propstr = g_value_dup_string(&property);930 if (G_VALUE_HOLDS_STRING(&property) && cb != NULL) {
832931 /* If it's got a string, and we have a value for that
833 /* g_debug("\tProperty value: %s", propstr); */932 we'll get the string out and call the call back */
834933 gchar * propstr = g_value_dup_string(&property);
835 return cb(listener, server, propstr, cb_data);934 return cb(listener, server, propstr, cb_data);
935 } else if (G_VALUE_HOLDS_UINT(&property) && cb_uint != NULL) {
936 /* If it's got a UINT and we have a callback for that
937 let's grab the value and call the callback. */
938 guint val = g_value_get_uint(&property);
939 return cb_uint(listener, server, val, cb_data);
940 } else {
941 /* WTF!?!?!?! */
942 g_warning("Property back from server that we didn't understand.");
943 }
944
945 return;
836}946}
837947
948/* This is a helper function for all the functions that
949 get properties from the server. They all need to have
950 a callback setup with an intermediary data structure
951 and this function builds and populates that, then uses
952 a custom callback to call their callback */
838static void953static void
839get_server_property (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, const gchar * property_name, gpointer data)954get_server_property (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, indicate_listener_get_server_uint_property_cb callback_uint, const gchar * property_name, gpointer data)
840{955{
841 /* g_debug("Setting up callback for property %s on %s", property_name, INDICATE_LISTENER_SERVER_DBUS_NAME(server)); */956 /* g_debug("Setting up callback for property %s on %s", property_name, INDICATE_LISTENER_SERVER_DBUS_NAME(server)); */
842 IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);957 IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
@@ -864,10 +979,11 @@
864 DBUS_INTERFACE_PROPERTIES);979 DBUS_INTERFACE_PROPERTIES);
865 }980 }
866981
867 property_cb_t * localdata = g_new(property_cb_t, 1);982 property_cb_t * localdata = g_new0(property_cb_t, 1);
868 localdata->listener = listener;983 localdata->listener = listener;
869 localdata->server = server;984 localdata->server = server;
870 localdata->cb = callback;985 localdata->cb = callback;
986 localdata->cb_uint = callback_uint;
871 localdata->data = data;987 localdata->data = data;
872988
873 dbus_g_proxy_begin_call (proxyt->property_proxy,989 dbus_g_proxy_begin_call (proxyt->property_proxy,
@@ -885,13 +1001,19 @@
885void1001void
886indicate_listener_server_get_type (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data)1002indicate_listener_server_get_type (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data)
887{1003{
888 return get_server_property(listener, server, callback, "type", data);1004 return get_server_property(listener, server, callback, NULL, "type", data);
889}1005}
8901006
891void1007void
892indicate_listener_server_get_desktop (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data)1008indicate_listener_server_get_desktop (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_property_cb callback, gpointer data)
893{1009{
894 return get_server_property(listener, server, callback, "desktop", data);1010 return get_server_property(listener, server, callback, NULL, "desktop", data);
1011}
1012
1013void
1014indicate_listener_server_get_count (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_server_uint_property_cb callback, gpointer data)
1015{
1016 return get_server_property(listener, server, NULL, callback, "count", data);
895}1017}
8961018
897const gchar *1019const gchar *
@@ -1015,7 +1137,7 @@
10151137
1016 /* Check for root being "node" */1138 /* Check for root being "node" */
1017 xmlNodePtr root = xmlDocGetRootElement(xmldoc);1139 xmlNodePtr root = xmlDocGetRootElement(xmldoc);
1018 if (g_strcmp0(root->name, "node") != 0) {1140 if (g_strcmp0((gchar *)root->name, "node") != 0) {
1019 xmlFreeDoc(xmldoc);1141 xmlFreeDoc(xmldoc);
1020 g_warning("Introspection data from %s is not valid: %s", server->name, OUT_data);1142 g_warning("Introspection data from %s is not valid: %s", server->name, OUT_data);
1021 return;1143 return;
@@ -1038,12 +1160,12 @@
1038 xmlNodePtr children;1160 xmlNodePtr children;
1039 for (children = root->children; children != NULL; children = children->next) {1161 for (children = root->children; children != NULL; children = children->next) {
1040 gchar * xmlnameval = NULL;1162 gchar * xmlnameval = NULL;
1041 if (g_strcmp0(children->name, nodename) == 0) {1163 if (g_strcmp0((gchar *)children->name, nodename) == 0) {
1042 xmlAttrPtr attrib;1164 xmlAttrPtr attrib;
1043 for (attrib = children->properties; attrib != NULL; attrib = attrib->next) {1165 for (attrib = children->properties; attrib != NULL; attrib = attrib->next) {
1044 if (g_strcmp0(attrib->name, "name") == 0) {1166 if (g_strcmp0((gchar *)attrib->name, "name") == 0) {
1045 if (attrib->children != NULL) {1167 if (attrib->children != NULL) {
1046 xmlnameval = attrib->children->content;1168 xmlnameval = (gchar *)attrib->children->content;
1047 }1169 }
1048 break;1170 break;
1049 }1171 }
@@ -1082,3 +1204,50 @@
10821204
1083 return;1205 return;
1084}1206}
1207
1208/**
1209 indicate_listener_set_default_max_indicators:
1210 @listener: Instance of #IndicateListener to set on.
1211 @max: The new default number of max indicators.
1212
1213 This function sets the number that is given to new servers
1214 when they start for the max number of indicators that you want
1215 to see. The client should enforce this number.
1216
1217 Note: This function WILL NOT reconfigure already recognized
1218 servers. It only affects new servers.
1219*/
1220void
1221indicate_listener_set_default_max_indicators (IndicateListener * listener, gint max)
1222{
1223 g_return_if_fail(INDICATE_IS_LISTENER(listener));
1224 IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
1225 priv->max_indicators = max;
1226 return;
1227}
1228
1229/**
1230 indicate_listener_set_server_max_indicators:
1231 @listener: Instance of #IndicateListener to set on.
1232 @server: Server that the new max should be set on.
1233 @max: The new number of max indicators.
1234
1235 This function changes the max number of indicators that
1236 a server should send. If the number is different than the
1237 previous number a signal will be sent to the application to
1238 adjust then number of indicators that they have. This is
1239 sent asynchronously.
1240*/
1241void
1242indicate_listener_set_server_max_indicators (IndicateListener * listener, IndicateListenerServer * server, gint max)
1243{
1244 g_return_if_fail(INDICATE_IS_LISTENER(listener));
1245 g_return_if_fail(server != NULL); /* All we can really check :-/ */
1246
1247 if (server->max_indicators != max) {
1248 server->max_indicators = max;
1249 org_freedesktop_indicator_set_max_indicators_async(server->proxy, server->max_indicators, set_max_indicators_cb, server->name);
1250 }
1251
1252 return;
1253}
10851254
=== modified file 'libindicate/listener.h'
--- libindicate/listener.h 2009-08-03 22:53:17 +0000
+++ libindicate/listener.h 2009-09-05 16:38:55 +0000
@@ -52,6 +52,7 @@
52#define INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED "indicator-modified"52#define INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED "indicator-modified"
53#define INDICATE_LISTENER_SIGNAL_SERVER_ADDED "server-added"53#define INDICATE_LISTENER_SIGNAL_SERVER_ADDED "server-added"
54#define INDICATE_LISTENER_SIGNAL_SERVER_REMOVED "server-removed"54#define INDICATE_LISTENER_SIGNAL_SERVER_REMOVED "server-removed"
55#define INDICATE_LISTENER_SIGNAL_SERVER_COUNT_CHANGED "server-count-changed"
5556
56#define INDICATE_LISTENER_SERVER_DBUS_NAME(server) (indicate_listener_server_get_dbusname(server))57#define INDICATE_LISTENER_SERVER_DBUS_NAME(server) (indicate_listener_server_get_dbusname(server))
57#define INDICATE_LISTENER_INDICATOR_ID(indicator) (indicate_listener_indicator_get_id(indicator))58#define INDICATE_LISTENER_INDICATOR_ID(indicator) (indicate_listener_indicator_get_id(indicator))
@@ -69,17 +70,42 @@
69 GObject parent;70 GObject parent;
70};71};
7172
73/**
74 IndicateListenerClass:
75 @parent: Parent class #GObjectClass.
76 @indicator_added: Slot for IndicateListener::indicator-added.
77 @indicator_removed: Slot for IndicateListener::indicator-removed.
78 @indicator_modified: Slot for IndicateListener::indicator-modified.
79 @server_added: Slot for IndicateListener::server-added.
80 @server_removed: Slot for IndicateListener::server-removed.
81 @server_count_changed: Slot for IndicateListener::server-count-changed.
82 @indicate_listener_reserved1: Reserved for future use
83 @indicate_listener_reserved2: Reserved for future use
84 @indicate_listener_reserved3: Reserved for future use
85 @indicate_listener_reserved4: Reserved for future use
86
87 The class has all of the signals that are supplied by
88 the listener about what is happening on the server.
89*/
72typedef struct _IndicateListenerClass IndicateListenerClass;90typedef struct _IndicateListenerClass IndicateListenerClass;
73struct _IndicateListenerClass {91struct _IndicateListenerClass {
92 /* Parent */
74 GObjectClass parent;93 GObjectClass parent;
7594
76 /* Signals */95 /* Signals */
77 void (* indicator_added) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type);96 void (* indicator_added) (IndicateListenerServer * server, IndicateListenerIndicator * indicator);
78 void (* indicator_removed) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type);97 void (* indicator_removed) (IndicateListenerServer * server, IndicateListenerIndicator * indicator);
79 void (* indicator_modified) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gchar * property);98 void (* indicator_modified) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property);
8099
81 void (* server_added) (IndicateListenerServer * server, gchar * type);100 void (* server_added) (IndicateListenerServer * server, gchar * type);
82 void (* server_removed) (IndicateListenerServer * server, gchar * type);101 void (* server_removed) (IndicateListenerServer * server, gchar * type);
102 void (* server_count_changed) (IndicateListenerServer * server, guint count);
103
104 /* Future Use */
105 void (*indicate_listener_reserved1)(void);
106 void (*indicate_listener_reserved2)(void);
107 void (*indicate_listener_reserved3)(void);
108 void (*indicate_listener_reserved4)(void);
83};109};
84110
85GType indicate_listener_get_type (void) G_GNUC_CONST;111GType indicate_listener_get_type (void) G_GNUC_CONST;
@@ -87,6 +113,7 @@
87typedef void (*indicate_listener_get_property_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data);113typedef void (*indicate_listener_get_property_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data);
88typedef void (*indicate_listener_get_property_time_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GTimeVal * propertydata, gpointer data);114typedef void (*indicate_listener_get_property_time_cb) (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GTimeVal * propertydata, gpointer data);
89typedef void (*indicate_listener_get_server_property_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data);115typedef void (*indicate_listener_get_server_property_cb) (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data);
116typedef void (*indicate_listener_get_server_uint_property_cb) (IndicateListener * listener, IndicateListenerServer * server, guint value, gpointer data);
90117
91/* Create a new listener */118/* Create a new listener */
92IndicateListener * indicate_listener_new (void);119IndicateListener * indicate_listener_new (void);
@@ -106,6 +133,10 @@
106void indicate_listener_display (IndicateListener * listener,133void indicate_listener_display (IndicateListener * listener,
107 IndicateListenerServer * server,134 IndicateListenerServer * server,
108 IndicateListenerIndicator * indicator);135 IndicateListenerIndicator * indicator);
136void indicate_listener_displayed (IndicateListener * listener,
137 IndicateListenerServer * server,
138 IndicateListenerIndicator * indicator,
139 gboolean displayed);
109void indicate_listener_server_get_type (IndicateListener * listener,140void indicate_listener_server_get_type (IndicateListener * listener,
110 IndicateListenerServer * server,141 IndicateListenerServer * server,
111 indicate_listener_get_server_property_cb callback,142 indicate_listener_get_server_property_cb callback,
@@ -114,6 +145,10 @@
114 IndicateListenerServer * server,145 IndicateListenerServer * server,
115 indicate_listener_get_server_property_cb callback,146 indicate_listener_get_server_property_cb callback,
116 gpointer data);147 gpointer data);
148void indicate_listener_server_get_count (IndicateListener * listener,
149 IndicateListenerServer * server,
150 indicate_listener_get_server_uint_property_cb callback,
151 gpointer data);
117const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server);152const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server);
118guint indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator);153guint indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator);
119void indicate_listener_server_show_interest (IndicateListener * listener,154void indicate_listener_server_show_interest (IndicateListener * listener,
@@ -125,6 +160,11 @@
125gboolean indicate_listener_server_check_interest (IndicateListener * listener,160gboolean indicate_listener_server_check_interest (IndicateListener * listener,
126 IndicateListenerServer * server,161 IndicateListenerServer * server,
127 IndicateInterests interest);162 IndicateInterests interest);
163void indicate_listener_set_default_max_indicators (IndicateListener * listener,
164 gint max);
165void indicate_listener_set_server_max_indicators (IndicateListener * listener,
166 IndicateListenerServer * server,
167 gint max);
128168
129G_END_DECLS169G_END_DECLS
130170
131171
=== modified file 'libindicate/server-marshal.list'
--- libindicate/server-marshal.list 2009-07-21 16:37:51 +0000
+++ libindicate/server-marshal.list 2009-08-28 19:55:12 +0000
@@ -26,4 +26,5 @@
26# <http://www.gnu.org/licenses/>26# <http://www.gnu.org/licenses/>
27#27#
28# IndicatorAdded28# IndicatorAdded
29VOID:UINT
29VOID:UINT,STRING30VOID:UINT,STRING
3031
=== modified file 'libindicate/server.c'
--- libindicate/server.c 2009-08-05 00:25:55 +0000
+++ libindicate/server.c 2009-09-08 20:58:26 +0000
@@ -37,18 +37,19 @@
37enum {37enum {
38 NO_GET_DESKTOP,38 NO_GET_DESKTOP,
39 NO_GET_INDICATOR_COUNT,39 NO_GET_INDICATOR_COUNT,
40 NO_GET_INDICATOR_COUNT_BY_TYPE,
41 NO_GET_INDICATOR_LIST,40 NO_GET_INDICATOR_LIST,
42 NO_GET_INDICATOR_LIST_BY_TYPE,
43 NO_GET_INDICATOR_PROPERTY,41 NO_GET_INDICATOR_PROPERTY,
44 NO_GET_INDICATOR_PROPERTY_GROUP,42 NO_GET_INDICATOR_PROPERTY_GROUP,
45 NO_GET_INDICATOR_PROPERTIES,43 NO_GET_INDICATOR_PROPERTIES,
46 NO_SHOW_INDICATOR_TO_USER,44 NO_SHOW_INDICATOR_TO_USER,
45 NO_INDICATOR_DISPLAYED,
47 INVALID_INDICATOR_ID,46 INVALID_INDICATOR_ID,
48 NO_SHOW_INTEREST,47 NO_SHOW_INTEREST,
49 NO_REMOVE_INTEREST,48 NO_REMOVE_INTEREST,
50 SHOW_INTEREST_FAILED,49 SHOW_INTEREST_FAILED,
51 REMOVE_INTEREST_FAILED,50 REMOVE_INTEREST_FAILED,
51 NO_MAX_INDICATORS_SET,
52 MAX_INDICATORS_SET_FAILED,
52 LAST_ERROR53 LAST_ERROR
53};54};
5455
@@ -62,6 +63,9 @@
62 SERVER_DISPLAY,63 SERVER_DISPLAY,
63 INTEREST_ADDED,64 INTEREST_ADDED,
64 INTEREST_REMOVED,65 INTEREST_REMOVED,
66 MAX_INDICATORS_CHANGED,
67 INDICATOR_NOT_SHOWN,
68 SERVER_COUNT_CHANGED,
65 LAST_SIGNAL69 LAST_SIGNAL
66};70};
6771
@@ -69,7 +73,8 @@
69enum {73enum {
70 PROP_0,74 PROP_0,
71 PROP_DESKTOP,75 PROP_DESKTOP,
72 PROP_TYPE76 PROP_TYPE,
77 PROP_COUNT
73};78};
7479
75static guint signals[LAST_SIGNAL] = { 0 };80static guint signals[LAST_SIGNAL] = { 0 };
@@ -89,12 +94,17 @@
8994
90 gchar * desktop;95 gchar * desktop;
91 gchar * type;96 gchar * type;
97 guint count;
9298
93 // TODO: Should have a more robust way to track this, but this'll work for now99 // TODO: Should have a more robust way to track this, but this'll work for now
94 guint num_hidden;100 guint num_hidden;
95101
96 gboolean interests[INDICATE_INTEREST_LAST];102 /* Folks storage */
97 GList * interestedfolks;103 GList * interestedfolks;
104
105 /* Folks caches */
106 gint max_indicators;
107 gboolean interests[INDICATE_INTEREST_LAST];
98};108};
99109
100#define INDICATE_SERVER_GET_PRIVATE(o) \110#define INDICATE_SERVER_GET_PRIVATE(o) \
@@ -104,8 +114,12 @@
104struct _IndicateServerInterestedFolk {114struct _IndicateServerInterestedFolk {
105 gchar * sender;115 gchar * sender;
106 gboolean interests[INDICATE_INTEREST_LAST];116 gboolean interests[INDICATE_INTEREST_LAST];
117 gint max_indicators;
118 GHashTable * indicators_displayed;
107};119};
108120
121static const gint MAX_INDICATORS_INFINITE = -1;
122static const gint MAX_INDICATORS_UNSET = -2;
109123
110/* Define Type */124/* Define Type */
111G_DEFINE_TYPE (IndicateServer, indicate_server, G_TYPE_OBJECT);125G_DEFINE_TYPE (IndicateServer, indicate_server, G_TYPE_OBJECT);
@@ -113,20 +127,25 @@
113/* Prototypes */127/* Prototypes */
114static void indicate_server_finalize (GObject * obj);128static void indicate_server_finalize (GObject * obj);
115static gboolean get_indicator_count (IndicateServer * server, guint * count, GError **error);129static gboolean get_indicator_count (IndicateServer * server, guint * count, GError **error);
116static gboolean get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error);
117static gboolean get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error);130static gboolean get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error);
118static gboolean get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error);131static IndicateIndicator * get_indicator (IndicateServer * server, guint id, GError **error);
119static gboolean get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error);132static gboolean get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error);
120static gboolean get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);133static gboolean get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);
121static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error);134static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error);
122static gboolean show_indicator_to_user (IndicateServer * server, guint id, GError ** error);135static gboolean show_indicator_to_user (IndicateServer * server, guint id, GError ** error);
136static gboolean indicator_displayed (IndicateServer * server, gchar * sender, guint id, gboolean displayed, GError ** error);
123static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server);137static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server);
138static void indicator_display_check_recalc (gpointer key, gpointer value, gpointer userdata);
139static void recalculate_indicator_displayed (IndicateServer * server, guint id);
124static guint get_next_id (IndicateServer * server);140static guint get_next_id (IndicateServer * server);
125static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec);141static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec);
126static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec);142static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec);
127static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest);143static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest);
128static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest);144static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest);
129static gboolean check_interest (IndicateServer * server, IndicateInterests intrest);145static gboolean check_interest (IndicateServer * server, IndicateInterests intrest);
146static gint max_indicators_get (IndicateServer * server);
147static gboolean max_indicators_set (IndicateServer * server, gchar * sender, gint max);
148static void recalculate_max_indicators (IndicateServer * server);
130static gint indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b);149static gint indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b);
131static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender);150static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender);
132static void indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value);151static void indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value);
@@ -135,15 +154,15 @@
135154
136/* DBus API */155/* DBus API */
137gboolean _indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error);156gboolean _indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error);
138gboolean _indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error);
139gboolean _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error);157gboolean _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error);
140gboolean _indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error);
141gboolean _indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error);158gboolean _indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error);
142gboolean _indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);159gboolean _indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);
143gboolean _indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error);160gboolean _indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error);
144gboolean _indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error);161gboolean _indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error);
162gboolean _indicate_server_indicator_displayed (IndicateServer * server, guint id, gboolean displayed, DBusGMethodInvocation * method);
145gboolean _indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method);163gboolean _indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method);
146gboolean _indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method);164gboolean _indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method);
165gboolean _indicate_server_set_max_indicators (IndicateServer * server, gint max, DBusGMethodInvocation * method);
147166
148/* Has to be after the dbus prototypes */167/* Has to be after the dbus prototypes */
149#include "dbus-indicate-server.h"168#include "dbus-indicate-server.h"
@@ -168,38 +187,32 @@
168 IndicateServer::indicator-added:187 IndicateServer::indicator-added:
169 @arg0: The #IndicateServer object188 @arg0: The #IndicateServer object
170 @arg1: The #IndicateIndicator ID number189 @arg1: The #IndicateIndicator ID number
171 @arg2: The type of the indicator
172190
173 Emitted every time that a new indicator is made visible to191 Emitted every time that a new indicator is made visible to
174 the world. This results in a signal on DBus.192 the world. This results in a signal on DBus.
175
176 Can be emitted by subclasses using indicate_server_emit_indicator_added()
177 */193 */
178 signals[INDICATOR_ADDED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_ADDED,194 signals[INDICATOR_ADDED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_ADDED,
179 G_TYPE_FROM_CLASS (class),195 G_TYPE_FROM_CLASS (class),
180 G_SIGNAL_RUN_LAST,196 G_SIGNAL_RUN_LAST,
181 G_STRUCT_OFFSET (IndicateServerClass, indicator_added),197 G_STRUCT_OFFSET (IndicateServerClass, indicator_added),
182 NULL, NULL,198 NULL, NULL,
183 _indicate_server_marshal_VOID__UINT_STRING,199 _indicate_server_marshal_VOID__UINT,
184 G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);200 G_TYPE_NONE, 1, G_TYPE_UINT);
185 /**201 /**
186 IndicateServer::indicator-removed:202 IndicateServer::indicator-removed:
187 @arg0: The #IndicateServer object203 @arg0: The #IndicateServer object
188 @arg1: The #IndicateIndicator ID number204 @arg1: The #IndicateIndicator ID number
189 @arg2: The type of the indicator
190205
191 Emitted every time that a new indicator is made invisible to206 Emitted every time that a new indicator is made invisible to
192 the world. This results in a signal on DBus.207 the world. This results in a signal on DBus.
193
194 Can be emitted by subclasses using indicate_server_emit_indicator_removed()
195 */208 */
196 signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED,209 signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED,
197 G_TYPE_FROM_CLASS (class),210 G_TYPE_FROM_CLASS (class),
198 G_SIGNAL_RUN_LAST,211 G_SIGNAL_RUN_LAST,
199 G_STRUCT_OFFSET (IndicateServerClass, indicator_removed),212 G_STRUCT_OFFSET (IndicateServerClass, indicator_removed),
200 NULL, NULL,213 NULL, NULL,
201 _indicate_server_marshal_VOID__UINT_STRING,214 _indicate_server_marshal_VOID__UINT,
202 G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);215 G_TYPE_NONE, 1, G_TYPE_UINT);
203 /**216 /**
204 IndicateServer::indicator-modified:217 IndicateServer::indicator-modified:
205 @arg0: The #IndicateServer object218 @arg0: The #IndicateServer object
@@ -208,8 +221,6 @@
208221
209 Emitted every time that a property on an indicator changes222 Emitted every time that a property on an indicator changes
210 and it is visible to the world. This results in a signal on DBus.223 and it is visible to the world. This results in a signal on DBus.
211
212 Can be emitted by subclasses using indicate_server_emit_indicator_modified()
213 */224 */
214 signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED,225 signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED,
215 G_TYPE_FROM_CLASS (class),226 G_TYPE_FROM_CLASS (class),
@@ -256,8 +267,6 @@
256 Emitted when a listener signals that the server itself should be267 Emitted when a listener signals that the server itself should be
257 displayed. This signal is caused by a user clicking on the application268 displayed. This signal is caused by a user clicking on the application
258 item in the Messaging Menu. This signal is emitted by DBus.269 item in the Messaging Menu. This signal is emitted by DBus.
259
260 Can be emitted by subclasses using indicate_server_emit_server_display()
261 */270 */
262 signals[SERVER_DISPLAY] = g_signal_new(INDICATE_SERVER_SIGNAL_SERVER_DISPLAY,271 signals[SERVER_DISPLAY] = g_signal_new(INDICATE_SERVER_SIGNAL_SERVER_DISPLAY,
263 G_TYPE_FROM_CLASS (class),272 G_TYPE_FROM_CLASS (class),
@@ -296,6 +305,36 @@
296 NULL, NULL,305 NULL, NULL,
297 g_cclosure_marshal_VOID__UINT,306 g_cclosure_marshal_VOID__UINT,
298 G_TYPE_NONE, 1, G_TYPE_UINT);307 G_TYPE_NONE, 1, G_TYPE_UINT);
308 /**
309 IndicateServer::max-indicators-changed:
310 @arg0: The #IndicateServer object
311 @arg1: The new max number of indicators
312
313 Emitted when a listener either specifies their max number
314 to be higher, or at all. The default is -1 or infinite.
315 */
316 signals[MAX_INDICATORS_CHANGED] = g_signal_new(INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED,
317 G_TYPE_FROM_CLASS (class),
318 G_SIGNAL_RUN_LAST,
319 G_STRUCT_OFFSET (IndicateServerClass, max_indicators_changed),
320 NULL, NULL,
321 g_cclosure_marshal_VOID__INT,
322 G_TYPE_NONE, 1, G_TYPE_INT);
323 /**
324 IndicateServer::server-count-changed:
325 @arg0: The #IndicateServer object
326 @arg1: The count variable on the server changed.
327
328 Emitted when the count property of the server changes
329 to a new value.
330 */
331 signals[SERVER_COUNT_CHANGED] = g_signal_new(INDICATE_SERVER_SIGNAL_SERVER_COUNT_CHANGED,
332 G_TYPE_FROM_CLASS (class),
333 G_SIGNAL_RUN_LAST,
334 G_STRUCT_OFFSET (IndicateServerClass, server_count_changed),
335 NULL, NULL,
336 g_cclosure_marshal_VOID__UINT,
337 G_TYPE_NONE, 1, G_TYPE_UINT);
299338
300 g_object_class_install_property (gobj, PROP_DESKTOP,339 g_object_class_install_property (gobj, PROP_DESKTOP,
301 g_param_spec_string("desktop", "Desktop File",340 g_param_spec_string("desktop", "Desktop File",
@@ -307,22 +346,28 @@
307 "The type of indicators that this server will provide",346 "The type of indicators that this server will provide",
308 "",347 "",
309 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));348 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
349 g_object_class_install_property (gobj, PROP_COUNT,
350 g_param_spec_uint("count", "Server Count",
351 "A number reprsenting the number of items in a server",
352 0, G_MAXUINT, 0,
353 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
310354
311 dbus_g_object_type_install_info(INDICATE_TYPE_SERVER,355 dbus_g_object_type_install_info(INDICATE_TYPE_SERVER,
312 &dbus_glib__indicate_server_object_info);356 &dbus_glib__indicate_server_object_info);
313357
314 class->get_indicator_count = get_indicator_count;358 class->get_indicator_count = get_indicator_count;
315 class->get_indicator_count_by_type = get_indicator_count_by_type;
316 class->get_indicator_list = get_indicator_list;359 class->get_indicator_list = get_indicator_list;
317 class->get_indicator_list_by_type = get_indicator_list_by_type;
318 class->get_indicator_property = get_indicator_property;360 class->get_indicator_property = get_indicator_property;
319 class->get_indicator_property_group = get_indicator_property_group;361 class->get_indicator_property_group = get_indicator_property_group;
320 class->get_indicator_properties = get_indicator_properties;362 class->get_indicator_properties = get_indicator_properties;
321 class->show_indicator_to_user = show_indicator_to_user;363 class->show_indicator_to_user = show_indicator_to_user;
364 class->indicator_displayed = indicator_displayed;
322 class->get_next_id = get_next_id;365 class->get_next_id = get_next_id;
323 class->show_interest = show_interest;366 class->show_interest = show_interest;
324 class->remove_interest = remove_interest;367 class->remove_interest = remove_interest;
325 class->check_interest = check_interest;368 class->check_interest = check_interest;
369 class->max_indicators_get = max_indicators_get;
370 class->max_indicators_set = max_indicators_set;
326371
327 return;372 return;
328}373}
@@ -342,13 +387,14 @@
342 priv->current_id = 0;387 priv->current_id = 0;
343 priv->type = NULL;388 priv->type = NULL;
344 priv->desktop = NULL;389 priv->desktop = NULL;
390 priv->count = 0;
345391
346 guint i;392 guint i;
347 for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {393 for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
348 priv->interests[i] = FALSE;394 priv->interests[i] = FALSE;
349 }395 }
350 priv->interestedfolks = NULL;396 priv->interestedfolks = NULL;
351397 priv->max_indicators = MAX_INDICATORS_UNSET;
352398
353 return;399 return;
354}400}
@@ -385,54 +431,66 @@
385 g_return_if_fail(G_VALUE_HOLDS_STRING(value));431 g_return_if_fail(G_VALUE_HOLDS_STRING(value));
386 g_return_if_fail(id == PROP_DESKTOP || id == PROP_TYPE);432 g_return_if_fail(id == PROP_DESKTOP || id == PROP_TYPE);
387433
388 gchar ** outstr;
389 gchar * tempstr = NULL;
390 outstr = &tempstr;
391
392 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(obj);434 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(obj);
393 switch (id) {435 switch (id) {
394 case PROP_DESKTOP:436 case PROP_DESKTOP:
395 outstr = &(priv->desktop);437 if (priv->desktop != NULL) {
438 g_free(priv->desktop);
439 }
440 priv->desktop = g_value_dup_string(value);
396 break;441 break;
397 case PROP_TYPE:442 case PROP_TYPE:
398 outstr = &(priv->type);443 if (priv->type != NULL) {
399 break;444 g_free(priv->type);
400 }445 }
401446 priv->type = g_value_dup_string(value);
402 if (*outstr != NULL) {447 break;
403 g_free(*outstr);448 case PROP_COUNT: {
404 }449 guint newval = g_value_get_uint(value);
405450 if (newval != priv->count) {
406 *outstr = g_strdup(g_value_get_string(value));451 priv->count = newval;
452 g_signal_emit(obj, signals[SERVER_COUNT_CHANGED], 0, newval, TRUE);
453 }
454 break;
455 }
456 }
407457
408 return;458 return;
409}459}
410460
461/* Gets the Gobject properties for the IndicateServer. Mostly
462 just copies strings and a whole uint! */
411static void463static void
412get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec)464get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec)
413{465{
414 g_return_if_fail(id == PROP_DESKTOP || id == PROP_TYPE);466 g_return_if_fail(id == PROP_DESKTOP || id == PROP_TYPE);
415467
416 gchar * outstr = NULL;
417 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(obj);468 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(obj);
418 switch (id) {469 switch (id) {
419 case PROP_DESKTOP:470 case PROP_DESKTOP:
420 outstr = priv->desktop;471 if (priv->desktop == NULL) {
472 g_value_set_string(value, "");
473 } else {
474 g_value_set_string(value, priv->desktop);
475 }
421 break;476 break;
422 case PROP_TYPE:477 case PROP_TYPE:
423 outstr = priv->type;478 if (priv->type == NULL) {
424 break;479 g_value_set_string(value, "");
425 }480 } else {
426481 g_value_set_string(value, priv->type);
427 if (outstr != NULL) {482 }
428 g_value_set_string(value, outstr);483 break;
429 } else {484 case PROP_COUNT:
430 g_value_set_static_string(value, "");485 g_value_set_uint(value, priv->count);
486 break;
431 }487 }
432488
433 return;489 return;
434}490}
435491
492/* Small little function to get an error quark for usage
493 with the GError errors back across DBus */
436static GQuark494static GQuark
437indicate_server_error_quark (void)495indicate_server_error_quark (void)
438{496{
@@ -467,8 +525,8 @@
467525
468 if (!priv->registered) {526 if (!priv->registered) {
469 dbus_g_connection_register_g_object(priv->connection,527 dbus_g_connection_register_g_object(priv->connection,
470 priv->path,528 priv->path,
471 G_OBJECT(server));529 G_OBJECT(server));
472 priv->registered = TRUE;530 priv->registered = TRUE;
473 }531 }
474532
@@ -525,6 +583,10 @@
525 priv->interests[i] = FALSE;583 priv->interests[i] = FALSE;
526 }584 }
527585
586 /* Signal that we don't have a max */
587 priv->max_indicators = MAX_INDICATORS_UNSET;
588 g_signal_emit(G_OBJECT(server), signals[MAX_INDICATORS_CHANGED], 0, MAX_INDICATORS_INFINITE, TRUE);
589
528 g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE);590 g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE);
529591
530 if (priv->dbus_proxy != NULL) {592 if (priv->dbus_proxy != NULL) {
@@ -540,6 +602,11 @@
540 return;602 return;
541}603}
542604
605/* Watches the DBus owner change signals to see if any
606 of our folk disappear. If one of our folks goes away
607 then it deals with the repercussions of deleting that
608 entry in terms of interest, max indicators and which
609 indicators are being displayed. */
543static void610static void
544dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server)611dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server)
545{612{
@@ -586,11 +653,63 @@
586 }653 }
587 }654 }
588655
589 g_free(folk);656 /* If the retired folk has set it's max indicators
590657 and it's the value we're using, we need to recalculate */
591 return;658 if (folk->max_indicators != MAX_INDICATORS_UNSET && folk->max_indicators == priv->max_indicators) {
592}659 recalculate_max_indicators(server);
593660 }
661
662 g_hash_table_foreach(folk->indicators_displayed, indicator_display_check_recalc, server);
663
664 /* Finally destory everything */
665 indicate_server_interested_folks_destroy(folk);
666 return;
667}
668
669/* Checks each value in the hash table to see if it's
670 been set. If it is, then we need to recalculate
671 the value of displayed. */
672static void
673indicator_display_check_recalc (gpointer key, gpointer value, gpointer userdata)
674{
675 if (!GPOINTER_TO_UINT(value)) {
676 return;
677 }
678
679 recalculate_indicator_displayed(INDICATE_SERVER(userdata), GPOINTER_TO_UINT(key));
680 return;
681}
682
683/* Look to see if a specific indicator ID has anyone watching
684 for it, and if not we need to set it to undisplayed. */
685static void
686recalculate_indicator_displayed (IndicateServer * server, guint id)
687{
688 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
689 GList * folkpointer;
690
691 for (folkpointer = priv->interestedfolks; folkpointer != NULL; folkpointer = g_list_next(folkpointer)) {
692 IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)folkpointer->data;
693 if (g_hash_table_lookup(folk->indicators_displayed, GUINT_TO_POINTER(id))) {
694 break;
695 }
696 }
697
698 if (folkpointer == NULL) {
699 /* We went through the list and no one cares about
700 this indicator. It's not displayed anymore. */
701 IndicateIndicator * indicator = get_indicator(server, id, NULL);
702 if (indicator != NULL) {
703 indicate_indicator_set_displayed(indicator, FALSE);
704 } else {
705 g_warning("I'm removing a displayed set from an indicator that doesn't seem to exist.");
706 }
707 }
708
709 return;
710}
711
712/* Get the next ID from the server */
594static guint713static guint
595get_next_id (IndicateServer * server)714get_next_id (IndicateServer * server)
596{715{
@@ -599,6 +718,10 @@
599 return priv->current_id;718 return priv->current_id;
600}719}
601720
721/* Allows a listener to show interest. First we look to see
722 if we've talked to this listener before and if so we just
723 mark their folk listing. If it changes the overall setting
724 then we need to signal. */
602static gboolean725static gboolean
603show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest)726show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest)
604{727{
@@ -615,7 +738,7 @@
615 GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal);738 GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal);
616 IndicateServerInterestedFolk * folkpointer = NULL;739 IndicateServerInterestedFolk * folkpointer = NULL;
617 if (entry == NULL) {740 if (entry == NULL) {
618 folkpointer = g_new(IndicateServerInterestedFolk, 1);741 folkpointer = g_new0(IndicateServerInterestedFolk, 1);
619 indicate_server_interested_folks_init(folkpointer, sender);742 indicate_server_interested_folks_init(folkpointer, sender);
620 priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);743 priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
621 } else {744 } else {
@@ -631,6 +754,9 @@
631 return TRUE;754 return TRUE;
632}755}
633756
757/* Removes an interest from a folk. It removes it from the
758 folk structure and then checks to see if that has global
759 effect, and handles it. */
634static gboolean760static gboolean
635remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest)761remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest)
636{762{
@@ -643,18 +769,24 @@
643769
644 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);770 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
645771
772 /* Figure out the folk that we're talking to. If we
773 have an entry for them, use it, otherwise we need
774 to create one. */
646 GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal);775 GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal);
647 IndicateServerInterestedFolk * folkpointer = NULL;776 IndicateServerInterestedFolk * folkpointer = NULL;
648 if (entry == NULL) {777 if (entry == NULL) {
649 folkpointer = g_new(IndicateServerInterestedFolk, 1);778 folkpointer = g_new0(IndicateServerInterestedFolk, 1);
650 indicate_server_interested_folks_init(folkpointer, sender);779 indicate_server_interested_folks_init(folkpointer, sender);
651 priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);780 priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
652 } else {781 } else {
653 folkpointer = (IndicateServerInterestedFolk *)entry->data;782 folkpointer = (IndicateServerInterestedFolk *)entry->data;
654 }783 }
655784
785 /* Set the interest for this guy */
656 indicate_server_interested_folks_set(folkpointer, interest, FALSE);786 indicate_server_interested_folks_set(folkpointer, interest, FALSE);
657787
788 /* Check to see if the interest has changed as a result of
789 this an announce it to the world */
658 if (priv->interests[interest]) {790 if (priv->interests[interest]) {
659 guint i;791 guint i;
660 for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {792 for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
@@ -675,6 +807,8 @@
675 return TRUE;807 return TRUE;
676}808}
677809
810/* Checks to see if a particular interest value is
811 set. Uses the interest cache. */
678static gboolean812static gboolean
679check_interest (IndicateServer * server, IndicateInterests interest)813check_interest (IndicateServer * server, IndicateInterests interest)
680{814{
@@ -682,12 +816,109 @@
682 return priv->interests[interest];816 return priv->interests[interest];
683}817}
684818
819/* Internal function that can be subclassed to get
820 the value of the max number of indicators. */
821static gint
822max_indicators_get (IndicateServer * server)
823{
824 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
825 if (priv->max_indicators == MAX_INDICATORS_UNSET) {
826 return MAX_INDICATORS_INFINITE;
827 } else {
828 return priv->max_indicators;
829 }
830}
831
832/* Internal function to set the number of max indicators
833 from a particular listener. */
834static gboolean
835max_indicators_set (IndicateServer * server, gchar * sender, gint max)
836{
837 g_return_val_if_fail(max >= MAX_INDICATORS_INFINITE, FALSE);
838
839 IndicateServerInterestedFolk localfolk;
840 localfolk.sender = sender;
841
842 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
843
844 /* Figure out the folk that we're talking to. If we
845 have an entry for them, use it, otherwise we need
846 to create one. */
847 GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal);
848 IndicateServerInterestedFolk * folkpointer = NULL;
849 if (entry == NULL) {
850 folkpointer = g_new0(IndicateServerInterestedFolk, 1);
851 indicate_server_interested_folks_init(folkpointer, sender);
852 priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
853 } else {
854 folkpointer = (IndicateServerInterestedFolk *)entry->data;
855 }
856
857 /* If there's a change going on... */
858 if (max != folkpointer->max_indicators) {
859 gboolean recalculate = FALSE;
860 /* If this guy is setting it to infinite or is
861 increasing the number */
862 if ((max == -1 && priv->max_indicators != -1) || max > priv->max_indicators) {
863 recalculate = TRUE;
864 }
865
866 /* Or if potentially we were the ones setting the
867 value for everyone */
868 if (priv->max_indicators == folkpointer->max_indicators) {
869 recalculate = TRUE;
870 }
871
872 folkpointer->max_indicators = max;
873 if (recalculate) {
874 recalculate_max_indicators(server);
875 }
876 }
877
878 return TRUE;
879}
880
881/* Look through all the folks and trying to figure out
882 what the max should be. Signal if it changes. */
883static void
884recalculate_max_indicators (IndicateServer * server)
885{
886 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
887
888 /* Let's talk to all the folks and see what they
889 think the max should be. */
890 GList * folkitem;
891 gint newmax = MAX_INDICATORS_UNSET;
892 for (folkitem = priv->interestedfolks; folkitem != NULL; folkitem = g_list_next(folkitem)) {
893 IndicateServerInterestedFolk * thisfolk = (IndicateServerInterestedFolk *)folkitem->data;
894 if (thisfolk->max_indicators == MAX_INDICATORS_UNSET) {
895 continue;
896 }
897 if (thisfolk->max_indicators == MAX_INDICATORS_INFINITE) {
898 newmax = MAX_INDICATORS_INFINITE;
899 break;
900 }
901 if (thisfolk->max_indicators > newmax) {
902 newmax = thisfolk->max_indicators;
903 }
904 }
905
906 /* Okay, what ever happened, now it's changing
907 things and we need to tell everyone. */
908 if (priv->max_indicators != newmax) {
909 priv->max_indicators = newmax;
910 g_signal_emit(G_OBJECT(server), signals[MAX_INDICATORS_CHANGED], 0, newmax, TRUE);
911 }
912
913 return;
914}
915
685static void916static void
686indicator_show_cb (IndicateIndicator * indicator, IndicateServer * server)917indicator_show_cb (IndicateIndicator * indicator, IndicateServer * server)
687{918{
688 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);919 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
689 priv->num_hidden--;920 priv->num_hidden--;
690 g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE);921 g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), TRUE);
691 return;922 return;
692}923}
693924
@@ -696,7 +927,7 @@
696{927{
697 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);928 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
698 priv->num_hidden++;929 priv->num_hidden++;
699 g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE);930 g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), TRUE);
700 return;931 return;
701}932}
702933
@@ -730,7 +961,7 @@
730 if (!indicate_indicator_is_visible(indicator)) {961 if (!indicate_indicator_is_visible(indicator)) {
731 priv->num_hidden++;962 priv->num_hidden++;
732 } else {963 } else {
733 g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE);964 g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), TRUE);
734 }965 }
735966
736 g_signal_connect(indicator, INDICATE_INDICATOR_SIGNAL_SHOW, G_CALLBACK(indicator_show_cb), server);967 g_signal_connect(indicator, INDICATE_INDICATOR_SIGNAL_SHOW, G_CALLBACK(indicator_show_cb), server);
@@ -758,7 +989,7 @@
758989
759 priv->indicators = g_slist_remove(priv->indicators, indicator);990 priv->indicators = g_slist_remove(priv->indicators, indicator);
760 if (indicate_indicator_is_visible(indicator)) {991 if (indicate_indicator_is_visible(indicator)) {
761 g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE);992 g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), TRUE);
762 } else {993 } else {
763 priv->num_hidden--;994 priv->num_hidden--;
764 }995 }
@@ -883,54 +1114,6 @@
883 return TRUE;1114 return TRUE;
884}1115}
8851116
886typedef struct {
887 gchar * type;
888 guint count;
889} count_by_t;
890
891static void
892count_by_type (IndicateIndicator * indicator, count_by_t * cbt)
893{
894 g_return_if_fail(INDICATE_IS_INDICATOR(indicator));
895 if (!indicate_indicator_is_visible(indicator)) {
896 return;
897 }
898
899 const gchar * type = indicate_indicator_get_indicator_type(indicator);
900 /* g_debug("Looking for indicator of type '%s' and have type '%s'", cbt->type, type); */
901
902 if (type == NULL && cbt->type == NULL) {
903 cbt->count++;
904 } else if (type == NULL || cbt->type == NULL) {
905 } else if (!g_strcmp0(type, cbt->type)) {
906 cbt->count++;
907 }
908
909 return;
910}
911
912static gboolean
913get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error)
914{
915 /* g_debug("get_indicator_count_by_type: '%s'", type); */
916 count_by_t cbt;
917 cbt.type = type;
918 cbt.count = 0;
919
920 /* Handle the NULL string case as NULL itself, we're a big
921 boy language; we have pointers. */
922 if (cbt.type != NULL && cbt.type[0] == '\0') {
923 cbt.type = NULL;
924 }
925
926 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
927
928 g_slist_foreach(priv->indicators, (GFunc)count_by_type, &cbt);
929 *count = cbt.count;
930
931 return TRUE;
932}
933
934static gboolean1117static gboolean
935get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error)1118get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error)
936{1119{
@@ -956,44 +1139,6 @@
956 return TRUE;1139 return TRUE;
957}1140}
9581141
959static gboolean
960get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error)
961{
962 g_return_val_if_fail(INDICATE_IS_SERVER(server), TRUE);
963
964 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
965 g_return_val_if_fail(class->get_indicator_count != NULL, TRUE);
966
967 if (type != NULL && type[0] == '\0') {
968 type = NULL;
969 }
970
971 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
972
973 /* Can't be larger than this and it's not worth the reallocation
974 for the small number we have. The memory isn't worth the time. */
975 *indicators = g_array_sized_new(FALSE, FALSE, sizeof(guint), g_slist_length(priv->indicators) - priv->num_hidden);
976
977 GSList * iter;
978 int i;
979 for (iter = priv->indicators, i = 0; iter != NULL; iter = iter->next) {
980 IndicateIndicator * indicator = INDICATE_INDICATOR(iter->data);
981 if (indicate_indicator_is_visible(indicator)) {
982 const gchar * itype = indicate_indicator_get_indicator_type(indicator);
983 guint id = indicate_indicator_get_id(indicator);
984
985 if (type == NULL && itype == NULL) {
986 g_array_insert_val(*indicators, i++, id);
987 } else if (type == NULL || itype == NULL) {
988 } else if (!g_strcmp0(type, itype)) {
989 g_array_insert_val(*indicators, i++, id);
990 }
991 }
992 }
993
994 return TRUE;
995}
996
997static IndicateIndicator *1142static IndicateIndicator *
998get_indicator (IndicateServer * server, guint id, GError **error)1143get_indicator (IndicateServer * server, guint id, GError **error)
999{1144{
@@ -1087,6 +1232,45 @@
1087 return TRUE;1232 return TRUE;
1088}1233}
10891234
1235/* A function representing when an indicator is shown
1236 to the user in some form. First it sees if we've talked
1237 to this listener before and uses that entry. Otherwise, we
1238 build one. If we're displaying it, things are good, we can
1239 just set that. If we're not, then we need to check to see
1240 if anyone else is before continuing. */
1241static gboolean
1242indicator_displayed (IndicateServer * server, gchar * sender, guint id, gboolean displayed, GError ** error)
1243{
1244 IndicateServerInterestedFolk localfolk;
1245 localfolk.sender = sender;
1246
1247 IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
1248
1249 GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal);
1250 IndicateServerInterestedFolk * folkpointer = NULL;
1251 if (entry == NULL) {
1252 folkpointer = g_new0(IndicateServerInterestedFolk, 1);
1253 indicate_server_interested_folks_init(folkpointer, sender);
1254 priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
1255 } else {
1256 folkpointer = (IndicateServerInterestedFolk *)entry->data;
1257 }
1258
1259 g_hash_table_insert(folkpointer->indicators_displayed, GUINT_TO_POINTER(id), GUINT_TO_POINTER(displayed));
1260
1261 if (displayed) {
1262 IndicateIndicator * indicator = get_indicator(server, id, error);
1263 if (indicator == NULL) {
1264 return FALSE;
1265 }
1266
1267 indicate_indicator_set_displayed(indicator, displayed);
1268 } else {
1269 recalculate_indicator_displayed(server, id);
1270 }
1271
1272 return TRUE;
1273}
10901274
1091/* Virtual Functions */1275/* Virtual Functions */
1092gboolean 1276gboolean
@@ -1111,27 +1295,6 @@
1111}1295}
11121296
1113gboolean 1297gboolean
1114_indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error)
1115{
1116 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
1117
1118 if (class != NULL && class->get_indicator_count_by_type != NULL) {
1119 return class->get_indicator_count_by_type (server, type, count, error);
1120 }
1121
1122 if (error) {
1123 g_set_error(error,
1124 indicate_server_error_quark(),
1125 NO_GET_INDICATOR_COUNT_BY_TYPE,
1126 "get_indicator_count_by_type function doesn't exist for this server class: %s",
1127 G_OBJECT_TYPE_NAME(server));
1128 return FALSE;
1129 }
1130
1131 return TRUE;
1132}
1133
1134gboolean
1135_indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error)1298_indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error)
1136{1299{
1137 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);1300 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
@@ -1153,27 +1316,6 @@
1153}1316}
11541317
1155gboolean 1318gboolean
1156_indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error)
1157{
1158 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
1159
1160 if (class != NULL && class->get_indicator_list_by_type != NULL) {
1161 return class->get_indicator_list_by_type (server, type, indicators, error);
1162 }
1163
1164 if (error) {
1165 g_set_error(error,
1166 indicate_server_error_quark(),
1167 NO_GET_INDICATOR_LIST_BY_TYPE,
1168 "get_indicator_list_by_type function doesn't exist for this server class: %s",
1169 G_OBJECT_TYPE_NAME(server));
1170 return FALSE;
1171 }
1172
1173 return TRUE;
1174}
1175
1176gboolean
1177_indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error)1319_indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error)
1178{1320{
1179 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);1321 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
@@ -1257,6 +1399,36 @@
1257 return TRUE;1399 return TRUE;
1258}1400}
12591401
1402/* DBus function to wrap a virtual function call so that
1403 it can be subclassed if someone so chooses */
1404gboolean
1405_indicate_server_indicator_displayed (IndicateServer * server, guint id, gboolean displayed, DBusGMethodInvocation * method)
1406{
1407 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
1408
1409 if (class != NULL && class->indicator_displayed != NULL) {
1410 GError * error = NULL;
1411 if (class->indicator_displayed (server, dbus_g_method_get_sender(method), id, displayed, &error)) {
1412 dbus_g_method_return(method);
1413 return TRUE;
1414 } else {
1415 dbus_g_method_return_error(method, error);
1416 g_error_free(error);
1417 return FALSE;
1418 }
1419 }
1420
1421 GError * error = NULL;
1422 g_set_error(&error,
1423 indicate_server_error_quark(),
1424 NO_INDICATOR_DISPLAYED,
1425 "indicator_displayed function doesn't exist for this server class: %s",
1426 G_OBJECT_TYPE_NAME(server));
1427 dbus_g_method_return_error(method, error);
1428 g_error_free(error);
1429 return FALSE;
1430}
1431
1260/**1432/**
1261 indicate_server_get_next_id:1433 indicate_server_get_next_id:
1262 @server: The #IndicateServer the ID will be on1434 @server: The #IndicateServer the ID will be on
@@ -1316,10 +1488,10 @@
1316 } else {1488 } else {
1317 GError * error;1489 GError * error;
1318 g_set_error(&error,1490 g_set_error(&error,
1319 indicate_server_error_quark(),1491 indicate_server_error_quark(),
1320 SHOW_INTEREST_FAILED,1492 SHOW_INTEREST_FAILED,
1321 "Unable to show interest: %s",1493 "Unable to show interest: %s",
1322 interest);1494 interest);
1323 dbus_g_method_return_error(method, error);1495 dbus_g_method_return_error(method, error);
1324 g_error_free(error);1496 g_error_free(error);
1325 return FALSE;1497 return FALSE;
@@ -1328,10 +1500,10 @@
13281500
1329 GError * error;1501 GError * error;
1330 g_set_error(&error,1502 g_set_error(&error,
1331 indicate_server_error_quark(),1503 indicate_server_error_quark(),
1332 NO_SHOW_INTEREST,1504 NO_SHOW_INTEREST,
1333 "show_interest function doesn't exist for this server class: %s",1505 "show_interest function doesn't exist for this server class: %s",
1334 G_OBJECT_TYPE_NAME(server));1506 G_OBJECT_TYPE_NAME(server));
1335 dbus_g_method_return_error(method, error);1507 dbus_g_method_return_error(method, error);
1336 g_error_free(error);1508 g_error_free(error);
1337 return FALSE;1509 return FALSE;
@@ -1370,6 +1542,39 @@
1370 return FALSE;1542 return FALSE;
1371}1543}
13721544
1545gboolean
1546_indicate_server_set_max_indicators (IndicateServer * server, gint max, DBusGMethodInvocation * method)
1547{
1548 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
1549
1550 if (class != NULL && class->max_indicators_set != NULL) {
1551 if (class->max_indicators_set (server, dbus_g_method_get_sender(method), max)){
1552 dbus_g_method_return(method);
1553 return TRUE;
1554 } else {
1555 GError * error;
1556 g_set_error(&error,
1557 indicate_server_error_quark(),
1558 MAX_INDICATORS_SET_FAILED,
1559 "Unable to set max indicators: %d",
1560 max);
1561 dbus_g_method_return_error(method, error);
1562 g_error_free(error);
1563 return FALSE;
1564 }
1565 }
1566
1567 GError * error;
1568 g_set_error(&error,
1569 indicate_server_error_quark(),
1570 NO_MAX_INDICATORS_SET,
1571 "max_indicators_set function doesn't exist for this server class: %s",
1572 G_OBJECT_TYPE_NAME(server));
1573 dbus_g_method_return_error(method, error);
1574 g_error_free(error);
1575 return FALSE;
1576}
1577
1373/**1578/**
1374 indicate_server_check_interest:1579 indicate_server_check_interest:
1375 @server: The #IndicateServer being checked1580 @server: The #IndicateServer being checked
@@ -1394,85 +1599,40 @@
1394 return FALSE;1599 return FALSE;
1395}1600}
13961601
1397/* Signal emission functions for sub-classes of the server */1602/**
13981603 indicate_server_get_max_indicators:
1399/**1604 @server: The #IndicateServer being checked
1400 indicate_server_emit_indicator_added:1605
1401 @server: The #IndicateServer being represented1606 This function looks at everyone listening and determines
1402 @id: The ID of the indicator being added1607 the max number of indicators that can be shown to anyone.
1403 @type: The type of the indicator1608
14041609 Return value: A max number or -1 for unlimited.
1405 This function emits the #IndicateServer::indicator-added signal and is1610*/
1406 used by subclasses.1611gint
1407*/1612indicate_server_get_max_indicators (IndicateServer * server)
1408void 1613{
1409indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type)1614 IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
1410{1615
1411 g_return_if_fail (INDICATE_IS_SERVER (server));1616 if (class != NULL && class->max_indicators_get != NULL) {
1412 g_return_if_fail (type);1617 return class->max_indicators_get (server);
14131618 }
1414 g_signal_emit(server, signals[INDICATOR_ADDED], 0, id, type);1619
1415}1620 g_warning("get_max_indicators function not implemented in this server class: %s", G_OBJECT_TYPE_NAME(server));
14161621 return -1;
1417/**
1418 indicate_server_emit_indicator_removed:
1419 @server: The #IndicateServer being represented
1420 @id: The ID of the indicator being removed
1421 @type: The type of the indicator
1422
1423 This function emits the #IndicateServer::indicator-removed signal and is
1424 used by subclasses.
1425*/
1426void
1427indicate_server_emit_indicator_removed (IndicateServer *server, guint id, const gchar *type)
1428{
1429 g_return_if_fail (INDICATE_IS_SERVER (server));
1430 g_return_if_fail (type);
1431
1432 g_signal_emit(server, signals[INDICATOR_REMOVED], 0, id, type);
1433}
1434
1435/**
1436 indicate_server_emit_indicator_modified:
1437 @server: The #IndicateServer being represented
1438 @id: The ID of the indicator with the modified property
1439 @property: The name of the property being modified
1440
1441 This function emits the #IndicateServer::indicator-modified signal and is
1442 used by subclasses.
1443*/
1444void
1445indicate_server_emit_indicator_modified (IndicateServer *server, guint id, const gchar *property)
1446{
1447 g_return_if_fail (INDICATE_IS_SERVER (server));
1448 g_return_if_fail (property);
1449
1450 g_signal_emit(server, signals[INDICATOR_MODIFIED], 0, id, property);
1451}
1452
1453/**
1454 indicate_server_emit_server_display:
1455 @server: The #IndicateServer being displayed
1456
1457 This function emits the #IndicateServer::server-display signal and is
1458 used by subclasses.
1459*/
1460void
1461indicate_server_emit_server_display (IndicateServer *server)
1462{
1463 g_return_if_fail (INDICATE_IS_SERVER (server));
1464
1465 g_signal_emit(server, signals[SERVER_DISPLAY], 0, TRUE);
1466}1622}
14671623
1468/* *** Folks stuff *** */1624/* *** Folks stuff *** */
14691625
1626/* This checks for folk by looking at the sender value
1627 and sees if we can find any that have the same sender. */
1470static gint1628static gint
1471indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b)1629indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b)
1472{1630{
1473 return g_strcmp0(((IndicateServerInterestedFolk *)a)->sender,((IndicateServerInterestedFolk *)b)->sender);1631 return g_strcmp0(((IndicateServerInterestedFolk *)a)->sender,((IndicateServerInterestedFolk *)b)->sender);
1474}1632}
14751633
1634/* Creates a IndicateServerInterestedFolk structure and
1635 initializes the default values to reasonable defaults. */
1476static void1636static void
1477indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender)1637indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender)
1478{1638{
@@ -1483,9 +1643,14 @@
1483 folk->interests[i] = FALSE;1643 folk->interests[i] = FALSE;
1484 }1644 }
14851645
1646 folk->max_indicators = MAX_INDICATORS_UNSET;
1647
1648 folk->indicators_displayed = g_hash_table_new(g_direct_hash, g_direct_equal);
1649
1486 return;1650 return;
1487}1651}
14881652
1653/* Identifies an interest in the folk. */
1489static void1654static void
1490indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value)1655indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value)
1491{1656{
@@ -1493,6 +1658,8 @@
1493 return;1658 return;
1494}1659}
14951660
1661/* Copies the interest table from a folk structure into a
1662 generic gboolean array of length INDICATE_INTEREST_LAST */
1496static void1663static void
1497indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests)1664indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests)
1498{1665{
@@ -1506,11 +1673,15 @@
1506 return;1673 return;
1507}1674}
15081675
1676/* Destroys all the internal parts of the IndicateServerInterestedFolk
1677 and then destroys the structure itself */
1509static void1678static void
1510indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk)1679indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk)
1511{1680{
1512 g_free(folk->sender);1681 g_free(folk->sender);
1682 g_hash_table_destroy(folk->indicators_displayed);
1513 g_free(folk);1683 g_free(folk);
1514 return;1684 return;
1515}1685}
1686
1516/* *** End Folks *** */1687/* *** End Folks *** */
15171688
=== modified file 'libindicate/server.h'
--- libindicate/server.h 2009-08-03 17:50:57 +0000
+++ libindicate/server.h 2009-09-08 21:57:25 +0000
@@ -47,14 +47,26 @@
4747
48#define INDICATE_SERVER_INDICATOR_NULL (0)48#define INDICATE_SERVER_INDICATOR_NULL (0)
4949
50#define INDICATE_SERVER_SIGNAL_INDICATOR_ADDED "indicator-added"50#define INDICATE_SERVER_SIGNAL_INDICATOR_ADDED "indicator-new"
51#define INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED "indicator-removed"51#define INDICATE_SERVER_SIGNAL_INDICATOR_ADDED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_INDICATOR_ADDED, INDICATE_TYPE_SERVER))
52#define INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED "indicator-modified"52#define INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED "indicator-delete"
53#define INDICATE_SERVER_SIGNAL_SERVER_SHOW "server-show"53#define INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED, INDICATE_TYPE_SERVER))
54#define INDICATE_SERVER_SIGNAL_SERVER_HIDE "server-hide"54#define INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED "indicator-modified"
55#define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY "server-display"55#define INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED, INDICATE_TYPE_SERVER))
56#define INDICATE_SERVER_SIGNAL_INTEREST_ADDED "interest-added"56#define INDICATE_SERVER_SIGNAL_SERVER_SHOW "server-show"
57#define INDICATE_SERVER_SIGNAL_INTEREST_REMOVED "interest-removed"57#define INDICATE_SERVER_SIGNAL_SERVER_SHOW_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_SERVER_SHOW, INDICATE_TYPE_SERVER))
58#define INDICATE_SERVER_SIGNAL_SERVER_HIDE "server-hide"
59#define INDICATE_SERVER_SIGNAL_SERVER_HIDE_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_SERVER_HIDE, INDICATE_TYPE_SERVER))
60#define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY "server-display"
61#define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_SERVER_DISPLAY, INDICATE_TYPE_SERVER))
62#define INDICATE_SERVER_SIGNAL_INTEREST_ADDED "interest-added"
63#define INDICATE_SERVER_SIGNAL_INTEREST_ADDED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_INTEREST_ADDED, INDICATE_TYPE_SERVER))
64#define INDICATE_SERVER_SIGNAL_INTEREST_REMOVED "interest-removed"
65#define INDICATE_SERVER_SIGNAL_INTEREST_REMOVED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_INTEREST_REMOVED, INDICATE_TYPE_SERVER))
66#define INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED "max-indicators-changed"
67#define INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED, INDICATE_TYPE_SERVER))
68#define INDICATE_SERVER_SIGNAL_SERVER_COUNT_CHANGED "server-count-changed"
69#define INDICATE_SERVER_SIGNAL_SERVER_COUNT_CHANGED_ID (g_signal_lookup(INDICATE_SERVER_SIGNAL_SERVER_COUNT_CHANGED, INDICATE_TYPE_SERVER))
5870
59/**71/**
60 IndicateServer:72 IndicateServer:
@@ -84,13 +96,11 @@
84 @server_display: Slot for #IndicateServer::server-display.96 @server_display: Slot for #IndicateServer::server-display.
85 @interest_added: Slot for #IndicateServer::interest-added.97 @interest_added: Slot for #IndicateServer::interest-added.
86 @interest_removed: Slot for #IndicateServer::interest-removed.98 @interest_removed: Slot for #IndicateServer::interest-removed.
99 @max_indicators_changed: Slot for #IndicateServer::max-indicators-changed.
100 @server_count_changed: Slot for #IndicateServer::server-count-changed.
87 @get_indicator_count: Returns the number of indicators that are visible101 @get_indicator_count: Returns the number of indicators that are visible
88 on the bus. Hidden indicators should not be counted.102 on the bus. Hidden indicators should not be counted.
89 @get_indicator_count_by_type: Returns the number of indicators that are
90 of a given type and visible on the bus.
91 @get_indicator_list: List all of the indicators that are visible.103 @get_indicator_list: List all of the indicators that are visible.
92 @get_indicator_list_by_type: List all of the indicators of a given
93 type that are visible.
94 @get_indicator_property: Get a property from a particular indicator.104 @get_indicator_property: Get a property from a particular indicator.
95 @get_indicator_property_group: Get the values for a set of properties105 @get_indicator_property_group: Get the values for a set of properties
96 as an array of entries, returning an array as well.106 as an array of entries, returning an array as well.
@@ -98,6 +108,8 @@
98 on a particular indicator.108 on a particular indicator.
99 @show_indicator_to_user: Respond to someone on the bus asking to show109 @show_indicator_to_user: Respond to someone on the bus asking to show
100 a particular indicator to the user.110 a particular indicator to the user.
111 @indicator_displayed: An indicator has been visualized by the listener
112 or it hasn't. This function tracks that.
101 @get_next_id: Get the next unused indicator ID.113 @get_next_id: Get the next unused indicator ID.
102 @show_interest: React to someone signifying that they are interested114 @show_interest: React to someone signifying that they are interested
103 in this server.115 in this server.
@@ -105,6 +117,10 @@
105 server, remove it's interest.117 server, remove it's interest.
106 @check_interest: Check to see if anyone on the bus is interested in this118 @check_interest: Check to see if anyone on the bus is interested in this
107 server for a particular feature.119 server for a particular feature.
120 @max_indicators_set: Set the maximum number of indicators that a
121 given listener can display.
122 @max_indicators_get: Gets the maximum number of indicators from all
123 listeners that care about this server.
108 @indicate_server_reserved1: Reserved for future use124 @indicate_server_reserved1: Reserved for future use
109 @indicate_server_reserved2: Reserved for future use125 @indicate_server_reserved2: Reserved for future use
110 @indicate_server_reserved3: Reserved for future use126 @indicate_server_reserved3: Reserved for future use
@@ -120,28 +136,31 @@
120 GObjectClass parent;136 GObjectClass parent;
121137
122 /* Signals */138 /* Signals */
123 void (* indicator_added) (IndicateServer * server, guint id, gchar * type);139 void (* indicator_added) (IndicateServer * server, guint id);
124 void (* indicator_removed) (IndicateServer * server, guint id, gchar * type);140 void (* indicator_removed) (IndicateServer * server, guint id);
125 void (* indicator_modified) (IndicateServer * server, guint id, gchar * property);141 void (* indicator_modified) (IndicateServer * server, guint id, gchar * property);
126 void (* server_show) (IndicateServer * server, gchar * type);142 void (* server_show) (IndicateServer * server, gchar * type);
127 void (* server_hide) (IndicateServer * server, gchar * type);143 void (* server_hide) (IndicateServer * server, gchar * type);
128 void (* server_display) (IndicateServer * server);144 void (* server_display) (IndicateServer * server);
129 void (* interest_added) (IndicateServer * server, IndicateInterests interest);145 void (* interest_added) (IndicateServer * server, IndicateInterests interest);
130 void (* interest_removed) (IndicateServer * server, IndicateInterests interest);146 void (* interest_removed) (IndicateServer * server, IndicateInterests interest);
147 void (* max_indicators_changed) (IndicateServer * server, gint max);
148 void (* server_count_changed) (IndicateServer * server, guint count);
131149
132 /* Virtual Functions */150 /* Virtual Functions */
133 gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error);151 gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error);
134 gboolean (*get_indicator_count_by_type) (IndicateServer * server, gchar * type, guint * count, GError **error);
135 gboolean (*get_indicator_list) (IndicateServer * server, GArray ** indicators, GError ** error);152 gboolean (*get_indicator_list) (IndicateServer * server, GArray ** indicators, GError ** error);
136 gboolean (*get_indicator_list_by_type) (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error);
137 gboolean (*get_indicator_property) (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error);153 gboolean (*get_indicator_property) (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error);
138 gboolean (*get_indicator_property_group) (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);154 gboolean (*get_indicator_property_group) (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);
139 gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error);155 gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error);
140 gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, GError ** error);156 gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, GError ** error);
157 gboolean (*indicator_displayed) (IndicateServer * server, gchar * sender, guint id, gboolean displayed, GError ** error);
141 guint (*get_next_id) (IndicateServer * server);158 guint (*get_next_id) (IndicateServer * server);
142 gboolean (*show_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest);159 gboolean (*show_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest);
143 gboolean (*remove_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest);160 gboolean (*remove_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest);
144 gboolean (*check_interest) (IndicateServer * server, IndicateInterests interest);161 gboolean (*check_interest) (IndicateServer * server, IndicateInterests interest);
162 gboolean (*max_indicators_set) (IndicateServer * server, gchar * sender, gint max);
163 gint (*max_indicators_get) (IndicateServer * server);
145164
146 /* Reserver for future use */165 /* Reserver for future use */
147 void (*indicate_server_reserved1)(void);166 void (*indicate_server_reserved1)(void);
@@ -159,6 +178,7 @@
159 * out of */178 * out of */
160void indicate_server_set_desktop_file (IndicateServer * server, const gchar * path);179void indicate_server_set_desktop_file (IndicateServer * server, const gchar * path);
161void indicate_server_set_type (IndicateServer * server, const gchar * type);180void indicate_server_set_type (IndicateServer * server, const gchar * type);
181void indicate_server_set_count (IndicateServer * server, guint count);
162182
163/* Show and hide the server on DBus, this allows for the server to183/* Show and hide the server on DBus, this allows for the server to
164 * be created, change the object, and then shown. If for some184 * be created, change the object, and then shown. If for some
@@ -176,13 +196,8 @@
176196
177/* Check to see if there is someone, out there, who likes this */197/* Check to see if there is someone, out there, who likes this */
178gboolean indicate_server_check_interest (IndicateServer * server, IndicateInterests interest);198gboolean indicate_server_check_interest (IndicateServer * server, IndicateInterests interest);
179199/* See how many indicators we can show */
180200gint indicate_server_get_max_indicators (IndicateServer * server);
181/* Signal emission functions for sub-classes of the server */
182void indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type);
183void indicate_server_emit_indicator_removed (IndicateServer *server, guint id, const gchar *type);
184void indicate_server_emit_indicator_modified (IndicateServer *server, guint id, const gchar *property);
185void indicate_server_emit_server_display (IndicateServer *server);
186201
187/**202/**
188 SECTION:server203 SECTION:server
189204
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2009-04-27 15:48:38 +0000
+++ tests/Makefile.am 2009-09-03 22:04:01 +0000
@@ -3,7 +3,11 @@
3 test_simple \3 test_simple \
4 test_interests \4 test_interests \
5 test_interests_multi \5 test_interests_multi \
6 test_thousand_indicators6 test_thousand_indicators \
7 test_max_indicators \
8 test_max_indicators_repeat \
9 test_indicator_display \
10 test_indicator_display_half
711
8libexec_PROGRAMS = \12libexec_PROGRAMS = \
9 test-interests-client \13 test-interests-client \
@@ -16,7 +20,14 @@
16 test-thousand-indicators-client \20 test-thousand-indicators-client \
17 test-thousand-indicators-server \21 test-thousand-indicators-server \
18 test-simple-client \22 test-simple-client \
19 test-simple-server23 test-simple-server \
24 test-max-indicators-server-repeat \
25 test-max-indicators-server \
26 test-max-indicators-client \
27 test-indicator-display-server \
28 test-indicator-display-client \
29 test-indicator-display-half-server \
30 test-indicator-display-half-client
2031
21EXTRA_DIST = \32EXTRA_DIST = \
22 $(TESTS)33 $(TESTS)
@@ -139,3 +150,81 @@
139 ../libindicate/libindicate.la \150 ../libindicate/libindicate.la \
140 $(LIBINDICATE_LIBS)151 $(LIBINDICATE_LIBS)
141152
153test_max_indicators: test-max-indicators-client test-max-indicators-server
154
155test_max_indicators_client_SOURCES = \
156 test-max-indicators-client.c test-max-indicators-list.h
157
158test_max_indicators_client_CFLAGS = \
159 $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
160
161test_max_indicators_client_LDADD = \
162 ../libindicate/libindicate.la \
163 $(LIBINDICATE_LIBS)
164
165test_max_indicators_server_SOURCES = \
166 test-max-indicators-server.c test-max-indicators-list.h
167
168test_max_indicators_server_CFLAGS = \
169 $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
170
171test_max_indicators_server_LDADD = \
172 ../libindicate/libindicate.la \
173 $(LIBINDICATE_LIBS)
174
175test_max_indicators_repeat: test-max-indicators-client test-max-indicators-server-repeat
176
177test_max_indicators_server_repeat_SOURCES = \
178 test-max-indicators-server-repeat.c test-max-indicators-list.h
179
180test_max_indicators_server_repeat_CFLAGS = \
181 $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
182
183test_max_indicators_server_repeat_LDADD = \
184 ../libindicate/libindicate.la \
185 $(LIBINDICATE_LIBS)
186
187test_indicator_display: test-indicator-display-client test-indicator-display-server
188
189test_indicator_display_client_SOURCES = \
190 test-indicator-display-client.c
191
192test_indicator_display_client_CFLAGS = \
193 $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
194
195test_indicator_display_client_LDADD = \
196 ../libindicate/libindicate.la \
197 $(LIBINDICATE_LIBS)
198
199test_indicator_display_server_SOURCES = \
200 test-indicator-display-server.c
201
202test_indicator_display_server_CFLAGS = \
203 $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
204
205test_indicator_display_server_LDADD = \
206 ../libindicate/libindicate.la \
207 $(LIBINDICATE_LIBS)
208
209test_indicator_display_half: test-indicator-display-half-client test-indicator-display-half-server
210
211test_indicator_display_half_client_SOURCES = \
212 test-indicator-display-half-client.c
213
214test_indicator_display_half_client_CFLAGS = \
215 $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
216
217test_indicator_display_half_client_LDADD = \
218 ../libindicate/libindicate.la \
219 $(LIBINDICATE_LIBS)
220
221test_indicator_display_half_server_SOURCES = \
222 test-indicator-display-half-server.c
223
224test_indicator_display_half_server_CFLAGS = \
225 $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
226
227test_indicator_display_half_server_LDADD = \
228 ../libindicate/libindicate.la \
229 $(LIBINDICATE_LIBS)
230
142231
=== added file 'tests/test-indicator-display-client.c'
--- tests/test-indicator-display-client.c 1970-01-01 00:00:00 +0000
+++ tests/test-indicator-display-client.c 2009-09-03 21:32:22 +0000
@@ -0,0 +1,64 @@
1
2#include <glib.h>
3#include "libindicate/indicator.h"
4#include "libindicate/server.h"
5#include "libindicate/interests.h"
6
7#define MAX_INDICATOR_COUNT 100
8
9static gboolean passed = TRUE;
10static GMainLoop * mainloop = NULL;
11static int count = 0;
12
13
14static void
15indicator_displayed (IndicateIndicator * indicator, gboolean displayed, gpointer user_data)
16{
17 g_debug("Indicator displayed: %s", displayed ? "true" : "false");
18 if (displayed) {
19 count++;
20 }
21
22 return;
23}
24
25static gboolean
26done_timeout_cb (gpointer data)
27{
28 g_debug("%d of %d indicators displayed", count, MAX_INDICATOR_COUNT);
29 if (count != MAX_INDICATOR_COUNT) {
30 passed = FALSE;
31 }
32 g_main_loop_quit(mainloop);
33 return FALSE;
34}
35
36static guint indicators = 0;
37static gboolean
38idle_func (gpointer data)
39{
40 if (indicators == MAX_INDICATOR_COUNT) {
41 return FALSE;
42 }
43
44 indicators++;
45 IndicateIndicator * indicator = indicate_indicator_new();
46 g_signal_connect(G_OBJECT(indicator), INDICATE_INDICATOR_SIGNAL_DISPLAYED, G_CALLBACK(indicator_displayed), NULL);
47 indicate_indicator_show(indicator);
48
49 return TRUE;
50}
51
52int
53main (int argc, char * argv)
54{
55 g_type_init();
56
57 g_idle_add(idle_func, NULL);
58 g_timeout_add(MAX_INDICATOR_COUNT * 10, done_timeout_cb, NULL);
59
60 mainloop = g_main_loop_new(NULL, FALSE);
61 g_main_loop_run(mainloop);
62
63 return !passed;
64}
065
=== added file 'tests/test-indicator-display-half-client.c'
--- tests/test-indicator-display-half-client.c 1970-01-01 00:00:00 +0000
+++ tests/test-indicator-display-half-client.c 2009-09-03 22:01:41 +0000
@@ -0,0 +1,64 @@
1
2#include <glib.h>
3#include "libindicate/indicator.h"
4#include "libindicate/server.h"
5#include "libindicate/interests.h"
6
7#define MAX_INDICATOR_COUNT 100
8
9static gboolean passed = TRUE;
10static GMainLoop * mainloop = NULL;
11static int count = 0;
12
13
14static void
15indicator_displayed (IndicateIndicator * indicator, gboolean displayed, gpointer user_data)
16{
17 g_debug("Indicator displayed: %s", displayed ? "true" : "false");
18 if (displayed) {
19 count++;
20 }
21
22 return;
23}
24
25static gboolean
26done_timeout_cb (gpointer data)
27{
28 g_debug("%d of %d indicators displayed", count, MAX_INDICATOR_COUNT / 2);
29 if (count != MAX_INDICATOR_COUNT / 2) {
30 passed = FALSE;
31 }
32 g_main_loop_quit(mainloop);
33 return FALSE;
34}
35
36static guint indicators = 0;
37static gboolean
38idle_func (gpointer data)
39{
40 if (indicators == MAX_INDICATOR_COUNT) {
41 return FALSE;
42 }
43
44 indicators++;
45 IndicateIndicator * indicator = indicate_indicator_new();
46 g_signal_connect(G_OBJECT(indicator), INDICATE_INDICATOR_SIGNAL_DISPLAYED, G_CALLBACK(indicator_displayed), NULL);
47 indicate_indicator_show(indicator);
48
49 return TRUE;
50}
51
52int
53main (int argc, char * argv)
54{
55 g_type_init();
56
57 g_idle_add(idle_func, NULL);
58 g_timeout_add(MAX_INDICATOR_COUNT * 10, done_timeout_cb, NULL);
59
60 mainloop = g_main_loop_new(NULL, FALSE);
61 g_main_loop_run(mainloop);
62
63 return !passed;
64}
065
=== added file 'tests/test-indicator-display-half-server.c'
--- tests/test-indicator-display-half-server.c 1970-01-01 00:00:00 +0000
+++ tests/test-indicator-display-half-server.c 2009-09-03 22:01:41 +0000
@@ -0,0 +1,55 @@
1
2#include <glib.h>
3#include "libindicate/listener.h"
4#include "test-max-indicators-list.h"
5
6static gboolean passed = TRUE;
7static GMainLoop * mainloop = NULL;
8
9gboolean doit = TRUE;
10
11static void
12indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gpointer data)
13{
14 if (doit) {
15 indicate_listener_displayed(listener, server, indicator, TRUE);
16 doit = FALSE;
17 } else {
18 doit = TRUE;
19 }
20 return;
21}
22
23static gboolean
24failed_cb (gpointer data)
25{
26 g_debug("Done indicatating displayed");
27 g_main_loop_quit(mainloop);
28 return FALSE;
29}
30
31static void
32server_removed (void)
33{
34 g_debug("Server went away, exiting.");
35 g_main_loop_quit(mainloop);
36 return;
37}
38
39int
40main (int argc, char * argv)
41{
42 g_type_init();
43
44 IndicateListener * listener = indicate_listener_ref_default();
45
46 g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED, G_CALLBACK(indicator_added), NULL);
47 g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_REMOVED, G_CALLBACK(server_removed), NULL);
48
49 g_timeout_add_seconds(2, failed_cb, NULL);
50
51 mainloop = g_main_loop_new(NULL, FALSE);
52 g_main_loop_run(mainloop);
53
54 return !passed;
55}
056
=== added file 'tests/test-indicator-display-server.c'
--- tests/test-indicator-display-server.c 1970-01-01 00:00:00 +0000
+++ tests/test-indicator-display-server.c 2009-09-03 21:25:30 +0000
@@ -0,0 +1,48 @@
1
2#include <glib.h>
3#include "libindicate/listener.h"
4#include "test-max-indicators-list.h"
5
6static gboolean passed = TRUE;
7static GMainLoop * mainloop = NULL;
8
9
10static void
11indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gpointer data)
12{
13 return indicate_listener_displayed(listener, server, indicator, TRUE);
14}
15
16static gboolean
17failed_cb (gpointer data)
18{
19 g_debug("Done indicatating displayed");
20 g_main_loop_quit(mainloop);
21 return FALSE;
22}
23
24static void
25server_removed (void)
26{
27 g_debug("Server went away, exiting.");
28 g_main_loop_quit(mainloop);
29 return;
30}
31
32int
33main (int argc, char * argv)
34{
35 g_type_init();
36
37 IndicateListener * listener = indicate_listener_ref_default();
38
39 g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED, G_CALLBACK(indicator_added), NULL);
40 g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_REMOVED, G_CALLBACK(server_removed), NULL);
41
42 g_timeout_add_seconds(2, failed_cb, NULL);
43
44 mainloop = g_main_loop_new(NULL, FALSE);
45 g_main_loop_run(mainloop);
46
47 return !passed;
48}
049
=== added file 'tests/test-max-indicators-client.c'
--- tests/test-max-indicators-client.c 1970-01-01 00:00:00 +0000
+++ tests/test-max-indicators-client.c 2009-09-03 01:47:13 +0000
@@ -0,0 +1,57 @@
1
2#include <glib.h>
3#include "libindicate/indicator.h"
4#include "libindicate/server.h"
5#include "libindicate/interests.h"
6#include "test-max-indicators-list.h"
7
8static gboolean passed = TRUE;
9static GMainLoop * mainloop = NULL;
10static int count = 0;
11
12
13static void
14max_changed (IndicateServer * server, gint max, gpointer userdata)
15{
16 g_debug("Oh, max changed: %d", max);
17
18 if (max != max_indicator_list[count]) {
19 passed = FALSE;
20 g_debug("\tBut that's not right! We wanted: %d", max_indicator_list[count]);
21 }
22 count++;
23
24 if (count == MAX_INDICATOR_COUNT) {
25 g_main_loop_quit(mainloop);
26 }
27
28 return;
29}
30
31static gboolean
32done_timeout_cb (gpointer data)
33{
34 g_debug("All maxes not set");
35 passed = FALSE;
36 g_main_loop_quit(mainloop);
37 return FALSE;
38}
39
40int
41main (int argc, char * argv)
42{
43 g_type_init();
44
45 IndicateIndicator * indicator = indicate_indicator_new();
46 indicate_indicator_show(indicator);
47
48 IndicateServer * server = indicate_server_ref_default();
49 g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED, G_CALLBACK(max_changed), NULL);
50
51 g_timeout_add(MAX_INDICATOR_COUNT * 10 * 100, done_timeout_cb, indicator);
52
53 mainloop = g_main_loop_new(NULL, FALSE);
54 g_main_loop_run(mainloop);
55
56 return !passed;
57}
058
=== added file 'tests/test-max-indicators-list.h'
--- tests/test-max-indicators-list.h 1970-01-01 00:00:00 +0000
+++ tests/test-max-indicators-list.h 2009-09-03 01:37:33 +0000
@@ -0,0 +1,3 @@
1
2#define MAX_INDICATOR_COUNT 8
3gint max_indicator_list[MAX_INDICATOR_COUNT] = { 1, 0, 1000, 0, 500, 1, 7, -1 };
04
=== added file 'tests/test-max-indicators-server-repeat.c'
--- tests/test-max-indicators-server-repeat.c 1970-01-01 00:00:00 +0000
+++ tests/test-max-indicators-server-repeat.c 2009-09-03 01:50:10 +0000
@@ -0,0 +1,86 @@
1
2#include <glib.h>
3#include "libindicate/listener.h"
4#include "test-max-indicators-list.h"
5
6gint repeat_list[MAX_INDICATOR_COUNT] = { 2, 3, 1, 4, 2, 3, 1, 20 };
7
8static gboolean passed = TRUE;
9static GMainLoop * mainloop = NULL;
10
11static guint count = 0;
12static guint repeat = 0;
13
14static IndicateListener * l = NULL;
15static IndicateListenerServer * s = NULL;
16
17gboolean
18set_max (gpointer userdata)
19{
20 g_debug("Setting max indicators to: %d", max_indicator_list[count]);
21 indicate_listener_set_server_max_indicators(l, s, max_indicator_list[count]);
22 if (repeat == repeat_list[count]) {
23 count++;
24 repeat = 0;
25 } else {
26 repeat++;
27 }
28
29 if (count >= MAX_INDICATOR_COUNT) {
30 return FALSE;
31 } else {
32 return TRUE;
33 }
34}
35
36static void
37server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
38{
39 g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
40
41 if (l != NULL || s != NULL) {
42 g_warning("Adding a second server? %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server));
43 return;
44 }
45
46 l = listener;
47 s = server;
48
49 g_timeout_add(100, set_max, NULL);
50
51 return;
52}
53
54static gboolean
55failed_cb (gpointer data)
56{
57 g_debug("Done indicatating max indicators");
58 g_main_loop_quit(mainloop);
59 return FALSE;
60}
61
62int
63main (int argc, char * argv)
64{
65 g_type_init();
66
67 IndicateListener * listener = indicate_listener_ref_default();
68
69 g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
70
71 guint i, repeat_sum = 0;
72 for (i = 0; i < MAX_INDICATOR_COUNT; i++) {
73 repeat_sum += repeat_list[i];
74 }
75
76 if (repeat_sum / MAX_INDICATOR_COUNT > 9) {
77 g_warning("Risk of client timeout.");
78 }
79
80 g_timeout_add((MAX_INDICATOR_COUNT + 4 + repeat_sum) * 100, failed_cb, NULL);
81
82 mainloop = g_main_loop_new(NULL, FALSE);
83 g_main_loop_run(mainloop);
84
85 return !passed;
86}
087
=== added file 'tests/test-max-indicators-server.c'
--- tests/test-max-indicators-server.c 1970-01-01 00:00:00 +0000
+++ tests/test-max-indicators-server.c 2009-09-03 01:50:10 +0000
@@ -0,0 +1,69 @@
1
2#include <glib.h>
3#include "libindicate/listener.h"
4#include "test-max-indicators-list.h"
5
6static gboolean passed = TRUE;
7static GMainLoop * mainloop = NULL;
8
9static guint count = 0;
10
11static IndicateListener * l = NULL;
12static IndicateListenerServer * s = NULL;
13
14gboolean
15set_max (gpointer userdata)
16{
17 g_debug("Setting max indicators to: %d", max_indicator_list[count]);
18 indicate_listener_set_server_max_indicators(l, s, max_indicator_list[count]);
19 count++;
20
21 if (count >= MAX_INDICATOR_COUNT) {
22 return FALSE;
23 } else {
24 return TRUE;
25 }
26}
27
28static void
29server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
30{
31 g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
32
33 if (l != NULL || s != NULL) {
34 g_warning("Adding a second server? %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server));
35 return;
36 }
37
38 l = listener;
39 s = server;
40
41 g_timeout_add(100, set_max, NULL);
42
43 return;
44}
45
46static gboolean
47failed_cb (gpointer data)
48{
49 g_debug("Done indicatating max indicators");
50 g_main_loop_quit(mainloop);
51 return FALSE;
52}
53
54int
55main (int argc, char * argv)
56{
57 g_type_init();
58
59 IndicateListener * listener = indicate_listener_ref_default();
60
61 g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
62
63 g_timeout_add((MAX_INDICATOR_COUNT + 4) * 100, failed_cb, NULL);
64
65 mainloop = g_main_loop_new(NULL, FALSE);
66 g_main_loop_run(mainloop);
67
68 return !passed;
69}
070
=== added file 'tests/test_indicator_display'
--- tests/test_indicator_display 1970-01-01 00:00:00 +0000
+++ tests/test_indicator_display 2009-09-03 21:07:15 +0000
@@ -0,0 +1,5 @@
1#!/bin/sh
2
3DBUS_RUNNER="dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf"
4
5${DBUS_RUNNER} --task ./test-indicator-display-client --task-name Client --task ./test-indicator-display-server --task-name Server
06
=== added file 'tests/test_indicator_display_half'
--- tests/test_indicator_display_half 1970-01-01 00:00:00 +0000
+++ tests/test_indicator_display_half 2009-09-03 21:58:04 +0000
@@ -0,0 +1,5 @@
1#!/bin/sh
2
3DBUS_RUNNER="dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf"
4
5${DBUS_RUNNER} --task ./test-indicator-display-half-client --task-name Client --task ./test-indicator-display-half-server --task-name Server
06
=== added file 'tests/test_max_indicators'
--- tests/test_max_indicators 1970-01-01 00:00:00 +0000
+++ tests/test_max_indicators 2009-09-02 22:07:29 +0000
@@ -0,0 +1,5 @@
1#!/bin/sh
2
3DBUS_RUNNER="dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf"
4
5${DBUS_RUNNER} --task ./test-max-indicators-client --task-name Client --task ./test-max-indicators-server --task-name Server
06
=== added file 'tests/test_max_indicators_repeat'
--- tests/test_max_indicators_repeat 1970-01-01 00:00:00 +0000
+++ tests/test_max_indicators_repeat 2009-09-03 01:41:31 +0000
@@ -0,0 +1,5 @@
1#!/bin/sh
2
3DBUS_RUNNER="dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf"
4
5${DBUS_RUNNER} --task ./test-max-indicators-client --task-name Client --task ./test-max-indicators-server-repeat --task-name Server

Subscribers

People subscribed via source and target branches

to all changes: