summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-19 02:35:50 (UTC)
committer alwin <alwin>2003-12-19 02:35:50 (UTC)
commitffc12a369b26b1c652213a48eb635ce24eab5458 (patch) (unidiff)
treea9751d94a6f6a128edd6270977ac872a97bebe2f
parent5b88f5d05b2f3f5d106b58b07bc7018f757cfc03 (diff)
downloadopie-ffc12a369b26b1c652213a48eb635ce24eab5458.zip
opie-ffc12a369b26b1c652213a48eb635ce24eab5458.tar.gz
opie-ffc12a369b26b1c652213a48eb635ce24eab5458.tar.bz2
fetching body-structure/content mostly finished
hard-limit: no mail larger than 5MB will fetched TODO: messages has to be cached in memory. otherwise on every part fetch we must fetch the whole message again. Idea: setup a content cache for imap, too.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp183
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h8
-rw-r--r--noncore/net/mail/pop3wrapper.cpp183
-rw-r--r--noncore/net/mail/pop3wrapper.h8
4 files changed, 318 insertions, 64 deletions
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index b0b985c..2c2a42a 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -81,77 +81,54 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail )
81 body = parseMail(message); 81 body = parseMail(message);
82 free(message); 82 free(message);
83 return body; 83 return body;
84} 84}
85 85
86RecBody POP3wrapper::parseMail( char *message ) 86RecBody POP3wrapper::parseMail( char *message )
87{ 87{
88 int err = MAILIMF_NO_ERROR; 88 int err = MAILIMF_NO_ERROR;
89 /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ 89 /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
90 size_t curTok = 0; 90 size_t curTok = 0;
91 mailimf_message *result = 0; 91 mailimf_message *result = 0;
92 mailmessage * msg=0; 92 mailmessage * msg=0;
93 mailmime_single_fields fields;
94
95 /* is bound to msg and will be freed there */
93 struct mailmime * mime=0; 96 struct mailmime * mime=0;
94 struct mailmime_single_fields fields; 97
95
96 RecBody body; 98 RecBody body;
97 99
98 100
99 err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result ); 101 err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result );
100 if ( err != MAILIMF_NO_ERROR ) { 102 if ( err != MAILIMF_NO_ERROR ) {
101 if (result) mailimf_message_free(result); 103 if (result) mailimf_message_free(result);
102 return body; 104 return body;
103 } 105 }
104 106
105#if 0
106 char*body_msg = message; 107 char*body_msg = message;
107 if ( result && result->msg_body && result->msg_body->bd_text ) {
108 body_msg = (char*)result->msg_body->bd_text;
109 result->msg_body->bd_text = 0;
110 }
111
112 msg = mailmessage_new(); 108 msg = mailmessage_new();
113 mailmessage_init(msg, NULL, data_message_driver, 0, strlen(body_msg)); 109 mailmessage_init(msg, NULL, data_message_driver, 0, strlen(body_msg));
114 generic_message_t * msg_data; 110 generic_message_t * msg_data;
115 msg_data = (generic_message_t *)msg->msg_data; 111 msg_data = (generic_message_t *)msg->msg_data;
116 msg_data->msg_fetched = 1; 112 msg_data->msg_fetched = 1;
117 msg_data->msg_message = body_msg; 113 msg_data->msg_message = body_msg;
118 msg_data->msg_length = strlen(body_msg); 114 msg_data->msg_length = strlen(body_msg);
115
116
119 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 117 memset(&fields, 0, sizeof(struct mailmime_single_fields));
120 err = mailmessage_get_bodystructure(msg,&mime); 118 err = mailmessage_get_bodystructure(msg,&mime);
119 traverseBody(body,msg,mime);
120
121 mailmessage_free(msg);
121 122
122 if (mime->mm_mime_fields != NULL) {
123 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
124 mime->mm_content_type);
125 }
126#endif
127
128#if 1
129 if ( result && result->msg_body && result->msg_body->bd_text ) {
130 qDebug( "POP3: bodytext found" );
131 // when curTok isn't set to 0 this line will fault! 'cause upper line faults!
132 body.setBodytext( QString( result->msg_body->bd_text ) );
133#if 0
134 curTok = 0;
135 mailmime_content*mresult = 0;
136 size_t index = 0;
137 mailmime_content_parse(result->msg_body->bd_text,
138 strlen(result->msg_body->bd_text),&index,&mresult);
139 if (mresult) {
140 mailmime_content_free(mresult);
141 }
142#endif
143 mailimf_message_free(result);
144 }
145#endif
146 return body; 123 return body;
147} 124}
148 125
149void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) 126void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
150{ 127{
151 int err = MAILPOP3_NO_ERROR; 128 int err = MAILPOP3_NO_ERROR;
152 char * header = 0; 129 char * header = 0;
153 /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ 130 /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
154 size_t length = 0; 131 size_t length = 0;
155 carray * messages = 0; 132 carray * messages = 0;
156 133
157 login(); 134 login();
@@ -447,12 +424,154 @@ void POP3wrapper::answeredMail(const RecMail&)
447{ 424{
448} 425}
449 426
450encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&) 427encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&)
451{ 428{
452 return new encodedString(); 429 return new encodedString();
453} 430}
454 431
455encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&) 432encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&)
456{ 433{
457 return new encodedString(); 434 return new encodedString();
458} 435}
436
437void POP3wrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rec)
438{
439 if (current_rec >= 10) {
440 qDebug("too deep recursion!");
441 }
442 if (!message || !mime) {
443 return;
444 }
445 int r;
446 char*data = 0;
447 size_t len;
448 clistiter * cur = 0;
449 mailmime_single_fields fields;
450 int res;
451 QString b;
452 memset(&fields, 0, sizeof(struct mailmime_single_fields));
453 RecPart part;
454
455 if (mime->mm_mime_fields != NULL) {
456 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
457 mime->mm_content_type);
458 }
459 switch (mime->mm_type) {
460 case MAILMIME_SINGLE:
461 r = mailmessage_fetch_section(message,mime,&data,&len);
462 fillSingleBody(part,message,mime);
463 if (part.Type()=="text" && target.Bodytext().isNull()) {
464 encodedString*r = new encodedString();
465 r->setContent(data,len);
466 encodedString*res = decode_String(r,part.Encoding());
467 b = QString(res->Content());
468 delete r;
469 delete res;
470 target.setBodytext(b);
471 target.setDescription(part);
472 } else {
473 /* TODO: Add the content to a list and store it for later use */
474 if (data) free(data);
475 target.addPart(part);
476 }
477 break;
478 case MAILMIME_MULTIPLE:
479 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
480 traverseBody(target,message, (mailmime*)clist_content(cur),current_rec+1);
481 }
482 break;
483 case MAILMIME_MESSAGE:
484 if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
485 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,current_rec+1);
486 }
487 break;
488 }
489}
490
491QString POP3wrapper::getencoding(mailmime_mechanism*aEnc)
492{
493 QString enc="7bit";
494 if (!aEnc) return enc;
495 switch(aEnc->enc_type) {
496 case MAILMIME_MECHANISM_7BIT:
497 enc = "7bit";
498 break;
499 case MAILMIME_MECHANISM_8BIT:
500 enc = "8bit";
501 break;
502 case MAILMIME_MECHANISM_BINARY:
503 enc = "binary";
504 break;
505 case MAILMIME_MECHANISM_QUOTED_PRINTABLE:
506 enc = "quoted-printable";
507 break;
508 case MAILMIME_MECHANISM_BASE64:
509 enc = "base64";
510 break;
511 case MAILMIME_MECHANISM_TOKEN:
512 default:
513 if (aEnc->enc_token) {
514 enc = QString(aEnc->enc_token);
515 }
516 break;
517 }
518 return enc;
519}
520
521void POP3wrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
522{
523 if (!mime) {
524 return;
525 }
526 mailmime_content*type = mime->mm_content_type;
527 mailmime_field*field = 0;
528 clistcell*current;
529 if (!type) {
530 target.setType("text");
531 target.setSubtype("plain");
532 } else {
533 target.setSubtype(type->ct_subtype);
534 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
535 case MAILMIME_DISCRETE_TYPE_TEXT:
536 target.setType("text");
537 break;
538 case MAILMIME_DISCRETE_TYPE_IMAGE:
539 target.setType("image");
540 break;
541 case MAILMIME_DISCRETE_TYPE_AUDIO:
542 target.setType("audio");
543 break;
544 case MAILMIME_DISCRETE_TYPE_VIDEO:
545 target.setType("video");
546 break;
547 case MAILMIME_DISCRETE_TYPE_APPLICATION:
548 target.setType("application");
549 break;
550 case MAILMIME_DISCRETE_TYPE_EXTENSION:
551 default:
552 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
553 target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
554 }
555 break;
556 }
557 }
558 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
559 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
560 field = (mailmime_field*)current->data;
561 switch(field->fld_type) {
562 case MAILMIME_FIELD_TRANSFER_ENCODING:
563 target.setEncoding(getencoding(field->fld_data.fld_encoding));
564 break;
565 case MAILMIME_FIELD_ID:
566 target.setIdentifier(field->fld_data.fld_id);
567 break;
568 case MAILMIME_FIELD_DESCRIPTION:
569 target.setDescription(field->fld_data.fld_description);
570 break;
571 default:
572 break;
573 }
574 }
575 }
576 // TODO search the parameter list for unique id and so on
577}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index a05021c..4171a76 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -1,22 +1,25 @@
1#ifndef __POP3WRAPPER 1#ifndef __POP3WRAPPER
2#define __POP3WRAPPER 2#define __POP3WRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5#include "abstractmail.h" 5#include "abstractmail.h"
6 6
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9class encodedString; 9class encodedString;
10struct mailpop3; 10struct mailpop3;
11struct mailmessage;
12struct mailmime;
13struct mailmime_mechanism;
11 14
12class POP3wrapper : public AbstractMail 15class POP3wrapper : public AbstractMail
13{ 16{
14 Q_OBJECT 17 Q_OBJECT
15 18
16public: 19public:
17 POP3wrapper( POP3account *a ); 20 POP3wrapper( POP3account *a );
18 virtual ~POP3wrapper(); 21 virtual ~POP3wrapper();
19 /* mailbox will be ignored */ 22 /* mailbox will be ignored */
20 virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); 23 virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
21 virtual QList<Folder>* listFolders(); 24 virtual QList<Folder>* listFolders();
22 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); 25 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
@@ -31,19 +34,24 @@ public:
31 34
32protected: 35protected:
33 void login(); 36 void login();
34 void logout(); 37 void logout();
35 38
36 RecMail *parseHeader( const char *header ); 39 RecMail *parseHeader( const char *header );
37 RecBody parseMail( char *message ); 40 RecBody parseMail( char *message );
38 QString parseMailboxList( mailimf_mailbox_list *list ); 41 QString parseMailboxList( mailimf_mailbox_list *list );
39 QString parseMailbox( mailimf_mailbox *box ); 42 QString parseMailbox( mailimf_mailbox *box );
40 QString parseGroup( mailimf_group *group ); 43 QString parseGroup( mailimf_group *group );
41 QString parseAddressList( mailimf_address_list *list ); 44 QString parseAddressList( mailimf_address_list *list );
42 QString parseDateTime( mailimf_date_time *date ); 45 QString parseDateTime( mailimf_date_time *date );
46
47 static void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0);
48 static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime);
49 static QString POP3wrapper::getencoding(mailmime_mechanism*aEnc);
50
43 POP3account *account; 51 POP3account *account;
44 mailpop3 *m_pop3; 52 mailpop3 *m_pop3;
45 QString msgTempName; 53 QString msgTempName;
46 unsigned int last_msg_id; 54 unsigned int last_msg_id;
47}; 55};
48 56
49#endif 57#endif
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index b0b985c..2c2a42a 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -81,77 +81,54 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail )
81 body = parseMail(message); 81 body = parseMail(message);
82 free(message); 82 free(message);
83 return body; 83 return body;
84} 84}
85 85
86RecBody POP3wrapper::parseMail( char *message ) 86RecBody POP3wrapper::parseMail( char *message )
87{ 87{
88 int err = MAILIMF_NO_ERROR; 88 int err = MAILIMF_NO_ERROR;
89 /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ 89 /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
90 size_t curTok = 0; 90 size_t curTok = 0;
91 mailimf_message *result = 0; 91 mailimf_message *result = 0;
92 mailmessage * msg=0; 92 mailmessage * msg=0;
93 mailmime_single_fields fields;
94
95 /* is bound to msg and will be freed there */
93 struct mailmime * mime=0; 96 struct mailmime * mime=0;
94 struct mailmime_single_fields fields; 97
95
96 RecBody body; 98 RecBody body;
97 99
98 100
99 err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result ); 101 err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result );
100 if ( err != MAILIMF_NO_ERROR ) { 102 if ( err != MAILIMF_NO_ERROR ) {
101 if (result) mailimf_message_free(result); 103 if (result) mailimf_message_free(result);
102 return body; 104 return body;
103 } 105 }
104 106
105#if 0
106 char*body_msg = message; 107 char*body_msg = message;
107 if ( result && result->msg_body && result->msg_body->bd_text ) {
108 body_msg = (char*)result->msg_body->bd_text;
109 result->msg_body->bd_text = 0;
110 }
111
112 msg = mailmessage_new(); 108 msg = mailmessage_new();
113 mailmessage_init(msg, NULL, data_message_driver, 0, strlen(body_msg)); 109 mailmessage_init(msg, NULL, data_message_driver, 0, strlen(body_msg));
114 generic_message_t * msg_data; 110 generic_message_t * msg_data;
115 msg_data = (generic_message_t *)msg->msg_data; 111 msg_data = (generic_message_t *)msg->msg_data;
116 msg_data->msg_fetched = 1; 112 msg_data->msg_fetched = 1;
117 msg_data->msg_message = body_msg; 113 msg_data->msg_message = body_msg;
118 msg_data->msg_length = strlen(body_msg); 114 msg_data->msg_length = strlen(body_msg);
115
116
119 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 117 memset(&fields, 0, sizeof(struct mailmime_single_fields));
120 err = mailmessage_get_bodystructure(msg,&mime); 118 err = mailmessage_get_bodystructure(msg,&mime);
119 traverseBody(body,msg,mime);
120
121 mailmessage_free(msg);
121 122
122 if (mime->mm_mime_fields != NULL) {
123 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
124 mime->mm_content_type);
125 }
126#endif
127
128#if 1
129 if ( result && result->msg_body && result->msg_body->bd_text ) {
130 qDebug( "POP3: bodytext found" );
131 // when curTok isn't set to 0 this line will fault! 'cause upper line faults!
132 body.setBodytext( QString( result->msg_body->bd_text ) );
133#if 0
134 curTok = 0;
135 mailmime_content*mresult = 0;
136 size_t index = 0;
137 mailmime_content_parse(result->msg_body->bd_text,
138 strlen(result->msg_body->bd_text),&index,&mresult);
139 if (mresult) {
140 mailmime_content_free(mresult);
141 }
142#endif
143 mailimf_message_free(result);
144 }
145#endif
146 return body; 123 return body;
147} 124}
148 125
149void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) 126void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
150{ 127{
151 int err = MAILPOP3_NO_ERROR; 128 int err = MAILPOP3_NO_ERROR;
152 char * header = 0; 129 char * header = 0;
153 /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */ 130 /* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
154 size_t length = 0; 131 size_t length = 0;
155 carray * messages = 0; 132 carray * messages = 0;
156 133
157 login(); 134 login();
@@ -447,12 +424,154 @@ void POP3wrapper::answeredMail(const RecMail&)
447{ 424{
448} 425}
449 426
450encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&) 427encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&)
451{ 428{
452 return new encodedString(); 429 return new encodedString();
453} 430}
454 431
455encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&) 432encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&)
456{ 433{
457 return new encodedString(); 434 return new encodedString();
458} 435}
436
437void POP3wrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rec)
438{
439 if (current_rec >= 10) {
440 qDebug("too deep recursion!");
441 }
442 if (!message || !mime) {
443 return;
444 }
445 int r;
446 char*data = 0;
447 size_t len;
448 clistiter * cur = 0;
449 mailmime_single_fields fields;
450 int res;
451 QString b;
452 memset(&fields, 0, sizeof(struct mailmime_single_fields));
453 RecPart part;
454
455 if (mime->mm_mime_fields != NULL) {
456 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
457 mime->mm_content_type);
458 }
459 switch (mime->mm_type) {
460 case MAILMIME_SINGLE:
461 r = mailmessage_fetch_section(message,mime,&data,&len);
462 fillSingleBody(part,message,mime);
463 if (part.Type()=="text" && target.Bodytext().isNull()) {
464 encodedString*r = new encodedString();
465 r->setContent(data,len);
466 encodedString*res = decode_String(r,part.Encoding());
467 b = QString(res->Content());
468 delete r;
469 delete res;
470 target.setBodytext(b);
471 target.setDescription(part);
472 } else {
473 /* TODO: Add the content to a list and store it for later use */
474 if (data) free(data);
475 target.addPart(part);
476 }
477 break;
478 case MAILMIME_MULTIPLE:
479 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
480 traverseBody(target,message, (mailmime*)clist_content(cur),current_rec+1);
481 }
482 break;
483 case MAILMIME_MESSAGE:
484 if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
485 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,current_rec+1);
486 }
487 break;
488 }
489}
490
491QString POP3wrapper::getencoding(mailmime_mechanism*aEnc)
492{
493 QString enc="7bit";
494 if (!aEnc) return enc;
495 switch(aEnc->enc_type) {
496 case MAILMIME_MECHANISM_7BIT:
497 enc = "7bit";
498 break;
499 case MAILMIME_MECHANISM_8BIT:
500 enc = "8bit";
501 break;
502 case MAILMIME_MECHANISM_BINARY:
503 enc = "binary";
504 break;
505 case MAILMIME_MECHANISM_QUOTED_PRINTABLE:
506 enc = "quoted-printable";
507 break;
508 case MAILMIME_MECHANISM_BASE64:
509 enc = "base64";
510 break;
511 case MAILMIME_MECHANISM_TOKEN:
512 default:
513 if (aEnc->enc_token) {
514 enc = QString(aEnc->enc_token);
515 }
516 break;
517 }
518 return enc;
519}
520
521void POP3wrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
522{
523 if (!mime) {
524 return;
525 }
526 mailmime_content*type = mime->mm_content_type;
527 mailmime_field*field = 0;
528 clistcell*current;
529 if (!type) {
530 target.setType("text");
531 target.setSubtype("plain");
532 } else {
533 target.setSubtype(type->ct_subtype);
534 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
535 case MAILMIME_DISCRETE_TYPE_TEXT:
536 target.setType("text");
537 break;
538 case MAILMIME_DISCRETE_TYPE_IMAGE:
539 target.setType("image");
540 break;
541 case MAILMIME_DISCRETE_TYPE_AUDIO:
542 target.setType("audio");
543 break;
544 case MAILMIME_DISCRETE_TYPE_VIDEO:
545 target.setType("video");
546 break;
547 case MAILMIME_DISCRETE_TYPE_APPLICATION:
548 target.setType("application");
549 break;
550 case MAILMIME_DISCRETE_TYPE_EXTENSION:
551 default:
552 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
553 target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
554 }
555 break;
556 }
557 }
558 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
559 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
560 field = (mailmime_field*)current->data;
561 switch(field->fld_type) {
562 case MAILMIME_FIELD_TRANSFER_ENCODING:
563 target.setEncoding(getencoding(field->fld_data.fld_encoding));
564 break;
565 case MAILMIME_FIELD_ID:
566 target.setIdentifier(field->fld_data.fld_id);
567 break;
568 case MAILMIME_FIELD_DESCRIPTION:
569 target.setDescription(field->fld_data.fld_description);
570 break;
571 default:
572 break;
573 }
574 }
575 }
576 // TODO search the parameter list for unique id and so on
577}
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h
index a05021c..4171a76 100644
--- a/noncore/net/mail/pop3wrapper.h
+++ b/noncore/net/mail/pop3wrapper.h
@@ -1,22 +1,25 @@
1#ifndef __POP3WRAPPER 1#ifndef __POP3WRAPPER
2#define __POP3WRAPPER 2#define __POP3WRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5#include "abstractmail.h" 5#include "abstractmail.h"
6 6
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9class encodedString; 9class encodedString;
10struct mailpop3; 10struct mailpop3;
11struct mailmessage;
12struct mailmime;
13struct mailmime_mechanism;
11 14
12class POP3wrapper : public AbstractMail 15class POP3wrapper : public AbstractMail
13{ 16{
14 Q_OBJECT 17 Q_OBJECT
15 18
16public: 19public:
17 POP3wrapper( POP3account *a ); 20 POP3wrapper( POP3account *a );
18 virtual ~POP3wrapper(); 21 virtual ~POP3wrapper();
19 /* mailbox will be ignored */ 22 /* mailbox will be ignored */
20 virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); 23 virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
21 virtual QList<Folder>* listFolders(); 24 virtual QList<Folder>* listFolders();
22 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); 25 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
@@ -31,19 +34,24 @@ public:
31 34
32protected: 35protected:
33 void login(); 36 void login();
34 void logout(); 37 void logout();
35 38
36 RecMail *parseHeader( const char *header ); 39 RecMail *parseHeader( const char *header );
37 RecBody parseMail( char *message ); 40 RecBody parseMail( char *message );
38 QString parseMailboxList( mailimf_mailbox_list *list ); 41 QString parseMailboxList( mailimf_mailbox_list *list );
39 QString parseMailbox( mailimf_mailbox *box ); 42 QString parseMailbox( mailimf_mailbox *box );
40 QString parseGroup( mailimf_group *group ); 43 QString parseGroup( mailimf_group *group );
41 QString parseAddressList( mailimf_address_list *list ); 44 QString parseAddressList( mailimf_address_list *list );
42 QString parseDateTime( mailimf_date_time *date ); 45 QString parseDateTime( mailimf_date_time *date );
46
47 static void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0);
48 static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime);
49 static QString POP3wrapper::getencoding(mailmime_mechanism*aEnc);
50
43 POP3account *account; 51 POP3account *account;
44 mailpop3 *m_pop3; 52 mailpop3 *m_pop3;
45 QString msgTempName; 53 QString msgTempName;
46 unsigned int last_msg_id; 54 unsigned int last_msg_id;
47}; 55};
48 56
49#endif 57#endif