author | alwin <alwin> | 2004-03-12 19:24:38 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-12 19:24:38 (UTC) |
commit | b600871ce93553a116a66fd80acd6dfc1cc46829 (patch) (unidiff) | |
tree | b361346a49e09d9f0220993583bf183cf29bd974 /noncore/net/mail/libmailwrapper/imapwrapper.cpp | |
parent | 874d5a34eca296263dcd1adf857aebe9981825a1 (diff) | |
download | opie-b600871ce93553a116a66fd80acd6dfc1cc46829.zip opie-b600871ce93553a116a66fd80acd6dfc1cc46829.tar.gz opie-b600871ce93553a116a66fd80acd6dfc1cc46829.tar.bz2 |
some more smart-pointers
some bugfixes
some renaming of internals
Diffstat (limited to 'noncore/net/mail/libmailwrapper/imapwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 3b3be0f..071e734 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -196,25 +196,25 @@ void IMAPwrapper::login() | |||
196 | 196 | ||
197 | void IMAPwrapper::logout() | 197 | void IMAPwrapper::logout() |
198 | { | 198 | { |
199 | int err = MAILIMAP_NO_ERROR; | 199 | int err = MAILIMAP_NO_ERROR; |
200 | if (!m_imap) return; | 200 | if (!m_imap) return; |
201 | err = mailimap_logout( m_imap ); | 201 | err = mailimap_logout( m_imap ); |
202 | err = mailimap_close( m_imap ); | 202 | err = mailimap_close( m_imap ); |
203 | mailimap_free( m_imap ); | 203 | mailimap_free( m_imap ); |
204 | m_imap = 0; | 204 | m_imap = 0; |
205 | m_Lastmbox = ""; | 205 | m_Lastmbox = ""; |
206 | } | 206 | } |
207 | 207 | ||
208 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | 208 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::OSmartPointer<RecMail> > &target ) |
209 | { | 209 | { |
210 | int err = MAILIMAP_NO_ERROR; | 210 | int err = MAILIMAP_NO_ERROR; |
211 | clist *result = 0; | 211 | clist *result = 0; |
212 | clistcell *current; | 212 | clistcell *current; |
213 | mailimap_fetch_type *fetchType = 0; | 213 | mailimap_fetch_type *fetchType = 0; |
214 | mailimap_set *set = 0; | 214 | mailimap_set *set = 0; |
215 | 215 | ||
216 | login(); | 216 | login(); |
217 | if (!m_imap) { | 217 | if (!m_imap) { |
218 | return; | 218 | return; |
219 | } | 219 | } |
220 | /* select mailbox READONLY for operations */ | 220 | /* select mailbox READONLY for operations */ |
@@ -257,25 +257,25 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
257 | m->setMbox(mailbox); | 257 | m->setMbox(mailbox); |
258 | m->setWrapper(this); | 258 | m->setWrapper(this); |
259 | target.append(m); | 259 | target.append(m); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | 262 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); |
263 | } else { | 263 | } else { |
264 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 264 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); |
265 | } | 265 | } |
266 | if (result) mailimap_fetch_list_free(result); | 266 | if (result) mailimap_fetch_list_free(result); |
267 | } | 267 | } |
268 | 268 | ||
269 | QValueList<Opie::osmart_pointer<Folder> >* IMAPwrapper::listFolders() | 269 | QValueList<Opie::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
270 | { | 270 | { |
271 | const char *path, *mask; | 271 | const char *path, *mask; |
272 | int err = MAILIMAP_NO_ERROR; | 272 | int err = MAILIMAP_NO_ERROR; |
273 | clist *result = 0; | 273 | clist *result = 0; |
274 | clistcell *current = 0; | 274 | clistcell *current = 0; |
275 | clistcell*cur_flag = 0; | 275 | clistcell*cur_flag = 0; |
276 | mailimap_mbx_list_flags*bflags = 0; | 276 | mailimap_mbx_list_flags*bflags = 0; |
277 | 277 | ||
278 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 278 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
279 | login(); | 279 | login(); |
280 | if (!m_imap) { | 280 | if (!m_imap) { |
281 | return folders; | 281 | return folders; |
@@ -473,49 +473,49 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
473 | /* msg is already deleted */ | 473 | /* msg is already deleted */ |
474 | if (mFlags.testBit(FLAG_DELETED) && m) { | 474 | if (mFlags.testBit(FLAG_DELETED) && m) { |
475 | delete m; | 475 | delete m; |
476 | m = 0; | 476 | m = 0; |
477 | } | 477 | } |
478 | if (m) { | 478 | if (m) { |
479 | m->setFlags(mFlags); | 479 | m->setFlags(mFlags); |
480 | m->setMsgsize(size); | 480 | m->setMsgsize(size); |
481 | } | 481 | } |
482 | return m; | 482 | return m; |
483 | } | 483 | } |
484 | 484 | ||
485 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 485 | RecBody IMAPwrapper::fetchBody(const RecMailP&mail) |
486 | { | 486 | { |
487 | RecBody body; | 487 | RecBody body; |
488 | const char *mb; | 488 | const char *mb; |
489 | int err = MAILIMAP_NO_ERROR; | 489 | int err = MAILIMAP_NO_ERROR; |
490 | clist *result = 0; | 490 | clist *result = 0; |
491 | clistcell *current; | 491 | clistcell *current; |
492 | mailimap_fetch_att *fetchAtt = 0; | 492 | mailimap_fetch_att *fetchAtt = 0; |
493 | mailimap_fetch_type *fetchType = 0; | 493 | mailimap_fetch_type *fetchType = 0; |
494 | mailimap_set *set = 0; | 494 | mailimap_set *set = 0; |
495 | mailimap_body*body_desc = 0; | 495 | mailimap_body*body_desc = 0; |
496 | 496 | ||
497 | mb = mail.getMbox().latin1(); | 497 | mb = mail->getMbox().latin1(); |
498 | 498 | ||
499 | login(); | 499 | login(); |
500 | if (!m_imap) { | 500 | if (!m_imap) { |
501 | return body; | 501 | return body; |
502 | } | 502 | } |
503 | err = selectMbox(mail.getMbox()); | 503 | err = selectMbox(mail->getMbox()); |
504 | if ( err != MAILIMAP_NO_ERROR ) { | 504 | if ( err != MAILIMAP_NO_ERROR ) { |
505 | return body; | 505 | return body; |
506 | } | 506 | } |
507 | 507 | ||
508 | /* the range has to start at 1!!! not with 0!!!! */ | 508 | /* the range has to start at 1!!! not with 0!!!! */ |
509 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 509 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
510 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 510 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
511 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 511 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
512 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 512 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
513 | mailimap_set_free( set ); | 513 | mailimap_set_free( set ); |
514 | mailimap_fetch_type_free( fetchType ); | 514 | mailimap_fetch_type_free( fetchType ); |
515 | 515 | ||
516 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 516 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
517 | mailimap_msg_att * msg_att; | 517 | mailimap_msg_att * msg_att; |
518 | msg_att = (mailimap_msg_att*)current->data; | 518 | msg_att = (mailimap_msg_att*)current->data; |
519 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 519 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
520 | QValueList<int> path; | 520 | QValueList<int> path; |
521 | body_desc = item->att_data.att_static->att_data.att_body; | 521 | body_desc = item->att_data.att_static->att_data.att_body; |
@@ -559,47 +559,47 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
559 | } | 559 | } |
560 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 560 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
561 | from+=">"; | 561 | from+=">"; |
562 | } | 562 | } |
563 | l.append(QString(from)); | 563 | l.append(QString(from)); |
564 | if (++count > 99) { | 564 | if (++count > 99) { |
565 | break; | 565 | break; |
566 | } | 566 | } |
567 | } | 567 | } |
568 | return l; | 568 | return l; |
569 | } | 569 | } |
570 | 570 | ||
571 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) | 571 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
572 | { | 572 | { |
573 | encodedString*res=new encodedString; | 573 | encodedString*res=new encodedString; |
574 | int err; | 574 | int err; |
575 | mailimap_fetch_type *fetchType; | 575 | mailimap_fetch_type *fetchType; |
576 | mailimap_set *set; | 576 | mailimap_set *set; |
577 | clistcell*current,*cur; | 577 | clistcell*current,*cur; |
578 | mailimap_section_part * section_part = 0; | 578 | mailimap_section_part * section_part = 0; |
579 | mailimap_section_spec * section_spec = 0; | 579 | mailimap_section_spec * section_spec = 0; |
580 | mailimap_section * section = 0; | 580 | mailimap_section * section = 0; |
581 | mailimap_fetch_att * fetch_att = 0; | 581 | mailimap_fetch_att * fetch_att = 0; |
582 | 582 | ||
583 | login(); | 583 | login(); |
584 | if (!m_imap) { | 584 | if (!m_imap) { |
585 | return res; | 585 | return res; |
586 | } | 586 | } |
587 | if (!internal_call) { | 587 | if (!internal_call) { |
588 | err = selectMbox(mail.getMbox()); | 588 | err = selectMbox(mail->getMbox()); |
589 | if ( err != MAILIMAP_NO_ERROR ) { | 589 | if ( err != MAILIMAP_NO_ERROR ) { |
590 | return res; | 590 | return res; |
591 | } | 591 | } |
592 | } | 592 | } |
593 | set = mailimap_set_new_single(mail.getNumber()); | 593 | set = mailimap_set_new_single(mail->getNumber()); |
594 | 594 | ||
595 | clist*id_list = 0; | 595 | clist*id_list = 0; |
596 | 596 | ||
597 | /* if path == empty then its a request for the whole rfc822 mail and generates | 597 | /* if path == empty then its a request for the whole rfc822 mail and generates |
598 | a "fetch <id> (body[])" statement on imap server */ | 598 | a "fetch <id> (body[])" statement on imap server */ |
599 | if (path.count()>0 ) { | 599 | if (path.count()>0 ) { |
600 | id_list = clist_new(); | 600 | id_list = clist_new(); |
601 | for (unsigned j=0; j < path.count();++j) { | 601 | for (unsigned j=0; j < path.count();++j) { |
602 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 602 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
603 | *p_id = path[j]; | 603 | *p_id = path[j]; |
604 | clist_append(id_list,p_id); | 604 | clist_append(id_list,p_id); |
605 | } | 605 | } |
@@ -632,25 +632,25 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> | |||
632 | } | 632 | } |
633 | } | 633 | } |
634 | } | 634 | } |
635 | } else { | 635 | } else { |
636 | qDebug("error fetching text: %s",m_imap->imap_response); | 636 | qDebug("error fetching text: %s",m_imap->imap_response); |
637 | } | 637 | } |
638 | if (result) mailimap_fetch_list_free(result); | 638 | if (result) mailimap_fetch_list_free(result); |
639 | return res; | 639 | return res; |
640 | } | 640 | } |
641 | 641 | ||
642 | /* current_recursion is for recursive calls. | 642 | /* current_recursion is for recursive calls. |
643 | current_count means the position inside the internal loop! */ | 643 | current_count means the position inside the internal loop! */ |
644 | void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, | 644 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body, |
645 | int current_recursion,QValueList<int>recList,int current_count) | 645 | int current_recursion,QValueList<int>recList,int current_count) |
646 | { | 646 | { |
647 | if (!body || current_recursion>=10) { | 647 | if (!body || current_recursion>=10) { |
648 | return; | 648 | return; |
649 | } | 649 | } |
650 | switch (body->bd_type) { | 650 | switch (body->bd_type) { |
651 | case MAILIMAP_BODY_1PART: | 651 | case MAILIMAP_BODY_1PART: |
652 | { | 652 | { |
653 | QValueList<int>countlist = recList; | 653 | QValueList<int>countlist = recList; |
654 | countlist.append(current_count); | 654 | countlist.append(current_count); |
655 | RecPart currentPart; | 655 | RecPart currentPart; |
656 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 656 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
@@ -860,116 +860,116 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
860 | encoding=QString(enc->enc_value); | 860 | encoding=QString(enc->enc_value); |
861 | enc->enc_value=0L; | 861 | enc->enc_value=0L; |
862 | free(t); | 862 | free(t); |
863 | } | 863 | } |
864 | } | 864 | } |
865 | if (which->bd_description) { | 865 | if (which->bd_description) { |
866 | target_part.setDescription(QString(which->bd_description)); | 866 | target_part.setDescription(QString(which->bd_description)); |
867 | } | 867 | } |
868 | target_part.setEncoding(encoding); | 868 | target_part.setEncoding(encoding); |
869 | target_part.setSize(which->bd_size); | 869 | target_part.setSize(which->bd_size); |
870 | } | 870 | } |
871 | 871 | ||
872 | void IMAPwrapper::deleteMail(const RecMail&mail) | 872 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
873 | { | 873 | { |
874 | mailimap_flag_list*flist; | 874 | mailimap_flag_list*flist; |
875 | mailimap_set *set; | 875 | mailimap_set *set; |
876 | mailimap_store_att_flags * store_flags; | 876 | mailimap_store_att_flags * store_flags; |
877 | int err; | 877 | int err; |
878 | login(); | 878 | login(); |
879 | if (!m_imap) { | 879 | if (!m_imap) { |
880 | return; | 880 | return; |
881 | } | 881 | } |
882 | err = selectMbox(mail.getMbox()); | 882 | err = selectMbox(mail->getMbox()); |
883 | if ( err != MAILIMAP_NO_ERROR ) { | 883 | if ( err != MAILIMAP_NO_ERROR ) { |
884 | return; | 884 | return; |
885 | } | 885 | } |
886 | flist = mailimap_flag_list_new_empty(); | 886 | flist = mailimap_flag_list_new_empty(); |
887 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 887 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
888 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 888 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
889 | set = mailimap_set_new_single(mail.getNumber()); | 889 | set = mailimap_set_new_single(mail->getNumber()); |
890 | err = mailimap_store(m_imap,set,store_flags); | 890 | err = mailimap_store(m_imap,set,store_flags); |
891 | mailimap_set_free( set ); | 891 | mailimap_set_free( set ); |
892 | mailimap_store_att_flags_free(store_flags); | 892 | mailimap_store_att_flags_free(store_flags); |
893 | 893 | ||
894 | if (err != MAILIMAP_NO_ERROR) { | 894 | if (err != MAILIMAP_NO_ERROR) { |
895 | qDebug("error deleting mail: %s",m_imap->imap_response); | 895 | qDebug("error deleting mail: %s",m_imap->imap_response); |
896 | return; | 896 | return; |
897 | } | 897 | } |
898 | qDebug("deleting mail: %s",m_imap->imap_response); | 898 | qDebug("deleting mail: %s",m_imap->imap_response); |
899 | /* should we realy do that at this moment? */ | 899 | /* should we realy do that at this moment? */ |
900 | err = mailimap_expunge(m_imap); | 900 | err = mailimap_expunge(m_imap); |
901 | if (err != MAILIMAP_NO_ERROR) { | 901 | if (err != MAILIMAP_NO_ERROR) { |
902 | qDebug("error deleting mail: %s",m_imap->imap_response); | 902 | qDebug("error deleting mail: %s",m_imap->imap_response); |
903 | } | 903 | } |
904 | qDebug("Delete successfull %s",m_imap->imap_response); | 904 | qDebug("Delete successfull %s",m_imap->imap_response); |
905 | } | 905 | } |
906 | 906 | ||
907 | void IMAPwrapper::answeredMail(const RecMail&mail) | 907 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
908 | { | 908 | { |
909 | mailimap_flag_list*flist; | 909 | mailimap_flag_list*flist; |
910 | mailimap_set *set; | 910 | mailimap_set *set; |
911 | mailimap_store_att_flags * store_flags; | 911 | mailimap_store_att_flags * store_flags; |
912 | int err; | 912 | int err; |
913 | login(); | 913 | login(); |
914 | if (!m_imap) { | 914 | if (!m_imap) { |
915 | return; | 915 | return; |
916 | } | 916 | } |
917 | err = selectMbox(mail.getMbox()); | 917 | err = selectMbox(mail->getMbox()); |
918 | if ( err != MAILIMAP_NO_ERROR ) { | 918 | if ( err != MAILIMAP_NO_ERROR ) { |
919 | return; | 919 | return; |
920 | } | 920 | } |
921 | flist = mailimap_flag_list_new_empty(); | 921 | flist = mailimap_flag_list_new_empty(); |
922 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 922 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
923 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 923 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
924 | set = mailimap_set_new_single(mail.getNumber()); | 924 | set = mailimap_set_new_single(mail->getNumber()); |
925 | err = mailimap_store(m_imap,set,store_flags); | 925 | err = mailimap_store(m_imap,set,store_flags); |
926 | mailimap_set_free( set ); | 926 | mailimap_set_free( set ); |
927 | mailimap_store_att_flags_free(store_flags); | 927 | mailimap_store_att_flags_free(store_flags); |
928 | 928 | ||
929 | if (err != MAILIMAP_NO_ERROR) { | 929 | if (err != MAILIMAP_NO_ERROR) { |
930 | qDebug("error marking mail: %s",m_imap->imap_response); | 930 | qDebug("error marking mail: %s",m_imap->imap_response); |
931 | return; | 931 | return; |
932 | } | 932 | } |
933 | } | 933 | } |
934 | 934 | ||
935 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 935 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
936 | { | 936 | { |
937 | QString body(""); | 937 | QString body(""); |
938 | encodedString*res = fetchRawPart(mail,path,internal_call); | 938 | encodedString*res = fetchRawPart(mail,path,internal_call); |
939 | encodedString*r = decode_String(res,enc); | 939 | encodedString*r = decode_String(res,enc); |
940 | delete res; | 940 | delete res; |
941 | if (r) { | 941 | if (r) { |
942 | if (r->Length()>0) { | 942 | if (r->Length()>0) { |
943 | body = r->Content(); | 943 | body = r->Content(); |
944 | } | 944 | } |
945 | delete r; | 945 | delete r; |
946 | } | 946 | } |
947 | return body; | 947 | return body; |
948 | } | 948 | } |
949 | 949 | ||
950 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | 950 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part) |
951 | { | 951 | { |
952 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); | 952 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); |
953 | } | 953 | } |
954 | 954 | ||
955 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) | 955 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPart&part) |
956 | { | 956 | { |
957 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); | 957 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); |
958 | encodedString*r = decode_String(res,part.Encoding()); | 958 | encodedString*r = decode_String(res,part.Encoding()); |
959 | delete res; | 959 | delete res; |
960 | return r; | 960 | return r; |
961 | } | 961 | } |
962 | 962 | ||
963 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | 963 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part) |
964 | { | 964 | { |
965 | return fetchRawPart(mail,part.Positionlist(),false); | 965 | return fetchRawPart(mail,part.Positionlist(),false); |
966 | } | 966 | } |
967 | 967 | ||
968 | int IMAPwrapper::deleteAllMail(const FolderP&folder) | 968 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
969 | { | 969 | { |
970 | login(); | 970 | login(); |
971 | if (!m_imap) { | 971 | if (!m_imap) { |
972 | return 0; | 972 | return 0; |
973 | } | 973 | } |
974 | mailimap_flag_list*flist; | 974 | mailimap_flag_list*flist; |
975 | mailimap_set *set; | 975 | mailimap_set *set; |
@@ -1046,25 +1046,24 @@ int IMAPwrapper::deleteMbox(const FolderP&folder) | |||
1046 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1046 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1047 | return 0; | 1047 | return 0; |
1048 | } | 1048 | } |
1049 | return 1; | 1049 | return 1; |
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1052 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1053 | { | 1053 | { |
1054 | mailimap_status_att_list * att_list =0; | 1054 | mailimap_status_att_list * att_list =0; |
1055 | mailimap_mailbox_data_status * status=0; | 1055 | mailimap_mailbox_data_status * status=0; |
1056 | clistiter * cur = 0; | 1056 | clistiter * cur = 0; |
1057 | int r = 0; | 1057 | int r = 0; |
1058 | int res = 0; | ||
1059 | target_stat.message_count = 0; | 1058 | target_stat.message_count = 0; |
1060 | target_stat.message_unseen = 0; | 1059 | target_stat.message_unseen = 0; |
1061 | target_stat.message_recent = 0; | 1060 | target_stat.message_recent = 0; |
1062 | login(); | 1061 | login(); |
1063 | if (!m_imap) { | 1062 | if (!m_imap) { |
1064 | return; | 1063 | return; |
1065 | } | 1064 | } |
1066 | att_list = mailimap_status_att_list_new_empty(); | 1065 | att_list = mailimap_status_att_list_new_empty(); |
1067 | if (!att_list) return; | 1066 | if (!att_list) return; |
1068 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 1067 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
1069 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 1068 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
1070 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 1069 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
@@ -1106,25 +1105,25 @@ void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folde | |||
1106 | 1105 | ||
1107 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1106 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1108 | { | 1107 | { |
1109 | return account->getType(); | 1108 | return account->getType(); |
1110 | } | 1109 | } |
1111 | 1110 | ||
1112 | const QString&IMAPwrapper::getName()const | 1111 | const QString&IMAPwrapper::getName()const |
1113 | { | 1112 | { |
1114 | qDebug("Get name: %s",account->getAccountName().latin1()); | 1113 | qDebug("Get name: %s",account->getAccountName().latin1()); |
1115 | return account->getAccountName(); | 1114 | return account->getAccountName(); |
1116 | } | 1115 | } |
1117 | 1116 | ||
1118 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) | 1117 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1119 | { | 1118 | { |
1120 | // dummy | 1119 | // dummy |
1121 | QValueList<int> path; | 1120 | QValueList<int> path; |
1122 | return fetchRawPart(mail,path,false); | 1121 | return fetchRawPart(mail,path,false); |
1123 | } | 1122 | } |
1124 | 1123 | ||
1125 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1124 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1126 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1125 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1127 | { | 1126 | { |
1128 | if (targetWrapper != this) { | 1127 | if (targetWrapper != this) { |
1129 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 1128 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
1130 | qDebug("Using generic"); | 1129 | qDebug("Using generic"); |
@@ -1145,41 +1144,41 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | |||
1145 | mailimap_set_free( set ); | 1144 | mailimap_set_free( set ); |
1146 | if ( err != MAILIMAP_NO_ERROR ) { | 1145 | if ( err != MAILIMAP_NO_ERROR ) { |
1147 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); | 1146 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); |
1148 | Global::statusMessage(error_msg); | 1147 | Global::statusMessage(error_msg); |
1149 | qDebug(error_msg); | 1148 | qDebug(error_msg); |
1150 | return; | 1149 | return; |
1151 | } | 1150 | } |
1152 | if (moveit) { | 1151 | if (moveit) { |
1153 | deleteAllMail(fromFolder); | 1152 | deleteAllMail(fromFolder); |
1154 | } | 1153 | } |
1155 | } | 1154 | } |
1156 | 1155 | ||
1157 | void IMAPwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1156 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1158 | { | 1157 | { |
1159 | if (targetWrapper != this) { | 1158 | if (targetWrapper != this) { |
1160 | qDebug("Using generic"); | 1159 | qDebug("Using generic"); |
1161 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1160 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1162 | return; | 1161 | return; |
1163 | } | 1162 | } |
1164 | mailimap_set *set = 0; | 1163 | mailimap_set *set = 0; |
1165 | login(); | 1164 | login(); |
1166 | if (!m_imap) { | 1165 | if (!m_imap) { |
1167 | return; | 1166 | return; |
1168 | } | 1167 | } |
1169 | int err = selectMbox(mail.getMbox()); | 1168 | int err = selectMbox(mail->getMbox()); |
1170 | if ( err != MAILIMAP_NO_ERROR ) { | 1169 | if ( err != MAILIMAP_NO_ERROR ) { |
1171 | return; | 1170 | return; |
1172 | } | 1171 | } |
1173 | set = mailimap_set_new_single(mail.getNumber()); | 1172 | set = mailimap_set_new_single(mail->getNumber()); |
1174 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1173 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1175 | mailimap_set_free( set ); | 1174 | mailimap_set_free( set ); |
1176 | if ( err != MAILIMAP_NO_ERROR ) { | 1175 | if ( err != MAILIMAP_NO_ERROR ) { |
1177 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); | 1176 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); |
1178 | Global::statusMessage(error_msg); | 1177 | Global::statusMessage(error_msg); |
1179 | qDebug(error_msg); | 1178 | qDebug(error_msg); |
1180 | return; | 1179 | return; |
1181 | } | 1180 | } |
1182 | if (moveit) { | 1181 | if (moveit) { |
1183 | deleteMail(mail); | 1182 | deleteMail(mail); |
1184 | } | 1183 | } |
1185 | } | 1184 | } |