summaryrefslogtreecommitdiff
authoralwin <alwin>2004-03-08 03:04:35 (UTC)
committer alwin <alwin>2004-03-08 03:04:35 (UTC)
commit25d95c1b4e61445c695177c79049ccf7741e83f7 (patch) (unidiff)
tree9f90bf01e587fcd6a9bf0b2c52da7ae98f4871f0
parent9553bf83fd98812781b5d15aad9b69daaadec3f5 (diff)
downloadopie-25d95c1b4e61445c695177c79049ccf7741e83f7.zip
opie-25d95c1b4e61445c695177c79049ccf7741e83f7.tar.gz
opie-25d95c1b4e61445c695177c79049ccf7741e83f7.tar.bz2
obsolete methode removed
store msgids when parsing a mail-header
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
@@ -217,125 +217,48 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi
217 target.addPart(part); 217 target.addPart(part);
218 } 218 }
219 if (mime->mm_data.mm_message.mm_msg_mime != NULL) { 219 if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
220 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); 220 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1);
221 } 221 }
222 } 222 }
223 break; 223 break;
224 } 224 }
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;
334 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 257 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
335 mailimf_address *addr = (mailimf_address *) current->data; 258 mailimf_address *addr = (mailimf_address *) current->data;
336 259
337 if ( !first ) { 260 if ( !first ) {
338 result.append( "," ); 261 result.append( "," );
339 } else { 262 } else {
340 first = false; 263 first = false;
341 } 264 }
@@ -479,38 +402,40 @@ void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const
479 mFlags.setBit(FLAG_SEEN); 402 mFlags.setBit(FLAG_SEEN);
480 } 403 }
481 mailimf_single_fields single_fields; 404 mailimf_single_fields single_fields;
482 mailimf_single_fields_init(&single_fields, msg->msg_fields); 405 mailimf_single_fields_init(&single_fields, msg->msg_fields);
483 mail->setMsgsize(msg->msg_size); 406 mail->setMsgsize(msg->msg_size);
484 mail->setFlags(mFlags); 407 mail->setFlags(mFlags);
485 mail->setMbox(mailbox); 408 mail->setMbox(mailbox);
486 mail->setNumber(msg->msg_index); 409 mail->setNumber(msg->msg_index);
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
@@ -21,46 +21,45 @@ struct mailimf_address_list;
21struct mailsession; 21struct mailsession;
22struct mailstorage; 22struct mailstorage;
23struct mailfolder; 23struct mailfolder;
24 24
25/* this class hold just the funs shared between 25/* this class hold just the funs shared between
26 * mbox and pop3 (later mh, too) mail access. 26 * mbox and pop3 (later mh, too) mail access.
27 * it is not desigend to make a instance of it! 27 * it is not desigend to make a instance of it!
28 */ 28 */
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;
62 mailstorage * m_storage; 61 mailstorage * m_storage;
63 mailfolder*m_folder; 62 mailfolder*m_folder;
64}; 63};
65 64
66#endif 65#endif