summaryrefslogtreecommitdiff
authorconber <conber>2002-06-15 09:46:14 (UTC)
committer conber <conber>2002-06-15 09:46:14 (UTC)
commit7f2eef29708380844922f34f59ba4e9beefbf7c3 (patch) (unidiff)
treef57125fbaabddecc35d6677f1b9e48a4594165d5
parent0acbdd392814589df303b6e50c79d9822e3db27a (diff)
downloadopie-7f2eef29708380844922f34f59ba4e9beefbf7c3.zip
opie-7f2eef29708380844922f34f59ba4e9beefbf7c3.tar.gz
opie-7f2eef29708380844922f34f59ba4e9beefbf7c3.tar.bz2
initial checkin
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--apps/Applications/mail.desktop5
-rw-r--r--noncore/unsupported/mail2/LICENSE504
-rw-r--r--noncore/unsupported/mail2/README23
-rw-r--r--noncore/unsupported/mail2/TODO31
-rw-r--r--noncore/unsupported/mail2/accounteditor.cpp82
-rw-r--r--noncore/unsupported/mail2/accounteditor.h24
-rw-r--r--noncore/unsupported/mail2/accounteditorbase.ui751
-rw-r--r--noncore/unsupported/mail2/addresspicker.cpp117
-rw-r--r--noncore/unsupported/mail2/addresspicker.h24
-rw-r--r--noncore/unsupported/mail2/addresspickerbase.ui86
-rw-r--r--noncore/unsupported/mail2/attachdiag.cpp71
-rw-r--r--noncore/unsupported/mail2/attachdiag.h27
-rw-r--r--noncore/unsupported/mail2/bend/bend.cpp116
-rw-r--r--noncore/unsupported/mail2/bend/bend.h38
-rw-r--r--noncore/unsupported/mail2/bend/bend.pro10
-rw-r--r--noncore/unsupported/mail2/bend/bendimpl.cpp39
-rw-r--r--noncore/unsupported/mail2/bend/bendimpl.h27
-rw-r--r--noncore/unsupported/mail2/composer.cpp215
-rw-r--r--noncore/unsupported/mail2/composer.h52
-rw-r--r--noncore/unsupported/mail2/composerbase.cpp199
-rw-r--r--noncore/unsupported/mail2/composerbase.h55
-rw-r--r--noncore/unsupported/mail2/configdiag.cpp144
-rw-r--r--noncore/unsupported/mail2/configdiag.h48
-rw-r--r--noncore/unsupported/mail2/configdiagbase.ui352
-rw-r--r--noncore/unsupported/mail2/folderwidget.cpp314
-rw-r--r--noncore/unsupported/mail2/folderwidget.h123
-rw-r--r--noncore/unsupported/mail2/libmail/configfile.cpp112
-rw-r--r--noncore/unsupported/mail2/libmail/configfile.h97
-rw-r--r--noncore/unsupported/mail2/libmail/defines.h8
-rw-r--r--noncore/unsupported/mail2/libmail/imapbase.cpp110
-rw-r--r--noncore/unsupported/mail2/libmail/imapbase.h52
-rw-r--r--noncore/unsupported/mail2/libmail/imaphandler.cpp334
-rw-r--r--noncore/unsupported/mail2/libmail/imaphandler.h86
-rw-r--r--noncore/unsupported/mail2/libmail/imapresponse.cpp448
-rw-r--r--noncore/unsupported/mail2/libmail/imapresponse.h531
-rw-r--r--noncore/unsupported/mail2/libmail/libmail.pro26
-rw-r--r--noncore/unsupported/mail2/libmail/mailfactory.cpp173
-rw-r--r--noncore/unsupported/mail2/libmail/mailfactory.h109
-rw-r--r--noncore/unsupported/mail2/libmail/md5.cpp242
-rw-r--r--noncore/unsupported/mail2/libmail/md5.h35
-rw-r--r--noncore/unsupported/mail2/libmail/miscfunctions.cpp295
-rw-r--r--noncore/unsupported/mail2/libmail/miscfunctions.h27
-rw-r--r--noncore/unsupported/mail2/libmail/sharp_char.h241
-rw-r--r--noncore/unsupported/mail2/libmail/smtphandler.cpp172
-rw-r--r--noncore/unsupported/mail2/libmail/smtphandler.h55
-rw-r--r--noncore/unsupported/mail2/libmail/zaurusstuff.cpp38
-rw-r--r--noncore/unsupported/mail2/libmail/zaurusstuff.h23
-rw-r--r--noncore/unsupported/mail2/listviewplus.cpp54
-rw-r--r--noncore/unsupported/mail2/listviewplus.h37
-rw-r--r--noncore/unsupported/mail2/mail.pro48
-rw-r--r--noncore/unsupported/mail2/mailtable.cpp171
-rw-r--r--noncore/unsupported/mail2/mailtable.h121
-rw-r--r--noncore/unsupported/mail2/main.cpp14
-rw-r--r--noncore/unsupported/mail2/mainwindow.cpp65
-rw-r--r--noncore/unsupported/mail2/mainwindow.h24
-rw-r--r--noncore/unsupported/mail2/mainwindowbase.cpp75
-rw-r--r--noncore/unsupported/mail2/mainwindowbase.h35
-rw-r--r--noncore/unsupported/mail2/opendiag.cpp8
-rw-r--r--noncore/unsupported/mail2/opendiag.h16
-rw-r--r--noncore/unsupported/mail2/opendiagbase.ui254
-rw-r--r--noncore/unsupported/mail2/opie-mail2.control9
-rw-r--r--noncore/unsupported/mail2/passdiag.cpp38
-rw-r--r--noncore/unsupported/mail2/passdiag.h21
-rw-r--r--noncore/unsupported/mail2/passdiagbase.ui115
-rw-r--r--noncore/unsupported/mail2/rename.cpp39
-rw-r--r--noncore/unsupported/mail2/rename.h20
-rw-r--r--noncore/unsupported/mail2/renamebase.ui79
-rw-r--r--noncore/unsupported/mail2/searchdiag.cpp128
-rw-r--r--noncore/unsupported/mail2/searchdiag.h32
-rw-r--r--noncore/unsupported/mail2/searchdiagbase.ui179
-rw-r--r--noncore/unsupported/mail2/viewmail.cpp172
-rw-r--r--noncore/unsupported/mail2/viewmail.h65
-rw-r--r--noncore/unsupported/mail2/viewmailbase.cpp65
-rw-r--r--noncore/unsupported/mail2/viewmailbase.h32
-rw-r--r--pics/mail/abort.pngbin0 -> 794 bytes
-rw-r--r--pics/mail/add.pngbin0 -> 393 bytes
-rw-r--r--pics/mail/addbook.pngbin0 -> 533 bytes
-rw-r--r--pics/mail/attach.pngbin0 -> 429 bytes
-rw-r--r--pics/mail/configure.pngbin0 -> 307 bytes
-rw-r--r--pics/mail/delete.pngbin0 -> 382 bytes
-rw-r--r--pics/mail/desktopicon.pngbin0 -> 1021 bytes
-rw-r--r--pics/mail/find.pngbin0 -> 485 bytes
-rw-r--r--pics/mail/folder.pngbin0 -> 357 bytes
-rw-r--r--pics/mail/forward.pngbin0 -> 544 bytes
-rw-r--r--pics/mail/inbox.pngbin0 -> 380 bytes
-rw-r--r--pics/mail/mailchecker.pngbin0 -> 546 bytes
-rw-r--r--pics/mail/newmail.pngbin0 -> 516 bytes
-rw-r--r--pics/mail/remove.pngbin0 -> 379 bytes
-rw-r--r--pics/mail/reply.pngbin0 -> 547 bytes
-rw-r--r--pics/mail/savemail.pngbin0 -> 430 bytes
-rw-r--r--pics/mail/sendall.pngbin0 -> 404 bytes
-rw-r--r--pics/mail/sendmail.pngbin0 -> 495 bytes
-rw-r--r--pics/mail/sendqueue.pngbin0 -> 386 bytes
93 files changed, 8607 insertions, 0 deletions
diff --git a/apps/Applications/mail.desktop b/apps/Applications/mail.desktop
new file mode 100644
index 0000000..efcca33
--- a/dev/null
+++ b/apps/Applications/mail.desktop
@@ -0,0 +1,5 @@
1[Desktop Entry]
2Name=E-Mail
3Exec=mail
4Type=Application
5Icon=mail/desktopicon
diff --git a/noncore/unsupported/mail2/LICENSE b/noncore/unsupported/mail2/LICENSE
new file mode 100644
index 0000000..b1e3f5a
--- a/dev/null
+++ b/noncore/unsupported/mail2/LICENSE
@@ -0,0 +1,504 @@
1 GNU LESSER GENERAL PUBLIC LICENSE
2 Version 2.1, February 1999
3
4 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9[This is the first released version of the Lesser GPL. It also counts
10 as the successor of the GNU Library Public License, version 2, hence
11 the version number 2.1.]
12
13 Preamble
14
15 The licenses for most software are designed to take away your
16freedom to share and change it. By contrast, the GNU General Public
17Licenses are intended to guarantee your freedom to share and change
18free software--to make sure the software is free for all its users.
19
20 This license, the Lesser General Public License, applies to some
21specially designated software packages--typically libraries--of the
22Free Software Foundation and other authors who decide to use it. You
23can use it too, but we suggest you first think carefully about whether
24this license or the ordinary General Public License is the better
25strategy to use in any particular case, based on the explanations below.
26
27 When we speak of free software, we are referring to freedom of use,
28not price. Our General Public Licenses are designed to make sure that
29you have the freedom to distribute copies of free software (and charge
30for this service if you wish); that you receive source code or can get
31it if you want it; that you can change the software and use pieces of
32it in new free programs; and that you are informed that you can do
33these things.
34
35 To protect your rights, we need to make restrictions that forbid
36distributors to deny you these rights or to ask you to surrender these
37rights. These restrictions translate to certain responsibilities for
38you if you distribute copies of the library or if you modify it.
39
40 For example, if you distribute copies of the library, whether gratis
41or for a fee, you must give the recipients all the rights that we gave
42you. You must make sure that they, too, receive or can get the source
43code. If you link other code with the library, you must provide
44complete object files to the recipients, so that they can relink them
45with the library after making changes to the library and recompiling
46it. And you must show them these terms so they know their rights.
47
48 We protect your rights with a two-step method: (1) we copyright the
49library, and (2) we offer you this license, which gives you legal
50permission to copy, distribute and/or modify the library.
51
52 To protect each distributor, we want to make it very clear that
53there is no warranty for the free library. Also, if the library is
54modified by someone else and passed on, the recipients should know
55that what they have is not the original version, so that the original
56author's reputation will not be affected by problems that might be
57introduced by others.
58
59 Finally, software patents pose a constant threat to the existence of
60any free program. We wish to make sure that a company cannot
61effectively restrict the users of a free program by obtaining a
62restrictive license from a patent holder. Therefore, we insist that
63any patent license obtained for a version of the library must be
64consistent with the full freedom of use specified in this license.
65
66 Most GNU software, including some libraries, is covered by the
67ordinary GNU General Public License. This license, the GNU Lesser
68General Public License, applies to certain designated libraries, and
69is quite different from the ordinary General Public License. We use
70this license for certain libraries in order to permit linking those
71libraries into non-free programs.
72
73 When a program is linked with a library, whether statically or using
74a shared library, the combination of the two is legally speaking a
75combined work, a derivative of the original library. The ordinary
76General Public License therefore permits such linking only if the
77entire combination fits its criteria of freedom. The Lesser General
78Public License permits more lax criteria for linking other code with
79the library.
80
81 We call this license the "Lesser" General Public License because it
82does Less to protect the user's freedom than the ordinary General
83Public License. It also provides other free software developers Less
84of an advantage over competing non-free programs. These disadvantages
85are the reason we use the ordinary General Public License for many
86libraries. However, the Lesser license provides advantages in certain
87special circumstances.
88
89 For example, on rare occasions, there may be a special need to
90encourage the widest possible use of a certain library, so that it becomes
91a de-facto standard. To achieve this, non-free programs must be
92allowed to use the library. A more frequent case is that a free
93library does the same job as widely used non-free libraries. In this
94case, there is little to gain by limiting the free library to free
95software only, so we use the Lesser General Public License.
96
97 In other cases, permission to use a particular library in non-free
98programs enables a greater number of people to use a large body of
99free software. For example, permission to use the GNU C Library in
100non-free programs enables many more people to use the whole GNU
101operating system, as well as its variant, the GNU/Linux operating
102system.
103
104 Although the Lesser General Public License is Less protective of the
105users' freedom, it does ensure that the user of a program that is
106linked with the Library has the freedom and the wherewithal to run
107that program using a modified version of the Library.
108
109 The precise terms and conditions for copying, distribution and
110modification follow. Pay close attention to the difference between a
111"work based on the library" and a "work that uses the library". The
112former contains code derived from the library, whereas the latter must
113be combined with the library in order to run.
114
115 GNU LESSER GENERAL PUBLIC LICENSE
116 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117
118 0. This License Agreement applies to any software library or other
119program which contains a notice placed by the copyright holder or
120other authorized party saying it may be distributed under the terms of
121this Lesser General Public License (also called "this License").
122Each licensee is addressed as "you".
123
124 A "library" means a collection of software functions and/or data
125prepared so as to be conveniently linked with application programs
126(which use some of those functions and data) to form executables.
127
128 The "Library", below, refers to any such software library or work
129which has been distributed under these terms. A "work based on the
130Library" means either the Library or any derivative work under
131copyright law: that is to say, a work containing the Library or a
132portion of it, either verbatim or with modifications and/or translated
133straightforwardly into another language. (Hereinafter, translation is
134included without limitation in the term "modification".)
135
136 "Source code" for a work means the preferred form of the work for
137making modifications to it. For a library, complete source code means
138all the source code for all modules it contains, plus any associated
139interface definition files, plus the scripts used to control compilation
140and installation of the library.
141
142 Activities other than copying, distribution and modification are not
143covered by this License; they are outside its scope. The act of
144running a program using the Library is not restricted, and output from
145such a program is covered only if its contents constitute a work based
146on the Library (independent of the use of the Library in a tool for
147writing it). Whether that is true depends on what the Library does
148and what the program that uses the Library does.
149
150 1. You may copy and distribute verbatim copies of the Library's
151complete source code as you receive it, in any medium, provided that
152you conspicuously and appropriately publish on each copy an
153appropriate copyright notice and disclaimer of warranty; keep intact
154all the notices that refer to this License and to the absence of any
155warranty; and distribute a copy of this License along with the
156Library.
157
158 You may charge a fee for the physical act of transferring a copy,
159and you may at your option offer warranty protection in exchange for a
160fee.
161
162 2. You may modify your copy or copies of the Library or any portion
163of it, thus forming a work based on the Library, and copy and
164distribute such modifications or work under the terms of Section 1
165above, provided that you also meet all of these conditions:
166
167 a) The modified work must itself be a software library.
168
169 b) You must cause the files modified to carry prominent notices
170 stating that you changed the files and the date of any change.
171
172 c) You must cause the whole of the work to be licensed at no
173 charge to all third parties under the terms of this License.
174
175 d) If a facility in the modified Library refers to a function or a
176 table of data to be supplied by an application program that uses
177 the facility, other than as an argument passed when the facility
178 is invoked, then you must make a good faith effort to ensure that,
179 in the event an application does not supply such function or
180 table, the facility still operates, and performs whatever part of
181 its purpose remains meaningful.
182
183 (For example, a function in a library to compute square roots has
184 a purpose that is entirely well-defined independent of the
185 application. Therefore, Subsection 2d requires that any
186 application-supplied function or table used by this function must
187 be optional: if the application does not supply it, the square
188 root function must still compute square roots.)
189
190These requirements apply to the modified work as a whole. If
191identifiable sections of that work are not derived from the Library,
192and can be reasonably considered independent and separate works in
193themselves, then this License, and its terms, do not apply to those
194sections when you distribute them as separate works. But when you
195distribute the same sections as part of a whole which is a work based
196on the Library, the distribution of the whole must be on the terms of
197this License, whose permissions for other licensees extend to the
198entire whole, and thus to each and every part regardless of who wrote
199it.
200
201Thus, it is not the intent of this section to claim rights or contest
202your rights to work written entirely by you; rather, the intent is to
203exercise the right to control the distribution of derivative or
204collective works based on the Library.
205
206In addition, mere aggregation of another work not based on the Library
207with the Library (or with a work based on the Library) on a volume of
208a storage or distribution medium does not bring the other work under
209the scope of this License.
210
211 3. You may opt to apply the terms of the ordinary GNU General Public
212License instead of this License to a given copy of the Library. To do
213this, you must alter all the notices that refer to this License, so
214that they refer to the ordinary GNU General Public License, version 2,
215instead of to this License. (If a newer version than version 2 of the
216ordinary GNU General Public License has appeared, then you can specify
217that version instead if you wish.) Do not make any other change in
218these notices.
219
220 Once this change is made in a given copy, it is irreversible for
221that copy, so the ordinary GNU General Public License applies to all
222subsequent copies and derivative works made from that copy.
223
224 This option is useful when you wish to copy part of the code of
225the Library into a program that is not a library.
226
227 4. You may copy and distribute the Library (or a portion or
228derivative of it, under Section 2) in object code or executable form
229under the terms of Sections 1 and 2 above provided that you accompany
230it with the complete corresponding machine-readable source code, which
231must be distributed under the terms of Sections 1 and 2 above on a
232medium customarily used for software interchange.
233
234 If distribution of object code is made by offering access to copy
235from a designated place, then offering equivalent access to copy the
236source code from the same place satisfies the requirement to
237distribute the source code, even though third parties are not
238compelled to copy the source along with the object code.
239
240 5. A program that contains no derivative of any portion of the
241Library, but is designed to work with the Library by being compiled or
242linked with it, is called a "work that uses the Library". Such a
243work, in isolation, is not a derivative work of the Library, and
244therefore falls outside the scope of this License.
245
246 However, linking a "work that uses the Library" with the Library
247creates an executable that is a derivative of the Library (because it
248contains portions of the Library), rather than a "work that uses the
249library". The executable is therefore covered by this License.
250Section 6 states terms for distribution of such executables.
251
252 When a "work that uses the Library" uses material from a header file
253that is part of the Library, the object code for the work may be a
254derivative work of the Library even though the source code is not.
255Whether this is true is especially significant if the work can be
256linked without the Library, or if the work is itself a library. The
257threshold for this to be true is not precisely defined by law.
258
259 If such an object file uses only numerical parameters, data
260structure layouts and accessors, and small macros and small inline
261functions (ten lines or less in length), then the use of the object
262file is unrestricted, regardless of whether it is legally a derivative
263work. (Executables containing this object code plus portions of the
264Library will still fall under Section 6.)
265
266 Otherwise, if the work is a derivative of the Library, you may
267distribute the object code for the work under the terms of Section 6.
268Any executables containing that work also fall under Section 6,
269whether or not they are linked directly with the Library itself.
270
271 6. As an exception to the Sections above, you may also combine or
272link a "work that uses the Library" with the Library to produce a
273work containing portions of the Library, and distribute that work
274under terms of your choice, provided that the terms permit
275modification of the work for the customer's own use and reverse
276engineering for debugging such modifications.
277
278 You must give prominent notice with each copy of the work that the
279Library is used in it and that the Library and its use are covered by
280this License. You must supply a copy of this License. If the work
281during execution displays copyright notices, you must include the
282copyright notice for the Library among them, as well as a reference
283directing the user to the copy of this License. Also, you must do one
284of these things:
285
286 a) Accompany the work with the complete corresponding
287 machine-readable source code for the Library including whatever
288 changes were used in the work (which must be distributed under
289 Sections 1 and 2 above); and, if the work is an executable linked
290 with the Library, with the complete machine-readable "work that
291 uses the Library", as object code and/or source code, so that the
292 user can modify the Library and then relink to produce a modified
293 executable containing the modified Library. (It is understood
294 that the user who changes the contents of definitions files in the
295 Library will not necessarily be able to recompile the application
296 to use the modified definitions.)
297
298 b) Use a suitable shared library mechanism for linking with the
299 Library. A suitable mechanism is one that (1) uses at run time a
300 copy of the library already present on the user's computer system,
301 rather than copying library functions into the executable, and (2)
302 will operate properly with a modified version of the library, if
303 the user installs one, as long as the modified version is
304 interface-compatible with the version that the work was made with.
305
306 c) Accompany the work with a written offer, valid for at
307 least three years, to give the same user the materials
308 specified in Subsection 6a, above, for a charge no more
309 than the cost of performing this distribution.
310
311 d) If distribution of the work is made by offering access to copy
312 from a designated place, offer equivalent access to copy the above
313 specified materials from the same place.
314
315 e) Verify that the user has already received a copy of these
316 materials or that you have already sent this user a copy.
317
318 For an executable, the required form of the "work that uses the
319Library" must include any data and utility programs needed for
320reproducing the executable from it. However, as a special exception,
321the materials to be distributed need not include anything that is
322normally distributed (in either source or binary form) with the major
323components (compiler, kernel, and so on) of the operating system on
324which the executable runs, unless that component itself accompanies
325the executable.
326
327 It may happen that this requirement contradicts the license
328restrictions of other proprietary libraries that do not normally
329accompany the operating system. Such a contradiction means you cannot
330use both them and the Library together in an executable that you
331distribute.
332
333 7. You may place library facilities that are a work based on the
334Library side-by-side in a single library together with other library
335facilities not covered by this License, and distribute such a combined
336library, provided that the separate distribution of the work based on
337the Library and of the other library facilities is otherwise
338permitted, and provided that you do these two things:
339
340 a) Accompany the combined library with a copy of the same work
341 based on the Library, uncombined with any other library
342 facilities. This must be distributed under the terms of the
343 Sections above.
344
345 b) Give prominent notice with the combined library of the fact
346 that part of it is a work based on the Library, and explaining
347 where to find the accompanying uncombined form of the same work.
348
349 8. You may not copy, modify, sublicense, link with, or distribute
350the Library except as expressly provided under this License. Any
351attempt otherwise to copy, modify, sublicense, link with, or
352distribute the Library is void, and will automatically terminate your
353rights under this License. However, parties who have received copies,
354or rights, from you under this License will not have their licenses
355terminated so long as such parties remain in full compliance.
356
357 9. You are not required to accept this License, since you have not
358signed it. However, nothing else grants you permission to modify or
359distribute the Library or its derivative works. These actions are
360prohibited by law if you do not accept this License. Therefore, by
361modifying or distributing the Library (or any work based on the
362Library), you indicate your acceptance of this License to do so, and
363all its terms and conditions for copying, distributing or modifying
364the Library or works based on it.
365
366 10. Each time you redistribute the Library (or any work based on the
367Library), the recipient automatically receives a license from the
368original licensor to copy, distribute, link with or modify the Library
369subject to these terms and conditions. You may not impose any further
370restrictions on the recipients' exercise of the rights granted herein.
371You are not responsible for enforcing compliance by third parties with
372this License.
373
374 11. If, as a consequence of a court judgment or allegation of patent
375infringement or for any other reason (not limited to patent issues),
376conditions are imposed on you (whether by court order, agreement or
377otherwise) that contradict the conditions of this License, they do not
378excuse you from the conditions of this License. If you cannot
379distribute so as to satisfy simultaneously your obligations under this
380License and any other pertinent obligations, then as a consequence you
381may not distribute the Library at all. For example, if a patent
382license would not permit royalty-free redistribution of the Library by
383all those who receive copies directly or indirectly through you, then
384the only way you could satisfy both it and this License would be to
385refrain entirely from distribution of the Library.
386
387If any portion of this section is held invalid or unenforceable under any
388particular circumstance, the balance of the section is intended to apply,
389and the section as a whole is intended to apply in other circumstances.
390
391It is not the purpose of this section to induce you to infringe any
392patents or other property right claims or to contest validity of any
393such claims; this section has the sole purpose of protecting the
394integrity of the free software distribution system which is
395implemented by public license practices. Many people have made
396generous contributions to the wide range of software distributed
397through that system in reliance on consistent application of that
398system; it is up to the author/donor to decide if he or she is willing
399to distribute software through any other system and a licensee cannot
400impose that choice.
401
402This section is intended to make thoroughly clear what is believed to
403be a consequence of the rest of this License.
404
405 12. If the distribution and/or use of the Library is restricted in
406certain countries either by patents or by copyrighted interfaces, the
407original copyright holder who places the Library under this License may add
408an explicit geographical distribution limitation excluding those countries,
409so that distribution is permitted only in or among countries not thus
410excluded. In such case, this License incorporates the limitation as if
411written in the body of this License.
412
413 13. The Free Software Foundation may publish revised and/or new
414versions of the Lesser General Public License from time to time.
415Such new versions will be similar in spirit to the present version,
416but may differ in detail to address new problems or concerns.
417
418Each version is given a distinguishing version number. If the Library
419specifies a version number of this License which applies to it and
420"any later version", you have the option of following the terms and
421conditions either of that version or of any later version published by
422the Free Software Foundation. If the Library does not specify a
423license version number, you may choose any version ever published by
424the Free Software Foundation.
425
426 14. If you wish to incorporate parts of the Library into other free
427programs whose distribution conditions are incompatible with these,
428write to the author to ask for permission. For software which is
429copyrighted by the Free Software Foundation, write to the Free
430Software Foundation; we sometimes make exceptions for this. Our
431decision will be guided by the two goals of preserving the free status
432of all derivatives of our free software and of promoting the sharing
433and reuse of software generally.
434
435 NO WARRANTY
436
437 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446
447 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456DAMAGES.
457
458 END OF TERMS AND CONDITIONS
459
460 How to Apply These Terms to Your New Libraries
461
462 If you develop a new library, and you want it to be of the greatest
463possible use to the public, we recommend making it free software that
464everyone can redistribute and change. You can do so by permitting
465redistribution under these terms (or, alternatively, under the terms of the
466ordinary General Public License).
467
468 To apply these terms, attach the following notices to the library. It is
469safest to attach them to the start of each source file to most effectively
470convey the exclusion of warranty; and each file should have at least the
471"copyright" line and a pointer to where the full notice is found.
472
473 <one line to give the library's name and a brief idea of what it does.>
474 Copyright (C) <year> <name of author>
475
476 This library is free software; you can redistribute it and/or
477 modify it under the terms of the GNU Lesser General Public
478 License as published by the Free Software Foundation; either
479 version 2.1 of the License, or (at your option) any later version.
480
481 This library is distributed in the hope that it will be useful,
482 but WITHOUT ANY WARRANTY; without even the implied warranty of
483 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484 Lesser General Public License for more details.
485
486 You should have received a copy of the GNU Lesser General Public
487 License along with this library; if not, write to the Free Software
488 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
489
490Also add information on how to contact you by electronic and paper mail.
491
492You should also get your employer (if you work as a programmer) or your
493school, if any, to sign a "copyright disclaimer" for the library, if
494necessary. Here is a sample; alter the names:
495
496 Yoyodyne, Inc., hereby disclaims all copyright interest in the
497 library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498
499 <signature of Ty Coon>, 1 April 1990
500 Ty Coon, President of Vice
501
502That's all there is to it!
503
504
diff --git a/noncore/unsupported/mail2/README b/noncore/unsupported/mail2/README
new file mode 100644
index 0000000..85fc951
--- a/dev/null
+++ b/noncore/unsupported/mail2/README
@@ -0,0 +1,23 @@
1Mail README
2-----------------------------------------------------------------------------
3
4!! !! !! !! !!
5This program does not yet work. You can send email, but IMAP inbox viewing
6isn't posible due some bugs. Please don't complain. If you want to send mail,
7look for another program (Which does not exist yet.)
8!! !! !! !! !!
9
10About:
11Mail is divided into three parts: libmail, mail and bend.
12libmail is a library containing all classes needed both by mail and
13bend. This includes for example the IMAP classes, the plugin structure, and
14configfile management.
15mail is the mailer itself. You could say it is a gui to libmail.
16bend is the messagenotifier tool. It runs as an applet in the Opie taskbar.
17
18Compilation:
19To compile, you have to set $QTDIR and $TMAKEPATH to the appropriate
20directories. Then simply make in the toplevel directory of the distribution.
21
22Have fun, Constantin <cbergemann@lisa.de>.
23
diff --git a/noncore/unsupported/mail2/TODO b/noncore/unsupported/mail2/TODO
new file mode 100644
index 0000000..ef596dc
--- a/dev/null
+++ b/noncore/unsupported/mail2/TODO
@@ -0,0 +1,31 @@
1LISAmail TODO
2-----------------------------------------------------------------------------
3
4General stuff:
5 - If password is empty, ask for it during fetch.
6 - Check if all necessary fields in AccoundEditor are filled.
7
8Protocol related:
9 - The IMAP implentation is kinda strange and slow.
10 - The SMTP implentation is goddamn strange.
11 - POP3 support would be nice.
12 - NNTP would be kinda neat, too.
13 - Implent a plugin system.
14
15Security related:
16 - GnuPG support. This will require a seperate gpg managing utility in
17 the settings tab.
18 - sMIME? maybe in the distant future.
19
20Mail management:
21 - Header caching
22 - Sieve filtering support?
23 - Enqueueing/Draft support both on the IMAP server and local.
24
25Testing:
26 I'm using the courier-imap server at my developement site. I didn't have
27 much opportunity to test on other servers. Giving me test-accounts on other
28 servers would be helpfull.
29
30If you want something added, drop a mail. Comments are allways welcome.
31
diff --git a/noncore/unsupported/mail2/accounteditor.cpp b/noncore/unsupported/mail2/accounteditor.cpp
new file mode 100644
index 0000000..8230a69
--- a/dev/null
+++ b/noncore/unsupported/mail2/accounteditor.cpp
@@ -0,0 +1,82 @@
1#include <qmultilineedit.h>
2#include <qbuttongroup.h>
3#include <qradiobutton.h>
4#include <qmessagebox.h>
5#include <qtabwidget.h>
6#include <qlineedit.h>
7#include <qcheckbox.h>
8
9#include "accounteditor.h"
10#include "miscfunctions.h"
11
12AccountEditor::AccountEditor(Account account, QWidget *parent, const char *name, bool modal, WFlags fl)
13 : AccountEditorBase(parent, name, modal, fl), _account(account)
14{
15 TabWidget2->removePage(sslTab);
16
17 fillValues();
18}
19
20void AccountEditor::accept()
21{
22 int numLf = 0;
23 for (unsigned int i = 0; i <= signature->text().length(); i++) {
24 if (signature->text()[i] == '\n') numLf++;
25 }
26 if (numLf >= 4) {
27 int ret = QMessageBox::warning(this, tr("Warning"), tr("<p>Your signature is longer than 4 lines. This is considered inpolite by many people. You should shorten your signature.</p>"), tr("Change"), tr("Continue"));
28 if (ret == 0) return;
29 }
30
31 _account.setAccountName(_account.accountName() ? _account.accountName() : MiscFunctions::uniqueString());
32 _account.setRealName(realname->text());
33 _account.setEmail(email->text());
34 _account.setOrg(org->text());
35 _account.setImapServer(imapServer->text());
36 _account.setImapPort(imapPort->text());
37 _account.setSmtpServer(smtpServer->text());
38 _account.setSmtpPort(smtpPort->text());
39 _account.setUser(user->text());
40 _account.setPass(pass->text());
41 _account.setSmtpSsl(smtpssl->isChecked());
42 _account.setSmtpSslPort(smtpsPort->text());
43 _account.setImapSsl(imapssl->isChecked());
44 _account.setImapSslPort(imapsPort->text());
45 _account.setDefaultCc(addCc->isChecked());
46 _account.setDefaultBcc(addBcc->isChecked());
47 _account.setDefaultReplyTo(addReplyTo->isChecked());
48 _account.setCc(cc->text());
49 _account.setBcc(bcc->text());
50 _account.setReplyTo(replyTo->text());
51 _account.setSignature(signature->text());
52
53 QDialog::accept();
54}
55
56void AccountEditor::fillValues()
57{
58 realname->setText(_account.realName());
59 email->setText(_account.email());
60 org->setText(_account.org());
61 imapServer->setText(_account.imapServer());
62 imapPort->setText(!_account.imapPort().isEmpty() ? _account.imapPort() : QString("143"));
63 smtpServer->setText(_account.smtpServer());
64 smtpPort->setText(!_account.smtpPort().isEmpty() ? _account.smtpPort() : QString("25"));
65 user->setText(_account.user());
66 pass->setText(_account.pass());
67 smtpssl->setChecked(_account.smtpSsl());
68 smtpsPort->setText(_account.smtpSslPort());
69 imapssl->setChecked(_account.imapSsl());
70 imapsPort->setText(!_account.imapSslPort().isEmpty() ? _account.imapSslPort() : QString("993"));
71 addCc->setChecked(_account.defaultCc());
72 if (_account.defaultCc()) cc->setEnabled(true);
73 addBcc->setChecked(_account.defaultBcc());
74 if (_account.defaultBcc()) bcc->setEnabled(true);
75 addReplyTo->setChecked(_account.defaultReplyTo());
76 if (_account.defaultReplyTo()) replyTo->setEnabled(true);
77 cc->setText(_account.cc());
78 bcc->setText(_account.bcc());
79 replyTo->setText(_account.replyTo());
80 signature->setText(_account.signature());
81}
82
diff --git a/noncore/unsupported/mail2/accounteditor.h b/noncore/unsupported/mail2/accounteditor.h
new file mode 100644
index 0000000..4a2bda3
--- a/dev/null
+++ b/noncore/unsupported/mail2/accounteditor.h
@@ -0,0 +1,24 @@
1#ifndef ACCOUNTEDITOR_H
2#define ACCOUNTEDITOR_H
3
4#include "accounteditorbase.h"
5#include "configfile.h"
6
7class AccountEditor : public AccountEditorBase
8{
9 Q_OBJECT
10
11public:
12 AccountEditor(Account account = Account(), QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags fl = 0);
13
14 Account _account;
15
16protected slots:
17 void accept();
18
19protected:
20 void fillValues();
21
22};
23
24#endif
diff --git a/noncore/unsupported/mail2/accounteditorbase.ui b/noncore/unsupported/mail2/accounteditorbase.ui
new file mode 100644
index 0000000..fe9f2a4
--- a/dev/null
+++ b/noncore/unsupported/mail2/accounteditorbase.ui
@@ -0,0 +1,751 @@
1<!DOCTYPE UI><UI>
2<class>AccountEditorBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>AccountEditorBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>243</width>
15 <height>320</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Account Editor</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <grid>
29 <property stdset="1">
30 <name>margin</name>
31 <number>0</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>0</number>
36 </property>
37 <widget row="0" column="0" >
38 <class>QTabWidget</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>TabWidget2</cstring>
42 </property>
43 <property>
44 <name>layoutMargin</name>
45 </property>
46 <property>
47 <name>layoutSpacing</name>
48 </property>
49 <widget>
50 <class>QWidget</class>
51 <property stdset="1">
52 <name>name</name>
53 <cstring>tab</cstring>
54 </property>
55 <attribute>
56 <name>title</name>
57 <string>Server</string>
58 </attribute>
59 <grid>
60 <property stdset="1">
61 <name>margin</name>
62 <number>4</number>
63 </property>
64 <property stdset="1">
65 <name>spacing</name>
66 <number>3</number>
67 </property>
68 <widget row="0" column="0" >
69 <class>QLabel</class>
70 <property stdset="1">
71 <name>name</name>
72 <cstring>TextLabel2</cstring>
73 </property>
74 <property stdset="1">
75 <name>text</name>
76 <string>&lt;b&gt;IMAP:</string>
77 </property>
78 </widget>
79 <widget row="0" column="1" >
80 <class>QLineEdit</class>
81 <property stdset="1">
82 <name>name</name>
83 <cstring>imapServer</cstring>
84 </property>
85 </widget>
86 <widget row="1" column="0" >
87 <class>QLabel</class>
88 <property stdset="1">
89 <name>name</name>
90 <cstring>TextLabel3</cstring>
91 </property>
92 <property stdset="1">
93 <name>text</name>
94 <string>&lt;b&gt;Port:</string>
95 </property>
96 </widget>
97 <widget row="1" column="1" >
98 <class>QLineEdit</class>
99 <property stdset="1">
100 <name>name</name>
101 <cstring>imapPort</cstring>
102 </property>
103 </widget>
104 <spacer row="8" column="1" >
105 <property>
106 <name>name</name>
107 <cstring>Spacer2</cstring>
108 </property>
109 <property stdset="1">
110 <name>orientation</name>
111 <enum>Vertical</enum>
112 </property>
113 <property stdset="1">
114 <name>sizeType</name>
115 <enum>Expanding</enum>
116 </property>
117 <property>
118 <name>sizeHint</name>
119 <size>
120 <width>20</width>
121 <height>20</height>
122 </size>
123 </property>
124 </spacer>
125 <widget row="7" column="1" >
126 <class>QLineEdit</class>
127 <property stdset="1">
128 <name>name</name>
129 <cstring>smtpPort</cstring>
130 </property>
131 </widget>
132 <widget row="6" column="1" >
133 <class>QLineEdit</class>
134 <property stdset="1">
135 <name>name</name>
136 <cstring>smtpServer</cstring>
137 </property>
138 </widget>
139 <widget row="6" column="0" >
140 <class>QLabel</class>
141 <property stdset="1">
142 <name>name</name>
143 <cstring>TextLabel6</cstring>
144 </property>
145 <property stdset="1">
146 <name>text</name>
147 <string>&lt;b&gt;SMTP:</string>
148 </property>
149 </widget>
150 <widget row="7" column="0" >
151 <class>QLabel</class>
152 <property stdset="1">
153 <name>name</name>
154 <cstring>TextLabel7</cstring>
155 </property>
156 <property stdset="1">
157 <name>text</name>
158 <string>&lt;b&gt;Port:</string>
159 </property>
160 </widget>
161 <widget row="3" column="0" >
162 <class>QLabel</class>
163 <property stdset="1">
164 <name>name</name>
165 <cstring>TextLabel4</cstring>
166 </property>
167 <property stdset="1">
168 <name>text</name>
169 <string>&lt;b&gt;User:</string>
170 </property>
171 </widget>
172 <widget row="4" column="0" >
173 <class>QLabel</class>
174 <property stdset="1">
175 <name>name</name>
176 <cstring>TextLabel5</cstring>
177 </property>
178 <property stdset="1">
179 <name>text</name>
180 <string>&lt;b&gt;Pass:</string>
181 </property>
182 </widget>
183 <widget row="4" column="1" >
184 <class>QLineEdit</class>
185 <property stdset="1">
186 <name>name</name>
187 <cstring>pass</cstring>
188 </property>
189 <property stdset="1">
190 <name>echoMode</name>
191 <enum>Password</enum>
192 </property>
193 </widget>
194 <widget row="3" column="1" >
195 <class>QLineEdit</class>
196 <property stdset="1">
197 <name>name</name>
198 <cstring>user</cstring>
199 </property>
200 </widget>
201 <widget row="2" column="0" rowspan="1" colspan="2" >
202 <class>Line</class>
203 <property stdset="1">
204 <name>name</name>
205 <cstring>Line1</cstring>
206 </property>
207 <property stdset="1">
208 <name>orientation</name>
209 <enum>Horizontal</enum>
210 </property>
211 </widget>
212 <widget row="5" column="0" rowspan="1" colspan="2" >
213 <class>Line</class>
214 <property stdset="1">
215 <name>name</name>
216 <cstring>Line2</cstring>
217 </property>
218 <property stdset="1">
219 <name>orientation</name>
220 <enum>Horizontal</enum>
221 </property>
222 </widget>
223 </grid>
224 </widget>
225 <widget>
226 <class>QWidget</class>
227 <property stdset="1">
228 <name>name</name>
229 <cstring>tab</cstring>
230 </property>
231 <attribute>
232 <name>title</name>
233 <string>Identity</string>
234 </attribute>
235 <grid>
236 <property stdset="1">
237 <name>margin</name>
238 <number>4</number>
239 </property>
240 <property stdset="1">
241 <name>spacing</name>
242 <number>3</number>
243 </property>
244 <widget row="0" column="0" >
245 <class>QLabel</class>
246 <property stdset="1">
247 <name>name</name>
248 <cstring>TextLabel8</cstring>
249 </property>
250 <property stdset="1">
251 <name>text</name>
252 <string>&lt;b&gt;Name:</string>
253 </property>
254 </widget>
255 <widget row="0" column="1" >
256 <class>QLineEdit</class>
257 <property stdset="1">
258 <name>name</name>
259 <cstring>realname</cstring>
260 </property>
261 </widget>
262 <widget row="1" column="1" >
263 <class>QLineEdit</class>
264 <property stdset="1">
265 <name>name</name>
266 <cstring>email</cstring>
267 </property>
268 </widget>
269 <widget row="1" column="0" >
270 <class>QLabel</class>
271 <property stdset="1">
272 <name>name</name>
273 <cstring>TextLabel9</cstring>
274 </property>
275 <property stdset="1">
276 <name>text</name>
277 <string>&lt;b&gt;E-Mail:</string>
278 </property>
279 </widget>
280 <widget row="2" column="0" >
281 <class>QLabel</class>
282 <property stdset="1">
283 <name>name</name>
284 <cstring>TextLabel10</cstring>
285 </property>
286 <property stdset="1">
287 <name>text</name>
288 <string>&lt;b&gt;Org:</string>
289 </property>
290 </widget>
291 <widget row="2" column="1" >
292 <class>QLineEdit</class>
293 <property stdset="1">
294 <name>name</name>
295 <cstring>org</cstring>
296 </property>
297 </widget>
298 <spacer row="3" column="1" >
299 <property>
300 <name>name</name>
301 <cstring>Spacer1</cstring>
302 </property>
303 <property stdset="1">
304 <name>orientation</name>
305 <enum>Vertical</enum>
306 </property>
307 <property stdset="1">
308 <name>sizeType</name>
309 <enum>Expanding</enum>
310 </property>
311 <property>
312 <name>sizeHint</name>
313 <size>
314 <width>20</width>
315 <height>20</height>
316 </size>
317 </property>
318 </spacer>
319 </grid>
320 </widget>
321 <widget>
322 <class>QWidget</class>
323 <property stdset="1">
324 <name>name</name>
325 <cstring>tab</cstring>
326 </property>
327 <attribute>
328 <name>title</name>
329 <string>Advanced</string>
330 </attribute>
331 <grid>
332 <property stdset="1">
333 <name>margin</name>
334 <number>4</number>
335 </property>
336 <property stdset="1">
337 <name>spacing</name>
338 <number>3</number>
339 </property>
340 <widget row="0" column="0" >
341 <class>QCheckBox</class>
342 <property stdset="1">
343 <name>name</name>
344 <cstring>addCc</cstring>
345 </property>
346 <property stdset="1">
347 <name>text</name>
348 <string>Cc</string>
349 </property>
350 </widget>
351 <widget row="1" column="0" >
352 <class>QCheckBox</class>
353 <property stdset="1">
354 <name>name</name>
355 <cstring>addBcc</cstring>
356 </property>
357 <property stdset="1">
358 <name>text</name>
359 <string>Bcc</string>
360 </property>
361 </widget>
362 <widget row="2" column="0" >
363 <class>QCheckBox</class>
364 <property stdset="1">
365 <name>name</name>
366 <cstring>addReplyTo</cstring>
367 </property>
368 <property stdset="1">
369 <name>text</name>
370 <string>Reply-To</string>
371 </property>
372 </widget>
373 <widget row="2" column="1" >
374 <class>QLineEdit</class>
375 <property stdset="1">
376 <name>name</name>
377 <cstring>replyTo</cstring>
378 </property>
379 <property stdset="1">
380 <name>enabled</name>
381 <bool>false</bool>
382 </property>
383 </widget>
384 <widget row="1" column="1" >
385 <class>QLineEdit</class>
386 <property stdset="1">
387 <name>name</name>
388 <cstring>bcc</cstring>
389 </property>
390 <property stdset="1">
391 <name>enabled</name>
392 <bool>false</bool>
393 </property>
394 </widget>
395 <widget row="0" column="1" >
396 <class>QLineEdit</class>
397 <property stdset="1">
398 <name>name</name>
399 <cstring>cc</cstring>
400 </property>
401 <property stdset="1">
402 <name>enabled</name>
403 <bool>false</bool>
404 </property>
405 </widget>
406 <widget row="3" column="0" rowspan="1" colspan="2" >
407 <class>QLabel</class>
408 <property stdset="1">
409 <name>name</name>
410 <cstring>TextLabel12</cstring>
411 </property>
412 <property stdset="1">
413 <name>text</name>
414 <string>&lt;b&gt;Signature:</string>
415 </property>
416 </widget>
417 <widget row="4" column="0" rowspan="1" colspan="2" >
418 <class>QMultiLineEdit</class>
419 <property stdset="1">
420 <name>name</name>
421 <cstring>signature</cstring>
422 </property>
423 </widget>
424 <spacer row="5" column="1" >
425 <property>
426 <name>name</name>
427 <cstring>Spacer3</cstring>
428 </property>
429 <property stdset="1">
430 <name>orientation</name>
431 <enum>Vertical</enum>
432 </property>
433 <property stdset="1">
434 <name>sizeType</name>
435 <enum>Expanding</enum>
436 </property>
437 <property>
438 <name>sizeHint</name>
439 <size>
440 <width>20</width>
441 <height>20</height>
442 </size>
443 </property>
444 </spacer>
445 </grid>
446 </widget>
447 <widget>
448 <class>QWidget</class>
449 <property stdset="1">
450 <name>name</name>
451 <cstring>sslTab</cstring>
452 </property>
453 <attribute>
454 <name>title</name>
455 <string>SSL</string>
456 </attribute>
457 <grid>
458 <property stdset="1">
459 <name>margin</name>
460 <number>4</number>
461 </property>
462 <property stdset="1">
463 <name>spacing</name>
464 <number>3</number>
465 </property>
466 <spacer row="2" column="0" >
467 <property>
468 <name>name</name>
469 <cstring>Spacer4</cstring>
470 </property>
471 <property stdset="1">
472 <name>orientation</name>
473 <enum>Vertical</enum>
474 </property>
475 <property stdset="1">
476 <name>sizeType</name>
477 <enum>Expanding</enum>
478 </property>
479 <property>
480 <name>sizeHint</name>
481 <size>
482 <width>20</width>
483 <height>20</height>
484 </size>
485 </property>
486 </spacer>
487 <widget row="0" column="0" >
488 <class>QButtonGroup</class>
489 <property stdset="1">
490 <name>name</name>
491 <cstring>ButtonGroup1</cstring>
492 </property>
493 <property stdset="1">
494 <name>title</name>
495 <string>IMAP</string>
496 </property>
497 <property>
498 <name>layoutMargin</name>
499 </property>
500 <property>
501 <name>layoutSpacing</name>
502 </property>
503 <grid>
504 <property stdset="1">
505 <name>margin</name>
506 <number>4</number>
507 </property>
508 <property stdset="1">
509 <name>spacing</name>
510 <number>3</number>
511 </property>
512 <widget row="0" column="0" >
513 <class>QCheckBox</class>
514 <property stdset="1">
515 <name>name</name>
516 <cstring>imapssl</cstring>
517 </property>
518 <property stdset="1">
519 <name>text</name>
520 <string>Use SSL</string>
521 </property>
522 </widget>
523 <widget row="1" column="0" >
524 <class>QFrame</class>
525 <property stdset="1">
526 <name>name</name>
527 <cstring>Frame11</cstring>
528 </property>
529 <property stdset="1">
530 <name>enabled</name>
531 <bool>false</bool>
532 </property>
533 <property stdset="1">
534 <name>frameShape</name>
535 <enum>NoFrame</enum>
536 </property>
537 <property stdset="1">
538 <name>frameShadow</name>
539 <enum>Raised</enum>
540 </property>
541 <property>
542 <name>layoutMargin</name>
543 </property>
544 <property>
545 <name>layoutSpacing</name>
546 </property>
547 <grid>
548 <property stdset="1">
549 <name>margin</name>
550 <number>0</number>
551 </property>
552 <property stdset="1">
553 <name>spacing</name>
554 <number>3</number>
555 </property>
556 <widget row="0" column="0" >
557 <class>QLabel</class>
558 <property stdset="1">
559 <name>name</name>
560 <cstring>TextLabel13</cstring>
561 </property>
562 <property stdset="1">
563 <name>enabled</name>
564 <bool>false</bool>
565 </property>
566 <property stdset="1">
567 <name>text</name>
568 <string>&lt;b&gt;Port:</string>
569 </property>
570 </widget>
571 <widget row="0" column="1" >
572 <class>QLineEdit</class>
573 <property stdset="1">
574 <name>name</name>
575 <cstring>imapsPort</cstring>
576 </property>
577 <property stdset="1">
578 <name>enabled</name>
579 <bool>false</bool>
580 </property>
581 <property stdset="1">
582 <name>text</name>
583 <string>993</string>
584 </property>
585 </widget>
586 </grid>
587 </widget>
588 </grid>
589 </widget>
590 <widget row="1" column="0" >
591 <class>QButtonGroup</class>
592 <property stdset="1">
593 <name>name</name>
594 <cstring>smtpSslGroup</cstring>
595 </property>
596 <property stdset="1">
597 <name>title</name>
598 <string>SMTP</string>
599 </property>
600 <property>
601 <name>layoutMargin</name>
602 </property>
603 <property>
604 <name>layoutSpacing</name>
605 </property>
606 <grid>
607 <property stdset="1">
608 <name>margin</name>
609 <number>4</number>
610 </property>
611 <property stdset="1">
612 <name>spacing</name>
613 <number>3</number>
614 </property>
615 <widget row="0" column="0" >
616 <class>QCheckBox</class>
617 <property stdset="1">
618 <name>name</name>
619 <cstring>smtpssl</cstring>
620 </property>
621 <property stdset="1">
622 <name>text</name>
623 <string>Use SSL</string>
624 </property>
625 </widget>
626 <widget row="1" column="0" >
627 <class>QFrame</class>
628 <property stdset="1">
629 <name>name</name>
630 <cstring>Frame6</cstring>
631 </property>
632 <property stdset="1">
633 <name>enabled</name>
634 <bool>false</bool>
635 </property>
636 <property stdset="1">
637 <name>frameShape</name>
638 <enum>NoFrame</enum>
639 </property>
640 <property stdset="1">
641 <name>frameShadow</name>
642 <enum>Raised</enum>
643 </property>
644 <property>
645 <name>layoutMargin</name>
646 </property>
647 <property>
648 <name>layoutSpacing</name>
649 </property>
650 <grid>
651 <property stdset="1">
652 <name>margin</name>
653 <number>0</number>
654 </property>
655 <property stdset="1">
656 <name>spacing</name>
657 <number>3</number>
658 </property>
659 <widget row="0" column="0" >
660 <class>QLabel</class>
661 <property stdset="1">
662 <name>name</name>
663 <cstring>TextLabel14</cstring>
664 </property>
665 <property stdset="1">
666 <name>text</name>
667 <string>&lt;b&gt;Port:</string>
668 </property>
669 </widget>
670 <widget row="0" column="1" >
671 <class>QLineEdit</class>
672 <property stdset="1">
673 <name>name</name>
674 <cstring>smtpsPort</cstring>
675 </property>
676 </widget>
677 </grid>
678 </widget>
679 </grid>
680 </widget>
681 </grid>
682 </widget>
683 </widget>
684 </grid>
685</widget>
686<connections>
687 <connection>
688 <sender>addCc</sender>
689 <signal>toggled(bool)</signal>
690 <receiver>cc</receiver>
691 <slot>setEnabled(bool)</slot>
692 </connection>
693 <connection>
694 <sender>addBcc</sender>
695 <signal>toggled(bool)</signal>
696 <receiver>bcc</receiver>
697 <slot>setEnabled(bool)</slot>
698 </connection>
699 <connection>
700 <sender>addReplyTo</sender>
701 <signal>toggled(bool)</signal>
702 <receiver>replyTo</receiver>
703 <slot>setEnabled(bool)</slot>
704 </connection>
705 <connection>
706 <sender>smtpssl</sender>
707 <signal>toggled(bool)</signal>
708 <receiver>Frame6</receiver>
709 <slot>setEnabled(bool)</slot>
710 </connection>
711 <connection>
712 <sender>imapssl</sender>
713 <signal>toggled(bool)</signal>
714 <receiver>Frame11</receiver>
715 <slot>setEnabled(bool)</slot>
716 </connection>
717 <connection>
718 <sender>imapssl</sender>
719 <signal>toggled(bool)</signal>
720 <receiver>imapsPort</receiver>
721 <slot>setEnabled(bool)</slot>
722 </connection>
723 <connection>
724 <sender>imapssl</sender>
725 <signal>toggled(bool)</signal>
726 <receiver>TextLabel13</receiver>
727 <slot>setEnabled(bool)</slot>
728 </connection>
729</connections>
730<tabstops>
731 <tabstop>TabWidget2</tabstop>
732 <tabstop>imapServer</tabstop>
733 <tabstop>imapPort</tabstop>
734 <tabstop>user</tabstop>
735 <tabstop>pass</tabstop>
736 <tabstop>smtpServer</tabstop>
737 <tabstop>smtpPort</tabstop>
738 <tabstop>realname</tabstop>
739 <tabstop>email</tabstop>
740 <tabstop>org</tabstop>
741 <tabstop>addCc</tabstop>
742 <tabstop>cc</tabstop>
743 <tabstop>addBcc</tabstop>
744 <tabstop>bcc</tabstop>
745 <tabstop>addReplyTo</tabstop>
746 <tabstop>replyTo</tabstop>
747 <tabstop>signature</tabstop>
748 <tabstop>imapsPort</tabstop>
749 <tabstop>smtpsPort</tabstop>
750</tabstops>
751</UI>
diff --git a/noncore/unsupported/mail2/addresspicker.cpp b/noncore/unsupported/mail2/addresspicker.cpp
new file mode 100644
index 0000000..178fe27
--- a/dev/null
+++ b/noncore/unsupported/mail2/addresspicker.cpp
@@ -0,0 +1,117 @@
1#include <qpushbutton.h>
2#include <qmessagebox.h>
3#include <qtextstream.h>
4#include <qlistbox.h>
5#include <qfile.h>
6
7#include <qpe/resource.h>
8
9#include <stdlib.h>
10
11#include "addresspicker.h"
12
13AddressPicker::AddressPicker(QWidget *parent, const char *name, bool modal,
14 WFlags fl) : AddressPickerBase(parent, name, modal, fl)
15{
16 okButton->setIconSet(Resource::loadPixmap("enter"));
17 cancelButton->setIconSet(Resource::loadPixmap("editdelete"));
18
19 connect(okButton, SIGNAL(clicked()), SLOT(accept()));
20 connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
21
22 QFile f((QString) getenv("HOME") + "/Applications/"
23 + "addressbook/addressbook.xml");
24
25 if (f.open(IO_ReadOnly)) {
26 QTextStream stream(&f);
27 QString content;
28 while (!f.atEnd()) content += stream.readLine() + "\n";
29 QStringList lines = QStringList::split(QRegExp("\\n"), content);
30 QStringList::Iterator it;
31 for (it = lines.begin(); it != lines.end(); it++) {
32 if ((*it).find(QRegExp("^<Contact.*")) != -1) {
33 int pos = (*it).find("FirstName=\"");
34 QString fname;
35 if (pos != -1) {
36 int i = 1;
37 QChar c;
38 while (c != '"') {
39 c = (*it)[pos + 10 + i];
40 if (c != '"') fname += c;
41 i++;
42 }
43 }
44 pos = (*it).find("LastName=\"");
45 QString lname;
46 if (pos != -1) {
47 int i = 1;
48 QChar c;
49 while (c != '"') {
50 c = (*it)[pos + 9 + i];
51 if (c != '"') lname += c;
52 i++;
53 }
54 }
55 pos = (*it).find("DefaultEmail=\"");
56 QString email;
57 if (pos != -1) {
58 int i = 1;
59 QChar c;
60 while (c != '"') {
61 c = (*it)[pos + 13 + i];
62 if (c != '"') email += c;
63 i++;
64 }
65 }
66 QString tname, temail;
67 if (!fname.isEmpty()) tname += fname;
68 if (!lname.isEmpty()) tname += fname.isEmpty() ? lname : (" " + lname);
69 if (!email.isEmpty()) temail += tname.isEmpty() ? email : (" <" + email + ">");
70 if (!email.isEmpty()) addressList->insertItem(tname + temail);
71 }
72 }
73 }
74 if (addressList->count() <= 0) {
75 addressList->insertItem(tr("There are no entries in the addressbook."));
76 addressList->setEnabled(false);
77 okButton->setEnabled(false);
78 }
79}
80
81void AddressPicker::accept()
82{
83 QListBoxItem *item = addressList->firstItem();
84 QString names;
85
86 while (item) {
87 if (item->selected())
88 names += item->text() + ", ";
89 item = item->next();
90 }
91 names.replace(names.length() - 2, 2, "");
92
93 if (names.isEmpty()) {
94 QMessageBox::information(this, tr("Error"), tr("<p>You have to select"
95 " at least one address entry.</p>"), tr("Ok"));
96 return;
97 }
98
99 selectedNames = names;
100 QDialog::accept();
101}
102
103QString AddressPicker::getNames()
104{
105 QString names = 0;
106
107 AddressPicker *picker = new AddressPicker(0, 0, true);
108 picker->showMaximized();
109 picker->show();
110
111 int ret = picker->exec();
112 if (QDialog::Accepted == ret) {
113 return picker->selectedNames;
114 }
115 return 0;
116}
117
diff --git a/noncore/unsupported/mail2/addresspicker.h b/noncore/unsupported/mail2/addresspicker.h
new file mode 100644
index 0000000..7d21915
--- a/dev/null
+++ b/noncore/unsupported/mail2/addresspicker.h
@@ -0,0 +1,24 @@
1#ifndef ADDRESSPICKER_H
2#define ADDRESSPICKER_H
3
4#include "addresspickerbase.h"
5
6class AddressPicker : public AddressPickerBase
7{
8 Q_OBJECT
9
10public:
11 static QString getNames();
12
13protected:
14 AddressPicker(QWidget *parent = 0, const char *name = 0,
15 bool modal = false, WFlags fl = 0);
16
17 QString selectedNames;
18
19 void accept();
20
21};
22
23#endif
24
diff --git a/noncore/unsupported/mail2/addresspickerbase.ui b/noncore/unsupported/mail2/addresspickerbase.ui
new file mode 100644
index 0000000..8eb288d
--- a/dev/null
+++ b/noncore/unsupported/mail2/addresspickerbase.ui
@@ -0,0 +1,86 @@
1<!DOCTYPE UI><UI>
2<class>AddressPickerBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>AddressPickerBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>286</width>
15 <height>320</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Address Picker</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <grid>
29 <property stdset="1">
30 <name>margin</name>
31 <number>4</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>3</number>
36 </property>
37 <widget row="0" column="0" rowspan="1" colspan="2" >
38 <class>QListBox</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>addressList</cstring>
42 </property>
43 <property stdset="1">
44 <name>selectionMode</name>
45 <enum>Multi</enum>
46 </property>
47 </widget>
48 <widget row="1" column="0" >
49 <class>QPushButton</class>
50 <property stdset="1">
51 <name>name</name>
52 <cstring>okButton</cstring>
53 </property>
54 <property stdset="1">
55 <name>minimumSize</name>
56 <size>
57 <width>10</width>
58 <height>0</height>
59 </size>
60 </property>
61 <property stdset="1">
62 <name>text</name>
63 <string>Ok</string>
64 </property>
65 </widget>
66 <widget row="1" column="1" >
67 <class>QPushButton</class>
68 <property stdset="1">
69 <name>name</name>
70 <cstring>cancelButton</cstring>
71 </property>
72 <property stdset="1">
73 <name>minimumSize</name>
74 <size>
75 <width>10</width>
76 <height>0</height>
77 </size>
78 </property>
79 <property stdset="1">
80 <name>text</name>
81 <string>Cancel</string>
82 </property>
83 </widget>
84 </grid>
85</widget>
86</UI>
diff --git a/noncore/unsupported/mail2/attachdiag.cpp b/noncore/unsupported/mail2/attachdiag.cpp
new file mode 100644
index 0000000..6e6c3d4
--- a/dev/null
+++ b/noncore/unsupported/mail2/attachdiag.cpp
@@ -0,0 +1,71 @@
1#include <qmessagebox.h>
2#include <qpushbutton.h>
3#include <qlistbox.h>
4#include <qlayout.h>
5
6#include <qpe/fileselector.h>
7#include <qpe/resource.h>
8
9#include <stdlib.h>
10
11#include "attachdiag.h"
12
13AttachDiag::AttachDiag(QWidget* parent = 0, const char* name = 0, bool modal, WFlags fl = 0)
14 : QDialog(parent, name, modal, fl)
15{
16 setCaption(tr("Attach File"));
17
18 QGridLayout *layout = new QGridLayout(this);
19 layout->setSpacing(3);
20 layout->setMargin(4);
21
22 FileSelector *fileSelector = new FileSelector("*", this, "FileSelector");
23 fileSelector->setCloseVisible(false);
24 fileSelector->setNewVisible(false);
25
26 layout->addMultiCellWidget(fileSelector, 0, 0, 0, 1);
27
28 QPushButton *attachButton = new QPushButton(this);
29 attachButton->setText(tr("Ok"));
30 attachButton->setIconSet(Resource::loadPixmap("enter"));
31
32 layout->addWidget(attachButton, 1, 0);
33
34 QPushButton *cancelButton = new QPushButton(this);
35 cancelButton->setText(tr("Cancel"));
36 cancelButton->setIconSet(Resource::loadPixmap("editdelete"));
37
38 layout->addWidget(cancelButton, 1, 1);
39
40 connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), SLOT(fileSelected(const DocLnk &)));
41 connect(attachButton, SIGNAL(clicked()), SLOT(accept()));
42 connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
43
44 if (fileSelector->selected() != NULL)
45 currentFile = *fileSelector->selected();
46
47 if (fileSelector->fileCount() == 0) {
48 attachButton->setEnabled(false);
49 fileSelector->setEnabled(false);
50 }
51}
52
53void AttachDiag::fileSelected(const DocLnk &file)
54{
55 currentFile = file;
56}
57
58DocLnk AttachDiag::getFile()
59{
60 AttachDiag *attach = new AttachDiag(0, 0, true);
61 attach->showMaximized();
62 attach->show();
63
64 if (QDialog::Accepted == attach->exec()) {
65 return attach->currentFile;
66 }
67
68 return DocLnk();
69 }
70
71
diff --git a/noncore/unsupported/mail2/attachdiag.h b/noncore/unsupported/mail2/attachdiag.h
new file mode 100644
index 0000000..c673cfc
--- a/dev/null
+++ b/noncore/unsupported/mail2/attachdiag.h
@@ -0,0 +1,27 @@
1#ifndef ATTACHDIAG_H
2#define ATTACHDIAG_H
3
4#include <qdialog.h>
5
6#include <qpe/applnk.h>
7
8class AttachDiag : public QDialog
9{
10 Q_OBJECT
11
12public:
13 static DocLnk getFile();
14
15protected:
16 AttachDiag(QWidget *parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0);
17
18private slots:
19 void fileSelected(const DocLnk &);
20
21private:
22 DocLnk currentFile;
23
24};
25
26#endif
27
diff --git a/noncore/unsupported/mail2/bend/bend.cpp b/noncore/unsupported/mail2/bend/bend.cpp
new file mode 100644
index 0000000..b4da3ac
--- a/dev/null
+++ b/noncore/unsupported/mail2/bend/bend.cpp
@@ -0,0 +1,116 @@
1#include <qlayout.h>
2#include <qpixmap.h>
3#include <qlabel.h>
4#include <qtimer.h>
5#include <qdir.h>
6
7#include <qpe/qcopenvelope_qws.h>
8#include <qpe/resource.h>
9#include <qpe/config.h>
10
11#include <stdlib.h>
12
13#include "configfile.h"
14#include "imapresponse.h"
15#include "imaphandler.h"
16#include "zaurusstuff.h"
17#include "bend.h"
18
19BenD::BenD(QWidget *parent, const char *name, WFlags fl)
20 : QButton(parent, name, fl)
21{
22 _config = new Config("mail");
23 _config->setGroup("Settings");
24
25 QVBoxLayout *layout = new QVBoxLayout(this);
26 layout->addItem(new QSpacerItem(0,0));
27
28 QLabel *pixmap = new QLabel(this);
29 pixmap->setPixmap(Resource::loadPixmap("mail/mailchecker"));
30 layout->addWidget(pixmap);
31
32 layout->addItem(new QSpacerItem(0,0));
33
34 hide();
35
36 connect(this, SIGNAL(clicked()), SLOT(slotClicked()));
37
38 if (!_config->readBoolEntry("Disabled", false)) {
39 _intervalMs = _config->readNumEntry("CheckEvery", 5) * 60000;
40 _intervalTimer = new QTimer();
41 _intervalTimer->start(_intervalMs);
42 connect(_intervalTimer, SIGNAL(timeout()), SLOT(slotCheck()));
43
44 QTimer::singleShot(0, this, SLOT(slotCheck()));
45 }
46}
47
48void BenD::drawButton(QPainter *) { }
49void BenD::drawButtonText(QPainter *) { }
50
51void BenD::slotClicked()
52{
53 QCopEnvelope e("QPE/System", "execute(QString)");
54 e << QString("mail");
55
56 if (_ledOn) {
57 ZaurusStuff::blinkLedOff();
58 _ledOn = false;
59 }
60}
61
62void BenD::slotCheck()
63{
64 // Check wether the check interval has been changed.
65 int newIntervalMs = _config->readNumEntry("CheckEvery", 5) * 60000;
66 if (newIntervalMs != _intervalMs) {
67 _intervalTimer->changeInterval(newIntervalMs);
68 _intervalMs = newIntervalMs;
69 }
70
71 QValueList<Account> acList = ConfigFile::getAccounts();
72 QValueList<Account>::Iterator ot;
73 for (ot = acList.begin(); ot != acList.end(); ot++) {
74 if (!((*ot).imapServer().isEmpty() ||
75 (*ot).imapPort().isEmpty() ||
76 (*ot).user().isEmpty() ||
77 (*ot).pass().isEmpty())) {
78 if (!((*ot).imapSsl() &&
79 (*ot).imapSslPort().isEmpty())) {
80 IMAPHandler *handler = new IMAPHandler(*ot);
81 handler->iStatus("INBOX", "RECENT");
82 connect(handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPStatus(IMAPResponse &)));
83 }
84 }
85 }
86}
87
88void BenD::slotIMAPStatus(IMAPResponse &response)
89{
90 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPStatus(IMAPResponse &)));
91
92 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
93 if (response.STATUS()[0].recent().toInt() > 0) {
94 if (isHidden()) show();
95 if (_config->readBoolEntry("BlinkLed", true))
96 ZaurusStuff::blinkLedOn();
97 if (_config->readBoolEntry("PlaySound", false)) {
98 ZaurusStuff::buzzerOn();
99 QTimer::singleShot(3000, this, SLOT(slotSoundOff()));
100 }
101 } else {
102 if (!isHidden()) hide();
103 if (!_ledOn) {
104 ZaurusStuff::blinkLedOff();
105 _ledOn = false;
106 }
107 }
108 response.imapHandler()->iLogout();
109 } else qWarning("BenD: WARNING: Couldn't retrieve INBOX status.");
110}
111
112void BenD::slotSoundOff()
113{
114 ZaurusStuff::buzzerOff();
115}
116
diff --git a/noncore/unsupported/mail2/bend/bend.h b/noncore/unsupported/mail2/bend/bend.h
new file mode 100644
index 0000000..cf50bc5
--- a/dev/null
+++ b/noncore/unsupported/mail2/bend/bend.h
@@ -0,0 +1,38 @@
1#ifndef BEND_H
2#define BEND_H
3
4#include <qbutton.h>
5
6class Config;
7class QTimer;
8class IMAPResponse;
9
10class BenD : public QButton
11{
12 Q_OBJECT
13
14public:
15 BenD(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
16
17protected:
18 void drawButton(QPainter *);
19 void drawButtonText(QPainter *);
20 void gotNewMail();
21 QString rot13(const QString &input);
22
23protected slots:
24 void slotCheck();
25 void slotClicked();
26 void slotSoundOff();
27 void slotIMAPStatus(IMAPResponse &response);
28
29private:
30 Config *_config;
31 QTimer *_intervalTimer;
32 int _intervalMs;
33 bool _ledOn;
34
35};
36
37#endif
38
diff --git a/noncore/unsupported/mail2/bend/bend.pro b/noncore/unsupported/mail2/bend/bend.pro
new file mode 100644
index 0000000..fe7b22c
--- a/dev/null
+++ b/noncore/unsupported/mail2/bend/bend.pro
@@ -0,0 +1,10 @@
1 TEMPLATE =lib
2 CONFIG +=qt warn_on release
3 HEADERS +=bend.h \
4 bendimpl.h
5 SOURCES +=bend.cpp \
6 bendimpl.cpp
7 INCLUDEPATH +=$(OPIEDIR)/include ../libmail
8 LIBS +=-lmail -lqpe
9 TARGET =bend
10 DESTDIR +=$(OPIEDIR)/plugins/applets/
diff --git a/noncore/unsupported/mail2/bend/bendimpl.cpp b/noncore/unsupported/mail2/bend/bendimpl.cpp
new file mode 100644
index 0000000..e616c68
--- a/dev/null
+++ b/noncore/unsupported/mail2/bend/bendimpl.cpp
@@ -0,0 +1,39 @@
1#include "bendimpl.h"
2#include "bend.h"
3
4BenDImpl::BenDImpl()
5 : _benD(0), ref(0)
6{
7
8}
9
10BenDImpl::~BenDImpl()
11{
12 delete _benD;
13}
14
15QWidget *BenDImpl::applet(QWidget *parent)
16{
17 if (!_benD) _benD = new BenD(parent);
18 return _benD;
19}
20
21int BenDImpl::position() const
22{
23 return 4;
24}
25
26QRESULT BenDImpl::queryInterface(const QUuid &uuid, QUnknownInterface **iface)
27{
28 *iface = 0;
29 if (uuid == IID_QUnknown) *iface = this;
30 else if (uuid == IID_TaskbarApplet) *iface = this;
31
32 if (*iface) (*iface)->addRef();
33 return QS_OK;
34}
35
36Q_EXPORT_INTERFACE()
37{
38 Q_CREATE_INSTANCE(BenDImpl)
39}
diff --git a/noncore/unsupported/mail2/bend/bendimpl.h b/noncore/unsupported/mail2/bend/bendimpl.h
new file mode 100644
index 0000000..c883f1b
--- a/dev/null
+++ b/noncore/unsupported/mail2/bend/bendimpl.h
@@ -0,0 +1,27 @@
1#ifndef BENDIMPL_H
2#define BENDIMPL_H
3
4#include <qpe/taskbarappletinterface.h>
5
6class BenD;
7
8class BenDImpl : public TaskbarAppletInterface
9{
10public:
11 BenDImpl();
12 virtual ~BenDImpl();
13
14 QRESULT queryInterface(const QUuid &uuid, QUnknownInterface **iface);
15 Q_REFCOUNT
16
17 virtual QWidget *applet(QWidget *parent);
18 virtual int position() const;
19
20private:
21 BenD *_benD;
22 ulong ref;
23
24};
25
26#endif
27
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp
new file mode 100644
index 0000000..2f13604
--- a/dev/null
+++ b/noncore/unsupported/mail2/composer.cpp
@@ -0,0 +1,215 @@
1#include <qmultilineedit.h>
2#include <qmessagebox.h>
3#include <qpopupmenu.h>
4#include <qcombobox.h>
5#include <qlineedit.h>
6#include <qaction.h>
7#include <qtimer.h>
8#include <qlabel.h>
9
10#include <qpe/resource.h>
11
12#include "addresspicker.h"
13#include "listviewplus.h"
14#include "smtphandler.h"
15#include "attachdiag.h"
16#include "composer.h"
17#include "rename.h"
18
19AttachViewItem::AttachViewItem(QListView *parent, Attachment &attachment)
20 : QListViewItem(parent), _attachment(attachment)
21{
22 setPixmap(0, _attachment.docLnk()->pixmap().isNull() ? Resource::loadPixmap("UnknownDocument-14") : _attachment.docLnk()->pixmap());
23 setText(0, _attachment.newName().isEmpty() ? _attachment.fileName() : _attachment.newName());
24 setText(1, _attachment.description());
25}
26
27Composer::Composer(QWidget *parent, const char *name, WFlags fl)
28 : ComposerBase(parent, name, fl)
29{
30 abort->setEnabled(false);
31 to->setFocus();
32
33 connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail()));
34 connect(addressbook, SIGNAL(activated()), SLOT(slotOpenAddressPicker()));
35 connect(addattach, SIGNAL(activated()), SLOT(slotAddAttach()));
36 connect(delattach, SIGNAL(activated()), SLOT(slotDelAttach()));
37
38 connect(from, SIGNAL(activated(int)), SLOT(slotFromChanged(int)));
39
40 connect(attachPopup, SIGNAL(activated(int)), SLOT(slotPopupHandler(int)));
41
42 QTimer::singleShot(0, this, SLOT(slotFillStuff()));
43 QTimer::singleShot(0, this, SLOT(slotResizing()));
44}
45
46void Composer::setSendMail(SendMail &sendMail)
47{
48 to->setText(sendMail.to());
49 cc->setText(sendMail.cc());
50 bcc->setText(sendMail.bcc());
51 subject->setText(sendMail.subject());
52 message->setText(sendMail.message());
53 _inReplyTo = sendMail.inReplyTo();
54
55 QValueList<Attachment> attachments = sendMail.attachments();
56 QValueList<Attachment>::Iterator it;
57 for (it = attachments.begin(); it != attachments.end(); it++) {
58 (void) new AttachViewItem(attachView, *it);
59 if (attachView->isHidden()) attachView->show();
60 }
61}
62
63void Composer::slotResizing()
64{
65 from->setMaximumWidth(width() - fromBox->width());
66 from->resize(width() - fromBox->width(), y());
67}
68
69void Composer::slotPopupHandler(int itemid)
70{
71 if (attachView->currentItem() == NULL) {
72 QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok"));
73 return;
74 }
75
76 if (itemid == POPUP_ATTACH_RENAME) {
77 QString tmp = Rename::rename(attachView->currentItem()->text(0), this);
78 if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp);
79 } else if (itemid == POPUP_ATTACH_DESC) {
80 QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this);
81 if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp);
82 } else if (itemid == POPUP_ATTACH_REMOVE) {
83 attachView->takeItem(attachView->currentItem());
84 }
85}
86
87void Composer::slotSendMail()
88{
89 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) {
90 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok"));
91 return;
92 }
93
94 SendMail smail;
95 smail.setFrom(from->currentText());
96 smail.setReplyTo(replyto->text());
97 smail.setTo(to->text());
98 smail.setCc(cc->text());
99 smail.setBcc(bcc->text());
100 smail.setSubject(subject->text());
101 smail.setMessage(message->text());
102 smail.setNeedsMime(attachView->childCount() == 0 ? false : true);
103 smail.setAccount(accountsLoaded[from->currentItem()]);
104
105 if (priority->currentItem() == POPUP_PRIO_LOW) {
106 smail.setPriority("Low");// No i18n on purpose
107 } else if (priority->currentItem() == POPUP_PRIO_NORMAL) {
108 smail.setPriority("Normal");// No i18n on purpose
109 } else if (priority->currentItem() == POPUP_PRIO_HIGH) {
110 smail.setPriority("High");// No i18n on purpose
111 }
112
113 QValueList<Attachment> attachments;
114 QListViewItem *item;
115 for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) {
116 attachments.append(((AttachViewItem *)item)->attachment());
117 }
118
119 smail.setAttachments(attachments);
120
121 QString header, message;
122 MailFactory::genMail(header, message, smail, this);
123
124 abort->setEnabled(true);
125
126 SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text());
127 connect(handler, SIGNAL(finished()), SLOT(slotSendFinished()));
128 connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &)));
129 connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &)));
130}
131
132void Composer::slotSendError(const QString &error)
133{
134 status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>"));
135 QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok"));
136}
137
138void Composer::slotSendFinished()
139{
140 status->setText(QString(0));
141 abort->setEnabled(false);
142}
143
144void Composer::slotFillStuff()
145{
146 QValueList<Account> accounts = ConfigFile::getAccounts();
147 int i = 0;
148
149 QValueList<Account>::Iterator it;
150 for (it = accounts.begin(); it != accounts.end(); it++) {
151 if (!(*it).email().isEmpty() && !(*it).smtpServer().isEmpty() && !(*it).smtpPort().isEmpty()) {
152 if (!(*it).realName().isEmpty())
153 from->insertItem((*it).realName() + " <" + (*it).email() + ">", i);
154 else
155 from->insertItem((*it).email());
156
157 accountsLoaded.append(*it);
158 i++;
159 }
160 }
161}
162
163void Composer::slotFromChanged(int id)
164{
165 Account account = accountsLoaded[id];
166
167 if (account.defaultCc()) cc->setText(account.cc());
168 if (account.defaultBcc()) bcc->setText(account.bcc());
169 if (account.defaultReplyTo()) replyto->setText(account.replyTo());
170 if (!account.signature().isEmpty())
171 message->setText(message->text() + "\n\n-- \n" + account.signature());
172}
173
174void Composer::slotOpenAddressPicker()
175{
176 if (!to->isHidden() && cc->isHidden() && bcc->isHidden()) {
177 if (to->text().isEmpty()) {
178 to->setText(AddressPicker::getNames());
179 } else {
180 to->setText(to->text() + ", " + AddressPicker::getNames());
181 }
182 } else if (to->isHidden() && !cc->isHidden() && bcc->isHidden()) {
183 if (cc->text().isEmpty()) {
184 cc->setText(AddressPicker::getNames());
185 } else {
186 cc->setText(cc->text() + ", " + AddressPicker::getNames());
187 }
188 } else if (to->isHidden() && cc->isHidden() && !bcc->isHidden()) {
189 if (bcc->text().isEmpty()) {
190 bcc->setText(AddressPicker::getNames());
191 } else {
192 bcc->setText(bcc->text() + ", " + AddressPicker::getNames());
193 }
194 }
195}
196
197void Composer::slotAddAttach()
198{
199 DocLnk lnk = AttachDiag::getFile();
200 if (lnk.name().isEmpty()) return;
201
202 Attachment attachment;
203 attachment.setFileName(lnk.file());
204 attachment.setNewName(lnk.name());
205 attachment.setDocLnk(&lnk);
206
207 (void) new AttachViewItem(attachView, attachment);
208}
209
210void Composer::slotDelAttach()
211{
212 if (attachView->currentItem() == NULL) return;
213 attachView->takeItem(attachView->currentItem());
214}
215
diff --git a/noncore/unsupported/mail2/composer.h b/noncore/unsupported/mail2/composer.h
new file mode 100644
index 0000000..a1af121
--- a/dev/null
+++ b/noncore/unsupported/mail2/composer.h
@@ -0,0 +1,52 @@
1#ifndef COMPOSER_H
2#define COMPOSER_H
3
4#include <qlistview.h>
5#include <qpe/applnk.h>
6
7#include "mailfactory.h"
8#include "composerbase.h"
9#include "configfile.h"
10
11class AttachViewItem : public QListViewItem
12{
13public:
14 AttachViewItem(QListView *parent, Attachment &attachment);
15
16 Attachment attachment() { return _attachment; }
17
18private:
19 Attachment _attachment;
20
21};
22
23class Composer : public ComposerBase
24{
25 Q_OBJECT
26
27public:
28 Composer(QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal);
29
30 void setSendMail(SendMail &sendMail);
31
32protected slots:
33 void slotPopupHandler(int itemid);
34 void slotSendMail();
35 void slotSendError(const QString &);
36 void slotSendFinished();
37 void slotResizing();
38 void slotFillStuff();
39 void slotFromChanged(int id);
40 void slotOpenAddressPicker();
41 void slotAddAttach();
42 void slotDelAttach();
43
44protected:
45 QValueList<Account> accountsLoaded;
46
47private:
48 QString _inReplyTo;
49
50};
51
52#endif
diff --git a/noncore/unsupported/mail2/composerbase.cpp b/noncore/unsupported/mail2/composerbase.cpp
new file mode 100644
index 0000000..7754863
--- a/dev/null
+++ b/noncore/unsupported/mail2/composerbase.cpp
@@ -0,0 +1,199 @@
1#include <qmultilineedit.h>
2#include <qpopupmenu.h>
3#include <qcombobox.h>
4#include <qlineedit.h>
5#include <qtoolbar.h>
6#include <qlayout.h>
7#include <qaction.h>
8#include <qlabel.h>
9#include <qvbox.h>
10
11#include <qpe/resource.h>
12
13#include "listviewplus.h"
14#include "composerbase.h"
15
16ComposerBase::ComposerBase(QWidget *parent, const char *name, WFlags fl)
17 : QMainWindow(parent, name, fl)
18{
19 setCaption(tr("Compose Message"));
20 setToolBarsMovable(false);
21
22 toolbar = new QToolBar(this);
23 addToolBar(toolbar);
24 toolbar->setHorizontalStretchable(true);
25
26 sendmail = new QAction(tr("Send the mail"), QIconSet(Resource::loadPixmap("mail/sendmail")), 0, 0, this);
27 sendmail->addTo(toolbar);
28
29 attachfile = new QAction(tr("Attach a file"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true);
30 attachfile->addTo(toolbar);
31 connect(attachfile, SIGNAL(toggled(bool)), SLOT(slotAttachfileChanged(bool)));
32
33 addressbook = new QAction(tr("Addressbook"), QIconSet(Resource::loadPixmap("mail/addbook")), 0, 0, this);
34 addressbook->addTo(toolbar);
35
36 QLabel *spacer = new QLabel(toolbar);
37 spacer->setBackgroundMode(QWidget::PaletteButton);
38 toolbar->setStretchableWidget(spacer);
39
40 abort = new QAction(tr("Abort sending"), QIconSet(Resource::loadPixmap("mail/abort")), 0, 0, this);
41 abort->addTo(toolbar);
42
43 QWidget *main = new QWidget(this);
44 setCentralWidget(main);
45
46 QGridLayout *layout = new QGridLayout(main);
47
48 fromBox = new QComboBox(main);
49 fromBox->insertItem(tr("From"), POPUP_FROM_FROM);
50 fromBox->insertItem(tr("Reply"), POPUP_FROM_REPLYTO);
51 layout->addWidget(fromBox, 0, 0);
52
53 connect(fromBox, SIGNAL(activated(int)), SLOT(slotFromMenuChanged(int)));
54
55 QHBoxLayout *fromLayout = new QHBoxLayout();
56 layout->addLayout(fromLayout, 0, 1);
57
58 from = new QComboBox(main);
59 fromLayout->addWidget(from);
60
61 replyto = new QLineEdit(main);
62 replyto->hide();
63 fromLayout->addWidget(replyto);
64
65 receiversBox = new QComboBox(main);
66 receiversBox->insertItem(tr("To"), POPUP_RECV_TO);
67 receiversBox->insertItem(tr("Cc"), POPUP_RECV_CC);
68 receiversBox->insertItem(tr("Bcc"), POPUP_RECV_BCC);
69 layout->addWidget(receiversBox, 1, 0);
70
71 connect(receiversBox, SIGNAL(activated(int)), SLOT(slotReceiverMenuChanged(int)));
72
73 QHBoxLayout *receiverLayout = new QHBoxLayout();
74 layout->addLayout(receiverLayout, 1, 1);
75
76 to = new QLineEdit(main);
77 receiverLayout->addWidget(to);
78
79 cc = new QLineEdit(main);
80 cc->hide();
81 receiverLayout->addWidget(cc);
82
83 bcc = new QLineEdit(main);
84 bcc->hide();
85 receiverLayout->addWidget(bcc);
86
87 subjectBox = new QComboBox(main);
88 subjectBox->insertItem(tr("Subj."), POPUP_SUBJ_SUBJECT);
89 subjectBox->insertItem(tr("Prio."), POPUP_SUBJ_PRIORITY);
90 layout->addWidget(subjectBox, 2, 0);
91 connect(subjectBox, SIGNAL(activated(int)), SLOT(slotSubjectMenuChanged(int)));
92
93 QHBoxLayout *subjectLayout = new QHBoxLayout();
94 layout->addLayout(subjectLayout, 2, 1);
95
96 subject = new QLineEdit(main);
97 subjectLayout->addWidget(subject);
98
99 priority = new QComboBox(main);
100 priority->insertItem(tr("Low"), POPUP_PRIO_LOW);
101 priority->insertItem(tr("Normal"), POPUP_PRIO_NORMAL);
102 priority->insertItem(tr("High"), POPUP_PRIO_HIGH);
103 priority->setCurrentItem(POPUP_PRIO_NORMAL);
104 priority->hide();
105 subjectLayout->addWidget(priority);
106
107 QVBox *view = new QVBox(main);
108 layout->addMultiCellWidget(view, 3, 3, 0, 1);
109
110 message = new QMultiLineEdit(view);
111 message->setMinimumHeight(30);
112
113 attachWindow = new QMainWindow(view, 0, 0);
114 attachWindow->setMinimumHeight(100);
115 attachWindow->setMaximumHeight(100);
116 attachWindow->setToolBarsMovable(false);
117 attachWindow->hide();
118
119 attachToolbar = new QToolBar(attachWindow);
120 attachToolbar->setVerticalStretchable(true);
121
122 addattach = new QAction(tr("Add an Attachement"), QIconSet(Resource::loadPixmap("mail/newmail")), 0, 0, this);
123 addattach->addTo(attachToolbar);
124
125 delattach = new QAction(tr("Remove Attachement"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this);
126 delattach->addTo(attachToolbar);
127
128 QLabel *attachSpacer = new QLabel(attachToolbar);
129 attachSpacer->setBackgroundMode(QWidget::PaletteButton);
130 attachToolbar->setStretchableWidget(attachSpacer);
131
132 attachWindow->addToolBar(attachToolbar, QMainWindow::Left);
133
134 attachView = new ListViewPlus(attachWindow);
135 attachView->addColumn(tr("Name"), 80);
136 attachView->addColumn(tr("Description"), 110);
137 attachView->setAllColumnsShowFocus(true);
138 attachWindow->setCentralWidget(attachView);
139
140 attachPopup = new QPopupMenu(attachView);
141 attachPopup->insertItem(tr("Rename"), POPUP_ATTACH_RENAME);
142 attachPopup->insertItem(tr("Change Description"), POPUP_ATTACH_DESC);
143 attachPopup->insertSeparator();
144 attachPopup->insertItem(tr("Remove"), POPUP_ATTACH_REMOVE);
145 attachView->setPopup(attachPopup);
146
147 status = new QLabel(view);
148 QFont tmpFont = status->font();
149 tmpFont.setPixelSize(8);
150 status->setFont(tmpFont);
151}
152
153void ComposerBase::slotAttachfileChanged(bool toggled)
154{
155 if (toggled) {
156 if (attachWindow->isHidden()) attachWindow->show();
157 } else {
158 if (!attachWindow->isHidden()) attachWindow->hide();
159 }
160}
161
162void ComposerBase::slotFromMenuChanged(int id)
163{
164 if (POPUP_FROM_FROM == id) {
165 if (from->isHidden()) from->show();
166 if (!replyto->isHidden()) replyto->hide();
167 } else if (POPUP_FROM_REPLYTO == id) {
168 if (!from->isHidden()) from->hide();
169 if (replyto->isHidden()) replyto->show();
170 }
171}
172
173void ComposerBase::slotReceiverMenuChanged(int id)
174{
175 if (POPUP_RECV_TO == id) {
176 if (to->isHidden()) to->show();
177 if (!cc->isHidden()) cc->hide();
178 if (!bcc->isHidden()) bcc->hide();
179 } else if (POPUP_RECV_CC == id) {
180 if (!to->isHidden()) to->hide();
181 if (cc->isHidden()) cc->show();
182 if (!bcc->isHidden()) bcc->hide();
183 } else if (POPUP_RECV_BCC == id) {
184 if (!to->isHidden()) to->hide();
185 if (!cc->isHidden()) cc->hide();
186 if (bcc->isHidden()) bcc->show();
187 }
188}
189
190void ComposerBase::slotSubjectMenuChanged(int id)
191{
192 if (POPUP_SUBJ_SUBJECT == id) {
193 if (subject->isHidden()) subject->show();
194 if (!priority->isHidden()) priority->hide();
195 } else if (POPUP_SUBJ_PRIORITY == id) {
196 if (!subject->isHidden()) subject->hide();
197 if (priority->isHidden()) priority->show();
198 }
199}
diff --git a/noncore/unsupported/mail2/composerbase.h b/noncore/unsupported/mail2/composerbase.h
new file mode 100644
index 0000000..e5fab67
--- a/dev/null
+++ b/noncore/unsupported/mail2/composerbase.h
@@ -0,0 +1,55 @@
1#ifndef COMPOSERBASE_H
2#define COMPOSERBASE_H
3
4#include <qmainwindow.h>
5
6class QMultiLineEdit;
7class ListViewPlus;
8class QPopupMenu;
9class QComboBox;
10class QLineEdit;
11class QToolBar;
12class QAction;
13class QLabel;
14
15class ComposerBase : public QMainWindow
16{
17 Q_OBJECT
18
19public:
20 ComposerBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
21
22protected:
23 static const int POPUP_FROM_FROM = 0;
24 static const int POPUP_FROM_REPLYTO = 1;
25 static const int POPUP_RECV_TO = 0;
26 static const int POPUP_RECV_CC = 1;
27 static const int POPUP_RECV_BCC = 2;
28 static const int POPUP_SUBJ_SUBJECT = 0;
29 static const int POPUP_SUBJ_PRIORITY = 1;
30 static const int POPUP_PRIO_LOW = 0;
31 static const int POPUP_PRIO_NORMAL = 1;
32 static const int POPUP_PRIO_HIGH = 2;
33 static const int POPUP_ATTACH_RENAME = 0;
34 static const int POPUP_ATTACH_DESC = 1;
35 static const int POPUP_ATTACH_REMOVE = 2;
36
37 QMultiLineEdit *message;
38 ListViewPlus *attachView;
39 QMainWindow *attachWindow;
40 QPopupMenu *attachPopup;
41 QComboBox *fromBox, *from, *receiversBox, *subjectBox, *priority;
42 QLineEdit *replyto, *to, *cc, *bcc, *subject;
43 QToolBar *toolbar, *attachToolbar;
44 QAction *sendmail, *attachfile, *addressbook, *abort, *addattach, *delattach;
45 QLabel *fromLabel, *status;
46
47protected slots:
48 void slotAttachfileChanged(bool toggled);
49 void slotFromMenuChanged(int id);
50 void slotReceiverMenuChanged(int id);
51 void slotSubjectMenuChanged(int id);
52
53};
54
55#endif
diff --git a/noncore/unsupported/mail2/configdiag.cpp b/noncore/unsupported/mail2/configdiag.cpp
new file mode 100644
index 0000000..be1f1f4
--- a/dev/null
+++ b/noncore/unsupported/mail2/configdiag.cpp
@@ -0,0 +1,144 @@
1#include <qmessagebox.h>
2#include <qpushbutton.h>
3#include <qtoolbutton.h>
4#include <qgroupbox.h>
5#include <qcheckbox.h>
6#include <qspinbox.h>
7#include <qheader.h>
8#include <qtimer.h>
9#include <qlabel.h>
10
11#include <qpe/resource.h>
12#include <qpe/config.h>
13
14#include "accounteditor.h"
15#include "zaurusstuff.h"
16#include "configdiag.h"
17#include "defines.h"
18
19AccountListItem::AccountListItem(QListView *parent, Account &account)
20 : QListViewItem(parent), _account(account)
21{
22 QString displayText;
23 if (!_account.realName().isEmpty() && !_account.email().isEmpty())
24 setText(0, _account.realName() + " <" + _account.email() + ">");
25 else if (_account.realName().isEmpty() && !_account.email().isEmpty())
26 setText(0, _account.email());
27 else if (!_account.realName().isEmpty() && _account.email().isEmpty())
28 setText(0, _account.realName());
29 else
30 setText(0, QObject::tr("(no name)"));
31
32 setPixmap(0, Resource::loadPixmap("mail/inbox"));
33}
34
35ConfigDiag::ConfigDiag(QWidget *parent, const char *name, bool modal, WFlags fl)
36 : ConfigDiagBase(parent, name, modal, fl)
37{
38 _configBenD = new Config("mail");
39 _configBenD->setGroup("Settings");
40 disabled->setChecked(_configBenD->readBoolEntry("Disabled", false));
41 playSound->setChecked(_configBenD->readBoolEntry("PlaySound", false));
42 blinkLed->setChecked(_configBenD->readBoolEntry("BlinkLed", true));
43 checkDelay->setValue(_configBenD->readNumEntry("CheckDelay", 5));
44
45 accountList->header()->hide();
46 disclaimer->setText(disclaimer->text().arg(VERSION));
47
48 connect(accountNew, SIGNAL(clicked()), SLOT(slotNewAccount()));
49 connect(accountEdit, SIGNAL(clicked()), SLOT(slotEditAccount()));
50 connect(accountDelete, SIGNAL(clicked()), SLOT(slotDelAccount()));
51
52 connect(testbutton, SIGNAL(clicked()), SLOT(slotTestSettings()));
53
54 slotFillLists();
55}
56
57void ConfigDiag::accept()
58{
59 _configBenD->setGroup("Settings");
60 _configBenD->writeEntry("Disabled", disabled->isChecked());
61 _configBenD->writeEntry("PlaySound", playSound->isChecked());
62 _configBenD->writeEntry("BlinkLed", blinkLed->isChecked());
63 _configBenD->writeEntry("CheckDelay", checkDelay->value());
64 _configBenD->write();
65
66 QDialog::accept();
67}
68
69void ConfigDiag::slotFillLists()
70{
71 accountList->clear();
72
73 QValueList<Account> accounts = ConfigFile::getAccounts();
74
75 QValueList<Account>::Iterator it;
76 for (it = accounts.begin(); it != accounts.end(); it++)
77 (void) new AccountListItem(accountList, *it);
78}
79
80void ConfigDiag::slotNewAccount()
81{
82 AccountEditor *editor = new AccountEditor(Account(), 0, 0, true);
83 editor->showMaximized();
84 editor->show();
85
86 if (QDialog::Accepted == editor->exec()) {
87 ConfigFile::updateAccount(editor->_account);
88 slotFillLists();
89 emit changed();
90 }
91}
92
93void ConfigDiag::slotEditAccount()
94{
95 if (!accountList->currentItem()) {
96 QMessageBox::information(this, tr("Error"), tr("<p>You have to select an account first.</p>"), tr("Ok"));
97 return;
98 }
99 Account account = ((AccountListItem *)accountList->currentItem())->account();
100
101 AccountEditor *editor = new AccountEditor(account, 0, 0, true);
102 editor->showMaximized();
103 editor->show();
104
105 if (QDialog::Accepted == editor->exec()) {
106 ConfigFile::updateAccount(editor->_account);
107 slotFillLists();
108 emit changed();
109 }
110}
111
112void ConfigDiag::slotDelAccount()
113{
114 if (!accountList->currentItem()) {
115 QMessageBox::information(this, tr("Error"), tr("<p>You have to select an account first.</p>"), tr("Ok"));
116 return;
117 }
118 Account account = ((AccountListItem *)accountList->currentItem())->account();
119
120 int ret = QMessageBox::information(this, tr("Question"), tr("<p>Do you relly want to delete the selected account?</p>"), tr("Yes"), tr("No"));
121 if (1 == ret) return;
122
123 ConfigFile::deleteAccount(account);
124 slotFillLists();
125 emit changed();
126}
127
128void ConfigDiag::slotTestSettings()
129{
130 testbutton->setEnabled(false);
131
132 if (blinkLed->isChecked()) ZaurusStuff::blinkLedOn();
133 if (playSound->isChecked()) ZaurusStuff::buzzerOn();
134 QTimer::singleShot(3000, this, SLOT(slotEndTest()));
135}
136
137void ConfigDiag::slotEndTest()
138{
139 if (playSound->isChecked()) ZaurusStuff::buzzerOff();
140 if (blinkLed->isChecked()) ZaurusStuff::blinkLedOff();
141
142 testbutton->setEnabled(true);
143}
144
diff --git a/noncore/unsupported/mail2/configdiag.h b/noncore/unsupported/mail2/configdiag.h
new file mode 100644
index 0000000..f70ba7f
--- a/dev/null
+++ b/noncore/unsupported/mail2/configdiag.h
@@ -0,0 +1,48 @@
1#ifndef CONFIGDIAG_H
2#define CONFIGDIAG_H
3
4#include <qlistview.h>
5
6#include "configdiagbase.h"
7#include "configfile.h"
8
9class Config;
10class Account;
11
12class AccountListItem : public QListViewItem
13{
14public:
15 AccountListItem(QListView *parent, Account &account);
16
17 Account account() { return _account; }
18
19protected:
20 Account _account;
21
22};
23
24class ConfigDiag : public ConfigDiagBase
25{
26 Q_OBJECT
27
28public:
29 ConfigDiag(QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags fl = 0);
30
31signals:
32 void changed();
33
34protected slots:
35 void accept();
36 void slotFillLists();
37 void slotNewAccount();
38 void slotEditAccount();
39 void slotDelAccount();
40 void slotTestSettings();
41 void slotEndTest();
42
43private:
44 Config *_configBenD;
45
46};
47
48#endif
diff --git a/noncore/unsupported/mail2/configdiagbase.ui b/noncore/unsupported/mail2/configdiagbase.ui
new file mode 100644
index 0000000..754458a
--- a/dev/null
+++ b/noncore/unsupported/mail2/configdiagbase.ui
@@ -0,0 +1,352 @@
1<!DOCTYPE UI><UI>
2<class>ConfigDiagBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>ConfigDiagBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>260</width>
15 <height>344</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Configuration</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <grid>
29 <property stdset="1">
30 <name>margin</name>
31 <number>0</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>0</number>
36 </property>
37 <widget row="0" column="0" >
38 <class>QTabWidget</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>TabWidget2</cstring>
42 </property>
43 <property>
44 <name>layoutMargin</name>
45 </property>
46 <property>
47 <name>layoutSpacing</name>
48 </property>
49 <widget>
50 <class>QWidget</class>
51 <property stdset="1">
52 <name>name</name>
53 <cstring>tab</cstring>
54 </property>
55 <attribute>
56 <name>title</name>
57 <string>Accounts</string>
58 </attribute>
59 <grid>
60 <property stdset="1">
61 <name>margin</name>
62 <number>4</number>
63 </property>
64 <property stdset="1">
65 <name>spacing</name>
66 <number>3</number>
67 </property>
68 <widget row="1" column="1" >
69 <class>QPushButton</class>
70 <property stdset="1">
71 <name>name</name>
72 <cstring>accountEdit</cstring>
73 </property>
74 <property stdset="1">
75 <name>text</name>
76 <string>Edit</string>
77 </property>
78 </widget>
79 <widget row="1" column="2" >
80 <class>QPushButton</class>
81 <property stdset="1">
82 <name>name</name>
83 <cstring>accountDelete</cstring>
84 </property>
85 <property stdset="1">
86 <name>text</name>
87 <string>Delete</string>
88 </property>
89 </widget>
90 <widget row="0" column="0" rowspan="1" colspan="3" >
91 <class>QListView</class>
92 <column>
93 <property>
94 <name>text</name>
95 <string>[Hidden]</string>
96 </property>
97 <property>
98 <name>clickable</name>
99 <bool>true</bool>
100 </property>
101 <property>
102 <name>resizeable</name>
103 <bool>true</bool>
104 </property>
105 </column>
106 <property stdset="1">
107 <name>name</name>
108 <cstring>accountList</cstring>
109 </property>
110 </widget>
111 <widget row="1" column="0" >
112 <class>QPushButton</class>
113 <property stdset="1">
114 <name>name</name>
115 <cstring>accountNew</cstring>
116 </property>
117 <property stdset="1">
118 <name>text</name>
119 <string>New</string>
120 </property>
121 </widget>
122 </grid>
123 </widget>
124 <widget>
125 <class>QWidget</class>
126 <property stdset="1">
127 <name>name</name>
128 <cstring>tab</cstring>
129 </property>
130 <attribute>
131 <name>title</name>
132 <string>General</string>
133 </attribute>
134 <grid>
135 <property stdset="1">
136 <name>margin</name>
137 <number>4</number>
138 </property>
139 <property stdset="1">
140 <name>spacing</name>
141 <number>3</number>
142 </property>
143 <spacer row="1" column="0" >
144 <property>
145 <name>name</name>
146 <cstring>Spacer5</cstring>
147 </property>
148 <property stdset="1">
149 <name>orientation</name>
150 <enum>Vertical</enum>
151 </property>
152 <property stdset="1">
153 <name>sizeType</name>
154 <enum>Expanding</enum>
155 </property>
156 <property>
157 <name>sizeHint</name>
158 <size>
159 <width>20</width>
160 <height>20</height>
161 </size>
162 </property>
163 </spacer>
164 <widget row="0" column="0" >
165 <class>QGroupBox</class>
166 <property stdset="1">
167 <name>name</name>
168 <cstring>notificationGroup</cstring>
169 </property>
170 <property stdset="1">
171 <name>title</name>
172 <string>Mail notification</string>
173 </property>
174 <property>
175 <name>layoutMargin</name>
176 </property>
177 <property>
178 <name>layoutSpacing</name>
179 </property>
180 <grid>
181 <property stdset="1">
182 <name>margin</name>
183 <number>4</number>
184 </property>
185 <property stdset="1">
186 <name>spacing</name>
187 <number>3</number>
188 </property>
189 <widget row="1" column="0" >
190 <class>QFrame</class>
191 <property stdset="1">
192 <name>name</name>
193 <cstring>Frame3</cstring>
194 </property>
195 <property stdset="1">
196 <name>frameShape</name>
197 <enum>NoFrame</enum>
198 </property>
199 <property stdset="1">
200 <name>frameShadow</name>
201 <enum>Raised</enum>
202 </property>
203 <property>
204 <name>layoutMargin</name>
205 </property>
206 <property>
207 <name>layoutSpacing</name>
208 </property>
209 <grid>
210 <property stdset="1">
211 <name>margin</name>
212 <number>0</number>
213 </property>
214 <property stdset="1">
215 <name>spacing</name>
216 <number>3</number>
217 </property>
218 <widget row="1" column="0" rowspan="1" colspan="3" >
219 <class>QCheckBox</class>
220 <property stdset="1">
221 <name>name</name>
222 <cstring>blinkLed</cstring>
223 </property>
224 <property stdset="1">
225 <name>sizePolicy</name>
226 <sizepolicy>
227 <hsizetype>3</hsizetype>
228 <vsizetype>0</vsizetype>
229 </sizepolicy>
230 </property>
231 <property stdset="1">
232 <name>text</name>
233 <string>Blink LED (Zaurus only)</string>
234 </property>
235 </widget>
236 <widget row="2" column="2" >
237 <class>QToolButton</class>
238 <property stdset="1">
239 <name>name</name>
240 <cstring>testbutton</cstring>
241 </property>
242 <property stdset="1">
243 <name>text</name>
244 <string> Test </string>
245 </property>
246 </widget>
247 <widget row="0" column="0" rowspan="1" colspan="3" >
248 <class>QCheckBox</class>
249 <property stdset="1">
250 <name>name</name>
251 <cstring>playSound</cstring>
252 </property>
253 <property stdset="1">
254 <name>text</name>
255 <string>Play sound (Zaurus only)</string>
256 </property>
257 </widget>
258 <widget row="2" column="0" >
259 <class>QLabel</class>
260 <property stdset="1">
261 <name>name</name>
262 <cstring>TextLabel1</cstring>
263 </property>
264 <property stdset="1">
265 <name>text</name>
266 <string>&lt;b&gt;Check&amp;nbsp;every</string>
267 </property>
268 </widget>
269 <widget row="2" column="1" >
270 <class>QSpinBox</class>
271 <property stdset="1">
272 <name>name</name>
273 <cstring>checkDelay</cstring>
274 </property>
275 <property stdset="1">
276 <name>sizePolicy</name>
277 <sizepolicy>
278 <hsizetype>3</hsizetype>
279 <vsizetype>0</vsizetype>
280 </sizepolicy>
281 </property>
282 <property stdset="1">
283 <name>suffix</name>
284 <string> min</string>
285 </property>
286 <property stdset="1">
287 <name>maxValue</name>
288 <number>30</number>
289 </property>
290 <property stdset="1">
291 <name>minValue</name>
292 <number>1</number>
293 </property>
294 <property stdset="1">
295 <name>value</name>
296 <number>1</number>
297 </property>
298 </widget>
299 </grid>
300 </widget>
301 <widget row="0" column="0" >
302 <class>QCheckBox</class>
303 <property stdset="1">
304 <name>name</name>
305 <cstring>disabled</cstring>
306 </property>
307 <property stdset="1">
308 <name>text</name>
309 <string>Disable mail notification</string>
310 </property>
311 </widget>
312 </grid>
313 </widget>
314 <widget row="2" column="0" >
315 <class>QLabel</class>
316 <property stdset="1">
317 <name>name</name>
318 <cstring>disclaimer</cstring>
319 </property>
320 <property stdset="1">
321 <name>text</name>
322 <string>&lt;p&gt;&lt;b&gt;Mail version %1&lt;/b&gt;&lt;hr&gt;
323Sponsored and Programmed by LISAsystems&lt;br&gt;
324Visit http://www.lisa.de/ for Information.
325 </string>
326 </property>
327 </widget>
328 </grid>
329 </widget>
330 </widget>
331 </grid>
332</widget>
333<connections>
334 <connection>
335 <sender>disabled</sender>
336 <signal>toggled(bool)</signal>
337 <receiver>Frame3</receiver>
338 <slot>setDisabled(bool)</slot>
339 </connection>
340</connections>
341<tabstops>
342 <tabstop>TabWidget2</tabstop>
343 <tabstop>accountList</tabstop>
344 <tabstop>accountNew</tabstop>
345 <tabstop>accountEdit</tabstop>
346 <tabstop>accountDelete</tabstop>
347 <tabstop>disabled</tabstop>
348 <tabstop>playSound</tabstop>
349 <tabstop>blinkLed</tabstop>
350 <tabstop>checkDelay</tabstop>
351</tabstops>
352</UI>
diff --git a/noncore/unsupported/mail2/folderwidget.cpp b/noncore/unsupported/mail2/folderwidget.cpp
new file mode 100644
index 0000000..ca2bb5a
--- a/dev/null
+++ b/noncore/unsupported/mail2/folderwidget.cpp
@@ -0,0 +1,314 @@
1#include <qmessagebox.h>
2#include <qtextstream.h>
3#include <qpopupmenu.h>
4#include <qheader.h>
5#include <qfile.h>
6#include <qdir.h>
7
8#include <qpe/resource.h>
9
10#include <stdlib.h>
11
12#include "folderwidget.h"
13#include "imaphandler.h"
14#include "imapbase.h"
15#include "rename.h"
16
17FolderWidgetItem::FolderWidgetItem(Folder &folder, QListView *parent)
18 : QListViewItem(parent), _folder(folder)
19{
20 setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox")));
21 setText(0, _folder.topFolder().account().user() + " (" + _folder.topFolder().account().imapServer() + ")");
22 setOpen(true);
23}
24
25FolderWidgetItem::FolderWidgetItem(Folder &folder, FolderWidgetItem *parent)
26 : QListViewItem(parent), _folder(folder)
27{
28 if (_folder.noCache()) {
29 setText(0, QObject::tr("<Foldertree not known.>"));
30 } else {
31 if (folder.fullName().upper() == "INBOX") {
32 setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox")));
33 setText(0, QObject::tr("Inbox"));
34 } else {
35 setPixmap(0, QPixmap(Resource::loadPixmap("mail/folder")));
36 setText(0, folder.fullName());
37 }
38 setOpen(true);
39 }
40}
41
42FolderWidget::FolderWidget(QWidget *parent, const char *name, WFlags fl)
43 : ListViewPlus(parent, name, fl)
44{
45 header()->hide();
46 addColumn("");
47 setSorting(-1);
48
49 QPopupMenu *menu = new QPopupMenu();
50 menu->insertItem(tr("Rename"), MENU_RENAME);
51 menu->insertItem(tr("Delete"), MENU_DELETE);
52 menu->insertItem(tr("Move"), MENU_MOVE);
53 menu->insertItem(tr("Copy"), MENU_COPY);
54 menu->insertSeparator();
55 menu->insertItem(tr("Create folder"), MENU_CREATE);
56 menu->insertSeparator();
57 menu->insertItem(tr("Rescan folder list"), MENU_RESCAN);
58 setPopup(menu);
59
60 getAccounts();
61
62 connect(menu, SIGNAL(activated(int)), SLOT(slotMenuActivated(int)));
63 connect(this, SIGNAL(clicked(QListViewItem *)), SLOT(slotItemClicked(QListViewItem *)));
64}
65
66FolderWidget::~FolderWidget()
67{
68 // TODO: Save folder tree.
69}
70
71void FolderWidget::update()
72{
73 getAccounts();
74}
75
76void FolderWidget::getAccounts()
77{
78 clear();
79
80 QValueList<Account> accounts = ConfigFile::getAccounts();
81 QValueList<Account>::Iterator it;
82 for (it = accounts.begin(); it != accounts.end(); it++) {
83 FolderWidgetItem *item = addAccount(*it);
84 QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + (*it).accountName());
85 if (!f.open(IO_ReadOnly)) {
86 Folder folder;
87 folder.setNoCache(true);
88 addFolder(folder, item);
89 } else {
90 QTextStream t(&f);
91 while (!t.atEnd()) {
92 QString separator = t.readLine();
93 QString fullname = t.readLine();
94 Folder folder;
95 folder.setSeparator(separator);
96 folder.setFullName(fullname);
97 folder.setTopFolder(item->folder().topFolder());
98 addFolder(folder, item);
99 }
100 f.close();
101 }
102 }
103}
104
105FolderWidgetItem *FolderWidget::addAccount(Account &account)
106{
107 TopFolder tf;
108 tf.setAccount(account);
109
110 // XXX This has to change!!! The folderwidget may not create an
111 // XXX IMAPHandler!!!! Do this in IMAPHandler!
112 tf.setIMAPHandler(new IMAPHandler(account));
113
114 Folder folder;
115 folder.setTopFolder(tf);
116
117 connect(tf.handler(), SIGNAL(IMAPLookingUpHost()), SLOT(slotIMAPLookingUpHost()));
118 connect(tf.handler(), SIGNAL(IMAPHostFound()), SLOT(slotIMAPHostFound()));
119 connect(tf.handler(), SIGNAL(IMAPConnected()), SLOT(slotIMAPConnected()));
120 connect(tf.handler(), SIGNAL(IMAPDisconnected()), SLOT(slotIMAPDisconnected()));
121 connect(tf.handler(), SIGNAL(IMAPError(int)), SLOT(slotIMAPError(int)));
122
123 return new FolderWidgetItem(folder, this);
124}
125
126FolderWidgetItem *FolderWidget::addFolder(Folder &folder, FolderWidgetItem *folderWidgetItem)
127{
128 return new FolderWidgetItem(folder, folderWidgetItem);
129}
130
131void FolderWidget::slotMenuActivated(int itemid)
132{
133 if (currentItem() == NULL) {
134 QMessageBox::information(this, tr("Error"), tr("<p>Please select an item first.</p>"), tr("Ok"));
135 return;
136 }
137
138 if (itemid == MENU_RENAME) {
139 if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return;
140
141 Folder folder = ((FolderWidgetItem *)currentItem())->folder();
142 QString newName = Rename::rename(folder.fullName(), this);
143 if (newName.isNull()) return;
144
145 folder.topFolder().handler()->iRename(folder.fullName(), newName);
146 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPRename(IMAPResponse &)));
147 } else if (itemid == MENU_DELETE) {
148 if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return;
149
150 Folder folder = ((FolderWidgetItem *)currentItem())->folder();
151
152 int ret = QMessageBox::information(this, tr("Question"), tr("<p>Do you really want to delete <pre>%1</pre>?").arg(folder.fullName()), tr("Yes"), tr("No"));
153 if (ret == 1) return;
154
155 _createFolder = folder;
156
157 folder.topFolder().handler()->iDelete(folder.fullName());
158 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPDelete(IMAPResponse &)));
159 } else if (itemid == MENU_MOVE) {
160
161 } else if (itemid == MENU_COPY) {
162
163 } else if (itemid == MENU_CREATE) {
164 Folder folder = (((FolderWidgetItem *)currentItem())->folder());
165 _createFolder = folder;
166
167 QString folderName = Rename::getText(tr("Foldername"), tr("<p>Please enter the name of the new folder.</p>"), this);
168 if (folderName.isNull()) return;
169
170 folder.topFolder().handler()->iCreate(folder.fullName() + folder.separator() + folderName);
171 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPCreate(IMAPResponse &)));
172 } else if (itemid == MENU_RESCAN) {
173 Folder folder = (((FolderWidgetItem *)currentItem())->folder());
174 _rescanAccount = folder.topFolder().account();
175
176 folder.topFolder().handler()->iList(".", "*");
177 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &)));
178 }
179}
180
181void FolderWidget::slotItemClicked(QListViewItem *item)
182{
183 if (item == NULL) return;
184 Folder folder = ((FolderWidgetItem *)item)->folder();
185 if (folder.fullName().isEmpty()) return;
186
187 emit folderSelected(folder);
188}
189
190void FolderWidget::slotIMAPLookingUpHost()
191{
192 emit status(tr("Looking up host..."));
193 emit connecting();
194}
195
196void FolderWidget::slotIMAPHostFound()
197{
198 emit status(tr("Host found."));
199}
200
201void FolderWidget::slotIMAPConnected()
202{
203 emit status(tr("Connected to host."));
204 emit connected();
205}
206
207void FolderWidget::slotIMAPError(int error)
208{
209 if (error == IMAPBase::IMAPErrConnectionRefused) {
210 QMessageBox::warning(this, tr("Error"), tr("<p>The IMAP connection was refused.</p>"), tr("Ok"));
211 } else if (error == IMAPBase::IMAPErrHostNotFound) {
212 QMessageBox::warning(this, tr("Error"), tr("<p>The host was not found.</p>"), tr("Ok"));
213 } else if (error == IMAPBase::IMAPErrSocketRead) {
214 QMessageBox::warning(this, tr("Error"), tr("<p>There was an error while reading from the socket.</p>"), tr("Ok"));
215 } else if (error == IMAPBase::IMAPErrLoginFailed) {
216 QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Check your password/username.</p>"), tr("Ok"));
217 } else {
218 QMessageBox::warning(this, tr("Error"), tr("<p>An unknown error was encountered.</p>"), tr("Ok"));
219 }
220}
221
222void FolderWidget::slotIMAPDisconnected()
223{
224 emit status(tr("Disconnected."));
225 emit disconnected();
226}
227
228void FolderWidget::slotIMAPLogin(IMAPResponse &response)
229{
230 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPLogin(IMAPResponse &)));
231
232 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
233 emit status(tr("Login successfull!"));
234 } else {
235 QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Go away.</p>"), tr("Ok"));
236 }
237}
238
239void FolderWidget::slotIMAPRename(IMAPResponse &response)
240{
241 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPRename(IMAPResponse &)));
242
243 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
244 emit status(tr("Renaming successfull!"));
245 } else {
246 QMessageBox::warning(this, tr("Error"), tr("<p>Renaming failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok"));
247 }
248}
249
250void FolderWidget::slotIMAPDelete(IMAPResponse &response)
251{
252 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPDelete(IMAPResponse &)));
253
254 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
255 emit status(tr("Deletion successfull!"));
256
257 _rescanAccount = _createFolder.topFolder().account();
258
259 _createFolder.topFolder().handler()->iList(".", "*");
260 connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &)));
261 } else {
262 QMessageBox::warning(this, tr("Error"), tr("<p>Delete failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok"));
263 }
264}
265
266void FolderWidget::slotIMAPCreate(IMAPResponse &response)
267{
268 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPCreate(IMAPResponse &)));
269
270 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
271 emit status(tr("Folder created. Rescanning..."));
272
273 _rescanAccount = _createFolder.topFolder().account();
274
275 _createFolder.topFolder().handler()->iList(".", "*");
276 connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &)));
277 } else {
278 QMessageBox::warning(this, tr("Error"), tr("<p>The folder could not be created. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok"));
279 }
280}
281
282void FolderWidget::slotIMAPList(IMAPResponse &response)
283{
284 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPList(IMAPResponse &)));
285
286 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
287 QDir d((QString) getenv("HOME") + "/Applications/mail/foldercache");
288 if (!d.exists()) {
289 system("mkdir -p $HOME/Applications/mail/foldercache");
290 qWarning("Created $HOME/Applications/mail/foldercache.");
291 }
292 QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + _rescanAccount.accountName());
293 if (!f.open(IO_WriteOnly)) {
294 QMessageBox::critical(this, tr("Error"), tr("<p>Couldn't open folder cache file for writing!</p>"), tr("Ok"));
295 return;
296 }
297 QTextStream t(&f);
298
299 QValueList<IMAPResponseLIST>::Iterator it;
300 QValueList<IMAPResponseLIST> lists = response.LIST();
301 for (it = lists.begin(); it != lists.end(); it++) {
302 t << (*it).folderSeparator() << "\n";
303 t << (*it).folder() << "\n";
304 }
305
306 f.close();
307
308 emit status(tr("Got folder list."));
309 getAccounts();
310 } else {
311 QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't retrieve the folder list. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok"));
312 }
313}
314
diff --git a/noncore/unsupported/mail2/folderwidget.h b/noncore/unsupported/mail2/folderwidget.h
new file mode 100644
index 0000000..bb10319
--- a/dev/null
+++ b/noncore/unsupported/mail2/folderwidget.h
@@ -0,0 +1,123 @@
1#ifndef FOLDERWIDGET_H
2#define FOLDERWIDGET_H
3
4#include "imapresponse.h"
5#include "listviewplus.h"
6#include "configfile.h"
7
8class IMAPHandler;
9
10class TopFolder
11{
12public:
13 TopFolder()
14 {
15 _valid = true;
16 }
17
18 bool isValid() { return _valid; }
19 void setAccount(Account account) { _account = account; }
20 Account account() { return _account; }
21 void setIMAPHandler(IMAPHandler *handler) { _handler = handler; }
22 IMAPHandler *handler() { return _handler; }
23
24private:
25 bool _valid;
26 Account _account;
27 IMAPHandler *_handler;
28
29};
30
31class Folder
32{
33public:
34 Folder()
35 {
36 _valid = true;
37 _noCache = false;
38 }
39
40 bool isValid() { return _valid; }
41 void setNoCache(bool noCache) { _noCache = noCache; }
42 bool noCache() { return _noCache; }
43 void setFullName(QString fullName) { _fullName = fullName; }
44 QString fullName() { return _fullName; }
45 void setSeparator(QString separator) { _separator = separator; }
46 QString separator() { return _separator; }
47 void setTopFolder(TopFolder topFolder) { _topFolder = topFolder; }
48 TopFolder topFolder() { return _topFolder; }
49
50private:
51 bool _valid, _noCache;
52 QString _fullName, _separator;
53 TopFolder _topFolder;
54
55};
56
57class FolderWidgetItem : public QListViewItem
58{
59public:
60 FolderWidgetItem(Folder &folder, QListView *parent);
61 FolderWidgetItem(Folder &folder, FolderWidgetItem *parent);
62
63 Folder folder() { return _folder; }
64
65private:
66 Folder _folder;
67
68};
69
70class FolderWidget : public ListViewPlus
71{
72 Q_OBJECT
73
74public:
75 FolderWidget(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
76 ~FolderWidget();
77
78public slots:
79 void update();
80
81signals:
82 void folderSelected(Folder folder);
83 void status(const QString &text);
84 void connecting();
85 void connected();
86 void disconnected();
87
88protected:
89 void getAccounts();
90 FolderWidgetItem *addFolder(Folder &folder, FolderWidgetItem *folderWidgetItem);
91 FolderWidgetItem *addAccount(Account &account);
92
93 static const int MENU_RENAME = 0;
94 static const int MENU_DELETE = 1;
95 static const int MENU_MOVE = 2;
96 static const int MENU_COPY = 3;
97 static const int MENU_CREATE = 4;
98 static const int MENU_RESCAN = 5;
99
100protected slots:
101 void slotMenuActivated(int itemid);
102 void slotItemClicked(QListViewItem *item);
103
104 void slotIMAPLookingUpHost();
105 void slotIMAPHostFound();
106 void slotIMAPConnected();
107 void slotIMAPError(int error);
108 void slotIMAPDisconnected();
109
110 void slotIMAPLogin(IMAPResponse &response);
111 void slotIMAPRename(IMAPResponse &response);
112 void slotIMAPDelete(IMAPResponse &response);
113 void slotIMAPCreate(IMAPResponse &response);
114 void slotIMAPList(IMAPResponse &response);
115
116private:
117 Account _rescanAccount;
118 Folder _createFolder;
119
120};
121
122#endif
123
diff --git a/noncore/unsupported/mail2/libmail/configfile.cpp b/noncore/unsupported/mail2/libmail/configfile.cpp
new file mode 100644
index 0000000..a5c2b49
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/configfile.cpp
@@ -0,0 +1,112 @@
1#include <qdir.h>
2
3#include <qpe/config.h>
4
5#include <stdlib.h>
6
7#include "configfile.h"
8
9ConfigFile::ConfigFile() : QObject()
10{
11 checkDirectory();
12
13 QDir dir((QString) getenv("HOME") + "/Applications/mail/accounts");
14 QStringList entries = dir.entryList("account-*");
15
16 QStringList::Iterator it;
17 for (it = entries.begin(); it != entries.end(); it++) {
18 Account account;
19
20 Config *config = new Config((QString) getenv("HOME") + "/Applications/mail/accounts/" + *it, Config::File);
21 config->setGroup("Account");
22 account.setAccountName((*it).replace(0, 8, ""));
23 account.setRealName(config->readEntry("RealName"));
24 account.setEmail(config->readEntry("Email"));
25 account.setOrg(config->readEntry("Organization"));
26 account.setImapServer(config->readEntry("ImapServer"));
27 account.setImapPort(config->readEntry("ImapPort"));
28 account.setSmtpServer(config->readEntry("SmtpServer"));
29 account.setSmtpPort(config->readEntry("SmtpPort"));
30 account.setUser(config->readEntry("User"));
31 account.setPass(rot13(config->readEntryCrypt("Pass")));
32 account.setSmtpSsl(config->readBoolEntry("SmtpSsl"));
33 account.setSmtpSslPort(config->readEntry("SmtpSslPort"));
34 account.setImapSsl(config->readBoolEntry("ImapSsl"));
35 account.setImapSslPort(config->readEntry("ImapSslPort"));
36 account.setDefaultCc(config->readBoolEntry("DefaultCc"));
37 account.setDefaultBcc(config->readBoolEntry("DefaultBcc"));
38 account.setDefaultReplyTo(config->readBoolEntry("DefaultReplyTo"));
39 account.setCc(config->readEntry("Cc"));
40 account.setBcc(config->readEntry("Bcc"));
41 account.setReplyTo(config->readEntry("ReplyTo"));
42 account.setSignature(config->readEntry("Signature").replace(QRegExp("<br>"), "\n"));
43
44 _accounts.append(account);
45 }
46}
47
48QValueList<Account> ConfigFile::getAccounts()
49{
50 ConfigFile *configFile = new ConfigFile();
51 return configFile->_accounts;
52}
53
54void ConfigFile::updateAccount(Account account)
55{
56 checkDirectory();
57 Config *config = new Config((QString) getenv("HOME") + "/Applications/mail/accounts/account-" + account.accountName(), Config::File);
58
59 config->setGroup("Account");
60 config->writeEntry("RealName", account.realName());
61 config->writeEntry("Email", account.email());
62 config->writeEntry("Organization", account.org());
63 config->writeEntry("ImapServer", account.imapServer());
64 config->writeEntry("ImapPort", account.imapPort());
65 config->writeEntry("SmtpServer", account.smtpServer());
66 config->writeEntry("SmtpPort", account.smtpPort());
67 config->writeEntry("User", account.user());
68 config->writeEntryCrypt("Pass", rot13(account.pass()));
69 config->writeEntry("SmtpSsl", account.smtpSsl());
70 config->writeEntry("SmtpSslPort", account.smtpSslPort());
71 config->writeEntry("ImapSsl", account.imapSsl());
72 config->writeEntry("ImapSslPort", account.imapSslPort());
73 config->writeEntry("DefaultCc", account.defaultCc());
74 config->writeEntry("DefaultBcc", account.defaultBcc());
75 config->writeEntry("DefaultReplyTo", account.defaultReplyTo());
76 config->writeEntry("Cc", account.cc());
77 config->writeEntry("Bcc", account.bcc());
78 config->writeEntry("ReplyTo", account.replyTo());
79 config->writeEntry("Signature", account.signature().replace(QRegExp("\\n"), "<br>"));
80
81 config->write();
82}
83
84void ConfigFile::deleteAccount(Account account)
85{
86 QFile f((QString) getenv("HOME") + "/Applications/mail/accounts/account-" + account.accountName());
87 f.remove();
88}
89
90void ConfigFile::checkDirectory()
91{
92 if (!QDir((QString) getenv("HOME") + "/Applications/mail/accounts").exists()) {
93 system("mkdir -p $HOME/Applications/mail/accounts");
94 qWarning("mail: $HOME/Applications/mail/accounts created");
95 }
96}
97
98QString ConfigFile::rot13(const QString &input)
99{
100 QString i = input;
101 int l = i.length();
102 while(l--) {
103 if (i[l] >= QChar('A') && i[l] <= QChar('M') ||
104 i[l] >= QChar('a') && i[l] <= QChar('m'))
105 i[l] = (char)((int)QChar(l[i])+13);
106 else if (i[l] >= QChar('N') && i[l] <= QChar('Z') ||
107 i[l] >= QChar('n') && i[l] <= QChar('z'))
108 i[l] = (char)((int)QChar(l[i])-13);
109 }
110 return i;
111}
112
diff --git a/noncore/unsupported/mail2/libmail/configfile.h b/noncore/unsupported/mail2/libmail/configfile.h
new file mode 100644
index 0000000..84b57d5
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/configfile.h
@@ -0,0 +1,97 @@
1#ifndef CONFIGFILE_H
2#define CONFIGFILE_H
3
4#include <qobject.h>
5
6class Config;
7
8class Account
9{
10public:
11 Account()
12 {
13 _smtpssl = false;
14 _imapssl = false;
15 _dateField = false;
16 _msgIdField = false;
17 _defaultCc = false;
18 _defaultBcc = false;
19 _defaultRep = false;
20 }
21
22 void setAccountName(QString accountName) { _accountName = accountName; }
23
24 void setRealName(QString name) { _name = name; }
25 void setEmail(QString email) { _email = email; }
26 void setOrg(QString org) { _org = org; }
27 void setImapServer(QString imapServer) { _imapServer = imapServer; }
28 void setImapPort(QString imapPort) { _imapPort = imapPort; }
29 void setSmtpServer(QString smtpServer) { _smtpServer = smtpServer; }
30 void setSmtpPort(QString smtpPort) { _smtpPort = smtpPort; }
31 void setUser(QString user) { _user = user; }
32 void setPass(QString pass) { _pass = pass; }
33 void setSmtpSsl(bool smtpssl) { _smtpssl = smtpssl; }
34 void setSmtpSslPort(QString smtpSslPort) { _smtpSslPort = smtpSslPort; }
35 void setImapSsl(bool imapssl) { _imapssl = imapssl; }
36 void setImapSslPort(QString imapSslPort) { _imapSslPort = imapSslPort; }
37 void setDateField(bool dateField) { _dateField = dateField; }
38 void setMsgIdField(bool msgIdField) { _msgIdField = msgIdField; }
39 void setDefaultCc(bool defaultCc) { _defaultCc = defaultCc; }
40 void setDefaultBcc(bool defaultBcc) { _defaultBcc = defaultBcc; }
41 void setDefaultReplyTo(bool defaultRep) { _defaultRep = defaultRep; }
42 void setCc(QString cc) { _cc = cc; }
43 void setBcc(QString bcc) { _bcc = bcc; }
44 void setReplyTo(QString replyTo) { _replyTo = replyTo; }
45 void setSignature(QString signature) { _signature = signature; }
46
47 QString accountName() { return _accountName; }
48
49 QString realName() { return _name; }
50 QString email() { return _email; }
51 QString org() { return _org; }
52 QString imapServer() { return _imapServer; }
53 QString imapPort() { return _imapPort; }
54 QString smtpServer() { return _smtpServer; }
55 QString smtpPort() { return _smtpPort; }
56 QString user() { return _user; }
57 QString pass() { return _pass; }
58 bool smtpSsl() { return _smtpssl; }
59 QString smtpSslPort() { return _smtpSslPort; }
60 bool imapSsl() { return _imapssl; }
61 QString imapSslPort() { return _imapSslPort; }
62 bool dateField() { return _dateField; }
63 bool msgIdField() { return _msgIdField; }
64 bool defaultCc() { return _defaultCc; }
65 bool defaultBcc() { return _defaultBcc; }
66 bool defaultReplyTo() { return _defaultRep; }
67 QString cc() { return _cc; }
68 QString bcc() { return _bcc; }
69 QString replyTo() { return _replyTo; }
70 QString signature() { return _signature; }
71
72private:
73 QString _accountName, _name, _email, _org, _imapServer, _smtpServer, _user, _pass, _cc, _bcc, _replyTo, _imapPort, _smtpPort, _signature, _smtpSslPort, _imapSslPort;
74 bool _dateField, _msgIdField, _defaultCc, _defaultBcc, _defaultRep, _smtpssl, _imapssl;
75
76};
77
78class ConfigFile : public QObject
79{
80 Q_OBJECT
81
82public:
83 static QValueList<Account> getAccounts();
84 static void updateAccount(Account account);
85 static void deleteAccount(Account account);
86
87protected:
88 static void checkDirectory();
89 static QString rot13(const QString &input);
90
91 ConfigFile();
92
93 QValueList<Account> _accounts;
94
95};
96
97#endif
diff --git a/noncore/unsupported/mail2/libmail/defines.h b/noncore/unsupported/mail2/libmail/defines.h
new file mode 100644
index 0000000..489cb0e
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/defines.h
@@ -0,0 +1,8 @@
1#ifndef DEFINES_H
2#define DEFINES_H
3
4#define VERSION "0.0.9"
5
6#define USERAGENT "LISAMail/" + VERSION
7
8#endif
diff --git a/noncore/unsupported/mail2/libmail/imapbase.cpp b/noncore/unsupported/mail2/libmail/imapbase.cpp
new file mode 100644
index 0000000..9a2ba47
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/imapbase.cpp
@@ -0,0 +1,110 @@
1#include <qsocket.h>
2#include <qtimer.h>
3
4#include "imapbase.h"
5
6IMAPBase::IMAPBase(const Account &account)
7 : QObject(), _account(account)
8{
9 _connected = false;
10 _writingAllowed = false;
11 _socket = new QSocket(this);
12
13 connect(_socket, SIGNAL(readyRead()), SLOT(slotDataAvailiable()));
14 connect(_socket, SIGNAL(hostFound()), SLOT(slotHostFound()));
15 connect(_socket, SIGNAL(connected()), SLOT(slotConnected()));
16 connect(_socket, SIGNAL(connectionClosed()), SLOT(slotDisconnected()));
17 connect(_socket, SIGNAL(error(int)), SLOT(slotError(int)));
18
19 QTimer *commandTimer = new QTimer(this);
20 commandTimer->start(200);
21 connect(commandTimer, SIGNAL(timeout()), SLOT(writeCommands()));
22}
23
24void IMAPBase::sendCommand(const QString &command)
25{
26 if (!_connected) makeConnect();
27 _commandQueue.append(command);
28}
29
30void IMAPBase::disconnect()
31{
32 _connected = false;
33 delete _socket;
34 emit disconnected();
35}
36
37void IMAPBase::makeConnect()
38{
39 emit lookingUpHost();
40 if (_socket == NULL) _socket = new QSocket(this);
41
42 Q_UINT16 port = _account.imapPort().toUInt();
43 _socket->connectToHost(_account.imapServer(), port);
44}
45
46void IMAPBase::writeCommands()
47{
48 if (!_connected) return;
49 if (_commandQueue.isEmpty()) return;
50 if (!_writingAllowed) return;
51
52 QStringList::Iterator it;
53 for (it = _commandQueue.begin(); it != _commandQueue.end(); it++) {
54 if (!(*it).isEmpty() && _writingAllowed) {
55#ifndef QT_NO_DEBUG
56 qDebug("IMAP > " + (*it).stripWhiteSpace());
57#endif
58 _socket->writeBlock((*it).latin1(), (*it).length());
59 _writingAllowed = false;
60 _commandQueue.remove(it);
61 break;
62 }
63 }
64}
65
66void IMAPBase::slotError(int err)
67{
68 if (err == QSocket::ErrConnectionRefused) {
69 emit error(IMAPErrConnectionRefused);
70 } else if (err == QSocket::ErrHostNotFound) {
71 emit error(IMAPErrHostNotFound);
72 } else if (err == QSocket::ErrSocketRead) {
73 emit error(IMAPErrSocketRead);
74 } else {
75 emit error(IMAPErrUnknownError);
76 }
77}
78
79void IMAPBase::slotHostFound()
80{
81 emit hostFound();
82}
83
84void IMAPBase::slotConnected()
85{
86 _connected = true;
87 emit connected();
88}
89
90void IMAPBase::slotDisconnected()
91{
92 _connected = false;
93 emit disconnected();
94}
95
96void IMAPBase::slotDataAvailiable()
97{
98 while (_socket->canReadLine()) {
99 _data += _socket->readLine();
100 if (_socket->atEnd()) {
101#ifndef QT_NO_DEBUG
102 qDebug("IMAP < " + _data.stripWhiteSpace());
103#endif
104 emit dataReceived(_data);
105 _writingAllowed = true;
106 _data = QString(0);
107 }
108 }
109}
110
diff --git a/noncore/unsupported/mail2/libmail/imapbase.h b/noncore/unsupported/mail2/libmail/imapbase.h
new file mode 100644
index 0000000..e4a0b97
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/imapbase.h
@@ -0,0 +1,52 @@
1#ifndef IMAPBASE_H
2#define IMAPBASE_H
3
4#include <qobject.h>
5
6#include "configfile.h"
7
8class QSocket;
9
10class IMAPBase : public QObject
11{
12 Q_OBJECT
13
14public:
15 IMAPBase(const Account &account);
16
17 enum Error { IMAPErrConnectionRefused, IMAPErrHostNotFound,
18 IMAPErrSocketRead, IMAPErrUnknownError,
19 IMAPErrLoginFailed };
20
21 void sendCommand(const QString &command);
22 void disconnect();
23
24signals:
25 void dataReceived(const QString &data);
26 void lookingUpHost();
27 void hostFound();
28 void connected();
29 void disconnected();
30 void error(int err);
31
32protected:
33 void makeConnect();
34
35protected slots:
36 void writeCommands();
37 void slotError(int error);
38 void slotHostFound();
39 void slotConnected();
40 void slotDisconnected();
41 void slotDataAvailiable();
42
43private:
44 Account _account;
45 QString _data;
46 QSocket *_socket;
47 QStringList _commandQueue;
48 bool _connected, _writingAllowed;
49
50};
51
52#endif
diff --git a/noncore/unsupported/mail2/libmail/imaphandler.cpp b/noncore/unsupported/mail2/libmail/imaphandler.cpp
new file mode 100644
index 0000000..66c92c5
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/imaphandler.cpp
@@ -0,0 +1,334 @@
1#include "imapresponse.h"
2#include "imaphandler.h"
3#include "imapbase.h"
4
5IMAPHandler::IMAPHandler(const Account &account)
6 : QObject(), _account(account)
7{
8 _loggingin = false;
9 _loggedin = false;
10 _tag = 0;
11 _ibase = new IMAPBase(account);
12
13 connect(_ibase, SIGNAL(dataReceived(const QString &)), SLOT(slotDataReceived(const QString &)));
14 connect(_ibase, SIGNAL(lookingUpHost()), SLOT(slotLookingUpHost()));
15 connect(_ibase, SIGNAL(hostFound()), SLOT(slotHostFound()));
16 connect(_ibase, SIGNAL(connected()), SLOT(slotConnected()));
17 connect(_ibase, SIGNAL(disconnected()), SLOT(slotDisconnected()));
18 connect(_ibase, SIGNAL(error(int)), SLOT(slotError(int)));
19}
20
21void IMAPHandler::doLogin()
22{
23 if (_loggedin) return;
24 if (_loggingin) return;
25
26 _loggingin = true;
27 iLogin(_account.user(), _account.pass());
28}
29
30QString IMAPHandler::iCapability()
31{
32 _ibase->sendCommand(QString("%1 CAPABILITY\r\n")
33 .arg(tag()));
34 return tag(false);
35}
36
37QString IMAPHandler::iNoop()
38{
39 _ibase->sendCommand(QString("%1 NOOP\r\n")
40 .arg(tag()));
41 return tag(false);
42}
43
44QString IMAPHandler::iLogout()
45{
46 _ibase->sendCommand(QString("%1 LOGOUT\r\n")
47 .arg(tag()));
48 return tag(false);
49}
50
51QString IMAPHandler::iAuthenticate(const QString &mechanism)
52{
53 _ibase->sendCommand(QString("%1 AUTHENTICATE \"%2\"\r\n")
54 .arg(tag())
55 .arg(escape(mechanism)));
56 return tag(false);
57}
58
59QString IMAPHandler::iLogin(const QString &user, const QString &pass)
60{
61 _ibase->sendCommand(QString("%1 LOGIN \"%2\" \"%3\"\r\n")
62 .arg(tag())
63 .arg(escape(user))
64 .arg(escape(pass)));
65 return tag(false);
66}
67
68QString IMAPHandler::iSelect(const QString &mailbox)
69{
70 doLogin();
71
72 _ibase->sendCommand(QString("%1 SELECT \"%2\"\r\n")
73 .arg(tag())
74 .arg(escape(mailbox)));
75 return tag(false);
76}
77
78QString IMAPHandler::iExamine(const QString &mailbox)
79{
80 doLogin();
81
82 _ibase->sendCommand(QString("%1 EXAMINE \"%2\"\r\n")
83 .arg(tag())
84 .arg(escape(mailbox)));
85 return tag(false);
86}
87
88QString IMAPHandler::iCreate(const QString &mailbox)
89{
90 doLogin();
91
92 _ibase->sendCommand(QString("%1 CREATE \"%2\"\r\n")
93 .arg(tag())
94 .arg(escape(mailbox)));
95 return tag(false);
96}
97
98QString IMAPHandler::iDelete(const QString &mailbox)
99{
100 doLogin();
101
102 _ibase->sendCommand(QString("%1 DELETE \"%2\"\r\n")
103 .arg(tag())
104 .arg(escape(mailbox)));
105 return tag(false);
106}
107
108QString IMAPHandler::iRename(const QString &mailbox, const QString &newMailbox)
109{
110 doLogin();
111
112 _ibase->sendCommand(QString("%1 RENAME \"%2\" \"%3\"\r\n")
113 .arg(tag())
114 .arg(escape(mailbox))
115 .arg(escape(newMailbox)));
116 return tag(false);
117}
118
119QString IMAPHandler::iSubscribe(const QString &mailbox)
120{
121 doLogin();
122
123 _ibase->sendCommand(QString("%1 SUBSCRIBE \"%2\"\r\n")
124 .arg(tag())
125 .arg(escape(mailbox)));
126 return tag(false);
127}
128
129QString IMAPHandler::iUnsubscribe(const QString &mailbox)
130{
131 doLogin();
132
133 _ibase->sendCommand(QString("%1 UNSUBSCRIBE \"%2\"\r\n")
134 .arg(tag())
135 .arg(escape(mailbox)));
136 return tag(false);
137}
138
139QString IMAPHandler::iList(const QString &reference, const QString &mailbox)
140{
141 doLogin();
142
143 _ibase->sendCommand(QString("%1 LIST \"%2\" \"%3\"\r\n")
144 .arg(tag())
145 .arg(escape(reference))
146 .arg(escape(mailbox)));
147 return tag(false);
148}
149
150QString IMAPHandler::iLsub(const QString &reference, const QString &mailbox)
151{
152 doLogin();
153
154 _ibase->sendCommand(QString("%1 LSUB \"%2\" \"%3\"\r\n")
155 .arg(tag())
156 .arg(escape(reference))
157 .arg(escape(mailbox)));
158 return tag(false);
159}
160
161QString IMAPHandler::iStatus(const QString &mailbox, const QString &items)
162{
163 doLogin();
164
165 _ibase->sendCommand(QString("%1 STATUS \"%2\" (%3)\r\n")
166 .arg(tag())
167 .arg(escape(mailbox))
168 .arg(escape(items)));
169 return tag(false);
170}
171
172QString IMAPHandler::iAppend(const QString &mailbox, const QString &literal, const QString &flags, const QString &datetime = 0)
173{
174 doLogin();
175
176 _ibase->sendCommand(QString("%1 APPEND \"%2\" (%3) \"%4\" {%5}\r\n%6\r\n")
177 .arg(tag())
178 .arg(escape(mailbox))
179 .arg(flags)
180 .arg(escape(datetime))
181 .arg(literal.length())
182 .arg(literal));
183 return tag(false);
184}
185
186QString IMAPHandler::iCheck()
187{
188 doLogin();
189
190 _ibase->sendCommand(QString("%1 CHECK\r\n")
191 .arg(tag()));
192 return tag(false);
193}
194
195QString IMAPHandler::iClose()
196{
197 doLogin();
198
199 _ibase->sendCommand(QString("%1 CLOSE\r\n")
200 .arg(tag()));
201 return tag(false);
202}
203
204QString IMAPHandler::iExpunge()
205{
206 doLogin();
207
208 _ibase->sendCommand(QString("%1 EXPUNGE\r\n")
209 .arg(tag()));
210 return tag(false);
211}
212
213QString IMAPHandler::iSearch(const QString &search, const QString &charset)
214{
215 doLogin();
216
217 _ibase->sendCommand(QString("%1 SEARCH %2 %3\r\n")
218 .arg(tag())
219 .arg(charset.isEmpty() ? QString(0) : escape(charset))
220 .arg(search));
221 return tag(false);
222}
223
224QString IMAPHandler::iFetch(const QString &message, const QString &items)
225{
226 doLogin();
227
228 _ibase->sendCommand(QString("%1 FETCH %2 (%3)\r\n")
229 .arg(tag())
230 .arg(message)
231 .arg(items));
232 return tag(false);
233}
234
235QString IMAPHandler::iStore(const QString &message, const QString &items)
236{
237 doLogin();
238
239 _ibase->sendCommand(QString("%1 STORE %2 %3\r\n")
240 .arg(tag())
241 .arg(message)
242 .arg(items));
243 return tag(false);
244}
245
246QString IMAPHandler::iCopy(const QString &message, const QString &mailbox)
247{
248 doLogin();
249
250 _ibase->sendCommand(QString("%1 COPY %2 \"%3\"\r\n")
251 .arg(tag())
252 .arg(message)
253 .arg(escape(mailbox)));
254 return tag(false);
255}
256
257QString IMAPHandler::iUid(const QString &command, const QString &arguments)
258{
259 doLogin();
260
261 _ibase->sendCommand(QString("%1 UID %2 %3\r\n")
262 .arg(tag())
263 .arg(command)
264 .arg(arguments));
265 return tag(false);
266}
267
268QString IMAPHandler::iX(const QString &commandAtom, const QString &arguments)
269{
270 doLogin();
271
272 _ibase->sendCommand(QString("%1 X%2 %3\r\n")
273 .arg(tag())
274 .arg(commandAtom)
275 .arg(arguments));
276 return tag(false);
277}
278
279QString IMAPHandler::escape(const QString &in)
280{
281 QString in_ = in;
282 return in_.replace(QRegExp("\""), "\\\"");
283}
284
285QString IMAPHandler::tag(bool count)
286{
287 return QString("a%1").arg(count ? _tag++ : _tag);
288}
289
290void IMAPHandler::slotDataReceived(const QString &data)
291{
292 IMAPResponseParser parser(data);
293 IMAPResponse response = parser.response();
294 response.setImapHandler(this);
295
296 if (!_loggingin) emit gotResponse(response);
297 else {
298 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
299 _loggingin = false;
300 _loggedin = true;
301 qWarning("OK. Logged in. Leaving loggingin state.");
302 } else {
303 _loggingin = false;
304 emit IMAPError(IMAPBase::IMAPErrLoginFailed);
305 }
306 }
307}
308
309void IMAPHandler::slotLookingUpHost()
310{
311 emit IMAPLookingUpHost();
312}
313
314void IMAPHandler::slotHostFound()
315{
316 emit IMAPHostFound();
317}
318
319void IMAPHandler::slotConnected()
320{
321 emit IMAPConnected();
322}
323
324void IMAPHandler::slotDisconnected()
325{
326 _loggedin = false;
327 emit IMAPDisconnected();
328}
329
330void IMAPHandler::slotError(int err)
331{
332 emit IMAPError(err);
333}
334
diff --git a/noncore/unsupported/mail2/libmail/imaphandler.h b/noncore/unsupported/mail2/libmail/imaphandler.h
new file mode 100644
index 0000000..8cb42db
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/imaphandler.h
@@ -0,0 +1,86 @@
1#ifndef IMAPHANDLER_H
2#define IMAPHANDLER_H
3
4#include <qobject.h>
5
6#include "configfile.h"
7
8class IMAPBase;
9class IMAPResponse;
10
11class IMAPHandler : public QObject
12{
13 Q_OBJECT
14
15public:
16 IMAPHandler(const Account &account);
17
18 QString iCapability();
19 QString iNoop();
20 QString iLogout();
21
22 QString iAuthenticate(const QString &mechanism);
23 QString iLogin(const QString &user, const QString &pass);
24
25 QString iSelect(const QString &mailbox);
26 QString iExamine(const QString &mailbox);
27 QString iCreate(const QString &mailbox);
28 QString iDelete(const QString &mailbox);
29 QString iRename(const QString &mailbox, const QString &newMailbox);
30
31 QString iSubscribe(const QString &mailbox);
32 QString iUnsubscribe(const QString &mailbox);
33
34 QString iList(const QString &reference, const QString &mailbox);
35 QString iLsub(const QString &reference, const QString &mailbox);
36
37 QString iStatus(const QString &mailbox, const QString &items);
38
39 QString iAppend(const QString &mailbox, const QString &literal, const QString &flags = 0, const QString &datetime = 0);
40
41 QString iCheck();
42 QString iClose();
43 QString iExpunge();
44
45 QString iSearch(const QString &search, const QString &charset = 0);
46
47 QString iFetch(const QString &message, const QString &items);
48
49 QString iStore(const QString &message, const QString &items);
50 QString iCopy(const QString &message, const QString &mailbox);
51
52 QString iUid(const QString &command, const QString &arguments);
53
54 QString iX(const QString &commandAtom, const QString &arguments);
55
56signals:
57 void gotResponse(IMAPResponse &response);
58
59 void IMAPLookingUpHost();
60 void IMAPHostFound();
61 void IMAPConnected();
62 void IMAPDisconnected();
63 void IMAPError(int err);
64
65protected:
66 void doLogin();
67 QString escape(const QString &in);
68 QString tag(bool count = true);
69
70protected slots:
71 void slotDataReceived(const QString &data);
72 void slotLookingUpHost();
73 void slotHostFound();
74 void slotConnected();
75 void slotDisconnected();
76 void slotError(int err);
77
78private:
79 Account _account;
80 IMAPBase *_ibase;
81 unsigned int _tag;
82 bool _loggingin, _loggedin;
83
84};
85
86#endif
diff --git a/noncore/unsupported/mail2/libmail/imapresponse.cpp b/noncore/unsupported/mail2/libmail/imapresponse.cpp
new file mode 100644
index 0000000..06dca33
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/imapresponse.cpp
@@ -0,0 +1,448 @@
1#include "imapresponse.h"
2
3static QString _previousData;
4static unsigned int _neededData;
5
6IMAPResponseParser::IMAPResponseParser(const QString &data)
7 {
8 QString _data = data, more;
9 _data.replace((QString)"\r\n", "\n");
10
11 QStringList lines = QStringList::split('\n', _data);
12 QStringList::Iterator it;
13 for (it = lines.begin(); it != lines.end(); it++) {
14 QString tag, lineData;
15
16 if (!_previousData.isNull()) {
17 qDebug(QString("IMAPResponseParser: got additional data. (%1/%2)").arg(_previousData.length()).arg(_neededData));
18 _previousData += *it + "\n";
19 if (_previousData.length() >= _neededData) {
20 _previousData += ")";
21 qDebug("IMAPResponseParser: got ALL additional data.");
22 qDebug("Data is: " + _previousData);
23 parseResponse(_previousData);
24 _previousData = QString(0);
25 _neededData = 0;
26 }
27 } else {
28 splitTagData(*it, tag, lineData);
29 if (tag == "*") {
30 int pos;
31 if ((pos = data.find(QRegExp("\\{\\d*\\}"))) != -1) {
32 qDebug("IMAPResponseParser: waiting for additional data...");
33 _previousData = lineData + "\n";
34
35 QString tmp = data.right(data.length() - pos - 1).stripWhiteSpace();
36 tmp.truncate(tmp.length() - 1);
37
38 _neededData = tmp.toUInt();
39 if (_previousData.length() >= _neededData) {
40 qDebug("IMAPResponseParser: got ALL additional data. (1st)");
41 parseResponse(_previousData);
42 _previousData = QString(0);
43 _neededData = 0;
44 } else {
45 break;
46 }
47 } else {
48 parseResponse(lineData);
49 }
50 } else if (tag == "+") {
51 emit needMoreData(_data);
52 } else {
53 _iresponse.setTag(tag);
54 parseResponse(_data, true);
55 }
56 }
57 }
58}
59
60IMAPResponse IMAPResponseParser::response()
61{
62 return _iresponse;
63}
64
65void IMAPResponseParser::parseResponse(const QString &data, bool tagged)
66{
67 QString response, line;
68 int pos;
69 bool isNum = false;
70 if ((pos = data.find(' ')) != -1) {
71 response = data.left(pos).upper();
72 response.toInt(&isNum);
73 line = data.right(data.length() - pos - 1);
74 } else {
75 qWarning("IMAPResponseParser: parseResponse: No response found.");
76 return;
77 }
78
79 if (response == "OK" && tagged) {
80 IMAPResponseStatusResponse status(OK, line);
81 status.setResponseCode(getResponseCode(status.comment()));
82 _iresponse.setStatusResponse(status);
83 } else if (response == "OK" && !tagged) {
84 IMAPResponseOK ok(line, getResponseCode(line));
85 _iresponse.addOK(ok);
86 } else if (response == "NO" && tagged) {
87 IMAPResponseStatusResponse status(NO, line);
88 status.setResponseCode(getResponseCode(status.comment()));
89 _iresponse.setStatusResponse(status);
90 } else if (response == "NO" && !tagged) {
91 IMAPResponseNO no(line, getResponseCode(line));
92 _iresponse.addNO(no);
93 } else if (response == "BAD" && tagged) {
94 IMAPResponseStatusResponse status(BAD, line);
95 status.setResponseCode(getResponseCode(status.comment()));
96 _iresponse.setStatusResponse(status);
97 } else if (response == "BAD" && !tagged) {
98 IMAPResponseBAD bad(line, getResponseCode(line));
99 _iresponse.addBAD(bad);
100 } else if (response == "PREAUTH" && tagged) {
101 IMAPResponseStatusResponse status(PREAUTH, line);
102 _iresponse.setStatusResponse(status);
103 } else if (response == "PREAUTH" && !tagged) {
104 qDebug("IMAPResponseParser: responseParser: got untagged PREAUTH response.");
105 // XXX
106 } else if (response == "BYE") {
107 IMAPResponseStatusResponse status(BYE, line);
108 if (!tagged) status.setExitedUnexpected(true);
109 _iresponse.setStatusResponse(status);
110 } else if (response == "CAPABILITY") {
111 IMAPResponseCAPABILITY capability(QStringList::split(' ', line));
112 _iresponse.addCAPABILITY(capability);
113 } else if (response == "LIST") {
114 QStringList list = splitData(line, true);
115
116 QStringList flags;
117 parseParenthesizedList(list[0], flags);
118
119 removeLimiters(list[1]);
120 removeLimiters(list[2]);
121 IMAPResponseLIST rlist(parseFlagList(flags), list[1], list[2]);
122 _iresponse.addLIST(rlist);
123 } else if (response == "LSUB") {
124 QStringList list = splitData(line, true);
125
126 QStringList flags;
127 parseParenthesizedList(list[0], flags);
128
129 removeLimiters(list[1]);
130 removeLimiters(list[2]);
131 IMAPResponseLSUB lsub(parseFlagList(flags), list[1], list[2]);
132 _iresponse.addLSUB(lsub);
133 } else if (response == "STATUS") {
134 QStringList list = splitData(line, true);
135
136 removeLimiters(list[0]);
137 IMAPResponseSTATUS status(list[0]);
138
139 QStringList flags;
140 parseParenthesizedList(list[1], flags);
141 QStringList::Iterator it;
142 for (it = flags.begin(); it != flags.end(); it++) {
143 if (*it == "MESSAGES") status.setMessages(*(++it));
144 else if (*it == "RECENT") status.setRecent(*(++it));
145 else if (*it == "UIDNEXT") status.setUidnext(*(++it));
146 else if (*it == "UIDVALIDITY") status.setUidvalidity(*(++it));
147 else if (*it == "UNSEEN") status.setUnseen(*(++it));
148 else qWarning("IMAPResponseParser: parseResponse: Unknown status data: " + *(it++) + "|");
149 }
150 _iresponse.addSTATUS(status);
151 } else if (response == "SEARCH") {
152 IMAPResponseSEARCH search(QStringList::split(' ', line));
153 _iresponse.addSEARCH(search);
154 } else if (response == "FLAGS") {
155 QStringList list;
156 parseParenthesizedList(line, list);
157
158 IMAPResponseFLAGS flags(parseFlagList(list));
159 _iresponse.addFLAGS(flags);
160 } else if (isNum) {
161 QStringList list = QStringList::split(' ', line);
162 if (list[0] == "EXISTS") {
163 IMAPResponseEXISTS exists(response);
164 _iresponse.addEXISTS(exists);
165 } else if (list[0] == "RECENT") {
166 IMAPResponseRECENT recent(response);
167 _iresponse.addRECENT(recent);
168 } else if (list[0] == "EXPUNGE") {
169 IMAPResponseEXPUNGE expunge(response);
170 _iresponse.addEXPUNGE(expunge);
171 } else if (list[0] == "FETCH") {
172 IMAPResponseFETCH fetch;
173 QStringList::Iterator it;
174
175 QStringList fetchList = splitData(line, true);
176 QStringList list;
177 parseParenthesizedList(fetchList[1], list);
178
179 for (it = list.begin(); it != list.end(); it++) {
180 if (*it == "BODY") {
181 qDebug("IMAPResponseParser: responseParser: got FETCH::BODY");
182 // XXX
183 } else if ((*it).find(QRegExp("BODY\\[\\d+\\]")) != -1) {
184 QString bodydata = *(++it);
185 qDebug("IMAPResponseParser: responseParser: got FETCH::BODY[x]");
186
187 QStringList blist;
188 parseParenthesizedList(bodydata, blist);
189
190 IMAPResponseBodyPart bodypart;
191 QString tmp;
192 for (unsigned int i = 2; i < blist.count(); i++) {
193 if (i != 2) tmp += " " + blist[i];
194 else tmp += blist[i];
195 }
196 bodypart.setData(tmp);
197
198 tmp = list[0];
199 tmp.replace(0, 5, "");
200 tmp.truncate(blist[0].length() - 1);
201 bodypart.setPart(tmp);
202
203 fetch.addBodyPart(bodypart);
204 } else if (*it == "BODYSTRUCTURE") {
205 qDebug("IMAPResponseParser: responseParser: got FETCH::BODYSTRUCTURE");
206/*
207 QString bsdata = *(++it);
208 QStringList bsList;
209 parseParenthesizedList(bsdata, bsList);
210
211 IMAPResponseBodystructure bodystructure;
212 QStringList attachml;
213
214 for (int i = 0; i < bsList.count() - 1; i++) {
215 parseParenthesizedList(bsList[0], attachml);
216
217 IMAPResponseBodypart bodypart;
218 bodypart.setMimeTypeMain(attachml[0] == "NIL" ? QString(0) : attachml[0]);
219 bodypart.setMimeTypeSub(attachml[1] == "NIL" ? QString(0) : attachml[1]);
220 bodypart.setAddData(attachml[2] == "NIL" ? QString(0) : attachml[2]);
221 // 3 (NIL)
222 // 4 (NIL)
223 bodypart.setEncoding(attachml[5] == "NIL" ? QString(0) : attachml[5]);
224 bodypart.setSize(attachml[6] == "NIL" ? QString(0) : attachml[6]);
225 bodypart.setLength(attachml[7] == "NIL" ? QString(0) : attachml[7]);
226 bodypart.setAttachInfo(attachml[8] == "NIL" ? QString(0) : attachml[8]);
227 // 9 (NIL)
228 // 10 (NIL)
229
230 bodystructure.addBodyPart(bodypart);
231 }
232*/
233 } else if (*it == "ENVELOPE") {
234 QString envdata = *(++it);
235 QStringList envList;
236 parseParenthesizedList(envdata, envList);
237
238 IMAPResponseEnvelope envelope;
239 envelope.setMailDate(envList[0] == "NIL" ? QString(0) : removeLimiters(envList[0]));
240 envelope.setSubject(envList[1] == "NIL" ? QString(0) : removeLimiters(envList[1]));
241
242 QStringList froml, senderl, replytol, tol, ccl, bccl;
243 QStringList froma, sendera, replytoa, toa, cca, bcca;
244 parseParenthesizedList(envList[2], froml);
245 parseParenthesizedList(envList[3], senderl);
246 parseParenthesizedList(envList[4], replytol);
247 parseParenthesizedList(envList[5], tol);
248 parseParenthesizedList(envList[6], ccl);
249 parseParenthesizedList(envList[7], bccl);
250
251 QStringList::Iterator it;
252 for (it = froml.begin(); it != froml.end(); it++) {
253 parseParenthesizedList(*it, froma);
254 if (froml[0] != "NIL")
255 envelope.addFrom(IMAPResponseAddress(
256 removeLimiters(froma[0]),
257 removeLimiters(froma[1]),
258 removeLimiters(froma[2]),
259 removeLimiters(froma[3])));
260 }
261
262 for (it = senderl.begin(); it != senderl.end(); it++) {
263 parseParenthesizedList(*it, sendera);
264 if (senderl[0] != "NIL")
265 envelope.addSender(IMAPResponseAddress(
266 removeLimiters(sendera[0]),
267 removeLimiters(sendera[1]),
268 removeLimiters(sendera[2]),
269 removeLimiters(sendera[3])));
270 }
271
272 for (it = replytol.begin(); it != replytol.end(); it++) {
273 parseParenthesizedList(*it, replytoa);
274 if (replytol[0] != "NIL")
275 envelope.addReplyTo(IMAPResponseAddress(
276 removeLimiters(replytoa[0]),
277 removeLimiters(replytoa[1]),
278 removeLimiters(replytoa[2]),
279 removeLimiters(replytoa[3])));
280 }
281
282 for (it = tol.begin(); it != tol.end(); it++) {
283 parseParenthesizedList(*it, toa);
284 if (tol[0] != "NIL")
285 envelope.addTo(IMAPResponseAddress(
286 removeLimiters(toa[0]),
287 removeLimiters(toa[1]),
288 removeLimiters(toa[2]),
289 removeLimiters(toa[3])));
290 }
291
292 for (it = ccl.begin(); it != ccl.end(); it++) {
293 parseParenthesizedList(*it, cca);
294 if (ccl[0] != "NIL")
295 envelope.addCc(IMAPResponseAddress(
296 removeLimiters(cca[0]),
297 removeLimiters(cca[1]),
298 removeLimiters(cca[2]),
299 removeLimiters(cca[3])));
300 }
301
302 for (it = bccl.begin(); it != bccl.end(); it++) {
303 parseParenthesizedList(*it, bcca);
304 if (bccl[0] != "NIL")
305 envelope.addBcc(IMAPResponseAddress(
306 removeLimiters(bcca[0]),
307 removeLimiters(bcca[1]),
308 removeLimiters(bcca[2]),
309 removeLimiters(bcca[3])));
310 }
311
312 envelope.setInReplyTo(envList[7] == "NIL" ? QString(0) : removeLimiters(envList[7]));
313 envelope.setMessageId(envList[8] == "NIL" ? QString(0) : removeLimiters(envList[8]));
314
315 fetch.setEnvelope(envelope);
316 } else if (*it == "FLAGS") {
317 QString flagdata = *(++it);
318 QStringList flags;
319 parseParenthesizedList(flagdata, flags);
320 fetch.setFlags(parseFlagList(flags));
321 } else if (*it == "INTERNALDATE") {
322 fetch.setInternalDate(removeLimiters(*(++it)));
323 } else if (*it == "RFC822" || *it == "BODY[]") {
324 qDebug("IMAPResponseParser: responseParser: got FETCH::RFC822");
325 // XXX
326 } else if (*it == "RFC822.HEADER" || *it == "BODY.PEEK[HEADER]") {
327 qDebug("IMAPResponseParser: responseParser: got FETCH::RFC822.HEADER");
328 // XXX
329 } else if (*it == "RFC822.SIZE") {
330 fetch.setRFC822Size(*(++it));
331 } else if (*it == "RFC822.TEXT" || *it == "BODY[TEXT]") {
332 qDebug("IMAPResponseParser: responseParser: got FETCH::RFC822.TEXT");
333 // XXX
334 } else if (*it == "UID") {
335 fetch.setUid(*(++it));
336 }
337 }
338 _iresponse.addFETCH(fetch);
339 }
340 } else qWarning("IMAPResponseParser: parseResponse: Unknown response: " + response + "|");
341}
342
343QStringList IMAPResponseParser::splitData(const QString &data, bool withBrackets)
344{
345 int b = 0;
346 bool a = false, noappend = false, escaped = false;
347 QString temp;
348 QStringList list;
349
350 for (unsigned int i = 0; i <= data.length(); i++) {
351 if (withBrackets && data[i] == '(' && !a) b++;
352 else if (withBrackets && data[i] == ')' && !a) b--;
353
354 if (data[i] == '"' && !escaped) a = !a;
355 else escaped = false;
356
357 if (data[i] == '\\' && data[i + 1] == '"') escaped = true;
358
359 if ((data[i] == ' ' || i == data.length()) && b == 0 && !a) {
360 list.append(temp);
361 temp = QString(0);
362 if (data[i] == ' ') noappend = true;
363 }
364
365 if (!noappend) temp += data[i];
366 noappend = false;
367 }
368
369 return list;
370}
371
372void IMAPResponseParser::parseParenthesizedList(const QString &data, QStringList &parsed)
373{
374 QString data_(data);
375 removeLimiters(data_, '(', ')');
376 parsed = splitData(data_, true);
377}
378
379void IMAPResponseParser::splitTagData(const QString &line, QString &tag, QString &data)
380{
381 int pos;
382 if ((pos = line.find(' ')) != -1) {
383 tag = line.left(pos);
384 data = line.right(line.length() - pos - 1);
385 } else qWarning("IMAPResponseParser: splitTagData: tag not found. Line was " + line + "|");
386}
387
388QString IMAPResponseParser::removeLimiters(QString &string, const QChar &sl, const QChar &el)
389{
390 QString tmpString;
391 if (string[0] == sl && string[string.length() - 1] == el) {
392 string.truncate(string.length() - 1);
393 string.replace(0, 1, "");
394
395 for (unsigned int i = 1; i <= string.length(); i++) {
396 if (string[i - 1] == '\\' && sl == '"') ++i;
397 tmpString += string[i - 1];
398 }
399 }
400
401 return tmpString;
402}
403
404IMAPResponseEnums::IMAPResponseCode IMAPResponseParser::getResponseCode(const QString &line)
405{
406 if (line.find(QRegExp((QString) "^\\[.*\\]" + ' ' + ".*")) != -1) {
407 int pos = line.find("] ");
408 QString code = line.left(pos + 1).upper();
409
410 if (code.find(QRegExp("[ALERT]")) != -1) return ALERT;
411 else if (code.find(QRegExp("[NEWNAME .* .*]")) != -1) return NEWNAME; // XXX
412 else if (code.find(QRegExp("[PARSE]")) != -1) return PARSE;
413 else if (code.find(QRegExp("[PERMANENTFLAGS \\d*]")) != -1) return PERMANENTFLAGS; // XXX
414 else if (code.find(QRegExp("[READ-ONLY]")) != -1) return READONLY;
415 else if (code.find(QRegExp("[READ-WRITE]")) != -1) return READWRITE;
416 else if (code.find(QRegExp("[TRYCREATE]")) != -1) return TRYCREATE;
417 else if (code.find(QRegExp("[UIDVALIDITY \\d*]")) != -1) return UIDVALIDITY; // XXX
418 else if (code.find(QRegExp("[UNSEEN \\d*]")) != -1) return UNSEEN; // XXX
419 else {
420 qWarning("IMAPResponseParser: getResponseCode: Unknown code: " + code + "|");
421 return UnknownCode;
422 }
423 }
424 return NoCode;
425}
426
427QValueList<IMAPResponseEnums::IMAPResponseFlags> IMAPResponseParser::parseFlagList(const QStringList &flagList)
428{
429 QValueList<IMAPResponseFlags> flags;
430 QStringList::ConstIterator it;
431 for (it = flagList.begin(); it != flagList.end(); it++) {
432 QString flag = (*it).lower();
433 if (flag == "\\seen") flags.append(Seen);
434 else if (flag == "\\answered") flags.append(Answered);
435 else if (flag == "\\flagged") flags.append(Flagged);
436 else if (flag == "\\deleted") flags.append(Deleted);
437 else if (flag == "\\draft") flags.append(Draft);
438 else if (flag == "\\recent") flags.append(Recent);
439 else if (flag == "\\noinferiors") flags.append(Noinferiors);
440 else if (flag == "\\noselect") flags.append(Noselect);
441 else if (flag == "\\marked") flags.append(Marked);
442 else if (flag == "\\unmarked") flags.append(Unmarked);
443 else if (flag.isEmpty()) { }
444 else qWarning("IMAPResponseParser: parseFlagList: Unknown flag: " + *it + "|");
445 }
446 return flags;
447}
448
diff --git a/noncore/unsupported/mail2/libmail/imapresponse.h b/noncore/unsupported/mail2/libmail/imapresponse.h
new file mode 100644
index 0000000..73435ee
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/imapresponse.h
@@ -0,0 +1,531 @@
1#ifndef IMAPRESPONSE_H
2#define IMAPRESPONSE_H
3
4#include <qobject.h>
5
6 #define MAX_BODYPARTS 50
7
8class IMAPHandler;
9
10class IMAPResponseEnums
11{
12public:
13 enum IMAPResponseStatus {
14 OK, NO, BAD, PREAUTH, BYE, UnknownStatus = 0
15 };
16
17 enum IMAPResponseFlags {
18 Seen, Answered, Flagged, Deleted, Draft, Recent,
19 Noinferiors, Noselect, Marked, Unmarked, UnknownFlag = 0
20 };
21
22 enum IMAPResponseCode {
23 ALERT, NEWNAME, PARSE, PERMANENTFLAGS, READONLY, READWRITE,
24 TRYCREATE, UIDVALIDITY, UNSEEN, NoCode, UnknownCode = 0
25 };
26
27};
28
29class IMAPResponseAddress
30{
31public:
32 IMAPResponseAddress(QString name = 0, QString adl = 0, QString mailbox = 0, QString host = 0)
33 {
34 _name = name;
35 _adl = adl;
36 _mailbox = mailbox;
37 _host = host;
38 }
39
40 void setName(QString name) { _name = name; }
41 QString name() { return _name; }
42 void setAdl(QString adl) { _adl = adl; }
43 QString adl() { return _adl; }
44 void setMailbox(QString mailbox) { _mailbox = mailbox; }
45 QString mailbox() { return _mailbox; }
46 void setHost(QString host) { _host = host; }
47 QString host() { return _host; }
48
49 QString toString()
50 {
51 if (_name.isNull() && _mailbox.isNull() && _host.isNull())
52 return QString(0);
53 if (_name != _mailbox + "@" + _host)
54 return _name + " <" + _mailbox + "@" + _host + ">";
55 else
56 return _name;
57 }
58
59 QString email()
60 {
61 if (_host.isEmpty()) return _mailbox;
62 else return _mailbox + "@" + _host;
63 }
64
65private:
66 QString _name, _adl, _mailbox, _host;
67
68};
69
70class IMAPResponseAddressList : public QValueList<IMAPResponseAddress>
71{
72public:
73 IMAPResponseAddressList()
74 : QValueList<IMAPResponseAddress>()
75 {
76
77 }
78
79 QString toString()
80 {
81 QString string;
82 IMAPResponseAddressList::Iterator it;
83 for (it = this->begin(); it != this->end(); it++) {
84 QString tmp = (*it).toString();
85 if (!tmp.isNull() && string.isEmpty()) string = tmp;
86 else if (!tmp.isNull()) string += ", " + tmp;
87 }
88 return string;
89 }
90
91};
92
93class IMAPResponseBody
94{
95public:
96 void setData(QString data) { _data = data; }
97 QString data() { return _data; }
98
99private:
100 QString _data;
101
102};
103
104class IMAPResponseBodyPart : public IMAPResponseBody
105{
106public:
107 void setPart(QString part) { _part = part; }
108 QString part() { return _part; }
109
110private:
111 QString _part;
112
113};
114
115class IMAPResponseEnvelope
116{
117public:
118 void setMailDate(QString date) { _date = date; }
119 QString mailDate() { return _date; }
120 void setSubject(QString subject) { _subject = subject; }
121 QString subject() { return _subject; }
122 void addFrom(IMAPResponseAddress from) { _from.append(from); }
123 IMAPResponseAddressList from() { return _from; }
124 void addSender(IMAPResponseAddress sender) { _sender.append(sender); }
125 IMAPResponseAddressList sender() { return _sender; }
126 void addReplyTo(IMAPResponseAddress replyTo) { _replyTo.append(replyTo); }
127 IMAPResponseAddressList replyTo() { return _replyTo; }
128 void addTo(IMAPResponseAddress to) { _to.append(to); }
129 IMAPResponseAddressList to() { return _to; }
130 void addCc(IMAPResponseAddress cc) { _cc.append(cc); }
131 IMAPResponseAddressList cc() { return _cc; }
132 void addBcc(IMAPResponseAddress bcc) { _bcc.append(bcc); }
133 IMAPResponseAddressList bcc() { return _bcc; }
134 void setInReplyTo(QString inReplyTo) { _inReplyTo = inReplyTo; }
135 QString inReplyTo() { return _inReplyTo; }
136 void setMessageId(QString messageId) { _messageId = messageId; }
137 QString messageId() { return _messageId; }
138
139private:
140 QString _date, _subject, _inReplyTo, _messageId;
141 IMAPResponseAddressList _from, _sender, _replyTo, _to, _cc, _bcc;
142
143};
144
145class IMAPResponseStatusResponse : public IMAPResponseEnums
146{
147public:
148 IMAPResponseStatusResponse(IMAPResponseStatus status = (IMAPResponseStatus)0, QString comment = 0, IMAPResponseCode code = (IMAPResponseCode)0)
149 {
150 _status = status;
151 _comment = comment;
152 _code = code;
153 }
154
155 void setStatus(IMAPResponseStatus status) { _status = status; }
156 IMAPResponseStatus status() { return _status; }
157 void setComment(QString comment) { _comment = comment; }
158 QString comment() { return _comment; }
159 void setResponseCode(IMAPResponseCode code) { _code = code; }
160 IMAPResponseCode responseCode() { return _code; }
161
162 void setExitedUnexpected(bool exitu) { _exitu = exitu; }
163 bool exitedUnexpected() { return _exitu; }
164
165private:
166 IMAPResponseStatus _status;
167 QString _comment;
168 IMAPResponseCode _code;
169 bool _exitu;
170
171};
172
173class IMAPResponseOK : public IMAPResponseEnums
174{
175public:
176 IMAPResponseOK(QString comment = 0, IMAPResponseCode code = (IMAPResponseCode)0)
177 {
178 _comment = comment;
179 _code = code;
180 }
181
182 void setComment(QString comment) { _comment = comment; }
183 QString comment() { return _comment; }
184 void setResponseCode(IMAPResponseCode code) { _code = code; }
185 IMAPResponseCode responseCode() { return _code; }
186
187private:
188 QString _comment;
189 IMAPResponseCode _code;
190
191};
192
193class IMAPResponseNO : public IMAPResponseEnums
194{
195public:
196 IMAPResponseNO(QString comment = 0, IMAPResponseCode code = (IMAPResponseCode)0)
197 {
198 _comment = comment;
199 _code = code;
200 }
201
202 void setComment(QString comment) { _comment = comment; }
203 QString comment() { return _comment; }
204 void setResponseCode(IMAPResponseCode code) { _code = code; }
205 IMAPResponseCode responseCode() { return _code; }
206
207private:
208 QString _comment;
209 IMAPResponseCode _code;
210
211};
212
213class IMAPResponseBAD : public IMAPResponseEnums
214{
215public:
216 IMAPResponseBAD(QString comment = 0, IMAPResponseCode code = (IMAPResponseCode)0)
217 {
218 _comment = comment;
219 _code = code;
220 }
221
222 void setComment(QString comment) { _comment = comment; }
223 QString comment() { return _comment; }
224 void setResponseCode(IMAPResponseCode code) { _code = code; }
225 IMAPResponseCode responseCode() { return _code; }
226
227private:
228 QString _comment;
229 IMAPResponseCode _code;
230
231};
232
233class IMAPResponseCAPABILITY
234{
235public:
236 IMAPResponseCAPABILITY(QStringList capabilities = 0)
237 {
238 _capabilities = capabilities;
239 }
240
241 void setCapabilities(QStringList capabilities) { _capabilities = capabilities; }
242 QStringList capabilities() { return _capabilities; }
243
244private:
245 QStringList _capabilities;
246
247};
248
249class IMAPResponseLIST : public IMAPResponseEnums
250{
251public:
252 IMAPResponseLIST(QValueList<IMAPResponseFlags> flags = QValueList<IMAPResponseFlags>(), QString folderSeparator = 0, QString folder = 0)
253 {
254 _flags = flags;
255 _folderSeparator = folderSeparator;
256 _folder = folder;
257 }
258
259 void setFlags(QValueList<IMAPResponseFlags> flags) { _flags = flags; }
260 QValueList<IMAPResponseFlags> flags() { return _flags; }
261 void setFolderSeparator(QString folderSeparator) { _folderSeparator = folderSeparator; }
262 QString folderSeparator() { return _folderSeparator; }
263 void setFolder(QString folder) { _folder = folder; }
264 QString folder() { return _folder; }
265
266private:
267 QValueList<IMAPResponseFlags> _flags;
268 QString _folderSeparator, _folder;
269
270};
271
272class IMAPResponseLSUB : public IMAPResponseEnums
273{
274public:
275 IMAPResponseLSUB(QValueList<IMAPResponseFlags> flags = QValueList<IMAPResponseFlags>(), QString folderSeperator = 0, QString folder = 0)
276 {
277 _flags = flags;
278 _folderSeperator = folderSeperator;
279 _folder = folder;
280 }
281
282 void setFlags(QValueList<IMAPResponseFlags> flags) { _flags = flags; }
283 QValueList<IMAPResponseFlags> flags() { return _flags; }
284 void setFolderSeperator(QString folderSeperator) { _folderSeperator = folderSeperator; }
285 QString folderSeperator() { return _folderSeperator; }
286 void setFolder(QString folder) { _folder = folder; }
287 QString folder() { return _folder; }
288
289private:
290 QValueList<IMAPResponseFlags> _flags;
291 QString _folderSeperator, _folder;
292
293};
294
295class IMAPResponseSTATUS
296{
297public:
298 IMAPResponseSTATUS(QString mailbox = 0, QString messages = 0, QString recent = 0, QString uidnext = 0, QString uidvalidity = 0, QString unseen = 0)
299 {
300 _mailbox = mailbox;
301 _messages = messages;
302 _recent = recent;
303 _uidnext = uidnext;
304 _uidvalidity = uidvalidity;
305 _unseen = unseen;
306 }
307
308 void setMailbox(QString &mailbox) { _mailbox = mailbox; }
309 QString mailbox() { return _mailbox; }
310 void setMessages(QString &messages) { _messages = messages; }
311 QString messages() { return _messages; }
312 void setRecent(QString &recent) { _recent = recent; }
313 QString recent() { return _recent; }
314 void setUidnext(QString &uidnext) { _uidnext = uidnext; }
315 QString uidnext() { return _uidnext; }
316 void setUidvalidity(QString &uidvalidity) { _uidvalidity = uidvalidity; }
317 QString uidvalidity() { return _uidvalidity; }
318 void setUnseen(QString &unseen) { _unseen = unseen; }
319 QString unseen() { return _unseen; }
320
321private:
322 QString _mailbox, _messages, _recent, _uidnext, _uidvalidity, _unseen;
323
324};
325
326class IMAPResponseSEARCH
327{
328public:
329 IMAPResponseSEARCH(QStringList mails = 0)
330 {
331 _mails = mails;
332 }
333
334 void setMails(QStringList mails) { _mails = mails; }
335 QStringList mails() { return _mails; }
336
337private:
338 QStringList _mails;
339
340};
341
342class IMAPResponseFLAGS : public IMAPResponseEnums
343{
344public:
345 IMAPResponseFLAGS(QValueList<IMAPResponseFlags> flags = QValueList<IMAPResponseFlags>())
346 {
347 _flags = flags;
348 }
349
350 void setFlags(QValueList<IMAPResponseFlags> flags) { _flags = flags; }
351 QValueList<IMAPResponseFlags> flags() { return _flags; }
352
353private:
354 QValueList<IMAPResponseFlags> _flags;
355
356};
357
358class IMAPResponseEXISTS
359{
360public:
361 IMAPResponseEXISTS(QString mails = 0)
362 {
363 _mails = mails;
364 }
365
366 void setMails(QString mails) { _mails = mails; }
367 QString mails() { return _mails; }
368
369private:
370 QString _mails;
371
372};
373
374class IMAPResponseRECENT
375{
376public:
377 IMAPResponseRECENT(QString mails = 0)
378 {
379 _mails = mails;
380 }
381
382 void setMails(QString mails) { _mails = mails; }
383 QString mails() { return _mails; }
384
385private:
386 QString _mails;
387
388};
389
390class IMAPResponseEXPUNGE
391{
392public:
393 IMAPResponseEXPUNGE(QString mails = 0)
394 {
395 _mails = mails;
396 }
397
398 void setMails(QString mails) { _mails = mails; }
399 QString mails() { return _mails; }
400
401private:
402 QString _mails;
403
404};
405
406class IMAPResponseFETCH : public IMAPResponseEnums
407{
408public:
409 void setEnvelope(IMAPResponseEnvelope envelope) { _envelope = envelope; }
410 IMAPResponseEnvelope envelope() { return _envelope; }
411 void setFlags(QValueList<IMAPResponseFlags> flags) { _flags = flags; }
412 QValueList<IMAPResponseFlags> flags() { return _flags; }
413 void setInternalDate(QString idate) { _idate = idate; }
414 QString internalDate() { return _idate; }
415 void setRFC822Size(QString rfc822size) { _rfc822size = rfc822size; }
416 QString RFC822Size() { return _rfc822size; }
417 void setUid(QString uid) { _uid = uid; }
418 QString uid() { return _uid; }
419
420 void setBody(QString body) { _body = body; }
421 QString body() { return _body; }
422 void addBodyPart(IMAPResponseBodyPart part) { _bodyParts.append(part); }
423 void setBodyParts(QValueList<IMAPResponseBodyPart> parts) { _bodyParts = parts; }
424 QValueList<IMAPResponseBodyPart> bodyParts() { return _bodyParts; }
425 IMAPResponseBodyPart bodyPart(int part) { return _bodyParts[part]; }
426 void setRfc822(QString rfc822) { _rfc822 = rfc822; }
427 QString rfc822() { return _rfc822; }
428 void setRfc822Header(QString rfc822Header) { _rfc822Header = rfc822Header; }
429 QString rfc822Header() { return _rfc822Header; }
430 void setRfc822Text(QString rfc822Text) { _rfc822Text = rfc822Text; }
431 QString rfc822Text() { return _rfc822Text; }
432
433private:
434 IMAPResponseEnvelope _envelope;
435 QValueList<IMAPResponseFlags> _flags;
436 QString _idate, _rfc822size, _uid, _body, _rfc822, _rfc822Header, _rfc822Text;
437 QValueList<IMAPResponseBodyPart> _bodyParts;
438
439};
440
441class IMAPResponse : public IMAPResponseEnums
442{
443public:
444 void setTag(QString tag) { _tag = tag; }
445 QString tag() { return _tag; }
446
447 void setImapHandler(IMAPHandler *handler) { _handler = handler; }
448 IMAPHandler *imapHandler() { return _handler; }
449
450 void setStatusResponse(IMAPResponseStatusResponse response) { _response = response; }
451 IMAPResponseStatusResponse statusResponse() { return _response; }
452
453 void addOK(IMAPResponseOK ok) { _okl.append(ok); }
454 void addNO(IMAPResponseNO no) { _nol.append(no); }
455 void addBAD(IMAPResponseBAD bad) { _badl.append(bad); }
456 void addCAPABILITY(IMAPResponseCAPABILITY capability) { _capabilityl.append(capability); }
457 void addLIST(IMAPResponseLIST list) { _listl.append(list); }
458 void addLSUB(IMAPResponseLSUB lsub) { _lsubl.append(lsub); }
459 void addSTATUS(IMAPResponseSTATUS status) { _statusl.append(status); }
460 void addSEARCH(IMAPResponseSEARCH search) { _searchl.append(search); }
461 void addFLAGS(IMAPResponseFLAGS flags) { _flagsl.append(flags); }
462 void addEXISTS(IMAPResponseEXISTS exists) { _existsl.append(exists); }
463 void addRECENT(IMAPResponseRECENT recent) { _recentl.append(recent); }
464 void addEXPUNGE(IMAPResponseEXPUNGE expunge) { _expungel.append(expunge); }
465 void addFETCH(IMAPResponseFETCH fetch) { _fetchl.append(fetch); }
466
467 QValueList<IMAPResponseOK> OK() { return _okl; }
468 QValueList<IMAPResponseNO> NO() { return _nol; }
469 QValueList<IMAPResponseBAD> BAD() { return _badl; }
470 QValueList<IMAPResponseCAPABILITY> CAPABILITY() { return _capabilityl; }
471 QValueList<IMAPResponseLIST> LIST() { return _listl; }
472 QValueList<IMAPResponseLSUB> LSUB() { return _lsubl; }
473 QValueList<IMAPResponseSTATUS> STATUS() { return _statusl; }
474 QValueList<IMAPResponseSEARCH> SEARCH() { return _searchl; }
475 QValueList<IMAPResponseFLAGS> FLAGS() { return _flagsl; }
476 QValueList<IMAPResponseEXISTS> EXISTS() { return _existsl; }
477 QValueList<IMAPResponseRECENT> RECENT() { return _recentl; }
478 QValueList<IMAPResponseEXPUNGE> EXPUNGE() { return _expungel; }
479 QValueList<IMAPResponseFETCH> FETCH() { return _fetchl; }
480
481private:
482 QString _tag;
483 IMAPResponseStatusResponse _response;
484
485 IMAPHandler *_handler;
486
487 QValueList<IMAPResponseOK> _okl;
488 QValueList<IMAPResponseNO> _nol;
489 QValueList<IMAPResponseBAD> _badl;
490 QValueList<IMAPResponseCAPABILITY> _capabilityl;
491 QValueList<IMAPResponseLIST> _listl;
492 QValueList<IMAPResponseLSUB> _lsubl;
493 QValueList<IMAPResponseSTATUS> _statusl;
494 QValueList<IMAPResponseSEARCH> _searchl;
495 QValueList<IMAPResponseFLAGS> _flagsl;
496 QValueList<IMAPResponseEXISTS> _existsl;
497 QValueList<IMAPResponseRECENT> _recentl;
498 QValueList<IMAPResponseEXPUNGE> _expungel;
499 QValueList<IMAPResponseFETCH> _fetchl;
500
501};
502
503class IMAPResponseParser : public QObject, public IMAPResponseEnums
504{
505 Q_OBJECT
506
507public:
508 IMAPResponseParser(const QString &data);
509
510 IMAPResponse response();
511
512signals:
513 void needMoreData(const QString &comment);
514
515protected:
516 void parseResponse(const QString &data, bool tagged = false);
517
518 QStringList splitData(const QString &data, bool withBrackets);
519 void parseParenthesizedList(const QString &data, QStringList &parsed);
520 void splitTagData(const QString &line, QString &tag, QString &data);
521 QString removeLimiters(QString &string, const QChar &sl = '"', const QChar &el = '"');
522 IMAPResponseCode getResponseCode(const QString &line);
523 QValueList<IMAPResponseFlags> parseFlagList(const QStringList &flags);
524
525private:
526 IMAPResponse _iresponse;
527
528};
529
530#endif
531
diff --git a/noncore/unsupported/mail2/libmail/libmail.pro b/noncore/unsupported/mail2/libmail/libmail.pro
new file mode 100644
index 0000000..662af90
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/libmail.pro
@@ -0,0 +1,26 @@
1 TEMPLATE =lib
2 CONFIG =qt warn_on release
3 HEADERS =configfile.h \
4 defines.h \
5 imapbase.h \
6 imaphandler.h \
7 imapresponse.h \
8 mailfactory.h \
9 md5.cpp \
10 miscfunctions.h \
11 sharp_char.h \
12 smtphandler.h \
13 zaurusstuff.h
14 SOURCES =configfile.cpp \
15 imapbase.cpp \
16 imaphandler.cpp \
17 imapresponse.cpp \
18 mailfactory.cpp \
19 md5.h \
20 miscfunctions.cpp \
21 smtphandler.cpp \
22 zaurusstuff.cpp
23 INCLUDEPATH +=$(OPIEDIR)/include
24 LIBS +=-L$(OPIEDIR)/lib -lqpe
25 TARGET =mail
26 DESTDIR =$(QTDIR)/lib
diff --git a/noncore/unsupported/mail2/libmail/mailfactory.cpp b/noncore/unsupported/mail2/libmail/mailfactory.cpp
new file mode 100644
index 0000000..58cf5f8
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/mailfactory.cpp
@@ -0,0 +1,173 @@
1#include <qmessagebox.h>
2#include <qtextstream.h>
3#include <qfile.h>
4
5#include <qpe/mimetype.h>
6
7#include "miscfunctions.h"
8#include "mailfactory.h"
9#include "defines.h"
10
11MailFactory::MailFactory(SendMail &smail, QWidget *parent)
12 : QObject(), _smail(smail), _parent(parent)
13{
14 _abort = false;
15 Account account = _smail.account();
16
17 if (!_smail.from().isEmpty())
18 _header += "From: " + _smail.from() + "\n";
19 if (!_smail.replyTo().isEmpty())
20 _header += "Reply-To: " + _smail.replyTo() + "\n";
21 if (!_smail.to().isEmpty())
22 _header += "To: " + _smail.to() + "\n";
23 if (!_smail.cc().isEmpty())
24 _header += "Cc: " + _smail.cc() + "\n";
25 if (!_smail.bcc().isEmpty())
26 _header += "Bcc: " + _smail.bcc() + "\n";
27 if (!_smail.subject().isEmpty())
28 _header += "Subject: " + _smail.subject() + "\n";
29 if (!_smail.priority().isEmpty() || (_smail.priority() != "Normal"))
30 _header += "Priority: " + _smail.priority() + "\n";
31 _header += "Date: " + MiscFunctions::rfcDate() + "\n";
32 if (!_smail.account().org().isEmpty())
33 _header += "Organization: " + _smail.account().org() + "\n";
34 if (_smail.needsMime())
35 _header += "Mime-Version: 1.0\n";
36 _header += "Message-Id: <" + MiscFunctions::uniqueString() + "." + account.email() + ">\n";
37 if (!_smail.inReplyTo().isEmpty())
38 _header += "In-Reply-To: " + _smail.inReplyTo() + "\n";
39 if (!QString((QString) USERAGENT).isEmpty())
40 _header += (QString) "User-Agent: " + USERAGENT + "\n";
41
42 if (!_smail.needsMime()) {
43 // if (_smail.encrypt() && !_smail.sign()) {
44 // openPgpEncrypt(_smail.message(), _header, _body);
45 // } else if (!_smail.encrypt() && _smail.sign()) {
46 // openPgpSign(_smail.message(), _header, _body);
47 // } else if (_smail.encrypt() && _smail.sign()) {
48 // openPgpSignEncrypt(_smail.message(), _header, _body);
49 // } else {
50 _body += _smail.message();
51 // }
52 } else {
53 QString boundary = MiscFunctions::uniqueString();
54
55 _header += "Content-Type: multipart/mixed; boundary=\"" + boundary + "\"\n";
56
57 _body += "This is a multi-part message in MIME format.\n\n";
58 _body += "--" + boundary + "\n";
59
60 // if (_smail.encrypt() && !_smail.sign()) {
61 // QString header, body;
62 // openPgpEncrypt(_smail.message(), header, body);
63 // _body += header + "\n" + body + "\n";
64 // } else if (!_smail.encrypt() && _smail.sign()) {
65 // QString header, body;
66 // openPgpSign(_smail.message(), header, body);
67 // _body += header + "\n" + body + "\n";
68 // } else if (_smail.encrypt() && _smail.sign()) {
69 // QString header, body;
70 // openPgpSignEncrypt(_smail.message(), header, body);
71 // _body += header + "\n" + body + "\n";
72 // } else {
73
74 // TODO: Do proper charset handling!
75 _body += "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
76 _body += "Content-Transfer-Encoding: 8bit\n\n";
77 _body += _smail.message() + "\n";
78 // }
79
80 QValueList<Attachment> attachments = _smail.attachments();
81 QValueList<Attachment>::Iterator it;
82 for (it = attachments.begin(); it != attachments.end(); it++) {
83 QFile f((*it).fileName());
84 if (f.open(IO_ReadOnly)) {
85 QTextStream t(&f);
86 QString file;
87 while (!t.atEnd()) file += t.readLine() + "\n";
88 f.close();
89 QString mimetype = (new MimeType(*(*it).docLnk()))->id();
90
91 _body += "\n--" + boundary + "\n";
92 _body += "Content-Type: " + mimetype + "; name=\"" + (*it).newName() + "\"\n";
93
94 // TODO: Decide which content transfer encoding is best. B64 for binary, QP for text.
95 _body += "Content-Transfer-Encoding: base64\n";
96
97 _body += "Content-Disposition: attachment; filename=\"" + (*it).newName() + "\"\n";
98 if (!(*it).description().isEmpty())
99 _body += "Content-Description: " + (*it).description() + "\n";
100
101 _body += "\n" + MiscFunctions::encodeBase64(file) + "\n";
102 } else {
103 int ret = QMessageBox::critical(_parent, tr("Error"), tr("<p>Couldn't attach file '%1'. Continue anyway or abort?</p>"), tr("Continue"), tr("Abort"));
104 if (ret == 1) {
105 it = attachments.end();
106 _abort = true;
107 }
108 }
109 }
110 _body += "\n--" + boundary + "--";
111 }
112
113 if (_abort) {
114 _body = QString(0);
115 _header = QString(0);
116 }
117}
118
119// Unfinished GPG code.
120/*
121void MailFactory::openPgpEncrypt(const QString &text, QString &header, QString &body)
122{
123 QString boundary = MiscFunctions::uniqueString();
124
125 header += "Content-Type: multipart/encrypted; boundary=\"" + boundary + "\"; protocol=\"application/pgp-encrypted\"\n";
126
127 body += "--" + boundary + "\n";
128 body += "Content-Type: application/pgp-encrypted\n\n";
129 body += "Version: 1\n\n";
130 body += "--" + boundary + "\n";
131 body += "Content-Type: application/octet-stream\n\n";
132 body += GpgHandling::encrypt(_smail.gpgReceivers(), text);
133 body += "\n--" + boundary + "--\n";
134}
135
136void MailFactory::openPgpSign(const QString &text, QString &header, QString &body)
137{
138 QString boundary = MiscFunctions::uniqueString();
139
140 header += "Content-Type: multipart/signed; boundary=\"" + boundary + "\"; protocol=\"application/pgp-signature\"\n";
141
142 body += "--" + boundary + "\n";
143
144 QString temp;
145 temp += "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
146 temp += "Content-Transfer-Encoding: quoted-printable\n\n";
147 temp += MiscFunctions::encodeQPrintable(text) + "\n";
148 body += temp;
149
150 temp.replace(QRegExp("\n"), "\r\n");
151 QString signature = GpgHandling::sign(temp, _parent);
152
153 body += "\n--" + boundary + "\n";
154 body += "Content-Type: application/pgp-signature\n\n";
155 body += signature + "\n";
156 body += "\n--" + boundary + "--\n";
157}
158
159void MailFactory::openPgpSignEncrypt(const QString &text, QString &header, QString &message)
160{
161 QString header_, message_;
162 openPgpSign(text, header_, message_);
163 openPgpEncrypt(header_ + "\n" + message_, header, message);
164}
165*/
166void MailFactory::genMail(QString &header, QString &message, SendMail &smail, QWidget *parent)
167{
168 MailFactory factory(smail, parent);
169
170 header = factory._header;
171 message = factory._body;
172}
173
diff --git a/noncore/unsupported/mail2/libmail/mailfactory.h b/noncore/unsupported/mail2/libmail/mailfactory.h
new file mode 100644
index 0000000..8f67447
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/mailfactory.h
@@ -0,0 +1,109 @@
1#ifndef MAILFACTORY_H
2#define MAILFACTORY_H
3
4#include <qobject.h>
5
6#include <qpe/applnk.h>
7
8#include "configfile.h"
9
10class Attachment
11{
12public:
13 void setFileName(QString fileName) { _fileName = fileName; }
14 void setNewName(QString newName) { _newName = newName; }
15 void setDescription(QString description) { _description = description; }
16 void setDocLnk(DocLnk *docLnk) { _docLnk = docLnk; }
17
18 QString fileName() { return _fileName; }
19 QString newName() { return _newName; }
20 QString description() { return _description; }
21 DocLnk *docLnk() { return _docLnk; }
22
23protected:
24 QString _fileName, _newName, _description;
25 DocLnk *_docLnk;
26
27};
28
29class SendMail
30{
31public:
32 SendMail() { _needsMime = false; }
33
34 void setAccount(Account account) { _account = account; }
35
36 void setFrom(QString from) { _from = from; }
37 void setReplyTo(QString replyTo) { _replyTo = replyTo; }
38 void setTo(QString to) { _to = to; }
39 void setCc(QString cc) { _cc = cc; }
40 void setBcc(QString bcc) { _bcc = bcc; }
41 void setSubject(QString subject) { _subject = subject; }
42 void setPriority(QString priority) { _priority = priority; }
43 void setMessage(QString message) { _message = message; }
44 void setInReplyTo(QString inReplyTo) { _inReplyTo = inReplyTo; }
45
46 void setNeedsMime(bool needsMime) { _needsMime = needsMime; }
47
48 //void setEncrypt(bool encrypt) { _encrypt = encrypt; }
49 //void setSign(bool sign) { _sign = sign; }
50 //void setGpgReceivers(QValueList<GpgKey> receivers) { _receivers = receivers; }
51 //void setGpgPassphrase(QString passphrase) { _passphrase = passphrase; }
52
53 void setAttachments(QValueList<Attachment> attachments) { _attachments = attachments; }
54 void addAttachment(Attachment attachment) { _attachments.append(attachment); }
55
56 Account account() { return _account; }
57
58 QString from() { return _from; }
59 QString replyTo() { return _replyTo; }
60 QString to() { return _to; }
61 QString cc() { return _cc; }
62 QString bcc() { return _bcc; }
63 QString subject() { return _subject; }
64 QString priority() { return _priority; }
65 QString message() { return _message; }
66 QString inReplyTo() { return _inReplyTo; }
67
68 bool needsMime() { return _needsMime; }
69
70 //bool encrypt() { return _encrypt; }
71 //bool sign() { return _sign; }
72 //QValueList<GpgKey> gpgReceivers() { return _receivers; }
73 //QString gpgPassphrase() { return _passphrase; }
74
75 QValueList<Attachment> attachments() { return _attachments; }
76
77protected:
78 Account _account;
79 QString _from, _replyTo, _to, _cc, _bcc, _subject, _priority, _message, _inReplyTo;
80 bool _needsMime;
81 //bool _encrypt, _sign;
82 //QValueList<GpgKey> _receivers;
83 //QString _passphrase;
84 QValueList<Attachment> _attachments;
85
86};
87
88class MailFactory : public QObject
89{
90 Q_OBJECT
91
92public:
93 static void genMail(QString &header, QString &message, SendMail &smail, QWidget *parent);
94
95protected:
96 MailFactory(SendMail &smail, QWidget *parent);
97
98 //void openPgpEncrypt(const QString &text, QString &header, QString &message);
99 //void openPgpSign(const QString &text, QString &header, QString &message);
100 //void openPgpSignEncrypt(const QString &text, QString &header, QString &message);
101
102 bool _abort;
103 SendMail _smail;
104 QWidget *_parent;
105 QString _header, _body;
106
107};
108
109#endif
diff --git a/noncore/unsupported/mail2/libmail/md5.cpp b/noncore/unsupported/mail2/libmail/md5.cpp
new file mode 100644
index 0000000..4ee2c42
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/md5.cpp
@@ -0,0 +1,242 @@
1// This code was written by Colin Plumb. I've made some small changes.
2// (Constantin Bergemann)
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8 #include <string.h> /* for memcpy() */
9#include "md5.h"
10
11#if __BYTE_ORDER == 1234
12 #define byteReverse(buf, len)/* Nothing */
13#else
14void byteReverse(unsigned char *buf, unsigned longs);
15
16/*
17 * Note: this code is harmless on little-endian machines.
18 */
19void byteReverse(unsigned char *buf, unsigned longs)
20{
21 u_int32_t t;
22 do {
23 t = (u_int32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
24 ((unsigned) buf[1] << 8 | buf[0]);
25 *(u_int32_t *) buf = t;
26 buf += 4;
27 } while (--longs);
28}
29#endif
30
31/*
32 * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
33 * initialization constants.
34 */
35void MD5_Init(MD5_CTX *ctx)
36{
37 ctx->buf[0] = 0x67452301;
38 ctx->buf[1] = 0xefcdab89;
39 ctx->buf[2] = 0x98badcfe;
40 ctx->buf[3] = 0x10325476;
41
42 ctx->bits[0] = 0;
43 ctx->bits[1] = 0;
44}
45
46/*
47 * Update context to reflect the concatenation of another buffer full
48 * of bytes.
49 */
50void MD5_Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len)
51{
52 u_int32_t t;
53
54 /* Update bitcount */
55
56 t = ctx->bits[0];
57 if ((ctx->bits[0] = t + ((u_int32_t) len << 3)) < t)
58 ctx->bits[1]++; /* Carry from low to high */
59 ctx->bits[1] += len >> 29;
60
61 t = (t >> 3) & 0x3f;/* Bytes already in shsInfo->data */
62
63 /* Handle any leading odd-sized chunks */
64
65 if (t) {
66 unsigned char *p = (unsigned char *) ctx->in + t;
67
68 t = 64 - t;
69 if (len < t) {
70 memcpy(p, buf, len);
71 return;
72 }
73 memcpy(p, buf, t);
74 byteReverse(ctx->in, 16);
75 MD5Transform(ctx->buf, (u_int32_t *) ctx->in);
76 buf += t;
77 len -= t;
78 }
79 /* Process data in 64-byte chunks */
80
81 while (len >= 64) {
82 memcpy(ctx->in, buf, 64);
83 byteReverse(ctx->in, 16);
84 MD5Transform(ctx->buf, (u_int32_t *) ctx->in);
85 buf += 64;
86 len -= 64;
87 }
88
89 /* Handle any remaining bytes of data. */
90
91 memcpy(ctx->in, buf, len);
92}
93
94/*
95 * Final wrapup - pad to 64-byte boundary with the bit pattern
96 * 1 0* (64-bit count of bits processed, MSB-first)
97 */
98void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
99{
100 unsigned count;
101 unsigned char *p;
102
103 /* Compute number of bytes mod 64 */
104 count = (ctx->bits[0] >> 3) & 0x3F;
105
106 /* Set the first char of padding to 0x80. This is safe since there is
107 always at least one byte free */
108 p = ctx->in + count;
109 *p++ = 0x80;
110
111 /* Bytes of padding needed to make 64 bytes */
112 count = 64 - 1 - count;
113
114 /* Pad out to 56 mod 64 */
115 if (count < 8) {
116 /* Two lots of padding: Pad the first block to 64 bytes */
117 memset(p, 0, count);
118 byteReverse(ctx->in, 16);
119 MD5Transform(ctx->buf, (u_int32_t *) ctx->in);
120
121 /* Now fill the next block with 56 bytes */
122 memset(ctx->in, 0, 56);
123 } else {
124 /* Pad block to 56 bytes */
125 memset(p, 0, count - 8);
126 }
127 byteReverse(ctx->in, 14);
128
129 /* Append length in bits and transform */
130 ((u_int32_t *) ctx->in)[14] = ctx->bits[0];
131 ((u_int32_t *) ctx->in)[15] = ctx->bits[1];
132
133 MD5Transform(ctx->buf, (u_int32_t *) ctx->in);
134 byteReverse((unsigned char *) ctx->buf, 4);
135 memcpy(digest, ctx->buf, 16);
136 memset((char *) ctx, 0, sizeof(ctx));/* In case it's sensitive */
137}
138
139/* The four core functions - F1 is optimized somewhat */
140
141/* #define F1(x, y, z) (x & y | ~x & z) */
142#define F1(x, y, z) (z ^ (x & (y ^ z)))
143#define F2(x, y, z) F1(z, x, y)
144#define F3(x, y, z) (x ^ y ^ z)
145#define F4(x, y, z) (y ^ (x | ~z))
146
147/* This is the central step in the MD5 algorithm. */
148#define MD5STEP(f, w, x, y, z, data, s) \
149 ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
150
151/*
152 * The core of the MD5 algorithm, this alters an existing MD5 hash to
153 * reflect the addition of 16 longwords of new data. MD5Update blocks
154 * the data and converts bytes into longwords for this routine.
155 */
156void MD5Transform(u_int32_t buf[4], u_int32_t const in[16])
157{
158 register u_int32_t a, b, c, d;
159
160 a = buf[0];
161 b = buf[1];
162 c = buf[2];
163 d = buf[3];
164
165 MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
166 MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
167 MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
168 MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
169 MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
170 MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
171 MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
172 MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
173 MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
174 MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
175 MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
176 MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
177 MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
178 MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
179 MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
180 MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
181
182 MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
183 MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
184 MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
185 MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
186 MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
187 MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
188 MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
189 MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
190 MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
191 MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
192 MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
193 MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
194 MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
195 MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
196 MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
197 MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
198
199 MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
200 MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
201 MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
202 MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
203 MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
204 MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
205 MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
206 MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
207 MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
208 MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
209 MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
210 MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
211 MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
212 MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
213 MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
214 MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
215
216 MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
217 MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
218 MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
219 MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
220 MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
221 MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
222 MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
223 MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
224 MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
225 MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
226 MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
227 MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
228 MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
229 MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
230 MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
231 MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
232
233 buf[0] += a;
234 buf[1] += b;
235 buf[2] += c;
236 buf[3] += d;
237}
238
239#ifdef __cplusplus
240} // extern "C"
241#endif
242
diff --git a/noncore/unsupported/mail2/libmail/md5.h b/noncore/unsupported/mail2/libmail/md5.h
new file mode 100644
index 0000000..221dd09
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/md5.h
@@ -0,0 +1,35 @@
1// This code was written by Colin Plumb. I've made some small changes.
2// (Constantin Bergemann)
3
4#ifndef _MD5_H_
5#define _MD5_H_
6
7#include <sys/types.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#define MD5_HASHBYTES 16
14
15typedef struct MD5Context {
16 u_int32_t buf[4];
17 u_int32_t bits[2];
18 unsigned char in[64];
19} MD5_CTX;
20
21extern void MD5_Init(MD5_CTX *context);
22extern void MD5_Update(MD5_CTX *context, unsigned char const *buf,
23 unsigned len);
24extern void MD5_Final(unsigned char digest[MD5_HASHBYTES], MD5_CTX *context);
25extern void MD5Transform(u_int32_t buf[4], u_int32_t const in[16]);
26extern char * MD5End(MD5_CTX *, char *);
27extern char * MD5File(const char *, char *);
28extern char * MD5Data (const unsigned char *, unsigned int, char *);
29
30#ifdef __cplusplus
31} // extern "C"
32#endif
33
34#endif /* !_MD5_H_ */
35
diff --git a/noncore/unsupported/mail2/libmail/miscfunctions.cpp b/noncore/unsupported/mail2/libmail/miscfunctions.cpp
new file mode 100644
index 0000000..0edbfa8
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/miscfunctions.cpp
@@ -0,0 +1,295 @@
1#include <qdatetime.h>
2
3#include <stdlib.h>
4#include <stdio.h>
5#include <time.h>
6
7#include <openssl/md5.h>
8
9#include "miscfunctions.h"
10
11QString MiscFunctions::encodeQPrintable(const QString &src)
12{
13 // TODO: implent encodeQPrintable
14 return src;
15}
16
17QString MiscFunctions::decodeQPrintable(const QString &src)
18{
19 QString out;
20
21 for (unsigned int i = 0; i <= src.length(); i++) {
22 if (src[i] == '=') {
23 if (src[i+1] == "\n") {
24 i += 1;
25 } else {
26 QString temp = QString("%1%2").arg(src[i+1]).arg(src[i+2]);
27 int number = temp.toInt(0, 16);
28
29 out += QChar(number);
30 i += 2;
31 }
32 } else {
33 out += src[i];
34 }
35 }
36 return out;
37}
38
39QString MiscFunctions::encodeBase64(const QString &src)
40{
41 char *dataPtr = (char *) src.latin1();
42 int len = src.length();
43 int count = 0;
44 QString temp = "";
45
46 while (len > 0) {
47 if (len < 3) {
48 encodeBase64Base(dataPtr, &temp, len);
49 len = 0;
50 } else {
51 encodeBase64Base(dataPtr, &temp, 3);
52 len -= 3;
53 dataPtr += 3;
54 count += 4;
55 }
56 if (count > 72) {
57 count = 0;
58 temp += "\n";
59 }
60 }
61
62 return temp;
63}
64
65void MiscFunctions::encodeBase64Base(char *src, QString *dest, int len)
66{
67 QString temp;
68 uchar c;
69 uchar bufOut[4];
70
71 bufOut[0] = src[0];
72 bufOut[0] >>= 2;
73
74 bufOut[1] = src[0];
75 bufOut[1] = bufOut[1] & (1 + 2);
76 bufOut[1] <<= 4;
77 if (len > 1) c = src[1];
78 else c = 0;
79
80 c = c & (16 + 32 + 64 + 128);
81 c >>= 4;
82 bufOut[1] = bufOut[1] | c;
83
84 bufOut[2] = src[1];
85 bufOut[2] = bufOut[2] & (1 + 2 + 4 + 8);
86 bufOut[2] <<= 2;
87 if (len > 2) c = src[2];
88 else c = 0;
89
90 c >>= 6;
91 bufOut[2] = bufOut[2] | c;
92
93 bufOut[3] = src[2];
94 bufOut[3] = bufOut[3] & (1 + 2 + 4 + 8 + 16 + 32);
95
96 if (len == 1) {
97 bufOut[2] = 64;
98 bufOut[3] = 64;
99 }
100 if (len == 2) {
101 bufOut[3] = 64;
102 }
103 for (int x = 0; x < 4; x++) {
104 if (bufOut[x] <= 25)
105 bufOut[x] += (uint) 'A';
106 else if (bufOut[x] >= 26 && bufOut[x] <= 51)
107 bufOut[x] += (uint) 'a' - 26;
108 else if (bufOut[x] >= 52 && bufOut[x] <= 61)
109 bufOut[x] += (uint) '0' - 52;
110 else if (bufOut[x] == 62)
111 bufOut[x] = '+';
112 else if (bufOut[x] == 63)
113 bufOut[x] = '/';
114 else if (bufOut[x] == 64)
115 bufOut[x] = '=';
116
117 dest->append(bufOut[x]);
118 }
119}
120
121QString MiscFunctions::decodeBase64(const QString &src)
122{
123 char plain[4];
124 char *destPtr;
125 QByteArray buffer;
126 uint bufCount = 0, pos = 0, decodedCount, x;
127
128 buffer.resize(src.length() * 3 / 4);
129 destPtr = buffer.data();
130
131 while (pos < src.length()) {
132 decodedCount = 4;
133 x = 0;
134 while ((x < 4) && (pos < src.length())) {
135 plain[x] = src[pos].latin1();
136 pos++;
137 if (plain[x] == '\r' || plain[x] == '\n' || plain[x] == ' ')
138 x--;
139 x++;
140 }
141 if (x > 1) {
142 decodedCount = decodeBase64Base(plain, destPtr);
143 destPtr += decodedCount;
144 bufCount += decodedCount;
145 }
146 }
147
148 buffer.resize(bufCount);
149 return QString(buffer);
150}
151
152int MiscFunctions::decodeBase64Base(char *src, char *bufOut)
153{
154 char c, z;
155 char li[4];
156 int processed;
157
158 for (int x = 0; x < 4; x++) {
159 c = src[x];
160
161 if ( (int) c >= 'A' && (int) c <= 'Z')
162 li[x] = (int) c - (int) 'A';
163 if ( (int) c >= 'a' && (int) c <= 'z')
164 li[x] = (int) c - (int) 'a' + 26;
165 if ( (int) c >= '0' && (int) c <= '9')
166 li[x] = (int) c - (int) '0' + 52;
167 if (c == '+')
168 li[x] = 62;
169 if (c == '/')
170 li[x] = 63;
171 }
172
173 processed = 1;
174 bufOut[0] = (char) li[0] & (32+16+8+4+2+1);
175 bufOut[0] <<= 2;
176 z = li[1] >> 4;
177 bufOut[0] = bufOut[0] | z;
178
179 if (src[2] != '=') {
180 bufOut[1] = (char) li[1] & (8+4+2+1);
181 bufOut[1] <<= 4;
182 z = li[2] >> 2;
183 bufOut[1] = bufOut[1] | z;
184 processed++;
185
186 if (src[3] != '=') {
187 bufOut[2] = (char) li[2] & (2+1);
188 bufOut[2] <<= 6;
189 z = li[3];
190 bufOut[2] = bufOut[2] | z;
191 processed++;
192 }
193 }
194 return processed;
195}
196
197QString MiscFunctions::uniqueString()
198{
199 QString uniqueString = QDate::currentDate().toString();
200 uniqueString += QTime::currentTime().toString();
201 uniqueString += QString("%1").arg(rand());
202
203 unsigned char md[16];
204
205 MD5_CTX ctx;
206 MD5_Init(&ctx);
207 MD5_Update(&ctx, (unsigned char *)uniqueString.latin1(), uniqueString.length());
208 MD5_Final(md, &ctx);
209
210 char hash[16];
211 for (unsigned int i = 0; i < sizeof(md); i++)
212 sprintf(hash + 2 * i, "%02x", md[i]);
213
214 return hash;
215}
216
217QString MiscFunctions::rfcDate()
218{
219 time_t t = time(NULL);
220 tm *time = localtime(&t);
221 QString pm, tzh, tzm, ths, tms, tss;
222
223 time->tm_gmtoff < 0 ? pm = "-" : pm = "+";
224 int h = abs(time->tm_gmtoff) / 3600;
225 int m = (abs(time->tm_gmtoff) - h * 3600) / 60;
226 h < 10 ? tzh = QString("0%1").arg(h) : tzh = QString("%1").arg(h);
227 m < 10 ? tzm = QString("0%1").arg(m) : tzm = QString("%1").arg(m);
228
229 int th = time->tm_hour;
230 int tm = time->tm_min;
231 int ts = time->tm_sec;
232 th < 10 ? ths = QString("0%1").arg(th) : ths = QString("%1").arg(th);
233 tm < 10 ? tms = QString("0%1").arg(tm) : tms = QString("%1").arg(tm);
234 ts < 10 ? tss = QString("0%1").arg(ts) : tss = QString("%1").arg(ts);
235
236 QString month = QDate().monthName(time->tm_mon + 1);
237 QString dayna = QDate().dayName(time->tm_wday);
238 QString tzone = pm + tzh + tzm;
239
240 return QString("%1, %2 %3 %4 %5:%6:%7 %8")
241 .arg(dayna)
242 .arg(time->tm_mday)
243 .arg(month)
244 .arg(time->tm_year + 1900)
245 .arg(ths)
246 .arg(tms)
247 .arg(tss)
248 .arg(tzone);
249}
250
251QString MiscFunctions::smtpAuthCramMd5(const QString &data, const QString &key)
252{
253 MD5_CTX context;
254 unsigned char k_ipad[65];
255 unsigned char k_opad[65];
256 unsigned char tk[16];
257 unsigned char digest[16];
258 unsigned char *key_int = (unsigned char *)key.latin1();
259 char hash[33];
260
261 if (key.length() > 64) {
262 MD5_CTX tctx;
263 MD5_Init(&tctx);
264 MD5_Update(&tctx, key_int, sizeof(key_int));
265 MD5_Final(tk, &tctx);
266
267 key_int = tk;
268 }
269
270 bzero(k_ipad, sizeof k_ipad);
271 bzero(k_opad, sizeof k_opad);
272 bcopy(key_int, k_ipad, sizeof(key_int));
273 bcopy(key_int, k_opad, sizeof(key_int));
274
275 for (int i = 0; i < 64; i++) {
276 k_ipad[i] ^= 0x36;
277 k_opad[i] ^= 0x5c;
278 }
279
280 MD5_Init(&context);
281 MD5_Update(&context, k_ipad, 64);
282 MD5_Update(&context, (unsigned char *)data.latin1(), data.length());
283 MD5_Final(digest, &context);
284
285 MD5_Init(&context);
286 MD5_Update(&context, k_opad, 64);
287 MD5_Update(&context, digest, 16);
288 MD5_Final(digest, &context);
289
290 for (unsigned int i = 0; i < sizeof(digest); i++)
291 sprintf (hash + 2 * i, "%02x", digest[i]);
292
293 return hash;
294}
295
diff --git a/noncore/unsupported/mail2/libmail/miscfunctions.h b/noncore/unsupported/mail2/libmail/miscfunctions.h
new file mode 100644
index 0000000..a13e1e3
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/miscfunctions.h
@@ -0,0 +1,27 @@
1#ifndef MISCFUNCTIONS_H
2#define MISCFUNCTIONS_H
3
4#include <qobject.h>
5
6class MiscFunctions : public QObject
7{
8 Q_OBJECT
9
10public:
11 static QString encodeQPrintable(const QString &src);
12 static QString decodeQPrintable(const QString &src);
13 static QString encodeBase64(const QString &src);
14 static QString decodeBase64(const QString &src);
15 static QString uniqueString();
16 static QString rfcDate();
17 static QString smtpAuthCramMd5(const QString &data, const QString &key);
18
19protected:
20 MiscFunctions() : QObject() { }
21
22 static void encodeBase64Base(char *src, QString *dest, int len);
23 static int decodeBase64Base(char *src, char *bufOut);
24
25};
26
27#endif
diff --git a/noncore/unsupported/mail2/libmail/sharp_char.h b/noncore/unsupported/mail2/libmail/sharp_char.h
new file mode 100644
index 0000000..8bd8beb
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/sharp_char.h
@@ -0,0 +1,241 @@
1/*
2 * linux/include/asm/sharp_char.h
3 */
4
5#ifndef __ASM_SHARP_CHAR_H_INCLUDED
6#define __ASM_SHARP_CHAR_H_INCLUDED
7
8/*
9 * If SHARPCHAR_USE_MISCDEV defined , misc driver architecture used instead of sharp_char
10 */
11
12#define SHARPCHAR_USE_MISCDEV
13
14/*
15 * devices defines...
16 */
17
18#ifndef SHARP_DEV_MAJOR
19#define SHARP_DEV_MAJOR 11
20#endif
21
22#ifndef SHARP_DEV_MINOR_START
23#define SHARP_DEV_MINOR_START 210
24#endif
25
26#define SHARP_DEV_MINOR_MAX 4 /* defines last minor number of SHARP device */
27
28#define SHARP_LED_MINOR (SHARP_DEV_MINOR_START+0)
29#define SHARP_BUZZER_MINOR (SHARP_DEV_MINOR_START+1)
30#define SHARP_GSM_MINOR (SHARP_DEV_MINOR_START+2)
31#define SHARP_AUDIOCTL_MINOR (SHARP_DEV_MINOR_START+3)
32#define SHARP_KBDCTL_MINOR (SHARP_DEV_MINOR_START+4)
33
34/*
35 * ioctl defines...
36 */
37
38#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
39
40/* --- for SHARP_LED device --- */
41 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
42#define SHARP_LED_GETSTATUS (SHARP_LED_IOCTL_START)
43#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
44#define SHARP_LED_ISUPPORTED (SHARP_LED_IOCTL_START+2)
45
46typedef struct sharp_led_status {
47 int which; /* select which LED status is wanted. */
48 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
49} sharp_led_status;
50
51#define SHARP_LED_WHICH_MAX 15 /* last number of LED */
52
53/* parameters for 'which' member */
54#define SHARP_LED_PDA 0 /* PDA status */
55#define SHARP_LED_DALARM 1 /* daily alarm */
56#define SHARP_LED_SALARM 2 /* schedule alarm */
57#define SHARP_LED_BATTERY 3 /* main battery status */
58#define SHARP_LED_ACSTATUS 4 /* AC line status */
59#define SHARP_LED_CHARGER 5 /* charger status */
60#define SHARP_LED_PHONE_RSSI 6 /* phone status (RSSI...) */
61#define SHARP_LED_PHONE_DIAL 7 /* phone status (dialing...) */
62#define SHARP_LED_PHONE_IN 8 /* phone status (incoming..) */
63#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
64#define SHARP_LED_MAIL_SEND 10 /* mail status (sending...) */
65#define SHARP_LED_MAIL_QUEUE 11 /* mail to send is in queue */
66#define SHARP_LED_COLLIE_0 12 /* 1st pri. battery LED control */
67#define SHARP_LED_COLLIE_1 13 /* 1st pri. mail LED control */
68#define SHARP_LED_COLLIE_2 14 /* reserved */
69#define SHARP_LED_COLLIE_3 15 /* reserved */
70
71/* parameters for 'status' member */
72#define LED_PDA_RUNNING 0 /* for SHARP_LED_RUN */
73#define LED_PDA_SUSPENDED 1 /* for SHARP_LED_RUN */
74#define LED_PDA_OFF 2 /* for SHARP_LED_RUN */
75#define LED_PDA_ERROR 3 /* for SHARP_LED_RUN */
76
77#define LED_DALARM_OFF 0 /* for SHARP_LED_DALARM */
78#define LED_DALARM_ON 1 /* for SHARP_LED_DALARM */
79
80#define LED_SALARM_OFF 0 /* for SHARP_LED_SALARM */
81#define LED_SALARM_ON 1 /* for SHARP_LED_SALARM */
82
83#define LED_BATTERY_GOOD 0 /* for SHARP_LED_BATTERY */
84#define LED_BATTERY_LOW 1 /* for SHARP_LED_BATTERY */
85#define LED_BATTERY_VERY_LOW 2 /* for SHARP_LED_BATTERY */
86#define LED_BATTERY_CRITICAL 3 /* for SHARP_LED_BATTERY */
87
88#define LED_CHARGER_OFF 0 /* for SHARP_LED_CHARGER */
89#define LED_CHARGER_CHARGING 1 /* for SHARP_LED_CHARGER */
90#define LED_CHARGER_ERROR 2 /* for SHARP_LED_CHARGER */
91
92#define LED_AC_NOT_CONNECTED 0 /* for SHARP_LED_ACSTATUS */
93#define LED_AC_CONNECTED 1 /* for SHARP_LED_ACSTATUS */
94
95#define LED_RSSI_OUT 0 /* for SHARP_LED_PHONE_RSSI */
96#define LED_RSSI_IN 1 /* for SHARP_LED_PHONE_RSSI */
97
98#define LED_DIAL_OFF 0 /* for SHARP_LED_PHONE_DIAL */
99#define LED_DIAL_DIALING 1 /* for SHARP_LED_PHONE_DIAL */
100#define LED_DIAL_HOLDING 2 /* for SHARP_LED_PHONE_DIAL */
101
102#define LED_PHONE_WAITING 0 /* for SHARP_LED_PHONE_IN */
103#define LED_PHONE_INCOMING 1 /* for SHARP_LED_PHONE_IN */
104
105#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
106#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
107#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
108
109#define LED_SENDMAIL_OFF 0 /* for SHARP_LED_MAIL_SEND */
110#define LED_SENDMAIL_SENDING 1 /* for SHARP_LED_MAIL_SEND */
111#define LED_SENDMAIL_ERROR 2 /* for SHARP_LED_MAIL_SEND */
112
113#define LED_MAILQUEUE_NOUNREAD 0 /* for SHARP_LED_MAIL_QUEUE */
114#define LED_MAILQUEUE_NEWMAIL 1 /* for SHARP_LED_MAIL_QUEUE */
115#define LED_MAILQUEUE_UNREAD 2 /* for SHARP_LED_MAIL_QUEUE */
116
117 #define LED_COLLIE_0_DEFAULT 0 /* for SHARP_LED_COLLIE_0 */
118#define LED_COLLIE_0_OFF 1 /* for SHARP_LED_COLLIE_0 */
119 #define LED_COLLIE_0_ON 2 /* for SHARP_LED_COLLIE_0 */
120 #define LED_COLLIE_0_FASTBLINK 3 /* for SHARP_LED_COLLIE_0 */
121 #define LED_COLLIE_0_SLOWBLINK 4 /* for SHARP_LED_COLLIE_0 */
122
123
124#define LED_COLLIE_1_DEFAULT 0 /* for SHARP_LED_COLLIE_1 */
125#define LED_COLLIE_1_OFF 1 /* for SHARP_LED_COLLIE_1 */
126#define LED_COLLIE_1_ON 2 /* for SHARP_LED_COLLIE_1 */
127#define LED_COLLIE_1_FLASHON 3 /* for SHARP_LED_COLLIE_1 */
128#define LED_COLLIE_1_FLASHOFF 4 /* for SHARP_LED_COLLIE_1 */
129#define LED_COLLIE_1_VFSTBLINK 5 /* for SHARP_LED_COLLIE_1 */
130#define LED_COLLIE_1_FASTBLINK 6 /* for SHARP_LED_COLLIE_1 */
131#define LED_COLLIE_1_NORMBLINK 7 /* for SHARP_LED_COLLIE_1 */
132#define LED_COLLIE_1_SLOWBLINK 8 /* for SHARP_LED_COLLIE_1 */
133#define LED_COLLIE_1_SOFTBLINK 9 /* for SHARP_LED_COLLIE_1 */
134#define LED_COLLIE_1_SOFTFLASH 10 /* for SHARP_LED_COLLIE_1 */
135
136/* --- for SHARP_BUZZER device --- */
137 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
138#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
139#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
140#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
141#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
142#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
143#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
144
145typedef struct sharp_buzzer_status { /* this struct is used for setvolume/getvolume */
146 int which; /* select which LED status is wanted. */
147 int volume; /* set new buzzer volume if you call SHARP_BUZZER_SETVOLUME */
148 int mute; /* set 1 to MUTE if you call SHARP_BUZZER_SETMUTE */
149} sharp_buzzer_status;
150
151#define SHARP_BUZ_WHICH_MAX 14 /* last number of buzzer */
152
153#define SHARP_BUZ_ALL_SOUNDS -1 /* for setting volumes of ALL sounds at a time */
154
155#define SHARP_BUZ_WRITESOUND 0 /* for sound datas through 'write' calls */
156#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
157#define SHARP_BUZ_KEYSOUND 2 /* key sound */
158#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
159#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
160#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
161#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
162#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
163#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
164#define SHARP_PDA_APPSTART 9 /* application start */
165#define SHARP_PDA_APPQUIT 10 /* application ends */
166#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
167#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
168#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
169#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
170
171#define SHARP_BUZ_VOLUME_OFF 0
172#define SHARP_BUZ_VOLUME_LOW 33
173#define SHARP_BUZ_VOLUME_MEDIUM 67
174#define SHARP_BUZ_VOLUME_HIGH 100 /* currentry , this is the maximum ... */
175#define SHARP_BUZ_VOLUME_MAX (SHARP_BUZ_VOLUME_HIGH)
176
177/* --- for SHARP_GSM device --- */
178 #defineSHARP_GSM_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
179#define SHARP_GSM_GETEXTSTATUS (SHARP_GSM_IOCTL_START+16)
180#define SHARP_GSM_INFO_TELL_MODE (SHARP_GSM_IOCTL_START+17)
181
182#define GSM_PHONE_NO_POWER 0 /* for SHARP_GSM_INFO_TELL_MODE */
183#define GSM_PHONE_NO_CONNECTION 1 /* for SHARP_GSM_INFO_TELL_MODE */
184#define GSM_PHONE_IN_ANALOG_MODE 2 /* for SHARP_GSM_INFO_TELL_MODE */
185#define GSM_PHONE_IN_DATA_MODE 3 /* for SHARP_GSM_INFO_TELL_MODE */
186
187typedef struct sharp_gsmext_status {
188 int carkit; /* be set as 1 , if car-kit is connected */
189 int headphone_mic; /* be set as 1 , if head-phone-microphone is inserted */
190} sharp_gsmext_status;
191
192/* --- for SHARP_AUDIOCTL device --- */
193 #defineSHARP_AUDIOCTL_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
194 #defineSHARP_AUDIOCTL_ARCH_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START+0x10)
195#define SHARP_IRIS_AUFIL_GETVAL (SHARP_AUDIOCTL_ARCH_IOCTL_START+0)
196#define SHARP_IRIS_AUFIL_SETVAL (SHARP_AUDIOCTL_ARCH_IOCTL_START+1)
197#define SHARP_IRIS_AMP_EXT_ON (SHARP_AUDIOCTL_ARCH_IOCTL_START+2)
198#define SHARP_IRIS_AMP_EXT_OFF (SHARP_AUDIOCTL_ARCH_IOCTL_START+3)
199
200
201#define SHARP_IRIS_AUFIL_FILTERON 0x01 /* Iris AudioCtl Specific. Enable Audio Filter */
202
203/* --- for SHARP_AUDIOCTL device --- */
204 #defineSHARP_KBDCTL_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
205#define SHARP_KBDCTL_GETMODIFSTAT (SHARP_KBDCTL_IOCTL_START+0)
206#define SHARP_KBDCTL_TOGGLEMODIFSTAT (SHARP_KBDCTL_IOCTL_START+1)
207#define SHARP_KBDCTL_SETHOLDTH (SHARP_KBDCTL_IOCTL_START+2)
208#define SHARP_KBDCTL_SETHOLDTH_GR (SHARP_KBDCTL_IOCTL_START+3)
209#define SHARP_KBDCTL_HOLDINFO_SETHD (SHARP_KBDCTL_IOCTL_START+4)
210#define SHARP_KBDCTL_HOLDINFO_SETSL (SHARP_KBDCTL_IOCTL_START+5)
211#define SHARP_KBDCTL_HOLDINFO_DELHD (SHARP_KBDCTL_IOCTL_START+6)
212#define SHARP_KBDCTL_HOLDINFO_DELSL (SHARP_KBDCTL_IOCTL_START+7)
213#define SHARP_KBDCTL_HOLDINFO_RESTHD (SHARP_KBDCTL_IOCTL_START+8)
214#define SHARP_KBDCTL_HOLDINFO_RESTSL (SHARP_KBDCTL_IOCTL_START+9)
215#define SHARP_KBDCTL_HOLDINFO_RESTFULL (SHARP_KBDCTL_IOCTL_START+10)
216
217typedef struct sharp_kbdctl_modifstat {
218 int which;
219 int stat;
220} sharp_kbdctl_modifstat;
221
222typedef struct sharp_kbdctl_holdstat {
223 int group;
224 int timeout;
225} sharp_kbdctl_holdstat;
226
227typedef struct sharp_kbdctl_holdcustom {
228 int normal_hardcode;
229 int normal_slcode;
230 int hold_slcode;
231} sharp_kbdctl_holdcustom;
232
233#define SHARP_EXTMODIF_2ND 0x01
234#define SHARP_EXTMODIF_CAPS 0x02
235#define SHARP_EXTMODIF_NUMLOCK 0x03
236
237#define HOLDKEY_GROUP_NORMAL 0
238#define HOLDKEY_GROUP_POWER 1
239
240#endif /* __ASM_SHARP_CHAR_H_INCLUDED */
241
diff --git a/noncore/unsupported/mail2/libmail/smtphandler.cpp b/noncore/unsupported/mail2/libmail/smtphandler.cpp
new file mode 100644
index 0000000..1bbad8b
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/smtphandler.cpp
@@ -0,0 +1,172 @@
1#warning "TODO: XXX This class needs to be rewritten. XXX"
2
3#include <qsocket.h>
4#include <qtimer.h>
5#include <qfile.h>
6#include <qdatetime.h>
7#include <qdir.h>
8#include <qregexp.h>
9
10#include <qpe/mimetype.h>
11#include <qpe/config.h>
12
13#include <stdlib.h>
14
15#include "smtphandler.h"
16#include "miscfunctions.h"
17
18SmtpHandler::SmtpHandler(const QString &header, const QString &message, Account &account, const QString &to)
19 : QObject(), _header(header), _message(message), _account(account), _to(to)
20{
21 _header.replace(QRegExp("\\n"), "\r\n");
22 _message.replace(QRegExp("\\n"), "\r\n");
23 _message.replace(QRegExp("\\r\\n\\.\\r\\n"), "\r\n..\r\n");
24
25 //_state = account.esmtpAuth() ? Ehlo : Helo;
26 _state = Helo;
27
28 _socket = new QSocket(this);
29 connect(_socket, SIGNAL(hostFound()), this, SLOT(hostFound()));
30 connect(_socket, SIGNAL(connected()), this, SLOT(connected()));
31 connect(_socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
32 connect(_socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
33
34 _socket->connectToHost(account.smtpServer(), account.smtpPort().toUInt());
35 emit status(tr("Looking up host..."));
36}
37
38void SmtpHandler::errorHandling(int err)
39{
40 if (err == QSocket::ErrConnectionRefused) {
41 emit error(tr("The server refused the connection."));
42 } else if (err == QSocket::ErrHostNotFound) {
43 emit error(tr("Host lookup failed."));
44 } else if (err == QSocket::ErrSocketRead) {
45 emit error(tr("The read from the socket failed for an unknown reason."));
46 } else {
47 emit error(tr("The sending failed for an unknown reason."));
48 }
49 stop();
50}
51
52void SmtpHandler::hostFound()
53{
54 emit status(tr("Host found."));
55}
56
57void SmtpHandler::connected()
58{
59 emit status(tr("Connected to %1").arg(_socket->peerName()));
60}
61
62void SmtpHandler::readyRead()
63{
64 if (!_socket->canReadLine()) return;
65 if (_state == Close) stop();
66
67 QString response = _socket->readLine();
68 QString temp = response;
69 temp.truncate(3);
70 int responseCode = temp.toInt();
71
72#ifndef QT_NO_DEBUG
73 qDebug(tr("SMTP > %3").arg(response.stripWhiteSpace()));
74#endif
75
76 response.replace(0, 4, "");
77 response.stripWhiteSpace();
78
79 if (_state == Ehlo && responseCode == 220) {
80 QString hostname = getenv("HOSTNAME");
81 if (hostname.stripWhiteSpace().isEmpty())
82 hostname = "opiemail";
83
84 emit status(tr("SMTP> EHLO *"));
85 sendToSocket(QString("EHLO %1\r\n").arg(hostname));
86 _state = Auth;
87 } else if (_state == Auth && responseCode == 250) {
88 QStringList capabilities;
89 while (_socket->canReadLine()) {
90 QString line = _socket->readLine().stripWhiteSpace();
91 capabilities.append(line);
92 }
93
94 // FIXME: Dirty, quick hack!
95 if (!capabilities.grep(QRegExp("^250-AUTH=LOGIN.*CRAM-MD5.*$")).isEmpty()) {
96 // emit errorOccourred(ErrAuthNotSupported);
97 _state = Mail;
98 } else {
99 emit status(tr("SMTP> AUTH CRAM-MD5"));
100 sendToSocket("AUTH CRAM-MD5\r\n");
101 _state = ReadAuth;
102 }
103 } else if (_state == ReadAuth && responseCode == 334) {
104 QString msgId = MiscFunctions::decodeBase64(response);
105
106 QString authString;
107 authString = _account.user() + " " +
108 MiscFunctions::smtpAuthCramMd5(msgId, _account.pass());
109 authString = MiscFunctions::encodeBase64(authString);
110
111 emit status(tr("SMTP> Authenticating"));
112 sendToSocket(authString + "\r\n");
113
114 _state = Mail;
115 } else if (_state == Helo && responseCode == 220) {
116 QString hostname = getenv("HOSTNAME");
117 if (hostname.stripWhiteSpace().isEmpty())
118 hostname = "opiemail";
119
120 emit status(tr("SMTP> HELO *"));
121 sendToSocket(QString("HELO %1\r\n").arg(hostname));
122 _state = Mail;
123 } else if (_state == Mail && responseCode == 250) {
124 emit status(tr("SMTP> MAIL FROM: *"));
125 sendToSocket("MAIL FROM: " + _account.email() + "\r\n");
126 _state = Rcpt;
127 } else if (_state == Rcpt && responseCode == 250) {
128 emit status(tr("SMTP> RCPT TO: *"));
129 sendToSocket("RCPT TO: " + _to + "\r\n");
130 _state = Data;
131 } else if (_state == Data && responseCode == 250) {
132 emit status(tr("SMTP> DATA"));
133 sendToSocket("DATA\r\n");
134 _state = Body;
135 } else if (_state == Body && responseCode == 354) {
136 emit status(tr("SMTP> Sending data..."));
137 sendToSocket(_header + "\r\n" + _message + "\r\n.\r\n", false);
138 _state = Quit;
139 } else if (_state == Quit) {
140 emit status(tr("SMTP> QUIT (Done)"));
141 sendToSocket("QUIT\r\n");
142 _state = Close;
143 } else if (_state == Close) {
144
145 } else {
146 emit error(tr("The server returned an error. This is the message:<br>%1").arg(response));
147 stop();
148 }
149}
150
151void SmtpHandler::sendToSocket(const QString &text, bool log)
152{
153 _socket->writeBlock(text.latin1(), text.length());
154
155 if (log) {
156#ifndef QT_NO_DEBUG
157 qDebug(tr("SMTP < %3").arg(text.stripWhiteSpace()));
158#endif
159 }
160}
161
162void SmtpHandler::stop()
163{
164 emit finished();
165 QTimer::singleShot(0, this, SLOT(deleteMe()));
166}
167
168void SmtpHandler::deleteMe()
169{
170 delete this;
171}
172
diff --git a/noncore/unsupported/mail2/libmail/smtphandler.h b/noncore/unsupported/mail2/libmail/smtphandler.h
new file mode 100644
index 0000000..abbcbcd
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/smtphandler.h
@@ -0,0 +1,55 @@
1#ifndef SMTPHANDLER_H
2#define SMTPHANDLER_H
3
4#include <qobject.h>
5#include <qstring.h>
6
7#include "configfile.h"
8
9class QSocket;
10
11class SmtpHandler : public QObject
12{
13 Q_OBJECT
14
15public:
16 SmtpHandler(const QString &header, const QString &message, Account &account, const QString &to);
17
18 enum SmtpError {
19 ErrConnectionRefused,
20 ErrHostNotFound,
21 ErrUnknownResponse,
22 ErrAuthNotSupported
23 };
24
25public slots:
26 void stop();
27
28signals:
29 void finished();
30 void error(const QString &);
31 void status(const QString &);
32
33private slots:
34 void readyRead();
35 void hostFound();
36 void connected();
37 void deleteMe();
38 void errorHandling(int);
39
40private:
41 void sendToSocket(const QString &text, bool log = true);
42
43 enum State { Ehlo, Auth, ReadAuth, Helo, Mail, Rcpt,
44 Data, Body, Quit, Close };
45
46 QString _header, _message;
47 Account _account;
48 QString _to;
49 QSocket *_socket;
50 int _state;
51};
52
53#endif
54
55
diff --git a/noncore/unsupported/mail2/libmail/zaurusstuff.cpp b/noncore/unsupported/mail2/libmail/zaurusstuff.cpp
new file mode 100644
index 0000000..bbf1541
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/zaurusstuff.cpp
@@ -0,0 +1,38 @@
1#include <sys/ioctl.h>
2#include <fcntl.h>
3#include <stdio.h>
4
5#include "zaurusstuff.h"
6#include "sharp_char.h"
7
8ZaurusStuff::ZaurusStuff() : QObject()
9{
10
11}
12
13void ZaurusStuff::blinkLedOn()
14{
15 sharp_led_status st;
16 st.which = SHARP_LED_COLLIE_1;
17 st.status = LED_COLLIE_1_FLASHON;
18 ioctl(open("/dev/sharp_led", O_WRONLY), SHARP_LED_SETSTATUS, &st);
19}
20
21void ZaurusStuff::blinkLedOff()
22{
23 sharp_led_status st;
24 st.which = SHARP_LED_COLLIE_1;
25 st.status = LED_COLLIE_1_DEFAULT;
26 ioctl(open("/dev/sharp_led", O_WRONLY), SHARP_LED_SETSTATUS, &st);
27}
28
29void ZaurusStuff::buzzerOn()
30{
31 ioctl(open("/dev/sharp_buz", O_WRONLY), SHARP_BUZZER_MAKESOUND, 4);
32}
33
34void ZaurusStuff::buzzerOff()
35{
36
37}
38
diff --git a/noncore/unsupported/mail2/libmail/zaurusstuff.h b/noncore/unsupported/mail2/libmail/zaurusstuff.h
new file mode 100644
index 0000000..33c65da
--- a/dev/null
+++ b/noncore/unsupported/mail2/libmail/zaurusstuff.h
@@ -0,0 +1,23 @@
1#ifndef ZAURUSSTUFF_H
2#define ZAURUSSTUFF_H
3
4#include <qobject.h>
5
6class ZaurusStuff : public QObject
7{
8 Q_OBJECT
9
10public:
11 static void blinkLedOn();
12 static void blinkLedOff();
13 static void buzzerOn();
14 static void buzzerOff();
15
16protected:
17 ZaurusStuff();
18
19
20};
21
22#endif
23
diff --git a/noncore/unsupported/mail2/listviewplus.cpp b/noncore/unsupported/mail2/listviewplus.cpp
new file mode 100644
index 0000000..ce5f35f
--- a/dev/null
+++ b/noncore/unsupported/mail2/listviewplus.cpp
@@ -0,0 +1,54 @@
1#include <qpopupmenu.h>
2#include <qtimer.h>
3
4#include "listviewplus.h"
5
6ListViewPlus::ListViewPlus(QWidget *parent, const char *name, WFlags fl)
7 : QListView(parent, name, fl)
8{
9
10}
11
12void ListViewPlus::keyPressEvent(QKeyEvent *event)
13{
14 switch(event->key()) {
15 case Qt::Key_Space: // FALLTHROUGH
16 case Qt::Key_Enter:
17 if (currentItem() != 0)
18 emit clicked(currentItem());
19 break;
20 default: break;
21 }
22
23 QListView::keyPressEvent(event);
24}
25
26void ListViewPlus::setPopup(QPopupMenu *popup, int delay)
27{
28 _popup = popup;
29 _delay = delay;
30
31 connect(this, SIGNAL(pressed(QListViewItem *, const QPoint &, int)), SLOT(_initPopup(QListViewItem *, const QPoint &, int)));
32 connect(this, SIGNAL(clicked(QListViewItem *, const QPoint &, int)), SLOT(_cancelPopup(QListViewItem *, const QPoint &, int)));
33}
34
35void ListViewPlus::_initPopup(QListViewItem *, const QPoint &point, int)
36{
37 _point = point;
38
39 _timer = new QTimer();
40 _timer->start(_delay, true);
41
42 connect(_timer, SIGNAL(timeout()), this, SLOT(_showPopup()));
43}
44
45void ListViewPlus::_cancelPopup(QListViewItem *, const QPoint &, int)
46{
47 delete _timer;
48}
49
50void ListViewPlus::_showPopup()
51{
52 _popup->popup(_point);
53}
54
diff --git a/noncore/unsupported/mail2/listviewplus.h b/noncore/unsupported/mail2/listviewplus.h
new file mode 100644
index 0000000..519bc39
--- a/dev/null
+++ b/noncore/unsupported/mail2/listviewplus.h
@@ -0,0 +1,37 @@
1#ifndef LISTVIEWPLUS_H
2#define LISTVIEWPLUS_H
3
4#include <qlistview.h>
5
6class QPopupMenu;
7class QPoint;
8class QTimer;
9
10class ListViewPlus : public QListView
11{
12 Q_OBJECT
13
14public:
15 ListViewPlus(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
16
17 void setPopup(QPopupMenu *popup, int delay = 800);
18 QPopupMenu *popup() { return _popup; }
19
20protected:
21 void keyPressEvent(QKeyEvent *event);
22
23private slots:
24 void _initPopup(QListViewItem *, const QPoint &point, int);
25 void _cancelPopup(QListViewItem *, const QPoint &, int);
26 void _showPopup();
27
28private:
29 QPopupMenu *_popup;
30 QPoint _point;
31 QTimer *_timer;
32 int _delay;
33
34};
35
36#endif
37
diff --git a/noncore/unsupported/mail2/mail.pro b/noncore/unsupported/mail2/mail.pro
new file mode 100644
index 0000000..6e498fd
--- a/dev/null
+++ b/noncore/unsupported/mail2/mail.pro
@@ -0,0 +1,48 @@
1 TEMPLATE = app
2 CONFIG = qt warn_on release
3 HEADERS = accounteditor.h \
4 addresspicker.h \
5 attachdiag.h \
6 composer.h \
7 composerbase.h \
8 configdiag.h \
9 folderwidget.h \
10 listviewplus.h \
11 mailtable.h \
12 mainwindow.h \
13 mainwindowbase.h \
14 opendiag.h \
15 passdiag.h \
16 rename.h \
17 searchdiag.h \
18 viewmail.h \
19 viewmailbase.h
20 SOURCES = accounteditor.cpp \
21 addresspicker.cpp \
22 attachdiag.cpp \
23 composer.cpp \
24 composerbase.cpp \
25 configdiag.cpp \
26 folderwidget.cpp \
27 listviewplus.cpp \
28 mailtable.cpp \
29 main.cpp \
30 mainwindow.cpp \
31 mainwindowbase.cpp \
32 opendiag.cpp \
33 passdiag.cpp \
34 rename.cpp \
35 searchdiag.cpp \
36 viewmail.cpp \
37 viewmailbase.cpp
38 INTERFACES = accounteditorbase.ui \
39 addresspickerbase.ui \
40 configdiagbase.ui \
41 opendiagbase.ui \
42 passdiagbase.ui \
43 renamebase.ui \
44 searchdiagbase.ui
45 INCLUDEPATH += $(OPIEDIR)/include libmail
46 LIBS += -lmail -lqpe
47 TARGET = mail
48 DESTDIR = $(OPIEDIR)/bin
diff --git a/noncore/unsupported/mail2/mailtable.cpp b/noncore/unsupported/mail2/mailtable.cpp
new file mode 100644
index 0000000..fd179f0
--- a/dev/null
+++ b/noncore/unsupported/mail2/mailtable.cpp
@@ -0,0 +1,171 @@
1#include <qmessagebox.h>
2#include <qpopupmenu.h>
3#include <qheader.h>
4#include <qtimer.h>
5
6#include "folderwidget.h"
7#include "imaphandler.h"
8#include "mailtable.h"
9
10MailTableItem::MailTableItem(QListView *parent, IMAPResponseFETCH fetch)
11 : QListViewItem(parent), _fetch(fetch)
12{
13 _draft = false;
14 _new = false;
15 _unseen = true;
16
17 QValueList<IMAPResponseEnums::IMAPResponseFlags>::Iterator it;
18 QValueList<IMAPResponseEnums::IMAPResponseFlags> flags = fetch.flags();
19 for (it = flags.begin(); it != flags.end(); it++) {
20 if (*it == IMAPResponseEnums::Draft) _draft = true;
21 else if (*it == IMAPResponseEnums::Recent) _new = true;
22 else if (*it == IMAPResponseEnums::Seen) _unseen = false;
23 }
24
25 setText(0, fetch.envelope().from()[0].name().isEmpty() ? QObject::tr("(no from)") : fetch.envelope().from()[0].name());
26 setText(1, fetch.envelope().subject().isEmpty() ? QObject::tr("(no subject)") : fetch.envelope().subject());
27 setText(2, fetch.envelope().mailDate().isEmpty() ? QObject::tr("(no date)") : fetch.envelope().mailDate());
28}
29
30void MailTableItem::paintCell(QPainter *painter, const QColorGroup &cg, int col, int width, int align)
31{
32 QColor color = cg.color(QColorGroup::Text);
33 QFont font = painter->font();
34 if (_draft) {
35 color = QColor("#707070");
36 } else if (_new) {
37 color = QColor("#ff0000");
38 font.setBold(true);
39 } else if (_unseen) {
40 font.setBold(true);
41 }
42
43 painter->setFont(font);
44 QColorGroup cg_(cg);
45 cg_.setColor(QColorGroup::Text, color);
46
47 QListViewItem::paintCell(painter, cg_, col, width, align);
48}
49
50MailTable::MailTable(QWidget *parent, const char *name, WFlags fl)
51 : ListViewPlus(parent, name, fl), _parent(parent)
52{
53 _stopped = false;
54
55 setSorting(-1);
56
57 setAllColumnsShowFocus(true);
58 addColumn(tr("From"), 100);
59 addColumn(tr("Subject"), 100);
60 addColumn(tr("Date"), 100);
61
62 QPopupMenu *menu = new QPopupMenu(this);
63 menu->insertItem(tr("Copy"), MENU_COPY);
64
65 QPopupMenu *markMenu = new QPopupMenu(this);
66 markMenu->insertItem(tr("Seen"), MENU_MARK_READ);
67 markMenu->insertItem(tr("Unseen"), MENU_MARK_UNREAD);
68 markMenu->insertSeparator();
69 markMenu->insertItem(tr("Marked"), MENU_MARK_MARKED);
70 markMenu->insertItem(tr("Unmarked"), MENU_MARK_UNMARKED);
71
72 menu->insertItem(tr("Mark as..."), markMenu, MENU_MARK);
73 menu->insertSeparator();
74 menu->insertItem(tr("Delete Mail"), MENU_DELETE);
75 setPopup(menu);
76
77 connect(this, SIGNAL(clicked(QListViewItem *)), SLOT(itemClicked(QListViewItem *)));
78}
79
80void MailTable::setFolder(Folder folder)
81{
82 folder.topFolder().handler()->iSelect(folder.fullName());
83 _handler = folder.topFolder().handler();
84 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSelect(IMAPResponse &)));
85}
86
87void MailTable::setHeaders(QValueList<IMAPResponseFETCH> response)
88{
89 clear();
90 QValueList<IMAPResponseFETCH>::Iterator it;
91 for (it = response.begin(); it != response.end(); it++) {
92 (void) new MailTableItem(this, *it);
93 }
94}
95
96void MailTable::slotIMAPSelect(IMAPResponse &response)
97{
98 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSelect(IMAPResponse &)));
99
100 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
101 clear();
102 QString mails = response.EXISTS()[0].mails();
103 if (mails.toInt() == 0) {
104 emit status(tr("Mailbox contained no mails."));
105 return;
106 }
107 int a = mails.toInt() / 5;
108 int b = mails.toInt() % 5;
109
110 _downloadSteps = a;
111 if (b > 0) _downloadSteps++;
112 _lastStep = b;
113 _currentProgress = 0;
114
115 emit totalSteps(_downloadSteps);
116 emit progress(_currentProgress);
117 emit stopEnabled(true);
118
119 response.imapHandler()->iFetch(QString("1:%1").arg((a == 0) ? b : 5), "ENVELOPE FLAGS UID");
120 emit status(tr("Getting mail headers..."));
121 connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPFetch(IMAPResponse &)));
122 } else {
123 QMessageBox::warning(this, tr("Error"), tr("<p>An error occoured during the selection of the mailbox. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok"));
124 }
125}
126
127void MailTable::slotIMAPFetch(IMAPResponse &response)
128{
129 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPFetch(IMAPResponse &)));
130
131 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
132 QValueList<IMAPResponseFETCH>::Iterator it;
133 QValueList<IMAPResponseFETCH> fetch = response.FETCH();
134 for (it = fetch.begin(); it != fetch.end(); it++) {
135 (void) new MailTableItem(this, *it);
136 }
137 emit progress(++_currentProgress);
138
139 if (_currentProgress != _downloadSteps) {
140 if (_stopped) {
141 _currentProgress = 0;
142 _downloadSteps = 0;
143 _lastStep = 0;
144 _stopped = false;
145 emit status(tr("Stopped"));
146 emit resetProgress();
147 emit stopEnabled(false);
148 } else {
149 response.imapHandler()->iFetch(QString("%1:%2").arg(_currentProgress * 5 + 1).arg((_currentProgress + 1 == _downloadSteps) ? _currentProgress * 5 + _lastStep : _currentProgress * 5 + 5), "ENVELOPE FLAGS UID");
150 connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPFetch(IMAPResponse &)));
151 }
152 } else {
153 _currentProgress = 0;
154 _downloadSteps = 0;
155 _lastStep = 0;
156 emit status(tr("Got all mail headers."));
157 emit resetProgress();
158 emit stopEnabled(false);
159 }
160 } else {
161 emit status(tr("<font color=#ff0000>Couldn't fetch mail."));
162 }
163}
164
165void MailTable::itemClicked(QListViewItem *item)
166{
167 if (item == NULL) return;
168 emit mailClicked(((MailTableItem *)item)->fetch(), _handler);
169}
170
171
diff --git a/noncore/unsupported/mail2/mailtable.h b/noncore/unsupported/mail2/mailtable.h
new file mode 100644
index 0000000..6deb70a
--- a/dev/null
+++ b/noncore/unsupported/mail2/mailtable.h
@@ -0,0 +1,121 @@
1#ifndef MAILTABLE_H
2#define MAILTABLE_H
3
4#include <qdatetime.h>
5
6#include "listviewplus.h"
7#include "imapresponse.h"
8#include "folderwidget.h"
9#include "imaphandler.h"
10
11class MailPart
12{
13public:
14 void setMimeType(QString mimeType) { _mimeType = mimeType; }
15 void setFileName(QString fileName) { _fileName = fileName; }
16 void setDescription(QString description) { _description = description; }
17 void setData(QString data) { _data = data; }
18
19 QString mimeType() { return _mimeType; }
20 QString fileName() { return _fileName; }
21 QString description() { return _description; }
22 QString data() { return _data; }
23
24private:
25 QString _mimeType, _fileName, _description, _data;
26
27};
28
29class Mail
30{
31public:
32 enum ReadState { New, Unread, Old };
33
34 void setFrom(QString from) { _from = from; }
35 void setTo(QString to) { _to = to; }
36 void setSubject(QString subject) { _subject = subject; }
37 void setDate(QDate date) { _date = date; }
38 void setBody(QString body) { _body = body; }
39 void setReadState(ReadState readState) { _readState = readState; }
40 void setMailParts(QValueList<MailPart> parts) { _parts = parts; }
41 void addMailParts(MailPart part) { _parts.append(part); }
42
43 QString from() { return _from; }
44 QString to() { return _to; }
45 QString subject() { return _subject; }
46 QDate date() { return _date; }
47 QString body() { return _body; }
48 ReadState readState() { return _readState; }
49 QValueList<MailPart> mailParts() { return _parts; }
50
51private:
52 QString _from, _to, _subject, _body;
53 QDate _date;
54 QValueList<MailPart> _parts;
55 ReadState _readState;
56
57};
58
59class MailTableItem : public QListViewItem
60{
61public:
62 MailTableItem(QListView *parent, IMAPResponseFETCH fetch);
63
64 IMAPResponseFETCH fetch() { return _fetch; }
65
66protected:
67 void paintCell(QPainter *painter, const QColorGroup &cg, int col, int width, int align);
68
69private:
70 IMAPResponseFETCH _fetch;
71 bool _draft, _new, _unseen;
72
73};
74
75class MailTable : public ListViewPlus
76{
77 Q_OBJECT
78
79public:
80 MailTable(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
81
82 void addMail(Mail &mail);
83 void setHeaders(QValueList<IMAPResponseFETCH> response);
84
85public slots:
86 void stop() { _stopped = true; }
87 void setFolder(Folder folder);
88
89signals:
90 void totalSteps(int steps);
91 void progress(int progress);
92 void resetProgress();
93 void mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler);
94 void status(const QString &text);
95 void stopEnabled(bool stop);
96
97protected:
98 static const int MENU_COPY = 0;
99 static const int MENU_MARK_READ = 0;
100 static const int MENU_MARK_UNREAD = 1;
101 static const int MENU_MARK_MARKED = 2;
102 static const int MENU_MARK_UNMARKED = 3;
103 static const int MENU_MARK = 1;
104 static const int MENU_DELETE = 2;
105
106protected slots:
107 void itemClicked(QListViewItem *);
108
109 void slotIMAPSelect(IMAPResponse &response);
110 void slotIMAPFetch(IMAPResponse &response);
111
112private:
113 QWidget *_parent;
114 IMAPHandler *_handler;
115 int _downloadSteps, _lastStep, _currentProgress;
116 bool _stopped;
117
118};
119
120#endif
121
diff --git a/noncore/unsupported/mail2/main.cpp b/noncore/unsupported/mail2/main.cpp
new file mode 100644
index 0000000..ddacf3d
--- a/dev/null
+++ b/noncore/unsupported/mail2/main.cpp
@@ -0,0 +1,14 @@
1#include <qpe/qpeapplication.h>
2
3#include "mainwindow.h"
4
5int main(int argc, char *argv[])
6{
7 QPEApplication app(argc, argv);
8
9 MainWindow mw;
10 app.showMainWidget(&mw);
11
12 return app.exec();
13}
14
diff --git a/noncore/unsupported/mail2/mainwindow.cpp b/noncore/unsupported/mail2/mainwindow.cpp
new file mode 100644
index 0000000..4d15e23
--- a/dev/null
+++ b/noncore/unsupported/mail2/mainwindow.cpp
@@ -0,0 +1,65 @@
1#include <qprogressbar.h>
2#include <qmessagebox.h>
3#include <qaction.h>
4#include <qlabel.h>
5
6#include "folderwidget.h"
7#include "mainwindow.h"
8#include "configdiag.h"
9#include "configfile.h"
10#include "searchdiag.h"
11#include "mailtable.h"
12#include "composer.h"
13#include "viewmail.h"
14
15MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl)
16 : MainWindowBase(parent, name, fl)
17{
18 stop->setEnabled(false);
19
20 connect(folderView, SIGNAL(status(const QString &)), statusLabel, SLOT(setText(const QString &)));
21 connect(folderView, SIGNAL(folderSelected(Folder)), mailView, SLOT(setFolder(Folder)));
22
23 connect(mailView, SIGNAL(mailClicked(IMAPResponseFETCH, IMAPHandler *)), SLOT(mailClicked(IMAPResponseFETCH, IMAPHandler *)));
24 connect(mailView, SIGNAL(status(const QString &)), statusLabel, SLOT(setText(const QString &)));
25 connect(mailView, SIGNAL(totalSteps(int)), statusProgress, SLOT(setTotalSteps(int)));
26 connect(mailView, SIGNAL(progress(int)), statusProgress, SLOT(setProgress(int)));
27 connect(mailView, SIGNAL(resetProgress()), statusProgress, SLOT(reset()));
28 connect(mailView, SIGNAL(stopEnabled(bool)), stop, SLOT(setEnabled(bool)));
29
30 connect(stop, SIGNAL(activated()), mailView, SLOT(stop()));
31
32 connect(compose, SIGNAL(activated()), SLOT(slotCompose()));
33 connect(findmails, SIGNAL(activated()), SLOT(slotSearch()));
34 connect(configure, SIGNAL(activated()), SLOT(slotConfigure()));
35}
36
37void MainWindow::slotCompose()
38{
39 Composer *composer = new Composer();
40 composer->showMaximized();
41 composer->show();
42}
43
44void MainWindow::slotSearch()
45{
46 SearchDiag *searchDiag = new SearchDiag(this, 0, true);
47 searchDiag->showMaximized();
48 searchDiag->show();
49}
50
51void MainWindow::slotConfigure()
52{
53 ConfigDiag *configDiag = new ConfigDiag(this, 0, true);
54 configDiag->showMaximized();
55 configDiag->show();
56
57 connect(configDiag, SIGNAL(changed()), folderView, SLOT(update()));
58}
59
60void MainWindow::mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler)
61{
62 ViewMail *viewMail = new ViewMail(mail, handler);
63 viewMail->showMaximized();
64 viewMail->show();
65}
diff --git a/noncore/unsupported/mail2/mainwindow.h b/noncore/unsupported/mail2/mainwindow.h
new file mode 100644
index 0000000..1edf10b
--- a/dev/null
+++ b/noncore/unsupported/mail2/mainwindow.h
@@ -0,0 +1,24 @@
1#ifndef MAINWINDOW_H
2#define MAINWINDOW_H
3
4#include "mainwindowbase.h"
5
6class IMAPHandler;
7class IMAPResponseFETCH;
8
9class MainWindow : public MainWindowBase
10{
11 Q_OBJECT
12
13public:
14 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
15
16protected slots:
17 void slotCompose();
18 void slotSearch();
19 void slotConfigure();
20 void mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler);
21
22};
23
24#endif
diff --git a/noncore/unsupported/mail2/mainwindowbase.cpp b/noncore/unsupported/mail2/mainwindowbase.cpp
new file mode 100644
index 0000000..4054af6
--- a/dev/null
+++ b/noncore/unsupported/mail2/mainwindowbase.cpp
@@ -0,0 +1,75 @@
1#include <qprogressbar.h>
2#include <qtoolbutton.h>
3#include <qpopupmenu.h>
4#include <qtoolbar.h>
5#include <qaction.h>
6#include <qheader.h>
7#include <qlabel.h>
8#include <qvbox.h>
9
10#include <qpe/resource.h>
11
12#include "mainwindowbase.h"
13#include "folderwidget.h"
14#include "mailtable.h"
15
16MainWindowBase::MainWindowBase(QWidget *parent, const char *name, WFlags fl)
17 : QMainWindow(parent, name, fl)
18{
19 setCaption(tr("E-Mail"));
20 setToolBarsMovable(false);
21
22 toolbar = new QToolBar(this);
23 addToolBar(toolbar);
24 toolbar->setHorizontalStretchable(true);
25
26 compose = new QAction(tr("Compose new mail"), QIconSet(Resource::loadPixmap("mail/newmail")), 0, 0, this);
27 compose->addTo(toolbar);
28
29 folders = new QAction(tr("Show/hide folders"), QIconSet(Resource::loadPixmap("mail/folder")), 0, 0, this, 0, true);
30 folders->addTo(toolbar);
31 connect(folders, SIGNAL(toggled(bool)), SLOT(slotFoldersToggled(bool)));
32
33 findmails = new QAction(tr("Search mails"), QIconSet(Resource::loadPixmap("mail/find")), 0, 0, this);
34 findmails->addTo(toolbar);
35
36 configure = new QAction(tr("Configuration"), QIconSet(Resource::loadPixmap("mail/configure")), 0, 0, this);
37 configure->addTo(toolbar);
38
39 QLabel *spacer = new QLabel(toolbar);
40 spacer->setBackgroundMode(QWidget::PaletteButton);
41 toolbar->setStretchableWidget(spacer);
42
43 stop = new QAction(tr("Abort"), QIconSet(Resource::loadPixmap("mail/abort")), 0, 0, this);
44 stop->addTo(toolbar);
45
46 QVBox *view = new QVBox(this);
47 setCentralWidget(view);
48
49 folderView = new FolderWidget(view);
50 folderView->setMinimumHeight(90);
51 folderView->setMaximumHeight(90);
52 folderView->hide();
53
54 mailView = new MailTable(view);
55 mailView->setMinimumHeight(50);
56
57 QHBox *status = new QHBox(view);
58
59 statusLabel = new QLabel(status);
60 QFont tmpFont = statusLabel->font();
61 tmpFont.setPixelSize(8);
62 statusLabel->setFont(tmpFont);
63
64 statusProgress = new QProgressBar(status);
65 statusProgress->setCenterIndicator(true);
66 statusProgress->setMaximumHeight(15);
67 statusProgress->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
68}
69
70void MainWindowBase::slotFoldersToggled(bool toggled)
71{
72 if (folderView->isHidden() && toggled) folderView->show();
73 if (!folderView->isHidden() && !toggled) folderView->hide();
74}
75
diff --git a/noncore/unsupported/mail2/mainwindowbase.h b/noncore/unsupported/mail2/mainwindowbase.h
new file mode 100644
index 0000000..cf23f4f
--- a/dev/null
+++ b/noncore/unsupported/mail2/mainwindowbase.h
@@ -0,0 +1,35 @@
1#ifndef MAINWINDOWBASE_H
2#define MAINWINDOWBASE_H
3
4#include <qmainwindow.h>
5
6class ServerConnection;
7class QProgressBar;
8class FolderWidget;
9class MailTable;
10class QToolBar;
11class QAction;
12class QLabel;
13
14class MainWindowBase : public QMainWindow
15{
16 Q_OBJECT
17
18public:
19 MainWindowBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
20
21protected slots:
22 void slotFoldersToggled(bool toggled);
23
24protected:
25 ServerConnection *serverConnection;
26 QProgressBar *statusProgress;
27 FolderWidget *folderView;
28 MailTable *mailView;
29 QToolBar *toolbar;
30 QAction *compose, *folders, *findmails, *configure, *stop;
31 QLabel *statusLabel;
32
33};
34
35#endif
diff --git a/noncore/unsupported/mail2/opendiag.cpp b/noncore/unsupported/mail2/opendiag.cpp
new file mode 100644
index 0000000..3dc3fd5
--- a/dev/null
+++ b/noncore/unsupported/mail2/opendiag.cpp
@@ -0,0 +1,8 @@
1#include "opendiag.h"
2
3OpenDiag::OpenDiag(QWidget *parent, const char *name, WFlags fl)
4 : OpenDiagBase(parent, name, fl)
5{
6
7}
8
diff --git a/noncore/unsupported/mail2/opendiag.h b/noncore/unsupported/mail2/opendiag.h
new file mode 100644
index 0000000..b74490b
--- a/dev/null
+++ b/noncore/unsupported/mail2/opendiag.h
@@ -0,0 +1,16 @@
1#ifndef OPENDIAG_H
2#define OPENDIAG_H
3
4#include "opendiagbase.h"
5
6class OpenDiag : public OpenDiagBase
7{
8 Q_OBJECT
9
10public:
11 OpenDiag(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
12
13};
14
15#endif
16
diff --git a/noncore/unsupported/mail2/opendiagbase.ui b/noncore/unsupported/mail2/opendiagbase.ui
new file mode 100644
index 0000000..8360864
--- a/dev/null
+++ b/noncore/unsupported/mail2/opendiagbase.ui
@@ -0,0 +1,254 @@
1<!DOCTYPE UI><UI>
2<class>OpenDiagBase</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>OpenDiagBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>244</width>
15 <height>269</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Open file...</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <grid>
29 <property stdset="1">
30 <name>margin</name>
31 <number>4</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>3</number>
36 </property>
37 <widget row="8" column="0" >
38 <class>QLayoutWidget</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>Layout3</cstring>
42 </property>
43 <hbox>
44 <property stdset="1">
45 <name>margin</name>
46 <number>0</number>
47 </property>
48 <property stdset="1">
49 <name>spacing</name>
50 <number>6</number>
51 </property>
52 <widget>
53 <class>QProgressBar</class>
54 <property stdset="1">
55 <name>name</name>
56 <cstring>progress</cstring>
57 </property>
58 <property stdset="1">
59 <name>centerIndicator</name>
60 <bool>true</bool>
61 </property>
62 </widget>
63 <widget>
64 <class>QToolButton</class>
65 <property stdset="1">
66 <name>name</name>
67 <cstring>stop</cstring>
68 </property>
69 <property stdset="1">
70 <name>text</name>
71 <string> Stop </string>
72 </property>
73 </widget>
74 </hbox>
75 </widget>
76 <widget row="7" column="0" >
77 <class>QLabel</class>
78 <property stdset="1">
79 <name>name</name>
80 <cstring>statusLabel</cstring>
81 </property>
82 <property stdset="1">
83 <name>text</name>
84 <string>&lt;b&gt;%1&lt;/b&gt; kB of &lt;b&gt;%2&lt;/b&gt; kB at &lt;b&gt;%3&lt;/b&gt; kB/s</string>
85 </property>
86 </widget>
87 <spacer row="6" column="0" >
88 <property>
89 <name>name</name>
90 <cstring>Spacer2</cstring>
91 </property>
92 <property stdset="1">
93 <name>orientation</name>
94 <enum>Vertical</enum>
95 </property>
96 <property stdset="1">
97 <name>sizeType</name>
98 <enum>Expanding</enum>
99 </property>
100 <property>
101 <name>sizeHint</name>
102 <size>
103 <width>20</width>
104 <height>20</height>
105 </size>
106 </property>
107 </spacer>
108 <widget row="0" column="0" >
109 <class>QLabel</class>
110 <property stdset="1">
111 <name>name</name>
112 <cstring>icon</cstring>
113 </property>
114 <property stdset="1">
115 <name>text</name>
116 <string>[Icon]</string>
117 </property>
118 <property stdset="1">
119 <name>alignment</name>
120 <set>AlignCenter</set>
121 </property>
122 <property>
123 <name>hAlign</name>
124 </property>
125 </widget>
126 <widget row="1" column="0" >
127 <class>QLabel</class>
128 <property stdset="1">
129 <name>name</name>
130 <cstring>mimeType</cstring>
131 </property>
132 <property stdset="1">
133 <name>text</name>
134 <string>&lt;i&gt;application/v-card</string>
135 </property>
136 <property stdset="1">
137 <name>alignment</name>
138 <set>AlignCenter</set>
139 </property>
140 <property>
141 <name>hAlign</name>
142 </property>
143 </widget>
144 <widget row="2" column="0" >
145 <class>QPushButton</class>
146 <property stdset="1">
147 <name>name</name>
148 <cstring>open</cstring>
149 </property>
150 <property stdset="1">
151 <name>font</name>
152 <font>
153 <bold>1</bold>
154 </font>
155 </property>
156 <property stdset="1">
157 <name>text</name>
158 <string>Open using an application</string>
159 </property>
160 </widget>
161 <widget row="3" column="0" >
162 <class>QPushButton</class>
163 <property stdset="1">
164 <name>name</name>
165 <cstring>save</cstring>
166 </property>
167 <property stdset="1">
168 <name>text</name>
169 <string>Save to disk</string>
170 </property>
171 </widget>
172 <widget row="4" column="0" >
173 <class>QPushButton</class>
174 <property stdset="1">
175 <name>name</name>
176 <cstring>show</cstring>
177 </property>
178 <property stdset="1">
179 <name>text</name>
180 <string>Display</string>
181 </property>
182 </widget>
183 <widget row="5" column="0" >
184 <class>QButtonGroup</class>
185 <property stdset="1">
186 <name>name</name>
187 <cstring>ButtonGroup1</cstring>
188 </property>
189 <property stdset="1">
190 <name>title</name>
191 <string>Save to</string>
192 </property>
193 <property>
194 <name>layoutMargin</name>
195 </property>
196 <property>
197 <name>layoutSpacing</name>
198 </property>
199 <hbox>
200 <property stdset="1">
201 <name>margin</name>
202 <number>4</number>
203 </property>
204 <property stdset="1">
205 <name>spacing</name>
206 <number>3</number>
207 </property>
208 <widget>
209 <class>QRadioButton</class>
210 <property stdset="1">
211 <name>name</name>
212 <cstring>saveToRam</cstring>
213 </property>
214 <property stdset="1">
215 <name>text</name>
216 <string>RAM</string>
217 </property>
218 <property stdset="1">
219 <name>checked</name>
220 <bool>true</bool>
221 </property>
222 </widget>
223 <widget>
224 <class>QRadioButton</class>
225 <property stdset="1">
226 <name>name</name>
227 <cstring>saveToCf</cstring>
228 </property>
229 <property stdset="1">
230 <name>text</name>
231 <string>CF</string>
232 </property>
233 </widget>
234 <widget>
235 <class>QRadioButton</class>
236 <property stdset="1">
237 <name>name</name>
238 <cstring>saveToSd</cstring>
239 </property>
240 <property stdset="1">
241 <name>text</name>
242 <string>SD</string>
243 </property>
244 </widget>
245 </hbox>
246 </widget>
247 </grid>
248</widget>
249<tabstops>
250 <tabstop>open</tabstop>
251 <tabstop>save</tabstop>
252 <tabstop>show</tabstop>
253</tabstops>
254</UI>
diff --git a/noncore/unsupported/mail2/opie-mail2.control b/noncore/unsupported/mail2/opie-mail2.control
new file mode 100644
index 0000000..5195789
--- a/dev/null
+++ b/noncore/unsupported/mail2/opie-mail2.control
@@ -0,0 +1,9 @@
1Files: bin/mail $QTDIR/lib/libmail.so* plugins/applets/libbend.so* apps/Applications/mail.desktop pics/mail/*.png
2Priority: optional
3Section: qpe/applications
4Maintainer: Constantin Bergemann <cbergemann@lisa.de>
5Architecture: arm
6Version: 0.0.9-$SUB_VERSION
7Depends: opie-base
8Description: An IMAP mail client
9License: LGPL
diff --git a/noncore/unsupported/mail2/passdiag.cpp b/noncore/unsupported/mail2/passdiag.cpp
new file mode 100644
index 0000000..d3daa2c
--- a/dev/null
+++ b/noncore/unsupported/mail2/passdiag.cpp
@@ -0,0 +1,38 @@
1#include <qmessagebox.h>
2#include <qpushbutton.h>
3#include <qlineedit.h>
4#include <qlabel.h>
5
6#include "passdiag.h"
7
8PassDiag::PassDiag(QString text, QWidget *parent, const char *name, bool modal, WFlags fl)
9 : PassDiagBase(parent, name, modal, fl)
10{
11 infoLabel->setText(text);
12
13 connect(ok, SIGNAL(clicked()), SLOT(accept()));
14 connect(cancel, SIGNAL(clicked()), SLOT(close()));
15}
16
17void PassDiag::accept()
18{
19 if (password->text().isEmpty()) {
20 QMessageBox::information(this, tr("Error"), tr("<p>You have to enter a password or click on cancel.</p>"), tr("Ok"));
21 return;
22 }
23
24 QDialog::accept();
25}
26
27QString PassDiag::getPassword(QWidget *parent, QString text)
28{
29 PassDiag *diag = new PassDiag(text, parent, 0, true);
30 diag->show();
31
32 if (QDialog::Accepted == diag->exec()) {
33 return diag->password->text();
34 }
35
36 return 0;
37}
38
diff --git a/noncore/unsupported/mail2/passdiag.h b/noncore/unsupported/mail2/passdiag.h
new file mode 100644
index 0000000..b611dd5
--- a/dev/null
+++ b/noncore/unsupported/mail2/passdiag.h
@@ -0,0 +1,21 @@
1#ifndef PASSDIAG_H
2#define PASSDIAG_H
3
4#include "passdiagbase.h"
5
6class PassDiag : public PassDiagBase
7{
8 Q_OBJECT
9
10public:
11 static QString getPassword(QWidget *parent, QString text);
12
13protected:
14 PassDiag(QString text, QWidget *parent, const char *name = 0, bool modal = false, WFlags fl = 0);
15
16protected slots:
17 void accept();
18
19};
20
21#endif
diff --git a/noncore/unsupported/mail2/passdiagbase.ui b/noncore/unsupported/mail2/passdiagbase.ui
new file mode 100644
index 0000000..daf8bad
--- a/dev/null
+++ b/noncore/unsupported/mail2/passdiagbase.ui
@@ -0,0 +1,115 @@
1<!DOCTYPE UI><UI>
2<class>PassDiagBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>PassDiagBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>216</width>
15 <height>120</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Enter your Password</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <grid>
29 <property stdset="1">
30 <name>margin</name>
31 <number>4</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>3</number>
36 </property>
37 <widget row="0" column="0" rowspan="1" colspan="4" >
38 <class>QLabel</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>infoLabel</cstring>
42 </property>
43 <property stdset="1">
44 <name>text</name>
45 <string>Please enter your GPG passphrase:</string>
46 </property>
47 </widget>
48 <widget row="1" column="0" rowspan="1" colspan="4" >
49 <class>QLineEdit</class>
50 <property stdset="1">
51 <name>name</name>
52 <cstring>password</cstring>
53 </property>
54 <property stdset="1">
55 <name>echoMode</name>
56 <enum>Password</enum>
57 </property>
58 </widget>
59 <widget row="2" column="0" rowspan="1" colspan="4" >
60 <class>QCheckBox</class>
61 <property stdset="1">
62 <name>name</name>
63 <cstring>showPasswd</cstring>
64 </property>
65 <property stdset="1">
66 <name>text</name>
67 <string>Show Password</string>
68 </property>
69 </widget>
70 <widget row="4" column="1" >
71 <class>QPushButton</class>
72 <property stdset="1">
73 <name>name</name>
74 <cstring>ok</cstring>
75 </property>
76 <property stdset="1">
77 <name>text</name>
78 <string>Ok</string>
79 </property>
80 </widget>
81 <widget row="4" column="2" >
82 <class>QPushButton</class>
83 <property stdset="1">
84 <name>name</name>
85 <cstring>cancel</cstring>
86 </property>
87 <property stdset="1">
88 <name>text</name>
89 <string>Cancel</string>
90 </property>
91 </widget>
92 <spacer row="3" column="2" >
93 <property>
94 <name>name</name>
95 <cstring>Spacer3</cstring>
96 </property>
97 <property stdset="1">
98 <name>orientation</name>
99 <enum>Vertical</enum>
100 </property>
101 <property stdset="1">
102 <name>sizeType</name>
103 <enum>Expanding</enum>
104 </property>
105 <property>
106 <name>sizeHint</name>
107 <size>
108 <width>20</width>
109 <height>20</height>
110 </size>
111 </property>
112 </spacer>
113 </grid>
114</widget>
115</UI>
diff --git a/noncore/unsupported/mail2/rename.cpp b/noncore/unsupported/mail2/rename.cpp
new file mode 100644
index 0000000..8c2fde1
--- a/dev/null
+++ b/noncore/unsupported/mail2/rename.cpp
@@ -0,0 +1,39 @@
1#include <qlineedit.h>
2#include <qlabel.h>
3
4#include "rename.h"
5
6Rename::Rename(QWidget *parent, const char *name, bool modal, WFlags fl)
7 : RenameBase(parent, name, modal, fl)
8{
9}
10
11QString Rename::rename(const QString &on, QWidget *parent)
12{
13 Rename *rename = new Rename(parent, 0, true);
14 rename->oldName->setText(on);
15 rename->newName->setText(on);
16 rename->newName->setFocus();
17
18 if (rename->exec() == QDialog::Accepted) {
19 return rename->newName->text();
20 }
21
22 return QString(0);
23}
24
25QString Rename::getText(const QString &caption, const QString &secondLabel, QWidget *parent)
26{
27 Rename *rename = new Rename(parent, 0, true);
28 rename->firstLabel->hide();
29 rename->oldName->hide();
30 rename->setCaption(caption);
31 rename->secondLabel->setText(secondLabel);
32
33 if (rename->exec() == QDialog::Accepted) {
34 return rename->newName->text();
35 }
36
37 return QString(0);
38}
39
diff --git a/noncore/unsupported/mail2/rename.h b/noncore/unsupported/mail2/rename.h
new file mode 100644
index 0000000..757623e
--- a/dev/null
+++ b/noncore/unsupported/mail2/rename.h
@@ -0,0 +1,20 @@
1#ifndef RENAME_H
2#define RENAME_H
3
4#include "renamebase.h"
5
6class Rename : public RenameBase
7{
8 Q_OBJECT
9
10public:
11 static QString rename(const QString &on, QWidget *parent);
12 static QString getText(const QString &caption, const QString &secondLabel, QWidget *parent);
13
14protected:
15 Rename(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags fl = 0);
16
17};
18
19#endif
20
diff --git a/noncore/unsupported/mail2/renamebase.ui b/noncore/unsupported/mail2/renamebase.ui
new file mode 100644
index 0000000..20b7ffb
--- a/dev/null
+++ b/noncore/unsupported/mail2/renamebase.ui
@@ -0,0 +1,79 @@
1<!DOCTYPE UI><UI>
2<class>RenameBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>RenameBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>179</width>
15 <height>91</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Renaming</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <grid>
29 <property stdset="1">
30 <name>margin</name>
31 <number>4</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>3</number>
36 </property>
37 <widget row="1" column="0" >
38 <class>QLineEdit</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>oldName</cstring>
42 </property>
43 <property stdset="1">
44 <name>enabled</name>
45 <bool>false</bool>
46 </property>
47 </widget>
48 <widget row="0" column="0" >
49 <class>QLabel</class>
50 <property stdset="1">
51 <name>name</name>
52 <cstring>firstLabel</cstring>
53 </property>
54 <property stdset="1">
55 <name>text</name>
56 <string>&lt;div align=center&gt;Renaming</string>
57 </property>
58 </widget>
59 <widget row="2" column="0" >
60 <class>QLabel</class>
61 <property stdset="1">
62 <name>name</name>
63 <cstring>secondLabel</cstring>
64 </property>
65 <property stdset="1">
66 <name>text</name>
67 <string>&lt;div align=center&gt;to</string>
68 </property>
69 </widget>
70 <widget row="3" column="0" >
71 <class>QLineEdit</class>
72 <property stdset="1">
73 <name>name</name>
74 <cstring>newName</cstring>
75 </property>
76 </widget>
77 </grid>
78</widget>
79</UI>
diff --git a/noncore/unsupported/mail2/searchdiag.cpp b/noncore/unsupported/mail2/searchdiag.cpp
new file mode 100644
index 0000000..33b8afb
--- a/dev/null
+++ b/noncore/unsupported/mail2/searchdiag.cpp
@@ -0,0 +1,128 @@
1#include <qmessagebox.h>
2#include <qpushbutton.h>
3#include <qcombobox.h>
4#include <qlineedit.h>
5
6#include <qpe/qpeapplication.h>
7
8#include "imaphandler.h"
9#include "searchdiag.h"
10#include "viewmail.h"
11
12 #define INMENU_BODY0
13 #define INMENU_HEADERF1
14 #define INMENU_SUBJECT2
15 #define INMENU_FROM3
16 #define INMENU_TO4
17
18SearchDiag::SearchDiag(QWidget *parent, const char *name, WFlags fl)
19 : SearchDiagBase(parent, name, fl)
20 {
21 _selected = false;
22
23 in->insertItem(tr("Body"), INMENU_BODY);
24 in->insertItem(tr("Header Field"), INMENU_HEADERF);
25 in->insertItem(tr("Subject"), INMENU_SUBJECT);
26 in->insertItem(tr("From"), INMENU_FROM);
27 in->insertItem(tr("To"), INMENU_TO);
28
29 connect(folderView, SIGNAL(folderSelected(Folder)), SLOT(folderSelected(Folder)));
30 connect(in, SIGNAL(activated(int)), SLOT(slotInItemActivated(int)));
31 connect(mailTable, SIGNAL(mailClicked(IMAPResponseFETCH, IMAPHandler *)), SLOT(slotMailClicked(IMAPResponseFETCH, IMAPHandler *)));
32}
33
34void SearchDiag::accept()
35{
36 if (searchFor->text().isEmpty()) {
37 QMessageBox::information(this, tr("Error"), tr("<p>Please enter what to search for.</p>"), tr("Ok"));
38 return;
39 }
40
41 if (!_selected) {
42 QMessageBox::information(this, tr("Error"), tr("<p>Please select a folder.</p>"), tr("Ok"));
43 return;
44 }
45
46 if (in->currentItem() == INMENU_HEADERF && other->currentText().isEmpty()) {
47 QMessageBox::information(this, tr("Error"), tr("<p>Please enter a header field to search in.</p>"), tr("Ok"));
48 return;
49 }
50
51 _folder.topFolder().handler()->iSelect(_folder.fullName());
52 connect(_folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSelect(IMAPResponse &)));
53}
54
55void SearchDiag::folderSelected(Folder folder)
56{
57 _selected = true;
58 _folder = folder;
59}
60
61void SearchDiag::slotIMAPSelect(IMAPResponse &response)
62{
63 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSelect(IMAPResponse &)));
64
65 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
66 if (in->currentItem() == INMENU_BODY) {
67 response.imapHandler()->iSearch("BODY \"" + searchFor->text() + "\"");
68 } else if (in->currentItem() == INMENU_HEADERF) {
69 response.imapHandler()->iSearch("HEADER \""+ other->currentText() + "\" \"" + searchFor->text() + "\"");
70 } else if (in->currentItem() == INMENU_SUBJECT) {
71 response.imapHandler()->iSearch("SUBJECT \"" + searchFor->text() + "\"");
72 } else if (in->currentItem() == INMENU_FROM) {
73 response.imapHandler()->iSearch("FROM \"" + searchFor->text() + "\"");
74 } else if (in->currentItem() == INMENU_TO) {
75 response.imapHandler()->iSearch("TO \"" + searchFor->text() + "\"");
76 } else return;
77
78 connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSearch(IMAPResponse &)));
79 } else {
80 QMessageBox::warning(this, tr("Error"), tr("<p>Could not select the folder. Aborting. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok"));
81 }
82}
83
84void SearchDiag::slotIMAPSearch(IMAPResponse &response)
85{
86 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSearch(IMAPResponse &)));
87
88 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
89 IMAPResponseSEARCH results = response.SEARCH()[0];
90 if (results.mails().count() == 0) {
91 QMessageBox::information(this, tr("Results"), tr("<p>No mails match your criteria.</p>"), tr("Ok"));
92 return;
93 }
94
95 response.imapHandler()->iFetch(results.mails().join(","), "ENVELOPE FLAGS UID");
96 connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPFetch(IMAPResponse &)));
97 } else {
98 QMessageBox::warning(this, tr("Error"), tr("<p>Search failed. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok"));
99 }
100}
101
102void SearchDiag::slotIMAPFetch(IMAPResponse &response)
103{
104 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSearch(IMAPResponse &)));
105
106 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
107 mailTable->setHeaders(response.FETCH());
108 } else {
109 QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't fetch the mail headers. (Server said: %1)").arg(response.statusResponse().comment()));
110 }
111}
112
113void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *)
114{
115 ViewMail *viewMail = new ViewMail(fetch, _folder.topFolder().handler());
116 viewMail->showMaximized();
117 viewMail->show();
118}
119
120void SearchDiag::slotInItemActivated(int index)
121{
122 if (index == INMENU_HEADERF) {
123 other->setEnabled(true);
124 } else {
125 other->setEnabled(false);
126 }
127}
128
diff --git a/noncore/unsupported/mail2/searchdiag.h b/noncore/unsupported/mail2/searchdiag.h
new file mode 100644
index 0000000..5db57e3
--- a/dev/null
+++ b/noncore/unsupported/mail2/searchdiag.h
@@ -0,0 +1,32 @@
1#ifndef SEARCHDIAG_H
2#define SEARCHDIAG_H
3
4#include "searchdiagbase.h"
5#include "mailtable.h"
6
7class IMAPResponse;
8
9class SearchDiag : public SearchDiagBase
10{
11 Q_OBJECT
12
13public:
14 SearchDiag(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
15
16protected slots:
17 void accept();
18 void slotInItemActivated(int index);
19 void folderSelected(Folder folder);
20 void slotMailClicked(IMAPResponseFETCH response, IMAPHandler *);
21
22 void slotIMAPSelect(IMAPResponse &);
23 void slotIMAPSearch(IMAPResponse &);
24 void slotIMAPFetch(IMAPResponse &);
25
26private:
27 bool _selected;
28 Folder _folder;
29
30};
31
32#endif
diff --git a/noncore/unsupported/mail2/searchdiagbase.ui b/noncore/unsupported/mail2/searchdiagbase.ui
new file mode 100644
index 0000000..644180b
--- a/dev/null
+++ b/noncore/unsupported/mail2/searchdiagbase.ui
@@ -0,0 +1,179 @@
1<!DOCTYPE UI><UI>
2<class>SearchDiagBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>SearchDiagBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>260</width>
15 <height>336</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Mail Search</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <grid>
29 <property stdset="1">
30 <name>margin</name>
31 <number>4</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>3</number>
36 </property>
37 <widget row="0" column="0" >
38 <class>QLabel</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>TextLabel10</cstring>
42 </property>
43 <property stdset="1">
44 <name>text</name>
45 <string>&lt;b&gt;Search&amp;nbsp;in:</string>
46 </property>
47 </widget>
48 <widget row="1" column="1" >
49 <class>QLineEdit</class>
50 <property stdset="1">
51 <name>name</name>
52 <cstring>searchFor</cstring>
53 </property>
54 </widget>
55 <widget row="1" column="0" >
56 <class>QLabel</class>
57 <property stdset="1">
58 <name>name</name>
59 <cstring>TextLabel11</cstring>
60 </property>
61 <property stdset="1">
62 <name>text</name>
63 <string>&lt;b&gt;For:</string>
64 </property>
65 </widget>
66 <widget row="0" column="1" >
67 <class>QLayoutWidget</class>
68 <property stdset="1">
69 <name>name</name>
70 <cstring>Layout1</cstring>
71 </property>
72 <property>
73 <name>layoutSpacing</name>
74 </property>
75 <hbox>
76 <property stdset="1">
77 <name>margin</name>
78 <number>0</number>
79 </property>
80 <property stdset="1">
81 <name>spacing</name>
82 <number>3</number>
83 </property>
84 <widget>
85 <class>QComboBox</class>
86 <property stdset="1">
87 <name>name</name>
88 <cstring>in</cstring>
89 </property>
90 </widget>
91 <widget>
92 <class>QComboBox</class>
93 <property stdset="1">
94 <name>name</name>
95 <cstring>other</cstring>
96 </property>
97 <property stdset="1">
98 <name>enabled</name>
99 <bool>false</bool>
100 </property>
101 <property stdset="1">
102 <name>editable</name>
103 <bool>true</bool>
104 </property>
105 </widget>
106 </hbox>
107 </widget>
108 <widget row="3" column="0" rowspan="1" colspan="2" >
109 <class>MailTable</class>
110 <property stdset="1">
111 <name>name</name>
112 <cstring>mailTable</cstring>
113 </property>
114 </widget>
115 <widget row="2" column="0" rowspan="1" colspan="2" >
116 <class>FolderWidget</class>
117 <property stdset="1">
118 <name>name</name>
119 <cstring>folderView</cstring>
120 </property>
121 <property stdset="1">
122 <name>minimumSize</name>
123 <size>
124 <width>0</width>
125 <height>100</height>
126 </size>
127 </property>
128 <property stdset="1">
129 <name>maximumSize</name>
130 <size>
131 <width>32767</width>
132 <height>100</height>
133 </size>
134 </property>
135 </widget>
136 </grid>
137</widget>
138<customwidgets>
139 <customwidget>
140 <class>MailTable</class>
141 <header location="local">mailtable.h</header>
142 <sizehint>
143 <width>-1</width>
144 <height>-1</height>
145 </sizehint>
146 <container>0</container>
147 <sizepolicy>
148 <hordata>5</hordata>
149 <verdata>5</verdata>
150 </sizepolicy>
151 <pixmap>image0</pixmap>
152 </customwidget>
153 <customwidget>
154 <class>FolderWidget</class>
155 <header location="local">folderwidget.h</header>
156 <sizehint>
157 <width>-1</width>
158 <height>-1</height>
159 </sizehint>
160 <container>0</container>
161 <sizepolicy>
162 <hordata>5</hordata>
163 <verdata>5</verdata>
164 </sizepolicy>
165 <pixmap>image0</pixmap>
166 </customwidget>
167</customwidgets>
168<images>
169 <image>
170 <name>image0</name>
171 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
172 </image>
173</images>
174<tabstops>
175 <tabstop>in</tabstop>
176 <tabstop>other</tabstop>
177 <tabstop>searchFor</tabstop>
178</tabstops>
179</UI>
diff --git a/noncore/unsupported/mail2/viewmail.cpp b/noncore/unsupported/mail2/viewmail.cpp
new file mode 100644
index 0000000..ae1f5f3
--- a/dev/null
+++ b/noncore/unsupported/mail2/viewmail.cpp
@@ -0,0 +1,172 @@
1#include <qtextbrowser.h>
2#include <qmessagebox.h>
3#include <qaction.h>
4
5#include "mailfactory.h"
6#include "composer.h"
7#include "viewmail.h"
8
9AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore)
10 : QListViewItem(parent), _attachItemStore(attachItemStore)
11{
12 setText(0, _attachItemStore.mimeType());
13 setText(1, _attachItemStore.fileName());
14 setText(2, _attachItemStore.description());
15}
16
17AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore)
18 : QListViewItem(parent), _attachItemStore(attachItemStore)
19{
20 setText(0, _attachItemStore.mimeType());
21 setText(1, _attachItemStore.fileName());
22 setText(2, _attachItemStore.description());
23}
24
25ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl)
26 : ViewMailBase(parent, name, fl), _mail(mail), _handler(handler)
27{
28 setCaption(caption().arg(mail.envelope().from()[0].name()));
29
30 _gotBody = false;
31 _mailHtml = tr(
32 "<html><body>"
33 "<div align=center><b>%1</b></div>"
34 "<b>From:</b> %2<br>"
35 "<b>To:</b> %3<br>"
36 "%4"
37 "%5"
38 "<b>Date:</b> %6<hr>"
39 "<font face=fixed>%7</font>")
40 .arg(deHtml(mail.envelope().subject().isNull() ? tr("(no subject)")
41 : deHtml(mail.envelope().subject())))
42 .arg(deHtml(mail.envelope().from().toString().isNull() ? tr("(no from)")
43 : mail.envelope().from().toString()))
44 .arg(deHtml(mail.envelope().to().toString().isNull() ? tr("(no recipient)")
45 : mail.envelope().to().toString()))
46 .arg(mail.envelope().cc().toString().isNull() ? QString(0)
47 : tr("<b>Cc:</b> %1<br>").arg(deHtml(mail.envelope().cc().toString())))
48 .arg(mail.envelope().bcc().toString().isNull() ? QString(0)
49 : tr("<b>Bcc:</b> %1<br>").arg(deHtml(mail.envelope().bcc().toString())))
50 .arg(mail.envelope().mailDate().isNull() ? tr("(no date)")
51 : mail.envelope().mailDate())
52 .arg("%1");
53
54 connect(reply, SIGNAL(activated()), SLOT(slotReply()));
55 connect(forward, SIGNAL(activated()), SLOT(slotForward()));
56
57 attachments->setEnabled(_gotBody);
58 browser->setText(QString(_mailHtml).arg(tr("Getting mail body from server. Please wait...")));
59
60 _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid()));
61 connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &)));
62}
63
64QString ViewMail::deHtml(const QString &string)
65{
66 QString string_ = string;
67 string_.replace(QRegExp("&"), "&amp;");
68 string_.replace(QRegExp("<"), "&lt;");
69 string_.replace(QRegExp(">"), "&gt;");
70 string_.replace(QRegExp("\\n"), "<br>");
71 return string_;
72}
73
74void ViewMail::slotReply()
75{
76 if (!_gotBody) {
77 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
78 return;
79 }
80
81 QString rtext;
82 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
83 .arg(_mail.envelope().from()[0].toString())
84 .arg(_mail.envelope().mailDate());
85
86 QString text = _mail.bodyPart(1).data();
87 QStringList lines = QStringList::split(QRegExp("\\n"), text);
88 QStringList::Iterator it;
89 for (it = lines.begin(); it != lines.end(); it++) {
90 rtext += "> " + *it + "\n";
91 }
92 rtext += "\n";
93
94 QString prefix;
95 if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = "";
96 else prefix = "Re: "; // no i18n on purpose
97
98 SendMail sendMail;
99 sendMail.setTo(_mail.envelope().from()[0].toString());
100 sendMail.setSubject(prefix + _mail.envelope().subject());
101 sendMail.setInReplyTo(_mail.envelope().messageId());
102 sendMail.setMessage(rtext);
103
104 Composer *composer = new Composer(0, 0, Qt::WType_Modal);
105 composer->setSendMail(sendMail);
106 composer->showMaximized();
107 composer->show();
108}
109
110void ViewMail::slotForward()
111{
112 if (!_gotBody) {
113 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
114 return;
115 }
116
117 QString ftext;
118 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
119 .arg(_mail.envelope().from()[0].toString());
120 if (!_mail.envelope().mailDate().isNull())
121 ftext += QString("Date: %1\n")
122 .arg(_mail.envelope().mailDate());
123 if (!_mail.envelope().from()[0].toString().isNull())
124 ftext += QString("From: %1\n")
125 .arg(_mail.envelope().from()[0].toString());
126 if (!_mail.envelope().to().toString().isNull())
127 ftext += QString("To: %1\n")
128 .arg(_mail.envelope().to().toString());
129 if (!_mail.envelope().cc().toString().isNull())
130 ftext += QString("Cc: %1\n")
131 .arg(_mail.envelope().cc().toString());
132 if (!_mail.envelope().bcc().toString().isNull())
133 ftext += QString("Bcc: %1\n")
134 .arg(_mail.envelope().bcc().toString());
135 if (!_mail.envelope().subject().isNull())
136 ftext += QString("Subject: %1\n")
137 .arg(_mail.envelope().subject());
138
139 ftext += QString("\n%1\n")
140 .arg(_mail.bodyPart(1).data());
141
142 ftext += QString("----- End forwarded message -----\n");
143
144 SendMail sendMail;
145 sendMail.setSubject("Fwd: " + _mail.envelope().subject());
146 sendMail.setMessage(ftext);
147
148 Composer *composer = new Composer(0, 0, Qt::WType_Modal);
149 composer->setSendMail(sendMail);
150 composer->showMaximized();
151 composer->show();
152}
153
154void ViewMail::slotIMAPUid(IMAPResponse &response)
155{
156 disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &)));
157
158 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
159 QValueList<IMAPResponseBodyPart> bodyParts;
160 bodyParts.append(response.FETCH()[0].bodyPart(1));
161 _mail.setBodyParts(bodyParts);
162
163 browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(1).data())));
164
165 // fillList(response.FETCH()[0].bodyStructure());
166
167 _gotBody = true;
168 } else {
169 QMessageBox::warning(this, tr("Error"), tr("<p>I was unable to retrieve the mail from the server. You can try again later or give up.</p>"), tr("Ok"));
170 }
171}
172
diff --git a/noncore/unsupported/mail2/viewmail.h b/noncore/unsupported/mail2/viewmail.h
new file mode 100644
index 0000000..a013e43
--- a/dev/null
+++ b/noncore/unsupported/mail2/viewmail.h
@@ -0,0 +1,65 @@
1#ifndef VIEWMAIL_H
2#define VIEWMAIL_H
3
4#include <qlistview.h>
5
6#include "viewmailbase.h"
7#include "imapresponse.h"
8#include "mailtable.h"
9
10class AttachItemStore
11{
12public:
13 void setMimeType(QString mimeType) { _mimeType = mimeType; }
14 QString mimeType() { return _mimeType; }
15 void setFileName(QString fileName) { _fileName = fileName; }
16 QString fileName() { return _fileName; }
17 void setDescription(QString description) { _description = description; }
18 QString description() { return _description; }
19 void setPartNum(QString partNum) { _partNum = partNum; }
20 QString partNum() { return _partNum; }
21
22private:
23 QString _mimeType, _fileName, _description, _partNum;
24
25};
26
27class AttachItem : public QListViewItem
28{
29public:
30 AttachItem(QListView *parent, AttachItemStore &attachment);
31 AttachItem(QListViewItem *parent, AttachItemStore &attachment);
32
33 AttachItemStore attachItemStore() { return _attachItemStore; }
34
35private:
36 AttachItemStore _attachItemStore;
37
38};
39
40class ViewMail : public ViewMailBase
41{
42 Q_OBJECT
43
44public:
45 ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal);
46
47protected:
48 //void fillList(IMAPResponseBODYSTRUCTURE &structure);
49 QString deHtml(const QString &string);
50
51protected slots:
52 void slotReply();
53 void slotForward();
54
55 void slotIMAPUid(IMAPResponse &response);
56
57private:
58 IMAPResponseFETCH _mail;
59 IMAPHandler *_handler;
60 QString _mailHtml;
61 bool _gotBody;
62
63};
64
65#endif
diff --git a/noncore/unsupported/mail2/viewmailbase.cpp b/noncore/unsupported/mail2/viewmailbase.cpp
new file mode 100644
index 0000000..134e5cb
--- a/dev/null
+++ b/noncore/unsupported/mail2/viewmailbase.cpp
@@ -0,0 +1,65 @@
1#include <qtextbrowser.h>
2#include <qlistview.h>
3#include <qtoolbar.h>
4#include <qaction.h>
5#include <qlabel.h>
6#include <qvbox.h>
7
8#include <qpe/resource.h>
9
10#include "viewmailbase.h"
11#include "opendiag.h"
12
13ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl)
14 : QMainWindow(parent, name, fl)
15{
16 setCaption(tr("E-Mail by %1"));
17 setToolBarsMovable(false);
18
19 toolbar = new QToolBar(this);
20 toolbar->setHorizontalStretchable(true);
21 addToolBar(toolbar);
22
23 reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this);
24 reply->addTo(toolbar);
25
26 forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this);
27 forward->addTo(toolbar);
28
29 attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true);
30 attachbutton->addTo(toolbar);
31 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool)));
32
33 deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this);
34 deleteMail->addTo(toolbar);
35
36 QLabel *spacer = new QLabel(toolbar);
37 spacer->setBackgroundMode(QWidget::PaletteButton);
38 toolbar->setStretchableWidget(spacer);
39
40 QVBox *view = new QVBox(this);
41 setCentralWidget(view);
42
43 attachments = new QListView(view);
44 attachments->setMinimumHeight(90);
45 attachments->setMaximumHeight(90);
46 attachments->setAllColumnsShowFocus(true);
47 attachments->addColumn("Mime Type", 100);
48 attachments->addColumn("Filename", 100);
49 attachments->addColumn("Description", 100);
50 attachments->hide();
51
52 browser = new QTextBrowser(view);
53
54 openDiag = new OpenDiag(view);
55 openDiag->hide();
56
57}
58
59void ViewMailBase::slotChangeAttachview(bool state)
60{
61 if (state) attachments->show();
62 else attachments->hide();
63}
64
65
diff --git a/noncore/unsupported/mail2/viewmailbase.h b/noncore/unsupported/mail2/viewmailbase.h
new file mode 100644
index 0000000..183bb04
--- a/dev/null
+++ b/noncore/unsupported/mail2/viewmailbase.h
@@ -0,0 +1,32 @@
1#ifndef VIEWMAILBASE_H
2#define VIEWMAILBASE_H
3
4#include <qmainwindow.h>
5
6class QAction;
7class OpenDiag;
8class QToolBar;
9class QListView;
10class QTextBrowser;
11
12class ViewMailBase : public QMainWindow
13{
14 Q_OBJECT
15
16public:
17 ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
18
19protected:
20 QAction *reply, *forward, *attachbutton, *deleteMail;
21 QListView *attachments;
22 QToolBar *toolbar;
23 QTextBrowser *browser;
24 OpenDiag *openDiag;
25
26protected slots:
27 void slotChangeAttachview(bool state);
28
29};
30
31#endif
32
diff --git a/pics/mail/abort.png b/pics/mail/abort.png
new file mode 100644
index 0000000..2967268
--- a/dev/null
+++ b/pics/mail/abort.png
Binary files differ
diff --git a/pics/mail/add.png b/pics/mail/add.png
new file mode 100644
index 0000000..44c8380
--- a/dev/null
+++ b/pics/mail/add.png
Binary files differ
diff --git a/pics/mail/addbook.png b/pics/mail/addbook.png
new file mode 100644
index 0000000..8192b35
--- a/dev/null
+++ b/pics/mail/addbook.png
Binary files differ
diff --git a/pics/mail/attach.png b/pics/mail/attach.png
new file mode 100644
index 0000000..437f577
--- a/dev/null
+++ b/pics/mail/attach.png
Binary files differ
diff --git a/pics/mail/configure.png b/pics/mail/configure.png
new file mode 100644
index 0000000..04e0ad4
--- a/dev/null
+++ b/pics/mail/configure.png
Binary files differ
diff --git a/pics/mail/delete.png b/pics/mail/delete.png
new file mode 100644
index 0000000..d34845e
--- a/dev/null
+++ b/pics/mail/delete.png
Binary files differ
diff --git a/pics/mail/desktopicon.png b/pics/mail/desktopicon.png
new file mode 100644
index 0000000..a58165a
--- a/dev/null
+++ b/pics/mail/desktopicon.png
Binary files differ
diff --git a/pics/mail/find.png b/pics/mail/find.png
new file mode 100644
index 0000000..7112019
--- a/dev/null
+++ b/pics/mail/find.png
Binary files differ
diff --git a/pics/mail/folder.png b/pics/mail/folder.png
new file mode 100644
index 0000000..a7acdd6
--- a/dev/null
+++ b/pics/mail/folder.png
Binary files differ
diff --git a/pics/mail/forward.png b/pics/mail/forward.png
new file mode 100644
index 0000000..c6b0647
--- a/dev/null
+++ b/pics/mail/forward.png
Binary files differ
diff --git a/pics/mail/inbox.png b/pics/mail/inbox.png
new file mode 100644
index 0000000..5b83fec
--- a/dev/null
+++ b/pics/mail/inbox.png
Binary files differ
diff --git a/pics/mail/mailchecker.png b/pics/mail/mailchecker.png
new file mode 100644
index 0000000..969c015
--- a/dev/null
+++ b/pics/mail/mailchecker.png
Binary files differ
diff --git a/pics/mail/newmail.png b/pics/mail/newmail.png
new file mode 100644
index 0000000..0c99794
--- a/dev/null
+++ b/pics/mail/newmail.png
Binary files differ
diff --git a/pics/mail/remove.png b/pics/mail/remove.png
new file mode 100644
index 0000000..40fed4f
--- a/dev/null
+++ b/pics/mail/remove.png
Binary files differ
diff --git a/pics/mail/reply.png b/pics/mail/reply.png
new file mode 100644
index 0000000..446200d
--- a/dev/null
+++ b/pics/mail/reply.png
Binary files differ
diff --git a/pics/mail/savemail.png b/pics/mail/savemail.png
new file mode 100644
index 0000000..0974a24
--- a/dev/null
+++ b/pics/mail/savemail.png
Binary files differ
diff --git a/pics/mail/sendall.png b/pics/mail/sendall.png
new file mode 100644
index 0000000..8b0d0aa
--- a/dev/null
+++ b/pics/mail/sendall.png
Binary files differ
diff --git a/pics/mail/sendmail.png b/pics/mail/sendmail.png
new file mode 100644
index 0000000..faefe1c
--- a/dev/null
+++ b/pics/mail/sendmail.png
Binary files differ
diff --git a/pics/mail/sendqueue.png b/pics/mail/sendqueue.png
new file mode 100644
index 0000000..bfb14c8
--- a/dev/null
+++ b/pics/mail/sendqueue.png
Binary files differ