Diffstat (limited to 'kmicromail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 6faa524..5441a9b 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,105 +1,106 @@ | |||
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 | 11 | ||
11 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
12 | int IMAPwrapper::mMax = 0; | 13 | int IMAPwrapper::mMax = 0; |
13 | int IMAPwrapper::mCurrent = 0; | 14 | int IMAPwrapper::mCurrent = 0; |
14 | 15 | ||
15 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 16 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
16 | : AbstractMail() | 17 | : AbstractMail() |
17 | { | 18 | { |
18 | account = a; | 19 | account = a; |
19 | m_imap = 0; | 20 | m_imap = 0; |
20 | m_Lastmbox = ""; | 21 | m_Lastmbox = ""; |
21 | mCurrent = 0; | 22 | mCurrent = 0; |
22 | mMax = 0; | 23 | mMax = 0; |
23 | } | 24 | } |
24 | 25 | ||
25 | IMAPwrapper::~IMAPwrapper() | 26 | IMAPwrapper::~IMAPwrapper() |
26 | { | 27 | { |
27 | logout(); | 28 | logout(); |
28 | } | 29 | } |
29 | 30 | ||
30 | /* to avoid to often select statements in loops etc. | 31 | /* to avoid to often select statements in loops etc. |
31 | we trust that we are logged in and connection is established!*/ | 32 | we trust that we are logged in and connection is established!*/ |
32 | int IMAPwrapper::selectMbox(const QString&mbox) | 33 | int IMAPwrapper::selectMbox(const QString&mbox) |
33 | { | 34 | { |
34 | if (mbox == m_Lastmbox) { | 35 | if (mbox == m_Lastmbox) { |
35 | return MAILIMAP_NO_ERROR; | 36 | return MAILIMAP_NO_ERROR; |
36 | } | 37 | } |
37 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 38 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
38 | if ( err != MAILIMAP_NO_ERROR ) { | 39 | if ( err != MAILIMAP_NO_ERROR ) { |
39 | m_Lastmbox = ""; | 40 | m_Lastmbox = ""; |
40 | return err; | 41 | return err; |
41 | } | 42 | } |
42 | m_Lastmbox = mbox; | 43 | m_Lastmbox = mbox; |
43 | return err; | 44 | return err; |
44 | } | 45 | } |
45 | 46 | ||
46 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 47 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
47 | { | 48 | { |
48 | //qDebug("imap progress %d of %d ",current,maximum ); | 49 | //qDebug("imap progress %d of %d ",current,maximum ); |
49 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); | 50 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); |
50 | //qApp->processEvents() | 51 | //qApp->processEvents() |
51 | static int last = 0; | 52 | static int last = 0; |
52 | if ( last != current ) | 53 | if ( last != current ) |
53 | IMAPwrapper::progress(); | 54 | IMAPwrapper::progress(); |
54 | last = current; | 55 | last = current; |
55 | } | 56 | } |
56 | void IMAPwrapper::progress( QString m ) | 57 | void IMAPwrapper::progress( QString m ) |
57 | { | 58 | { |
58 | 59 | ||
59 | static QString mProgrMess; | 60 | static QString mProgrMess; |
60 | if ( m != QString::null ) { | 61 | if ( m != QString::null ) { |
61 | mProgrMess = m; | 62 | mProgrMess = m; |
62 | mCurrent = 0; | 63 | mCurrent = 0; |
63 | return; | 64 | return; |
64 | } | 65 | } |
65 | QString mess; | 66 | QString mess; |
66 | //qDebug("progress "); | 67 | //qDebug("progress "); |
67 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); | 68 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); |
68 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); | 69 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); |
69 | Global::statusMessage(mess); | 70 | Global::statusMessage(mess); |
70 | qApp->processEvents(); | 71 | qApp->processEvents(); |
71 | } | 72 | } |
72 | bool IMAPwrapper::start_tls(bool force_tls) | 73 | bool IMAPwrapper::start_tls(bool force_tls) |
73 | { | 74 | { |
74 | int err; | 75 | int err; |
75 | bool try_tls; | 76 | bool try_tls; |
76 | mailimap_capability_data * cap_data = 0; | 77 | mailimap_capability_data * cap_data = 0; |
77 | 78 | ||
78 | err = mailimap_capability(m_imap,&cap_data); | 79 | err = mailimap_capability(m_imap,&cap_data); |
79 | if (err != MAILIMAP_NO_ERROR) { | 80 | if (err != MAILIMAP_NO_ERROR) { |
80 | Global::statusMessage("error getting capabilities!"); | 81 | Global::statusMessage("error getting capabilities!"); |
81 | return false; | 82 | return false; |
82 | } | 83 | } |
83 | clistiter * cur; | 84 | clistiter * cur; |
84 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 85 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
85 | struct mailimap_capability * cap; | 86 | struct mailimap_capability * cap; |
86 | cap = (struct mailimap_capability *)clist_content(cur); | 87 | cap = (struct mailimap_capability *)clist_content(cur); |
87 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 88 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
88 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 89 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
89 | try_tls = true; | 90 | try_tls = true; |
90 | break; | 91 | break; |
91 | } | 92 | } |
92 | } | 93 | } |
93 | } | 94 | } |
94 | if (cap_data) { | 95 | if (cap_data) { |
95 | mailimap_capability_data_free(cap_data); | 96 | mailimap_capability_data_free(cap_data); |
96 | } | 97 | } |
97 | if (try_tls) { | 98 | if (try_tls) { |
98 | err = mailimap_starttls(m_imap); | 99 | err = mailimap_starttls(m_imap); |
99 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 100 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
100 | Global::statusMessage(tr("Server has no TLS support!")); | 101 | Global::statusMessage(tr("Server has no TLS support!")); |
101 | try_tls = false; | 102 | try_tls = false; |
102 | } else { | 103 | } else { |
103 | mailstream_low * low; | 104 | mailstream_low * low; |
104 | mailstream_low * new_low; | 105 | mailstream_low * new_low; |
105 | low = mailstream_get_low(m_imap->imap_stream); | 106 | low = mailstream_get_low(m_imap->imap_stream); |
@@ -363,194 +364,209 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | |||
363 | list = (mailimap_mailbox_list *) current->data; | 364 | list = (mailimap_mailbox_list *) current->data; |
364 | // it is better use the deep copy mechanism of qt itself | 365 | // it is better use the deep copy mechanism of qt itself |
365 | // instead of using strdup! | 366 | // instead of using strdup! |
366 | temp = list->mb_name; | 367 | temp = list->mb_name; |
367 | if (temp.lower()=="inbox") | 368 | if (temp.lower()=="inbox") |
368 | continue; | 369 | continue; |
369 | if (temp.lower()==account->getPrefix().lower()) | 370 | if (temp.lower()==account->getPrefix().lower()) |
370 | continue; | 371 | continue; |
371 | if ( (bflags = list->mb_flag) ) { | 372 | if ( (bflags = list->mb_flag) ) { |
372 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 373 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
373 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 374 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
374 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 375 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
375 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 376 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
376 | no_inferiors = true; | 377 | no_inferiors = true; |
377 | } | 378 | } |
378 | } | 379 | } |
379 | } | 380 | } |
380 | del = list->mb_delimiter; | 381 | del = list->mb_delimiter; |
381 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 382 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
382 | } | 383 | } |
383 | } else { | 384 | } else { |
384 | qDebug("error fetching folders "); | 385 | qDebug("error fetching folders "); |
385 | 386 | ||
386 | } | 387 | } |
387 | if (result) mailimap_list_result_free( result ); | 388 | if (result) mailimap_list_result_free( result ); |
388 | return folders; | 389 | return folders; |
389 | } | 390 | } |
390 | 391 | ||
391 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 392 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
392 | { | 393 | { |
393 | RecMail * m = 0; | 394 | RecMail * m = 0; |
394 | mailimap_msg_att_item *item=0; | 395 | mailimap_msg_att_item *item=0; |
395 | clistcell *current,*c,*cf; | 396 | clistcell *current,*c,*cf; |
396 | mailimap_msg_att_dynamic*flist; | 397 | mailimap_msg_att_dynamic*flist; |
397 | mailimap_flag_fetch*cflag; | 398 | mailimap_flag_fetch*cflag; |
398 | int size; | 399 | int size; |
399 | QBitArray mFlags(7); | 400 | QBitArray mFlags(7); |
400 | QStringList addresslist; | 401 | QStringList addresslist; |
401 | 402 | ||
402 | if (!m_att) { | 403 | if (!m_att) { |
403 | return m; | 404 | return m; |
404 | } | 405 | } |
405 | m = new RecMail(); | 406 | m = new RecMail(); |
406 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 407 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
407 | current = c; | 408 | current = c; |
408 | size = 0; | 409 | size = 0; |
409 | item = (mailimap_msg_att_item*)current->data; | 410 | item = (mailimap_msg_att_item*)current->data; |
410 | if ( !item ) | 411 | if ( !item ) |
411 | continue; | 412 | continue; |
412 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 413 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
413 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 414 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
414 | if (!flist || !flist->att_list) { | 415 | if (!flist || !flist->att_list) { |
415 | continue; | 416 | continue; |
416 | } | 417 | } |
417 | cf = flist->att_list->first; | 418 | cf = flist->att_list->first; |
418 | if( ! cf ) | 419 | if( ! cf ) |
419 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 420 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
420 | cflag = (mailimap_flag_fetch*)cf->data; | 421 | cflag = (mailimap_flag_fetch*)cf->data; |
421 | if( ! cflag ) | 422 | if( ! cflag ) |
422 | qDebug("imap:not cflag "); | 423 | qDebug("imap:not cflag "); |
423 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 424 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
424 | switch (cflag->fl_flag->fl_type) { | 425 | switch (cflag->fl_flag->fl_type) { |
425 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 426 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
426 | mFlags.setBit(FLAG_ANSWERED); | 427 | mFlags.setBit(FLAG_ANSWERED); |
427 | break; | 428 | break; |
428 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 429 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
429 | mFlags.setBit(FLAG_FLAGGED); | 430 | mFlags.setBit(FLAG_FLAGGED); |
430 | break; | 431 | break; |
431 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 432 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
432 | mFlags.setBit(FLAG_DELETED); | 433 | mFlags.setBit(FLAG_DELETED); |
433 | break; | 434 | break; |
434 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 435 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
435 | mFlags.setBit(FLAG_SEEN); | 436 | mFlags.setBit(FLAG_SEEN); |
436 | break; | 437 | break; |
437 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 438 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
438 | mFlags.setBit(FLAG_DRAFT); | 439 | mFlags.setBit(FLAG_DRAFT); |
439 | break; | 440 | break; |
440 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 441 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
441 | break; | 442 | break; |
442 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 443 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
443 | break; | 444 | break; |
444 | default: | 445 | default: |
445 | break; | 446 | break; |
446 | } | 447 | } |
447 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 448 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
448 | mFlags.setBit(FLAG_RECENT); | 449 | mFlags.setBit(FLAG_RECENT); |
449 | } | 450 | } |
450 | } | 451 | } |
451 | continue; | 452 | continue; |
452 | } | 453 | } |
453 | if ( item->att_data.att_static == NULL ) | 454 | if ( item->att_data.att_static == NULL ) |
454 | continue; | 455 | continue; |
455 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 456 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
456 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 457 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
457 | if ( head == NULL ) | 458 | if ( head == NULL ) |
458 | continue; | 459 | continue; |
459 | if ( head->env_date != NULL ) | 460 | if ( head->env_date != NULL ) { |
460 | m->setDate(head->env_date); | 461 | m->setDate(head->env_date); |
462 | struct mailimf_date_time result; | ||
463 | struct mailimf_date_time* date = &result; | ||
464 | struct mailimf_date_time **re = &date; | ||
465 | size_t length = m->getDate().length(); | ||
466 | size_t index = 0; | ||
467 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | ||
468 | m->setDate( Genericwrapper::parseDateTime( date ) ); | ||
469 | char tmp[23]; | ||
470 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", | ||
471 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | ||
472 | m->setIsoDate( QString( tmp ) ); | ||
473 | } else { | ||
474 | m->setIsoDate(head->env_date); | ||
475 | } | ||
476 | } | ||
461 | if ( head->env_subject != NULL ) | 477 | if ( head->env_subject != NULL ) |
462 | m->setSubject(convert_String((const char*)head->env_subject)); | 478 | m->setSubject(convert_String((const char*)head->env_subject)); |
463 | //m->setSubject(head->env_subject); | 479 | //m->setSubject(head->env_subject); |
464 | if (head->env_from!=NULL) { | 480 | if (head->env_from!=NULL) { |
465 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 481 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
466 | if (addresslist.count()) { | 482 | if (addresslist.count()) { |
467 | m->setFrom(addresslist.first()); | 483 | m->setFrom(addresslist.first()); |
468 | } | 484 | } |
469 | } | 485 | } |
470 | if (head->env_to!=NULL) { | 486 | if (head->env_to!=NULL) { |
471 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 487 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
472 | m->setTo(addresslist); | 488 | m->setTo(addresslist); |
473 | } | 489 | } |
474 | if (head->env_cc!=NULL) { | 490 | if (head->env_cc!=NULL) { |
475 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 491 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
476 | m->setCC(addresslist); | 492 | m->setCC(addresslist); |
477 | } | 493 | } |
478 | if (head->env_bcc!=NULL) { | 494 | if (head->env_bcc!=NULL) { |
479 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 495 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
480 | m->setBcc(addresslist); | 496 | m->setBcc(addresslist); |
481 | } | 497 | } |
482 | /* reply to address, eg. email. */ | 498 | /* reply to address, eg. email. */ |
483 | if (head->env_reply_to!=NULL) { | 499 | if (head->env_reply_to!=NULL) { |
484 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 500 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
485 | if (addresslist.count()) { | 501 | if (addresslist.count()) { |
486 | m->setReplyto(addresslist.first()); | 502 | m->setReplyto(addresslist.first()); |
487 | } | 503 | } |
488 | } | 504 | } |
489 | if (head->env_in_reply_to!=NULL) { | 505 | if (head->env_in_reply_to!=NULL) { |
490 | QString h(head->env_in_reply_to); | 506 | QString h(head->env_in_reply_to); |
491 | while (h.length()>0 && h[0]=='<') { | 507 | while (h.length()>0 && h[0]=='<') { |
492 | h.remove(0,1); | 508 | h.remove(0,1); |
493 | } | 509 | } |
494 | while (h.length()>0 && h[h.length()-1]=='>') { | 510 | while (h.length()>0 && h[h.length()-1]=='>') { |
495 | h.remove(h.length()-1,1); | 511 | h.remove(h.length()-1,1); |
496 | } | 512 | } |
497 | if (h.length()>0) { | 513 | if (h.length()>0) { |
498 | m->setInreply(QStringList(h)); | 514 | m->setInreply(QStringList(h)); |
499 | } | 515 | } |
500 | } | 516 | } |
501 | if (head->env_message_id != NULL) { | 517 | if (head->env_message_id != NULL) { |
502 | m->setMsgid(QString(head->env_message_id)); | 518 | m->setMsgid(QString(head->env_message_id)); |
503 | } | 519 | } |
504 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 520 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
505 | #if 0 | 521 | #if 0 |
506 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 522 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
507 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 523 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
508 | qDebug("time %s ",da.toString().latin1() ); | 524 | qDebug("time %s ",da.toString().latin1() ); |
509 | #endif | 525 | #endif |
510 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 526 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
511 | size = item->att_data.att_static->att_data.att_rfc822_size; | 527 | size = item->att_data.att_static->att_data.att_rfc822_size; |
512 | } | 528 | } |
513 | } | 529 | } |
514 | /* msg is already deleted */ | 530 | /* msg is already deleted */ |
515 | if (mFlags.testBit(FLAG_DELETED) && m) { | 531 | if (mFlags.testBit(FLAG_DELETED) && m) { |
516 | delete m; | 532 | delete m; |
517 | m = 0; | 533 | m = 0; |
518 | } | 534 | } |
519 | if (m) { | 535 | if (m) { |
520 | m->setFlags(mFlags); | 536 | m->setFlags(mFlags); |
521 | m->setMsgsize(size); | 537 | m->setMsgsize(size); |
522 | } | 538 | } |
523 | return m; | 539 | return m; |
524 | } | 540 | } |
525 | 541 | ||
526 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 542 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
527 | { | 543 | { |
528 | RecBodyP body = new RecBody(); | 544 | RecBodyP body = new RecBody(); |
529 | const char *mb; | 545 | const char *mb; |
530 | int err = MAILIMAP_NO_ERROR; | 546 | int err = MAILIMAP_NO_ERROR; |
531 | clist *result = 0; | 547 | clist *result = 0; |
532 | clistcell *current; | 548 | clistcell *current; |
533 | mailimap_fetch_att *fetchAtt = 0; | 549 | mailimap_fetch_att *fetchAtt = 0; |
534 | mailimap_fetch_type *fetchType = 0; | 550 | mailimap_fetch_type *fetchType = 0; |
535 | mailimap_set *set = 0; | 551 | mailimap_set *set = 0; |
536 | mailimap_body*body_desc = 0; | 552 | mailimap_body*body_desc = 0; |
537 | 553 | ||
538 | mb = mail->getMbox().latin1(); | 554 | mb = mail->getMbox().latin1(); |
539 | 555 | ||
540 | login(); | 556 | login(); |
541 | if (!m_imap) { | 557 | if (!m_imap) { |
542 | return body; | 558 | return body; |
543 | } | 559 | } |
544 | err = selectMbox(mail->getMbox()); | 560 | err = selectMbox(mail->getMbox()); |
545 | if ( err != MAILIMAP_NO_ERROR ) { | 561 | if ( err != MAILIMAP_NO_ERROR ) { |
546 | return body; | 562 | return body; |
547 | } | 563 | } |
548 | 564 | ||
549 | /* the range has to start at 1!!! not with 0!!!! */ | 565 | /* the range has to start at 1!!! not with 0!!!! */ |
550 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 566 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
551 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 567 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
552 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 568 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
553 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 569 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
554 | mailimap_set_free( set ); | 570 | mailimap_set_free( set ); |
555 | mailimap_fetch_type_free( fetchType ); | 571 | mailimap_fetch_type_free( fetchType ); |
556 | 572 | ||