-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 23 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 23 |
2 files changed, 22 insertions, 24 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index 30eb678..853e4a2 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -1,20 +1,20 @@ | |||
1 | 1 | ||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include <libetpan/mailimap.h> | 4 | #include <libetpan/libetpan.h> |
5 | 5 | ||
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | 9 | ||
10 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 10 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
11 | : AbstractMail() | 11 | : AbstractMail() |
12 | { | 12 | { |
13 | account = a; | 13 | account = a; |
14 | m_imap = 0; | 14 | m_imap = 0; |
15 | } | 15 | } |
16 | 16 | ||
17 | IMAPwrapper::~IMAPwrapper() | 17 | IMAPwrapper::~IMAPwrapper() |
18 | { | 18 | { |
19 | logout(); | 19 | logout(); |
20 | } | 20 | } |
@@ -309,34 +309,33 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
309 | if (head->env_cc!=NULL) { | 309 | if (head->env_cc!=NULL) { |
310 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 310 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
311 | m->setCC(addresslist); | 311 | m->setCC(addresslist); |
312 | } | 312 | } |
313 | if (head->env_bcc!=NULL) { | 313 | if (head->env_bcc!=NULL) { |
314 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 314 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
315 | m->setBcc(addresslist); | 315 | m->setBcc(addresslist); |
316 | } | 316 | } |
317 | if (head->env_reply_to!=NULL) { | 317 | if (head->env_reply_to!=NULL) { |
318 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 318 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
319 | if (addresslist.count()) { | 319 | if (addresslist.count()) { |
320 | m->setReplyto(addresslist.first()); | 320 | m->setReplyto(addresslist.first()); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | m->setMsgid(QString(head->env_message_id)); | 323 | m->setMsgid(QString(head->env_message_id)); |
324 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 324 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
325 | #if 0 | 325 | #if 0 |
326 | |||
327 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 326 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
328 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 327 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
329 | 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); | 328 | 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); |
330 | qDebug(da.toString()); | 329 | qDebug(da.toString()); |
331 | #endif | 330 | #endif |
332 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 331 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
333 | size = item->att_data.att_static->att_data.att_rfc822_size; | 332 | size = item->att_data.att_static->att_data.att_rfc822_size; |
334 | } | 333 | } |
335 | } | 334 | } |
336 | /* msg is already deleted */ | 335 | /* msg is already deleted */ |
337 | if (mFlags.testBit(FLAG_DELETED) && m) { | 336 | if (mFlags.testBit(FLAG_DELETED) && m) { |
338 | delete m; | 337 | delete m; |
339 | m = 0; | 338 | m = 0; |
340 | } | 339 | } |
341 | if (m) { | 340 | if (m) { |
342 | m->setFlags(mFlags); | 341 | m->setFlags(mFlags); |
@@ -541,54 +540,54 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> | |||
541 | } | 540 | } |
542 | 541 | ||
543 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) | 542 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) |
544 | { | 543 | { |
545 | /* current_recursion is for avoiding ugly mails which has a to deep body-structure */ | 544 | /* current_recursion is for avoiding ugly mails which has a to deep body-structure */ |
546 | if (!mailDescription||current_recursion==10) { | 545 | if (!mailDescription||current_recursion==10) { |
547 | return; | 546 | return; |
548 | } | 547 | } |
549 | clistcell*current; | 548 | clistcell*current; |
550 | mailimap_body*current_body; | 549 | mailimap_body*current_body; |
551 | unsigned int count = 0; | 550 | unsigned int count = 0; |
552 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 551 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
553 | /* the point in the message */ | 552 | /* the point in the message */ |
554 | ++count; | 553 | ++count; |
555 | current_body = (mailimap_body*)current->data; | 554 | current_body = (mailimap_body*)current->data; |
556 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 555 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
557 | QValueList<int>clist = recList; | 556 | QValueList<int>countlist = recList; |
558 | clist.append(count); | 557 | countlist.append(count); |
559 | searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist); | 558 | searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,countlist); |
560 | } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ | 559 | } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ |
561 | RecPart currentPart; | 560 | RecPart currentPart; |
562 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); | 561 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); |
563 | QValueList<int>clist = recList; | 562 | QValueList<int>countlist = recList; |
564 | clist.append(count); | 563 | countlist.append(count); |
565 | /* important: Check for is NULL 'cause a body can be empty! */ | 564 | /* important: Check for is NULL 'cause a body can be empty! */ |
566 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { | 565 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { |
567 | QString body_text = fetchTextPart(mail,clist,true,currentPart.Encoding()); | 566 | QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding()); |
568 | target_body.setDescription(currentPart); | 567 | target_body.setDescription(currentPart); |
569 | target_body.setBodytext(body_text); | 568 | target_body.setBodytext(body_text); |
570 | } else { | 569 | } else { |
571 | QString id(""); | 570 | QString id(""); |
572 | for (unsigned int j = 0; j < clist.count();++j) { | 571 | for (unsigned int j = 0; j < countlist.count();++j) { |
573 | id+=(j>0?" ":""); | 572 | id+=(j>0?" ":""); |
574 | id+=QString("%1").arg(clist[j]); | 573 | id+=QString("%1").arg(countlist[j]); |
575 | } | 574 | } |
576 | qDebug("ID= %s",id.latin1()); | 575 | qDebug("ID= %s",id.latin1()); |
577 | currentPart.setIdentifier(id); | 576 | currentPart.setIdentifier(id); |
578 | currentPart.setPositionlist(clist); | 577 | currentPart.setPositionlist(countlist); |
579 | target_body.addPart(currentPart); | 578 | target_body.addPart(currentPart); |
580 | } | 579 | } |
581 | } | 580 | } |
582 | } | 581 | } |
583 | } | 582 | } |
584 | 583 | ||
585 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) | 584 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) |
586 | { | 585 | { |
587 | if (!Description) { | 586 | if (!Description) { |
588 | return; | 587 | return; |
589 | } | 588 | } |
590 | switch (Description->bd_type) { | 589 | switch (Description->bd_type) { |
591 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 590 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
592 | target_part.setType("text"); | 591 | target_part.setType("text"); |
593 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 592 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
594 | break; | 593 | break; |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 30eb678..853e4a2 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,20 +1,20 @@ | |||
1 | 1 | ||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include <libetpan/mailimap.h> | 4 | #include <libetpan/libetpan.h> |
5 | 5 | ||
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | 9 | ||
10 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 10 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
11 | : AbstractMail() | 11 | : AbstractMail() |
12 | { | 12 | { |
13 | account = a; | 13 | account = a; |
14 | m_imap = 0; | 14 | m_imap = 0; |
15 | } | 15 | } |
16 | 16 | ||
17 | IMAPwrapper::~IMAPwrapper() | 17 | IMAPwrapper::~IMAPwrapper() |
18 | { | 18 | { |
19 | logout(); | 19 | logout(); |
20 | } | 20 | } |
@@ -309,34 +309,33 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
309 | if (head->env_cc!=NULL) { | 309 | if (head->env_cc!=NULL) { |
310 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 310 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
311 | m->setCC(addresslist); | 311 | m->setCC(addresslist); |
312 | } | 312 | } |
313 | if (head->env_bcc!=NULL) { | 313 | if (head->env_bcc!=NULL) { |
314 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 314 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
315 | m->setBcc(addresslist); | 315 | m->setBcc(addresslist); |
316 | } | 316 | } |
317 | if (head->env_reply_to!=NULL) { | 317 | if (head->env_reply_to!=NULL) { |
318 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 318 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
319 | if (addresslist.count()) { | 319 | if (addresslist.count()) { |
320 | m->setReplyto(addresslist.first()); | 320 | m->setReplyto(addresslist.first()); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | m->setMsgid(QString(head->env_message_id)); | 323 | m->setMsgid(QString(head->env_message_id)); |
324 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 324 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
325 | #if 0 | 325 | #if 0 |
326 | |||
327 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 326 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
328 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 327 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
329 | 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); | 328 | 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); |
330 | qDebug(da.toString()); | 329 | qDebug(da.toString()); |
331 | #endif | 330 | #endif |
332 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 331 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
333 | size = item->att_data.att_static->att_data.att_rfc822_size; | 332 | size = item->att_data.att_static->att_data.att_rfc822_size; |
334 | } | 333 | } |
335 | } | 334 | } |
336 | /* msg is already deleted */ | 335 | /* msg is already deleted */ |
337 | if (mFlags.testBit(FLAG_DELETED) && m) { | 336 | if (mFlags.testBit(FLAG_DELETED) && m) { |
338 | delete m; | 337 | delete m; |
339 | m = 0; | 338 | m = 0; |
340 | } | 339 | } |
341 | if (m) { | 340 | if (m) { |
342 | m->setFlags(mFlags); | 341 | m->setFlags(mFlags); |
@@ -541,54 +540,54 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> | |||
541 | } | 540 | } |
542 | 541 | ||
543 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) | 542 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) |
544 | { | 543 | { |
545 | /* current_recursion is for avoiding ugly mails which has a to deep body-structure */ | 544 | /* current_recursion is for avoiding ugly mails which has a to deep body-structure */ |
546 | if (!mailDescription||current_recursion==10) { | 545 | if (!mailDescription||current_recursion==10) { |
547 | return; | 546 | return; |
548 | } | 547 | } |
549 | clistcell*current; | 548 | clistcell*current; |
550 | mailimap_body*current_body; | 549 | mailimap_body*current_body; |
551 | unsigned int count = 0; | 550 | unsigned int count = 0; |
552 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 551 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
553 | /* the point in the message */ | 552 | /* the point in the message */ |
554 | ++count; | 553 | ++count; |
555 | current_body = (mailimap_body*)current->data; | 554 | current_body = (mailimap_body*)current->data; |
556 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 555 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
557 | QValueList<int>clist = recList; | 556 | QValueList<int>countlist = recList; |
558 | clist.append(count); | 557 | countlist.append(count); |
559 | searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist); | 558 | searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,countlist); |
560 | } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ | 559 | } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ |
561 | RecPart currentPart; | 560 | RecPart currentPart; |
562 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); | 561 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); |
563 | QValueList<int>clist = recList; | 562 | QValueList<int>countlist = recList; |
564 | clist.append(count); | 563 | countlist.append(count); |
565 | /* important: Check for is NULL 'cause a body can be empty! */ | 564 | /* important: Check for is NULL 'cause a body can be empty! */ |
566 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { | 565 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { |
567 | QString body_text = fetchTextPart(mail,clist,true,currentPart.Encoding()); | 566 | QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding()); |
568 | target_body.setDescription(currentPart); | 567 | target_body.setDescription(currentPart); |
569 | target_body.setBodytext(body_text); | 568 | target_body.setBodytext(body_text); |
570 | } else { | 569 | } else { |
571 | QString id(""); | 570 | QString id(""); |
572 | for (unsigned int j = 0; j < clist.count();++j) { | 571 | for (unsigned int j = 0; j < countlist.count();++j) { |
573 | id+=(j>0?" ":""); | 572 | id+=(j>0?" ":""); |
574 | id+=QString("%1").arg(clist[j]); | 573 | id+=QString("%1").arg(countlist[j]); |
575 | } | 574 | } |
576 | qDebug("ID= %s",id.latin1()); | 575 | qDebug("ID= %s",id.latin1()); |
577 | currentPart.setIdentifier(id); | 576 | currentPart.setIdentifier(id); |
578 | currentPart.setPositionlist(clist); | 577 | currentPart.setPositionlist(countlist); |
579 | target_body.addPart(currentPart); | 578 | target_body.addPart(currentPart); |
580 | } | 579 | } |
581 | } | 580 | } |
582 | } | 581 | } |
583 | } | 582 | } |
584 | 583 | ||
585 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) | 584 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) |
586 | { | 585 | { |
587 | if (!Description) { | 586 | if (!Description) { |
588 | return; | 587 | return; |
589 | } | 588 | } |
590 | switch (Description->bd_type) { | 589 | switch (Description->bd_type) { |
591 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 590 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
592 | target_part.setType("text"); | 591 | target_part.setType("text"); |
593 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 592 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
594 | break; | 593 | break; |