summaryrefslogtreecommitdiff
authoralwin <alwin>2004-10-25 22:33:48 (UTC)
committer alwin <alwin>2004-10-25 22:33:48 (UTC)
commitd29de6d360b0570c12778beea9f654a8fcdbe3c7 (patch) (unidiff)
treeae0b3505b57e0fd47f353faf287408c354d3e6c6
parentef34b8716b06f2225d7cf76e22a7a72cf5b689df (diff)
downloadopie-d29de6d360b0570c12778beea9f654a8fcdbe3c7.zip
opie-d29de6d360b0570c12778beea9f654a8fcdbe3c7.tar.gz
opie-d29de6d360b0570c12778beea9f654a8fcdbe3c7.tar.bz2
moved out pure helper funs
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp13
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.h5
2 files changed, 4 insertions, 14 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,59 +1,59 @@
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;
36 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 36 memset(&fields, 0, sizeof(struct mailmime_single_fields));
37 if (mime->mm_mime_fields != NULL) { 37 if (mime->mm_mime_fields != NULL) {
38 mailmime_single_fields_init(&fields, mime->mm_mime_fields, 38 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
39 mime->mm_content_type); 39 mime->mm_content_type);
40 } 40 }
41 41
42 mailmime_content*type = fields.fld_content; 42 mailmime_content*type = fields.fld_content;
43 clistcell*current; 43 clistcell*current;
44 if (!type) { 44 if (!type) {
45 target->setType("text"); 45 target->setType("text");
46 target->setSubtype("plain"); 46 target->setSubtype("plain");
47 } else { 47 } else {
48 target->setSubtype(type->ct_subtype); 48 target->setSubtype(type->ct_subtype);
49 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { 49 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
50 case MAILMIME_DISCRETE_TYPE_TEXT: 50 case MAILMIME_DISCRETE_TYPE_TEXT:
51 target->setType("text"); 51 target->setType("text");
52 break; 52 break;
53 case MAILMIME_DISCRETE_TYPE_IMAGE: 53 case MAILMIME_DISCRETE_TYPE_IMAGE:
54 target->setType("image"); 54 target->setType("image");
55 break; 55 break;
56 case MAILMIME_DISCRETE_TYPE_AUDIO: 56 case MAILMIME_DISCRETE_TYPE_AUDIO:
57 target->setType("audio"); 57 target->setType("audio");
58 break; 58 break;
59 case MAILMIME_DISCRETE_TYPE_VIDEO: 59 case MAILMIME_DISCRETE_TYPE_VIDEO:
@@ -198,105 +198,96 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m
198 } 198 }
199 traverseBody(target,message, cbody,countlist,current_rec+1,ccount); 199 traverseBody(target,message, cbody,countlist,current_rec+1,ccount);
200 if (cbody->mm_type==MAILMIME_MULTIPLE) { 200 if (cbody->mm_type==MAILMIME_MULTIPLE) {
201 countlist = recList; 201 countlist = recList;
202 } 202 }
203 ++ccount; 203 ++ccount;
204 } 204 }
205 } 205 }
206 break; 206 break;
207 case MAILMIME_MESSAGE: 207 case MAILMIME_MESSAGE:
208 { 208 {
209 QValueList<int>countlist = recList; 209 QValueList<int>countlist = recList;
210 countlist.append(current_count); 210 countlist.append(current_count);
211 /* the own header is always at recursion 0 - we don't need that */ 211 /* the own header is always at recursion 0 - we don't need that */
212 if (current_rec > 0) { 212 if (current_rec > 0) {
213 part->setPositionlist(countlist); 213 part->setPositionlist(countlist);
214 r = mailmessage_fetch_section(message,mime,&data,&len); 214 r = mailmessage_fetch_section(message,mime,&data,&len);
215 part->setSize(len); 215 part->setSize(len);
216 part->setPositionlist(countlist); 216 part->setPositionlist(countlist);
217 b = gen_attachment_id(); 217 b = gen_attachment_id();
218 part->setIdentifier(b); 218 part->setIdentifier(b);
219 part->setType("message"); 219 part->setType("message");
220 part->setSubtype("rfc822"); 220 part->setSubtype("rfc822");
221 bodyCache[b]=new encodedString(data,len); 221 bodyCache[b]=new encodedString(data,len);
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;
279 break; 270 break;
280 } 271 }
281 } 272 }
282 273
283 return result; 274 return result;
284} 275}
285 276
286QString Genericwrapper::parseGroup( mailimf_group *group ) 277QString Genericwrapper::parseGroup( mailimf_group *group )
287{ 278{
288 QString result( "" ); 279 QString result( "" );
289 280
290 result.append( group->grp_display_name ); 281 result.append( group->grp_display_name );
291 result.append( ": " ); 282 result.append( ": " );
292 283
293 if ( group->grp_mb_list != NULL ) { 284 if ( group->grp_mb_list != NULL ) {
294 result.append( parseMailboxList( group->grp_mb_list ) ); 285 result.append( parseMailboxList( group->grp_mb_list ) );
295 } 286 }
296 287
297 result.append( ";" ); 288 result.append( ";" );
298 289
299 return result; 290 return result;
300} 291}
301 292
302QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) 293QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h
index 8be9212..3336556 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.h
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.h
@@ -1,67 +1,66 @@
1#ifndef __GENERIC_WRAPPER_H 1#ifndef __GENERIC_WRAPPER_H
2#define __GENERIC_WRAPPER_H 2#define __GENERIC_WRAPPER_H
3 3
4#include "abstractmail.h" 4#include "abstractmail.h"
5#include "mailstatics.h"
5#include <qmap.h> 6#include <qmap.h>
6#include <qstring.h> 7#include <qstring.h>
7#include <libetpan/clist.h> 8#include <libetpan/clist.h>
8 9
9class RecMail; 10class RecMail;
10class RecBody; 11class RecBody;
11class encodedString; 12class encodedString;
12struct mailpop3; 13struct mailpop3;
13struct mailmessage; 14struct mailmessage;
14struct mailmime; 15struct mailmime;
15struct mailmime_mechanism; 16struct mailmime_mechanism;
16struct mailimf_mailbox_list; 17struct mailimf_mailbox_list;
17struct mailimf_mailbox; 18struct mailimf_mailbox;
18struct mailimf_date_time;
19struct mailimf_group; 19struct mailimf_group;
20struct mailimf_address_list; 20struct mailimf_address_list;
21struct mailsession; 21struct mailsession;
22struct mailstorage; 22struct mailstorage;
23struct mailfolder; 23struct mailfolder;
24struct mailimf_in_reply_to; 24struct mailimf_in_reply_to;
25 25
26/* this class hold just the funs shared between 26/* this class hold just the funs shared between
27 * mbox and pop3 (later mh, too) mail access. 27 * mbox and pop3 (later mh, too) mail access.
28 * it is not desigend to make a instance of it! 28 * it is not desigend to make a instance of it!
29 */ 29 */
30class Genericwrapper : public AbstractMail 30class Genericwrapper : public AbstractMail,public MailStatics
31{ 31{
32 Q_OBJECT 32 Q_OBJECT
33public: 33public:
34 Genericwrapper(); 34 Genericwrapper();
35 virtual ~Genericwrapper(); 35 virtual ~Genericwrapper();
36 36
37 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part); 37 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part);
38 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part); 38 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part);
39 virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); 39 virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part);
40 virtual void cleanMimeCache(); 40 virtual void cleanMimeCache();
41 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} 41 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;}
42 virtual void logout(){}; 42 virtual void logout(){};
43 virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; 43 virtual void storeMessage(const char*msg,size_t length, const QString&folder){};
44 44
45protected: 45protected:
46 RecBodyP parseMail( mailmessage * msg ); 46 RecBodyP parseMail( mailmessage * msg );
47 QString parseMailboxList( mailimf_mailbox_list *list ); 47 QString parseMailboxList( mailimf_mailbox_list *list );
48 QString parseMailbox( mailimf_mailbox *box ); 48 QString parseMailbox( mailimf_mailbox *box );
49 QString parseGroup( mailimf_group *group ); 49 QString parseGroup( mailimf_group *group );
50 QString parseAddressList( mailimf_address_list *list ); 50 QString parseAddressList( mailimf_address_list *list );
51 QString parseDateTime( mailimf_date_time *date );
52 51
53 void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); 52 void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1);
54 static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime); 53 static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime);
55 static void fillParameters(RecPartP&target,clist*parameters); 54 static void fillParameters(RecPartP&target,clist*parameters);
56 static QString getencoding(mailmime_mechanism*aEnc); 55 static QString getencoding(mailmime_mechanism*aEnc);
57 virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); 56 virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false);
58 QStringList parseInreplies(mailimf_in_reply_to * in_replies); 57 QStringList parseInreplies(mailimf_in_reply_to * in_replies);
59 58
60 QString msgTempName; 59 QString msgTempName;
61 unsigned int last_msg_id; 60 unsigned int last_msg_id;
62 QMap<QString,encodedString*> bodyCache; 61 QMap<QString,encodedString*> bodyCache;
63 mailstorage * m_storage; 62 mailstorage * m_storage;
64 mailfolder*m_folder; 63 mailfolder*m_folder;
65}; 64};
66 65
67#endif 66#endif