author | zautrix <zautrix> | 2004-10-18 10:57:05 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-18 10:57:05 (UTC) |
commit | a83b6694d2f80ec58f6eb88684897052c69276a0 (patch) (unidiff) | |
tree | 4b20f33e874f035f54021638125ed293e4202613 | |
parent | 112db6c41265da5255a58424186d95d7a00b6ff0 (diff) | |
download | kdepimpi-a83b6694d2f80ec58f6eb88684897052c69276a0.zip kdepimpi-a83b6694d2f80ec58f6eb88684897052c69276a0.tar.gz kdepimpi-a83b6694d2f80ec58f6eb88684897052c69276a0.tar.bz2 |
some mail imap changes
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 127 |
1 files changed, 72 insertions, 55 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index b0dd1b8..a6688ed 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -16,104 +16,105 @@ 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 | //qDebug("imap progress %d of %d ",current,maximum ); | 50 | //qDebug("imap progress %d of %d ",current,maximum ); |
51 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); | 51 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); |
52 | //qApp->processEvents() | 52 | //qApp->processEvents() |
53 | static int last = 0; | 53 | static int last = 0; |
54 | if ( last != current ) | 54 | if ( last != current ) |
55 | IMAPwrapper::progress(); | 55 | IMAPwrapper::progress(); |
56 | last = current; | 56 | last = current; |
57 | } | 57 | } |
58 | void IMAPwrapper::progress( QString m ) | 58 | void IMAPwrapper::progress( QString m ) |
59 | { | 59 | { |
60 | 60 | ||
61 | static QString mProgrMess; | 61 | static QString mProgrMess; |
62 | if ( m != QString::null ) { | 62 | if ( m != QString::null ) { |
63 | mProgrMess = m; | 63 | mProgrMess = m; |
64 | mCurrent = 0; | 64 | mCurrent = 1; |
65 | return; | 65 | return; |
66 | } | 66 | } |
67 | QString mess; | 67 | QString mess; |
68 | //qDebug("progress "); | 68 | //qDebug("progress "); |
69 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); | 69 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); |
70 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); | 70 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); |
71 | Global::statusMessage(mess); | 71 | Global::statusMessage(mess); |
72 | qDebug("Progress %s %s", mess.latin1(), m.latin1()); | ||
72 | qApp->processEvents(); | 73 | qApp->processEvents(); |
73 | } | 74 | } |
74 | bool IMAPwrapper::start_tls(bool force_tls) | 75 | bool IMAPwrapper::start_tls(bool force_tls) |
75 | { | 76 | { |
76 | int err; | 77 | int err; |
77 | bool try_tls; | 78 | bool try_tls; |
78 | mailimap_capability_data * cap_data = 0; | 79 | mailimap_capability_data * cap_data = 0; |
79 | 80 | ||
80 | err = mailimap_capability(m_imap,&cap_data); | 81 | err = mailimap_capability(m_imap,&cap_data); |
81 | if (err != MAILIMAP_NO_ERROR) { | 82 | if (err != MAILIMAP_NO_ERROR) { |
82 | Global::statusMessage("error getting capabilities!"); | 83 | Global::statusMessage("error getting capabilities!"); |
83 | return false; | 84 | return false; |
84 | } | 85 | } |
85 | clistiter * cur; | 86 | clistiter * cur; |
86 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 87 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
87 | struct mailimap_capability * cap; | 88 | struct mailimap_capability * cap; |
88 | cap = (struct mailimap_capability *)clist_content(cur); | 89 | cap = (struct mailimap_capability *)clist_content(cur); |
89 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 90 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
90 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 91 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
91 | try_tls = true; | 92 | try_tls = true; |
92 | break; | 93 | break; |
93 | } | 94 | } |
94 | } | 95 | } |
95 | } | 96 | } |
96 | if (cap_data) { | 97 | if (cap_data) { |
97 | mailimap_capability_data_free(cap_data); | 98 | mailimap_capability_data_free(cap_data); |
98 | } | 99 | } |
99 | if (try_tls) { | 100 | if (try_tls) { |
100 | err = mailimap_starttls(m_imap); | 101 | err = mailimap_starttls(m_imap); |
101 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 102 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
102 | Global::statusMessage(tr("Server has no TLS support!")); | 103 | Global::statusMessage(tr("Server has no TLS support!")); |
103 | try_tls = false; | 104 | try_tls = false; |
104 | } else { | 105 | } else { |
105 | mailstream_low * low; | 106 | mailstream_low * low; |
106 | mailstream_low * new_low; | 107 | mailstream_low * new_low; |
107 | low = mailstream_get_low(m_imap->imap_stream); | 108 | low = mailstream_get_low(m_imap->imap_stream); |
108 | if (!low) { | 109 | if (!low) { |
109 | try_tls = false; | 110 | try_tls = false; |
110 | } else { | 111 | } else { |
111 | int fd = mailstream_low_get_fd(low); | 112 | int fd = mailstream_low_get_fd(low); |
112 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 113 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
113 | mailstream_low_free(low); | 114 | mailstream_low_free(low); |
114 | mailstream_set_low(m_imap->imap_stream, new_low); | 115 | mailstream_set_low(m_imap->imap_stream, new_low); |
115 | } else { | 116 | } else { |
116 | try_tls = false; | 117 | try_tls = false; |
117 | } | 118 | } |
118 | } | 119 | } |
119 | } | 120 | } |
@@ -188,157 +189,173 @@ void IMAPwrapper::login() | |||
188 | failure="Unknown failure"; | 189 | failure="Unknown failure"; |
189 | } | 190 | } |
190 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); | 191 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); |
191 | mailimap_free( m_imap ); | 192 | mailimap_free( m_imap ); |
192 | m_imap = 0; | 193 | m_imap = 0; |
193 | return; | 194 | return; |
194 | } | 195 | } |
195 | 196 | ||
196 | if (!ssl) { | 197 | if (!ssl) { |
197 | try_tls = start_tls(force_tls); | 198 | try_tls = start_tls(force_tls); |
198 | } | 199 | } |
199 | 200 | ||
200 | bool ok = true; | 201 | bool ok = true; |
201 | if (force_tls && !try_tls) { | 202 | if (force_tls && !try_tls) { |
202 | Global::statusMessage(tr("Server has no TLS support!")); | 203 | Global::statusMessage(tr("Server has no TLS support!")); |
203 | ok = false; | 204 | ok = false; |
204 | } | 205 | } |
205 | 206 | ||
206 | 207 | ||
207 | /* login */ | 208 | /* login */ |
208 | 209 | ||
209 | if (ok) { | 210 | if (ok) { |
210 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); | 211 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); |
211 | if ( err != MAILIMAP_NO_ERROR ) { | 212 | if ( err != MAILIMAP_NO_ERROR ) { |
212 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); | 213 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); |
213 | ok = false; | 214 | ok = false; |
214 | } | 215 | } |
215 | } | 216 | } |
216 | if (!ok) { | 217 | if (!ok) { |
217 | err = mailimap_close( m_imap ); | 218 | err = mailimap_close( m_imap ); |
218 | mailimap_free( m_imap ); | 219 | mailimap_free( m_imap ); |
219 | m_imap = 0; | 220 | m_imap = 0; |
220 | } | 221 | } |
221 | } | 222 | } |
222 | 223 | ||
223 | void IMAPwrapper::logout() | 224 | void IMAPwrapper::logout() |
224 | { | 225 | { |
225 | int err = MAILIMAP_NO_ERROR; | 226 | int err = MAILIMAP_NO_ERROR; |
226 | if (!m_imap) return; | 227 | if (!m_imap) return; |
227 | err = mailimap_logout( m_imap ); | 228 | err = mailimap_logout( m_imap ); |
228 | err = mailimap_close( m_imap ); | 229 | err = mailimap_close( m_imap ); |
229 | mailimap_free( m_imap ); | 230 | mailimap_free( m_imap ); |
230 | m_imap = 0; | 231 | m_imap = 0; |
231 | m_Lastmbox = ""; | 232 | m_Lastmbox = ""; |
232 | } | 233 | } |
233 | 234 | ||
234 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) | 235 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) |
235 | { | 236 | { |
236 | int err = MAILIMAP_NO_ERROR; | ||
237 | clist *result = 0; | ||
238 | clistcell *current; | ||
239 | mailimap_fetch_type *fetchType = 0; | ||
240 | mailimap_set *set = 0; | ||
241 | |||
242 | login(); | ||
243 | if (!m_imap) { | ||
244 | return; | ||
245 | } | ||
246 | /* select mailbox READONLY for operations */ | ||
247 | err = selectMbox(mailbox); | ||
248 | if ( err != MAILIMAP_NO_ERROR ) { | ||
249 | return; | ||
250 | } | ||
251 | 237 | ||
252 | int last = m_imap->imap_selection_info->sel_exists; | 238 | int tryAgain = 1; |
239 | while ( tryAgain >= 0 ) { | ||
240 | int err = MAILIMAP_NO_ERROR; | ||
241 | clist *result = 0; | ||
242 | clistcell *current; | ||
243 | mailimap_fetch_type *fetchType = 0; | ||
244 | mailimap_set *set = 0; | ||
253 | 245 | ||
254 | if (last == 0) { | 246 | login(); |
255 | Global::statusMessage(tr("Mailbox has no mails")); | 247 | if (!m_imap) { |
256 | return; | 248 | return; |
257 | } else { | 249 | } |
258 | } | 250 | /* select mailbox READONLY for operations */ |
259 | 251 | err = selectMbox(mailbox); | |
260 | Global::statusMessage(tr("Fetching header list")); | 252 | if ( err != MAILIMAP_NO_ERROR ) { |
261 | qApp->processEvents(); | 253 | return; |
262 | /* the range has to start at 1!!! not with 0!!!! */ | 254 | } |
263 | set = mailimap_set_new_interval( 1, last ); | ||
264 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | ||
265 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | ||
266 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | ||
267 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | ||
268 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | ||
269 | |||
270 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | ||
271 | mailimap_set_free( set ); | ||
272 | mailimap_fetch_type_free( fetchType ); | ||
273 | 255 | ||
274 | QString date,subject,from; | 256 | int last = m_imap->imap_selection_info->sel_exists; |
275 | 257 | ||
276 | if ( err == MAILIMAP_NO_ERROR ) { | 258 | if (last == 0) { |
277 | mailimap_msg_att * msg_att; | 259 | Global::statusMessage(tr("Mailbox has no mails")); |
278 | int i = 0; | 260 | return; |
279 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 261 | } else { |
280 | ++i; | 262 | } |
281 | msg_att = (mailimap_msg_att*)current->data; | 263 | progress( tr("Fetch ")); |
282 | RecMail*m = parse_list_result(msg_att); | 264 | mMax = last; |
283 | if (m) { | 265 | //qDebug("last %d ", last); |
284 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { | 266 | Global::statusMessage(tr("Fetching header list")); |
285 | m->setNumber(i); | 267 | qApp->processEvents(); |
286 | m->setMbox(mailbox); | 268 | /* the range has to start at 1!!! not with 0!!!! */ |
287 | m->setWrapper(this); | 269 | //LR the access to web.de imap server is no working with value 1 |
288 | target.append(m); | 270 | qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); |
271 | set = mailimap_set_new_interval( tryAgain, last ); | ||
272 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | ||
273 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | ||
274 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | ||
275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | ||
276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | ||
277 | |||
278 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | ||
279 | mailimap_set_free( set ); | ||
280 | mailimap_fetch_type_free( fetchType ); | ||
281 | |||
282 | QString date,subject,from; | ||
283 | |||
284 | if ( err == MAILIMAP_NO_ERROR ) { | ||
285 | tryAgain = -1; | ||
286 | mailimap_msg_att * msg_att; | ||
287 | int i = 0; | ||
288 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | ||
289 | ++i; | ||
290 | //qDebug("iii %d ",i); | ||
291 | msg_att = (mailimap_msg_att*)current->data; | ||
292 | RecMail*m = parse_list_result(msg_att); | ||
293 | if (m) { | ||
294 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { | ||
295 | m->setNumber(i); | ||
296 | m->setMbox(mailbox); | ||
297 | m->setWrapper(this); | ||
298 | target.append(m); | ||
299 | } | ||
289 | } | 300 | } |
290 | } | 301 | } |
302 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | ||
303 | } else { | ||
304 | --tryAgain; | ||
305 | --tryAgain; | ||
306 | if ( tryAgain < 0 ) | ||
307 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | ||
308 | else | ||
309 | qDebug("try again... "); | ||
291 | } | 310 | } |
292 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | 311 | |
293 | } else { | 312 | if (result) mailimap_fetch_list_free(result); |
294 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | ||
295 | } | 313 | } |
296 | if (result) mailimap_fetch_list_free(result); | ||
297 | } | 314 | } |
298 | 315 | ||
299 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 316 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
300 | { | 317 | { |
301 | const char *path, *mask; | 318 | const char *path, *mask; |
302 | int err = MAILIMAP_NO_ERROR; | 319 | int err = MAILIMAP_NO_ERROR; |
303 | clist *result = 0; | 320 | clist *result = 0; |
304 | clistcell *current = 0; | 321 | clistcell *current = 0; |
305 | clistcell*cur_flag = 0; | 322 | clistcell*cur_flag = 0; |
306 | mailimap_mbx_list_flags*bflags = 0; | 323 | mailimap_mbx_list_flags*bflags = 0; |
307 | 324 | ||
308 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 325 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
309 | login(); | 326 | login(); |
310 | if (!m_imap) { | 327 | if (!m_imap) { |
311 | return folders; | 328 | return folders; |
312 | } | 329 | } |
313 | 330 | ||
314 | /* | 331 | /* |
315 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 332 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
316 | * We must not forget to filter them out in next loop! | 333 | * We must not forget to filter them out in next loop! |
317 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 334 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
318 | */ | 335 | */ |
319 | Global::statusMessage(tr("Fetching folder list")); | 336 | Global::statusMessage(tr("Fetching folder list")); |
320 | qApp->processEvents(); | 337 | qApp->processEvents(); |
321 | QString temp; | 338 | QString temp; |
322 | mask = "INBOX" ; | 339 | mask = "INBOX" ; |
323 | mailimap_mailbox_list *list; | 340 | mailimap_mailbox_list *list; |
324 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 341 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
325 | QString del; | 342 | QString del; |
326 | bool selectable = true; | 343 | bool selectable = true; |
327 | bool no_inferiors = false; | 344 | bool no_inferiors = false; |
328 | if ( err == MAILIMAP_NO_ERROR ) { | 345 | if ( err == MAILIMAP_NO_ERROR ) { |
329 | current = result->first; | 346 | current = result->first; |
330 | for ( int i = result->count; i > 0; i-- ) { | 347 | for ( int i = result->count; i > 0; i-- ) { |
331 | list = (mailimap_mailbox_list *) current->data; | 348 | list = (mailimap_mailbox_list *) current->data; |
332 | // it is better use the deep copy mechanism of qt itself | 349 | // it is better use the deep copy mechanism of qt itself |
333 | // instead of using strdup! | 350 | // instead of using strdup! |
334 | temp = list->mb_name; | 351 | temp = list->mb_name; |
335 | del = list->mb_delimiter; | 352 | del = list->mb_delimiter; |
336 | current = current->next; | 353 | current = current->next; |
337 | if ( (bflags = list->mb_flag) ) { | 354 | if ( (bflags = list->mb_flag) ) { |
338 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 355 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
339 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 356 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
340 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 357 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
341 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 358 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
342 | no_inferiors = true; | 359 | no_inferiors = true; |
343 | } | 360 | } |
344 | } | 361 | } |
@@ -907,97 +924,97 @@ void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which | |||
907 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 924 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
908 | encoding = "7bit"; | 925 | encoding = "7bit"; |
909 | break; | 926 | break; |
910 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 927 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
911 | encoding = "8bit"; | 928 | encoding = "8bit"; |
912 | break; | 929 | break; |
913 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 930 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
914 | encoding="binary"; | 931 | encoding="binary"; |
915 | break; | 932 | break; |
916 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 933 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
917 | encoding="base64"; | 934 | encoding="base64"; |
918 | break; | 935 | break; |
919 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 936 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
920 | encoding="quoted-printable"; | 937 | encoding="quoted-printable"; |
921 | break; | 938 | break; |
922 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 939 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
923 | default: | 940 | default: |
924 | if (enc->enc_value) { | 941 | if (enc->enc_value) { |
925 | char*t=enc->enc_value; | 942 | char*t=enc->enc_value; |
926 | encoding=QString(enc->enc_value); | 943 | encoding=QString(enc->enc_value); |
927 | enc->enc_value=0L; | 944 | enc->enc_value=0L; |
928 | free(t); | 945 | free(t); |
929 | } | 946 | } |
930 | } | 947 | } |
931 | if (which->bd_description) { | 948 | if (which->bd_description) { |
932 | target_part->setDescription(QString(which->bd_description)); | 949 | target_part->setDescription(QString(which->bd_description)); |
933 | } | 950 | } |
934 | target_part->setEncoding(encoding); | 951 | target_part->setEncoding(encoding); |
935 | target_part->setSize(which->bd_size); | 952 | target_part->setSize(which->bd_size); |
936 | } | 953 | } |
937 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | 954 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) |
938 | { | 955 | { |
939 | //#if 0 | 956 | //#if 0 |
940 | mailimap_flag_list*flist; | 957 | mailimap_flag_list*flist; |
941 | mailimap_set *set; | 958 | mailimap_set *set; |
942 | mailimap_store_att_flags * store_flags; | 959 | mailimap_store_att_flags * store_flags; |
943 | int err; | 960 | int err; |
944 | login(); | 961 | login(); |
945 | //#endif | 962 | //#endif |
946 | if (!m_imap) { | 963 | if (!m_imap) { |
947 | return; | 964 | return; |
948 | } | 965 | } |
949 | int iii = 0; | 966 | int iii = 0; |
950 | int count = target.count(); | 967 | int count = target.count(); |
951 | // qDebug("imap remove count %d ", count); | 968 | // qDebug("imap remove count %d ", count); |
952 | 969 | ||
953 | 970 | ||
954 | mMax = count; | 971 | mMax = count; |
955 | //progress( tr("Delete")); | 972 | progress( tr("Delete")); |
956 | 973 | ||
957 | QProgressBar wid ( count ); | 974 | QProgressBar wid ( count ); |
958 | wid.setCaption( tr("Deleting ...")); | 975 | wid.setCaption( tr("Deleting ...")); |
959 | wid.show(); | 976 | wid.show(); |
960 | while (iii < count ) { | 977 | while (iii < count ) { |
961 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 978 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |
962 | wid.setProgress( iii ); | 979 | wid.setProgress( iii ); |
963 | wid.raise(); | 980 | wid.raise(); |
964 | qApp->processEvents(); | 981 | qApp->processEvents(); |
965 | RecMailP mail = (*target.at( iii )); | 982 | RecMailP mail = (*target.at( iii )); |
966 | //#if 0 | 983 | //#if 0 |
967 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); | 984 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); |
968 | err = selectMbox(mail->getMbox()); | 985 | err = selectMbox(mail->getMbox()); |
969 | if ( err != MAILIMAP_NO_ERROR ) { | 986 | if ( err != MAILIMAP_NO_ERROR ) { |
970 | return; | 987 | return; |
971 | } | 988 | } |
972 | flist = mailimap_flag_list_new_empty(); | 989 | flist = mailimap_flag_list_new_empty(); |
973 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 990 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
974 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 991 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
975 | set = mailimap_set_new_single(mail->getNumber()); | 992 | set = mailimap_set_new_single(mail->getNumber()); |
976 | err = mailimap_store(m_imap,set,store_flags); | 993 | err = mailimap_store(m_imap,set,store_flags); |
977 | mailimap_set_free( set ); | 994 | mailimap_set_free( set ); |
978 | mailimap_store_att_flags_free(store_flags); | 995 | mailimap_store_att_flags_free(store_flags); |
979 | 996 | ||
980 | if (err != MAILIMAP_NO_ERROR) { | 997 | if (err != MAILIMAP_NO_ERROR) { |
981 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 998 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
982 | return; | 999 | return; |
983 | } | 1000 | } |
984 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1001 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
985 | /* should we realy do that at this moment? */ | 1002 | /* should we realy do that at this moment? */ |
986 | 1003 | ||
987 | // err = mailimap_expunge(m_imap); | 1004 | // err = mailimap_expunge(m_imap); |
988 | //if (err != MAILIMAP_NO_ERROR) { | 1005 | //if (err != MAILIMAP_NO_ERROR) { |
989 | // Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); | 1006 | // Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); |
990 | // } | 1007 | // } |
991 | //#endif | 1008 | //#endif |
992 | //deleteMail( mail); | 1009 | //deleteMail( mail); |
993 | ++iii; | 1010 | ++iii; |
994 | } | 1011 | } |
995 | //qDebug("Deleting imap mails... "); | 1012 | //qDebug("Deleting imap mails... "); |
996 | err = mailimap_expunge(m_imap); | 1013 | err = mailimap_expunge(m_imap); |
997 | if (err != MAILIMAP_NO_ERROR) { | 1014 | if (err != MAILIMAP_NO_ERROR) { |
998 | Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); | 1015 | Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); |
999 | } | 1016 | } |
1000 | } | 1017 | } |
1001 | void IMAPwrapper::deleteMail(const RecMailP&mail) | 1018 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
1002 | { | 1019 | { |
1003 | mailimap_flag_list*flist; | 1020 | mailimap_flag_list*flist; |