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) (ignore 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 | |||
@@ -184,49 +184,49 @@ void IMAPwrapper::login() | |||
184 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 184 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
185 | if ( err != MAILIMAP_NO_ERROR ) { | 185 | if ( err != MAILIMAP_NO_ERROR ) { |
186 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); | 186 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); |
187 | ok = false; | 187 | ok = false; |
188 | } | 188 | } |
189 | } | 189 | } |
190 | if (!ok) { | 190 | if (!ok) { |
191 | err = mailimap_close( m_imap ); | 191 | err = mailimap_close( m_imap ); |
192 | mailimap_free( m_imap ); | 192 | mailimap_free( m_imap ); |
193 | m_imap = 0; | 193 | m_imap = 0; |
194 | } | 194 | } |
195 | } | 195 | } |
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 */ |
221 | err = selectMbox(mailbox); | 221 | err = selectMbox(mailbox); |
222 | if ( err != MAILIMAP_NO_ERROR ) { | 222 | if ( err != MAILIMAP_NO_ERROR ) { |
223 | return; | 223 | return; |
224 | } | 224 | } |
225 | 225 | ||
226 | int last = m_imap->imap_selection_info->sel_exists; | 226 | int last = m_imap->imap_selection_info->sel_exists; |
227 | 227 | ||
228 | if (last == 0) { | 228 | if (last == 0) { |
229 | Global::statusMessage(tr("Mailbox has no mails")); | 229 | Global::statusMessage(tr("Mailbox has no mails")); |
230 | return; | 230 | return; |
231 | } else { | 231 | } else { |
232 | } | 232 | } |
@@ -245,49 +245,49 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
245 | 245 | ||
246 | QString date,subject,from; | 246 | QString date,subject,from; |
247 | 247 | ||
248 | if ( err == MAILIMAP_NO_ERROR ) { | 248 | if ( err == MAILIMAP_NO_ERROR ) { |
249 | mailimap_msg_att * msg_att; | 249 | mailimap_msg_att * msg_att; |
250 | int i = 0; | 250 | int i = 0; |
251 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 251 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
252 | ++i; | 252 | ++i; |
253 | msg_att = (mailimap_msg_att*)current->data; | 253 | msg_att = (mailimap_msg_att*)current->data; |
254 | RecMail*m = parse_list_result(msg_att); | 254 | RecMail*m = parse_list_result(msg_att); |
255 | if (m) { | 255 | if (m) { |
256 | m->setNumber(i); | 256 | m->setNumber(i); |
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; |
282 | } | 282 | } |
283 | 283 | ||
284 | /* | 284 | /* |
285 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 285 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
286 | * We must not forget to filter them out in next loop! | 286 | * We must not forget to filter them out in next loop! |
287 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 287 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
288 | */ | 288 | */ |
289 | QString temp; | 289 | QString temp; |
290 | mask = "INBOX" ; | 290 | mask = "INBOX" ; |
291 | mailimap_mailbox_list *list; | 291 | mailimap_mailbox_list *list; |
292 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 292 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
293 | QString del; | 293 | QString del; |
@@ -461,73 +461,73 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
461 | } | 461 | } |
462 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 462 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
463 | #if 0 | 463 | #if 0 |
464 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 464 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
465 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 465 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
466 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); | 466 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); |
467 | qDebug(da.toString()); | 467 | qDebug(da.toString()); |
468 | #endif | 468 | #endif |
469 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 469 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
470 | size = item->att_data.att_static->att_data.att_rfc822_size; | 470 | size = item->att_data.att_static->att_data.att_rfc822_size; |
471 | } | 471 | } |
472 | } | 472 | } |
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; |
522 | traverseBody(mail,body_desc,body,0,path); | 522 | traverseBody(mail,body_desc,body,0,path); |
523 | } else { | 523 | } else { |
524 | qDebug("error fetching body: %s",m_imap->imap_response); | 524 | qDebug("error fetching body: %s",m_imap->imap_response); |
525 | } | 525 | } |
526 | if (result) mailimap_fetch_list_free(result); | 526 | if (result) mailimap_fetch_list_free(result); |
527 | return body; | 527 | return body; |
528 | } | 528 | } |
529 | 529 | ||
530 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 530 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
531 | { | 531 | { |
532 | QStringList l; | 532 | QStringList l; |
533 | QString from; | 533 | QString from; |
@@ -547,71 +547,71 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
547 | from+=" "; | 547 | from+=" "; |
548 | named_from = true; | 548 | named_from = true; |
549 | } | 549 | } |
550 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 550 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
551 | from+="<"; | 551 | from+="<"; |
552 | } | 552 | } |
553 | if (current_address->ad_mailbox_name) { | 553 | if (current_address->ad_mailbox_name) { |
554 | from+=QString(current_address->ad_mailbox_name); | 554 | from+=QString(current_address->ad_mailbox_name); |
555 | from+="@"; | 555 | from+="@"; |
556 | } | 556 | } |
557 | if (current_address->ad_host_name) { | 557 | if (current_address->ad_host_name) { |
558 | from+=QString(current_address->ad_host_name); | 558 | from+=QString(current_address->ad_host_name); |
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 | } |
606 | section_part = mailimap_section_part_new(id_list); | 606 | section_part = mailimap_section_part_new(id_list); |
607 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 607 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
608 | } | 608 | } |
609 | 609 | ||
610 | section = mailimap_section_new(section_spec); | 610 | section = mailimap_section_new(section_spec); |
611 | fetch_att = mailimap_fetch_att_new_body_section(section); | 611 | fetch_att = mailimap_fetch_att_new_body_section(section); |
612 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 612 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
613 | 613 | ||
614 | clist*result = 0; | 614 | clist*result = 0; |
615 | 615 | ||
616 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 616 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
617 | mailimap_set_free( set ); | 617 | mailimap_set_free( set ); |
@@ -620,49 +620,49 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> | |||
620 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 620 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
621 | mailimap_msg_att * msg_att; | 621 | mailimap_msg_att * msg_att; |
622 | msg_att = (mailimap_msg_att*)current->data; | 622 | msg_att = (mailimap_msg_att*)current->data; |
623 | mailimap_msg_att_item*msg_att_item; | 623 | mailimap_msg_att_item*msg_att_item; |
624 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 624 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
625 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 625 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
626 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 626 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
627 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 627 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
628 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 628 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
629 | /* detach - we take over the content */ | 629 | /* detach - we take over the content */ |
630 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 630 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
631 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 631 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
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; |
657 | QString id(""); | 657 | QString id(""); |
658 | currentPart.setPositionlist(countlist); | 658 | currentPart.setPositionlist(countlist); |
659 | for (unsigned int j = 0; j < countlist.count();++j) { | 659 | for (unsigned int j = 0; j < countlist.count();++j) { |
660 | id+=(j>0?" ":""); | 660 | id+=(j>0?" ":""); |
661 | id+=QString("%1").arg(countlist[j]); | 661 | id+=QString("%1").arg(countlist[j]); |
662 | } | 662 | } |
663 | qDebug("ID = %s",id.latin1()); | 663 | qDebug("ID = %s",id.latin1()); |
664 | currentPart.setIdentifier(id); | 664 | currentPart.setIdentifier(id); |
665 | fillSinglePart(currentPart,part1); | 665 | fillSinglePart(currentPart,part1); |
666 | /* important: Check for is NULL 'cause a body can be empty! | 666 | /* important: Check for is NULL 'cause a body can be empty! |
667 | And we put it only into the mail if it is the FIRST part */ | 667 | And we put it only into the mail if it is the FIRST part */ |
668 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body.Bodytext().isNull() && countlist[0]==1) { | 668 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body.Bodytext().isNull() && countlist[0]==1) { |
@@ -848,140 +848,140 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
848 | encoding="binary"; | 848 | encoding="binary"; |
849 | break; | 849 | break; |
850 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 850 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
851 | encoding="base64"; | 851 | encoding="base64"; |
852 | break; | 852 | break; |
853 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 853 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
854 | encoding="quoted-printable"; | 854 | encoding="quoted-printable"; |
855 | break; | 855 | break; |
856 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 856 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
857 | default: | 857 | default: |
858 | if (enc->enc_value) { | 858 | if (enc->enc_value) { |
859 | char*t=enc->enc_value; | 859 | char*t=enc->enc_value; |
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; |
976 | mailimap_store_att_flags * store_flags; | 976 | mailimap_store_att_flags * store_flags; |
977 | int err = selectMbox(folder->getName()); | 977 | int err = selectMbox(folder->getName()); |
978 | if ( err != MAILIMAP_NO_ERROR ) { | 978 | if ( err != MAILIMAP_NO_ERROR ) { |
979 | return 0; | 979 | return 0; |
980 | } | 980 | } |
981 | 981 | ||
982 | int last = m_imap->imap_selection_info->sel_exists; | 982 | int last = m_imap->imap_selection_info->sel_exists; |
983 | if (last == 0) { | 983 | if (last == 0) { |
984 | Global::statusMessage(tr("Mailbox has no mails!")); | 984 | Global::statusMessage(tr("Mailbox has no mails!")); |
985 | return 0; | 985 | return 0; |
986 | } | 986 | } |
987 | flist = mailimap_flag_list_new_empty(); | 987 | flist = mailimap_flag_list_new_empty(); |
@@ -1034,49 +1034,48 @@ int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,cons | |||
1034 | return 0; | 1034 | return 0; |
1035 | } | 1035 | } |
1036 | return 1; | 1036 | return 1; |
1037 | } | 1037 | } |
1038 | 1038 | ||
1039 | int IMAPwrapper::deleteMbox(const FolderP&folder) | 1039 | int IMAPwrapper::deleteMbox(const FolderP&folder) |
1040 | { | 1040 | { |
1041 | if (!folder) return 0; | 1041 | if (!folder) return 0; |
1042 | login(); | 1042 | login(); |
1043 | if (!m_imap) {return 0;} | 1043 | if (!m_imap) {return 0;} |
1044 | int res = mailimap_delete(m_imap,folder->getName()); | 1044 | int res = mailimap_delete(m_imap,folder->getName()); |
1045 | if (res != MAILIMAP_NO_ERROR) { | 1045 | if (res != MAILIMAP_NO_ERROR) { |
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); |
1071 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 1070 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
1072 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { | 1071 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
1073 | for (cur = clist_begin(status->st_info_list); | 1072 | for (cur = clist_begin(status->st_info_list); |
1074 | cur != NULL ; cur = clist_next(cur)) { | 1073 | cur != NULL ; cur = clist_next(cur)) { |
1075 | mailimap_status_info * status_info; | 1074 | mailimap_status_info * status_info; |
1076 | status_info = (mailimap_status_info *)clist_content(cur); | 1075 | status_info = (mailimap_status_info *)clist_content(cur); |
1077 | switch (status_info->st_att) { | 1076 | switch (status_info->st_att) { |
1078 | case MAILIMAP_STATUS_ATT_MESSAGES: | 1077 | case MAILIMAP_STATUS_ATT_MESSAGES: |
1079 | target_stat.message_count = status_info->st_value; | 1078 | target_stat.message_count = status_info->st_value; |
1080 | break; | 1079 | break; |
1081 | case MAILIMAP_STATUS_ATT_RECENT: | 1080 | case MAILIMAP_STATUS_ATT_RECENT: |
1082 | target_stat.message_recent = status_info->st_value; | 1081 | target_stat.message_recent = status_info->st_value; |
@@ -1094,92 +1093,92 @@ void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | |||
1094 | } | 1093 | } |
1095 | 1094 | ||
1096 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 1095 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
1097 | { | 1096 | { |
1098 | login(); | 1097 | login(); |
1099 | if (!m_imap) return; | 1098 | if (!m_imap) return; |
1100 | if (!msg) return; | 1099 | if (!msg) return; |
1101 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 1100 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1102 | if (r != MAILIMAP_NO_ERROR) { | 1101 | if (r != MAILIMAP_NO_ERROR) { |
1103 | Global::statusMessage("Error storing mail!"); | 1102 | Global::statusMessage("Error storing mail!"); |
1104 | } | 1103 | } |
1105 | } | 1104 | } |
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"); |
1131 | return; | 1130 | return; |
1132 | } | 1131 | } |
1133 | mailimap_set *set = 0; | 1132 | mailimap_set *set = 0; |
1134 | login(); | 1133 | login(); |
1135 | if (!m_imap) { | 1134 | if (!m_imap) { |
1136 | return; | 1135 | return; |
1137 | } | 1136 | } |
1138 | int err = selectMbox(fromFolder->getName()); | 1137 | int err = selectMbox(fromFolder->getName()); |
1139 | if ( err != MAILIMAP_NO_ERROR ) { | 1138 | if ( err != MAILIMAP_NO_ERROR ) { |
1140 | return; | 1139 | return; |
1141 | } | 1140 | } |
1142 | int last = m_imap->imap_selection_info->sel_exists; | 1141 | int last = m_imap->imap_selection_info->sel_exists; |
1143 | set = mailimap_set_new_interval( 1, last ); | 1142 | set = mailimap_set_new_interval( 1, last ); |
1144 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1143 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
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 | } |