Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
24 files changed, 223 insertions, 228 deletions
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 7e6d383..68a7a4d 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -72,25 +72,25 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin | |||
72 | &result_text,&target_length); | 72 | &result_text,&target_length); |
73 | 73 | ||
74 | encodedString* result = new encodedString(); | 74 | encodedString* result = new encodedString(); |
75 | if (err == MAILIMF_NO_ERROR) { | 75 | if (err == MAILIMF_NO_ERROR) { |
76 | result->setContent(result_text,target_length); | 76 | result->setContent(result_text,target_length); |
77 | } | 77 | } |
78 | qDebug("Decode string finished"); | 78 | qDebug("Decode string finished"); |
79 | return result; | 79 | return result; |
80 | } | 80 | } |
81 | 81 | ||
82 | QString AbstractMail::convert_String(const char*text) | 82 | QString AbstractMail::convert_String(const char*text) |
83 | { | 83 | { |
84 | size_t index = 0; | 84 | //size_t index = 0; |
85 | char*res = 0; | 85 | char*res = 0; |
86 | int err = MAILIMF_NO_ERROR; | 86 | int err = MAILIMF_NO_ERROR; |
87 | 87 | ||
88 | QString result(text); | 88 | QString result(text); |
89 | 89 | ||
90 | /* due a bug in libetpan it isn't usable this moment */ | 90 | /* due a bug in libetpan it isn't usable this moment */ |
91 | /* int err = mailmime_encoded_phrase_parse("iso-8859-1", | 91 | /* int err = mailmime_encoded_phrase_parse("iso-8859-1", |
92 | text, strlen(text),&index, "iso-8859-1",&res);*/ | 92 | text, strlen(text),&index, "iso-8859-1",&res);*/ |
93 | //qDebug("Input: %s",text); | 93 | //qDebug("Input: %s",text); |
94 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 94 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
95 | // result = QString(res); | 95 | // result = QString(res); |
96 | // qDebug("Res: %s, length: %i",res,strlen(res)); | 96 | // qDebug("Res: %s, length: %i",res,strlen(res)); |
@@ -102,66 +102,66 @@ QString AbstractMail::convert_String(const char*text) | |||
102 | /* cp & paste from launcher */ | 102 | /* cp & paste from launcher */ |
103 | QString AbstractMail::gen_attachment_id() | 103 | QString AbstractMail::gen_attachment_id() |
104 | { | 104 | { |
105 | QFile file( "/proc/sys/kernel/random/uuid" ); | 105 | QFile file( "/proc/sys/kernel/random/uuid" ); |
106 | if (!file.open(IO_ReadOnly ) ) | 106 | if (!file.open(IO_ReadOnly ) ) |
107 | return QString::null; | 107 | return QString::null; |
108 | 108 | ||
109 | QTextStream stream(&file); | 109 | QTextStream stream(&file); |
110 | 110 | ||
111 | return "{" + stream.read().stripWhiteSpace() + "}"; | 111 | return "{" + stream.read().stripWhiteSpace() + "}"; |
112 | } | 112 | } |
113 | 113 | ||
114 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& delemiter,bool) | 114 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) |
115 | { | 115 | { |
116 | return 0; | 116 | return 0; |
117 | } | 117 | } |
118 | 118 | ||
119 | QString AbstractMail::defaultLocalfolder() | 119 | QString AbstractMail::defaultLocalfolder() |
120 | { | 120 | { |
121 | QString f = getenv( "HOME" ); | 121 | QString f = getenv( "HOME" ); |
122 | f += "/Applications/opiemail/localmail"; | 122 | f += "/Applications/opiemail/localmail"; |
123 | return f; | 123 | return f; |
124 | } | 124 | } |
125 | 125 | ||
126 | QString AbstractMail::draftFolder() | 126 | QString AbstractMail::draftFolder() |
127 | { | 127 | { |
128 | return QString("Drafts"); | 128 | return QString("Drafts"); |
129 | } | 129 | } |
130 | 130 | ||
131 | /* temporary - will be removed when implemented in all classes */ | 131 | /* temporary - will be removed when implemented in all classes */ |
132 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) | 132 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::OSmartPointer<RecMail> > &) |
133 | { | 133 | { |
134 | } | 134 | } |
135 | 135 | ||
136 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 136 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
137 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 137 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
138 | { | 138 | { |
139 | QList<RecMail> t; | 139 | QValueList<RecMailP> t; |
140 | listMessages(fromFolder->getName(),t); | 140 | listMessages(fromFolder->getName(),t); |
141 | encodedString*st = 0; | 141 | encodedString*st = 0; |
142 | while (t.count()>0) { | 142 | while (t.count()>0) { |
143 | RecMail*r = t.at(0); | 143 | RecMailP r = (*t.begin()); |
144 | st = fetchRawBody(*r); | 144 | st = fetchRawBody(r); |
145 | if (st) { | 145 | if (st) { |
146 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 146 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
147 | delete st; | 147 | delete st; |
148 | } | 148 | } |
149 | t.removeFirst(); | 149 | t.remove(t.begin()); |
150 | } | 150 | } |
151 | if (moveit) { | 151 | if (moveit) { |
152 | deleteAllMail(fromFolder); | 152 | deleteAllMail(fromFolder); |
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
156 | void AbstractMail::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 156 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
157 | { | 157 | { |
158 | encodedString*st = 0; | 158 | encodedString*st = 0; |
159 | st = fetchRawBody(mail); | 159 | st = fetchRawBody(mail); |
160 | if (st) { | 160 | if (st) { |
161 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 161 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
162 | delete st; | 162 | delete st; |
163 | } | 163 | } |
164 | if (moveit) { | 164 | if (moveit) { |
165 | deleteMail(mail); | 165 | deleteMail(mail); |
166 | } | 166 | } |
167 | } | 167 | } |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index d911468..b03d757 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -1,64 +1,62 @@ | |||
1 | #ifndef __abstract_mail_ | 1 | #ifndef __abstract_mail_ |
2 | #define __abstract_mail_ | 2 | #define __abstract_mail_ |
3 | 3 | ||
4 | #include "maildefines.h" | 4 | #include "maildefines.h" |
5 | 5 | ||
6 | #include "settings.h" | 6 | #include "settings.h" |
7 | 7 | ||
8 | #include <qobject.h> | 8 | #include <qobject.h> |
9 | #include <opie2/osmart_pointer.h> | 9 | #include <opie2/osmartpointer.h> |
10 | #include "mailtypes.h" | ||
10 | 11 | ||
11 | class RecMail; | ||
12 | class RecBody; | ||
13 | class RecPart; | ||
14 | class IMAPwrapper; | 12 | class IMAPwrapper; |
15 | class POP3wrapper; | 13 | class POP3wrapper; |
16 | class Folder; | 14 | class Folder; |
17 | class encodedString; | 15 | class encodedString; |
18 | struct folderStat; | 16 | struct folderStat; |
19 | 17 | ||
20 | class AbstractMail:public QObject | 18 | class AbstractMail:public QObject |
21 | { | 19 | { |
22 | Q_OBJECT | 20 | Q_OBJECT |
23 | public: | 21 | public: |
24 | AbstractMail(){}; | 22 | AbstractMail(){}; |
25 | virtual ~AbstractMail(){} | 23 | virtual ~AbstractMail(){} |
26 | virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders()=0; | 24 | virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders()=0; |
27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 25 | virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target )=0; |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | 26 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; |
29 | virtual RecBody fetchBody(const RecMail&mail)=0; | 27 | virtual RecBody fetchBody(const RecMailP&mail)=0; |
30 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; | 28 | virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part)=0; |
31 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | 29 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part)=0; |
32 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | 30 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part)=0; |
33 | virtual encodedString* fetchRawBody(const RecMail&mail)=0; | 31 | virtual encodedString* fetchRawBody(const RecMailP&mail)=0; |
34 | 32 | ||
35 | virtual void deleteMail(const RecMail&mail)=0; | 33 | virtual void deleteMail(const RecMailP&mail)=0; |
36 | virtual void answeredMail(const RecMail&mail)=0; | 34 | virtual void answeredMail(const RecMailP&mail)=0; |
37 | virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&)=0; | 35 | virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&)=0; |
38 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); | 36 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::OSmartPointer<RecMail> >&target); |
39 | virtual int deleteMbox(const Opie::osmart_pointer<Folder>&)=0; | 37 | virtual int deleteMbox(const Opie::OSmartPointer<Folder>&)=0; |
40 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 38 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
41 | 39 | ||
42 | virtual void mvcpAllMails(const Opie::osmart_pointer<Folder>&fromFolder, | 40 | virtual void mvcpAllMails(const Opie::OSmartPointer<Folder>&fromFolder, |
43 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 41 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
44 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 42 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
45 | 43 | ||
46 | virtual void cleanMimeCache(){}; | 44 | virtual void cleanMimeCache(){}; |
47 | /* mail box methods */ | 45 | /* mail box methods */ |
48 | /* parameter is the box to create. | 46 | /* parameter is the box to create. |
49 | * if the implementing subclass has prefixes, | 47 | * if the implementing subclass has prefixes, |
50 | * them has to be appended automatic. | 48 | * them has to be appended automatic. |
51 | */ | 49 | */ |
52 | virtual int createMbox(const QString&,const Opie::osmart_pointer<Folder>&parentfolder=0, | 50 | virtual int createMbox(const QString&,const Opie::OSmartPointer<Folder>&parentfolder=0, |
53 | const QString& delemiter="/",bool getsubfolder=false); | 51 | const QString& delemiter="/",bool getsubfolder=false); |
54 | virtual void logout()=0; | 52 | virtual void logout()=0; |
55 | 53 | ||
56 | static AbstractMail* getWrapper(IMAPaccount *a); | 54 | static AbstractMail* getWrapper(IMAPaccount *a); |
57 | static AbstractMail* getWrapper(POP3account *a); | 55 | static AbstractMail* getWrapper(POP3account *a); |
58 | static AbstractMail* getWrapper(NNTPaccount *a); | 56 | static AbstractMail* getWrapper(NNTPaccount *a); |
59 | /* mbox only! */ | 57 | /* mbox only! */ |
60 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); | 58 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
61 | static AbstractMail* getWrapper(Account*a); | 59 | static AbstractMail* getWrapper(Account*a); |
62 | 60 | ||
63 | static QString defaultLocalfolder(); | 61 | static QString defaultLocalfolder(); |
64 | static QString draftFolder(); | 62 | static QString draftFolder(); |
diff --git a/noncore/net/mail/libmailwrapper/generatemail.cpp b/noncore/net/mail/libmailwrapper/generatemail.cpp index 4f7ec0c..cb7ccc0 100644 --- a/noncore/net/mail/libmailwrapper/generatemail.cpp +++ b/noncore/net/mail/libmailwrapper/generatemail.cpp | |||
@@ -270,25 +270,25 @@ err_free_param: | |||
270 | mailmime_parameter_free( param ); | 270 | mailmime_parameter_free( param ); |
271 | err_free: | 271 | err_free: |
272 | qDebug( "buildTxtPart - error" ); | 272 | qDebug( "buildTxtPart - error" ); |
273 | 273 | ||
274 | return NULL; // Error :( | 274 | return NULL; // Error :( |
275 | } | 275 | } |
276 | 276 | ||
277 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { | 277 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { |
278 | return mailimf_mailbox_new( strdup( name.latin1() ), | 278 | return mailimf_mailbox_new( strdup( name.latin1() ), |
279 | strdup( mail.latin1() ) ); | 279 | strdup( mail.latin1() ) ); |
280 | } | 280 | } |
281 | 281 | ||
282 | mailimf_fields *Generatemail::createImfFields(const Opie::osmart_pointer<Mail>&mail ) | 282 | mailimf_fields *Generatemail::createImfFields(const Opie::OSmartPointer<Mail>&mail ) |
283 | { | 283 | { |
284 | mailimf_fields *fields = NULL; | 284 | mailimf_fields *fields = NULL; |
285 | mailimf_field *xmailer = NULL; | 285 | mailimf_field *xmailer = NULL; |
286 | mailimf_mailbox *sender=0,*fromBox=0; | 286 | mailimf_mailbox *sender=0,*fromBox=0; |
287 | mailimf_mailbox_list *from=0; | 287 | mailimf_mailbox_list *from=0; |
288 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; | 288 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; |
289 | clist*in_reply_to = 0; | 289 | clist*in_reply_to = 0; |
290 | char *subject = strdup( mail->getSubject().latin1() ); | 290 | char *subject = strdup( mail->getSubject().latin1() ); |
291 | int err; | 291 | int err; |
292 | int res = 1; | 292 | int res = 1; |
293 | 293 | ||
294 | sender = newMailbox( mail->getName(), mail->getMail() ); | 294 | sender = newMailbox( mail->getName(), mail->getMail() ); |
@@ -390,25 +390,25 @@ mailimf_fields *Generatemail::createImfFields(const Opie::osmart_pointer<Mail>&m | |||
390 | } | 390 | } |
391 | if (sender) { | 391 | if (sender) { |
392 | mailimf_mailbox_free( sender ); | 392 | mailimf_mailbox_free( sender ); |
393 | } | 393 | } |
394 | if (subject) { | 394 | if (subject) { |
395 | free( subject ); | 395 | free( subject ); |
396 | } | 396 | } |
397 | } | 397 | } |
398 | } | 398 | } |
399 | return fields; | 399 | return fields; |
400 | } | 400 | } |
401 | 401 | ||
402 | mailmime *Generatemail::createMimeMail(const Opie::osmart_pointer<Mail> &mail ) { | 402 | mailmime *Generatemail::createMimeMail(const Opie::OSmartPointer<Mail> &mail ) { |
403 | mailmime *message, *txtPart; | 403 | mailmime *message, *txtPart; |
404 | mailimf_fields *fields; | 404 | mailimf_fields *fields; |
405 | int err; | 405 | int err; |
406 | 406 | ||
407 | fields = createImfFields( mail ); | 407 | fields = createImfFields( mail ); |
408 | if ( fields == NULL ) | 408 | if ( fields == NULL ) |
409 | goto err_free; | 409 | goto err_free; |
410 | 410 | ||
411 | message = mailmime_new_message_data( NULL ); | 411 | message = mailmime_new_message_data( NULL ); |
412 | if ( message == NULL ) | 412 | if ( message == NULL ) |
413 | goto err_free_fields; | 413 | goto err_free_fields; |
414 | 414 | ||
diff --git a/noncore/net/mail/libmailwrapper/generatemail.h b/noncore/net/mail/libmailwrapper/generatemail.h index 409a55e..c246a2a 100644 --- a/noncore/net/mail/libmailwrapper/generatemail.h +++ b/noncore/net/mail/libmailwrapper/generatemail.h | |||
@@ -1,21 +1,21 @@ | |||
1 | #ifndef __GENERATE_MAIL_H | 1 | #ifndef __GENERATE_MAIL_H |
2 | #define __GENERATE_MAIL_H | 2 | #define __GENERATE_MAIL_H |
3 | 3 | ||
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | 5 | ||
6 | #include <qobject.h> | 6 | #include <qobject.h> |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | #include <opie2/osmart_pointer.h> | 9 | #include <opie2/osmartpointer.h> |
10 | 10 | ||
11 | class Mail; | 11 | class Mail; |
12 | class RecMail; | 12 | class RecMail; |
13 | class Attachment; | 13 | class Attachment; |
14 | struct mailimf_fields; | 14 | struct mailimf_fields; |
15 | struct mailimf_field; | 15 | struct mailimf_field; |
16 | struct mailimf_mailbox; | 16 | struct mailimf_mailbox; |
17 | struct mailmime; | 17 | struct mailmime; |
18 | struct mailimf_address_list; | 18 | struct mailimf_address_list; |
19 | class progressMailSend; | 19 | class progressMailSend; |
20 | struct mailsmtp; | 20 | struct mailsmtp; |
21 | 21 | ||
@@ -27,20 +27,20 @@ public: | |||
27 | virtual ~Generatemail(); | 27 | virtual ~Generatemail(); |
28 | 28 | ||
29 | protected: | 29 | protected: |
30 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); | 30 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); |
31 | static char *getFrom( mailmime *mail ); | 31 | static char *getFrom( mailmime *mail ); |
32 | static char *getFrom( mailimf_field *ffrom); | 32 | static char *getFrom( mailimf_field *ffrom); |
33 | static mailimf_field *getField( mailimf_fields *fields, int type ); | 33 | static mailimf_field *getField( mailimf_fields *fields, int type ); |
34 | mailimf_address_list *parseAddresses(const QString&addr ); | 34 | mailimf_address_list *parseAddresses(const QString&addr ); |
35 | void addFileParts( mailmime *message,const QList<Attachment>&files ); | 35 | void addFileParts( mailmime *message,const QList<Attachment>&files ); |
36 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); | 36 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); |
37 | mailmime *buildTxtPart(const QString&str ); | 37 | mailmime *buildTxtPart(const QString&str ); |
38 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); | 38 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); |
39 | mailimf_fields *createImfFields(const Opie::osmart_pointer<Mail> &mail ); | 39 | mailimf_fields *createImfFields(const Opie::OSmartPointer<Mail> &mail ); |
40 | mailmime *createMimeMail(const Opie::osmart_pointer<Mail>&mail ); | 40 | mailmime *createMimeMail(const Opie::OSmartPointer<Mail>&mail ); |
41 | clist *createRcptList( mailimf_fields *fields ); | 41 | clist *createRcptList( mailimf_fields *fields ); |
42 | 42 | ||
43 | static const char* USER_AGENT; | 43 | static const char* USER_AGENT; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | #endif | 46 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index 6c8a5a1..ee2c8cd 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -322,41 +322,41 @@ QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | |||
322 | if ( !first ) { | 322 | if ( !first ) { |
323 | result.append( "," ); | 323 | result.append( "," ); |
324 | } else { | 324 | } else { |
325 | first = false; | 325 | first = false; |
326 | } | 326 | } |
327 | 327 | ||
328 | result.append( parseMailbox( box ) ); | 328 | result.append( parseMailbox( box ) ); |
329 | } | 329 | } |
330 | 330 | ||
331 | return result; | 331 | return result; |
332 | } | 332 | } |
333 | 333 | ||
334 | encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part) | 334 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPart&part) |
335 | { | 335 | { |
336 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); | 336 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); |
337 | if (it==bodyCache.end()) return new encodedString(); | 337 | if (it==bodyCache.end()) return new encodedString(); |
338 | encodedString*t = decode_String(it.data(),part.Encoding()); | 338 | encodedString*t = decode_String(it.data(),part.Encoding()); |
339 | return t; | 339 | return t; |
340 | } | 340 | } |
341 | 341 | ||
342 | encodedString* Genericwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | 342 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part) |
343 | { | 343 | { |
344 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); | 344 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); |
345 | if (it==bodyCache.end()) return new encodedString(); | 345 | if (it==bodyCache.end()) return new encodedString(); |
346 | encodedString*t = it.data(); | 346 | encodedString*t = it.data(); |
347 | return t; | 347 | return t; |
348 | } | 348 | } |
349 | 349 | ||
350 | QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | 350 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part) |
351 | { | 351 | { |
352 | encodedString*t = fetchDecodedPart(mail,part); | 352 | encodedString*t = fetchDecodedPart(mail,part); |
353 | QString text=t->Content(); | 353 | QString text=t->Content(); |
354 | delete t; | 354 | delete t; |
355 | return text; | 355 | return text; |
356 | } | 356 | } |
357 | 357 | ||
358 | void Genericwrapper::cleanMimeCache() | 358 | void Genericwrapper::cleanMimeCache() |
359 | { | 359 | { |
360 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); | 360 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); |
361 | for (;it!=bodyCache.end();++it) { | 361 | for (;it!=bodyCache.end();++it) { |
362 | encodedString*t = it.data(); | 362 | encodedString*t = it.data(); |
@@ -378,25 +378,25 @@ QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | |||
378 | h.remove(0,1); | 378 | h.remove(0,1); |
379 | } | 379 | } |
380 | while (h.length()>0 && h[h.length()-1]=='>') { | 380 | while (h.length()>0 && h[h.length()-1]=='>') { |
381 | h.remove(h.length()-1,1); | 381 | h.remove(h.length()-1,1); |
382 | } | 382 | } |
383 | if (h.length()>0) { | 383 | if (h.length()>0) { |
384 | res.append(h); | 384 | res.append(h); |
385 | } | 385 | } |
386 | } | 386 | } |
387 | return res; | 387 | return res; |
388 | } | 388 | } |
389 | 389 | ||
390 | void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to) | 390 | void Genericwrapper::parseList(QValueList<Opie::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) |
391 | { | 391 | { |
392 | int r; | 392 | int r; |
393 | mailmessage_list * env_list = 0; | 393 | mailmessage_list * env_list = 0; |
394 | r = mailsession_get_messages_list(session,&env_list); | 394 | r = mailsession_get_messages_list(session,&env_list); |
395 | if (r != MAIL_NO_ERROR) { | 395 | if (r != MAIL_NO_ERROR) { |
396 | qDebug("Error message list"); | 396 | qDebug("Error message list"); |
397 | return; | 397 | return; |
398 | } | 398 | } |
399 | r = mailsession_get_envelopes_list(session, env_list); | 399 | r = mailsession_get_envelopes_list(session, env_list); |
400 | if (r != MAIL_NO_ERROR) { | 400 | if (r != MAIL_NO_ERROR) { |
401 | qDebug("Error filling message list"); | 401 | qDebug("Error filling message list"); |
402 | if (env_list) { | 402 | if (env_list) { |
@@ -406,25 +406,25 @@ void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const | |||
406 | } | 406 | } |
407 | mailimf_references * refs = 0; | 407 | mailimf_references * refs = 0; |
408 | mailimf_in_reply_to * in_replies = 0; | 408 | mailimf_in_reply_to * in_replies = 0; |
409 | uint32_t i = 0; | 409 | uint32_t i = 0; |
410 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 410 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
411 | mailmessage * msg; | 411 | mailmessage * msg; |
412 | QBitArray mFlags(7); | 412 | QBitArray mFlags(7); |
413 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 413 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
414 | if (msg->msg_fields == NULL) { | 414 | if (msg->msg_fields == NULL) { |
415 | //qDebug("could not fetch envelope of message %i", i); | 415 | //qDebug("could not fetch envelope of message %i", i); |
416 | continue; | 416 | continue; |
417 | } | 417 | } |
418 | RecMail * mail = new RecMail(); | 418 | RecMailP mail = new RecMail(); |
419 | mail->setWrapper(this); | 419 | mail->setWrapper(this); |
420 | mail_flags * flag_result = 0; | 420 | mail_flags * flag_result = 0; |
421 | r = mailmessage_get_flags(msg,&flag_result); | 421 | r = mailmessage_get_flags(msg,&flag_result); |
422 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 422 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
423 | mFlags.setBit(FLAG_SEEN); | 423 | mFlags.setBit(FLAG_SEEN); |
424 | } | 424 | } |
425 | mailimf_single_fields single_fields; | 425 | mailimf_single_fields single_fields; |
426 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 426 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
427 | mail->setMsgsize(msg->msg_size); | 427 | mail->setMsgsize(msg->msg_size); |
428 | mail->setFlags(mFlags); | 428 | mail->setFlags(mFlags); |
429 | mail->setMbox(mailbox); | 429 | mail->setMbox(mailbox); |
430 | mail->setNumber(msg->msg_index); | 430 | mail->setNumber(msg->msg_index); |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h index d0db45a..f9968d1 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.h +++ b/noncore/net/mail/libmailwrapper/genericwrapper.h | |||
@@ -25,43 +25,43 @@ struct 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 | */ |
30 | class Genericwrapper : public AbstractMail | 30 | class Genericwrapper : public AbstractMail |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | Genericwrapper(); | 34 | Genericwrapper(); |
35 | virtual ~Genericwrapper(); | 35 | virtual ~Genericwrapper(); |
36 | 36 | ||
37 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 37 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part); |
38 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 38 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part); |
39 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 39 | virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part); |
40 | virtual void cleanMimeCache(); | 40 | virtual void cleanMimeCache(); |
41 | virtual int deleteMbox(const Opie::osmart_pointer<Folder>&){return 1;} | 41 | virtual int deleteMbox(const Opie::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 | ||
45 | protected: | 45 | protected: |
46 | RecBody parseMail( mailmessage * msg ); | 46 | RecBody 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 ); | 51 | QString parseDateTime( mailimf_date_time *date ); |
52 | 52 | ||
53 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); | 53 | 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); | 54 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); |
55 | static void fillParameters(RecPart&target,clist*parameters); | 55 | static void fillParameters(RecPart&target,clist*parameters); |
56 | static QString getencoding(mailmime_mechanism*aEnc); | 56 | static QString getencoding(mailmime_mechanism*aEnc); |
57 | virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); | 57 | virtual void parseList(QValueList<Opie::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); |
58 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); | 58 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); |
59 | 59 | ||
60 | QString msgTempName; | 60 | QString msgTempName; |
61 | unsigned int last_msg_id; | 61 | unsigned int last_msg_id; |
62 | QMap<QString,encodedString*> bodyCache; | 62 | QMap<QString,encodedString*> bodyCache; |
63 | mailstorage * m_storage; | 63 | mailstorage * m_storage; |
64 | mailfolder*m_folder; | 64 | mailfolder*m_folder; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | #endif | 67 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 3b3be0f..071e734 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -196,25 +196,25 @@ void IMAPwrapper::login() | |||
196 | 196 | ||
197 | void IMAPwrapper::logout() | 197 | void IMAPwrapper::logout() |
198 | { | 198 | { |
199 | int err = MAILIMAP_NO_ERROR; | 199 | int err = MAILIMAP_NO_ERROR; |
200 | if (!m_imap) return; | 200 | if (!m_imap) return; |
201 | err = mailimap_logout( m_imap ); | 201 | err = mailimap_logout( m_imap ); |
202 | err = mailimap_close( m_imap ); | 202 | err = mailimap_close( m_imap ); |
203 | mailimap_free( m_imap ); | 203 | mailimap_free( m_imap ); |
204 | m_imap = 0; | 204 | m_imap = 0; |
205 | m_Lastmbox = ""; | 205 | m_Lastmbox = ""; |
206 | } | 206 | } |
207 | 207 | ||
208 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | 208 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::OSmartPointer<RecMail> > &target ) |
209 | { | 209 | { |
210 | int err = MAILIMAP_NO_ERROR; | 210 | int err = MAILIMAP_NO_ERROR; |
211 | clist *result = 0; | 211 | clist *result = 0; |
212 | clistcell *current; | 212 | clistcell *current; |
213 | mailimap_fetch_type *fetchType = 0; | 213 | mailimap_fetch_type *fetchType = 0; |
214 | mailimap_set *set = 0; | 214 | mailimap_set *set = 0; |
215 | 215 | ||
216 | login(); | 216 | login(); |
217 | if (!m_imap) { | 217 | if (!m_imap) { |
218 | return; | 218 | return; |
219 | } | 219 | } |
220 | /* select mailbox READONLY for operations */ | 220 | /* select mailbox READONLY for operations */ |
@@ -257,25 +257,25 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
257 | m->setMbox(mailbox); | 257 | m->setMbox(mailbox); |
258 | m->setWrapper(this); | 258 | m->setWrapper(this); |
259 | target.append(m); | 259 | target.append(m); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | 262 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); |
263 | } else { | 263 | } else { |
264 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 264 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); |
265 | } | 265 | } |
266 | if (result) mailimap_fetch_list_free(result); | 266 | if (result) mailimap_fetch_list_free(result); |
267 | } | 267 | } |
268 | 268 | ||
269 | QValueList<Opie::osmart_pointer<Folder> >* IMAPwrapper::listFolders() | 269 | QValueList<Opie::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
270 | { | 270 | { |
271 | const char *path, *mask; | 271 | const char *path, *mask; |
272 | int err = MAILIMAP_NO_ERROR; | 272 | int err = MAILIMAP_NO_ERROR; |
273 | clist *result = 0; | 273 | clist *result = 0; |
274 | clistcell *current = 0; | 274 | clistcell *current = 0; |
275 | clistcell*cur_flag = 0; | 275 | clistcell*cur_flag = 0; |
276 | mailimap_mbx_list_flags*bflags = 0; | 276 | mailimap_mbx_list_flags*bflags = 0; |
277 | 277 | ||
278 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 278 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
279 | login(); | 279 | login(); |
280 | if (!m_imap) { | 280 | if (!m_imap) { |
281 | return folders; | 281 | return folders; |
@@ -473,49 +473,49 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
473 | /* msg is already deleted */ | 473 | /* msg is already deleted */ |
474 | if (mFlags.testBit(FLAG_DELETED) && m) { | 474 | if (mFlags.testBit(FLAG_DELETED) && m) { |
475 | delete m; | 475 | delete m; |
476 | m = 0; | 476 | m = 0; |
477 | } | 477 | } |
478 | if (m) { | 478 | if (m) { |
479 | m->setFlags(mFlags); | 479 | m->setFlags(mFlags); |
480 | m->setMsgsize(size); | 480 | m->setMsgsize(size); |
481 | } | 481 | } |
482 | return m; | 482 | return m; |
483 | } | 483 | } |
484 | 484 | ||
485 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 485 | RecBody IMAPwrapper::fetchBody(const RecMailP&mail) |
486 | { | 486 | { |
487 | RecBody body; | 487 | RecBody body; |
488 | const char *mb; | 488 | const char *mb; |
489 | int err = MAILIMAP_NO_ERROR; | 489 | int err = MAILIMAP_NO_ERROR; |
490 | clist *result = 0; | 490 | clist *result = 0; |
491 | clistcell *current; | 491 | clistcell *current; |
492 | mailimap_fetch_att *fetchAtt = 0; | 492 | mailimap_fetch_att *fetchAtt = 0; |
493 | mailimap_fetch_type *fetchType = 0; | 493 | mailimap_fetch_type *fetchType = 0; |
494 | mailimap_set *set = 0; | 494 | mailimap_set *set = 0; |
495 | mailimap_body*body_desc = 0; | 495 | mailimap_body*body_desc = 0; |
496 | 496 | ||
497 | mb = mail.getMbox().latin1(); | 497 | mb = mail->getMbox().latin1(); |
498 | 498 | ||
499 | login(); | 499 | login(); |
500 | if (!m_imap) { | 500 | if (!m_imap) { |
501 | return body; | 501 | return body; |
502 | } | 502 | } |
503 | err = selectMbox(mail.getMbox()); | 503 | err = selectMbox(mail->getMbox()); |
504 | if ( err != MAILIMAP_NO_ERROR ) { | 504 | if ( err != MAILIMAP_NO_ERROR ) { |
505 | return body; | 505 | return body; |
506 | } | 506 | } |
507 | 507 | ||
508 | /* the range has to start at 1!!! not with 0!!!! */ | 508 | /* the range has to start at 1!!! not with 0!!!! */ |
509 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 509 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
510 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 510 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
511 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 511 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
512 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 512 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
513 | mailimap_set_free( set ); | 513 | mailimap_set_free( set ); |
514 | mailimap_fetch_type_free( fetchType ); | 514 | mailimap_fetch_type_free( fetchType ); |
515 | 515 | ||
516 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 516 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
517 | mailimap_msg_att * msg_att; | 517 | mailimap_msg_att * msg_att; |
518 | msg_att = (mailimap_msg_att*)current->data; | 518 | msg_att = (mailimap_msg_att*)current->data; |
519 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 519 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
520 | QValueList<int> path; | 520 | QValueList<int> path; |
521 | body_desc = item->att_data.att_static->att_data.att_body; | 521 | body_desc = item->att_data.att_static->att_data.att_body; |
@@ -559,47 +559,47 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
559 | } | 559 | } |
560 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 560 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
561 | from+=">"; | 561 | from+=">"; |
562 | } | 562 | } |
563 | l.append(QString(from)); | 563 | l.append(QString(from)); |
564 | if (++count > 99) { | 564 | if (++count > 99) { |
565 | break; | 565 | break; |
566 | } | 566 | } |
567 | } | 567 | } |
568 | return l; | 568 | return l; |
569 | } | 569 | } |
570 | 570 | ||
571 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) | 571 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
572 | { | 572 | { |
573 | encodedString*res=new encodedString; | 573 | encodedString*res=new encodedString; |
574 | int err; | 574 | int err; |
575 | mailimap_fetch_type *fetchType; | 575 | mailimap_fetch_type *fetchType; |
576 | mailimap_set *set; | 576 | mailimap_set *set; |
577 | clistcell*current,*cur; | 577 | clistcell*current,*cur; |
578 | mailimap_section_part * section_part = 0; | 578 | mailimap_section_part * section_part = 0; |
579 | mailimap_section_spec * section_spec = 0; | 579 | mailimap_section_spec * section_spec = 0; |
580 | mailimap_section * section = 0; | 580 | mailimap_section * section = 0; |
581 | mailimap_fetch_att * fetch_att = 0; | 581 | mailimap_fetch_att * fetch_att = 0; |
582 | 582 | ||
583 | login(); | 583 | login(); |
584 | if (!m_imap) { | 584 | if (!m_imap) { |
585 | return res; | 585 | return res; |
586 | } | 586 | } |
587 | if (!internal_call) { | 587 | if (!internal_call) { |
588 | err = selectMbox(mail.getMbox()); | 588 | err = selectMbox(mail->getMbox()); |
589 | if ( err != MAILIMAP_NO_ERROR ) { | 589 | if ( err != MAILIMAP_NO_ERROR ) { |
590 | return res; | 590 | return res; |
591 | } | 591 | } |
592 | } | 592 | } |
593 | set = mailimap_set_new_single(mail.getNumber()); | 593 | set = mailimap_set_new_single(mail->getNumber()); |
594 | 594 | ||
595 | clist*id_list = 0; | 595 | clist*id_list = 0; |
596 | 596 | ||
597 | /* if path == empty then its a request for the whole rfc822 mail and generates | 597 | /* if path == empty then its a request for the whole rfc822 mail and generates |
598 | a "fetch <id> (body[])" statement on imap server */ | 598 | a "fetch <id> (body[])" statement on imap server */ |
599 | if (path.count()>0 ) { | 599 | if (path.count()>0 ) { |
600 | id_list = clist_new(); | 600 | id_list = clist_new(); |
601 | for (unsigned j=0; j < path.count();++j) { | 601 | for (unsigned j=0; j < path.count();++j) { |
602 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 602 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
603 | *p_id = path[j]; | 603 | *p_id = path[j]; |
604 | clist_append(id_list,p_id); | 604 | clist_append(id_list,p_id); |
605 | } | 605 | } |
@@ -632,25 +632,25 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> | |||
632 | } | 632 | } |
633 | } | 633 | } |
634 | } | 634 | } |
635 | } else { | 635 | } else { |
636 | qDebug("error fetching text: %s",m_imap->imap_response); | 636 | qDebug("error fetching text: %s",m_imap->imap_response); |
637 | } | 637 | } |
638 | if (result) mailimap_fetch_list_free(result); | 638 | if (result) mailimap_fetch_list_free(result); |
639 | return res; | 639 | return res; |
640 | } | 640 | } |
641 | 641 | ||
642 | /* current_recursion is for recursive calls. | 642 | /* current_recursion is for recursive calls. |
643 | current_count means the position inside the internal loop! */ | 643 | current_count means the position inside the internal loop! */ |
644 | void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, | 644 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body, |
645 | int current_recursion,QValueList<int>recList,int current_count) | 645 | int current_recursion,QValueList<int>recList,int current_count) |
646 | { | 646 | { |
647 | if (!body || current_recursion>=10) { | 647 | if (!body || current_recursion>=10) { |
648 | return; | 648 | return; |
649 | } | 649 | } |
650 | switch (body->bd_type) { | 650 | switch (body->bd_type) { |
651 | case MAILIMAP_BODY_1PART: | 651 | case MAILIMAP_BODY_1PART: |
652 | { | 652 | { |
653 | QValueList<int>countlist = recList; | 653 | QValueList<int>countlist = recList; |
654 | countlist.append(current_count); | 654 | countlist.append(current_count); |
655 | RecPart currentPart; | 655 | RecPart currentPart; |
656 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 656 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
@@ -860,116 +860,116 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
860 | encoding=QString(enc->enc_value); | 860 | encoding=QString(enc->enc_value); |
861 | enc->enc_value=0L; | 861 | enc->enc_value=0L; |
862 | free(t); | 862 | free(t); |
863 | } | 863 | } |
864 | } | 864 | } |
865 | if (which->bd_description) { | 865 | if (which->bd_description) { |
866 | target_part.setDescription(QString(which->bd_description)); | 866 | target_part.setDescription(QString(which->bd_description)); |
867 | } | 867 | } |
868 | target_part.setEncoding(encoding); | 868 | target_part.setEncoding(encoding); |
869 | target_part.setSize(which->bd_size); | 869 | target_part.setSize(which->bd_size); |
870 | } | 870 | } |
871 | 871 | ||
872 | void IMAPwrapper::deleteMail(const RecMail&mail) | 872 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
873 | { | 873 | { |
874 | mailimap_flag_list*flist; | 874 | mailimap_flag_list*flist; |
875 | mailimap_set *set; | 875 | mailimap_set *set; |
876 | mailimap_store_att_flags * store_flags; | 876 | mailimap_store_att_flags * store_flags; |
877 | int err; | 877 | int err; |
878 | login(); | 878 | login(); |
879 | if (!m_imap) { | 879 | if (!m_imap) { |
880 | return; | 880 | return; |
881 | } | 881 | } |
882 | err = selectMbox(mail.getMbox()); | 882 | err = selectMbox(mail->getMbox()); |
883 | if ( err != MAILIMAP_NO_ERROR ) { | 883 | if ( err != MAILIMAP_NO_ERROR ) { |
884 | return; | 884 | return; |
885 | } | 885 | } |
886 | flist = mailimap_flag_list_new_empty(); | 886 | flist = mailimap_flag_list_new_empty(); |
887 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 887 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
888 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 888 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
889 | set = mailimap_set_new_single(mail.getNumber()); | 889 | set = mailimap_set_new_single(mail->getNumber()); |
890 | err = mailimap_store(m_imap,set,store_flags); | 890 | err = mailimap_store(m_imap,set,store_flags); |
891 | mailimap_set_free( set ); | 891 | mailimap_set_free( set ); |
892 | mailimap_store_att_flags_free(store_flags); | 892 | mailimap_store_att_flags_free(store_flags); |
893 | 893 | ||
894 | if (err != MAILIMAP_NO_ERROR) { | 894 | if (err != MAILIMAP_NO_ERROR) { |
895 | qDebug("error deleting mail: %s",m_imap->imap_response); | 895 | qDebug("error deleting mail: %s",m_imap->imap_response); |
896 | return; | 896 | return; |
897 | } | 897 | } |
898 | qDebug("deleting mail: %s",m_imap->imap_response); | 898 | qDebug("deleting mail: %s",m_imap->imap_response); |
899 | /* should we realy do that at this moment? */ | 899 | /* should we realy do that at this moment? */ |
900 | err = mailimap_expunge(m_imap); | 900 | err = mailimap_expunge(m_imap); |
901 | if (err != MAILIMAP_NO_ERROR) { | 901 | if (err != MAILIMAP_NO_ERROR) { |
902 | qDebug("error deleting mail: %s",m_imap->imap_response); | 902 | qDebug("error deleting mail: %s",m_imap->imap_response); |
903 | } | 903 | } |
904 | qDebug("Delete successfull %s",m_imap->imap_response); | 904 | qDebug("Delete successfull %s",m_imap->imap_response); |
905 | } | 905 | } |
906 | 906 | ||
907 | void IMAPwrapper::answeredMail(const RecMail&mail) | 907 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
908 | { | 908 | { |
909 | mailimap_flag_list*flist; | 909 | mailimap_flag_list*flist; |
910 | mailimap_set *set; | 910 | mailimap_set *set; |
911 | mailimap_store_att_flags * store_flags; | 911 | mailimap_store_att_flags * store_flags; |
912 | int err; | 912 | int err; |
913 | login(); | 913 | login(); |
914 | if (!m_imap) { | 914 | if (!m_imap) { |
915 | return; | 915 | return; |
916 | } | 916 | } |
917 | err = selectMbox(mail.getMbox()); | 917 | err = selectMbox(mail->getMbox()); |
918 | if ( err != MAILIMAP_NO_ERROR ) { | 918 | if ( err != MAILIMAP_NO_ERROR ) { |
919 | return; | 919 | return; |
920 | } | 920 | } |
921 | flist = mailimap_flag_list_new_empty(); | 921 | flist = mailimap_flag_list_new_empty(); |
922 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 922 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
923 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 923 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
924 | set = mailimap_set_new_single(mail.getNumber()); | 924 | set = mailimap_set_new_single(mail->getNumber()); |
925 | err = mailimap_store(m_imap,set,store_flags); | 925 | err = mailimap_store(m_imap,set,store_flags); |
926 | mailimap_set_free( set ); | 926 | mailimap_set_free( set ); |
927 | mailimap_store_att_flags_free(store_flags); | 927 | mailimap_store_att_flags_free(store_flags); |
928 | 928 | ||
929 | if (err != MAILIMAP_NO_ERROR) { | 929 | if (err != MAILIMAP_NO_ERROR) { |
930 | qDebug("error marking mail: %s",m_imap->imap_response); | 930 | qDebug("error marking mail: %s",m_imap->imap_response); |
931 | return; | 931 | return; |
932 | } | 932 | } |
933 | } | 933 | } |
934 | 934 | ||
935 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 935 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
936 | { | 936 | { |
937 | QString body(""); | 937 | QString body(""); |
938 | encodedString*res = fetchRawPart(mail,path,internal_call); | 938 | encodedString*res = fetchRawPart(mail,path,internal_call); |
939 | encodedString*r = decode_String(res,enc); | 939 | encodedString*r = decode_String(res,enc); |
940 | delete res; | 940 | delete res; |
941 | if (r) { | 941 | if (r) { |
942 | if (r->Length()>0) { | 942 | if (r->Length()>0) { |
943 | body = r->Content(); | 943 | body = r->Content(); |
944 | } | 944 | } |
945 | delete r; | 945 | delete r; |
946 | } | 946 | } |
947 | return body; | 947 | return body; |
948 | } | 948 | } |
949 | 949 | ||
950 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | 950 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part) |
951 | { | 951 | { |
952 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); | 952 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); |
953 | } | 953 | } |
954 | 954 | ||
955 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) | 955 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPart&part) |
956 | { | 956 | { |
957 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); | 957 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); |
958 | encodedString*r = decode_String(res,part.Encoding()); | 958 | encodedString*r = decode_String(res,part.Encoding()); |
959 | delete res; | 959 | delete res; |
960 | return r; | 960 | return r; |
961 | } | 961 | } |
962 | 962 | ||
963 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | 963 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part) |
964 | { | 964 | { |
965 | return fetchRawPart(mail,part.Positionlist(),false); | 965 | return fetchRawPart(mail,part.Positionlist(),false); |
966 | } | 966 | } |
967 | 967 | ||
968 | int IMAPwrapper::deleteAllMail(const FolderP&folder) | 968 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
969 | { | 969 | { |
970 | login(); | 970 | login(); |
971 | if (!m_imap) { | 971 | if (!m_imap) { |
972 | return 0; | 972 | return 0; |
973 | } | 973 | } |
974 | mailimap_flag_list*flist; | 974 | mailimap_flag_list*flist; |
975 | mailimap_set *set; | 975 | mailimap_set *set; |
@@ -1046,25 +1046,24 @@ int IMAPwrapper::deleteMbox(const FolderP&folder) | |||
1046 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1046 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1047 | return 0; | 1047 | return 0; |
1048 | } | 1048 | } |
1049 | return 1; | 1049 | return 1; |
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1052 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1053 | { | 1053 | { |
1054 | mailimap_status_att_list * att_list =0; | 1054 | mailimap_status_att_list * att_list =0; |
1055 | mailimap_mailbox_data_status * status=0; | 1055 | mailimap_mailbox_data_status * status=0; |
1056 | clistiter * cur = 0; | 1056 | clistiter * cur = 0; |
1057 | int r = 0; | 1057 | int r = 0; |
1058 | int res = 0; | ||
1059 | target_stat.message_count = 0; | 1058 | target_stat.message_count = 0; |
1060 | target_stat.message_unseen = 0; | 1059 | target_stat.message_unseen = 0; |
1061 | target_stat.message_recent = 0; | 1060 | target_stat.message_recent = 0; |
1062 | login(); | 1061 | login(); |
1063 | if (!m_imap) { | 1062 | if (!m_imap) { |
1064 | return; | 1063 | return; |
1065 | } | 1064 | } |
1066 | att_list = mailimap_status_att_list_new_empty(); | 1065 | att_list = mailimap_status_att_list_new_empty(); |
1067 | if (!att_list) return; | 1066 | if (!att_list) return; |
1068 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 1067 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
1069 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 1068 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
1070 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 1069 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
@@ -1106,25 +1105,25 @@ void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folde | |||
1106 | 1105 | ||
1107 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1106 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1108 | { | 1107 | { |
1109 | return account->getType(); | 1108 | return account->getType(); |
1110 | } | 1109 | } |
1111 | 1110 | ||
1112 | const QString&IMAPwrapper::getName()const | 1111 | const QString&IMAPwrapper::getName()const |
1113 | { | 1112 | { |
1114 | qDebug("Get name: %s",account->getAccountName().latin1()); | 1113 | qDebug("Get name: %s",account->getAccountName().latin1()); |
1115 | return account->getAccountName(); | 1114 | return account->getAccountName(); |
1116 | } | 1115 | } |
1117 | 1116 | ||
1118 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) | 1117 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1119 | { | 1118 | { |
1120 | // dummy | 1119 | // dummy |
1121 | QValueList<int> path; | 1120 | QValueList<int> path; |
1122 | return fetchRawPart(mail,path,false); | 1121 | return fetchRawPart(mail,path,false); |
1123 | } | 1122 | } |
1124 | 1123 | ||
1125 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1124 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1126 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1125 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1127 | { | 1126 | { |
1128 | if (targetWrapper != this) { | 1127 | if (targetWrapper != this) { |
1129 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 1128 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
1130 | qDebug("Using generic"); | 1129 | qDebug("Using generic"); |
@@ -1145,41 +1144,41 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | |||
1145 | mailimap_set_free( set ); | 1144 | mailimap_set_free( set ); |
1146 | if ( err != MAILIMAP_NO_ERROR ) { | 1145 | if ( err != MAILIMAP_NO_ERROR ) { |
1147 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); | 1146 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); |
1148 | Global::statusMessage(error_msg); | 1147 | Global::statusMessage(error_msg); |
1149 | qDebug(error_msg); | 1148 | qDebug(error_msg); |
1150 | return; | 1149 | return; |
1151 | } | 1150 | } |
1152 | if (moveit) { | 1151 | if (moveit) { |
1153 | deleteAllMail(fromFolder); | 1152 | deleteAllMail(fromFolder); |
1154 | } | 1153 | } |
1155 | } | 1154 | } |
1156 | 1155 | ||
1157 | void IMAPwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1156 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1158 | { | 1157 | { |
1159 | if (targetWrapper != this) { | 1158 | if (targetWrapper != this) { |
1160 | qDebug("Using generic"); | 1159 | qDebug("Using generic"); |
1161 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1160 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1162 | return; | 1161 | return; |
1163 | } | 1162 | } |
1164 | mailimap_set *set = 0; | 1163 | mailimap_set *set = 0; |
1165 | login(); | 1164 | login(); |
1166 | if (!m_imap) { | 1165 | if (!m_imap) { |
1167 | return; | 1166 | return; |
1168 | } | 1167 | } |
1169 | int err = selectMbox(mail.getMbox()); | 1168 | int err = selectMbox(mail->getMbox()); |
1170 | if ( err != MAILIMAP_NO_ERROR ) { | 1169 | if ( err != MAILIMAP_NO_ERROR ) { |
1171 | return; | 1170 | return; |
1172 | } | 1171 | } |
1173 | set = mailimap_set_new_single(mail.getNumber()); | 1172 | set = mailimap_set_new_single(mail->getNumber()); |
1174 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1173 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1175 | mailimap_set_free( set ); | 1174 | mailimap_set_free( set ); |
1176 | if ( err != MAILIMAP_NO_ERROR ) { | 1175 | if ( err != MAILIMAP_NO_ERROR ) { |
1177 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); | 1176 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); |
1178 | Global::statusMessage(error_msg); | 1177 | Global::statusMessage(error_msg); |
1179 | qDebug(error_msg); | 1178 | qDebug(error_msg); |
1180 | return; | 1179 | return; |
1181 | } | 1180 | } |
1182 | if (moveit) { | 1181 | if (moveit) { |
1183 | deleteMail(mail); | 1182 | deleteMail(mail); |
1184 | } | 1183 | } |
1185 | } | 1184 | } |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 15f049f..3bd5967 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -14,67 +14,67 @@ struct mailimap_body_type_basic; | |||
14 | struct mailimap_body_type_msg; | 14 | struct mailimap_body_type_msg; |
15 | struct mailimap_body_type_mpart; | 15 | struct mailimap_body_type_mpart; |
16 | struct mailimap_body_fields; | 16 | struct mailimap_body_fields; |
17 | struct mailimap_msg_att; | 17 | struct mailimap_msg_att; |
18 | class encodedString; | 18 | class encodedString; |
19 | 19 | ||
20 | class IMAPwrapper : public AbstractMail | 20 | class IMAPwrapper : public AbstractMail |
21 | { | 21 | { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | public: | 23 | public: |
24 | IMAPwrapper( IMAPaccount *a ); | 24 | IMAPwrapper( IMAPaccount *a ); |
25 | virtual ~IMAPwrapper(); | 25 | virtual ~IMAPwrapper(); |
26 | virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders(); | 26 | virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); |
27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); | 27 | virtual void listMessages(const QString & mailbox,QValueList<Opie::OSmartPointer<RecMail> >&target ); |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
29 | 29 | ||
30 | virtual void deleteMail(const RecMail&mail); | 30 | virtual void deleteMail(const RecMailP&mail); |
31 | virtual void answeredMail(const RecMail&mail); | 31 | virtual void answeredMail(const RecMailP&mail); |
32 | virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&folder); | 32 | virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&folder); |
33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
34 | virtual void mvcpAllMails(const Opie::osmart_pointer<Folder>&fromFolder, | 34 | virtual void mvcpAllMails(const Opie::OSmartPointer<Folder>&fromFolder, |
35 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 35 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
36 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 36 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
37 | 37 | ||
38 | virtual RecBody fetchBody(const RecMail&mail); | 38 | virtual RecBody fetchBody(const RecMailP&mail); |
39 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 39 | virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part); |
40 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 40 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part); |
41 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 41 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part); |
42 | virtual encodedString* fetchRawBody(const RecMail&mail); | 42 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
43 | 43 | ||
44 | virtual int createMbox(const QString&,const Opie::osmart_pointer<Folder>&parentfolder=0, | 44 | virtual int createMbox(const QString&,const Opie::OSmartPointer<Folder>&parentfolder=0, |
45 | const QString& delemiter="/",bool getsubfolder=false); | 45 | const QString& delemiter="/",bool getsubfolder=false); |
46 | virtual int deleteMbox(const Opie::osmart_pointer<Folder>&folder); | 46 | virtual int deleteMbox(const Opie::OSmartPointer<Folder>&folder); |
47 | 47 | ||
48 | static void imap_progress( size_t current, size_t maximum ); | 48 | static void imap_progress( size_t current, size_t maximum ); |
49 | 49 | ||
50 | virtual void logout(); | 50 | virtual void logout(); |
51 | virtual MAILLIB::ATYPE getType()const; | 51 | virtual MAILLIB::ATYPE getType()const; |
52 | virtual const QString&getName()const; | 52 | virtual const QString&getName()const; |
53 | 53 | ||
54 | protected: | 54 | protected: |
55 | RecMail*parse_list_result(mailimap_msg_att*); | 55 | RecMail*parse_list_result(mailimap_msg_att*); |
56 | void login(); | 56 | void login(); |
57 | bool start_tls(bool force=true); | 57 | bool start_tls(bool force=true); |
58 | 58 | ||
59 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 59 | virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
60 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); | 60 | virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call); |
61 | int selectMbox(const QString&mbox); | 61 | int selectMbox(const QString&mbox); |
62 | 62 | ||
63 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 63 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
64 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 64 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
65 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 65 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
66 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 66 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
67 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); | 67 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); |
68 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 68 | void traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
69 | 69 | ||
70 | /* just helpers */ | 70 | /* just helpers */ |
71 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 71 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
72 | static QStringList address_list_to_stringlist(clist*list); | 72 | static QStringList address_list_to_stringlist(clist*list); |
73 | 73 | ||
74 | 74 | ||
75 | IMAPaccount *account; | 75 | IMAPaccount *account; |
76 | mailimap *m_imap; | 76 | mailimap *m_imap; |
77 | QString m_Lastmbox; | 77 | QString m_Lastmbox; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | #endif | 80 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index 49b3caa..7dd7e58 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -1,23 +1,23 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | RecMail::RecMail() | 4 | RecMail::RecMail() |
5 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 5 | :Opie::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) |
6 | { | 6 | { |
7 | init(); | 7 | init(); |
8 | } | 8 | } |
9 | 9 | ||
10 | RecMail::RecMail(const RecMail&old) | 10 | RecMail::RecMail(const RecMail&old) |
11 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 11 | :Opie::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
12 | { | 12 | { |
13 | init(); | 13 | init(); |
14 | copy_old(old); | 14 | copy_old(old); |
15 | qDebug("Copy constructor RecMail"); | 15 | qDebug("Copy constructor RecMail"); |
16 | } | 16 | } |
17 | 17 | ||
18 | RecMail::~RecMail() | 18 | RecMail::~RecMail() |
19 | { | 19 | { |
20 | wrapper = 0; | 20 | wrapper = 0; |
21 | } | 21 | } |
22 | 22 | ||
23 | void RecMail::copy_old(const RecMail&old) | 23 | void RecMail::copy_old(const RecMail&old) |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index 10d367f..dc10de6 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -1,93 +1,96 @@ | |||
1 | #ifndef __MAIL_TYPES_H | 1 | #ifndef __MAIL_TYPES_H |
2 | #define __MAIL_TYPES_H | 2 | #define __MAIL_TYPES_H |
3 | 3 | ||
4 | #define FLAG_ANSWERED 0 | 4 | #define FLAG_ANSWERED 0 |
5 | #define FLAG_FLAGGED 1 | 5 | #define FLAG_FLAGGED 1 |
6 | #define FLAG_DELETED 2 | 6 | #define FLAG_DELETED 2 |
7 | #define FLAG_SEEN 3 | 7 | #define FLAG_SEEN 3 |
8 | #define FLAG_DRAFT 4 | 8 | #define FLAG_DRAFT 4 |
9 | #define FLAG_RECENT 5 | 9 | #define FLAG_RECENT 5 |
10 | 10 | ||
11 | #include <opie2/osmartpointer.h> | ||
12 | |||
11 | #include <qbitarray.h> | 13 | #include <qbitarray.h> |
12 | #include <qstring.h> | 14 | #include <qstring.h> |
13 | #include <qstringlist.h> | 15 | #include <qstringlist.h> |
14 | #include <qmap.h> | 16 | #include <qmap.h> |
15 | #include <qvaluelist.h> | 17 | #include <qvaluelist.h> |
16 | 18 | ||
17 | class AbstractMail; | 19 | class AbstractMail; |
18 | /* a class to describe mails in a mailbox */ | 20 | /* a class to describe mails in a mailbox */ |
19 | /* Attention! | 21 | /* Attention! |
20 | From programmers point of view it would make sense to | 22 | From programmers point of view it would make sense to |
21 | store the mail body into this class, too. | 23 | store the mail body into this class, too. |
22 | But: not from the point of view of the device. | 24 | But: not from the point of view of the device. |
23 | Mailbodies can be real large. So we request them when | 25 | Mailbodies can be real large. So we request them when |
24 | needed from the mail-wrapper class direct from the server itself | 26 | needed from the mail-wrapper class direct from the server itself |
25 | (imap) or from a file-based cache (pop3?) | 27 | (imap) or from a file-based cache (pop3?) |
26 | So there is no interface "const QString&body()" but you should | 28 | So there is no interface "const QString&body()" but you should |
27 | make a request to the mailwrapper with this class as parameter to | 29 | make a request to the mailwrapper with this class as parameter to |
28 | get the body. Same words for the attachments. | 30 | get the body. Same words for the attachments. |
29 | */ | 31 | */ |
30 | class RecMail | 32 | class RecMail:public Opie::ORefCount |
31 | { | 33 | { |
32 | public: | 34 | public: |
33 | RecMail(); | 35 | RecMail(); |
34 | RecMail(const RecMail&old); | 36 | RecMail(const RecMail&old); |
35 | virtual ~RecMail(); | 37 | virtual ~RecMail(); |
36 | 38 | ||
37 | const int getNumber()const{return msg_number;} | 39 | const unsigned int getNumber()const{return msg_number;} |
38 | void setNumber(int number){msg_number=number;} | 40 | void setNumber(unsigned int number){msg_number=number;} |
39 | const QString&getDate()const{ return date; } | 41 | const QString&getDate()const{ return date; } |
40 | void setDate( const QString&a ) { date = a; } | 42 | void setDate( const QString&a ) { date = a; } |
41 | const QString&getFrom()const{ return from; } | 43 | const QString&getFrom()const{ return from; } |
42 | void setFrom( const QString&a ) { from = a; } | 44 | void setFrom( const QString&a ) { from = a; } |
43 | const QString&getSubject()const { return subject; } | 45 | const QString&getSubject()const { return subject; } |
44 | void setSubject( const QString&s ) { subject = s; } | 46 | void setSubject( const QString&s ) { subject = s; } |
45 | const QString&getMbox()const{return mbox;} | 47 | const QString&getMbox()const{return mbox;} |
46 | void setMbox(const QString&box){mbox = box;} | 48 | void setMbox(const QString&box){mbox = box;} |
47 | void setMsgid(const QString&id){msg_id=id;} | 49 | void setMsgid(const QString&id){msg_id=id;} |
48 | const QString&Msgid()const{return msg_id;} | 50 | const QString&Msgid()const{return msg_id;} |
49 | void setReplyto(const QString&reply){replyto=reply;} | 51 | void setReplyto(const QString&reply){replyto=reply;} |
50 | const QString&Replyto()const{return replyto;} | 52 | const QString&Replyto()const{return replyto;} |
51 | void setMsgsize(int size){msg_size = size;} | 53 | void setMsgsize(unsigned int size){msg_size = size;} |
52 | const int Msgsize()const{return msg_size;} | 54 | const unsigned int Msgsize()const{return msg_size;} |
53 | 55 | ||
54 | 56 | ||
55 | void setTo(const QStringList&list); | 57 | void setTo(const QStringList&list); |
56 | const QStringList&To()const; | 58 | const QStringList&To()const; |
57 | void setCC(const QStringList&list); | 59 | void setCC(const QStringList&list); |
58 | const QStringList&CC()const; | 60 | const QStringList&CC()const; |
59 | void setBcc(const QStringList&list); | 61 | void setBcc(const QStringList&list); |
60 | const QStringList&Bcc()const; | 62 | const QStringList&Bcc()const; |
61 | void setInreply(const QStringList&list); | 63 | void setInreply(const QStringList&list); |
62 | const QStringList&Inreply()const; | 64 | const QStringList&Inreply()const; |
63 | void setReferences(const QStringList&list); | 65 | void setReferences(const QStringList&list); |
64 | const QStringList&References()const; | 66 | const QStringList&References()const; |
65 | 67 | ||
66 | const QBitArray&getFlags()const{return msg_flags;} | 68 | const QBitArray&getFlags()const{return msg_flags;} |
67 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 69 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
68 | 70 | ||
69 | void setWrapper(AbstractMail*wrapper); | 71 | void setWrapper(AbstractMail*wrapper); |
70 | AbstractMail* Wrapper(); | 72 | AbstractMail* Wrapper(); |
71 | 73 | ||
72 | protected: | 74 | protected: |
73 | QString subject,date,from,mbox,msg_id,replyto; | 75 | QString subject,date,from,mbox,msg_id,replyto; |
74 | int msg_number,msg_size; | 76 | unsigned int msg_number,msg_size; |
75 | QBitArray msg_flags; | 77 | QBitArray msg_flags; |
76 | QStringList to,cc,bcc,in_reply_to,references; | 78 | QStringList to,cc,bcc,in_reply_to,references; |
77 | AbstractMail*wrapper; | 79 | AbstractMail*wrapper; |
78 | void init(); | 80 | void init(); |
79 | void copy_old(const RecMail&old); | 81 | void copy_old(const RecMail&old); |
80 | }; | 82 | }; |
81 | 83 | ||
84 | typedef Opie::OSmartPointer<RecMail> RecMailP; | ||
82 | typedef QMap<QString,QString> part_plist_t; | 85 | typedef QMap<QString,QString> part_plist_t; |
83 | 86 | ||
84 | class RecPart | 87 | class RecPart |
85 | { | 88 | { |
86 | protected: | 89 | protected: |
87 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 90 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
88 | unsigned int m_lines,m_size; | 91 | unsigned int m_lines,m_size; |
89 | part_plist_t m_Parameters; | 92 | part_plist_t m_Parameters; |
90 | /* describes the position in the mail */ | 93 | /* describes the position in the mail */ |
91 | QValueList<int> m_poslist; | 94 | QValueList<int> m_poslist; |
92 | 95 | ||
93 | public: | 96 | public: |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp index c71d69f..9bf2fd3 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp | |||
@@ -146,25 +146,25 @@ QString IMAPFolder::decodeFolderName( const QString &name ) | |||
146 | } | 146 | } |
147 | } | 147 | } |
148 | /* skip over trailing '-' in modified UTF-7 encoding */ | 148 | /* skip over trailing '-' in modified UTF-7 encoding */ |
149 | if (src[srcPtr] == '-') | 149 | if (src[srcPtr] == '-') |
150 | ++srcPtr; | 150 | ++srcPtr; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | return QString::fromUtf8( dst.data() ); | 154 | return QString::fromUtf8( dst.data() ); |
155 | } | 155 | } |
156 | 156 | ||
157 | Mail::Mail() | 157 | Mail::Mail() |
158 | :Opie::oref_count(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") | 158 | :Opie::ORefCount(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") |
159 | { | 159 | { |
160 | } | 160 | } |
161 | 161 | ||
162 | MHFolder::MHFolder(const QString&disp_name,const QString&mbox) | 162 | MHFolder::MHFolder(const QString&disp_name,const QString&mbox) |
163 | : Folder( disp_name,"/" ) | 163 | : Folder( disp_name,"/" ) |
164 | { | 164 | { |
165 | separator = "/"; | 165 | separator = "/"; |
166 | name = mbox; | 166 | name = mbox; |
167 | if (!disp_name.startsWith("/") && disp_name.length()>0) | 167 | if (!disp_name.startsWith("/") && disp_name.length()>0) |
168 | name+="/"; | 168 | name+="/"; |
169 | name+=disp_name; | 169 | name+=disp_name; |
170 | if (disp_name.length()==0) { | 170 | if (disp_name.length()==0) { |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index 3b3bb32..6bf0078 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h | |||
@@ -1,43 +1,43 @@ | |||
1 | #ifndef MAILWRAPPER_H | 1 | #ifndef MAILWRAPPER_H |
2 | #define MAILWRAPPER_H | 2 | #define MAILWRAPPER_H |
3 | 3 | ||
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | 5 | ||
6 | #include <qbitarray.h> | 6 | #include <qbitarray.h> |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | 8 | ||
9 | #include "settings.h" | 9 | #include "settings.h" |
10 | 10 | ||
11 | #include <opie2/osmart_pointer.h> | 11 | #include <opie2/osmartpointer.h> |
12 | 12 | ||
13 | class Attachment | 13 | class Attachment |
14 | { | 14 | { |
15 | public: | 15 | public: |
16 | Attachment( DocLnk lnk ); | 16 | Attachment( DocLnk lnk ); |
17 | virtual ~Attachment(){} | 17 | virtual ~Attachment(){} |
18 | const QString getFileName()const{ return doc.file(); } | 18 | const QString getFileName()const{ return doc.file(); } |
19 | const QString getName()const{ return doc.name(); } | 19 | const QString getName()const{ return doc.name(); } |
20 | const QString getMimeType()const{ return doc.type(); } | 20 | const QString getMimeType()const{ return doc.type(); } |
21 | const QPixmap getPixmap()const{ return doc.pixmap(); } | 21 | const QPixmap getPixmap()const{ return doc.pixmap(); } |
22 | const int getSize()const { return size; } | 22 | const int getSize()const { return size; } |
23 | DocLnk getDocLnk() { return doc; } | 23 | DocLnk getDocLnk() { return doc; } |
24 | 24 | ||
25 | protected: | 25 | protected: |
26 | DocLnk doc; | 26 | DocLnk doc; |
27 | int size; | 27 | int size; |
28 | 28 | ||
29 | }; | 29 | }; |
30 | 30 | ||
31 | class Mail:public Opie::oref_count | 31 | class Mail:public Opie::ORefCount |
32 | { | 32 | { |
33 | public: | 33 | public: |
34 | Mail(); | 34 | Mail(); |
35 | /* Possible that this destructor must not be declared virtual | 35 | /* Possible that this destructor must not be declared virtual |
36 | * 'cause it seems that it will never have some child classes. | 36 | * 'cause it seems that it will never have some child classes. |
37 | * in this case this object will not get a virtual table -> memory and | 37 | * in this case this object will not get a virtual table -> memory and |
38 | * speed will be a little bit better? | 38 | * speed will be a little bit better? |
39 | */ | 39 | */ |
40 | virtual ~Mail(){} | 40 | virtual ~Mail(){} |
41 | void addAttachment( Attachment *att ) { attList.append( att ); } | 41 | void addAttachment( Attachment *att ) { attList.append( att ); } |
42 | const QList<Attachment>& getAttachments()const { return attList; } | 42 | const QList<Attachment>& getAttachments()const { return attList; } |
43 | void removeAttachment( Attachment *att ) { attList.remove( att ); } | 43 | void removeAttachment( Attachment *att ) { attList.remove( att ); } |
@@ -57,41 +57,41 @@ public: | |||
57 | void setSubject( const QString&s ) { subject = s; } | 57 | void setSubject( const QString&s ) { subject = s; } |
58 | const QString&getReply()const{ return reply; } | 58 | const QString&getReply()const{ return reply; } |
59 | void setReply( const QString&a ) { reply = a; } | 59 | void setReply( const QString&a ) { reply = a; } |
60 | void setInreply(const QStringList&list){m_in_reply_to = list;} | 60 | void setInreply(const QStringList&list){m_in_reply_to = list;} |
61 | const QStringList&Inreply()const{return m_in_reply_to;} | 61 | const QStringList&Inreply()const{return m_in_reply_to;} |
62 | 62 | ||
63 | private: | 63 | private: |
64 | QList<Attachment> attList; | 64 | QList<Attachment> attList; |
65 | QString name, mail, to, cc, bcc, reply, subject, message; | 65 | QString name, mail, to, cc, bcc, reply, subject, message; |
66 | QStringList m_in_reply_to; | 66 | QStringList m_in_reply_to; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | class Folder:public Opie::oref_count | 69 | class Folder:public Opie::ORefCount |
70 | { | 70 | { |
71 | public: | 71 | public: |
72 | Folder( const QString&init_name,const QString&sep ); | 72 | Folder( const QString&init_name,const QString&sep ); |
73 | virtual ~Folder(); | 73 | virtual ~Folder(); |
74 | const QString&getDisplayName()const { return nameDisplay; } | 74 | const QString&getDisplayName()const { return nameDisplay; } |
75 | const QString&getName()const { return name; } | 75 | const QString&getName()const { return name; } |
76 | const QString&getPrefix()const{return prefix; } | 76 | const QString&getPrefix()const{return prefix; } |
77 | virtual bool may_select()const{return true;} | 77 | virtual bool may_select()const{return true;} |
78 | virtual bool no_inferior()const{return true;} | 78 | virtual bool no_inferior()const{return true;} |
79 | const QString&Separator()const; | 79 | const QString&Separator()const; |
80 | 80 | ||
81 | protected: | 81 | protected: |
82 | QString nameDisplay, name, separator,prefix; | 82 | QString nameDisplay, name, separator,prefix; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | typedef Opie::osmart_pointer<Folder> FolderP; | 85 | typedef Opie::OSmartPointer<Folder> FolderP; |
86 | 86 | ||
87 | class MHFolder : public Folder | 87 | class MHFolder : public Folder |
88 | { | 88 | { |
89 | public: | 89 | public: |
90 | MHFolder(const QString&disp_name,const QString&mbox); | 90 | MHFolder(const QString&disp_name,const QString&mbox); |
91 | virtual ~MHFolder(); | 91 | virtual ~MHFolder(); |
92 | }; | 92 | }; |
93 | 93 | ||
94 | class IMAPFolder : public Folder | 94 | class IMAPFolder : public Folder |
95 | { | 95 | { |
96 | public: | 96 | public: |
97 | IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); | 97 | IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index 9ff3de2..5e6b714 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -10,121 +10,121 @@ MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) | |||
10 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) | 10 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) |
11 | { | 11 | { |
12 | QDir dir(MBOXPath); | 12 | QDir dir(MBOXPath); |
13 | if (!dir.exists()) { | 13 | if (!dir.exists()) { |
14 | dir.mkdir(MBOXPath); | 14 | dir.mkdir(MBOXPath); |
15 | } | 15 | } |
16 | } | 16 | } |
17 | 17 | ||
18 | MBOXwrapper::~MBOXwrapper() | 18 | MBOXwrapper::~MBOXwrapper() |
19 | { | 19 | { |
20 | } | 20 | } |
21 | 21 | ||
22 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | 22 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) |
23 | { | 23 | { |
24 | mailstorage*storage = mailstorage_new(NULL); | 24 | mailstorage*storage = mailstorage_new(NULL); |
25 | QString p = MBOXPath+"/"; | 25 | QString p = MBOXPath+"/"; |
26 | p+=mailbox; | 26 | p+=mailbox; |
27 | 27 | ||
28 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 28 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
29 | mailfolder*folder; | 29 | mailfolder*folder; |
30 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 30 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
31 | r = mailfolder_connect(folder); | 31 | r = mailfolder_connect(folder); |
32 | if (r != MAIL_NO_ERROR) { | 32 | if (r != MAIL_NO_ERROR) { |
33 | qDebug("Error initializing mbox"); | 33 | qDebug("Error initializing mbox"); |
34 | mailfolder_free(folder); | 34 | mailfolder_free(folder); |
35 | mailstorage_free(storage); | 35 | mailstorage_free(storage); |
36 | return; | 36 | return; |
37 | } | 37 | } |
38 | 38 | ||
39 | parseList(target,folder->fld_session,mailbox); | 39 | parseList(target,folder->fld_session,mailbox); |
40 | 40 | ||
41 | mailfolder_disconnect(folder); | 41 | mailfolder_disconnect(folder); |
42 | mailfolder_free(folder); | 42 | mailfolder_free(folder); |
43 | mailstorage_free(storage); | 43 | mailstorage_free(storage); |
44 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 44 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
45 | } | 45 | } |
46 | 46 | ||
47 | QValueList<Opie::osmart_pointer<Folder> >* MBOXwrapper::listFolders() | 47 | QValueList<Opie::OSmartPointer<Folder> >* MBOXwrapper::listFolders() |
48 | { | 48 | { |
49 | QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<Opie::osmart_pointer<Folder> >(); | 49 | QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >(); |
50 | QDir dir(MBOXPath); | 50 | QDir dir(MBOXPath); |
51 | if (!dir.exists()) return folders; | 51 | if (!dir.exists()) return folders; |
52 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 52 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
53 | QStringList entries = dir.entryList(); | 53 | QStringList entries = dir.entryList(); |
54 | QStringList::ConstIterator it = entries.begin(); | 54 | QStringList::ConstIterator it = entries.begin(); |
55 | for (;it!=entries.end();++it) { | 55 | for (;it!=entries.end();++it) { |
56 | FolderP inb=new Folder(*it,"/"); | 56 | FolderP inb=new Folder(*it,"/"); |
57 | folders->append(inb); | 57 | folders->append(inb); |
58 | } | 58 | } |
59 | return folders; | 59 | return folders; |
60 | } | 60 | } |
61 | 61 | ||
62 | void MBOXwrapper::deleteMail(const RecMail&mail) | 62 | void MBOXwrapper::deleteMail(const RecMailP & mail) |
63 | { | 63 | { |
64 | mailstorage*storage = mailstorage_new(NULL); | 64 | mailstorage*storage = mailstorage_new(NULL); |
65 | QString p = MBOXPath+"/"; | 65 | QString p = MBOXPath+"/"; |
66 | p+=mail.getMbox(); | 66 | p+=mail->getMbox(); |
67 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 67 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
68 | mailfolder*folder; | 68 | mailfolder*folder; |
69 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 69 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
70 | r = mailfolder_connect(folder); | 70 | r = mailfolder_connect(folder); |
71 | if (r != MAIL_NO_ERROR) { | 71 | if (r != MAIL_NO_ERROR) { |
72 | qDebug("Error initializing mbox"); | 72 | qDebug("Error initializing mbox"); |
73 | mailfolder_free(folder); | 73 | mailfolder_free(folder); |
74 | mailstorage_free(storage); | 74 | mailstorage_free(storage); |
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); | 77 | r = mailsession_remove_message(folder->fld_session,mail->getNumber()); |
78 | if (r != MAIL_NO_ERROR) { | 78 | if (r != MAIL_NO_ERROR) { |
79 | qDebug("error deleting mail"); | 79 | qDebug("error deleting mail"); |
80 | } | 80 | } |
81 | mailfolder_free(folder); | 81 | mailfolder_free(folder); |
82 | mailstorage_free(storage); | 82 | mailstorage_free(storage); |
83 | } | 83 | } |
84 | 84 | ||
85 | void MBOXwrapper::answeredMail(const RecMail&) | 85 | void MBOXwrapper::answeredMail(const RecMailP&) |
86 | { | 86 | { |
87 | } | 87 | } |
88 | 88 | ||
89 | RecBody MBOXwrapper::fetchBody( const RecMail &mail ) | 89 | RecBody MBOXwrapper::fetchBody( const RecMailP &mail ) |
90 | { | 90 | { |
91 | RecBody body; | 91 | RecBody body; |
92 | mailstorage*storage = mailstorage_new(NULL); | 92 | mailstorage*storage = mailstorage_new(NULL); |
93 | QString p = MBOXPath+"/"; | 93 | QString p = MBOXPath+"/"; |
94 | p+=mail.getMbox(); | 94 | p+=mail->getMbox(); |
95 | mailmessage * msg; | 95 | mailmessage * msg; |
96 | char*data=0; | 96 | char*data=0; |
97 | size_t size; | 97 | size_t size; |
98 | 98 | ||
99 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 99 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
100 | mailfolder*folder; | 100 | mailfolder*folder; |
101 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 101 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
102 | r = mailfolder_connect(folder); | 102 | r = mailfolder_connect(folder); |
103 | if (r != MAIL_NO_ERROR) { | 103 | if (r != MAIL_NO_ERROR) { |
104 | qDebug("Error initializing mbox"); | 104 | qDebug("Error initializing mbox"); |
105 | mailfolder_free(folder); | 105 | mailfolder_free(folder); |
106 | mailstorage_free(storage); | 106 | mailstorage_free(storage); |
107 | return body; | 107 | return body; |
108 | } | 108 | } |
109 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 109 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); |
110 | if (r != MAIL_NO_ERROR) { | 110 | if (r != MAIL_NO_ERROR) { |
111 | qDebug("Error fetching mail %i",mail.getNumber()); | 111 | qDebug("Error fetching mail %i",mail->getNumber()); |
112 | mailfolder_free(folder); | 112 | mailfolder_free(folder); |
113 | mailstorage_free(storage); | 113 | mailstorage_free(storage); |
114 | return body; | 114 | return body; |
115 | } | 115 | } |
116 | r = mailmessage_fetch(msg,&data,&size); | 116 | r = mailmessage_fetch(msg,&data,&size); |
117 | if (r != MAIL_NO_ERROR) { | 117 | if (r != MAIL_NO_ERROR) { |
118 | qDebug("Error fetching mail %i",mail.getNumber()); | 118 | qDebug("Error fetching mail %i",mail->getNumber()); |
119 | mailfolder_free(folder); | 119 | mailfolder_free(folder); |
120 | mailstorage_free(storage); | 120 | mailstorage_free(storage); |
121 | mailmessage_free(msg); | 121 | mailmessage_free(msg); |
122 | return body; | 122 | return body; |
123 | } | 123 | } |
124 | body = parseMail(msg); | 124 | body = parseMail(msg); |
125 | mailmessage_fetch_result_free(msg,data); | 125 | mailmessage_fetch_result_free(msg,data); |
126 | mailfolder_free(folder); | 126 | mailfolder_free(folder); |
127 | mailstorage_free(storage); | 127 | mailstorage_free(storage); |
128 | 128 | ||
129 | return body; | 129 | return body; |
130 | } | 130 | } |
@@ -160,87 +160,88 @@ void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folde | |||
160 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 160 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
161 | if (r != MAIL_NO_ERROR) { | 161 | if (r != MAIL_NO_ERROR) { |
162 | Global::statusMessage(tr("Error init folder")); | 162 | Global::statusMessage(tr("Error init folder")); |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | r = mailmbox_append_message(f,msg,length); | 165 | r = mailmbox_append_message(f,msg,length); |
166 | if (r != MAIL_NO_ERROR) { | 166 | if (r != MAIL_NO_ERROR) { |
167 | Global::statusMessage(tr("Error writing to message folder")); | 167 | Global::statusMessage(tr("Error writing to message folder")); |
168 | } | 168 | } |
169 | mailmbox_done(f); | 169 | mailmbox_done(f); |
170 | } | 170 | } |
171 | 171 | ||
172 | encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail) | 172 | encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) |
173 | { | 173 | { |
174 | RecBody body; | 174 | RecBody body; |
175 | mailstorage*storage = mailstorage_new(NULL); | 175 | mailstorage*storage = mailstorage_new(NULL); |
176 | QString p = MBOXPath+"/"; | 176 | QString p = MBOXPath+"/"; |
177 | p+=mail.getMbox(); | 177 | p+=mail->getMbox(); |
178 | mailmessage * msg; | 178 | mailmessage * msg; |
179 | char*data=0; | 179 | char*data=0; |
180 | size_t size; | 180 | size_t size; |
181 | 181 | ||
182 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 182 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
183 | mailfolder*folder; | 183 | mailfolder*folder; |
184 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 184 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
185 | r = mailfolder_connect(folder); | 185 | r = mailfolder_connect(folder); |
186 | if (r != MAIL_NO_ERROR) { | 186 | if (r != MAIL_NO_ERROR) { |
187 | Global::statusMessage(tr("Error initializing mbox")); | 187 | Global::statusMessage(tr("Error initializing mbox")); |
188 | mailfolder_free(folder); | 188 | mailfolder_free(folder); |
189 | mailstorage_free(storage); | 189 | mailstorage_free(storage); |
190 | return 0; | 190 | return 0; |
191 | } | 191 | } |
192 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 192 | r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); |
193 | if (r != MAIL_NO_ERROR) { | 193 | if (r != MAIL_NO_ERROR) { |
194 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 194 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
195 | mailfolder_free(folder); | 195 | mailfolder_free(folder); |
196 | mailstorage_free(storage); | 196 | mailstorage_free(storage); |
197 | return 0; | 197 | return 0; |
198 | } | 198 | } |
199 | r = mailmessage_fetch(msg,&data,&size); | 199 | r = mailmessage_fetch(msg,&data,&size); |
200 | if (r != MAIL_NO_ERROR) { | 200 | if (r != MAIL_NO_ERROR) { |
201 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 201 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
202 | mailfolder_free(folder); | 202 | mailfolder_free(folder); |
203 | mailstorage_free(storage); | 203 | mailstorage_free(storage); |
204 | mailmessage_free(msg); | 204 | mailmessage_free(msg); |
205 | return 0; | 205 | return 0; |
206 | } | 206 | } |
207 | encodedString*result = new encodedString(data,size); | 207 | encodedString*result = new encodedString(data,size); |
208 | 208 | ||
209 | mailfolder_free(folder); | 209 | mailfolder_free(folder); |
210 | mailstorage_free(storage); | 210 | mailstorage_free(storage); |
211 | mailmessage_free(msg); | 211 | mailmessage_free(msg); |
212 | return result; | 212 | return result; |
213 | } | 213 | } |
214 | 214 | ||
215 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 215 | void MBOXwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) |
216 | { | 216 | { |
217 | QString p = MBOXPath+"/"; | 217 | QString p = MBOXPath+"/"; |
218 | p+=mailbox; | 218 | p+=mailbox; |
219 | mailmbox_folder*f = 0; | 219 | mailmbox_folder*f = 0; |
220 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 220 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
221 | if (r != MAIL_NO_ERROR) { | 221 | if (r != MAIL_NO_ERROR) { |
222 | qDebug("Error init folder"); | 222 | qDebug("Error init folder"); |
223 | return; | 223 | return; |
224 | } | 224 | } |
225 | deleteMails(f,target); | 225 | deleteMails(f,target); |
226 | mailmbox_done(f); | 226 | mailmbox_done(f); |
227 | } | 227 | } |
228 | 228 | ||
229 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) | 229 | void MBOXwrapper::deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target) |
230 | { | 230 | { |
231 | if (!f) return; | 231 | if (!f) return; |
232 | int r; | 232 | int r; |
233 | for (unsigned int i=0; i < target.count();++i) { | 233 | QValueList<RecMailP>::ConstIterator it; |
234 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); | 234 | for (it=target.begin(); it != target.end();++it) { |
235 | r = mailmbox_delete_msg(f,(*it)->getNumber()); | ||
235 | if (r!=MAILMBOX_NO_ERROR) { | 236 | if (r!=MAILMBOX_NO_ERROR) { |
236 | qDebug("error delete mail"); | 237 | qDebug("error delete mail"); |
237 | } | 238 | } |
238 | } | 239 | } |
239 | r = mailmbox_expunge(f); | 240 | r = mailmbox_expunge(f); |
240 | if (r != MAILMBOX_NO_ERROR) { | 241 | if (r != MAILMBOX_NO_ERROR) { |
241 | qDebug("error expunge mailbox"); | 242 | qDebug("error expunge mailbox"); |
242 | } | 243 | } |
243 | } | 244 | } |
244 | 245 | ||
245 | int MBOXwrapper::deleteAllMail(const FolderP&tfolder) | 246 | int MBOXwrapper::deleteAllMail(const FolderP&tfolder) |
246 | { | 247 | { |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index c3d9b50..33eeb1e 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h | |||
@@ -1,48 +1,46 @@ | |||
1 | #ifndef __MBOX_WRAPPER_H | 1 | #ifndef __MBOX_WRAPPER_H |
2 | #define __MBOX_WRAPPER_H | 2 | #define __MBOX_WRAPPER_H |
3 | 3 | ||
4 | #include "genericwrapper.h" | 4 | #include "genericwrapper.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | 6 | ||
7 | class RecMail; | ||
8 | class RecBody; | ||
9 | class encodedString; | 7 | class encodedString; |
10 | struct mailmbox_folder; | 8 | struct mailmbox_folder; |
11 | 9 | ||
12 | class MBOXwrapper : public Genericwrapper | 10 | class MBOXwrapper : public Genericwrapper |
13 | { | 11 | { |
14 | Q_OBJECT | 12 | Q_OBJECT |
15 | 13 | ||
16 | public: | 14 | public: |
17 | MBOXwrapper(const QString & dir,const QString&name); | 15 | MBOXwrapper(const QString & dir,const QString&name); |
18 | virtual ~MBOXwrapper(); | 16 | virtual ~MBOXwrapper(); |
19 | 17 | ||
20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 18 | virtual void listMessages(const QString & mailbox, QValueList<RecMailP>&target ); |
21 | virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders(); | 19 | virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); |
22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 20 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
23 | 21 | ||
24 | virtual void deleteMail(const RecMail&mail); | 22 | virtual void deleteMail(const RecMailP&mail); |
25 | virtual void answeredMail(const RecMail&mail); | 23 | virtual void answeredMail(const RecMailP&mail); |
26 | 24 | ||
27 | virtual int createMbox(const QString&folder,const Opie::osmart_pointer<Folder>&f=0, | 25 | virtual int createMbox(const QString&folder,const Opie::OSmartPointer<Folder>&f=0, |
28 | const QString&d="",bool s=false); | 26 | const QString&d="",bool s=false); |
29 | virtual int deleteMbox(const Opie::osmart_pointer<Folder>&); | 27 | virtual int deleteMbox(const Opie::OSmartPointer<Folder>&); |
30 | 28 | ||
31 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 29 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
32 | 30 | ||
33 | virtual RecBody fetchBody( const RecMail &mail ); | 31 | virtual RecBody fetchBody( const RecMailP &mail ); |
34 | static void mbox_progress( size_t current, size_t maximum ); | 32 | static void mbox_progress( size_t current, size_t maximum ); |
35 | 33 | ||
36 | virtual encodedString* fetchRawBody(const RecMail&mail); | 34 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
37 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); | 35 | virtual void deleteMails(const QString & FolderName,const QValueList<RecMailP> &target); |
38 | virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&); | 36 | virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&); |
39 | virtual MAILLIB::ATYPE getType()const; | 37 | virtual MAILLIB::ATYPE getType()const; |
40 | virtual const QString&getName()const; | 38 | virtual const QString&getName()const; |
41 | 39 | ||
42 | protected: | 40 | protected: |
43 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | 41 | static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target); |
44 | QString MBOXPath; | 42 | QString MBOXPath; |
45 | QString MBOXName; | 43 | QString MBOXName; |
46 | }; | 44 | }; |
47 | 45 | ||
48 | #endif | 46 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index aaaa20a..0b00a2e 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -51,105 +51,104 @@ void MHwrapper::clean_storage() | |||
51 | if (m_storage) { | 51 | if (m_storage) { |
52 | mailstorage_disconnect(m_storage); | 52 | mailstorage_disconnect(m_storage); |
53 | mailstorage_free(m_storage); | 53 | mailstorage_free(m_storage); |
54 | m_storage = 0; | 54 | m_storage = 0; |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | MHwrapper::~MHwrapper() | 58 | MHwrapper::~MHwrapper() |
59 | { | 59 | { |
60 | clean_storage(); | 60 | clean_storage(); |
61 | } | 61 | } |
62 | 62 | ||
63 | void MHwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | 63 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target ) |
64 | { | 64 | { |
65 | init_storage(); | 65 | init_storage(); |
66 | if (!m_storage) { | 66 | if (!m_storage) { |
67 | return; | 67 | return; |
68 | } | 68 | } |
69 | QString f = buildPath(mailbox); | 69 | QString f = buildPath(mailbox); |
70 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 70 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
71 | if (r!=MAIL_NO_ERROR) { | 71 | if (r!=MAIL_NO_ERROR) { |
72 | qDebug("listMessages: error selecting folder!"); | 72 | qDebug("listMessages: error selecting folder!"); |
73 | return; | 73 | return; |
74 | } | 74 | } |
75 | parseList(target,m_storage->sto_session,f); | 75 | parseList(target,m_storage->sto_session,f); |
76 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 76 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
77 | } | 77 | } |
78 | 78 | ||
79 | QValueList<Opie::osmart_pointer<Folder> >* MHwrapper::listFolders() | 79 | QValueList<Opie::OSmartPointer<Folder> >* MHwrapper::listFolders() |
80 | { | 80 | { |
81 | QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<Opie::osmart_pointer<Folder> >(); | 81 | QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >(); |
82 | /* this is needed! */ | 82 | /* this is needed! */ |
83 | if (m_storage) mailstorage_disconnect(m_storage); | 83 | if (m_storage) mailstorage_disconnect(m_storage); |
84 | init_storage(); | 84 | init_storage(); |
85 | if (!m_storage) { | 85 | if (!m_storage) { |
86 | return folders; | 86 | return folders; |
87 | } | 87 | } |
88 | mail_list*flist = 0; | 88 | mail_list*flist = 0; |
89 | clistcell*current=0; | 89 | clistcell*current=0; |
90 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 90 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
91 | if (r != MAIL_NO_ERROR || !flist) { | 91 | if (r != MAIL_NO_ERROR || !flist) { |
92 | qDebug("error getting folder list"); | 92 | qDebug("error getting folder list"); |
93 | return folders; | 93 | return folders; |
94 | } | 94 | } |
95 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 95 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
96 | QString t = (char*)current->data; | 96 | QString t = (char*)current->data; |
97 | t.replace(0,MHPath.length(),""); | 97 | t.replace(0,MHPath.length(),""); |
98 | folders->append(new MHFolder(t,MHPath)); | 98 | folders->append(new MHFolder(t,MHPath)); |
99 | } | 99 | } |
100 | mail_list_free(flist); | 100 | mail_list_free(flist); |
101 | return folders; | 101 | return folders; |
102 | } | 102 | } |
103 | 103 | ||
104 | void MHwrapper::deleteMail(const RecMail&mail) | 104 | void MHwrapper::deleteMail(const RecMailP&mail) |
105 | { | 105 | { |
106 | init_storage(); | 106 | init_storage(); |
107 | if (!m_storage) { | 107 | if (!m_storage) { |
108 | return; | 108 | return; |
109 | } | 109 | } |
110 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 110 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
111 | if (r!=MAIL_NO_ERROR) { | 111 | if (r!=MAIL_NO_ERROR) { |
112 | qDebug("error selecting folder!"); | 112 | qDebug("error selecting folder!"); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | r = mailsession_remove_message(m_storage->sto_session,mail.getNumber()); | 115 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); |
116 | if (r != MAIL_NO_ERROR) { | 116 | if (r != MAIL_NO_ERROR) { |
117 | qDebug("error deleting mail"); | 117 | qDebug("error deleting mail"); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | void MHwrapper::answeredMail(const RecMail&) | 121 | void MHwrapper::answeredMail(const RecMailP&) |
122 | { | 122 | { |
123 | } | 123 | } |
124 | 124 | ||
125 | RecBody MHwrapper::fetchBody( const RecMail &mail ) | 125 | RecBody MHwrapper::fetchBody( const RecMailP &mail ) |
126 | { | 126 | { |
127 | RecBody body; | 127 | RecBody body; |
128 | init_storage(); | 128 | init_storage(); |
129 | if (!m_storage) { | 129 | if (!m_storage) { |
130 | return body; | 130 | return body; |
131 | } | 131 | } |
132 | mailmessage * msg; | 132 | mailmessage * msg; |
133 | char*data=0; | 133 | char*data=0; |
134 | size_t size; | ||
135 | 134 | ||
136 | /* mail should hold the complete path! */ | 135 | /* mail should hold the complete path! */ |
137 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 136 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
138 | if (r != MAIL_NO_ERROR) { | 137 | if (r != MAIL_NO_ERROR) { |
139 | return body; | 138 | return body; |
140 | } | 139 | } |
141 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); | 140 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
142 | if (r != MAIL_NO_ERROR) { | 141 | if (r != MAIL_NO_ERROR) { |
143 | qDebug("Error fetching mail %i",mail.getNumber()); | 142 | qDebug("Error fetching mail %i",mail->getNumber()); |
144 | return body; | 143 | return body; |
145 | } | 144 | } |
146 | body = parseMail(msg); | 145 | body = parseMail(msg); |
147 | mailmessage_fetch_result_free(msg,data); | 146 | mailmessage_fetch_result_free(msg,data); |
148 | return body; | 147 | return body; |
149 | } | 148 | } |
150 | 149 | ||
151 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 150 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
152 | { | 151 | { |
153 | qDebug("MH %i von %i",current,maximum); | 152 | qDebug("MH %i von %i",current,maximum); |
154 | } | 153 | } |
155 | 154 | ||
@@ -203,67 +202,66 @@ void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) | |||
203 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 202 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
204 | if (r!=MAIL_NO_ERROR) { | 203 | if (r!=MAIL_NO_ERROR) { |
205 | qDebug("error selecting folder!"); | 204 | qDebug("error selecting folder!"); |
206 | return; | 205 | return; |
207 | } | 206 | } |
208 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); | 207 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); |
209 | if (r!=MAIL_NO_ERROR) { | 208 | if (r!=MAIL_NO_ERROR) { |
210 | qDebug("error storing mail"); | 209 | qDebug("error storing mail"); |
211 | } | 210 | } |
212 | return; | 211 | return; |
213 | } | 212 | } |
214 | 213 | ||
215 | encodedString* MHwrapper::fetchRawBody(const RecMail&mail) | 214 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) |
216 | { | 215 | { |
217 | encodedString*result = 0; | 216 | encodedString*result = 0; |
218 | init_storage(); | 217 | init_storage(); |
219 | if (!m_storage) { | 218 | if (!m_storage) { |
220 | return result; | 219 | return result; |
221 | } | 220 | } |
222 | mailmessage * msg = 0; | 221 | mailmessage * msg = 0; |
223 | char*data=0; | 222 | char*data=0; |
224 | size_t size; | 223 | size_t size; |
225 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 224 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
226 | if (r!=MAIL_NO_ERROR) { | 225 | if (r!=MAIL_NO_ERROR) { |
227 | qDebug("error selecting folder!"); | 226 | qDebug("error selecting folder!"); |
228 | return result; | 227 | return result; |
229 | } | 228 | } |
230 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); | 229 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
231 | if (r != MAIL_NO_ERROR) { | 230 | if (r != MAIL_NO_ERROR) { |
232 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 231 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
233 | return 0; | 232 | return 0; |
234 | } | 233 | } |
235 | r = mailmessage_fetch(msg,&data,&size); | 234 | r = mailmessage_fetch(msg,&data,&size); |
236 | if (r != MAIL_NO_ERROR) { | 235 | if (r != MAIL_NO_ERROR) { |
237 | Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber())); | 236 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
238 | if (msg) mailmessage_free(msg); | 237 | if (msg) mailmessage_free(msg); |
239 | return 0; | 238 | return 0; |
240 | } | 239 | } |
241 | result = new encodedString(data,size); | 240 | result = new encodedString(data,size); |
242 | if (msg) mailmessage_free(msg); | 241 | if (msg) mailmessage_free(msg); |
243 | return result; | 242 | return result; |
244 | } | 243 | } |
245 | 244 | ||
246 | void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 245 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) |
247 | { | 246 | { |
248 | QString f = buildPath(mailbox); | 247 | QString f = buildPath(mailbox); |
249 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 248 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
250 | if (r!=MAIL_NO_ERROR) { | 249 | if (r!=MAIL_NO_ERROR) { |
251 | qDebug("deleteMails: error selecting folder!"); | 250 | qDebug("deleteMails: error selecting folder!"); |
252 | return; | 251 | return; |
253 | } | 252 | } |
254 | RecMail*c = 0; | 253 | QValueList<RecMailP>::ConstIterator it; |
255 | for (unsigned int i=0; i < target.count();++i) { | 254 | for (it=target.begin(); it!=target.end();++it) { |
256 | c = target.at(i); | 255 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); |
257 | r = mailsession_remove_message(m_storage->sto_session,c->getNumber()); | ||
258 | if (r != MAIL_NO_ERROR) { | 256 | if (r != MAIL_NO_ERROR) { |
259 | qDebug("error deleting mail"); | 257 | qDebug("error deleting mail"); |
260 | break; | 258 | break; |
261 | } | 259 | } |
262 | } | 260 | } |
263 | } | 261 | } |
264 | 262 | ||
265 | int MHwrapper::deleteAllMail(const FolderP&tfolder) | 263 | int MHwrapper::deleteAllMail(const FolderP&tfolder) |
266 | { | 264 | { |
267 | init_storage(); | 265 | init_storage(); |
268 | if (!m_storage) { | 266 | if (!m_storage) { |
269 | return 0; | 267 | return 0; |
@@ -363,46 +361,46 @@ void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | |||
363 | } | 361 | } |
364 | } | 362 | } |
365 | 363 | ||
366 | MAILLIB::ATYPE MHwrapper::getType()const | 364 | MAILLIB::ATYPE MHwrapper::getType()const |
367 | { | 365 | { |
368 | return MAILLIB::A_MH; | 366 | return MAILLIB::A_MH; |
369 | } | 367 | } |
370 | 368 | ||
371 | const QString&MHwrapper::getName()const | 369 | const QString&MHwrapper::getName()const |
372 | { | 370 | { |
373 | return MHName; | 371 | return MHName; |
374 | } | 372 | } |
375 | void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 373 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
376 | { | 374 | { |
377 | init_storage(); | 375 | init_storage(); |
378 | if (!m_storage) { | 376 | if (!m_storage) { |
379 | return; | 377 | return; |
380 | } | 378 | } |
381 | if (targetWrapper != this) { | 379 | if (targetWrapper != this) { |
382 | qDebug("Using generic"); | 380 | qDebug("Using generic"); |
383 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 381 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
384 | return; | 382 | return; |
385 | } | 383 | } |
386 | qDebug("Using internal routines for move/copy"); | 384 | qDebug("Using internal routines for move/copy"); |
387 | QString tf = buildPath(targetFolder); | 385 | QString tf = buildPath(targetFolder); |
388 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 386 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
389 | if (r != MAIL_NO_ERROR) { | 387 | if (r != MAIL_NO_ERROR) { |
390 | qDebug("Error selecting source mailbox"); | 388 | qDebug("Error selecting source mailbox"); |
391 | return; | 389 | return; |
392 | } | 390 | } |
393 | if (moveit) { | 391 | if (moveit) { |
394 | r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | 392 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
395 | } else { | 393 | } else { |
396 | r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | 394 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
397 | } | 395 | } |
398 | if (r != MAIL_NO_ERROR) { | 396 | if (r != MAIL_NO_ERROR) { |
399 | qDebug("Error copy/moving mail internal (%i)",r); | 397 | qDebug("Error copy/moving mail internal (%i)",r); |
400 | } | 398 | } |
401 | } | 399 | } |
402 | 400 | ||
403 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, | 401 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, |
404 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 402 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
405 | { | 403 | { |
406 | init_storage(); | 404 | init_storage(); |
407 | if (!m_storage) { | 405 | if (!m_storage) { |
408 | return; | 406 | return; |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h index c7c8183..208cf2f 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.h +++ b/noncore/net/mail/libmailwrapper/mhwrapper.h | |||
@@ -1,55 +1,53 @@ | |||
1 | #ifndef __MH_WRAPPER_H | 1 | #ifndef __MH_WRAPPER_H |
2 | #define __MH_WRAPPER_H | 2 | #define __MH_WRAPPER_H |
3 | 3 | ||
4 | #include "maildefines.h" | 4 | #include "maildefines.h" |
5 | 5 | ||
6 | #include "genericwrapper.h" | 6 | #include "genericwrapper.h" |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | 8 | ||
9 | class RecMail; | ||
10 | class RecBody; | ||
11 | class encodedString; | 9 | class encodedString; |
12 | struct mailmbox_folder; | 10 | struct mailmbox_folder; |
13 | class OProcess; | 11 | class OProcess; |
14 | 12 | ||
15 | class MHwrapper : public Genericwrapper | 13 | class MHwrapper : public Genericwrapper |
16 | { | 14 | { |
17 | Q_OBJECT | 15 | Q_OBJECT |
18 | public: | 16 | public: |
19 | MHwrapper(const QString & dir,const QString&name); | 17 | MHwrapper(const QString & dir,const QString&name); |
20 | virtual ~MHwrapper(); | 18 | virtual ~MHwrapper(); |
21 | 19 | ||
22 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 20 | virtual void listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target ); |
23 | virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders(); | 21 | virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
25 | 23 | ||
26 | virtual void deleteMail(const RecMail&mail); | 24 | virtual void deleteMail(const RecMailP&mail); |
27 | virtual void answeredMail(const RecMail&mail); | 25 | virtual void answeredMail(const RecMailP&mail); |
28 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 26 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
29 | virtual void mvcpAllMails(const Opie::osmart_pointer<Folder>&fromFolder, | 27 | virtual void mvcpAllMails(const Opie::OSmartPointer<Folder>&fromFolder, |
30 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 28 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
31 | 29 | ||
32 | virtual int createMbox(const QString&folder,const Opie::osmart_pointer<Folder>&f=0, | 30 | virtual int createMbox(const QString&folder,const Opie::OSmartPointer<Folder>&f=0, |
33 | const QString&d="",bool s=false); | 31 | const QString&d="",bool s=false); |
34 | virtual int deleteMbox(const Opie::osmart_pointer<Folder>&); | 32 | virtual int deleteMbox(const Opie::OSmartPointer<Folder>&); |
35 | 33 | ||
36 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 34 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
37 | 35 | ||
38 | virtual RecBody fetchBody( const RecMail &mail ); | 36 | virtual RecBody fetchBody( const RecMailP &mail ); |
39 | static void mbox_progress( size_t current, size_t maximum ); | 37 | static void mbox_progress( size_t current, size_t maximum ); |
40 | 38 | ||
41 | virtual encodedString* fetchRawBody(const RecMail&mail); | 39 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
42 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); | 40 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::OSmartPointer<RecMail> > &target); |
43 | virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&); | 41 | virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&); |
44 | virtual MAILLIB::ATYPE getType()const; | 42 | virtual MAILLIB::ATYPE getType()const; |
45 | virtual const QString&getName()const; | 43 | virtual const QString&getName()const; |
46 | 44 | ||
47 | public slots: | 45 | public slots: |
48 | /* for deleting maildirs we are using a system call */ | 46 | /* for deleting maildirs we are using a system call */ |
49 | virtual void oprocessStderr(OProcess*, char *buffer, int ); | 47 | virtual void oprocessStderr(OProcess*, char *buffer, int ); |
50 | virtual void processEnded(OProcess *); | 48 | virtual void processEnded(OProcess *); |
51 | protected: | 49 | protected: |
52 | QString buildPath(const QString&p); | 50 | QString buildPath(const QString&p); |
53 | QString MHPath; | 51 | QString MHPath; |
54 | QString MHName; | 52 | QString MHName; |
55 | 53 | ||
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index 2ec052c..c0b3eec 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -23,52 +23,52 @@ NNTPwrapper::~NNTPwrapper() { | |||
23 | logout(); | 23 | logout(); |
24 | QFile msg_cache(msgTempName); | 24 | QFile msg_cache(msgTempName); |
25 | if (msg_cache.exists()) { | 25 | if (msg_cache.exists()) { |
26 | msg_cache.remove(); | 26 | msg_cache.remove(); |
27 | } | 27 | } |
28 | } | 28 | } |
29 | 29 | ||
30 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { | 30 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { |
31 | qDebug( "NNTP: %i of %i", current, maximum ); | 31 | qDebug( "NNTP: %i of %i", current, maximum ); |
32 | } | 32 | } |
33 | 33 | ||
34 | 34 | ||
35 | RecBody NNTPwrapper::fetchBody( const RecMail &mail ) { | 35 | RecBody NNTPwrapper::fetchBody( const RecMailP &mail ) { |
36 | int err = NEWSNNTP_NO_ERROR; | 36 | int err = NEWSNNTP_NO_ERROR; |
37 | char *message = 0; | 37 | char *message = 0; |
38 | size_t length = 0; | 38 | size_t length = 0; |
39 | 39 | ||
40 | login(); | 40 | login(); |
41 | if ( !m_nntp ) { | 41 | if ( !m_nntp ) { |
42 | return RecBody(); | 42 | return RecBody(); |
43 | } | 43 | } |
44 | 44 | ||
45 | RecBody body; | 45 | RecBody body; |
46 | mailmessage * mailmsg; | 46 | mailmessage * mailmsg; |
47 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { | 47 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { |
48 | qDebug("Message to large: %i",mail.Msgsize()); | 48 | qDebug("Message to large: %i",mail->Msgsize()); |
49 | return body; | 49 | return body; |
50 | } | 50 | } |
51 | 51 | ||
52 | QFile msg_cache(msgTempName); | 52 | QFile msg_cache(msgTempName); |
53 | 53 | ||
54 | cleanMimeCache(); | 54 | cleanMimeCache(); |
55 | 55 | ||
56 | if (mail.getNumber()!=last_msg_id) { | 56 | if (mail->getNumber()!=last_msg_id) { |
57 | if (msg_cache.exists()) { | 57 | if (msg_cache.exists()) { |
58 | msg_cache.remove(); | 58 | msg_cache.remove(); |
59 | } | 59 | } |
60 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 60 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
61 | last_msg_id = mail.getNumber(); | 61 | last_msg_id = mail->getNumber(); |
62 | err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); | 62 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); |
63 | err = mailmessage_fetch(mailmsg,&message,&length); | 63 | err = mailmessage_fetch(mailmsg,&message,&length); |
64 | msg_cache.writeBlock(message,length); | 64 | msg_cache.writeBlock(message,length); |
65 | } else { | 65 | } else { |
66 | QString msg=""; | 66 | QString msg=""; |
67 | msg_cache.open(IO_ReadOnly); | 67 | msg_cache.open(IO_ReadOnly); |
68 | message = new char[4096]; | 68 | message = new char[4096]; |
69 | memset(message,0,4096); | 69 | memset(message,0,4096); |
70 | while (msg_cache.readBlock(message,4095)>0) { | 70 | while (msg_cache.readBlock(message,4095)>0) { |
71 | msg+=message; | 71 | msg+=message; |
72 | memset(message,0,4096); | 72 | memset(message,0,4096); |
73 | } | 73 | } |
74 | delete message; | 74 | delete message; |
@@ -87,25 +87,25 @@ RecBody NNTPwrapper::fetchBody( const RecMail &mail ) { | |||
87 | body = parseMail(mailmsg); | 87 | body = parseMail(mailmsg); |
88 | 88 | ||
89 | /* clean up */ | 89 | /* clean up */ |
90 | if (mailmsg) | 90 | if (mailmsg) |
91 | mailmessage_free(mailmsg); | 91 | mailmessage_free(mailmsg); |
92 | if (message) | 92 | if (message) |
93 | free(message); | 93 | free(message); |
94 | 94 | ||
95 | return body; | 95 | return body; |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | void NNTPwrapper::listMessages(const QString & which, QList<RecMail> &target ) | 99 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::OSmartPointer<RecMail> > &target ) |
100 | { | 100 | { |
101 | login(); | 101 | login(); |
102 | if (!m_nntp) | 102 | if (!m_nntp) |
103 | return; | 103 | return; |
104 | uint32_t res_messages,res_recent,res_unseen; | 104 | uint32_t res_messages,res_recent,res_unseen; |
105 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); | 105 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); |
106 | parseList(target,m_nntp->sto_session,which,true); | 106 | parseList(target,m_nntp->sto_session,which,true); |
107 | } | 107 | } |
108 | 108 | ||
109 | void NNTPwrapper::login() | 109 | void NNTPwrapper::login() |
110 | { | 110 | { |
111 | if (account->getOffline()) | 111 | if (account->getOffline()) |
@@ -179,27 +179,27 @@ void NNTPwrapper::login() | |||
179 | 179 | ||
180 | } | 180 | } |
181 | 181 | ||
182 | void NNTPwrapper::logout() | 182 | void NNTPwrapper::logout() |
183 | { | 183 | { |
184 | int err = NEWSNNTP_NO_ERROR; | 184 | int err = NEWSNNTP_NO_ERROR; |
185 | if ( m_nntp == NULL ) | 185 | if ( m_nntp == NULL ) |
186 | return; | 186 | return; |
187 | mailstorage_free(m_nntp); | 187 | mailstorage_free(m_nntp); |
188 | m_nntp = 0; | 188 | m_nntp = 0; |
189 | } | 189 | } |
190 | 190 | ||
191 | QValueList<Opie::osmart_pointer<Folder> >* NNTPwrapper::listFolders() { | 191 | QValueList<Opie::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { |
192 | 192 | ||
193 | QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<Opie::osmart_pointer<Folder> >(); | 193 | QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >(); |
194 | QStringList groups; | 194 | QStringList groups; |
195 | if (account) { | 195 | if (account) { |
196 | groups = account->getGroups(); | 196 | groups = account->getGroups(); |
197 | } | 197 | } |
198 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { | 198 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { |
199 | folders->append(new Folder((*it),".")); | 199 | folders->append(new Folder((*it),".")); |
200 | } | 200 | } |
201 | return folders; | 201 | return folders; |
202 | } | 202 | } |
203 | 203 | ||
204 | /* we made this method in raw nntp access of etpan and not via generic interface | 204 | /* we made this method in raw nntp access of etpan and not via generic interface |
205 | * 'cause in that case there will be doubled copy operations. eg. the etpan would | 205 | * 'cause in that case there will be doubled copy operations. eg. the etpan would |
@@ -230,54 +230,54 @@ QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { | |||
230 | group = ( newsnntp_group_description* ) current->data; | 230 | group = ( newsnntp_group_description* ) current->data; |
231 | if (!group||!group->grp_name||strlen(group->grp_name)==0) continue; | 231 | if (!group||!group->grp_name||strlen(group->grp_name)==0) continue; |
232 | res.append(group->grp_name); | 232 | res.append(group->grp_name); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | } | 235 | } |
236 | if (result) { | 236 | if (result) { |
237 | newsnntp_list_free(result); | 237 | newsnntp_list_free(result); |
238 | } | 238 | } |
239 | return res; | 239 | return res; |
240 | } | 240 | } |
241 | 241 | ||
242 | void NNTPwrapper::answeredMail(const RecMail&) {} | 242 | void NNTPwrapper::answeredMail(const RecMailP&) {} |
243 | 243 | ||
244 | void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { | 244 | void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { |
245 | login(); | 245 | login(); |
246 | target_stat.message_count = 0; | 246 | target_stat.message_count = 0; |
247 | target_stat.message_unseen = 0; | 247 | target_stat.message_unseen = 0; |
248 | target_stat.message_recent = 0; | 248 | target_stat.message_recent = 0; |
249 | if (!m_nntp) | 249 | if (!m_nntp) |
250 | return; | 250 | return; |
251 | int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, | 251 | int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, |
252 | &target_stat.message_recent,&target_stat.message_unseen); | 252 | &target_stat.message_recent,&target_stat.message_unseen); |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { | 256 | encodedString* NNTPwrapper::fetchRawBody(const RecMailP&mail) { |
257 | char*target=0; | 257 | char*target=0; |
258 | size_t length=0; | 258 | size_t length=0; |
259 | encodedString*res = 0; | 259 | encodedString*res = 0; |
260 | mailmessage * mailmsg = 0; | 260 | mailmessage * mailmsg = 0; |
261 | int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); | 261 | int err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); |
262 | err = mailmessage_fetch(mailmsg,&target,&length); | 262 | err = mailmessage_fetch(mailmsg,&target,&length); |
263 | if (mailmsg) | 263 | if (mailmsg) |
264 | mailmessage_free(mailmsg); | 264 | mailmessage_free(mailmsg); |
265 | if (target) { | 265 | if (target) { |
266 | res = new encodedString(target,length); | 266 | res = new encodedString(target,length); |
267 | } | 267 | } |
268 | return res; | 268 | return res; |
269 | } | 269 | } |
270 | 270 | ||
271 | MAILLIB::ATYPE NNTPwrapper::getType()const { | 271 | MAILLIB::ATYPE NNTPwrapper::getType()const { |
272 | return account->getType(); | 272 | return account->getType(); |
273 | } | 273 | } |
274 | 274 | ||
275 | const QString&NNTPwrapper::getName()const{ | 275 | const QString&NNTPwrapper::getName()const{ |
276 | return account->getAccountName(); | 276 | return account->getAccountName(); |
277 | } | 277 | } |
278 | 278 | ||
279 | void NNTPwrapper::deleteMail(const RecMail&) { | 279 | void NNTPwrapper::deleteMail(const RecMailP&) { |
280 | } | 280 | } |
281 | 281 | ||
282 | int NNTPwrapper::deleteAllMail(const FolderP&) { | 282 | int NNTPwrapper::deleteAllMail(const FolderP&) { |
283 | } | 283 | } |
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h index d3a384a..a7e4b95 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.h +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h | |||
@@ -11,36 +11,36 @@ struct mailstorage; | |||
11 | struct mailfolder; | 11 | struct mailfolder; |
12 | 12 | ||
13 | class NNTPwrapper : public Genericwrapper | 13 | class NNTPwrapper : public Genericwrapper |
14 | { | 14 | { |
15 | 15 | ||
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | 17 | ||
18 | public: | 18 | public: |
19 | NNTPwrapper( NNTPaccount *a ); | 19 | NNTPwrapper( NNTPaccount *a ); |
20 | virtual ~NNTPwrapper(); | 20 | virtual ~NNTPwrapper(); |
21 | 21 | ||
22 | /* mailbox will be ignored */ | 22 | /* mailbox will be ignored */ |
23 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 23 | virtual void listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target ); |
24 | /* should only get the subscribed one */ | 24 | /* should only get the subscribed one */ |
25 | virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders(); | 25 | virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); |
26 | /* mailbox will be ignored */ | 26 | /* mailbox will be ignored */ |
27 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 27 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
28 | QStringList listAllNewsgroups(const QString&mask = QString::null); | 28 | QStringList listAllNewsgroups(const QString&mask = QString::null); |
29 | virtual void deleteMail(const RecMail&mail); | 29 | virtual void deleteMail(const RecMailP&mail); |
30 | virtual void answeredMail(const RecMail&mail); | 30 | virtual void answeredMail(const RecMailP&mail); |
31 | virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&); | 31 | virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&); |
32 | 32 | ||
33 | virtual RecBody fetchBody( const RecMail &mail ); | 33 | virtual RecBody fetchBody( const RecMailP &mail ); |
34 | virtual encodedString* fetchRawBody(const RecMail&mail); | 34 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
35 | virtual void logout(); | 35 | virtual void logout(); |
36 | virtual MAILLIB::ATYPE getType()const; | 36 | virtual MAILLIB::ATYPE getType()const; |
37 | virtual const QString&getName()const; | 37 | virtual const QString&getName()const; |
38 | static void nntp_progress( size_t current, size_t maximum ); | 38 | static void nntp_progress( size_t current, size_t maximum ); |
39 | 39 | ||
40 | protected: | 40 | protected: |
41 | void login(); | 41 | void login(); |
42 | NNTPaccount *account; | 42 | NNTPaccount *account; |
43 | mailstorage* m_nntp; | 43 | mailstorage* m_nntp; |
44 | 44 | ||
45 | 45 | ||
46 | }; | 46 | }; |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 7bf7ed2..6737d6c 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -21,52 +21,52 @@ POP3wrapper::POP3wrapper( POP3account *a ) | |||
21 | POP3wrapper::~POP3wrapper() { | 21 | POP3wrapper::~POP3wrapper() { |
22 | logout(); | 22 | logout(); |
23 | QFile msg_cache(msgTempName); | 23 | QFile msg_cache(msgTempName); |
24 | if (msg_cache.exists()) { | 24 | if (msg_cache.exists()) { |
25 | msg_cache.remove(); | 25 | msg_cache.remove(); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { | 29 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { |
30 | qDebug( "POP3: %i of %i", current, maximum ); | 30 | qDebug( "POP3: %i of %i", current, maximum ); |
31 | } | 31 | } |
32 | 32 | ||
33 | RecBody POP3wrapper::fetchBody( const RecMail &mail ) { | 33 | RecBody POP3wrapper::fetchBody( const RecMailP &mail ) { |
34 | int err = MAILPOP3_NO_ERROR; | 34 | int err = MAILPOP3_NO_ERROR; |
35 | char *message = 0; | 35 | char *message = 0; |
36 | size_t length = 0; | 36 | size_t length = 0; |
37 | 37 | ||
38 | login(); | 38 | login(); |
39 | if ( !m_pop3 ) { | 39 | if ( !m_pop3 ) { |
40 | return RecBody(); | 40 | return RecBody(); |
41 | } | 41 | } |
42 | 42 | ||
43 | RecBody body; | 43 | RecBody body; |
44 | mailmessage * mailmsg; | 44 | mailmessage * mailmsg; |
45 | if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) { | 45 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { |
46 | qDebug("Message to large: %i",mail.Msgsize()); | 46 | qDebug("Message to large: %i",mail->Msgsize()); |
47 | return body; | 47 | return body; |
48 | } | 48 | } |
49 | 49 | ||
50 | QFile msg_cache(msgTempName); | 50 | QFile msg_cache(msgTempName); |
51 | 51 | ||
52 | cleanMimeCache(); | 52 | cleanMimeCache(); |
53 | 53 | ||
54 | if (mail.getNumber()!=last_msg_id) { | 54 | if (mail->getNumber()!=last_msg_id) { |
55 | if (msg_cache.exists()) { | 55 | if (msg_cache.exists()) { |
56 | msg_cache.remove(); | 56 | msg_cache.remove(); |
57 | } | 57 | } |
58 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 58 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
59 | last_msg_id = mail.getNumber(); | 59 | last_msg_id = mail->getNumber(); |
60 | err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg); | 60 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
61 | err = mailmessage_fetch(mailmsg,&message,&length); | 61 | err = mailmessage_fetch(mailmsg,&message,&length); |
62 | msg_cache.writeBlock(message,length); | 62 | msg_cache.writeBlock(message,length); |
63 | } else { | 63 | } else { |
64 | QString msg=""; | 64 | QString msg=""; |
65 | msg_cache.open(IO_ReadOnly); | 65 | msg_cache.open(IO_ReadOnly); |
66 | message = new char[4096]; | 66 | message = new char[4096]; |
67 | memset(message,0,4096); | 67 | memset(message,0,4096); |
68 | while (msg_cache.readBlock(message,4095)>0) { | 68 | while (msg_cache.readBlock(message,4095)>0) { |
69 | msg+=message; | 69 | msg+=message; |
70 | memset(message,0,4096); | 70 | memset(message,0,4096); |
71 | } | 71 | } |
72 | delete message; | 72 | delete message; |
@@ -84,25 +84,25 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) { | |||
84 | } | 84 | } |
85 | body = parseMail(mailmsg); | 85 | body = parseMail(mailmsg); |
86 | 86 | ||
87 | /* clean up */ | 87 | /* clean up */ |
88 | if (mailmsg) | 88 | if (mailmsg) |
89 | mailmessage_free(mailmsg); | 89 | mailmessage_free(mailmsg); |
90 | if (message) | 90 | if (message) |
91 | free(message); | 91 | free(message); |
92 | 92 | ||
93 | return body; | 93 | return body; |
94 | } | 94 | } |
95 | 95 | ||
96 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | 96 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::OSmartPointer<RecMail> > &target ) |
97 | { | 97 | { |
98 | login(); | 98 | login(); |
99 | if (!m_pop3) | 99 | if (!m_pop3) |
100 | return; | 100 | return; |
101 | uint32_t res_messages,res_recent,res_unseen; | 101 | uint32_t res_messages,res_recent,res_unseen; |
102 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 102 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
103 | parseList(target,m_pop3->sto_session,"INBOX"); | 103 | parseList(target,m_pop3->sto_session,"INBOX"); |
104 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); | 104 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); |
105 | } | 105 | } |
106 | 106 | ||
107 | void POP3wrapper::login() | 107 | void POP3wrapper::login() |
108 | { | 108 | { |
@@ -160,50 +160,49 @@ void POP3wrapper::login() | |||
160 | 160 | ||
161 | err = mailstorage_connect(m_pop3); | 161 | err = mailstorage_connect(m_pop3); |
162 | if (err != MAIL_NO_ERROR) { | 162 | if (err != MAIL_NO_ERROR) { |
163 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); | 163 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); |
164 | Global::statusMessage(tr("Error initializing folder")); | 164 | Global::statusMessage(tr("Error initializing folder")); |
165 | mailstorage_free(m_pop3); | 165 | mailstorage_free(m_pop3); |
166 | m_pop3 = 0; | 166 | m_pop3 = 0; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | void POP3wrapper::logout() | 170 | void POP3wrapper::logout() |
171 | { | 171 | { |
172 | int err = MAILPOP3_NO_ERROR; | ||
173 | if ( m_pop3 == NULL ) | 172 | if ( m_pop3 == NULL ) |
174 | return; | 173 | return; |
175 | mailstorage_free(m_pop3); | 174 | mailstorage_free(m_pop3); |
176 | m_pop3 = 0; | 175 | m_pop3 = 0; |
177 | } | 176 | } |
178 | 177 | ||
179 | 178 | ||
180 | QValueList<Opie::osmart_pointer<Folder> >* POP3wrapper::listFolders() { | 179 | QValueList<Opie::OSmartPointer<Folder> >* POP3wrapper::listFolders() { |
181 | QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<FolderP>(); | 180 | QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); |
182 | FolderP inb=new Folder("INBOX","/"); | 181 | FolderP inb=new Folder("INBOX","/"); |
183 | folders->append(inb); | 182 | folders->append(inb); |
184 | return folders; | 183 | return folders; |
185 | } | 184 | } |
186 | 185 | ||
187 | void POP3wrapper::deleteMail(const RecMail&mail) { | 186 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
188 | login(); | 187 | login(); |
189 | if (!m_pop3) | 188 | if (!m_pop3) |
190 | return; | 189 | return; |
191 | int err = mailsession_remove_message(m_pop3->sto_session,mail.getNumber()); | 190 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
192 | if (err != MAIL_NO_ERROR) { | 191 | if (err != MAIL_NO_ERROR) { |
193 | Global::statusMessage(tr("error deleting mail")); | 192 | Global::statusMessage(tr("error deleting mail")); |
194 | } | 193 | } |
195 | } | 194 | } |
196 | 195 | ||
197 | void POP3wrapper::answeredMail(const RecMail&) {} | 196 | void POP3wrapper::answeredMail(const RecMailP&) {} |
198 | 197 | ||
199 | int POP3wrapper::deleteAllMail(const FolderP&) { | 198 | int POP3wrapper::deleteAllMail(const FolderP&) { |
200 | login(); | 199 | login(); |
201 | if (!m_pop3) | 200 | if (!m_pop3) |
202 | return 0; | 201 | return 0; |
203 | int res = 1; | 202 | int res = 1; |
204 | 203 | ||
205 | uint32_t result = 0; | 204 | uint32_t result = 0; |
206 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 205 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
207 | if (err != MAIL_NO_ERROR) { | 206 | if (err != MAIL_NO_ERROR) { |
208 | Global::statusMessage(tr("Error getting folder info")); | 207 | Global::statusMessage(tr("Error getting folder info")); |
209 | return 0; | 208 | return 0; |
@@ -219,32 +218,35 @@ int POP3wrapper::deleteAllMail(const FolderP&) { | |||
219 | return res; | 218 | return res; |
220 | } | 219 | } |
221 | 220 | ||
222 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | 221 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
223 | login(); | 222 | login(); |
224 | target_stat.message_count = 0; | 223 | target_stat.message_count = 0; |
225 | target_stat.message_unseen = 0; | 224 | target_stat.message_unseen = 0; |
226 | target_stat.message_recent = 0; | 225 | target_stat.message_recent = 0; |
227 | if (!m_pop3) | 226 | if (!m_pop3) |
228 | return; | 227 | return; |
229 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, | 228 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, |
230 | &target_stat.message_recent,&target_stat.message_unseen); | 229 | &target_stat.message_recent,&target_stat.message_unseen); |
230 | if (r != MAIL_NO_ERROR) { | ||
231 | qDebug("error getting folter status."); | ||
232 | } | ||
231 | } | 233 | } |
232 | 234 | ||
233 | encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) { | 235 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { |
234 | char*target=0; | 236 | char*target=0; |
235 | size_t length=0; | 237 | size_t length=0; |
236 | encodedString*res = 0; | 238 | encodedString*res = 0; |
237 | mailmessage * mailmsg = 0; | 239 | mailmessage * mailmsg = 0; |
238 | int err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg); | 240 | int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
239 | err = mailmessage_fetch(mailmsg,&target,&length); | 241 | err = mailmessage_fetch(mailmsg,&target,&length); |
240 | if (mailmsg) | 242 | if (mailmsg) |
241 | mailmessage_free(mailmsg); | 243 | mailmessage_free(mailmsg); |
242 | if (target) { | 244 | if (target) { |
243 | res = new encodedString(target,length); | 245 | res = new encodedString(target,length); |
244 | } | 246 | } |
245 | return res; | 247 | return res; |
246 | } | 248 | } |
247 | 249 | ||
248 | MAILLIB::ATYPE POP3wrapper::getType()const { | 250 | MAILLIB::ATYPE POP3wrapper::getType()const { |
249 | return account->getType(); | 251 | return account->getType(); |
250 | } | 252 | } |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index e4afb94..31eb6f1 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -8,35 +8,35 @@ | |||
8 | class encodedString; | 8 | class encodedString; |
9 | struct mailstorage; | 9 | struct mailstorage; |
10 | struct mailfolder; | 10 | struct mailfolder; |
11 | 11 | ||
12 | class POP3wrapper : public Genericwrapper | 12 | class POP3wrapper : public Genericwrapper |
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | 15 | ||
16 | public: | 16 | public: |
17 | POP3wrapper( POP3account *a ); | 17 | POP3wrapper( POP3account *a ); |
18 | virtual ~POP3wrapper(); | 18 | virtual ~POP3wrapper(); |
19 | /* mailbox will be ignored */ | 19 | /* mailbox will be ignored */ |
20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 20 | virtual void listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target ); |
21 | virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders(); | 21 | virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); |
22 | /* mailbox will be ignored */ | 22 | /* mailbox will be ignored */ |
23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
24 | 24 | ||
25 | virtual void deleteMail(const RecMail&mail); | 25 | virtual void deleteMail(const RecMailP&mail); |
26 | virtual void answeredMail(const RecMail&mail); | 26 | virtual void answeredMail(const RecMailP&mail); |
27 | virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&); | 27 | virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&); |
28 | 28 | ||
29 | virtual RecBody fetchBody( const RecMail &mail ); | 29 | virtual RecBody fetchBody( const RecMailP &mail ); |
30 | virtual encodedString* fetchRawBody(const RecMail&mail); | 30 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
31 | virtual void logout(); | 31 | virtual void logout(); |
32 | virtual MAILLIB::ATYPE getType()const; | 32 | virtual MAILLIB::ATYPE getType()const; |
33 | virtual const QString&getName()const; | 33 | virtual const QString&getName()const; |
34 | static void pop3_progress( size_t current, size_t maximum ); | 34 | static void pop3_progress( size_t current, size_t maximum ); |
35 | 35 | ||
36 | protected: | 36 | protected: |
37 | void login(); | 37 | void login(); |
38 | POP3account *account; | 38 | POP3account *account; |
39 | mailstorage*m_pop3; | 39 | mailstorage*m_pop3; |
40 | }; | 40 | }; |
41 | 41 | ||
42 | #endif | 42 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index afc5618..86673aa 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -303,53 +303,53 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) | |||
303 | result = 0; | 303 | result = 0; |
304 | } | 304 | } |
305 | 305 | ||
306 | if (!result) { | 306 | if (!result) { |
307 | storeFailedMail(data,size,failuretext); | 307 | storeFailedMail(data,size,failuretext); |
308 | } else { | 308 | } else { |
309 | qDebug( "Mail sent." ); | 309 | qDebug( "Mail sent." ); |
310 | storeMail(data,size,"Sent"); | 310 | storeMail(data,size,"Sent"); |
311 | } | 311 | } |
312 | return result; | 312 | return result; |
313 | } | 313 | } |
314 | 314 | ||
315 | void SMTPwrapper::sendMail(const Opie::osmart_pointer<Mail>&mail,bool later ) | 315 | void SMTPwrapper::sendMail(const Opie::OSmartPointer<Mail>&mail,bool later ) |
316 | { | 316 | { |
317 | mailmime * mimeMail; | 317 | mailmime * mimeMail; |
318 | 318 | ||
319 | mimeMail = createMimeMail(mail ); | 319 | mimeMail = createMimeMail(mail ); |
320 | if ( mimeMail == NULL ) { | 320 | if ( mimeMail == NULL ) { |
321 | qDebug( "sendMail: error creating mime mail" ); | 321 | qDebug( "sendMail: error creating mime mail" ); |
322 | } else { | 322 | } else { |
323 | sendProgress = new progressMailSend(); | 323 | sendProgress = new progressMailSend(); |
324 | sendProgress->show(); | 324 | sendProgress->show(); |
325 | sendProgress->setMaxMails(1); | 325 | sendProgress->setMaxMails(1); |
326 | smtpSend( mimeMail,later); | 326 | smtpSend( mimeMail,later); |
327 | qDebug("Clean up done"); | 327 | qDebug("Clean up done"); |
328 | sendProgress->hide(); | 328 | sendProgress->hide(); |
329 | delete sendProgress; | 329 | delete sendProgress; |
330 | sendProgress = 0; | 330 | sendProgress = 0; |
331 | mailmime_free( mimeMail ); | 331 | mailmime_free( mimeMail ); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,RecMail*which) { | 335 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { |
336 | size_t curTok = 0; | 336 | size_t curTok = 0; |
337 | mailimf_fields *fields = 0; | 337 | mailimf_fields *fields = 0; |
338 | mailimf_field*ffrom = 0; | 338 | mailimf_field*ffrom = 0; |
339 | clist *rcpts = 0; | 339 | clist *rcpts = 0; |
340 | char*from = 0; | 340 | char*from = 0; |
341 | int res = 0; | 341 | int res = 0; |
342 | 342 | ||
343 | encodedString * data = wrap->fetchRawBody(*which); | 343 | encodedString * data = wrap->fetchRawBody(which); |
344 | if (!data) | 344 | if (!data) |
345 | return 0; | 345 | return 0; |
346 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); | 346 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); |
347 | if (err != MAILIMF_NO_ERROR) { | 347 | if (err != MAILIMF_NO_ERROR) { |
348 | delete data; | 348 | delete data; |
349 | delete wrap; | 349 | delete wrap; |
350 | return 0; | 350 | return 0; |
351 | } | 351 | } |
352 | 352 | ||
353 | rcpts = createRcptList( fields ); | 353 | rcpts = createRcptList( fields ); |
354 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); | 354 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); |
355 | from = getFrom(ffrom); | 355 | from = getFrom(ffrom); |
@@ -382,26 +382,26 @@ bool SMTPwrapper::flushOutbox() { | |||
382 | qDebug("No smtp account given"); | 382 | qDebug("No smtp account given"); |
383 | return false; | 383 | return false; |
384 | } | 384 | } |
385 | 385 | ||
386 | bool reset_user_value = false; | 386 | bool reset_user_value = false; |
387 | QString localfolders = AbstractMail::defaultLocalfolder(); | 387 | QString localfolders = AbstractMail::defaultLocalfolder(); |
388 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); | 388 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
389 | if (!wrap) { | 389 | if (!wrap) { |
390 | qDebug("memory error"); | 390 | qDebug("memory error"); |
391 | return false; | 391 | return false; |
392 | } | 392 | } |
393 | QString oldPw, oldUser; | 393 | QString oldPw, oldUser; |
394 | QList<RecMail> mailsToSend; | 394 | QValueList<RecMailP> mailsToSend; |
395 | QList<RecMail> mailsToRemove; | 395 | QValueList<RecMailP> mailsToRemove; |
396 | QString mbox("Outgoing"); | 396 | QString mbox("Outgoing"); |
397 | wrap->listMessages(mbox,mailsToSend); | 397 | wrap->listMessages(mbox,mailsToSend); |
398 | if (mailsToSend.count()==0) { | 398 | if (mailsToSend.count()==0) { |
399 | delete wrap; | 399 | delete wrap; |
400 | qDebug("No mails to send"); | 400 | qDebug("No mails to send"); |
401 | return false; | 401 | return false; |
402 | } | 402 | } |
403 | 403 | ||
404 | oldPw = m_SmtpAccount->getPassword(); | 404 | oldPw = m_SmtpAccount->getPassword(); |
405 | oldUser = m_SmtpAccount->getUser(); | 405 | oldUser = m_SmtpAccount->getUser(); |
406 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { | 406 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { |
407 | // get'em | 407 | // get'em |
@@ -412,45 +412,43 @@ bool SMTPwrapper::flushOutbox() { | |||
412 | // ok | 412 | // ok |
413 | user = login.getUser().latin1(); | 413 | user = login.getUser().latin1(); |
414 | pass = login.getPassword().latin1(); | 414 | pass = login.getPassword().latin1(); |
415 | reset_user_value = true; | 415 | reset_user_value = true; |
416 | m_SmtpAccount->setUser(user); | 416 | m_SmtpAccount->setUser(user); |
417 | m_SmtpAccount->setPassword(pass); | 417 | m_SmtpAccount->setPassword(pass); |
418 | } else { | 418 | } else { |
419 | return true; | 419 | return true; |
420 | } | 420 | } |
421 | } | 421 | } |
422 | 422 | ||
423 | 423 | ||
424 | mailsToSend.setAutoDelete(false); | ||
425 | sendProgress = new progressMailSend(); | 424 | sendProgress = new progressMailSend(); |
426 | sendProgress->show(); | 425 | sendProgress->show(); |
427 | sendProgress->setMaxMails(mailsToSend.count()); | 426 | sendProgress->setMaxMails(mailsToSend.count()); |
428 | 427 | ||
429 | while (mailsToSend.count()>0) { | 428 | while (mailsToSend.count()>0) { |
430 | if (sendQueuedMail(wrap,mailsToSend.at(0))==0) { | 429 | if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) { |
431 | QMessageBox::critical(0,tr("Error sending mail"), | 430 | QMessageBox::critical(0,tr("Error sending mail"), |
432 | tr("Error sending queued mail - breaking")); | 431 | tr("Error sending queued mail - breaking")); |
433 | returnValue = false; | 432 | returnValue = false; |
434 | break; | 433 | break; |
435 | } | 434 | } |
436 | mailsToRemove.append(mailsToSend.at(0)); | 435 | mailsToRemove.append((*mailsToSend.begin())); |
437 | mailsToSend.removeFirst(); | 436 | mailsToSend.remove(mailsToSend.begin()); |
438 | sendProgress->setCurrentMails(mailsToRemove.count()); | 437 | sendProgress->setCurrentMails(mailsToRemove.count()); |
439 | } | 438 | } |
440 | if (reset_user_value) { | 439 | if (reset_user_value) { |
441 | m_SmtpAccount->setUser(oldUser); | 440 | m_SmtpAccount->setUser(oldUser); |
442 | m_SmtpAccount->setPassword(oldPw); | 441 | m_SmtpAccount->setPassword(oldPw); |
443 | } | 442 | } |
444 | Config cfg( "mail" ); | 443 | Config cfg( "mail" ); |
445 | cfg.setGroup( "Status" ); | 444 | cfg.setGroup( "Status" ); |
446 | m_queuedMail = 0; | 445 | m_queuedMail = 0; |
447 | cfg.writeEntry( "outgoing", m_queuedMail ); | 446 | cfg.writeEntry( "outgoing", m_queuedMail ); |
448 | emit queuedMails( m_queuedMail ); | 447 | emit queuedMails( m_queuedMail ); |
449 | sendProgress->hide(); | 448 | sendProgress->hide(); |
450 | delete sendProgress; | 449 | delete sendProgress; |
451 | sendProgress = 0; | 450 | sendProgress = 0; |
452 | wrap->deleteMails(mbox,mailsToRemove); | 451 | wrap->deleteMails(mbox,mailsToRemove); |
453 | mailsToSend.setAutoDelete(true); | ||
454 | delete wrap; | 452 | delete wrap; |
455 | return returnValue; | 453 | return returnValue; |
456 | } | 454 | } |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h index 08bde74..71ae35c 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.h +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h | |||
@@ -2,37 +2,37 @@ | |||
2 | #ifndef SMTPwrapper_H | 2 | #ifndef SMTPwrapper_H |
3 | #define SMTPwrapper_H | 3 | #define SMTPwrapper_H |
4 | 4 | ||
5 | #include <qpe/applnk.h> | 5 | #include <qpe/applnk.h> |
6 | 6 | ||
7 | #include <qbitarray.h> | 7 | #include <qbitarray.h> |
8 | #include <qdatetime.h> | 8 | #include <qdatetime.h> |
9 | #include <libetpan/clist.h> | 9 | #include <libetpan/clist.h> |
10 | 10 | ||
11 | #include "settings.h" | 11 | #include "settings.h" |
12 | #include "generatemail.h" | 12 | #include "generatemail.h" |
13 | 13 | ||
14 | #include <opie2/osmart_pointer.h> | 14 | #include <opie2/osmartpointer.h> |
15 | 15 | ||
16 | class SMTPaccount; | 16 | class SMTPaccount; |
17 | class AbstractMail; | 17 | class AbstractMail; |
18 | 18 | ||
19 | class SMTPwrapper : public Generatemail | 19 | class SMTPwrapper : public Generatemail |
20 | { | 20 | { |
21 | Q_OBJECT | 21 | Q_OBJECT |
22 | 22 | ||
23 | public: | 23 | public: |
24 | SMTPwrapper(SMTPaccount * aSmtp); | 24 | SMTPwrapper(SMTPaccount * aSmtp); |
25 | virtual ~SMTPwrapper(); | 25 | virtual ~SMTPwrapper(); |
26 | void sendMail(const Opie::osmart_pointer<Mail>& mail,bool later=false ); | 26 | void sendMail(const Opie::OSmartPointer<Mail>& mail,bool later=false ); |
27 | bool flushOutbox(); | 27 | bool flushOutbox(); |
28 | 28 | ||
29 | static progressMailSend*sendProgress; | 29 | static progressMailSend*sendProgress; |
30 | 30 | ||
31 | signals: | 31 | signals: |
32 | void queuedMails( int ); | 32 | void queuedMails( int ); |
33 | 33 | ||
34 | protected: | 34 | protected: |
35 | mailsmtp *m_smtp; | 35 | mailsmtp *m_smtp; |
36 | SMTPaccount * m_SmtpAccount; | 36 | SMTPaccount * m_SmtpAccount; |
37 | 37 | ||
38 | void connect_server(); | 38 | void connect_server(); |
@@ -41,23 +41,23 @@ protected: | |||
41 | 41 | ||
42 | 42 | ||
43 | void smtpSend( mailmime *mail,bool later); | 43 | void smtpSend( mailmime *mail,bool later); |
44 | 44 | ||
45 | static void storeMail(const char*mail, size_t length, const QString&box); | 45 | static void storeMail(const char*mail, size_t length, const QString&box); |
46 | static QString mailsmtpError( int err ); | 46 | static QString mailsmtpError( int err ); |
47 | static void progress( size_t current, size_t maximum ); | 47 | static void progress( size_t current, size_t maximum ); |
48 | 48 | ||
49 | int smtpSend(char*from,clist*rcpts,const char*data,size_t size); | 49 | int smtpSend(char*from,clist*rcpts,const char*data,size_t size); |
50 | 50 | ||
51 | void storeMail(mailmime*mail, const QString&box); | 51 | void storeMail(mailmime*mail, const QString&box); |
52 | 52 | ||
53 | int sendQueuedMail(AbstractMail*wrap,RecMail*which); | 53 | int sendQueuedMail(AbstractMail*wrap,const Opie::OSmartPointer<RecMail>&which); |
54 | void storeFailedMail(const char*data,unsigned int size, const char*failuremessage); | 54 | void storeFailedMail(const char*data,unsigned int size, const char*failuremessage); |
55 | 55 | ||
56 | int m_queuedMail; | 56 | int m_queuedMail; |
57 | 57 | ||
58 | protected slots: | 58 | protected slots: |
59 | void emitQCop( int queued ); | 59 | void emitQCop( int queued ); |
60 | 60 | ||
61 | }; | 61 | }; |
62 | 62 | ||
63 | #endif | 63 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/storemail.cpp b/noncore/net/mail/libmailwrapper/storemail.cpp index 052e0f1..595e7fc 100644 --- a/noncore/net/mail/libmailwrapper/storemail.cpp +++ b/noncore/net/mail/libmailwrapper/storemail.cpp | |||
@@ -40,25 +40,25 @@ Storemail::Storemail(const QString&aFolder) | |||
40 | m_Account = 0; | 40 | m_Account = 0; |
41 | m_tfolder = aFolder; | 41 | m_tfolder = aFolder; |
42 | wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); | 42 | wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); |
43 | if (wrapper) { | 43 | if (wrapper) { |
44 | wrapper->createMbox(m_tfolder); | 44 | wrapper->createMbox(m_tfolder); |
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 | ||
48 | Storemail::~Storemail() | 48 | Storemail::~Storemail() |
49 | { | 49 | { |
50 | } | 50 | } |
51 | 51 | ||
52 | int Storemail::storeMail(const Opie::osmart_pointer<Mail>&mail) | 52 | int Storemail::storeMail(const Opie::OSmartPointer<Mail>&mail) |
53 | { | 53 | { |
54 | if (!wrapper) return 0; | 54 | if (!wrapper) return 0; |
55 | int ret = 1; | 55 | int ret = 1; |
56 | 56 | ||
57 | mailmime * mimeMail = 0; | 57 | mailmime * mimeMail = 0; |
58 | mimeMail = createMimeMail(mail ); | 58 | mimeMail = createMimeMail(mail ); |
59 | if ( mimeMail == NULL ) { | 59 | if ( mimeMail == NULL ) { |
60 | qDebug( "storeMail: error creating mime mail" ); | 60 | qDebug( "storeMail: error creating mime mail" ); |
61 | return 0; | 61 | return 0; |
62 | } | 62 | } |
63 | char *data; | 63 | char *data; |
64 | size_t size; | 64 | size_t size; |
diff --git a/noncore/net/mail/libmailwrapper/storemail.h b/noncore/net/mail/libmailwrapper/storemail.h index 7d8ea3d..80c7431 100644 --- a/noncore/net/mail/libmailwrapper/storemail.h +++ b/noncore/net/mail/libmailwrapper/storemail.h | |||
@@ -9,21 +9,21 @@ class Account; | |||
9 | class Mail; | 9 | class Mail; |
10 | class AbstractMail; | 10 | class AbstractMail; |
11 | 11 | ||
12 | class Storemail : public Generatemail | 12 | class Storemail : public Generatemail |
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | public: | 15 | public: |
16 | Storemail(Account*aAccount,const QString&aFolder); | 16 | Storemail(Account*aAccount,const QString&aFolder); |
17 | Storemail(const QString&dir,const QString&aFolder); | 17 | Storemail(const QString&dir,const QString&aFolder); |
18 | Storemail(const QString&aFolder); | 18 | Storemail(const QString&aFolder); |
19 | virtual ~Storemail(); | 19 | virtual ~Storemail(); |
20 | 20 | ||
21 | int storeMail(const Opie::osmart_pointer<Mail>&mail); | 21 | int storeMail(const Opie::OSmartPointer<Mail>&mail); |
22 | 22 | ||
23 | protected: | 23 | protected: |
24 | Account* m_Account; | 24 | Account* m_Account; |
25 | QString m_tfolder; | 25 | QString m_tfolder; |
26 | AbstractMail*wrapper; | 26 | AbstractMail*wrapper; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | #endif | 29 | #endif |