Merge lp:~ted/libappindicator/remove-service into lp:libappindicator
- remove-service
- Merge into trunk
Proposed by
Ted Gould
Status: | Merged |
---|---|
Merged at revision: | 170 |
Proposed branch: | lp:~ted/libappindicator/remove-service |
Merge into: | lp:libappindicator |
Diff against target: |
4202 lines (+44/-3848) 21 files modified
COPYING (+0/-674) Makefile.am (+2/-3) autogen.sh (+1/-1) configure.ac (+15/-53) data/Makefile.am (+0/-17) data/indicator-application.service.in (+0/-3) data/ordering-override.keyfile (+0/-5) docs/reference/Makefile.am (+2/-2) example/Makefile.am (+2/-2) src/Makefile.am (+5/-55) src/application-service-appstore.c (+0/-1305) src/application-service-appstore.h (+0/-73) src/application-service-watcher.c (+0/-302) src/application-service-watcher.h (+0/-61) src/application-service.c (+0/-78) src/application-service.xml (+0/-59) src/dbus-properties.xml (+0/-23) src/indicator-application.c (+0/-879) src/notification-approver.xml (+0/-29) tests/Makefile.am (+17/-45) tests/test-approver.c (+0/-179) |
To merge this branch: | bzr merge lp:~ted/libappindicator/remove-service |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Indicator Applet Developers | Pending | ||
Review via email: mp+42561@code.launchpad.net |
Commit message
Description of the change
Remove the service from the repo so that it's lib only.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed file 'COPYING' | |||
2 | --- COPYING 2009-11-30 21:22:03 +0000 | |||
3 | +++ COPYING 1970-01-01 00:00:00 +0000 | |||
4 | @@ -1,674 +0,0 @@ | |||
5 | 1 | GNU GENERAL PUBLIC LICENSE | ||
6 | 2 | Version 3, 29 June 2007 | ||
7 | 3 | |||
8 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> | ||
9 | 5 | Everyone is permitted to copy and distribute verbatim copies | ||
10 | 6 | of this license document, but changing it is not allowed. | ||
11 | 7 | |||
12 | 8 | Preamble | ||
13 | 9 | |||
14 | 10 | The GNU General Public License is a free, copyleft license for | ||
15 | 11 | software and other kinds of works. | ||
16 | 12 | |||
17 | 13 | The licenses for most software and other practical works are designed | ||
18 | 14 | to take away your freedom to share and change the works. By contrast, | ||
19 | 15 | the GNU General Public License is intended to guarantee your freedom to | ||
20 | 16 | share and change all versions of a program--to make sure it remains free | ||
21 | 17 | software for all its users. We, the Free Software Foundation, use the | ||
22 | 18 | GNU General Public License for most of our software; it applies also to | ||
23 | 19 | any other work released this way by its authors. You can apply it to | ||
24 | 20 | your programs, too. | ||
25 | 21 | |||
26 | 22 | When we speak of free software, we are referring to freedom, not | ||
27 | 23 | price. Our General Public Licenses are designed to make sure that you | ||
28 | 24 | have the freedom to distribute copies of free software (and charge for | ||
29 | 25 | them if you wish), that you receive source code or can get it if you | ||
30 | 26 | want it, that you can change the software or use pieces of it in new | ||
31 | 27 | free programs, and that you know you can do these things. | ||
32 | 28 | |||
33 | 29 | To protect your rights, we need to prevent others from denying you | ||
34 | 30 | these rights or asking you to surrender the rights. Therefore, you have | ||
35 | 31 | certain responsibilities if you distribute copies of the software, or if | ||
36 | 32 | you modify it: responsibilities to respect the freedom of others. | ||
37 | 33 | |||
38 | 34 | For example, if you distribute copies of such a program, whether | ||
39 | 35 | gratis or for a fee, you must pass on to the recipients the same | ||
40 | 36 | freedoms that you received. You must make sure that they, too, receive | ||
41 | 37 | or can get the source code. And you must show them these terms so they | ||
42 | 38 | know their rights. | ||
43 | 39 | |||
44 | 40 | Developers that use the GNU GPL protect your rights with two steps: | ||
45 | 41 | (1) assert copyright on the software, and (2) offer you this License | ||
46 | 42 | giving you legal permission to copy, distribute and/or modify it. | ||
47 | 43 | |||
48 | 44 | For the developers' and authors' protection, the GPL clearly explains | ||
49 | 45 | that there is no warranty for this free software. For both users' and | ||
50 | 46 | authors' sake, the GPL requires that modified versions be marked as | ||
51 | 47 | changed, so that their problems will not be attributed erroneously to | ||
52 | 48 | authors of previous versions. | ||
53 | 49 | |||
54 | 50 | Some devices are designed to deny users access to install or run | ||
55 | 51 | modified versions of the software inside them, although the manufacturer | ||
56 | 52 | can do so. This is fundamentally incompatible with the aim of | ||
57 | 53 | protecting users' freedom to change the software. The systematic | ||
58 | 54 | pattern of such abuse occurs in the area of products for individuals to | ||
59 | 55 | use, which is precisely where it is most unacceptable. Therefore, we | ||
60 | 56 | have designed this version of the GPL to prohibit the practice for those | ||
61 | 57 | products. If such problems arise substantially in other domains, we | ||
62 | 58 | stand ready to extend this provision to those domains in future versions | ||
63 | 59 | of the GPL, as needed to protect the freedom of users. | ||
64 | 60 | |||
65 | 61 | Finally, every program is threatened constantly by software patents. | ||
66 | 62 | States should not allow patents to restrict development and use of | ||
67 | 63 | software on general-purpose computers, but in those that do, we wish to | ||
68 | 64 | avoid the special danger that patents applied to a free program could | ||
69 | 65 | make it effectively proprietary. To prevent this, the GPL assures that | ||
70 | 66 | patents cannot be used to render the program non-free. | ||
71 | 67 | |||
72 | 68 | The precise terms and conditions for copying, distribution and | ||
73 | 69 | modification follow. | ||
74 | 70 | |||
75 | 71 | TERMS AND CONDITIONS | ||
76 | 72 | |||
77 | 73 | 0. Definitions. | ||
78 | 74 | |||
79 | 75 | "This License" refers to version 3 of the GNU General Public License. | ||
80 | 76 | |||
81 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of | ||
82 | 78 | works, such as semiconductor masks. | ||
83 | 79 | |||
84 | 80 | "The Program" refers to any copyrightable work licensed under this | ||
85 | 81 | License. Each licensee is addressed as "you". "Licensees" and | ||
86 | 82 | "recipients" may be individuals or organizations. | ||
87 | 83 | |||
88 | 84 | To "modify" a work means to copy from or adapt all or part of the work | ||
89 | 85 | in a fashion requiring copyright permission, other than the making of an | ||
90 | 86 | exact copy. The resulting work is called a "modified version" of the | ||
91 | 87 | earlier work or a work "based on" the earlier work. | ||
92 | 88 | |||
93 | 89 | A "covered work" means either the unmodified Program or a work based | ||
94 | 90 | on the Program. | ||
95 | 91 | |||
96 | 92 | To "propagate" a work means to do anything with it that, without | ||
97 | 93 | permission, would make you directly or secondarily liable for | ||
98 | 94 | infringement under applicable copyright law, except executing it on a | ||
99 | 95 | computer or modifying a private copy. Propagation includes copying, | ||
100 | 96 | distribution (with or without modification), making available to the | ||
101 | 97 | public, and in some countries other activities as well. | ||
102 | 98 | |||
103 | 99 | To "convey" a work means any kind of propagation that enables other | ||
104 | 100 | parties to make or receive copies. Mere interaction with a user through | ||
105 | 101 | a computer network, with no transfer of a copy, is not conveying. | ||
106 | 102 | |||
107 | 103 | An interactive user interface displays "Appropriate Legal Notices" | ||
108 | 104 | to the extent that it includes a convenient and prominently visible | ||
109 | 105 | feature that (1) displays an appropriate copyright notice, and (2) | ||
110 | 106 | tells the user that there is no warranty for the work (except to the | ||
111 | 107 | extent that warranties are provided), that licensees may convey the | ||
112 | 108 | work under this License, and how to view a copy of this License. If | ||
113 | 109 | the interface presents a list of user commands or options, such as a | ||
114 | 110 | menu, a prominent item in the list meets this criterion. | ||
115 | 111 | |||
116 | 112 | 1. Source Code. | ||
117 | 113 | |||
118 | 114 | The "source code" for a work means the preferred form of the work | ||
119 | 115 | for making modifications to it. "Object code" means any non-source | ||
120 | 116 | form of a work. | ||
121 | 117 | |||
122 | 118 | A "Standard Interface" means an interface that either is an official | ||
123 | 119 | standard defined by a recognized standards body, or, in the case of | ||
124 | 120 | interfaces specified for a particular programming language, one that | ||
125 | 121 | is widely used among developers working in that language. | ||
126 | 122 | |||
127 | 123 | The "System Libraries" of an executable work include anything, other | ||
128 | 124 | than the work as a whole, that (a) is included in the normal form of | ||
129 | 125 | packaging a Major Component, but which is not part of that Major | ||
130 | 126 | Component, and (b) serves only to enable use of the work with that | ||
131 | 127 | Major Component, or to implement a Standard Interface for which an | ||
132 | 128 | implementation is available to the public in source code form. A | ||
133 | 129 | "Major Component", in this context, means a major essential component | ||
134 | 130 | (kernel, window system, and so on) of the specific operating system | ||
135 | 131 | (if any) on which the executable work runs, or a compiler used to | ||
136 | 132 | produce the work, or an object code interpreter used to run it. | ||
137 | 133 | |||
138 | 134 | The "Corresponding Source" for a work in object code form means all | ||
139 | 135 | the source code needed to generate, install, and (for an executable | ||
140 | 136 | work) run the object code and to modify the work, including scripts to | ||
141 | 137 | control those activities. However, it does not include the work's | ||
142 | 138 | System Libraries, or general-purpose tools or generally available free | ||
143 | 139 | programs which are used unmodified in performing those activities but | ||
144 | 140 | which are not part of the work. For example, Corresponding Source | ||
145 | 141 | includes interface definition files associated with source files for | ||
146 | 142 | the work, and the source code for shared libraries and dynamically | ||
147 | 143 | linked subprograms that the work is specifically designed to require, | ||
148 | 144 | such as by intimate data communication or control flow between those | ||
149 | 145 | subprograms and other parts of the work. | ||
150 | 146 | |||
151 | 147 | The Corresponding Source need not include anything that users | ||
152 | 148 | can regenerate automatically from other parts of the Corresponding | ||
153 | 149 | Source. | ||
154 | 150 | |||
155 | 151 | The Corresponding Source for a work in source code form is that | ||
156 | 152 | same work. | ||
157 | 153 | |||
158 | 154 | 2. Basic Permissions. | ||
159 | 155 | |||
160 | 156 | All rights granted under this License are granted for the term of | ||
161 | 157 | copyright on the Program, and are irrevocable provided the stated | ||
162 | 158 | conditions are met. This License explicitly affirms your unlimited | ||
163 | 159 | permission to run the unmodified Program. The output from running a | ||
164 | 160 | covered work is covered by this License only if the output, given its | ||
165 | 161 | content, constitutes a covered work. This License acknowledges your | ||
166 | 162 | rights of fair use or other equivalent, as provided by copyright law. | ||
167 | 163 | |||
168 | 164 | You may make, run and propagate covered works that you do not | ||
169 | 165 | convey, without conditions so long as your license otherwise remains | ||
170 | 166 | in force. You may convey covered works to others for the sole purpose | ||
171 | 167 | of having them make modifications exclusively for you, or provide you | ||
172 | 168 | with facilities for running those works, provided that you comply with | ||
173 | 169 | the terms of this License in conveying all material for which you do | ||
174 | 170 | not control copyright. Those thus making or running the covered works | ||
175 | 171 | for you must do so exclusively on your behalf, under your direction | ||
176 | 172 | and control, on terms that prohibit them from making any copies of | ||
177 | 173 | your copyrighted material outside their relationship with you. | ||
178 | 174 | |||
179 | 175 | Conveying under any other circumstances is permitted solely under | ||
180 | 176 | the conditions stated below. Sublicensing is not allowed; section 10 | ||
181 | 177 | makes it unnecessary. | ||
182 | 178 | |||
183 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. | ||
184 | 180 | |||
185 | 181 | No covered work shall be deemed part of an effective technological | ||
186 | 182 | measure under any applicable law fulfilling obligations under article | ||
187 | 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or | ||
188 | 184 | similar laws prohibiting or restricting circumvention of such | ||
189 | 185 | measures. | ||
190 | 186 | |||
191 | 187 | When you convey a covered work, you waive any legal power to forbid | ||
192 | 188 | circumvention of technological measures to the extent such circumvention | ||
193 | 189 | is effected by exercising rights under this License with respect to | ||
194 | 190 | the covered work, and you disclaim any intention to limit operation or | ||
195 | 191 | modification of the work as a means of enforcing, against the work's | ||
196 | 192 | users, your or third parties' legal rights to forbid circumvention of | ||
197 | 193 | technological measures. | ||
198 | 194 | |||
199 | 195 | 4. Conveying Verbatim Copies. | ||
200 | 196 | |||
201 | 197 | You may convey verbatim copies of the Program's source code as you | ||
202 | 198 | receive it, in any medium, provided that you conspicuously and | ||
203 | 199 | appropriately publish on each copy an appropriate copyright notice; | ||
204 | 200 | keep intact all notices stating that this License and any | ||
205 | 201 | non-permissive terms added in accord with section 7 apply to the code; | ||
206 | 202 | keep intact all notices of the absence of any warranty; and give all | ||
207 | 203 | recipients a copy of this License along with the Program. | ||
208 | 204 | |||
209 | 205 | You may charge any price or no price for each copy that you convey, | ||
210 | 206 | and you may offer support or warranty protection for a fee. | ||
211 | 207 | |||
212 | 208 | 5. Conveying Modified Source Versions. | ||
213 | 209 | |||
214 | 210 | You may convey a work based on the Program, or the modifications to | ||
215 | 211 | produce it from the Program, in the form of source code under the | ||
216 | 212 | terms of section 4, provided that you also meet all of these conditions: | ||
217 | 213 | |||
218 | 214 | a) The work must carry prominent notices stating that you modified | ||
219 | 215 | it, and giving a relevant date. | ||
220 | 216 | |||
221 | 217 | b) The work must carry prominent notices stating that it is | ||
222 | 218 | released under this License and any conditions added under section | ||
223 | 219 | 7. This requirement modifies the requirement in section 4 to | ||
224 | 220 | "keep intact all notices". | ||
225 | 221 | |||
226 | 222 | c) You must license the entire work, as a whole, under this | ||
227 | 223 | License to anyone who comes into possession of a copy. This | ||
228 | 224 | License will therefore apply, along with any applicable section 7 | ||
229 | 225 | additional terms, to the whole of the work, and all its parts, | ||
230 | 226 | regardless of how they are packaged. This License gives no | ||
231 | 227 | permission to license the work in any other way, but it does not | ||
232 | 228 | invalidate such permission if you have separately received it. | ||
233 | 229 | |||
234 | 230 | d) If the work has interactive user interfaces, each must display | ||
235 | 231 | Appropriate Legal Notices; however, if the Program has interactive | ||
236 | 232 | interfaces that do not display Appropriate Legal Notices, your | ||
237 | 233 | work need not make them do so. | ||
238 | 234 | |||
239 | 235 | A compilation of a covered work with other separate and independent | ||
240 | 236 | works, which are not by their nature extensions of the covered work, | ||
241 | 237 | and which are not combined with it such as to form a larger program, | ||
242 | 238 | in or on a volume of a storage or distribution medium, is called an | ||
243 | 239 | "aggregate" if the compilation and its resulting copyright are not | ||
244 | 240 | used to limit the access or legal rights of the compilation's users | ||
245 | 241 | beyond what the individual works permit. Inclusion of a covered work | ||
246 | 242 | in an aggregate does not cause this License to apply to the other | ||
247 | 243 | parts of the aggregate. | ||
248 | 244 | |||
249 | 245 | 6. Conveying Non-Source Forms. | ||
250 | 246 | |||
251 | 247 | You may convey a covered work in object code form under the terms | ||
252 | 248 | of sections 4 and 5, provided that you also convey the | ||
253 | 249 | machine-readable Corresponding Source under the terms of this License, | ||
254 | 250 | in one of these ways: | ||
255 | 251 | |||
256 | 252 | a) Convey the object code in, or embodied in, a physical product | ||
257 | 253 | (including a physical distribution medium), accompanied by the | ||
258 | 254 | Corresponding Source fixed on a durable physical medium | ||
259 | 255 | customarily used for software interchange. | ||
260 | 256 | |||
261 | 257 | b) Convey the object code in, or embodied in, a physical product | ||
262 | 258 | (including a physical distribution medium), accompanied by a | ||
263 | 259 | written offer, valid for at least three years and valid for as | ||
264 | 260 | long as you offer spare parts or customer support for that product | ||
265 | 261 | model, to give anyone who possesses the object code either (1) a | ||
266 | 262 | copy of the Corresponding Source for all the software in the | ||
267 | 263 | product that is covered by this License, on a durable physical | ||
268 | 264 | medium customarily used for software interchange, for a price no | ||
269 | 265 | more than your reasonable cost of physically performing this | ||
270 | 266 | conveying of source, or (2) access to copy the | ||
271 | 267 | Corresponding Source from a network server at no charge. | ||
272 | 268 | |||
273 | 269 | c) Convey individual copies of the object code with a copy of the | ||
274 | 270 | written offer to provide the Corresponding Source. This | ||
275 | 271 | alternative is allowed only occasionally and noncommercially, and | ||
276 | 272 | only if you received the object code with such an offer, in accord | ||
277 | 273 | with subsection 6b. | ||
278 | 274 | |||
279 | 275 | d) Convey the object code by offering access from a designated | ||
280 | 276 | place (gratis or for a charge), and offer equivalent access to the | ||
281 | 277 | Corresponding Source in the same way through the same place at no | ||
282 | 278 | further charge. You need not require recipients to copy the | ||
283 | 279 | Corresponding Source along with the object code. If the place to | ||
284 | 280 | copy the object code is a network server, the Corresponding Source | ||
285 | 281 | may be on a different server (operated by you or a third party) | ||
286 | 282 | that supports equivalent copying facilities, provided you maintain | ||
287 | 283 | clear directions next to the object code saying where to find the | ||
288 | 284 | Corresponding Source. Regardless of what server hosts the | ||
289 | 285 | Corresponding Source, you remain obligated to ensure that it is | ||
290 | 286 | available for as long as needed to satisfy these requirements. | ||
291 | 287 | |||
292 | 288 | e) Convey the object code using peer-to-peer transmission, provided | ||
293 | 289 | you inform other peers where the object code and Corresponding | ||
294 | 290 | Source of the work are being offered to the general public at no | ||
295 | 291 | charge under subsection 6d. | ||
296 | 292 | |||
297 | 293 | A separable portion of the object code, whose source code is excluded | ||
298 | 294 | from the Corresponding Source as a System Library, need not be | ||
299 | 295 | included in conveying the object code work. | ||
300 | 296 | |||
301 | 297 | A "User Product" is either (1) a "consumer product", which means any | ||
302 | 298 | tangible personal property which is normally used for personal, family, | ||
303 | 299 | or household purposes, or (2) anything designed or sold for incorporation | ||
304 | 300 | into a dwelling. In determining whether a product is a consumer product, | ||
305 | 301 | doubtful cases shall be resolved in favor of coverage. For a particular | ||
306 | 302 | product received by a particular user, "normally used" refers to a | ||
307 | 303 | typical or common use of that class of product, regardless of the status | ||
308 | 304 | of the particular user or of the way in which the particular user | ||
309 | 305 | actually uses, or expects or is expected to use, the product. A product | ||
310 | 306 | is a consumer product regardless of whether the product has substantial | ||
311 | 307 | commercial, industrial or non-consumer uses, unless such uses represent | ||
312 | 308 | the only significant mode of use of the product. | ||
313 | 309 | |||
314 | 310 | "Installation Information" for a User Product means any methods, | ||
315 | 311 | procedures, authorization keys, or other information required to install | ||
316 | 312 | and execute modified versions of a covered work in that User Product from | ||
317 | 313 | a modified version of its Corresponding Source. The information must | ||
318 | 314 | suffice to ensure that the continued functioning of the modified object | ||
319 | 315 | code is in no case prevented or interfered with solely because | ||
320 | 316 | modification has been made. | ||
321 | 317 | |||
322 | 318 | If you convey an object code work under this section in, or with, or | ||
323 | 319 | specifically for use in, a User Product, and the conveying occurs as | ||
324 | 320 | part of a transaction in which the right of possession and use of the | ||
325 | 321 | User Product is transferred to the recipient in perpetuity or for a | ||
326 | 322 | fixed term (regardless of how the transaction is characterized), the | ||
327 | 323 | Corresponding Source conveyed under this section must be accompanied | ||
328 | 324 | by the Installation Information. But this requirement does not apply | ||
329 | 325 | if neither you nor any third party retains the ability to install | ||
330 | 326 | modified object code on the User Product (for example, the work has | ||
331 | 327 | been installed in ROM). | ||
332 | 328 | |||
333 | 329 | The requirement to provide Installation Information does not include a | ||
334 | 330 | requirement to continue to provide support service, warranty, or updates | ||
335 | 331 | for a work that has been modified or installed by the recipient, or for | ||
336 | 332 | the User Product in which it has been modified or installed. Access to a | ||
337 | 333 | network may be denied when the modification itself materially and | ||
338 | 334 | adversely affects the operation of the network or violates the rules and | ||
339 | 335 | protocols for communication across the network. | ||
340 | 336 | |||
341 | 337 | Corresponding Source conveyed, and Installation Information provided, | ||
342 | 338 | in accord with this section must be in a format that is publicly | ||
343 | 339 | documented (and with an implementation available to the public in | ||
344 | 340 | source code form), and must require no special password or key for | ||
345 | 341 | unpacking, reading or copying. | ||
346 | 342 | |||
347 | 343 | 7. Additional Terms. | ||
348 | 344 | |||
349 | 345 | "Additional permissions" are terms that supplement the terms of this | ||
350 | 346 | License by making exceptions from one or more of its conditions. | ||
351 | 347 | Additional permissions that are applicable to the entire Program shall | ||
352 | 348 | be treated as though they were included in this License, to the extent | ||
353 | 349 | that they are valid under applicable law. If additional permissions | ||
354 | 350 | apply only to part of the Program, that part may be used separately | ||
355 | 351 | under those permissions, but the entire Program remains governed by | ||
356 | 352 | this License without regard to the additional permissions. | ||
357 | 353 | |||
358 | 354 | When you convey a copy of a covered work, you may at your option | ||
359 | 355 | remove any additional permissions from that copy, or from any part of | ||
360 | 356 | it. (Additional permissions may be written to require their own | ||
361 | 357 | removal in certain cases when you modify the work.) You may place | ||
362 | 358 | additional permissions on material, added by you to a covered work, | ||
363 | 359 | for which you have or can give appropriate copyright permission. | ||
364 | 360 | |||
365 | 361 | Notwithstanding any other provision of this License, for material you | ||
366 | 362 | add to a covered work, you may (if authorized by the copyright holders of | ||
367 | 363 | that material) supplement the terms of this License with terms: | ||
368 | 364 | |||
369 | 365 | a) Disclaiming warranty or limiting liability differently from the | ||
370 | 366 | terms of sections 15 and 16 of this License; or | ||
371 | 367 | |||
372 | 368 | b) Requiring preservation of specified reasonable legal notices or | ||
373 | 369 | author attributions in that material or in the Appropriate Legal | ||
374 | 370 | Notices displayed by works containing it; or | ||
375 | 371 | |||
376 | 372 | c) Prohibiting misrepresentation of the origin of that material, or | ||
377 | 373 | requiring that modified versions of such material be marked in | ||
378 | 374 | reasonable ways as different from the original version; or | ||
379 | 375 | |||
380 | 376 | d) Limiting the use for publicity purposes of names of licensors or | ||
381 | 377 | authors of the material; or | ||
382 | 378 | |||
383 | 379 | e) Declining to grant rights under trademark law for use of some | ||
384 | 380 | trade names, trademarks, or service marks; or | ||
385 | 381 | |||
386 | 382 | f) Requiring indemnification of licensors and authors of that | ||
387 | 383 | material by anyone who conveys the material (or modified versions of | ||
388 | 384 | it) with contractual assumptions of liability to the recipient, for | ||
389 | 385 | any liability that these contractual assumptions directly impose on | ||
390 | 386 | those licensors and authors. | ||
391 | 387 | |||
392 | 388 | All other non-permissive additional terms are considered "further | ||
393 | 389 | restrictions" within the meaning of section 10. If the Program as you | ||
394 | 390 | received it, or any part of it, contains a notice stating that it is | ||
395 | 391 | governed by this License along with a term that is a further | ||
396 | 392 | restriction, you may remove that term. If a license document contains | ||
397 | 393 | a further restriction but permits relicensing or conveying under this | ||
398 | 394 | License, you may add to a covered work material governed by the terms | ||
399 | 395 | of that license document, provided that the further restriction does | ||
400 | 396 | not survive such relicensing or conveying. | ||
401 | 397 | |||
402 | 398 | If you add terms to a covered work in accord with this section, you | ||
403 | 399 | must place, in the relevant source files, a statement of the | ||
404 | 400 | additional terms that apply to those files, or a notice indicating | ||
405 | 401 | where to find the applicable terms. | ||
406 | 402 | |||
407 | 403 | Additional terms, permissive or non-permissive, may be stated in the | ||
408 | 404 | form of a separately written license, or stated as exceptions; | ||
409 | 405 | the above requirements apply either way. | ||
410 | 406 | |||
411 | 407 | 8. Termination. | ||
412 | 408 | |||
413 | 409 | You may not propagate or modify a covered work except as expressly | ||
414 | 410 | provided under this License. Any attempt otherwise to propagate or | ||
415 | 411 | modify it is void, and will automatically terminate your rights under | ||
416 | 412 | this License (including any patent licenses granted under the third | ||
417 | 413 | paragraph of section 11). | ||
418 | 414 | |||
419 | 415 | However, if you cease all violation of this License, then your | ||
420 | 416 | license from a particular copyright holder is reinstated (a) | ||
421 | 417 | provisionally, unless and until the copyright holder explicitly and | ||
422 | 418 | finally terminates your license, and (b) permanently, if the copyright | ||
423 | 419 | holder fails to notify you of the violation by some reasonable means | ||
424 | 420 | prior to 60 days after the cessation. | ||
425 | 421 | |||
426 | 422 | Moreover, your license from a particular copyright holder is | ||
427 | 423 | reinstated permanently if the copyright holder notifies you of the | ||
428 | 424 | violation by some reasonable means, this is the first time you have | ||
429 | 425 | received notice of violation of this License (for any work) from that | ||
430 | 426 | copyright holder, and you cure the violation prior to 30 days after | ||
431 | 427 | your receipt of the notice. | ||
432 | 428 | |||
433 | 429 | Termination of your rights under this section does not terminate the | ||
434 | 430 | licenses of parties who have received copies or rights from you under | ||
435 | 431 | this License. If your rights have been terminated and not permanently | ||
436 | 432 | reinstated, you do not qualify to receive new licenses for the same | ||
437 | 433 | material under section 10. | ||
438 | 434 | |||
439 | 435 | 9. Acceptance Not Required for Having Copies. | ||
440 | 436 | |||
441 | 437 | You are not required to accept this License in order to receive or | ||
442 | 438 | run a copy of the Program. Ancillary propagation of a covered work | ||
443 | 439 | occurring solely as a consequence of using peer-to-peer transmission | ||
444 | 440 | to receive a copy likewise does not require acceptance. However, | ||
445 | 441 | nothing other than this License grants you permission to propagate or | ||
446 | 442 | modify any covered work. These actions infringe copyright if you do | ||
447 | 443 | not accept this License. Therefore, by modifying or propagating a | ||
448 | 444 | covered work, you indicate your acceptance of this License to do so. | ||
449 | 445 | |||
450 | 446 | 10. Automatic Licensing of Downstream Recipients. | ||
451 | 447 | |||
452 | 448 | Each time you convey a covered work, the recipient automatically | ||
453 | 449 | receives a license from the original licensors, to run, modify and | ||
454 | 450 | propagate that work, subject to this License. You are not responsible | ||
455 | 451 | for enforcing compliance by third parties with this License. | ||
456 | 452 | |||
457 | 453 | An "entity transaction" is a transaction transferring control of an | ||
458 | 454 | organization, or substantially all assets of one, or subdividing an | ||
459 | 455 | organization, or merging organizations. If propagation of a covered | ||
460 | 456 | work results from an entity transaction, each party to that | ||
461 | 457 | transaction who receives a copy of the work also receives whatever | ||
462 | 458 | licenses to the work the party's predecessor in interest had or could | ||
463 | 459 | give under the previous paragraph, plus a right to possession of the | ||
464 | 460 | Corresponding Source of the work from the predecessor in interest, if | ||
465 | 461 | the predecessor has it or can get it with reasonable efforts. | ||
466 | 462 | |||
467 | 463 | You may not impose any further restrictions on the exercise of the | ||
468 | 464 | rights granted or affirmed under this License. For example, you may | ||
469 | 465 | not impose a license fee, royalty, or other charge for exercise of | ||
470 | 466 | rights granted under this License, and you may not initiate litigation | ||
471 | 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that | ||
472 | 468 | any patent claim is infringed by making, using, selling, offering for | ||
473 | 469 | sale, or importing the Program or any portion of it. | ||
474 | 470 | |||
475 | 471 | 11. Patents. | ||
476 | 472 | |||
477 | 473 | A "contributor" is a copyright holder who authorizes use under this | ||
478 | 474 | License of the Program or a work on which the Program is based. The | ||
479 | 475 | work thus licensed is called the contributor's "contributor version". | ||
480 | 476 | |||
481 | 477 | A contributor's "essential patent claims" are all patent claims | ||
482 | 478 | owned or controlled by the contributor, whether already acquired or | ||
483 | 479 | hereafter acquired, that would be infringed by some manner, permitted | ||
484 | 480 | by this License, of making, using, or selling its contributor version, | ||
485 | 481 | but do not include claims that would be infringed only as a | ||
486 | 482 | consequence of further modification of the contributor version. For | ||
487 | 483 | purposes of this definition, "control" includes the right to grant | ||
488 | 484 | patent sublicenses in a manner consistent with the requirements of | ||
489 | 485 | this License. | ||
490 | 486 | |||
491 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free | ||
492 | 488 | patent license under the contributor's essential patent claims, to | ||
493 | 489 | make, use, sell, offer for sale, import and otherwise run, modify and | ||
494 | 490 | propagate the contents of its contributor version. | ||
495 | 491 | |||
496 | 492 | In the following three paragraphs, a "patent license" is any express | ||
497 | 493 | agreement or commitment, however denominated, not to enforce a patent | ||
498 | 494 | (such as an express permission to practice a patent or covenant not to | ||
499 | 495 | sue for patent infringement). To "grant" such a patent license to a | ||
500 | 496 | party means to make such an agreement or commitment not to enforce a | ||
501 | 497 | patent against the party. | ||
502 | 498 | |||
503 | 499 | If you convey a covered work, knowingly relying on a patent license, | ||
504 | 500 | and the Corresponding Source of the work is not available for anyone | ||
505 | 501 | to copy, free of charge and under the terms of this License, through a | ||
506 | 502 | publicly available network server or other readily accessible means, | ||
507 | 503 | then you must either (1) cause the Corresponding Source to be so | ||
508 | 504 | available, or (2) arrange to deprive yourself of the benefit of the | ||
509 | 505 | patent license for this particular work, or (3) arrange, in a manner | ||
510 | 506 | consistent with the requirements of this License, to extend the patent | ||
511 | 507 | license to downstream recipients. "Knowingly relying" means you have | ||
512 | 508 | actual knowledge that, but for the patent license, your conveying the | ||
513 | 509 | covered work in a country, or your recipient's use of the covered work | ||
514 | 510 | in a country, would infringe one or more identifiable patents in that | ||
515 | 511 | country that you have reason to believe are valid. | ||
516 | 512 | |||
517 | 513 | If, pursuant to or in connection with a single transaction or | ||
518 | 514 | arrangement, you convey, or propagate by procuring conveyance of, a | ||
519 | 515 | covered work, and grant a patent license to some of the parties | ||
520 | 516 | receiving the covered work authorizing them to use, propagate, modify | ||
521 | 517 | or convey a specific copy of the covered work, then the patent license | ||
522 | 518 | you grant is automatically extended to all recipients of the covered | ||
523 | 519 | work and works based on it. | ||
524 | 520 | |||
525 | 521 | A patent license is "discriminatory" if it does not include within | ||
526 | 522 | the scope of its coverage, prohibits the exercise of, or is | ||
527 | 523 | conditioned on the non-exercise of one or more of the rights that are | ||
528 | 524 | specifically granted under this License. You may not convey a covered | ||
529 | 525 | work if you are a party to an arrangement with a third party that is | ||
530 | 526 | in the business of distributing software, under which you make payment | ||
531 | 527 | to the third party based on the extent of your activity of conveying | ||
532 | 528 | the work, and under which the third party grants, to any of the | ||
533 | 529 | parties who would receive the covered work from you, a discriminatory | ||
534 | 530 | patent license (a) in connection with copies of the covered work | ||
535 | 531 | conveyed by you (or copies made from those copies), or (b) primarily | ||
536 | 532 | for and in connection with specific products or compilations that | ||
537 | 533 | contain the covered work, unless you entered into that arrangement, | ||
538 | 534 | or that patent license was granted, prior to 28 March 2007. | ||
539 | 535 | |||
540 | 536 | Nothing in this License shall be construed as excluding or limiting | ||
541 | 537 | any implied license or other defenses to infringement that may | ||
542 | 538 | otherwise be available to you under applicable patent law. | ||
543 | 539 | |||
544 | 540 | 12. No Surrender of Others' Freedom. | ||
545 | 541 | |||
546 | 542 | If conditions are imposed on you (whether by court order, agreement or | ||
547 | 543 | otherwise) that contradict the conditions of this License, they do not | ||
548 | 544 | excuse you from the conditions of this License. If you cannot convey a | ||
549 | 545 | covered work so as to satisfy simultaneously your obligations under this | ||
550 | 546 | License and any other pertinent obligations, then as a consequence you may | ||
551 | 547 | not convey it at all. For example, if you agree to terms that obligate you | ||
552 | 548 | to collect a royalty for further conveying from those to whom you convey | ||
553 | 549 | the Program, the only way you could satisfy both those terms and this | ||
554 | 550 | License would be to refrain entirely from conveying the Program. | ||
555 | 551 | |||
556 | 552 | 13. Use with the GNU Affero General Public License. | ||
557 | 553 | |||
558 | 554 | Notwithstanding any other provision of this License, you have | ||
559 | 555 | permission to link or combine any covered work with a work licensed | ||
560 | 556 | under version 3 of the GNU Affero General Public License into a single | ||
561 | 557 | combined work, and to convey the resulting work. The terms of this | ||
562 | 558 | License will continue to apply to the part which is the covered work, | ||
563 | 559 | but the special requirements of the GNU Affero General Public License, | ||
564 | 560 | section 13, concerning interaction through a network will apply to the | ||
565 | 561 | combination as such. | ||
566 | 562 | |||
567 | 563 | 14. Revised Versions of this License. | ||
568 | 564 | |||
569 | 565 | The Free Software Foundation may publish revised and/or new versions of | ||
570 | 566 | the GNU General Public License from time to time. Such new versions will | ||
571 | 567 | be similar in spirit to the present version, but may differ in detail to | ||
572 | 568 | address new problems or concerns. | ||
573 | 569 | |||
574 | 570 | Each version is given a distinguishing version number. If the | ||
575 | 571 | Program specifies that a certain numbered version of the GNU General | ||
576 | 572 | Public License "or any later version" applies to it, you have the | ||
577 | 573 | option of following the terms and conditions either of that numbered | ||
578 | 574 | version or of any later version published by the Free Software | ||
579 | 575 | Foundation. If the Program does not specify a version number of the | ||
580 | 576 | GNU General Public License, you may choose any version ever published | ||
581 | 577 | by the Free Software Foundation. | ||
582 | 578 | |||
583 | 579 | If the Program specifies that a proxy can decide which future | ||
584 | 580 | versions of the GNU General Public License can be used, that proxy's | ||
585 | 581 | public statement of acceptance of a version permanently authorizes you | ||
586 | 582 | to choose that version for the Program. | ||
587 | 583 | |||
588 | 584 | Later license versions may give you additional or different | ||
589 | 585 | permissions. However, no additional obligations are imposed on any | ||
590 | 586 | author or copyright holder as a result of your choosing to follow a | ||
591 | 587 | later version. | ||
592 | 588 | |||
593 | 589 | 15. Disclaimer of Warranty. | ||
594 | 590 | |||
595 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY | ||
596 | 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT | ||
597 | 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY | ||
598 | 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, | ||
599 | 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
600 | 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM | ||
601 | 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF | ||
602 | 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. | ||
603 | 599 | |||
604 | 600 | 16. Limitation of Liability. | ||
605 | 601 | |||
606 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | ||
607 | 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS | ||
608 | 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY | ||
609 | 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE | ||
610 | 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF | ||
611 | 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD | ||
612 | 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), | ||
613 | 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF | ||
614 | 610 | SUCH DAMAGES. | ||
615 | 611 | |||
616 | 612 | 17. Interpretation of Sections 15 and 16. | ||
617 | 613 | |||
618 | 614 | If the disclaimer of warranty and limitation of liability provided | ||
619 | 615 | above cannot be given local legal effect according to their terms, | ||
620 | 616 | reviewing courts shall apply local law that most closely approximates | ||
621 | 617 | an absolute waiver of all civil liability in connection with the | ||
622 | 618 | Program, unless a warranty or assumption of liability accompanies a | ||
623 | 619 | copy of the Program in return for a fee. | ||
624 | 620 | |||
625 | 621 | END OF TERMS AND CONDITIONS | ||
626 | 622 | |||
627 | 623 | How to Apply These Terms to Your New Programs | ||
628 | 624 | |||
629 | 625 | If you develop a new program, and you want it to be of the greatest | ||
630 | 626 | possible use to the public, the best way to achieve this is to make it | ||
631 | 627 | free software which everyone can redistribute and change under these terms. | ||
632 | 628 | |||
633 | 629 | To do so, attach the following notices to the program. It is safest | ||
634 | 630 | to attach them to the start of each source file to most effectively | ||
635 | 631 | state the exclusion of warranty; and each file should have at least | ||
636 | 632 | the "copyright" line and a pointer to where the full notice is found. | ||
637 | 633 | |||
638 | 634 | <one line to give the program's name and a brief idea of what it does.> | ||
639 | 635 | Copyright (C) <year> <name of author> | ||
640 | 636 | |||
641 | 637 | This program is free software: you can redistribute it and/or modify | ||
642 | 638 | it under the terms of the GNU General Public License as published by | ||
643 | 639 | the Free Software Foundation, either version 3 of the License, or | ||
644 | 640 | (at your option) any later version. | ||
645 | 641 | |||
646 | 642 | This program is distributed in the hope that it will be useful, | ||
647 | 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
648 | 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
649 | 645 | GNU General Public License for more details. | ||
650 | 646 | |||
651 | 647 | You should have received a copy of the GNU General Public License | ||
652 | 648 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
653 | 649 | |||
654 | 650 | Also add information on how to contact you by electronic and paper mail. | ||
655 | 651 | |||
656 | 652 | If the program does terminal interaction, make it output a short | ||
657 | 653 | notice like this when it starts in an interactive mode: | ||
658 | 654 | |||
659 | 655 | <program> Copyright (C) <year> <name of author> | ||
660 | 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | ||
661 | 657 | This is free software, and you are welcome to redistribute it | ||
662 | 658 | under certain conditions; type `show c' for details. | ||
663 | 659 | |||
664 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate | ||
665 | 661 | parts of the General Public License. Of course, your program's commands | ||
666 | 662 | might be different; for a GUI interface, you would use an "about box". | ||
667 | 663 | |||
668 | 664 | You should also get your employer (if you work as a programmer) or school, | ||
669 | 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. | ||
670 | 666 | For more information on this, and how to apply and follow the GNU GPL, see | ||
671 | 667 | <http://www.gnu.org/licenses/>. | ||
672 | 668 | |||
673 | 669 | The GNU General Public License does not permit incorporating your program | ||
674 | 670 | into proprietary programs. If your program is a subroutine library, you | ||
675 | 671 | may consider it more useful to permit linking proprietary applications with | ||
676 | 672 | the library. If this is what you want to do, use the GNU Lesser General | ||
677 | 673 | Public License instead of this License. But first, please read | ||
678 | 674 | <http://www.gnu.org/philosophy/why-not-lgpl.html>. | ||
679 | 675 | 0 | ||
680 | === renamed file 'COPYING.LGPL.3' => 'COPYING' | |||
681 | === modified file 'Makefile.am' | |||
682 | --- Makefile.am 2010-09-15 22:16:00 +0000 | |||
683 | +++ Makefile.am 2010-12-06 15:12:11 +0000 | |||
684 | @@ -1,5 +1,5 @@ | |||
687 | 1 | SUBDIRS = data \ | 1 | SUBDIRS = \ |
688 | 2 | src \ | 2 | src \ |
689 | 3 | bindings \ | 3 | bindings \ |
690 | 4 | example \ | 4 | example \ |
691 | 5 | tests \ | 5 | tests \ |
692 | @@ -12,7 +12,6 @@ | |||
693 | 12 | xmldocs.make \ | 12 | xmldocs.make \ |
694 | 13 | autogen.sh \ | 13 | autogen.sh \ |
695 | 14 | COPYING.LGPL.2.1 \ | 14 | COPYING.LGPL.2.1 \ |
696 | 15 | COPYING.LGPL.3 \ | ||
697 | 16 | ChangeLog | 15 | ChangeLog |
698 | 17 | 16 | ||
699 | 18 | DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-localinstall --enable-introspection | 17 | DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-localinstall --enable-introspection |
700 | 19 | 18 | ||
701 | === modified file 'autogen.sh' | |||
702 | --- autogen.sh 2009-12-09 20:25:32 +0000 | |||
703 | +++ autogen.sh 2010-12-06 15:12:11 +0000 | |||
704 | @@ -1,6 +1,6 @@ | |||
705 | 1 | #!/bin/sh | 1 | #!/bin/sh |
706 | 2 | 2 | ||
708 | 3 | PKG_NAME="indicator-application" | 3 | PKG_NAME="liappindicator" |
709 | 4 | 4 | ||
710 | 5 | which gnome-autogen.sh || { | 5 | which gnome-autogen.sh || { |
711 | 6 | echo "You need gnome-common from GNOME SVN" | 6 | echo "You need gnome-common from GNOME SVN" |
712 | 7 | 7 | ||
713 | === modified file 'configure.ac' | |||
714 | --- configure.ac 2010-12-04 03:43:40 +0000 | |||
715 | +++ configure.ac 2010-12-06 15:12:11 +0000 | |||
716 | @@ -1,11 +1,11 @@ | |||
717 | 1 | 1 | ||
719 | 2 | AC_INIT(indicator-application, 0.2.9, ted@canonical.com) | 2 | AC_INIT(libappindicator, 0.2.90, ted@canonical.com) |
720 | 3 | AC_COPYRIGHT([Copyright 2009, 2010 Canonical]) | 3 | AC_COPYRIGHT([Copyright 2009, 2010 Canonical]) |
721 | 4 | 4 | ||
722 | 5 | AC_PREREQ(2.53) | 5 | AC_PREREQ(2.53) |
723 | 6 | 6 | ||
724 | 7 | AM_CONFIG_HEADER(config.h) | 7 | AM_CONFIG_HEADER(config.h) |
726 | 8 | AM_INIT_AUTOMAKE(indicator-application, 0.2.9) | 8 | AM_INIT_AUTOMAKE(libappindicator, 0.2.90) |
727 | 9 | 9 | ||
728 | 10 | AM_MAINTAINER_MODE | 10 | AM_MAINTAINER_MODE |
729 | 11 | 11 | ||
730 | @@ -41,7 +41,6 @@ | |||
731 | 41 | GTK3_REQUIRED_VERSION=2.91 | 41 | GTK3_REQUIRED_VERSION=2.91 |
732 | 42 | INDICATOR_REQUIRED_VERSION=0.3.5 | 42 | INDICATOR_REQUIRED_VERSION=0.3.5 |
733 | 43 | DBUSMENUGTK_REQUIRED_VERSION=0.2.2 | 43 | DBUSMENUGTK_REQUIRED_VERSION=0.2.2 |
734 | 44 | JSON_GLIB_REQUIRED_VERSION=0.7.6 | ||
735 | 45 | DBUS_GLIB_REQUIRED_VERSION=0.82 | 44 | DBUS_GLIB_REQUIRED_VERSION=0.82 |
736 | 46 | 45 | ||
737 | 47 | AC_ARG_WITH([gtk], | 46 | AC_ARG_WITH([gtk], |
738 | @@ -50,36 +49,26 @@ | |||
739 | 50 | [], | 49 | [], |
740 | 51 | [with_gtk=2]) | 50 | [with_gtk=2]) |
741 | 52 | AS_IF([test "x$with_gtk" = x3], | 51 | AS_IF([test "x$with_gtk" = x3], |
749 | 53 | [PKG_CHECK_MODULES(INDICATOR, gtk+-3.0 >= $GTK3_REQUIRED_VERSION | 52 | [PKG_CHECK_MODULES(LIBRARAY, gtk+-3.0 >= $GTK3_REQUIRED_VERSION |
750 | 54 | indicator3 >= $INDICATOR_REQUIRED_VERSION | 53 | indicator3 >= $INDICATOR_REQUIRED_VERSION |
751 | 55 | json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION | 54 | dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION |
752 | 56 | dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION | 55 | dbusmenu-gtk3 >= $DBUSMENUGTK_REQUIRED_VERSION) |
753 | 57 | dbusmenu-gtk3 >= $DBUSMENUGTK_REQUIRED_VERSION) | 56 | AC_SUBST(LIBRARY_CFLAGS) |
754 | 58 | AC_SUBST(INDICATOR_CFLAGS) | 57 | AC_SUBST(LIBRARY_LIBS) |
748 | 59 | AC_SUBST(INDICATOR_LIBS) | ||
755 | 60 | AC_DEFINE(HAVE_GTK3, 1, [whether gtk3 is available]) | 58 | AC_DEFINE(HAVE_GTK3, 1, [whether gtk3 is available]) |
756 | 61 | ], | 59 | ], |
757 | 62 | [test "x$with_gtk" = x2], | 60 | [test "x$with_gtk" = x2], |
765 | 63 | [PKG_CHECK_MODULES(INDICATOR, gtk+-2.0 >= $GTK_REQUIRED_VERSION | 61 | [PKG_CHECK_MODULES(LIBRARY, gtk+-2.0 >= $GTK_REQUIRED_VERSION |
766 | 64 | indicator >= $INDICATOR_REQUIRED_VERSION | 62 | indicator >= $INDICATOR_REQUIRED_VERSION |
767 | 65 | json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION | 63 | dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION |
768 | 66 | dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION | 64 | dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION) |
769 | 67 | dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION) | 65 | AC_SUBST(LIBRARY_CFLAGS) |
770 | 68 | AC_SUBST(INDICATOR_CFLAGS) | 66 | AC_SUBST(LIBRARY_LIBS) |
764 | 69 | AC_SUBST(INDICATOR_LIBS) | ||
771 | 70 | ], | 67 | ], |
772 | 71 | [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])] | 68 | [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])] |
773 | 72 | ) | 69 | ) |
774 | 73 | AM_CONDITIONAL(USE_GTK3, [test "x$with_gtk" = x3]) | 70 | AM_CONDITIONAL(USE_GTK3, [test "x$with_gtk" = x3]) |
775 | 74 | 71 | ||
776 | 75 | PKG_CHECK_MODULES(LIBRARY, gtk+-2.0 >= $GTK_REQUIRED_VERSION | ||
777 | 76 | indicator >= $INDICATOR_REQUIRED_VERSION | ||
778 | 77 | dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION | ||
779 | 78 | dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION) | ||
780 | 79 | |||
781 | 80 | AC_SUBST(LIBRARY_CFLAGS) | ||
782 | 81 | AC_SUBST(LIBRARY_LIBS) | ||
783 | 82 | |||
784 | 83 | ########################### | 72 | ########################### |
785 | 84 | # GObject Introspection | 73 | # GObject Introspection |
786 | 85 | ########################### | 74 | ########################### |
787 | @@ -164,31 +153,6 @@ | |||
788 | 164 | AC_ARG_ENABLE(localinstall, AS_HELP_STRING([--enable-localinstall], [install all of the files localy instead of system directories (for distcheck)]), with_localinstall=$enableval, with_localinstall=no) | 153 | AC_ARG_ENABLE(localinstall, AS_HELP_STRING([--enable-localinstall], [install all of the files localy instead of system directories (for distcheck)]), with_localinstall=$enableval, with_localinstall=no) |
789 | 165 | 154 | ||
790 | 166 | ########################### | 155 | ########################### |
791 | 167 | # Indicator Info | ||
792 | 168 | ########################### | ||
793 | 169 | |||
794 | 170 | if test "x$with_localinstall" = "xyes"; then | ||
795 | 171 | INDICATORDIR="${libdir}/indicators/2/" | ||
796 | 172 | INDICATORICONSDIR="${datadir}/libindicate/icons/" | ||
797 | 173 | else | ||
798 | 174 | INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator` | ||
799 | 175 | INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator` | ||
800 | 176 | fi | ||
801 | 177 | AC_SUBST(INDICATORDIR) | ||
802 | 178 | AC_SUBST(INDICATORICONSDIR) | ||
803 | 179 | |||
804 | 180 | ########################### | ||
805 | 181 | # DBus Service Info | ||
806 | 182 | ########################### | ||
807 | 183 | |||
808 | 184 | if test "x$with_localinstall" = "xyes"; then | ||
809 | 185 | DBUSSERVICEDIR="${datadir}/dbus-1/services/" | ||
810 | 186 | else | ||
811 | 187 | DBUSSERVICEDIR=`$PKG_CONFIG --variable=session_bus_services_dir dbus-1` | ||
812 | 188 | fi | ||
813 | 189 | AC_SUBST(DBUSSERVICEDIR) | ||
814 | 190 | |||
815 | 191 | ########################### | ||
816 | 192 | # Python | 156 | # Python |
817 | 193 | ########################### | 157 | ########################### |
818 | 194 | 158 | ||
819 | @@ -233,7 +197,6 @@ | |||
820 | 233 | bindings/mono/examples/Makefile | 197 | bindings/mono/examples/Makefile |
821 | 234 | bindings/mono/examples/indicator-example | 198 | bindings/mono/examples/indicator-example |
822 | 235 | bindings/python/Makefile | 199 | bindings/python/Makefile |
823 | 236 | data/Makefile | ||
824 | 237 | tests/Makefile | 200 | tests/Makefile |
825 | 238 | example/Makefile | 201 | example/Makefile |
826 | 239 | docs/Makefile | 202 | docs/Makefile |
827 | @@ -248,9 +211,8 @@ | |||
828 | 248 | 211 | ||
829 | 249 | AC_MSG_NOTICE([ | 212 | AC_MSG_NOTICE([ |
830 | 250 | 213 | ||
832 | 251 | Application Indicator Configuration: | 214 | Libappindicator Configuration: |
833 | 252 | 215 | ||
834 | 253 | Prefix: $prefix | 216 | Prefix: $prefix |
835 | 254 | Indicator Dir: $INDICATORDIR | ||
836 | 255 | GTK+ Version: $with_gtk | 217 | GTK+ Version: $with_gtk |
837 | 256 | ]) | 218 | ]) |
838 | 257 | 219 | ||
839 | === removed directory 'data' | |||
840 | === removed file 'data/Makefile.am' | |||
841 | --- data/Makefile.am 2010-08-10 21:31:39 +0000 | |||
842 | +++ data/Makefile.am 1970-01-01 00:00:00 +0000 | |||
843 | @@ -1,17 +0,0 @@ | |||
844 | 1 | |||
845 | 2 | dbus_servicesdir = $(DBUSSERVICEDIR) | ||
846 | 3 | dbus_services_DATA = indicator-application.service | ||
847 | 4 | |||
848 | 5 | %.service: %.service.in | ||
849 | 6 | sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ | ||
850 | 7 | |||
851 | 8 | overridedir = $(pkgdatadir) | ||
852 | 9 | override_DATA = ordering-override.keyfile | ||
853 | 10 | |||
854 | 11 | EXTRA_DIST = \ | ||
855 | 12 | indicator-application.service.in \ | ||
856 | 13 | ordering-override.keyfile | ||
857 | 14 | |||
858 | 15 | CLEANFILES = \ | ||
859 | 16 | indicator-application.service | ||
860 | 17 | |||
861 | 18 | 0 | ||
862 | === removed file 'data/indicator-application.service.in' | |||
863 | --- data/indicator-application.service.in 2009-11-25 03:52:40 +0000 | |||
864 | +++ data/indicator-application.service.in 1970-01-01 00:00:00 +0000 | |||
865 | @@ -1,3 +0,0 @@ | |||
866 | 1 | [D-BUS Service] | ||
867 | 2 | Name=org.ayatana.indicator.application | ||
868 | 3 | Exec=@libexecdir@/indicator-application-service | ||
869 | 4 | 0 | ||
870 | === removed file 'data/ordering-override.keyfile' | |||
871 | --- data/ordering-override.keyfile 2010-08-20 15:13:35 +0000 | |||
872 | +++ data/ordering-override.keyfile 1970-01-01 00:00:00 +0000 | |||
873 | @@ -1,5 +0,0 @@ | |||
874 | 1 | [Ordering Index Overrides] | ||
875 | 2 | gnome-power-manager=1 | ||
876 | 3 | gst-keyboard-xkb=2 | ||
877 | 4 | gsd-keyboard-xkb=3 | ||
878 | 5 | ibus=4 | ||
879 | 6 | 0 | ||
880 | === modified file 'docs/reference/Makefile.am' | |||
881 | --- docs/reference/Makefile.am 2010-12-03 22:15:12 +0000 | |||
882 | +++ docs/reference/Makefile.am 2010-12-06 15:12:11 +0000 | |||
883 | @@ -90,8 +90,8 @@ | |||
884 | 90 | # signals and properties. | 90 | # signals and properties. |
885 | 91 | # e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) | 91 | # e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) |
886 | 92 | # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) | 92 | # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) |
889 | 93 | GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/src $(INDICATOR_CFLAGS) | 93 | GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/src $(LIBRARY_CFLAGS) |
890 | 94 | GTKDOC_LIBS=$(top_builddir)/src/libappindicator.la $(top_builddir)/src/libapplication.la $(INDICATOR_LIBS) | 94 | GTKDOC_LIBS=$(top_builddir)/src/libappindicator.la $(LIBRARY_LIBS) |
891 | 95 | 95 | ||
892 | 96 | # This includes the standard gtk-doc make rules, copied by gtkdocize. | 96 | # This includes the standard gtk-doc make rules, copied by gtkdocize. |
893 | 97 | include $(top_srcdir)/gtk-doc.local.make | 97 | include $(top_srcdir)/gtk-doc.local.make |
894 | 98 | 98 | ||
895 | === modified file 'example/Makefile.am' | |||
896 | --- example/Makefile.am 2009-11-30 19:12:49 +0000 | |||
897 | +++ example/Makefile.am 2010-12-06 15:12:11 +0000 | |||
898 | @@ -10,10 +10,10 @@ | |||
899 | 10 | simple-client.c | 10 | simple-client.c |
900 | 11 | 11 | ||
901 | 12 | simple_client_CFLAGS = \ | 12 | simple_client_CFLAGS = \ |
903 | 13 | $(INDICATOR_CFLAGS) \ | 13 | $(LIBRARY_CFLAGS) \ |
904 | 14 | -Wall -Werror \ | 14 | -Wall -Werror \ |
905 | 15 | -I$(top_srcdir)/src | 15 | -I$(top_srcdir)/src |
906 | 16 | 16 | ||
907 | 17 | simple_client_LDADD = \ | 17 | simple_client_LDADD = \ |
909 | 18 | $(INDICATOR_LIBS) \ | 18 | $(LIBRARY_LIBS) \ |
910 | 19 | $(top_builddir)/src/libappindicator.la | 19 | $(top_builddir)/src/libappindicator.la |
911 | 20 | 20 | ||
912 | === modified file 'src/Makefile.am' | |||
913 | --- src/Makefile.am 2010-12-04 03:43:40 +0000 | |||
914 | +++ src/Makefile.am 2010-12-06 15:12:11 +0000 | |||
915 | @@ -22,60 +22,12 @@ | |||
916 | 22 | include $(top_srcdir)/Makefile.am.marshal | 22 | include $(top_srcdir)/Makefile.am.marshal |
917 | 23 | 23 | ||
918 | 24 | ################################## | 24 | ################################## |
943 | 25 | # Indicator | 25 | # Marshallers |
944 | 26 | ################################## | 26 | ################################## |
921 | 27 | |||
922 | 28 | applicationlibdir = $(INDICATORDIR) | ||
923 | 29 | applicationlib_LTLIBRARIES = libapplication.la | ||
924 | 30 | libapplication_la_SOURCES = \ | ||
925 | 31 | application-service-marshal.c \ | ||
926 | 32 | dbus-shared.h \ | ||
927 | 33 | indicator-application.c | ||
928 | 34 | libapplication_la_CFLAGS = $(INDICATOR_CFLAGS) \ | ||
929 | 35 | -Wall \ | ||
930 | 36 | -Wl,-Bsymbolic-functions \ | ||
931 | 37 | -Wl,-z,defs \ | ||
932 | 38 | -Wl,--as-needed \ | ||
933 | 39 | -Werror \ | ||
934 | 40 | -DG_LOG_DOMAIN=\"Indicator-Application\" | ||
935 | 41 | libapplication_la_LIBADD = $(INDICATOR_LIBS) | ||
936 | 42 | libapplication_la_LDFLAGS = -module -avoid-version | ||
937 | 43 | |||
938 | 44 | ################################## | ||
939 | 45 | # Service | ||
940 | 46 | ################################## | ||
941 | 47 | |||
942 | 48 | libexec_PROGRAMS = indicator-application-service | ||
945 | 49 | 27 | ||
946 | 50 | BUILT_SOURCES += \ | 28 | BUILT_SOURCES += \ |
947 | 51 | application-service-server.h \ | ||
948 | 52 | application-service-marshal.h \ | 29 | application-service-marshal.h \ |
975 | 53 | application-service-marshal.c \ | 30 | application-service-marshal.c |
950 | 54 | dbus-properties-client.h \ | ||
951 | 55 | notification-item-client.h \ | ||
952 | 56 | notification-watcher-server.h | ||
953 | 57 | |||
954 | 58 | indicator_application_service_SOURCES = \ | ||
955 | 59 | application-service.c \ | ||
956 | 60 | application-service-appstore.h \ | ||
957 | 61 | application-service-appstore.c \ | ||
958 | 62 | application-service-marshal.c \ | ||
959 | 63 | application-service-watcher.h \ | ||
960 | 64 | application-service-watcher.c \ | ||
961 | 65 | app-indicator-enum-types.c \ | ||
962 | 66 | dbus-shared.h \ | ||
963 | 67 | generate-id.h \ | ||
964 | 68 | generate-id.c | ||
965 | 69 | |||
966 | 70 | indicator_application_service_CFLAGS = \ | ||
967 | 71 | $(INDICATOR_CFLAGS) \ | ||
968 | 72 | -DDATADIR="\"$(pkgdatadir)\"" \ | ||
969 | 73 | -Wall -Werror \ | ||
970 | 74 | -DG_LOG_DOMAIN=\"indicator-application-service\" | ||
971 | 75 | |||
972 | 76 | indicator_application_service_LDADD = \ | ||
973 | 77 | $(INDICATOR_LIBS) \ | ||
974 | 78 | libappindicator$(VER).la | ||
976 | 79 | 31 | ||
977 | 80 | glib_marshal_list = application-service-marshal.list | 32 | glib_marshal_list = application-service-marshal.list |
978 | 81 | glib_marshal_prefix = _application_service_marshal | 33 | glib_marshal_prefix = _application_service_marshal |
979 | @@ -111,6 +63,7 @@ | |||
980 | 111 | app-indicator-enum-types.c \ | 63 | app-indicator-enum-types.c \ |
981 | 112 | app-indicator.c \ | 64 | app-indicator.c \ |
982 | 113 | application-service-marshal.c \ | 65 | application-service-marshal.c \ |
983 | 66 | dbus-shared.h \ | ||
984 | 114 | generate-id.h \ | 67 | generate-id.h \ |
985 | 115 | generate-id.c | 68 | generate-id.c |
986 | 116 | 69 | ||
987 | @@ -143,9 +96,6 @@ | |||
988 | 143 | ################################## | 96 | ################################## |
989 | 144 | 97 | ||
990 | 145 | DBUS_SPECS = \ | 98 | DBUS_SPECS = \ |
991 | 146 | dbus-properties.xml \ | ||
992 | 147 | application-service.xml \ | ||
993 | 148 | notification-approver.xml \ | ||
994 | 149 | notification-item.xml \ | 99 | notification-item.xml \ |
995 | 150 | notification-watcher.xml | 100 | notification-watcher.xml |
996 | 151 | 101 | ||
997 | @@ -202,7 +152,7 @@ | |||
998 | 202 | AppIndicator_0_1_gir_INCLUDES = \ | 152 | AppIndicator_0_1_gir_INCLUDES = \ |
999 | 203 | GObject-2.0 \ | 153 | GObject-2.0 \ |
1000 | 204 | $(GTKGIR) | 154 | $(GTKGIR) |
1002 | 205 | AppIndicator_0_1_gir_CFLAGS = $(INDICATOR_CFLAGS) -I$(srcdir) -I$(top_builddir)/src | 155 | AppIndicator_0_1_gir_CFLAGS = $(LIBRARY_CFLAGS) -I$(srcdir) -I$(top_builddir)/src |
1003 | 206 | AppIndicator_0_1_gir_LIBS = libappindicator$(VER).la | 156 | AppIndicator_0_1_gir_LIBS = libappindicator$(VER).la |
1004 | 207 | AppIndicator_0_1_gir_FILES = $(introspection_sources) | 157 | AppIndicator_0_1_gir_FILES = $(introspection_sources) |
1005 | 208 | 158 | ||
1006 | 209 | 159 | ||
1007 | === removed file 'src/application-service-appstore.c' | |||
1008 | --- src/application-service-appstore.c 2010-10-08 15:02:24 +0000 | |||
1009 | +++ src/application-service-appstore.c 1970-01-01 00:00:00 +0000 | |||
1010 | @@ -1,1305 +0,0 @@ | |||
1011 | 1 | /* | ||
1012 | 2 | An object that stores the registration of all the application | ||
1013 | 3 | indicators. It also communicates this to the indicator visualization. | ||
1014 | 4 | |||
1015 | 5 | Copyright 2009 Canonical Ltd. | ||
1016 | 6 | |||
1017 | 7 | Authors: | ||
1018 | 8 | Ted Gould <ted@canonical.com> | ||
1019 | 9 | |||
1020 | 10 | This program is free software: you can redistribute it and/or modify it | ||
1021 | 11 | under the terms of the GNU General Public License version 3, as published | ||
1022 | 12 | by the Free Software Foundation. | ||
1023 | 13 | |||
1024 | 14 | This program is distributed in the hope that it will be useful, but | ||
1025 | 15 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1026 | 16 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1027 | 17 | PURPOSE. See the GNU General Public License for more details. | ||
1028 | 18 | |||
1029 | 19 | You should have received a copy of the GNU General Public License along | ||
1030 | 20 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1031 | 21 | */ | ||
1032 | 22 | |||
1033 | 23 | #ifdef HAVE_CONFIG_H | ||
1034 | 24 | #include "config.h" | ||
1035 | 25 | #endif | ||
1036 | 26 | |||
1037 | 27 | #include <dbus/dbus-glib.h> | ||
1038 | 28 | #include "app-indicator.h" | ||
1039 | 29 | #include "app-indicator-enum-types.h" | ||
1040 | 30 | #include "application-service-appstore.h" | ||
1041 | 31 | #include "application-service-marshal.h" | ||
1042 | 32 | #include "dbus-properties-client.h" | ||
1043 | 33 | #include "dbus-shared.h" | ||
1044 | 34 | #include "notification-approver-client.h" | ||
1045 | 35 | #include "generate-id.h" | ||
1046 | 36 | |||
1047 | 37 | /* DBus Prototypes */ | ||
1048 | 38 | static gboolean _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps, GError ** error); | ||
1049 | 39 | |||
1050 | 40 | #include "application-service-server.h" | ||
1051 | 41 | |||
1052 | 42 | #define NOTIFICATION_ITEM_PROP_ID "Id" | ||
1053 | 43 | #define NOTIFICATION_ITEM_PROP_CATEGORY "Category" | ||
1054 | 44 | #define NOTIFICATION_ITEM_PROP_STATUS "Status" | ||
1055 | 45 | #define NOTIFICATION_ITEM_PROP_ICON_NAME "IconName" | ||
1056 | 46 | #define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName" | ||
1057 | 47 | #define NOTIFICATION_ITEM_PROP_ICON_THEME_PATH "IconThemePath" | ||
1058 | 48 | #define NOTIFICATION_ITEM_PROP_MENU "Menu" | ||
1059 | 49 | #define NOTIFICATION_ITEM_PROP_LABEL "XAyatanaLabel" | ||
1060 | 50 | #define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "XAyatanaLabelGuide" | ||
1061 | 51 | #define NOTIFICATION_ITEM_PROP_ORDERING_INDEX "XAyatanaOrderingIndex" | ||
1062 | 52 | |||
1063 | 53 | #define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon" | ||
1064 | 54 | #define NOTIFICATION_ITEM_SIG_NEW_AICON "NewAttentionIcon" | ||
1065 | 55 | #define NOTIFICATION_ITEM_SIG_NEW_STATUS "NewStatus" | ||
1066 | 56 | #define NOTIFICATION_ITEM_SIG_NEW_LABEL "XAyatanaNewLabel" | ||
1067 | 57 | #define NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH "NewIconThemePath" | ||
1068 | 58 | |||
1069 | 59 | #define OVERRIDE_GROUP_NAME "Ordering Index Overrides" | ||
1070 | 60 | #define OVERRIDE_FILE_NAME "ordering-override.keyfile" | ||
1071 | 61 | |||
1072 | 62 | /* Private Stuff */ | ||
1073 | 63 | struct _ApplicationServiceAppstorePrivate { | ||
1074 | 64 | DBusGConnection * bus; | ||
1075 | 65 | GList * applications; | ||
1076 | 66 | GList * approvers; | ||
1077 | 67 | GHashTable * ordering_overrides; | ||
1078 | 68 | }; | ||
1079 | 69 | |||
1080 | 70 | typedef enum { | ||
1081 | 71 | VISIBLE_STATE_HIDDEN, | ||
1082 | 72 | VISIBLE_STATE_SHOWN | ||
1083 | 73 | } visible_state_t; | ||
1084 | 74 | |||
1085 | 75 | #define STATE2STRING(x) ((x) == VISIBLE_STATE_HIDDEN ? "hidden" : "visible") | ||
1086 | 76 | |||
1087 | 77 | typedef struct _Approver Approver; | ||
1088 | 78 | struct _Approver { | ||
1089 | 79 | DBusGProxy * proxy; | ||
1090 | 80 | gboolean destroy_by_proxy; | ||
1091 | 81 | }; | ||
1092 | 82 | |||
1093 | 83 | typedef struct _Application Application; | ||
1094 | 84 | struct _Application { | ||
1095 | 85 | gchar * id; | ||
1096 | 86 | gchar * category; | ||
1097 | 87 | gchar * dbus_name; | ||
1098 | 88 | gchar * dbus_object; | ||
1099 | 89 | ApplicationServiceAppstore * appstore; /* not ref'd */ | ||
1100 | 90 | DBusGProxy * dbus_proxy; | ||
1101 | 91 | DBusGProxy * prop_proxy; | ||
1102 | 92 | gboolean validated; /* Whether we've gotten all the parameters and they look good. */ | ||
1103 | 93 | AppIndicatorStatus status; | ||
1104 | 94 | gchar * icon; | ||
1105 | 95 | gchar * aicon; | ||
1106 | 96 | gchar * menu; | ||
1107 | 97 | gchar * icon_theme_path; | ||
1108 | 98 | gchar * label; | ||
1109 | 99 | gchar * guide; | ||
1110 | 100 | gboolean currently_free; | ||
1111 | 101 | guint ordering_index; | ||
1112 | 102 | GList * approved_by; | ||
1113 | 103 | visible_state_t visible_state; | ||
1114 | 104 | }; | ||
1115 | 105 | |||
1116 | 106 | #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ | ||
1117 | 107 | (G_TYPE_INSTANCE_GET_PRIVATE ((o), APPLICATION_SERVICE_APPSTORE_TYPE, ApplicationServiceAppstorePrivate)) | ||
1118 | 108 | |||
1119 | 109 | /* Signals Stuff */ | ||
1120 | 110 | enum { | ||
1121 | 111 | APPLICATION_ADDED, | ||
1122 | 112 | APPLICATION_REMOVED, | ||
1123 | 113 | APPLICATION_ICON_CHANGED, | ||
1124 | 114 | APPLICATION_LABEL_CHANGED, | ||
1125 | 115 | APPLICATION_ICON_THEME_PATH_CHANGED, | ||
1126 | 116 | LAST_SIGNAL | ||
1127 | 117 | }; | ||
1128 | 118 | |||
1129 | 119 | static guint signals[LAST_SIGNAL] = { 0 }; | ||
1130 | 120 | |||
1131 | 121 | /* GObject stuff */ | ||
1132 | 122 | static void application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass); | ||
1133 | 123 | static void application_service_appstore_init (ApplicationServiceAppstore *self); | ||
1134 | 124 | static void application_service_appstore_dispose (GObject *object); | ||
1135 | 125 | static void application_service_appstore_finalize (GObject *object); | ||
1136 | 126 | static gint app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata); | ||
1137 | 127 | static void load_override_file (GHashTable * hash, const gchar * filename); | ||
1138 | 128 | static AppIndicatorStatus string_to_status(const gchar * status_string); | ||
1139 | 129 | static void apply_status (Application * app); | ||
1140 | 130 | static AppIndicatorCategory string_to_cat(const gchar * cat_string); | ||
1141 | 131 | static void approver_free (gpointer papprover, gpointer user_data); | ||
1142 | 132 | static void check_with_new_approver (gpointer papp, gpointer papprove); | ||
1143 | 133 | static void check_with_old_approver (gpointer papprove, gpointer papp); | ||
1144 | 134 | static Application * find_application (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * object); | ||
1145 | 135 | |||
1146 | 136 | G_DEFINE_TYPE (ApplicationServiceAppstore, application_service_appstore, G_TYPE_OBJECT); | ||
1147 | 137 | |||
1148 | 138 | static void | ||
1149 | 139 | application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass) | ||
1150 | 140 | { | ||
1151 | 141 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
1152 | 142 | |||
1153 | 143 | g_type_class_add_private (klass, sizeof (ApplicationServiceAppstorePrivate)); | ||
1154 | 144 | |||
1155 | 145 | object_class->dispose = application_service_appstore_dispose; | ||
1156 | 146 | object_class->finalize = application_service_appstore_finalize; | ||
1157 | 147 | |||
1158 | 148 | signals[APPLICATION_ADDED] = g_signal_new ("application-added", | ||
1159 | 149 | G_TYPE_FROM_CLASS(klass), | ||
1160 | 150 | G_SIGNAL_RUN_LAST, | ||
1161 | 151 | G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_added), | ||
1162 | 152 | NULL, NULL, | ||
1163 | 153 | _application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING_STRING_STRING, | ||
1164 | 154 | G_TYPE_NONE, 7, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); | ||
1165 | 155 | signals[APPLICATION_REMOVED] = g_signal_new ("application-removed", | ||
1166 | 156 | G_TYPE_FROM_CLASS(klass), | ||
1167 | 157 | G_SIGNAL_RUN_LAST, | ||
1168 | 158 | G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_removed), | ||
1169 | 159 | NULL, NULL, | ||
1170 | 160 | g_cclosure_marshal_VOID__INT, | ||
1171 | 161 | G_TYPE_NONE, 1, G_TYPE_INT, G_TYPE_NONE); | ||
1172 | 162 | signals[APPLICATION_ICON_CHANGED] = g_signal_new ("application-icon-changed", | ||
1173 | 163 | G_TYPE_FROM_CLASS(klass), | ||
1174 | 164 | G_SIGNAL_RUN_LAST, | ||
1175 | 165 | G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_icon_changed), | ||
1176 | 166 | NULL, NULL, | ||
1177 | 167 | _application_service_marshal_VOID__INT_STRING, | ||
1178 | 168 | G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING, G_TYPE_NONE); | ||
1179 | 169 | signals[APPLICATION_ICON_THEME_PATH_CHANGED] = g_signal_new ("application-icon-theme-path-changed", | ||
1180 | 170 | G_TYPE_FROM_CLASS(klass), | ||
1181 | 171 | G_SIGNAL_RUN_LAST, | ||
1182 | 172 | G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_icon_theme_path_changed), | ||
1183 | 173 | NULL, NULL, | ||
1184 | 174 | _application_service_marshal_VOID__INT_STRING, | ||
1185 | 175 | G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING, G_TYPE_NONE); | ||
1186 | 176 | signals[APPLICATION_LABEL_CHANGED] = g_signal_new ("application-label-changed", | ||
1187 | 177 | G_TYPE_FROM_CLASS(klass), | ||
1188 | 178 | G_SIGNAL_RUN_LAST, | ||
1189 | 179 | G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_label_changed), | ||
1190 | 180 | NULL, NULL, | ||
1191 | 181 | _application_service_marshal_VOID__INT_STRING_STRING, | ||
1192 | 182 | G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); | ||
1193 | 183 | |||
1194 | 184 | dbus_g_object_register_marshaller(_application_service_marshal_VOID__STRING_STRING, | ||
1195 | 185 | G_TYPE_NONE, | ||
1196 | 186 | G_TYPE_STRING, | ||
1197 | 187 | G_TYPE_STRING, | ||
1198 | 188 | G_TYPE_INVALID); | ||
1199 | 189 | dbus_g_object_register_marshaller(_application_service_marshal_VOID__BOOLEAN_STRING_OBJECT, | ||
1200 | 190 | G_TYPE_NONE, | ||
1201 | 191 | G_TYPE_BOOLEAN, | ||
1202 | 192 | G_TYPE_STRING, | ||
1203 | 193 | G_TYPE_OBJECT, | ||
1204 | 194 | G_TYPE_INVALID); | ||
1205 | 195 | |||
1206 | 196 | dbus_g_object_type_install_info(APPLICATION_SERVICE_APPSTORE_TYPE, | ||
1207 | 197 | &dbus_glib__application_service_server_object_info); | ||
1208 | 198 | |||
1209 | 199 | return; | ||
1210 | 200 | } | ||
1211 | 201 | |||
1212 | 202 | static void | ||
1213 | 203 | application_service_appstore_init (ApplicationServiceAppstore *self) | ||
1214 | 204 | { | ||
1215 | 205 | |||
1216 | 206 | ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE (self); | ||
1217 | 207 | |||
1218 | 208 | priv->applications = NULL; | ||
1219 | 209 | priv->approvers = NULL; | ||
1220 | 210 | |||
1221 | 211 | priv->ordering_overrides = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | ||
1222 | 212 | |||
1223 | 213 | load_override_file(priv->ordering_overrides, DATADIR "/" OVERRIDE_FILE_NAME); | ||
1224 | 214 | gchar * userfile = g_build_filename(g_get_user_data_dir(), "indicators", "application", OVERRIDE_FILE_NAME, NULL); | ||
1225 | 215 | load_override_file(priv->ordering_overrides, userfile); | ||
1226 | 216 | g_free(userfile); | ||
1227 | 217 | |||
1228 | 218 | GError * error = NULL; | ||
1229 | 219 | priv->bus = dbus_g_bus_get(DBUS_BUS_STARTER, &error); | ||
1230 | 220 | if (error != NULL) { | ||
1231 | 221 | g_error("Unable to get session bus: %s", error->message); | ||
1232 | 222 | g_error_free(error); | ||
1233 | 223 | return; | ||
1234 | 224 | } | ||
1235 | 225 | |||
1236 | 226 | dbus_g_connection_register_g_object(priv->bus, | ||
1237 | 227 | INDICATOR_APPLICATION_DBUS_OBJ, | ||
1238 | 228 | G_OBJECT(self)); | ||
1239 | 229 | |||
1240 | 230 | self->priv = priv; | ||
1241 | 231 | |||
1242 | 232 | return; | ||
1243 | 233 | } | ||
1244 | 234 | |||
1245 | 235 | static void | ||
1246 | 236 | application_service_appstore_dispose (GObject *object) | ||
1247 | 237 | { | ||
1248 | 238 | ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE(object)->priv; | ||
1249 | 239 | |||
1250 | 240 | while (priv->applications != NULL) { | ||
1251 | 241 | application_service_appstore_application_remove(APPLICATION_SERVICE_APPSTORE(object), | ||
1252 | 242 | ((Application *)priv->applications->data)->dbus_name, | ||
1253 | 243 | ((Application *)priv->applications->data)->dbus_object); | ||
1254 | 244 | } | ||
1255 | 245 | |||
1256 | 246 | if (priv->approvers != NULL) { | ||
1257 | 247 | g_list_foreach(priv->approvers, approver_free, object); | ||
1258 | 248 | g_list_free(priv->approvers); | ||
1259 | 249 | priv->approvers = NULL; | ||
1260 | 250 | } | ||
1261 | 251 | |||
1262 | 252 | G_OBJECT_CLASS (application_service_appstore_parent_class)->dispose (object); | ||
1263 | 253 | return; | ||
1264 | 254 | } | ||
1265 | 255 | |||
1266 | 256 | static void | ||
1267 | 257 | application_service_appstore_finalize (GObject *object) | ||
1268 | 258 | { | ||
1269 | 259 | ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE(object)->priv; | ||
1270 | 260 | |||
1271 | 261 | if (priv->ordering_overrides != NULL) { | ||
1272 | 262 | g_hash_table_destroy(priv->ordering_overrides); | ||
1273 | 263 | priv->ordering_overrides = NULL; | ||
1274 | 264 | } | ||
1275 | 265 | |||
1276 | 266 | G_OBJECT_CLASS (application_service_appstore_parent_class)->finalize (object); | ||
1277 | 267 | return; | ||
1278 | 268 | } | ||
1279 | 269 | |||
1280 | 270 | /* Loads the file and adds the override entries to the table | ||
1281 | 271 | of overrides */ | ||
1282 | 272 | static void | ||
1283 | 273 | load_override_file (GHashTable * hash, const gchar * filename) | ||
1284 | 274 | { | ||
1285 | 275 | g_return_if_fail(hash != NULL); | ||
1286 | 276 | g_return_if_fail(filename != NULL); | ||
1287 | 277 | |||
1288 | 278 | if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | ||
1289 | 279 | return; | ||
1290 | 280 | } | ||
1291 | 281 | |||
1292 | 282 | g_debug("Loading overrides from: '%s'", filename); | ||
1293 | 283 | |||
1294 | 284 | GError * error = NULL; | ||
1295 | 285 | GKeyFile * keyfile = g_key_file_new(); | ||
1296 | 286 | g_key_file_load_from_file(keyfile, filename, G_KEY_FILE_NONE, &error); | ||
1297 | 287 | |||
1298 | 288 | if (error != NULL) { | ||
1299 | 289 | g_warning("Unable to load keyfile '%s' because: %s", filename, error->message); | ||
1300 | 290 | g_error_free(error); | ||
1301 | 291 | g_key_file_free(keyfile); | ||
1302 | 292 | return; | ||
1303 | 293 | } | ||
1304 | 294 | |||
1305 | 295 | gchar ** keys = g_key_file_get_keys(keyfile, OVERRIDE_GROUP_NAME, NULL, &error); | ||
1306 | 296 | if (error != NULL) { | ||
1307 | 297 | g_warning("Unable to get keys from keyfile '%s' because: %s", filename, error->message); | ||
1308 | 298 | g_error_free(error); | ||
1309 | 299 | g_key_file_free(keyfile); | ||
1310 | 300 | return; | ||
1311 | 301 | } | ||
1312 | 302 | |||
1313 | 303 | gchar * key = keys[0]; | ||
1314 | 304 | gint i; | ||
1315 | 305 | |||
1316 | 306 | for (i = 0; (key = keys[i]) != NULL; i++) { | ||
1317 | 307 | GError * valerror = NULL; | ||
1318 | 308 | gint val = g_key_file_get_integer(keyfile, OVERRIDE_GROUP_NAME, key, &valerror); | ||
1319 | 309 | |||
1320 | 310 | if (valerror != NULL) { | ||
1321 | 311 | g_warning("Unable to get key '%s' out of file '%s' because: %s", key, filename, valerror->message); | ||
1322 | 312 | g_error_free(valerror); | ||
1323 | 313 | continue; | ||
1324 | 314 | } | ||
1325 | 315 | g_debug("%s: override '%s' with value '%d'", filename, key, val); | ||
1326 | 316 | |||
1327 | 317 | g_hash_table_insert(hash, g_strdup(key), GINT_TO_POINTER(val)); | ||
1328 | 318 | } | ||
1329 | 319 | g_strfreev(keys); | ||
1330 | 320 | g_key_file_free(keyfile); | ||
1331 | 321 | |||
1332 | 322 | return; | ||
1333 | 323 | } | ||
1334 | 324 | |||
1335 | 325 | /* Return from getting the properties from the item. We're looking at those | ||
1336 | 326 | and making sure we have everythign that we need. If we do, then we'll | ||
1337 | 327 | move on up to sending this onto the indicator. */ | ||
1338 | 328 | static void | ||
1339 | 329 | get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data) | ||
1340 | 330 | { | ||
1341 | 331 | if (error != NULL) { | ||
1342 | 332 | g_warning("Unable to get properties: %s", error->message); | ||
1343 | 333 | /* TODO: We need to free all the application data here */ | ||
1344 | 334 | return; | ||
1345 | 335 | } | ||
1346 | 336 | |||
1347 | 337 | Application * app = (Application *)data; | ||
1348 | 338 | |||
1349 | 339 | if (g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_MENU) == NULL || | ||
1350 | 340 | g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ID) == NULL || | ||
1351 | 341 | g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_CATEGORY) == NULL || | ||
1352 | 342 | g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_STATUS) == NULL || | ||
1353 | 343 | g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME) == NULL) { | ||
1354 | 344 | g_warning("Notification Item on object %s of %s doesn't have enough properties.", app->dbus_object, app->dbus_name); | ||
1355 | 345 | g_free(app); // Need to do more than this, but it gives the idea of the flow we're going for. | ||
1356 | 346 | return; | ||
1357 | 347 | } | ||
1358 | 348 | |||
1359 | 349 | app->validated = TRUE; | ||
1360 | 350 | |||
1361 | 351 | app->id = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ID)); | ||
1362 | 352 | app->category = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_CATEGORY)); | ||
1363 | 353 | app->status = string_to_status(g_value_get_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_STATUS))); | ||
1364 | 354 | |||
1365 | 355 | ApplicationServiceAppstorePrivate * priv = app->appstore->priv; | ||
1366 | 356 | |||
1367 | 357 | app->icon = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME)); | ||
1368 | 358 | |||
1369 | 359 | GValue * menuval = (GValue *)g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_MENU); | ||
1370 | 360 | if (G_VALUE_TYPE(menuval) == G_TYPE_STRING) { | ||
1371 | 361 | /* This is here to support an older version where we | ||
1372 | 362 | were using strings instea of object paths. */ | ||
1373 | 363 | app->menu = g_value_dup_string(menuval); | ||
1374 | 364 | } else { | ||
1375 | 365 | app->menu = g_strdup((gchar *)g_value_get_boxed(menuval)); | ||
1376 | 366 | } | ||
1377 | 367 | |||
1378 | 368 | if (g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_AICON_NAME) != NULL) { | ||
1379 | 369 | app->aicon = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_AICON_NAME)); | ||
1380 | 370 | } | ||
1381 | 371 | |||
1382 | 372 | gpointer icon_theme_path_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_THEME_PATH); | ||
1383 | 373 | if (icon_theme_path_data != NULL) { | ||
1384 | 374 | app->icon_theme_path = g_value_dup_string((GValue *)icon_theme_path_data); | ||
1385 | 375 | } else { | ||
1386 | 376 | app->icon_theme_path = g_strdup(""); | ||
1387 | 377 | } | ||
1388 | 378 | |||
1389 | 379 | gpointer ordering_index_over = g_hash_table_lookup(priv->ordering_overrides, app->id); | ||
1390 | 380 | if (ordering_index_over == NULL) { | ||
1391 | 381 | gpointer ordering_index_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ORDERING_INDEX); | ||
1392 | 382 | if (ordering_index_data == NULL || g_value_get_uint(ordering_index_data) == 0) { | ||
1393 | 383 | app->ordering_index = generate_id(string_to_cat(app->category), app->id); | ||
1394 | 384 | } else { | ||
1395 | 385 | app->ordering_index = g_value_get_uint(ordering_index_data); | ||
1396 | 386 | } | ||
1397 | 387 | } else { | ||
1398 | 388 | app->ordering_index = GPOINTER_TO_UINT(ordering_index_over); | ||
1399 | 389 | } | ||
1400 | 390 | g_debug("'%s' ordering index is '%X'", app->id, app->ordering_index); | ||
1401 | 391 | |||
1402 | 392 | gpointer label_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_LABEL); | ||
1403 | 393 | if (label_data != NULL) { | ||
1404 | 394 | app->label = g_value_dup_string((GValue *)label_data); | ||
1405 | 395 | } else { | ||
1406 | 396 | app->label = g_strdup(""); | ||
1407 | 397 | } | ||
1408 | 398 | |||
1409 | 399 | gpointer guide_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_LABEL_GUIDE); | ||
1410 | 400 | if (guide_data != NULL) { | ||
1411 | 401 | app->guide = g_value_dup_string((GValue *)guide_data); | ||
1412 | 402 | } else { | ||
1413 | 403 | app->guide = g_strdup(""); | ||
1414 | 404 | } | ||
1415 | 405 | |||
1416 | 406 | priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, NULL); | ||
1417 | 407 | g_list_foreach(priv->approvers, check_with_old_approver, app); | ||
1418 | 408 | |||
1419 | 409 | apply_status(app); | ||
1420 | 410 | |||
1421 | 411 | return; | ||
1422 | 412 | } | ||
1423 | 413 | |||
1424 | 414 | /* Check the application against an approver */ | ||
1425 | 415 | static void | ||
1426 | 416 | check_with_old_approver (gpointer papprove, gpointer papp) | ||
1427 | 417 | { | ||
1428 | 418 | /* Funny the parallels, eh? */ | ||
1429 | 419 | check_with_new_approver(papp, papprove); | ||
1430 | 420 | return; | ||
1431 | 421 | } | ||
1432 | 422 | |||
1433 | 423 | /* Simple translation function -- could be optimized */ | ||
1434 | 424 | static AppIndicatorStatus | ||
1435 | 425 | string_to_status(const gchar * status_string) | ||
1436 | 426 | { | ||
1437 | 427 | GEnumClass * klass = G_ENUM_CLASS(g_type_class_ref(APP_INDICATOR_TYPE_INDICATOR_STATUS)); | ||
1438 | 428 | g_return_val_if_fail(klass != NULL, APP_INDICATOR_STATUS_PASSIVE); | ||
1439 | 429 | |||
1440 | 430 | AppIndicatorStatus retval = APP_INDICATOR_STATUS_PASSIVE; | ||
1441 | 431 | |||
1442 | 432 | GEnumValue * val = g_enum_get_value_by_nick(klass, status_string); | ||
1443 | 433 | if (val == NULL) { | ||
1444 | 434 | g_warning("Unrecognized status '%s' assuming passive.", status_string); | ||
1445 | 435 | } else { | ||
1446 | 436 | retval = (AppIndicatorStatus)val->value; | ||
1447 | 437 | } | ||
1448 | 438 | |||
1449 | 439 | g_type_class_unref(klass); | ||
1450 | 440 | |||
1451 | 441 | return retval; | ||
1452 | 442 | } | ||
1453 | 443 | |||
1454 | 444 | /* Simple translation function -- could be optimized */ | ||
1455 | 445 | static AppIndicatorCategory | ||
1456 | 446 | string_to_cat(const gchar * cat_string) | ||
1457 | 447 | { | ||
1458 | 448 | GEnumClass * klass = G_ENUM_CLASS(g_type_class_ref(APP_INDICATOR_TYPE_INDICATOR_CATEGORY)); | ||
1459 | 449 | g_return_val_if_fail(klass != NULL, APP_INDICATOR_CATEGORY_OTHER); | ||
1460 | 450 | |||
1461 | 451 | AppIndicatorCategory retval = APP_INDICATOR_CATEGORY_OTHER; | ||
1462 | 452 | |||
1463 | 453 | GEnumValue * val = g_enum_get_value_by_nick(klass, cat_string); | ||
1464 | 454 | if (val == NULL) { | ||
1465 | 455 | g_warning("Unrecognized status '%s' assuming other.", cat_string); | ||
1466 | 456 | } else { | ||
1467 | 457 | retval = (AppIndicatorCategory)val->value; | ||
1468 | 458 | } | ||
1469 | 459 | |||
1470 | 460 | g_type_class_unref(klass); | ||
1471 | 461 | |||
1472 | 462 | return retval; | ||
1473 | 463 | } | ||
1474 | 464 | |||
1475 | 465 | |||
1476 | 466 | /* A small helper function to get the position of an application | ||
1477 | 467 | in the app list of the applications that are visible. */ | ||
1478 | 468 | static gint | ||
1479 | 469 | get_position (Application * app) { | ||
1480 | 470 | ApplicationServiceAppstore * appstore = app->appstore; | ||
1481 | 471 | ApplicationServiceAppstorePrivate * priv = appstore->priv; | ||
1482 | 472 | |||
1483 | 473 | GList * lapp; | ||
1484 | 474 | gint count; | ||
1485 | 475 | |||
1486 | 476 | /* Go through the list and try to find ours */ | ||
1487 | 477 | for (lapp = priv->applications, count = 0; lapp != NULL; lapp = g_list_next(lapp), count++) { | ||
1488 | 478 | if (lapp->data == app) { | ||
1489 | 479 | break; | ||
1490 | 480 | } | ||
1491 | 481 | |||
1492 | 482 | /* If the selected app isn't visible let's not | ||
1493 | 483 | count it's position */ | ||
1494 | 484 | Application * thisapp = (Application *)(lapp->data); | ||
1495 | 485 | if (thisapp->visible_state == VISIBLE_STATE_HIDDEN) { | ||
1496 | 486 | count--; | ||
1497 | 487 | } | ||
1498 | 488 | } | ||
1499 | 489 | |||
1500 | 490 | if (lapp == NULL) { | ||
1501 | 491 | g_warning("Unable to find position for app '%s'", app->id); | ||
1502 | 492 | return -1; | ||
1503 | 493 | } | ||
1504 | 494 | |||
1505 | 495 | return count; | ||
1506 | 496 | } | ||
1507 | 497 | |||
1508 | 498 | /* A simple global function for dealing with freeing the information | ||
1509 | 499 | in an Application structure */ | ||
1510 | 500 | static void | ||
1511 | 501 | application_free (Application * app) | ||
1512 | 502 | { | ||
1513 | 503 | if (app == NULL) return; | ||
1514 | 504 | g_debug("Application free '%s'", app->id); | ||
1515 | 505 | |||
1516 | 506 | /* Handle the case where this could be called by unref'ing one of | ||
1517 | 507 | the proxy objects. */ | ||
1518 | 508 | if (app->currently_free) return; | ||
1519 | 509 | app->currently_free = TRUE; | ||
1520 | 510 | |||
1521 | 511 | if (app->dbus_proxy) { | ||
1522 | 512 | g_object_unref(app->dbus_proxy); | ||
1523 | 513 | } | ||
1524 | 514 | if (app->prop_proxy) { | ||
1525 | 515 | g_object_unref(app->prop_proxy); | ||
1526 | 516 | } | ||
1527 | 517 | |||
1528 | 518 | if (app->id != NULL) { | ||
1529 | 519 | g_free(app->id); | ||
1530 | 520 | } | ||
1531 | 521 | if (app->category != NULL) { | ||
1532 | 522 | g_free(app->category); | ||
1533 | 523 | } | ||
1534 | 524 | if (app->dbus_name != NULL) { | ||
1535 | 525 | g_free(app->dbus_name); | ||
1536 | 526 | } | ||
1537 | 527 | if (app->dbus_object != NULL) { | ||
1538 | 528 | g_free(app->dbus_object); | ||
1539 | 529 | } | ||
1540 | 530 | if (app->icon != NULL) { | ||
1541 | 531 | g_free(app->icon); | ||
1542 | 532 | } | ||
1543 | 533 | if (app->aicon != NULL) { | ||
1544 | 534 | g_free(app->aicon); | ||
1545 | 535 | } | ||
1546 | 536 | if (app->menu != NULL) { | ||
1547 | 537 | g_free(app->menu); | ||
1548 | 538 | } | ||
1549 | 539 | if (app->icon_theme_path != NULL) { | ||
1550 | 540 | g_free(app->icon_theme_path); | ||
1551 | 541 | } | ||
1552 | 542 | if (app->label != NULL) { | ||
1553 | 543 | g_free(app->label); | ||
1554 | 544 | } | ||
1555 | 545 | if (app->guide != NULL) { | ||
1556 | 546 | g_free(app->guide); | ||
1557 | 547 | } | ||
1558 | 548 | if (app->approved_by != NULL) { | ||
1559 | 549 | g_list_free(app->approved_by); | ||
1560 | 550 | } | ||
1561 | 551 | |||
1562 | 552 | g_free(app); | ||
1563 | 553 | return; | ||
1564 | 554 | } | ||
1565 | 555 | |||
1566 | 556 | /* Gets called when the proxy is destroyed, which is usually when it | ||
1567 | 557 | drops off of the bus. */ | ||
1568 | 558 | static void | ||
1569 | 559 | application_removed_cb (DBusGProxy * proxy, gpointer userdata) | ||
1570 | 560 | { | ||
1571 | 561 | Application * app = (Application *)userdata; | ||
1572 | 562 | g_debug("Application proxy destroyed '%s'", app->id); | ||
1573 | 563 | |||
1574 | 564 | /* Remove from the panel */ | ||
1575 | 565 | app->status = APP_INDICATOR_STATUS_PASSIVE; | ||
1576 | 566 | apply_status(app); | ||
1577 | 567 | |||
1578 | 568 | /* Remove from the application list */ | ||
1579 | 569 | app->appstore->priv->applications = g_list_remove(app->appstore->priv->applications, app); | ||
1580 | 570 | |||
1581 | 571 | /* Destroy the data */ | ||
1582 | 572 | application_free(app); | ||
1583 | 573 | return; | ||
1584 | 574 | } | ||
1585 | 575 | |||
1586 | 576 | /* This function takes two Application structure | ||
1587 | 577 | pointers and uses their ordering index to compare them. */ | ||
1588 | 578 | static gint | ||
1589 | 579 | app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata) | ||
1590 | 580 | { | ||
1591 | 581 | Application * appa = (Application *)a; | ||
1592 | 582 | Application * appb = (Application *)b; | ||
1593 | 583 | return (appb->ordering_index/2) - (appa->ordering_index/2); | ||
1594 | 584 | } | ||
1595 | 585 | |||
1596 | 586 | /* Change the status of the application. If we're going passive | ||
1597 | 587 | it removes it from the panel. If we're coming online, then | ||
1598 | 588 | it add it to the panel. Otherwise it changes the icon. */ | ||
1599 | 589 | static void | ||
1600 | 590 | apply_status (Application * app) | ||
1601 | 591 | { | ||
1602 | 592 | ApplicationServiceAppstore * appstore = app->appstore; | ||
1603 | 593 | ApplicationServiceAppstorePrivate * priv = appstore->priv; | ||
1604 | 594 | |||
1605 | 595 | /* g_debug("Applying status. Status: %d Approved by: %d Approvers: %d Visible: %d", app->status, g_list_length(app->approved_by), g_list_length(priv->approvers), app->visible_state); */ | ||
1606 | 596 | |||
1607 | 597 | visible_state_t goal_state = VISIBLE_STATE_HIDDEN; | ||
1608 | 598 | |||
1609 | 599 | if (app->status != APP_INDICATOR_STATUS_PASSIVE && | ||
1610 | 600 | g_list_length(app->approved_by) >= g_list_length(priv->approvers)) { | ||
1611 | 601 | goal_state = VISIBLE_STATE_SHOWN; | ||
1612 | 602 | } | ||
1613 | 603 | |||
1614 | 604 | /* Nothing needs to change, we're good */ | ||
1615 | 605 | if (app->visible_state == goal_state /* ) { */ | ||
1616 | 606 | && goal_state == VISIBLE_STATE_HIDDEN) { | ||
1617 | 607 | /* TODO: Uhg, this is a little wrong in that we're going to | ||
1618 | 608 | send an icon every time the status changes and the indicator | ||
1619 | 609 | is visible even though it might not be updating. But, at | ||
1620 | 610 | this point we need a small patch that is harmless. In the | ||
1621 | 611 | future we need to track which icon is shown and remove the | ||
1622 | 612 | duplicate message. */ | ||
1623 | 613 | return; | ||
1624 | 614 | } | ||
1625 | 615 | |||
1626 | 616 | g_debug("Changing app '%s' state from %s to %s", app->id, STATE2STRING(app->visible_state), STATE2STRING(goal_state)); | ||
1627 | 617 | |||
1628 | 618 | /* This means we're going off line */ | ||
1629 | 619 | if (goal_state == VISIBLE_STATE_HIDDEN) { | ||
1630 | 620 | gint position = get_position(app); | ||
1631 | 621 | if (position == -1) return; | ||
1632 | 622 | |||
1633 | 623 | g_signal_emit(G_OBJECT(appstore), | ||
1634 | 624 | signals[APPLICATION_REMOVED], 0, | ||
1635 | 625 | position, TRUE); | ||
1636 | 626 | } else { | ||
1637 | 627 | /* Figure out which icon we should be using */ | ||
1638 | 628 | gchar * newicon = app->icon; | ||
1639 | 629 | if (app->status == APP_INDICATOR_STATUS_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') { | ||
1640 | 630 | newicon = app->aicon; | ||
1641 | 631 | } | ||
1642 | 632 | |||
1643 | 633 | /* Determine whether we're already shown or not */ | ||
1644 | 634 | if (app->visible_state == VISIBLE_STATE_HIDDEN) { | ||
1645 | 635 | /* Put on panel */ | ||
1646 | 636 | g_signal_emit(G_OBJECT(app->appstore), | ||
1647 | 637 | signals[APPLICATION_ADDED], 0, | ||
1648 | 638 | newicon, | ||
1649 | 639 | get_position(app), /* Position */ | ||
1650 | 640 | app->dbus_name, | ||
1651 | 641 | app->menu, | ||
1652 | 642 | app->icon_theme_path, | ||
1653 | 643 | app->label, | ||
1654 | 644 | app->guide, | ||
1655 | 645 | TRUE); | ||
1656 | 646 | } else { | ||
1657 | 647 | /* Icon update */ | ||
1658 | 648 | gint position = get_position(app); | ||
1659 | 649 | if (position == -1) return; | ||
1660 | 650 | |||
1661 | 651 | g_signal_emit(G_OBJECT(appstore), | ||
1662 | 652 | signals[APPLICATION_ICON_CHANGED], 0, | ||
1663 | 653 | position, newicon, TRUE); | ||
1664 | 654 | } | ||
1665 | 655 | } | ||
1666 | 656 | |||
1667 | 657 | app->visible_state = goal_state; | ||
1668 | 658 | |||
1669 | 659 | return; | ||
1670 | 660 | } | ||
1671 | 661 | |||
1672 | 662 | /* Gets the data back on an updated icon signal. Hopefully | ||
1673 | 663 | a new fun icon. */ | ||
1674 | 664 | static void | ||
1675 | 665 | new_icon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata) | ||
1676 | 666 | { | ||
1677 | 667 | /* Check for errors */ | ||
1678 | 668 | if (error != NULL) { | ||
1679 | 669 | g_warning("Unable to get updated icon name: %s", error->message); | ||
1680 | 670 | return; | ||
1681 | 671 | } | ||
1682 | 672 | |||
1683 | 673 | /* Grab the icon and make sure we have one */ | ||
1684 | 674 | const gchar * newicon = g_value_get_string(&value); | ||
1685 | 675 | if (newicon == NULL) { | ||
1686 | 676 | g_warning("Bad new icon :("); | ||
1687 | 677 | return; | ||
1688 | 678 | } | ||
1689 | 679 | |||
1690 | 680 | Application * app = (Application *) userdata; | ||
1691 | 681 | |||
1692 | 682 | if (g_strcmp0(newicon, app->icon)) { | ||
1693 | 683 | /* If the new icon is actually a new icon */ | ||
1694 | 684 | if (app->icon != NULL) g_free(app->icon); | ||
1695 | 685 | app->icon = g_strdup(newicon); | ||
1696 | 686 | |||
1697 | 687 | if (app->visible_state == VISIBLE_STATE_SHOWN && app->status == APP_INDICATOR_STATUS_ACTIVE) { | ||
1698 | 688 | gint position = get_position(app); | ||
1699 | 689 | if (position == -1) return; | ||
1700 | 690 | |||
1701 | 691 | g_signal_emit(G_OBJECT(app->appstore), | ||
1702 | 692 | signals[APPLICATION_ICON_CHANGED], 0, | ||
1703 | 693 | position, newicon, TRUE); | ||
1704 | 694 | } | ||
1705 | 695 | } | ||
1706 | 696 | |||
1707 | 697 | return; | ||
1708 | 698 | } | ||
1709 | 699 | |||
1710 | 700 | /* Gets the data back on an updated aicon signal. Hopefully | ||
1711 | 701 | a new fun icon. */ | ||
1712 | 702 | static void | ||
1713 | 703 | new_aicon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata) | ||
1714 | 704 | { | ||
1715 | 705 | /* Check for errors */ | ||
1716 | 706 | if (error != NULL) { | ||
1717 | 707 | g_warning("Unable to get updated icon name: %s", error->message); | ||
1718 | 708 | return; | ||
1719 | 709 | } | ||
1720 | 710 | |||
1721 | 711 | /* Grab the icon and make sure we have one */ | ||
1722 | 712 | const gchar * newicon = g_value_get_string(&value); | ||
1723 | 713 | if (newicon == NULL) { | ||
1724 | 714 | g_warning("Bad new icon :("); | ||
1725 | 715 | return; | ||
1726 | 716 | } | ||
1727 | 717 | |||
1728 | 718 | Application * app = (Application *) userdata; | ||
1729 | 719 | |||
1730 | 720 | if (g_strcmp0(newicon, app->aicon)) { | ||
1731 | 721 | /* If the new icon is actually a new icon */ | ||
1732 | 722 | if (app->aicon != NULL) g_free(app->aicon); | ||
1733 | 723 | app->aicon = g_strdup(newicon); | ||
1734 | 724 | |||
1735 | 725 | if (app->visible_state == VISIBLE_STATE_SHOWN && app->status == APP_INDICATOR_STATUS_ATTENTION) { | ||
1736 | 726 | gint position = get_position(app); | ||
1737 | 727 | if (position == -1) return; | ||
1738 | 728 | |||
1739 | 729 | g_signal_emit(G_OBJECT(app->appstore), | ||
1740 | 730 | signals[APPLICATION_ICON_CHANGED], 0, | ||
1741 | 731 | position, newicon, TRUE); | ||
1742 | 732 | } | ||
1743 | 733 | } | ||
1744 | 734 | |||
1745 | 735 | return; | ||
1746 | 736 | } | ||
1747 | 737 | |||
1748 | 738 | /* Called when the Notification Item signals that it | ||
1749 | 739 | has a new icon. */ | ||
1750 | 740 | static void | ||
1751 | 741 | new_icon (DBusGProxy * proxy, gpointer data) | ||
1752 | 742 | { | ||
1753 | 743 | Application * app = (Application *)data; | ||
1754 | 744 | if (!app->validated) return; | ||
1755 | 745 | |||
1756 | 746 | org_freedesktop_DBus_Properties_get_async(app->prop_proxy, | ||
1757 | 747 | NOTIFICATION_ITEM_DBUS_IFACE, | ||
1758 | 748 | NOTIFICATION_ITEM_PROP_ICON_NAME, | ||
1759 | 749 | new_icon_cb, | ||
1760 | 750 | app); | ||
1761 | 751 | return; | ||
1762 | 752 | } | ||
1763 | 753 | |||
1764 | 754 | /* Called when the Notification Item signals that it | ||
1765 | 755 | has a new attention icon. */ | ||
1766 | 756 | static void | ||
1767 | 757 | new_aicon (DBusGProxy * proxy, gpointer data) | ||
1768 | 758 | { | ||
1769 | 759 | Application * app = (Application *)data; | ||
1770 | 760 | if (!app->validated) return; | ||
1771 | 761 | |||
1772 | 762 | org_freedesktop_DBus_Properties_get_async(app->prop_proxy, | ||
1773 | 763 | NOTIFICATION_ITEM_DBUS_IFACE, | ||
1774 | 764 | NOTIFICATION_ITEM_PROP_AICON_NAME, | ||
1775 | 765 | new_aicon_cb, | ||
1776 | 766 | app); | ||
1777 | 767 | |||
1778 | 768 | return; | ||
1779 | 769 | } | ||
1780 | 770 | |||
1781 | 771 | /* Called when the Notification Item signals that it | ||
1782 | 772 | has a new status. */ | ||
1783 | 773 | static void | ||
1784 | 774 | new_status (DBusGProxy * proxy, const gchar * status, gpointer data) | ||
1785 | 775 | { | ||
1786 | 776 | Application * app = (Application *)data; | ||
1787 | 777 | if (!app->validated) return; | ||
1788 | 778 | |||
1789 | 779 | app->status = string_to_status(status); | ||
1790 | 780 | apply_status(app); | ||
1791 | 781 | |||
1792 | 782 | return; | ||
1793 | 783 | } | ||
1794 | 784 | |||
1795 | 785 | /* Called when the Notification Item signals that it | ||
1796 | 786 | has a new icon theme path. */ | ||
1797 | 787 | static void | ||
1798 | 788 | new_icon_theme_path (DBusGProxy * proxy, const gchar * icon_theme_path, gpointer data) | ||
1799 | 789 | { | ||
1800 | 790 | Application * app = (Application *)data; | ||
1801 | 791 | if (!app->validated) return; | ||
1802 | 792 | |||
1803 | 793 | if (g_strcmp0(icon_theme_path, app->icon_theme_path)) { | ||
1804 | 794 | /* If the new icon theme path is actually a new icon theme path */ | ||
1805 | 795 | if (app->icon_theme_path != NULL) g_free(app->icon_theme_path); | ||
1806 | 796 | app->icon_theme_path = g_strdup(icon_theme_path); | ||
1807 | 797 | |||
1808 | 798 | if (app->visible_state != VISIBLE_STATE_HIDDEN) { | ||
1809 | 799 | gint position = get_position(app); | ||
1810 | 800 | if (position == -1) return; | ||
1811 | 801 | |||
1812 | 802 | g_signal_emit(G_OBJECT(app->appstore), | ||
1813 | 803 | signals[APPLICATION_ICON_THEME_PATH_CHANGED], 0, | ||
1814 | 804 | position, app->icon_theme_path, TRUE); | ||
1815 | 805 | } | ||
1816 | 806 | } | ||
1817 | 807 | |||
1818 | 808 | return; | ||
1819 | 809 | } | ||
1820 | 810 | |||
1821 | 811 | /* Called when the Notification Item signals that it | ||
1822 | 812 | has a new label. */ | ||
1823 | 813 | static void | ||
1824 | 814 | new_label (DBusGProxy * proxy, const gchar * label, const gchar * guide, gpointer data) | ||
1825 | 815 | { | ||
1826 | 816 | Application * app = (Application *)data; | ||
1827 | 817 | if (!app->validated) return; | ||
1828 | 818 | |||
1829 | 819 | gboolean changed = FALSE; | ||
1830 | 820 | |||
1831 | 821 | if (g_strcmp0(app->label, label) != 0) { | ||
1832 | 822 | changed = TRUE; | ||
1833 | 823 | if (app->label != NULL) { | ||
1834 | 824 | g_free(app->label); | ||
1835 | 825 | app->label = NULL; | ||
1836 | 826 | } | ||
1837 | 827 | app->label = g_strdup(label); | ||
1838 | 828 | } | ||
1839 | 829 | |||
1840 | 830 | if (g_strcmp0(app->guide, guide) != 0) { | ||
1841 | 831 | changed = TRUE; | ||
1842 | 832 | if (app->guide != NULL) { | ||
1843 | 833 | g_free(app->guide); | ||
1844 | 834 | app->guide = NULL; | ||
1845 | 835 | } | ||
1846 | 836 | app->guide = g_strdup(guide); | ||
1847 | 837 | } | ||
1848 | 838 | |||
1849 | 839 | if (changed) { | ||
1850 | 840 | gint position = get_position(app); | ||
1851 | 841 | if (position == -1) return; | ||
1852 | 842 | |||
1853 | 843 | g_signal_emit(app->appstore, signals[APPLICATION_LABEL_CHANGED], 0, | ||
1854 | 844 | position, | ||
1855 | 845 | app->label != NULL ? app->label : "", | ||
1856 | 846 | app->guide != NULL ? app->guide : "", | ||
1857 | 847 | TRUE); | ||
1858 | 848 | } | ||
1859 | 849 | |||
1860 | 850 | return; | ||
1861 | 851 | } | ||
1862 | 852 | |||
1863 | 853 | /* Adding a new NotificationItem object from DBus in to the | ||
1864 | 854 | appstore. First, we need to get the information on it | ||
1865 | 855 | though. */ | ||
1866 | 856 | void | ||
1867 | 857 | application_service_appstore_application_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) | ||
1868 | 858 | { | ||
1869 | 859 | g_debug("Adding new application: %s:%s", dbus_name, dbus_object); | ||
1870 | 860 | |||
1871 | 861 | /* Make sure we got a sensible request */ | ||
1872 | 862 | g_return_if_fail(IS_APPLICATION_SERVICE_APPSTORE(appstore)); | ||
1873 | 863 | g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); | ||
1874 | 864 | g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0'); | ||
1875 | 865 | ApplicationServiceAppstorePrivate * priv = appstore->priv; | ||
1876 | 866 | Application * app = find_application(appstore, dbus_name, dbus_object); | ||
1877 | 867 | |||
1878 | 868 | if (app != NULL) { | ||
1879 | 869 | g_warning("Application already exists! Rerequesting properties."); | ||
1880 | 870 | org_freedesktop_DBus_Properties_get_all_async(app->prop_proxy, | ||
1881 | 871 | NOTIFICATION_ITEM_DBUS_IFACE, | ||
1882 | 872 | get_all_properties_cb, | ||
1883 | 873 | app); | ||
1884 | 874 | return; | ||
1885 | 875 | } | ||
1886 | 876 | |||
1887 | 877 | /* Build the application entry. This will be carried | ||
1888 | 878 | along until we're sure we've got everything. */ | ||
1889 | 879 | app = g_new0(Application, 1); | ||
1890 | 880 | |||
1891 | 881 | app->validated = FALSE; | ||
1892 | 882 | app->dbus_name = g_strdup(dbus_name); | ||
1893 | 883 | app->dbus_object = g_strdup(dbus_object); | ||
1894 | 884 | app->appstore = appstore; | ||
1895 | 885 | app->status = APP_INDICATOR_STATUS_PASSIVE; | ||
1896 | 886 | app->icon = NULL; | ||
1897 | 887 | app->aicon = NULL; | ||
1898 | 888 | app->menu = NULL; | ||
1899 | 889 | app->icon_theme_path = NULL; | ||
1900 | 890 | app->label = NULL; | ||
1901 | 891 | app->guide = NULL; | ||
1902 | 892 | app->currently_free = FALSE; | ||
1903 | 893 | app->ordering_index = 0; | ||
1904 | 894 | app->approved_by = NULL; | ||
1905 | 895 | app->visible_state = VISIBLE_STATE_HIDDEN; | ||
1906 | 896 | |||
1907 | 897 | /* Get the DBus proxy for the NotificationItem interface */ | ||
1908 | 898 | GError * error = NULL; | ||
1909 | 899 | app->dbus_proxy = dbus_g_proxy_new_for_name_owner(priv->bus, | ||
1910 | 900 | app->dbus_name, | ||
1911 | 901 | app->dbus_object, | ||
1912 | 902 | NOTIFICATION_ITEM_DBUS_IFACE, | ||
1913 | 903 | &error); | ||
1914 | 904 | |||
1915 | 905 | if (error != NULL) { | ||
1916 | 906 | g_warning("Unable to get notification item proxy for object '%s' on host '%s': %s", dbus_object, dbus_name, error->message); | ||
1917 | 907 | g_error_free(error); | ||
1918 | 908 | g_free(app); | ||
1919 | 909 | return; | ||
1920 | 910 | } | ||
1921 | 911 | |||
1922 | 912 | /* We've got it, let's watch it for destruction */ | ||
1923 | 913 | g_signal_connect(G_OBJECT(app->dbus_proxy), "destroy", G_CALLBACK(application_removed_cb), app); | ||
1924 | 914 | |||
1925 | 915 | /* Grab the property proxy interface */ | ||
1926 | 916 | app->prop_proxy = dbus_g_proxy_new_for_name_owner(priv->bus, | ||
1927 | 917 | app->dbus_name, | ||
1928 | 918 | app->dbus_object, | ||
1929 | 919 | DBUS_INTERFACE_PROPERTIES, | ||
1930 | 920 | &error); | ||
1931 | 921 | |||
1932 | 922 | if (error != NULL) { | ||
1933 | 923 | g_warning("Unable to get property proxy for object '%s' on host '%s': %s", dbus_object, dbus_name, error->message); | ||
1934 | 924 | g_error_free(error); | ||
1935 | 925 | g_object_unref(app->dbus_proxy); | ||
1936 | 926 | g_free(app); | ||
1937 | 927 | return; | ||
1938 | 928 | } | ||
1939 | 929 | |||
1940 | 930 | /* Connect to signals */ | ||
1941 | 931 | dbus_g_proxy_add_signal(app->dbus_proxy, | ||
1942 | 932 | NOTIFICATION_ITEM_SIG_NEW_ICON, | ||
1943 | 933 | G_TYPE_INVALID); | ||
1944 | 934 | dbus_g_proxy_add_signal(app->dbus_proxy, | ||
1945 | 935 | NOTIFICATION_ITEM_SIG_NEW_AICON, | ||
1946 | 936 | G_TYPE_INVALID); | ||
1947 | 937 | dbus_g_proxy_add_signal(app->dbus_proxy, | ||
1948 | 938 | NOTIFICATION_ITEM_SIG_NEW_STATUS, | ||
1949 | 939 | G_TYPE_STRING, | ||
1950 | 940 | G_TYPE_INVALID); | ||
1951 | 941 | dbus_g_proxy_add_signal(app->dbus_proxy, | ||
1952 | 942 | NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH, | ||
1953 | 943 | G_TYPE_STRING, | ||
1954 | 944 | G_TYPE_INVALID); | ||
1955 | 945 | dbus_g_proxy_add_signal(app->dbus_proxy, | ||
1956 | 946 | NOTIFICATION_ITEM_SIG_NEW_LABEL, | ||
1957 | 947 | G_TYPE_STRING, | ||
1958 | 948 | G_TYPE_STRING, | ||
1959 | 949 | G_TYPE_INVALID); | ||
1960 | 950 | |||
1961 | 951 | dbus_g_proxy_connect_signal(app->dbus_proxy, | ||
1962 | 952 | NOTIFICATION_ITEM_SIG_NEW_ICON, | ||
1963 | 953 | G_CALLBACK(new_icon), | ||
1964 | 954 | app, | ||
1965 | 955 | NULL); | ||
1966 | 956 | dbus_g_proxy_connect_signal(app->dbus_proxy, | ||
1967 | 957 | NOTIFICATION_ITEM_SIG_NEW_AICON, | ||
1968 | 958 | G_CALLBACK(new_aicon), | ||
1969 | 959 | app, | ||
1970 | 960 | NULL); | ||
1971 | 961 | dbus_g_proxy_connect_signal(app->dbus_proxy, | ||
1972 | 962 | NOTIFICATION_ITEM_SIG_NEW_STATUS, | ||
1973 | 963 | G_CALLBACK(new_status), | ||
1974 | 964 | app, | ||
1975 | 965 | NULL); | ||
1976 | 966 | dbus_g_proxy_connect_signal(app->dbus_proxy, | ||
1977 | 967 | NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH, | ||
1978 | 968 | G_CALLBACK(new_icon_theme_path), | ||
1979 | 969 | app, | ||
1980 | 970 | NULL); | ||
1981 | 971 | dbus_g_proxy_connect_signal(app->dbus_proxy, | ||
1982 | 972 | NOTIFICATION_ITEM_SIG_NEW_LABEL, | ||
1983 | 973 | G_CALLBACK(new_label), | ||
1984 | 974 | app, | ||
1985 | 975 | NULL); | ||
1986 | 976 | |||
1987 | 977 | /* Get all the propertiees */ | ||
1988 | 978 | org_freedesktop_DBus_Properties_get_all_async(app->prop_proxy, | ||
1989 | 979 | NOTIFICATION_ITEM_DBUS_IFACE, | ||
1990 | 980 | get_all_properties_cb, | ||
1991 | 981 | app); | ||
1992 | 982 | |||
1993 | 983 | /* We're returning, nothing is yet added until the properties | ||
1994 | 984 | come back and give us more info. */ | ||
1995 | 985 | return; | ||
1996 | 986 | } | ||
1997 | 987 | |||
1998 | 988 | /* Looks for an application in the list of applications */ | ||
1999 | 989 | static Application * | ||
2000 | 990 | find_application (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * object) | ||
2001 | 991 | { | ||
2002 | 992 | ApplicationServiceAppstorePrivate * priv = appstore->priv; | ||
2003 | 993 | GList * listpntr; | ||
2004 | 994 | |||
2005 | 995 | for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { | ||
2006 | 996 | Application * app = (Application *)listpntr->data; | ||
2007 | 997 | |||
2008 | 998 | if (!g_strcmp0(app->dbus_name, address) && !g_strcmp0(app->dbus_object, object)) { | ||
2009 | 999 | return app; | ||
2010 | 1000 | } | ||
2011 | 1001 | } | ||
2012 | 1002 | |||
2013 | 1003 | return NULL; | ||
2014 | 1004 | } | ||
2015 | 1005 | |||
2016 | 1006 | /* Removes an application. Currently only works for the apps | ||
2017 | 1007 | that are shown. */ | ||
2018 | 1008 | void | ||
2019 | 1009 | application_service_appstore_application_remove (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) | ||
2020 | 1010 | { | ||
2021 | 1011 | g_return_if_fail(IS_APPLICATION_SERVICE_APPSTORE(appstore)); | ||
2022 | 1012 | g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); | ||
2023 | 1013 | g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0'); | ||
2024 | 1014 | |||
2025 | 1015 | Application * app = find_application(appstore, dbus_name, dbus_object); | ||
2026 | 1016 | if (app != NULL) { | ||
2027 | 1017 | application_removed_cb(NULL, app); | ||
2028 | 1018 | } else { | ||
2029 | 1019 | g_warning("Unable to find application %s:%s", dbus_name, dbus_object); | ||
2030 | 1020 | } | ||
2031 | 1021 | |||
2032 | 1022 | return; | ||
2033 | 1023 | } | ||
2034 | 1024 | |||
2035 | 1025 | gchar** | ||
2036 | 1026 | application_service_appstore_application_get_list (ApplicationServiceAppstore * appstore) | ||
2037 | 1027 | { | ||
2038 | 1028 | ApplicationServiceAppstorePrivate * priv = appstore->priv; | ||
2039 | 1029 | gchar ** out; | ||
2040 | 1030 | gchar ** outpntr; | ||
2041 | 1031 | GList * listpntr; | ||
2042 | 1032 | |||
2043 | 1033 | out = g_new(gchar*, g_list_length(priv->applications) + 1); | ||
2044 | 1034 | |||
2045 | 1035 | for (listpntr = priv->applications, outpntr = out; listpntr != NULL; listpntr = g_list_next(listpntr), ++outpntr) { | ||
2046 | 1036 | Application * app = (Application *)listpntr->data; | ||
2047 | 1037 | *outpntr = g_strdup_printf("%s%s", app->dbus_name, app->dbus_object); | ||
2048 | 1038 | } | ||
2049 | 1039 | *outpntr = 0; | ||
2050 | 1040 | return out; | ||
2051 | 1041 | } | ||
2052 | 1042 | |||
2053 | 1043 | /* Creates a basic appstore object and attaches the | ||
2054 | 1044 | LRU file object to it. */ | ||
2055 | 1045 | ApplicationServiceAppstore * | ||
2056 | 1046 | application_service_appstore_new (void) | ||
2057 | 1047 | { | ||
2058 | 1048 | ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(g_object_new(APPLICATION_SERVICE_APPSTORE_TYPE, NULL)); | ||
2059 | 1049 | return appstore; | ||
2060 | 1050 | } | ||
2061 | 1051 | |||
2062 | 1052 | /* DBus Interface */ | ||
2063 | 1053 | static gboolean | ||
2064 | 1054 | _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps, GError ** error) | ||
2065 | 1055 | { | ||
2066 | 1056 | ApplicationServiceAppstorePrivate * priv = appstore->priv; | ||
2067 | 1057 | |||
2068 | 1058 | *apps = g_ptr_array_new(); | ||
2069 | 1059 | GList * listpntr; | ||
2070 | 1060 | gint position = 0; | ||
2071 | 1061 | |||
2072 | 1062 | for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { | ||
2073 | 1063 | Application * app = (Application *)listpntr->data; | ||
2074 | 1064 | if (app->visible_state == VISIBLE_STATE_HIDDEN) { | ||
2075 | 1065 | continue; | ||
2076 | 1066 | } | ||
2077 | 1067 | |||
2078 | 1068 | GValueArray * values = g_value_array_new(5); | ||
2079 | 1069 | |||
2080 | 1070 | GValue value = {0}; | ||
2081 | 1071 | |||
2082 | 1072 | /* Icon name */ | ||
2083 | 1073 | g_value_init(&value, G_TYPE_STRING); | ||
2084 | 1074 | g_value_set_string(&value, app->icon); | ||
2085 | 1075 | g_value_array_append(values, &value); | ||
2086 | 1076 | g_value_unset(&value); | ||
2087 | 1077 | |||
2088 | 1078 | /* Position */ | ||
2089 | 1079 | g_value_init(&value, G_TYPE_INT); | ||
2090 | 1080 | g_value_set_int(&value, position++); | ||
2091 | 1081 | g_value_array_append(values, &value); | ||
2092 | 1082 | g_value_unset(&value); | ||
2093 | 1083 | |||
2094 | 1084 | /* DBus Address */ | ||
2095 | 1085 | g_value_init(&value, G_TYPE_STRING); | ||
2096 | 1086 | g_value_set_string(&value, app->dbus_name); | ||
2097 | 1087 | g_value_array_append(values, &value); | ||
2098 | 1088 | g_value_unset(&value); | ||
2099 | 1089 | |||
2100 | 1090 | /* DBus Object */ | ||
2101 | 1091 | g_value_init(&value, DBUS_TYPE_G_OBJECT_PATH); | ||
2102 | 1092 | g_value_set_static_boxed(&value, app->menu); | ||
2103 | 1093 | g_value_array_append(values, &value); | ||
2104 | 1094 | g_value_unset(&value); | ||
2105 | 1095 | |||
2106 | 1096 | /* Icon path */ | ||
2107 | 1097 | g_value_init(&value, G_TYPE_STRING); | ||
2108 | 1098 | g_value_set_string(&value, app->icon_theme_path); | ||
2109 | 1099 | g_value_array_append(values, &value); | ||
2110 | 1100 | g_value_unset(&value); | ||
2111 | 1101 | |||
2112 | 1102 | /* Label */ | ||
2113 | 1103 | g_value_init(&value, G_TYPE_STRING); | ||
2114 | 1104 | g_value_set_string(&value, app->label); | ||
2115 | 1105 | g_value_array_append(values, &value); | ||
2116 | 1106 | g_value_unset(&value); | ||
2117 | 1107 | |||
2118 | 1108 | /* Guide */ | ||
2119 | 1109 | g_value_init(&value, G_TYPE_STRING); | ||
2120 | 1110 | g_value_set_string(&value, app->guide); | ||
2121 | 1111 | g_value_array_append(values, &value); | ||
2122 | 1112 | g_value_unset(&value); | ||
2123 | 1113 | |||
2124 | 1114 | g_ptr_array_add(*apps, values); | ||
2125 | 1115 | } | ||
2126 | 1116 | |||
2127 | 1117 | return TRUE; | ||
2128 | 1118 | } | ||
2129 | 1119 | |||
2130 | 1120 | /* Removes and approver from our list of approvers and | ||
2131 | 1121 | then sees if that changes our status. Most likely this | ||
2132 | 1122 | could make us visible if this approver rejected us. */ | ||
2133 | 1123 | static void | ||
2134 | 1124 | remove_approver (gpointer papp, gpointer pproxy) | ||
2135 | 1125 | { | ||
2136 | 1126 | Application * app = (Application *)papp; | ||
2137 | 1127 | app->approved_by = g_list_remove(app->approved_by, pproxy); | ||
2138 | 1128 | apply_status(app); | ||
2139 | 1129 | return; | ||
2140 | 1130 | } | ||
2141 | 1131 | |||
2142 | 1132 | /* Frees the data associated with an approver */ | ||
2143 | 1133 | static void | ||
2144 | 1134 | approver_free (gpointer papprover, gpointer user_data) | ||
2145 | 1135 | { | ||
2146 | 1136 | Approver * approver = (Approver *)papprover; | ||
2147 | 1137 | g_return_if_fail(approver != NULL); | ||
2148 | 1138 | |||
2149 | 1139 | ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(user_data); | ||
2150 | 1140 | g_list_foreach(appstore->priv->applications, remove_approver, approver->proxy); | ||
2151 | 1141 | |||
2152 | 1142 | if (approver->proxy != NULL) { | ||
2153 | 1143 | if (!approver->destroy_by_proxy) { | ||
2154 | 1144 | g_object_unref(approver->proxy); | ||
2155 | 1145 | } | ||
2156 | 1146 | approver->proxy = NULL; | ||
2157 | 1147 | } | ||
2158 | 1148 | |||
2159 | 1149 | g_free(approver); | ||
2160 | 1150 | return; | ||
2161 | 1151 | } | ||
2162 | 1152 | |||
2163 | 1153 | /* What did the approver tell us? */ | ||
2164 | 1154 | static void | ||
2165 | 1155 | approver_request_cb (DBusGProxy *proxy, gboolean OUT_approved, GError *error, gpointer userdata) | ||
2166 | 1156 | { | ||
2167 | 1157 | if (error == NULL) { | ||
2168 | 1158 | g_debug("Approver responded: %s", OUT_approved ? "approve" : "rejected"); | ||
2169 | 1159 | } else { | ||
2170 | 1160 | g_debug("Approver responded error: %s", error->message); | ||
2171 | 1161 | } | ||
2172 | 1162 | |||
2173 | 1163 | Application * app = (Application *)userdata; | ||
2174 | 1164 | |||
2175 | 1165 | if (OUT_approved || error != NULL) { | ||
2176 | 1166 | app->approved_by = g_list_prepend(app->approved_by, proxy); | ||
2177 | 1167 | } else { | ||
2178 | 1168 | app->approved_by = g_list_remove(app->approved_by, proxy); | ||
2179 | 1169 | } | ||
2180 | 1170 | |||
2181 | 1171 | apply_status(app); | ||
2182 | 1172 | return; | ||
2183 | 1173 | } | ||
2184 | 1174 | |||
2185 | 1175 | /* Run the applications through the new approver */ | ||
2186 | 1176 | static void | ||
2187 | 1177 | check_with_new_approver (gpointer papp, gpointer papprove) | ||
2188 | 1178 | { | ||
2189 | 1179 | Application * app = (Application *)papp; | ||
2190 | 1180 | Approver * approver = (Approver *)papprove; | ||
2191 | 1181 | |||
2192 | 1182 | org_ayatana_StatusNotifierApprover_approve_item_async(approver->proxy, | ||
2193 | 1183 | app->id, | ||
2194 | 1184 | app->category, | ||
2195 | 1185 | 0, | ||
2196 | 1186 | app->dbus_name, | ||
2197 | 1187 | app->dbus_object, | ||
2198 | 1188 | approver_request_cb, | ||
2199 | 1189 | app); | ||
2200 | 1190 | |||
2201 | 1191 | return; | ||
2202 | 1192 | } | ||
2203 | 1193 | |||
2204 | 1194 | /* Look through all the approvers and find the one with a given | ||
2205 | 1195 | proxy. */ | ||
2206 | 1196 | static gint | ||
2207 | 1197 | approver_find_by_proxy (gconstpointer papprover, gconstpointer pproxy) | ||
2208 | 1198 | { | ||
2209 | 1199 | Approver * approver = (Approver *)papprover; | ||
2210 | 1200 | |||
2211 | 1201 | if (approver->proxy == pproxy) { | ||
2212 | 1202 | return 0; | ||
2213 | 1203 | } | ||
2214 | 1204 | |||
2215 | 1205 | return -1; | ||
2216 | 1206 | } | ||
2217 | 1207 | |||
2218 | 1208 | /* Tracks when a proxy gets destroyed so that we know that the | ||
2219 | 1209 | approver has dropped off the bus. */ | ||
2220 | 1210 | static void | ||
2221 | 1211 | approver_destroyed (gpointer pproxy, gpointer pappstore) | ||
2222 | 1212 | { | ||
2223 | 1213 | ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(pappstore); | ||
2224 | 1214 | |||
2225 | 1215 | GList * lapprover = g_list_find_custom(appstore->priv->approvers, pproxy, approver_find_by_proxy); | ||
2226 | 1216 | if (lapprover == NULL) { | ||
2227 | 1217 | g_warning("Approver proxy died, but we don't seem to have that approver."); | ||
2228 | 1218 | return; | ||
2229 | 1219 | } | ||
2230 | 1220 | |||
2231 | 1221 | Approver * approver = (Approver *)lapprover->data; | ||
2232 | 1222 | approver->destroy_by_proxy = TRUE; | ||
2233 | 1223 | |||
2234 | 1224 | appstore->priv->approvers = g_list_remove(appstore->priv->approvers, approver); | ||
2235 | 1225 | approver_free(approver, appstore); | ||
2236 | 1226 | |||
2237 | 1227 | return; | ||
2238 | 1228 | } | ||
2239 | 1229 | |||
2240 | 1230 | /* A signal when an approver changes the why that it thinks about | ||
2241 | 1231 | a particular indicator. */ | ||
2242 | 1232 | void | ||
2243 | 1233 | approver_revise_judgement (DBusGProxy * proxy, gboolean new_status, gchar * address, DBusGProxy * get_path, gpointer user_data) | ||
2244 | 1234 | { | ||
2245 | 1235 | g_return_if_fail(IS_APPLICATION_SERVICE_APPSTORE(user_data)); | ||
2246 | 1236 | g_return_if_fail(address != NULL && address[0] != '\0'); | ||
2247 | 1237 | g_return_if_fail(get_path != NULL); | ||
2248 | 1238 | const gchar * path = dbus_g_proxy_get_path(get_path); | ||
2249 | 1239 | g_return_if_fail(path != NULL && path[0] != '\0'); | ||
2250 | 1240 | |||
2251 | 1241 | ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(user_data); | ||
2252 | 1242 | |||
2253 | 1243 | Application * app = find_application(appstore, address, path); | ||
2254 | 1244 | |||
2255 | 1245 | if (app == NULL) { | ||
2256 | 1246 | g_warning("Unable to update approver status of application (%s:%s) as it was not found", address, path); | ||
2257 | 1247 | return; | ||
2258 | 1248 | } | ||
2259 | 1249 | |||
2260 | 1250 | if (new_status) { | ||
2261 | 1251 | app->approved_by = g_list_prepend(app->approved_by, proxy); | ||
2262 | 1252 | } else { | ||
2263 | 1253 | app->approved_by = g_list_remove(app->approved_by, proxy); | ||
2264 | 1254 | } | ||
2265 | 1255 | apply_status(app); | ||
2266 | 1256 | |||
2267 | 1257 | return; | ||
2268 | 1258 | } | ||
2269 | 1259 | |||
2270 | 1260 | /* Adds a new approver to the app store */ | ||
2271 | 1261 | void | ||
2272 | 1262 | application_service_appstore_approver_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) | ||
2273 | 1263 | { | ||
2274 | 1264 | g_return_if_fail(IS_APPLICATION_SERVICE_APPSTORE(appstore)); | ||
2275 | 1265 | g_return_if_fail(dbus_name != NULL); | ||
2276 | 1266 | g_return_if_fail(dbus_object != NULL); | ||
2277 | 1267 | ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE (appstore); | ||
2278 | 1268 | |||
2279 | 1269 | Approver * approver = g_new0(Approver, 1); | ||
2280 | 1270 | approver->destroy_by_proxy = FALSE; | ||
2281 | 1271 | |||
2282 | 1272 | GError * error = NULL; | ||
2283 | 1273 | approver->proxy = dbus_g_proxy_new_for_name_owner(priv->bus, | ||
2284 | 1274 | dbus_name, | ||
2285 | 1275 | dbus_object, | ||
2286 | 1276 | NOTIFICATION_APPROVER_DBUS_IFACE, | ||
2287 | 1277 | &error); | ||
2288 | 1278 | if (error != NULL) { | ||
2289 | 1279 | g_warning("Unable to get approver interface on '%s:%s' : %s", dbus_name, dbus_object, error->message); | ||
2290 | 1280 | g_error_free(error); | ||
2291 | 1281 | g_free(approver); | ||
2292 | 1282 | return; | ||
2293 | 1283 | } | ||
2294 | 1284 | |||
2295 | 1285 | g_signal_connect(G_OBJECT(approver->proxy), "destroy", G_CALLBACK(approver_destroyed), appstore); | ||
2296 | 1286 | |||
2297 | 1287 | dbus_g_proxy_add_signal(approver->proxy, | ||
2298 | 1288 | "ReviseJudgement", | ||
2299 | 1289 | G_TYPE_BOOLEAN, | ||
2300 | 1290 | G_TYPE_STRING, | ||
2301 | 1291 | DBUS_TYPE_G_OBJECT_PATH, | ||
2302 | 1292 | G_TYPE_INVALID); | ||
2303 | 1293 | dbus_g_proxy_connect_signal(approver->proxy, | ||
2304 | 1294 | "ReviseJudgement", | ||
2305 | 1295 | G_CALLBACK(approver_revise_judgement), | ||
2306 | 1296 | appstore, | ||
2307 | 1297 | NULL); | ||
2308 | 1298 | |||
2309 | 1299 | priv->approvers = g_list_prepend(priv->approvers, approver); | ||
2310 | 1300 | |||
2311 | 1301 | g_list_foreach(priv->applications, check_with_new_approver, approver); | ||
2312 | 1302 | |||
2313 | 1303 | return; | ||
2314 | 1304 | } | ||
2315 | 1305 | |||
2316 | 1306 | 0 | ||
2317 | === removed file 'src/application-service-appstore.h' | |||
2318 | --- src/application-service-appstore.h 2010-10-08 15:02:24 +0000 | |||
2319 | +++ src/application-service-appstore.h 1970-01-01 00:00:00 +0000 | |||
2320 | @@ -1,73 +0,0 @@ | |||
2321 | 1 | /* | ||
2322 | 2 | An object that stores the registration of all the application | ||
2323 | 3 | indicators. It also communicates this to the indicator visualization. | ||
2324 | 4 | |||
2325 | 5 | Copyright 2009 Canonical Ltd. | ||
2326 | 6 | |||
2327 | 7 | Authors: | ||
2328 | 8 | Ted Gould <ted@canonical.com> | ||
2329 | 9 | |||
2330 | 10 | This program is free software: you can redistribute it and/or modify it | ||
2331 | 11 | under the terms of the GNU General Public License version 3, as published | ||
2332 | 12 | by the Free Software Foundation. | ||
2333 | 13 | |||
2334 | 14 | This program is distributed in the hope that it will be useful, but | ||
2335 | 15 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2336 | 16 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2337 | 17 | PURPOSE. See the GNU General Public License for more details. | ||
2338 | 18 | |||
2339 | 19 | You should have received a copy of the GNU General Public License along | ||
2340 | 20 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2341 | 21 | */ | ||
2342 | 22 | |||
2343 | 23 | #ifndef __APPLICATION_SERVICE_APPSTORE_H__ | ||
2344 | 24 | #define __APPLICATION_SERVICE_APPSTORE_H__ | ||
2345 | 25 | |||
2346 | 26 | #include <glib.h> | ||
2347 | 27 | #include <glib-object.h> | ||
2348 | 28 | |||
2349 | 29 | G_BEGIN_DECLS | ||
2350 | 30 | |||
2351 | 31 | #define APPLICATION_SERVICE_APPSTORE_TYPE (application_service_appstore_get_type ()) | ||
2352 | 32 | #define APPLICATION_SERVICE_APPSTORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_SERVICE_APPSTORE_TYPE, ApplicationServiceAppstore)) | ||
2353 | 33 | #define APPLICATION_SERVICE_APPSTORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_SERVICE_APPSTORE_TYPE, ApplicationServiceAppstoreClass)) | ||
2354 | 34 | #define IS_APPLICATION_SERVICE_APPSTORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_SERVICE_APPSTORE_TYPE)) | ||
2355 | 35 | #define IS_APPLICATION_SERVICE_APPSTORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_SERVICE_APPSTORE_TYPE)) | ||
2356 | 36 | #define APPLICATION_SERVICE_APPSTORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_SERVICE_APPSTORE_TYPE, ApplicationServiceAppstoreClass)) | ||
2357 | 37 | |||
2358 | 38 | typedef struct _ApplicationServiceAppstore ApplicationServiceAppstore; | ||
2359 | 39 | typedef struct _ApplicationServiceAppstoreClass ApplicationServiceAppstoreClass; | ||
2360 | 40 | typedef struct _ApplicationServiceAppstorePrivate ApplicationServiceAppstorePrivate; | ||
2361 | 41 | |||
2362 | 42 | struct _ApplicationServiceAppstoreClass { | ||
2363 | 43 | GObjectClass parent_class; | ||
2364 | 44 | |||
2365 | 45 | void (*application_added) (ApplicationServiceAppstore * appstore, gchar *, gint, gchar *, gchar *, gpointer); | ||
2366 | 46 | void (*application_removed) (ApplicationServiceAppstore * appstore, gint, gpointer); | ||
2367 | 47 | void (*application_icon_changed)(ApplicationServiceAppstore * appstore, gint, const gchar *, gpointer); | ||
2368 | 48 | void (*application_icon_theme_path_changed)(ApplicationServiceAppstore * appstore, gint, const gchar *, gpointer); | ||
2369 | 49 | void (*application_label_changed)(ApplicationServiceAppstore * appstore, gint, const gchar *, const gchar *, gpointer); | ||
2370 | 50 | }; | ||
2371 | 51 | |||
2372 | 52 | struct _ApplicationServiceAppstore { | ||
2373 | 53 | GObject parent; | ||
2374 | 54 | |||
2375 | 55 | ApplicationServiceAppstorePrivate * priv; | ||
2376 | 56 | }; | ||
2377 | 57 | |||
2378 | 58 | ApplicationServiceAppstore * application_service_appstore_new (void); | ||
2379 | 59 | GType application_service_appstore_get_type (void); | ||
2380 | 60 | void application_service_appstore_application_add (ApplicationServiceAppstore * appstore, | ||
2381 | 61 | const gchar * dbus_name, | ||
2382 | 62 | const gchar * dbus_object); | ||
2383 | 63 | void application_service_appstore_application_remove (ApplicationServiceAppstore * appstore, | ||
2384 | 64 | const gchar * dbus_name, | ||
2385 | 65 | const gchar * dbus_object); | ||
2386 | 66 | void application_service_appstore_approver_add (ApplicationServiceAppstore * appstore, | ||
2387 | 67 | const gchar * dbus_name, | ||
2388 | 68 | const gchar * dbus_object); | ||
2389 | 69 | gchar** application_service_appstore_application_get_list (ApplicationServiceAppstore * appstore); | ||
2390 | 70 | |||
2391 | 71 | G_END_DECLS | ||
2392 | 72 | |||
2393 | 73 | #endif | ||
2394 | 74 | 0 | ||
2395 | === removed file 'src/application-service-watcher.c' | |||
2396 | --- src/application-service-watcher.c 2010-10-08 16:04:27 +0000 | |||
2397 | +++ src/application-service-watcher.c 1970-01-01 00:00:00 +0000 | |||
2398 | @@ -1,302 +0,0 @@ | |||
2399 | 1 | /* | ||
2400 | 2 | An object implementing the NotificationWatcher interface and passes | ||
2401 | 3 | the information into the app-store. | ||
2402 | 4 | |||
2403 | 5 | Copyright 2009 Canonical Ltd. | ||
2404 | 6 | |||
2405 | 7 | Authors: | ||
2406 | 8 | Ted Gould <ted@canonical.com> | ||
2407 | 9 | |||
2408 | 10 | This program is free software: you can redistribute it and/or modify it | ||
2409 | 11 | under the terms of the GNU General Public License version 3, as published | ||
2410 | 12 | by the Free Software Foundation. | ||
2411 | 13 | |||
2412 | 14 | This program is distributed in the hope that it will be useful, but | ||
2413 | 15 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2414 | 16 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2415 | 17 | PURPOSE. See the GNU General Public License for more details. | ||
2416 | 18 | |||
2417 | 19 | You should have received a copy of the GNU General Public License along | ||
2418 | 20 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2419 | 21 | */ | ||
2420 | 22 | |||
2421 | 23 | #ifdef HAVE_CONFIG_H | ||
2422 | 24 | #include "config.h" | ||
2423 | 25 | #endif | ||
2424 | 26 | |||
2425 | 27 | #include <dbus/dbus-glib.h> | ||
2426 | 28 | #include <dbus/dbus-glib-lowlevel.h> | ||
2427 | 29 | #include <dbus/dbus-glib-bindings.h> | ||
2428 | 30 | #include "application-service-watcher.h" | ||
2429 | 31 | #include "dbus-shared.h" | ||
2430 | 32 | |||
2431 | 33 | /* Enum for the properties so that they can be quickly | ||
2432 | 34 | found and looked up. */ | ||
2433 | 35 | enum { | ||
2434 | 36 | PROP_0, | ||
2435 | 37 | PROP_PROTOCOL_VERSION, | ||
2436 | 38 | PROP_IS_STATUS_NOTIFIER_HOST_REGISTERED, | ||
2437 | 39 | PROP_REGISTERED_STATUS_NOTIFIER_ITEMS | ||
2438 | 40 | }; | ||
2439 | 41 | |||
2440 | 42 | /* The strings so that they can be slowly looked up. */ | ||
2441 | 43 | #define PROP_PROTOCOL_VERSION_S "protocol-version" | ||
2442 | 44 | #define PROP_IS_STATUS_NOTIFIER_HOST_REGISTERED_S "is-status-notifier-host-registered" | ||
2443 | 45 | #define PROP_REGISTERED_STATUS_NOTIFIER_ITEMS_S "registered-status-notifier-items" | ||
2444 | 46 | |||
2445 | 47 | #define CURRENT_PROTOCOL_VERSION 0 | ||
2446 | 48 | |||
2447 | 49 | static gboolean _notification_watcher_server_register_status_notifier_item (ApplicationServiceWatcher * appwatcher, const gchar * service, DBusGMethodInvocation * method); | ||
2448 | 50 | static gboolean _notification_watcher_server_register_status_notifier_host (ApplicationServiceWatcher * appwatcher, const gchar * host); | ||
2449 | 51 | static gboolean _notification_watcher_server_x_ayatana_register_notification_approver (ApplicationServiceWatcher * appwatcher, const gchar * path, const GArray * categories, DBusGMethodInvocation * method); | ||
2450 | 52 | static void get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer data); | ||
2451 | 53 | |||
2452 | 54 | #include "notification-watcher-server.h" | ||
2453 | 55 | |||
2454 | 56 | /* Private Stuff */ | ||
2455 | 57 | typedef struct _ApplicationServiceWatcherPrivate ApplicationServiceWatcherPrivate; | ||
2456 | 58 | struct _ApplicationServiceWatcherPrivate { | ||
2457 | 59 | ApplicationServiceAppstore * appstore; | ||
2458 | 60 | DBusGProxy * dbus_proxy; | ||
2459 | 61 | }; | ||
2460 | 62 | |||
2461 | 63 | #define APPLICATION_SERVICE_WATCHER_GET_PRIVATE(o) \ | ||
2462 | 64 | (G_TYPE_INSTANCE_GET_PRIVATE ((o), APPLICATION_SERVICE_WATCHER_TYPE, ApplicationServiceWatcherPrivate)) | ||
2463 | 65 | |||
2464 | 66 | /* Signals Stuff */ | ||
2465 | 67 | enum { | ||
2466 | 68 | STATUS_NOTIFIER_ITEM_REGISTERED, | ||
2467 | 69 | STATUS_NOTIFIER_ITEM_UNREGISTERED, | ||
2468 | 70 | STATUS_NOTIFIER_HOST_REGISTERED, | ||
2469 | 71 | LAST_SIGNAL | ||
2470 | 72 | }; | ||
2471 | 73 | |||
2472 | 74 | static guint signals[LAST_SIGNAL] = { 0 }; | ||
2473 | 75 | |||
2474 | 76 | /* GObject stuff */ | ||
2475 | 77 | static void application_service_watcher_class_init (ApplicationServiceWatcherClass *klass); | ||
2476 | 78 | static void application_service_watcher_init (ApplicationServiceWatcher *self); | ||
2477 | 79 | static void application_service_watcher_dispose (GObject *object); | ||
2478 | 80 | static void application_service_watcher_finalize (GObject *object); | ||
2479 | 81 | static void application_service_watcher_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); | ||
2480 | 82 | static void application_service_watcher_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); | ||
2481 | 83 | |||
2482 | 84 | G_DEFINE_TYPE (ApplicationServiceWatcher, application_service_watcher, G_TYPE_OBJECT); | ||
2483 | 85 | |||
2484 | 86 | static void | ||
2485 | 87 | application_service_watcher_class_init (ApplicationServiceWatcherClass *klass) | ||
2486 | 88 | { | ||
2487 | 89 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
2488 | 90 | |||
2489 | 91 | g_type_class_add_private (klass, sizeof (ApplicationServiceWatcherPrivate)); | ||
2490 | 92 | |||
2491 | 93 | object_class->dispose = application_service_watcher_dispose; | ||
2492 | 94 | object_class->finalize = application_service_watcher_finalize; | ||
2493 | 95 | |||
2494 | 96 | /* Property funcs */ | ||
2495 | 97 | object_class->set_property = application_service_watcher_set_property; | ||
2496 | 98 | object_class->get_property = application_service_watcher_get_property; | ||
2497 | 99 | |||
2498 | 100 | /* Properties */ | ||
2499 | 101 | g_object_class_install_property (object_class, | ||
2500 | 102 | PROP_PROTOCOL_VERSION, | ||
2501 | 103 | g_param_spec_int(PROP_PROTOCOL_VERSION_S, | ||
2502 | 104 | "Protocol Version", | ||
2503 | 105 | "Which version of the StatusNotifierProtocol this watcher implements", | ||
2504 | 106 | 0, G_MAXINT, | ||
2505 | 107 | CURRENT_PROTOCOL_VERSION, | ||
2506 | 108 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); | ||
2507 | 109 | g_object_class_install_property (object_class, | ||
2508 | 110 | PROP_IS_STATUS_NOTIFIER_HOST_REGISTERED, | ||
2509 | 111 | g_param_spec_boolean(PROP_IS_STATUS_NOTIFIER_HOST_REGISTERED_S, | ||
2510 | 112 | "Is StatusNotifierHost Registered", | ||
2511 | 113 | "True if there is at least one StatusNotifierHost registered", | ||
2512 | 114 | FALSE, | ||
2513 | 115 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); | ||
2514 | 116 | g_object_class_install_property (object_class, | ||
2515 | 117 | PROP_REGISTERED_STATUS_NOTIFIER_ITEMS, | ||
2516 | 118 | g_param_spec_boxed(PROP_REGISTERED_STATUS_NOTIFIER_ITEMS_S, | ||
2517 | 119 | "Registered StatusNotifierItems", | ||
2518 | 120 | "The list of StatusNotifierItems registered to this watcher", | ||
2519 | 121 | G_TYPE_STRV, | ||
2520 | 122 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); | ||
2521 | 123 | /* Signals */ | ||
2522 | 124 | signals[STATUS_NOTIFIER_ITEM_REGISTERED] = g_signal_new ("status-notifier-item-registered", | ||
2523 | 125 | G_TYPE_FROM_CLASS(klass), | ||
2524 | 126 | G_SIGNAL_RUN_LAST, | ||
2525 | 127 | G_STRUCT_OFFSET (ApplicationServiceWatcherClass, status_notifier_item_registered), | ||
2526 | 128 | NULL, NULL, | ||
2527 | 129 | g_cclosure_marshal_VOID__STRING, | ||
2528 | 130 | G_TYPE_NONE, 1, G_TYPE_STRING, G_TYPE_NONE); | ||
2529 | 131 | signals[STATUS_NOTIFIER_ITEM_UNREGISTERED] = g_signal_new ("status-notifier-item-unregistered", | ||
2530 | 132 | G_TYPE_FROM_CLASS(klass), | ||
2531 | 133 | G_SIGNAL_RUN_LAST, | ||
2532 | 134 | G_STRUCT_OFFSET (ApplicationServiceWatcherClass, status_notifier_item_unregistered), | ||
2533 | 135 | NULL, NULL, | ||
2534 | 136 | g_cclosure_marshal_VOID__STRING, | ||
2535 | 137 | G_TYPE_NONE, 1, G_TYPE_STRING, G_TYPE_NONE); | ||
2536 | 138 | signals[STATUS_NOTIFIER_HOST_REGISTERED] = g_signal_new ("status-notifier-host-registered", | ||
2537 | 139 | G_TYPE_FROM_CLASS(klass), | ||
2538 | 140 | G_SIGNAL_RUN_LAST, | ||
2539 | 141 | G_STRUCT_OFFSET (ApplicationServiceWatcherClass, status_notifier_host_registered), | ||
2540 | 142 | NULL, NULL, | ||
2541 | 143 | g_cclosure_marshal_VOID__VOID, | ||
2542 | 144 | G_TYPE_NONE, 0, G_TYPE_NONE); | ||
2543 | 145 | |||
2544 | 146 | dbus_g_object_type_install_info(APPLICATION_SERVICE_WATCHER_TYPE, | ||
2545 | 147 | &dbus_glib__notification_watcher_server_object_info); | ||
2546 | 148 | |||
2547 | 149 | return; | ||
2548 | 150 | } | ||
2549 | 151 | |||
2550 | 152 | static void | ||
2551 | 153 | application_service_watcher_init (ApplicationServiceWatcher *self) | ||
2552 | 154 | { | ||
2553 | 155 | ApplicationServiceWatcherPrivate * priv = APPLICATION_SERVICE_WATCHER_GET_PRIVATE(self); | ||
2554 | 156 | |||
2555 | 157 | priv->appstore = NULL; | ||
2556 | 158 | |||
2557 | 159 | GError * error = NULL; | ||
2558 | 160 | DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); | ||
2559 | 161 | if (error != NULL) { | ||
2560 | 162 | g_error("Unable to get session bus: %s", error->message); | ||
2561 | 163 | g_error_free(error); | ||
2562 | 164 | return; | ||
2563 | 165 | } | ||
2564 | 166 | |||
2565 | 167 | dbus_g_connection_register_g_object(session_bus, | ||
2566 | 168 | NOTIFICATION_WATCHER_DBUS_OBJ, | ||
2567 | 169 | G_OBJECT(self)); | ||
2568 | 170 | |||
2569 | 171 | priv->dbus_proxy = dbus_g_proxy_new_for_name_owner(session_bus, | ||
2570 | 172 | DBUS_SERVICE_DBUS, | ||
2571 | 173 | DBUS_PATH_DBUS, | ||
2572 | 174 | DBUS_INTERFACE_DBUS, | ||
2573 | 175 | &error); | ||
2574 | 176 | if (error != NULL) { | ||
2575 | 177 | g_error("Ah, can't get proxy to dbus: %s", error->message); | ||
2576 | 178 | g_error_free(error); | ||
2577 | 179 | return; | ||
2578 | 180 | } | ||
2579 | 181 | |||
2580 | 182 | org_freedesktop_DBus_request_name_async(priv->dbus_proxy, | ||
2581 | 183 | NOTIFICATION_WATCHER_DBUS_ADDR, | ||
2582 | 184 | DBUS_NAME_FLAG_DO_NOT_QUEUE, | ||
2583 | 185 | get_name_cb, | ||
2584 | 186 | self); | ||
2585 | 187 | |||
2586 | 188 | return; | ||
2587 | 189 | } | ||
2588 | 190 | |||
2589 | 191 | static void | ||
2590 | 192 | application_service_watcher_dispose (GObject *object) | ||
2591 | 193 | { | ||
2592 | 194 | ApplicationServiceWatcherPrivate * priv = APPLICATION_SERVICE_WATCHER_GET_PRIVATE(object); | ||
2593 | 195 | |||
2594 | 196 | if (priv->appstore != NULL) { | ||
2595 | 197 | g_object_unref(G_OBJECT(priv->appstore)); | ||
2596 | 198 | priv->appstore = NULL; | ||
2597 | 199 | } | ||
2598 | 200 | |||
2599 | 201 | G_OBJECT_CLASS (application_service_watcher_parent_class)->dispose (object); | ||
2600 | 202 | return; | ||
2601 | 203 | } | ||
2602 | 204 | |||
2603 | 205 | static void | ||
2604 | 206 | application_service_watcher_finalize (GObject *object) | ||
2605 | 207 | { | ||
2606 | 208 | |||
2607 | 209 | G_OBJECT_CLASS (application_service_watcher_parent_class)->finalize (object); | ||
2608 | 210 | return; | ||
2609 | 211 | } | ||
2610 | 212 | |||
2611 | 213 | static void | ||
2612 | 214 | application_service_watcher_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) | ||
2613 | 215 | { | ||
2614 | 216 | /* There are no writable properties for now */ | ||
2615 | 217 | } | ||
2616 | 218 | |||
2617 | 219 | static void | ||
2618 | 220 | application_service_watcher_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) | ||
2619 | 221 | { | ||
2620 | 222 | ApplicationServiceWatcherPrivate * priv = APPLICATION_SERVICE_WATCHER_GET_PRIVATE(object); | ||
2621 | 223 | switch (prop_id) { | ||
2622 | 224 | case PROP_PROTOCOL_VERSION: | ||
2623 | 225 | g_value_set_int (value, CURRENT_PROTOCOL_VERSION); | ||
2624 | 226 | break; | ||
2625 | 227 | case PROP_IS_STATUS_NOTIFIER_HOST_REGISTERED: | ||
2626 | 228 | g_value_set_boolean (value, TRUE); | ||
2627 | 229 | break; | ||
2628 | 230 | case PROP_REGISTERED_STATUS_NOTIFIER_ITEMS: | ||
2629 | 231 | g_value_set_boxed (value, application_service_appstore_application_get_list(priv->appstore)); | ||
2630 | 232 | break; | ||
2631 | 233 | } | ||
2632 | 234 | } | ||
2633 | 235 | |||
2634 | 236 | ApplicationServiceWatcher * | ||
2635 | 237 | application_service_watcher_new (ApplicationServiceAppstore * appstore) | ||
2636 | 238 | { | ||
2637 | 239 | GObject * obj = g_object_new(APPLICATION_SERVICE_WATCHER_TYPE, NULL); | ||
2638 | 240 | ApplicationServiceWatcherPrivate * priv = APPLICATION_SERVICE_WATCHER_GET_PRIVATE(obj); | ||
2639 | 241 | priv->appstore = appstore; | ||
2640 | 242 | g_object_ref(G_OBJECT(priv->appstore)); | ||
2641 | 243 | return APPLICATION_SERVICE_WATCHER(obj); | ||
2642 | 244 | } | ||
2643 | 245 | |||
2644 | 246 | static gboolean | ||
2645 | 247 | _notification_watcher_server_register_status_notifier_item (ApplicationServiceWatcher * appwatcher, const gchar * service, DBusGMethodInvocation * method) | ||
2646 | 248 | { | ||
2647 | 249 | ApplicationServiceWatcherPrivate * priv = APPLICATION_SERVICE_WATCHER_GET_PRIVATE(appwatcher); | ||
2648 | 250 | |||
2649 | 251 | if (service[0] == '/') { | ||
2650 | 252 | application_service_appstore_application_add(priv->appstore, | ||
2651 | 253 | dbus_g_method_get_sender(method), | ||
2652 | 254 | service); | ||
2653 | 255 | } else { | ||
2654 | 256 | application_service_appstore_application_add(priv->appstore, | ||
2655 | 257 | service, | ||
2656 | 258 | NOTIFICATION_ITEM_DEFAULT_OBJ); | ||
2657 | 259 | } | ||
2658 | 260 | |||
2659 | 261 | dbus_g_method_return(method, G_TYPE_NONE); | ||
2660 | 262 | return TRUE; | ||
2661 | 263 | } | ||
2662 | 264 | |||
2663 | 265 | static gboolean | ||
2664 | 266 | _notification_watcher_server_register_status_notifier_host (ApplicationServiceWatcher * appwatcher, const gchar * host) | ||
2665 | 267 | { | ||
2666 | 268 | |||
2667 | 269 | return FALSE; | ||
2668 | 270 | } | ||
2669 | 271 | |||
2670 | 272 | /* Function to handle the return of the get name. There isn't a whole | ||
2671 | 273 | lot that can be done, but we're atleast going to tell people. */ | ||
2672 | 274 | static void | ||
2673 | 275 | get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer data) | ||
2674 | 276 | { | ||
2675 | 277 | if (error != NULL) { | ||
2676 | 278 | g_warning("Unable to get watcher name '%s' because: %s", NOTIFICATION_WATCHER_DBUS_ADDR, error->message); | ||
2677 | 279 | return; | ||
2678 | 280 | } | ||
2679 | 281 | |||
2680 | 282 | if (status != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER && | ||
2681 | 283 | status != DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER) { | ||
2682 | 284 | g_warning("Unable to get watcher name '%s'", NOTIFICATION_WATCHER_DBUS_ADDR); | ||
2683 | 285 | return; | ||
2684 | 286 | } | ||
2685 | 287 | |||
2686 | 288 | return; | ||
2687 | 289 | } | ||
2688 | 290 | |||
2689 | 291 | static gboolean | ||
2690 | 292 | _notification_watcher_server_x_ayatana_register_notification_approver (ApplicationServiceWatcher * appwatcher, const gchar * path, const GArray * categories, DBusGMethodInvocation * method) | ||
2691 | 293 | { | ||
2692 | 294 | ApplicationServiceWatcherPrivate * priv = APPLICATION_SERVICE_WATCHER_GET_PRIVATE(appwatcher); | ||
2693 | 295 | |||
2694 | 296 | application_service_appstore_approver_add(priv->appstore, | ||
2695 | 297 | dbus_g_method_get_sender(method), | ||
2696 | 298 | path); | ||
2697 | 299 | |||
2698 | 300 | dbus_g_method_return(method, G_TYPE_NONE); | ||
2699 | 301 | return TRUE; | ||
2700 | 302 | } | ||
2701 | 303 | 0 | ||
2702 | === removed file 'src/application-service-watcher.h' | |||
2703 | --- src/application-service-watcher.h 2010-10-08 16:04:27 +0000 | |||
2704 | +++ src/application-service-watcher.h 1970-01-01 00:00:00 +0000 | |||
2705 | @@ -1,61 +0,0 @@ | |||
2706 | 1 | /* | ||
2707 | 2 | An object implementing the NotificationWatcher interface and passes | ||
2708 | 3 | the information into the app-store. | ||
2709 | 4 | |||
2710 | 5 | Copyright 2009 Canonical Ltd. | ||
2711 | 6 | |||
2712 | 7 | Authors: | ||
2713 | 8 | Ted Gould <ted@canonical.com> | ||
2714 | 9 | |||
2715 | 10 | This program is free software: you can redistribute it and/or modify it | ||
2716 | 11 | under the terms of the GNU General Public License version 3, as published | ||
2717 | 12 | by the Free Software Foundation. | ||
2718 | 13 | |||
2719 | 14 | This program is distributed in the hope that it will be useful, but | ||
2720 | 15 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2721 | 16 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2722 | 17 | PURPOSE. See the GNU General Public License for more details. | ||
2723 | 18 | |||
2724 | 19 | You should have received a copy of the GNU General Public License along | ||
2725 | 20 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2726 | 21 | */ | ||
2727 | 22 | |||
2728 | 23 | #ifndef __APPLICATION_SERVICE_WATCHER_H__ | ||
2729 | 24 | #define __APPLICATION_SERVICE_WATCHER_H__ | ||
2730 | 25 | |||
2731 | 26 | #include <glib.h> | ||
2732 | 27 | #include <glib-object.h> | ||
2733 | 28 | |||
2734 | 29 | #include "application-service-appstore.h" | ||
2735 | 30 | |||
2736 | 31 | G_BEGIN_DECLS | ||
2737 | 32 | |||
2738 | 33 | #define APPLICATION_SERVICE_WATCHER_TYPE (application_service_watcher_get_type ()) | ||
2739 | 34 | #define APPLICATION_SERVICE_WATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_SERVICE_WATCHER_TYPE, ApplicationServiceWatcher)) | ||
2740 | 35 | #define APPLICATION_SERVICE_WATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_SERVICE_WATCHER_TYPE, ApplicationServiceWatcherClass)) | ||
2741 | 36 | #define IS_APPLICATION_SERVICE_WATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_SERVICE_WATCHER_TYPE)) | ||
2742 | 37 | #define IS_APPLICATION_SERVICE_WATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_SERVICE_WATCHER_TYPE)) | ||
2743 | 38 | #define APPLICATION_SERVICE_WATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_SERVICE_WATCHER_TYPE, ApplicationServiceWatcherClass)) | ||
2744 | 39 | |||
2745 | 40 | typedef struct _ApplicationServiceWatcher ApplicationServiceWatcher; | ||
2746 | 41 | typedef struct _ApplicationServiceWatcherClass ApplicationServiceWatcherClass; | ||
2747 | 42 | |||
2748 | 43 | struct _ApplicationServiceWatcherClass { | ||
2749 | 44 | GObjectClass parent_class; | ||
2750 | 45 | |||
2751 | 46 | /* Signals */ | ||
2752 | 47 | void (*status_notifier_item_registered) (ApplicationServiceWatcher * watcher, gchar * object, gpointer data); | ||
2753 | 48 | void (*status_notifier_item_unregistered) (ApplicationServiceWatcher * watcher, gchar * object, gpointer data); | ||
2754 | 49 | void (*status_notifier_host_registered) (ApplicationServiceWatcher * watcher, gpointer data); | ||
2755 | 50 | }; | ||
2756 | 51 | |||
2757 | 52 | struct _ApplicationServiceWatcher { | ||
2758 | 53 | GObject parent; | ||
2759 | 54 | }; | ||
2760 | 55 | |||
2761 | 56 | GType application_service_watcher_get_type (void); | ||
2762 | 57 | ApplicationServiceWatcher * application_service_watcher_new (ApplicationServiceAppstore * appstore); | ||
2763 | 58 | |||
2764 | 59 | G_END_DECLS | ||
2765 | 60 | |||
2766 | 61 | #endif | ||
2767 | 62 | 0 | ||
2768 | === removed file 'src/application-service.c' | |||
2769 | --- src/application-service.c 2010-08-10 19:47:23 +0000 | |||
2770 | +++ src/application-service.c 1970-01-01 00:00:00 +0000 | |||
2771 | @@ -1,78 +0,0 @@ | |||
2772 | 1 | /* | ||
2773 | 2 | The core file for the service that starts up all the objects we need | ||
2774 | 3 | and houses our main loop. | ||
2775 | 4 | |||
2776 | 5 | Copyright 2009 Canonical Ltd. | ||
2777 | 6 | |||
2778 | 7 | Authors: | ||
2779 | 8 | Ted Gould <ted@canonical.com> | ||
2780 | 9 | |||
2781 | 10 | This program is free software: you can redistribute it and/or modify it | ||
2782 | 11 | under the terms of the GNU General Public License version 3, as published | ||
2783 | 12 | by the Free Software Foundation. | ||
2784 | 13 | |||
2785 | 14 | This program is distributed in the hope that it will be useful, but | ||
2786 | 15 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2787 | 16 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2788 | 17 | PURPOSE. See the GNU General Public License for more details. | ||
2789 | 18 | |||
2790 | 19 | You should have received a copy of the GNU General Public License along | ||
2791 | 20 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2792 | 21 | */ | ||
2793 | 22 | |||
2794 | 23 | |||
2795 | 24 | #include "libindicator/indicator-service.h" | ||
2796 | 25 | #include "notification-item-client.h" | ||
2797 | 26 | #include "application-service-appstore.h" | ||
2798 | 27 | #include "application-service-watcher.h" | ||
2799 | 28 | #include "dbus-shared.h" | ||
2800 | 29 | |||
2801 | 30 | /* The base main loop */ | ||
2802 | 31 | static GMainLoop * mainloop = NULL; | ||
2803 | 32 | /* Where the application registry lives */ | ||
2804 | 33 | static ApplicationServiceAppstore * appstore = NULL; | ||
2805 | 34 | /* Interface for applications */ | ||
2806 | 35 | static ApplicationServiceWatcher * watcher = NULL; | ||
2807 | 36 | /* The service management interface */ | ||
2808 | 37 | static IndicatorService * service = NULL; | ||
2809 | 38 | |||
2810 | 39 | /* Recieves the disonnection signal from the service | ||
2811 | 40 | object and closes the mainloop. */ | ||
2812 | 41 | static void | ||
2813 | 42 | service_disconnected (IndicatorService * service, gpointer data) | ||
2814 | 43 | { | ||
2815 | 44 | g_debug("Service disconnected"); | ||
2816 | 45 | if (mainloop != NULL) { | ||
2817 | 46 | g_main_loop_quit(mainloop); | ||
2818 | 47 | } | ||
2819 | 48 | return; | ||
2820 | 49 | } | ||
2821 | 50 | |||
2822 | 51 | /* Builds up the core objects and puts us spinning into | ||
2823 | 52 | a main loop. */ | ||
2824 | 53 | int | ||
2825 | 54 | main (int argc, char ** argv) | ||
2826 | 55 | { | ||
2827 | 56 | g_type_init(); | ||
2828 | 57 | |||
2829 | 58 | /* Bring us up as a basic indicator service */ | ||
2830 | 59 | service = indicator_service_new(INDICATOR_APPLICATION_DBUS_ADDR); | ||
2831 | 60 | g_signal_connect(G_OBJECT(service), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, G_CALLBACK(service_disconnected), NULL); | ||
2832 | 61 | |||
2833 | 62 | /* Building our app store */ | ||
2834 | 63 | appstore = application_service_appstore_new(); | ||
2835 | 64 | |||
2836 | 65 | /* Adding a watcher for the Apps coming up */ | ||
2837 | 66 | watcher = application_service_watcher_new(appstore); | ||
2838 | 67 | |||
2839 | 68 | /* Building and executing our main loop */ | ||
2840 | 69 | mainloop = g_main_loop_new(NULL, FALSE); | ||
2841 | 70 | g_main_loop_run(mainloop); | ||
2842 | 71 | |||
2843 | 72 | /* Unref'ing all the objects */ | ||
2844 | 73 | g_object_unref(G_OBJECT(watcher)); | ||
2845 | 74 | g_object_unref(G_OBJECT(appstore)); | ||
2846 | 75 | g_object_unref(G_OBJECT(service)); | ||
2847 | 76 | |||
2848 | 77 | return 0; | ||
2849 | 78 | } | ||
2850 | 79 | 0 | ||
2851 | === removed file 'src/application-service.xml' | |||
2852 | --- src/application-service.xml 2010-08-05 21:54:12 +0000 | |||
2853 | +++ src/application-service.xml 1970-01-01 00:00:00 +0000 | |||
2854 | @@ -1,59 +0,0 @@ | |||
2855 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2856 | 2 | <!-- | ||
2857 | 3 | An interface for communication between the service and indicator. | ||
2858 | 4 | |||
2859 | 5 | Copyright 2009 Canonical Ltd. | ||
2860 | 6 | |||
2861 | 7 | Authors: | ||
2862 | 8 | Ted Gould <ted@canonical.com> | ||
2863 | 9 | |||
2864 | 10 | This program is free software: you can redistribute it and/or modify it | ||
2865 | 11 | under the terms of the GNU General Public License version 3, as published | ||
2866 | 12 | by the Free Software Foundation. | ||
2867 | 13 | |||
2868 | 14 | This program is distributed in the hope that it will be useful, but | ||
2869 | 15 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2870 | 16 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2871 | 17 | PURPOSE. See the GNU General Public License for more details. | ||
2872 | 18 | |||
2873 | 19 | You should have received a copy of the GNU General Public License along | ||
2874 | 20 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2875 | 21 | --> | ||
2876 | 22 | <node name="/"> | ||
2877 | 23 | <interface name="org.ayatana.indicator.application.service"> | ||
2878 | 24 | <!-- Properties --> | ||
2879 | 25 | <!-- None currently --> | ||
2880 | 26 | |||
2881 | 27 | <!-- Methods --> | ||
2882 | 28 | <method name="GetApplications"> | ||
2883 | 29 | <arg type="a(sisosss)" name="applications" direction="out" /> | ||
2884 | 30 | </method> | ||
2885 | 31 | |||
2886 | 32 | <!-- Signals --> | ||
2887 | 33 | <signal name="ApplicationAdded"> | ||
2888 | 34 | <arg type="s" name="iconname" direction="out" /> | ||
2889 | 35 | <arg type="i" name="position" direction="out" /> | ||
2890 | 36 | <arg type="s" name="dbusaddress" direction="out" /> | ||
2891 | 37 | <arg type="o" name="dbusobject" direction="out" /> | ||
2892 | 38 | <arg type="s" name="iconpath" direction="out" /> | ||
2893 | 39 | <arg type="s" name="label" direction="out" /> | ||
2894 | 40 | <arg type="s" name="labelguide" direction="out" /> | ||
2895 | 41 | </signal> | ||
2896 | 42 | <signal name="ApplicationRemoved"> | ||
2897 | 43 | <arg type="i" name="position" direction="out" /> | ||
2898 | 44 | </signal> | ||
2899 | 45 | <signal name="ApplicationIconChanged"> | ||
2900 | 46 | <arg type="i" name="position" direction="out" /> | ||
2901 | 47 | <arg type="s" name="icon_name" direction="out" /> | ||
2902 | 48 | </signal> | ||
2903 | 49 | <signal name="ApplicationIconThemePathChanged"> | ||
2904 | 50 | <arg type="i" name="position" direction="out" /> | ||
2905 | 51 | <arg type="s" name="icon_theme_path" direction="out" /> | ||
2906 | 52 | </signal> | ||
2907 | 53 | <signal name="ApplicationLabelChanged"> | ||
2908 | 54 | <arg type="i" name="position" direction="out" /> | ||
2909 | 55 | <arg type="s" name="label" direction="out" /> | ||
2910 | 56 | <arg type="s" name="guide" direction="out" /> | ||
2911 | 57 | </signal> | ||
2912 | 58 | </interface> | ||
2913 | 59 | </node> | ||
2914 | 60 | 0 | ||
2915 | === removed file 'src/dbus-properties.xml' | |||
2916 | --- src/dbus-properties.xml 2009-11-07 04:50:48 +0000 | |||
2917 | +++ src/dbus-properties.xml 1970-01-01 00:00:00 +0000 | |||
2918 | @@ -1,23 +0,0 @@ | |||
2919 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2920 | 2 | <node name="/"> | ||
2921 | 3 | <interface name="org.freedesktop.DBus.Properties"> | ||
2922 | 4 | |||
2923 | 5 | <method name="Get"> | ||
2924 | 6 | <arg direction="in" type="s" name="Interface_Name"/> | ||
2925 | 7 | <arg direction="in" type="s" name="Property_Name"/> | ||
2926 | 8 | <arg direction="out" type="v" name="Value"/> | ||
2927 | 9 | </method> | ||
2928 | 10 | |||
2929 | 11 | <method name="Set"> | ||
2930 | 12 | <arg direction="in" type="s" name="Interface_Name"/> | ||
2931 | 13 | <arg direction="in" type="s" name="Property_Name"/> | ||
2932 | 14 | <arg direction="in" type="v" name="Value"/> | ||
2933 | 15 | </method> | ||
2934 | 16 | |||
2935 | 17 | <method name="GetAll"> | ||
2936 | 18 | <arg direction="in" type="s" name="Interface_Name"/> | ||
2937 | 19 | <arg direction="out" type="a{sv}" name="Properties"/> | ||
2938 | 20 | </method> | ||
2939 | 21 | |||
2940 | 22 | </interface> | ||
2941 | 23 | </node> | ||
2942 | 24 | 0 | ||
2943 | === removed file 'src/indicator-application.c' | |||
2944 | --- src/indicator-application.c 2010-12-04 03:12:06 +0000 | |||
2945 | +++ src/indicator-application.c 1970-01-01 00:00:00 +0000 | |||
2946 | @@ -1,879 +0,0 @@ | |||
2947 | 1 | /* | ||
2948 | 2 | The indicator application visualization object. It takes the information | ||
2949 | 3 | given by the service and turns it into real-world pixels that users can | ||
2950 | 4 | actually use. Well, GTK does that, but this asks nicely. | ||
2951 | 5 | |||
2952 | 6 | Copyright 2009 Canonical Ltd. | ||
2953 | 7 | |||
2954 | 8 | Authors: | ||
2955 | 9 | Ted Gould <ted@canonical.com> | ||
2956 | 10 | |||
2957 | 11 | This program is free software: you can redistribute it and/or modify it | ||
2958 | 12 | under the terms of the GNU General Public License version 3, as published | ||
2959 | 13 | by the Free Software Foundation. | ||
2960 | 14 | |||
2961 | 15 | This program is distributed in the hope that it will be useful, but | ||
2962 | 16 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2963 | 17 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2964 | 18 | PURPOSE. See the GNU General Public License for more details. | ||
2965 | 19 | |||
2966 | 20 | You should have received a copy of the GNU General Public License along | ||
2967 | 21 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2968 | 22 | */ | ||
2969 | 23 | |||
2970 | 24 | #ifdef HAVE_CONFIG_H | ||
2971 | 25 | #include "config.h" | ||
2972 | 26 | #endif | ||
2973 | 27 | |||
2974 | 28 | /* G Stuff */ | ||
2975 | 29 | #include <glib.h> | ||
2976 | 30 | #include <glib-object.h> | ||
2977 | 31 | #include <gtk/gtk.h> | ||
2978 | 32 | |||
2979 | 33 | /* DBus Stuff */ | ||
2980 | 34 | #include <dbus/dbus-glib.h> | ||
2981 | 35 | #ifdef HAVE_GTK3 | ||
2982 | 36 | #include <libdbusmenu-gtk3/menu.h> | ||
2983 | 37 | #else | ||
2984 | 38 | #include <libdbusmenu-gtk/menu.h> | ||
2985 | 39 | #endif | ||
2986 | 40 | |||
2987 | 41 | /* Indicator Stuff */ | ||
2988 | 42 | #include <libindicator/indicator.h> | ||
2989 | 43 | #include <libindicator/indicator-object.h> | ||
2990 | 44 | #include <libindicator/indicator-service-manager.h> | ||
2991 | 45 | #include <libindicator/indicator-image-helper.h> | ||
2992 | 46 | |||
2993 | 47 | /* Local Stuff */ | ||
2994 | 48 | #include "dbus-shared.h" | ||
2995 | 49 | #include "application-service-client.h" | ||
2996 | 50 | #include "application-service-marshal.h" | ||
2997 | 51 | |||
2998 | 52 | #define PANEL_ICON_SUFFIX "panel" | ||
2999 | 53 | |||
3000 | 54 | #define INDICATOR_APPLICATION_TYPE (indicator_application_get_type ()) | ||
3001 | 55 | #define INDICATOR_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_APPLICATION_TYPE, IndicatorApplication)) | ||
3002 | 56 | #define INDICATOR_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATOR_APPLICATION_TYPE, IndicatorApplicationClass)) | ||
3003 | 57 | #define IS_INDICATOR_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_APPLICATION_TYPE)) | ||
3004 | 58 | #define IS_INDICATOR_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_APPLICATION_TYPE)) | ||
3005 | 59 | #define INDICATOR_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_APPLICATION_TYPE, IndicatorApplicationClass)) | ||
3006 | 60 | |||
3007 | 61 | typedef struct _IndicatorApplication IndicatorApplication; | ||
3008 | 62 | typedef struct _IndicatorApplicationClass IndicatorApplicationClass; | ||
3009 | 63 | |||
3010 | 64 | struct _IndicatorApplicationClass { | ||
3011 | 65 | IndicatorObjectClass parent_class; | ||
3012 | 66 | }; | ||
3013 | 67 | |||
3014 | 68 | struct _IndicatorApplication { | ||
3015 | 69 | IndicatorObject parent; | ||
3016 | 70 | }; | ||
3017 | 71 | |||
3018 | 72 | GType indicator_application_get_type (void); | ||
3019 | 73 | |||
3020 | 74 | INDICATOR_SET_VERSION | ||
3021 | 75 | INDICATOR_SET_TYPE(INDICATOR_APPLICATION_TYPE) | ||
3022 | 76 | |||
3023 | 77 | #ifdef HAVE_CONFIG_H | ||
3024 | 78 | #include "config.h" | ||
3025 | 79 | #endif | ||
3026 | 80 | |||
3027 | 81 | typedef struct _IndicatorApplicationPrivate IndicatorApplicationPrivate; | ||
3028 | 82 | struct _IndicatorApplicationPrivate { | ||
3029 | 83 | IndicatorServiceManager * sm; | ||
3030 | 84 | DBusGConnection * bus; | ||
3031 | 85 | DBusGProxy * service_proxy; | ||
3032 | 86 | GList * applications; | ||
3033 | 87 | GHashTable * theme_dirs; | ||
3034 | 88 | guint disconnect_kill; | ||
3035 | 89 | }; | ||
3036 | 90 | |||
3037 | 91 | typedef struct _ApplicationEntry ApplicationEntry; | ||
3038 | 92 | struct _ApplicationEntry { | ||
3039 | 93 | IndicatorObjectEntry entry; | ||
3040 | 94 | gchar * icon_theme_path; | ||
3041 | 95 | gboolean old_service; | ||
3042 | 96 | gchar * dbusobject; | ||
3043 | 97 | gchar * dbusaddress; | ||
3044 | 98 | gchar * guide; | ||
3045 | 99 | gchar * longname; | ||
3046 | 100 | }; | ||
3047 | 101 | |||
3048 | 102 | #define INDICATOR_APPLICATION_GET_PRIVATE(o) \ | ||
3049 | 103 | (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_APPLICATION_TYPE, IndicatorApplicationPrivate)) | ||
3050 | 104 | |||
3051 | 105 | static void indicator_application_class_init (IndicatorApplicationClass *klass); | ||
3052 | 106 | static void indicator_application_init (IndicatorApplication *self); | ||
3053 | 107 | static void indicator_application_dispose (GObject *object); | ||
3054 | 108 | static void indicator_application_finalize (GObject *object); | ||
3055 | 109 | static GList * get_entries (IndicatorObject * io); | ||
3056 | 110 | static guint get_location (IndicatorObject * io, IndicatorObjectEntry * entry); | ||
3057 | 111 | void connection_changed (IndicatorServiceManager * sm, gboolean connected, IndicatorApplication * application); | ||
3058 | 112 | static void connected (IndicatorApplication * application); | ||
3059 | 113 | static void disconnected (IndicatorApplication * application); | ||
3060 | 114 | static void disconnected_helper (gpointer data, gpointer user_data); | ||
3061 | 115 | static gboolean disconnected_kill (gpointer user_data); | ||
3062 | 116 | static void disconnected_kill_helper (gpointer data, gpointer user_data); | ||
3063 | 117 | static void application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_theme_path, const gchar * label, const gchar * guide, IndicatorApplication * application); | ||
3064 | 118 | static void application_removed (DBusGProxy * proxy, gint position , IndicatorApplication * application); | ||
3065 | 119 | static void application_label_changed (DBusGProxy * proxy, gint position, const gchar * label, const gchar * guide, IndicatorApplication * application); | ||
3066 | 120 | static void application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconname, IndicatorApplication * application); | ||
3067 | 121 | static void application_icon_theme_path_changed (DBusGProxy * proxy, gint position, const gchar * icon_theme_path, IndicatorApplication * application); | ||
3068 | 122 | static void get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, gpointer userdata); | ||
3069 | 123 | static void get_applications_helper (gpointer data, gpointer user_data); | ||
3070 | 124 | static void theme_dir_unref(IndicatorApplication * ia, const gchar * dir); | ||
3071 | 125 | static void theme_dir_ref(IndicatorApplication * ia, const gchar * dir); | ||
3072 | 126 | |||
3073 | 127 | G_DEFINE_TYPE (IndicatorApplication, indicator_application, INDICATOR_OBJECT_TYPE); | ||
3074 | 128 | |||
3075 | 129 | static void | ||
3076 | 130 | indicator_application_class_init (IndicatorApplicationClass *klass) | ||
3077 | 131 | { | ||
3078 | 132 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
3079 | 133 | |||
3080 | 134 | g_type_class_add_private (klass, sizeof (IndicatorApplicationPrivate)); | ||
3081 | 135 | |||
3082 | 136 | object_class->dispose = indicator_application_dispose; | ||
3083 | 137 | object_class->finalize = indicator_application_finalize; | ||
3084 | 138 | |||
3085 | 139 | IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass); | ||
3086 | 140 | |||
3087 | 141 | io_class->get_entries = get_entries; | ||
3088 | 142 | io_class->get_location = get_location; | ||
3089 | 143 | |||
3090 | 144 | dbus_g_object_register_marshaller(_application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING_STRING_STRING, | ||
3091 | 145 | G_TYPE_NONE, | ||
3092 | 146 | G_TYPE_STRING, | ||
3093 | 147 | G_TYPE_INT, | ||
3094 | 148 | G_TYPE_STRING, | ||
3095 | 149 | G_TYPE_STRING, | ||
3096 | 150 | G_TYPE_STRING, | ||
3097 | 151 | G_TYPE_STRING, | ||
3098 | 152 | G_TYPE_STRING, | ||
3099 | 153 | G_TYPE_INVALID); | ||
3100 | 154 | dbus_g_object_register_marshaller(_application_service_marshal_VOID__INT_STRING, | ||
3101 | 155 | G_TYPE_NONE, | ||
3102 | 156 | G_TYPE_INT, | ||
3103 | 157 | G_TYPE_STRING, | ||
3104 | 158 | G_TYPE_INVALID); | ||
3105 | 159 | dbus_g_object_register_marshaller(_application_service_marshal_VOID__INT_STRING_STRING, | ||
3106 | 160 | G_TYPE_NONE, | ||
3107 | 161 | G_TYPE_INT, | ||
3108 | 162 | G_TYPE_STRING, | ||
3109 | 163 | G_TYPE_STRING, | ||
3110 | 164 | G_TYPE_INVALID); | ||
3111 | 165 | |||
3112 | 166 | return; | ||
3113 | 167 | } | ||
3114 | 168 | |||
3115 | 169 | static void | ||
3116 | 170 | indicator_application_init (IndicatorApplication *self) | ||
3117 | 171 | { | ||
3118 | 172 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(self); | ||
3119 | 173 | |||
3120 | 174 | /* These are built in the connection phase */ | ||
3121 | 175 | priv->bus = NULL; | ||
3122 | 176 | priv->service_proxy = NULL; | ||
3123 | 177 | priv->theme_dirs = NULL; | ||
3124 | 178 | priv->disconnect_kill = 0; | ||
3125 | 179 | |||
3126 | 180 | priv->sm = indicator_service_manager_new(INDICATOR_APPLICATION_DBUS_ADDR); | ||
3127 | 181 | g_signal_connect(G_OBJECT(priv->sm), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self); | ||
3128 | 182 | |||
3129 | 183 | priv->applications = NULL; | ||
3130 | 184 | |||
3131 | 185 | priv->theme_dirs = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | ||
3132 | 186 | |||
3133 | 187 | return; | ||
3134 | 188 | } | ||
3135 | 189 | |||
3136 | 190 | static void | ||
3137 | 191 | indicator_application_dispose (GObject *object) | ||
3138 | 192 | { | ||
3139 | 193 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(object); | ||
3140 | 194 | |||
3141 | 195 | if (priv->disconnect_kill != 0) { | ||
3142 | 196 | g_source_remove(priv->disconnect_kill); | ||
3143 | 197 | } | ||
3144 | 198 | |||
3145 | 199 | while (priv->applications != NULL) { | ||
3146 | 200 | application_removed(priv->service_proxy, | ||
3147 | 201 | 0, | ||
3148 | 202 | INDICATOR_APPLICATION(object)); | ||
3149 | 203 | } | ||
3150 | 204 | |||
3151 | 205 | if (priv->sm != NULL) { | ||
3152 | 206 | g_object_unref(priv->sm); | ||
3153 | 207 | priv->sm = NULL; | ||
3154 | 208 | } | ||
3155 | 209 | |||
3156 | 210 | if (priv->bus != NULL) { | ||
3157 | 211 | /* We're not incrementing the ref count on this one. */ | ||
3158 | 212 | priv->bus = NULL; | ||
3159 | 213 | } | ||
3160 | 214 | |||
3161 | 215 | if (priv->service_proxy != NULL) { | ||
3162 | 216 | g_object_unref(G_OBJECT(priv->service_proxy)); | ||
3163 | 217 | priv->service_proxy = NULL; | ||
3164 | 218 | } | ||
3165 | 219 | |||
3166 | 220 | if (priv->theme_dirs != NULL) { | ||
3167 | 221 | while (g_hash_table_size(priv->theme_dirs)) { | ||
3168 | 222 | GList * keys = g_hash_table_get_keys(priv->theme_dirs); | ||
3169 | 223 | theme_dir_unref(INDICATOR_APPLICATION(object), (gchar *)keys->data); | ||
3170 | 224 | } | ||
3171 | 225 | g_hash_table_destroy(priv->theme_dirs); | ||
3172 | 226 | priv->theme_dirs = NULL; | ||
3173 | 227 | } | ||
3174 | 228 | |||
3175 | 229 | G_OBJECT_CLASS (indicator_application_parent_class)->dispose (object); | ||
3176 | 230 | return; | ||
3177 | 231 | } | ||
3178 | 232 | |||
3179 | 233 | static void | ||
3180 | 234 | indicator_application_finalize (GObject *object) | ||
3181 | 235 | { | ||
3182 | 236 | |||
3183 | 237 | G_OBJECT_CLASS (indicator_application_parent_class)->finalize (object); | ||
3184 | 238 | return; | ||
3185 | 239 | } | ||
3186 | 240 | |||
3187 | 241 | /* Responds to connection change event from the service manager and | ||
3188 | 242 | splits it into two. */ | ||
3189 | 243 | void | ||
3190 | 244 | connection_changed (IndicatorServiceManager * sm, gboolean connect, IndicatorApplication * application) | ||
3191 | 245 | { | ||
3192 | 246 | g_return_if_fail(IS_INDICATOR_APPLICATION(application)); | ||
3193 | 247 | if (connect) { | ||
3194 | 248 | connected(application); | ||
3195 | 249 | } else { | ||
3196 | 250 | disconnected(application); | ||
3197 | 251 | } | ||
3198 | 252 | return; | ||
3199 | 253 | } | ||
3200 | 254 | |||
3201 | 255 | /* Brings up the connection to a service that has just come onto the | ||
3202 | 256 | bus, or is atleast new to us. */ | ||
3203 | 257 | void | ||
3204 | 258 | connected (IndicatorApplication * application) | ||
3205 | 259 | { | ||
3206 | 260 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); | ||
3207 | 261 | g_debug("Connected to Application Indicator Service."); | ||
3208 | 262 | |||
3209 | 263 | GError * error = NULL; | ||
3210 | 264 | |||
3211 | 265 | /* Grab the session bus */ | ||
3212 | 266 | if (priv->bus == NULL) { | ||
3213 | 267 | priv->bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); | ||
3214 | 268 | |||
3215 | 269 | if (error != NULL) { | ||
3216 | 270 | g_error("Unable to get session bus: %s", error->message); | ||
3217 | 271 | g_error_free(error); | ||
3218 | 272 | return; | ||
3219 | 273 | } | ||
3220 | 274 | } | ||
3221 | 275 | |||
3222 | 276 | if (priv->service_proxy == NULL) { | ||
3223 | 277 | /* Build the service proxy */ | ||
3224 | 278 | priv->service_proxy = dbus_g_proxy_new_for_name(priv->bus, | ||
3225 | 279 | INDICATOR_APPLICATION_DBUS_ADDR, | ||
3226 | 280 | INDICATOR_APPLICATION_DBUS_OBJ, | ||
3227 | 281 | INDICATOR_APPLICATION_DBUS_IFACE); | ||
3228 | 282 | |||
3229 | 283 | /* Set up proxy signals */ | ||
3230 | 284 | g_debug("Setup proxy signals"); | ||
3231 | 285 | dbus_g_proxy_add_signal(priv->service_proxy, | ||
3232 | 286 | "ApplicationAdded", | ||
3233 | 287 | G_TYPE_STRING, | ||
3234 | 288 | G_TYPE_INT, | ||
3235 | 289 | G_TYPE_STRING, | ||
3236 | 290 | G_TYPE_STRING, | ||
3237 | 291 | G_TYPE_STRING, | ||
3238 | 292 | G_TYPE_STRING, | ||
3239 | 293 | G_TYPE_STRING, | ||
3240 | 294 | G_TYPE_INVALID); | ||
3241 | 295 | dbus_g_proxy_add_signal(priv->service_proxy, | ||
3242 | 296 | "ApplicationRemoved", | ||
3243 | 297 | G_TYPE_INT, | ||
3244 | 298 | G_TYPE_INVALID); | ||
3245 | 299 | dbus_g_proxy_add_signal(priv->service_proxy, | ||
3246 | 300 | "ApplicationIconChanged", | ||
3247 | 301 | G_TYPE_INT, | ||
3248 | 302 | G_TYPE_STRING, | ||
3249 | 303 | G_TYPE_INVALID); | ||
3250 | 304 | dbus_g_proxy_add_signal(priv->service_proxy, | ||
3251 | 305 | "ApplicationIconThemePathChanged", | ||
3252 | 306 | G_TYPE_INT, | ||
3253 | 307 | G_TYPE_STRING, | ||
3254 | 308 | G_TYPE_INVALID); | ||
3255 | 309 | dbus_g_proxy_add_signal(priv->service_proxy, | ||
3256 | 310 | "ApplicationLabelChanged", | ||
3257 | 311 | G_TYPE_INT, | ||
3258 | 312 | G_TYPE_STRING, | ||
3259 | 313 | G_TYPE_STRING, | ||
3260 | 314 | G_TYPE_INVALID); | ||
3261 | 315 | |||
3262 | 316 | /* Connect to them */ | ||
3263 | 317 | g_debug("Connect to them."); | ||
3264 | 318 | dbus_g_proxy_connect_signal(priv->service_proxy, | ||
3265 | 319 | "ApplicationAdded", | ||
3266 | 320 | G_CALLBACK(application_added), | ||
3267 | 321 | application, | ||
3268 | 322 | NULL /* Disconnection Signal */); | ||
3269 | 323 | dbus_g_proxy_connect_signal(priv->service_proxy, | ||
3270 | 324 | "ApplicationRemoved", | ||
3271 | 325 | G_CALLBACK(application_removed), | ||
3272 | 326 | application, | ||
3273 | 327 | NULL /* Disconnection Signal */); | ||
3274 | 328 | dbus_g_proxy_connect_signal(priv->service_proxy, | ||
3275 | 329 | "ApplicationIconChanged", | ||
3276 | 330 | G_CALLBACK(application_icon_changed), | ||
3277 | 331 | application, | ||
3278 | 332 | NULL /* Disconnection Signal */); | ||
3279 | 333 | dbus_g_proxy_connect_signal(priv->service_proxy, | ||
3280 | 334 | "ApplicationIconThemePathChanged", | ||
3281 | 335 | G_CALLBACK(application_icon_theme_path_changed), | ||
3282 | 336 | application, | ||
3283 | 337 | NULL /* Disconnection Signal */); | ||
3284 | 338 | dbus_g_proxy_connect_signal(priv->service_proxy, | ||
3285 | 339 | "ApplicationLabelChanged", | ||
3286 | 340 | G_CALLBACK(application_label_changed), | ||
3287 | 341 | application, | ||
3288 | 342 | NULL /* Disconnection Signal */); | ||
3289 | 343 | } | ||
3290 | 344 | |||
3291 | 345 | /* Query it for existing applications */ | ||
3292 | 346 | g_debug("Request current apps"); | ||
3293 | 347 | org_ayatana_indicator_application_service_get_applications_async(priv->service_proxy, | ||
3294 | 348 | get_applications, | ||
3295 | 349 | application); | ||
3296 | 350 | |||
3297 | 351 | return; | ||
3298 | 352 | } | ||
3299 | 353 | |||
3300 | 354 | /* Marks every current application as belonging to the old | ||
3301 | 355 | service so that we can delete it if it doesn't come back. | ||
3302 | 356 | Also, sets up a timeout on comming back. */ | ||
3303 | 357 | static void | ||
3304 | 358 | disconnected (IndicatorApplication * application) | ||
3305 | 359 | { | ||
3306 | 360 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); | ||
3307 | 361 | g_list_foreach(priv->applications, disconnected_helper, application); | ||
3308 | 362 | /* I'll like this to be a little shorter, but it's a bit | ||
3309 | 363 | inpractical to make it so. This means that the user will | ||
3310 | 364 | probably notice a visible glitch. Though, if applications | ||
3311 | 365 | are disappearing there isn't much we can do. */ | ||
3312 | 366 | priv->disconnect_kill = g_timeout_add(250, disconnected_kill, application); | ||
3313 | 367 | return; | ||
3314 | 368 | } | ||
3315 | 369 | |||
3316 | 370 | /* Marks an entry as being from the old service */ | ||
3317 | 371 | static void | ||
3318 | 372 | disconnected_helper (gpointer data, gpointer user_data) | ||
3319 | 373 | { | ||
3320 | 374 | ApplicationEntry * entry = (ApplicationEntry *)data; | ||
3321 | 375 | entry->old_service = TRUE; | ||
3322 | 376 | return; | ||
3323 | 377 | } | ||
3324 | 378 | |||
3325 | 379 | /* Makes sure the old applications that don't come back | ||
3326 | 380 | get dropped. */ | ||
3327 | 381 | static gboolean | ||
3328 | 382 | disconnected_kill (gpointer user_data) | ||
3329 | 383 | { | ||
3330 | 384 | g_return_val_if_fail(IS_INDICATOR_APPLICATION(user_data), FALSE); | ||
3331 | 385 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(user_data); | ||
3332 | 386 | priv->disconnect_kill = 0; | ||
3333 | 387 | g_list_foreach(priv->applications, disconnected_kill_helper, user_data); | ||
3334 | 388 | return FALSE; | ||
3335 | 389 | } | ||
3336 | 390 | |||
3337 | 391 | /* Looks for entries that are still associated with the | ||
3338 | 392 | old service and removes them. */ | ||
3339 | 393 | static void | ||
3340 | 394 | disconnected_kill_helper (gpointer data, gpointer user_data) | ||
3341 | 395 | { | ||
3342 | 396 | g_return_if_fail(IS_INDICATOR_APPLICATION(user_data)); | ||
3343 | 397 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(user_data); | ||
3344 | 398 | ApplicationEntry * entry = (ApplicationEntry *)data; | ||
3345 | 399 | if (entry->old_service) { | ||
3346 | 400 | application_removed(NULL, g_list_index(priv->applications, data), INDICATOR_APPLICATION(user_data)); | ||
3347 | 401 | } | ||
3348 | 402 | return; | ||
3349 | 403 | } | ||
3350 | 404 | |||
3351 | 405 | /* Goes through the list of applications that we're maintaining and | ||
3352 | 406 | pulls out the IndicatorObjectEntry and returns that in a list | ||
3353 | 407 | for the caller. */ | ||
3354 | 408 | static GList * | ||
3355 | 409 | get_entries (IndicatorObject * io) | ||
3356 | 410 | { | ||
3357 | 411 | g_return_val_if_fail(IS_INDICATOR_APPLICATION(io), NULL); | ||
3358 | 412 | |||
3359 | 413 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(io); | ||
3360 | 414 | GList * retval = NULL; | ||
3361 | 415 | GList * apppointer = NULL; | ||
3362 | 416 | |||
3363 | 417 | for (apppointer = priv->applications; apppointer != NULL; apppointer = g_list_next(apppointer)) { | ||
3364 | 418 | IndicatorObjectEntry * entry = &(((ApplicationEntry *)apppointer->data)->entry); | ||
3365 | 419 | retval = g_list_prepend(retval, entry); | ||
3366 | 420 | } | ||
3367 | 421 | |||
3368 | 422 | if (retval != NULL) { | ||
3369 | 423 | retval = g_list_reverse(retval); | ||
3370 | 424 | } | ||
3371 | 425 | |||
3372 | 426 | return retval; | ||
3373 | 427 | } | ||
3374 | 428 | |||
3375 | 429 | /* Finds the location of a specific entry */ | ||
3376 | 430 | static guint | ||
3377 | 431 | get_location (IndicatorObject * io, IndicatorObjectEntry * entry) | ||
3378 | 432 | { | ||
3379 | 433 | g_return_val_if_fail(IS_INDICATOR_APPLICATION(io), 0); | ||
3380 | 434 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(io); | ||
3381 | 435 | return g_list_index(priv->applications, entry); | ||
3382 | 436 | } | ||
3383 | 437 | |||
3384 | 438 | /* Searching for ApplicationEntries where the dbusobject and | ||
3385 | 439 | address are the same. */ | ||
3386 | 440 | static gint | ||
3387 | 441 | application_added_search (gconstpointer a, gconstpointer b) | ||
3388 | 442 | { | ||
3389 | 443 | ApplicationEntry * appa = (ApplicationEntry *)a; | ||
3390 | 444 | ApplicationEntry * appb = (ApplicationEntry *)b; | ||
3391 | 445 | |||
3392 | 446 | if (g_strcmp0(appa->dbusaddress, appb->dbusaddress) == 0 && | ||
3393 | 447 | g_strcmp0(appa->dbusobject, appb->dbusobject) == 0) { | ||
3394 | 448 | return 0; | ||
3395 | 449 | } | ||
3396 | 450 | |||
3397 | 451 | return -1; | ||
3398 | 452 | } | ||
3399 | 453 | |||
3400 | 454 | /* Does a quick meausre of how big the string is in | ||
3401 | 455 | pixels with a Pango layout */ | ||
3402 | 456 | static gint | ||
3403 | 457 | measure_string (GtkStyle * style, PangoContext * context, const gchar * string) | ||
3404 | 458 | { | ||
3405 | 459 | PangoLayout * layout = pango_layout_new(context); | ||
3406 | 460 | pango_layout_set_text(layout, string, -1); | ||
3407 | 461 | pango_layout_set_font_description(layout, style->font_desc); | ||
3408 | 462 | |||
3409 | 463 | gint width; | ||
3410 | 464 | pango_layout_get_pixel_size(layout, &width, NULL); | ||
3411 | 465 | g_object_unref(layout); | ||
3412 | 466 | return width; | ||
3413 | 467 | } | ||
3414 | 468 | |||
3415 | 469 | /* Try to get a good guess at what a maximum width of the entire | ||
3416 | 470 | string would be. */ | ||
3417 | 471 | static void | ||
3418 | 472 | guess_label_size (ApplicationEntry * app) | ||
3419 | 473 | { | ||
3420 | 474 | /* This is during startup. */ | ||
3421 | 475 | if (app->entry.label == NULL) return; | ||
3422 | 476 | |||
3423 | 477 | GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(app->entry.label)); | ||
3424 | 478 | PangoContext * context = gtk_widget_get_pango_context(GTK_WIDGET(app->entry.label)); | ||
3425 | 479 | |||
3426 | 480 | gint length = measure_string(style, context, gtk_label_get_text(app->entry.label)); | ||
3427 | 481 | |||
3428 | 482 | if (app->guide != NULL) { | ||
3429 | 483 | gint guidelen = measure_string(style, context, app->guide); | ||
3430 | 484 | if (guidelen > length) { | ||
3431 | 485 | length = guidelen; | ||
3432 | 486 | } | ||
3433 | 487 | } | ||
3434 | 488 | |||
3435 | 489 | gtk_widget_set_size_request(GTK_WIDGET(app->entry.label), length, -1); | ||
3436 | 490 | |||
3437 | 491 | return; | ||
3438 | 492 | } | ||
3439 | 493 | |||
3440 | 494 | /* Here we respond to new applications by building up the | ||
3441 | 495 | ApplicationEntry and signaling the indicator host that | ||
3442 | 496 | we've got a new indicator. */ | ||
3443 | 497 | static void | ||
3444 | 498 | application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_theme_path, const gchar * label, const gchar * guide, IndicatorApplication * application) | ||
3445 | 499 | { | ||
3446 | 500 | g_return_if_fail(IS_INDICATOR_APPLICATION(application)); | ||
3447 | 501 | g_debug("Building new application entry: %s with icon: %s", dbusaddress, iconname); | ||
3448 | 502 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); | ||
3449 | 503 | |||
3450 | 504 | /* First search to see if we already have this entry */ | ||
3451 | 505 | ApplicationEntry searchapp; | ||
3452 | 506 | searchapp.dbusaddress = (gchar *)dbusaddress; /* Casting off const, but it's okay, we're not changing it */ | ||
3453 | 507 | searchapp.dbusobject = (gchar *)dbusobject; /* Casting off const, but it's okay, we're not changing it */ | ||
3454 | 508 | |||
3455 | 509 | GList * searchpointer = g_list_find_custom(priv->applications, &searchapp, application_added_search); | ||
3456 | 510 | if (searchpointer != NULL) { | ||
3457 | 511 | g_debug("\t...Already have that one."); | ||
3458 | 512 | ApplicationEntry * app = (ApplicationEntry *)searchpointer->data; | ||
3459 | 513 | app->old_service = FALSE; | ||
3460 | 514 | return; | ||
3461 | 515 | } | ||
3462 | 516 | |||
3463 | 517 | ApplicationEntry * app = g_new(ApplicationEntry, 1); | ||
3464 | 518 | |||
3465 | 519 | app->old_service = FALSE; | ||
3466 | 520 | app->icon_theme_path = NULL; | ||
3467 | 521 | if (icon_theme_path != NULL && icon_theme_path[0] != '\0') { | ||
3468 | 522 | app->icon_theme_path = g_strdup(icon_theme_path); | ||
3469 | 523 | theme_dir_ref(application, icon_theme_path); | ||
3470 | 524 | } | ||
3471 | 525 | |||
3472 | 526 | app->dbusaddress = g_strdup(dbusaddress); | ||
3473 | 527 | app->dbusobject = g_strdup(dbusobject); | ||
3474 | 528 | app->guide = NULL; | ||
3475 | 529 | |||
3476 | 530 | /* We make a long name using the suffix, and if that | ||
3477 | 531 | icon is available we want to use it. Otherwise we'll | ||
3478 | 532 | just use the name we were given. */ | ||
3479 | 533 | app->longname = NULL; | ||
3480 | 534 | if (!g_str_has_suffix(iconname, PANEL_ICON_SUFFIX)) { | ||
3481 | 535 | app->longname = g_strdup_printf("%s-%s", iconname, PANEL_ICON_SUFFIX); | ||
3482 | 536 | } else { | ||
3483 | 537 | app->longname = g_strdup(iconname); | ||
3484 | 538 | } | ||
3485 | 539 | app->entry.image = indicator_image_helper(app->longname); | ||
3486 | 540 | |||
3487 | 541 | if (label == NULL || label[0] == '\0') { | ||
3488 | 542 | app->entry.label = NULL; | ||
3489 | 543 | } else { | ||
3490 | 544 | app->entry.label = GTK_LABEL(gtk_label_new(label)); | ||
3491 | 545 | g_object_ref(G_OBJECT(app->entry.label)); | ||
3492 | 546 | gtk_widget_show(GTK_WIDGET(app->entry.label)); | ||
3493 | 547 | |||
3494 | 548 | if (app->guide != NULL) { | ||
3495 | 549 | g_free(app->guide); | ||
3496 | 550 | app->guide = NULL; | ||
3497 | 551 | } | ||
3498 | 552 | |||
3499 | 553 | if (guide != NULL) { | ||
3500 | 554 | app->guide = g_strdup(guide); | ||
3501 | 555 | } | ||
3502 | 556 | |||
3503 | 557 | guess_label_size(app); | ||
3504 | 558 | } | ||
3505 | 559 | |||
3506 | 560 | app->entry.menu = GTK_MENU(dbusmenu_gtkmenu_new((gchar *)dbusaddress, (gchar *)dbusobject)); | ||
3507 | 561 | |||
3508 | 562 | /* Keep copies of these for ourself, just in case. */ | ||
3509 | 563 | g_object_ref(app->entry.image); | ||
3510 | 564 | g_object_ref(app->entry.menu); | ||
3511 | 565 | |||
3512 | 566 | gtk_widget_show(GTK_WIDGET(app->entry.image)); | ||
3513 | 567 | |||
3514 | 568 | priv->applications = g_list_insert(priv->applications, app, position); | ||
3515 | 569 | |||
3516 | 570 | g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); | ||
3517 | 571 | return; | ||
3518 | 572 | } | ||
3519 | 573 | |||
3520 | 574 | /* This removes the application from the list and free's all | ||
3521 | 575 | of the memory associated with it. */ | ||
3522 | 576 | static void | ||
3523 | 577 | application_removed (DBusGProxy * proxy, gint position, IndicatorApplication * application) | ||
3524 | 578 | { | ||
3525 | 579 | g_return_if_fail(IS_INDICATOR_APPLICATION(application)); | ||
3526 | 580 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); | ||
3527 | 581 | ApplicationEntry * app = (ApplicationEntry *)g_list_nth_data(priv->applications, position); | ||
3528 | 582 | |||
3529 | 583 | if (app == NULL) { | ||
3530 | 584 | g_warning("Unable to find application at position: %d", position); | ||
3531 | 585 | return; | ||
3532 | 586 | } | ||
3533 | 587 | |||
3534 | 588 | priv->applications = g_list_remove(priv->applications, app); | ||
3535 | 589 | g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); | ||
3536 | 590 | |||
3537 | 591 | if (app->icon_theme_path != NULL) { | ||
3538 | 592 | theme_dir_unref(application, app->icon_theme_path); | ||
3539 | 593 | g_free(app->icon_theme_path); | ||
3540 | 594 | } | ||
3541 | 595 | if (app->dbusaddress != NULL) { | ||
3542 | 596 | g_free(app->dbusaddress); | ||
3543 | 597 | } | ||
3544 | 598 | if (app->dbusobject != NULL) { | ||
3545 | 599 | g_free(app->dbusobject); | ||
3546 | 600 | } | ||
3547 | 601 | if (app->guide != NULL) { | ||
3548 | 602 | g_free(app->guide); | ||
3549 | 603 | } | ||
3550 | 604 | if (app->longname != NULL) { | ||
3551 | 605 | g_free(app->longname); | ||
3552 | 606 | } | ||
3553 | 607 | if (app->entry.image != NULL) { | ||
3554 | 608 | g_object_unref(G_OBJECT(app->entry.image)); | ||
3555 | 609 | } | ||
3556 | 610 | if (app->entry.label != NULL) { | ||
3557 | 611 | g_object_unref(G_OBJECT(app->entry.label)); | ||
3558 | 612 | } | ||
3559 | 613 | if (app->entry.menu != NULL) { | ||
3560 | 614 | g_object_unref(G_OBJECT(app->entry.menu)); | ||
3561 | 615 | } | ||
3562 | 616 | g_free(app); | ||
3563 | 617 | |||
3564 | 618 | return; | ||
3565 | 619 | } | ||
3566 | 620 | |||
3567 | 621 | /* The callback for the signal that the label for an application | ||
3568 | 622 | has changed. */ | ||
3569 | 623 | static void | ||
3570 | 624 | application_label_changed (DBusGProxy * proxy, gint position, const gchar * label, const gchar * guide, IndicatorApplication * application) | ||
3571 | 625 | { | ||
3572 | 626 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); | ||
3573 | 627 | ApplicationEntry * app = (ApplicationEntry *)g_list_nth_data(priv->applications, position); | ||
3574 | 628 | gboolean signal_reload = FALSE; | ||
3575 | 629 | |||
3576 | 630 | if (app == NULL) { | ||
3577 | 631 | g_warning("Unable to find application at position: %d", position); | ||
3578 | 632 | return; | ||
3579 | 633 | } | ||
3580 | 634 | |||
3581 | 635 | if (label == NULL || label[0] == '\0') { | ||
3582 | 636 | /* No label, let's see if we need to delete the old one */ | ||
3583 | 637 | if (app->entry.label != NULL) { | ||
3584 | 638 | g_object_unref(G_OBJECT(app->entry.label)); | ||
3585 | 639 | app->entry.label = NULL; | ||
3586 | 640 | |||
3587 | 641 | signal_reload = TRUE; | ||
3588 | 642 | } | ||
3589 | 643 | } else { | ||
3590 | 644 | /* We've got a label, is this just an update or is | ||
3591 | 645 | it a new thing. */ | ||
3592 | 646 | if (app->entry.label != NULL) { | ||
3593 | 647 | gtk_label_set_text(app->entry.label, label); | ||
3594 | 648 | } else { | ||
3595 | 649 | app->entry.label = GTK_LABEL(gtk_label_new(label)); | ||
3596 | 650 | g_object_ref(G_OBJECT(app->entry.label)); | ||
3597 | 651 | gtk_widget_show(GTK_WIDGET(app->entry.label)); | ||
3598 | 652 | |||
3599 | 653 | signal_reload = TRUE; | ||
3600 | 654 | } | ||
3601 | 655 | } | ||
3602 | 656 | |||
3603 | 657 | /* Copy the guide if we have one */ | ||
3604 | 658 | if (app->guide != NULL) { | ||
3605 | 659 | g_free(app->guide); | ||
3606 | 660 | app->guide = NULL; | ||
3607 | 661 | } | ||
3608 | 662 | |||
3609 | 663 | if (guide != NULL && guide[0] != '\0') { | ||
3610 | 664 | app->guide = g_strdup(guide); | ||
3611 | 665 | } | ||
3612 | 666 | |||
3613 | 667 | /* Protected against not having a label */ | ||
3614 | 668 | guess_label_size(app); | ||
3615 | 669 | |||
3616 | 670 | if (signal_reload) { | ||
3617 | 671 | /* Telling the listener that this has been removed, and then | ||
3618 | 672 | readded to make it reparse the entry. */ | ||
3619 | 673 | if (app->entry.label != NULL) { | ||
3620 | 674 | gtk_widget_hide(GTK_WIDGET(app->entry.label)); | ||
3621 | 675 | } | ||
3622 | 676 | |||
3623 | 677 | if (app->entry.image != NULL) { | ||
3624 | 678 | gtk_widget_hide(GTK_WIDGET(app->entry.image)); | ||
3625 | 679 | } | ||
3626 | 680 | |||
3627 | 681 | if (app->entry.menu != NULL) { | ||
3628 | 682 | gtk_menu_detach(app->entry.menu); | ||
3629 | 683 | } | ||
3630 | 684 | |||
3631 | 685 | g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); | ||
3632 | 686 | |||
3633 | 687 | if (app->entry.label != NULL) { | ||
3634 | 688 | gtk_widget_show(GTK_WIDGET(app->entry.label)); | ||
3635 | 689 | } | ||
3636 | 690 | |||
3637 | 691 | if (app->entry.image != NULL) { | ||
3638 | 692 | indicator_image_helper_update(app->entry.image, app->longname); | ||
3639 | 693 | gtk_widget_show(GTK_WIDGET(app->entry.image)); | ||
3640 | 694 | } | ||
3641 | 695 | |||
3642 | 696 | g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); | ||
3643 | 697 | } | ||
3644 | 698 | |||
3645 | 699 | return; | ||
3646 | 700 | } | ||
3647 | 701 | |||
3648 | 702 | /* The callback for the signal that the icon for an application | ||
3649 | 703 | has changed. */ | ||
3650 | 704 | static void | ||
3651 | 705 | application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconname, IndicatorApplication * application) | ||
3652 | 706 | { | ||
3653 | 707 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); | ||
3654 | 708 | ApplicationEntry * app = (ApplicationEntry *)g_list_nth_data(priv->applications, position); | ||
3655 | 709 | |||
3656 | 710 | if (app == NULL) { | ||
3657 | 711 | g_warning("Unable to find application at position: %d", position); | ||
3658 | 712 | return; | ||
3659 | 713 | } | ||
3660 | 714 | |||
3661 | 715 | /* We make a long name using the suffix, and if that | ||
3662 | 716 | icon is available we want to use it. Otherwise we'll | ||
3663 | 717 | just use the name we were given. */ | ||
3664 | 718 | if (app->longname != NULL) { | ||
3665 | 719 | g_free(app->longname); | ||
3666 | 720 | app->longname = NULL; | ||
3667 | 721 | } | ||
3668 | 722 | if (!g_str_has_suffix(iconname, PANEL_ICON_SUFFIX)) { | ||
3669 | 723 | app->longname = g_strdup_printf("%s-%s", iconname, PANEL_ICON_SUFFIX); | ||
3670 | 724 | } else { | ||
3671 | 725 | app->longname = g_strdup(iconname); | ||
3672 | 726 | } | ||
3673 | 727 | indicator_image_helper_update(app->entry.image, app->longname); | ||
3674 | 728 | |||
3675 | 729 | return; | ||
3676 | 730 | } | ||
3677 | 731 | |||
3678 | 732 | /* The callback for the signal that the icon theme path for an application | ||
3679 | 733 | has changed. */ | ||
3680 | 734 | static void | ||
3681 | 735 | application_icon_theme_path_changed (DBusGProxy * proxy, gint position, const gchar * icon_theme_path, IndicatorApplication * application) | ||
3682 | 736 | { | ||
3683 | 737 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); | ||
3684 | 738 | ApplicationEntry * app = (ApplicationEntry *)g_list_nth_data(priv->applications, position); | ||
3685 | 739 | |||
3686 | 740 | if (app == NULL) { | ||
3687 | 741 | g_warning("Unable to find application at position: %d", position); | ||
3688 | 742 | return; | ||
3689 | 743 | } | ||
3690 | 744 | |||
3691 | 745 | if (g_strcmp0(icon_theme_path, app->icon_theme_path) != 0) { | ||
3692 | 746 | if(app->icon_theme_path != NULL) { | ||
3693 | 747 | theme_dir_unref(application, app->icon_theme_path); | ||
3694 | 748 | g_free(app->icon_theme_path); | ||
3695 | 749 | app->icon_theme_path = NULL; | ||
3696 | 750 | } | ||
3697 | 751 | if (icon_theme_path != NULL && icon_theme_path[0] != '\0') { | ||
3698 | 752 | app->icon_theme_path = g_strdup(icon_theme_path); | ||
3699 | 753 | theme_dir_ref(application, app->icon_theme_path); | ||
3700 | 754 | } | ||
3701 | 755 | indicator_image_helper_update(app->entry.image, app->longname); | ||
3702 | 756 | } | ||
3703 | 757 | |||
3704 | 758 | return; | ||
3705 | 759 | } | ||
3706 | 760 | |||
3707 | 761 | /* This repsonds to the list of applications that the service | ||
3708 | 762 | has and calls application_added on each one of them. */ | ||
3709 | 763 | static void | ||
3710 | 764 | get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, gpointer userdata) | ||
3711 | 765 | { | ||
3712 | 766 | if (error != NULL) { | ||
3713 | 767 | g_warning("Unable to get application list: %s", error->message); | ||
3714 | 768 | return; | ||
3715 | 769 | } | ||
3716 | 770 | g_ptr_array_foreach(OUT_applications, get_applications_helper, userdata); | ||
3717 | 771 | |||
3718 | 772 | return; | ||
3719 | 773 | } | ||
3720 | 774 | |||
3721 | 775 | /* A little helper that takes apart the DBus structure and calls | ||
3722 | 776 | application_added on every entry in the list. */ | ||
3723 | 777 | static void | ||
3724 | 778 | get_applications_helper (gpointer data, gpointer user_data) | ||
3725 | 779 | { | ||
3726 | 780 | GValueArray * array = (GValueArray *)data; | ||
3727 | 781 | |||
3728 | 782 | g_return_if_fail(array->n_values == 7); | ||
3729 | 783 | |||
3730 | 784 | const gchar * icon_name = g_value_get_string(g_value_array_get_nth(array, 0)); | ||
3731 | 785 | gint position = g_value_get_int(g_value_array_get_nth(array, 1)); | ||
3732 | 786 | const gchar * dbus_address = g_value_get_string(g_value_array_get_nth(array, 2)); | ||
3733 | 787 | const gchar * dbus_object = g_value_get_boxed(g_value_array_get_nth(array, 3)); | ||
3734 | 788 | const gchar * icon_theme_path = g_value_get_string(g_value_array_get_nth(array, 4)); | ||
3735 | 789 | const gchar * label = g_value_get_string(g_value_array_get_nth(array, 5)); | ||
3736 | 790 | const gchar * guide = g_value_get_string(g_value_array_get_nth(array, 6)); | ||
3737 | 791 | |||
3738 | 792 | return application_added(NULL, icon_name, position, dbus_address, dbus_object, icon_theme_path, label, guide, user_data); | ||
3739 | 793 | } | ||
3740 | 794 | |||
3741 | 795 | /* Unrefs a theme directory. This may involve removing it from | ||
3742 | 796 | the search path. */ | ||
3743 | 797 | static void | ||
3744 | 798 | theme_dir_unref(IndicatorApplication * ia, const gchar * dir) | ||
3745 | 799 | { | ||
3746 | 800 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(ia); | ||
3747 | 801 | |||
3748 | 802 | /* Grab the count for this dir */ | ||
3749 | 803 | int count = GPOINTER_TO_INT(g_hash_table_lookup(priv->theme_dirs, dir)); | ||
3750 | 804 | |||
3751 | 805 | /* Is this a simple deprecation, if so, we can just lower the | ||
3752 | 806 | number and move on. */ | ||
3753 | 807 | if (count > 1) { | ||
3754 | 808 | count--; | ||
3755 | 809 | g_hash_table_insert(priv->theme_dirs, g_strdup(dir), GINT_TO_POINTER(count)); | ||
3756 | 810 | return; | ||
3757 | 811 | } | ||
3758 | 812 | |||
3759 | 813 | /* Try to remove it from the hash table, this makes sure | ||
3760 | 814 | that it existed */ | ||
3761 | 815 | if (!g_hash_table_remove(priv->theme_dirs, dir)) { | ||
3762 | 816 | g_warning("Unref'd a directory that wasn't in the theme dir hash table."); | ||
3763 | 817 | return; | ||
3764 | 818 | } | ||
3765 | 819 | |||
3766 | 820 | GtkIconTheme * icon_theme = gtk_icon_theme_get_default(); | ||
3767 | 821 | gchar ** paths; | ||
3768 | 822 | gint path_count; | ||
3769 | 823 | |||
3770 | 824 | gtk_icon_theme_get_search_path(icon_theme, &paths, &path_count); | ||
3771 | 825 | |||
3772 | 826 | gint i; | ||
3773 | 827 | gboolean found = FALSE; | ||
3774 | 828 | for (i = 0; i < path_count; i++) { | ||
3775 | 829 | if (found) { | ||
3776 | 830 | /* If we've already found the right entry */ | ||
3777 | 831 | paths[i - 1] = paths[i]; | ||
3778 | 832 | } else { | ||
3779 | 833 | /* We're still looking, is this the one? */ | ||
3780 | 834 | if (!g_strcmp0(paths[i], dir)) { | ||
3781 | 835 | found = TRUE; | ||
3782 | 836 | /* We're freeing this here as it won't be captured by the | ||
3783 | 837 | g_strfreev() below as it's out of the array. */ | ||
3784 | 838 | g_free(paths[i]); | ||
3785 | 839 | } | ||
3786 | 840 | } | ||
3787 | 841 | } | ||
3788 | 842 | |||
3789 | 843 | /* If we found one we need to reset the path to | ||
3790 | 844 | accomidate the changes */ | ||
3791 | 845 | if (found) { | ||
3792 | 846 | paths[path_count - 1] = NULL; /* Clear the last one */ | ||
3793 | 847 | gtk_icon_theme_set_search_path(icon_theme, (const gchar **)paths, path_count - 1); | ||
3794 | 848 | } | ||
3795 | 849 | |||
3796 | 850 | g_strfreev(paths); | ||
3797 | 851 | |||
3798 | 852 | return; | ||
3799 | 853 | } | ||
3800 | 854 | |||
3801 | 855 | /* Refs a theme directory, and it may add it to the search | ||
3802 | 856 | path */ | ||
3803 | 857 | static void | ||
3804 | 858 | theme_dir_ref(IndicatorApplication * ia, const gchar * dir) | ||
3805 | 859 | { | ||
3806 | 860 | IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(ia); | ||
3807 | 861 | |||
3808 | 862 | int count = 0; | ||
3809 | 863 | if ((count = GPOINTER_TO_INT(g_hash_table_lookup(priv->theme_dirs, dir))) != 0) { | ||
3810 | 864 | /* It exists so what we need to do is increase the ref | ||
3811 | 865 | count of this dir. */ | ||
3812 | 866 | count++; | ||
3813 | 867 | } else { | ||
3814 | 868 | /* It doesn't exist, so we need to add it to the table | ||
3815 | 869 | and to the search path. */ | ||
3816 | 870 | gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), dir); | ||
3817 | 871 | g_debug("\tAppending search path: %s", dir); | ||
3818 | 872 | count = 1; | ||
3819 | 873 | } | ||
3820 | 874 | |||
3821 | 875 | g_hash_table_insert(priv->theme_dirs, g_strdup(dir), GINT_TO_POINTER(count)); | ||
3822 | 876 | |||
3823 | 877 | return; | ||
3824 | 878 | } | ||
3825 | 879 | |||
3826 | 880 | 0 | ||
3827 | === removed file 'src/notification-approver.xml' | |||
3828 | --- src/notification-approver.xml 2010-08-18 15:31:20 +0000 | |||
3829 | +++ src/notification-approver.xml 1970-01-01 00:00:00 +0000 | |||
3830 | @@ -1,29 +0,0 @@ | |||
3831 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
3832 | 2 | <node name="/"> | ||
3833 | 3 | <interface name="org.ayatana.StatusNotifierApprover"> | ||
3834 | 4 | |||
3835 | 5 | <!-- Methods --> | ||
3836 | 6 | <method name="ApproveItem"> | ||
3837 | 7 | <!-- KSNI ID --> | ||
3838 | 8 | <arg type="s" name="id" direction="in" /> | ||
3839 | 9 | <!-- KSNI Category --> | ||
3840 | 10 | <arg type="s" name="category" direction="in" /> | ||
3841 | 11 | <!-- Application PID --> | ||
3842 | 12 | <arg type="u" name="pid" direction="in" /> | ||
3843 | 13 | <!-- Application DBus Address --> | ||
3844 | 14 | <arg type="s" name="address" direction="in" /> | ||
3845 | 15 | <!-- Application DBus Path for KSNI interface --> | ||
3846 | 16 | <arg type="o" name="path" direction="in" /> | ||
3847 | 17 | <!-- So, what do you think? --> | ||
3848 | 18 | <arg type="b" name="approved" direction="out" /> | ||
3849 | 19 | </method> | ||
3850 | 20 | |||
3851 | 21 | <!-- Signals --> | ||
3852 | 22 | <signal name="ReviseJudgement"> | ||
3853 | 23 | <arg type="b" name="approved" direction="out" /> | ||
3854 | 24 | <arg type="s" name="address" direction="out" /> | ||
3855 | 25 | <arg type="o" name="path" direction="out" /> | ||
3856 | 26 | </signal> | ||
3857 | 27 | |||
3858 | 28 | </interface> | ||
3859 | 29 | </node> | ||
3860 | 30 | 0 | ||
3861 | === modified file 'tests/Makefile.am' | |||
3862 | --- tests/Makefile.am 2010-11-08 16:49:47 +0000 | |||
3863 | +++ tests/Makefile.am 2010-12-06 15:12:11 +0000 | |||
3864 | @@ -1,6 +1,5 @@ | |||
3865 | 1 | 1 | ||
3866 | 2 | check_PROGRAMS = \ | 2 | check_PROGRAMS = \ |
3867 | 3 | test-approver \ | ||
3868 | 4 | test-libappindicator \ | 3 | test-libappindicator \ |
3869 | 5 | test-libappindicator-dbus-client \ | 4 | test-libappindicator-dbus-client \ |
3870 | 6 | test-libappindicator-dbus-server \ | 5 | test-libappindicator-dbus-server \ |
3871 | @@ -25,13 +24,13 @@ | |||
3872 | 25 | test-libappindicator.c | 24 | test-libappindicator.c |
3873 | 26 | 25 | ||
3874 | 27 | test_libappindicator_CFLAGS = \ | 26 | test_libappindicator_CFLAGS = \ |
3876 | 28 | $(INDICATOR_CFLAGS) \ | 27 | $(LIBRARY_CFLAGS) \ |
3877 | 29 | -DSRCDIR="\"$(srcdir)\"" \ | 28 | -DSRCDIR="\"$(srcdir)\"" \ |
3878 | 30 | -Wall -Werror \ | 29 | -Wall -Werror \ |
3879 | 31 | -I$(top_srcdir)/src | 30 | -I$(top_srcdir)/src |
3880 | 32 | 31 | ||
3881 | 33 | test_libappindicator_LDADD = \ | 32 | test_libappindicator_LDADD = \ |
3883 | 34 | $(INDICATOR_LIBS) \ | 33 | $(LIBRARY_LIBS) \ |
3884 | 35 | $(top_builddir)/src/libappindicator.la | 34 | $(top_builddir)/src/libappindicator.la |
3885 | 36 | 35 | ||
3886 | 37 | ######################################### | 36 | ######################################### |
3887 | @@ -43,12 +42,12 @@ | |||
3888 | 43 | test-libappindicator-dbus-client.c | 42 | test-libappindicator-dbus-client.c |
3889 | 44 | 43 | ||
3890 | 45 | test_libappindicator_dbus_client_CFLAGS = \ | 44 | test_libappindicator_dbus_client_CFLAGS = \ |
3892 | 46 | $(INDICATOR_CFLAGS) \ | 45 | $(LIBRARY_CFLAGS) \ |
3893 | 47 | -Wall -Werror \ | 46 | -Wall -Werror \ |
3894 | 48 | -I$(top_srcdir)/src | 47 | -I$(top_srcdir)/src |
3895 | 49 | 48 | ||
3896 | 50 | test_libappindicator_dbus_client_LDADD = \ | 49 | test_libappindicator_dbus_client_LDADD = \ |
3898 | 51 | $(INDICATOR_LIBS) \ | 50 | $(LIBRARY_LIBS) \ |
3899 | 52 | $(top_builddir)/src/libappindicator.la | 51 | $(top_builddir)/src/libappindicator.la |
3900 | 53 | 52 | ||
3901 | 54 | ######################################### | 53 | ######################################### |
3902 | @@ -60,12 +59,12 @@ | |||
3903 | 60 | test-libappindicator-dbus-server.c | 59 | test-libappindicator-dbus-server.c |
3904 | 61 | 60 | ||
3905 | 62 | test_libappindicator_dbus_server_CFLAGS = \ | 61 | test_libappindicator_dbus_server_CFLAGS = \ |
3907 | 63 | $(INDICATOR_CFLAGS) \ | 62 | $(LIBRARY_CFLAGS) \ |
3908 | 64 | -Wall -Werror \ | 63 | -Wall -Werror \ |
3909 | 65 | -I$(top_srcdir)/src | 64 | -I$(top_srcdir)/src |
3910 | 66 | 65 | ||
3911 | 67 | test_libappindicator_dbus_server_LDADD = \ | 66 | test_libappindicator_dbus_server_LDADD = \ |
3913 | 68 | $(INDICATOR_LIBS) \ | 67 | $(LIBRARY_LIBS) \ |
3914 | 69 | $(top_builddir)/src/libappindicator.la | 68 | $(top_builddir)/src/libappindicator.la |
3915 | 70 | 69 | ||
3916 | 71 | ######################################### | 70 | ######################################### |
3917 | @@ -77,12 +76,12 @@ | |||
3918 | 77 | test-libappindicator-status-client.c | 76 | test-libappindicator-status-client.c |
3919 | 78 | 77 | ||
3920 | 79 | test_libappindicator_status_client_CFLAGS = \ | 78 | test_libappindicator_status_client_CFLAGS = \ |
3922 | 80 | $(INDICATOR_CFLAGS) \ | 79 | $(LIBRARY_CFLAGS) \ |
3923 | 81 | -Wall -Werror \ | 80 | -Wall -Werror \ |
3924 | 82 | -I$(top_srcdir)/src | 81 | -I$(top_srcdir)/src |
3925 | 83 | 82 | ||
3926 | 84 | test_libappindicator_status_client_LDADD = \ | 83 | test_libappindicator_status_client_LDADD = \ |
3928 | 85 | $(INDICATOR_LIBS) \ | 84 | $(LIBRARY_LIBS) \ |
3929 | 86 | $(top_builddir)/src/libappindicator.la | 85 | $(top_builddir)/src/libappindicator.la |
3930 | 87 | 86 | ||
3931 | 88 | ######################################### | 87 | ######################################### |
3932 | @@ -94,40 +93,13 @@ | |||
3933 | 94 | test-libappindicator-status-server.c | 93 | test-libappindicator-status-server.c |
3934 | 95 | 94 | ||
3935 | 96 | test_libappindicator_status_server_CFLAGS = \ | 95 | test_libappindicator_status_server_CFLAGS = \ |
3937 | 97 | $(INDICATOR_CFLAGS) \ | 96 | $(LIBRARY_CFLAGS) \ |
3938 | 98 | -Wall -Werror \ | 97 | -Wall -Werror \ |
3939 | 99 | -I$(top_srcdir)/src | 98 | -I$(top_srcdir)/src |
3940 | 100 | 99 | ||
3941 | 101 | test_libappindicator_status_server_LDADD = \ | 100 | test_libappindicator_status_server_LDADD = \ |
3971 | 102 | $(INDICATOR_LIBS) \ | 101 | $(LIBRARY_LIBS) \ |
3972 | 103 | $(top_builddir)/src/libappindicator.la | 102 | $(top_builddir)/src/libappindicator.la |
3944 | 104 | |||
3945 | 105 | ######################################### | ||
3946 | 106 | ## test-approver | ||
3947 | 107 | ######################################### | ||
3948 | 108 | |||
3949 | 109 | test_approver_SOURCES = \ | ||
3950 | 110 | test-approver.c | ||
3951 | 111 | |||
3952 | 112 | test_approver_CFLAGS = \ | ||
3953 | 113 | $(INDICATOR_CFLAGS) \ | ||
3954 | 114 | -Wall -Werror \ | ||
3955 | 115 | -I$(top_srcdir)/src \ | ||
3956 | 116 | -I$(top_builddir)/src | ||
3957 | 117 | |||
3958 | 118 | test_approver_LDADD = \ | ||
3959 | 119 | $(INDICATOR_LIBS) \ | ||
3960 | 120 | $(top_builddir)/src/libappindicator.la | ||
3961 | 121 | |||
3962 | 122 | test-approver-tester: test-approver Makefile.am | ||
3963 | 123 | @echo "#!/bin/bash" > $@ | ||
3964 | 124 | @echo export INDICATOR_SERVICE_SHUTDOWN_TIMEOUT=1000 >> $@ | ||
3965 | 125 | @echo . $(srcdir)/run-xvfb.sh >> $@ | ||
3966 | 126 | @echo $(DBUS_RUNNER) --task $(builddir)/test-approver --task-name Approver --task $(top_builddir)/src/indicator-application-service --task-name Service --ignore-return >> $@ | ||
3967 | 127 | @chmod +x $@ | ||
3968 | 128 | |||
3969 | 129 | TESTS += test-approver-tester | ||
3970 | 130 | |||
3973 | 131 | 103 | ||
3974 | 132 | ######################################### | 104 | ######################################### |
3975 | 133 | ## test-libappindicator-fallback | 105 | ## test-libappindicator-fallback |
3976 | @@ -137,24 +109,24 @@ | |||
3977 | 137 | test-libappindicator-fallback-watcher.c | 109 | test-libappindicator-fallback-watcher.c |
3978 | 138 | 110 | ||
3979 | 139 | test_libappindicator_fallback_watcher_CFLAGS = \ | 111 | test_libappindicator_fallback_watcher_CFLAGS = \ |
3981 | 140 | $(INDICATOR_CFLAGS) \ | 112 | $(LIBRARY_CFLAGS) \ |
3982 | 141 | -Wall -Werror \ | 113 | -Wall -Werror \ |
3983 | 142 | -I$(top_srcdir)/src | 114 | -I$(top_srcdir)/src |
3984 | 143 | 115 | ||
3985 | 144 | test_libappindicator_fallback_watcher_LDADD = \ | 116 | test_libappindicator_fallback_watcher_LDADD = \ |
3987 | 145 | $(INDICATOR_LIBS) \ | 117 | $(LIBRARY_LIBS) \ |
3988 | 146 | $(top_builddir)/src/libappindicator.la | 118 | $(top_builddir)/src/libappindicator.la |
3989 | 147 | 119 | ||
3990 | 148 | test_libappindicator_fallback_item_SOURCES = \ | 120 | test_libappindicator_fallback_item_SOURCES = \ |
3991 | 149 | test-libappindicator-fallback-item.c | 121 | test-libappindicator-fallback-item.c |
3992 | 150 | 122 | ||
3993 | 151 | test_libappindicator_fallback_item_CFLAGS = \ | 123 | test_libappindicator_fallback_item_CFLAGS = \ |
3995 | 152 | $(INDICATOR_CFLAGS) \ | 124 | $(LIBRARY_CFLAGS) \ |
3996 | 153 | -Wall -Werror \ | 125 | -Wall -Werror \ |
3997 | 154 | -I$(top_srcdir)/src | 126 | -I$(top_srcdir)/src |
3998 | 155 | 127 | ||
3999 | 156 | test_libappindicator_fallback_item_LDADD = \ | 128 | test_libappindicator_fallback_item_LDADD = \ |
4001 | 157 | $(INDICATOR_LIBS) \ | 129 | $(LIBRARY_LIBS) \ |
4002 | 158 | $(top_builddir)/src/libappindicator.la | 130 | $(top_builddir)/src/libappindicator.la |
4003 | 159 | 131 | ||
4004 | 160 | test-libappindicator-fallback: test-libappindicator-fallback-watcher test-libappindicator-fallback-item Makefile.am | 132 | test-libappindicator-fallback: test-libappindicator-fallback-watcher test-libappindicator-fallback-item Makefile.am |
4005 | @@ -213,11 +185,11 @@ | |||
4006 | 213 | test-simple-app.c | 185 | test-simple-app.c |
4007 | 214 | 186 | ||
4008 | 215 | test_simple_app_CFLAGS = \ | 187 | test_simple_app_CFLAGS = \ |
4010 | 216 | $(INDICATOR_CFLAGS) \ | 188 | $(LIBRARY_CFLAGS) \ |
4011 | 217 | -Wall -Werror \ | 189 | -Wall -Werror \ |
4012 | 218 | -I$(top_srcdir)/src | 190 | -I$(top_srcdir)/src |
4013 | 219 | 191 | ||
4014 | 220 | test_simple_app_LDADD = \ | 192 | test_simple_app_LDADD = \ |
4016 | 221 | $(INDICATOR_LIBS) \ | 193 | $(LIBRARY_LIBS) \ |
4017 | 222 | $(top_builddir)/src/libappindicator.la | 194 | $(top_builddir)/src/libappindicator.la |
4018 | 223 | 195 | ||
4019 | 224 | 196 | ||
4020 | === removed file 'tests/test-approver.c' | |||
4021 | --- tests/test-approver.c 2010-08-19 18:56:42 +0000 | |||
4022 | +++ tests/test-approver.c 1970-01-01 00:00:00 +0000 | |||
4023 | @@ -1,179 +0,0 @@ | |||
4024 | 1 | #include <glib.h> | ||
4025 | 2 | #include <glib-object.h> | ||
4026 | 3 | |||
4027 | 4 | #include <dbus/dbus-glib-bindings.h> | ||
4028 | 5 | |||
4029 | 6 | #include "notification-watcher-client.h" | ||
4030 | 7 | #include "dbus-shared.h" | ||
4031 | 8 | #include "app-indicator.h" | ||
4032 | 9 | |||
4033 | 10 | #define APPROVER_PATH "/my/approver" | ||
4034 | 11 | |||
4035 | 12 | #define INDICATOR_ID "test-indicator-id" | ||
4036 | 13 | #define INDICATOR_ICON "test-indicator-icon-name" | ||
4037 | 14 | #define INDICATOR_CATEGORY APP_INDICATOR_CATEGORY_APPLICATION_STATUS | ||
4038 | 15 | |||
4039 | 16 | #define TEST_APPROVER_TYPE (test_approver_get_type ()) | ||
4040 | 17 | #define TEST_APPROVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_APPROVER_TYPE, TestApprover)) | ||
4041 | 18 | #define TEST_APPROVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_APPROVER_TYPE, TestApproverClass)) | ||
4042 | 19 | #define IS_TEST_APPROVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_APPROVER_TYPE)) | ||
4043 | 20 | #define IS_TEST_APPROVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_APPROVER_TYPE)) | ||
4044 | 21 | #define TEST_APPROVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_APPROVER_TYPE, TestApproverClass)) | ||
4045 | 22 | |||
4046 | 23 | typedef struct _TestApprover TestApprover; | ||
4047 | 24 | typedef struct _TestApproverClass TestApproverClass; | ||
4048 | 25 | |||
4049 | 26 | struct _TestApproverClass { | ||
4050 | 27 | GObjectClass parent_class; | ||
4051 | 28 | }; | ||
4052 | 29 | |||
4053 | 30 | struct _TestApprover { | ||
4054 | 31 | GObject parent; | ||
4055 | 32 | }; | ||
4056 | 33 | |||
4057 | 34 | GType test_approver_get_type (void); | ||
4058 | 35 | |||
4059 | 36 | static void test_approver_class_init (TestApproverClass *klass); | ||
4060 | 37 | static void test_approver_init (TestApprover *self); | ||
4061 | 38 | static gboolean _notification_approver_server_approve_item (TestApprover * ta, const gchar * id, const gchar * category, guint pid, const gchar * address, const gchar * path, gboolean * approved, GError ** error); | ||
4062 | 39 | |||
4063 | 40 | #include "../src/notification-approver-server.h" | ||
4064 | 41 | |||
4065 | 42 | GMainLoop * main_loop = NULL; | ||
4066 | 43 | DBusGConnection * session_bus = NULL; | ||
4067 | 44 | DBusGProxy * bus_proxy = NULL; | ||
4068 | 45 | AppIndicator * app_indicator = NULL; | ||
4069 | 46 | gboolean passed = FALSE; | ||
4070 | 47 | |||
4071 | 48 | G_DEFINE_TYPE (TestApprover, test_approver, G_TYPE_OBJECT); | ||
4072 | 49 | |||
4073 | 50 | static void | ||
4074 | 51 | test_approver_class_init (TestApproverClass *klass) | ||
4075 | 52 | { | ||
4076 | 53 | dbus_g_object_type_install_info(TEST_APPROVER_TYPE, | ||
4077 | 54 | &dbus_glib__notification_approver_server_object_info); | ||
4078 | 55 | |||
4079 | 56 | return; | ||
4080 | 57 | } | ||
4081 | 58 | |||
4082 | 59 | static void | ||
4083 | 60 | test_approver_init (TestApprover *self) | ||
4084 | 61 | { | ||
4085 | 62 | dbus_g_connection_register_g_object(session_bus, | ||
4086 | 63 | APPROVER_PATH, | ||
4087 | 64 | G_OBJECT(self)); | ||
4088 | 65 | |||
4089 | 66 | return; | ||
4090 | 67 | } | ||
4091 | 68 | |||
4092 | 69 | static gboolean | ||
4093 | 70 | _notification_approver_server_approve_item (TestApprover * ta, const gchar * id, const gchar * category, guint pid, const gchar * address, const gchar * path, gboolean * approved, GError ** error) | ||
4094 | 71 | { | ||
4095 | 72 | *approved = TRUE; | ||
4096 | 73 | g_debug("Asked to approve indicator"); | ||
4097 | 74 | |||
4098 | 75 | if (g_strcmp0(id, INDICATOR_ID) == 0) { | ||
4099 | 76 | passed = TRUE; | ||
4100 | 77 | } | ||
4101 | 78 | |||
4102 | 79 | g_main_loop_quit(main_loop); | ||
4103 | 80 | |||
4104 | 81 | return TRUE; | ||
4105 | 82 | } | ||
4106 | 83 | |||
4107 | 84 | static void | ||
4108 | 85 | register_cb (DBusGProxy * proxy, GError * error, gpointer user_data) | ||
4109 | 86 | { | ||
4110 | 87 | if (error != NULL) { | ||
4111 | 88 | g_warning("Unable to register approver: %s", error->message); | ||
4112 | 89 | g_error_free(error); | ||
4113 | 90 | g_main_loop_quit(main_loop); | ||
4114 | 91 | return; | ||
4115 | 92 | } | ||
4116 | 93 | |||
4117 | 94 | g_debug("Building App Indicator"); | ||
4118 | 95 | app_indicator = app_indicator_new(INDICATOR_ID, INDICATOR_ICON, INDICATOR_CATEGORY); | ||
4119 | 96 | |||
4120 | 97 | GtkWidget * menu = gtk_menu_new(); | ||
4121 | 98 | GtkWidget * mi = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL); | ||
4122 | 99 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi); | ||
4123 | 100 | |||
4124 | 101 | app_indicator_set_menu(app_indicator, GTK_MENU(menu)); | ||
4125 | 102 | |||
4126 | 103 | return; | ||
4127 | 104 | } | ||
4128 | 105 | |||
4129 | 106 | gint owner_count = 0; | ||
4130 | 107 | gboolean | ||
4131 | 108 | check_for_service (gpointer user_data) | ||
4132 | 109 | { | ||
4133 | 110 | g_debug("Checking for Watcher"); | ||
4134 | 111 | |||
4135 | 112 | if (owner_count > 100) { | ||
4136 | 113 | g_warning("Couldn't find watcher after 100 tries."); | ||
4137 | 114 | g_main_loop_quit(main_loop); | ||
4138 | 115 | return FALSE; | ||
4139 | 116 | } | ||
4140 | 117 | |||
4141 | 118 | owner_count++; | ||
4142 | 119 | |||
4143 | 120 | gboolean has_owner = FALSE; | ||
4144 | 121 | org_freedesktop_DBus_name_has_owner(bus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, &has_owner, NULL); | ||
4145 | 122 | |||
4146 | 123 | if (has_owner) { | ||
4147 | 124 | const char * cats = NULL; | ||
4148 | 125 | DBusGProxy * proxy = dbus_g_proxy_new_for_name(session_bus, | ||
4149 | 126 | NOTIFICATION_WATCHER_DBUS_ADDR, | ||
4150 | 127 | NOTIFICATION_WATCHER_DBUS_OBJ, | ||
4151 | 128 | NOTIFICATION_WATCHER_DBUS_IFACE); | ||
4152 | 129 | |||
4153 | 130 | g_debug("Registering Approver"); | ||
4154 | 131 | org_kde_StatusNotifierWatcher_x_ayatana_register_notification_approver_async (proxy, APPROVER_PATH, &cats, register_cb, NULL); | ||
4155 | 132 | |||
4156 | 133 | return FALSE; | ||
4157 | 134 | } | ||
4158 | 135 | |||
4159 | 136 | return TRUE; | ||
4160 | 137 | } | ||
4161 | 138 | |||
4162 | 139 | gboolean | ||
4163 | 140 | fail_timeout (gpointer user_data) | ||
4164 | 141 | { | ||
4165 | 142 | g_debug("Failure timeout initiated."); | ||
4166 | 143 | g_main_loop_quit(main_loop); | ||
4167 | 144 | return FALSE; | ||
4168 | 145 | } | ||
4169 | 146 | |||
4170 | 147 | int | ||
4171 | 148 | main (int argc, char ** argv) | ||
4172 | 149 | { | ||
4173 | 150 | GError * error = NULL; | ||
4174 | 151 | |||
4175 | 152 | gtk_init(&argc, &argv); | ||
4176 | 153 | g_debug("Initing"); | ||
4177 | 154 | |||
4178 | 155 | session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); | ||
4179 | 156 | if (error != NULL) { | ||
4180 | 157 | g_warning("Unable to get session bus: %s", error->message); | ||
4181 | 158 | g_error_free(error); | ||
4182 | 159 | return -1; | ||
4183 | 160 | } | ||
4184 | 161 | |||
4185 | 162 | TestApprover * approver = g_object_new(TEST_APPROVER_TYPE, NULL); | ||
4186 | 163 | |||
4187 | 164 | bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); | ||
4188 | 165 | |||
4189 | 166 | g_timeout_add(100, check_for_service, NULL); | ||
4190 | 167 | g_timeout_add_seconds(2, fail_timeout, NULL); | ||
4191 | 168 | |||
4192 | 169 | main_loop = g_main_loop_new(NULL, FALSE); | ||
4193 | 170 | g_main_loop_run(main_loop); | ||
4194 | 171 | |||
4195 | 172 | g_object_unref(approver); | ||
4196 | 173 | |||
4197 | 174 | if (!passed) { | ||
4198 | 175 | return -1; | ||
4199 | 176 | } | ||
4200 | 177 | |||
4201 | 178 | return 0; | ||
4202 | 179 | } |