Diffstat (limited to 'noncore/net/mail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 86 |
1 files changed, 48 insertions, 38 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 9b7c0e0..fe75a15 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -28,36 +28,36 @@ int IMAPwrapper::selectMbox(const QString&mbox) | |||
28 | { | 28 | { |
29 | if (mbox == m_Lastmbox) { | 29 | if (mbox == m_Lastmbox) { |
30 | return MAILIMAP_NO_ERROR; | 30 | return MAILIMAP_NO_ERROR; |
31 | } | 31 | } |
32 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 32 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
33 | if ( err != MAILIMAP_NO_ERROR ) { | 33 | if ( err != MAILIMAP_NO_ERROR ) { |
34 | odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; | 34 | odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; |
35 | m_Lastmbox = ""; | 35 | m_Lastmbox = ""; |
36 | return err; | 36 | return err; |
37 | } | 37 | } |
38 | m_Lastmbox = mbox; | 38 | m_Lastmbox = mbox; |
39 | return err; | 39 | return err; |
40 | } | 40 | } |
41 | 41 | ||
42 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 42 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
43 | { | 43 | { |
44 | qApp->processEvents(); | 44 | qApp->processEvents(); |
45 | odebug << "IMAP: " << current << " of " << maximum << "" << oendl; | 45 | odebug << "IMAP: " << current << " of " << maximum << "" << oendl; |
46 | } | 46 | } |
47 | 47 | ||
48 | bool IMAPwrapper::start_tls(bool force_tls) | 48 | bool IMAPwrapper::start_tls(bool force_tls) |
49 | { | 49 | { |
50 | int err; | 50 | int err; |
51 | bool try_tls; | 51 | bool try_tls; |
52 | mailimap_capability_data * cap_data = 0; | 52 | mailimap_capability_data * cap_data = 0; |
53 | 53 | ||
54 | err = mailimap_capability(m_imap,&cap_data); | 54 | err = mailimap_capability(m_imap,&cap_data); |
55 | if (err != MAILIMAP_NO_ERROR) { | 55 | if (err != MAILIMAP_NO_ERROR) { |
56 | Global::statusMessage("error getting capabilities!"); | 56 | Global::statusMessage("error getting capabilities!"); |
57 | odebug << "error getting capabilities!" << oendl; | 57 | odebug << "error getting capabilities!" << oendl; |
58 | return false; | 58 | return false; |
59 | } | 59 | } |
60 | clistiter * cur; | 60 | clistiter * cur; |
61 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 61 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
62 | struct mailimap_capability * cap; | 62 | struct mailimap_capability * cap; |
63 | cap = (struct mailimap_capability *)clist_content(cur); | 63 | cap = (struct mailimap_capability *)clist_content(cur); |
@@ -72,13 +72,13 @@ bool IMAPwrapper::start_tls(bool force_tls) | |||
72 | mailimap_capability_data_free(cap_data); | 72 | mailimap_capability_data_free(cap_data); |
73 | } | 73 | } |
74 | if (try_tls) { | 74 | if (try_tls) { |
75 | err = mailimap_starttls(m_imap); | 75 | err = mailimap_starttls(m_imap); |
76 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 76 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
77 | Global::statusMessage(tr("Server has no TLS support!")); | 77 | Global::statusMessage(tr("Server has no TLS support!")); |
78 | odebug << "Server has no TLS support!" << oendl; | 78 | odebug << "Server has no TLS support!" << oendl; |
79 | try_tls = false; | 79 | try_tls = false; |
80 | } else { | 80 | } else { |
81 | mailstream_low * low; | 81 | mailstream_low * low; |
82 | mailstream_low * new_low; | 82 | mailstream_low * new_low; |
83 | low = mailstream_get_low(m_imap->imap_stream); | 83 | low = mailstream_get_low(m_imap->imap_stream); |
84 | if (!low) { | 84 | if (!low) { |
@@ -123,13 +123,13 @@ void IMAPwrapper::login() | |||
123 | if ( QDialog::Accepted == login.exec() ) { | 123 | if ( QDialog::Accepted == login.exec() ) { |
124 | // ok | 124 | // ok |
125 | user = login.getUser().latin1(); | 125 | user = login.getUser().latin1(); |
126 | pass = login.getPassword().latin1(); | 126 | pass = login.getPassword().latin1(); |
127 | } else { | 127 | } else { |
128 | // cancel | 128 | // cancel |
129 | odebug << "IMAP: Login canceled" << oendl; | 129 | odebug << "IMAP: Login canceled" << oendl; |
130 | return; | 130 | return; |
131 | } | 131 | } |
132 | } else { | 132 | } else { |
133 | user = account->getUser().latin1(); | 133 | user = account->getUser().latin1(); |
134 | pass = account->getPassword().latin1(); | 134 | pass = account->getPassword().latin1(); |
135 | } | 135 | } |
@@ -146,13 +146,13 @@ void IMAPwrapper::login() | |||
146 | } | 146 | } |
147 | if (account->ConnectionType()==1) { | 147 | if (account->ConnectionType()==1) { |
148 | force_tls = true; | 148 | force_tls = true; |
149 | } | 149 | } |
150 | 150 | ||
151 | if ( ssl ) { | 151 | if ( ssl ) { |
152 | odebug << "using ssl" << oendl; | 152 | odebug << "using ssl" << oendl; |
153 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | 153 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); |
154 | } else { | 154 | } else { |
155 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 155 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
156 | } | 156 | } |
157 | 157 | ||
158 | if ( err != MAILIMAP_NO_ERROR && | 158 | if ( err != MAILIMAP_NO_ERROR && |
@@ -174,13 +174,13 @@ void IMAPwrapper::login() | |||
174 | try_tls = start_tls(force_tls); | 174 | try_tls = start_tls(force_tls); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool ok = true; | 177 | bool ok = true; |
178 | if (force_tls && !try_tls) { | 178 | if (force_tls && !try_tls) { |
179 | Global::statusMessage(tr("Server has no TLS support!")); | 179 | Global::statusMessage(tr("Server has no TLS support!")); |
180 | odebug << "Server has no TLS support!" << oendl; | 180 | odebug << "Server has no TLS support!" << oendl; |
181 | ok = false; | 181 | ok = false; |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | /* login */ | 185 | /* login */ |
186 | 186 | ||
@@ -234,18 +234,22 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma | |||
234 | return; | 234 | return; |
235 | } else { | 235 | } else { |
236 | } | 236 | } |
237 | 237 | ||
238 | /* the range has to start at 1!!! not with 0!!!! */ | 238 | /* the range has to start at 1!!! not with 0!!!! */ |
239 | set = mailimap_set_new_interval( 1, last ); | 239 | set = mailimap_set_new_interval( 1, last ); |
240 | |||
241 | |||
242 | fetchType = mailimap_fetch_type_new_all(); | ||
243 | /* | ||
240 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 244 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
241 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 245 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
242 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 246 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
243 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 247 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
244 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 248 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
245 | 249 | */ | |
246 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 250 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
247 | mailimap_set_free( set ); | 251 | mailimap_set_free( set ); |
248 | mailimap_fetch_type_free( fetchType ); | 252 | mailimap_fetch_type_free( fetchType ); |
249 | 253 | ||
250 | QString date,subject,from; | 254 | QString date,subject,from; |
251 | 255 | ||
@@ -315,23 +319,23 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | |||
315 | } | 319 | } |
316 | } | 320 | } |
317 | } | 321 | } |
318 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 322 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
319 | } | 323 | } |
320 | } else { | 324 | } else { |
321 | odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl; | 325 | odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl; |
322 | } | 326 | } |
323 | mailimap_list_result_free( result ); | 327 | mailimap_list_result_free( result ); |
324 | 328 | ||
325 | /* | 329 | /* |
326 | * second stage - get the other then inbox folders | 330 | * second stage - get the other then inbox folders |
327 | */ | 331 | */ |
328 | mask = "*" ; | 332 | mask = "*" ; |
329 | path = account->getPrefix().latin1(); | 333 | path = account->getPrefix().latin1(); |
330 | if (!path) path = ""; | 334 | if (!path) path = ""; |
331 | odebug << path << oendl; | 335 | odebug << path << oendl; |
332 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 336 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
333 | if ( err == MAILIMAP_NO_ERROR ) { | 337 | if ( err == MAILIMAP_NO_ERROR ) { |
334 | current = result->first; | 338 | current = result->first; |
335 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 339 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
336 | no_inferiors = false; | 340 | no_inferiors = false; |
337 | list = (mailimap_mailbox_list *) current->data; | 341 | list = (mailimap_mailbox_list *) current->data; |
@@ -352,13 +356,13 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | |||
352 | } | 356 | } |
353 | } | 357 | } |
354 | del = list->mb_delimiter; | 358 | del = list->mb_delimiter; |
355 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 359 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
356 | } | 360 | } |
357 | } else { | 361 | } else { |
358 | odebug << "error fetching folders " << m_imap->imap_response << "" << oendl; | 362 | odebug << "error fetching folders " << m_imap->imap_response << "" << oendl; |
359 | } | 363 | } |
360 | if (result) mailimap_list_result_free( result ); | 364 | if (result) mailimap_list_result_free( result ); |
361 | return folders; | 365 | return folders; |
362 | } | 366 | } |
363 | 367 | ||
364 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 368 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
@@ -372,16 +376,16 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
372 | QBitArray mFlags(7); | 376 | QBitArray mFlags(7); |
373 | QStringList addresslist; | 377 | QStringList addresslist; |
374 | 378 | ||
375 | if (!m_att) { | 379 | if (!m_att) { |
376 | return m; | 380 | return m; |
377 | } | 381 | } |
382 | size = 0; | ||
378 | m = new RecMail(); | 383 | m = new RecMail(); |
379 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 384 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
380 | current = c; | 385 | current = c; |
381 | size = 0; | ||
382 | item = (mailimap_msg_att_item*)current->data; | 386 | item = (mailimap_msg_att_item*)current->data; |
383 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 387 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
384 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 388 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
385 | if (!flist->att_list) { | 389 | if (!flist->att_list) { |
386 | continue; | 390 | continue; |
387 | } | 391 | } |
@@ -462,29 +466,35 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
462 | } | 466 | } |
463 | if (head->env_message_id) { | 467 | if (head->env_message_id) { |
464 | m->setMsgid(QString(head->env_message_id)); | 468 | m->setMsgid(QString(head->env_message_id)); |
465 | } | 469 | } |
466 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 470 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
467 | #if 0 | 471 | #if 0 |
468 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 472 | mailimap_date_time*date = item->att_data.att_static->att_data.att_internal_date; |
473 | if (date->dt_sec>60 || date->dt_sec<0) date->dt_sec=0; | ||
474 | //QDateTime da(QDate(d->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec)); | ||
475 | QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" "; | ||
476 | timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" "; | ||
477 | timestring.sprintf(timestring+" %+05i",date->dt_zone); | ||
478 | m->setDate(timestring); | ||
469 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 479 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
470 | odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl; | 480 | odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl; |
471 | odebug << da.toString() << oendl; | 481 | odebug << da.toString() << oendl; |
472 | #endif | 482 | #endif |
473 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 483 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
474 | size = item->att_data.att_static->att_data.att_rfc822_size; | 484 | //size = item->att_data.att_static->att_data.att_rfc822_size; |
485 | m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size); | ||
475 | } | 486 | } |
476 | } | 487 | } |
477 | /* msg is already deleted */ | 488 | /* msg is already deleted */ |
478 | if (mFlags.testBit(FLAG_DELETED) && m) { | 489 | if (mFlags.testBit(FLAG_DELETED) && m) { |
479 | delete m; | 490 | delete m; |
480 | m = 0; | 491 | m = 0; |
481 | } | 492 | } |
482 | if (m) { | 493 | if (m) { |
483 | m->setFlags(mFlags); | 494 | m->setFlags(mFlags); |
484 | m->setMsgsize(size); | ||
485 | } | 495 | } |
486 | return m; | 496 | return m; |
487 | } | 497 | } |
488 | 498 | ||
489 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 499 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
490 | { | 500 | { |
@@ -522,13 +532,13 @@ RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | |||
522 | msg_att = (mailimap_msg_att*)current->data; | 532 | msg_att = (mailimap_msg_att*)current->data; |
523 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 533 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
524 | QValueList<int> path; | 534 | QValueList<int> path; |
525 | body_desc = item->att_data.att_static->att_data.att_body; | 535 | body_desc = item->att_data.att_static->att_data.att_body; |
526 | traverseBody(mail,body_desc,body,0,path); | 536 | traverseBody(mail,body_desc,body,0,path); |
527 | } else { | 537 | } else { |
528 | odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; | 538 | odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; |
529 | } | 539 | } |
530 | if (result) mailimap_fetch_list_free(result); | 540 | if (result) mailimap_fetch_list_free(result); |
531 | return body; | 541 | return body; |
532 | } | 542 | } |
533 | 543 | ||
534 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 544 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
@@ -634,13 +644,13 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int | |||
634 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 644 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
635 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 645 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
636 | } | 646 | } |
637 | } | 647 | } |
638 | } | 648 | } |
639 | } else { | 649 | } else { |
640 | odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; | 650 | odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; |
641 | } | 651 | } |
642 | if (result) mailimap_fetch_list_free(result); | 652 | if (result) mailimap_fetch_list_free(result); |
643 | return res; | 653 | return res; |
644 | } | 654 | } |
645 | 655 | ||
646 | /* current_recursion is for recursive calls. | 656 | /* current_recursion is for recursive calls. |
@@ -661,13 +671,13 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t | |||
661 | QString id(""); | 671 | QString id(""); |
662 | currentPart->setPositionlist(countlist); | 672 | currentPart->setPositionlist(countlist); |
663 | for (unsigned int j = 0; j < countlist.count();++j) { | 673 | for (unsigned int j = 0; j < countlist.count();++j) { |
664 | id+=(j>0?" ":""); | 674 | id+=(j>0?" ":""); |
665 | id+=QString("%1").arg(countlist[j]); | 675 | id+=QString("%1").arg(countlist[j]); |
666 | } | 676 | } |
667 | odebug << "ID = " << id.latin1() << "" << oendl; | 677 | odebug << "ID = " << id.latin1() << "" << oendl; |
668 | currentPart->setIdentifier(id); | 678 | currentPart->setIdentifier(id); |
669 | fillSinglePart(currentPart,part1); | 679 | fillSinglePart(currentPart,part1); |
670 | /* important: Check for is NULL 'cause a body can be empty! | 680 | /* important: Check for is NULL 'cause a body can be empty! |
671 | And we put it only into the mail if it is the FIRST part */ | 681 | And we put it only into the mail if it is the FIRST part */ |
672 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { | 682 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { |
673 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); | 683 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); |
@@ -702,13 +712,13 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t | |||
702 | target_body->addPart(targetPart); | 712 | target_body->addPart(targetPart); |
703 | QString id(""); | 713 | QString id(""); |
704 | for (unsigned int j = 0; j < countlist.count();++j) { | 714 | for (unsigned int j = 0; j < countlist.count();++j) { |
705 | id+=(j>0?" ":""); | 715 | id+=(j>0?" ":""); |
706 | id+=QString("%1").arg(countlist[j]); | 716 | id+=QString("%1").arg(countlist[j]); |
707 | } | 717 | } |
708 | odebug << "ID(mpart) = " << id.latin1() << "" << oendl; | 718 | odebug << "ID(mpart) = " << id.latin1() << "" << oendl; |
709 | } | 719 | } |
710 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 720 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
711 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 721 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
712 | countlist = recList; | 722 | countlist = recList; |
713 | } | 723 | } |
714 | ++ccount; | 724 | ++ccount; |
@@ -746,25 +756,25 @@ void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_tex | |||
746 | { | 756 | { |
747 | if (!which) { | 757 | if (!which) { |
748 | return; | 758 | return; |
749 | } | 759 | } |
750 | QString sub; | 760 | QString sub; |
751 | sub = which->bd_media_text; | 761 | sub = which->bd_media_text; |
752 | odebug << "Type= text/" << which->bd_media_text << "" << oendl; | 762 | odebug << "Type= text/" << which->bd_media_text << "" << oendl; |
753 | target_part->setSubtype(sub.lower()); | 763 | target_part->setSubtype(sub.lower()); |
754 | target_part->setLines(which->bd_lines); | 764 | target_part->setLines(which->bd_lines); |
755 | fillBodyFields(target_part,which->bd_fields); | 765 | fillBodyFields(target_part,which->bd_fields); |
756 | } | 766 | } |
757 | 767 | ||
758 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) | 768 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) |
759 | { | 769 | { |
760 | if (!which) { | 770 | if (!which) { |
761 | return; | 771 | return; |
762 | } | 772 | } |
763 | target_part->setSubtype("rfc822"); | 773 | target_part->setSubtype("rfc822"); |
764 | odebug << "Message part" << oendl; | 774 | odebug << "Message part" << oendl; |
765 | /* we set this type to text/plain */ | 775 | /* we set this type to text/plain */ |
766 | target_part->setLines(which->bd_lines); | 776 | target_part->setLines(which->bd_lines); |
767 | fillBodyFields(target_part,which->bd_fields); | 777 | fillBodyFields(target_part,which->bd_fields); |
768 | } | 778 | } |
769 | 779 | ||
770 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) | 780 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) |
@@ -817,13 +827,13 @@ void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_ba | |||
817 | } | 827 | } |
818 | if (which->bd_media_basic->med_subtype) { | 828 | if (which->bd_media_basic->med_subtype) { |
819 | sub = which->bd_media_basic->med_subtype; | 829 | sub = which->bd_media_basic->med_subtype; |
820 | } else { | 830 | } else { |
821 | sub = ""; | 831 | sub = ""; |
822 | } | 832 | } |
823 | odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; | 833 | odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; |
824 | target_part->setType(type.lower()); | 834 | target_part->setType(type.lower()); |
825 | target_part->setSubtype(sub.lower()); | 835 | target_part->setSubtype(sub.lower()); |
826 | fillBodyFields(target_part,which->bd_fields); | 836 | fillBodyFields(target_part,which->bd_fields); |
827 | } | 837 | } |
828 | 838 | ||
829 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) | 839 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) |
@@ -893,22 +903,22 @@ void IMAPwrapper::deleteMail(const RecMailP&mail) | |||
893 | set = mailimap_set_new_single(mail->getNumber()); | 903 | set = mailimap_set_new_single(mail->getNumber()); |
894 | err = mailimap_store(m_imap,set,store_flags); | 904 | err = mailimap_store(m_imap,set,store_flags); |
895 | mailimap_set_free( set ); | 905 | mailimap_set_free( set ); |
896 | mailimap_store_att_flags_free(store_flags); | 906 | mailimap_store_att_flags_free(store_flags); |
897 | 907 | ||
898 | if (err != MAILIMAP_NO_ERROR) { | 908 | if (err != MAILIMAP_NO_ERROR) { |
899 | odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 909 | odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
900 | return; | 910 | return; |
901 | } | 911 | } |
902 | odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 912 | odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
903 | /* should we realy do that at this moment? */ | 913 | /* should we realy do that at this moment? */ |
904 | err = mailimap_expunge(m_imap); | 914 | err = mailimap_expunge(m_imap); |
905 | if (err != MAILIMAP_NO_ERROR) { | 915 | if (err != MAILIMAP_NO_ERROR) { |
906 | odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 916 | odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
907 | } | 917 | } |
908 | odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; | 918 | odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; |
909 | } | 919 | } |
910 | 920 | ||
911 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 921 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
912 | { | 922 | { |
913 | mailimap_flag_list*flist; | 923 | mailimap_flag_list*flist; |
914 | mailimap_set *set; | 924 | mailimap_set *set; |
@@ -928,13 +938,13 @@ void IMAPwrapper::answeredMail(const RecMailP&mail) | |||
928 | set = mailimap_set_new_single(mail->getNumber()); | 938 | set = mailimap_set_new_single(mail->getNumber()); |
929 | err = mailimap_store(m_imap,set,store_flags); | 939 | err = mailimap_store(m_imap,set,store_flags); |
930 | mailimap_set_free( set ); | 940 | mailimap_set_free( set ); |
931 | mailimap_store_att_flags_free(store_flags); | 941 | mailimap_store_att_flags_free(store_flags); |
932 | 942 | ||
933 | if (err != MAILIMAP_NO_ERROR) { | 943 | if (err != MAILIMAP_NO_ERROR) { |
934 | odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; | 944 | odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; |
935 | return; | 945 | return; |
936 | } | 946 | } |
937 | } | 947 | } |
938 | 948 | ||
939 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 949 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
940 | { | 950 | { |
@@ -996,20 +1006,20 @@ int IMAPwrapper::deleteAllMail(const FolderP&folder) | |||
996 | mailimap_set_free( set ); | 1006 | mailimap_set_free( set ); |
997 | mailimap_store_att_flags_free(store_flags); | 1007 | mailimap_store_att_flags_free(store_flags); |
998 | if (err != MAILIMAP_NO_ERROR) { | 1008 | if (err != MAILIMAP_NO_ERROR) { |
999 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1009 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
1000 | return 0; | 1010 | return 0; |
1001 | } | 1011 | } |
1002 | odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1012 | odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1003 | /* should we realy do that at this moment? */ | 1013 | /* should we realy do that at this moment? */ |
1004 | err = mailimap_expunge(m_imap); | 1014 | err = mailimap_expunge(m_imap); |
1005 | if (err != MAILIMAP_NO_ERROR) { | 1015 | if (err != MAILIMAP_NO_ERROR) { |
1006 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1016 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
1007 | return 0; | 1017 | return 0; |
1008 | } | 1018 | } |
1009 | odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; | 1019 | odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; |
1010 | return 1; | 1020 | return 1; |
1011 | } | 1021 | } |
1012 | 1022 | ||
1013 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) | 1023 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) |
1014 | { | 1024 | { |
1015 | if (folder.length()==0) return 0; | 1025 | if (folder.length()==0) return 0; |
@@ -1028,13 +1038,13 @@ int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,cons | |||
1028 | pre+=delemiter; | 1038 | pre+=delemiter; |
1029 | } else { | 1039 | } else { |
1030 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); | 1040 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); |
1031 | return 0; | 1041 | return 0; |
1032 | } | 1042 | } |
1033 | } | 1043 | } |
1034 | odebug << "Creating " << pre.latin1() << "" << oendl; | 1044 | odebug << "Creating " << pre.latin1() << "" << oendl; |
1035 | int res = mailimap_create(m_imap,pre.latin1()); | 1045 | int res = mailimap_create(m_imap,pre.latin1()); |
1036 | if (res != MAILIMAP_NO_ERROR) { | 1046 | if (res != MAILIMAP_NO_ERROR) { |
1037 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1047 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1038 | return 0; | 1048 | return 0; |
1039 | } | 1049 | } |
1040 | return 1; | 1050 | return 1; |
@@ -1087,13 +1097,13 @@ void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | |||
1087 | case MAILIMAP_STATUS_ATT_UNSEEN: | 1097 | case MAILIMAP_STATUS_ATT_UNSEEN: |
1088 | target_stat.message_unseen = status_info->st_value; | 1098 | target_stat.message_unseen = status_info->st_value; |
1089 | break; | 1099 | break; |
1090 | } | 1100 | } |
1091 | } | 1101 | } |
1092 | } else { | 1102 | } else { |
1093 | odebug << "Error retrieving status" << oendl; | 1103 | odebug << "Error retrieving status" << oendl; |
1094 | } | 1104 | } |
1095 | if (status) mailimap_mailbox_data_status_free(status); | 1105 | if (status) mailimap_mailbox_data_status_free(status); |
1096 | if (att_list) mailimap_status_att_list_free(att_list); | 1106 | if (att_list) mailimap_status_att_list_free(att_list); |
1097 | } | 1107 | } |
1098 | 1108 | ||
1099 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 1109 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
@@ -1111,13 +1121,13 @@ MAILLIB::ATYPE IMAPwrapper::getType()const | |||
1111 | { | 1121 | { |
1112 | return account->getType(); | 1122 | return account->getType(); |
1113 | } | 1123 | } |
1114 | 1124 | ||
1115 | const QString&IMAPwrapper::getName()const | 1125 | const QString&IMAPwrapper::getName()const |
1116 | { | 1126 | { |
1117 | odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; | 1127 | odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; |
1118 | return account->getAccountName(); | 1128 | return account->getAccountName(); |
1119 | } | 1129 | } |
1120 | 1130 | ||
1121 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | 1131 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1122 | { | 1132 | { |
1123 | // dummy | 1133 | // dummy |
@@ -1127,13 +1137,13 @@ encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | |||
1127 | 1137 | ||
1128 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1138 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1129 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1139 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1130 | { | 1140 | { |
1131 | if (targetWrapper != this) { | 1141 | if (targetWrapper != this) { |
1132 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 1142 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
1133 | odebug << "Using generic" << oendl; | 1143 | odebug << "Using generic" << oendl; |
1134 | return; | 1144 | return; |
1135 | } | 1145 | } |
1136 | mailimap_set *set = 0; | 1146 | mailimap_set *set = 0; |
1137 | login(); | 1147 | login(); |
1138 | if (!m_imap) { | 1148 | if (!m_imap) { |
1139 | return; | 1149 | return; |
@@ -1146,24 +1156,24 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | |||
1146 | set = mailimap_set_new_interval( 1, last ); | 1156 | set = mailimap_set_new_interval( 1, last ); |
1147 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1157 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1148 | mailimap_set_free( set ); | 1158 | mailimap_set_free( set ); |
1149 | if ( err != MAILIMAP_NO_ERROR ) { | 1159 | if ( err != MAILIMAP_NO_ERROR ) { |
1150 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); | 1160 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); |
1151 | Global::statusMessage(error_msg); | 1161 | Global::statusMessage(error_msg); |
1152 | odebug << error_msg << oendl; | 1162 | odebug << error_msg << oendl; |
1153 | return; | 1163 | return; |
1154 | } | 1164 | } |
1155 | if (moveit) { | 1165 | if (moveit) { |
1156 | deleteAllMail(fromFolder); | 1166 | deleteAllMail(fromFolder); |
1157 | } | 1167 | } |
1158 | } | 1168 | } |
1159 | 1169 | ||
1160 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1170 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1161 | { | 1171 | { |
1162 | if (targetWrapper != this) { | 1172 | if (targetWrapper != this) { |
1163 | odebug << "Using generic" << oendl; | 1173 | odebug << "Using generic" << oendl; |
1164 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1174 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1165 | return; | 1175 | return; |
1166 | } | 1176 | } |
1167 | mailimap_set *set = 0; | 1177 | mailimap_set *set = 0; |
1168 | login(); | 1178 | login(); |
1169 | if (!m_imap) { | 1179 | if (!m_imap) { |
@@ -1176,13 +1186,13 @@ void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,Abstra | |||
1176 | set = mailimap_set_new_single(mail->getNumber()); | 1186 | set = mailimap_set_new_single(mail->getNumber()); |
1177 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1187 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1178 | mailimap_set_free( set ); | 1188 | mailimap_set_free( set ); |
1179 | if ( err != MAILIMAP_NO_ERROR ) { | 1189 | if ( err != MAILIMAP_NO_ERROR ) { |
1180 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); | 1190 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); |
1181 | Global::statusMessage(error_msg); | 1191 | Global::statusMessage(error_msg); |
1182 | odebug << error_msg << oendl; | 1192 | odebug << error_msg << oendl; |
1183 | return; | 1193 | return; |
1184 | } | 1194 | } |
1185 | if (moveit) { | 1195 | if (moveit) { |
1186 | deleteMail(mail); | 1196 | deleteMail(mail); |
1187 | } | 1197 | } |
1188 | } | 1198 | } |