Merge lp:~ted/libappindicator/remove-service into lp:libappindicator

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
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+42561@code.launchpad.net

Description of the change

Remove the service from the repo so that it's lib only.

To post a comment you must log in.
179. By Ted Gould

Updating to trunk so that we get the GI fixes

180. By Ted Gould

Updating to trunk with GTK3 support.

181. By Ted Gould

Merging from trunk with the desktop convience function.

182. By Ted Gould

No indicator directory without the service

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

Subscribers

People subscribed via source and target branches