summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2013-03-28 02:30:25 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2013-03-28 02:30:25 +0200
commit184297bdf04b278f6e1dcba1ebd9d917d9607a75 (patch)
treeb71767c513f025a31bc2ede2888ee94684ff2735
Initial commit
-rw-r--r--AUTHORS6
-rw-r--r--Apathy.Approver.client4
-rw-r--r--Apathy.Handler.client10
-rw-r--r--COPYING674
-rw-r--r--TODO15
-rw-r--r--apathy.pngbin0 -> 296879 bytes
-rw-r--r--apathy/AccountEditor.py512
-rw-r--r--apathy/Accounts.py267
-rw-r--r--apathy/Apathy.py84
-rw-r--r--apathy/Approver.py178
-rw-r--r--apathy/Call.py45
-rw-r--r--apathy/ContactInfo.py117
-rw-r--r--apathy/Contacts.py476
-rw-r--r--apathy/Conversation.py300
-rw-r--r--apathy/ErrorDialog.py58
-rw-r--r--apathy/FileTransfer.py34
-rw-r--r--apathy/Globals.py75
-rw-r--r--apathy/Handler.py205
-rw-r--r--apathy/NewAccount.py39
-rw-r--r--apathy/NewContact.py113
-rw-r--r--apathy/Parser.py134
-rw-r--r--apathy/PresenceEditor.py85
-rw-r--r--apathy/PresenceWidget.py159
-rw-r--r--apathy/__init__.py0
-rwxr-xr-xbin/apathy-accounts38
-rwxr-xr-xbin/apathy-approver38
-rwxr-xr-xbin/apathy-contacts38
-rwxr-xr-xbin/apathy-handler38
-rw-r--r--data/apathy-accounts.desktop.in9
-rw-r--r--data/apathy-approver.desktop.in10
-rw-r--r--data/apathy-contacts.desktop.in9
-rw-r--r--data/apathy-handler.desktop.in10
-rw-r--r--data/icons/128x128/apps/apathy.pngbin0 -> 19026 bytes
-rw-r--r--data/icons/16x16/apps/apathy.pngbin0 -> 747 bytes
-rw-r--r--data/icons/192x192/apps/apathy.pngbin0 -> 41549 bytes
-rw-r--r--data/icons/22x22/apps/apathy.pngbin0 -> 1171 bytes
-rw-r--r--data/icons/24x24/apps/apathy.pngbin0 -> 1324 bytes
-rw-r--r--data/icons/256x256/apps/apathy.pngbin0 -> 72110 bytes
-rw-r--r--data/icons/32x32/apps/apathy.pngbin0 -> 2021 bytes
-rw-r--r--data/icons/36x36/apps/apathy.pngbin0 -> 2401 bytes
-rw-r--r--data/icons/48x48/actions/account-new.pngbin0 -> 775 bytes
-rw-r--r--data/icons/48x48/actions/accounts.pngbin0 -> 3762 bytes
-rw-r--r--data/icons/48x48/actions/apathetic.pngbin0 -> 3113 bytes
-rw-r--r--data/icons/48x48/actions/call.pngbin0 -> 3528 bytes
-rw-r--r--data/icons/48x48/actions/close.pngbin0 -> 3073 bytes
-rw-r--r--data/icons/48x48/actions/contact-new.pngbin0 -> 2473 bytes
-rw-r--r--data/icons/48x48/actions/contacts.pngbin0 -> 3437 bytes
-rw-r--r--data/icons/48x48/actions/message.pngbin0 -> 1298 bytes
-rw-r--r--data/icons/48x48/apps/apathy.pngbin0 -> 3766 bytes
-rw-r--r--data/icons/48x48/apps/im-google-talk.pngbin0 -> 3043 bytes
-rw-r--r--data/icons/48x48/apps/im-msn.pngbin0 -> 3004 bytes
-rw-r--r--data/icons/64x64/apps/apathy.pngbin0 -> 6022 bytes
-rw-r--r--data/icons/72x72/apps/apathy.pngbin0 -> 7051 bytes
-rw-r--r--data/icons/96x96/apps/apathy.pngbin0 -> 11538 bytes
-rw-r--r--data/icons/scalable/apps/apathy.svg661
-rw-r--r--data/org.freedesktop.Telepathy.Client.Apathy.Approver.service3
-rw-r--r--data/org.freedesktop.Telepathy.Client.Apathy.Handler.service3
-rw-r--r--debian/changelog36
-rw-r--r--debian/compat1
-rw-r--r--debian/control20
-rw-r--r--debian/copyright17
-rw-r--r--debian/docs1
-rw-r--r--debian/pycompat1
-rwxr-xr-xdebian/rules4
-rw-r--r--po/apathy.pot296
-rw-r--r--po/fi.po304
-rw-r--r--po/it.po306
-rw-r--r--po/pt_BR.po300
-rw-r--r--po/ru.po301
-rwxr-xr-xsetup.py36
70 files changed, 6070 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..ff15965
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,6 @@
1Michael Sheldon <mike@mikeasoft.com>
2Alasdair MacLeod <alasdair.macleod@gmail.com>
3Paul Wermann <stuff4tschaka@gmx.net>
4Kai Huuhko <kai@kaihuuhko.com>
5
6Launcher icons by swordplay <swordplay@gmail.com> from Bodhi Linux forums.
diff --git a/Apathy.Approver.client b/Apathy.Approver.client
new file mode 100644
index 0000000..6248824
--- /dev/null
+++ b/Apathy.Approver.client
@@ -0,0 +1,4 @@
1[org.freedesktop.Telepathy.Client]
2Interfaces=org.freedesktop.Telepathy.Client.Approver
3
4[org.freedesktop.Telepathy.Client.Approver.ApproverChannelFilter 0]
diff --git a/Apathy.Handler.client b/Apathy.Handler.client
new file mode 100644
index 0000000..3be4175
--- /dev/null
+++ b/Apathy.Handler.client
@@ -0,0 +1,10 @@
1[org.freedesktop.Telepathy.Client]
2Interfaces=org.freedesktop.Telepathy.Client.Handler
3
4[org.freedesktop.Telepathy.Client.Handler.HandlerChannelFilter 0]
5org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Text
6org.freedesktop.Telepathy.Channel.TargetHandleType u=0
7
8[org.freedesktop.Telepathy.Client.Handler.HandlerChannelFilter 1]
9org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Text
10org.freedesktop.Telepathy.Channel.TargetHandleType u=1
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,674 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 3, 29 June 2007
3
4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8 Preamble
9
10 The GNU General Public License is a free, copyleft license for
11software and other kinds of works.
12
13 The licenses for most software and other practical works are designed
14to take away your freedom to share and change the works. By contrast,
15the GNU General Public License is intended to guarantee your freedom to
16share and change all versions of a program--to make sure it remains free
17software for all its users. We, the Free Software Foundation, use the
18GNU General Public License for most of our software; it applies also to
19any other work released this way by its authors. You can apply it to
20your programs, too.
21
22 When we speak of free software, we are referring to freedom, not
23price. Our General Public Licenses are designed to make sure that you
24have the freedom to distribute copies of free software (and charge for
25them if you wish), that you receive source code or can get it if you
26want it, that you can change the software or use pieces of it in new
27free programs, and that you know you can do these things.
28
29 To protect your rights, we need to prevent others from denying you
30these rights or asking you to surrender the rights. Therefore, you have
31certain responsibilities if you distribute copies of the software, or if
32you modify it: responsibilities to respect the freedom of others.
33
34 For example, if you distribute copies of such a program, whether
35gratis or for a fee, you must pass on to the recipients the same
36freedoms that you received. You must make sure that they, too, receive
37or can get the source code. And you must show them these terms so they
38know their rights.
39
40 Developers that use the GNU GPL protect your rights with two steps:
41(1) assert copyright on the software, and (2) offer you this License
42giving you legal permission to copy, distribute and/or modify it.
43
44 For the developers' and authors' protection, the GPL clearly explains
45that there is no warranty for this free software. For both users' and
46authors' sake, the GPL requires that modified versions be marked as
47changed, so that their problems will not be attributed erroneously to
48authors of previous versions.
49
50 Some devices are designed to deny users access to install or run
51modified versions of the software inside them, although the manufacturer
52can do so. This is fundamentally incompatible with the aim of
53protecting users' freedom to change the software. The systematic
54pattern of such abuse occurs in the area of products for individuals to
55use, which is precisely where it is most unacceptable. Therefore, we
56have designed this version of the GPL to prohibit the practice for those
57products. If such problems arise substantially in other domains, we
58stand ready to extend this provision to those domains in future versions
59of the GPL, as needed to protect the freedom of users.
60
61 Finally, every program is threatened constantly by software patents.
62States should not allow patents to restrict development and use of
63software on general-purpose computers, but in those that do, we wish to
64avoid the special danger that patents applied to a free program could
65make it effectively proprietary. To prevent this, the GPL assures that
66patents cannot be used to render the program non-free.
67
68 The precise terms and conditions for copying, distribution and
69modification follow.
70
71 TERMS AND CONDITIONS
72
73 0. Definitions.
74
75 "This License" refers to version 3 of the GNU General Public License.
76
77 "Copyright" also means copyright-like laws that apply to other kinds of
78works, such as semiconductor masks.
79
80 "The Program" refers to any copyrightable work licensed under this
81License. Each licensee is addressed as "you". "Licensees" and
82"recipients" may be individuals or organizations.
83
84 To "modify" a work means to copy from or adapt all or part of the work
85in a fashion requiring copyright permission, other than the making of an
86exact copy. The resulting work is called a "modified version" of the
87earlier work or a work "based on" the earlier work.
88
89 A "covered work" means either the unmodified Program or a work based
90on the Program.
91
92 To "propagate" a work means to do anything with it that, without
93permission, would make you directly or secondarily liable for
94infringement under applicable copyright law, except executing it on a
95computer or modifying a private copy. Propagation includes copying,
96distribution (with or without modification), making available to the
97public, and in some countries other activities as well.
98
99 To "convey" a work means any kind of propagation that enables other
100parties to make or receive copies. Mere interaction with a user through
101a computer network, with no transfer of a copy, is not conveying.
102
103 An interactive user interface displays "Appropriate Legal Notices"
104to the extent that it includes a convenient and prominently visible
105feature that (1) displays an appropriate copyright notice, and (2)
106tells the user that there is no warranty for the work (except to the
107extent that warranties are provided), that licensees may convey the
108work under this License, and how to view a copy of this License. If
109the interface presents a list of user commands or options, such as a
110menu, a prominent item in the list meets this criterion.
111
112 1. Source Code.
113
114 The "source code" for a work means the preferred form of the work
115for making modifications to it. "Object code" means any non-source
116form of a work.
117
118 A "Standard Interface" means an interface that either is an official
119standard defined by a recognized standards body, or, in the case of
120interfaces specified for a particular programming language, one that
121is widely used among developers working in that language.
122
123 The "System Libraries" of an executable work include anything, other
124than the work as a whole, that (a) is included in the normal form of
125packaging a Major Component, but which is not part of that Major
126Component, and (b) serves only to enable use of the work with that
127Major Component, or to implement a Standard Interface for which an
128implementation is available to the public in source code form. A
129"Major Component", in this context, means a major essential component
130(kernel, window system, and so on) of the specific operating system
131(if any) on which the executable work runs, or a compiler used to
132produce the work, or an object code interpreter used to run it.
133
134 The "Corresponding Source" for a work in object code form means all
135the source code needed to generate, install, and (for an executable
136work) run the object code and to modify the work, including scripts to
137control those activities. However, it does not include the work's
138System Libraries, or general-purpose tools or generally available free
139programs which are used unmodified in performing those activities but
140which are not part of the work. For example, Corresponding Source
141includes interface definition files associated with source files for
142the work, and the source code for shared libraries and dynamically
143linked subprograms that the work is specifically designed to require,
144such as by intimate data communication or control flow between those
145subprograms and other parts of the work.
146
147 The Corresponding Source need not include anything that users
148can regenerate automatically from other parts of the Corresponding
149Source.
150
151 The Corresponding Source for a work in source code form is that
152same work.
153
154 2. Basic Permissions.
155
156 All rights granted under this License are granted for the term of
157copyright on the Program, and are irrevocable provided the stated
158conditions are met. This License explicitly affirms your unlimited
159permission to run the unmodified Program. The output from running a
160covered work is covered by this License only if the output, given its
161content, constitutes a covered work. This License acknowledges your
162rights of fair use or other equivalent, as provided by copyright law.
163
164 You may make, run and propagate covered works that you do not
165convey, without conditions so long as your license otherwise remains
166in force. You may convey covered works to others for the sole purpose
167of having them make modifications exclusively for you, or provide you
168with facilities for running those works, provided that you comply with
169the terms of this License in conveying all material for which you do
170not control copyright. Those thus making or running the covered works
171for you must do so exclusively on your behalf, under your direction
172and control, on terms that prohibit them from making any copies of
173your copyrighted material outside their relationship with you.
174
175 Conveying under any other circumstances is permitted solely under
176the conditions stated below. Sublicensing is not allowed; section 10
177makes it unnecessary.
178
179 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
181 No covered work shall be deemed part of an effective technological
182measure under any applicable law fulfilling obligations under article
18311 of the WIPO copyright treaty adopted on 20 December 1996, or
184similar laws prohibiting or restricting circumvention of such
185measures.
186
187 When you convey a covered work, you waive any legal power to forbid
188circumvention of technological measures to the extent such circumvention
189is effected by exercising rights under this License with respect to
190the covered work, and you disclaim any intention to limit operation or
191modification of the work as a means of enforcing, against the work's
192users, your or third parties' legal rights to forbid circumvention of
193technological measures.
194
195 4. Conveying Verbatim Copies.
196
197 You may convey verbatim copies of the Program's source code as you
198receive it, in any medium, provided that you conspicuously and
199appropriately publish on each copy an appropriate copyright notice;
200keep intact all notices stating that this License and any
201non-permissive terms added in accord with section 7 apply to the code;
202keep intact all notices of the absence of any warranty; and give all
203recipients a copy of this License along with the Program.
204
205 You may charge any price or no price for each copy that you convey,
206and you may offer support or warranty protection for a fee.
207
208 5. Conveying Modified Source Versions.
209
210 You may convey a work based on the Program, or the modifications to
211produce it from the Program, in the form of source code under the
212terms of section 4, provided that you also meet all of these conditions:
213
214 a) The work must carry prominent notices stating that you modified
215 it, and giving a relevant date.
216
217 b) The work must carry prominent notices stating that it is
218 released under this License and any conditions added under section
219 7. This requirement modifies the requirement in section 4 to
220 "keep intact all notices".
221
222 c) You must license the entire work, as a whole, under this
223 License to anyone who comes into possession of a copy. This
224 License will therefore apply, along with any applicable section 7
225 additional terms, to the whole of the work, and all its parts,
226 regardless of how they are packaged. This License gives no
227 permission to license the work in any other way, but it does not
228 invalidate such permission if you have separately received it.
229
230 d) If the work has interactive user interfaces, each must display
231 Appropriate Legal Notices; however, if the Program has interactive
232 interfaces that do not display Appropriate Legal Notices, your
233 work need not make them do so.
234
235 A compilation of a covered work with other separate and independent
236works, which are not by their nature extensions of the covered work,
237and which are not combined with it such as to form a larger program,
238in or on a volume of a storage or distribution medium, is called an
239"aggregate" if the compilation and its resulting copyright are not
240used to limit the access or legal rights of the compilation's users
241beyond what the individual works permit. Inclusion of a covered work
242in an aggregate does not cause this License to apply to the other
243parts of the aggregate.
244
245 6. Conveying Non-Source Forms.
246
247 You may convey a covered work in object code form under the terms
248of sections 4 and 5, provided that you also convey the
249machine-readable Corresponding Source under the terms of this License,
250in one of these ways:
251
252 a) Convey the object code in, or embodied in, a physical product
253 (including a physical distribution medium), accompanied by the
254 Corresponding Source fixed on a durable physical medium
255 customarily used for software interchange.
256
257 b) Convey the object code in, or embodied in, a physical product
258 (including a physical distribution medium), accompanied by a
259 written offer, valid for at least three years and valid for as
260 long as you offer spare parts or customer support for that product
261 model, to give anyone who possesses the object code either (1) a
262 copy of the Corresponding Source for all the software in the
263 product that is covered by this License, on a durable physical
264 medium customarily used for software interchange, for a price no
265 more than your reasonable cost of physically performing this
266 conveying of source, or (2) access to copy the
267 Corresponding Source from a network server at no charge.
268
269 c) Convey individual copies of the object code with a copy of the
270 written offer to provide the Corresponding Source. This
271 alternative is allowed only occasionally and noncommercially, and
272 only if you received the object code with such an offer, in accord
273 with subsection 6b.
274
275 d) Convey the object code by offering access from a designated
276 place (gratis or for a charge), and offer equivalent access to the
277 Corresponding Source in the same way through the same place at no
278 further charge. You need not require recipients to copy the
279 Corresponding Source along with the object code. If the place to
280 copy the object code is a network server, the Corresponding Source
281 may be on a different server (operated by you or a third party)
282 that supports equivalent copying facilities, provided you maintain
283 clear directions next to the object code saying where to find the
284 Corresponding Source. Regardless of what server hosts the
285 Corresponding Source, you remain obligated to ensure that it is
286 available for as long as needed to satisfy these requirements.
287
288 e) Convey the object code using peer-to-peer transmission, provided
289 you inform other peers where the object code and Corresponding
290 Source of the work are being offered to the general public at no
291 charge under subsection 6d.
292
293 A separable portion of the object code, whose source code is excluded
294from the Corresponding Source as a System Library, need not be
295included in conveying the object code work.
296
297 A "User Product" is either (1) a "consumer product", which means any
298tangible personal property which is normally used for personal, family,
299or household purposes, or (2) anything designed or sold for incorporation
300into a dwelling. In determining whether a product is a consumer product,
301doubtful cases shall be resolved in favor of coverage. For a particular
302product received by a particular user, "normally used" refers to a
303typical or common use of that class of product, regardless of the status
304of the particular user or of the way in which the particular user
305actually uses, or expects or is expected to use, the product. A product
306is a consumer product regardless of whether the product has substantial
307commercial, industrial or non-consumer uses, unless such uses represent
308the only significant mode of use of the product.
309
310 "Installation Information" for a User Product means any methods,
311procedures, authorization keys, or other information required to install
312and execute modified versions of a covered work in that User Product from
313a modified version of its Corresponding Source. The information must
314suffice to ensure that the continued functioning of the modified object
315code is in no case prevented or interfered with solely because
316modification has been made.
317
318 If you convey an object code work under this section in, or with, or
319specifically for use in, a User Product, and the conveying occurs as
320part of a transaction in which the right of possession and use of the
321User Product is transferred to the recipient in perpetuity or for a
322fixed term (regardless of how the transaction is characterized), the
323Corresponding Source conveyed under this section must be accompanied
324by the Installation Information. But this requirement does not apply
325if neither you nor any third party retains the ability to install
326modified object code on the User Product (for example, the work has
327been installed in ROM).
328
329 The requirement to provide Installation Information does not include a
330requirement to continue to provide support service, warranty, or updates
331for a work that has been modified or installed by the recipient, or for
332the User Product in which it has been modified or installed. Access to a
333network may be denied when the modification itself materially and
334adversely affects the operation of the network or violates the rules and
335protocols for communication across the network.
336
337 Corresponding Source conveyed, and Installation Information provided,
338in accord with this section must be in a format that is publicly
339documented (and with an implementation available to the public in
340source code form), and must require no special password or key for
341unpacking, reading or copying.
342
343 7. Additional Terms.
344
345 "Additional permissions" are terms that supplement the terms of this
346License by making exceptions from one or more of its conditions.
347Additional permissions that are applicable to the entire Program shall
348be treated as though they were included in this License, to the extent
349that they are valid under applicable law. If additional permissions
350apply only to part of the Program, that part may be used separately
351under those permissions, but the entire Program remains governed by
352this License without regard to the additional permissions.
353
354 When you convey a copy of a covered work, you may at your option
355remove any additional permissions from that copy, or from any part of
356it. (Additional permissions may be written to require their own
357removal in certain cases when you modify the work.) You may place
358additional permissions on material, added by you to a covered work,
359for which you have or can give appropriate copyright permission.
360
361 Notwithstanding any other provision of this License, for material you
362add to a covered work, you may (if authorized by the copyright holders of
363that material) supplement the terms of this License with terms:
364
365 a) Disclaiming warranty or limiting liability differently from the
366 terms of sections 15 and 16 of this License; or
367
368 b) Requiring preservation of specified reasonable legal notices or
369 author attributions in that material or in the Appropriate Legal
370 Notices displayed by works containing it; or
371
372 c) Prohibiting misrepresentation of the origin of that material, or
373 requiring that modified versions of such material be marked in
374 reasonable ways as different from the original version; or
375
376 d) Limiting the use for publicity purposes of names of licensors or
377 authors of the material; or
378
379 e) Declining to grant rights under trademark law for use of some
380 trade names, trademarks, or service marks; or
381
382 f) Requiring indemnification of licensors and authors of that
383 material by anyone who conveys the material (or modified versions of
384 it) with contractual assumptions of liability to the recipient, for
385 any liability that these contractual assumptions directly impose on
386 those licensors and authors.
387
388 All other non-permissive additional terms are considered "further
389restrictions" within the meaning of section 10. If the Program as you
390received it, or any part of it, contains a notice stating that it is
391governed by this License along with a term that is a further
392restriction, you may remove that term. If a license document contains
393a further restriction but permits relicensing or conveying under this
394License, you may add to a covered work material governed by the terms
395of that license document, provided that the further restriction does
396not survive such relicensing or conveying.
397
398 If you add terms to a covered work in accord with this section, you
399must place, in the relevant source files, a statement of the
400additional terms that apply to those files, or a notice indicating
401where to find the applicable terms.
402
403 Additional terms, permissive or non-permissive, may be stated in the
404form of a separately written license, or stated as exceptions;
405the above requirements apply either way.
406
407 8. Termination.
408
409 You may not propagate or modify a covered work except as expressly
410provided under this License. Any attempt otherwise to propagate or
411modify it is void, and will automatically terminate your rights under
412this License (including any patent licenses granted under the third
413paragraph of section 11).
414
415 However, if you cease all violation of this License, then your
416license from a particular copyright holder is reinstated (a)
417provisionally, unless and until the copyright holder explicitly and
418finally terminates your license, and (b) permanently, if the copyright
419holder fails to notify you of the violation by some reasonable means
420prior to 60 days after the cessation.
421
422 Moreover, your license from a particular copyright holder is
423reinstated permanently if the copyright holder notifies you of the
424violation by some reasonable means, this is the first time you have
425received notice of violation of this License (for any work) from that
426copyright holder, and you cure the violation prior to 30 days after
427your receipt of the notice.
428
429 Termination of your rights under this section does not terminate the
430licenses of parties who have received copies or rights from you under
431this License. If your rights have been terminated and not permanently
432reinstated, you do not qualify to receive new licenses for the same
433material under section 10.
434
435 9. Acceptance Not Required for Having Copies.
436
437 You are not required to accept this License in order to receive or
438run a copy of the Program. Ancillary propagation of a covered work
439occurring solely as a consequence of using peer-to-peer transmission
440to receive a copy likewise does not require acceptance. However,
441nothing other than this License grants you permission to propagate or
442modify any covered work. These actions infringe copyright if you do
443not accept this License. Therefore, by modifying or propagating a
444covered work, you indicate your acceptance of this License to do so.
445
446 10. Automatic Licensing of Downstream Recipients.
447
448 Each time you convey a covered work, the recipient automatically
449receives a license from the original licensors, to run, modify and
450propagate that work, subject to this License. You are not responsible
451for enforcing compliance by third parties with this License.
452
453 An "entity transaction" is a transaction transferring control of an
454organization, or substantially all assets of one, or subdividing an
455organization, or merging organizations. If propagation of a covered
456work results from an entity transaction, each party to that
457transaction who receives a copy of the work also receives whatever
458licenses to the work the party's predecessor in interest had or could
459give under the previous paragraph, plus a right to possession of the
460Corresponding Source of the work from the predecessor in interest, if
461the predecessor has it or can get it with reasonable efforts.
462
463 You may not impose any further restrictions on the exercise of the
464rights granted or affirmed under this License. For example, you may
465not impose a license fee, royalty, or other charge for exercise of
466rights granted under this License, and you may not initiate litigation
467(including a cross-claim or counterclaim in a lawsuit) alleging that
468any patent claim is infringed by making, using, selling, offering for
469sale, or importing the Program or any portion of it.
470
471 11. Patents.
472
473 A "contributor" is a copyright holder who authorizes use under this
474License of the Program or a work on which the Program is based. The
475work thus licensed is called the contributor's "contributor version".
476
477 A contributor's "essential patent claims" are all patent claims
478owned or controlled by the contributor, whether already acquired or
479hereafter acquired, that would be infringed by some manner, permitted
480by this License, of making, using, or selling its contributor version,
481but do not include claims that would be infringed only as a
482consequence of further modification of the contributor version. For
483purposes of this definition, "control" includes the right to grant
484patent sublicenses in a manner consistent with the requirements of
485this License.
486
487 Each contributor grants you a non-exclusive, worldwide, royalty-free
488patent license under the contributor's essential patent claims, to
489make, use, sell, offer for sale, import and otherwise run, modify and
490propagate the contents of its contributor version.
491
492 In the following three paragraphs, a "patent license" is any express
493agreement or commitment, however denominated, not to enforce a patent
494(such as an express permission to practice a patent or covenant not to
495sue for patent infringement). To "grant" such a patent license to a
496party means to make such an agreement or commitment not to enforce a
497patent against the party.
498
499 If you convey a covered work, knowingly relying on a patent license,
500and the Corresponding Source of the work is not available for anyone
501to copy, free of charge and under the terms of this License, through a
502publicly available network server or other readily accessible means,
503then you must either (1) cause the Corresponding Source to be so
504available, or (2) arrange to deprive yourself of the benefit of the
505patent license for this particular work, or (3) arrange, in a manner
506consistent with the requirements of this License, to extend the patent
507license to downstream recipients. "Knowingly relying" means you have
508actual knowledge that, but for the patent license, your conveying the
509covered work in a country, or your recipient's use of the covered work
510in a country, would infringe one or more identifiable patents in that
511country that you have reason to believe are valid.
512
513 If, pursuant to or in connection with a single transaction or
514arrangement, you convey, or propagate by procuring conveyance of, a
515covered work, and grant a patent license to some of the parties
516receiving the covered work authorizing them to use, propagate, modify
517or convey a specific copy of the covered work, then the patent license
518you grant is automatically extended to all recipients of the covered
519work and works based on it.
520
521 A patent license is "discriminatory" if it does not include within
522the scope of its coverage, prohibits the exercise of, or is
523conditioned on the non-exercise of one or more of the rights that are
524specifically granted under this License. You may not convey a covered
525work if you are a party to an arrangement with a third party that is
526in the business of distributing software, under which you make payment
527to the third party based on the extent of your activity of conveying
528the work, and under which the third party grants, to any of the
529parties who would receive the covered work from you, a discriminatory
530patent license (a) in connection with copies of the covered work
531conveyed by you (or copies made from those copies), or (b) primarily
532for and in connection with specific products or compilations that
533contain the covered work, unless you entered into that arrangement,
534or that patent license was granted, prior to 28 March 2007.
535
536 Nothing in this License shall be construed as excluding or limiting
537any implied license or other defenses to infringement that may
538otherwise be available to you under applicable patent law.
539
540 12. No Surrender of Others' Freedom.
541
542 If conditions are imposed on you (whether by court order, agreement or
543otherwise) that contradict the conditions of this License, they do not
544excuse you from the conditions of this License. If you cannot convey a
545covered work so as to satisfy simultaneously your obligations under this
546License and any other pertinent obligations, then as a consequence you may
547not convey it at all. For example, if you agree to terms that obligate you
548to collect a royalty for further conveying from those to whom you convey
549the Program, the only way you could satisfy both those terms and this
550License would be to refrain entirely from conveying the Program.
551
552 13. Use with the GNU Affero General Public License.
553
554 Notwithstanding any other provision of this License, you have
555permission to link or combine any covered work with a work licensed
556under version 3 of the GNU Affero General Public License into a single
557combined work, and to convey the resulting work. The terms of this
558License will continue to apply to the part which is the covered work,
559but the special requirements of the GNU Affero General Public License,
560section 13, concerning interaction through a network will apply to the
561combination as such.
562
563 14. Revised Versions of this License.
564
565 The Free Software Foundation may publish revised and/or new versions of
566the GNU General Public License from time to time. Such new versions will
567be similar in spirit to the present version, but may differ in detail to
568address new problems or concerns.
569
570 Each version is given a distinguishing version number. If the
571Program specifies that a certain numbered version of the GNU General
572Public License "or any later version" applies to it, you have the
573option of following the terms and conditions either of that numbered
574version or of any later version published by the Free Software
575Foundation. If the Program does not specify a version number of the
576GNU General Public License, you may choose any version ever published
577by the Free Software Foundation.
578
579 If the Program specifies that a proxy can decide which future
580versions of the GNU General Public License can be used, that proxy's
581public statement of acceptance of a version permanently authorizes you
582to choose that version for the Program.
583
584 Later license versions may give you additional or different
585permissions. However, no additional obligations are imposed on any
586author or copyright holder as a result of your choosing to follow a
587later version.
588
589 15. Disclaimer of Warranty.
590
591 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
600 16. Limitation of Liability.
601
602 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610SUCH DAMAGES.
611
612 17. Interpretation of Sections 15 and 16.
613
614 If the disclaimer of warranty and limitation of liability provided
615above cannot be given local legal effect according to their terms,
616reviewing courts shall apply local law that most closely approximates
617an absolute waiver of all civil liability in connection with the
618Program, unless a warranty or assumption of liability accompanies a
619copy of the Program in return for a fee.
620
621 END OF TERMS AND CONDITIONS
622
623 How to Apply These Terms to Your New Programs
624
625 If you develop a new program, and you want it to be of the greatest
626possible use to the public, the best way to achieve this is to make it
627free software which everyone can redistribute and change under these terms.
628
629 To do so, attach the following notices to the program. It is safest
630to attach them to the start of each source file to most effectively
631state the exclusion of warranty; and each file should have at least
632the "copyright" line and a pointer to where the full notice is found.
633
634 <one line to give the program's name and a brief idea of what it does.>
635 Copyright (C) <year> <name of author>
636
637 This program is free software: you can redistribute it and/or modify
638 it under the terms of the GNU General Public License as published by
639 the Free Software Foundation, either version 3 of the License, or
640 (at your option) any later version.
641
642 This program is distributed in the hope that it will be useful,
643 but WITHOUT ANY WARRANTY; without even the implied warranty of
644 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 GNU General Public License for more details.
646
647 You should have received a copy of the GNU General Public License
648 along with this program. If not, see <http://www.gnu.org/licenses/>.
649
650Also add information on how to contact you by electronic and paper mail.
651
652 If the program does terminal interaction, make it output a short
653notice like this when it starts in an interactive mode:
654
655 <program> Copyright (C) <year> <name of author>
656 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 This is free software, and you are welcome to redistribute it
658 under certain conditions; type `show c' for details.
659
660The hypothetical commands `show w' and `show c' should show the appropriate
661parts of the General Public License. Of course, your program's commands
662might be different; for a GUI interface, you would use an "about box".
663
664 You should also get your employer (if you work as a programmer) or school,
665if any, to sign a "copyright disclaimer" for the program, if necessary.
666For more information on this, and how to apply and follow the GNU GPL, see
667<http://www.gnu.org/licenses/>.
668
669 The GNU General Public License does not permit incorporating your program
670into proprietary programs. If your program is a subroutine library, you
671may consider it more useful to permit linking proprietary applications with
672the library. If this is what you want to do, use the GNU Lesser General
673Public License instead of this License. But first, please read
674<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..4a4d3b6
--- /dev/null
+++ b/TODO
@@ -0,0 +1,15 @@
1- SMS
2- Multi-User Chats
3- Audio/Video calls
4- Implement logging for chats, see http://telepathy.freedesktop.org/wiki/Logger
5
6GUI:
7- Use more size_hints, remove hard resize to 480x640 if possible
8- Very simple account creator for common services like msn, google-talk and facebook
9- Contact combining (This would require an external contacts manager)
10
11Suggestions from users:
12imagine - somewhere in background we have handler.
13I open chat to you and say "Hello!" and then close.
14You open yours, and type "Hi!".
15I see new message via notify, press on baloon and chat window opened again.
diff --git a/apathy.png b/apathy.png
new file mode 100644
index 0000000..294c7f2
--- /dev/null
+++ b/apathy.png
Binary files differ
diff --git a/apathy/AccountEditor.py b/apathy/AccountEditor.py
new file mode 100644
index 0000000..8596a61
--- /dev/null
+++ b/apathy/AccountEditor.py
@@ -0,0 +1,512 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Alasdair MacLeod <alasdair.macleod@gmail.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24import os.path
25import logging
26from getpass import getuser
27import mimetypes
28import tempfile
29
30import elementary as elm
31
32from ErrorDialog import ErrorDialog
33from Globals import *
34
35from gi.repository import GObject
36from gi.repository import TelepathyGLib as Tp
37
38class AccountEditor(object):
39 def __init__(self, parent, pager, am, account=None):
40 self.parentwin = parent
41 self.pager = pager
42
43 self.bt_protocol = None
44 self.account = account
45 self.am = am
46 self.protos = {}
47 self.cms = {}
48
49 self.box = box = elm.Box(parent)
50
51 self.protocol_list = protocol_list = elm.Hoversel(box)
52 protocol_list.text= _("Select protocol").encode("utf-8")
53 self.populate_protocol_list(protocol_list)
54 box.pack_end(protocol_list)
55 protocol_list.show()
56
57 self.box1 = box1 = elm.Box(box)
58 box1.size_hint_weight_set(1.0, 1.0)
59 box1.size_hint_align_set(-1.0, -1.0)
60 box1.show()
61
62 scroller = elm.Scroller(box)
63 scroller.size_hint_weight_set(1.0, 1.0)
64 scroller.size_hint_align_set(-1.0, -1.0)
65 scroller.content_set(box1)
66 scroller.page_relative_set(0.0, 0.0)
67 scroller.bounce_set(False, False)
68 scroller.show()
69 box.pack_end(scroller)
70
71 self.box2 = box2 = elm.Box(box)
72 box2.size_hint_weight_set(1.0, 0.0)
73 box2.size_hint_align_set(-1.0, 0.0)
74 box2.horizontal_set(True)
75 box2.show()
76 box.pack_end(box2)
77
78 self.btn_save_settings = btn_save_settings = elm.Button(box)
79 btn_save_settings.text_set(_("Save Settings").encode("utf-8"))
80 btn_save_settings.size_hint_weight_set(1.0, 0.0)
81 btn_save_settings.size_hint_align_set(-1.0, 0.0)
82 btn_save_settings.callback_clicked_add(self.save)
83 self.box2.pack_end(btn_save_settings)
84 btn_save_settings.show()
85
86 xbtn = elm.Button(box)
87 xbtn.size_hint_weight_set(1.0, 0.0)
88 xbtn.size_hint_align_set(-1.0, 0.0)
89 xbtn.callback_clicked_add(self._close)
90 xbtn.text_set(_("Close").encode("utf-8"))
91 box2.pack_end(xbtn)
92 xbtn.show()
93
94 def populate_protocol_list(self, component):
95 logging.debug("Populating protocol list")
96 daemon = Tp.DBusDaemon.dup()
97 Tp.list_connection_managers_async(daemon, self.got_cms, component)
98
99 def got_cms(self, spam, result, component):
100 cms = Tp.list_connection_managers_finish(result)
101
102 for cm in cms:
103 self.cms[cm.get_name()] = cm
104 protos = cm.dup_protocols()
105 for proto in protos:
106 self.protos[proto.get_name()] = proto
107 ic = elm.Icon(self.box)
108 ic.standard_set("im-"+proto.get_name())
109 component.item_add(str.capitalize(proto.get_name()+" ("+cm.get_name()+")"), "im-"+proto.get_name(), elm.ELM_ICON_STANDARD, self._protocol_selected, proto, cm)
110
111 if self.account:
112 self.populate_data(self.account)
113
114 def populate_data(self, account):
115 self.account = account
116 cm = account.get_connection_manager()
117 proto = account.get_protocol()
118 self._protocol_selected(None, None, self.protos[proto], self.cms[cm])
119
120 account.get_avatar_async(self.got_avatar, None)
121
122 if proto == "jabber":
123 self.jabber_service_selected(self.props[Tp.IFACE_ACCOUNT+".Service"], None, account.get_service())
124 elif proto == "irc":
125 self.irc_service_selected(self.props[Tp.IFACE_ACCOUNT+".Service"], None, account.get_service())
126
127 self.dname.text_set(account.get_display_name())
128
129 self.props[Tp.IFACE_ACCOUNT+".Icon"].text_set(account.get_icon_name())
130 self.props[Tp.IFACE_ACCOUNT+".Nickname"].text_set(account.get_nickname())
131 self.props[Tp.IFACE_ACCOUNT+".Enabled"].state_set(account.is_enabled())
132 self.props[Tp.IFACE_ACCOUNT+".ConnectAutomatically"].state_set(account.get_connect_automatically())
133
134 self.auto_presence_selected(None, None, account.get_automatic_presence())
135
136 for param, v in self.params.iteritems():
137 params = account.get_parameters()
138 if param in params:
139 if type(v).__name__ == "Check":
140 self.params[param].state_set(params[param])
141 elif type(v).__name__ == "Entry":
142 self.params[param].text_set(params[param])
143 else:
144 logging.error("Unknown field %s" % (v))
145
146 def got_avatar(self, account, result, user_data):
147 data = account.get_avatar_finish(result)
148 if data:
149 avatar = tempfile.NamedTemporaryFile(delete=False)
150 avatar.write(data)
151 avatar.close()
152 self.avatar.file_set(avatar.name)
153
154 def _protocol_selected(self, obj, data, proto, cm):
155 self.proto = proto
156 self.cm = cm
157 self.protocol_list.text_set(str.capitalize(proto.get_name()+" ("+cm.get_name()+")"))
158 self.box1.clear()
159
160 self.props = {}
161 self.params = {}
162 self.changed = {}
163
164 params = proto.dup_params()
165
166 # Avatar
167 self.avatar = avatar = elm.Photo(self.box)
168 avatar.size_set(100)
169 avatar.callback_clicked_add(self.avatar_clicked)
170
171 avatarframe = elm.Frame(self.box)
172 avatarframe.text_set(_("Avatar").encode("utf-8"))
173 avatarframe.size_hint_align_set(0.5, -1.0)
174 avatarframe.content_set(avatar)
175 self.box1.pack_end(avatarframe)
176 avatar.show()
177 avatarframe.show()
178
179 # Service
180 proto_name = proto.get_name()
181 if proto_name == "jabber" or proto_name == "irc":
182 self.props[Tp.IFACE_ACCOUNT+".Service"] = service = elm.Hoversel(self.box)
183 service.text_set(_("Select").encode("utf-8"))
184 servframe = elm.Frame(self.box)
185 servframe.size_hint_align_set(-1.0, -1.0)
186 servframe.text_set(_("Service").encode("utf-8"))
187 servframe.content_set(service)
188 self.box1.pack_end(servframe)
189 servframe.show()
190 service.show()
191
192 proto_name = proto.get_name()
193 if proto_name == "jabber":
194 for s in ["jabber", "google-talk", "ovi-chat", "facebook", "lj-talk", "windows-live"]:
195 service.item_add(str.capitalize(s), "im-"+s, elm.ELM_ICON_STANDARD, self.jabber_service_selected, s)
196 elif proto_name == "irc":
197 for s in ["Freenode", "IRCNet", "GimpNet"]:
198 service.item_add(s, None, elm.ELM_ICON_NONE, self.irc_service_selected, s)
199
200 # Display Name
201 dnameframe = elm.Frame(self.box)
202 dnameframe.text_set(_("Display Name").encode("utf-8"))
203 dnameframe.size_hint_align_set(-1.0, -1.0)
204 self.dname = dname = elm.Entry(self.box)
205 dname.single_line_set(True)
206 dnameframe.content_set(dname)
207 dname.show()
208 self.box1.pack_end(dnameframe)
209 dnameframe.show()
210 dname.text_set(getuser()+" ("+proto.get_name()+")")
211
212 # Entries: Nickname, Icon
213 for name, title in {Tp.IFACE_ACCOUNT+".Nickname": _("Nickname").encode("utf-8"), Tp.IFACE_ACCOUNT+".Icon": _("Icon").encode("utf-8")}.iteritems():
214 frame = elm.Frame(self.box)
215 frame.text_set(title)
216 frame.size_hint_align_set(-1.0, -1.0)
217 self.props[name] = entry = elm.Entry(self.box)
218 entry.single_line_set(True)
219 frame.content_set(entry)
220 entry.show()
221 self.box1.pack_end(frame)
222 frame.show()
223
224 self.props[Tp.IFACE_ACCOUNT+".Icon"].text_set("im-"+proto.get_name())
225
226 # Checks: Enabled, ConnectAutomatically
227 for name, title in {Tp.IFACE_ACCOUNT+".Enabled": _("Enabled").encode("utf-8"), Tp.IFACE_ACCOUNT+".ConnectAutomatically": _("Connect Automatically").encode("utf-8")}.iteritems():
228 frame = elm.Frame(self.box)
229 frame.text_set(title)
230 frame.size_hint_align_set(-1.0, -1.0)
231 self.props[name] = check = elm.Check(self.box)
232 frame.content_set(check)
233 check.show()
234 self.box1.pack_end(frame)
235 frame.show()
236
237 self.props[Tp.IFACE_ACCOUNT+".Enabled"].state_set(True)
238
239 # TODO: Automatic Presence
240 apres = elm.Hoversel(self.box)
241 apres.text_set(_("Select"))
242 apresframe = elm.Frame(self.box)
243 apresframe.size_hint_align_set(-1.0, -1.0)
244 apresframe.text_set(_("Automatic Presence"))
245 apresframe.content_set(apres)
246 #self.box1.pack_end(apresframe)
247 #apresframe.show()
248 #apres.show()
249
250 paramhead = elm.Label(self.box)
251 paramhead.text_set("<br/>"+_("Account parameters:").encode("utf-8")+"<br/>")
252 paramhead.show()
253 self.box1.pack_end(paramhead)
254
255 # Parameters
256 for param in params:
257 if param.is_dbus_property():
258 continue
259
260 pname = param.get_name()
261 defaultvalue = GObject.Value()
262
263 frame = elm.Frame(self.box)
264 frame.size_hint_align_set(-1.0, -1.0)
265
266 frametext = "%s" % (pname.rsplit(".", 1)[-1])
267 if param.is_required():
268 frametext = frametext+" "+_("REQUIRED")
269
270 ptype = param.get_dbus_signature()
271
272 if ptype == "b":
273 entry = self.params[pname] = elm.Check(self.box)
274 entry.callback_changed_add(lambda x, pname=pname: self._changed(x, pname))
275 if param.get_default(defaultvalue):
276 pdefault = defaultvalue.get_boolean()
277 entry.state_set(pdefault)
278 frametext = frametext+" - "+_("Default: %s") % (str(pdefault))
279
280 elif ptype == "s":
281 entry = self.params[pname] = elm.Entry(self.box)
282 entry.callback_changed_user_add(lambda x, pname=pname: self._changed(x, pname))
283 entry.single_line_set(True)
284 if param.is_secret():
285 entry.password_set(True)
286 if param.get_default(defaultvalue):
287 pdefault = defaultvalue.get_string()
288 entry.entry_set(pdefault)
289 frametext = frametext+" - "+_("Default: %s") % (pdefault)
290
291 elif ptype in ["n", "q", "i", "u", "x", "t"]:
292 entry = self.params[pname] = elm.Spinner(self.box)
293 entry.callback_changed_add(lambda x, pname=pname: self._changed(x, pname))
294 if "port" in pname:
295 entry.min_max_set(0, 65535)
296 else:
297 entry.min_max_set(0, 100000)
298 if param.get_default(defaultvalue):
299 if ptype in ["n", "i", "x"]:
300 pdefault = defaultvalue.get_int()
301 else:
302 pdefault = defaultvalue.get_uint()
303 entry.value_set(pdefault)
304 frametext = frametext+" - "+_("Default: %s") % (str(pdefault))
305
306 #elif ptype == "as":
307 #Multiline entry? Comma-delimited? List with buttons?
308 #entry = self.params[pname] = List(self.box)
309
310 else:
311 logging.debug("Unknown parameter type %s in %s" % (ptype, pname))
312 entry = self.params[pname] = elm.Entry(self.box)
313 entry.callback_changed_user_add(lambda x, pname=pname: self._changed(x, pname))
314 entry.single_line_set(True)
315
316 frame.text_set(frametext)
317
318 entry.show()
319 frame.content_set(entry)
320 self.box1.pack_end(frame)
321 frame.show()
322
323 def jabber_service_selected(self, hoversel, item, service):
324 hoversel.text_set(service.capitalize())
325 if service:
326 self.props[Tp.IFACE_ACCOUNT+".Icon"].text_set("im-"+service)
327 else:
328 self.props[Tp.IFACE_ACCOUNT+".Icon"].text_set("im-jabber")
329 self.props[Tp.IFACE_ACCOUNT+".Service"] = service
330
331 def irc_service_selected(self, hoversel, item, service):
332 hoversel.text_set(service.capitalize())
333 self.props[Tp.IFACE_ACCOUNT+".Service"] = service
334
335 def auto_presence_selected(self, hoversel, item, presence):
336 #TODO: Automatic Presence
337 pass
338
339 def avatar_clicked(self, obj):
340 avatarwin = elm.InnerWindow(self.parentwin)
341
342 avatarsel = elm.Fileselector(avatarwin)
343 avatarsel.is_save_set(False)
344 avatarsel.expandable_set(True)
345 avatarsel.callback_done_add(self.avatar_selected, avatarwin)
346
347 avatarwin.content_set(avatarsel)
348 avatarsel.show()
349 avatarwin.activate()
350
351 def avatar_selected(self, obj, selected, avatarwin):
352 if selected:
353 with open(selected, "r") as f:
354 avatar = bytearray(f.read())
355 mimetype = mimetypes.guess_type(selected)[0]
356
357 if self.check_avatar(mimetype, avatar):
358 self.avatar.file_set(selected)
359 self.avatardata = [bytearray(avatar), mimetype]
360 obj.delete()
361 avatarwin.delete()
362
363 def check_avatar(self, mimetype, avatar):
364 req = self.proto.get_avatar_requirements()
365
366 if not req:
367 req = Tp.AvatarRequirements.new(
368 ("image/png", "image/jpeg", "image/gif"),
369 32, #min
370 32,
371 64, #recommended
372 64,
373 96, #max
374 96,
375 32768 #max file
376 )
377
378 warn_file_size = 8192
379 valid = True
380
381 # Mime type checks
382 if not mimetype in req.supported_mime_types:
383 dialog = ErrorDialog(self.parentwin, _("Error").encode("utf-8"), _("Your avatar file is of wrong type, %s, the allowed types are %s") % (mimetype, str(req.supported_mime_types)))
384 valid = False
385
386 # File Size checks
387 if len(avatar)>req.maximum_bytes:
388 dialog = ErrorDialog(self.parentwin, _("Error").encode("utf-8"), _("Your avatar file is too large, %d bytes, the limit is %d bytes") % (len(avatar), req.maximum_bytes))
389 valid = False
390 elif len(avatar)>warn_file_size:
391 dialog = ErrorDialog(self.parentwin, _("Warning").encode("utf-8"), _("Your avatar file is of size %d bytes, which is larger than the recommended size %d bytes. Be aware that this account may not be able to set its presence correctly.") % (len(avatar), warn_file_size))
392
393 return valid
394
395 def _changed(self, x, key):
396 logging.debug("Entry %s changed" % (key.rsplit(".", 1)[-1]))
397 self.changed[key] = x
398
399 def save(self, data):
400 try: self.proto
401 except:
402 logging.info("No Protocol Selected")
403 errdlg = ErrorDialog(self.parentwin, _("Error").encode("utf-8"), _("No Protocol Selected").encode("utf-8"))
404 return
405
406 account = {}
407 account["displayname"] = self.dname.entry_get()
408 account["props"] = {}
409 account["params"] = {}
410
411 for k, v in self.props.iteritems():
412 if type(v).__name__ == "Check":
413 logging.debug("prop check %s" % (k))
414 account["props"][k] = v.state_get()
415 elif type(v).__name__ == "Entry":
416 prop = v.entry_get().replace("<br>", "")
417 logging.debug("prop entry %s" % (k))
418 account["props"][k] = str(prop)
419 elif type(v).__name__ == "str":
420 logging.debug("prop string %s" % (k))
421 account["props"][k] = v
422 elif type(v).__name__ == "tuple":
423 logging.debug("prop list %s" % (k))
424 account["props"][k] = v
425 else:
426 logging.debug("Unknown prop type %s in %s" % (type(v).__name__, k))
427
428 for k, v in self.changed.iteritems():
429 k = k.rsplit(".", 1)[-1]
430 if type(v).__name__ == "Check":
431 logging.debug("param check %s" % (k))
432 account["params"][k] = v.state_get()
433 elif type(v).__name__ == "Entry":
434 param = v.entry_get().replace("<br>", "")
435 logging.debug("param entry %s" % (k))
436 account["params"][k] = str(param)
437 elif type(v).__name__ == "Spinner":
438 param = v.value_get()
439 logging.debug("param spinner %s" % (k))
440 account["params"][k] = int(param)
441 #elif type(v).__name__ == "":
442 else:
443 logging.debug("Unknown param type %s in %s" % (type(v).__name__, k))
444
445 logging.info("Saving account for Display Name %s" % (account["displayname"]))
446
447 if self.account:
448 #We are editing an account
449 apaccount = self.account
450 apaccount.set_display_name_async(account["displayname"], self._display_name_set, None)
451 apaccount.set_enabled_async(account["props"][Tp.IFACE_ACCOUNT+".Enabled"], self._prop_set, None)
452 apaccount.set_icon_name_async(account["props"][Tp.IFACE_ACCOUNT+".Icon"], self._prop_set, None)
453 try: account["props"][Tp.IFACE_ACCOUNT+".Service"]
454 except KeyError:
455 pass
456 else:
457 apaccount.set_service_async(account["props"][Tp.IFACE_ACCOUNT+".Service"], self._prop_set, None)
458 #TODO: apaccount.set_automatic_presence_async(account["props"]["autopres"], self._prop_set, None)
459 apaccount.set_connect_automatically_async(account["props"][Tp.IFACE_ACCOUNT+".ConnectAutomatically"], self._prop_set, None)
460 apaccount.set_nickname_async(account["props"][Tp.IFACE_ACCOUNT+".Nickname"], self._prop_set, None)
461
462 try: self.avatardata
463 except AttributeError:
464 pass
465 else:
466 avatar, mimetype = self.avatardata
467 apaccount.set_avatar_async(avatar, mimetype, self._avatar_set, None)
468
469 if account["params"]:
470 # XXX: update_parameters(_vardict)_async is broken by https://bugs.freedesktop.org/show_bug.cgi?id=59757
471 pu = elm.Popup(self.box)
472 pu.part_text_set("title,text", "Account parameter updates disabled")
473 pu.text = "Updating the account parameters has been temporally disabled pending a fix to the underlaying library. As a workaround delete and recreate your account."
474 pub = elm.Button(self.box)
475 pub.text = "OK"
476 pub.callback_clicked_add(self._close)
477 pu.part_content_set("button1", pub)
478 pu.show()
479 #apaccount.update_parameters_async(account["params"], "", self._prop_set, None)
480 logging.info("Account %s updated" % (account["displayname"]))
481 #self._close()
482 else:
483 self.am.create_account_async(self.cm.get_name(), self.proto.get_name(), self.dname.entry_get(), account["params"], account["props"], self.account_created, None)
484
485 def account_created(self, am, result, user_data):
486 try:
487 account = am.create_account_finish(result)
488 except GObject.GError as gerror:
489 logging.exception("Error while creating account")
490 ErrorDialog(self.parentwin, _("Error").encode("utf-8"), gerror.message)
491 else:
492 logging.info("Account %s created" % (account.get_display_name()))
493 try: self.avatardata
494 except: pass
495 else:
496 avatar, mimetype = self.avatardata
497 account.set_avatar_async(avatar, mimetype, self._avatar_set, None)
498 self._close()
499
500 def _display_name_set(self, account, result, user_data):
501 if not account.set_display_name_finish(result):
502 errordlg = ErrorDialog(self.parentwin, _("Error").encode("utf-8"), "Could not set Display Name")
503
504 def _avatar_set(self, account, result, user_data):
505 if not account.set_avatar_finish(result):
506 errordlg = ErrorDialog(self.parentwin, _("Error").encode("utf-8"), "Could not set Avatar")
507
508 def _prop_set(self, account, result, user_data):
509 pass
510
511 def _close(self, *args):
512 self.pager.item_pop()
diff --git a/apathy/Accounts.py b/apathy/Accounts.py
new file mode 100644
index 0000000..7f28a9a
--- /dev/null
+++ b/apathy/Accounts.py
@@ -0,0 +1,267 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24import os.path
25import gettext
26import logging
27
28import ecore
29import elementary as elm
30from evas import EVAS_ASPECT_CONTROL_VERTICAL, EVAS_HINT_FILL, EVAS_HINT_EXPAND
31
32from Globals import *
33from AccountEditor import AccountEditor
34from PresenceEditor import PresenceEditor
35
36from gi.repository import GObject
37GObject.threads_init()
38from gi.repository import TelepathyGLib as Tp
39
40class Accounts(object):
41 def __init__(self):
42 self.accounts = {}
43 self._signals = []
44 self.accounts_list_items = {}
45
46 self.window = window = elm.StandardWindow("accounts", "Apathy - Accounts")
47 window.callback_delete_request_add(self.quit)
48
49 box = elm.Box(window)
50
51 self.accounts_list = accounts_list = elm.Genlist(window)
52 accounts_list.size_hint_weight = (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND)
53 accounts_list.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
54 accounts_list.mode_set(elm.ELM_LIST_COMPRESS)
55 accounts_list.callback_activated_add(self.item_activated_cb)
56 accounts_list.callback_selected_add(self.item_selected_cb)
57 accounts_list.show()
58 box.pack_end(accounts_list)
59
60 edit_box = elm.Box(window)
61 edit_box.horizontal = True
62 edit_box.size_hint_weight = (EVAS_HINT_EXPAND, 0.0)
63 edit_box.size_hint_align = (EVAS_HINT_FILL, 1.0)
64
65 btn = elm.Button(window)
66 btn.callback_clicked_add(self._add_account)
67 btn.size_hint_weight = (EVAS_HINT_EXPAND, 0.0)
68 btn.size_hint_align = (EVAS_HINT_FILL, 0.0)
69 btn.text = _("Create a new account")
70 btn.show()
71 edit_box.pack_end(btn)
72
73 self.presence_list = presence_list = elm.Hoversel(window)
74 presence_list.text = _("Set presence").encode("utf-8")
75 self._populate_presence_list()
76 presence_list.show()
77 edit_box.pack_end(presence_list)
78
79 box.pack_end(edit_box)
80 edit_box.show()
81
82 box.show()
83
84 self.pager = pager = elm.Naviframe(window)
85 pager.size_hint_weight = (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND)
86 pager.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL)
87 window.resize_object_add(pager)
88 pager.item_simple_push(box)
89 pager.show()
90
91 window.resize(480, 640)
92 window.show()
93
94 am = self.am = Tp.AccountManager.dup()
95 factory = self.am.get_factory()
96 factory.add_account_features([Tp.Account.get_feature_quark_connection()])
97 factory.add_connection_features([
98 Tp.Connection.get_feature_quark_avatar_requirements(),
99 ])
100
101 self.am.prepare_async(None, self._am_ready, None)
102
103 def _am_ready(self, am, result, error):
104 am.connect("account-enabled", self.am_account_enabled)
105 am.connect("account-disabled", self.am_account_disabled)
106 am.connect("account-removed", self.am_account_removed)
107 am.connect("account-validity-changed", self.am_account_validity_changed)
108 accounts = am.get_valid_accounts()
109 for account in accounts:
110 account.prepare_async(None, self.am_account_ready, None)
111
112 def am_account_ready(self, account, result, error):
113 a = Account(self, account)
114 suffix = account.get_path_suffix()
115 self.accounts[suffix] = a
116
117 def am_account_enabled(self, am, account, *args):
118 pass #self.accounts_list_items[account.get_path_suffix()].disabled_set(False)
119
120 def am_account_disabled(self, am, account, *args):
121 pass #self.accounts_list_items[account.get_path_suffix()].disabled_set(True)
122
123 def am_account_removed(self, am, account, *args):
124 self.accounts_list_items[account.get_path_suffix()].delete()
125
126 def am_account_validity_changed(self, am, account, valid, *args):
127 if valid:
128 account.prepare_async(None, self._account_ready, None)
129
130 def _populate_presence_list(self):
131 presences = {
132 "offline": (1, True, False),
133 "available": (2, True, True),
134 "away": (3, True, True),
135 "xa": (4, True, True),
136 "hidden": (5, True, False),
137 "dnd": (6, True, True),
138 "unknown": (7, False, False),
139 "error": (8, False, False),
140 }
141
142 conf = get_conf()
143
144 for status, spec in presences.iteritems():
145 presence, settable_on_self, can_have_message = spec
146 if settable_on_self:
147 if can_have_message:
148 try:
149 message = conf.get("StatusMessages", status)
150 except:
151 logging.exception("Status message for status %s not found in configuration file." % (status))
152 message = ""
153 self.presence_list.item_add(status.capitalize(), None, 0, self._set_presence, presence, status, message)
154 else:
155 self.presence_list.item_add(status.capitalize(), None, 0, self._set_presence, presence, status)
156
157 self.presence_list.item_add(_("Edit")+"...", None, 0, self._edit_presences)
158
159 def _edit_presences(self, obj, event, *args):
160 editor = PresenceEditor(self.window, self.pager)
161 self.pager.item_simple_push(editor.box)
162
163 def _add_account(self, obj, *args):
164 editor = AccountEditor(self.window, self.pager, self.am)
165 self.pager.item_simple_push(editor.box)
166
167 def item_activated_cb(self, genlist, genlistitem, *args):
168 account = genlistitem.data_get()
169 editor = AccountEditor(self.window, self.pager, self.am, account)
170 self.pager.item_simple_push(editor.box)
171
172 def _delete_account(self, obj, *args):
173 if(self.accounts_list.selected_item):
174 account = self.accounts_list.selected_item.data
175 account.remove_async(self._account_deleted(), None)
176
177 def _set_presence(self, obj, event, prestype, presence, message=""):
178 if self.accounts_list.selected_item:
179 account = self.accounts_list.selected_item.data
180 logging.info("Setting presence %s for account %s" % (presence, account.get_display_name()))
181 account.request_presence_async(prestype, presence, message, self._changed_presence, None)
182 obj.text = _("Set presence")+" ("+presence+")"
183
184 def _changed_presence(self, account, result, *args):
185 try:
186 account.request_presence_finish(result)
187 except:
188 logging.exception("Setting presence failed")
189 else:
190 logging.info("Presence set")
191
192 def _account_deleted(self):
193 logging.info("Account deleted")
194
195 def _balance_changed(self, *args):
196 pass
197
198 def item_selected_cb(self, obj, item):
199 account = item.data_get()
200 presence, status, status_message = account.get_requested_presence()
201 self.presence_list.text_set(_("Set presence")+" ("+status.capitalize()+")")
202
203 def quit(self, *args):
204 elm.exit()
205
206class AccountManager(object):
207 def __init__(self, am):
208 pass
209
210class Account(object):
211 def __init__(self, parent, account):
212 self.account = account
213 self.list_item = parent.accounts_list.item_append(AccountItem("default"), account, None, elm.ELM_GENLIST_ITEM_NONE)
214 account.connect("presence-changed", self._presence_changed)
215 account.connect("notify::changing-presence", self._presence_changing)
216
217 def _presence_changed(self, account, presence, status, status_message):
218 self.accounts_list_items[account.get_path_suffix()].update()
219
220 def _presence_changing(self, account, changing):
221 self.accounts_list_items[account.get_path_suffix()].update()
222
223class AccountItem(elm.GenlistItemClass):
224 def text_get(self, obj, part, account):
225 presence, status, status_message = account.get_current_presence()
226 text = "%s" % (account.get_display_name())
227 if status_message:
228 text += " [%s]" % (status_message)
229 return text
230
231 def content_get(self, obj, part, account):
232 if part == "elm.swallow.icon":
233 ic = elm.Icon(obj)
234 if account.get_icon_name():
235 ic.file_set(os.path.join(IMAGE_PATH, account.get_icon_name()+".png"))
236 ic.standard = account.get_icon_name()
237 else:
238 ic.standard = "apathetic"
239 elif part == "elm.swallow.end":
240 if account.get_changing_presence():
241 ic = elm.Progressbar(obj)
242 ic.style = "wheel"
243 ic.pulse_set(True)
244 ic.pulse(True)
245 else:
246 ic = elm.Icon(obj)
247 presence, status, status_message = account.get_current_presence()
248 ic.file_set(os.path.join(IMAGE_PATH, status+".png"))
249 ic.standard = "user-"+status
250 ic.size_hint_aspect = (EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)
251 return ic
252
253if __name__ == "__main__":
254 gettext.install("apathy", "/usr/share/locale", unicode=1)
255
256 # Log
257 if not os.path.exists(USER_PATH):
258 os.mkdir(USER_PATH, 0700)
259 logging.basicConfig(format="[%(levelname)s] in %(module)s line %(lineno)s (%(funcName)s): %(message)s", level=logging.DEBUG)
260
261 elm.init()
262
263 ecore.main_loop_glib_integrate()
264 accounts = Accounts()
265
266 elm.run()
267 elm.shutdown()
diff --git a/apathy/Apathy.py b/apathy/Apathy.py
new file mode 100644
index 0000000..d33d21f
--- /dev/null
+++ b/apathy/Apathy.py
@@ -0,0 +1,84 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24import os.path, gettext
25
26from Accounts import Accounts
27from Contacts import Contacts
28from Globals import *
29
30import ecore, dbus, e_dbus
31import elementary as e
32
33from gi.repository import GObject
34GObject.threads_init()
35from gi.repository import TelepathyGLib as Tp
36#Tp.debug_set_flags("all")
37
38class Apathy(e.Window):
39 def __init__(self, log):
40 e.Window.__init__(self, "apathy", e.ELM_WIN_BASIC)
41
42 self.title_set("Apathy")
43 self.callback_delete_request_add(self.quit)
44
45 bg = e.Background(self)
46 bg.size_hint_weight_set(1.0, 1.0)
47 self.resize_object_add(bg)
48 bg.show()
49
50 self.flip = flip = e.Flip(self)
51 self.contacts = contacts = Contacts(self)
52 self.accounts = accounts = Accounts(self)
53 flip.content_front_set(contacts)
54 flip.content_back_set(accounts)
55 flip.size_hint_weight_set(1.0, 1.0)
56 flip.size_hint_align_set(-1.0, -1.0)
57 self.resize_object_add(flip)
58 flip.show()
59
60 self.resize(480, 640)
61 self.show()
62
63 def quit(self, *args):
64 log.info("Apathy is exiting")
65 e.exit()
66
67if __name__ == "__main__":
68 if not os.path.exists(USER_PATH):
69 os.mkdir(USER_PATH, 0700)
70 if not os.path.exists(IMAGE_PATH):
71 os.mkdir(IMAGE_PATH, 0777)
72
73 gettext.install("apathy", "/usr/share/locale", unicode=1)
74
75 e.init()
76 dbus_mainloop = e_dbus.DBusEcoreMainLoop()
77 dbus.set_default_main_loop(dbus_mainloop)
78
79 apathy = Apathy(log)
80
81 ecore.main_loop_glib_integrate()
82
83 e.run()
84 e.shutdown()
diff --git a/apathy/Approver.py b/apathy/Approver.py
new file mode 100644
index 0000000..6958482
--- /dev/null
+++ b/apathy/Approver.py
@@ -0,0 +1,178 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24import os.path
25import gettext
26import logging
27
28import ecore
29import elementary as elm
30from evas import EVAS_ASPECT_CONTROL_VERTICAL
31
32from Globals import *
33
34from gi.repository import TelepathyGLib as Tp
35
36class Approver(object):
37 def __init__(self):
38 global log
39 log = logging.getLogger("apathy.approver")
40
41 daemon = Tp.DBusDaemon.dup()
42 factory = Tp.AutomaticClientFactory.new(daemon)
43 factory.add_account_features([Tp.Account.get_feature_quark_connection()])
44 factory.add_connection_features([
45 Tp.Connection.get_feature_quark_contact_list(),
46 Tp.Connection.get_feature_quark_contact_groups(),
47 Tp.Connection.get_feature_quark_avatar_requirements(),
48 ])
49 factory.add_contact_features([
50 Tp.ContactFeature.ALIAS,
51 Tp.ContactFeature.CONTACT_GROUPS,
52 Tp.ContactFeature.PRESENCE,
53 Tp.ContactFeature.AVATAR_DATA,
54 Tp.ContactFeature.SUBSCRIPTION_STATES,
55 Tp.ContactFeature.CAPABILITIES,
56 Tp.ContactFeature.CONTACT_INFO,
57 Tp.ContactFeature.LOCATION,
58 ])
59
60 self.approver = Tp.SimpleApprover.new_with_factory(
61 factory, #Factory/am/tpdbus
62 'Apathy.Approver', #name
63 False, #uniquify
64 self.channel_approver, #handler func
65 None, #data
66 )
67 self.approver.add_approver_filter({
68 })
69 self.approver.register()
70
71 def accept(self, button, dispatch_operation, win):
72 dispatch_operation.handle_with_async(Tp.CLIENT_BUS_NAME_BASE+"Apathy.Handler", self.channel_handled, win)
73
74 def cancelled(self, button, dispatch_operation, win):
75 dispatch_operation.destroy_channels_async(Tp.ChannelGroupChangeReason.NONE, "", self.channel_dropped, win)
76
77 def channel_handled(self, dispatch_operation, result, win):
78 dispatch_operation.handle_with_finish(result)
79 log.debug("%s %s %s" % (dispatch_operation, result, win))
80 win.delete()
81
82 def channel_dropped(self, dispatch_operation, result, win):
83 dispatch_operation.destroy_channels_finish(result)
84 log.debug("%s %s %s" % (dispatch_operation, result, win))
85 win.delete()
86
87 def channel_lost(self, channel, domain, code, message, user_data):
88 log.debug("%s %s %s %s %s" % (channel, domain, code, message, user_data))
89
90 def channel_approver(self, approver, account, connection, channels, dispatch_operation, context, user_data):
91 log.debug("%s %s %s %s %s %s %s" % (approver, account, connection, channels, dispatch_operation, context, user_data))
92
93 dispatch_operation.connect("channel-lost", self.channel_lost)
94
95 window = elm.Window("approver", elm.ELM_WIN_DIALOG_BASIC)
96 window.title = "Apathy - Approver"
97 window.callback_delete_request_add(self.quit)
98
99 bg = elm.Background(window)
100 bg.size_hint_weight = 1, 1
101 window.resize_object_add(bg)
102 bg.show()
103
104 box = elm.Box(window)
105 box.size_hint_weight_set(1.0, 1.0)
106 window.resize_object_add(box)
107 box.show()
108
109 title = elm.Label(window)
110 title.text_set("<b>"+_("Accept channel from").encode("ascii", "xmlcharrefreplace")+"</b>")
111 box.pack_end(title)
112 title.show()
113
114 for channel in channels:
115 log.info("Asking approval for a channel from %s" % (channel.get_identifier()))
116
117 identifier = channel.get_target_contact().get_alias()
118 if not identifier:
119 identifier = channel.get_identifier()
120 label = elm.Label(window)
121 label.size_hint_weight_set(1.0, 1.0)
122 label.show()
123 label.text_set("%s" % (identifier))
124 box.pack_end(label)
125
126 ok = elm.Button(window)
127 ok.text_set(_("Yes").encode("utf-8"))
128 ok_ic = elm.Icon(window)
129 ok_ic.standard_set("call-start")
130 ok.content_set(ok_ic)
131
132 cancel = elm.Button(window)
133 cancel.text_set(_("No").encode("utf-8"))
134 cancel_ic = elm.Icon(window)
135 cancel_ic.standard_set("call-stop")
136 cancel.content_set(cancel_ic)
137
138 ok.callback_clicked_add(self.accept, dispatch_operation, window)
139 cancel.callback_clicked_add(self.cancelled, dispatch_operation, window)
140
141 option_box = elm.Box(window)
142 option_box.horizontal_set(True)
143 option_box.size_hint_weight_set(1.0, 1.0)
144 option_box.pack_end(ok)
145 option_box.pack_end(cancel)
146 ok.show()
147 cancel.show()
148 option_box.show()
149 box.pack_end(option_box)
150
151 window.show()
152
153 context.accept()
154
155 def quit(self, *args):
156 elm.exit()
157
158if __name__ == "__main__":
159 gettext.install("apathy", "/usr/share/locale", unicode=1)
160
161 # Log
162 if not os.path.exists(USER_PATH):
163 os.mkdir(USER_PATH, 0700)
164 log = logging.getLogger("apathy.approver")
165 log.setLevel(logging.DEBUG)
166 streamformatter = logging.Formatter("[%(levelname)s] in %(module)s line %(lineno)s (%(funcName)s): %(message)s")
167 handler_stream = logging.StreamHandler()
168 handler_stream.setFormatter(streamformatter)
169 log.addHandler(handler_stream)
170
171 elm.init()
172 elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
173
174 ecore.main_loop_glib_integrate()
175 approver = Approver()
176
177 elm.run()
178 elm.shutdown()
diff --git a/apathy/Call.py b/apathy/Call.py
new file mode 100644
index 0000000..fe9655f
--- /dev/null
+++ b/apathy/Call.py
@@ -0,0 +1,45 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# #
8# This program is free software: you can redistribute it and/or modify #
9# it under the terms of the GNU General Public License as published by #
10# the Free Software Foundation, either version 3 of the License, or #
11# (at your option) any later version. #
12# #
13# This program is distributed in the hope that it will be useful, #
14# but WITHOUT ANY WARRANTY; without even the implied warranty of #
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16# GNU General Public License for more details. #
17# #
18# You should have received a copy of the GNU General Public License #
19# along with this program. If not, see <http://www.gnu.org/licenses/>. #
20# #
21#########################################################################
22
23import elementary, evas
24from datetime import datetime
25
26from gi.repository import TelepathyGLib as Tp
27
28class Call(elementary.Box):
29 def __init__(self, contact, channel, parent, apathy):
30 elementary.Box.__init__(self, parent)
31 self.contact = contact
32 self.channel = channel
33
34 self.apathy = apathy
35
36 disconnect_button = elementary.Button(self)
37 disconnect_button.text_set("Disconnect")
38 disconnect_button.size_hint_weight_set(0.0, 0.0)
39 disconnect_button.size_hint_align_set(-1.0, 0.0)
40 disconnect_button.clicked = self.disconnect
41 self.pack_end(disconnect_button)
42 disconnect_button.show()
43
44 def disconnect(self, obj, event, *args):
45 print "Disconnect"
diff --git a/apathy/ContactInfo.py b/apathy/ContactInfo.py
new file mode 100644
index 0000000..1c25cdf
--- /dev/null
+++ b/apathy/ContactInfo.py
@@ -0,0 +1,117 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24from elementary import *
25from evas import EVAS_ASPECT_CONTROL_VERTICAL
26
27from gi.repository import TelepathyGLib as Tp
28
29class ContactInfo(Box):
30 def __init__(self, parent, contact):
31 self.parentwin = parent
32 Box.__init__(self, parent.window)
33
34 self.size_hint_align_set(-1.0, -1.0)
35 self.size_hint_weight_set(1.0, 1.0)
36
37 ident = Label(self)
38 ident.text_set("<br><b>%s</b><br>" % contact.get_identifier())
39 self.pack_end(ident)
40 ident.show()
41
42 avatar = Photo(self)
43 avatar.size_set(200)
44 avatar_file = contact.get_avatar_file()
45 if avatar_file:
46 path = avatar_file.get_path()
47 avatar.file_set(path)
48 self.pack_end(avatar)
49 avatar.show()
50
51 textbox = Box(self)
52 textcap = ""
53 audiocap = ""
54 audiovideocap = ""
55 caps = contact.get_capabilities()
56 if caps:
57 if caps.supports_text_chats():
58 textcap = _("Yes")
59 if caps.supports_audio_call(Tp.HandleType.CONTACT):
60 audiocap = _("Yes")
61 if caps.supports_audio_video_call(Tp.HandleType.CONTACT):
62 audiovideocap = _("Yes")
63 states = {
64 Tp.SubscriptionState.UNKNOWN: _("Unknown"),
65 Tp.SubscriptionState.NO: _("No"),
66 Tp.SubscriptionState.REMOVED_REMOTELY: _("Denied"),
67 Tp.SubscriptionState.ASK: _("Waiting confirmation"),
68 Tp.SubscriptionState.YES: _("Yes")
69 }
70
71 location = ""
72 if contact.get_location():
73 location = contact.get_location()
74
75 blocked = _("No")
76 if contact.is_blocked():
77 blocked = _("Yes")
78
79 texts = {
80 _("Alias"): contact.get_alias().decode("utf-8"),
81 _("Status"): contact.get_presence_status().capitalize(),
82 _("Message"): contact.get_presence_message().decode("utf-8"),
83 _("Location"): location,
84 _("Account"): contact.get_connection().get_account().get_display_name(),
85 _("Subscribed to"): states[contact.get_subscribe_state()],
86 _("Published to"): states[contact.get_publish_state()],
87 _("Blocked"): blocked,
88 _("Can send text"): textcap,
89 _("Can call"): audiocap,
90 _("Can call with video"): audiovideocap,
91 }
92 for k, v in texts.iteritems():
93 k = k.encode("ascii", "xmlcharrefreplace")
94 v = v.encode("ascii", "xmlcharrefreplace")
95 label = Label(self)
96 label.text_set("<b>%s:</b> %s" % (k, v))
97 label.size_hint_align_set(0.0, 0.0)
98 textbox.pack_end(label)
99 label.show()
100
101 self.pack_end(textbox)
102 textbox.show()
103
104 fill = Box(self)
105 fill.size_hint_weight_set(1.0, 1.0)
106 self.pack_end(fill)
107
108 xbtn = Button(self)
109 xbtn.text_set(_("Close"))
110 xbtn.size_hint_weight_set(1.0, 0.0)
111 xbtn.size_hint_align_set(-1.0, 1.0)
112 xbtn.callback_clicked_add(self.close)
113 self.pack_end(xbtn)
114 xbtn.show()
115
116 def close(self, button):
117 self.parentwin.pager.item_pop()
diff --git a/apathy/Contacts.py b/apathy/Contacts.py
new file mode 100644
index 0000000..082e29d
--- /dev/null
+++ b/apathy/Contacts.py
@@ -0,0 +1,476 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24import os.path
25import gettext
26import logging
27
28import ecore
29import elementary as elm
30from evas import EVAS_ASPECT_CONTROL_VERTICAL
31
32from ContactInfo import ContactInfo
33from Globals import *
34from ErrorDialog import ErrorDialog
35
36from gi.repository import GObject
37GObject.threads_init()
38from gi.repository import TelepathyGLib as Tp
39
40class ContactItem(elm.GenlistItemClass):
41 def text_get(self, obj, part, contact):
42 if part == "elm.text":
43 msg = contact.get_presence_message()
44 if msg:
45 string = " %s - %s" % (contact.get_alias(), contact.get_presence_message())
46 else:
47 string = " %s" % (contact.get_alias())
48 return string
49 if part == "elm.text.sub":
50 return " %s" % contact.get_presence_message()
51
52 def content_get(self, obj, part, contact):
53 ic = elm.Icon(obj)
54 if part == "elm.swallow.icon":
55 if contact.get_presence_status() != "offline":
56 avatar = contact.get_avatar_file()
57 if avatar:
58 path = avatar.get_path()
59 ic.file_set(path)
60 else:
61 ic.standard_set("apathetic")
62 elif part == "elm.swallow.end":
63 status = contact.get_presence_status()
64 if status == "xa":
65 status = "away-extended"
66 ic.standard_set("user-"+status)
67 ic.size_hint_aspect_set(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)
68
69 return ic
70
71class ContactGroup(elm.GenlistItemClass):
72 def text_get(self, obj, part, contactgroup):
73 return contactgroup
74
75 def content_get(self, obj, part, contactgroup):
76 if part == "elm.swallow.icon":
77 ic = elm.Icon(obj)
78 ic.standard_set("media-playback-start")
79 ic.size_hint_aspect_set(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)
80 return ic
81 else:
82 return
83
84class Contacts(object):
85 def __init__(self):
86 self.accounts = {}
87 self._signals = []
88
89 self.contacts = {}
90 self.contact_items = {}
91 self.group_items = {}
92 self.selected_contact = None
93
94 global log
95 log = logging.getLogger("apathy.contacts")
96
97 self.window = window = elm.StandardWindow("contacts", "Apathy - Contacts")
98 window.callback_delete_request_add(self.quit)
99
100 self.am = am = Tp.AccountManager.dup()
101 factory = am.get_factory()
102 factory.add_account_features([Tp.Account.get_feature_quark_connection()])
103 factory.add_connection_features([
104 Tp.Connection.get_feature_quark_contact_list(),
105 Tp.Connection.get_feature_quark_contact_groups(),
106 Tp.Connection.get_feature_quark_contact_blocking(),
107 Tp.Connection.get_feature_quark_avatar_requirements(),
108 ])
109 factory.add_contact_features([
110 Tp.ContactFeature.ALIAS,
111 Tp.ContactFeature.CONTACT_GROUPS,
112 Tp.ContactFeature.PRESENCE,
113 Tp.ContactFeature.AVATAR_DATA,
114 Tp.ContactFeature.SUBSCRIPTION_STATES,
115 Tp.ContactFeature.CAPABILITIES,
116 Tp.ContactFeature.CONTACT_INFO,
117 Tp.ContactFeature.LOCATION,
118 Tp.ContactFeature.CONTACT_BLOCKING,
119 ])
120
121 am.prepare_async(None, self._am_ready, None)
122
123 box = elm.Box(window)
124
125 self.contact_list = contact_list = elm.Genlist(window)
126 contact_list.size_hint_weight_set(1.0, 1.0)
127 contact_list.size_hint_align_set(-1.0, -1.0)
128 contact_list.mode_set(elm.ELM_LIST_COMPRESS)
129 box.pack_end(contact_list)
130 contact_list.show()
131 contact_list.callback_longpressed_add(self.create_contact_info)
132 contact_list.callback_clicked_double_add(self.show_menu)
133
134 btn_box = elm.Box(window)
135 btn_box.horizontal_set(True)
136 btn_box.size_hint_weight_set(1.0, 0.0)
137 btn_box.size_hint_align_set(-1.0, 1.0)
138
139 #add_btn = elm.Button(window)
140 #add_btn.callback_clicked_add(self.new_contact)
141 #Translators: Verb, to add something
142 #add_btn.text_set(_("Add").encode("utf-8"))
143 #add_btn.size_hint_weight_set(1.0, 0.0)
144 #add_btn.size_hint_align_set(-1.0, 1.0)
145
146 #btn_box.pack_end(add_btn)
147 #add_btn.show()
148 #block_btn.show()
149 #box.pack_end(btn_box)
150 #btn_box.show()
151
152 self.pager = pager = elm.Naviframe(window)
153 pager.size_hint_weight_set(1.0, 1.0)
154 pager.size_hint_align_set(-1.0, -1.0)
155 window.resize_object_add(pager)
156 pager.show()
157 pager.item_simple_push(box)
158
159 window.resize(480, 640)
160 window.show()
161
162 def _am_ready(self, am, result, error):
163 for account in am.get_valid_accounts():
164 self.accounts[account.get_path_suffix()] = item = Account(self)
165 account.prepare_async(None, item.account_ready, None)
166 log.info("Added account for %s to the list of accounts" % (account.get_display_name()))
167
168 def new_contact(self, obj, *args):
169 new_contact_page = NewContact(self, self.am)
170
171 def create_contact_info(self, genlist, item):
172 contact = item.data_get()
173 contact_info = ContactInfo(self, contact)
174 self.pager.item_simple_push(contact_info)
175
176 def start_conversation(self, genlist, item):
177 contact = item.data_get()
178 account = contact.get_connection().get_account()
179 contact_id = contact.get_identifier()
180 request_dict = {
181 Tp.PROP_CHANNEL_CHANNEL_TYPE: Tp.IFACE_CHANNEL_TYPE_TEXT,
182 Tp.PROP_CHANNEL_TARGET_HANDLE_TYPE: int(Tp.HandleType.CONTACT),
183 Tp.PROP_CHANNEL_TARGET_ID: contact_id
184 }
185 request = Tp.AccountChannelRequest.new(account, request_dict, 0)
186 request.ensure_channel_async("", None, self.ensure_channel_cb, None)
187
188 def start_call(self, genlist, item):
189 contact = item.data_get()
190 account = contact.get_connection().get_account()
191 contact_id = contact.get_identifier()
192 request_dict = {
193 Tp.PROP_CHANNEL_CHANNEL_TYPE: Tp.IFACE_CHANNEL_TYPE_CALL,
194 Tp.PROP_CHANNEL_TARGET_HANDLE_TYPE: int(Tp.HandleType.CONTACT),
195 Tp.PROP_CHANNEL_TARGET_ID: contact_id
196 }
197 request = Tp.AccountChannelRequest.new(account, request_dict, 0)
198 request.ensure_channel_async("", None, self.ensure_channel_cb, None)
199
200 def ensure_channel_cb(self, request, result, user_data):
201 try:
202 request.ensure_channel_finish(result)
203 except GObject.GError as gerror:
204 ErrorDialog(self.window, _("Error"), gerror.message)
205
206 def block_contact(self, genlist, item):
207 contact = item.data_get()
208 contact.block_async(False, self.contact_blocked, None)
209
210 def contact_blocked(self, contact, result, user_data):
211 try:
212 contact.block_finish(result)
213 except GObject.GError as gerror:
214 ErrorDialog(self, _("Error"), gerror.message)
215
216 def unblock_contact(self, genlist, item):
217 contact = item.data_get()
218 contact.unblock_async(self.contact_unblocked, None)
219
220 def contact_unblocked(self, contact, result, user_data):
221 try:
222 contact.unblock_finish(result)
223 except GObject.GError as gerror:
224 ErrorDialog(self, _("Error"), gerror.message)
225
226 def show_menu(self, genlist, item):
227 contact = item.data_get()
228 menu = elm.Menu(self.window)
229 menu.item_add(None, _("Text").encode("utf-8"), "message", self.menu_conversation, genlist, item)
230 #menu.item_add(None, _("Call"), "call", self.menu_call, genlist, item)
231 #menu.item_add(None, _("Send file", "file", self.menu_file, genlist, item)
232 menu.item_separator_add()
233 if contact.is_blocked():
234 menu.item_add(None, _("Unblock").encode("utf-8"), "", self.menu_unblock, genlist, item)
235 else:
236 menu.item_add(None, _("Block").encode("utf-8"), "", self.menu_block, genlist, item)
237 menu.item_add(None, _("Information").encode("utf-8"), "", self.menu_contact_info, genlist, item)
238
239 w, h = genlist.size_get()
240 menu.move(w/2-50, h/2-100)
241 menu.show()
242
243 def menu_conversation(self, menu, menuitem, genlist, item):
244 self.start_conversation(genlist, item)
245 def menu_call(self, menu, menuitem, genlist, item):
246 self.start_call(genlist, item)
247 def menu_file(self, menu, menuitem, genlist, item):
248 pass
249 def menu_block(self, menu, menuitem, genlist, item):
250 self.block_contact(genlist, item)
251 def menu_unblock(self, menu, menuitem, genlist, item):
252 self.unblock_contact(genlist, item)
253 def menu_contact_info(self, menu, menuitem, genlist, item):
254 self.create_contact_info(genlist, item)
255
256 def quit(self, *args):
257 elm.exit()
258
259class Account(object):
260 def __init__(self, parent):
261 self.parent = parent
262
263 self._signals = []
264 self.group_items = {}
265
266 def account_ready(self, account, result, error):
267 self.account = account
268
269 if account.get_connection_status()[0] == Tp.ConnectionStatus.CONNECTED:
270 self.get_contacts(account.get_connection())
271
272 account.connect("status-changed", self._status_changed)
273
274 def _status_changed(self, account, old_status, new_status, reason, dbus_error_name, details, *args):
275 log.debug("Connection status for %s changed from %s to %s, reason %s, dbus error %s, details %s" % (account.get_display_name(), old_status, new_status, reason, dbus_error_name, details))
276 connection = account.get_connection()
277 contact_list = self.parent
278
279 if new_status == Tp.ConnectionStatus.CONNECTED:
280 if connection.get_contact_list_state() == Tp.ContactListState.SUCCESS:
281 self._signals.append(connection.connect("groups-created", self._groups_created))
282 self._signals.append(connection.connect("groups-removed", self._groups_removed))
283 self.get_contacts(connection)
284 else:
285 self._signals.append(connection.connect("notify::contact-list-state", self._contact_list_state_changed))
286
287 elif new_status == Tp.ConnectionStatus.DISCONNECTED:
288 log.debug("%s disconnected" % (connection.get_object_path()))
289 for sigid in self._signals:
290 connection.disconnect(sigid)
291 try:
292 for k, v in connection.contact_items.iteritems():
293 for item in v:
294 item.delete()
295 for k, v in connection.group_items.iteritems():
296 v.delete()
297 except:
298 pass
299
300 def get_contacts(self, connection):
301 connection.group_items = {}
302 connection.contact_items = {}
303 contact_list = self.parent
304 groups = connection.get_contact_groups()
305 if not groups:
306 groups.append(_("Non-grouped contacts").encode("utf-8"))
307 self._groups_created(groups)
308 contacts = connection.dup_contact_list()
309 self._contact_list_changed(contacts, None)
310
311 self._signals.append(connection.connect("contact-list-changed", self._contact_list_changed))
312 #connection.connect("balance-changed", self._balance_changed)
313 #connection.connect("blocked-contacts-changed", self._blocked_contacts_changed)
314 #connection.connect("group-renamed", self._group_renamed)
315
316 def _groups_created(self, added):
317 for group in added:
318 self.account.get_connection().group_items[group] = item = self.add_group(group)
319 item.select_mode_set(elm.ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
320
321 def _groups_removed(self, removed):
322 for group in removed:
323 log.debug("Group %s was removed" % (group))
324
325 def _contact_list_state_changed(self, connection, prop):
326 if connection.get_contact_list_state() == Tp.ContactListState.SUCCESS:
327 self.get_contacts(connection)
328
329 def _send_message(self, obj, *args):
330 pass
331
332 def _call(self, obj, *args):
333 pass
334
335 def add_contact(self, contact):
336 connection = contact.get_connection()
337 item_class = ContactItem("default")
338 contact_items = []
339 groups = contact.get_contact_groups()
340 if not groups:
341 groups = [_("Contacts")]
342 for group in groups:
343 try:
344 group = connection.group_items[group]
345 except KeyError:
346 group = None
347 contact_item = self.parent.contact_list.item_append(item_class, contact, group, elm.ELM_GENLIST_ITEM_NONE)
348 contact_item.tooltip_content_cb_set(self._contact_tooltip, contact)
349 contact_items.append(contact_item)
350 return contact_items
351
352 def _contact_list_changed(self, added, removed, *args):
353 if added:
354 for contact in added:
355 log.debug("contact %s added" % contact.get_handle())
356 contact.get_connection().contact_items[contact.get_handle()] = items = self.add_contact(contact)
357 #~ for item in items:
358 #~ if contact.get_presence_status() == "offline":
359 #~ item.disabled_set(True)
360 #~ else:
361 #~ item.disabled_set(False)
362 contact.connect("presence-changed", self._presence_changed)
363 #contact.connect("contact-groups-changed", self._groups_changed)
364 #contact.connect("subscription-states-changed", self._subscription_states_changed)
365 contact.connect("notify::avatar-file", self._contact_changed)
366 if removed:
367 for contact in removed:
368 log.debug("contact %s removed" % contact.get_handle())
369 contact.get_connection().contact_items[contact.get_handle()].delete()
370 del contact
371
372 def _contact_tooltip(self, list, item, contact):
373 helplabel = elm.Label(self.parent.window)
374 helplabel.size_hint_align_set(0.0, 0.0)
375 helplabel.text_set("<b>Double-click</b> for contact options<br/><b>Longpress</b> for more information")
376
377 avatar = elm.Photo(self.parent.window)
378 avatar.size_set(100)
379 avatar_file = contact.get_avatar_file()
380 if avatar_file:
381 path = avatar_file.get_path()
382 avatar.file_set(path)
383
384 textbox = elm.Box(self.parent.window)
385 textcap = ""
386 audiocap = ""
387 audiovideocap = ""
388 caps = contact.get_capabilities()
389 if caps:
390 if caps.supports_text_chats():
391 textcap = _("Yes")
392 if caps.supports_audio_call(Tp.HandleType.CONTACT):
393 audiocap = _("Yes")
394 if caps.supports_audio_video_call(Tp.HandleType.CONTACT):
395 audiovideocap = _("Yes")
396 states = {
397 Tp.SubscriptionState.UNKNOWN: _("Unknown"),
398 Tp.SubscriptionState.NO: _("No"),
399 Tp.SubscriptionState.REMOVED_REMOTELY: _("Denied"),
400 Tp.SubscriptionState.ASK: _("Waiting confirmation"),
401 Tp.SubscriptionState.YES: _("Yes")
402 }
403 texts = {
404 _("Identifier"): contact.get_identifier(),
405 _("Status"): contact.get_presence_status().capitalize(),
406 _("Message"): contact.get_presence_message().decode("utf-8"),
407 _("Account"): contact.get_connection().get_account().get_display_name(),
408 _("Subscribed to"): states[contact.get_subscribe_state()],
409 _("Published to"): states[contact.get_publish_state()],
410 _("Can send text"): textcap,
411 _("Can call"): audiocap,
412 _("Can call with video"): audiovideocap,
413 }
414 for k, v in texts.iteritems():
415 k = k.encode("ascii", "xmlcharrefreplace")
416 v = v.encode("ascii", "xmlcharrefreplace")
417 label = elm.Label(self.parent.window)
418 label.text_set("<b>%s:</b> %s" % (k, v))
419 label.size_hint_align_set(0.0, 0.0)
420 textbox.pack_end(label)
421 label.show()
422
423 infobox = elm.Box(self.parent.window)
424 infobox.horizontal_set(True)
425 infobox.pack_end(avatar)
426 avatar.show()
427 infobox.pack_end(textbox)
428 textbox.show()
429 box = elm.Box(self.parent.window)
430 box.pack_end(helplabel)
431 helplabel.show()
432 box.pack_end(infobox)
433 infobox.show()
434 box.show()
435 return box
436
437 def add_group(self, group):
438 group_class = ContactGroup()
439 return self.parent.contact_list.item_append(group_class, group, None, elm.ELM_GENLIST_ITEM_GROUP)
440
441 def _group_renamed(self, old_name, new_name, *args):
442 pass
443
444 def _presence_changed(self, contact, presence, status, message, *args):
445 for item in contact.get_connection().contact_items[contact.get_handle()]:
446 #~ if status == "offline":
447 #~ item.disabled_set(True)
448 #~ else:
449 #~ item.disabled_set(False)
450 item.update()
451 notify(_("Presence changed"), _("%s is now %s").encode("utf-8") % (contact.get_alias(), status), "notification-information")
452
453 def _contact_changed(self, contact, signal):
454 for item in contact.get_connection().contact_items[contact.get_handle()]:
455 item.update()
456
457if __name__ == "__main__":
458 gettext.install("apathy", "/usr/share/locale", unicode=1)
459
460 # Log
461 if not os.path.exists(USER_PATH):
462 os.mkdir(USER_PATH, 0700)
463 log = logging.getLogger("apathy.contacts")
464 log.setLevel(logging.DEBUG)
465 streamformatter = logging.Formatter("[%(levelname)s] in %(module)s line %(lineno)s (%(funcName)s): %(message)s")
466 handler_stream = logging.StreamHandler()
467 handler_stream.setFormatter(streamformatter)
468 log.addHandler(handler_stream)
469
470 elm.init()
471
472 ecore.main_loop_glib_integrate()
473 contacts = Contacts()
474
475 elm.run()
476 elm.shutdown()
diff --git a/apathy/Conversation.py b/apathy/Conversation.py
new file mode 100644
index 0000000..50ad609
--- /dev/null
+++ b/apathy/Conversation.py
@@ -0,0 +1,300 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24import logging
25from datetime import datetime
26from time import time
27from threading import Timer
28import webbrowser
29
30from evas import EVAS_ASPECT_CONTROL_VERTICAL
31import elementary as elm
32
33from Globals import *
34from Parser import parse
35
36from gi.repository import TelepathyGLib as Tp
37
38class Conversation(object):
39 def __init__(self, parent, channel):
40 self.parentwin = parent.window
41 self.contact = channel.get_target_contact()
42 self.channel = channel
43
44 global log
45 log = logging.getLogger("apathy.handler")
46
47 self.chat_state = "inactive"
48
49 box = self.box = elm.Box(self.parentwin)
50 box.size_hint_weight_set(1.0, 1.0)
51 box.size_hint_align_set(-1.0, -1.0)
52
53 self.scroll = elm.Scroller(self.box)
54 self.scroll.size_hint_weight_set(1.0, 1.0)
55 self.scroll.size_hint_align_set(-1.0, -1.0)
56 self.scroll.bounce_set(False,True)
57 box.pack_end(self.scroll)
58 self.scroll.show()
59
60 self.message_box = elm.Box(self.box)
61 self.message_box.size_hint_weight_set(1.0, 1.0)
62 self.message_box.size_hint_align_set(-1.0, -1.0)
63 self.scroll.content_set(self.message_box)
64 self.message_box.show()
65
66 fr_entry = elm.Frame(self.box)
67 fr_entry.text_set(_("Input:").encode("utf-8"))
68 fr_entry.size_hint_align_set(0.0, 0.0)
69 fr_entry.size_hint_align_set(-1.0, 0.0)
70
71 self.text_entry = elm.Entry(self.box)
72 self.text_entry.elm_event_callback_add(self.entry_event)
73 self.text_entry.focus_set(True)
74
75 fr_entry.content_set(self.text_entry)
76 box.pack_end(fr_entry)
77 self.text_entry.show()
78 fr_entry.show()
79
80 box1 = elm.Box(self.box)
81 box1.horizontal_set(True)
82 box1.size_hint_weight_set(1.0, 0.0)
83 box1.size_hint_align_set(-1.0, 0.0)
84 box.pack_end(box1)
85
86 self.entry_mode = entry_mode = elm.Check(self.box)
87 entry_mode.text_set(_("Quick entry mode").encode("utf-8"))
88 box1.pack_end(entry_mode)
89 entry_mode.show()
90
91 self.emotes = emotes = elm.Check(self.box)
92 emotes.text_set(_("Emoticons").encode("utf-8"))
93 box1.pack_end(emotes)
94 emotes.show()
95
96 send_button = elm.Button(self.box)
97 send_button.text_set(_("Send").encode("utf-8"))
98 send_button.size_hint_weight_set(1.0, 0.0)
99 send_button.size_hint_align_set(-1.0, 0.0)
100 send_button.callback_clicked_add(self.send_clicked)
101 box1.pack_end(send_button)
102 send_button.show()
103
104 box1.show()
105 box.show()
106
107 channel.connect('message-received', self.message_received)
108 channel.connect('message-sent', self.message_sent)
109 #channel.connect('send-error', self.send_error_cb)
110 channel.connect("chat-state-changed", self.chat_state_changed)
111
112 messages = channel.get_pending_messages()
113 for message in messages:
114 self.message_received(channel, message)
115
116 def request_channel_error_cb(self, exception):
117 log.error("Error" % (str(exception)))
118
119 def add_bubble(self, text, timestamp, sender, corner, avatar = None):
120 timestr = datetime.fromtimestamp(timestamp).strftime("%c")
121 bb = elm.Bubble(self.box)
122 bb.pos_set(corner)
123 bb.text_set(sender)
124 bb.part_text_set("info", timestr)
125 bb.size_hint_weight_set(0.0, 0.0)
126 bb.size_hint_align_set(-1.0, 0.0)
127 ab = elm.Entry(self.box)
128 ab.callback_anchor_clicked_add(self.anchor_clicked)
129 ab.callback_anchor_hover_opened_add(self.anchor_hover_opened)
130 ab.editable_set(False)
131 ab.text_set(text)
132 ab.anchor_hover_style_set("popup")
133 ab.anchor_hover_parent_set(self.parentwin)
134 bb.part_content_set("default", ab)
135 if avatar:
136 bb.part_content_set("icon", avatar)
137
138 self.message_box.pack_end(bb)
139 bb.show()
140 self.scroll.region_show(0, self.scroll.child_size_get()[1] - 0, 100, 100)
141
142 def anchor_clicked(self, obj, event_info):
143 log.debug("Clicked on anchor %s" % (event_info.name))
144 self.anchor_name = event_info.name
145
146 def anchor_hover_opened(self, obj, event_info):
147 log.debug(event_info)
148 btn = elm.Button(obj)
149 parts = self.anchor_name.partition(":")
150 if parts[0] == "url":
151 btn.text_set("Open in browser")
152 btn.callback_clicked_add(lambda x: webbrowser.open(parts[2]))
153 btn2 = elm.Button(obj)
154 btn2.text_set("Open internally")
155 btn2.callback_clicked_add(self.open_web, parts[2])
156 btn2.callback_clicked_add(lambda x: obj.anchor_hover_end())
157 event_info.hover.part_content_set("top", btn2)
158 btn2.show()
159 elif parts[0] == "mailto":
160 btn.text_set("Send mail")
161 btn.callback_clicked_add(lambda x: webbrowser.open(self.anchor_name))
162 btn.callback_clicked_add(lambda x: obj.anchor_hover_end())
163 btn.show()
164 event_info.hover.part_content_set("middle", btn)
165
166 def open_web(self, obj, url):
167 box = elm.Box(self.parentwin)
168 web = elm.Web(self.parentwin)
169 inwin = elm.InnerWindow(self.parentwin)
170 xbtn = elm.Button(self.parentwin)
171
172 web.size_hint_weight_set(1.0, 1.0)
173 web.size_hint_align_set(-1.0, -1.0)
174
175 web.uri_set(url)
176 xbtn.text_set(_("Close").encode("utf-8"))
177 xbtn.callback_clicked_add(lambda x: inwin.delete())
178
179 box.pack_end(web)
180 box.pack_end(xbtn)
181 inwin.content_set(box)
182
183 web.show()
184 xbtn.show()
185 box.show()
186 inwin.show()
187
188 def chat_state_changed(self, channel, contact, state, *args):
189 ic = elm.Icon(self.parentwin)
190 ic.file_set(os.path.join(IMAGE_PATH, "apathy.png"))
191 ic.size_hint_aspect_set(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)
192
193 states = {
194 Tp.ChannelChatState.GONE: "left the chat",
195 Tp.ChannelChatState.INACTIVE: "has not been active",
196 Tp.ChannelChatState.ACTIVE: "is active",
197 Tp.ChannelChatState.PAUSED: "paused writing message",
198 Tp.ChannelChatState.COMPOSING: "is writing message",
199 }
200 log.debug("%s, %s, %s" % (channel, contact, states[state]))
201 if state == Tp.ChannelChatState.GONE:
202 self.add_bubble("<em>%s %s</em>" % (self.contact.get_alias(), states[state]), time(), self.contact.get_alias(), elm.ELM_BUBBLE_POS_TOP_LEFT, ic)
203 #TODO: chat states
204
205 def entry_event(self, obj, entry, something, event, *args):
206 if event.keyname == "Return" and self.entry_mode.state_get():
207 self.send(entry.entry_get().replace("<br/>", ""))
208 else:
209 if self.chat_state == "composing":
210 self.compose_timer.cancel()
211 elif self.chat_state == "paused":
212 self.pause_timer.cancel()
213 self.compose_timer = Timer(2.0, self.timer_stopped)
214 self.compose_timer.start()
215 if not self.chat_state == "composing":
216 self.channel.set_chat_state_async(Tp.ChannelChatState.COMPOSING, None, None)
217 self.chat_state = "composing"
218 return True
219
220 def paused(self, channel, result, *args):
221 self.pause_timer = Timer(2.0, self.timer_stopped)
222 self.pause_timer.start()
223
224 def timer_stopped(self, *args):
225 if self.chat_state == "composing":
226 self.channel.set_chat_state_async(Tp.ChannelChatState.PAUSED, self.paused, None)
227 self.chat_state = "paused"
228 elif self.chat_state == "paused":
229 self.channel.set_chat_state_async(Tp.ChannelChatState.ACTIVE, None, None)
230 self.chat_state = "active"
231
232 def send_clicked(self, obj, *args):
233 message = self.text_entry.entry_get()
234 self.send(message)
235
236 def send(self, message):
237 if not len(message.replace("<br/>", "\n").strip()) == 0:
238 text = self.text_entry.markup_to_utf8(message)
239 message = Tp.ClientMessage.new_text(Tp.ChannelTextMessageType.NORMAL, text)
240 self.channel.send_message_async(message, 0, lambda a, b, c: 0, None)
241 self.text_entry.entry_set("")
242 self.text_entry.focus_set(True)
243
244 self.compose_timer.cancel()
245 try:
246 self.pause_timer.cancel()
247 except:
248 pass
249 self.channel.set_chat_state_async(Tp.ChannelChatState.ACTIVE, None, None)
250 self.chat_state = "active"
251
252 def message_received(self, channel, message):
253 text, flags = message.to_text()
254 timestamp = message.get_received_timestamp()
255
256 log.debug(text)
257 log.debug(type(text))
258 types = {
259 Tp.ChannelTextMessageType.NORMAL: "Normal message",
260 Tp.ChannelTextMessageType.ACTION: "User action",
261 Tp.ChannelTextMessageType.NOTICE: "Notice",
262 Tp.ChannelTextMessageType.AUTO_REPLY: "Automatically generated reply",
263 Tp.ChannelTextMessageType.DELIVERY_REPORT: "Delivery report"
264 }
265 log.debug(types[message.get_message_type()])
266
267 if message.get_message_type() == Tp.ChannelTextMessageType.DELIVERY_REPORT:
268 channel.ack_message_async(message, lambda a, b, c: 0, None)
269 return
270
271 try:
272 avatar_path = self.contact.get_avatar_file().get_path()
273 except:
274 avatar = None
275 else:
276 avatar = elm.Icon(self.parentwin)
277 avatar.file_set(avatar_path)
278 avatar.size_hint_aspect_set(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1)
279
280 text = parse(self.text_entry.utf8_to_markup(text), urls=False, emotes=self.emotes.state_get())
281 log.debug(text)
282 log.debug(type(text))
283 self.add_bubble(text, timestamp, self.contact.get_alias(), elm.ELM_BUBBLE_POS_TOP_LEFT, avatar)
284
285 if not self.parentwin.focus_get():
286 notify(_("Message from %s").encode("utf-8") % (self.contact.get_alias()), text, "notification-information")
287 set_urgent(self.parentwin, True)
288
289 channel.ack_message_async(message, lambda a, b, c: 0, None)
290
291 def message_sent(self, channel, message, flags, token, *args):
292 text, flags = message.to_text()
293 log.debug(text)
294 timestamp = message.get_sent_timestamp()
295 text = text.replace("\n", "<br/>")
296 text = parse(text, urls=False, emotes=self.emotes.state_get())
297 self.add_bubble(text, timestamp, "You", elm.ELM_BUBBLE_POS_TOP_RIGHT)
298
299 def send_error_cb(self, error, timestamp, type, text):
300 log.debug('Error %d sending message: %s' % (error, text))
diff --git a/apathy/ErrorDialog.py b/apathy/ErrorDialog.py
new file mode 100644
index 0000000..eadec9d
--- /dev/null
+++ b/apathy/ErrorDialog.py
@@ -0,0 +1,58 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24from elementary import *
25
26class ErrorDialog(InnerWindow):
27 def __init__(self, parent, title, *args):
28 InnerWindow.__init__(self, parent)
29 box0 = Box(parent)
30
31 label = Entry(parent)
32 label.editable_set(False)
33 label.text_set(" ".join(args))
34
35 frame = Frame(parent)
36 frame.size_hint_align_set(-1.0, -1.0)
37 frame.text_set(title)
38 frame.content_set(label)
39 box0.pack_end(frame)
40
41 xbtn = Button(parent)
42 xbtn.callback_clicked_add(self._destroy)
43 xbtn.text_set(_("Close").encode("utf-8"))
44 box0.pack_end(xbtn)
45
46 xbtn.show()
47 label.show()
48 frame.show()
49
50 box0.show()
51
52 self.content_set(box0)
53 self.style_set("minimal_vertical")
54
55 self.activate()
56
57 def _destroy(self, *args):
58 self.hide()
diff --git a/apathy/FileTransfer.py b/apathy/FileTransfer.py
new file mode 100644
index 0000000..1c64540
--- /dev/null
+++ b/apathy/FileTransfer.py
@@ -0,0 +1,34 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24from elementary import *
25from evas import EVAS_ASPECT_CONTROL_VERTICAL
26
27from gi.repository import TelepathyGLib as Tp
28
29class FileTransfer(Box):
30 def __init__(self, parent, channel):
31 Box.__init__(self, parent)
32
33 channel.connect("notify::state", self.state_changed)
34
diff --git a/apathy/Globals.py b/apathy/Globals.py
new file mode 100644
index 0000000..89c80bd
--- /dev/null
+++ b/apathy/Globals.py
@@ -0,0 +1,75 @@
1
2#########################################################################
3# #
4# Apathy - A telepathy based communications client for mobile platforms #
5# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
6# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
7# #
8# This program is free software: you can redistribute it and/or modify #
9# it under the terms of the GNU General Public License as published by #
10# the Free Software Foundation, either version 3 of the License, or #
11# (at your option) any later version. #
12# #
13# This program is distributed in the hope that it will be useful, #
14# but WITHOUT ANY WARRANTY; without even the implied warranty of #
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16# GNU General Public License for more details. #
17# #
18# You should have received a copy of the GNU General Public License #
19# along with this program. If not, see <http://www.gnu.org/licenses/>. #
20# #
21#########################################################################
22
23from os import getenv
24import os.path
25import ConfigParser
26
27try:
28 from gi.repository import Notify as LibNotify #clash with elm Notify
29except ImportError:
30 def notify(*args):
31 pass
32else:
33 LibNotify.init("Apathy")
34 def notify(title, msg, importance):
35 n = LibNotify.Notification.new(title, msg, importance)
36 n.set_timeout(3000)
37 n.show()
38
39try:
40 import ecore.x
41except ImportError:
42 def set_urgent(*args):
43 pass
44else:
45 from datetime import datetime
46 def set_urgent(window, urgent):
47 xid = window.xwindow_xid_get()
48 xwin = ecore.x.Window_from_xid(xid)
49 hints = list(xwin.icccm_hints_get())
50 hints[6] = int(urgent) #Urgency hint
51 xwin.icccm_hints_set(*hints)
52
53USER_PATH = getenv("APATHY_USER_PATH")
54IMAGE_PATH = getenv("APATHY_IMAGE_PATH")
55
56if not USER_PATH:
57 USER_PATH = os.path.expanduser(os.path.join("~", ".apathy"))
58if not IMAGE_PATH:
59 IMAGE_PATH = os.path.join(USER_PATH, "images")
60
61def get_conf():
62 conf = ConfigParser.SafeConfigParser()
63 conf_path = os.path.join(USER_PATH, "apathy.conf")
64 if not os.path.exists(USER_PATH):
65 os.mkdir(USER_PATH, 0700)
66 if not os.path.exists(os.path.join(conf_path)):
67 conf.add_section("StatusMessages")
68 conf.set("StatusMessages", "available", "http://launchpad.net/apathy")
69 conf.set("StatusMessages", "away", "http://launchpad.net/apathy")
70 conf.set("StatusMessages", "xa", "http://launchpad.net/apathy")
71 conf.set("StatusMessages", "dnd", "http://launchpad.net/apathy")
72 with open(conf_path, 'wb') as configfile:
73 conf.write(configfile)
74 conf.read(conf_path)
75 return conf
diff --git a/apathy/Handler.py b/apathy/Handler.py
new file mode 100644
index 0000000..d9ea376
--- /dev/null
+++ b/apathy/Handler.py
@@ -0,0 +1,205 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24import os.path
25import gettext
26import logging
27
28import ecore
29import elementary as elm
30from evas import EVAS_ASPECT_CONTROL_VERTICAL
31
32from Globals import *
33from Conversation import Conversation
34
35from gi.repository import GObject
36GObject.threads_init()
37from gi.repository import TelepathyGLib as Tp
38
39class Handler(object):
40 def __init__(self):
41 global log
42 log = logging.getLogger("apathy.handler")
43
44 window = self.window = elm.StandardWindow("handler", "Apathy - Handler")
45 window.callback_delete_request_add(self.quit)
46 window.callback_focus_in_add(lambda x: set_urgent(self.window, False))
47
48 box = elm.Box(window)
49 box.size_hint_weight_set(1.0, 1.0)
50 box.size_hint_align_set(-1.0, -1.0)
51 self.window.resize_object_add(box)
52
53 self.chatlist = chatlist = elm.Hoversel(window)
54 self.chatlist.text_set(_("Channels"))
55 chatlist.size_hint_weight_set(1.0, 0.0)
56 chatlist.size_hint_align_set(-1.0, -1.0)
57 box.pack_end(chatlist)
58 chatlist.show()
59
60 self.pager = pager = elm.Naviframe(window)
61 pager.size_hint_weight_set(1.0, 1.0)
62 pager.size_hint_align_set(-1.0, -1.0)
63 #self.resize_object_add(pager)
64 box.pack_end(pager)
65 pager.show()
66
67 xbtn = elm.Button(window)
68 xbtn.callback_clicked_add(self.close_channel_box)
69 xbtn.text_set(_("Close"))
70 xbtn.size_hint_weight_set(1.0, 0.0)
71 xbtn.size_hint_align_set(-1.0, -1.0)
72 box.pack_end(xbtn)
73 xbtn.show()
74
75 box.show()
76
77 daemon = Tp.DBusDaemon.dup()
78 factory = Tp.AutomaticClientFactory.new(daemon)
79 factory.add_account_features([
80 Tp.Account.get_feature_quark_connection()
81 ])
82 factory.add_connection_features([
83 Tp.Connection.get_feature_quark_capabilities(),
84 Tp.Connection.get_feature_quark_contact_list(),
85 Tp.Connection.get_feature_quark_contact_groups(),
86 Tp.Connection.get_feature_quark_avatar_requirements(),
87 ])
88 factory.add_contact_features([
89 Tp.ContactFeature.ALIAS,
90 Tp.ContactFeature.CONTACT_GROUPS,
91 Tp.ContactFeature.PRESENCE,
92 Tp.ContactFeature.AVATAR_DATA,
93 Tp.ContactFeature.SUBSCRIPTION_STATES,
94 Tp.ContactFeature.CAPABILITIES,
95 Tp.ContactFeature.CONTACT_INFO,
96 Tp.ContactFeature.LOCATION,
97 ])
98 factory.add_channel_features([
99 Tp.Channel.get_feature_quark_contacts(),
100 Tp.Channel.get_feature_quark_chat_states(),
101 Tp.TextChannel.get_feature_quark_incoming_messages(),
102 ])
103
104 self.handler = Tp.SimpleHandler.new_with_factory(
105 factory, #Factory/am/tpdbus
106 False, #bypass approval
107 False, #requests
108 'Apathy.Handler', #name
109 False, #uniquify
110 self.channel_handler, #handler func
111 None, #data
112 )
113 self.handler.add_handler_filter(
114 {
115 Tp.PROP_CHANNEL_CHANNEL_TYPE: Tp.IFACE_CHANNEL_TYPE_TEXT,
116 Tp.PROP_CHANNEL_TARGET_HANDLE_TYPE: int(Tp.HandleType.CONTACT),
117 }
118 )
119 self.handler.add_handler_capabilities([
120 Tp.IFACE_CHANNEL_INTERFACE_MESSAGES,
121 ])
122 self.handler.register()
123
124 def channel_handler(self, handler, account, connection, channels, requests, user_action_time, context, user_data):
125 log.debug("%s %s %s %s %s %s %s %s" % (handler, account, connection, channels, requests, user_action_time, context, user_data))
126 for c in channels:
127 log.debug(c.get_handle())
128
129 box_of_channels = Channels(self, channels)
130 box_of_channels.show()
131
132 identifier = channels[0].get_target_contact().get_alias()
133 if not identifier:
134 identifier = channels[0].get_identifier()
135
136 try:
137 avatar = channels[0].get_target_contact().get_avatar_file().get_path()
138 except:
139 avatar = None
140
141 box_of_channels.list_item = self.chatlist.item_add(identifier, avatar, elm.ELM_ICON_FILE, self.selected, box_of_channels)
142
143 self.pager.item_simple_push(box_of_channels)
144 self.window.resize(480, 640)
145 self.window.show()
146
147 context.accept()
148
149 def selected(self, chatlist, item, pager_item):
150 self.pager.item_simple_promote(pager_item)
151
152 def close_channel_box(self, obj, *args):
153 box_of_channels = self.pager.top_item_get().content_get()
154 try:
155 for channel in box_of_channels.channels:
156 channel.close_async(lambda x, y, z: None, None)
157 self.pager.item_pop()
158 box_of_channels.list_item.delete()
159 del box_of_channels
160 except:
161 pass
162 if not self.pager.top_item_get():
163 self.quit()
164
165 def quit(self, *args):
166 elm.exit()
167
168class Channels(elm.Box):
169 def __init__(self, parent, channels):
170 elm.Box.__init__(self, parent.window)
171 self.channels = []
172 self.list_item = None
173
174 self.size_hint_weight_set(1.0, 1.0)
175 self.size_hint_align_set(-1.0, -1.0)
176
177 for channel in channels:
178 if isinstance(channel, Tp.TextChannel):
179 log.info("Handling text channel with %s" % (channel.get_identifier()))
180 conversation = Conversation(parent, channel)
181 self.pack_end(conversation.box)
182 self.channels.append(channel)
183 else:
184 log.error("Non-supported channel")
185
186if __name__ == "__main__":
187 gettext.install("apathy", "/usr/share/locale", unicode=1)
188
189 # Log
190 if not os.path.exists(USER_PATH):
191 os.mkdir(USER_PATH, 0700)
192 log = logging.getLogger("apathy.handler")
193 log.setLevel(logging.DEBUG)
194 streamformatter = logging.Formatter("[%(levelname)s] in %(module)s line %(lineno)s (%(funcName)s): %(message)s")
195 handler_stream = logging.StreamHandler()
196 handler_stream.setFormatter(streamformatter)
197 log.addHandler(handler_stream)
198
199 elm.init()
200
201 ecore.main_loop_glib_integrate()
202 handler = Handler()
203
204 elm.run()
205 elm.shutdown()
diff --git a/apathy/NewAccount.py b/apathy/NewAccount.py
new file mode 100644
index 0000000..f650c7c
--- /dev/null
+++ b/apathy/NewAccount.py
@@ -0,0 +1,39 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24from elementary import *
25from evas import EVAS_ASPECT_CONTROL_VERTICAL
26
27from Globals import *
28
29from gi.repository import TelepathyGLib as Tp
30
31class NewAccount(InnerWindow):
32 def __init__(self, parent, am):
33 self.parentwin = parent
34 InnerWindow.__init__(self, parent)
35
36 global log
37 log = get_log()
38
39 self.box = box = Box(self)
diff --git a/apathy/NewContact.py b/apathy/NewContact.py
new file mode 100644
index 0000000..3cc3cfc
--- /dev/null
+++ b/apathy/NewContact.py
@@ -0,0 +1,113 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24from elementary import *
25from evas import EVAS_ASPECT_CONTROL_VERTICAL
26
27from Globals import *
28
29from gi.repository import GObject
30GObject.threads_init()
31from gi.repository import TelepathyGLib as Tp
32
33class NewContact(InnerWindow):
34 def __init__(self, parent, am):
35 self.parentwin = parent
36 InnerWindow.__init__(self, parent)
37
38 global log
39 log = get_log()
40
41 self.box = box = Box(self)
42
43 acc_sel = Hoversel(self)
44 acc_sel.text_set(_("Select account"))
45 acc_sel.size_hint_weight_set(1.0, 0.0)
46 acc_sel.size_hint_align_set(-1.0, 0.0)
47 box.pack_end(acc_sel)
48 acc_sel.show()
49
50 self.btn_box = btn_box = Box(self)
51 btn_box.horizontal_set(True)
52 btn_box.size_hint_weight_set(1.0, 0.0)
53 btn_box.size_hint_align_set(-1.0, 0.0)
54 box.pack_end(btn_box)
55 btn_box.show()
56
57 xbtn = Button(self)
58 xbtn.text_set(_("Close"))
59 #xbtn.callback_clicked_add(lambda x: parent.pager.content_pop())
60 xbtn.callback_clicked_add(lambda x: self.delete())
61 btn_box.pack_end(xbtn)
62 xbtn.show()
63
64 self.content_set(box)
65 self.show()
66
67 for account in am.get_valid_accounts():
68 acc_sel.item_add(account.get_display_name(), account.get_icon_name(), ELM_ICON_STANDARD, self.selected, account)
69
70 def selected(self, acc_sel, item, account):
71 frame = Frame(self)
72 frame.text_set("Identifier of contact")
73 frame.size_hint_weight_set(1.0, 0.0)
74 frame.size_hint_align_set(-1.0, 0.0)
75 entry = Entry(self)
76 entry.single_line_set(True)
77 frame.content_set(entry)
78 self.box.pack_before(frame, self.btn_box)
79 entry.show()
80 frame.show()
81
82 go = Button(self)
83 go.callback_clicked_add(self.add_go, entry, account)
84 go.text_set(_("Add"))
85 self.btn_box.pack_end(go)
86 go.show()
87
88 def add_go(self, obj, entry, account):
89 identifier = entry.entry_get()
90 account.request_presence_async(Tp.ConnectionPresenceType.AVAILABLE, "available", "", self.online, identifier)
91
92 def online(self, account, result, identifier, *args):
93 account.get_connection().get_contacts_by_id(
94 (
95 identifier,
96 ),
97 (
98 Tp.ContactFeature.ALIAS,
99 Tp.ContactFeature.CONTACT_GROUPS,
100 Tp.ContactFeature.PRESENCE,
101 Tp.ContactFeature.AVATAR_DATA,
102 Tp.ContactFeature.SUBSCRIPTION_STATES,
103 Tp.ContactFeature.CAPABILITIES,
104 Tp.ContactFeature.CONTACT_INFO,
105 Tp.ContactFeature.LOCATION,
106 ),
107 self.got_contact, None, None)
108
109 def got_contact(self, connection, n_ids, contacts, requested_ids, failed_id_errors, error, user_data, *args):
110 #import os, signal; os.kill(os.getpid(), signal.SIGINT)
111 print("%s %s %s %s %s %s %s %s" % (connection, n_ids, contacts, requested_ids, failed_id_errors, error, user_data, args))
112 for contact in contacts:
113 print("Contact is %s" % contact)
diff --git a/apathy/Parser.py b/apathy/Parser.py
new file mode 100644
index 0000000..145fcf5
--- /dev/null
+++ b/apathy/Parser.py
@@ -0,0 +1,134 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24import re
25
26def parse(text, urls=True, emotes=True):
27 text = text.replace("<br/>", "\n")
28 text = text.replace("&", "&amp;")
29 text = text.replace("<", "&lt;")
30 text = text.replace(">", "&gt;")
31
32 if urls:
33 #URLs
34 p = re.compile(r'(\b\S*://\S*\b)')
35 text = p.sub(r'<a href=url:\1>\1</a>', text)
36
37 #mail
38 p = re.compile(r'(\b(\.|\w)*@\w*(\.|\w)*\b)')
39 text = p.sub(r'<a href=mailto:\1>\1</a>', text)
40
41 if emotes:
42 #emoticons
43 emoticons = {
44 ":)": "happy",
45 ":-)": "happy",
46 ":D": "haha",
47 ":-D": "haha",
48 ";)": "wink",
49 ";-)": "wink",
50 ":-O": "omg",
51 ":P": "tongue-dangling",
52 ":-P": "tongue-dangling",
53 "(H)": "smile",
54 ":@": "",
55 ":$": "",
56 ":S": "",
57 ":(": "sorry",
58 ":'(": "very-sorry",
59 ":|": "",
60 "(6)": "evil",
61 "(A)": "",
62 "(L)": "love",
63 "(U)": "",
64 "(M)": "",
65 "(@)": "",
66 "(&)": "",
67 "(S)": "",
68 "(*)": "",
69 "(~)": "",
70 "(8)": "",
71 "(E)": "",
72 "(F)": "",
73 "(W)": "",
74 "(O)": "",
75 "(K)": "kiss",
76 "(G)": "",
77 "(^)": "",
78 "(P)": "",
79 "(I)": "",
80 "(C)": "",
81 "(T)": "",
82 "({)": "",
83 "(})": "",
84 "(B)": "",
85 "(D)": "",
86 "(Z)": "",
87 "(X)": "",
88 "(Y)": "",
89 "(N)": "",
90 ":[": "",
91 "(nah)": "",
92 "(#)": "",
93 "(R)": "",
94 ":-#": "",
95 "8o|": "",
96 "8-|": "",
97 "^o)": "",
98 ":-*": "",
99 "+o(": "",
100 "(sn)": "",
101 "(tu)": "",
102 "(pl)": "",
103 "(||)": "",
104 "(pi)": "",
105 "(so)": "",
106 "(au)": "",
107 "(ap)": "",
108 "(um)": "",
109 "(ip)": "",
110 "(co)": "",
111 "(mp)": "",
112 "(brb)": "",
113 "(st)": "",
114 "(h5)": "",
115 "(mo)": "",
116 "(bah)": "",
117 ":^)": "",
118 "*-)": "",
119 "(li)": "",
120 "<:o)": "",
121 "8-)": "",
122 "|-)": "",
123 "('.')": "",
124 "(ci)": "",
125 "(%)": "",
126 "(xx)": "",
127 "(yn)": "",
128 }
129 for k, v in emoticons.iteritems():
130 p = re.compile(re.escape(k))
131 text = p.sub(r'<item size=32x32 vsize=full href=emoticon/%s></item>' % v, text)
132
133 text = text.replace("\n", "<br/>")
134 return text
diff --git a/apathy/PresenceEditor.py b/apathy/PresenceEditor.py
new file mode 100644
index 0000000..edb8822
--- /dev/null
+++ b/apathy/PresenceEditor.py
@@ -0,0 +1,85 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24import elementary as elm
25
26from Globals import *
27
28class PresenceEditor(object):
29 def __init__(self, parent, pager):
30 self.parentwin = parent
31 self.pager = pager
32
33 self.entries = {}
34
35 self.conf = get_conf()
36 messages = self.conf.items("StatusMessages")
37
38 self.box = box = elm.Box(parent)
39
40 for status, message in messages:
41 frame = elm.Frame(parent)
42 frame.size_hint_weight_set(1.0, 0.0)
43 frame.size_hint_align_set(-1.0, -1.0)
44 frame.text_set(status.capitalize())
45 self.entries[status] = entry = elm.Entry(parent)
46 entry.size_hint_weight_set(1.0, 1.0)
47 entry.size_hint_align_set(-1.0, -1.0)
48 entry.single_line_set(True)
49 entry.text_set(message)
50 frame.content_set(entry)
51 box.pack_end(frame)
52 entry.show()
53 frame.show()
54
55 box1 = elm.Box(parent)
56 box1.horizontal_set(True)
57 box1.size_hint_weight_set(1.0, 0.0)
58 box1.size_hint_align_set(-1.0, 0.0)
59
60 save_btn = elm.Button(parent)
61 save_btn.size_hint_weight_set(1.0, 0.0)
62 save_btn.size_hint_align_set(-1.0, 0.0)
63 save_btn.text_set(_("Save"))
64 save_btn.callback_clicked_add(self.save)
65 box1.pack_end(save_btn)
66 save_btn.show()
67
68 xbtn = elm.Button(parent)
69 xbtn.size_hint_weight_set(1.0, 0.0)
70 xbtn.size_hint_align_set(-1.0, 0.0)
71 xbtn.text_set(_("Close"))
72 xbtn.callback_clicked_add(lambda x: pager.item_pop())
73 box.pack_end(xbtn)
74 xbtn.show()
75
76 box.pack_end(box1)
77 box.show()
78
79 def save(self, obj, *args):
80 for status, entry in self.entries.iteritems():
81 message = entry.entry_get()
82 self.conf.set("StatusMessages", status, message)
83 with open(conf_path, 'wb') as configfile:
84 self.conf.write(configfile)
85 self.pager.item_pop()
diff --git a/apathy/PresenceWidget.py b/apathy/PresenceWidget.py
new file mode 100644
index 0000000..be00aaa
--- /dev/null
+++ b/apathy/PresenceWidget.py
@@ -0,0 +1,159 @@
1#!/usr/bin/env python
2
3#########################################################################
4# #
5# Apathy - A telepathy based communications client for mobile platforms #
6# Copyright (C) 2009 Michael Sheldon <mike@mikeasoft.com> #
7# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com> #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22#########################################################################
23
24import gettext
25import logging
26
27import ecore
28from elementary import *
29from evas import EVAS_ASPECT_CONTROL_VERTICAL
30
31from Globals import *
32from PresenceEditor import PresenceEditor
33
34from gi.repository import GObject
35GObject.threads_init()
36from gi.repository import TelepathyGLib as Tp
37
38class PresenceWidget(Window):
39 def __init__(self):
40 Window.__init__(self, "presence", ELM_WIN_BASIC)
41
42 global log
43 log = logging.getLogger("apathy.presence")
44
45 self.title_set(_("Apathy - Presence"))
46 self.callback_delete_request_add(self.quit)
47 #self.alpha_set(True)
48
49 bg = Background(self)
50 bg.size_hint_weight_set(1.0, 1.0)
51 self.resize_object_add(bg)
52 bg.show()
53
54 self.presence_list = presence_list = Hoversel(self)
55 presence_list.size_hint_weight_set(1.0, 1.0)
56 presence_list.size_hint_align_set(-1.0, 0.0)
57 self._populate_presence_list()
58
59 box = Box(self)
60 box.size_hint_weight_set(1.0, 1.0)
61 self.resize_object_add(box)
62 box.pack_end(presence_list)
63 box.show()
64 presence_list.show()
65
66 self.resize(300, 400)
67 self.show()
68
69 self.am = am = Tp.AccountManager.dup()
70 factory = am.get_factory()
71 factory.add_account_features([Tp.Account.get_feature_quark_connection()])
72 factory.add_connection_features([
73 Tp.Connection.get_feature_quark_contact_list(),
74 Tp.Connection.get_feature_quark_contact_groups(),
75 Tp.Connection.get_feature_quark_avatar_requirements(),
76 ])
77
78 am.prepare_async(None, self._am_ready, None)
79
80 def _am_ready(self, am, result, error):
81 am.prepare_finish(result)
82 am.connect("most-available-presence-changed", self.presence_changed)
83 presence, status, message = am.get_most_available_presence()
84 self.presence_list.text_set(status.capitalize())
85 ic = Icon(self)
86 ic.standard_set("user-"+status)
87 self.presence_list.content_set(ic)
88
89 def _populate_presence_list(self):
90 presences = {
91 "offline": (1, True, False),
92 "available": (2, True, True),
93 "away": (3, True, True),
94 "xa": (4, True, True),
95 "hidden": (5, True, False),
96 "dnd": (6, True, True),
97 "unknown": (7, False, False),
98 "error": (8, False, False),
99 }
100
101 conf = get_conf()
102
103 for status, spec in presences.iteritems():
104 presence, settable_on_self, can_have_message = spec
105 if settable_on_self:
106 if can_have_message:
107 try:
108 message = conf.get("StatusMessages", status)
109 except:
110 log.exception("Status message for status %s not found in configuration file." % (status))
111 message = ""
112 if status == "xa":
113 icon = "user-away-extended"
114 elif status == "hidden":
115 icon = "user-invisible"
116 elif status == "dnd":
117 icon = "user-busy"
118 else:
119 icon = "user-"+status
120 self.presence_list.item_add(status.capitalize(), icon, ELM_ICON_STANDARD, self._set_presence, presence, status, message)
121
122 #self.presence_list.item_add(_("Edit")+"...", None, 0, self._edit_presences)
123
124 def _set_presence(self, obj, event, presence, status, message=""):
125 self.am.set_all_requested_presences(presence, status, message)
126
127 def _edit_presences(self, obj, event, *args):
128 editor = PresenceEditor(self)
129 self.pager.item_simple_push(editor)
130
131 def presence_changed(self, am, presence, status, message):
132 self.presence_list.text_set(status.capitalize())
133 ic = Icon(self)
134 ic.standard_set("user-"+status)
135 self.presence_list.content_set(ic)
136
137 def quit(self, *args):
138 exit()
139
140if __name__ == "__main__":
141 gettext.install("apathy", "/usr/share/locale", unicode=1)
142
143 # Log
144 if not os.path.exists(USER_PATH):
145 os.mkdir(USER_PATH, 0700)
146 log = logging.getLogger("apathy.presence")
147 log.setLevel(logging.DEBUG)
148 streamformatter = logging.Formatter("[%(levelname)s] in %(module)s line %(lineno)s (%(funcName)s): %(message)s")
149 handler_stream = logging.StreamHandler()
150 handler_stream.setFormatter(streamformatter)
151 log.addHandler(handler_stream)
152
153 init()
154
155 ecore.main_loop_glib_integrate()
156 presence = PresenceWidget()
157
158 run()
159 shutdown()
diff --git a/apathy/__init__.py b/apathy/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apathy/__init__.py
diff --git a/bin/apathy-accounts b/bin/apathy-accounts
new file mode 100755
index 0000000..44cbb24
--- /dev/null
+++ b/bin/apathy-accounts
@@ -0,0 +1,38 @@
1#!/usr/bin/env python
2import os
3import sys
4import logging
5
6import gettext
7import ecore
8import elementary as elm
9
10ENV_PATHS = {"APATHY_IMAGE_PATH" : "/usr/share/apathy/images/"}
11
12#must set variables before importing Globals because it requires them
13for var, path in ENV_PATHS.iteritems():
14 #if it is not already set, set the enviroment variable.
15 os.environ.setdefault(var, path)
16
17import apathy.Accounts as Accounts
18from apathy.Globals import *
19
20gettext.install("apathy", "/usr/share/locale", unicode=1)
21
22# Log
23if not os.path.exists(USER_PATH):
24 os.mkdir(USER_PATH, 0700)
25log = logging.getLogger("apathy.accounts")
26log.setLevel(logging.DEBUG)
27fileformatter = logging.Formatter("[%(created)s] [%(levelname)s] in %(module)s line %(lineno)s (%(funcName)s): %(message)s")
28handler_file = logging.FileHandler(os.path.join(USER_PATH, "apathy-accounts.log"), "w")
29handler_file.setFormatter(fileformatter)
30handler_file.setLevel(logging.ERROR)
31log.addHandler(handler_file)
32
33#Launch the program
34elm.init()
35ecore.main_loop_glib_integrate()
36accounts = Accounts.Accounts()
37elm.run()
38elm.shutdown()
diff --git a/bin/apathy-approver b/bin/apathy-approver
new file mode 100755
index 0000000..223859b
--- /dev/null
+++ b/bin/apathy-approver
@@ -0,0 +1,38 @@
1#!/usr/bin/env python
2import os
3import sys
4import logging
5
6import gettext
7import ecore
8import elementary as elm
9
10ENV_PATHS = {"APATHY_IMAGE_PATH" : "/usr/share/apathy/images/"}
11
12#must set variables before importing Globals because it requires them
13for var, path in ENV_PATHS.iteritems():
14 #if it is not already set, set the enviroment variable.
15 os.environ.setdefault(var, path)
16
17import apathy.Approver as Approver
18from apathy.Globals import *
19
20gettext.install("apathy", "/usr/share/locale", unicode=1)
21
22# Log
23if not os.path.exists(USER_PATH):
24 os.mkdir(USER_PATH, 0700)
25log = logging.getLogger("apathy.approver")
26log.setLevel(logging.DEBUG)
27fileformatter = logging.Formatter("[%(created)s] [%(levelname)s] in %(module)s line %(lineno)s (%(funcName)s): %(message)s")
28handler_file = logging.FileHandler(os.path.join(USER_PATH, "apathy-approver.log"), "w")
29handler_file.setFormatter(fileformatter)
30handler_file.setLevel(logging.ERROR)
31log.addHandler(handler_file)
32
33# Launch the program
34elm.init()
35ecore.main_loop_glib_integrate()
36approver = Approver.Approver()
37elm.run()
38elm.shutdown()
diff --git a/bin/apathy-contacts b/bin/apathy-contacts
new file mode 100755
index 0000000..833caeb
--- /dev/null
+++ b/bin/apathy-contacts
@@ -0,0 +1,38 @@
1#!/usr/bin/env python
2import os
3import sys
4import logging
5
6import gettext
7import ecore
8import elementary as elm
9
10ENV_PATHS = {"APATHY_IMAGE_PATH" : "/usr/share/apathy/images/"}
11
12#must set variables before importing Globals because it requires them
13for var, path in ENV_PATHS.iteritems():
14 #if it is not already set, set the enviroment variable.
15 os.environ.setdefault(var, path)
16
17import apathy.Contacts as Contacts
18from apathy.Globals import *
19
20gettext.install("apathy", "/usr/share/locale", unicode=1)
21
22# Log
23if not os.path.exists(USER_PATH):
24 os.mkdir(USER_PATH, 0700)
25log = logging.getLogger("apathy.contacts")
26log.setLevel(logging.DEBUG)
27fileformatter = logging.Formatter("[%(created)s] [%(levelname)s] in %(module)s line %(lineno)s (%(funcName)s): %(message)s")
28handler_file = logging.FileHandler(os.path.join(USER_PATH, "apathy-contacts.log"), "w")
29handler_file.setFormatter(fileformatter)
30handler_file.setLevel(logging.ERROR)
31log.addHandler(handler_file)
32
33# Launch the program
34elm.init()
35ecore.main_loop_glib_integrate()
36contacts = Contacts.Contacts()
37elm.run()
38elm.shutdown()
diff --git a/bin/apathy-handler b/bin/apathy-handler
new file mode 100755
index 0000000..6fa2583
--- /dev/null
+++ b/bin/apathy-handler
@@ -0,0 +1,38 @@
1#!/usr/bin/env python
2import os
3import sys
4import logging
5
6import gettext
7import ecore
8import elementary as elm
9
10ENV_PATHS = {"APATHY_IMAGE_PATH" : "/usr/share/apathy/images/"}
11
12#must set variables before importing Globals because it requires them
13for var, path in ENV_PATHS.iteritems():
14 #if it is not already set, set the enviroment variable.
15 os.environ.setdefault(var, path)
16
17import apathy.Handler as Handler
18from apathy.Globals import *
19
20gettext.install("apathy", "/usr/share/locale", unicode=1)
21
22# Log
23if not os.path.exists(USER_PATH):
24 os.mkdir(USER_PATH, 0700)
25log = logging.getLogger("apathy.handler")
26log.setLevel(logging.DEBUG)
27fileformatter = logging.Formatter("[%(created)s] [%(levelname)s] in %(module)s line %(lineno)s (%(funcName)s): %(message)s")
28handler_file = logging.FileHandler(os.path.join(USER_PATH, "apathy-handler.log"), "w")
29handler_file.setFormatter(fileformatter)
30handler_file.setLevel(logging.ERROR)
31log.addHandler(handler_file)
32
33#Launch the program
34elm.init()
35ecore.main_loop_glib_integrate()
36handler = Handler.Handler()
37elm.run()
38elm.shutdown()
diff --git a/data/apathy-accounts.desktop.in b/data/apathy-accounts.desktop.in
new file mode 100644
index 0000000..2fb7201
--- /dev/null
+++ b/data/apathy-accounts.desktop.in
@@ -0,0 +1,9 @@
1[Desktop Entry]
2_Name=Apathy - Accounts
3_GenericName=Communications Client
4Exec=apathy-accounts
5Icon=apathy
6Type=Application
7Terminal=false
8Categories=Network;InstantMessaging;
9StartupNotify=true
diff --git a/data/apathy-approver.desktop.in b/data/apathy-approver.desktop.in
new file mode 100644
index 0000000..b77c131
--- /dev/null
+++ b/data/apathy-approver.desktop.in
@@ -0,0 +1,10 @@
1[Desktop Entry]
2Name=Apathy Approver
3GenericName=Communications Client
4Exec=apathy-approver
5Icon=apathy
6Type=Application
7Terminal=false
8Categories=Network;InstantMessaging;
9StartupNotify=true
10NoDisplay=true
diff --git a/data/apathy-contacts.desktop.in b/data/apathy-contacts.desktop.in
new file mode 100644
index 0000000..7050514
--- /dev/null
+++ b/data/apathy-contacts.desktop.in
@@ -0,0 +1,9 @@
1[Desktop Entry]
2_Name=Apathy - Contacts
3_GenericName=Communications Client
4Exec=apathy-contacts
5Icon=apathy
6Type=Application
7Terminal=false
8Categories=Network;InstantMessaging;
9StartupNotify=true
diff --git a/data/apathy-handler.desktop.in b/data/apathy-handler.desktop.in
new file mode 100644
index 0000000..6ed32f2
--- /dev/null
+++ b/data/apathy-handler.desktop.in
@@ -0,0 +1,10 @@
1[Desktop Entry]
2Name=Apathy Handler
3GenericName=Communications Client
4Exec=apathy-handler
5Icon=apathy
6Type=Application
7Terminal=false
8Categories=Network;InstantMessaging;
9StartupNotify=true
10NoDisplay=true
diff --git a/data/icons/128x128/apps/apathy.png b/data/icons/128x128/apps/apathy.png
new file mode 100644
index 0000000..8126339
--- /dev/null
+++ b/data/icons/128x128/apps/apathy.png
Binary files differ
diff --git a/data/icons/16x16/apps/apathy.png b/data/icons/16x16/apps/apathy.png
new file mode 100644
index 0000000..09a7d4d
--- /dev/null
+++ b/data/icons/16x16/apps/apathy.png
Binary files differ
diff --git a/data/icons/192x192/apps/apathy.png b/data/icons/192x192/apps/apathy.png
new file mode 100644
index 0000000..bb2d098
--- /dev/null
+++ b/data/icons/192x192/apps/apathy.png
Binary files differ
diff --git a/data/icons/22x22/apps/apathy.png b/data/icons/22x22/apps/apathy.png
new file mode 100644
index 0000000..d941aff
--- /dev/null
+++ b/data/icons/22x22/apps/apathy.png
Binary files differ
diff --git a/data/icons/24x24/apps/apathy.png b/data/icons/24x24/apps/apathy.png
new file mode 100644
index 0000000..2897492
--- /dev/null
+++ b/data/icons/24x24/apps/apathy.png
Binary files differ
diff --git a/data/icons/256x256/apps/apathy.png b/data/icons/256x256/apps/apathy.png
new file mode 100644
index 0000000..5f1b6b8
--- /dev/null
+++ b/data/icons/256x256/apps/apathy.png
Binary files differ
diff --git a/data/icons/32x32/apps/apathy.png b/data/icons/32x32/apps/apathy.png
new file mode 100644
index 0000000..6396748
--- /dev/null
+++ b/data/icons/32x32/apps/apathy.png
Binary files differ
diff --git a/data/icons/36x36/apps/apathy.png b/data/icons/36x36/apps/apathy.png
new file mode 100644
index 0000000..b7f0601
--- /dev/null
+++ b/data/icons/36x36/apps/apathy.png
Binary files differ
diff --git a/data/icons/48x48/actions/account-new.png b/data/icons/48x48/actions/account-new.png
new file mode 100644
index 0000000..9bd1f8b
--- /dev/null
+++ b/data/icons/48x48/actions/account-new.png
Binary files differ
diff --git a/data/icons/48x48/actions/accounts.png b/data/icons/48x48/actions/accounts.png
new file mode 100644
index 0000000..809ddca
--- /dev/null
+++ b/data/icons/48x48/actions/accounts.png
Binary files differ
diff --git a/data/icons/48x48/actions/apathetic.png b/data/icons/48x48/actions/apathetic.png
new file mode 100644
index 0000000..ae2ef9d
--- /dev/null
+++ b/data/icons/48x48/actions/apathetic.png
Binary files differ
diff --git a/data/icons/48x48/actions/call.png b/data/icons/48x48/actions/call.png
new file mode 100644
index 0000000..17e50da
--- /dev/null
+++ b/data/icons/48x48/actions/call.png
Binary files differ
diff --git a/data/icons/48x48/actions/close.png b/data/icons/48x48/actions/close.png
new file mode 100644
index 0000000..b727d12
--- /dev/null
+++ b/data/icons/48x48/actions/close.png
Binary files differ
diff --git a/data/icons/48x48/actions/contact-new.png b/data/icons/48x48/actions/contact-new.png
new file mode 100644
index 0000000..787979a
--- /dev/null
+++ b/data/icons/48x48/actions/contact-new.png
Binary files differ
diff --git a/data/icons/48x48/actions/contacts.png b/data/icons/48x48/actions/contacts.png
new file mode 100644
index 0000000..df66ec7
--- /dev/null
+++ b/data/icons/48x48/actions/contacts.png
Binary files differ
diff --git a/data/icons/48x48/actions/message.png b/data/icons/48x48/actions/message.png
new file mode 100644
index 0000000..4dc51cf
--- /dev/null
+++ b/data/icons/48x48/actions/message.png
Binary files differ
diff --git a/data/icons/48x48/apps/apathy.png b/data/icons/48x48/apps/apathy.png
new file mode 100644
index 0000000..3b70707
--- /dev/null
+++ b/data/icons/48x48/apps/apathy.png
Binary files differ
diff --git a/data/icons/48x48/apps/im-google-talk.png b/data/icons/48x48/apps/im-google-talk.png
new file mode 100644
index 0000000..de3cc4b
--- /dev/null
+++ b/data/icons/48x48/apps/im-google-talk.png
Binary files differ
diff --git a/data/icons/48x48/apps/im-msn.png b/data/icons/48x48/apps/im-msn.png
new file mode 100644
index 0000000..280882a
--- /dev/null
+++ b/data/icons/48x48/apps/im-msn.png
Binary files differ
diff --git a/data/icons/64x64/apps/apathy.png b/data/icons/64x64/apps/apathy.png
new file mode 100644
index 0000000..2b928ed
--- /dev/null
+++ b/data/icons/64x64/apps/apathy.png
Binary files differ
diff --git a/data/icons/72x72/apps/apathy.png b/data/icons/72x72/apps/apathy.png
new file mode 100644
index 0000000..548cc91
--- /dev/null
+++ b/data/icons/72x72/apps/apathy.png
Binary files differ
diff --git a/data/icons/96x96/apps/apathy.png b/data/icons/96x96/apps/apathy.png
new file mode 100644
index 0000000..2628663
--- /dev/null
+++ b/data/icons/96x96/apps/apathy.png
Binary files differ
diff --git a/data/icons/scalable/apps/apathy.svg b/data/icons/scalable/apps/apathy.svg
new file mode 100644
index 0000000..51f5dd8
--- /dev/null
+++ b/data/icons/scalable/apps/apathy.svg
@@ -0,0 +1,661 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!-- Created with Inkscape (http://www.inkscape.org/) -->
3<svg
4 xmlns:dc="http://purl.org/dc/elements/1.1/"
5 xmlns:cc="http://creativecommons.org/ns#"
6 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
7 xmlns:svg="http://www.w3.org/2000/svg"
8 xmlns="http://www.w3.org/2000/svg"
9 xmlns:xlink="http://www.w3.org/1999/xlink"
10 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12 width="751.56006"
13 height="760.3772"
14 id="svg3246"
15 sodipodi:version="0.32"
16 inkscape:version="0.46"
17 sodipodi:docname="apathy_flyer3.svg"
18 inkscape:output_extension="org.inkscape.output.svg.inkscape"
19 version="1.0"
20 inkscape:export-filename="/home/paul/apathy.png"
21 inkscape:export-xdpi="11.687732"
22 inkscape:export-ydpi="11.687732">
23 <defs
24 id="defs3248">
25 <linearGradient
26 id="linearGradient3361">
27 <stop
28 style="stop-color:#ff0d0d;stop-opacity:1;"
29 offset="0"
30 id="stop3363" />
31 <stop
32 style="stop-color:#ff9797;stop-opacity:1;"
33 offset="1"
34 id="stop3365" />
35 </linearGradient>
36 <linearGradient
37 id="linearGradient3483">
38 <stop
39 style="stop-color:#ffffff;stop-opacity:0.20746888;"
40 offset="0"
41 id="stop3485" />
42 <stop
43 style="stop-color:#ffffff;stop-opacity:0;"
44 offset="1"
45 id="stop3487" />
46 </linearGradient>
47 <linearGradient