summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper/genericwrapper.cpp
authoralwin <alwin>2004-10-25 22:33:48 (UTC)
committer alwin <alwin>2004-10-25 22:33:48 (UTC)
commitd29de6d360b0570c12778beea9f654a8fcdbe3c7 (patch) (unidiff)
treeae0b3505b57e0fd47f353faf287408c354d3e6c6 /noncore/net/mail/libmailwrapper/genericwrapper.cpp
parentef34b8716b06f2225d7cf76e22a7a72cf5b689df (diff)
downloadopie-d29de6d360b0570c12778beea9f654a8fcdbe3c7.zip
opie-d29de6d360b0570c12778beea9f654a8fcdbe3c7.tar.gz
opie-d29de6d360b0570c12778beea9f654a8fcdbe3c7.tar.bz2
moved out pure helper funs
Diffstat (limited to 'noncore/net/mail/libmailwrapper/genericwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp13
1 files changed, 2 insertions, 11 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index 5ec9415..703235d 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -1,35 +1,35 @@
1#include "genericwrapper.h" 1#include "genericwrapper.h"
2#include <libetpan/libetpan.h> 2#include <libetpan/libetpan.h>
3#include "mailtypes.h" 3#include "mailtypes.h"
4#include "mailstatics.h"
4 5
5#include <opie2/odebug.h> 6#include <opie2/odebug.h>
6#include <qpe/timestring.h>
7#include <qdatetime.h> 7#include <qdatetime.h>
8 8
9using namespace Opie::Core; 9using namespace Opie::Core;
10Genericwrapper::Genericwrapper() 10Genericwrapper::Genericwrapper()
11 : AbstractMail() 11 : AbstractMail(),MailStatics()
12{ 12{
13 bodyCache.clear(); 13 bodyCache.clear();
14 m_storage = 0; 14 m_storage = 0;
15 m_folder = 0; 15 m_folder = 0;
16} 16}
17 17
18Genericwrapper::~Genericwrapper() 18Genericwrapper::~Genericwrapper()
19{ 19{
20 if (m_folder) { 20 if (m_folder) {
21 mailfolder_free(m_folder); 21 mailfolder_free(m_folder);
22 } 22 }
23 if (m_storage) { 23 if (m_storage) {
24 mailstorage_free(m_storage); 24 mailstorage_free(m_storage);
25 } 25 }
26 cleanMimeCache(); 26 cleanMimeCache();
27} 27}
28 28
29void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) 29void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime)
30{ 30{
31 if (!mime) { 31 if (!mime) {
32 return; 32 return;
33 } 33 }
34 mailmime_field*field = 0; 34 mailmime_field*field = 0;
35 mailmime_single_fields fields; 35 mailmime_single_fields fields;
@@ -222,57 +222,48 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m
222 target->addPart(part); 222 target->addPart(part);
223 } 223 }
224 if (mime->mm_data.mm_message.mm_msg_mime != NULL) { 224 if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
225 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); 225 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1);
226 } 226 }
227 } 227 }
228 break; 228 break;
229 } 229 }
230} 230}
231 231
232RecBodyP Genericwrapper::parseMail( mailmessage * msg ) 232RecBodyP Genericwrapper::parseMail( mailmessage * msg )
233{ 233{
234 int err = MAILIMF_NO_ERROR; 234 int err = MAILIMF_NO_ERROR;
235 mailmime_single_fields fields; 235 mailmime_single_fields fields;
236 /* is bound to msg and will be freed there */ 236 /* is bound to msg and will be freed there */
237 mailmime * mime=0; 237 mailmime * mime=0;
238 RecBodyP body = new RecBody(); 238 RecBodyP body = new RecBody();
239 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 239 memset(&fields, 0, sizeof(struct mailmime_single_fields));
240 err = mailmessage_get_bodystructure(msg,&mime); 240 err = mailmessage_get_bodystructure(msg,&mime);
241 QValueList<int>recList; 241 QValueList<int>recList;
242 traverseBody(body,msg,mime,recList); 242 traverseBody(body,msg,mime,recList);
243 return body; 243 return body;
244} 244}
245 245
246QString Genericwrapper::parseDateTime( mailimf_date_time *date )
247{
248 QDateTime da(QDate(date->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec));
249 QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" ";
250 timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" ";
251 timestring.sprintf(timestring+" %+05i",date->dt_zone);
252 return timestring;
253}
254
255QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 246QString Genericwrapper::parseAddressList( mailimf_address_list *list )
256{ 247{
257 QString result( "" ); 248 QString result( "" );
258 249
259 bool first = true; 250 bool first = true;
260 if (list == 0) return result; 251 if (list == 0) return result;
261 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 252 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
262 mailimf_address *addr = (mailimf_address *) current->data; 253 mailimf_address *addr = (mailimf_address *) current->data;
263 254
264 if ( !first ) { 255 if ( !first ) {
265 result.append( "," ); 256 result.append( "," );
266 } else { 257 } else {
267 first = false; 258 first = false;
268 } 259 }
269 260
270 switch ( addr->ad_type ) { 261 switch ( addr->ad_type ) {
271 case MAILIMF_ADDRESS_MAILBOX: 262 case MAILIMF_ADDRESS_MAILBOX:
272 result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); 263 result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
273 break; 264 break;
274 case MAILIMF_ADDRESS_GROUP: 265 case MAILIMF_ADDRESS_GROUP:
275 result.append( parseGroup( addr->ad_data.ad_group ) ); 266 result.append( parseGroup( addr->ad_data.ad_group ) );
276 break; 267 break;
277 default: 268 default:
278 odebug << "Generic: unkown mailimf address type" << oendl; 269 odebug << "Generic: unkown mailimf address type" << oendl;