author | zautrix <zautrix> | 2005-01-24 12:16:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-24 12:16:16 (UTC) |
commit | d4f5ce1bedd03191da5ecef2dc68381c10ef1fba (patch) (unidiff) | |
tree | 2d6860078083e588f8f365b308ee4ffb2c34f1c1 | |
parent | 485a6b28e3be6437742852970fdd122ba071b726 (diff) | |
download | kdepimpi-d4f5ce1bedd03191da5ecef2dc68381c10ef1fba.zip kdepimpi-d4f5ce1bedd03191da5ecef2dc68381c10ef1fba.tar.gz kdepimpi-d4f5ce1bedd03191da5ecef2dc68381c10ef1fba.tar.bz2 |
more imap fixes
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 7 | ||||
-rw-r--r-- | kmicromail/libetpan/imap/mailimap_parser.c | 22 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 67 | ||||
-rw-r--r-- | kmicromail/viewmailbase.cpp | 2 |
4 files changed, 64 insertions, 34 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 5bfe1c8..cbed872 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,786 +1,793 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 1.9.20 ************ | 3 | ********** VERSION 1.9.20 ************ |
4 | 4 | ||
5 | KO/Pi: | 5 | KO/Pi: |
6 | Added for the "dislplay one day" agenda mode | 6 | Added for the "dislplay one day" agenda mode |
7 | info in the caption and in the day lables: | 7 | info in the caption and in the day lables: |
8 | Now it is displayed, if the selected day is from "day before yesterday" | 8 | Now it is displayed, if the selected day is from "day before yesterday" |
9 | to "day after tomorrow". | 9 | to "day after tomorrow". |
10 | Made it possible to delete a Todo, which has sub-todos. | 10 | Made it possible to delete a Todo, which has sub-todos. |
11 | Fixed two small problems in the todo view. | 11 | Fixed two small problems in the todo view. |
12 | Added missing German translation for filter edit and print dialog. | 12 | Added missing German translation for filter edit and print dialog. |
13 | Made search dialog closeable by cancel key. | 13 | Made search dialog closeable by cancel key. |
14 | 14 | ||
15 | Made it possible to select in the date picker the (ligt grey ) | 15 | Made it possible to select in the date picker the (ligt grey ) |
16 | dates of the prev./next month with the mouse. | 16 | dates of the prev./next month with the mouse. |
17 | 17 | ||
18 | OM/Pi: | ||
19 | "Delete mail" icon in main window now deletes all selected mails. | ||
20 | Fixed the problem, that the state flag of imap mails was ignored. | ||
21 | Now mails with "FLAG_SEEN" on the imap server get no icon in the list view | ||
22 | to idecate that they are already seen. | ||
23 | Fixed the problem that the body of some mails was not displayed in the | ||
24 | mail viewer when fetching them from the imap server directly to read them. | ||
18 | 25 | ||
19 | 26 | ||
20 | 27 | ||
21 | ********** VERSION 1.9.19 ************ | 28 | ********** VERSION 1.9.19 ************ |
22 | 29 | ||
23 | Added a lot of missing translations to KA/Pi, | 30 | Added a lot of missing translations to KA/Pi, |
24 | Added some missing translations to KO/Pi and OM/Pi. | 31 | Added some missing translations to KO/Pi and OM/Pi. |
25 | 32 | ||
26 | Fixed some minor problems in KA/Pi + KO/Pi. | 33 | Fixed some minor problems in KA/Pi + KO/Pi. |
27 | 34 | ||
28 | Fixed a crash when closing PwM/Pi. | 35 | Fixed a crash when closing PwM/Pi. |
29 | Added German translation for PwM/Pi. | 36 | Added German translation for PwM/Pi. |
30 | 37 | ||
31 | Made view change and Month View update faster in KO/Pi. | 38 | Made view change and Month View update faster in KO/Pi. |
32 | 39 | ||
33 | 40 | ||
34 | ********** VERSION 1.9.18 ************ | 41 | ********** VERSION 1.9.18 ************ |
35 | 42 | ||
36 | FYI: The VERSION 1.9.17 was a testing release only. | 43 | FYI: The VERSION 1.9.17 was a testing release only. |
37 | Please read the changelog of VERSION 1.9.17 as well. | 44 | Please read the changelog of VERSION 1.9.17 as well. |
38 | 45 | ||
39 | Cleaned up the syncing config dialog. | 46 | Cleaned up the syncing config dialog. |
40 | Added sync config options for date range for events. | 47 | Added sync config options for date range for events. |
41 | Added sync config options for filters on incoming data. | 48 | Added sync config options for filters on incoming data. |
42 | Added sync config options for filters on outgoing data. | 49 | Added sync config options for filters on outgoing data. |
43 | Please read the updated SyncHowTo about the new filter settings. | 50 | Please read the updated SyncHowTo about the new filter settings. |
44 | These filter settings make it now possible to sync with shared | 51 | These filter settings make it now possible to sync with shared |
45 | calendars without writing back private or confidential data | 52 | calendars without writing back private or confidential data |
46 | (via the outgoing filters). | 53 | (via the outgoing filters). |
47 | To sync only with particular parts of a shared calendar, | 54 | To sync only with particular parts of a shared calendar, |
48 | the incoming filter settings can be used. | 55 | the incoming filter settings can be used. |
49 | An example can be found in the SyncHowTo. | 56 | An example can be found in the SyncHowTo. |
50 | Same for shared addressbooks. | 57 | Same for shared addressbooks. |
51 | 58 | ||
52 | Added a setting for the global kdepim data storage. | 59 | Added a setting for the global kdepim data storage. |
53 | Usually the data is stored in (yourhomedir/kdepim). | 60 | Usually the data is stored in (yourhomedir/kdepim). |
54 | Now you can set in the Global config dialog TAB, subTAB "Data storage path" | 61 | Now you can set in the Global config dialog TAB, subTAB "Data storage path" |
55 | a directory where all the kdepim data is stored. | 62 | a directory where all the kdepim data is stored. |
56 | That makes it easy to save all kdepim data on a SD card on the Z, for example. | 63 | That makes it easy to save all kdepim data on a SD card on the Z, for example. |
57 | 64 | ||
58 | KO/Pi: | 65 | KO/Pi: |
59 | The timeedit input has a pulldown list for times. | 66 | The timeedit input has a pulldown list for times. |
60 | If opened, this pulldown list should now has the right time highlighted. | 67 | If opened, this pulldown list should now has the right time highlighted. |
61 | Added the possibility to exclude events/todos/journals in a filter. | 68 | Added the possibility to exclude events/todos/journals in a filter. |
62 | You should exclude journals, if you do not want them to sync with a public calendar. | 69 | You should exclude journals, if you do not want them to sync with a public calendar. |
63 | 70 | ||
64 | KA/Pi: | 71 | KA/Pi: |
65 | Added the possibility to in/exclude public/private/confidential contacts to a filter. | 72 | Added the possibility to in/exclude public/private/confidential contacts to a filter. |
66 | If you have already defined filterrules in KA/Pi you have to adjust them all by setting the "include public/private/confidential" property manually. Sorry for that ... | 73 | If you have already defined filterrules in KA/Pi you have to adjust them all by setting the "include public/private/confidential" property manually. Sorry for that ... |
67 | Added printing of card view and details view on desktop. | 74 | Added printing of card view and details view on desktop. |
68 | Printing of list view is not working... | 75 | Printing of list view is not working... |
69 | Added button for removing pictures in contact editor. | 76 | Added button for removing pictures in contact editor. |
70 | Parsing data fix of KA/Pi version 1.9.17. | 77 | Parsing data fix of KA/Pi version 1.9.17. |
71 | Fixed the "parse name automatically" problem of KA/Pi version 1.9.17. | 78 | Fixed the "parse name automatically" problem of KA/Pi version 1.9.17. |
72 | Fixed some syncing merging problems. | 79 | Fixed some syncing merging problems. |
73 | 80 | ||
74 | 81 | ||
75 | ********** VERSION 1.9.17 ************ | 82 | ********** VERSION 1.9.17 ************ |
76 | 83 | ||
77 | KO/Pi: | 84 | KO/Pi: |
78 | Fixed that tooltips were not updated after moving an item in agenda view. | 85 | Fixed that tooltips were not updated after moving an item in agenda view. |
79 | Fixed a bug in sorting start date for recurring events in list view. | 86 | Fixed a bug in sorting start date for recurring events in list view. |
80 | Changed the left button in todo viewer from "Agenda" to "Set completed". | 87 | Changed the left button in todo viewer from "Agenda" to "Set completed". |
81 | This makes it possible to change a todo in the What's Next View quickly to the completed state without leaving the What's Next View. | 88 | This makes it possible to change a todo in the What's Next View quickly to the completed state without leaving the What's Next View. |
82 | Added more info in the todo viewer: Startdate, parent/sub todos. | 89 | Added more info in the todo viewer: Startdate, parent/sub todos. |
83 | 90 | ||
84 | 91 | ||
85 | KA/Pi: | 92 | KA/Pi: |
86 | All fields search does now actually search all the (possible) fields, | 93 | All fields search does now actually search all the (possible) fields, |
87 | not only those listed in the contact list. | 94 | not only those listed in the contact list. |
88 | Made is possible to inline a picture in a vcard on the Z. | 95 | Made is possible to inline a picture in a vcard on the Z. |
89 | This was only possible on the desktop, now is it possible on the Z as well. | 96 | This was only possible on the desktop, now is it possible on the Z as well. |
90 | Fixed of missing save settings after filter configuration. | 97 | Fixed of missing save settings after filter configuration. |
91 | Made saving of addressbook much faster. | 98 | Made saving of addressbook much faster. |
92 | Fixed extension widget layout problem. | 99 | Fixed extension widget layout problem. |
93 | Fixed saving of default formatted name settings. | 100 | Fixed saving of default formatted name settings. |
94 | Fixed formatted name handling in edit dialog. | 101 | Fixed formatted name handling in edit dialog. |
95 | Added an option for changing formatted names of many contacts | 102 | Added an option for changing formatted names of many contacts |
96 | (menu: File - Change - Set formatted name). | 103 | (menu: File - Change - Set formatted name). |
97 | 104 | ||
98 | QWhatsThis was not working on the Z ( only black rectangle was shown). | 105 | QWhatsThis was not working on the Z ( only black rectangle was shown). |
99 | This is Fixed. | 106 | This is Fixed. |
100 | 107 | ||
101 | KDE-Sync: | 108 | KDE-Sync: |
102 | Now readonly KDE resources are synced as well. | 109 | Now readonly KDE resources are synced as well. |
103 | (They are not changed in KDE itself, of course). | 110 | (They are not changed in KDE itself, of course). |
104 | 111 | ||
105 | 112 | ||
106 | 113 | ||
107 | ********** VERSION 1.9.16 ************ | 114 | ********** VERSION 1.9.16 ************ |
108 | 115 | ||
109 | KO/Pi: | 116 | KO/Pi: |
110 | Fixed search dialog size on Z 6000 (480x640 display). | 117 | Fixed search dialog size on Z 6000 (480x640 display). |
111 | Added setting to hide/show time in agenda items. | 118 | Added setting to hide/show time in agenda items. |
112 | Added setting to hide not running todos in todo view. | 119 | Added setting to hide not running todos in todo view. |
113 | Added columns for start date/time in todo view. | 120 | Added columns for start date/time in todo view. |
114 | Replaced the solid half-hour lines in agenda view by dot lines. | 121 | Replaced the solid half-hour lines in agenda view by dot lines. |
115 | Added possibility of printing the What's Next View on the desktop | 122 | Added possibility of printing the What's Next View on the desktop |
116 | (i.e. Windows and Linux). | 123 | (i.e. Windows and Linux). |
117 | Fixed a crash in KO/Pi when starting KO/Pi with What's Next view. | 124 | Fixed a crash in KO/Pi when starting KO/Pi with What's Next view. |
118 | Added tooltips in month view.(Tooltips only available on desktop) | 125 | Added tooltips in month view.(Tooltips only available on desktop) |
119 | 126 | ||
120 | Fixed a strange problem in KO/Pi alarm applet. | 127 | Fixed a strange problem in KO/Pi alarm applet. |
121 | Did not find the actual problem, | 128 | Did not find the actual problem, |
122 | such that now Qtopia reboots again if deinstalling the alarm applet. | 129 | such that now Qtopia reboots again if deinstalling the alarm applet. |
123 | But the alarm applet should work again. | 130 | But the alarm applet should work again. |
124 | 131 | ||
125 | KA/Pi: | 132 | KA/Pi: |
126 | Fixed the problem, that internal pictures were not saved. | 133 | Fixed the problem, that internal pictures were not saved. |
127 | 134 | ||
128 | Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes. | 135 | Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes. |
129 | 136 | ||
130 | Fixed some minor problems. (Like word wrap in help text windows). | 137 | Fixed some minor problems. (Like word wrap in help text windows). |
131 | 138 | ||
132 | Fixed a compiling problem in microkde/kresources. | 139 | Fixed a compiling problem in microkde/kresources. |
133 | 140 | ||
134 | KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM. | 141 | KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM. |
135 | This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9) | 142 | This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9) |
136 | such that now syncing KO/Pi with Sharp DTM should work on the | 143 | such that now syncing KO/Pi with Sharp DTM should work on the |
137 | Zaurus C 3000 model. | 144 | Zaurus C 3000 model. |
138 | 145 | ||
139 | ********** VERSION 1.9.15 ************ | 146 | ********** VERSION 1.9.15 ************ |
140 | 147 | ||
141 | Usebilty enhancements in KO/Pi: | 148 | Usebilty enhancements in KO/Pi: |
142 | When clicking on the date in a month view cell, the day view is shown. | 149 | When clicking on the date in a month view cell, the day view is shown. |
143 | Old behaviour was, that the "new event" dialog popped up. | 150 | Old behaviour was, that the "new event" dialog popped up. |
144 | 151 | ||
145 | Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu). | 152 | Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu). |
146 | That means, you can restore the latest | 153 | That means, you can restore the latest |
147 | event/todo/journal you have deleted. | 154 | event/todo/journal you have deleted. |
148 | A journal is deleted, if you clear all the text of the journal. | 155 | A journal is deleted, if you clear all the text of the journal. |
149 | 156 | ||
150 | Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14. | 157 | Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14. |
151 | 158 | ||
152 | KA/Pi starting in 480x640 resolution: | 159 | KA/Pi starting in 480x640 resolution: |
153 | Hide the filter action in toolbar | 160 | Hide the filter action in toolbar |
154 | and added icons for undo/delete/redo in toolbar. | 161 | and added icons for undo/delete/redo in toolbar. |
155 | 162 | ||
156 | Change in OM/Pi ViewMail dialog: | 163 | Change in OM/Pi ViewMail dialog: |
157 | When clicking on the "delete" icon the mail is deleted after confirmation as usual. | 164 | When clicking on the "delete" icon the mail is deleted after confirmation as usual. |
158 | But the edit dialog is not closed as before, now the next mail in the folder is shown automatically (if there is any). | 165 | But the edit dialog is not closed as before, now the next mail in the folder is shown automatically (if there is any). |
159 | 166 | ||
160 | Fixed a crash when deleting mail-accounts in OM/Pi. | 167 | Fixed a crash when deleting mail-accounts in OM/Pi. |
161 | 168 | ||
162 | 169 | ||
163 | ********** VERSION 1.9.14 ************ | 170 | ********** VERSION 1.9.14 ************ |
164 | 171 | ||
165 | Fixed some problems with the dialog sizes when switching | 172 | Fixed some problems with the dialog sizes when switching |
166 | portrait/landscape mode on 640x480 PDA display. | 173 | portrait/landscape mode on 640x480 PDA display. |
167 | 174 | ||
168 | Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi. | 175 | Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi. |
169 | 176 | ||
170 | Fixed an ugly bug in KOpieMail: | 177 | Fixed an ugly bug in KOpieMail: |
171 | KOpieMail was not able to write files (mails) to MSDOS file system, | 178 | KOpieMail was not able to write files (mails) to MSDOS file system, |
172 | like on an usual preformatted SD card. That should work now. | 179 | like on an usual preformatted SD card. That should work now. |
173 | To save your mail data on the Sd card do the following: | 180 | To save your mail data on the Sd card do the following: |
174 | Create a dir on the SD card: | 181 | Create a dir on the SD card: |
175 | mkdir /mnt/card/localmail | 182 | mkdir /mnt/card/localmail |
176 | Go to your home dir: | 183 | Go to your home dir: |
177 | cd | 184 | cd |
178 | Go to kopiemail data storage dir: | 185 | Go to kopiemail data storage dir: |
179 | cd kdepim/apps/kopiemail | 186 | cd kdepim/apps/kopiemail |
180 | Create a symlink to the SD card: | 187 | Create a symlink to the SD card: |
181 | ls -s /mnt/card/localmail | 188 | ls -s /mnt/card/localmail |
182 | Now KOpieMail will store all mails on the SD card. | 189 | Now KOpieMail will store all mails on the SD card. |
183 | 190 | ||
184 | KO/Pi Monthview: | 191 | KO/Pi Monthview: |
185 | Now "Go to Today" selects the current month from day 1-end, | 192 | Now "Go to Today" selects the current month from day 1-end, |
186 | not the current date + some days. | 193 | not the current date + some days. |
187 | I.e. "Go to Today" shows now always | 194 | I.e. "Go to Today" shows now always |
188 | the current month with first day of month in the first row. | 195 | the current month with first day of month in the first row. |
189 | 196 | ||
190 | Added missing German translation. | 197 | Added missing German translation. |
191 | 198 | ||
192 | Fixed icons of executeable on Wintendo. | 199 | Fixed icons of executeable on Wintendo. |
193 | 200 | ||
194 | Added a "Show next Mail" button to the OM/Pi | 201 | Added a "Show next Mail" button to the OM/Pi |
195 | mail viewer such that the mail below the current mail | 202 | mail viewer such that the mail below the current mail |
196 | in the mail list view of the current folder | 203 | in the mail list view of the current folder |
197 | can be read with a single click. | 204 | can be read with a single click. |
198 | 205 | ||
199 | 206 | ||
200 | ********** VERSION 1.9.13 ************ | 207 | ********** VERSION 1.9.13 ************ |
201 | 208 | ||
202 | Fixed nasty PwM/Pi file reading bug, when | 209 | Fixed nasty PwM/Pi file reading bug, when |
203 | the used hash algo of file is different then the global | 210 | the used hash algo of file is different then the global |
204 | hash algo. | 211 | hash algo. |
205 | 212 | ||
206 | Added KA/Pi support for opie mailit mailapplication. | 213 | Added KA/Pi support for opie mailit mailapplication. |
207 | 214 | ||
208 | Fixed some bugs in OM/Pi. | 215 | Fixed some bugs in OM/Pi. |
209 | Now character conversion tables are available for the Zaurus | 216 | Now character conversion tables are available for the Zaurus |
210 | to make OM/Pi working properly. | 217 | to make OM/Pi working properly. |
211 | To get the character conversion in OM/Pi working, please download | 218 | To get the character conversion in OM/Pi working, please download |
212 | at the sourceforge project site the package | 219 | at the sourceforge project site the package |
213 | sr-character-conversion_SharpROM_arm.ipk.zip | 220 | sr-character-conversion_SharpROM_arm.ipk.zip |
214 | (or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms) | 221 | (or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms) |
215 | from the section "general files for KDE/Pim" | 222 | from the section "general files for KDE/Pim" |
216 | Instructions how to install this package are in a ReadMe in this file. | 223 | Instructions how to install this package are in a ReadMe in this file. |
217 | 224 | ||
218 | 225 | ||
219 | Fixed the orientation change problem in KA/Pi when switching | 226 | Fixed the orientation change problem in KA/Pi when switching |
220 | portrait/landscape mode. | 227 | portrait/landscape mode. |
221 | 228 | ||
222 | French translation available for KA/Pi and OM/Pi. | 229 | French translation available for KA/Pi and OM/Pi. |
223 | 230 | ||
224 | Fixed some problems with categories in KO/Pi in DTM sync. | 231 | Fixed some problems with categories in KO/Pi in DTM sync. |
225 | 232 | ||
226 | Added selection dialog for export to phone in KA/Pi. | 233 | Added selection dialog for export to phone in KA/Pi. |
227 | 234 | ||
228 | If in KO/Pi is an attendee selected to add to a meeting and this | 235 | If in KO/Pi is an attendee selected to add to a meeting and this |
229 | attendee is already in the list of attendees, this person is not added | 236 | attendee is already in the list of attendees, this person is not added |
230 | again. | 237 | again. |
231 | 238 | ||
232 | Some menu cleanup in KA/Pi. | 239 | Some menu cleanup in KA/Pi. |
233 | 240 | ||
234 | ********** VERSION 1.9.12 ************ | 241 | ********** VERSION 1.9.12 ************ |
235 | 242 | ||
236 | Fix for the bug in KO/Pi What's Next view of version 1.9.11. | 243 | Fix for the bug in KO/Pi What's Next view of version 1.9.11. |
237 | 244 | ||
238 | Bugfix: Licence file is now shown again. | 245 | Bugfix: Licence file is now shown again. |
239 | 246 | ||
240 | OM/Pi now supports Unicode (utf8 charset). | 247 | OM/Pi now supports Unicode (utf8 charset). |
241 | Fixed some bugs in OM/Pi. | 248 | Fixed some bugs in OM/Pi. |
242 | 249 | ||
243 | KA/Pi has more German translation. | 250 | KA/Pi has more German translation. |
244 | 251 | ||
245 | 252 | ||
246 | ********** VERSION 1.9.11 ************ | 253 | ********** VERSION 1.9.11 ************ |
247 | 254 | ||
248 | Fixed several problems in PWM/Pi, like | 255 | Fixed several problems in PWM/Pi, like |
249 | asking the user, if unsaved changed are pending | 256 | asking the user, if unsaved changed are pending |
250 | when closing the app. | 257 | when closing the app. |
251 | And PwM/Pi handles now different texts for the | 258 | And PwM/Pi handles now different texts for the |
252 | fields Description, Username, Password, configurable per category. | 259 | fields Description, Username, Password, configurable per category. |
253 | 260 | ||
254 | Fixed a crash in KO/Pi , when importing/loading vcs files | 261 | Fixed a crash in KO/Pi , when importing/loading vcs files |
255 | which have an entry with an attendee with state: | 262 | which have an entry with an attendee with state: |
256 | NEEDS ACTION | 263 | NEEDS ACTION |
257 | 264 | ||
258 | Fixed some problems in the German translation of OM/Pi, | 265 | Fixed some problems in the German translation of OM/Pi, |
259 | which makes some dialogs not fitting on the screen | 266 | which makes some dialogs not fitting on the screen |
260 | of the Z 5500. | 267 | of the Z 5500. |
261 | 268 | ||
262 | Fixed Qtopia crash, when disabling/deinstalling | 269 | Fixed Qtopia crash, when disabling/deinstalling |
263 | KO/Pi alarm applet. | 270 | KO/Pi alarm applet. |
264 | 271 | ||
265 | Implemented direct KDE<->KA/Pi sync for KA/Pi running | 272 | Implemented direct KDE<->KA/Pi sync for KA/Pi running |
266 | on Linux desktop. | 273 | on Linux desktop. |
267 | 274 | ||
268 | Added feature "remove sync info" to sync menu. | 275 | Added feature "remove sync info" to sync menu. |
269 | 276 | ||
270 | Tweaked the KO/Pi What's next view a bit, added | 277 | Tweaked the KO/Pi What's next view a bit, added |
271 | setting to hide events that are done. | 278 | setting to hide events that are done. |
272 | 279 | ||
273 | Disabled "beam receive enabled" on startup to | 280 | Disabled "beam receive enabled" on startup to |
274 | avoid problems if Fastload is enabled. | 281 | avoid problems if Fastload is enabled. |
275 | Please set "beam receive enabled", | 282 | Please set "beam receive enabled", |
276 | if you want to receive data via IR. | 283 | if you want to receive data via IR. |
277 | 284 | ||
278 | Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running | 285 | Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running |
279 | on Linux desktop. | 286 | on Linux desktop. |
280 | 287 | ||
281 | Made in KA/Pi scrolling possible, if details view is selected. | 288 | Made in KA/Pi scrolling possible, if details view is selected. |
282 | (The keyboard focus is set automatically to the search line) | 289 | (The keyboard focus is set automatically to the search line) |
283 | 290 | ||
284 | Fixed a bug in DMT sync, that a new entry in DTM was added | 291 | Fixed a bug in DMT sync, that a new entry in DTM was added |
285 | on every sync to Kx/Pi. | 292 | on every sync to Kx/Pi. |
286 | 293 | ||
287 | Fixed missing writing of KA/Pi categories to DMT entries when syncing. | 294 | Fixed missing writing of KA/Pi categories to DMT entries when syncing. |
288 | 295 | ||
289 | Fixed a bug in DMT sync with todos created in KO/Pi containing | 296 | Fixed a bug in DMT sync with todos created in KO/Pi containing |
290 | non-latin1 characters. | 297 | non-latin1 characters. |
291 | 298 | ||
292 | Rearranged package contents of Sharp-ipks and made all | 299 | Rearranged package contents of Sharp-ipks and made all |
293 | packages installable on SD again. | 300 | packages installable on SD again. |
294 | 301 | ||
295 | Fixed the writing of addressbook data in DTM sync. | 302 | Fixed the writing of addressbook data in DTM sync. |
296 | Empty fields in KA/Pi were not removed. | 303 | Empty fields in KA/Pi were not removed. |
297 | 304 | ||
298 | Added better category handling in KA/Pi: | 305 | Added better category handling in KA/Pi: |
299 | Added item | 306 | Added item |
300 | Edit Categories and | 307 | Edit Categories and |
301 | Manage new categories | 308 | Manage new categories |
302 | to the settings menu. | 309 | to the settings menu. |
303 | Possible to configure a view to display categories. | 310 | Possible to configure a view to display categories. |
304 | 311 | ||
305 | Added detailed "KDE Sync Howto" and "Multi Sync Howto" to Help menu. | 312 | Added detailed "KDE Sync Howto" and "Multi Sync Howto" to Help menu. |
306 | 313 | ||
307 | Fixed displaying of "free" days and time in KO Monthview and Agendaview. | 314 | Fixed displaying of "free" days and time in KO Monthview and Agendaview. |
308 | 315 | ||
309 | ... and many other bugfixes. | 316 | ... and many other bugfixes. |
310 | 317 | ||
311 | ********** VERSION 1.9.10 ************ | 318 | ********** VERSION 1.9.10 ************ |
312 | 319 | ||
313 | Many internal small bugfixes. | 320 | Many internal small bugfixes. |
314 | And fix of the "big" bug in KO/Pi, | 321 | And fix of the "big" bug in KO/Pi, |
315 | that after Syncing the appointments had an offset by several hours. | 322 | that after Syncing the appointments had an offset by several hours. |
316 | That was a problem with the internal timezone setting, | 323 | That was a problem with the internal timezone setting, |
317 | introduced by the changed timezone configuration settings. | 324 | introduced by the changed timezone configuration settings. |
318 | 325 | ||
319 | German translation for OM/Pi is now available. | 326 | German translation for OM/Pi is now available. |
320 | 327 | ||
321 | 328 | ||
322 | ********** VERSION 1.9.9 ************ | 329 | ********** VERSION 1.9.9 ************ |
323 | 330 | ||
324 | KDE-Pim/Pi has a new Member! | 331 | KDE-Pim/Pi has a new Member! |
325 | It is called PWM/Pi (Passwordmanager/platform-independent) | 332 | It is called PWM/Pi (Passwordmanager/platform-independent) |
326 | and it is available for the Zaurus. | 333 | and it is available for the Zaurus. |
327 | It is planned, that it will be available later for Windows. | 334 | It is planned, that it will be available later for Windows. |
328 | (And for Linux, of course). | 335 | (And for Linux, of course). |
329 | It is a port of the Passwordmanager of KDE. | 336 | It is a port of the Passwordmanager of KDE. |
330 | It will need the MicroKDElibs to run. | 337 | It will need the MicroKDElibs to run. |
331 | 338 | ||
332 | Made loading of addressbooks in KA/Pi up to 7 times faster! | 339 | Made loading of addressbooks in KA/Pi up to 7 times faster! |
333 | The bigger your addressbook file, the more starting speed | 340 | The bigger your addressbook file, the more starting speed |
334 | will you gain. (relatively) | 341 | will you gain. (relatively) |
335 | 342 | ||
336 | The Qtopia addressbook connector is now platform independend | 343 | The Qtopia addressbook connector is now platform independend |
337 | as well and should work on any platform for importing/exporting | 344 | as well and should work on any platform for importing/exporting |
338 | Qtopia and Opie XML files. | 345 | Qtopia and Opie XML files. |
339 | 346 | ||
340 | Added a +30min feature to the timezone settings to make | 347 | Added a +30min feature to the timezone settings to make |
341 | KDE-Pim/Pi useable in Australia and other parts on the | 348 | KDE-Pim/Pi useable in Australia and other parts on the |
342 | world with strange timezones ;-) | 349 | world with strange timezones ;-) |
343 | 350 | ||
344 | German "Umlaute" should now be sorted correctly on the Z in KA/Pi. | 351 | German "Umlaute" should now be sorted correctly on the Z in KA/Pi. |
345 | 352 | ||
346 | It is now possible to disable the | 353 | It is now possible to disable the |
347 | "receive data via infrared" feature, such that syncing with | 354 | "receive data via infrared" feature, such that syncing with |
348 | Outlook is now possible again with Kx/Pi runing. | 355 | Outlook is now possible again with Kx/Pi runing. |
349 | Please disable it, before syncing Sharp DTM with Outlook. | 356 | Please disable it, before syncing Sharp DTM with Outlook. |
350 | For your convenience, the "receive data via infrared" feature | 357 | For your convenience, the "receive data via infrared" feature |
351 | is disabled automatically, if you sync Kx/Pi with DTM. | 358 | is disabled automatically, if you sync Kx/Pi with DTM. |
352 | You have to enable it again manually after syncing. | 359 | You have to enable it again manually after syncing. |
353 | Enabling this feature makes it impossible to start the | 360 | Enabling this feature makes it impossible to start the |
354 | Sharp DTM apps. If this feature is enabled, you will only get the | 361 | Sharp DTM apps. If this feature is enabled, you will only get the |
355 | alarm notification from KO/Pi and not from the Sharp calendar. | 362 | alarm notification from KO/Pi and not from the Sharp calendar. |
356 | This is very useful if you sync KO/Pi with Sharp DTM, | 363 | This is very useful if you sync KO/Pi with Sharp DTM, |
357 | because after syncing you usually would get notified about | 364 | because after syncing you usually would get notified about |
358 | an alarm by KO/Pi and the Sharp Calendar. | 365 | an alarm by KO/Pi and the Sharp Calendar. |
359 | 366 | ||
360 | Together with the Linux desktop version of KO/Pi | 367 | Together with the Linux desktop version of KO/Pi |
361 | it is now possible to sync KO/Pi on the Zaurus | 368 | it is now possible to sync KO/Pi on the Zaurus |
362 | with the complete KDE-desktop (3.3 or later) | 369 | with the complete KDE-desktop (3.3 or later) |
363 | calendar data easily. | 370 | calendar data easily. |
364 | That makes it possible to sync the Z with one | 371 | That makes it possible to sync the Z with one |
365 | click of a mouse with the KDE-Desktop. | 372 | click of a mouse with the KDE-Desktop. |
366 | This feature it available for all Zaurus platforms KO/Pi | 373 | This feature it available for all Zaurus platforms KO/Pi |
367 | is running on. | 374 | is running on. |
368 | The only thing needed is a running KO/Pi on Linux and | 375 | The only thing needed is a running KO/Pi on Linux and |
369 | a compiled version of the small | 376 | a compiled version of the small |
370 | KDE-Pim/Pi<->KDE-Desktop access command line program, | 377 | KDE-Pim/Pi<->KDE-Desktop access command line program, |
371 | which is in the KDE-Pim/Pi sources available. | 378 | which is in the KDE-Pim/Pi sources available. |
372 | 379 | ||
373 | The "KDE-desktop" syncing feature for KA/Pi will follow | 380 | The "KDE-desktop" syncing feature for KA/Pi will follow |
374 | in the next releases. | 381 | in the next releases. |
375 | 382 | ||
376 | Fixed the vcard export bug, which had the version 1.9.8. | 383 | Fixed the vcard export bug, which had the version 1.9.8. |
377 | 384 | ||
378 | Added missing GERMAN translation to KO/Pi. | 385 | Added missing GERMAN translation to KO/Pi. |
379 | Hi PsionX, could you add the missing french translation?Thx! | 386 | Hi PsionX, could you add the missing french translation?Thx! |
380 | 387 | ||
381 | Translation files for KA/Pi are available as well. | 388 | Translation files for KA/Pi are available as well. |
382 | GERMAN translation will be available in the next release. | 389 | GERMAN translation will be available in the next release. |
383 | PsionX ( yres, you again ;-) ), could you start translating | 390 | PsionX ( yres, you again ;-) ), could you start translating |
384 | KA/Pi? Thx! | 391 | KA/Pi? Thx! |
385 | 392 | ||
386 | You can download the version 1.9.9 at | 393 | You can download the version 1.9.9 at |
387 | 394 | ||
388 | http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 | 395 | http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 |
389 | 396 | ||
390 | Note: | 397 | Note: |
391 | To run the mail program OM/Pi you need libopenssl. | 398 | To run the mail program OM/Pi you need libopenssl. |
392 | A link to a download loaction is available at | 399 | A link to a download loaction is available at |
393 | ZSI at www.killefiz.de | 400 | ZSI at www.killefiz.de |
394 | 401 | ||
395 | 402 | ||
396 | ********** VERSION 1.9.8 ************ | 403 | ********** VERSION 1.9.8 ************ |
397 | 404 | ||
398 | Fixed character decoding in OM/Pi. | 405 | Fixed character decoding in OM/Pi. |
399 | (e.g. German "Umlaute" were not displayed properly.) | 406 | (e.g. German "Umlaute" were not displayed properly.) |
400 | 407 | ||
401 | Made is possible to reparent todos in KO/Pi. | 408 | Made is possible to reparent todos in KO/Pi. |
402 | Use contextmenu or keys (look at Help-Keys + Colors) for that. | 409 | Use contextmenu or keys (look at Help-Keys + Colors) for that. |
403 | 410 | ||
404 | Added the missing Sync-Howto and WhatsNew to the packages. | 411 | Added the missing Sync-Howto and WhatsNew to the packages. |
405 | 412 | ||
406 | KO/Pi on Linux desktop can now sync with KDE desktop. | 413 | KO/Pi on Linux desktop can now sync with KDE desktop. |
407 | That means: When using KO/Pi on Linux desktop for syncing with | 414 | That means: When using KO/Pi on Linux desktop for syncing with |
408 | KDE desktop and the Zaurus, the Zaurus can be synced now | 415 | KDE desktop and the Zaurus, the Zaurus can be synced now |
409 | with all KDE-Calendar resources, not only with one local file. | 416 | with all KDE-Calendar resources, not only with one local file. |
410 | (That makes it possible to sync the Zaurus with the | 417 | (That makes it possible to sync the Zaurus with the |
411 | calendar data on a Kolab server) | 418 | calendar data on a Kolab server) |
412 | 419 | ||
413 | KA/Pi syncing with KDE desktop will be available in the next version. | 420 | KA/Pi syncing with KDE desktop will be available in the next version. |
414 | 421 | ||
415 | 422 | ||
416 | ********** VERSION 1.9.7 ************ | 423 | ********** VERSION 1.9.7 ************ |
417 | 424 | ||
418 | KO/Pi - KA/Pi on Windows: | 425 | KO/Pi - KA/Pi on Windows: |
419 | Now a directory can be defined by the user, where the | 426 | Now a directory can be defined by the user, where the |
420 | application/config data should be saved. | 427 | application/config data should be saved. |
421 | Define your desired path in the evironment variable | 428 | Define your desired path in the evironment variable |
422 | MICROKDEHOME | 429 | MICROKDEHOME |
423 | before starting KO/Pi or KA/Pi. | 430 | before starting KO/Pi or KA/Pi. |
424 | 431 | ||
425 | An easy Kx/Pi to Kx/Pi syncing is now possible | 432 | An easy Kx/Pi to Kx/Pi syncing is now possible |
426 | (it is called Pi-Sync) via network. | 433 | (it is called Pi-Sync) via network. |
427 | Please look at the Sync Howto. | 434 | Please look at the Sync Howto. |
428 | 435 | ||
429 | Exporting of calendar data and contacts to mobile phones is now possible. | 436 | Exporting of calendar data and contacts to mobile phones is now possible. |
430 | The SyncHowto is updated with information howto | 437 | The SyncHowto is updated with information howto |
431 | access/sync mobile phones. | 438 | access/sync mobile phones. |
432 | Please look at the Sync Howto. | 439 | Please look at the Sync Howto. |
433 | 440 | ||
434 | Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. | 441 | Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. |
435 | Please disable Fastload for the original contact/calendar applications | 442 | Please disable Fastload for the original contact/calendar applications |
436 | and close them. | 443 | and close them. |
437 | KO/Pi and KA/Pi must be running in order to receive the data. | 444 | KO/Pi and KA/Pi must be running in order to receive the data. |
438 | (KO/Pi and KA/Pi are always running if Fastload for them is enabled!) | 445 | (KO/Pi and KA/Pi are always running if Fastload for them is enabled!) |
439 | 446 | ||
440 | In the KA/Pi details view are now the preferred tel. numbers displayed on top | 447 | In the KA/Pi details view are now the preferred tel. numbers displayed on top |
441 | of the other data ( emails/tel.numbers/addresses) | 448 | of the other data ( emails/tel.numbers/addresses) |
442 | 449 | ||
443 | Fixed some syncing problems in KA/Pi. | 450 | Fixed some syncing problems in KA/Pi. |
444 | 451 | ||
445 | Added font settings for the KA/Pi details view. | 452 | Added font settings for the KA/Pi details view. |
446 | Added fields "children's name" and "gender" to KA/Pi. | 453 | Added fields "children's name" and "gender" to KA/Pi. |
447 | 454 | ||
448 | Made searching in KA/Pi better: | 455 | Made searching in KA/Pi better: |
449 | Now the first item in a view is selected after a search automatically and | 456 | Now the first item in a view is selected after a search automatically and |
450 | the views can be scrolled up/down when the search input field has the keyboard focus. | 457 | the views can be scrolled up/down when the search input field has the keyboard focus. |
451 | 458 | ||
452 | And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. | 459 | And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. |
453 | 460 | ||
454 | 461 | ||
455 | ********** VERSION 1.9.6 ************ | 462 | ********** VERSION 1.9.6 ************ |
456 | 463 | ||
457 | Changes in the external application communication on the Zaurus | 464 | Changes in the external application communication on the Zaurus |
458 | in order to use less RAM when the apps are running. | 465 | in order to use less RAM when the apps are running. |
459 | First syncing of addressbooks (KA/Pi) is possible. | 466 | First syncing of addressbooks (KA/Pi) is possible. |
460 | 467 | ||
461 | 468 | ||
462 | ********** VERSION 1.9.5a ************ | 469 | ********** VERSION 1.9.5a ************ |
463 | 470 | ||
464 | Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. | 471 | Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. |
465 | Fixed some small bugs. | 472 | Fixed some small bugs. |
466 | KA/Pi shows now the birthday in summary view. | 473 | KA/Pi shows now the birthday in summary view. |
467 | Now OM/Pi and KA/Pi are using the date format defined in KO/Pi | 474 | Now OM/Pi and KA/Pi are using the date format defined in KO/Pi |
468 | for displaying dates. | 475 | for displaying dates. |
469 | 476 | ||
470 | 477 | ||
471 | ********** VERSION 1.9.5 ************ | 478 | ********** VERSION 1.9.5 ************ |
472 | 479 | ||
473 | There is still no Addressbook syncing! | 480 | There is still no Addressbook syncing! |
474 | 481 | ||
475 | New in 1.9.5: | 482 | New in 1.9.5: |
476 | 483 | ||
477 | Many bugfixes. | 484 | Many bugfixes. |
478 | Better searching in KA/Pi. | 485 | Better searching in KA/Pi. |
479 | You can configure in KA/Pi if you want to search only after | 486 | You can configure in KA/Pi if you want to search only after |
480 | <return> key pressed. | 487 | <return> key pressed. |
481 | 488 | ||
482 | Better mail downloading in OM/Pi. | 489 | Better mail downloading in OM/Pi. |
483 | 490 | ||
484 | First experimental alpha version of sync of KO/Pi with mobile phones. | 491 | First experimental alpha version of sync of KO/Pi with mobile phones. |
485 | See gammu documentation for supported phones. | 492 | See gammu documentation for supported phones. |
486 | You need to install the package kammu_1.9.5_arm.ipk for sync of KO/Pi with mobile phones. kammu_1.9.5_arm.ipk needs libbluetooth and libsdp. | 493 | You need to install the package kammu_1.9.5_arm.ipk for sync of KO/Pi with mobile phones. kammu_1.9.5_arm.ipk needs libbluetooth and libsdp. |
487 | Quick hint how to use: | 494 | Quick hint how to use: |
488 | NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! | 495 | NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! |
489 | Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. | 496 | Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. |
490 | Create syncprofile - mobile device | 497 | Create syncprofile - mobile device |
491 | Remove entry for model. (Leave empty ). | 498 | Remove entry for model. (Leave empty ). |
492 | Enable infrared on Zaurus and your Phone. | 499 | Enable infrared on Zaurus and your Phone. |
493 | Sync. | 500 | Sync. |
494 | To get a more detailed log, start kopi from konsole. | 501 | To get a more detailed log, start kopi from konsole. |
495 | 502 | ||
496 | ********** VERSION 1.9.4 ************ | 503 | ********** VERSION 1.9.4 ************ |
497 | 504 | ||
498 | This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus. | 505 | This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus. |
499 | 506 | ||
500 | WARNING: | 507 | WARNING: |
501 | PLEASE BACKUP ALL YOUR DATA! | 508 | PLEASE BACKUP ALL YOUR DATA! |
502 | We have changed a lot and maybe there are some unknown problems. | 509 | We have changed a lot and maybe there are some unknown problems. |
503 | 510 | ||
504 | SYNC HANDLING HAS CHANGED! | 511 | SYNC HANDLING HAS CHANGED! |
505 | Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. | 512 | Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. |
506 | (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). | 513 | (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). |
507 | 514 | ||
508 | You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs. | 515 | You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs. |
509 | If you get the error: "Install only possible in main memory", just try it again to install it on SD card. That worked for me. And it was reported that rebooting Qtopia did help in this case as well. | 516 | If you get the error: "Install only possible in main memory", just try it again to install it on SD card. That worked for me. And it was reported that rebooting Qtopia did help in this case as well. |
510 | 517 | ||
511 | As programs are available: | 518 | As programs are available: |
512 | KO/Pi (korganizer ipk) - a calendar program. | 519 | KO/Pi (korganizer ipk) - a calendar program. |
513 | KA/Pi (kaddressbook ipk ) - an addressbook | 520 | KA/Pi (kaddressbook ipk ) - an addressbook |
514 | OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support. | 521 | OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support. |
515 | 522 | ||
516 | An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode. | 523 | An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode. |
517 | (If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia) | 524 | (If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia) |
518 | 525 | ||
519 | All the applications are installed in a "Pim" TAB. | 526 | All the applications are installed in a "Pim" TAB. |
520 | If this TAB is new on your system, you can get an icon in this TAB by installing pim_TAB_icon_1.9.4_arm.ipk | 527 | If this TAB is new on your system, you can get an icon in this TAB by installing pim_TAB_icon_1.9.4_arm.ipk |
521 | 528 | ||
522 | All the application are integrated. | 529 | All the application are integrated. |
523 | Such that you can choose in KO/Pi the attendees of a meeting from the addresses in KA/Pi. When you click in KA/Pi on the email address, OM/Pi is started to write the mail. | 530 | Such that you can choose in KO/Pi the attendees of a meeting from the addresses in KA/Pi. When you click in KA/Pi on the email address, OM/Pi is started to write the mail. |
524 | 531 | ||
525 | HINT: | 532 | HINT: |
526 | If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number. | 533 | If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number. |
527 | 534 | ||
528 | What's new? | 535 | What's new? |
529 | 536 | ||
530 | SYNC HANDLING HAS CHANGED! | 537 | SYNC HANDLING HAS CHANGED! |
531 | Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. | 538 | Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. |
532 | (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). | 539 | (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). |
533 | 540 | ||
534 | New in OM/Pi: | 541 | New in OM/Pi: |
535 | When copying(i.e. downloading mails) , you can specify, that only mails of a given size should be downloaded. Added mail copy possibility for selected mails. | 542 | When copying(i.e. downloading mails) , you can specify, that only mails of a given size should be downloaded. Added mail copy possibility for selected mails. |
536 | 543 | ||
537 | New in KO/Pi: | 544 | New in KO/Pi: |
538 | French is now available for KO/Pi. | 545 | French is now available for KO/Pi. |
539 | Choose menu:Actions - Configure:TAB locale | 546 | Choose menu:Actions - Configure:TAB locale |
540 | Syncing has changed. | 547 | Syncing has changed. |
541 | Phone sync available soon. | 548 | Phone sync available soon. |
542 | Not much changes, I cannot remember them ... | 549 | Not much changes, I cannot remember them ... |
543 | 550 | ||
544 | New in KA/Pi: | 551 | New in KA/Pi: |
545 | Beaming possible. | 552 | Beaming possible. |
546 | Sharp DTM readonly access possible( create a new DTM resource ); | 553 | Sharp DTM readonly access possible( create a new DTM resource ); |
547 | Better searching possible. | 554 | Better searching possible. |
548 | Search is performed only after pressing the return key. | 555 | Search is performed only after pressing the return key. |
549 | Use wildcard * to specify parts of a name. | 556 | Use wildcard * to specify parts of a name. |
550 | 557 | ||
551 | Better name/email selection dialog (called from KO/Pi or OM/Pi). In this dialog, now searching is possible. Like in KA/Pi, use return key and wildcard * . | 558 | Better name/email selection dialog (called from KO/Pi or OM/Pi). In this dialog, now searching is possible. Like in KA/Pi, use return key and wildcard * . |
552 | 559 | ||
553 | A big improvement is the new management of the contact access. | 560 | A big improvement is the new management of the contact access. |
554 | In version 1.9.3, every application was using their own addressbook access data. | 561 | In version 1.9.3, every application was using their own addressbook access data. |
555 | That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi. | 562 | That means, the addressbook was loaded up to three times in the memory, when accessed by KA/Pi, KO/Pi and OM/Pi. |
556 | That was wasting of memory, if you had several hundreds of contacts. | 563 | That was wasting of memory, if you had several hundreds of contacts. |
557 | 564 | ||
558 | Now only KA/Pi accesses the addressbook. | 565 | Now only KA/Pi accesses the addressbook. |
559 | If KO/Pi or OM/Pi want to get some name/email data, they request KA/Pi to open the name/email selection dialog and send it back to them. | 566 | If KO/Pi or OM/Pi want to get some name/email data, they request KA/Pi to open the name/email selection dialog and send it back to them. |
560 | If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly. | 567 | If you click on an attendee in a meeting, its contact data is displayed in KA/Pi directly. |
561 | That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first. | 568 | That means, if KO/Pi or OM/Pi want to access contact data, KA/Pi is started first. |
562 | 569 | ||
563 | New in the KO/Pi alarm applet: | 570 | New in the KO/Pi alarm applet: |
564 | Configure your own timer popup menu! | 571 | Configure your own timer popup menu! |
565 | (Text and minutes for timer countdown) | 572 | (Text and minutes for timer countdown) |
566 | Just edit the file | 573 | Just edit the file |
567 | (yourhomedir)/.kopialarmtimerrc | 574 | (yourhomedir)/.kopialarmtimerrc |
568 | and start/stop a timer to get a new menu with the data of this file. | 575 | and start/stop a timer to get a new menu with the data of this file. |
569 | 576 | ||
570 | ********** VERSION 1.9.3 ************ | 577 | ********** VERSION 1.9.3 ************ |
571 | 1) | 578 | 1) |
572 | Now KO/Pi on Windows imports directly the calendar data of | 579 | Now KO/Pi on Windows imports directly the calendar data of |
573 | an installed Outlook. Should work with OL version >= 2000. | 580 | an installed Outlook. Should work with OL version >= 2000. |
574 | 581 | ||
575 | ********** VERSION 1.9.2 ************ | 582 | ********** VERSION 1.9.2 ************ |
576 | 1) | 583 | 1) |
577 | KDE-Pim/Pi has got a new member: | 584 | KDE-Pim/Pi has got a new member: |
578 | KmicroMail (KM/Pi) is a mail program, | 585 | KmicroMail (KM/Pi) is a mail program, |
579 | which can handle IMAP and POP mail access. | 586 | which can handle IMAP and POP mail access. |
580 | It is based on Opie-Mail v3. | 587 | It is based on Opie-Mail v3. |
581 | All dependencies to the Opie libraries ar removed, | 588 | All dependencies to the Opie libraries ar removed, |
582 | such that no additional Opie lib is needed. | 589 | such that no additional Opie lib is needed. |
583 | It is already integrated in KO/Pi and KA/Pi. | 590 | It is already integrated in KO/Pi and KA/Pi. |
584 | It it now available for the Zaurus,probably it | 591 | It it now available for the Zaurus,probably it |
585 | will be available for other platforms later. | 592 | will be available for other platforms later. |
586 | Hint: | 593 | Hint: |
587 | Create your own contact (name + email) | 594 | Create your own contact (name + email) |
588 | in KA/Pi, select this contact and choose menu: | 595 | in KA/Pi, select this contact and choose menu: |
589 | Settings - Set Who Am I. | 596 | Settings - Set Who Am I. |
590 | Now the settings of this contact are used as | 597 | Now the settings of this contact are used as |
591 | the sender data in KM/Pi. | 598 | the sender data in KM/Pi. |
592 | 2) | 599 | 2) |
593 | KDE-Pim/Pi is split up in five different | 600 | KDE-Pim/Pi is split up in five different |
594 | packages now precompiled for Sharp Zaurus: | 601 | packages now precompiled for Sharp Zaurus: |
595 | --kmicrokdelibs_1.9.2_arm.ipk | 602 | --kmicrokdelibs_1.9.2_arm.ipk |
596 | The libs are needed for any | 603 | The libs are needed for any |
597 | of the following programs: | 604 | of the following programs: |
598 | --kaddressbook_1.9.2_arm.ipk | 605 | --kaddressbook_1.9.2_arm.ipk |
599 | --kmicromail_1.9.2_arm.ipk | 606 | --kmicromail_1.9.2_arm.ipk |
600 | --korganizer_1.9.2_arm.ipk | 607 | --korganizer_1.9.2_arm.ipk |
601 | Independ from that, there is the alarm applet | 608 | Independ from that, there is the alarm applet |
602 | available for KO/Pi, which also offers | 609 | available for KO/Pi, which also offers |
603 | quick access for a new mail or | 610 | quick access for a new mail or |
604 | showing the addressbook.: | 611 | showing the addressbook.: |
605 | --korganizer-alarm_1.9.2_arm.ipk | 612 | --korganizer-alarm_1.9.2_arm.ipk |
606 | Independend means, that the alarm applet | 613 | Independend means, that the alarm applet |
607 | does not need any of the libs or programs above to run. | 614 | does not need any of the libs or programs above to run. |
608 | But it would be quite useless without these programs. | 615 | But it would be quite useless without these programs. |
609 | NOTE: | 616 | NOTE: |
610 | If you get a | 617 | If you get a |
611 | "This application depends on other programs" | 618 | "This application depends on other programs" |
612 | during installation of | 619 | during installation of |
613 | --kmicrokdelibs_1.9.2_arm.ipk | 620 | --kmicrokdelibs_1.9.2_arm.ipk |
614 | you probably do not have to care about that. | 621 | you probably do not have to care about that. |
615 | kmicrokdelibs_1.9.2 will come with some | 622 | kmicrokdelibs_1.9.2 will come with some |
616 | resource plugins, which needs additional libraries. | 623 | resource plugins, which needs additional libraries. |
617 | (E.g. libopie1, if you want to use the | 624 | (E.g. libopie1, if you want to use the |
618 | opie resource connector in KA/Pi). | 625 | opie resource connector in KA/Pi). |
619 | If you do not have this libraries installed, | 626 | If you do not have this libraries installed, |
620 | you simply cannot use the resource. | 627 | you simply cannot use the resource. |
621 | To make it clear: | 628 | To make it clear: |
622 | If the libraries are missing, the applications | 629 | If the libraries are missing, the applications |
623 | using kmicrokdelibs will start, | 630 | using kmicrokdelibs will start, |
624 | because the resources are plugins. | 631 | because the resources are plugins. |
625 | 3) | 632 | 3) |
626 | KO/Pi and friends are now installable on SD-Card! | 633 | KO/Pi and friends are now installable on SD-Card! |
627 | It is recommended to install all libs and apps | 634 | It is recommended to install all libs and apps |
628 | on the SD card or all in the internal storage. | 635 | on the SD card or all in the internal storage. |
629 | There may be problems, if this is mixed. | 636 | There may be problems, if this is mixed. |
630 | 4) | 637 | 4) |
631 | Fixed two bugs in the alarm notification on Windows. | 638 | Fixed two bugs in the alarm notification on Windows. |
632 | 5) | 639 | 5) |
633 | Great improvement! | 640 | Great improvement! |
634 | KO/Pi uses now the latest version of libical. | 641 | KO/Pi uses now the latest version of libical. |
635 | Libical is the library which actually reads | 642 | Libical is the library which actually reads |
636 | the calendar files and extract the data from it. | 643 | the calendar files and extract the data from it. |
637 | With the old version, there were problems | 644 | With the old version, there were problems |
638 | (crashes or program hangs) when licical did read | 645 | (crashes or program hangs) when licical did read |
639 | files, which were not stored from KO/Pi. | 646 | files, which were not stored from KO/Pi. |
640 | I do not know, if the new libical works perfect, | 647 | I do not know, if the new libical works perfect, |
641 | but actually it works much better than | 648 | but actually it works much better than |
642 | the old version. | 649 | the old version. |
643 | There are no problems with compatibility with | 650 | There are no problems with compatibility with |
644 | old calendar files of KO/Pi, of course! | 651 | old calendar files of KO/Pi, of course! |
645 | 6) | 652 | 6) |
646 | New in KA/Pi: | 653 | New in KA/Pi: |
647 | Opie addressbook resource connector available! | 654 | Opie addressbook resource connector available! |
648 | You will need libopie1 and the opie addressbook, | 655 | You will need libopie1 and the opie addressbook, |
649 | of course. | 656 | of course. |
650 | With the Opie addressbook resource connector, | 657 | With the Opie addressbook resource connector, |
651 | you can access the Opie addressbook readonly in KA/Pi. | 658 | you can access the Opie addressbook readonly in KA/Pi. |
652 | If you want to edit or import the data into KA/Pi, | 659 | If you want to edit or import the data into KA/Pi, |
653 | do this: | 660 | do this: |
654 | a) Create an Opie resource. | 661 | a) Create an Opie resource. |
655 | (Menu: Settings-Configure Resources). | 662 | (Menu: Settings-Configure Resources). |
656 | After configuration and restarting KA/Pi you should see | 663 | After configuration and restarting KA/Pi you should see |
657 | the Opie contacts in KA/Pi. | 664 | the Opie contacts in KA/Pi. |
658 | b) Select some or all Opie contacts. | 665 | b) Select some or all Opie contacts. |
659 | (NOTE: +++++ | 666 | (NOTE: +++++ |
660 | To know exactly, what contacts are Opie contacts, | 667 | To know exactly, what contacts are Opie contacts, |
661 | do this: Choose menu: | 668 | do this: Choose menu: |
662 | View-Modify View - TAB Fields. | 669 | View-Modify View - TAB Fields. |
663 | Select in the above list "Resource" and click | 670 | Select in the above list "Resource" and click |
664 | down arrow to add it to the "Selected fields". | 671 | down arrow to add it to the "Selected fields". |
665 | Click OK. | 672 | Click OK. |
666 | Now you have a new column "Resource" in your list, | 673 | Now you have a new column "Resource" in your list, |
667 | where you can see, what an Opie resource is. | 674 | where you can see, what an Opie resource is. |
668 | ++++ NOTE end.) | 675 | ++++ NOTE end.) |
669 | Ok, we do have now some Opie contacts seleted. | 676 | Ok, we do have now some Opie contacts seleted. |
670 | (Use SHIFT or CTRL key in order to multiple select). | 677 | (Use SHIFT or CTRL key in order to multiple select). |
671 | c) Choose menu: Edit-Copy. | 678 | c) Choose menu: Edit-Copy. |
672 | d) Choose menu: Edit-Paste. | 679 | d) Choose menu: Edit-Paste. |
673 | e) Select the resource, you want to add the contacts to. | 680 | e) Select the resource, you want to add the contacts to. |
674 | Congrats! Now you have read/write access to the copied | 681 | Congrats! Now you have read/write access to the copied |
675 | opie contacts as "real" KA/Pi contacts. | 682 | opie contacts as "real" KA/Pi contacts. |
676 | 683 | ||
677 | 684 | ||
678 | ********** VERSION 1.9.1 ************ | 685 | ********** VERSION 1.9.1 ************ |
679 | 1) | 686 | 1) |
680 | +++ IMPORTANT 1 +++ | 687 | +++ IMPORTANT 1 +++ |
681 | 688 | ||
682 | The storing place of the default calendar | 689 | The storing place of the default calendar |
683 | file has changed! | 690 | file has changed! |
684 | The default calendar file was | 691 | The default calendar file was |
685 | Applications/korganizer/mycalendar.ics | 692 | Applications/korganizer/mycalendar.ics |
686 | on Zaurus and | 693 | on Zaurus and |
687 | (yourHomeDir)/korganizer/mycalendar.ics | 694 | (yourHomeDir)/korganizer/mycalendar.ics |
688 | on Windows/Linux desktop. Now it is | 695 | on Windows/Linux desktop. Now it is |
689 | (yourHomeDir)/kdepim/korganizer/mycalendar.ics | 696 | (yourHomeDir)/kdepim/korganizer/mycalendar.ics |
690 | on Zaurus, Windows and Linux. | 697 | on Zaurus, Windows and Linux. |
691 | To load the old file, choose menu | 698 | To load the old file, choose menu |
692 | File-Load calendar backup. | 699 | File-Load calendar backup. |
693 | (It should be loaded automatically | 700 | (It should be loaded automatically |
694 | at startup with a warning message displayed). | 701 | at startup with a warning message displayed). |
695 | The place of the configuration file has changed too. | 702 | The place of the configuration file has changed too. |
696 | If you want to use your old KO/Pi config, | 703 | If you want to use your old KO/Pi config, |
697 | copy it to | 704 | copy it to |
698 | (yourHomeDir)/kdepim/config/korganizerrc | 705 | (yourHomeDir)/kdepim/config/korganizerrc |
699 | Please read VERSION 1.9.0 - topic 3) as well! | 706 | Please read VERSION 1.9.0 - topic 3) as well! |
700 | 707 | ||
701 | +++ IMPORTANT 2 +++ | 708 | +++ IMPORTANT 2 +++ |
702 | 709 | ||
703 | Because of the new paths, you will need | 710 | Because of the new paths, you will need |
704 | a new version of the KO/Pi alarm applet | 711 | a new version of the KO/Pi alarm applet |
705 | for Zaurus. | 712 | for Zaurus. |
706 | Use version >= 1.9.1 | 713 | Use version >= 1.9.1 |
707 | 714 | ||
708 | 2) | 715 | 2) |
709 | Now the QWhat'sThis Icon works for items | 716 | Now the QWhat'sThis Icon works for items |
710 | in the month view as well. | 717 | in the month view as well. |
711 | (See VERSION 1.7.8 Topic 1) ). | 718 | (See VERSION 1.7.8 Topic 1) ). |
712 | 3) | 719 | 3) |
713 | You can import birtsdays/anniversaries | 720 | You can import birtsdays/anniversaries |
714 | from KA/Pi into KO/Pi. | 721 | from KA/Pi into KO/Pi. |
715 | Choose menu File-Import birthdays. | 722 | Choose menu File-Import birthdays. |
716 | If you import twice, already imported items | 723 | If you import twice, already imported items |
717 | will not be imported again, if they | 724 | will not be imported again, if they |
718 | have not been changed in KO/Pi. | 725 | have not been changed in KO/Pi. |
719 | 4) | 726 | 4) |
720 | When syncing with sharp DTM, now a progress | 727 | When syncing with sharp DTM, now a progress |
721 | is shown, when the data is written back. | 728 | is shown, when the data is written back. |
722 | If there is much data in KO/Pi and no data | 729 | If there is much data in KO/Pi and no data |
723 | in DTM, that can take a long time. | 730 | in DTM, that can take a long time. |
724 | (But only for the first time ). | 731 | (But only for the first time ). |
725 | 5) | 732 | 5) |
726 | In the search dialog, you can search | 733 | In the search dialog, you can search |
727 | now for the name/email of an attendee | 734 | now for the name/email of an attendee |
728 | of an event/todo. | 735 | of an event/todo. |
729 | To get more space for displaying | 736 | To get more space for displaying |
730 | search results, the buttons | 737 | search results, the buttons |
731 | for "search" and "close" on the | 738 | for "search" and "close" on the |
732 | bottom are removed in the PDA version. | 739 | bottom are removed in the PDA version. |
733 | You have to click OK in the top right | 740 | You have to click OK in the top right |
734 | corner to do a search. | 741 | corner to do a search. |
735 | 6) | 742 | 6) |
736 | Now it is possible to disable the displaying | 743 | Now it is possible to disable the displaying |
737 | of todo items in the Allday part of the Agenda. | 744 | of todo items in the Allday part of the Agenda. |
738 | Choose Menu Action-Configure, | 745 | Choose Menu Action-Configure, |
739 | TAB Todo View, checkbox | 746 | TAB Todo View, checkbox |
740 | "Allday Agenda view shows todos" | 747 | "Allday Agenda view shows todos" |
741 | 7) | 748 | 7) |
742 | If FastLoad is enabled, now the settings and the | 749 | If FastLoad is enabled, now the settings and the |
743 | calendar data are saved, when KO/Pi is closed. | 750 | calendar data are saved, when KO/Pi is closed. |
744 | (If no Fastload is enabled, KO/Pi saves | 751 | (If no Fastload is enabled, KO/Pi saves |
745 | the data as well, of course) | 752 | the data as well, of course) |
746 | 8) | 753 | 8) |
747 | The Agenda View has a minimize-splitter now, | 754 | The Agenda View has a minimize-splitter now, |
748 | such that the height of the allday part can be | 755 | such that the height of the allday part can be |
749 | changed quickly. | 756 | changed quickly. |
750 | 757 | ||
751 | ********** VERSION 1.9.0 ************ | 758 | ********** VERSION 1.9.0 ************ |
752 | 1) | 759 | 1) |
753 | KO/Pi is now merged with the new microKDE from KA/Pi. | 760 | KO/Pi is now merged with the new microKDE from KA/Pi. |
754 | KO/Pi accesses now KA/Pi as the addressbook. | 761 | KO/Pi accesses now KA/Pi as the addressbook. |
755 | The other ddressbook-plugins are not working any longer. | 762 | The other ddressbook-plugins are not working any longer. |
756 | (It is planned, that later KA/Pi itself uses these plugins) | 763 | (It is planned, that later KA/Pi itself uses these plugins) |
757 | New versions of KO/Pi are only available | 764 | New versions of KO/Pi are only available |
758 | together with KA/Pi as the KDE-Pim/Pi package. | 765 | together with KA/Pi as the KDE-Pim/Pi package. |
759 | 2) | 766 | 2) |
760 | If you click on an attendee of a meeting in the | 767 | If you click on an attendee of a meeting in the |
761 | event viewer, a detailed summary of the | 768 | event viewer, a detailed summary of the |
762 | attendee is shown. | 769 | attendee is shown. |
763 | 3) | 770 | 3) |
764 | The place of the configuration file has changed. | 771 | The place of the configuration file has changed. |
765 | If you want to use your old KO/Pi config, copy | 772 | If you want to use your old KO/Pi config, copy |
766 | Applications/korganizer/config_korganizerrc | 773 | Applications/korganizer/config_korganizerrc |
767 | to | 774 | to |
768 | Applications/korganizer/config/korganizerrc | 775 | Applications/korganizer/config/korganizerrc |
769 | 776 | ||
770 | ********** VERSION 1.7.8 ************ | 777 | ********** VERSION 1.7.8 ************ |
771 | 1) | 778 | 1) |
772 | Now the QWhat'sThis ist working. | 779 | Now the QWhat'sThis ist working. |
773 | Enable the QWhat'sThis icon in the toolbar. | 780 | Enable the QWhat'sThis icon in the toolbar. |
774 | (You have to restart to reload the changed toolbar config). | 781 | (You have to restart to reload the changed toolbar config). |
775 | Now click on the QWhat'sThis Icon | 782 | Now click on the QWhat'sThis Icon |
776 | in the top right corner of KO/Pi. | 783 | in the top right corner of KO/Pi. |
777 | Then click on an item in the Agenda View: | 784 | Then click on an item in the Agenda View: |
778 | You will get a detailed display of the items content. | 785 | You will get a detailed display of the items content. |
779 | 2) | 786 | 2) |
780 | Some other very minor changes. | 787 | Some other very minor changes. |
781 | But I have forgotten the details ... | 788 | But I have forgotten the details ... |
782 | For that reason I start this log here: | 789 | For that reason I start this log here: |
783 | To document my changes, when I am doing it. | 790 | To document my changes, when I am doing it. |
784 | 791 | ||
785 | ********** VERSION 1.7.7 ************ | 792 | ********** VERSION 1.7.7 ************ |
786 | Stable Version of KO/Pi | 793 | Stable Version of KO/Pi |
diff --git a/kmicromail/libetpan/imap/mailimap_parser.c b/kmicromail/libetpan/imap/mailimap_parser.c index 1c2ecde..560e58a 100644 --- a/kmicromail/libetpan/imap/mailimap_parser.c +++ b/kmicromail/libetpan/imap/mailimap_parser.c | |||
@@ -866,3074 +866,3092 @@ static int mailimap_greater_parse(mailstream * fd, MMAPString * buffer, | |||
866 | size_t * index) | 866 | size_t * index) |
867 | { | 867 | { |
868 | return mailimap_unstrict_char_parse(fd, buffer, index, '>'); | 868 | return mailimap_unstrict_char_parse(fd, buffer, index, '>'); |
869 | } | 869 | } |
870 | 870 | ||
871 | static int mailimap_obracket_parse(mailstream * fd, MMAPString * buffer, | 871 | static int mailimap_obracket_parse(mailstream * fd, MMAPString * buffer, |
872 | size_t * index) | 872 | size_t * index) |
873 | { | 873 | { |
874 | return mailimap_unstrict_char_parse(fd, buffer, index, '['); | 874 | return mailimap_unstrict_char_parse(fd, buffer, index, '['); |
875 | } | 875 | } |
876 | 876 | ||
877 | static int mailimap_cbracket_parse(mailstream * fd, MMAPString * buffer, | 877 | static int mailimap_cbracket_parse(mailstream * fd, MMAPString * buffer, |
878 | size_t * index) | 878 | size_t * index) |
879 | { | 879 | { |
880 | return mailimap_unstrict_char_parse(fd, buffer, index, ']'); | 880 | return mailimap_unstrict_char_parse(fd, buffer, index, ']'); |
881 | } | 881 | } |
882 | 882 | ||
883 | static int mailimap_dquote_parse(mailstream * fd, MMAPString * buffer, | 883 | static int mailimap_dquote_parse(mailstream * fd, MMAPString * buffer, |
884 | size_t * index) | 884 | size_t * index) |
885 | { | 885 | { |
886 | return mailimap_char_parse(fd, buffer, index, '\"'); | 886 | return mailimap_char_parse(fd, buffer, index, '\"'); |
887 | } | 887 | } |
888 | 888 | ||
889 | static int mailimap_crlf_parse(mailstream * fd, MMAPString * buffer, | 889 | static int mailimap_crlf_parse(mailstream * fd, MMAPString * buffer, |
890 | size_t * index) | 890 | size_t * index) |
891 | { | 891 | { |
892 | size_t cur_token = * index; | 892 | size_t cur_token = * index; |
893 | 893 | ||
894 | #ifdef UNSTRICT_SYNTAX | 894 | #ifdef UNSTRICT_SYNTAX |
895 | mailimap_space_parse(fd, buffer, &cur_token); | 895 | mailimap_space_parse(fd, buffer, &cur_token); |
896 | #endif | 896 | #endif |
897 | 897 | ||
898 | if (mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "\r\n")) { | 898 | if (mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "\r\n")) { |
899 | * index = cur_token; | 899 | * index = cur_token; |
900 | return MAILIMAP_NO_ERROR; | 900 | return MAILIMAP_NO_ERROR; |
901 | } | 901 | } |
902 | 902 | ||
903 | #ifdef UNSTRICT_SYNTAX | 903 | #ifdef UNSTRICT_SYNTAX |
904 | else if (mailimap_unstrict_char_parse(fd, buffer, &cur_token, '\n')) { | 904 | else if (mailimap_unstrict_char_parse(fd, buffer, &cur_token, '\n')) { |
905 | * index = cur_token; | 905 | * index = cur_token; |
906 | return MAILIMAP_NO_ERROR; | 906 | return MAILIMAP_NO_ERROR; |
907 | } | 907 | } |
908 | #endif | 908 | #endif |
909 | 909 | ||
910 | else | 910 | else |
911 | return MAILIMAP_ERROR_PARSE; | 911 | return MAILIMAP_ERROR_PARSE; |
912 | } | 912 | } |
913 | 913 | ||
914 | typedef int mailimap_struct_parser(mailstream * fd, MMAPString * buffer, | 914 | typedef int mailimap_struct_parser(mailstream * fd, MMAPString * buffer, |
915 | size_t * index, void * result, | 915 | size_t * index, void * result, |
916 | size_t progr_rate, | 916 | size_t progr_rate, |
917 | progress_function * progr_fun); | 917 | progress_function * progr_fun); |
918 | typedef int mailimap_struct_destructor(void * result); | 918 | typedef int mailimap_struct_destructor(void * result); |
919 | 919 | ||
920 | 920 | ||
921 | static int | 921 | static int |
922 | mailimap_struct_multiple_parse(mailstream * fd, MMAPString * buffer, | 922 | mailimap_struct_multiple_parse(mailstream * fd, MMAPString * buffer, |
923 | size_t * index, clist ** result, | 923 | size_t * index, clist ** result, |
924 | mailimap_struct_parser * parser, | 924 | mailimap_struct_parser * parser, |
925 | mailimap_struct_destructor * destructor, | 925 | mailimap_struct_destructor * destructor, |
926 | size_t progr_rate, | 926 | size_t progr_rate, |
927 | progress_function * progr_fun) | 927 | progress_function * progr_fun) |
928 | { | 928 | { |
929 | clist * struct_list; | 929 | clist * struct_list; |
930 | size_t cur_token; | 930 | size_t cur_token; |
931 | void * value; | 931 | void * value; |
932 | int r; | 932 | int r; |
933 | int res; | 933 | int res; |
934 | 934 | ||
935 | cur_token = * index; | 935 | cur_token = * index; |
936 | 936 | ||
937 | r = parser(fd, buffer, &cur_token, &value, progr_rate, progr_fun); | 937 | r = parser(fd, buffer, &cur_token, &value, progr_rate, progr_fun); |
938 | if (r != MAILIMAP_NO_ERROR) { | 938 | if (r != MAILIMAP_NO_ERROR) { |
939 | res = r; | 939 | res = r; |
940 | goto err; | 940 | goto err; |
941 | } | 941 | } |
942 | 942 | ||
943 | struct_list = clist_new(); | 943 | struct_list = clist_new(); |
944 | if (struct_list == NULL) { | 944 | if (struct_list == NULL) { |
945 | destructor(value); | 945 | destructor(value); |
946 | res = MAILIMAP_ERROR_MEMORY; | 946 | res = MAILIMAP_ERROR_MEMORY; |
947 | goto err; | 947 | goto err; |
948 | } | 948 | } |
949 | 949 | ||
950 | r = clist_append(struct_list, value); | 950 | r = clist_append(struct_list, value); |
951 | if (r < 0) { | 951 | if (r < 0) { |
952 | destructor(value); | 952 | destructor(value); |
953 | res = MAILIMAP_ERROR_MEMORY; | 953 | res = MAILIMAP_ERROR_MEMORY; |
954 | goto free_list; | 954 | goto free_list; |
955 | } | 955 | } |
956 | 956 | ||
957 | while (1) { | 957 | while (1) { |
958 | r = parser(fd, buffer, &cur_token, &value, progr_rate, progr_fun); | 958 | r = parser(fd, buffer, &cur_token, &value, progr_rate, progr_fun); |
959 | if (r == MAILIMAP_ERROR_PARSE) | 959 | if (r == MAILIMAP_ERROR_PARSE) |
960 | break; | 960 | break; |
961 | if (r != MAILIMAP_NO_ERROR) { | 961 | if (r != MAILIMAP_NO_ERROR) { |
962 | res = r; | 962 | res = r; |
963 | goto free_list; | 963 | goto free_list; |
964 | } | 964 | } |
965 | 965 | ||
966 | r = clist_append(struct_list, value); | 966 | r = clist_append(struct_list, value); |
967 | if (r < 0) { | 967 | if (r < 0) { |
968 | destructor(value); | 968 | destructor(value); |
969 | res = MAILIMAP_ERROR_MEMORY; | 969 | res = MAILIMAP_ERROR_MEMORY; |
970 | goto free_list; | 970 | goto free_list; |
971 | } | 971 | } |
972 | } | 972 | } |
973 | 973 | ||
974 | * result = struct_list; | 974 | * result = struct_list; |
975 | * index = cur_token; | 975 | * index = cur_token; |
976 | 976 | ||
977 | return MAILIMAP_NO_ERROR; | 977 | return MAILIMAP_NO_ERROR; |
978 | 978 | ||
979 | free_list: | 979 | free_list: |
980 | clist_foreach(struct_list, (clist_func) destructor, NULL); | 980 | clist_foreach(struct_list, (clist_func) destructor, NULL); |
981 | clist_free(struct_list); | 981 | clist_free(struct_list); |
982 | err: | 982 | err: |
983 | return res; | 983 | return res; |
984 | } | 984 | } |
985 | 985 | ||
986 | static int | 986 | static int |
987 | mailimap_struct_list_parse(mailstream * fd, MMAPString * buffer, | 987 | mailimap_struct_list_parse(mailstream * fd, MMAPString * buffer, |
988 | size_t * index, clist ** result, | 988 | size_t * index, clist ** result, |
989 | char symbol, | 989 | char symbol, |
990 | mailimap_struct_parser * parser, | 990 | mailimap_struct_parser * parser, |
991 | mailimap_struct_destructor * destructor, | 991 | mailimap_struct_destructor * destructor, |
992 | size_t progr_rate, | 992 | size_t progr_rate, |
993 | progress_function * progr_fun) | 993 | progress_function * progr_fun) |
994 | { | 994 | { |
995 | clist * struct_list; | 995 | clist * struct_list; |
996 | size_t cur_token; | 996 | size_t cur_token; |
997 | void * value; | 997 | void * value; |
998 | size_t final_token; | 998 | size_t final_token; |
999 | int r; | 999 | int r; |
1000 | int res; | 1000 | int res; |
1001 | 1001 | ||
1002 | cur_token = * index; | 1002 | cur_token = * index; |
1003 | struct_list = NULL; | 1003 | struct_list = NULL; |
1004 | 1004 | ||
1005 | r = parser(fd, buffer, &cur_token, &value, progr_rate, progr_fun); | 1005 | r = parser(fd, buffer, &cur_token, &value, progr_rate, progr_fun); |
1006 | if (r != MAILIMAP_NO_ERROR) { | 1006 | if (r != MAILIMAP_NO_ERROR) { |
1007 | res = r; | 1007 | res = r; |
1008 | goto err; | 1008 | goto err; |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | struct_list = clist_new(); | 1011 | struct_list = clist_new(); |
1012 | if (struct_list == NULL) { | 1012 | if (struct_list == NULL) { |
1013 | destructor(value); | 1013 | destructor(value); |
1014 | res = MAILIMAP_ERROR_MEMORY; | 1014 | res = MAILIMAP_ERROR_MEMORY; |
1015 | goto err; | 1015 | goto err; |
1016 | } | 1016 | } |
1017 | 1017 | ||
1018 | r = clist_append(struct_list, value); | 1018 | r = clist_append(struct_list, value); |
1019 | if (r < 0) { | 1019 | if (r < 0) { |
1020 | destructor(value); | 1020 | destructor(value); |
1021 | res = MAILIMAP_ERROR_MEMORY; | 1021 | res = MAILIMAP_ERROR_MEMORY; |
1022 | goto free_list; | 1022 | goto free_list; |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | final_token = cur_token; | 1025 | final_token = cur_token; |
1026 | 1026 | ||
1027 | while (1) { | 1027 | while (1) { |
1028 | r = mailimap_unstrict_char_parse(fd, buffer, &cur_token, symbol); | 1028 | r = mailimap_unstrict_char_parse(fd, buffer, &cur_token, symbol); |
1029 | if (r == MAILIMAP_ERROR_PARSE) | 1029 | if (r == MAILIMAP_ERROR_PARSE) |
1030 | break; | 1030 | break; |
1031 | if (r != MAILIMAP_NO_ERROR) { | 1031 | if (r != MAILIMAP_NO_ERROR) { |
1032 | res = r; | 1032 | res = r; |
1033 | goto free_list; | 1033 | goto free_list; |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | r = parser(fd, buffer, &cur_token, &value, progr_rate, progr_fun); | 1036 | r = parser(fd, buffer, &cur_token, &value, progr_rate, progr_fun); |
1037 | if (r == MAILIMAP_ERROR_PARSE) | 1037 | if (r == MAILIMAP_ERROR_PARSE) |
1038 | break; | 1038 | break; |
1039 | 1039 | ||
1040 | if (r != MAILIMAP_NO_ERROR) { | 1040 | if (r != MAILIMAP_NO_ERROR) { |
1041 | res = r; | 1041 | res = r; |
1042 | goto free_list; | 1042 | goto free_list; |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | r = clist_append(struct_list, value); | 1045 | r = clist_append(struct_list, value); |
1046 | if (r < 0) { | 1046 | if (r < 0) { |
1047 | destructor(value); | 1047 | destructor(value); |
1048 | res = MAILIMAP_ERROR_MEMORY; | 1048 | res = MAILIMAP_ERROR_MEMORY; |
1049 | goto free_list; | 1049 | goto free_list; |
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | final_token = cur_token; | 1052 | final_token = cur_token; |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | * result = struct_list; | 1055 | * result = struct_list; |
1056 | * index = final_token; | 1056 | * index = final_token; |
1057 | 1057 | ||
1058 | return MAILIMAP_NO_ERROR; | 1058 | return MAILIMAP_NO_ERROR; |
1059 | 1059 | ||
1060 | free_list: | 1060 | free_list: |
1061 | clist_foreach(struct_list, (clist_func) destructor, NULL); | 1061 | clist_foreach(struct_list, (clist_func) destructor, NULL); |
1062 | clist_free(struct_list); | 1062 | clist_free(struct_list); |
1063 | err: | 1063 | err: |
1064 | return res; | 1064 | return res; |
1065 | } | 1065 | } |
1066 | 1066 | ||
1067 | static int | 1067 | static int |
1068 | mailimap_struct_spaced_list_parse(mailstream * fd, MMAPString * buffer, | 1068 | mailimap_struct_spaced_list_parse(mailstream * fd, MMAPString * buffer, |
1069 | size_t * index, clist ** result, | 1069 | size_t * index, clist ** result, |
1070 | mailimap_struct_parser * parser, | 1070 | mailimap_struct_parser * parser, |
1071 | mailimap_struct_destructor * destructor, | 1071 | mailimap_struct_destructor * destructor, |
1072 | size_t progr_rate, | 1072 | size_t progr_rate, |
1073 | progress_function * progr_fun) | 1073 | progress_function * progr_fun) |
1074 | { | 1074 | { |
1075 | return mailimap_struct_list_parse(fd, buffer, index, result, | 1075 | return mailimap_struct_list_parse(fd, buffer, index, result, |
1076 | ' ', parser, destructor, | 1076 | ' ', parser, destructor, |
1077 | progr_rate, progr_fun); | 1077 | progr_rate, progr_fun); |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | 1080 | ||
1081 | 1081 | ||
1082 | static int | 1082 | static int |
1083 | mailimap_custom_string_parse(mailstream * fd, MMAPString * buffer, | 1083 | mailimap_custom_string_parse(mailstream * fd, MMAPString * buffer, |
1084 | size_t * index, char ** result, | 1084 | size_t * index, char ** result, |
1085 | int (* is_custom_char)(char)) | 1085 | int (* is_custom_char)(char)) |
1086 | { | 1086 | { |
1087 | size_t begin; | 1087 | size_t begin; |
1088 | size_t end; | 1088 | size_t end; |
1089 | char * gstr; | 1089 | char * gstr; |
1090 | 1090 | ||
1091 | begin = * index; | 1091 | begin = * index; |
1092 | 1092 | ||
1093 | #ifdef UNSTRICT_SYNTAX | 1093 | #ifdef UNSTRICT_SYNTAX |
1094 | mailimap_space_parse(fd, buffer, &begin); | 1094 | mailimap_space_parse(fd, buffer, &begin); |
1095 | #endif | 1095 | #endif |
1096 | 1096 | ||
1097 | end = begin; | 1097 | end = begin; |
1098 | 1098 | ||
1099 | while (is_custom_char(buffer->str[end])) | 1099 | while (is_custom_char(buffer->str[end])) |
1100 | end ++; | 1100 | end ++; |
1101 | 1101 | ||
1102 | if (end != begin) { | 1102 | if (end != begin) { |
1103 | gstr = malloc(end - begin + 1); | 1103 | gstr = malloc(end - begin + 1); |
1104 | if (gstr == NULL) | 1104 | if (gstr == NULL) |
1105 | return MAILIMAP_ERROR_MEMORY; | 1105 | return MAILIMAP_ERROR_MEMORY; |
1106 | 1106 | ||
1107 | strncpy(gstr, buffer->str + begin, end - begin); | 1107 | strncpy(gstr, buffer->str + begin, end - begin); |
1108 | gstr[end - begin] = '\0'; | 1108 | gstr[end - begin] = '\0'; |
1109 | 1109 | ||
1110 | * index = end; | 1110 | * index = end; |
1111 | * result = gstr; | 1111 | * result = gstr; |
1112 | return MAILIMAP_NO_ERROR; | 1112 | return MAILIMAP_NO_ERROR; |
1113 | } | 1113 | } |
1114 | else | 1114 | else |
1115 | return MAILIMAP_ERROR_PARSE; | 1115 | return MAILIMAP_ERROR_PARSE; |
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | 1118 | ||
1119 | 1119 | ||
1120 | static int | 1120 | static int |
1121 | mailimap_nz_number_alloc_parse(mailstream * fd, MMAPString * buffer, | 1121 | mailimap_nz_number_alloc_parse(mailstream * fd, MMAPString * buffer, |
1122 | size_t * index, | 1122 | size_t * index, |
1123 | uint32_t ** result, | 1123 | uint32_t ** result, |
1124 | size_t progr_rate, | 1124 | size_t progr_rate, |
1125 | progress_function * progr_fun) | 1125 | progress_function * progr_fun) |
1126 | { | 1126 | { |
1127 | uint32_t number; | 1127 | uint32_t number; |
1128 | uint32_t * number_alloc; | 1128 | uint32_t * number_alloc; |
1129 | size_t cur_token; | 1129 | size_t cur_token; |
1130 | int r; | 1130 | int r; |
1131 | 1131 | ||
1132 | cur_token = * index; | 1132 | cur_token = * index; |
1133 | 1133 | ||
1134 | r = mailimap_nz_number_parse(fd, buffer, &cur_token, &number); | 1134 | r = mailimap_nz_number_parse(fd, buffer, &cur_token, &number); |
1135 | if (r != MAILIMAP_NO_ERROR) | 1135 | if (r != MAILIMAP_NO_ERROR) |
1136 | return r; | 1136 | return r; |
1137 | 1137 | ||
1138 | number_alloc = mailimap_number_alloc_new(number); | 1138 | number_alloc = mailimap_number_alloc_new(number); |
1139 | if (number_alloc == NULL) | 1139 | if (number_alloc == NULL) |
1140 | return MAILIMAP_ERROR_MEMORY; | 1140 | return MAILIMAP_ERROR_MEMORY; |
1141 | 1141 | ||
1142 | * index = cur_token; | 1142 | * index = cur_token; |
1143 | * result = number_alloc; | 1143 | * result = number_alloc; |
1144 | 1144 | ||
1145 | return MAILIMAP_NO_ERROR; | 1145 | return MAILIMAP_NO_ERROR; |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | 1148 | ||
1149 | static int is_ctl(char ch) | 1149 | static int is_ctl(char ch) |
1150 | { | 1150 | { |
1151 | unsigned char uch = (unsigned char) ch; | 1151 | unsigned char uch = (unsigned char) ch; |
1152 | 1152 | ||
1153 | return (uch <= 0x1F); | 1153 | return (uch <= 0x1F); |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | static int is_char(char ch) | 1156 | static int is_char(char ch) |
1157 | { | 1157 | { |
1158 | #ifdef UNSTRICT_SYNTAX | 1158 | #ifdef UNSTRICT_SYNTAX |
1159 | return (ch != 0); | 1159 | return (ch != 0); |
1160 | #else | 1160 | #else |
1161 | unsigned char uch = ch; | 1161 | unsigned char uch = ch; |
1162 | 1162 | ||
1163 | return (uch >= 0x01) && (uch <= 0x7f); | 1163 | return (uch >= 0x01) && (uch <= 0x7f); |
1164 | #endif | 1164 | #endif |
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | static int is_alpha(char ch) | 1167 | static int is_alpha(char ch) |
1168 | { | 1168 | { |
1169 | return ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && (ch <= 'z'))); | 1169 | return ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && (ch <= 'z'))); |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | static int is_digit(char ch) | 1172 | static int is_digit(char ch) |
1173 | { | 1173 | { |
1174 | return (ch >= '0') && (ch <= '9'); | 1174 | return (ch >= '0') && (ch <= '9'); |
1175 | } | 1175 | } |
1176 | 1176 | ||
1177 | static int mailimap_digit_parse(mailstream * fd, MMAPString * buffer, | 1177 | static int mailimap_digit_parse(mailstream * fd, MMAPString * buffer, |
1178 | size_t * index, int * result) | 1178 | size_t * index, int * result) |
1179 | { | 1179 | { |
1180 | size_t cur_token; | 1180 | size_t cur_token; |
1181 | 1181 | ||
1182 | cur_token = * index; | 1182 | cur_token = * index; |
1183 | 1183 | ||
1184 | if (is_digit(buffer->str[cur_token])) { | 1184 | if (is_digit(buffer->str[cur_token])) { |
1185 | * result = buffer->str[cur_token] - '0'; | 1185 | * result = buffer->str[cur_token] - '0'; |
1186 | cur_token ++; | 1186 | cur_token ++; |
1187 | * index = cur_token; | 1187 | * index = cur_token; |
1188 | return MAILIMAP_NO_ERROR; | 1188 | return MAILIMAP_NO_ERROR; |
1189 | } | 1189 | } |
1190 | else | 1190 | else |
1191 | return MAILIMAP_ERROR_PARSE; | 1191 | return MAILIMAP_ERROR_PARSE; |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | 1194 | ||
1195 | /* ******************** parser **************************** */ | 1195 | /* ******************** parser **************************** */ |
1196 | 1196 | ||
1197 | /* | 1197 | /* |
1198 | address = "(" addr-name SP addr-adl SP addr-mailbox SP | 1198 | address = "(" addr-name SP addr-adl SP addr-mailbox SP |
1199 | addr-host ")" | 1199 | addr-host ")" |
1200 | */ | 1200 | */ |
1201 | 1201 | ||
1202 | static int mailimap_address_parse(mailstream * fd, MMAPString * buffer, | 1202 | static int mailimap_address_parse(mailstream * fd, MMAPString * buffer, |
1203 | size_t * index, | 1203 | size_t * index, |
1204 | struct mailimap_address ** result, | 1204 | struct mailimap_address ** result, |
1205 | size_t progr_rate, | 1205 | size_t progr_rate, |
1206 | progress_function * progr_fun) | 1206 | progress_function * progr_fun) |
1207 | { | 1207 | { |
1208 | size_t cur_token; | 1208 | size_t cur_token; |
1209 | char * addr_name; | 1209 | char * addr_name; |
1210 | char * addr_adl; | 1210 | char * addr_adl; |
1211 | char * addr_mailbox; | 1211 | char * addr_mailbox; |
1212 | char * addr_host; | 1212 | char * addr_host; |
1213 | struct mailimap_address * addr; | 1213 | struct mailimap_address * addr; |
1214 | int r; | 1214 | int r; |
1215 | int res; | 1215 | int res; |
1216 | 1216 | ||
1217 | cur_token = * index; | 1217 | cur_token = * index; |
1218 | 1218 | ||
1219 | addr_name = NULL; | 1219 | addr_name = NULL; |
1220 | addr_adl = NULL; | 1220 | addr_adl = NULL; |
1221 | addr_mailbox = NULL; | 1221 | addr_mailbox = NULL; |
1222 | addr_host = NULL; | 1222 | addr_host = NULL; |
1223 | 1223 | ||
1224 | r = mailimap_oparenth_parse(fd, buffer, &cur_token); | 1224 | r = mailimap_oparenth_parse(fd, buffer, &cur_token); |
1225 | if (r != MAILIMAP_NO_ERROR) { | 1225 | if (r != MAILIMAP_NO_ERROR) { |
1226 | res = r; | 1226 | res = r; |
1227 | goto err; | 1227 | goto err; |
1228 | } | 1228 | } |
1229 | 1229 | ||
1230 | r = mailimap_addr_name_parse(fd, buffer, &cur_token, &addr_name, | 1230 | r = mailimap_addr_name_parse(fd, buffer, &cur_token, &addr_name, |
1231 | progr_rate, progr_fun); | 1231 | progr_rate, progr_fun); |
1232 | if (r != MAILIMAP_NO_ERROR) { | 1232 | if (r != MAILIMAP_NO_ERROR) { |
1233 | res = r; | 1233 | res = r; |
1234 | goto err; | 1234 | goto err; |
1235 | } | 1235 | } |
1236 | 1236 | ||
1237 | r = mailimap_space_parse(fd, buffer, &cur_token); | 1237 | r = mailimap_space_parse(fd, buffer, &cur_token); |
1238 | if (r != MAILIMAP_NO_ERROR) { | 1238 | if (r != MAILIMAP_NO_ERROR) { |
1239 | res = r; | 1239 | res = r; |
1240 | goto addr_name_free; | 1240 | goto addr_name_free; |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | r = mailimap_addr_adl_parse(fd, buffer, &cur_token, &addr_adl, | 1243 | r = mailimap_addr_adl_parse(fd, buffer, &cur_token, &addr_adl, |
1244 | progr_rate, progr_fun); | 1244 | progr_rate, progr_fun); |
1245 | if (r != MAILIMAP_NO_ERROR) { | 1245 | if (r != MAILIMAP_NO_ERROR) { |
1246 | res = r; | 1246 | res = r; |
1247 | goto addr_name_free; | 1247 | goto addr_name_free; |
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | r = mailimap_space_parse(fd, buffer, &cur_token); | 1250 | r = mailimap_space_parse(fd, buffer, &cur_token); |
1251 | if (r != MAILIMAP_NO_ERROR) { | 1251 | if (r != MAILIMAP_NO_ERROR) { |
1252 | res = r; | 1252 | res = r; |
1253 | goto addr_adl_free; | 1253 | goto addr_adl_free; |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | r = mailimap_addr_mailbox_parse(fd, buffer, &cur_token, &addr_mailbox, | 1256 | r = mailimap_addr_mailbox_parse(fd, buffer, &cur_token, &addr_mailbox, |
1257 | progr_rate, progr_fun); | 1257 | progr_rate, progr_fun); |
1258 | if (r != MAILIMAP_NO_ERROR) { | 1258 | if (r != MAILIMAP_NO_ERROR) { |
1259 | res = r; | 1259 | res = r; |
1260 | goto addr_adl_free; | 1260 | goto addr_adl_free; |
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | r = mailimap_space_parse(fd, buffer, &cur_token); | 1263 | r = mailimap_space_parse(fd, buffer, &cur_token); |
1264 | if (r != MAILIMAP_NO_ERROR) { | 1264 | if (r != MAILIMAP_NO_ERROR) { |
1265 | res = r; | 1265 | res = r; |
1266 | goto addr_mailbox_free; | 1266 | goto addr_mailbox_free; |
1267 | } | 1267 | } |
1268 | 1268 | ||
1269 | r = mailimap_addr_host_parse(fd, buffer, &cur_token, &addr_host, | 1269 | r = mailimap_addr_host_parse(fd, buffer, &cur_token, &addr_host, |
1270 | progr_rate, progr_fun); | 1270 | progr_rate, progr_fun); |
1271 | if (r != MAILIMAP_NO_ERROR) { | 1271 | if (r != MAILIMAP_NO_ERROR) { |
1272 | res = r; | 1272 | res = r; |
1273 | goto addr_mailbox_free; | 1273 | goto addr_mailbox_free; |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | r = mailimap_cparenth_parse(fd, buffer, &cur_token); | 1276 | r = mailimap_cparenth_parse(fd, buffer, &cur_token); |
1277 | if (r != MAILIMAP_NO_ERROR) { | 1277 | if (r != MAILIMAP_NO_ERROR) { |
1278 | res = r; | 1278 | res = r; |
1279 | goto addr_host_free; | 1279 | goto addr_host_free; |
1280 | } | 1280 | } |
1281 | 1281 | ||
1282 | addr = mailimap_address_new(addr_name, addr_adl, addr_mailbox, addr_host); | 1282 | addr = mailimap_address_new(addr_name, addr_adl, addr_mailbox, addr_host); |
1283 | 1283 | ||
1284 | if (addr == NULL) { | 1284 | if (addr == NULL) { |
1285 | res = MAILIMAP_ERROR_MEMORY; | 1285 | res = MAILIMAP_ERROR_MEMORY; |
1286 | goto addr_host_free; | 1286 | goto addr_host_free; |
1287 | } | 1287 | } |
1288 | 1288 | ||
1289 | * result = addr; | 1289 | * result = addr; |
1290 | * index = cur_token; | 1290 | * index = cur_token; |
1291 | 1291 | ||
1292 | return MAILIMAP_NO_ERROR; | 1292 | return MAILIMAP_NO_ERROR; |
1293 | 1293 | ||
1294 | addr_host_free: | 1294 | addr_host_free: |
1295 | mailimap_addr_host_free(addr_host); | 1295 | mailimap_addr_host_free(addr_host); |
1296 | addr_mailbox_free: | 1296 | addr_mailbox_free: |
1297 | mailimap_addr_mailbox_free(addr_mailbox); | 1297 | mailimap_addr_mailbox_free(addr_mailbox); |
1298 | addr_adl_free: | 1298 | addr_adl_free: |
1299 | mailimap_addr_adl_free(addr_adl); | 1299 | mailimap_addr_adl_free(addr_adl); |
1300 | addr_name_free: | 1300 | addr_name_free: |
1301 | mailimap_addr_name_free(addr_name); | 1301 | mailimap_addr_name_free(addr_name); |
1302 | err: | 1302 | err: |
1303 | return res; | 1303 | return res; |
1304 | } | 1304 | } |
1305 | 1305 | ||
1306 | /* | 1306 | /* |
1307 | addr-adl = nstring | 1307 | addr-adl = nstring |
1308 | ; Holds route from [RFC-822] route-addr if | 1308 | ; Holds route from [RFC-822] route-addr if |
1309 | ; non-NIL | 1309 | ; non-NIL |
1310 | */ | 1310 | */ |
1311 | 1311 | ||
1312 | static int mailimap_addr_adl_parse(mailstream * fd, MMAPString * buffer, | 1312 | static int mailimap_addr_adl_parse(mailstream * fd, MMAPString * buffer, |
1313 | size_t * index, char ** result, | 1313 | size_t * index, char ** result, |
1314 | size_t progr_rate, | 1314 | size_t progr_rate, |
1315 | progress_function * progr_fun) | 1315 | progress_function * progr_fun) |
1316 | { | 1316 | { |
1317 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, | 1317 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, |
1318 | progr_rate, progr_fun); | 1318 | progr_rate, progr_fun); |
1319 | } | 1319 | } |
1320 | 1320 | ||
1321 | /* | 1321 | /* |
1322 | addr-host = nstring | 1322 | addr-host = nstring |
1323 | ; NIL indicates [RFC-822] group syntax. | 1323 | ; NIL indicates [RFC-822] group syntax. |
1324 | ; Otherwise, holds [RFC-822] domain name | 1324 | ; Otherwise, holds [RFC-822] domain name |
1325 | */ | 1325 | */ |
1326 | 1326 | ||
1327 | static int mailimap_addr_host_parse(mailstream * fd, MMAPString * buffer, | 1327 | static int mailimap_addr_host_parse(mailstream * fd, MMAPString * buffer, |
1328 | size_t * index, char ** result, | 1328 | size_t * index, char ** result, |
1329 | size_t progr_rate, | 1329 | size_t progr_rate, |
1330 | progress_function * progr_fun) | 1330 | progress_function * progr_fun) |
1331 | { | 1331 | { |
1332 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, | 1332 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, |
1333 | progr_rate, progr_fun); | 1333 | progr_rate, progr_fun); |
1334 | } | 1334 | } |
1335 | 1335 | ||
1336 | /* | 1336 | /* |
1337 | addr-mailbox = nstring | 1337 | addr-mailbox = nstring |
1338 | ; NIL indicates end of [RFC-822] group; if | 1338 | ; NIL indicates end of [RFC-822] group; if |
1339 | ; non-NIL and addr-host is NIL, holds | 1339 | ; non-NIL and addr-host is NIL, holds |
1340 | ; [RFC-822] group name. | 1340 | ; [RFC-822] group name. |
1341 | ; Otherwise, holds [RFC-822] local-part | 1341 | ; Otherwise, holds [RFC-822] local-part |
1342 | ; after removing [RFC-822] quoting | 1342 | ; after removing [RFC-822] quoting |
1343 | */ | 1343 | */ |
1344 | 1344 | ||
1345 | static int mailimap_addr_mailbox_parse(mailstream * fd, MMAPString * buffer, | 1345 | static int mailimap_addr_mailbox_parse(mailstream * fd, MMAPString * buffer, |
1346 | size_t * index, char ** result, | 1346 | size_t * index, char ** result, |
1347 | size_t progr_rate, | 1347 | size_t progr_rate, |
1348 | progress_function * progr_fun) | 1348 | progress_function * progr_fun) |
1349 | { | 1349 | { |
1350 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, | 1350 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, |
1351 | progr_rate, progr_fun); | 1351 | progr_rate, progr_fun); |
1352 | } | 1352 | } |
1353 | 1353 | ||
1354 | 1354 | ||
1355 | /* | 1355 | /* |
1356 | addr-name = nstring | 1356 | addr-name = nstring |
1357 | ; If non-NIL, holds phrase from [RFC-822] | 1357 | ; If non-NIL, holds phrase from [RFC-822] |
1358 | ; mailbox after removing [RFC-822] quoting | 1358 | ; mailbox after removing [RFC-822] quoting |
1359 | */ | 1359 | */ |
1360 | 1360 | ||
1361 | static int mailimap_addr_name_parse(mailstream * fd, MMAPString * buffer, | 1361 | static int mailimap_addr_name_parse(mailstream * fd, MMAPString * buffer, |
1362 | size_t * index, char ** result, | 1362 | size_t * index, char ** result, |
1363 | size_t progr_rate, | 1363 | size_t progr_rate, |
1364 | progress_function * progr_fun) | 1364 | progress_function * progr_fun) |
1365 | { | 1365 | { |
1366 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, | 1366 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, |
1367 | progr_rate, progr_fun); | 1367 | progr_rate, progr_fun); |
1368 | } | 1368 | } |
1369 | 1369 | ||
1370 | 1370 | ||
1371 | /* | 1371 | /* |
1372 | NOT IMPLEMENTED | 1372 | NOT IMPLEMENTED |
1373 | append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP | 1373 | append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP |
1374 | literal | 1374 | literal |
1375 | */ | 1375 | */ |
1376 | 1376 | ||
1377 | /* | 1377 | /* |
1378 | astring = 1*ASTRING-CHAR / string | 1378 | astring = 1*ASTRING-CHAR / string |
1379 | */ | 1379 | */ |
1380 | 1380 | ||
1381 | static int is_astring_char(char ch); | 1381 | static int is_astring_char(char ch); |
1382 | 1382 | ||
1383 | static int | 1383 | static int |
1384 | mailimap_atom_astring_parse(mailstream * fd, MMAPString * buffer, | 1384 | mailimap_atom_astring_parse(mailstream * fd, MMAPString * buffer, |
1385 | size_t * index, char ** result, | 1385 | size_t * index, char ** result, |
1386 | size_t progr_rate, | 1386 | size_t progr_rate, |
1387 | progress_function * progr_fun) | 1387 | progress_function * progr_fun) |
1388 | { | 1388 | { |
1389 | return mailimap_custom_string_parse(fd, buffer, index, result, | 1389 | return mailimap_custom_string_parse(fd, buffer, index, result, |
1390 | is_astring_char); | 1390 | is_astring_char); |
1391 | } | 1391 | } |
1392 | 1392 | ||
1393 | static int | 1393 | static int |
1394 | mailimap_astring_parse(mailstream * fd, MMAPString * buffer, | 1394 | mailimap_astring_parse(mailstream * fd, MMAPString * buffer, |
1395 | size_t * index, | 1395 | size_t * index, |
1396 | char ** result, | 1396 | char ** result, |
1397 | size_t progr_rate, | 1397 | size_t progr_rate, |
1398 | progress_function * progr_fun) | 1398 | progress_function * progr_fun) |
1399 | { | 1399 | { |
1400 | size_t cur_token; | 1400 | size_t cur_token; |
1401 | char * astring; | 1401 | char * astring; |
1402 | int r; | 1402 | int r; |
1403 | 1403 | ||
1404 | cur_token = * index; | 1404 | cur_token = * index; |
1405 | 1405 | ||
1406 | r = mailimap_atom_astring_parse(fd, buffer, &cur_token, &astring, | 1406 | r = mailimap_atom_astring_parse(fd, buffer, &cur_token, &astring, |
1407 | progr_rate, progr_fun); | 1407 | progr_rate, progr_fun); |
1408 | switch (r) { | 1408 | switch (r) { |
1409 | case MAILIMAP_NO_ERROR: | 1409 | case MAILIMAP_NO_ERROR: |
1410 | break; | 1410 | break; |
1411 | 1411 | ||
1412 | case MAILIMAP_ERROR_PARSE: | 1412 | case MAILIMAP_ERROR_PARSE: |
1413 | r = mailimap_string_parse(fd, buffer, &cur_token, &astring, NULL, | 1413 | r = mailimap_string_parse(fd, buffer, &cur_token, &astring, NULL, |
1414 | progr_rate, progr_fun); | 1414 | progr_rate, progr_fun); |
1415 | if (r != MAILIMAP_NO_ERROR) | 1415 | if (r != MAILIMAP_NO_ERROR) |
1416 | return r; | 1416 | return r; |
1417 | break; | 1417 | break; |
1418 | 1418 | ||
1419 | default: | 1419 | default: |
1420 | return r; | 1420 | return r; |
1421 | } | 1421 | } |
1422 | 1422 | ||
1423 | * result = astring; | 1423 | * result = astring; |
1424 | * index = cur_token; | 1424 | * index = cur_token; |
1425 | 1425 | ||
1426 | return MAILIMAP_NO_ERROR; | 1426 | return MAILIMAP_NO_ERROR; |
1427 | } | 1427 | } |
1428 | 1428 | ||
1429 | /* | 1429 | /* |
1430 | ASTRING-CHAR = ATOM-CHAR / resp-specials | 1430 | ASTRING-CHAR = ATOM-CHAR / resp-specials |
1431 | */ | 1431 | */ |
1432 | 1432 | ||
1433 | static int is_atom_char(char ch); | 1433 | static int is_atom_char(char ch); |
1434 | static int is_resp_specials(char ch); | 1434 | static int is_resp_specials(char ch); |
1435 | 1435 | ||
1436 | static int is_astring_char(char ch) | 1436 | static int is_astring_char(char ch) |
1437 | { | 1437 | { |
1438 | if (is_atom_char(ch)) | 1438 | if (is_atom_char(ch)) |
1439 | return TRUE; | 1439 | return TRUE; |
1440 | if (is_resp_specials(ch)) | 1440 | if (is_resp_specials(ch)) |
1441 | return TRUE; | 1441 | return TRUE; |
1442 | return FALSE; | 1442 | return FALSE; |
1443 | } | 1443 | } |
1444 | 1444 | ||
1445 | /* | 1445 | /* |
1446 | atom = 1*ATOM-CHAR | 1446 | atom = 1*ATOM-CHAR |
1447 | */ | 1447 | */ |
1448 | 1448 | ||
1449 | static int mailimap_atom_parse(mailstream * fd, MMAPString * buffer, | 1449 | static int mailimap_atom_parse(mailstream * fd, MMAPString * buffer, |
1450 | size_t * index, char ** result, | 1450 | size_t * index, char ** result, |
1451 | size_t progr_rate, | 1451 | size_t progr_rate, |
1452 | progress_function * progr_fun) | 1452 | progress_function * progr_fun) |
1453 | { | 1453 | { |
1454 | return mailimap_custom_string_parse(fd, buffer, index, result, | 1454 | return mailimap_custom_string_parse(fd, buffer, index, result, |
1455 | is_atom_char); | 1455 | is_atom_char); |
1456 | } | 1456 | } |
1457 | 1457 | ||
1458 | /* | 1458 | /* |
1459 | ATOM-CHAR = <any CHAR except atom-specials> | 1459 | ATOM-CHAR = <any CHAR except atom-specials> |
1460 | */ | 1460 | */ |
1461 | 1461 | ||
1462 | static int is_atom_specials(char ch); | 1462 | static int is_atom_specials(char ch); |
1463 | 1463 | ||
1464 | static int is_atom_char(char ch) | 1464 | static int is_atom_char(char ch) |
1465 | { | 1465 | { |
1466 | if (is_atom_specials(ch)) | 1466 | if (is_atom_specials(ch)) |
1467 | return FALSE; | 1467 | return FALSE; |
1468 | 1468 | ||
1469 | return is_char(ch); | 1469 | return is_char(ch); |
1470 | } | 1470 | } |
1471 | 1471 | ||
1472 | /* | 1472 | /* |
1473 | atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / | 1473 | atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / |
1474 | quoted-specials / resp-specials | 1474 | quoted-specials / resp-specials |
1475 | 1475 | ||
1476 | no "}" because there is no need (Mark Crispin) | 1476 | no "}" because there is no need (Mark Crispin) |
1477 | */ | 1477 | */ |
1478 | 1478 | ||
1479 | static int is_quoted_specials(char ch); | 1479 | static int is_quoted_specials(char ch); |
1480 | static int is_list_wildcards(char ch); | 1480 | static int is_list_wildcards(char ch); |
1481 | 1481 | ||
1482 | static int is_atom_specials(char ch) | 1482 | static int is_atom_specials(char ch) |
1483 | { | 1483 | { |
1484 | switch (ch) { | 1484 | switch (ch) { |
1485 | case '(': | 1485 | case '(': |
1486 | case ')': | 1486 | case ')': |
1487 | case '{': | 1487 | case '{': |
1488 | case ' ': | 1488 | case ' ': |
1489 | return TRUE; | 1489 | return TRUE; |
1490 | }; | 1490 | }; |
1491 | if (is_ctl(ch)) | 1491 | if (is_ctl(ch)) |
1492 | return TRUE; | 1492 | return TRUE; |
1493 | if (is_list_wildcards(ch)) | 1493 | if (is_list_wildcards(ch)) |
1494 | return TRUE; | 1494 | return TRUE; |
1495 | if (is_resp_specials(ch)) | 1495 | if (is_resp_specials(ch)) |
1496 | return TRUE; | 1496 | return TRUE; |
1497 | 1497 | ||
1498 | return is_quoted_specials(ch); | 1498 | return is_quoted_specials(ch); |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | /* | 1501 | /* |
1502 | NOT IMPLEMENTED | 1502 | NOT IMPLEMENTED |
1503 | authenticate = "AUTHENTICATE" SP auth-type *(CRLF base64) | 1503 | authenticate = "AUTHENTICATE" SP auth-type *(CRLF base64) |
1504 | */ | 1504 | */ |
1505 | 1505 | ||
1506 | /* | 1506 | /* |
1507 | auth-type = atom | 1507 | auth-type = atom |
1508 | ; Defined by [SASL] | 1508 | ; Defined by [SASL] |
1509 | */ | 1509 | */ |
1510 | 1510 | ||
1511 | static int mailimap_auth_type_parse(mailstream * fd, MMAPString * buffer, | 1511 | static int mailimap_auth_type_parse(mailstream * fd, MMAPString * buffer, |
1512 | size_t * index, char ** result, | 1512 | size_t * index, char ** result, |
1513 | size_t progr_rate, | 1513 | size_t progr_rate, |
1514 | progress_function * progr_fun) | 1514 | progress_function * progr_fun) |
1515 | { | 1515 | { |
1516 | return mailimap_atom_parse(fd, buffer, index, result, | 1516 | return mailimap_atom_parse(fd, buffer, index, result, |
1517 | progr_rate, progr_fun); | 1517 | progr_rate, progr_fun); |
1518 | } | 1518 | } |
1519 | 1519 | ||
1520 | /* | 1520 | /* |
1521 | base64 = *(4base64-char) [base64-terminal] | 1521 | base64 = *(4base64-char) [base64-terminal] |
1522 | */ | 1522 | */ |
1523 | 1523 | ||
1524 | static int is_base64_4char(char * str); | 1524 | static int is_base64_4char(char * str); |
1525 | static int is_base64_terminal(char * str); | 1525 | static int is_base64_terminal(char * str); |
1526 | 1526 | ||
1527 | static int mailimap_base64_parse(mailstream * fd, MMAPString * buffer, | 1527 | static int mailimap_base64_parse(mailstream * fd, MMAPString * buffer, |
1528 | size_t * index, char ** result, | 1528 | size_t * index, char ** result, |
1529 | size_t progr_rate, | 1529 | size_t progr_rate, |
1530 | progress_function * progr_fun) | 1530 | progress_function * progr_fun) |
1531 | { | 1531 | { |
1532 | size_t begin; | 1532 | size_t begin; |
1533 | size_t end; | 1533 | size_t end; |
1534 | char * gstr; | 1534 | char * gstr; |
1535 | 1535 | ||
1536 | begin = * index; | 1536 | begin = * index; |
1537 | end = begin; | 1537 | end = begin; |
1538 | 1538 | ||
1539 | while (is_base64_4char(buffer->str + end)) | 1539 | while (is_base64_4char(buffer->str + end)) |
1540 | end += 4; | 1540 | end += 4; |
1541 | if (is_base64_terminal(buffer->str + end)) | 1541 | if (is_base64_terminal(buffer->str + end)) |
1542 | end += 4; | 1542 | end += 4; |
1543 | else | 1543 | else |
1544 | return MAILIMAP_ERROR_PARSE; | 1544 | return MAILIMAP_ERROR_PARSE; |
1545 | 1545 | ||
1546 | gstr = malloc(end - begin + 1); | 1546 | gstr = malloc(end - begin + 1); |
1547 | if (gstr == NULL) | 1547 | if (gstr == NULL) |
1548 | return MAILIMAP_ERROR_MEMORY; | 1548 | return MAILIMAP_ERROR_MEMORY; |
1549 | strncpy(gstr, buffer->str + begin, end - begin); | 1549 | strncpy(gstr, buffer->str + begin, end - begin); |
1550 | gstr[end - begin] = '\0'; | 1550 | gstr[end - begin] = '\0'; |
1551 | 1551 | ||
1552 | * result = gstr; | 1552 | * result = gstr; |
1553 | * index = end; | 1553 | * index = end; |
1554 | 1554 | ||
1555 | return MAILIMAP_NO_ERROR; | 1555 | return MAILIMAP_NO_ERROR; |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | /* | 1558 | /* |
1559 | base64-char = ALPHA / DIGIT / "+" / "/" | 1559 | base64-char = ALPHA / DIGIT / "+" / "/" |
1560 | ; Case-sensitive | 1560 | ; Case-sensitive |
1561 | */ | 1561 | */ |
1562 | 1562 | ||
1563 | static int is_base64_char(char ch) | 1563 | static int is_base64_char(char ch) |
1564 | { | 1564 | { |
1565 | return (is_alpha(ch) || is_digit(ch) || ch == '+' || ch == '/'); | 1565 | return (is_alpha(ch) || is_digit(ch) || ch == '+' || ch == '/'); |
1566 | } | 1566 | } |
1567 | 1567 | ||
1568 | static int is_base64_4char(char * str) | 1568 | static int is_base64_4char(char * str) |
1569 | { | 1569 | { |
1570 | size_t i; | 1570 | size_t i; |
1571 | 1571 | ||
1572 | for (i = 0 ; i < 4 ; i++) | 1572 | for (i = 0 ; i < 4 ; i++) |
1573 | if (!is_base64_char(str[i])) | 1573 | if (!is_base64_char(str[i])) |
1574 | return FALSE; | 1574 | return FALSE; |
1575 | return TRUE; | 1575 | return TRUE; |
1576 | } | 1576 | } |
1577 | 1577 | ||
1578 | /* | 1578 | /* |
1579 | base64-terminal = (2base64-char "==") / (3base64-char "=") | 1579 | base64-terminal = (2base64-char "==") / (3base64-char "=") |
1580 | */ | 1580 | */ |
1581 | 1581 | ||
1582 | static int is_base64_terminal(char * str) | 1582 | static int is_base64_terminal(char * str) |
1583 | { | 1583 | { |
1584 | if (str[0] == 0) | 1584 | if (str[0] == 0) |
1585 | return FALSE; | 1585 | return FALSE; |
1586 | if (str[1] == 0) | 1586 | if (str[1] == 0) |
1587 | return FALSE; | 1587 | return FALSE; |
1588 | if (str[2] == 0) | 1588 | if (str[2] == 0) |
1589 | return FALSE; | 1589 | return FALSE; |
1590 | if (str[3] == 0) | 1590 | if (str[3] == 0) |
1591 | return FALSE; | 1591 | return FALSE; |
1592 | 1592 | ||
1593 | if (is_base64_char(str[0]) || is_base64_char(str[1]) | 1593 | if (is_base64_char(str[0]) || is_base64_char(str[1]) |
1594 | || str[2] == '=' || str[3] == '=') | 1594 | || str[2] == '=' || str[3] == '=') |
1595 | return TRUE; | 1595 | return TRUE; |
1596 | if (is_base64_char(str[0]) || is_base64_char(str[1]) | 1596 | if (is_base64_char(str[0]) || is_base64_char(str[1]) |
1597 | || is_base64_char(str[2]) || str[3] == '=') | 1597 | || is_base64_char(str[2]) || str[3] == '=') |
1598 | return TRUE; | 1598 | return TRUE; |
1599 | return FALSE; | 1599 | return FALSE; |
1600 | } | 1600 | } |
1601 | 1601 | ||
1602 | 1602 | ||
1603 | /* | 1603 | /* |
1604 | body = "(" (body-type-1part / body-type-mpart) ")" | 1604 | body = "(" (body-type-1part / body-type-mpart) ")" |
1605 | */ | 1605 | */ |
1606 | 1606 | ||
1607 | static int mailimap_body_parse(mailstream * fd, MMAPString * buffer, | 1607 | static int mailimap_body_parse(mailstream * fd, MMAPString * buffer, |
1608 | size_t * index, | 1608 | size_t * index, |
1609 | struct mailimap_body ** result, | 1609 | struct mailimap_body ** result, |
1610 | size_t progr_rate, | 1610 | size_t progr_rate, |
1611 | progress_function * progr_fun) | 1611 | progress_function * progr_fun) |
1612 | { | 1612 | { |
1613 | struct mailimap_body_type_1part * body_type_1part; | 1613 | struct mailimap_body_type_1part * body_type_1part; |
1614 | struct mailimap_body_type_mpart * body_type_mpart; | 1614 | struct mailimap_body_type_mpart * body_type_mpart; |
1615 | struct mailimap_body * body; | 1615 | struct mailimap_body * body; |
1616 | size_t cur_token; | 1616 | size_t cur_token; |
1617 | int type; | 1617 | int type; |
1618 | int r; | 1618 | int r; |
1619 | int res; | 1619 | int res; |
1620 | 1620 | ||
1621 | cur_token = * index; | 1621 | cur_token = * index; |
1622 | 1622 | ||
1623 | body_type_1part = NULL; | 1623 | body_type_1part = NULL; |
1624 | body_type_mpart = NULL; | 1624 | body_type_mpart = NULL; |
1625 | 1625 | ||
1626 | r = mailimap_oparenth_parse(fd, buffer, &cur_token); | 1626 | r = mailimap_oparenth_parse(fd, buffer, &cur_token); |
1627 | if (r != MAILIMAP_NO_ERROR) { | 1627 | if (r != MAILIMAP_NO_ERROR) { |
1628 | res = r; | 1628 | res = r; |
1629 | goto err; | 1629 | goto err; |
1630 | } | 1630 | } |
1631 | 1631 | ||
1632 | type = MAILIMAP_BODY_ERROR; /* XXX - removes a gcc warning */ | 1632 | type = MAILIMAP_BODY_ERROR; /* XXX - removes a gcc warning */ |
1633 | 1633 | ||
1634 | r = mailimap_body_type_1part_parse(fd, buffer, &cur_token, &body_type_1part, | 1634 | r = mailimap_body_type_1part_parse(fd, buffer, &cur_token, &body_type_1part, |
1635 | progr_rate, progr_fun); | 1635 | progr_rate, progr_fun); |
1636 | if (r == MAILIMAP_NO_ERROR) | 1636 | if (r == MAILIMAP_NO_ERROR) |
1637 | type = MAILIMAP_BODY_1PART; | 1637 | type = MAILIMAP_BODY_1PART; |
1638 | 1638 | ||
1639 | if (r == MAILIMAP_ERROR_PARSE) { | 1639 | if (r == MAILIMAP_ERROR_PARSE) { |
1640 | r = mailimap_body_type_mpart_parse(fd, buffer, &cur_token, | 1640 | r = mailimap_body_type_mpart_parse(fd, buffer, &cur_token, |
1641 | &body_type_mpart, | 1641 | &body_type_mpart, |
1642 | progr_rate, progr_fun); | 1642 | progr_rate, progr_fun); |
1643 | 1643 | ||
1644 | if (r == MAILIMAP_NO_ERROR) | 1644 | if (r == MAILIMAP_NO_ERROR) |
1645 | type = MAILIMAP_BODY_MPART; | 1645 | type = MAILIMAP_BODY_MPART; |
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | if (r != MAILIMAP_NO_ERROR) { | 1648 | if (r != MAILIMAP_NO_ERROR) { |
1649 | res = r; | 1649 | res = r; |
1650 | goto err; | 1650 | goto err; |
1651 | } | 1651 | } |
1652 | 1652 | ||
1653 | r = mailimap_cparenth_parse(fd, buffer, &cur_token); | 1653 | r = mailimap_cparenth_parse(fd, buffer, &cur_token); |
1654 | if (r != MAILIMAP_NO_ERROR) { | 1654 | if (r != MAILIMAP_NO_ERROR) { |
1655 | res = r; | 1655 | res = r; |
1656 | goto free; | 1656 | goto free; |
1657 | } | 1657 | } |
1658 | 1658 | ||
1659 | body = mailimap_body_new(type, body_type_1part, body_type_mpart); | 1659 | body = mailimap_body_new(type, body_type_1part, body_type_mpart); |
1660 | if (body == NULL) { | 1660 | if (body == NULL) { |
1661 | res = MAILIMAP_ERROR_MEMORY; | 1661 | res = MAILIMAP_ERROR_MEMORY; |
1662 | goto free; | 1662 | goto free; |
1663 | } | 1663 | } |
1664 | 1664 | ||
1665 | * result = body; | 1665 | * result = body; |
1666 | * index = cur_token; | 1666 | * index = cur_token; |
1667 | 1667 | ||
1668 | return MAILIMAP_NO_ERROR; | 1668 | return MAILIMAP_NO_ERROR; |
1669 | 1669 | ||
1670 | free: | 1670 | free: |
1671 | if (body_type_1part) | 1671 | if (body_type_1part) |
1672 | mailimap_body_type_1part_free(body_type_1part); | 1672 | mailimap_body_type_1part_free(body_type_1part); |
1673 | if (body_type_mpart) | 1673 | if (body_type_mpart) |
1674 | mailimap_body_type_mpart_free(body_type_mpart); | 1674 | mailimap_body_type_mpart_free(body_type_mpart); |
1675 | err: | 1675 | err: |
1676 | return res; | 1676 | return res; |
1677 | } | 1677 | } |
1678 | 1678 | ||
1679 | /* | 1679 | /* |
1680 | body-extension = nstring / number / | 1680 | body-extension = nstring / number / |
1681 | "(" body-extension *(SP body-extension) ")" | 1681 | "(" body-extension *(SP body-extension) ")" |
1682 | ; Future expansion. Client implementations | 1682 | ; Future expansion. Client implementations |
1683 | ; MUST accept body-extension fields. Server | 1683 | ; MUST accept body-extension fields. Server |
1684 | ; implementations MUST NOT generate | 1684 | ; implementations MUST NOT generate |
1685 | ; body-extension fields except as defined by | 1685 | ; body-extension fields except as defined by |
1686 | ; future standard or standards-track | 1686 | ; future standard or standards-track |
1687 | ; revisions of this specification. | 1687 | ; revisions of this specification. |
1688 | */ | 1688 | */ |
1689 | 1689 | ||
1690 | /* | 1690 | /* |
1691 | "(" body-extension *(SP body-extension) ")" | 1691 | "(" body-extension *(SP body-extension) ")" |
1692 | */ | 1692 | */ |
1693 | 1693 | ||
1694 | static int | 1694 | static int |
1695 | mailimap_body_ext_list_parse(mailstream * fd, MMAPString * buffer, | 1695 | mailimap_body_ext_list_parse(mailstream * fd, MMAPString * buffer, |
1696 | size_t * index, | 1696 | size_t * index, |
1697 | clist ** result, | 1697 | clist ** result, |
1698 | size_t progr_rate, | 1698 | size_t progr_rate, |
1699 | progress_function * progr_fun) | 1699 | progress_function * progr_fun) |
1700 | { | 1700 | { |
1701 | size_t cur_token; | 1701 | size_t cur_token; |
1702 | clist * list; | 1702 | clist * list; |
1703 | int r; | 1703 | int r; |
1704 | int res; | 1704 | int res; |
1705 | 1705 | ||
1706 | cur_token = * index; | 1706 | cur_token = * index; |
1707 | 1707 | ||
1708 | r = mailimap_oparenth_parse(fd, buffer, &cur_token); | 1708 | r = mailimap_oparenth_parse(fd, buffer, &cur_token); |
1709 | if (r != MAILIMAP_NO_ERROR) { | 1709 | if (r != MAILIMAP_NO_ERROR) { |
1710 | res = r; | 1710 | res = r; |
1711 | goto err; | 1711 | goto err; |
1712 | } | 1712 | } |
1713 | 1713 | ||
1714 | r = mailimap_struct_spaced_list_parse(fd, buffer, | 1714 | r = mailimap_struct_spaced_list_parse(fd, buffer, |
1715 | &cur_token, &list, | 1715 | &cur_token, &list, |
1716 | (mailimap_struct_parser * ) | 1716 | (mailimap_struct_parser * ) |
1717 | mailimap_body_extension_parse, | 1717 | mailimap_body_extension_parse, |
1718 | (mailimap_struct_destructor * ) | 1718 | (mailimap_struct_destructor * ) |
1719 | mailimap_body_extension_free, | 1719 | mailimap_body_extension_free, |
1720 | progr_rate, progr_fun); | 1720 | progr_rate, progr_fun); |
1721 | if (r != MAILIMAP_NO_ERROR) { | 1721 | if (r != MAILIMAP_NO_ERROR) { |
1722 | res = r; | 1722 | res = r; |
1723 | goto err; | 1723 | goto err; |
1724 | } | 1724 | } |
1725 | 1725 | ||
1726 | r = mailimap_cparenth_parse(fd, buffer, &cur_token); | 1726 | r = mailimap_cparenth_parse(fd, buffer, &cur_token); |
1727 | if (r != MAILIMAP_NO_ERROR) { | 1727 | if (r != MAILIMAP_NO_ERROR) { |
1728 | res = r; | 1728 | res = r; |
1729 | goto free_list; | 1729 | goto free_list; |
1730 | } | 1730 | } |
1731 | 1731 | ||
1732 | * index = cur_token; | 1732 | * index = cur_token; |
1733 | * result = list; | 1733 | * result = list; |
1734 | 1734 | ||
1735 | return MAILIMAP_NO_ERROR; | 1735 | return MAILIMAP_NO_ERROR; |
1736 | 1736 | ||
1737 | free_list: | 1737 | free_list: |
1738 | clist_foreach(list, (clist_func) mailimap_body_extension_free, NULL); | 1738 | clist_foreach(list, (clist_func) mailimap_body_extension_free, NULL); |
1739 | clist_free(list); | 1739 | clist_free(list); |
1740 | err: | 1740 | err: |
1741 | return res; | 1741 | return res; |
1742 | } | 1742 | } |
1743 | 1743 | ||
1744 | /* | 1744 | /* |
1745 | body-extension = nstring / number / | 1745 | body-extension = nstring / number / |
1746 | "(" body-extension *(SP body-extension) ")" | 1746 | "(" body-extension *(SP body-extension) ")" |
1747 | ; Future expansion. Client implementations | 1747 | ; Future expansion. Client implementations |
1748 | ; MUST accept body-extension fields. Server | 1748 | ; MUST accept body-extension fields. Server |
1749 | ; implementations MUST NOT generate | 1749 | ; implementations MUST NOT generate |
1750 | ; body-extension fields except as defined by | 1750 | ; body-extension fields except as defined by |
1751 | ; future standard or standards-track | 1751 | ; future standard or standards-track |
1752 | ; revisions of this specification. | 1752 | ; revisions of this specification. |
1753 | */ | 1753 | */ |
1754 | 1754 | ||
1755 | static int | 1755 | static int |
1756 | mailimap_body_extension_parse(mailstream * fd, MMAPString * buffer, | 1756 | mailimap_body_extension_parse(mailstream * fd, MMAPString * buffer, |
1757 | size_t * index, | 1757 | size_t * index, |
1758 | struct mailimap_body_extension ** result, | 1758 | struct mailimap_body_extension ** result, |
1759 | size_t progr_rate, | 1759 | size_t progr_rate, |
1760 | progress_function * progr_fun) | 1760 | progress_function * progr_fun) |
1761 | { | 1761 | { |
1762 | size_t cur_token; | 1762 | size_t cur_token; |
1763 | uint32_t number; | 1763 | uint32_t number; |
1764 | char * nstring; | 1764 | char * nstring; |
1765 | clist * body_extension_list; | 1765 | clist * body_extension_list; |
1766 | struct mailimap_body_extension * body_extension; | 1766 | struct mailimap_body_extension * body_extension; |
1767 | int type; | 1767 | int type; |
1768 | int r; | 1768 | int r; |
1769 | int res; | 1769 | int res; |
1770 | 1770 | ||
1771 | cur_token = * index; | 1771 | cur_token = * index; |
1772 | 1772 | ||
1773 | nstring = NULL; | 1773 | nstring = NULL; |
1774 | number = 0; | 1774 | number = 0; |
1775 | body_extension_list = NULL; | 1775 | body_extension_list = NULL; |
1776 | type = MAILIMAP_BODY_EXTENSION_ERROR; /* XXX - removes a gcc warning */ | 1776 | type = MAILIMAP_BODY_EXTENSION_ERROR; /* XXX - removes a gcc warning */ |
1777 | 1777 | ||
1778 | r = mailimap_nstring_parse(fd, buffer, &cur_token, &nstring, NULL, | 1778 | r = mailimap_nstring_parse(fd, buffer, &cur_token, &nstring, NULL, |
1779 | progr_rate, progr_fun); | 1779 | progr_rate, progr_fun); |
1780 | if (r == MAILIMAP_NO_ERROR) | 1780 | if (r == MAILIMAP_NO_ERROR) |
1781 | type = MAILIMAP_BODY_EXTENSION_NSTRING; | 1781 | type = MAILIMAP_BODY_EXTENSION_NSTRING; |
1782 | 1782 | ||
1783 | if (r == MAILIMAP_ERROR_PARSE) { | 1783 | if (r == MAILIMAP_ERROR_PARSE) { |
1784 | r = mailimap_number_parse(fd, buffer, &cur_token, &number); | 1784 | r = mailimap_number_parse(fd, buffer, &cur_token, &number); |
1785 | 1785 | ||
1786 | if (r == MAILIMAP_NO_ERROR) | 1786 | if (r == MAILIMAP_NO_ERROR) |
1787 | type = MAILIMAP_BODY_EXTENSION_NUMBER; | 1787 | type = MAILIMAP_BODY_EXTENSION_NUMBER; |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | if (r == MAILIMAP_ERROR_PARSE) { | 1790 | if (r == MAILIMAP_ERROR_PARSE) { |
1791 | r = mailimap_body_ext_list_parse(fd, buffer, &cur_token, | 1791 | r = mailimap_body_ext_list_parse(fd, buffer, &cur_token, |
1792 | &body_extension_list, | 1792 | &body_extension_list, |
1793 | progr_rate, progr_fun); | 1793 | progr_rate, progr_fun); |
1794 | 1794 | ||
1795 | if (r == MAILIMAP_NO_ERROR) | 1795 | if (r == MAILIMAP_NO_ERROR) |
1796 | type = MAILIMAP_BODY_EXTENSION_LIST; | 1796 | type = MAILIMAP_BODY_EXTENSION_LIST; |
1797 | } | 1797 | } |
1798 | 1798 | ||
1799 | if (r != MAILIMAP_NO_ERROR) { | 1799 | if (r != MAILIMAP_NO_ERROR) { |
1800 | res = r; | 1800 | res = r; |
1801 | goto err; | 1801 | goto err; |
1802 | } | 1802 | } |
1803 | 1803 | ||
1804 | body_extension = mailimap_body_extension_new(type, nstring, number, | 1804 | body_extension = mailimap_body_extension_new(type, nstring, number, |
1805 | body_extension_list); | 1805 | body_extension_list); |
1806 | 1806 | ||
1807 | if (body_extension == NULL) { | 1807 | if (body_extension == NULL) { |
1808 | res = MAILIMAP_ERROR_MEMORY; | 1808 | res = MAILIMAP_ERROR_MEMORY; |
1809 | goto free; | 1809 | goto free; |
1810 | } | 1810 | } |
1811 | 1811 | ||
1812 | * result = body_extension; | 1812 | * result = body_extension; |
1813 | * index = cur_token; | 1813 | * index = cur_token; |
1814 | 1814 | ||
1815 | return MAILIMAP_NO_ERROR; | 1815 | return MAILIMAP_NO_ERROR; |
1816 | 1816 | ||
1817 | free: | 1817 | free: |
1818 | if (nstring != NULL) | 1818 | if (nstring != NULL) |
1819 | mailimap_nstring_free(nstring); | 1819 | mailimap_nstring_free(nstring); |
1820 | if (body_extension_list) { | 1820 | if (body_extension_list) { |
1821 | clist_foreach(body_extension_list, | 1821 | clist_foreach(body_extension_list, |
1822 | (clist_func) mailimap_body_extension_free, | 1822 | (clist_func) mailimap_body_extension_free, |
1823 | NULL); | 1823 | NULL); |
1824 | clist_free(body_extension_list); | 1824 | clist_free(body_extension_list); |
1825 | } | 1825 | } |
1826 | err: | 1826 | err: |
1827 | return res; | 1827 | return res; |
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | /* | 1830 | /* |
1831 | body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang | 1831 | body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang |
1832 | *(SP body-extension)]] | 1832 | *(SP body-extension)]] |
1833 | ; MUST NOT be returned on non-extensible | 1833 | ; MUST NOT be returned on non-extensible |
1834 | ; "BODY" fetch | 1834 | ; "BODY" fetch |
1835 | */ | 1835 | */ |
1836 | 1836 | ||
1837 | /* | 1837 | /* |
1838 | *(SP body-extension) | 1838 | *(SP body-extension) |
1839 | */ | 1839 | */ |
1840 | 1840 | ||
1841 | static int | 1841 | static int |
1842 | mailimap_body_ext_1part_3_parse(mailstream * fd, MMAPString * buffer, | 1842 | mailimap_body_ext_1part_3_parse(mailstream * fd, MMAPString * buffer, |
1843 | size_t * index, | 1843 | size_t * index, |
1844 | clist ** body_ext_list, | 1844 | clist ** body_ext_list, |
1845 | size_t progr_rate, | 1845 | size_t progr_rate, |
1846 | progress_function * progr_fun) | 1846 | progress_function * progr_fun) |
1847 | { | 1847 | { |
1848 | size_t cur_token; | 1848 | size_t cur_token; |
1849 | int r; | 1849 | int r; |
1850 | 1850 | ||
1851 | cur_token = * index; | 1851 | cur_token = * index; |
1852 | * body_ext_list = NULL; | 1852 | * body_ext_list = NULL; |
1853 | 1853 | ||
1854 | r = mailimap_space_parse(fd, buffer, &cur_token); | 1854 | r = mailimap_space_parse(fd, buffer, &cur_token); |
1855 | if (r != MAILIMAP_NO_ERROR) | 1855 | if (r != MAILIMAP_NO_ERROR) |
1856 | return r; | 1856 | return r; |
1857 | 1857 | ||
1858 | r = mailimap_struct_spaced_list_parse(fd, buffer, &cur_token, | 1858 | r = mailimap_struct_spaced_list_parse(fd, buffer, &cur_token, |
1859 | body_ext_list, | 1859 | body_ext_list, |
1860 | (mailimap_struct_parser *) | 1860 | (mailimap_struct_parser *) |
1861 | mailimap_body_extension_parse, | 1861 | mailimap_body_extension_parse, |
1862 | (mailimap_struct_destructor *) | 1862 | (mailimap_struct_destructor *) |
1863 | mailimap_body_extension_free, | 1863 | mailimap_body_extension_free, |
1864 | progr_rate, progr_fun); | 1864 | progr_rate, progr_fun); |
1865 | if (r != MAILIMAP_NO_ERROR) | 1865 | if (r != MAILIMAP_NO_ERROR) |
1866 | return r; | 1866 | return r; |
1867 | 1867 | ||
1868 | * index = cur_token; | 1868 | * index = cur_token; |
1869 | 1869 | ||
1870 | return MAILIMAP_NO_ERROR; | 1870 | return MAILIMAP_NO_ERROR; |
1871 | } | 1871 | } |
1872 | 1872 | ||
1873 | 1873 | ||
1874 | /* | 1874 | /* |
1875 | [SP body-fld-lang | 1875 | [SP body-fld-lang |
1876 | *(SP body-extension)]] | 1876 | *(SP body-extension)]] |
1877 | */ | 1877 | */ |
1878 | 1878 | ||
1879 | static int | 1879 | static int |
1880 | mailimap_body_ext_1part_2_parse(mailstream * fd, MMAPString * buffer, | 1880 | mailimap_body_ext_1part_2_parse(mailstream * fd, MMAPString * buffer, |
1881 | size_t * index, | 1881 | size_t * index, |
1882 | struct mailimap_body_fld_lang ** fld_lang, | 1882 | struct mailimap_body_fld_lang ** fld_lang, |
1883 | clist ** body_ext_list, | 1883 | clist ** body_ext_list, |
1884 | size_t progr_rate, | 1884 | size_t progr_rate, |
1885 | progress_function * progr_fun) | 1885 | progress_function * progr_fun) |
1886 | { | 1886 | { |
1887 | size_t cur_token; | 1887 | size_t cur_token; |
1888 | int r; | 1888 | int r; |
1889 | 1889 | ||
1890 | cur_token = * index; | 1890 | cur_token = * index; |
1891 | * fld_lang = NULL; | 1891 | * fld_lang = NULL; |
1892 | * body_ext_list = NULL; | 1892 | * body_ext_list = NULL; |
1893 | 1893 | ||
1894 | r = mailimap_space_parse(fd, buffer, &cur_token); | 1894 | r = mailimap_space_parse(fd, buffer, &cur_token); |
1895 | if (r != MAILIMAP_NO_ERROR) | 1895 | if (r != MAILIMAP_NO_ERROR) |
1896 | return r; | 1896 | return r; |
1897 | 1897 | ||
1898 | r = mailimap_body_fld_lang_parse(fd, buffer, &cur_token, fld_lang, | 1898 | r = mailimap_body_fld_lang_parse(fd, buffer, &cur_token, fld_lang, |
1899 | progr_rate, progr_fun); | 1899 | progr_rate, progr_fun); |
1900 | if (r != MAILIMAP_NO_ERROR) | 1900 | if (r != MAILIMAP_NO_ERROR) |
1901 | return r; | 1901 | return r; |
1902 | 1902 | ||
1903 | r = mailimap_body_ext_1part_3_parse(fd, buffer, &cur_token, | 1903 | r = mailimap_body_ext_1part_3_parse(fd, buffer, &cur_token, |
1904 | body_ext_list, progr_rate, progr_fun); | 1904 | body_ext_list, progr_rate, progr_fun); |
1905 | if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) | 1905 | if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) |
1906 | return r; | 1906 | return r; |
1907 | 1907 | ||
1908 | * index = cur_token; | 1908 | * index = cur_token; |
1909 | 1909 | ||
1910 | return MAILIMAP_NO_ERROR; | 1910 | return MAILIMAP_NO_ERROR; |
1911 | } | 1911 | } |
1912 | 1912 | ||
1913 | 1913 | ||
1914 | /* | 1914 | /* |
1915 | SP body-fld-dsp [SP body-fld-lang | 1915 | SP body-fld-dsp [SP body-fld-lang |
1916 | *(SP body-extension)]] | 1916 | *(SP body-extension)]] |
1917 | */ | 1917 | */ |
1918 | 1918 | ||
1919 | static int | 1919 | static int |
1920 | mailimap_body_ext_1part_1_parse(mailstream * fd, MMAPString * buffer, | 1920 | mailimap_body_ext_1part_1_parse(mailstream * fd, MMAPString * buffer, |
1921 | size_t * index, | 1921 | size_t * index, |
1922 | struct mailimap_body_fld_dsp ** fld_dsp, | 1922 | struct mailimap_body_fld_dsp ** fld_dsp, |
1923 | struct mailimap_body_fld_lang ** fld_lang, | 1923 | struct mailimap_body_fld_lang ** fld_lang, |
1924 | clist ** body_ext_list, | 1924 | clist ** body_ext_list, |
1925 | size_t progr_rate, | 1925 | size_t progr_rate, |
1926 | progress_function * progr_fun) | 1926 | progress_function * progr_fun) |
1927 | { | 1927 | { |
1928 | size_t cur_token; | 1928 | size_t cur_token; |
1929 | int r; | 1929 | int r; |
1930 | 1930 | ||
1931 | cur_token = * index; | 1931 | cur_token = * index; |
1932 | * fld_dsp = NULL; | 1932 | * fld_dsp = NULL; |
1933 | * fld_lang = NULL; | 1933 | * fld_lang = NULL; |
1934 | * body_ext_list = NULL; | 1934 | * body_ext_list = NULL; |
1935 | 1935 | ||
1936 | r = mailimap_space_parse(fd, buffer, &cur_token); | 1936 | r = mailimap_space_parse(fd, buffer, &cur_token); |
1937 | if (r != MAILIMAP_NO_ERROR) | 1937 | if (r != MAILIMAP_NO_ERROR) |
1938 | return r; | 1938 | return r; |
1939 | 1939 | ||
1940 | r = mailimap_body_fld_dsp_parse(fd, buffer, &cur_token, fld_dsp, | 1940 | r = mailimap_body_fld_dsp_parse(fd, buffer, &cur_token, fld_dsp, |
1941 | progr_rate, progr_fun); | 1941 | progr_rate, progr_fun); |
1942 | if (r != MAILIMAP_NO_ERROR) | 1942 | if (r != MAILIMAP_NO_ERROR) |
1943 | return r; | 1943 | return r; |
1944 | 1944 | ||
1945 | r = mailimap_body_ext_1part_2_parse(fd, buffer, &cur_token, | 1945 | r = mailimap_body_ext_1part_2_parse(fd, buffer, &cur_token, |
1946 | fld_lang, body_ext_list, | 1946 | fld_lang, body_ext_list, |
1947 | progr_rate, progr_fun); | 1947 | progr_rate, progr_fun); |
1948 | if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) | 1948 | if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) |
1949 | return r; | 1949 | return r; |
1950 | 1950 | ||
1951 | * index = cur_token; | 1951 | * index = cur_token; |
1952 | 1952 | ||
1953 | return MAILIMAP_NO_ERROR; | 1953 | return MAILIMAP_NO_ERROR; |
1954 | } | 1954 | } |
1955 | 1955 | ||
1956 | /* | 1956 | /* |
1957 | body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang | 1957 | body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang |
1958 | *(SP body-extension)]] | 1958 | *(SP body-extension)]] |
1959 | ; MUST NOT be returned on non-extensible | 1959 | ; MUST NOT be returned on non-extensible |
1960 | ; "BODY" fetch | 1960 | ; "BODY" fetch |
1961 | */ | 1961 | */ |
1962 | 1962 | ||
1963 | static int | 1963 | static int |
1964 | mailimap_body_ext_1part_parse(mailstream * fd, MMAPString * buffer, | 1964 | mailimap_body_ext_1part_parse(mailstream * fd, MMAPString * buffer, |
1965 | size_t * index, | 1965 | size_t * index, |
1966 | struct mailimap_body_ext_1part ** result, | 1966 | struct mailimap_body_ext_1part ** result, |
1967 | size_t progr_rate, | 1967 | size_t progr_rate, |
1968 | progress_function * progr_fun) | 1968 | progress_function * progr_fun) |
1969 | { | 1969 | { |
1970 | size_t cur_token; | 1970 | size_t cur_token; |
1971 | 1971 | ||
1972 | char * fld_md5; | 1972 | char * fld_md5; |
1973 | struct mailimap_body_fld_dsp * fld_dsp; | 1973 | struct mailimap_body_fld_dsp * fld_dsp; |
1974 | struct mailimap_body_fld_lang * fld_lang; | 1974 | struct mailimap_body_fld_lang * fld_lang; |
1975 | clist * body_ext_list; | 1975 | clist * body_ext_list; |
1976 | int r; | 1976 | int r; |
1977 | int res; | 1977 | int res; |
1978 | 1978 | ||
1979 | struct mailimap_body_ext_1part * ext_1part; | 1979 | struct mailimap_body_ext_1part * ext_1part; |
1980 | 1980 | ||
1981 | cur_token = * index; | 1981 | cur_token = * index; |
1982 | 1982 | ||
1983 | fld_md5 = NULL; | 1983 | fld_md5 = NULL; |
1984 | fld_dsp = NULL; | 1984 | fld_dsp = NULL; |
1985 | fld_lang = NULL; | 1985 | fld_lang = NULL; |
1986 | body_ext_list = NULL; | 1986 | body_ext_list = NULL; |
1987 | 1987 | ||
1988 | r = mailimap_body_fld_md5_parse(fd, buffer, &cur_token, &fld_md5, | 1988 | r = mailimap_body_fld_md5_parse(fd, buffer, &cur_token, &fld_md5, |
1989 | progr_rate, progr_fun); | 1989 | progr_rate, progr_fun); |
1990 | if (r != MAILIMAP_NO_ERROR) { | 1990 | if (r != MAILIMAP_NO_ERROR) { |
1991 | res = r; | 1991 | res = r; |
1992 | goto err; | 1992 | goto err; |
1993 | } | 1993 | } |
1994 | 1994 | ||
1995 | r = mailimap_body_ext_1part_1_parse(fd, buffer, &cur_token, | 1995 | r = mailimap_body_ext_1part_1_parse(fd, buffer, &cur_token, |
1996 | &fld_dsp, | 1996 | &fld_dsp, |
1997 | &fld_lang, | 1997 | &fld_lang, |
1998 | &body_ext_list, | 1998 | &body_ext_list, |
1999 | progr_rate, progr_fun); | 1999 | progr_rate, progr_fun); |
2000 | if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) { | 2000 | if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) { |
2001 | res = r; | 2001 | res = r; |
2002 | goto free; | 2002 | goto free; |
2003 | } | 2003 | } |
2004 | 2004 | ||
2005 | ext_1part = mailimap_body_ext_1part_new(fld_md5, fld_dsp, fld_lang, | 2005 | ext_1part = mailimap_body_ext_1part_new(fld_md5, fld_dsp, fld_lang, |
2006 | body_ext_list); | 2006 | body_ext_list); |
2007 | 2007 | ||
2008 | if (ext_1part == NULL) { | 2008 | if (ext_1part == NULL) { |
2009 | res = MAILIMAP_ERROR_MEMORY; | 2009 | res = MAILIMAP_ERROR_MEMORY; |
2010 | goto free; | 2010 | goto free; |
2011 | } | 2011 | } |
2012 | 2012 | ||
2013 | * result = ext_1part; | 2013 | * result = ext_1part; |
2014 | * index = cur_token; | 2014 | * index = cur_token; |
2015 | 2015 | ||
2016 | return MAILIMAP_NO_ERROR; | 2016 | return MAILIMAP_NO_ERROR; |
2017 | 2017 | ||
2018 | free: | 2018 | free: |
2019 | if (body_ext_list) { | 2019 | if (body_ext_list) { |
2020 | clist_foreach(body_ext_list, (clist_func) mailimap_body_extension_free, | 2020 | clist_foreach(body_ext_list, (clist_func) mailimap_body_extension_free, |
2021 | NULL); | 2021 | NULL); |
2022 | clist_free(body_ext_list); | 2022 | clist_free(body_ext_list); |
2023 | } | 2023 | } |
2024 | if (fld_lang) | 2024 | if (fld_lang) |
2025 | mailimap_body_fld_lang_free(fld_lang); | 2025 | mailimap_body_fld_lang_free(fld_lang); |
2026 | if (fld_dsp) | 2026 | if (fld_dsp) |
2027 | mailimap_body_fld_dsp_free(fld_dsp); | 2027 | mailimap_body_fld_dsp_free(fld_dsp); |
2028 | mailimap_body_fld_md5_free(fld_md5); | 2028 | mailimap_body_fld_md5_free(fld_md5); |
2029 | err: | 2029 | err: |
2030 | return res; | 2030 | return res; |
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | 2033 | ||
2034 | /* | 2034 | /* |
2035 | body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang | 2035 | body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang |
2036 | *(SP body-extension)]] | 2036 | *(SP body-extension)]] |
2037 | ; MUST NOT be returned on non-extensible | 2037 | ; MUST NOT be returned on non-extensible |
2038 | ; "BODY" fetch | 2038 | ; "BODY" fetch |
2039 | */ | 2039 | */ |
2040 | 2040 | ||
2041 | static int | 2041 | static int |
2042 | mailimap_body_ext_mpart_parse(mailstream * fd, MMAPString * buffer, | 2042 | mailimap_body_ext_mpart_parse(mailstream * fd, MMAPString * buffer, |
2043 | size_t * index, | 2043 | size_t * index, |
2044 | struct mailimap_body_ext_mpart ** result, | 2044 | struct mailimap_body_ext_mpart ** result, |
2045 | size_t progr_rate, | 2045 | size_t progr_rate, |
2046 | progress_function * progr_fun) | 2046 | progress_function * progr_fun) |
2047 | { | 2047 | { |
2048 | size_t cur_token; | 2048 | size_t cur_token; |
2049 | 2049 | ||
2050 | struct mailimap_body_fld_dsp * fld_dsp; | 2050 | struct mailimap_body_fld_dsp * fld_dsp; |
2051 | struct mailimap_body_fld_lang * fld_lang; | 2051 | struct mailimap_body_fld_lang * fld_lang; |
2052 | struct mailimap_body_fld_param * fld_param; | 2052 | struct mailimap_body_fld_param * fld_param; |
2053 | clist * body_ext_list; | 2053 | clist * body_ext_list; |
2054 | 2054 | ||
2055 | struct mailimap_body_ext_mpart * ext_mpart; | 2055 | struct mailimap_body_ext_mpart * ext_mpart; |
2056 | int r; | 2056 | int r; |
2057 | int res; | 2057 | int res; |
2058 | 2058 | ||
2059 | cur_token = * index; | 2059 | cur_token = * index; |
2060 | 2060 | ||
2061 | fld_param = NULL; | 2061 | fld_param = NULL; |
2062 | fld_dsp = NULL; | 2062 | fld_dsp = NULL; |
2063 | fld_lang = NULL; | 2063 | fld_lang = NULL; |
2064 | body_ext_list = NULL; | 2064 | body_ext_list = NULL; |
2065 | 2065 | ||
2066 | r = mailimap_body_fld_param_parse(fd, buffer, &cur_token, &fld_param, | 2066 | r = mailimap_body_fld_param_parse(fd, buffer, &cur_token, &fld_param, |
2067 | progr_rate, progr_fun); | 2067 | progr_rate, progr_fun); |
2068 | if (r != MAILIMAP_NO_ERROR) { | 2068 | if (r != MAILIMAP_NO_ERROR) { |
2069 | res = r; | 2069 | res = r; |
2070 | goto err; | 2070 | goto err; |
2071 | } | 2071 | } |
2072 | 2072 | ||
2073 | r = mailimap_body_ext_1part_1_parse(fd, buffer, &cur_token, | 2073 | r = mailimap_body_ext_1part_1_parse(fd, buffer, &cur_token, |
2074 | &fld_dsp, | 2074 | &fld_dsp, |
2075 | &fld_lang, | 2075 | &fld_lang, |
2076 | &body_ext_list, | 2076 | &body_ext_list, |
2077 | progr_rate, progr_fun); | 2077 | progr_rate, progr_fun); |
2078 | if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) { | 2078 | if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) { |
2079 | res = r; | 2079 | res = r; |
2080 | goto free; | 2080 | goto free; |
2081 | } | 2081 | } |
2082 | 2082 | ||
2083 | ext_mpart = mailimap_body_ext_mpart_new(fld_param, fld_dsp, fld_lang, | 2083 | ext_mpart = mailimap_body_ext_mpart_new(fld_param, fld_dsp, fld_lang, |
2084 | body_ext_list); | 2084 | body_ext_list); |
2085 | if (ext_mpart == NULL) { | 2085 | if (ext_mpart == NULL) { |
2086 | res = MAILIMAP_ERROR_MEMORY; | 2086 | res = MAILIMAP_ERROR_MEMORY; |
2087 | goto free; | 2087 | goto free; |
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | * result = ext_mpart; | 2090 | * result = ext_mpart; |
2091 | * index = cur_token; | 2091 | * index = cur_token; |
2092 | 2092 | ||
2093 | return MAILIMAP_NO_ERROR; | 2093 | return MAILIMAP_NO_ERROR; |
2094 | 2094 | ||
2095 | free: | 2095 | free: |
2096 | if (body_ext_list) { | 2096 | if (body_ext_list) { |
2097 | clist_foreach(body_ext_list, (clist_func) mailimap_body_extension_free, | 2097 | clist_foreach(body_ext_list, (clist_func) mailimap_body_extension_free, |
2098 | NULL); | 2098 | NULL); |
2099 | clist_free(body_ext_list); | 2099 | clist_free(body_ext_list); |
2100 | } | 2100 | } |
2101 | if (fld_lang) | 2101 | if (fld_lang) |
2102 | mailimap_body_fld_lang_free(fld_lang); | 2102 | mailimap_body_fld_lang_free(fld_lang); |
2103 | if (fld_dsp) | 2103 | if (fld_dsp) |
2104 | mailimap_body_fld_dsp_free(fld_dsp); | 2104 | mailimap_body_fld_dsp_free(fld_dsp); |
2105 | if (fld_param != NULL) | 2105 | if (fld_param != NULL) |
2106 | mailimap_body_fld_param_free(fld_param); | 2106 | mailimap_body_fld_param_free(fld_param); |
2107 | err: | 2107 | err: |
2108 | return res; | 2108 | return res; |
2109 | } | 2109 | } |
2110 | 2110 | ||
2111 | /* | 2111 | /* |
2112 | body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP | 2112 | body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP |
2113 | body-fld-enc SP body-fld-octets | 2113 | body-fld-enc SP body-fld-octets |
2114 | */ | 2114 | */ |
2115 | 2115 | ||
2116 | static int | 2116 | static int |
2117 | mailimap_body_fields_parse(mailstream * fd, MMAPString * buffer, | 2117 | mailimap_body_fields_parse(mailstream * fd, MMAPString * buffer, |
2118 | size_t * index, | 2118 | size_t * index, |
2119 | struct mailimap_body_fields ** result, | 2119 | struct mailimap_body_fields ** result, |
2120 | size_t progr_rate, | 2120 | size_t progr_rate, |
2121 | progress_function * progr_fun) | 2121 | progress_function * progr_fun) |
2122 | { | 2122 | { |
2123 | struct mailimap_body_fields * body_fields; | 2123 | struct mailimap_body_fields * body_fields; |
2124 | size_t cur_token; | 2124 | size_t cur_token; |
2125 | struct mailimap_body_fld_param * body_fld_param; | 2125 | struct mailimap_body_fld_param * body_fld_param; |
2126 | char * body_fld_id; | 2126 | char * body_fld_id; |
2127 | char * body_fld_desc; | 2127 | char * body_fld_desc; |
2128 | struct mailimap_body_fld_enc * body_fld_enc; | 2128 | struct mailimap_body_fld_enc * body_fld_enc; |
2129 | size_t body_fld_octets; | 2129 | size_t body_fld_octets; |
2130 | int r; | 2130 | int r; |
2131 | int res; | 2131 | int res; |
2132 | 2132 | ||
2133 | body_fld_param = NULL; | 2133 | body_fld_param = NULL; |
2134 | body_fld_id = NULL; | 2134 | body_fld_id = NULL; |
2135 | body_fld_desc = NULL; | 2135 | body_fld_desc = NULL; |
2136 | body_fld_enc = NULL; | 2136 | body_fld_enc = NULL; |
2137 | body_fld_octets = 0; | 2137 | body_fld_octets = 0; |
2138 | 2138 | ||
2139 | cur_token = * index; | 2139 | cur_token = * index; |
2140 | 2140 | ||
2141 | r = mailimap_body_fld_param_parse(fd, buffer, &cur_token, &body_fld_param, | 2141 | r = mailimap_body_fld_param_parse(fd, buffer, &cur_token, &body_fld_param, |
2142 | progr_rate, progr_fun); | 2142 | progr_rate, progr_fun); |
2143 | if (r != MAILIMAP_NO_ERROR) { | 2143 | if (r != MAILIMAP_NO_ERROR) { |
2144 | res = r; | 2144 | res = r; |
2145 | goto err; | 2145 | goto err; |
2146 | } | 2146 | } |
2147 | 2147 | ||
2148 | r = mailimap_space_parse(fd, buffer, &cur_token); | 2148 | r = mailimap_space_parse(fd, buffer, &cur_token); |
2149 | if (r != MAILIMAP_NO_ERROR) { | 2149 | if (r != MAILIMAP_NO_ERROR) { |
2150 | res = r; | 2150 | res = r; |
2151 | goto fld_param_free; | 2151 | goto fld_param_free; |
2152 | } | 2152 | } |
2153 | 2153 | ||
2154 | r = mailimap_body_fld_id_parse(fd, buffer, &cur_token, &body_fld_id, | 2154 | r = mailimap_body_fld_id_parse(fd, buffer, &cur_token, &body_fld_id, |
2155 | progr_rate, progr_fun); | 2155 | progr_rate, progr_fun); |
2156 | if (r != MAILIMAP_NO_ERROR) { | 2156 | if (r != MAILIMAP_NO_ERROR) { |
2157 | res = r; | 2157 | res = r; |
2158 | goto fld_param_free; | 2158 | goto fld_param_free; |
2159 | } | 2159 | } |
2160 | 2160 | ||
2161 | r = mailimap_space_parse(fd, buffer, &cur_token); | 2161 | r = mailimap_space_parse(fd, buffer, &cur_token); |
2162 | if (r != MAILIMAP_NO_ERROR) { | 2162 | if (r != MAILIMAP_NO_ERROR) { |
2163 | res = r; | 2163 | res = r; |
2164 | goto fld_id_free; | 2164 | goto fld_id_free; |
2165 | } | 2165 | } |
2166 | 2166 | ||
2167 | r = mailimap_body_fld_desc_parse(fd, buffer, &cur_token, &body_fld_desc, | 2167 | r = mailimap_body_fld_desc_parse(fd, buffer, &cur_token, &body_fld_desc, |
2168 | progr_rate, progr_fun); | 2168 | progr_rate, progr_fun); |
2169 | if (r != MAILIMAP_NO_ERROR) { | 2169 | if (r != MAILIMAP_NO_ERROR) { |
2170 | res = r; | 2170 | res = r; |
2171 | goto fld_id_free; | 2171 | goto fld_id_free; |
2172 | } | 2172 | } |
2173 | 2173 | ||
2174 | r = mailimap_space_parse(fd, buffer, &cur_token); | 2174 | r = mailimap_space_parse(fd, buffer, &cur_token); |
2175 | if (r != MAILIMAP_NO_ERROR) { | 2175 | if (r != MAILIMAP_NO_ERROR) { |
2176 | res = r; | 2176 | res = r; |
2177 | goto fld_desc_free; | 2177 | goto fld_desc_free; |
2178 | } | 2178 | } |
2179 | 2179 | ||
2180 | r = mailimap_body_fld_enc_parse(fd, buffer, &cur_token, &body_fld_enc, | 2180 | r = mailimap_body_fld_enc_parse(fd, buffer, &cur_token, &body_fld_enc, |
2181 | progr_rate, progr_fun); | 2181 | progr_rate, progr_fun); |
2182 | if (r != MAILIMAP_NO_ERROR) { | 2182 | if (r != MAILIMAP_NO_ERROR) { |
2183 | res = r; | 2183 | res = r; |
2184 | goto fld_desc_free; | 2184 | goto fld_desc_free; |
2185 | } | 2185 | } |
2186 | 2186 | ||
2187 | r = mailimap_space_parse(fd, buffer, &cur_token); | 2187 | r = mailimap_space_parse(fd, buffer, &cur_token); |
2188 | if (r != MAILIMAP_NO_ERROR) { | 2188 | if (r != MAILIMAP_NO_ERROR) { |
2189 | res = r; | 2189 | res = r; |
2190 | goto fld_enc_free; | 2190 | goto fld_enc_free; |
2191 | } | 2191 | } |
2192 | 2192 | ||
2193 | r = mailimap_body_fld_octets_parse(fd, buffer, &cur_token, | 2193 | r = mailimap_body_fld_octets_parse(fd, buffer, &cur_token, |
2194 | &body_fld_octets); | 2194 | &body_fld_octets); |
2195 | if (r != MAILIMAP_NO_ERROR) { | 2195 | if (r != MAILIMAP_NO_ERROR) { |
2196 | res = r; | 2196 | res = r; |
2197 | goto fld_enc_free; | 2197 | goto fld_enc_free; |
2198 | } | 2198 | } |
2199 | 2199 | ||
2200 | body_fields = mailimap_body_fields_new(body_fld_param, | 2200 | body_fields = mailimap_body_fields_new(body_fld_param, |
2201 | body_fld_id, | 2201 | body_fld_id, |
2202 | body_fld_desc, | 2202 | body_fld_desc, |
2203 | body_fld_enc, | 2203 | body_fld_enc, |
2204 | body_fld_octets); | 2204 | body_fld_octets); |
2205 | if (body_fields == NULL) { | 2205 | if (body_fields == NULL) { |
2206 | res = MAILIMAP_ERROR_MEMORY; | 2206 | res = MAILIMAP_ERROR_MEMORY; |
2207 | goto fld_enc_free; | 2207 | goto fld_enc_free; |
2208 | } | 2208 | } |
2209 | 2209 | ||
2210 | * result = body_fields; | 2210 | * result = body_fields; |
2211 | * index = cur_token; | 2211 | * index = cur_token; |
2212 | 2212 | ||
2213 | return MAILIMAP_NO_ERROR; | 2213 | return MAILIMAP_NO_ERROR; |
2214 | 2214 | ||
2215 | fld_enc_free: | 2215 | fld_enc_free: |
2216 | mailimap_body_fld_enc_free(body_fld_enc); | 2216 | mailimap_body_fld_enc_free(body_fld_enc); |
2217 | fld_desc_free: | 2217 | fld_desc_free: |
2218 | mailimap_body_fld_desc_free(body_fld_desc); | 2218 | mailimap_body_fld_desc_free(body_fld_desc); |
2219 | fld_id_free: | 2219 | fld_id_free: |
2220 | mailimap_body_fld_id_free(body_fld_id); | 2220 | mailimap_body_fld_id_free(body_fld_id); |
2221 | fld_param_free: | 2221 | fld_param_free: |
2222 | if (body_fld_param != NULL) | 2222 | if (body_fld_param != NULL) |
2223 | mailimap_body_fld_param_free(body_fld_param); | 2223 | mailimap_body_fld_param_free(body_fld_param); |
2224 | err: | 2224 | err: |
2225 | return res; | 2225 | return res; |
2226 | } | 2226 | } |
2227 | 2227 | ||
2228 | /* | 2228 | /* |
2229 | body-fld-desc = nstring | 2229 | body-fld-desc = nstring |
2230 | */ | 2230 | */ |
2231 | 2231 | ||
2232 | static int mailimap_body_fld_desc_parse(mailstream * fd, MMAPString * buffer, | 2232 | static int mailimap_body_fld_desc_parse(mailstream * fd, MMAPString * buffer, |
2233 | size_t * index, char ** result, | 2233 | size_t * index, char ** result, |
2234 | size_t progr_rate, | 2234 | size_t progr_rate, |
2235 | progress_function * progr_fun) | 2235 | progress_function * progr_fun) |
2236 | { | 2236 | { |
2237 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, | 2237 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, |
2238 | progr_rate, progr_fun); | 2238 | progr_rate, progr_fun); |
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | /* | 2241 | /* |
2242 | body-fld-dsp = "(" string SP body-fld-param ")" / nil | 2242 | body-fld-dsp = "(" string SP body-fld-param ")" / nil |
2243 | */ | 2243 | */ |
2244 | 2244 | ||
2245 | static int | 2245 | static int |
2246 | mailimap_body_fld_dsp_parse(mailstream * fd, MMAPString * buffer, | 2246 | mailimap_body_fld_dsp_parse(mailstream * fd, MMAPString * buffer, |
2247 | size_t * index, | 2247 | size_t * index, |
2248 | struct mailimap_body_fld_dsp ** result, | 2248 | struct mailimap_body_fld_dsp ** result, |
2249 | size_t progr_rate, | 2249 | size_t progr_rate, |
2250 | progress_function * progr_fun) | 2250 | progress_function * progr_fun) |
2251 | { | 2251 | { |
2252 | size_t cur_token; | 2252 | size_t cur_token; |
2253 | char * name; | 2253 | char * name; |
2254 | struct mailimap_body_fld_param * body_fld_param; | 2254 | struct mailimap_body_fld_param * body_fld_param; |
2255 | struct mailimap_body_fld_dsp * body_fld_dsp; | 2255 | struct mailimap_body_fld_dsp * body_fld_dsp; |
2256 | int res; | 2256 | int res; |
2257 | int r; | 2257 | int r; |
2258 | 2258 | ||
2259 | cur_token = * index; | 2259 | cur_token = * index; |
2260 | name = NULL; | 2260 | name = NULL; |
2261 | body_fld_param = NULL; | 2261 | body_fld_param = NULL; |
2262 | 2262 | ||
2263 | r = mailimap_nil_parse(fd, buffer, &cur_token); | 2263 | r = mailimap_nil_parse(fd, buffer, &cur_token); |
2264 | if (r == MAILIMAP_NO_ERROR) { | 2264 | if (r == MAILIMAP_NO_ERROR) { |
2265 | * result = NULL; | 2265 | * result = NULL; |
2266 | * index = cur_token; | 2266 | * index = cur_token; |
2267 | return MAILIMAP_NO_ERROR; | 2267 | return MAILIMAP_NO_ERROR; |
2268 | } | 2268 | } |
2269 | 2269 | ||
2270 | if (r != MAILIMAP_ERROR_PARSE) { | 2270 | if (r != MAILIMAP_ERROR_PARSE) { |
2271 | res = r; | 2271 | res = r; |
2272 | goto err; | 2272 | goto err; |
2273 | } | 2273 | } |
2274 | 2274 | ||
2275 | r = mailimap_oparenth_parse(fd, buffer, &cur_token); | 2275 | r = mailimap_oparenth_parse(fd, buffer, &cur_token); |
2276 | if (r != MAILIMAP_NO_ERROR) { | 2276 | if (r != MAILIMAP_NO_ERROR) { |
2277 | res = r; | 2277 | res = r; |
2278 | goto err; | 2278 | goto err; |
2279 | } | 2279 | } |
2280 | 2280 | ||
2281 | r = mailimap_string_parse(fd, buffer, &cur_token, &name, NULL, | 2281 | r = mailimap_string_parse(fd, buffer, &cur_token, &name, NULL, |
2282 | progr_rate, progr_fun); | 2282 | progr_rate, progr_fun); |
2283 | if (r != MAILIMAP_NO_ERROR) { | 2283 | if (r != MAILIMAP_NO_ERROR) { |
2284 | res = r; | 2284 | res = r; |
2285 | goto err; | 2285 | goto err; |
2286 | } | 2286 | } |
2287 | 2287 | ||
2288 | r = mailimap_space_parse(fd, buffer, &cur_token); | 2288 | r = mailimap_space_parse(fd, buffer, &cur_token); |
2289 | if (r != MAILIMAP_NO_ERROR) { | 2289 | if (r != MAILIMAP_NO_ERROR) { |
2290 | res = r; | 2290 | res = r; |
2291 | goto string_free; | 2291 | goto string_free; |
2292 | } | 2292 | } |
2293 | 2293 | ||
2294 | r = mailimap_body_fld_param_parse(fd, buffer, &cur_token, | 2294 | r = mailimap_body_fld_param_parse(fd, buffer, &cur_token, |
2295 | &body_fld_param, | 2295 | &body_fld_param, |
2296 | progr_rate, progr_fun); | 2296 | progr_rate, progr_fun); |
2297 | if (r != MAILIMAP_NO_ERROR) { | 2297 | if (r != MAILIMAP_NO_ERROR) { |
2298 | res = r; | 2298 | res = r; |
2299 | goto string_free; | 2299 | goto string_free; |
2300 | } | 2300 | } |
2301 | 2301 | ||
2302 | r = mailimap_cparenth_parse(fd, buffer, &cur_token); | 2302 | r = mailimap_cparenth_parse(fd, buffer, &cur_token); |
2303 | if (r != MAILIMAP_NO_ERROR) { | 2303 | if (r != MAILIMAP_NO_ERROR) { |
2304 | res = r; | 2304 | res = r; |
2305 | goto string_free; | 2305 | goto string_free; |
2306 | } | 2306 | } |
2307 | 2307 | ||
2308 | body_fld_dsp = mailimap_body_fld_dsp_new(name, body_fld_param); | 2308 | body_fld_dsp = mailimap_body_fld_dsp_new(name, body_fld_param); |
2309 | if (body_fld_dsp == NULL) { | 2309 | if (body_fld_dsp == NULL) { |
2310 | res = MAILIMAP_ERROR_MEMORY; | 2310 | res = MAILIMAP_ERROR_MEMORY; |
2311 | goto fld_param_free; | 2311 | goto fld_param_free; |
2312 | } | 2312 | } |
2313 | 2313 | ||
2314 | * index = cur_token; | 2314 | * index = cur_token; |
2315 | * result = body_fld_dsp; | 2315 | * result = body_fld_dsp; |
2316 | 2316 | ||
2317 | return MAILIMAP_NO_ERROR; | 2317 | return MAILIMAP_NO_ERROR; |
2318 | 2318 | ||
2319 | fld_param_free: | 2319 | fld_param_free: |
2320 | if (body_fld_param != NULL) | 2320 | if (body_fld_param != NULL) |
2321 | mailimap_body_fld_param_free(body_fld_param); | 2321 | mailimap_body_fld_param_free(body_fld_param); |
2322 | string_free: | 2322 | string_free: |
2323 | mailimap_string_free(name); | 2323 | mailimap_string_free(name); |
2324 | err: | 2324 | err: |
2325 | return res; | 2325 | return res; |
2326 | } | 2326 | } |
2327 | 2327 | ||
2328 | /* | 2328 | /* |
2329 | body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ | 2329 | body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ |
2330 | "QUOTED-PRINTABLE") DQUOTE) / string | 2330 | "QUOTED-PRINTABLE") DQUOTE) / string |
2331 | */ | 2331 | */ |
2332 | 2332 | ||
2333 | static inline int | 2333 | static inline int |
2334 | mailimap_body_fld_known_enc_parse(mailstream * fd, MMAPString * buffer, | 2334 | mailimap_body_fld_known_enc_parse(mailstream * fd, MMAPString * buffer, |
2335 | size_t * index, | 2335 | size_t * index, |
2336 | int * result, | 2336 | int * result, |
2337 | size_t progr_rate, | 2337 | size_t progr_rate, |
2338 | progress_function * progr_fun) | 2338 | progress_function * progr_fun) |
2339 | { | 2339 | { |
2340 | size_t cur_token; | 2340 | size_t cur_token; |
2341 | int type; | 2341 | int type; |
2342 | int r; | 2342 | int r; |
2343 | int res; | 2343 | int res; |
2344 | 2344 | ||
2345 | cur_token = * index; | 2345 | cur_token = * index; |
2346 | 2346 | ||
2347 | r = mailimap_dquote_parse(fd, buffer, &cur_token); | 2347 | r = mailimap_dquote_parse(fd, buffer, &cur_token); |
2348 | if (r != MAILIMAP_NO_ERROR) { | 2348 | if (r != MAILIMAP_NO_ERROR) { |
2349 | res = r; | 2349 | res = r; |
2350 | goto err; | 2350 | goto err; |
2351 | } | 2351 | } |
2352 | 2352 | ||
2353 | type = mailimap_encoding_get_token_value(fd, buffer, &cur_token); | 2353 | type = mailimap_encoding_get_token_value(fd, buffer, &cur_token); |
2354 | 2354 | ||
2355 | if (type == -1) { | 2355 | if (type == -1) { |
2356 | res = MAILIMAP_ERROR_PARSE; | 2356 | res = MAILIMAP_ERROR_PARSE; |
2357 | goto err; | 2357 | goto err; |
2358 | } | 2358 | } |
2359 | 2359 | ||
2360 | r = mailimap_dquote_parse(fd, buffer, &cur_token); | 2360 | r = mailimap_dquote_parse(fd, buffer, &cur_token); |
2361 | if (r != MAILIMAP_NO_ERROR) { | 2361 | if (r != MAILIMAP_NO_ERROR) { |
2362 | res = r; | 2362 | res = r; |
2363 | goto err; | 2363 | goto err; |
2364 | } | 2364 | } |
2365 | 2365 | ||
2366 | * result = type; | 2366 | * result = type; |
2367 | * index = cur_token; | 2367 | * index = cur_token; |
2368 | 2368 | ||
2369 | return MAILIMAP_NO_ERROR; | 2369 | return MAILIMAP_NO_ERROR; |
2370 | 2370 | ||
2371 | err: | 2371 | err: |
2372 | return res; | 2372 | return res; |
2373 | } | 2373 | } |
2374 | 2374 | ||
2375 | static int | 2375 | static int |
2376 | mailimap_body_fld_enc_parse(mailstream * fd, MMAPString * buffer, | 2376 | mailimap_body_fld_enc_parse(mailstream * fd, MMAPString * buffer, |
2377 | size_t * index, | 2377 | size_t * index, |
2378 | struct mailimap_body_fld_enc ** result, | 2378 | struct mailimap_body_fld_enc ** result, |
2379 | size_t progr_rate, | 2379 | size_t progr_rate, |
2380 | progress_function * progr_fun) | 2380 | progress_function * progr_fun) |
2381 | { | 2381 | { |
2382 | size_t cur_token; | 2382 | size_t cur_token; |
2383 | int type; | 2383 | int type; |
2384 | char * value; | 2384 | char * value; |
2385 | struct mailimap_body_fld_enc * body_fld_enc; | 2385 | struct mailimap_body_fld_enc * body_fld_enc; |
2386 | int r; | 2386 | int r; |
2387 | int res; | 2387 | int res; |
2388 | 2388 | ||
2389 | cur_token = * index; | 2389 | cur_token = * index; |
2390 | 2390 | ||
2391 | r = mailimap_body_fld_known_enc_parse(fd, buffer, &cur_token, | 2391 | r = mailimap_body_fld_known_enc_parse(fd, buffer, &cur_token, |
2392 | &type, progr_rate, progr_fun); | 2392 | &type, progr_rate, progr_fun); |
2393 | if (r == MAILIMAP_NO_ERROR) { | 2393 | if (r == MAILIMAP_NO_ERROR) { |
2394 | value = NULL; | 2394 | value = NULL; |
2395 | } | 2395 | } |
2396 | else if (r == MAILIMAP_ERROR_PARSE) { | 2396 | else if (r == MAILIMAP_ERROR_PARSE) { |
2397 | type = MAILIMAP_BODY_FLD_ENC_OTHER; | 2397 | type = MAILIMAP_BODY_FLD_ENC_OTHER; |
2398 | 2398 | ||
2399 | r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL, | 2399 | r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL, |
2400 | progr_rate, progr_fun); | 2400 | progr_rate, progr_fun); |
2401 | if (r != MAILIMAP_NO_ERROR) { | 2401 | if (r != MAILIMAP_NO_ERROR) { |
2402 | res = r; | 2402 | // LR start |
2403 | goto err; | 2403 | // accept NIL and set type to utf8 |
2404 | int ret = r; | ||
2405 | r = mailimap_char_parse(fd, buffer, &cur_token, 'N'); | ||
2406 | if (r == MAILIMAP_NO_ERROR) { | ||
2407 | r = mailimap_char_parse(fd, buffer, &cur_token, 'I'); | ||
2408 | if (r == MAILIMAP_NO_ERROR) { | ||
2409 | r = mailimap_char_parse(fd, buffer, &cur_token, 'L'); | ||
2410 | if (r == MAILIMAP_NO_ERROR) { | ||
2411 | type = 4; | ||
2412 | ret = MAILIMAP_NO_ERROR; | ||
2413 | value = NULL; | ||
2414 | } | ||
2415 | } | ||
2416 | } | ||
2417 | if ( ret != MAILIMAP_NO_ERROR ) { | ||
2418 | res = ret; | ||
2419 | goto err; | ||
2420 | } | ||
2421 | // LR end | ||
2404 | } | 2422 | } |
2405 | } | 2423 | } |
2406 | else { | 2424 | else { |
2407 | res = r; | 2425 | res = r; |
2408 | goto err; | 2426 | goto err; |
2409 | } | 2427 | } |
2410 | 2428 | ||
2411 | body_fld_enc = mailimap_body_fld_enc_new(type, value); | 2429 | body_fld_enc = mailimap_body_fld_enc_new(type, value); |
2412 | if (body_fld_enc == NULL) { | 2430 | if (body_fld_enc == NULL) { |
2413 | res = MAILIMAP_ERROR_MEMORY; | 2431 | res = MAILIMAP_ERROR_MEMORY; |
2414 | goto value_free; | 2432 | goto value_free; |
2415 | } | 2433 | } |
2416 | 2434 | ||
2417 | * result = body_fld_enc; | 2435 | * result = body_fld_enc; |
2418 | * index = cur_token; | 2436 | * index = cur_token; |
2419 | 2437 | ||
2420 | return MAILIMAP_NO_ERROR; | 2438 | return MAILIMAP_NO_ERROR; |
2421 | 2439 | ||
2422 | value_free: | 2440 | value_free: |
2423 | if (value) | 2441 | if (value) |
2424 | mailimap_string_free(value); | 2442 | mailimap_string_free(value); |
2425 | err: | 2443 | err: |
2426 | return res; | 2444 | return res; |
2427 | } | 2445 | } |
2428 | 2446 | ||
2429 | /* | 2447 | /* |
2430 | body-fld-id = nstring | 2448 | body-fld-id = nstring |
2431 | */ | 2449 | */ |
2432 | 2450 | ||
2433 | static int mailimap_body_fld_id_parse(mailstream * fd, MMAPString * buffer, | 2451 | static int mailimap_body_fld_id_parse(mailstream * fd, MMAPString * buffer, |
2434 | size_t * index, char ** result, | 2452 | size_t * index, char ** result, |
2435 | size_t progr_rate, | 2453 | size_t progr_rate, |
2436 | progress_function * progr_fun) | 2454 | progress_function * progr_fun) |
2437 | { | 2455 | { |
2438 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, | 2456 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, |
2439 | progr_rate, progr_fun); | 2457 | progr_rate, progr_fun); |
2440 | } | 2458 | } |
2441 | 2459 | ||
2442 | 2460 | ||
2443 | /* | 2461 | /* |
2444 | body-fld-lang = nstring / "(" string *(SP string) ")" | 2462 | body-fld-lang = nstring / "(" string *(SP string) ")" |
2445 | */ | 2463 | */ |
2446 | 2464 | ||
2447 | /* | 2465 | /* |
2448 | "(" string *(SP string) ")" | 2466 | "(" string *(SP string) ")" |
2449 | */ | 2467 | */ |
2450 | 2468 | ||
2451 | static int | 2469 | static int |
2452 | mailimap_body_fld_lang_list_parse(mailstream * fd, MMAPString * buffer, | 2470 | mailimap_body_fld_lang_list_parse(mailstream * fd, MMAPString * buffer, |
2453 | size_t * index, clist ** result, | 2471 | size_t * index, clist ** result, |
2454 | size_t progr_rate, | 2472 | size_t progr_rate, |
2455 | progress_function * progr_fun) | 2473 | progress_function * progr_fun) |
2456 | { | 2474 | { |
2457 | size_t cur_token; | 2475 | size_t cur_token; |
2458 | clist * list; | 2476 | clist * list; |
2459 | int r; | 2477 | int r; |
2460 | int res; | 2478 | int res; |
2461 | 2479 | ||
2462 | cur_token = * index; | 2480 | cur_token = * index; |
2463 | 2481 | ||
2464 | r = mailimap_oparenth_parse(fd, buffer, &cur_token); | 2482 | r = mailimap_oparenth_parse(fd, buffer, &cur_token); |
2465 | if (r != MAILIMAP_NO_ERROR) { | 2483 | if (r != MAILIMAP_NO_ERROR) { |
2466 | res = r; | 2484 | res = r; |
2467 | goto err; | 2485 | goto err; |
2468 | } | 2486 | } |
2469 | 2487 | ||
2470 | list = clist_new(); | 2488 | list = clist_new(); |
2471 | if (list == NULL) { | 2489 | if (list == NULL) { |
2472 | res = MAILIMAP_ERROR_MEMORY; | 2490 | res = MAILIMAP_ERROR_MEMORY; |
2473 | goto err; | 2491 | goto err; |
2474 | } | 2492 | } |
2475 | 2493 | ||
2476 | while (1) { | 2494 | while (1) { |
2477 | char * elt; | 2495 | char * elt; |
2478 | 2496 | ||
2479 | r = mailimap_string_parse(fd, buffer, &cur_token, &elt, NULL, | 2497 | r = mailimap_string_parse(fd, buffer, &cur_token, &elt, NULL, |
2480 | progr_rate, progr_fun); | 2498 | progr_rate, progr_fun); |
2481 | if (r != MAILIMAP_ERROR_PARSE) | 2499 | if (r != MAILIMAP_ERROR_PARSE) |
2482 | break; | 2500 | break; |
2483 | else if (r == MAILIMAP_NO_ERROR) { | 2501 | else if (r == MAILIMAP_NO_ERROR) { |
2484 | r = clist_append(list, elt); | 2502 | r = clist_append(list, elt); |
2485 | if (r < 0) { | 2503 | if (r < 0) { |
2486 | mailimap_string_free(elt); | 2504 | mailimap_string_free(elt); |
2487 | res = r; | 2505 | res = r; |
2488 | goto list_free; | 2506 | goto list_free; |
2489 | } | 2507 | } |
2490 | } | 2508 | } |
2491 | else { | 2509 | else { |
2492 | res = r; | 2510 | res = r; |
2493 | goto list_free; | 2511 | goto list_free; |
2494 | } | 2512 | } |
2495 | } | 2513 | } |
2496 | 2514 | ||
2497 | r = mailimap_cparenth_parse(fd, buffer, &cur_token); | 2515 | r = mailimap_cparenth_parse(fd, buffer, &cur_token); |
2498 | if (r != MAILIMAP_NO_ERROR) { | 2516 | if (r != MAILIMAP_NO_ERROR) { |
2499 | res = r; | 2517 | res = r; |
2500 | goto list_free; | 2518 | goto list_free; |
2501 | } | 2519 | } |
2502 | 2520 | ||
2503 | * index = cur_token; | 2521 | * index = cur_token; |
2504 | * result = list; | 2522 | * result = list; |
2505 | 2523 | ||
2506 | return MAILIMAP_NO_ERROR; | 2524 | return MAILIMAP_NO_ERROR; |
2507 | 2525 | ||
2508 | list_free: | 2526 | list_free: |
2509 | clist_foreach(list, (clist_func) mailimap_string_free, NULL); | 2527 | clist_foreach(list, (clist_func) mailimap_string_free, NULL); |
2510 | clist_free(list); | 2528 | clist_free(list); |
2511 | err: | 2529 | err: |
2512 | return res; | 2530 | return res; |
2513 | } | 2531 | } |
2514 | 2532 | ||
2515 | /* | 2533 | /* |
2516 | body-fld-lang = nstring / "(" string *(SP string) ")" | 2534 | body-fld-lang = nstring / "(" string *(SP string) ")" |
2517 | */ | 2535 | */ |
2518 | 2536 | ||
2519 | static int | 2537 | static int |
2520 | mailimap_body_fld_lang_parse(mailstream * fd, MMAPString * buffer, | 2538 | mailimap_body_fld_lang_parse(mailstream * fd, MMAPString * buffer, |
2521 | size_t * index, | 2539 | size_t * index, |
2522 | struct mailimap_body_fld_lang ** result, | 2540 | struct mailimap_body_fld_lang ** result, |
2523 | size_t progr_rate, | 2541 | size_t progr_rate, |
2524 | progress_function * progr_fun) | 2542 | progress_function * progr_fun) |
2525 | { | 2543 | { |
2526 | char * value; | 2544 | char * value; |
2527 | clist * list; | 2545 | clist * list; |
2528 | struct mailimap_body_fld_lang * fld_lang; | 2546 | struct mailimap_body_fld_lang * fld_lang; |
2529 | int type; | 2547 | int type; |
2530 | int r; | 2548 | int r; |
2531 | int res; | 2549 | int res; |
2532 | 2550 | ||
2533 | size_t cur_token; | 2551 | size_t cur_token; |
2534 | 2552 | ||
2535 | cur_token = * index; | 2553 | cur_token = * index; |
2536 | 2554 | ||
2537 | value = NULL; | 2555 | value = NULL; |
2538 | list = NULL; | 2556 | list = NULL; |
2539 | type = MAILIMAP_BODY_FLD_LANG_ERROR; /* XXX - removes a gcc warning */ | 2557 | type = MAILIMAP_BODY_FLD_LANG_ERROR; /* XXX - removes a gcc warning */ |
2540 | 2558 | ||
2541 | r = mailimap_nstring_parse(fd, buffer, &cur_token, &value, NULL, | 2559 | r = mailimap_nstring_parse(fd, buffer, &cur_token, &value, NULL, |
2542 | progr_rate, progr_fun); | 2560 | progr_rate, progr_fun); |
2543 | if (r == MAILIMAP_NO_ERROR) | 2561 | if (r == MAILIMAP_NO_ERROR) |
2544 | type = MAILIMAP_BODY_FLD_LANG_SINGLE; | 2562 | type = MAILIMAP_BODY_FLD_LANG_SINGLE; |
2545 | 2563 | ||
2546 | if (r == MAILIMAP_ERROR_PARSE) { | 2564 | if (r == MAILIMAP_ERROR_PARSE) { |
2547 | r = mailimap_body_fld_lang_list_parse(fd, buffer, &cur_token, &list, | 2565 | r = mailimap_body_fld_lang_list_parse(fd, buffer, &cur_token, &list, |
2548 | progr_rate, progr_fun); | 2566 | progr_rate, progr_fun); |
2549 | if (r == MAILIMAP_NO_ERROR) | 2567 | if (r == MAILIMAP_NO_ERROR) |
2550 | type = MAILIMAP_BODY_FLD_LANG_LIST; | 2568 | type = MAILIMAP_BODY_FLD_LANG_LIST; |
2551 | } | 2569 | } |
2552 | 2570 | ||
2553 | if (r != MAILIMAP_NO_ERROR) { | 2571 | if (r != MAILIMAP_NO_ERROR) { |
2554 | res = r; | 2572 | res = r; |
2555 | goto err; | 2573 | goto err; |
2556 | } | 2574 | } |
2557 | 2575 | ||
2558 | fld_lang = mailimap_body_fld_lang_new(type, value, list); | 2576 | fld_lang = mailimap_body_fld_lang_new(type, value, list); |
2559 | if (fld_lang == NULL) { | 2577 | if (fld_lang == NULL) { |
2560 | res = MAILIMAP_ERROR_MEMORY; | 2578 | res = MAILIMAP_ERROR_MEMORY; |
2561 | goto free; | 2579 | goto free; |
2562 | } | 2580 | } |
2563 | 2581 | ||
2564 | * index = cur_token; | 2582 | * index = cur_token; |
2565 | * result = fld_lang; | 2583 | * result = fld_lang; |
2566 | 2584 | ||
2567 | return MAILIMAP_NO_ERROR; | 2585 | return MAILIMAP_NO_ERROR; |
2568 | 2586 | ||
2569 | free: | 2587 | free: |
2570 | if (value) | 2588 | if (value) |
2571 | mailimap_nstring_free(value); | 2589 | mailimap_nstring_free(value); |
2572 | if (list) { | 2590 | if (list) { |
2573 | clist_foreach(list, (clist_func) mailimap_string_free, NULL); | 2591 | clist_foreach(list, (clist_func) mailimap_string_free, NULL); |
2574 | clist_free(list); | 2592 | clist_free(list); |
2575 | } | 2593 | } |
2576 | err: | 2594 | err: |
2577 | return res; | 2595 | return res; |
2578 | } | 2596 | } |
2579 | 2597 | ||
2580 | /* | 2598 | /* |
2581 | body-fld-lines = number | 2599 | body-fld-lines = number |
2582 | */ | 2600 | */ |
2583 | 2601 | ||
2584 | static int mailimap_body_fld_lines_parse(mailstream * fd, | 2602 | static int mailimap_body_fld_lines_parse(mailstream * fd, |
2585 | MMAPString * buffer, size_t * index, | 2603 | MMAPString * buffer, size_t * index, |
2586 | uint32_t * result) | 2604 | uint32_t * result) |
2587 | { | 2605 | { |
2588 | return mailimap_number_parse(fd, buffer, index, result); | 2606 | return mailimap_number_parse(fd, buffer, index, result); |
2589 | } | 2607 | } |
2590 | 2608 | ||
2591 | /* | 2609 | /* |
2592 | body-fld-md5 = nstring | 2610 | body-fld-md5 = nstring |
2593 | */ | 2611 | */ |
2594 | 2612 | ||
2595 | static int mailimap_body_fld_md5_parse(mailstream * fd, MMAPString * buffer, | 2613 | static int mailimap_body_fld_md5_parse(mailstream * fd, MMAPString * buffer, |
2596 | size_t * index, char ** result, | 2614 | size_t * index, char ** result, |
2597 | size_t progr_rate, | 2615 | size_t progr_rate, |
2598 | progress_function * progr_fun) | 2616 | progress_function * progr_fun) |
2599 | { | 2617 | { |
2600 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, | 2618 | return mailimap_nstring_parse(fd, buffer, index, result, NULL, |
2601 | progr_rate, progr_fun); | 2619 | progr_rate, progr_fun); |
2602 | } | 2620 | } |
2603 | 2621 | ||
2604 | /* | 2622 | /* |
2605 | body-fld-octets = number | 2623 | body-fld-octets = number |
2606 | */ | 2624 | */ |
2607 | 2625 | ||
2608 | static int mailimap_body_fld_octets_parse(mailstream * fd, | 2626 | static int mailimap_body_fld_octets_parse(mailstream * fd, |
2609 | MMAPString * buffer, size_t * index, | 2627 | MMAPString * buffer, size_t * index, |
2610 | uint32_t * result) | 2628 | uint32_t * result) |
2611 | { | 2629 | { |
2612 | return mailimap_number_parse(fd, buffer, index, result); | 2630 | return mailimap_number_parse(fd, buffer, index, result); |
2613 | } | 2631 | } |
2614 | 2632 | ||
2615 | /* | 2633 | /* |
2616 | body-fld-param = "(" string SP string *(SP string SP string) ")" / nil | 2634 | body-fld-param = "(" string SP string *(SP string SP string) ")" / nil |
2617 | */ | 2635 | */ |
2618 | 2636 | ||
2619 | /* | 2637 | /* |
2620 | string SP string | 2638 | string SP string |
2621 | */ | 2639 | */ |
2622 | 2640 | ||
2623 | static int | 2641 | static int |
2624 | mailimap_single_body_fld_param_parse(mailstream * fd, MMAPString * buffer, | 2642 | mailimap_single_body_fld_param_parse(mailstream * fd, MMAPString * buffer, |
2625 | size_t * index, | 2643 | size_t * index, |
2626 | struct mailimap_single_body_fld_param ** | 2644 | struct mailimap_single_body_fld_param ** |
2627 | result, | 2645 | result, |
2628 | size_t progr_rate, | 2646 | size_t progr_rate, |
2629 | progress_function * progr_fun) | 2647 | progress_function * progr_fun) |
2630 | { | 2648 | { |
2631 | struct mailimap_single_body_fld_param * param; | 2649 | struct mailimap_single_body_fld_param * param; |
2632 | char * name; | 2650 | char * name; |
2633 | char * value; | 2651 | char * value; |
2634 | size_t cur_token; | 2652 | size_t cur_token; |
2635 | int r; | 2653 | int r; |
2636 | int res; | 2654 | int res; |
2637 | 2655 | ||
2638 | cur_token = * index; | 2656 | cur_token = * index; |
2639 | 2657 | ||
2640 | name = NULL; | 2658 | name = NULL; |
2641 | value = NULL; | 2659 | value = NULL; |
2642 | 2660 | ||
2643 | r = mailimap_string_parse(fd, buffer, &cur_token, &name, NULL, | 2661 | r = mailimap_string_parse(fd, buffer, &cur_token, &name, NULL, |
2644 | progr_rate, progr_fun); | 2662 | progr_rate, progr_fun); |
2645 | if (r != MAILIMAP_NO_ERROR) { | 2663 | if (r != MAILIMAP_NO_ERROR) { |
2646 | res = r; | 2664 | res = r; |
2647 | goto err; | 2665 | goto err; |
2648 | } | 2666 | } |
2649 | 2667 | ||
2650 | r = mailimap_space_parse(fd, buffer, &cur_token); | 2668 | r = mailimap_space_parse(fd, buffer, &cur_token); |
2651 | if (r != MAILIMAP_NO_ERROR) { | 2669 | if (r != MAILIMAP_NO_ERROR) { |
2652 | res = r; | 2670 | res = r; |
2653 | goto free_name; | 2671 | goto free_name; |
2654 | } | 2672 | } |
2655 | 2673 | ||
2656 | r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL, | 2674 | r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL, |
2657 | progr_rate, progr_fun); | 2675 | progr_rate, progr_fun); |
2658 | if (r != MAILIMAP_NO_ERROR) { | 2676 | if (r != MAILIMAP_NO_ERROR) { |
2659 | res = r; | 2677 | res = r; |
2660 | goto free_name; | 2678 | goto free_name; |
2661 | } | 2679 | } |
2662 | 2680 | ||
2663 | param = mailimap_single_body_fld_param_new(name, value); | 2681 | param = mailimap_single_body_fld_param_new(name, value); |
2664 | if (param == NULL) { | 2682 | if (param == NULL) { |
2665 | res = MAILIMAP_ERROR_MEMORY; | 2683 | res = MAILIMAP_ERROR_MEMORY; |
2666 | goto free_value; | 2684 | goto free_value; |
2667 | } | 2685 | } |
2668 | 2686 | ||
2669 | * result = param; | 2687 | * result = param; |
2670 | * index = cur_token; | 2688 | * index = cur_token; |
2671 | 2689 | ||
2672 | return MAILIMAP_NO_ERROR; | 2690 | return MAILIMAP_NO_ERROR; |
2673 | 2691 | ||
2674 | free_value: | 2692 | free_value: |
2675 | mailimap_string_free(name); | 2693 | mailimap_string_free(name); |
2676 | free_name: | 2694 | free_name: |
2677 | mailimap_string_free(value); | 2695 | mailimap_string_free(value); |
2678 | err: | 2696 | err: |
2679 | return res; | 2697 | return res; |
2680 | } | 2698 | } |
2681 | 2699 | ||
2682 | /* | 2700 | /* |
2683 | body-fld-param = "(" string SP string *(SP string SP string) ")" / nil | 2701 | body-fld-param = "(" string SP string *(SP string SP string) ")" / nil |
2684 | */ | 2702 | */ |
2685 | 2703 | ||
2686 | static int | 2704 | static int |
2687 | mailimap_body_fld_param_parse(mailstream * fd, | 2705 | mailimap_body_fld_param_parse(mailstream * fd, |
2688 | MMAPString * buffer, size_t * index, | 2706 | MMAPString * buffer, size_t * index, |
2689 | struct mailimap_body_fld_param ** result, | 2707 | struct mailimap_body_fld_param ** result, |
2690 | size_t progr_rate, | 2708 | size_t progr_rate, |
2691 | progress_function * progr_fun) | 2709 | progress_function * progr_fun) |
2692 | { | 2710 | { |
2693 | size_t cur_token; | 2711 | size_t cur_token; |
2694 | clist * param_list; | 2712 | clist * param_list; |
2695 | struct mailimap_body_fld_param * fld_param; | 2713 | struct mailimap_body_fld_param * fld_param; |
2696 | int r; | 2714 | int r; |
2697 | int res; | 2715 | int res; |
2698 | 2716 | ||
2699 | param_list = NULL; | 2717 | param_list = NULL; |
2700 | cur_token = * index; | 2718 | cur_token = * index; |
2701 | 2719 | ||
2702 | r = mailimap_nil_parse(fd, buffer, &cur_token); | 2720 | r = mailimap_nil_parse(fd, buffer, &cur_token); |
2703 | if (r == MAILIMAP_NO_ERROR) { | 2721 | if (r == MAILIMAP_NO_ERROR) { |
2704 | * result = NULL; | 2722 | * result = NULL; |
2705 | * index = cur_token; | 2723 | * index = cur_token; |
2706 | return MAILIMAP_NO_ERROR; | 2724 | return MAILIMAP_NO_ERROR; |
2707 | } | 2725 | } |
2708 | 2726 | ||
2709 | if (r != MAILIMAP_ERROR_PARSE) { | 2727 | if (r != MAILIMAP_ERROR_PARSE) { |
2710 | res = r; | 2728 | res = r; |
2711 | goto err; | 2729 | goto err; |
2712 | } | 2730 | } |
2713 | 2731 | ||
2714 | r = mailimap_oparenth_parse(fd, buffer, &cur_token); | 2732 | r = mailimap_oparenth_parse(fd, buffer, &cur_token); |
2715 | if (r != MAILIMAP_NO_ERROR) { | 2733 | if (r != MAILIMAP_NO_ERROR) { |
2716 | res = r; | 2734 | res = r; |
2717 | goto err; | 2735 | goto err; |
2718 | } | 2736 | } |
2719 | 2737 | ||
2720 | r = mailimap_struct_spaced_list_parse(fd, buffer, &cur_token, ¶m_list, | 2738 | r = mailimap_struct_spaced_list_parse(fd, buffer, &cur_token, ¶m_list, |
2721 | (mailimap_struct_parser *) | 2739 | (mailimap_struct_parser *) |
2722 | mailimap_single_body_fld_param_parse, | 2740 | mailimap_single_body_fld_param_parse, |
2723 | (mailimap_struct_destructor *) | 2741 | (mailimap_struct_destructor *) |
2724 | mailimap_single_body_fld_param_free, | 2742 | mailimap_single_body_fld_param_free, |
2725 | progr_rate, progr_fun); | 2743 | progr_rate, progr_fun); |
2726 | if (r != MAILIMAP_NO_ERROR) { | 2744 | if (r != MAILIMAP_NO_ERROR) { |
2727 | res = r; | 2745 | res = r; |
2728 | goto err; | 2746 | goto err; |
2729 | } | 2747 | } |
2730 | 2748 | ||
2731 | r = mailimap_cparenth_parse(fd, buffer, &cur_token); | 2749 | r = mailimap_cparenth_parse(fd, buffer, &cur_token); |
2732 | if (r != MAILIMAP_NO_ERROR) { | 2750 | if (r != MAILIMAP_NO_ERROR) { |
2733 | res = r; | 2751 | res = r; |
2734 | goto free; | 2752 | goto free; |
2735 | } | 2753 | } |
2736 | 2754 | ||
2737 | fld_param = mailimap_body_fld_param_new(param_list); | 2755 | fld_param = mailimap_body_fld_param_new(param_list); |
2738 | if (fld_param == NULL) { | 2756 | if (fld_param == NULL) { |
2739 | res = MAILIMAP_ERROR_MEMORY; | 2757 | res = MAILIMAP_ERROR_MEMORY; |
2740 | goto free; | 2758 | goto free; |
2741 | } | 2759 | } |
2742 | 2760 | ||
2743 | * index = cur_token; | 2761 | * index = cur_token; |
2744 | * result = fld_param; | 2762 | * result = fld_param; |
2745 | 2763 | ||
2746 | return MAILIMAP_NO_ERROR; | 2764 | return MAILIMAP_NO_ERROR; |
2747 | 2765 | ||
2748 | free: | 2766 | free: |
2749 | clist_foreach(param_list, | 2767 | clist_foreach(param_list, |
2750 | (clist_func) mailimap_single_body_fld_param_free, | 2768 | (clist_func) mailimap_single_body_fld_param_free, |
2751 | NULL); | 2769 | NULL); |
2752 | clist_free(param_list); | 2770 | clist_free(param_list); |
2753 | err: | 2771 | err: |
2754 | return res; | 2772 | return res; |
2755 | } | 2773 | } |
2756 | 2774 | ||
2757 | /* | 2775 | /* |
2758 | body-type-1part = (body-type-basic / body-type-msg / body-type-text) | 2776 | body-type-1part = (body-type-basic / body-type-msg / body-type-text) |
2759 | [SP body-ext-1part] | 2777 | [SP body-ext-1part] |
2760 | */ | 2778 | */ |
2761 | 2779 | ||
2762 | static int | 2780 | static int |
2763 | mailimap_body_type_1part_parse(mailstream * fd, MMAPString * buffer, | 2781 | mailimap_body_type_1part_parse(mailstream * fd, MMAPString * buffer, |
2764 | size_t * index, | 2782 | size_t * index, |
2765 | struct mailimap_body_type_1part ** result, | 2783 | struct mailimap_body_type_1part ** result, |
2766 | size_t progr_rate, | 2784 | size_t progr_rate, |
2767 | progress_function * progr_fun) | 2785 | progress_function * progr_fun) |
2768 | { | 2786 | { |
2769 | size_t cur_token; | 2787 | size_t cur_token; |
2770 | struct mailimap_body_type_1part * body_type_1part; | 2788 | struct mailimap_body_type_1part * body_type_1part; |
2771 | struct mailimap_body_type_basic * body_type_basic; | 2789 | struct mailimap_body_type_basic * body_type_basic; |
2772 | struct mailimap_body_type_msg * body_type_msg; | 2790 | struct mailimap_body_type_msg * body_type_msg; |
2773 | struct mailimap_body_type_text * body_type_text; | 2791 | struct mailimap_body_type_text * body_type_text; |
2774 | struct mailimap_body_ext_1part * body_ext_1part; | 2792 | struct mailimap_body_ext_1part * body_ext_1part; |
2775 | int type; | 2793 | int type; |
2776 | size_t final_token; | 2794 | size_t final_token; |
2777 | int r; | 2795 | int r; |
2778 | int res; | 2796 | int res; |
2779 | 2797 | ||
2780 | cur_token = * index; | 2798 | cur_token = * index; |
2781 | 2799 | ||
2782 | body_type_basic = NULL; | 2800 | body_type_basic = NULL; |
2783 | body_type_msg = NULL; | 2801 | body_type_msg = NULL; |
2784 | body_type_text = NULL; | 2802 | body_type_text = NULL; |
2785 | body_ext_1part = NULL; | 2803 | body_ext_1part = NULL; |
2786 | 2804 | ||
2787 | type = MAILIMAP_BODY_TYPE_1PART_ERROR; /* XXX - removes a gcc warning */ | 2805 | type = MAILIMAP_BODY_TYPE_1PART_ERROR; /* XXX - removes a gcc warning */ |
2788 | 2806 | ||
2789 | r = mailimap_body_type_msg_parse(fd, buffer, &cur_token, | 2807 | r = mailimap_body_type_msg_parse(fd, buffer, &cur_token, |
2790 | &body_type_msg, | 2808 | &body_type_msg, |
2791 | progr_rate, progr_fun); | 2809 | progr_rate, progr_fun); |
2792 | if (r == MAILIMAP_NO_ERROR) | 2810 | if (r == MAILIMAP_NO_ERROR) |
2793 | type = MAILIMAP_BODY_TYPE_1PART_MSG; | 2811 | type = MAILIMAP_BODY_TYPE_1PART_MSG; |
2794 | 2812 | ||
2795 | if (r == MAILIMAP_ERROR_PARSE) { | 2813 | if (r == MAILIMAP_ERROR_PARSE) { |
2796 | r = mailimap_body_type_text_parse(fd, buffer, &cur_token, | 2814 | r = mailimap_body_type_text_parse(fd, buffer, &cur_token, |
2797 | &body_type_text, | 2815 | &body_type_text, |
2798 | progr_rate, progr_fun); | 2816 | progr_rate, progr_fun); |
2799 | if (r == MAILIMAP_NO_ERROR) | 2817 | if (r == MAILIMAP_NO_ERROR) |
2800 | type = MAILIMAP_BODY_TYPE_1PART_TEXT; | 2818 | type = MAILIMAP_BODY_TYPE_1PART_TEXT; |
2801 | } | 2819 | } |
2802 | 2820 | ||
2803 | if (r == MAILIMAP_ERROR_PARSE) { | 2821 | if (r == MAILIMAP_ERROR_PARSE) { |
2804 | r = mailimap_body_type_basic_parse(fd, buffer, &cur_token, | 2822 | r = mailimap_body_type_basic_parse(fd, buffer, &cur_token, |
2805 | &body_type_basic, | 2823 | &body_type_basic, |
2806 | progr_rate, progr_fun); | 2824 | progr_rate, progr_fun); |
2807 | if (r == MAILIMAP_NO_ERROR) | 2825 | if (r == MAILIMAP_NO_ERROR) |
2808 | type = MAILIMAP_BODY_TYPE_1PART_BASIC; | 2826 | type = MAILIMAP_BODY_TYPE_1PART_BASIC; |
2809 | } | 2827 | } |
2810 | 2828 | ||
2811 | if (r != MAILIMAP_NO_ERROR) { | 2829 | if (r != MAILIMAP_NO_ERROR) { |
2812 | res = r; | 2830 | res = r; |
2813 | goto err; | 2831 | goto err; |
2814 | } | 2832 | } |
2815 | 2833 | ||
2816 | final_token = cur_token; | 2834 | final_token = cur_token; |
2817 | body_ext_1part = NULL; | 2835 | body_ext_1part = NULL; |
2818 | 2836 | ||
2819 | r = mailimap_space_parse(fd, buffer, &cur_token); | 2837 | r = mailimap_space_parse(fd, buffer, &cur_token); |
2820 | 2838 | ||
2821 | if (r == MAILIMAP_NO_ERROR) { | 2839 | if (r == MAILIMAP_NO_ERROR) { |
2822 | r = mailimap_body_ext_1part_parse(fd, buffer, &cur_token, &body_ext_1part, | 2840 | r = mailimap_body_ext_1part_parse(fd, buffer, &cur_token, &body_ext_1part, |
2823 | progr_rate, progr_fun); | 2841 | progr_rate, progr_fun); |
2824 | if (r == MAILIMAP_NO_ERROR) | 2842 | if (r == MAILIMAP_NO_ERROR) |
2825 | final_token = cur_token; | 2843 | final_token = cur_token; |
2826 | else if (r == MAILIMAP_ERROR_PARSE) { | 2844 | else if (r == MAILIMAP_ERROR_PARSE) { |
2827 | /* do nothing */ | 2845 | /* do nothing */ |
2828 | } | 2846 | } |
2829 | else { | 2847 | else { |
2830 | res = r; | 2848 | res = r; |
2831 | goto free; | 2849 | goto free; |
2832 | } | 2850 | } |
2833 | } | 2851 | } |
2834 | else if (r == MAILIMAP_ERROR_PARSE) { | 2852 | else if (r == MAILIMAP_ERROR_PARSE) { |
2835 | /* do nothing */ | 2853 | /* do nothing */ |
2836 | } | 2854 | } |
2837 | else { | 2855 | else { |
2838 | res = r; | 2856 | res = r; |
2839 | goto free; | 2857 | goto free; |
2840 | } | 2858 | } |
2841 | 2859 | ||
2842 | body_type_1part = mailimap_body_type_1part_new(type, body_type_basic, | 2860 | body_type_1part = mailimap_body_type_1part_new(type, body_type_basic, |
2843 | body_type_msg, body_type_text, | 2861 | body_type_msg, body_type_text, |
2844 | body_ext_1part); | 2862 | body_ext_1part); |
2845 | if (body_type_1part == NULL) { | 2863 | if (body_type_1part == NULL) { |
2846 | res = MAILIMAP_ERROR_MEMORY; | 2864 | res = MAILIMAP_ERROR_MEMORY; |
2847 | goto free; | 2865 | goto free; |
2848 | } | 2866 | } |
2849 | 2867 | ||
2850 | * index = final_token; | 2868 | * index = final_token; |
2851 | * result = body_type_1part; | 2869 | * result = body_type_1part; |
2852 | 2870 | ||
2853 | return MAILIMAP_NO_ERROR; | 2871 | return MAILIMAP_NO_ERROR; |
2854 | 2872 | ||
2855 | free: | 2873 | free: |
2856 | if (body_type_basic) | 2874 | if (body_type_basic) |
2857 | mailimap_body_type_basic_free(body_type_basic); | 2875 | mailimap_body_type_basic_free(body_type_basic); |
2858 | if (body_type_msg) | 2876 | if (body_type_msg) |
2859 | mailimap_body_type_msg_free(body_type_msg); | 2877 | mailimap_body_type_msg_free(body_type_msg); |
2860 | if (body_type_text) | 2878 | if (body_type_text) |
2861 | mailimap_body_type_text_free(body_type_text); | 2879 | mailimap_body_type_text_free(body_type_text); |
2862 | if (body_ext_1part) | 2880 | if (body_ext_1part) |
2863 | mailimap_body_ext_1part_free(body_ext_1part); | 2881 | mailimap_body_ext_1part_free(body_ext_1part); |
2864 | err: | 2882 | err: |
2865 | return res; | 2883 | return res; |
2866 | } | 2884 | } |
2867 | 2885 | ||
2868 | /* | 2886 | /* |
2869 | body-type-basic = media-basic SP body-fields | 2887 | body-type-basic = media-basic SP body-fields |
2870 | ; MESSAGE subtype MUST NOT be "RFC822" | 2888 | ; MESSAGE subtype MUST NOT be "RFC822" |
2871 | */ | 2889 | */ |
2872 | 2890 | ||
2873 | static int | 2891 | static int |
2874 | mailimap_body_type_basic_parse(mailstream * fd, MMAPString * buffer, | 2892 | mailimap_body_type_basic_parse(mailstream * fd, MMAPString * buffer, |
2875 | size_t * index, | 2893 | size_t * index, |
2876 | struct mailimap_body_type_basic ** result, | 2894 | struct mailimap_body_type_basic ** result, |
2877 | size_t progr_rate, | 2895 | size_t progr_rate, |
2878 | progress_function * progr_fun) | 2896 | progress_function * progr_fun) |
2879 | { | 2897 | { |
2880 | size_t cur_token; | 2898 | size_t cur_token; |
2881 | struct mailimap_body_type_basic * body_type_basic; | 2899 | struct mailimap_body_type_basic * body_type_basic; |
2882 | struct mailimap_media_basic * media_basic; | 2900 | struct mailimap_media_basic * media_basic; |
2883 | struct mailimap_body_fields * body_fields; | 2901 | struct mailimap_body_fields * body_fields; |
2884 | int r; | 2902 | int r; |
2885 | int res; | 2903 | int res; |
2886 | 2904 | ||
2887 | cur_token = * index; | 2905 | cur_token = * index; |
2888 | 2906 | ||
2889 | media_basic = NULL; | 2907 | media_basic = NULL; |
2890 | body_fields = NULL; | 2908 | body_fields = NULL; |
2891 | 2909 | ||
2892 | r = mailimap_media_basic_parse(fd, buffer, &cur_token, &media_basic, | 2910 | r = mailimap_media_basic_parse(fd, buffer, &cur_token, &media_basic, |
2893 | progr_rate, progr_fun); | 2911 | progr_rate, progr_fun); |
2894 | if (r != MAILIMAP_NO_ERROR) { | 2912 | if (r != MAILIMAP_NO_ERROR) { |
2895 | res = r; | 2913 | res = r; |
2896 | goto err; | 2914 | goto err; |
2897 | } | 2915 | } |
2898 | 2916 | ||
2899 | r = mailimap_space_parse(fd, buffer, &cur_token); | 2917 | r = mailimap_space_parse(fd, buffer, &cur_token); |
2900 | if (r != MAILIMAP_NO_ERROR) { | 2918 | if (r != MAILIMAP_NO_ERROR) { |
2901 | res = r; | 2919 | res = r; |
2902 | goto free_media_basic; | 2920 | goto free_media_basic; |
2903 | } | 2921 | } |
2904 | 2922 | ||
2905 | r = mailimap_body_fields_parse(fd, buffer, &cur_token, &body_fields, | 2923 | r = mailimap_body_fields_parse(fd, buffer, &cur_token, &body_fields, |
2906 | progr_rate, progr_fun); | 2924 | progr_rate, progr_fun); |
2907 | if (r != MAILIMAP_NO_ERROR) { | 2925 | if (r != MAILIMAP_NO_ERROR) { |
2908 | res = r; | 2926 | res = r; |
2909 | goto free_media_basic; | 2927 | goto free_media_basic; |
2910 | } | 2928 | } |
2911 | 2929 | ||
2912 | body_type_basic = mailimap_body_type_basic_new(media_basic, body_fields); | 2930 | body_type_basic = mailimap_body_type_basic_new(media_basic, body_fields); |
2913 | if (body_type_basic == NULL) { | 2931 | if (body_type_basic == NULL) { |
2914 | res = MAILIMAP_ERROR_MEMORY; | 2932 | res = MAILIMAP_ERROR_MEMORY; |
2915 | goto free_body_fields; | 2933 | goto free_body_fields; |
2916 | } | 2934 | } |
2917 | 2935 | ||
2918 | * index = cur_token; | 2936 | * index = cur_token; |
2919 | * result = body_type_basic; | 2937 | * result = body_type_basic; |
2920 | 2938 | ||
2921 | return MAILIMAP_NO_ERROR; | 2939 | return MAILIMAP_NO_ERROR; |
2922 | 2940 | ||
2923 | free_body_fields: | 2941 | free_body_fields: |
2924 | mailimap_body_fields_free(body_fields); | 2942 | mailimap_body_fields_free(body_fields); |
2925 | free_media_basic: | 2943 | free_media_basic: |
2926 | mailimap_media_basic_free(media_basic); | 2944 | mailimap_media_basic_free(media_basic); |
2927 | err: | 2945 | err: |
2928 | return res; | 2946 | return res; |
2929 | } | 2947 | } |
2930 | 2948 | ||
2931 | /* | 2949 | /* |
2932 | body-type-mpart = 1*body SP media-subtype | 2950 | body-type-mpart = 1*body SP media-subtype |
2933 | [SP body-ext-mpart] | 2951 | [SP body-ext-mpart] |
2934 | */ | 2952 | */ |
2935 | 2953 | ||
2936 | static int | 2954 | static int |
2937 | mailimap_body_type_mpart_parse(mailstream * fd, | 2955 | mailimap_body_type_mpart_parse(mailstream * fd, |
2938 | MMAPString * buffer, | 2956 | MMAPString * buffer, |
2939 | size_t * index, | 2957 | size_t * index, |
2940 | struct mailimap_body_type_mpart ** result, | 2958 | struct mailimap_body_type_mpart ** result, |
2941 | size_t progr_rate, | 2959 | size_t progr_rate, |
2942 | progress_function * progr_fun) | 2960 | progress_function * progr_fun) |
2943 | { | 2961 | { |
2944 | struct mailimap_body_type_mpart * body_type_mpart; | 2962 | struct mailimap_body_type_mpart * body_type_mpart; |
2945 | clist * body_list; | 2963 | clist * body_list; |
2946 | size_t cur_token; | 2964 | size_t cur_token; |
2947 | size_t final_token; | 2965 | size_t final_token; |
2948 | char * media_subtype; | 2966 | char * media_subtype; |
2949 | struct mailimap_body_ext_mpart * body_ext_mpart; | 2967 | struct mailimap_body_ext_mpart * body_ext_mpart; |
2950 | int r; | 2968 | int r; |
2951 | int res; | 2969 | int res; |
2952 | 2970 | ||
2953 | cur_token = * index; | 2971 | cur_token = * index; |
2954 | 2972 | ||
2955 | body_list = NULL; | 2973 | body_list = NULL; |
2956 | media_subtype = NULL; | 2974 | media_subtype = NULL; |
2957 | body_ext_mpart = NULL; | 2975 | body_ext_mpart = NULL; |
2958 | 2976 | ||
2959 | r = mailimap_struct_multiple_parse(fd, buffer, &cur_token, | 2977 | r = mailimap_struct_multiple_parse(fd, buffer, &cur_token, |
2960 | &body_list, | 2978 | &body_list, |
2961 | (mailimap_struct_parser *) | 2979 | (mailimap_struct_parser *) |
2962 | mailimap_body_parse, | 2980 | mailimap_body_parse, |
2963 | (mailimap_struct_destructor *) | 2981 | (mailimap_struct_destructor *) |
2964 | mailimap_body_free, | 2982 | mailimap_body_free, |
2965 | progr_rate, progr_fun); | 2983 | progr_rate, progr_fun); |
2966 | if (r != MAILIMAP_NO_ERROR) { | 2984 | if (r != MAILIMAP_NO_ERROR) { |
2967 | res = r; | 2985 | res = r; |
2968 | goto err; | 2986 | goto err; |
2969 | } | 2987 | } |
2970 | 2988 | ||
2971 | r = mailimap_space_parse(fd, buffer, &cur_token); | 2989 | r = mailimap_space_parse(fd, buffer, &cur_token); |
2972 | if (r != MAILIMAP_NO_ERROR) { | 2990 | if (r != MAILIMAP_NO_ERROR) { |
2973 | res = r; | 2991 | res = r; |
2974 | goto free_body_list; | 2992 | goto free_body_list; |
2975 | } | 2993 | } |
2976 | 2994 | ||
2977 | r = mailimap_media_subtype_parse(fd, buffer, &cur_token, &media_subtype, | 2995 | r = mailimap_media_subtype_parse(fd, buffer, &cur_token, &media_subtype, |
2978 | progr_rate, progr_fun); | 2996 | progr_rate, progr_fun); |
2979 | if (r != MAILIMAP_NO_ERROR) { | 2997 | if (r != MAILIMAP_NO_ERROR) { |
2980 | res = r; | 2998 | res = r; |
2981 | goto free_body_list; | 2999 | goto free_body_list; |
2982 | } | 3000 | } |
2983 | 3001 | ||
2984 | final_token = cur_token; | 3002 | final_token = cur_token; |
2985 | 3003 | ||
2986 | body_ext_mpart = NULL; | 3004 | body_ext_mpart = NULL; |
2987 | 3005 | ||
2988 | r = mailimap_space_parse(fd, buffer, &cur_token); | 3006 | r = mailimap_space_parse(fd, buffer, &cur_token); |
2989 | if (r == MAILIMAP_NO_ERROR) { | 3007 | if (r == MAILIMAP_NO_ERROR) { |
2990 | r = mailimap_body_ext_mpart_parse(fd, buffer, &cur_token, &body_ext_mpart, | 3008 | r = mailimap_body_ext_mpart_parse(fd, buffer, &cur_token, &body_ext_mpart, |
2991 | progr_rate, progr_fun); | 3009 | progr_rate, progr_fun); |
2992 | if (r == MAILIMAP_NO_ERROR) | 3010 | if (r == MAILIMAP_NO_ERROR) |
2993 | final_token = cur_token; | 3011 | final_token = cur_token; |
2994 | else if (r == MAILIMAP_ERROR_PARSE) { | 3012 | else if (r == MAILIMAP_ERROR_PARSE) { |
2995 | /* do nothing */ | 3013 | /* do nothing */ |
2996 | } | 3014 | } |
2997 | else { | 3015 | else { |
2998 | res = r; | 3016 | res = r; |
2999 | goto free_body_list; | 3017 | goto free_body_list; |
3000 | } | 3018 | } |
3001 | } | 3019 | } |
3002 | else if (r == MAILIMAP_ERROR_PARSE) { | 3020 | else if (r == MAILIMAP_ERROR_PARSE) { |
3003 | /* do nothing */ | 3021 | /* do nothing */ |
3004 | } | 3022 | } |
3005 | else { | 3023 | else { |
3006 | res = r; | 3024 | res = r; |
3007 | goto free_body_list; | 3025 | goto free_body_list; |
3008 | } | 3026 | } |
3009 | 3027 | ||
3010 | body_type_mpart = mailimap_body_type_mpart_new(body_list, media_subtype, | 3028 | body_type_mpart = mailimap_body_type_mpart_new(body_list, media_subtype, |
3011 | body_ext_mpart); | 3029 | body_ext_mpart); |
3012 | if (body_type_mpart == NULL) { | 3030 | if (body_type_mpart == NULL) { |
3013 | res = MAILIMAP_ERROR_MEMORY; | 3031 | res = MAILIMAP_ERROR_MEMORY; |
3014 | goto free_body_ext_mpart; | 3032 | goto free_body_ext_mpart; |
3015 | } | 3033 | } |
3016 | 3034 | ||
3017 | * result = body_type_mpart; | 3035 | * result = body_type_mpart; |
3018 | * index = final_token; | 3036 | * index = final_token; |
3019 | 3037 | ||
3020 | return MAILIMAP_NO_ERROR; | 3038 | return MAILIMAP_NO_ERROR; |
3021 | 3039 | ||
3022 | free_body_ext_mpart: | 3040 | free_body_ext_mpart: |
3023 | if (body_ext_mpart) | 3041 | if (body_ext_mpart) |
3024 | mailimap_body_ext_mpart_free(body_ext_mpart); | 3042 | mailimap_body_ext_mpart_free(body_ext_mpart); |
3025 | mailimap_media_subtype_free(media_subtype); | 3043 | mailimap_media_subtype_free(media_subtype); |
3026 | free_body_list: | 3044 | free_body_list: |
3027 | clist_foreach(body_list, (clist_func) mailimap_body_free, NULL); | 3045 | clist_foreach(body_list, (clist_func) mailimap_body_free, NULL); |
3028 | clist_free(body_list); | 3046 | clist_free(body_list); |
3029 | err: | 3047 | err: |
3030 | return res; | 3048 | return res; |
3031 | } | 3049 | } |
3032 | 3050 | ||
3033 | /* | 3051 | /* |
3034 | body-type-msg = media-message SP body-fields SP envelope | 3052 | body-type-msg = media-message SP body-fields SP envelope |
3035 | SP body SP body-fld-lines | 3053 | SP body SP body-fld-lines |
3036 | */ | 3054 | */ |
3037 | 3055 | ||
3038 | static int | 3056 | static int |
3039 | mailimap_body_type_msg_parse(mailstream * fd, MMAPString * buffer, | 3057 | mailimap_body_type_msg_parse(mailstream * fd, MMAPString * buffer, |
3040 | size_t * index, | 3058 | size_t * index, |
3041 | struct mailimap_body_type_msg ** result, | 3059 | struct mailimap_body_type_msg ** result, |
3042 | size_t progr_rate, | 3060 | size_t progr_rate, |
3043 | progress_function * progr_fun) | 3061 | progress_function * progr_fun) |
3044 | { | 3062 | { |
3045 | struct mailimap_body_fields * body_fields; | 3063 | struct mailimap_body_fields * body_fields; |
3046 | struct mailimap_envelope * envelope; | 3064 | struct mailimap_envelope * envelope; |
3047 | struct mailimap_body * body; | 3065 | struct mailimap_body * body; |
3048 | uint32_t body_fld_lines; | 3066 | uint32_t body_fld_lines; |
3049 | struct mailimap_body_type_msg * body_type_msg; | 3067 | struct mailimap_body_type_msg * body_type_msg; |
3050 | size_t cur_token; | 3068 | size_t cur_token; |
3051 | int r; | 3069 | int r; |
3052 | int res; | 3070 | int res; |
3053 | 3071 | ||
3054 | cur_token = * index; | 3072 | cur_token = * index; |
3055 | 3073 | ||
3056 | body_fields = NULL; | 3074 | body_fields = NULL; |
3057 | envelope = NULL; | 3075 | envelope = NULL; |
3058 | body = NULL; | 3076 | body = NULL; |
3059 | body_fld_lines = 0; | 3077 | body_fld_lines = 0; |
3060 | 3078 | ||
3061 | r = mailimap_media_message_parse(fd, buffer, &cur_token); | 3079 | r = mailimap_media_message_parse(fd, buffer, &cur_token); |
3062 | if (r != MAILIMAP_NO_ERROR) { | 3080 | if (r != MAILIMAP_NO_ERROR) { |
3063 | res = r; | 3081 | res = r; |
3064 | goto err; | 3082 | goto err; |
3065 | } | 3083 | } |
3066 | 3084 | ||
3067 | r = mailimap_space_parse(fd, buffer, &cur_token); | 3085 | r = mailimap_space_parse(fd, buffer, &cur_token); |
3068 | if (r != MAILIMAP_NO_ERROR) { | 3086 | if (r != MAILIMAP_NO_ERROR) { |
3069 | res = r; | 3087 | res = r; |
3070 | goto err; | 3088 | goto err; |
3071 | } | 3089 | } |
3072 | 3090 | ||
3073 | r = mailimap_body_fields_parse(fd, buffer, &cur_token, &body_fields, | 3091 | r = mailimap_body_fields_parse(fd, buffer, &cur_token, &body_fields, |
3074 | progr_rate, progr_fun); | 3092 | progr_rate, progr_fun); |
3075 | if (r != MAILIMAP_NO_ERROR) { | 3093 | if (r != MAILIMAP_NO_ERROR) { |
3076 | res = r; | 3094 | res = r; |
3077 | goto err; | 3095 | goto err; |
3078 | } | 3096 | } |
3079 | 3097 | ||
3080 | r = mailimap_space_parse(fd, buffer, &cur_token); | 3098 | r = mailimap_space_parse(fd, buffer, &cur_token); |
3081 | if (r != MAILIMAP_NO_ERROR) { | 3099 | if (r != MAILIMAP_NO_ERROR) { |
3082 | res = r; | 3100 | res = r; |
3083 | goto body_fields; | 3101 | goto body_fields; |
3084 | } | 3102 | } |
3085 | 3103 | ||
3086 | r = mailimap_envelope_parse(fd, buffer, &cur_token, &envelope, | 3104 | r = mailimap_envelope_parse(fd, buffer, &cur_token, &envelope, |
3087 | progr_rate, progr_fun); | 3105 | progr_rate, progr_fun); |
3088 | if (r != MAILIMAP_NO_ERROR) { | 3106 | if (r != MAILIMAP_NO_ERROR) { |
3089 | res = r; | 3107 | res = r; |
3090 | goto body_fields; | 3108 | goto body_fields; |
3091 | } | 3109 | } |
3092 | 3110 | ||
3093 | r = mailimap_space_parse(fd, buffer, &cur_token); | 3111 | r = mailimap_space_parse(fd, buffer, &cur_token); |
3094 | if (r != MAILIMAP_NO_ERROR) { | 3112 | if (r != MAILIMAP_NO_ERROR) { |
3095 | res = r; | 3113 | res = r; |
3096 | goto envelope; | 3114 | goto envelope; |
3097 | } | 3115 | } |
3098 | 3116 | ||
3099 | r = mailimap_body_parse(fd, buffer, &cur_token, &body, | 3117 | r = mailimap_body_parse(fd, buffer, &cur_token, &body, |
3100 | progr_rate, progr_fun); | 3118 | progr_rate, progr_fun); |
3101 | if (r != MAILIMAP_NO_ERROR) { | 3119 | if (r != MAILIMAP_NO_ERROR) { |
3102 | res = r; | 3120 | res = r; |
3103 | goto envelope; | 3121 | goto envelope; |
3104 | } | 3122 | } |
3105 | 3123 | ||
3106 | r = mailimap_space_parse(fd, buffer, &cur_token); | 3124 | r = mailimap_space_parse(fd, buffer, &cur_token); |
3107 | if (r != MAILIMAP_NO_ERROR) { | 3125 | if (r != MAILIMAP_NO_ERROR) { |
3108 | res = r; | 3126 | res = r; |
3109 | goto body; | 3127 | goto body; |
3110 | } | 3128 | } |
3111 | 3129 | ||
3112 | r = mailimap_body_fld_lines_parse(fd, buffer, &cur_token, | 3130 | r = mailimap_body_fld_lines_parse(fd, buffer, &cur_token, |
3113 | &body_fld_lines); | 3131 | &body_fld_lines); |
3114 | if (r != MAILIMAP_NO_ERROR) { | 3132 | if (r != MAILIMAP_NO_ERROR) { |
3115 | res = r; | 3133 | res = r; |
3116 | goto body; | 3134 | goto body; |
3117 | } | 3135 | } |
3118 | 3136 | ||
3119 | body_type_msg = mailimap_body_type_msg_new(body_fields, envelope, | 3137 | body_type_msg = mailimap_body_type_msg_new(body_fields, envelope, |
3120 | body, body_fld_lines); | 3138 | body, body_fld_lines); |
3121 | if (body_type_msg == NULL) { | 3139 | if (body_type_msg == NULL) { |
3122 | res = MAILIMAP_ERROR_MEMORY; | 3140 | res = MAILIMAP_ERROR_MEMORY; |
3123 | goto body; | 3141 | goto body; |
3124 | } | 3142 | } |
3125 | 3143 | ||
3126 | * result = body_type_msg; | 3144 | * result = body_type_msg; |
3127 | * index = cur_token; | 3145 | * index = cur_token; |
3128 | 3146 | ||
3129 | return MAILIMAP_NO_ERROR; | 3147 | return MAILIMAP_NO_ERROR; |
3130 | 3148 | ||
3131 | body: | 3149 | body: |
3132 | mailimap_body_free(body); | 3150 | mailimap_body_free(body); |
3133 | envelope: | 3151 | envelope: |
3134 | mailimap_envelope_free(envelope); | 3152 | mailimap_envelope_free(envelope); |
3135 | body_fields: | 3153 | body_fields: |
3136 | mailimap_body_fields_free(body_fields); | 3154 | mailimap_body_fields_free(body_fields); |
3137 | err: | 3155 | err: |
3138 | return res; | 3156 | return res; |
3139 | } | 3157 | } |
3140 | 3158 | ||
3141 | /* | 3159 | /* |
3142 | body-type-text = media-text SP body-fields SP body-fld-lines | 3160 | body-type-text = media-text SP body-fields SP body-fld-lines |
3143 | */ | 3161 | */ |
3144 | 3162 | ||
3145 | static int | 3163 | static int |
3146 | mailimap_body_type_text_parse(mailstream * fd, MMAPString * buffer, | 3164 | mailimap_body_type_text_parse(mailstream * fd, MMAPString * buffer, |
3147 | size_t * index, | 3165 | size_t * index, |
3148 | struct mailimap_body_type_text ** | 3166 | struct mailimap_body_type_text ** |
3149 | result, | 3167 | result, |
3150 | size_t progr_rate, | 3168 | size_t progr_rate, |
3151 | progress_function * progr_fun) | 3169 | progress_function * progr_fun) |
3152 | { | 3170 | { |
3153 | char * media_text; | 3171 | char * media_text; |
3154 | struct mailimap_body_fields * body_fields; | 3172 | struct mailimap_body_fields * body_fields; |
3155 | uint32_t body_fld_lines; | 3173 | uint32_t body_fld_lines; |
3156 | struct mailimap_body_type_text * body_type_text; | 3174 | struct mailimap_body_type_text * body_type_text; |
3157 | size_t cur_token; | 3175 | size_t cur_token; |
3158 | int r; | 3176 | int r; |
3159 | int res; | 3177 | int res; |
3160 | 3178 | ||
3161 | media_text = NULL; | 3179 | media_text = NULL; |
3162 | body_fields = NULL; | 3180 | body_fields = NULL; |
3163 | body_fld_lines = 0; | 3181 | body_fld_lines = 0; |
3164 | 3182 | ||
3165 | cur_token = * index; | 3183 | cur_token = * index; |
3166 | 3184 | ||
3167 | r = mailimap_media_text_parse(fd, buffer, &cur_token, &media_text, | 3185 | r = mailimap_media_text_parse(fd, buffer, &cur_token, &media_text, |
3168 | progr_rate, progr_fun); | 3186 | progr_rate, progr_fun); |
3169 | if (r != MAILIMAP_NO_ERROR) { | 3187 | if (r != MAILIMAP_NO_ERROR) { |
3170 | res = r; | 3188 | res = r; |
3171 | goto err; | 3189 | goto err; |
3172 | } | 3190 | } |
3173 | 3191 | ||
3174 | r = mailimap_space_parse(fd, buffer, &cur_token); | 3192 | r = mailimap_space_parse(fd, buffer, &cur_token); |
3175 | if (r != MAILIMAP_NO_ERROR) { | 3193 | if (r != MAILIMAP_NO_ERROR) { |
3176 | res = r; | 3194 | res = r; |
3177 | goto free_media_text; | 3195 | goto free_media_text; |
3178 | } | 3196 | } |
3179 | 3197 | ||
3180 | r = mailimap_body_fields_parse(fd, buffer, &cur_token, &body_fields, | 3198 | r = mailimap_body_fields_parse(fd, buffer, &cur_token, &body_fields, |
3181 | progr_rate, progr_fun); | 3199 | progr_rate, progr_fun); |
3182 | if (r != MAILIMAP_NO_ERROR) { | 3200 | if (r != MAILIMAP_NO_ERROR) { |
3183 | res = r; | 3201 | res = r; |
3184 | goto free_media_text; | 3202 | goto free_media_text; |
3185 | } | 3203 | } |
3186 | 3204 | ||
3187 | r = mailimap_space_parse(fd, buffer, &cur_token); | 3205 | r = mailimap_space_parse(fd, buffer, &cur_token); |
3188 | if (r != MAILIMAP_NO_ERROR) { | 3206 | if (r != MAILIMAP_NO_ERROR) { |
3189 | res = r; | 3207 | res = r; |
3190 | goto free_body_fields; | 3208 | goto free_body_fields; |
3191 | } | 3209 | } |
3192 | 3210 | ||
3193 | r = mailimap_body_fld_lines_parse(fd, buffer, &cur_token, &body_fld_lines); | 3211 | r = mailimap_body_fld_lines_parse(fd, buffer, &cur_token, &body_fld_lines); |
3194 | if (r != MAILIMAP_NO_ERROR) { | 3212 | if (r != MAILIMAP_NO_ERROR) { |
3195 | res = r; | 3213 | res = r; |
3196 | goto free_body_fields; | 3214 | goto free_body_fields; |
3197 | } | 3215 | } |
3198 | 3216 | ||
3199 | body_type_text = mailimap_body_type_text_new(media_text, body_fields, | 3217 | body_type_text = mailimap_body_type_text_new(media_text, body_fields, |
3200 | body_fld_lines); | 3218 | body_fld_lines); |
3201 | if (body_type_text == NULL) { | 3219 | if (body_type_text == NULL) { |
3202 | res = MAILIMAP_ERROR_MEMORY; | 3220 | res = MAILIMAP_ERROR_MEMORY; |
3203 | goto free_body_fields; | 3221 | goto free_body_fields; |
3204 | } | 3222 | } |
3205 | 3223 | ||
3206 | * result = body_type_text; | 3224 | * result = body_type_text; |
3207 | * index = cur_token; | 3225 | * index = cur_token; |
3208 | 3226 | ||
3209 | return MAILIMAP_NO_ERROR; | 3227 | return MAILIMAP_NO_ERROR; |
3210 | 3228 | ||
3211 | free_body_fields: | 3229 | free_body_fields: |
3212 | mailimap_body_fields_free(body_fields); | 3230 | mailimap_body_fields_free(body_fields); |
3213 | free_media_text: | 3231 | free_media_text: |
3214 | mailimap_media_text_free(media_text); | 3232 | mailimap_media_text_free(media_text); |
3215 | err: | 3233 | err: |
3216 | return res; | 3234 | return res; |
3217 | } | 3235 | } |
3218 | 3236 | ||
3219 | 3237 | ||
3220 | /* | 3238 | /* |
3221 | capability = ("AUTH=" auth-type) / atom | 3239 | capability = ("AUTH=" auth-type) / atom |
3222 | ; New capabilities MUST begin with "X" or be | 3240 | ; New capabilities MUST begin with "X" or be |
3223 | ; registered with IANA as standard or | 3241 | ; registered with IANA as standard or |
3224 | ; standards-track | 3242 | ; standards-track |
3225 | */ | 3243 | */ |
3226 | 3244 | ||
3227 | static int | 3245 | static int |
3228 | mailimap_capability_parse(mailstream * fd, MMAPString * buffer, | 3246 | mailimap_capability_parse(mailstream * fd, MMAPString * buffer, |
3229 | size_t * index, | 3247 | size_t * index, |
3230 | struct mailimap_capability ** result, | 3248 | struct mailimap_capability ** result, |
3231 | size_t progr_rate, | 3249 | size_t progr_rate, |
3232 | progress_function * progr_fun) | 3250 | progress_function * progr_fun) |
3233 | { | 3251 | { |
3234 | size_t cur_token; | 3252 | size_t cur_token; |
3235 | int type; | 3253 | int type; |
3236 | char * auth_type; | 3254 | char * auth_type; |
3237 | char * atom; | 3255 | char * atom; |
3238 | struct mailimap_capability * cap; | 3256 | struct mailimap_capability * cap; |
3239 | int r; | 3257 | int r; |
3240 | int res; | 3258 | int res; |
3241 | 3259 | ||
3242 | cur_token = * index; | 3260 | cur_token = * index; |
3243 | 3261 | ||
3244 | auth_type = NULL; | 3262 | auth_type = NULL; |
3245 | atom = NULL; | 3263 | atom = NULL; |
3246 | 3264 | ||
3247 | r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "AUTH="); | 3265 | r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "AUTH="); |
3248 | switch (r) { | 3266 | switch (r) { |
3249 | case MAILIMAP_NO_ERROR: | 3267 | case MAILIMAP_NO_ERROR: |
3250 | type = MAILIMAP_CAPABILITY_AUTH_TYPE; | 3268 | type = MAILIMAP_CAPABILITY_AUTH_TYPE; |
3251 | 3269 | ||
3252 | r = mailimap_auth_type_parse(fd, buffer, &cur_token, &auth_type, | 3270 | r = mailimap_auth_type_parse(fd, buffer, &cur_token, &auth_type, |
3253 | progr_rate, progr_fun); | 3271 | progr_rate, progr_fun); |
3254 | if (r != MAILIMAP_NO_ERROR) { | 3272 | if (r != MAILIMAP_NO_ERROR) { |
3255 | res = r; | 3273 | res = r; |
3256 | goto err; | 3274 | goto err; |
3257 | } | 3275 | } |
3258 | break; | 3276 | break; |
3259 | 3277 | ||
3260 | case MAILIMAP_ERROR_PARSE: | 3278 | case MAILIMAP_ERROR_PARSE: |
3261 | r = mailimap_atom_parse(fd, buffer, &cur_token, &atom, | 3279 | r = mailimap_atom_parse(fd, buffer, &cur_token, &atom, |
3262 | progr_rate, progr_fun); | 3280 | progr_rate, progr_fun); |
3263 | if (r != MAILIMAP_NO_ERROR) { | 3281 | if (r != MAILIMAP_NO_ERROR) { |
3264 | res = r; | 3282 | res = r; |
3265 | goto err; | 3283 | goto err; |
3266 | } | 3284 | } |
3267 | 3285 | ||
3268 | type = MAILIMAP_CAPABILITY_NAME; | 3286 | type = MAILIMAP_CAPABILITY_NAME; |
3269 | break; | 3287 | break; |
3270 | 3288 | ||
3271 | default: | 3289 | default: |
3272 | res = r; | 3290 | res = r; |
3273 | goto err; | 3291 | goto err; |
3274 | } | 3292 | } |
3275 | 3293 | ||
3276 | cap = mailimap_capability_new(type, auth_type, atom); | 3294 | cap = mailimap_capability_new(type, auth_type, atom); |
3277 | if (cap == NULL) { | 3295 | if (cap == NULL) { |
3278 | res = MAILIMAP_ERROR_MEMORY; | 3296 | res = MAILIMAP_ERROR_MEMORY; |
3279 | goto free; | 3297 | goto free; |
3280 | } | 3298 | } |
3281 | 3299 | ||
3282 | * result = cap; | 3300 | * result = cap; |
3283 | * index = cur_token; | 3301 | * index = cur_token; |
3284 | 3302 | ||
3285 | return MAILIMAP_NO_ERROR; | 3303 | return MAILIMAP_NO_ERROR; |
3286 | 3304 | ||
3287 | free: | 3305 | free: |
3288 | if (auth_type) | 3306 | if (auth_type) |
3289 | mailimap_auth_type_free(auth_type); | 3307 | mailimap_auth_type_free(auth_type); |
3290 | if (atom) | 3308 | if (atom) |
3291 | mailimap_atom_free(atom); | 3309 | mailimap_atom_free(atom); |
3292 | err: | 3310 | err: |
3293 | return res; | 3311 | return res; |
3294 | } | 3312 | } |
3295 | 3313 | ||
3296 | /* | 3314 | /* |
3297 | capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev1" | 3315 | capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev1" |
3298 | *(SP capability) | 3316 | *(SP capability) |
3299 | ; IMAP4rev1 servers which offer RFC 1730 | 3317 | ; IMAP4rev1 servers which offer RFC 1730 |
3300 | ; compatibility MUST list "IMAP4" as the first | 3318 | ; compatibility MUST list "IMAP4" as the first |
3301 | ; capability. | 3319 | ; capability. |
3302 | */ | 3320 | */ |
3303 | 3321 | ||
3304 | /* | 3322 | /* |
3305 | SP capability *(SP capability) | 3323 | SP capability *(SP capability) |
3306 | */ | 3324 | */ |
3307 | 3325 | ||
3308 | static int mailimap_capability_list_parse(mailstream * fd, | 3326 | static int mailimap_capability_list_parse(mailstream * fd, |
3309 | MMAPString * buffer, | 3327 | MMAPString * buffer, |
3310 | size_t * index, | 3328 | size_t * index, |
3311 | clist ** result, | 3329 | clist ** result, |
3312 | size_t progr_rate, | 3330 | size_t progr_rate, |
3313 | progress_function * progr_fun) | 3331 | progress_function * progr_fun) |
3314 | { | 3332 | { |
3315 | size_t cur_token; | 3333 | size_t cur_token; |
3316 | clist * list; | 3334 | clist * list; |
3317 | int r; | 3335 | int r; |
3318 | 3336 | ||
3319 | cur_token = * index; | 3337 | cur_token = * index; |
3320 | 3338 | ||
3321 | r = mailimap_space_parse(fd, buffer, &cur_token); | 3339 | r = mailimap_space_parse(fd, buffer, &cur_token); |
3322 | if (r != MAILIMAP_NO_ERROR) | 3340 | if (r != MAILIMAP_NO_ERROR) |
3323 | return r; | 3341 | return r; |
3324 | 3342 | ||
3325 | r = mailimap_struct_spaced_list_parse(fd, buffer, &cur_token, &list, | 3343 | r = mailimap_struct_spaced_list_parse(fd, buffer, &cur_token, &list, |
3326 | (mailimap_struct_parser *) | 3344 | (mailimap_struct_parser *) |
3327 | mailimap_capability_parse, | 3345 | mailimap_capability_parse, |
3328 | (mailimap_struct_destructor *) | 3346 | (mailimap_struct_destructor *) |
3329 | mailimap_capability_free, | 3347 | mailimap_capability_free, |
3330 | progr_rate, progr_fun); | 3348 | progr_rate, progr_fun); |
3331 | if (r != MAILIMAP_NO_ERROR) | 3349 | if (r != MAILIMAP_NO_ERROR) |
3332 | return r; | 3350 | return r; |
3333 | 3351 | ||
3334 | * index = cur_token; | 3352 | * index = cur_token; |
3335 | * result = list; | 3353 | * result = list; |
3336 | 3354 | ||
3337 | return MAILIMAP_NO_ERROR; | 3355 | return MAILIMAP_NO_ERROR; |
3338 | } | 3356 | } |
3339 | 3357 | ||
3340 | static int | 3358 | static int |
3341 | mailimap_capability_data_parse(mailstream * fd, MMAPString * buffer, | 3359 | mailimap_capability_data_parse(mailstream * fd, MMAPString * buffer, |
3342 | size_t * index, | 3360 | size_t * index, |
3343 | struct mailimap_capability_data ** result, | 3361 | struct mailimap_capability_data ** result, |
3344 | size_t progr_rate, | 3362 | size_t progr_rate, |
3345 | progress_function * progr_fun) | 3363 | progress_function * progr_fun) |
3346 | { | 3364 | { |
3347 | size_t cur_token; | 3365 | size_t cur_token; |
3348 | clist * cap_list; | 3366 | clist * cap_list; |
3349 | #if 0 | 3367 | #if 0 |
3350 | clist * cap_list_2; | 3368 | clist * cap_list_2; |
3351 | #endif | 3369 | #endif |
3352 | struct mailimap_capability_data * cap_data; | 3370 | struct mailimap_capability_data * cap_data; |
3353 | int r; | 3371 | int r; |
3354 | int res; | 3372 | int res; |
3355 | 3373 | ||
3356 | cur_token = * index; | 3374 | cur_token = * index; |
3357 | 3375 | ||
3358 | cap_list = NULL; | 3376 | cap_list = NULL; |
3359 | #if 0 | 3377 | #if 0 |
3360 | cap_list_2 = NULL; | 3378 | cap_list_2 = NULL; |
3361 | #endif | 3379 | #endif |
3362 | 3380 | ||
3363 | r = mailimap_token_case_insensitive_parse(fd, buffer, | 3381 | r = mailimap_token_case_insensitive_parse(fd, buffer, |
3364 | &cur_token, "CAPABILITY"); | 3382 | &cur_token, "CAPABILITY"); |
3365 | if (r != MAILIMAP_NO_ERROR) { | 3383 | if (r != MAILIMAP_NO_ERROR) { |
3366 | res = r; | 3384 | res = r; |
3367 | goto err; | 3385 | goto err; |
3368 | } | 3386 | } |
3369 | 3387 | ||
3370 | r = mailimap_capability_list_parse(fd, buffer, &cur_token, | 3388 | r = mailimap_capability_list_parse(fd, buffer, &cur_token, |
3371 | &cap_list, | 3389 | &cap_list, |
3372 | progr_rate, progr_fun); | 3390 | progr_rate, progr_fun); |
3373 | 3391 | ||
3374 | if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) { | 3392 | if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) { |
3375 | res = r; | 3393 | res = r; |
3376 | goto err; | 3394 | goto err; |
3377 | } | 3395 | } |
3378 | 3396 | ||
3379 | #if 0 | 3397 | #if 0 |
3380 | if (!mailimap_space_parse(fd, buffer, &cur_token)) { | 3398 | if (!mailimap_space_parse(fd, buffer, &cur_token)) { |
3381 | res = r; | 3399 | res = r; |
3382 | goto free_list; | 3400 | goto free_list; |
3383 | } | 3401 | } |
3384 | 3402 | ||
3385 | if (!mailimap_token_case_insensitive_parse(fd, buffer, | 3403 | if (!mailimap_token_case_insensitive_parse(fd, buffer, |
3386 | &cur_token, "IMAP4rev1")) | 3404 | &cur_token, "IMAP4rev1")) |
3387 | goto free_list; | 3405 | goto free_list; |
3388 | 3406 | ||
3389 | r = mailimap_capability_list_parse(fd, buffer, &cur_token, | 3407 | r = mailimap_capability_list_parse(fd, buffer, &cur_token, |
3390 | &cap_list_2, | 3408 | &cap_list_2, |
3391 | progr_rate, progr_fun); | 3409 | progr_rate, progr_fun); |
3392 | 3410 | ||
3393 | cap_list = g_list_concat(cap_list, cap_list_2); | 3411 | cap_list = g_list_concat(cap_list, cap_list_2); |
3394 | #endif | 3412 | #endif |
3395 | 3413 | ||
3396 | cap_data = mailimap_capability_data_new(cap_list); | 3414 | cap_data = mailimap_capability_data_new(cap_list); |
3397 | if (cap_data == NULL) { | 3415 | if (cap_data == NULL) { |
3398 | res = MAILIMAP_ERROR_MEMORY; | 3416 | res = MAILIMAP_ERROR_MEMORY; |
3399 | goto free_list; | 3417 | goto free_list; |
3400 | } | 3418 | } |
3401 | 3419 | ||
3402 | * result = cap_data; | 3420 | * result = cap_data; |
3403 | * index = cur_token; | 3421 | * index = cur_token; |
3404 | 3422 | ||
3405 | return MAILIMAP_NO_ERROR; | 3423 | return MAILIMAP_NO_ERROR; |
3406 | 3424 | ||
3407 | free_list: | 3425 | free_list: |
3408 | if (cap_list) { | 3426 | if (cap_list) { |
3409 | clist_foreach(cap_list, (clist_func) mailimap_capability_free, NULL); | 3427 | clist_foreach(cap_list, (clist_func) mailimap_capability_free, NULL); |
3410 | clist_free(cap_list); | 3428 | clist_free(cap_list); |
3411 | } | 3429 | } |
3412 | err: | 3430 | err: |
3413 | return res; | 3431 | return res; |
3414 | } | 3432 | } |
3415 | 3433 | ||
3416 | /* | 3434 | /* |
3417 | UNIMPLEMENTED BECAUSE UNUSED (only in literal) | 3435 | UNIMPLEMENTED BECAUSE UNUSED (only in literal) |
3418 | CHAR8 = %x01-ff | 3436 | CHAR8 = %x01-ff |
3419 | ; any OCTET except NUL, %x00 | 3437 | ; any OCTET except NUL, %x00 |
3420 | */ | 3438 | */ |
3421 | 3439 | ||
3422 | /* | 3440 | /* |
3423 | static gboolean is_char8(gchar ch) | 3441 | static gboolean is_char8(gchar ch) |
3424 | { | 3442 | { |
3425 | return (ch != 0x00); | 3443 | return (ch != 0x00); |
3426 | } | 3444 | } |
3427 | */ | 3445 | */ |
3428 | 3446 | ||
3429 | 3447 | ||
3430 | /* | 3448 | /* |
3431 | UNIMPLEMENTED | 3449 | UNIMPLEMENTED |
3432 | command = tag SP (command-any / command-auth / command-nonauth / | 3450 | command = tag SP (command-any / command-auth / command-nonauth / |
3433 | command-select) CRLF | 3451 | command-select) CRLF |
3434 | ; Modal based on state | 3452 | ; Modal based on state |
3435 | */ | 3453 | */ |
3436 | 3454 | ||
3437 | /* | 3455 | /* |
3438 | UNIMPLEMENTED | 3456 | UNIMPLEMENTED |
3439 | command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / x-command | 3457 | command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / x-command |
3440 | ; Valid in all states | 3458 | ; Valid in all states |
3441 | */ | 3459 | */ |
3442 | 3460 | ||
3443 | /* | 3461 | /* |
3444 | UNIMPLEMENTED | 3462 | UNIMPLEMENTED |
3445 | command-auth = append / create / delete / examine / list / lsub / | 3463 | command-auth = append / create / delete / examine / list / lsub / |
3446 | rename / select / status / subscribe / unsubscribe | 3464 | rename / select / status / subscribe / unsubscribe |
3447 | ; Valid only in Authenticated or Selected state | 3465 | ; Valid only in Authenticated or Selected state |
3448 | */ | 3466 | */ |
3449 | 3467 | ||
3450 | /* | 3468 | /* |
3451 | UNIMPLEMENTED | 3469 | UNIMPLEMENTED |
3452 | command-nonauth = login / authenticate | 3470 | command-nonauth = login / authenticate |
3453 | ; Valid only when in Not Authenticated state | 3471 | ; Valid only when in Not Authenticated state |
3454 | */ | 3472 | */ |
3455 | 3473 | ||
3456 | /* | 3474 | /* |
3457 | UNIMPLEMENTED | 3475 | UNIMPLEMENTED |
3458 | command-select = "CHECK" / "CLOSE" / "EXPUNGE" / copy / fetch / store / | 3476 | command-select = "CHECK" / "CLOSE" / "EXPUNGE" / copy / fetch / store / |
3459 | uid / search | 3477 | uid / search |
3460 | ; Valid only when in Selected state | 3478 | ; Valid only when in Selected state |
3461 | */ | 3479 | */ |
3462 | 3480 | ||
3463 | /* | 3481 | /* |
3464 | continue-req = "+" SP (resp-text / base64) CRLF | 3482 | continue-req = "+" SP (resp-text / base64) CRLF |
3465 | */ | 3483 | */ |
3466 | 3484 | ||
3467 | int | 3485 | int |
3468 | mailimap_continue_req_parse(mailstream * fd, MMAPString * buffer, | 3486 | mailimap_continue_req_parse(mailstream * fd, MMAPString * buffer, |
3469 | size_t * index, | 3487 | size_t * index, |
3470 | struct mailimap_continue_req ** result, | 3488 | struct mailimap_continue_req ** result, |
3471 | size_t progr_rate, | 3489 | size_t progr_rate, |
3472 | progress_function * progr_fun) | 3490 | progress_function * progr_fun) |
3473 | { | 3491 | { |
3474 | struct mailimap_resp_text * resp_text; | 3492 | struct mailimap_resp_text * resp_text; |
3475 | size_t cur_token; | 3493 | size_t cur_token; |
3476 | struct mailimap_continue_req * cont_req; | 3494 | struct mailimap_continue_req * cont_req; |
3477 | char * base64; | 3495 | char * base64; |
3478 | int type; | 3496 | int type; |
3479 | int r; | 3497 | int r; |
3480 | int res; | 3498 | int res; |
3481 | 3499 | ||
3482 | cur_token = * index; | 3500 | cur_token = * index; |
3483 | 3501 | ||
3484 | r = mailimap_plus_parse(fd, buffer, &cur_token); | 3502 | r = mailimap_plus_parse(fd, buffer, &cur_token); |
3485 | if (r != MAILIMAP_NO_ERROR) | 3503 | if (r != MAILIMAP_NO_ERROR) |
3486 | return r; | 3504 | return r; |
3487 | 3505 | ||
3488 | r = mailimap_space_parse(fd, buffer, &cur_token); | 3506 | r = mailimap_space_parse(fd, buffer, &cur_token); |
3489 | if (r != MAILIMAP_NO_ERROR) | 3507 | if (r != MAILIMAP_NO_ERROR) |
3490 | return r; | 3508 | return r; |
3491 | 3509 | ||
3492 | resp_text = NULL; | 3510 | resp_text = NULL; |
3493 | base64 = NULL; | 3511 | base64 = NULL; |
3494 | 3512 | ||
3495 | type = MAILIMAP_CONTINUE_REQ_ERROR; /* XXX - removes a gcc warning */ | 3513 | type = MAILIMAP_CONTINUE_REQ_ERROR; /* XXX - removes a gcc warning */ |
3496 | 3514 | ||
3497 | r = mailimap_base64_parse(fd, buffer, &cur_token, &base64, | 3515 | r = mailimap_base64_parse(fd, buffer, &cur_token, &base64, |
3498 | progr_rate, progr_fun); | 3516 | progr_rate, progr_fun); |
3499 | 3517 | ||
3500 | if (r == MAILIMAP_NO_ERROR) | 3518 | if (r == MAILIMAP_NO_ERROR) |
3501 | type = MAILIMAP_CONTINUE_REQ_BASE64; | 3519 | type = MAILIMAP_CONTINUE_REQ_BASE64; |
3502 | 3520 | ||
3503 | if (r == MAILIMAP_ERROR_PARSE) { | 3521 | if (r == MAILIMAP_ERROR_PARSE) { |
3504 | r = mailimap_resp_text_parse(fd, buffer, &cur_token, &resp_text, | 3522 | r = mailimap_resp_text_parse(fd, buffer, &cur_token, &resp_text, |
3505 | progr_rate, progr_fun); | 3523 | progr_rate, progr_fun); |
3506 | 3524 | ||
3507 | if (r == MAILIMAP_NO_ERROR) | 3525 | if (r == MAILIMAP_NO_ERROR) |
3508 | type = MAILIMAP_CONTINUE_REQ_TEXT; | 3526 | type = MAILIMAP_CONTINUE_REQ_TEXT; |
3509 | } | 3527 | } |
3510 | 3528 | ||
3511 | if (r != MAILIMAP_NO_ERROR) { | 3529 | if (r != MAILIMAP_NO_ERROR) { |
3512 | res = r; | 3530 | res = r; |
3513 | goto err; | 3531 | goto err; |
3514 | } | 3532 | } |
3515 | 3533 | ||
3516 | r = mailimap_crlf_parse(fd, buffer, &cur_token); | 3534 | r = mailimap_crlf_parse(fd, buffer, &cur_token); |
3517 | if (r != MAILIMAP_NO_ERROR) { | 3535 | if (r != MAILIMAP_NO_ERROR) { |
3518 | res = r; | 3536 | res = r; |
3519 | goto free; | 3537 | goto free; |
3520 | } | 3538 | } |
3521 | 3539 | ||
3522 | cont_req = mailimap_continue_req_new(type, resp_text, base64); | 3540 | cont_req = mailimap_continue_req_new(type, resp_text, base64); |
3523 | if (cont_req == NULL) { | 3541 | if (cont_req == NULL) { |
3524 | res = MAILIMAP_ERROR_MEMORY; | 3542 | res = MAILIMAP_ERROR_MEMORY; |
3525 | goto free; | 3543 | goto free; |
3526 | } | 3544 | } |
3527 | 3545 | ||
3528 | * result = cont_req; | 3546 | * result = cont_req; |
3529 | * index = cur_token; | 3547 | * index = cur_token; |
3530 | 3548 | ||
3531 | return MAILIMAP_NO_ERROR; | 3549 | return MAILIMAP_NO_ERROR; |
3532 | 3550 | ||
3533 | free: | 3551 | free: |
3534 | if (base64 != NULL) | 3552 | if (base64 != NULL) |
3535 | mailimap_base64_free(base64); | 3553 | mailimap_base64_free(base64); |
3536 | if (resp_text != NULL) | 3554 | if (resp_text != NULL) |
3537 | mailimap_resp_text_free(resp_text); | 3555 | mailimap_resp_text_free(resp_text); |
3538 | err: | 3556 | err: |
3539 | return res; | 3557 | return res; |
3540 | } | 3558 | } |
3541 | 3559 | ||
3542 | /* | 3560 | /* |
3543 | UNIMPLEMENTED | 3561 | UNIMPLEMENTED |
3544 | copy = "COPY" SP set SP mailbox | 3562 | copy = "COPY" SP set SP mailbox |
3545 | */ | 3563 | */ |
3546 | 3564 | ||
3547 | /* | 3565 | /* |
3548 | UNIMPLEMENTED | 3566 | UNIMPLEMENTED |
3549 | create = "CREATE" SP mailbox | 3567 | create = "CREATE" SP mailbox |
3550 | ; Use of INBOX gives a NO error | 3568 | ; Use of INBOX gives a NO error |
3551 | */ | 3569 | */ |
3552 | 3570 | ||
3553 | /* | 3571 | /* |
3554 | UNIMPLEMENTED | 3572 | UNIMPLEMENTED |
3555 | date = date-text / DQUOTE date-text DQUOTE | 3573 | date = date-text / DQUOTE date-text DQUOTE |
3556 | */ | 3574 | */ |
3557 | 3575 | ||
3558 | /* | 3576 | /* |
3559 | UNIMPLEMENTED | 3577 | UNIMPLEMENTED |
3560 | date-day = 1*2DIGIT | 3578 | date-day = 1*2DIGIT |
3561 | ; Day of month | 3579 | ; Day of month |
3562 | */ | 3580 | */ |
3563 | 3581 | ||
3564 | /* | 3582 | /* |
3565 | static gboolean mailimap_date_day_parse(mailstream * fd, | 3583 | static gboolean mailimap_date_day_parse(mailstream * fd, |
3566 | MMAPString * buffer, | 3584 | MMAPString * buffer, |
3567 | guint32 * index, | 3585 | guint32 * index, |
3568 | gint * result) | 3586 | gint * result) |
3569 | { | 3587 | { |
3570 | guint32 cur_token; | 3588 | guint32 cur_token; |
3571 | gint digit; | 3589 | gint digit; |
3572 | gint number; | 3590 | gint number; |
3573 | 3591 | ||
3574 | cur_token = * index; | 3592 | cur_token = * index; |
3575 | 3593 | ||
3576 | if (!mailimap_digit_parse(fd, buffer, &cur_token, &digit)) | 3594 | if (!mailimap_digit_parse(fd, buffer, &cur_token, &digit)) |
3577 | return FALSE; | 3595 | return FALSE; |
3578 | 3596 | ||
3579 | number = digit; | 3597 | number = digit; |
3580 | 3598 | ||
3581 | if (mailimap_digit_parse(fd, buffer, &cur_token, &digit)) | 3599 | if (mailimap_digit_parse(fd, buffer, &cur_token, &digit)) |
3582 | number = number * 10 + digit; | 3600 | number = number * 10 + digit; |
3583 | 3601 | ||
3584 | * result = number; | 3602 | * result = number; |
3585 | * index = cur_token; | 3603 | * index = cur_token; |
3586 | 3604 | ||
3587 | return TRUE; | 3605 | return TRUE; |
3588 | } | 3606 | } |
3589 | */ | 3607 | */ |
3590 | 3608 | ||
3591 | /* | 3609 | /* |
3592 | date-day-fixed = (SP DIGIT) / 2DIGIT | 3610 | date-day-fixed = (SP DIGIT) / 2DIGIT |
3593 | ; Fixed-format version of date-day | 3611 | ; Fixed-format version of date-day |
3594 | */ | 3612 | */ |
3595 | 3613 | ||
3596 | static int mailimap_date_day_fixed_parse(mailstream * fd, | 3614 | static int mailimap_date_day_fixed_parse(mailstream * fd, |
3597 | MMAPString * buffer, | 3615 | MMAPString * buffer, |
3598 | size_t * index, | 3616 | size_t * index, |
3599 | int * result) | 3617 | int * result) |
3600 | { | 3618 | { |
3601 | #ifdef UNSTRICT_SYNTAX | 3619 | #ifdef UNSTRICT_SYNTAX |
3602 | size_t cur_token; | 3620 | size_t cur_token; |
3603 | uint32_t day; | 3621 | uint32_t day; |
3604 | int r; | 3622 | int r; |
3605 | 3623 | ||
3606 | cur_token = * index; | 3624 | cur_token = * index; |
3607 | 3625 | ||
3608 | r = mailimap_number_parse(fd, buffer, &cur_token, &day); | 3626 | r = mailimap_number_parse(fd, buffer, &cur_token, &day); |
3609 | if (r != MAILIMAP_NO_ERROR) | 3627 | if (r != MAILIMAP_NO_ERROR) |
3610 | return r; | 3628 | return r; |
3611 | 3629 | ||
3612 | * index = cur_token; | 3630 | * index = cur_token; |
3613 | * result = day; | 3631 | * result = day; |
3614 | 3632 | ||
3615 | return MAILIMAP_NO_ERROR; | 3633 | return MAILIMAP_NO_ERROR; |
3616 | 3634 | ||
3617 | #else | 3635 | #else |
3618 | size_t cur_token; | 3636 | size_t cur_token; |
3619 | int r; | 3637 | int r; |
3620 | 3638 | ||
3621 | cur_token = * index; | 3639 | cur_token = * index; |
3622 | 3640 | ||
3623 | if (mailimap_space_parse(fd, buffer, &cur_token)) { | 3641 | if (mailimap_space_parse(fd, buffer, &cur_token)) { |
3624 | int digit; | 3642 | int digit; |
3625 | 3643 | ||
3626 | r = mailimap_digit_parse(fd, buffer, &cur_token, &digit); | 3644 | r = mailimap_digit_parse(fd, buffer, &cur_token, &digit); |
3627 | if (r != MAILIMAP_NO_ERROR) | 3645 | if (r != MAILIMAP_NO_ERROR) |
3628 | return r; | 3646 | return r; |
3629 | 3647 | ||
3630 | * result = digit; | 3648 | * result = digit; |
3631 | * index = cur_token; | 3649 | * index = cur_token; |
3632 | 3650 | ||
3633 | return MAILIMAP_NO_ERROR; | 3651 | return MAILIMAP_NO_ERROR; |
3634 | } | 3652 | } |
3635 | else { | 3653 | else { |
3636 | int digit1; | 3654 | int digit1; |
3637 | int digit2; | 3655 | int digit2; |
3638 | 3656 | ||
3639 | r = mailimap_digit_parse(fd, buffer, &cur_token, &digit1); | 3657 | r = mailimap_digit_parse(fd, buffer, &cur_token, &digit1); |
3640 | if (r != MAILIMAP_NO_ERROR) | 3658 | if (r != MAILIMAP_NO_ERROR) |
3641 | return r; | 3659 | return r; |
3642 | r = mailimap_digit_parse(fd, buffer, &cur_token, &digit2); | 3660 | r = mailimap_digit_parse(fd, buffer, &cur_token, &digit2); |
3643 | if (r != MAILIMAP_NO_ERROR) | 3661 | if (r != MAILIMAP_NO_ERROR) |
3644 | return r; | 3662 | return r; |
3645 | 3663 | ||
3646 | * result = digit1 * 10 + digit2; | 3664 | * result = digit1 * 10 + digit2; |
3647 | * index = cur_token; | 3665 | * index = cur_token; |
3648 | 3666 | ||
3649 | return MAILIMAP_NO_ERROR; | 3667 | return MAILIMAP_NO_ERROR; |
3650 | } | 3668 | } |
3651 | #endif | 3669 | #endif |
3652 | } | 3670 | } |
3653 | 3671 | ||
3654 | 3672 | ||
3655 | /* | 3673 | /* |
3656 | date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / | 3674 | date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / |
3657 | "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" | 3675 | "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" |
3658 | */ | 3676 | */ |
3659 | 3677 | ||
3660 | static int mailimap_date_month_parse(mailstream * fd, MMAPString * buffer, | 3678 | static int mailimap_date_month_parse(mailstream * fd, MMAPString * buffer, |
3661 | size_t * index, int * result) | 3679 | size_t * index, int * result) |
3662 | { | 3680 | { |
3663 | size_t cur_token; | 3681 | size_t cur_token; |
3664 | int month; | 3682 | int month; |
3665 | 3683 | ||
3666 | cur_token = * index; | 3684 | cur_token = * index; |
3667 | 3685 | ||
3668 | month = mailimap_month_get_token_value(fd, buffer, &cur_token); | 3686 | month = mailimap_month_get_token_value(fd, buffer, &cur_token); |
3669 | if (month == -1) | 3687 | if (month == -1) |
3670 | return MAILIMAP_ERROR_PARSE; | 3688 | return MAILIMAP_ERROR_PARSE; |
3671 | 3689 | ||
3672 | * result = month; | 3690 | * result = month; |
3673 | * index = cur_token; | 3691 | * index = cur_token; |
3674 | 3692 | ||
3675 | return MAILIMAP_NO_ERROR; | 3693 | return MAILIMAP_NO_ERROR; |
3676 | } | 3694 | } |
3677 | 3695 | ||
3678 | /* | 3696 | /* |
3679 | UNIMPLEMENTED | 3697 | UNIMPLEMENTED |
3680 | date-text = date-day "-" date-month "-" date-year | 3698 | date-text = date-day "-" date-month "-" date-year |
3681 | */ | 3699 | */ |
3682 | 3700 | ||
3683 | /* | 3701 | /* |
3684 | static struct mailimap_date_text * | 3702 | static struct mailimap_date_text * |
3685 | mailimap_date_text_new(gint day, gint month, gint year) | 3703 | mailimap_date_text_new(gint day, gint month, gint year) |
3686 | { | 3704 | { |
3687 | struct mailimap_date_text * date_text; | 3705 | struct mailimap_date_text * date_text; |
3688 | 3706 | ||
3689 | date_text = g_new(struct mailimap_date_text, 1); | 3707 | date_text = g_new(struct mailimap_date_text, 1); |
3690 | if (date_text == NULL) | 3708 | if (date_text == NULL) |
3691 | return NULL; | 3709 | return NULL; |
3692 | 3710 | ||
3693 | date_text->day = day; | 3711 | date_text->day = day; |
3694 | date_text->month = month; | 3712 | date_text->month = month; |
3695 | date_text->year = year; | 3713 | date_text->year = year; |
3696 | 3714 | ||
3697 | return date_text; | 3715 | return date_text; |
3698 | } | 3716 | } |
3699 | 3717 | ||
3700 | static void mailimap_date_text_free(struct mailimap_date_text * date_text) | 3718 | static void mailimap_date_text_free(struct mailimap_date_text * date_text) |
3701 | { | 3719 | { |
3702 | g_free(date_text); | 3720 | g_free(date_text); |
3703 | } | 3721 | } |
3704 | 3722 | ||
3705 | static gboolean | 3723 | static gboolean |
3706 | mailimap_date_text_parse(mailstream * fd, MMAPString * buffer, | 3724 | mailimap_date_text_parse(mailstream * fd, MMAPString * buffer, |
3707 | guint32 * index, struct mailimap_date_text ** result) | 3725 | guint32 * index, struct mailimap_date_text ** result) |
3708 | { | 3726 | { |
3709 | struct mailimap_date_text * date_text; | 3727 | struct mailimap_date_text * date_text; |
3710 | gint day; | 3728 | gint day; |
3711 | gint month; | 3729 | gint month; |
3712 | gint year; | 3730 | gint year; |
3713 | guint32 cur_token; | 3731 | guint32 cur_token; |
3714 | 3732 | ||
3715 | cur_token = * index; | 3733 | cur_token = * index; |
3716 | 3734 | ||
3717 | if (!mailimap_date_day_parse(fd, buffer, &cur_token, &day)) | 3735 | if (!mailimap_date_day_parse(fd, buffer, &cur_token, &day)) |
3718 | return FALSE; | 3736 | return FALSE; |
3719 | 3737 | ||
3720 | if (!mailimap_minus_parse(fd, buffer, &cur_token)) | 3738 | if (!mailimap_minus_parse(fd, buffer, &cur_token)) |
3721 | return FALSE; | 3739 | return FALSE; |
3722 | 3740 | ||
3723 | if (!mailimap_date_month_parse(fd, buffer, &cur_token, &month)) | 3741 | if (!mailimap_date_month_parse(fd, buffer, &cur_token, &month)) |
3724 | return FALSE; | 3742 | return FALSE; |
3725 | 3743 | ||
3726 | if (!mailimap_minus_parse(fd, buffer, &cur_token)) | 3744 | if (!mailimap_minus_parse(fd, buffer, &cur_token)) |
3727 | return FALSE; | 3745 | return FALSE; |
3728 | 3746 | ||
3729 | if (!mailimap_date_year_parse(fd, buffer, &cur_token, &year)) | 3747 | if (!mailimap_date_year_parse(fd, buffer, &cur_token, &year)) |
3730 | return FALSE; | 3748 | return FALSE; |
3731 | 3749 | ||
3732 | date_text = mailimap_date_text_new(day, month, year); | 3750 | date_text = mailimap_date_text_new(day, month, year); |
3733 | if (date_text == NULL) | 3751 | if (date_text == NULL) |
3734 | return FALSE; | 3752 | return FALSE; |
3735 | 3753 | ||
3736 | * result = date_text; | 3754 | * result = date_text; |
3737 | * index = cur_token; | 3755 | * index = cur_token; |
3738 | 3756 | ||
3739 | return TRUE; | 3757 | return TRUE; |
3740 | } | 3758 | } |
3741 | */ | 3759 | */ |
3742 | 3760 | ||
3743 | /* | 3761 | /* |
3744 | date-year = 4DIGIT | 3762 | date-year = 4DIGIT |
3745 | */ | 3763 | */ |
3746 | 3764 | ||
3747 | static int mailimap_date_year_parse(mailstream * fd, MMAPString * buffer, | 3765 | static int mailimap_date_year_parse(mailstream * fd, MMAPString * buffer, |
3748 | size_t * index, int * result) | 3766 | size_t * index, int * result) |
3749 | { | 3767 | { |
3750 | #ifdef UNSTRICT_SYNTAX | 3768 | #ifdef UNSTRICT_SYNTAX |
3751 | uint32_t year; | 3769 | uint32_t year; |
3752 | int r; | 3770 | int r; |
3753 | size_t cur_token; | 3771 | size_t cur_token; |
3754 | 3772 | ||
3755 | cur_token = * index; | 3773 | cur_token = * index; |
3756 | 3774 | ||
3757 | r = mailimap_number_parse(fd, buffer, &cur_token, &year); | 3775 | r = mailimap_number_parse(fd, buffer, &cur_token, &year); |
3758 | if (r != MAILIMAP_NO_ERROR) | 3776 | if (r != MAILIMAP_NO_ERROR) |
3759 | return r; | 3777 | return r; |
3760 | 3778 | ||
3761 | * result = year; | 3779 | * result = year; |
3762 | * index = cur_token; | 3780 | * index = cur_token; |
3763 | 3781 | ||
3764 | return MAILIMAP_NO_ERROR; | 3782 | return MAILIMAP_NO_ERROR; |
3765 | #else | 3783 | #else |
3766 | int i; | 3784 | int i; |
3767 | size_t cur_token; | 3785 | size_t cur_token; |
3768 | int year; | 3786 | int year; |
3769 | int digit; | 3787 | int digit; |
3770 | int r; | 3788 | int r; |
3771 | 3789 | ||
3772 | cur_token = * index; | 3790 | cur_token = * index; |
3773 | year = 0; | 3791 | year = 0; |
3774 | 3792 | ||
3775 | for(i = 0 ; i < 4 ; i ++) { | 3793 | for(i = 0 ; i < 4 ; i ++) { |
3776 | r = mailimap_digit_parse(fd, buffer, &cur_token, &digit); | 3794 | r = mailimap_digit_parse(fd, buffer, &cur_token, &digit); |
3777 | if (r != MAILIMAP_NO_ERROR) | 3795 | if (r != MAILIMAP_NO_ERROR) |
3778 | return r; | 3796 | return r; |
3779 | year = year * 10 + digit; | 3797 | year = year * 10 + digit; |
3780 | } | 3798 | } |
3781 | 3799 | ||
3782 | * result = year; | 3800 | * result = year; |
3783 | * index = cur_token; | 3801 | * index = cur_token; |
3784 | 3802 | ||
3785 | return MAILIMAP_NO_ERROR; | 3803 | return MAILIMAP_NO_ERROR; |
3786 | #endif | 3804 | #endif |
3787 | } | 3805 | } |
3788 | 3806 | ||
3789 | /* | 3807 | /* |
3790 | date-time = DQUOTE date-day-fixed "-" date-month "-" date-year | 3808 | date-time = DQUOTE date-day-fixed "-" date-month "-" date-year |
3791 | SP time SP zone DQUOTE | 3809 | SP time SP zone DQUOTE |
3792 | */ | 3810 | */ |
3793 | 3811 | ||
3794 | static int mailimap_date_time_parse(mailstream * fd, MMAPString * buffer, | 3812 | static int mailimap_date_time_parse(mailstream * fd, MMAPString * buffer, |
3795 | size_t * index, | 3813 | size_t * index, |
3796 | struct mailimap_date_time ** result, | 3814 | struct mailimap_date_time ** result, |
3797 | size_t progr_rate, | 3815 | size_t progr_rate, |
3798 | progress_function * progr_fun) | 3816 | progress_function * progr_fun) |
3799 | { | 3817 | { |
3800 | int day; | 3818 | int day; |
3801 | int month; | 3819 | int month; |
3802 | int year; | 3820 | int year; |
3803 | int hour; | 3821 | int hour; |
3804 | int min; | 3822 | int min; |
3805 | int sec; | 3823 | int sec; |
3806 | struct mailimap_date_time * date_time; | 3824 | struct mailimap_date_time * date_time; |
3807 | size_t cur_token; | 3825 | size_t cur_token; |
3808 | int zone; | 3826 | int zone; |
3809 | int r; | 3827 | int r; |
3810 | 3828 | ||
3811 | cur_token = * index; | 3829 | cur_token = * index; |
3812 | 3830 | ||
3813 | r = mailimap_dquote_parse(fd, buffer, &cur_token); | 3831 | r = mailimap_dquote_parse(fd, buffer, &cur_token); |
3814 | if (r != MAILIMAP_NO_ERROR) | 3832 | if (r != MAILIMAP_NO_ERROR) |
3815 | return r; | 3833 | return r; |
3816 | 3834 | ||
3817 | r = mailimap_date_day_fixed_parse(fd, buffer, &cur_token, &day); | 3835 | r = mailimap_date_day_fixed_parse(fd, buffer, &cur_token, &day); |
3818 | if (r != MAILIMAP_NO_ERROR) | 3836 | if (r != MAILIMAP_NO_ERROR) |
3819 | return r; | 3837 | return r; |
3820 | 3838 | ||
3821 | r = mailimap_minus_parse(fd, buffer, &cur_token); | 3839 | r = mailimap_minus_parse(fd, buffer, &cur_token); |
3822 | if (r != MAILIMAP_NO_ERROR) | 3840 | if (r != MAILIMAP_NO_ERROR) |
3823 | return r; | 3841 | return r; |
3824 | 3842 | ||
3825 | r = mailimap_date_month_parse(fd, buffer, &cur_token, &month); | 3843 | r = mailimap_date_month_parse(fd, buffer, &cur_token, &month); |
3826 | if (r != MAILIMAP_NO_ERROR) | 3844 | if (r != MAILIMAP_NO_ERROR) |
3827 | return r; | 3845 | return r; |
3828 | 3846 | ||
3829 | r = mailimap_minus_parse(fd, buffer, &cur_token); | 3847 | r = mailimap_minus_parse(fd, buffer, &cur_token); |
3830 | if (r != MAILIMAP_NO_ERROR) | 3848 | if (r != MAILIMAP_NO_ERROR) |
3831 | return r; | 3849 | return r; |
3832 | 3850 | ||
3833 | r = mailimap_date_year_parse(fd, buffer, &cur_token, &year); | 3851 | r = mailimap_date_year_parse(fd, buffer, &cur_token, &year); |
3834 | if (r != MAILIMAP_NO_ERROR) | 3852 | if (r != MAILIMAP_NO_ERROR) |
3835 | return r; | 3853 | return r; |
3836 | 3854 | ||
3837 | r = mailimap_space_parse(fd, buffer, &cur_token); | 3855 | r = mailimap_space_parse(fd, buffer, &cur_token); |
3838 | if (r != MAILIMAP_NO_ERROR) | 3856 | if (r != MAILIMAP_NO_ERROR) |
3839 | return r; | 3857 | return r; |
3840 | 3858 | ||
3841 | r = mailimap_time_parse(fd, buffer, &cur_token, &hour, &min, &sec); | 3859 | r = mailimap_time_parse(fd, buffer, &cur_token, &hour, &min, &sec); |
3842 | if (r != MAILIMAP_NO_ERROR) | 3860 | if (r != MAILIMAP_NO_ERROR) |
3843 | return r; | 3861 | return r; |
3844 | 3862 | ||
3845 | r = mailimap_space_parse(fd, buffer, &cur_token); | 3863 | r = mailimap_space_parse(fd, buffer, &cur_token); |
3846 | if (r != MAILIMAP_NO_ERROR) | 3864 | if (r != MAILIMAP_NO_ERROR) |
3847 | return r; | 3865 | return r; |
3848 | 3866 | ||
3849 | r = mailimap_zone_parse(fd, buffer, &cur_token, &zone); | 3867 | r = mailimap_zone_parse(fd, buffer, &cur_token, &zone); |
3850 | if (r != MAILIMAP_NO_ERROR) | 3868 | if (r != MAILIMAP_NO_ERROR) |
3851 | return r; | 3869 | return r; |
3852 | 3870 | ||
3853 | r = mailimap_dquote_parse(fd, buffer, &cur_token); | 3871 | r = mailimap_dquote_parse(fd, buffer, &cur_token); |
3854 | if (r != MAILIMAP_NO_ERROR) | 3872 | if (r != MAILIMAP_NO_ERROR) |
3855 | return r; | 3873 | return r; |
3856 | 3874 | ||
3857 | date_time = mailimap_date_time_new(day, month, year, hour, min, sec, zone); | 3875 | date_time = mailimap_date_time_new(day, month, year, hour, min, sec, zone); |
3858 | if (date_time == NULL) | 3876 | if (date_time == NULL) |
3859 | return MAILIMAP_ERROR_MEMORY; | 3877 | return MAILIMAP_ERROR_MEMORY; |
3860 | 3878 | ||
3861 | * result = date_time; | 3879 | * result = date_time; |
3862 | * index = cur_token; | 3880 | * index = cur_token; |
3863 | 3881 | ||
3864 | return MAILIMAP_NO_ERROR; | 3882 | return MAILIMAP_NO_ERROR; |
3865 | } | 3883 | } |
3866 | 3884 | ||
3867 | 3885 | ||
3868 | /* | 3886 | /* |
3869 | UNIMPLEMENTED | 3887 | UNIMPLEMENTED |
3870 | delete = "DELETE" SP mailbox | 3888 | delete = "DELETE" SP mailbox |
3871 | ; Use of INBOX gives a NO error | 3889 | ; Use of INBOX gives a NO error |
3872 | */ | 3890 | */ |
3873 | 3891 | ||
3874 | /* | 3892 | /* |
3875 | digit-nz = %x31-39 | 3893 | digit-nz = %x31-39 |
3876 | ; 1-9 | 3894 | ; 1-9 |
3877 | */ | 3895 | */ |
3878 | 3896 | ||
3879 | #ifndef UNSTRICT_SYNTAX | 3897 | #ifndef UNSTRICT_SYNTAX |
3880 | static int is_digit_nz(char ch) | 3898 | static int is_digit_nz(char ch) |
3881 | { | 3899 | { |
3882 | return (ch >= '1') && (ch <= '9'); | 3900 | return (ch >= '1') && (ch <= '9'); |
3883 | } | 3901 | } |
3884 | 3902 | ||
3885 | static int mailimap_digit_nz_parse(mailstream * fd, MMAPString * buffer, | 3903 | static int mailimap_digit_nz_parse(mailstream * fd, MMAPString * buffer, |
3886 | size_t * index, int * result) | 3904 | size_t * index, int * result) |
3887 | { | 3905 | { |
3888 | size_t cur_token; | 3906 | size_t cur_token; |
3889 | 3907 | ||
3890 | cur_token = * index; | 3908 | cur_token = * index; |
3891 | 3909 | ||
3892 | if (is_digit_nz(buffer->str[cur_token])) { | 3910 | if (is_digit_nz(buffer->str[cur_token])) { |
3893 | * result = buffer->str[cur_token] - '0'; | 3911 | * result = buffer->str[cur_token] - '0'; |
3894 | cur_token ++; | 3912 | cur_token ++; |
3895 | * index = cur_token; | 3913 | * index = cur_token; |
3896 | return MAILIMAP_NO_ERROR; | 3914 | return MAILIMAP_NO_ERROR; |
3897 | } | 3915 | } |
3898 | else | 3916 | else |
3899 | return MAILIMAP_ERROR_PARSE; | 3917 | return MAILIMAP_ERROR_PARSE; |
3900 | } | 3918 | } |
3901 | #endif | 3919 | #endif |
3902 | 3920 | ||
3903 | /* | 3921 | /* |
3904 | envelope = "(" env-date SP env-subject SP env-from SP env-sender SP | 3922 | envelope = "(" env-date SP env-subject SP env-from SP env-sender SP |
3905 | env-reply-to SP env-to SP env-cc SP env-bcc SP | 3923 | env-reply-to SP env-to SP env-cc SP env-bcc SP |
3906 | env-in-reply-to SP env-message-id ")" | 3924 | env-in-reply-to SP env-message-id ")" |
3907 | */ | 3925 | */ |
3908 | 3926 | ||
3909 | static int mailimap_envelope_parse(mailstream * fd, MMAPString * buffer, | 3927 | static int mailimap_envelope_parse(mailstream * fd, MMAPString * buffer, |
3910 | size_t * index, | 3928 | size_t * index, |
3911 | struct mailimap_envelope ** result, | 3929 | struct mailimap_envelope ** result, |
3912 | size_t progr_rate, | 3930 | size_t progr_rate, |
3913 | progress_function * progr_fun) | 3931 | progress_function * progr_fun) |
3914 | { | 3932 | { |
3915 | size_t cur_token; | 3933 | size_t cur_token; |
3916 | char * date; | 3934 | char * date; |
3917 | char * subject; | 3935 | char * subject; |
3918 | struct mailimap_env_from * from; | 3936 | struct mailimap_env_from * from; |
3919 | struct mailimap_env_sender * sender; | 3937 | struct mailimap_env_sender * sender; |
3920 | struct mailimap_env_reply_to * reply_to; | 3938 | struct mailimap_env_reply_to * reply_to; |
3921 | struct mailimap_env_to * to; | 3939 | struct mailimap_env_to * to; |
3922 | struct mailimap_env_cc * cc; | 3940 | struct mailimap_env_cc * cc; |
3923 | struct mailimap_env_bcc * bcc; | 3941 | struct mailimap_env_bcc * bcc; |
3924 | char * in_reply_to; | 3942 | char * in_reply_to; |
3925 | char * message_id; | 3943 | char * message_id; |
3926 | struct mailimap_envelope * envelope; | 3944 | struct mailimap_envelope * envelope; |
3927 | int r; | 3945 | int r; |
3928 | int res; | 3946 | int res; |
3929 | 3947 | ||
3930 | date = NULL; | 3948 | date = NULL; |
3931 | subject = NULL; | 3949 | subject = NULL; |
3932 | from = NULL; | 3950 | from = NULL; |
3933 | sender = NULL; | 3951 | sender = NULL; |
3934 | reply_to = NULL; | 3952 | reply_to = NULL; |
3935 | to = NULL; | 3953 | to = NULL; |
3936 | cc = NULL; | 3954 | cc = NULL; |
3937 | bcc = NULL; | 3955 | bcc = NULL; |
3938 | in_reply_to = NULL; | 3956 | in_reply_to = NULL; |
3939 | message_id = NULL; | 3957 | message_id = NULL; |
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index d9496af..93fb7de 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,1360 +1,1365 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 9 | #include <qprogressbar.h> |
10 | #include "genericwrapper.h" | 10 | #include "genericwrapper.h" |
11 | #include <kglobal.h> | 11 | #include <kglobal.h> |
12 | 12 | ||
13 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
14 | int IMAPwrapper::mMax = 0; | 14 | int IMAPwrapper::mMax = 0; |
15 | int IMAPwrapper::mCurrent = 0; | 15 | int IMAPwrapper::mCurrent = 0; |
16 | 16 | ||
17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
18 | : AbstractMail() | 18 | : AbstractMail() |
19 | { | 19 | { |
20 | account = a; | 20 | account = a; |
21 | m_imap = 0; | 21 | m_imap = 0; |
22 | m_Lastmbox = ""; | 22 | m_Lastmbox = ""; |
23 | mCurrent = 0; | 23 | mCurrent = 0; |
24 | mMax = 0; | 24 | mMax = 0; |
25 | } | 25 | } |
26 | 26 | ||
27 | IMAPwrapper::~IMAPwrapper() | 27 | IMAPwrapper::~IMAPwrapper() |
28 | { | 28 | { |
29 | logout(); | 29 | logout(); |
30 | } | 30 | } |
31 | 31 | ||
32 | /* to avoid to often select statements in loops etc. | 32 | /* to avoid to often select statements in loops etc. |
33 | we trust that we are logged in and connection is established!*/ | 33 | we trust that we are logged in and connection is established!*/ |
34 | int IMAPwrapper::selectMbox(const QString&mbox) | 34 | int IMAPwrapper::selectMbox(const QString&mbox) |
35 | { | 35 | { |
36 | if (mbox == m_Lastmbox) { | 36 | if (mbox == m_Lastmbox) { |
37 | return MAILIMAP_NO_ERROR; | 37 | return MAILIMAP_NO_ERROR; |
38 | } | 38 | } |
39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
40 | if ( err != MAILIMAP_NO_ERROR ) { | 40 | if ( err != MAILIMAP_NO_ERROR ) { |
41 | m_Lastmbox = ""; | 41 | m_Lastmbox = ""; |
42 | return err; | 42 | return err; |
43 | } | 43 | } |
44 | m_Lastmbox = mbox; | 44 | m_Lastmbox = mbox; |
45 | return err; | 45 | return err; |
46 | } | 46 | } |
47 | 47 | ||
48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
49 | { | 49 | { |
50 | qApp->processEvents(); | 50 | qApp->processEvents(); |
51 | return; | 51 | return; |
52 | //qDebug("imap progress %d of %d ",current,maximum ); | 52 | //qDebug("imap progress %d of %d ",current,maximum ); |
53 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); | 53 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); |
54 | //qApp->processEvents() | 54 | //qApp->processEvents() |
55 | static unsigned int last = 0; | 55 | static unsigned int last = 0; |
56 | if ( last != current ) | 56 | if ( last != current ) |
57 | IMAPwrapper::progress(); | 57 | IMAPwrapper::progress(); |
58 | last = current; | 58 | last = current; |
59 | } | 59 | } |
60 | void IMAPwrapper::progress( QString m ) | 60 | void IMAPwrapper::progress( QString m ) |
61 | { | 61 | { |
62 | static QString mProgrMess; | 62 | static QString mProgrMess; |
63 | if ( m != QString::null ) { | 63 | if ( m != QString::null ) { |
64 | mProgrMess = m; | 64 | mProgrMess = m; |
65 | mCurrent = 1; | 65 | mCurrent = 1; |
66 | return; | 66 | return; |
67 | } | 67 | } |
68 | QString mess; | 68 | QString mess; |
69 | //qDebug("progress "); | 69 | //qDebug("progress "); |
70 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); | 70 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); |
71 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); | 71 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); |
72 | Global::statusMessage(mess); | 72 | Global::statusMessage(mess); |
73 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); | 73 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); |
74 | qApp->processEvents(); | 74 | qApp->processEvents(); |
75 | } | 75 | } |
76 | bool IMAPwrapper::start_tls(bool force_tls) | 76 | bool IMAPwrapper::start_tls(bool force_tls) |
77 | { | 77 | { |
78 | int err; | 78 | int err; |
79 | bool try_tls = force_tls; | 79 | bool try_tls = force_tls; |
80 | mailimap_capability_data * cap_data = 0; | 80 | mailimap_capability_data * cap_data = 0; |
81 | 81 | ||
82 | err = mailimap_capability(m_imap,&cap_data); | 82 | err = mailimap_capability(m_imap,&cap_data); |
83 | if (err != MAILIMAP_NO_ERROR) { | 83 | if (err != MAILIMAP_NO_ERROR) { |
84 | Global::statusMessage("error getting capabilities!"); | 84 | Global::statusMessage("error getting capabilities!"); |
85 | return false; | 85 | return false; |
86 | } | 86 | } |
87 | clistiter * cur; | 87 | clistiter * cur; |
88 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 88 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
89 | struct mailimap_capability * cap; | 89 | struct mailimap_capability * cap; |
90 | cap = (struct mailimap_capability *)clist_content(cur); | 90 | cap = (struct mailimap_capability *)clist_content(cur); |
91 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 91 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
92 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 92 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
93 | try_tls = true; | 93 | try_tls = true; |
94 | break; | 94 | break; |
95 | } | 95 | } |
96 | } | 96 | } |
97 | } | 97 | } |
98 | if (cap_data) { | 98 | if (cap_data) { |
99 | mailimap_capability_data_free(cap_data); | 99 | mailimap_capability_data_free(cap_data); |
100 | } | 100 | } |
101 | if (try_tls) { | 101 | if (try_tls) { |
102 | err = mailimap_starttls(m_imap); | 102 | err = mailimap_starttls(m_imap); |
103 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 103 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
104 | Global::statusMessage(i18n("Server has no TLS support!")); | 104 | Global::statusMessage(i18n("Server has no TLS support!")); |
105 | try_tls = false; | 105 | try_tls = false; |
106 | } else { | 106 | } else { |
107 | mailstream_low * low; | 107 | mailstream_low * low; |
108 | mailstream_low * new_low; | 108 | mailstream_low * new_low; |
109 | low = mailstream_get_low(m_imap->imap_stream); | 109 | low = mailstream_get_low(m_imap->imap_stream); |
110 | if (!low) { | 110 | if (!low) { |
111 | try_tls = false; | 111 | try_tls = false; |
112 | } else { | 112 | } else { |
113 | int fd = mailstream_low_get_fd(low); | 113 | int fd = mailstream_low_get_fd(low); |
114 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 114 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
115 | mailstream_low_free(low); | 115 | mailstream_low_free(low); |
116 | mailstream_set_low(m_imap->imap_stream, new_low); | 116 | mailstream_set_low(m_imap->imap_stream, new_low); |
117 | } else { | 117 | } else { |
118 | try_tls = false; | 118 | try_tls = false; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | } | 122 | } |
123 | return try_tls; | 123 | return try_tls; |
124 | } | 124 | } |
125 | 125 | ||
126 | void IMAPwrapper::login() | 126 | void IMAPwrapper::login() |
127 | { | 127 | { |
128 | QString server, user, pass; | 128 | QString server, user, pass; |
129 | uint16_t port; | 129 | uint16_t port; |
130 | int err = MAILIMAP_NO_ERROR; | 130 | int err = MAILIMAP_NO_ERROR; |
131 | 131 | ||
132 | if (account->getOffline()) return; | 132 | if (account->getOffline()) return; |
133 | /* we are connected this moment */ | 133 | /* we are connected this moment */ |
134 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 134 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
135 | if (m_imap) { | 135 | if (m_imap) { |
136 | err = mailimap_noop(m_imap); | 136 | err = mailimap_noop(m_imap); |
137 | if (err!=MAILIMAP_NO_ERROR) { | 137 | if (err!=MAILIMAP_NO_ERROR) { |
138 | logout(); | 138 | logout(); |
139 | } else { | 139 | } else { |
140 | mailstream_flush(m_imap->imap_stream); | 140 | mailstream_flush(m_imap->imap_stream); |
141 | return; | 141 | return; |
142 | } | 142 | } |
143 | } | 143 | } |
144 | server = account->getServer(); | 144 | server = account->getServer(); |
145 | port = account->getPort().toUInt(); | 145 | port = account->getPort().toUInt(); |
146 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 146 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
147 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 147 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
148 | login.show(); | 148 | login.show(); |
149 | if ( QDialog::Accepted == login.exec() ) { | 149 | if ( QDialog::Accepted == login.exec() ) { |
150 | // ok | 150 | // ok |
151 | user = login.getUser(); | 151 | user = login.getUser(); |
152 | pass = login.getPassword(); | 152 | pass = login.getPassword(); |
153 | } else { | 153 | } else { |
154 | // cancel | 154 | // cancel |
155 | return; | 155 | return; |
156 | } | 156 | } |
157 | } else { | 157 | } else { |
158 | user = account->getUser(); | 158 | user = account->getUser(); |
159 | pass = account->getPassword(); | 159 | pass = account->getPassword(); |
160 | } | 160 | } |
161 | 161 | ||
162 | m_imap = mailimap_new( 20, &imap_progress ); | 162 | m_imap = mailimap_new( 20, &imap_progress ); |
163 | 163 | ||
164 | /* connect */ | 164 | /* connect */ |
165 | bool ssl = false; | 165 | bool ssl = false; |
166 | bool try_tls = false; | 166 | bool try_tls = false; |
167 | bool force_tls = false; | 167 | bool force_tls = false; |
168 | 168 | ||
169 | if ( account->ConnectionType() == 2 ) { | 169 | if ( account->ConnectionType() == 2 ) { |
170 | ssl = true; | 170 | ssl = true; |
171 | } | 171 | } |
172 | if (account->ConnectionType()==1) { | 172 | if (account->ConnectionType()==1) { |
173 | force_tls = true; | 173 | force_tls = true; |
174 | } | 174 | } |
175 | 175 | ||
176 | if ( ssl ) { | 176 | if ( ssl ) { |
177 | qDebug("using ssl "); | 177 | qDebug("using ssl "); |
178 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); | 178 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); |
179 | qDebug("back "); | 179 | qDebug("back "); |
180 | } else { | 180 | } else { |
181 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); | 181 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); |
182 | } | 182 | } |
183 | 183 | ||
184 | if ( err != MAILIMAP_NO_ERROR && | 184 | if ( err != MAILIMAP_NO_ERROR && |
185 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 185 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
186 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 186 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
187 | QString failure = ""; | 187 | QString failure = ""; |
188 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 188 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
189 | failure="Connection refused"; | 189 | failure="Connection refused"; |
190 | } else { | 190 | } else { |
191 | failure="Unknown failure"; | 191 | failure="Unknown failure"; |
192 | } | 192 | } |
193 | Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); | 193 | Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); |
194 | mailimap_free( m_imap ); | 194 | mailimap_free( m_imap ); |
195 | m_imap = 0; | 195 | m_imap = 0; |
196 | return; | 196 | return; |
197 | } | 197 | } |
198 | 198 | ||
199 | if (!ssl) { | 199 | if (!ssl) { |
200 | try_tls = start_tls(force_tls); | 200 | try_tls = start_tls(force_tls); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool ok = true; | 203 | bool ok = true; |
204 | if (force_tls && !try_tls) { | 204 | if (force_tls && !try_tls) { |
205 | Global::statusMessage(i18n("Server has no TLS support!")); | 205 | Global::statusMessage(i18n("Server has no TLS support!")); |
206 | ok = false; | 206 | ok = false; |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | /* login */ | 210 | /* login */ |
211 | 211 | ||
212 | if (ok) { | 212 | if (ok) { |
213 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); | 213 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); |
214 | if ( err != MAILIMAP_NO_ERROR ) { | 214 | if ( err != MAILIMAP_NO_ERROR ) { |
215 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); | 215 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); |
216 | ok = false; | 216 | ok = false; |
217 | } | 217 | } |
218 | } | 218 | } |
219 | if (!ok) { | 219 | if (!ok) { |
220 | err = mailimap_close( m_imap ); | 220 | err = mailimap_close( m_imap ); |
221 | mailimap_free( m_imap ); | 221 | mailimap_free( m_imap ); |
222 | m_imap = 0; | 222 | m_imap = 0; |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
226 | void IMAPwrapper::logout() | 226 | void IMAPwrapper::logout() |
227 | { | 227 | { |
228 | int err = MAILIMAP_NO_ERROR; | 228 | int err = MAILIMAP_NO_ERROR; |
229 | if (!m_imap) return; | 229 | if (!m_imap) return; |
230 | err = mailimap_logout( m_imap ); | 230 | err = mailimap_logout( m_imap ); |
231 | err = mailimap_close( m_imap ); | 231 | err = mailimap_close( m_imap ); |
232 | mailimap_free( m_imap ); | 232 | mailimap_free( m_imap ); |
233 | m_imap = 0; | 233 | m_imap = 0; |
234 | m_Lastmbox = ""; | 234 | m_Lastmbox = ""; |
235 | } | 235 | } |
236 | 236 | ||
237 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) | 237 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) |
238 | { | 238 | { |
239 | 239 | ||
240 | int tryAgain = 1; | 240 | int tryAgain = 1; |
241 | while ( tryAgain >= 0 ) { | 241 | while ( tryAgain >= 0 ) { |
242 | int err = MAILIMAP_NO_ERROR; | 242 | int err = MAILIMAP_NO_ERROR; |
243 | clist *result = 0; | 243 | clist *result = 0; |
244 | clistcell *current; | 244 | clistcell *current; |
245 | mailimap_fetch_type *fetchType = 0; | 245 | mailimap_fetch_type *fetchType = 0; |
246 | mailimap_set *set = 0; | 246 | mailimap_set *set = 0; |
247 | 247 | ||
248 | login(); | 248 | login(); |
249 | if (!m_imap) { | 249 | if (!m_imap) { |
250 | return; | 250 | return; |
251 | } | 251 | } |
252 | /* select mailbox READONLY for operations */ | 252 | /* select mailbox READONLY for operations */ |
253 | err = selectMbox(mailbox); | 253 | err = selectMbox(mailbox); |
254 | if ( err != MAILIMAP_NO_ERROR ) { | 254 | if ( err != MAILIMAP_NO_ERROR ) { |
255 | return; | 255 | return; |
256 | } | 256 | } |
257 | 257 | ||
258 | int last = m_imap->imap_selection_info->sel_exists; | 258 | int last = m_imap->imap_selection_info->sel_exists; |
259 | 259 | ||
260 | if (last == 0) { | 260 | if (last == 0) { |
261 | Global::statusMessage(i18n("Mailbox has no mails")); | 261 | Global::statusMessage(i18n("Mailbox has no mails")); |
262 | return; | 262 | return; |
263 | } else { | 263 | } else { |
264 | } | 264 | } |
265 | progress( i18n("Fetch ")); | 265 | progress( i18n("Fetch ")); |
266 | mMax = last; | 266 | mMax = last; |
267 | //qDebug("last %d ", last); | 267 | //qDebug("last %d ", last); |
268 | Global::statusMessage(i18n("Fetching header list")); | 268 | Global::statusMessage(i18n("Fetching header list")); |
269 | qApp->processEvents(); | 269 | qApp->processEvents(); |
270 | /* the range has to start at 1!!! not with 0!!!! */ | 270 | /* the range has to start at 1!!! not with 0!!!! */ |
271 | //LR the access to web.de imap server is no working with value 1 | 271 | //LR the access to web.de imap server is no working with value 1 |
272 | //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); | 272 | //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); |
273 | set = mailimap_set_new_interval( tryAgain, last ); | 273 | set = mailimap_set_new_interval( tryAgain, last ); |
274 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 274 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
277 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 277 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
278 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 278 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
279 | 279 | ||
280 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 280 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
281 | mailimap_set_free( set ); | 281 | mailimap_set_free( set ); |
282 | mailimap_fetch_type_free( fetchType ); | 282 | mailimap_fetch_type_free( fetchType ); |
283 | 283 | ||
284 | QString date,subject,from; | 284 | QString date,subject,from; |
285 | 285 | ||
286 | if ( err == MAILIMAP_NO_ERROR ) { | 286 | if ( err == MAILIMAP_NO_ERROR ) { |
287 | tryAgain = -1; | 287 | tryAgain = -1; |
288 | mailimap_msg_att * msg_att; | 288 | mailimap_msg_att * msg_att; |
289 | int i = 0; | 289 | int i = 0; |
290 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 290 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
291 | ++i; | 291 | ++i; |
292 | //qDebug("iii %d ",i); | 292 | //qDebug("iii %d ",i); |
293 | msg_att = (mailimap_msg_att*)current->data; | 293 | msg_att = (mailimap_msg_att*)current->data; |
294 | RecMail*m = parse_list_result(msg_att); | 294 | RecMail*m = parse_list_result(msg_att); |
295 | if (m) { | 295 | if (m) { |
296 | if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) { | 296 | if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) { |
297 | m->setNumber(i); | 297 | m->setNumber(i); |
298 | m->setMbox(mailbox); | 298 | m->setMbox(mailbox); |
299 | m->setWrapper(this); | 299 | m->setWrapper(this); |
300 | target.append(m); | 300 | target.append(m); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | } | 303 | } |
304 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); | 304 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); |
305 | } else { | 305 | } else { |
306 | --tryAgain; | 306 | --tryAgain; |
307 | --tryAgain;//disabled tryagain by adding this line | 307 | --tryAgain;//disabled tryagain by adding this line |
308 | if ( tryAgain < 0 ) | 308 | if ( tryAgain < 0 ) |
309 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); | 309 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); |
310 | else | 310 | else |
311 | qDebug("try again... "); | 311 | qDebug("try again... "); |
312 | } | 312 | } |
313 | 313 | ||
314 | if (result) mailimap_fetch_list_free(result); | 314 | if (result) mailimap_fetch_list_free(result); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | 317 | ||
318 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 318 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
319 | { | 319 | { |
320 | const char *path, *mask; | 320 | const char *path, *mask; |
321 | int err = MAILIMAP_NO_ERROR; | 321 | int err = MAILIMAP_NO_ERROR; |
322 | clist *result = 0; | 322 | clist *result = 0; |
323 | clistcell *current = 0; | 323 | clistcell *current = 0; |
324 | clistcell*cur_flag = 0; | 324 | clistcell*cur_flag = 0; |
325 | mailimap_mbx_list_flags*bflags = 0; | 325 | mailimap_mbx_list_flags*bflags = 0; |
326 | 326 | ||
327 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 327 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
328 | login(); | 328 | login(); |
329 | if (!m_imap) { | 329 | if (!m_imap) { |
330 | return folders; | 330 | return folders; |
331 | } | 331 | } |
332 | 332 | ||
333 | /* | 333 | /* |
334 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 334 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
335 | * We must not forget to filter them out in next loop! | 335 | * We must not forget to filter them out in next loop! |
336 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 336 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
337 | */ | 337 | */ |
338 | Global::statusMessage(i18n("Fetching folder list")); | 338 | Global::statusMessage(i18n("Fetching folder list")); |
339 | qApp->processEvents(); | 339 | qApp->processEvents(); |
340 | QString temp; | 340 | QString temp; |
341 | mask = "INBOX" ; | 341 | mask = "INBOX" ; |
342 | mailimap_mailbox_list *list; | 342 | mailimap_mailbox_list *list; |
343 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 343 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
344 | QString del; | 344 | QString del; |
345 | bool selectable = true; | 345 | bool selectable = true; |
346 | bool no_inferiors = false; | 346 | bool no_inferiors = false; |
347 | if ( err == MAILIMAP_NO_ERROR ) { | 347 | if ( err == MAILIMAP_NO_ERROR ) { |
348 | current = result->first; | 348 | current = result->first; |
349 | for ( int i = result->count; i > 0; i-- ) { | 349 | for ( int i = result->count; i > 0; i-- ) { |
350 | list = (mailimap_mailbox_list *) current->data; | 350 | list = (mailimap_mailbox_list *) current->data; |
351 | // it is better use the deep copy mechanism of qt itself | 351 | // it is better use the deep copy mechanism of qt itself |
352 | // instead of using strdup! | 352 | // instead of using strdup! |
353 | temp = list->mb_name; | 353 | temp = list->mb_name; |
354 | del = list->mb_delimiter; | 354 | del = list->mb_delimiter; |
355 | current = current->next; | 355 | current = current->next; |
356 | if ( (bflags = list->mb_flag) ) { | 356 | if ( (bflags = list->mb_flag) ) { |
357 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 357 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
358 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 358 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
359 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 359 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
360 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 360 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
361 | no_inferiors = true; | 361 | no_inferiors = true; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | } | 364 | } |
365 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 365 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
366 | } | 366 | } |
367 | } else { | 367 | } else { |
368 | qDebug("error fetching folders: "); | 368 | qDebug("error fetching folders: "); |
369 | 369 | ||
370 | } | 370 | } |
371 | mailimap_list_result_free( result ); | 371 | mailimap_list_result_free( result ); |
372 | 372 | ||
373 | /* | 373 | /* |
374 | * second stage - get the other then inbox folders | 374 | * second stage - get the other then inbox folders |
375 | */ | 375 | */ |
376 | mask = "*" ; | 376 | mask = "*" ; |
377 | path = account->getPrefix().latin1(); | 377 | path = account->getPrefix().latin1(); |
378 | if (!path) path = ""; | 378 | if (!path) path = ""; |
379 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 379 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
380 | if ( err == MAILIMAP_NO_ERROR ) { | 380 | if ( err == MAILIMAP_NO_ERROR ) { |
381 | current = result->first; | 381 | current = result->first; |
382 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 382 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
383 | no_inferiors = false; | 383 | no_inferiors = false; |
384 | list = (mailimap_mailbox_list *) current->data; | 384 | list = (mailimap_mailbox_list *) current->data; |
385 | // it is better use the deep copy mechanism of qt itself | 385 | // it is better use the deep copy mechanism of qt itself |
386 | // instead of using strdup! | 386 | // instead of using strdup! |
387 | temp = list->mb_name; | 387 | temp = list->mb_name; |
388 | if (temp.lower()=="inbox") | 388 | if (temp.lower()=="inbox") |
389 | continue; | 389 | continue; |
390 | if (temp.lower()==account->getPrefix().lower()) | 390 | if (temp.lower()==account->getPrefix().lower()) |
391 | continue; | 391 | continue; |
392 | if ( (bflags = list->mb_flag) ) { | 392 | if ( (bflags = list->mb_flag) ) { |
393 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 393 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
394 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 394 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
395 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 395 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
396 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 396 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
397 | no_inferiors = true; | 397 | no_inferiors = true; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | } | 400 | } |
401 | del = list->mb_delimiter; | 401 | del = list->mb_delimiter; |
402 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 402 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
403 | } | 403 | } |
404 | } else { | 404 | } else { |
405 | qDebug("error fetching folders "); | 405 | qDebug("error fetching folders "); |
406 | 406 | ||
407 | } | 407 | } |
408 | if (result) mailimap_list_result_free( result ); | 408 | if (result) mailimap_list_result_free( result ); |
409 | return folders; | 409 | return folders; |
410 | } | 410 | } |
411 | 411 | ||
412 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 412 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
413 | { | 413 | { |
414 | RecMail * m = 0; | 414 | RecMail * m = 0; |
415 | mailimap_msg_att_item *item=0; | 415 | mailimap_msg_att_item *item=0; |
416 | clistcell *current,*c,*cf; | 416 | clistcell *current,*c,*cf; |
417 | mailimap_msg_att_dynamic*flist; | 417 | mailimap_msg_att_dynamic*flist; |
418 | mailimap_flag_fetch*cflag; | 418 | mailimap_flag_fetch*cflag; |
419 | int size = 0; | 419 | int size = 0; |
420 | QBitArray mFlags(7); | 420 | QBitArray mFlags(7); |
421 | QStringList addresslist; | 421 | QStringList addresslist; |
422 | 422 | ||
423 | if (!m_att) { | 423 | if (!m_att) { |
424 | return m; | 424 | return m; |
425 | } | 425 | } |
426 | m = new RecMail(); | 426 | m = new RecMail(); |
427 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 427 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
428 | current = c; | 428 | current = c; |
429 | size = 0; | 429 | size = 0; |
430 | item = (mailimap_msg_att_item*)current->data; | 430 | item = (mailimap_msg_att_item*)current->data; |
431 | if ( !item ) | 431 | if ( !item ) |
432 | continue; | 432 | continue; |
433 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 433 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
434 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 434 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
435 | if (!flist || !flist->att_list) { | 435 | if (!flist || !flist->att_list) { |
436 | continue; | 436 | continue; |
437 | } | 437 | } |
438 | cf = flist->att_list->first; | 438 | cf = flist->att_list->first; |
439 | if( ! cf ) | 439 | if( cf ) { |
440 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 440 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
441 | cflag = (mailimap_flag_fetch*)cf->data; | 441 | cflag = (mailimap_flag_fetch*)cf->data; |
442 | if( ! cflag ) | 442 | if( ! cflag ) |
443 | qDebug("imap:not cflag "); | 443 | qDebug("imap:NO cflag "); |
444 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 444 | else { |
445 | switch (cflag->fl_flag->fl_type) { | 445 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
446 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 446 | switch (cflag->fl_flag->fl_type) { |
447 | mFlags.setBit(FLAG_ANSWERED); | 447 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
448 | break; | 448 | mFlags.setBit(FLAG_ANSWERED); |
449 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 449 | break; |
450 | mFlags.setBit(FLAG_FLAGGED); | 450 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
451 | break; | 451 | mFlags.setBit(FLAG_FLAGGED); |
452 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 452 | break; |
453 | mFlags.setBit(FLAG_DELETED); | 453 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
454 | break; | 454 | mFlags.setBit(FLAG_DELETED); |
455 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 455 | break; |
456 | mFlags.setBit(FLAG_SEEN); | 456 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
457 | break; | 457 | mFlags.setBit(FLAG_SEEN); |
458 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 458 | break; |
459 | mFlags.setBit(FLAG_DRAFT); | 459 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
460 | break; | 460 | mFlags.setBit(FLAG_DRAFT); |
461 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 461 | break; |
462 | break; | 462 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
463 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 463 | break; |
464 | break; | 464 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
465 | default: | 465 | break; |
466 | break; | 466 | default: |
467 | break; | ||
468 | } | ||
469 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | ||
470 | mFlags.setBit(FLAG_RECENT); | ||
471 | } | ||
467 | } | 472 | } |
468 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | ||
469 | mFlags.setBit(FLAG_RECENT); | ||
470 | } | 473 | } |
471 | } | 474 | } |
475 | //qDebug(" continue"); | ||
472 | continue; | 476 | continue; |
473 | } | 477 | } |
474 | if ( item->att_data.att_static == NULL ) | 478 | if ( item->att_data.att_static == NULL ) |
475 | continue; | 479 | continue; |
476 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 480 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
477 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 481 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
478 | if ( head == NULL ) | 482 | if ( head == NULL ) |
479 | continue; | 483 | continue; |
480 | if ( head->env_date != NULL ) { | 484 | if ( head->env_date != NULL ) { |
481 | m->setDate(head->env_date); | 485 | m->setDate(head->env_date); |
482 | //struct mailimf_date_time result; | 486 | //struct mailimf_date_time result; |
483 | struct mailimf_date_time* date;// = &result; | 487 | struct mailimf_date_time* date;// = &result; |
484 | struct mailimf_date_time **re = &date; | 488 | struct mailimf_date_time **re = &date; |
485 | size_t length = m->getDate().length(); | 489 | size_t length = m->getDate().length(); |
486 | size_t index = 0; | 490 | size_t index = 0; |
487 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | 491 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { |
492 | //qDebug("parseDateTime "); | ||
488 | QDateTime dt = Genericwrapper::parseDateTime( date ); | 493 | QDateTime dt = Genericwrapper::parseDateTime( date ); |
489 | QString ret; | 494 | QString ret; |
490 | if ( dt.date() == QDate::currentDate () ) | 495 | if ( dt.date() == QDate::currentDate () ) |
491 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 496 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
492 | else { | 497 | else { |
493 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 498 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
494 | } | 499 | } |
495 | m->setDate( ret ); | 500 | m->setDate( ret ); |
496 | char tmp[20]; | 501 | char tmp[20]; |
497 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", | 502 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", |
498 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); | 503 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); |
499 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); | 504 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); |
500 | m->setIsoDate( QString( tmp ) ); | 505 | m->setIsoDate( QString( tmp ) ); |
501 | mailimf_date_time_free ( date ); | 506 | mailimf_date_time_free ( date ); |
502 | } else { | 507 | } else { |
503 | m->setIsoDate(head->env_date); | 508 | m->setIsoDate(head->env_date); |
504 | } | 509 | } |
505 | } | 510 | } |
506 | if ( head->env_subject != NULL ) | 511 | if ( head->env_subject != NULL ) |
507 | m->setSubject(convert_String((const char*)head->env_subject)); | 512 | m->setSubject(convert_String((const char*)head->env_subject)); |
508 | //m->setSubject(head->env_subject); | 513 | //m->setSubject(head->env_subject); |
509 | if (head->env_from!=NULL) { | 514 | if (head->env_from!=NULL) { |
510 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 515 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
511 | if (addresslist.count()) { | 516 | if (addresslist.count()) { |
512 | m->setFrom(addresslist.first()); | 517 | m->setFrom(addresslist.first()); |
513 | } | 518 | } |
514 | } | 519 | } |
515 | if (head->env_to!=NULL) { | 520 | if (head->env_to!=NULL) { |
516 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 521 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
517 | m->setTo(addresslist); | 522 | m->setTo(addresslist); |
518 | } | 523 | } |
519 | if (head->env_cc!=NULL) { | 524 | if (head->env_cc!=NULL) { |
520 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 525 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
521 | m->setCC(addresslist); | 526 | m->setCC(addresslist); |
522 | } | 527 | } |
523 | if (head->env_bcc!=NULL) { | 528 | if (head->env_bcc!=NULL) { |
524 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 529 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
525 | m->setBcc(addresslist); | 530 | m->setBcc(addresslist); |
526 | } | 531 | } |
527 | /* reply to address, eg. email. */ | 532 | /* reply to address, eg. email. */ |
528 | if (head->env_reply_to!=NULL) { | 533 | if (head->env_reply_to!=NULL) { |
529 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 534 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
530 | if (addresslist.count()) { | 535 | if (addresslist.count()) { |
531 | m->setReplyto(addresslist.first()); | 536 | m->setReplyto(addresslist.first()); |
532 | } | 537 | } |
533 | } | 538 | } |
534 | if (head->env_in_reply_to!=NULL) { | 539 | if (head->env_in_reply_to!=NULL) { |
535 | QString h(head->env_in_reply_to); | 540 | QString h(head->env_in_reply_to); |
536 | while (h.length()>0 && h[0]=='<') { | 541 | while (h.length()>0 && h[0]=='<') { |
537 | h.remove(0,1); | 542 | h.remove(0,1); |
538 | } | 543 | } |
539 | while (h.length()>0 && h[h.length()-1]=='>') { | 544 | while (h.length()>0 && h[h.length()-1]=='>') { |
540 | h.remove(h.length()-1,1); | 545 | h.remove(h.length()-1,1); |
541 | } | 546 | } |
542 | if (h.length()>0) { | 547 | if (h.length()>0) { |
543 | m->setInreply(QStringList(h)); | 548 | m->setInreply(QStringList(h)); |
544 | } | 549 | } |
545 | } | 550 | } |
546 | if (head->env_message_id != NULL) { | 551 | if (head->env_message_id != NULL) { |
547 | m->setMsgid(QString(head->env_message_id)); | 552 | m->setMsgid(QString(head->env_message_id)); |
548 | } | 553 | } |
549 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 554 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
550 | #if 0 | 555 | #if 0 |
551 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 556 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
552 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 557 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
553 | qDebug("time %s ",da.toString().latin1() ); | 558 | qDebug("time %s ",da.toString().latin1() ); |
554 | #endif | 559 | #endif |
555 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 560 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
556 | size = item->att_data.att_static->att_data.att_rfc822_size; | 561 | size = item->att_data.att_static->att_data.att_rfc822_size; |
557 | } | 562 | } |
558 | } | 563 | } |
559 | /* msg is already deleted */ | 564 | /* msg is already deleted */ |
560 | if (mFlags.testBit(FLAG_DELETED) && m) { | 565 | if (mFlags.testBit(FLAG_DELETED) && m) { |
561 | delete m; | 566 | delete m; |
562 | m = 0; | 567 | m = 0; |
563 | } | 568 | } |
564 | if (m) { | 569 | if (m) { |
565 | m->setFlags(mFlags); | 570 | m->setFlags(mFlags); |
566 | m->setMsgsize(size); | 571 | m->setMsgsize(size); |
567 | } | 572 | } |
568 | return m; | 573 | return m; |
569 | } | 574 | } |
570 | 575 | ||
571 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 576 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
572 | { | 577 | { |
573 | RecBodyP body = new RecBody(); | 578 | RecBodyP body = new RecBody(); |
574 | const char *mb; | 579 | const char *mb; |
575 | int err = MAILIMAP_NO_ERROR; | 580 | int err = MAILIMAP_NO_ERROR; |
576 | clist *result = 0; | 581 | clist *result = 0; |
577 | clistcell *current; | 582 | clistcell *current; |
578 | mailimap_fetch_att *fetchAtt = 0; | 583 | mailimap_fetch_att *fetchAtt = 0; |
579 | mailimap_fetch_type *fetchType = 0; | 584 | mailimap_fetch_type *fetchType = 0; |
580 | mailimap_set *set = 0; | 585 | mailimap_set *set = 0; |
581 | mailimap_body*body_desc = 0; | 586 | mailimap_body*body_desc = 0; |
582 | 587 | ||
583 | mb = mail->getMbox().latin1(); | 588 | mb = mail->getMbox().latin1(); |
584 | 589 | ||
585 | login(); | 590 | login(); |
586 | if (!m_imap) { | 591 | if (!m_imap) { |
587 | return body; | 592 | return body; |
588 | } | 593 | } |
589 | err = selectMbox(mail->getMbox()); | 594 | err = selectMbox(mail->getMbox()); |
590 | if ( err != MAILIMAP_NO_ERROR ) { | 595 | if ( err != MAILIMAP_NO_ERROR ) { |
591 | return body; | 596 | return body; |
592 | } | 597 | } |
593 | 598 | ||
594 | /* the range has to start at 1!!! not with 0!!!! */ | 599 | /* the range has to start at 1!!! not with 0!!!! */ |
595 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 600 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
596 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 601 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
597 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 602 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
598 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 603 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
599 | mailimap_set_free( set ); | 604 | mailimap_set_free( set ); |
600 | mailimap_fetch_type_free( fetchType ); | 605 | mailimap_fetch_type_free( fetchType ); |
601 | 606 | ||
602 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 607 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
603 | mailimap_msg_att * msg_att; | 608 | mailimap_msg_att * msg_att; |
604 | msg_att = (mailimap_msg_att*)current->data; | 609 | msg_att = (mailimap_msg_att*)current->data; |
605 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 610 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
606 | QValueList<int> path; | 611 | QValueList<int> path; |
607 | body_desc = item->att_data.att_static->att_data.att_body; | 612 | body_desc = item->att_data.att_static->att_data.att_body; |
608 | traverseBody(mail,body_desc,body,0,path); | 613 | traverseBody(mail,body_desc,body,0,path); |
609 | } else { | 614 | } else { |
610 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; | 615 | qDebug("error fetching body %d (%d): %s", err, MAILIMAP_NO_ERROR, m_imap->imap_response ); |
611 | } | 616 | } |
612 | if (result) mailimap_fetch_list_free(result); | 617 | if (result) mailimap_fetch_list_free(result); |
613 | return body; | 618 | return body; |
614 | } | 619 | } |
615 | 620 | ||
616 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 621 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
617 | { | 622 | { |
618 | QStringList l; | 623 | QStringList l; |
619 | QString from; | 624 | QString from; |
620 | bool named_from; | 625 | bool named_from; |
621 | clistcell *current = NULL; | 626 | clistcell *current = NULL; |
622 | mailimap_address * current_address=NULL; | 627 | mailimap_address * current_address=NULL; |
623 | if (!list) { | 628 | if (!list) { |
624 | return l; | 629 | return l; |
625 | } | 630 | } |
626 | unsigned int count = 0; | 631 | unsigned int count = 0; |
627 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 632 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
628 | from = ""; | 633 | from = ""; |
629 | named_from = false; | 634 | named_from = false; |
630 | current_address=(mailimap_address*)current->data; | 635 | current_address=(mailimap_address*)current->data; |
631 | if (current_address->ad_personal_name){ | 636 | if (current_address->ad_personal_name){ |
632 | from+=convert_String((const char*)current_address->ad_personal_name); | 637 | from+=convert_String((const char*)current_address->ad_personal_name); |
633 | from+=" "; | 638 | from+=" "; |
634 | named_from = true; | 639 | named_from = true; |
635 | } | 640 | } |
636 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 641 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
637 | from+="<"; | 642 | from+="<"; |
638 | } | 643 | } |
639 | if (current_address->ad_mailbox_name) { | 644 | if (current_address->ad_mailbox_name) { |
640 | from+=QString(current_address->ad_mailbox_name); | 645 | from+=QString(current_address->ad_mailbox_name); |
641 | from+="@"; | 646 | from+="@"; |
642 | } | 647 | } |
643 | if (current_address->ad_host_name) { | 648 | if (current_address->ad_host_name) { |
644 | from+=QString(current_address->ad_host_name); | 649 | from+=QString(current_address->ad_host_name); |
645 | } | 650 | } |
646 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 651 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
647 | from+=">"; | 652 | from+=">"; |
648 | } | 653 | } |
649 | l.append(QString(from)); | 654 | l.append(QString(from)); |
650 | if (++count > 99) { | 655 | if (++count > 99) { |
651 | break; | 656 | break; |
652 | } | 657 | } |
653 | } | 658 | } |
654 | return l; | 659 | return l; |
655 | } | 660 | } |
656 | 661 | ||
657 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) | 662 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
658 | { | 663 | { |
659 | encodedString*res=new encodedString; | 664 | encodedString*res=new encodedString; |
660 | int err; | 665 | int err; |
661 | mailimap_fetch_type *fetchType; | 666 | mailimap_fetch_type *fetchType; |
662 | mailimap_set *set; | 667 | mailimap_set *set; |
663 | clistcell*current,*cur; | 668 | clistcell*current,*cur; |
664 | mailimap_section_part * section_part = 0; | 669 | mailimap_section_part * section_part = 0; |
665 | mailimap_section_spec * section_spec = 0; | 670 | mailimap_section_spec * section_spec = 0; |
666 | mailimap_section * section = 0; | 671 | mailimap_section * section = 0; |
667 | mailimap_fetch_att * fetch_att = 0; | 672 | mailimap_fetch_att * fetch_att = 0; |
668 | 673 | ||
669 | login(); | 674 | login(); |
670 | if (!m_imap) { | 675 | if (!m_imap) { |
671 | return res; | 676 | return res; |
672 | } | 677 | } |
673 | if (!internal_call) { | 678 | if (!internal_call) { |
674 | err = selectMbox(mail->getMbox()); | 679 | err = selectMbox(mail->getMbox()); |
675 | if ( err != MAILIMAP_NO_ERROR ) { | 680 | if ( err != MAILIMAP_NO_ERROR ) { |
676 | return res; | 681 | return res; |
677 | } | 682 | } |
678 | } | 683 | } |
679 | set = mailimap_set_new_single(mail->getNumber()); | 684 | set = mailimap_set_new_single(mail->getNumber()); |
680 | 685 | ||
681 | clist*id_list = 0; | 686 | clist*id_list = 0; |
682 | 687 | ||
683 | /* if path == empty then its a request for the whole rfc822 mail and generates | 688 | /* if path == empty then its a request for the whole rfc822 mail and generates |
684 | a "fetch <id> (body[])" statement on imap server */ | 689 | a "fetch <id> (body[])" statement on imap server */ |
685 | if (path.count()>0 ) { | 690 | if (path.count()>0 ) { |
686 | id_list = clist_new(); | 691 | id_list = clist_new(); |
687 | for (unsigned j=0; j < path.count();++j) { | 692 | for (unsigned j=0; j < path.count();++j) { |
688 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 693 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
689 | *p_id = path[j]; | 694 | *p_id = path[j]; |
690 | clist_append(id_list,p_id); | 695 | clist_append(id_list,p_id); |
691 | } | 696 | } |
692 | section_part = mailimap_section_part_new(id_list); | 697 | section_part = mailimap_section_part_new(id_list); |
693 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 698 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
694 | } | 699 | } |
695 | 700 | ||
696 | section = mailimap_section_new(section_spec); | 701 | section = mailimap_section_new(section_spec); |
697 | fetch_att = mailimap_fetch_att_new_body_section(section); | 702 | fetch_att = mailimap_fetch_att_new_body_section(section); |
698 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 703 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
699 | 704 | ||
700 | clist*result = 0; | 705 | clist*result = 0; |
701 | 706 | ||
702 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 707 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
703 | mailimap_set_free( set ); | 708 | mailimap_set_free( set ); |
704 | mailimap_fetch_type_free( fetchType ); | 709 | mailimap_fetch_type_free( fetchType ); |
705 | 710 | ||
706 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 711 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
707 | mailimap_msg_att * msg_att; | 712 | mailimap_msg_att * msg_att; |
708 | msg_att = (mailimap_msg_att*)current->data; | 713 | msg_att = (mailimap_msg_att*)current->data; |
709 | mailimap_msg_att_item*msg_att_item; | 714 | mailimap_msg_att_item*msg_att_item; |
710 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 715 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
711 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 716 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
712 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 717 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
713 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 718 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
714 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 719 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
715 | /* detach - we take over the content */ | 720 | /* detach - we take over the content */ |
716 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 721 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
717 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 722 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
718 | } | 723 | } |
719 | } | 724 | } |
720 | } | 725 | } |
721 | } else { | 726 | } else { |
722 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; | 727 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; |
723 | } | 728 | } |
724 | if (result) mailimap_fetch_list_free(result); | 729 | if (result) mailimap_fetch_list_free(result); |
725 | return res; | 730 | return res; |
726 | } | 731 | } |
727 | 732 | ||
728 | /* current_recursion is for recursive calls. | 733 | /* current_recursion is for recursive calls. |
729 | current_count means the position inside the internal loop! */ | 734 | current_count means the position inside the internal loop! */ |
730 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, | 735 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, |
731 | int current_recursion,QValueList<int>recList,int current_count) | 736 | int current_recursion,QValueList<int>recList,int current_count) |
732 | { | 737 | { |
733 | if (!body || current_recursion>=10) { | 738 | if (!body || current_recursion>=10) { |
734 | return; | 739 | return; |
735 | } | 740 | } |
736 | switch (body->bd_type) { | 741 | switch (body->bd_type) { |
737 | case MAILIMAP_BODY_1PART: | 742 | case MAILIMAP_BODY_1PART: |
738 | { | 743 | { |
739 | QValueList<int>countlist = recList; | 744 | QValueList<int>countlist = recList; |
740 | countlist.append(current_count); | 745 | countlist.append(current_count); |
741 | RecPartP currentPart = new RecPart(); | 746 | RecPartP currentPart = new RecPart(); |
742 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 747 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
743 | QString id(""); | 748 | QString id(""); |
744 | currentPart->setPositionlist(countlist); | 749 | currentPart->setPositionlist(countlist); |
745 | for (unsigned int j = 0; j < countlist.count();++j) { | 750 | for (unsigned int j = 0; j < countlist.count();++j) { |
746 | id+=(j>0?" ":""); | 751 | id+=(j>0?" ":""); |
747 | id+=QString("%1").arg(countlist[j]); | 752 | id+=QString("%1").arg(countlist[j]); |
748 | } | 753 | } |
749 | //odebug << "ID = " << id.latin1() << "" << oendl; | 754 | //odebug << "ID = " << id.latin1() << "" << oendl; |
750 | currentPart->setIdentifier(id); | 755 | currentPart->setIdentifier(id); |
751 | fillSinglePart(currentPart,part1); | 756 | fillSinglePart(currentPart,part1); |
752 | /* important: Check for is NULL 'cause a body can be empty! | 757 | /* important: Check for is NULL 'cause a body can be empty! |
753 | And we put it only into the mail if it is the FIRST part */ | 758 | And we put it only into the mail if it is the FIRST part */ |
754 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { | 759 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { |
755 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); | 760 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); |
756 | 761 | ||
757 | size_t index = 0; | 762 | size_t index = 0; |
758 | char*res = 0; | 763 | char*res = 0; |
759 | int err = MAILIMF_NO_ERROR; | 764 | int err = MAILIMF_NO_ERROR; |
760 | 765 | ||
761 | QString charset = currentPart->searchParamter( "charset"); | 766 | QString charset = currentPart->searchParamter( "charset"); |
762 | qDebug("CHARSET %s ",charset.latin1() ); | 767 | qDebug("CHARSET %s ",charset.latin1() ); |
763 | if ( false ) { | 768 | if ( false ) { |
764 | //if ( !charset.isEmpty() ) { | 769 | //if ( !charset.isEmpty() ) { |
765 | target_body->setCharset( charset ); | 770 | target_body->setCharset( charset ); |
766 | //err = mailmime_encoded_phrase_parse("iso-8859-1", | 771 | //err = mailmime_encoded_phrase_parse("iso-8859-1", |
767 | // text, strlen(text),&index, "iso-8859-1",&res); | 772 | // text, strlen(text),&index, "iso-8859-1",&res); |
768 | err = mailmime_encoded_phrase_parse(charset.latin1(), | 773 | err = mailmime_encoded_phrase_parse(charset.latin1(), |
769 | body_text.latin1(), body_text.length(),&index, "utf-8",&res); | 774 | body_text.latin1(), body_text.length(),&index, "utf-8",&res); |
770 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 775 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
771 | //qDebug("res %d %s ", index, res); | 776 | //qDebug("res %d %s ", index, res); |
772 | body_text = QString::fromUtf8(res); | 777 | body_text = QString::fromUtf8(res); |
773 | } | 778 | } |
774 | if (res) free(res); | 779 | if (res) free(res); |
775 | } | 780 | } |
776 | //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); | 781 | //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); |
777 | target_body->setDescription(currentPart); | 782 | target_body->setDescription(currentPart); |
778 | target_body->setBodytext(body_text); | 783 | target_body->setBodytext(body_text); |
779 | if (countlist.count()>1) { | 784 | if (countlist.count()>1) { |
780 | target_body->addPart(currentPart); | 785 | target_body->addPart(currentPart); |
781 | } | 786 | } |
782 | } else { | 787 | } else { |
783 | target_body->addPart(currentPart); | 788 | target_body->addPart(currentPart); |
784 | } | 789 | } |
785 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 790 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
786 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 791 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
787 | } | 792 | } |
788 | } | 793 | } |
789 | break; | 794 | break; |
790 | case MAILIMAP_BODY_MPART: | 795 | case MAILIMAP_BODY_MPART: |
791 | { | 796 | { |
792 | QValueList<int>countlist = recList; | 797 | QValueList<int>countlist = recList; |
793 | clistcell*current=0; | 798 | clistcell*current=0; |
794 | mailimap_body*current_body=0; | 799 | mailimap_body*current_body=0; |
795 | unsigned int ccount = 1; | 800 | unsigned int ccount = 1; |
796 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 801 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
797 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 802 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
798 | current_body = (mailimap_body*)current->data; | 803 | current_body = (mailimap_body*)current->data; |
799 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 804 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
800 | RecPartP targetPart = new RecPart(); | 805 | RecPartP targetPart = new RecPart(); |
801 | targetPart->setType("multipart"); | 806 | targetPart->setType("multipart"); |
802 | fillMultiPart(targetPart,mailDescription); | 807 | fillMultiPart(targetPart,mailDescription); |
803 | countlist.append(current_count); | 808 | countlist.append(current_count); |
804 | targetPart->setPositionlist(countlist); | 809 | targetPart->setPositionlist(countlist); |
805 | target_body->addPart(targetPart); | 810 | target_body->addPart(targetPart); |
806 | QString id(""); | 811 | QString id(""); |
807 | for (unsigned int j = 0; j < countlist.count();++j) { | 812 | for (unsigned int j = 0; j < countlist.count();++j) { |
808 | id+=(j>0?" ":""); | 813 | id+=(j>0?" ":""); |
809 | id+=QString("%1").arg(countlist[j]); | 814 | id+=QString("%1").arg(countlist[j]); |
810 | } | 815 | } |
811 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; | 816 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; |
812 | } | 817 | } |
813 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 818 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
814 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 819 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
815 | countlist = recList; | 820 | countlist = recList; |
816 | } | 821 | } |
817 | ++ccount; | 822 | ++ccount; |
818 | } | 823 | } |
819 | } | 824 | } |
820 | break; | 825 | break; |
821 | default: | 826 | default: |
822 | break; | 827 | break; |
823 | } | 828 | } |
824 | } | 829 | } |
825 | 830 | ||
826 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) | 831 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) |
827 | { | 832 | { |
828 | if (!Description) { | 833 | if (!Description) { |
829 | return; | 834 | return; |
830 | } | 835 | } |
831 | switch (Description->bd_type) { | 836 | switch (Description->bd_type) { |
832 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 837 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
833 | target_part->setType("text"); | 838 | target_part->setType("text"); |
834 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 839 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
835 | break; | 840 | break; |
836 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 841 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
837 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 842 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
838 | break; | 843 | break; |
839 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 844 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
840 | target_part->setType("message"); | 845 | target_part->setType("message"); |
841 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | 846 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); |
842 | break; | 847 | break; |
843 | default: | 848 | default: |
844 | break; | 849 | break; |
845 | } | 850 | } |
846 | } | 851 | } |
847 | 852 | ||
848 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) | 853 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) |
849 | { | 854 | { |
850 | if (!which) { | 855 | if (!which) { |
851 | return; | 856 | return; |
852 | } | 857 | } |
853 | QString sub; | 858 | QString sub; |
854 | sub = which->bd_media_text; | 859 | sub = which->bd_media_text; |
855 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; | 860 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; |
856 | target_part->setSubtype(sub.lower()); | 861 | target_part->setSubtype(sub.lower()); |
857 | target_part->setLines(which->bd_lines); | 862 | target_part->setLines(which->bd_lines); |
858 | fillBodyFields(target_part,which->bd_fields); | 863 | fillBodyFields(target_part,which->bd_fields); |
859 | } | 864 | } |
860 | 865 | ||
861 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) | 866 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) |
862 | { | 867 | { |
863 | if (!which) { | 868 | if (!which) { |
864 | return; | 869 | return; |
865 | } | 870 | } |
866 | target_part->setSubtype("rfc822"); | 871 | target_part->setSubtype("rfc822"); |
867 | //odebug << "Message part" << oendl; | 872 | //odebug << "Message part" << oendl; |
868 | /* we set this type to text/plain */ | 873 | /* we set this type to text/plain */ |
869 | target_part->setLines(which->bd_lines); | 874 | target_part->setLines(which->bd_lines); |
870 | fillBodyFields(target_part,which->bd_fields); | 875 | fillBodyFields(target_part,which->bd_fields); |
871 | } | 876 | } |
872 | 877 | ||
873 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) | 878 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) |
874 | { | 879 | { |
875 | if (!which) return; | 880 | if (!which) return; |
876 | QString sub = which->bd_media_subtype; | 881 | QString sub = which->bd_media_subtype; |
877 | target_part->setSubtype(sub.lower()); | 882 | target_part->setSubtype(sub.lower()); |
878 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 883 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
879 | clistcell*cur = 0; | 884 | clistcell*cur = 0; |
880 | mailimap_single_body_fld_param*param=0; | 885 | mailimap_single_body_fld_param*param=0; |
881 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 886 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
882 | param = (mailimap_single_body_fld_param*)cur->data; | 887 | param = (mailimap_single_body_fld_param*)cur->data; |
883 | if (param) { | 888 | if (param) { |
884 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 889 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
885 | } | 890 | } |
886 | } | 891 | } |
887 | } | 892 | } |
888 | } | 893 | } |
889 | 894 | ||
890 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) | 895 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) |
891 | { | 896 | { |
892 | if (!which) { | 897 | if (!which) { |
893 | return; | 898 | return; |
894 | } | 899 | } |
895 | QString type,sub; | 900 | QString type,sub; |
896 | switch (which->bd_media_basic->med_type) { | 901 | switch (which->bd_media_basic->med_type) { |
897 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 902 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
898 | type = "application"; | 903 | type = "application"; |
899 | break; | 904 | break; |
900 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 905 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
901 | type = "audio"; | 906 | type = "audio"; |
902 | break; | 907 | break; |
903 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 908 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
904 | type = "image"; | 909 | type = "image"; |
905 | break; | 910 | break; |
906 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 911 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
907 | type = "message"; | 912 | type = "message"; |
908 | break; | 913 | break; |
909 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 914 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
910 | type = "video"; | 915 | type = "video"; |
911 | break; | 916 | break; |
912 | case MAILIMAP_MEDIA_BASIC_OTHER: | 917 | case MAILIMAP_MEDIA_BASIC_OTHER: |
913 | default: | 918 | default: |
914 | if (which->bd_media_basic->med_basic_type) { | 919 | if (which->bd_media_basic->med_basic_type) { |
915 | type = which->bd_media_basic->med_basic_type; | 920 | type = which->bd_media_basic->med_basic_type; |
916 | } else { | 921 | } else { |
917 | type = ""; | 922 | type = ""; |
918 | } | 923 | } |
919 | break; | 924 | break; |
920 | } | 925 | } |
921 | if (which->bd_media_basic->med_subtype) { | 926 | if (which->bd_media_basic->med_subtype) { |
922 | sub = which->bd_media_basic->med_subtype; | 927 | sub = which->bd_media_basic->med_subtype; |
923 | } else { | 928 | } else { |
924 | sub = ""; | 929 | sub = ""; |
925 | } | 930 | } |
926 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; | 931 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; |
927 | target_part->setType(type.lower()); | 932 | target_part->setType(type.lower()); |
928 | target_part->setSubtype(sub.lower()); | 933 | target_part->setSubtype(sub.lower()); |
929 | fillBodyFields(target_part,which->bd_fields); | 934 | fillBodyFields(target_part,which->bd_fields); |
930 | } | 935 | } |
931 | 936 | ||
932 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) | 937 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) |
933 | { | 938 | { |
934 | if (!which) return; | 939 | if (!which) return; |
935 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 940 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
936 | clistcell*cur; | 941 | clistcell*cur; |
937 | mailimap_single_body_fld_param*param=0; | 942 | mailimap_single_body_fld_param*param=0; |
938 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 943 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
939 | param = (mailimap_single_body_fld_param*)cur->data; | 944 | param = (mailimap_single_body_fld_param*)cur->data; |
940 | if (param) { | 945 | if (param) { |
941 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 946 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
942 | } | 947 | } |
943 | } | 948 | } |
944 | } | 949 | } |
945 | mailimap_body_fld_enc*enc = which->bd_encoding; | 950 | mailimap_body_fld_enc*enc = which->bd_encoding; |
946 | QString encoding(""); | 951 | QString encoding(""); |
947 | switch (enc->enc_type) { | 952 | switch (enc->enc_type) { |
948 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 953 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
949 | encoding = "7bit"; | 954 | encoding = "7bit"; |
950 | break; | 955 | break; |
951 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 956 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
952 | encoding = "8bit"; | 957 | encoding = "8bit"; |
953 | break; | 958 | break; |
954 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 959 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
955 | encoding="binary"; | 960 | encoding="binary"; |
956 | break; | 961 | break; |
957 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 962 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
958 | encoding="base64"; | 963 | encoding="base64"; |
959 | break; | 964 | break; |
960 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 965 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
961 | encoding="quoted-printable"; | 966 | encoding="quoted-printable"; |
962 | break; | 967 | break; |
963 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 968 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
964 | default: | 969 | default: |
965 | if (enc->enc_value) { | 970 | if (enc->enc_value) { |
966 | char*t=enc->enc_value; | 971 | char*t=enc->enc_value; |
967 | encoding=QString(enc->enc_value); | 972 | encoding=QString(enc->enc_value); |
968 | enc->enc_value=0L; | 973 | enc->enc_value=0L; |
969 | free(t); | 974 | free(t); |
970 | } | 975 | } |
971 | } | 976 | } |
972 | if (which->bd_description) { | 977 | if (which->bd_description) { |
973 | target_part->setDescription(QString(which->bd_description)); | 978 | target_part->setDescription(QString(which->bd_description)); |
974 | } | 979 | } |
975 | target_part->setEncoding(encoding); | 980 | target_part->setEncoding(encoding); |
976 | target_part->setSize(which->bd_size); | 981 | target_part->setSize(which->bd_size); |
977 | } | 982 | } |
978 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | 983 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) |
979 | { | 984 | { |
980 | //#if 0 | 985 | //#if 0 |
981 | mailimap_flag_list*flist; | 986 | mailimap_flag_list*flist; |
982 | mailimap_set *set; | 987 | mailimap_set *set; |
983 | mailimap_store_att_flags * store_flags; | 988 | mailimap_store_att_flags * store_flags; |
984 | int err; | 989 | int err; |
985 | login(); | 990 | login(); |
986 | //#endif | 991 | //#endif |
987 | if (!m_imap) { | 992 | if (!m_imap) { |
988 | return; | 993 | return; |
989 | } | 994 | } |
990 | int iii = 0; | 995 | int iii = 0; |
991 | int count = target.count(); | 996 | int count = target.count(); |
992 | // qDebug("imap remove count %d ", count); | 997 | // qDebug("imap remove count %d ", count); |
993 | 998 | ||
994 | 999 | ||
995 | mMax = count; | 1000 | mMax = count; |
996 | progress( i18n("Delete")); | 1001 | progress( i18n("Delete")); |
997 | 1002 | ||
998 | QProgressBar wid ( count ); | 1003 | QProgressBar wid ( count ); |
999 | wid.setCaption( i18n("Deleting ...")); | 1004 | wid.setCaption( i18n("Deleting ...")); |
1000 | wid.show(); | 1005 | wid.show(); |
1001 | while (iii < count ) { | 1006 | while (iii < count ) { |
1002 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); | 1007 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
1003 | wid.setProgress( iii ); | 1008 | wid.setProgress( iii ); |
1004 | wid.raise(); | 1009 | wid.raise(); |
1005 | qApp->processEvents(); | 1010 | qApp->processEvents(); |
1006 | RecMailP mail = (*target.at( iii )); | 1011 | RecMailP mail = (*target.at( iii )); |
1007 | //#if 0 | 1012 | //#if 0 |
1008 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); | 1013 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); |
1009 | err = selectMbox(mail->getMbox()); | 1014 | err = selectMbox(mail->getMbox()); |
1010 | if ( err != MAILIMAP_NO_ERROR ) { | 1015 | if ( err != MAILIMAP_NO_ERROR ) { |
1011 | return; | 1016 | return; |
1012 | } | 1017 | } |
1013 | flist = mailimap_flag_list_new_empty(); | 1018 | flist = mailimap_flag_list_new_empty(); |
1014 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1019 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1015 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1020 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1016 | set = mailimap_set_new_single(mail->getNumber()); | 1021 | set = mailimap_set_new_single(mail->getNumber()); |
1017 | err = mailimap_store(m_imap,set,store_flags); | 1022 | err = mailimap_store(m_imap,set,store_flags); |
1018 | mailimap_set_free( set ); | 1023 | mailimap_set_free( set ); |
1019 | mailimap_store_att_flags_free(store_flags); | 1024 | mailimap_store_att_flags_free(store_flags); |
1020 | 1025 | ||
1021 | if (err != MAILIMAP_NO_ERROR) { | 1026 | if (err != MAILIMAP_NO_ERROR) { |
1022 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1027 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
1023 | return; | 1028 | return; |
1024 | } | 1029 | } |
1025 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1030 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1026 | /* should we realy do that at this moment? */ | 1031 | /* should we realy do that at this moment? */ |
1027 | 1032 | ||
1028 | // err = mailimap_expunge(m_imap); | 1033 | // err = mailimap_expunge(m_imap); |
1029 | //if (err != MAILIMAP_NO_ERROR) { | 1034 | //if (err != MAILIMAP_NO_ERROR) { |
1030 | // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); | 1035 | // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); |
1031 | // } | 1036 | // } |
1032 | //#endif | 1037 | //#endif |
1033 | //deleteMail( mail); | 1038 | //deleteMail( mail); |
1034 | ++iii; | 1039 | ++iii; |
1035 | } | 1040 | } |
1036 | //qDebug("Deleting imap mails... "); | 1041 | //qDebug("Deleting imap mails... "); |
1037 | err = mailimap_expunge(m_imap); | 1042 | err = mailimap_expunge(m_imap); |
1038 | if (err != MAILIMAP_NO_ERROR) { | 1043 | if (err != MAILIMAP_NO_ERROR) { |
1039 | Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); | 1044 | Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); |
1040 | } | 1045 | } |
1041 | } | 1046 | } |
1042 | void IMAPwrapper::deleteMail(const RecMailP&mail) | 1047 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
1043 | { | 1048 | { |
1044 | mailimap_flag_list*flist; | 1049 | mailimap_flag_list*flist; |
1045 | mailimap_set *set; | 1050 | mailimap_set *set; |
1046 | mailimap_store_att_flags * store_flags; | 1051 | mailimap_store_att_flags * store_flags; |
1047 | int err; | 1052 | int err; |
1048 | login(); | 1053 | login(); |
1049 | if (!m_imap) { | 1054 | if (!m_imap) { |
1050 | return; | 1055 | return; |
1051 | } | 1056 | } |
1052 | err = selectMbox(mail->getMbox()); | 1057 | err = selectMbox(mail->getMbox()); |
1053 | if ( err != MAILIMAP_NO_ERROR ) { | 1058 | if ( err != MAILIMAP_NO_ERROR ) { |
1054 | return; | 1059 | return; |
1055 | } | 1060 | } |
1056 | flist = mailimap_flag_list_new_empty(); | 1061 | flist = mailimap_flag_list_new_empty(); |
1057 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1062 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1058 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1063 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1059 | set = mailimap_set_new_single(mail->getNumber()); | 1064 | set = mailimap_set_new_single(mail->getNumber()); |
1060 | err = mailimap_store(m_imap,set,store_flags); | 1065 | err = mailimap_store(m_imap,set,store_flags); |
1061 | mailimap_set_free( set ); | 1066 | mailimap_set_free( set ); |
1062 | mailimap_store_att_flags_free(store_flags); | 1067 | mailimap_store_att_flags_free(store_flags); |
1063 | 1068 | ||
1064 | if (err != MAILIMAP_NO_ERROR) { | 1069 | if (err != MAILIMAP_NO_ERROR) { |
1065 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1070 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
1066 | return; | 1071 | return; |
1067 | } | 1072 | } |
1068 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1073 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1069 | /* should we realy do that at this moment? */ | 1074 | /* should we realy do that at this moment? */ |
1070 | 1075 | ||
1071 | err = mailimap_expunge(m_imap); | 1076 | err = mailimap_expunge(m_imap); |
1072 | if (err != MAILIMAP_NO_ERROR) { | 1077 | if (err != MAILIMAP_NO_ERROR) { |
1073 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1078 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1074 | } | 1079 | } |
1075 | //qDebug("IMAPwrapper::deleteMail 2"); | 1080 | //qDebug("IMAPwrapper::deleteMail 2"); |
1076 | 1081 | ||
1077 | } | 1082 | } |
1078 | 1083 | ||
1079 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 1084 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
1080 | { | 1085 | { |
1081 | mailimap_flag_list*flist; | 1086 | mailimap_flag_list*flist; |
1082 | mailimap_set *set; | 1087 | mailimap_set *set; |
1083 | mailimap_store_att_flags * store_flags; | 1088 | mailimap_store_att_flags * store_flags; |
1084 | int err; | 1089 | int err; |
1085 | login(); | 1090 | login(); |
1086 | if (!m_imap) { | 1091 | if (!m_imap) { |
1087 | return; | 1092 | return; |
1088 | } | 1093 | } |
1089 | err = selectMbox(mail->getMbox()); | 1094 | err = selectMbox(mail->getMbox()); |
1090 | if ( err != MAILIMAP_NO_ERROR ) { | 1095 | if ( err != MAILIMAP_NO_ERROR ) { |
1091 | return; | 1096 | return; |
1092 | } | 1097 | } |
1093 | flist = mailimap_flag_list_new_empty(); | 1098 | flist = mailimap_flag_list_new_empty(); |
1094 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 1099 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
1095 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 1100 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
1096 | set = mailimap_set_new_single(mail->getNumber()); | 1101 | set = mailimap_set_new_single(mail->getNumber()); |
1097 | err = mailimap_store(m_imap,set,store_flags); | 1102 | err = mailimap_store(m_imap,set,store_flags); |
1098 | mailimap_set_free( set ); | 1103 | mailimap_set_free( set ); |
1099 | mailimap_store_att_flags_free(store_flags); | 1104 | mailimap_store_att_flags_free(store_flags); |
1100 | 1105 | ||
1101 | if (err != MAILIMAP_NO_ERROR) { | 1106 | if (err != MAILIMAP_NO_ERROR) { |
1102 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; | 1107 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; |
1103 | return; | 1108 | return; |
1104 | } | 1109 | } |
1105 | } | 1110 | } |
1106 | 1111 | ||
1107 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 1112 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
1108 | { | 1113 | { |
1109 | QString body(""); | 1114 | QString body(""); |
1110 | encodedString*res = fetchRawPart(mail,path,internal_call); | 1115 | encodedString*res = fetchRawPart(mail,path,internal_call); |
1111 | encodedString*r = decode_String(res,enc); | 1116 | encodedString*r = decode_String(res,enc); |
1112 | delete res; | 1117 | delete res; |
1113 | if (r) { | 1118 | if (r) { |
1114 | if (r->Length()>0) { | 1119 | if (r->Length()>0) { |
1115 | body = r->Content(); | 1120 | body = r->Content(); |
1116 | } | 1121 | } |
1117 | delete r; | 1122 | delete r; |
1118 | } | 1123 | } |
1119 | return body; | 1124 | return body; |
1120 | } | 1125 | } |
1121 | 1126 | ||
1122 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 1127 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
1123 | { | 1128 | { |
1124 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); | 1129 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); |
1125 | } | 1130 | } |
1126 | 1131 | ||
1127 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) | 1132 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) |
1128 | { | 1133 | { |
1129 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); | 1134 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); |
1130 | encodedString*r = decode_String(res,part->Encoding()); | 1135 | encodedString*r = decode_String(res,part->Encoding()); |
1131 | delete res; | 1136 | delete res; |
1132 | return r; | 1137 | return r; |
1133 | } | 1138 | } |
1134 | 1139 | ||
1135 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) | 1140 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) |
1136 | { | 1141 | { |
1137 | return fetchRawPart(mail,part->Positionlist(),false); | 1142 | return fetchRawPart(mail,part->Positionlist(),false); |
1138 | } | 1143 | } |
1139 | 1144 | ||
1140 | int IMAPwrapper::deleteAllMail(const FolderP&folder) | 1145 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
1141 | { | 1146 | { |
1142 | login(); | 1147 | login(); |
1143 | if (!m_imap) { | 1148 | if (!m_imap) { |
1144 | return 0; | 1149 | return 0; |
1145 | } | 1150 | } |
1146 | mailimap_flag_list*flist; | 1151 | mailimap_flag_list*flist; |
1147 | mailimap_set *set; | 1152 | mailimap_set *set; |
1148 | mailimap_store_att_flags * store_flags; | 1153 | mailimap_store_att_flags * store_flags; |
1149 | int err = selectMbox(folder->getName()); | 1154 | int err = selectMbox(folder->getName()); |
1150 | if ( err != MAILIMAP_NO_ERROR ) { | 1155 | if ( err != MAILIMAP_NO_ERROR ) { |
1151 | return 0; | 1156 | return 0; |
1152 | } | 1157 | } |
1153 | 1158 | ||
1154 | int last = m_imap->imap_selection_info->sel_exists; | 1159 | int last = m_imap->imap_selection_info->sel_exists; |
1155 | if (last == 0) { | 1160 | if (last == 0) { |
1156 | Global::statusMessage(i18n("Mailbox has no mails!")); | 1161 | Global::statusMessage(i18n("Mailbox has no mails!")); |
1157 | return 0; | 1162 | return 0; |
1158 | } | 1163 | } |
1159 | flist = mailimap_flag_list_new_empty(); | 1164 | flist = mailimap_flag_list_new_empty(); |
1160 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1165 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1161 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1166 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1162 | set = mailimap_set_new_interval( 1, last ); | 1167 | set = mailimap_set_new_interval( 1, last ); |
1163 | err = mailimap_store(m_imap,set,store_flags); | 1168 | err = mailimap_store(m_imap,set,store_flags); |
1164 | mailimap_set_free( set ); | 1169 | mailimap_set_free( set ); |
1165 | mailimap_store_att_flags_free(store_flags); | 1170 | mailimap_store_att_flags_free(store_flags); |
1166 | if (err != MAILIMAP_NO_ERROR) { | 1171 | if (err != MAILIMAP_NO_ERROR) { |
1167 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1172 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1168 | return 0; | 1173 | return 0; |
1169 | } | 1174 | } |
1170 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1175 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1171 | /* should we realy do that at this moment? */ | 1176 | /* should we realy do that at this moment? */ |
1172 | err = mailimap_expunge(m_imap); | 1177 | err = mailimap_expunge(m_imap); |
1173 | if (err != MAILIMAP_NO_ERROR) { | 1178 | if (err != MAILIMAP_NO_ERROR) { |
1174 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1179 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1175 | return 0; | 1180 | return 0; |
1176 | } | 1181 | } |
1177 | // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; | 1182 | // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; |
1178 | return 1; | 1183 | return 1; |
1179 | } | 1184 | } |
1180 | 1185 | ||
1181 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) | 1186 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) |
1182 | { | 1187 | { |
1183 | if (folder.length()==0) return 0; | 1188 | if (folder.length()==0) return 0; |
1184 | login(); | 1189 | login(); |
1185 | if (!m_imap) {return 0;} | 1190 | if (!m_imap) {return 0;} |
1186 | QString pre = account->getPrefix(); | 1191 | QString pre = account->getPrefix(); |
1187 | if (delemiter.length()>0 && pre.findRev(delemiter)!=((int)pre.length())-1) { | 1192 | if (delemiter.length()>0 && pre.findRev(delemiter)!=((int)pre.length())-1) { |
1188 | pre+=delemiter; | 1193 | pre+=delemiter; |
1189 | } | 1194 | } |
1190 | if (parentfolder) { | 1195 | if (parentfolder) { |
1191 | pre += parentfolder->getDisplayName()+delemiter; | 1196 | pre += parentfolder->getDisplayName()+delemiter; |
1192 | } | 1197 | } |
1193 | pre+=folder; | 1198 | pre+=folder; |
1194 | if (getsubfolder) { | 1199 | if (getsubfolder) { |
1195 | if (delemiter.length()>0) { | 1200 | if (delemiter.length()>0) { |
1196 | pre+=delemiter; | 1201 | pre+=delemiter; |
1197 | } else { | 1202 | } else { |
1198 | Global::statusMessage(i18n("Cannot create folder %1 for holding subfolders").arg(pre)); | 1203 | Global::statusMessage(i18n("Cannot create folder %1 for holding subfolders").arg(pre)); |
1199 | return 0; | 1204 | return 0; |
1200 | } | 1205 | } |
1201 | } | 1206 | } |
1202 | // odebug << "Creating " << pre.latin1() << "" << oendl; | 1207 | // odebug << "Creating " << pre.latin1() << "" << oendl; |
1203 | int res = mailimap_create(m_imap,pre.latin1()); | 1208 | int res = mailimap_create(m_imap,pre.latin1()); |
1204 | if (res != MAILIMAP_NO_ERROR) { | 1209 | if (res != MAILIMAP_NO_ERROR) { |
1205 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); | 1210 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); |
1206 | return 0; | 1211 | return 0; |
1207 | } | 1212 | } |
1208 | return 1; | 1213 | return 1; |
1209 | } | 1214 | } |
1210 | 1215 | ||
1211 | int IMAPwrapper::deleteMbox(const FolderP&folder) | 1216 | int IMAPwrapper::deleteMbox(const FolderP&folder) |
1212 | { | 1217 | { |
1213 | if (!folder) return 0; | 1218 | if (!folder) return 0; |
1214 | login(); | 1219 | login(); |
1215 | if (!m_imap) {return 0;} | 1220 | if (!m_imap) {return 0;} |
1216 | int res = mailimap_delete(m_imap,folder->getName()); | 1221 | int res = mailimap_delete(m_imap,folder->getName()); |
1217 | if (res != MAILIMAP_NO_ERROR) { | 1222 | if (res != MAILIMAP_NO_ERROR) { |
1218 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); | 1223 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); |
1219 | return 0; | 1224 | return 0; |
1220 | } | 1225 | } |
1221 | return 1; | 1226 | return 1; |
1222 | } | 1227 | } |
1223 | 1228 | ||
1224 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1229 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1225 | { | 1230 | { |
1226 | mailimap_status_att_list * att_list =0; | 1231 | mailimap_status_att_list * att_list =0; |
1227 | mailimap_mailbox_data_status * status=0; | 1232 | mailimap_mailbox_data_status * status=0; |
1228 | clistiter * cur = 0; | 1233 | clistiter * cur = 0; |
1229 | int r = 0; | 1234 | int r = 0; |
1230 | target_stat.message_count = 0; | 1235 | target_stat.message_count = 0; |
1231 | target_stat.message_unseen = 0; | 1236 | target_stat.message_unseen = 0; |
1232 | target_stat.message_recent = 0; | 1237 | target_stat.message_recent = 0; |
1233 | login(); | 1238 | login(); |
1234 | if (!m_imap) { | 1239 | if (!m_imap) { |
1235 | return; | 1240 | return; |
1236 | } | 1241 | } |
1237 | att_list = mailimap_status_att_list_new_empty(); | 1242 | att_list = mailimap_status_att_list_new_empty(); |
1238 | if (!att_list) return; | 1243 | if (!att_list) return; |
1239 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 1244 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
1240 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 1245 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
1241 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 1246 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
1242 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 1247 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
1243 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { | 1248 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
1244 | for (cur = clist_begin(status->st_info_list); | 1249 | for (cur = clist_begin(status->st_info_list); |
1245 | cur != NULL ; cur = clist_next(cur)) { | 1250 | cur != NULL ; cur = clist_next(cur)) { |
1246 | mailimap_status_info * status_info; | 1251 | mailimap_status_info * status_info; |
1247 | status_info = (mailimap_status_info *)clist_content(cur); | 1252 | status_info = (mailimap_status_info *)clist_content(cur); |
1248 | switch (status_info->st_att) { | 1253 | switch (status_info->st_att) { |
1249 | case MAILIMAP_STATUS_ATT_MESSAGES: | 1254 | case MAILIMAP_STATUS_ATT_MESSAGES: |
1250 | target_stat.message_count = status_info->st_value; | 1255 | target_stat.message_count = status_info->st_value; |
1251 | break; | 1256 | break; |
1252 | case MAILIMAP_STATUS_ATT_RECENT: | 1257 | case MAILIMAP_STATUS_ATT_RECENT: |
1253 | target_stat.message_recent = status_info->st_value; | 1258 | target_stat.message_recent = status_info->st_value; |
1254 | break; | 1259 | break; |
1255 | case MAILIMAP_STATUS_ATT_UNSEEN: | 1260 | case MAILIMAP_STATUS_ATT_UNSEEN: |
1256 | target_stat.message_unseen = status_info->st_value; | 1261 | target_stat.message_unseen = status_info->st_value; |
1257 | break; | 1262 | break; |
1258 | } | 1263 | } |
1259 | } | 1264 | } |
1260 | } else { | 1265 | } else { |
1261 | // odebug << "Error retrieving status" << oendl; | 1266 | // odebug << "Error retrieving status" << oendl; |
1262 | } | 1267 | } |
1263 | if (status) mailimap_mailbox_data_status_free(status); | 1268 | if (status) mailimap_mailbox_data_status_free(status); |
1264 | if (att_list) mailimap_status_att_list_free(att_list); | 1269 | if (att_list) mailimap_status_att_list_free(att_list); |
1265 | } | 1270 | } |
1266 | 1271 | ||
1267 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 1272 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
1268 | { | 1273 | { |
1269 | login(); | 1274 | login(); |
1270 | if (!m_imap) return; | 1275 | if (!m_imap) return; |
1271 | if (!msg) return; | 1276 | if (!msg) return; |
1272 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 1277 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1273 | if (r != MAILIMAP_NO_ERROR) { | 1278 | if (r != MAILIMAP_NO_ERROR) { |
1274 | Global::statusMessage("Error storing mail!"); | 1279 | Global::statusMessage("Error storing mail!"); |
1275 | } | 1280 | } |
1276 | } | 1281 | } |
1277 | 1282 | ||
1278 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1283 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1279 | { | 1284 | { |
1280 | return account->getType(); | 1285 | return account->getType(); |
1281 | } | 1286 | } |
1282 | 1287 | ||
1283 | const QString&IMAPwrapper::getName()const | 1288 | const QString&IMAPwrapper::getName()const |
1284 | { | 1289 | { |
1285 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; | 1290 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; |
1286 | return account->getAccountName(); | 1291 | return account->getAccountName(); |
1287 | } | 1292 | } |
1288 | 1293 | ||
1289 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | 1294 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1290 | { | 1295 | { |
1291 | // dummy | 1296 | // dummy |
1292 | QValueList<int> path; | 1297 | QValueList<int> path; |
1293 | return fetchRawPart(mail,path,false); | 1298 | return fetchRawPart(mail,path,false); |
1294 | } | 1299 | } |
1295 | 1300 | ||
1296 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1301 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1297 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 1302 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
1298 | { | 1303 | { |
1299 | if (targetWrapper != this || maxSizeInKb > 0 ) { | 1304 | if (targetWrapper != this || maxSizeInKb > 0 ) { |
1300 | mMax = 0; | 1305 | mMax = 0; |
1301 | progress( i18n("Copy")); | 1306 | progress( i18n("Copy")); |
1302 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); | 1307 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); |
1303 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); | 1308 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); |
1304 | // odebug << "Using generic" << oendl; | 1309 | // odebug << "Using generic" << oendl; |
1305 | return; | 1310 | return; |
1306 | } | 1311 | } |
1307 | mailimap_set *set = 0; | 1312 | mailimap_set *set = 0; |
1308 | login(); | 1313 | login(); |
1309 | if (!m_imap) { | 1314 | if (!m_imap) { |
1310 | return; | 1315 | return; |
1311 | } | 1316 | } |
1312 | int err = selectMbox(fromFolder->getName()); | 1317 | int err = selectMbox(fromFolder->getName()); |
1313 | if ( err != MAILIMAP_NO_ERROR ) { | 1318 | if ( err != MAILIMAP_NO_ERROR ) { |
1314 | return; | 1319 | return; |
1315 | } | 1320 | } |
1316 | Global::statusMessage( i18n("Copying mails on server...") ); | 1321 | Global::statusMessage( i18n("Copying mails on server...") ); |
1317 | int last = m_imap->imap_selection_info->sel_exists; | 1322 | int last = m_imap->imap_selection_info->sel_exists; |
1318 | set = mailimap_set_new_interval( 1, last ); | 1323 | set = mailimap_set_new_interval( 1, last ); |
1319 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1324 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1320 | mailimap_set_free( set ); | 1325 | mailimap_set_free( set ); |
1321 | if ( err != MAILIMAP_NO_ERROR ) { | 1326 | if ( err != MAILIMAP_NO_ERROR ) { |
1322 | QString error_msg = i18n("Error copy mails: %1").arg(m_imap->imap_response); | 1327 | QString error_msg = i18n("Error copy mails: %1").arg(m_imap->imap_response); |
1323 | Global::statusMessage(error_msg); | 1328 | Global::statusMessage(error_msg); |
1324 | // odebug << error_msg << oendl; | 1329 | // odebug << error_msg << oendl; |
1325 | return; | 1330 | return; |
1326 | } | 1331 | } |
1327 | if (moveit) { | 1332 | if (moveit) { |
1328 | deleteAllMail(fromFolder); | 1333 | deleteAllMail(fromFolder); |
1329 | } | 1334 | } |
1330 | } | 1335 | } |
1331 | 1336 | ||
1332 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1337 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1333 | { | 1338 | { |
1334 | if (targetWrapper != this) { | 1339 | if (targetWrapper != this) { |
1335 | // odebug << "Using generic" << oendl; | 1340 | // odebug << "Using generic" << oendl; |
1336 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1341 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1337 | return; | 1342 | return; |
1338 | } | 1343 | } |
1339 | mailimap_set *set = 0; | 1344 | mailimap_set *set = 0; |
1340 | login(); | 1345 | login(); |
1341 | if (!m_imap) { | 1346 | if (!m_imap) { |
1342 | return; | 1347 | return; |
1343 | } | 1348 | } |
1344 | int err = selectMbox(mail->getMbox()); | 1349 | int err = selectMbox(mail->getMbox()); |
1345 | if ( err != MAILIMAP_NO_ERROR ) { | 1350 | if ( err != MAILIMAP_NO_ERROR ) { |
1346 | return; | 1351 | return; |
1347 | } | 1352 | } |
1348 | set = mailimap_set_new_single(mail->getNumber()); | 1353 | set = mailimap_set_new_single(mail->getNumber()); |
1349 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1354 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1350 | mailimap_set_free( set ); | 1355 | mailimap_set_free( set ); |
1351 | if ( err != MAILIMAP_NO_ERROR ) { | 1356 | if ( err != MAILIMAP_NO_ERROR ) { |
1352 | QString error_msg = i18n("error copy mail: %1").arg(m_imap->imap_response); | 1357 | QString error_msg = i18n("error copy mail: %1").arg(m_imap->imap_response); |
1353 | Global::statusMessage(error_msg); | 1358 | Global::statusMessage(error_msg); |
1354 | // odebug << error_msg << oendl; | 1359 | // odebug << error_msg << oendl; |
1355 | return; | 1360 | return; |
1356 | } | 1361 | } |
1357 | if (moveit) { | 1362 | if (moveit) { |
1358 | deleteMail(mail); | 1363 | deleteMail(mail); |
1359 | } | 1364 | } |
1360 | } | 1365 | } |
diff --git a/kmicromail/viewmailbase.cpp b/kmicromail/viewmailbase.cpp index c4731a7..d21696a 100644 --- a/kmicromail/viewmailbase.cpp +++ b/kmicromail/viewmailbase.cpp | |||
@@ -1,104 +1,104 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | #include <qtextbrowser.h> | 2 | #include <qtextbrowser.h> |
3 | #include <qlistview.h> | 3 | #include <qlistview.h> |
4 | #include <qaction.h> | 4 | #include <qaction.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qvbox.h> | 6 | #include <qvbox.h> |
7 | 7 | ||
8 | #include <qtoolbar.h> | 8 | #include <qtoolbar.h> |
9 | #include <qmenubar.h> | 9 | #include <qmenubar.h> |
10 | #include <kiconloader.h> | 10 | #include <kiconloader.h> |
11 | //#include <qpe/resource.h> | 11 | //#include <qpe/resource.h> |
12 | #include <klocale.h> | 12 | #include <klocale.h> |
13 | 13 | ||
14 | #include "viewmailbase.h" | 14 | #include "viewmailbase.h" |
15 | //#include "opendiag.h" | 15 | //#include "opendiag.h" |
16 | 16 | ||
17 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) | 17 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) |
18 | : QMainWindow(parent, name, fl) | 18 | : QMainWindow(parent, name, fl) |
19 | { | 19 | { |
20 | 20 | ||
21 | setToolBarsMovable(false); | 21 | setToolBarsMovable(false); |
22 | 22 | ||
23 | toolbar = new QToolBar(this); | 23 | toolbar = new QToolBar(this); |
24 | menubar = new QMenuBar( toolbar ); | 24 | menubar = new QMenuBar( toolbar ); |
25 | mailmenu = new QPopupMenu( menubar ); | 25 | mailmenu = new QPopupMenu( menubar ); |
26 | menubar->insertItem( i18n( "Mail" ), mailmenu ); | 26 | menubar->insertItem( i18n( "Mail" ), mailmenu ); |
27 | 27 | ||
28 | toolbar->setHorizontalStretchable(true); | 28 | toolbar->setHorizontalStretchable(true); |
29 | addToolBar(toolbar); | 29 | addToolBar(toolbar); |
30 | 30 | ||
31 | reply = new QAction(i18n("Reply"),SmallIcon("reply"), 0, 0, this); | 31 | reply = new QAction(i18n("Reply"),SmallIcon("reply"), 0, 0, this); |
32 | reply->addTo(toolbar); | 32 | reply->addTo(toolbar); |
33 | reply->addTo(mailmenu); | 33 | reply->addTo(mailmenu); |
34 | 34 | ||
35 | forward = new QAction(i18n("Forward"),SmallIcon("forward"), 0, 0, this); | 35 | forward = new QAction(i18n("Forward"),SmallIcon("forward"), 0, 0, this); |
36 | forward->addTo(toolbar); | 36 | forward->addTo(toolbar); |
37 | forward->addTo(mailmenu); | 37 | forward->addTo(mailmenu); |
38 | 38 | ||
39 | attachbutton = new QAction(i18n("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true); | 39 | attachbutton = new QAction(i18n("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true); |
40 | attachbutton->addTo(toolbar); | 40 | attachbutton->addTo(toolbar); |
41 | attachbutton->addTo(mailmenu); | 41 | attachbutton->addTo(mailmenu); |
42 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); | 42 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); |
43 | 43 | ||
44 | 44 | ||
45 | showHtml = new QAction( i18n( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true ); | 45 | showHtml = new QAction( i18n( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true ); |
46 | showHtml->addTo( toolbar ); | 46 | showHtml->addTo( toolbar ); |
47 | showHtml->addTo( mailmenu ); | 47 | showHtml->addTo( mailmenu ); |
48 | 48 | ||
49 | deleteMail = new QAction(i18n("Delete Mail"),SmallIcon("trash"), 0, 0, this); | 49 | deleteMail = new QAction(i18n("Delete Mail"),SmallIcon("trash"), 0, 0, this); |
50 | deleteMail->addTo(toolbar); | 50 | deleteMail->addTo(toolbar); |
51 | deleteMail->addTo(mailmenu); | 51 | deleteMail->addTo(mailmenu); |
52 | 52 | ||
53 | 53 | ||
54 | 54 | ||
55 | nextMail = new QAction(i18n("Show next mail"),SmallIcon("add"), 0, 0, this); | 55 | nextMail = new QAction(i18n("Show next mail"),SmallIcon("enter"), 0, 0, this); |
56 | QLabel *spacer = new QLabel(toolbar); | 56 | QLabel *spacer = new QLabel(toolbar); |
57 | nextMail->addTo(toolbar); | 57 | nextMail->addTo(toolbar); |
58 | nextMail->addTo(mailmenu); | 58 | nextMail->addTo(mailmenu); |
59 | 59 | ||
60 | 60 | ||
61 | 61 | ||
62 | 62 | ||
63 | closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); | 63 | closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); |
64 | //QLabel *spacer = new QLabel(toolbar); | 64 | //QLabel *spacer = new QLabel(toolbar); |
65 | spacer->setBackgroundMode(QWidget::PaletteButton); | 65 | spacer->setBackgroundMode(QWidget::PaletteButton); |
66 | toolbar->setStretchableWidget(spacer); | 66 | toolbar->setStretchableWidget(spacer); |
67 | closeMail->addTo(toolbar); | 67 | closeMail->addTo(toolbar); |
68 | closeMail->addTo(mailmenu); | 68 | closeMail->addTo(mailmenu); |
69 | QVBox *view = new QVBox(this); | 69 | QVBox *view = new QVBox(this); |
70 | setCentralWidget(view); | 70 | setCentralWidget(view); |
71 | 71 | ||
72 | attachments = new QListView(view); | 72 | attachments = new QListView(view); |
73 | attachments->setMinimumHeight(90); | 73 | attachments->setMinimumHeight(90); |
74 | attachments->setMaximumHeight(90); | 74 | attachments->setMaximumHeight(90); |
75 | attachments->setAllColumnsShowFocus(true); | 75 | attachments->setAllColumnsShowFocus(true); |
76 | attachments->addColumn("Mime Type", 60); | 76 | attachments->addColumn("Mime Type", 60); |
77 | attachments->addColumn(i18n("Description"), 100); | 77 | attachments->addColumn(i18n("Description"), 100); |
78 | attachments->addColumn(i18n("Filename"), 80); | 78 | attachments->addColumn(i18n("Filename"), 80); |
79 | attachments->addColumn(i18n("Size"), 80); | 79 | attachments->addColumn(i18n("Size"), 80); |
80 | attachments->setSorting(-1); | 80 | attachments->setSorting(-1); |
81 | attachments->hide(); | 81 | attachments->hide(); |
82 | 82 | ||
83 | browser = new QTextBrowser(view); | 83 | browser = new QTextBrowser(view); |
84 | 84 | ||
85 | //openDiag = new OpenDiag(view); | 85 | //openDiag = new OpenDiag(view); |
86 | //openDiag->hide(); | 86 | //openDiag->hide(); |
87 | 87 | ||
88 | } | 88 | } |
89 | 89 | ||
90 | void ViewMailBase::slotChangeAttachview(bool state) | 90 | void ViewMailBase::slotChangeAttachview(bool state) |
91 | { | 91 | { |
92 | if (state) attachments->show(); | 92 | if (state) attachments->show(); |
93 | else attachments->hide(); | 93 | else attachments->hide(); |
94 | } | 94 | } |
95 | 95 | ||
96 | void ViewMailBase::keyPressEvent ( QKeyEvent * e ) | 96 | void ViewMailBase::keyPressEvent ( QKeyEvent * e ) |
97 | { | 97 | { |
98 | if( e->key()==Qt::Key_Escape ) { | 98 | if( e->key()==Qt::Key_Escape ) { |
99 | close(); | 99 | close(); |
100 | e->accept(); | 100 | e->accept(); |
101 | return; | 101 | return; |
102 | } | 102 | } |
103 | QWidget::keyPressEvent(e); | 103 | QWidget::keyPressEvent(e); |
104 | } | 104 | } |