summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp85
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.h1
2 files changed, 5 insertions, 81 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index 3fe319b..eb2c031 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -225,109 +225,32 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi
225} 225}
226 226
227RecBody Genericwrapper::parseMail( mailmessage * msg ) 227RecBody Genericwrapper::parseMail( mailmessage * msg )
228{ 228{
229 int err = MAILIMF_NO_ERROR; 229 int err = MAILIMF_NO_ERROR;
230 mailmime_single_fields fields; 230 mailmime_single_fields fields;
231 /* is bound to msg and will be freed there */ 231 /* is bound to msg and will be freed there */
232 mailmime * mime=0; 232 mailmime * mime=0;
233 RecBody body; 233 RecBody body;
234 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 234 memset(&fields, 0, sizeof(struct mailmime_single_fields));
235 err = mailmessage_get_bodystructure(msg,&mime); 235 err = mailmessage_get_bodystructure(msg,&mime);
236 QValueList<int>recList; 236 QValueList<int>recList;
237 traverseBody(body,msg,mime,recList); 237 traverseBody(body,msg,mime,recList);
238 return body; 238 return body;
239} 239}
240 240
241RecMail *Genericwrapper::parseHeader( const char *header )
242{
243 int err = MAILIMF_NO_ERROR;
244 size_t curTok = 0;
245 RecMail *mail = new RecMail();
246 mailimf_fields *fields = 0;
247 mailimf_references * refs = 0;
248 mailimf_keywords*keys = 0;
249 QString status;
250 QString value;
251 QBitArray mFlags(7);
252
253 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
254 for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) {
255 mailimf_field *field = (mailimf_field *) current->data;
256 switch ( field->fld_type ) {
257 case MAILIMF_FIELD_FROM:
258 mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) );
259 break;
260 case MAILIMF_FIELD_TO:
261 mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) );
262 break;
263 case MAILIMF_FIELD_CC:
264 mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) );
265 break;
266 case MAILIMF_FIELD_BCC:
267 mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) );
268 break;
269 case MAILIMF_FIELD_SUBJECT:
270 mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) );
271 break;
272 case MAILIMF_FIELD_ORIG_DATE:
273 mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) );
274 break;
275 case MAILIMF_FIELD_MESSAGE_ID:
276 mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value));
277 break;
278 case MAILIMF_FIELD_REFERENCES:
279 refs = field->fld_data.fld_references;
280 if (refs && refs->mid_list && clist_count(refs->mid_list)) {
281 char * text = (char*)refs->mid_list->first->data;
282 mail->setReplyto(QString(text));
283 }
284 break;
285 case MAILIMF_FIELD_KEYWORDS:
286 keys = field->fld_data.fld_keywords;
287 for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) {
288 qDebug("Keyword: %s",(char*)cur->data);
289 }
290 break;
291 case MAILIMF_FIELD_OPTIONAL_FIELD:
292 status = field->fld_data.fld_optional_field->fld_name;
293 value = field->fld_data.fld_optional_field->fld_value;
294 if (status.lower()=="status") {
295 if (value.lower()=="ro") {
296 mFlags.setBit(FLAG_SEEN);
297 }
298 } else if (status.lower()=="x-status") {
299 qDebug("X-Status: %s",value.latin1());
300 if (value.lower()=="a") {
301 mFlags.setBit(FLAG_ANSWERED);
302 }
303 } else {
304// qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name,
305// field->fld_data.fld_optional_field->fld_value);
306 }
307 break;
308 default:
309 qDebug("Non parsed field");
310 break;
311 }
312 }
313 if (fields) mailimf_fields_free(fields);
314 mail->setFlags(mFlags);
315 return mail;
316}
317
318QString Genericwrapper::parseDateTime( mailimf_date_time *date ) 241QString Genericwrapper::parseDateTime( mailimf_date_time *date )
319{ 242{
320 char tmp[23]; 243 char tmp[23];
321 244
322 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 245 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
323 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 246 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
324 247
325 return QString( tmp ); 248 return QString( tmp );
326} 249}
327 250
328QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 251QString Genericwrapper::parseAddressList( mailimf_address_list *list )
329{ 252{
330 QString result( "" ); 253 QString result( "" );
331 254
332 bool first = true; 255 bool first = true;
333 if (list == 0) return result; 256 if (list == 0) return result;
@@ -487,30 +410,32 @@ void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const
487 if (single_fields.fld_subject) 410 if (single_fields.fld_subject)
488 mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); 411 mail->setSubject( convert_String(single_fields.fld_subject->sbj_value));
489 if (single_fields.fld_from) 412 if (single_fields.fld_from)
490 mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); 413 mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list));
491 if (!mbox_as_to) { 414 if (!mbox_as_to) {
492 if (single_fields.fld_to) 415 if (single_fields.fld_to)
493 mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); 416 mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) );
494 } else { 417 } else {
495 mail->setTo(mailbox); 418 mail->setTo(mailbox);
496 } 419 }
497 if (single_fields.fld_cc) 420 if (single_fields.fld_cc)
498 mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); 421 mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) );
499 if (single_fields.fld_bcc) 422 if (single_fields.fld_bcc)
500 mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); 423 mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) );
501 if (single_fields.fld_orig_date) 424 if (single_fields.fld_orig_date)
502 mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); 425 mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) );
503 // crashes when accessing pop3 account 426 // crashes when accessing pop3 account?
504 // if (single_fields.fld_message_id->mid_value) 427 if (single_fields.fld_message_id->mid_value) {
505 // mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); 428 mail->setMsgid(QString(single_fields.fld_message_id->mid_value));
429 qDebug("Msqgid == %s",mail->Msgid().latin1());
430 }
506 refs = single_fields.fld_references; 431 refs = single_fields.fld_references;
507 if (refs && refs->mid_list && clist_count(refs->mid_list)) { 432 if (refs && refs->mid_list && clist_count(refs->mid_list)) {
508 char * text = (char*)refs->mid_list->first->data; 433 char * text = (char*)refs->mid_list->first->data;
509 mail->setReplyto(QString(text)); 434 mail->setReplyto(QString(text));
510 } 435 }
511 target.append(mail); 436 target.append(mail);
512 } 437 }
513 if (env_list) { 438 if (env_list) {
514 mailmessage_list_free(env_list); 439 mailmessage_list_free(env_list);
515 } 440 }
516} 441}
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h
index b451416..0870912 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.h
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.h
@@ -29,33 +29,32 @@ struct mailfolder;
29class Genericwrapper : public AbstractMail 29class Genericwrapper : public AbstractMail
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32public: 32public:
33 Genericwrapper(); 33 Genericwrapper();
34 virtual ~Genericwrapper(); 34 virtual ~Genericwrapper();
35 35
36 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); 36 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
37 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); 37 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
38 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); 38 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
39 virtual void cleanMimeCache(); 39 virtual void cleanMimeCache();
40 virtual int deleteMbox(const Folder*){return 1;} 40 virtual int deleteMbox(const Folder*){return 1;}
41 virtual void logout(){}; 41 virtual void logout(){};
42 virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; 42 virtual void storeMessage(const char*msg,size_t length, const QString&folder){};
43 43
44protected: 44protected:
45 RecMail *parseHeader( const char *header );
46 RecBody parseMail( mailmessage * msg ); 45 RecBody parseMail( mailmessage * msg );
47 QString parseMailboxList( mailimf_mailbox_list *list ); 46 QString parseMailboxList( mailimf_mailbox_list *list );
48 QString parseMailbox( mailimf_mailbox *box ); 47 QString parseMailbox( mailimf_mailbox *box );
49 QString parseGroup( mailimf_group *group ); 48 QString parseGroup( mailimf_group *group );
50 QString parseAddressList( mailimf_address_list *list ); 49 QString parseAddressList( mailimf_address_list *list );
51 QString parseDateTime( mailimf_date_time *date ); 50 QString parseDateTime( mailimf_date_time *date );
52 51
53 void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); 52 void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1);
54 static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); 53 static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime);
55 static void fillParameters(RecPart&target,clist*parameters); 54 static void fillParameters(RecPart&target,clist*parameters);
56 static QString getencoding(mailmime_mechanism*aEnc); 55 static QString getencoding(mailmime_mechanism*aEnc);
57 virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); 56 virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false);
58 57
59 QString msgTempName; 58 QString msgTempName;
60 unsigned int last_msg_id; 59 unsigned int last_msg_id;
61 QMap<QString,encodedString*> bodyCache; 60 QMap<QString,encodedString*> bodyCache;