Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
24 files changed, 82 insertions, 68 deletions
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 68a7a4d..6bebb7b 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -1,37 +1,38 @@ | |||
1 | #include "abstractmail.h" | 1 | #include "abstractmail.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "nntpwrapper.h" | 4 | #include "nntpwrapper.h" |
5 | #include "mhwrapper.h" | 5 | #include "mhwrapper.h" |
6 | #include "mailtypes.h" | 6 | #include "mailtypes.h" |
7 | 7 | ||
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <libetpan/mailmime_content.h> | 11 | #include <libetpan/mailmime_content.h> |
12 | #include <libetpan/mailmime.h> | 12 | #include <libetpan/mailmime.h> |
13 | 13 | ||
14 | using namespace Opie::Core; | ||
14 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 15 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
15 | { | 16 | { |
16 | return new IMAPwrapper(a); | 17 | return new IMAPwrapper(a); |
17 | } | 18 | } |
18 | 19 | ||
19 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 20 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
20 | { | 21 | { |
21 | return new POP3wrapper(a); | 22 | return new POP3wrapper(a); |
22 | } | 23 | } |
23 | 24 | ||
24 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | 25 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) |
25 | { | 26 | { |
26 | return new NNTPwrapper(a); | 27 | return new NNTPwrapper(a); |
27 | } | 28 | } |
28 | 29 | ||
29 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | 30 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
30 | { | 31 | { |
31 | return new MHwrapper(a,name); | 32 | return new MHwrapper(a,name); |
32 | } | 33 | } |
33 | 34 | ||
34 | AbstractMail* AbstractMail::getWrapper(Account*a) | 35 | AbstractMail* AbstractMail::getWrapper(Account*a) |
35 | { | 36 | { |
36 | if (!a) return 0; | 37 | if (!a) return 0; |
37 | switch (a->getType()) { | 38 | switch (a->getType()) { |
@@ -108,49 +109,49 @@ QString AbstractMail::gen_attachment_id() | |||
108 | 109 | ||
109 | QTextStream stream(&file); | 110 | QTextStream stream(&file); |
110 | 111 | ||
111 | return "{" + stream.read().stripWhiteSpace() + "}"; | 112 | return "{" + stream.read().stripWhiteSpace() + "}"; |
112 | } | 113 | } |
113 | 114 | ||
114 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) | 115 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) |
115 | { | 116 | { |
116 | return 0; | 117 | return 0; |
117 | } | 118 | } |
118 | 119 | ||
119 | QString AbstractMail::defaultLocalfolder() | 120 | QString AbstractMail::defaultLocalfolder() |
120 | { | 121 | { |
121 | QString f = getenv( "HOME" ); | 122 | QString f = getenv( "HOME" ); |
122 | f += "/Applications/opiemail/localmail"; | 123 | f += "/Applications/opiemail/localmail"; |
123 | return f; | 124 | return f; |
124 | } | 125 | } |
125 | 126 | ||
126 | QString AbstractMail::draftFolder() | 127 | QString AbstractMail::draftFolder() |
127 | { | 128 | { |
128 | return QString("Drafts"); | 129 | return QString("Drafts"); |
129 | } | 130 | } |
130 | 131 | ||
131 | /* temporary - will be removed when implemented in all classes */ | 132 | /* temporary - will be removed when implemented in all classes */ |
132 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::OSmartPointer<RecMail> > &) | 133 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) |
133 | { | 134 | { |
134 | } | 135 | } |
135 | 136 | ||
136 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 137 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
137 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 138 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
138 | { | 139 | { |
139 | QValueList<RecMailP> t; | 140 | QValueList<RecMailP> t; |
140 | listMessages(fromFolder->getName(),t); | 141 | listMessages(fromFolder->getName(),t); |
141 | encodedString*st = 0; | 142 | encodedString*st = 0; |
142 | while (t.count()>0) { | 143 | while (t.count()>0) { |
143 | RecMailP r = (*t.begin()); | 144 | RecMailP r = (*t.begin()); |
144 | st = fetchRawBody(r); | 145 | st = fetchRawBody(r); |
145 | if (st) { | 146 | if (st) { |
146 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 147 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
147 | delete st; | 148 | delete st; |
148 | } | 149 | } |
149 | t.remove(t.begin()); | 150 | t.remove(t.begin()); |
150 | } | 151 | } |
151 | if (moveit) { | 152 | if (moveit) { |
152 | deleteAllMail(fromFolder); | 153 | deleteAllMail(fromFolder); |
153 | } | 154 | } |
154 | } | 155 | } |
155 | 156 | ||
156 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 157 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index b03d757..2d55c83 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -1,72 +1,72 @@ | |||
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/osmartpointer.h> | 9 | #include <opie2/osmartpointer.h> |
10 | #include "mailtypes.h" | 10 | #include "mailtypes.h" |
11 | 11 | ||
12 | class IMAPwrapper; | 12 | class IMAPwrapper; |
13 | class POP3wrapper; | 13 | class POP3wrapper; |
14 | class Folder; | 14 | class Folder; |
15 | class encodedString; | 15 | class encodedString; |
16 | struct folderStat; | 16 | struct folderStat; |
17 | 17 | ||
18 | class AbstractMail:public QObject | 18 | class AbstractMail:public QObject |
19 | { | 19 | { |
20 | Q_OBJECT | 20 | Q_OBJECT |
21 | public: | 21 | public: |
22 | AbstractMail(){}; | 22 | AbstractMail(){}; |
23 | virtual ~AbstractMail(){} | 23 | virtual ~AbstractMail(){} |
24 | virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders()=0; | 24 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0; |
25 | virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target )=0; | 25 | virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target )=0; |
26 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | 26 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; |
27 | virtual RecBody fetchBody(const RecMailP&mail)=0; | 27 | virtual RecBody fetchBody(const RecMailP&mail)=0; |
28 | virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part)=0; | 28 | virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part)=0; |
29 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part)=0; | 29 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part)=0; |
30 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part)=0; | 30 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part)=0; |
31 | virtual encodedString* fetchRawBody(const RecMailP&mail)=0; | 31 | virtual encodedString* fetchRawBody(const RecMailP&mail)=0; |
32 | 32 | ||
33 | virtual void deleteMail(const RecMailP&mail)=0; | 33 | virtual void deleteMail(const RecMailP&mail)=0; |
34 | virtual void answeredMail(const RecMailP&mail)=0; | 34 | virtual void answeredMail(const RecMailP&mail)=0; |
35 | virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&)=0; | 35 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0; |
36 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::OSmartPointer<RecMail> >&target); | 36 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target); |
37 | virtual int deleteMbox(const Opie::OSmartPointer<Folder>&)=0; | 37 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0; |
38 | 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; |
39 | 39 | ||
40 | virtual void mvcpAllMails(const Opie::OSmartPointer<Folder>&fromFolder, | 40 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
41 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 41 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
42 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 42 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
43 | 43 | ||
44 | virtual void cleanMimeCache(){}; | 44 | virtual void cleanMimeCache(){}; |
45 | /* mail box methods */ | 45 | /* mail box methods */ |
46 | /* parameter is the box to create. | 46 | /* parameter is the box to create. |
47 | * if the implementing subclass has prefixes, | 47 | * if the implementing subclass has prefixes, |
48 | * them has to be appended automatic. | 48 | * them has to be appended automatic. |
49 | */ | 49 | */ |
50 | virtual int createMbox(const QString&,const Opie::OSmartPointer<Folder>&parentfolder=0, | 50 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, |
51 | const QString& delemiter="/",bool getsubfolder=false); | 51 | const QString& delemiter="/",bool getsubfolder=false); |
52 | virtual void logout()=0; | 52 | virtual void logout()=0; |
53 | 53 | ||
54 | static AbstractMail* getWrapper(IMAPaccount *a); | 54 | static AbstractMail* getWrapper(IMAPaccount *a); |
55 | static AbstractMail* getWrapper(POP3account *a); | 55 | static AbstractMail* getWrapper(POP3account *a); |
56 | static AbstractMail* getWrapper(NNTPaccount *a); | 56 | static AbstractMail* getWrapper(NNTPaccount *a); |
57 | /* mbox only! */ | 57 | /* mbox only! */ |
58 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); | 58 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
59 | static AbstractMail* getWrapper(Account*a); | 59 | static AbstractMail* getWrapper(Account*a); |
60 | 60 | ||
61 | static QString defaultLocalfolder(); | 61 | static QString defaultLocalfolder(); |
62 | static QString draftFolder(); | 62 | static QString draftFolder(); |
63 | 63 | ||
64 | virtual MAILLIB::ATYPE getType()const=0; | 64 | virtual MAILLIB::ATYPE getType()const=0; |
65 | virtual const QString&getName()const=0; | 65 | virtual const QString&getName()const=0; |
66 | 66 | ||
67 | protected: | 67 | protected: |
68 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 68 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
69 | static QString convert_String(const char*text); | 69 | static QString convert_String(const char*text); |
70 | static QString gen_attachment_id(); | 70 | static QString gen_attachment_id(); |
71 | }; | 71 | }; |
72 | #endif | 72 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/generatemail.cpp b/noncore/net/mail/libmailwrapper/generatemail.cpp index cb7ccc0..cb58d82 100644 --- a/noncore/net/mail/libmailwrapper/generatemail.cpp +++ b/noncore/net/mail/libmailwrapper/generatemail.cpp | |||
@@ -1,31 +1,32 @@ | |||
1 | #include "generatemail.h" | 1 | #include "generatemail.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | 3 | ||
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | 5 | ||
6 | #include <qt.h> | 6 | #include <qt.h> |
7 | 7 | ||
8 | using namespace Opie::Core; | ||
8 | const char* Generatemail::USER_AGENT="OpieMail v0.6"; | 9 | const char* Generatemail::USER_AGENT="OpieMail v0.6"; |
9 | 10 | ||
10 | Generatemail::Generatemail() | 11 | Generatemail::Generatemail() |
11 | { | 12 | { |
12 | } | 13 | } |
13 | 14 | ||
14 | Generatemail::~Generatemail() | 15 | Generatemail::~Generatemail() |
15 | { | 16 | { |
16 | } | 17 | } |
17 | 18 | ||
18 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { | 19 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { |
19 | clistiter *it, *it2; | 20 | clistiter *it, *it2; |
20 | 21 | ||
21 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { | 22 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { |
22 | mailimf_address *addr; | 23 | mailimf_address *addr; |
23 | addr = (mailimf_address *) it->data; | 24 | addr = (mailimf_address *) it->data; |
24 | 25 | ||
25 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { | 26 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { |
26 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); | 27 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); |
27 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { | 28 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { |
28 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; | 29 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; |
29 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { | 30 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { |
30 | mailimf_mailbox *mbox; | 31 | mailimf_mailbox *mbox; |
31 | mbox = (mailimf_mailbox *) it2->data; | 32 | mbox = (mailimf_mailbox *) it2->data; |
@@ -258,49 +259,49 @@ mailmime *Generatemail::buildTxtPart(const QString&str ) { | |||
258 | if ( err != MAILIMF_NO_ERROR ) | 259 | if ( err != MAILIMF_NO_ERROR ) |
259 | goto err_free_txtPart; | 260 | goto err_free_txtPart; |
260 | 261 | ||
261 | return txtPart; // Success :) | 262 | return txtPart; // Success :) |
262 | 263 | ||
263 | err_free_txtPart: | 264 | err_free_txtPart: |
264 | mailmime_free( txtPart ); | 265 | mailmime_free( txtPart ); |
265 | err_free_fields: | 266 | err_free_fields: |
266 | mailmime_fields_free( fields ); | 267 | mailmime_fields_free( fields ); |
267 | err_free_content: | 268 | err_free_content: |
268 | mailmime_content_free( content ); | 269 | mailmime_content_free( content ); |
269 | err_free_param: | 270 | err_free_param: |
270 | mailmime_parameter_free( param ); | 271 | mailmime_parameter_free( param ); |
271 | err_free: | 272 | err_free: |
272 | qDebug( "buildTxtPart - error" ); | 273 | qDebug( "buildTxtPart - error" ); |
273 | 274 | ||
274 | return NULL; // Error :( | 275 | return NULL; // Error :( |
275 | } | 276 | } |
276 | 277 | ||
277 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { | 278 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { |
278 | return mailimf_mailbox_new( strdup( name.latin1() ), | 279 | return mailimf_mailbox_new( strdup( name.latin1() ), |
279 | strdup( mail.latin1() ) ); | 280 | strdup( mail.latin1() ) ); |
280 | } | 281 | } |
281 | 282 | ||
282 | mailimf_fields *Generatemail::createImfFields(const Opie::OSmartPointer<Mail>&mail ) | 283 | mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail ) |
283 | { | 284 | { |
284 | mailimf_fields *fields = NULL; | 285 | mailimf_fields *fields = NULL; |
285 | mailimf_field *xmailer = NULL; | 286 | mailimf_field *xmailer = NULL; |
286 | mailimf_mailbox *sender=0,*fromBox=0; | 287 | mailimf_mailbox *sender=0,*fromBox=0; |
287 | mailimf_mailbox_list *from=0; | 288 | mailimf_mailbox_list *from=0; |
288 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; | 289 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; |
289 | clist*in_reply_to = 0; | 290 | clist*in_reply_to = 0; |
290 | char *subject = strdup( mail->getSubject().latin1() ); | 291 | char *subject = strdup( mail->getSubject().latin1() ); |
291 | int err; | 292 | int err; |
292 | int res = 1; | 293 | int res = 1; |
293 | 294 | ||
294 | sender = newMailbox( mail->getName(), mail->getMail() ); | 295 | sender = newMailbox( mail->getName(), mail->getMail() ); |
295 | if ( sender == NULL ) { | 296 | if ( sender == NULL ) { |
296 | res = 0; | 297 | res = 0; |
297 | } | 298 | } |
298 | 299 | ||
299 | if (res) { | 300 | if (res) { |
300 | fromBox = newMailbox( mail->getName(), mail->getMail() ); | 301 | fromBox = newMailbox( mail->getName(), mail->getMail() ); |
301 | } | 302 | } |
302 | if ( fromBox == NULL ) { | 303 | if ( fromBox == NULL ) { |
303 | res = 0; | 304 | res = 0; |
304 | } | 305 | } |
305 | 306 | ||
306 | if (res) { | 307 | if (res) { |
@@ -378,49 +379,49 @@ mailimf_fields *Generatemail::createImfFields(const Opie::OSmartPointer<Mail>&ma | |||
378 | if (reply) | 379 | if (reply) |
379 | mailimf_address_list_free( reply ); | 380 | mailimf_address_list_free( reply ); |
380 | if (bcc) | 381 | if (bcc) |
381 | mailimf_address_list_free( bcc ); | 382 | mailimf_address_list_free( bcc ); |
382 | if (cc) | 383 | if (cc) |
383 | mailimf_address_list_free( cc ); | 384 | mailimf_address_list_free( cc ); |
384 | if (to) | 385 | if (to) |
385 | mailimf_address_list_free( to ); | 386 | mailimf_address_list_free( to ); |
386 | if (fromBox) { | 387 | if (fromBox) { |
387 | mailimf_mailbox_free( fromBox ); | 388 | mailimf_mailbox_free( fromBox ); |
388 | } else if (from) { | 389 | } else if (from) { |
389 | mailimf_mailbox_list_free( from ); | 390 | mailimf_mailbox_list_free( from ); |
390 | } | 391 | } |
391 | if (sender) { | 392 | if (sender) { |
392 | mailimf_mailbox_free( sender ); | 393 | mailimf_mailbox_free( sender ); |
393 | } | 394 | } |
394 | if (subject) { | 395 | if (subject) { |
395 | free( subject ); | 396 | free( subject ); |
396 | } | 397 | } |
397 | } | 398 | } |
398 | } | 399 | } |
399 | return fields; | 400 | return fields; |
400 | } | 401 | } |
401 | 402 | ||
402 | mailmime *Generatemail::createMimeMail(const Opie::OSmartPointer<Mail> &mail ) { | 403 | mailmime *Generatemail::createMimeMail(const Opie::Core::OSmartPointer<Mail> &mail ) { |
403 | mailmime *message, *txtPart; | 404 | mailmime *message, *txtPart; |
404 | mailimf_fields *fields; | 405 | mailimf_fields *fields; |
405 | int err; | 406 | int err; |
406 | 407 | ||
407 | fields = createImfFields( mail ); | 408 | fields = createImfFields( mail ); |
408 | if ( fields == NULL ) | 409 | if ( fields == NULL ) |
409 | goto err_free; | 410 | goto err_free; |
410 | 411 | ||
411 | message = mailmime_new_message_data( NULL ); | 412 | message = mailmime_new_message_data( NULL ); |
412 | if ( message == NULL ) | 413 | if ( message == NULL ) |
413 | goto err_free_fields; | 414 | goto err_free_fields; |
414 | 415 | ||
415 | mailmime_set_imf_fields( message, fields ); | 416 | mailmime_set_imf_fields( message, fields ); |
416 | 417 | ||
417 | txtPart = buildTxtPart( mail->getMessage() ); | 418 | txtPart = buildTxtPart( mail->getMessage() ); |
418 | 419 | ||
419 | if ( txtPart == NULL ) | 420 | if ( txtPart == NULL ) |
420 | goto err_free_message; | 421 | goto err_free_message; |
421 | 422 | ||
422 | err = mailmime_smart_add_part( message, txtPart ); | 423 | err = mailmime_smart_add_part( message, txtPart ); |
423 | if ( err != MAILIMF_NO_ERROR ) | 424 | if ( err != MAILIMF_NO_ERROR ) |
424 | goto err_free_txtPart; | 425 | goto err_free_txtPart; |
425 | 426 | ||
426 | addFileParts( message, mail->getAttachments() ); | 427 | addFileParts( message, mail->getAttachments() ); |
diff --git a/noncore/net/mail/libmailwrapper/generatemail.h b/noncore/net/mail/libmailwrapper/generatemail.h index c246a2a..a767b61 100644 --- a/noncore/net/mail/libmailwrapper/generatemail.h +++ b/noncore/net/mail/libmailwrapper/generatemail.h | |||
@@ -15,32 +15,32 @@ 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 | ||
22 | class Generatemail : public QObject | 22 | class Generatemail : public QObject |
23 | { | 23 | { |
24 | Q_OBJECT | 24 | Q_OBJECT |
25 | public: | 25 | public: |
26 | Generatemail(); | 26 | Generatemail(); |
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::OSmartPointer<Mail> &mail ); | 39 | mailimf_fields *createImfFields(const Opie::Core::OSmartPointer<Mail> &mail ); |
40 | mailmime *createMimeMail(const Opie::OSmartPointer<Mail>&mail ); | 40 | mailmime *createMimeMail(const Opie::Core::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 ee2c8cd..f428415 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,28 +1,29 @@ | |||
1 | #include "genericwrapper.h" | 1 | #include "genericwrapper.h" |
2 | #include <libetpan/libetpan.h> | 2 | #include <libetpan/libetpan.h> |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | 4 | ||
5 | using namespace Opie::Core; | ||
5 | Genericwrapper::Genericwrapper() | 6 | Genericwrapper::Genericwrapper() |
6 | : AbstractMail() | 7 | : AbstractMail() |
7 | { | 8 | { |
8 | bodyCache.clear(); | 9 | bodyCache.clear(); |
9 | m_storage = 0; | 10 | m_storage = 0; |
10 | m_folder = 0; | 11 | m_folder = 0; |
11 | } | 12 | } |
12 | 13 | ||
13 | Genericwrapper::~Genericwrapper() | 14 | Genericwrapper::~Genericwrapper() |
14 | { | 15 | { |
15 | if (m_folder) { | 16 | if (m_folder) { |
16 | mailfolder_free(m_folder); | 17 | mailfolder_free(m_folder); |
17 | } | 18 | } |
18 | if (m_storage) { | 19 | if (m_storage) { |
19 | mailstorage_free(m_storage); | 20 | mailstorage_free(m_storage); |
20 | } | 21 | } |
21 | cleanMimeCache(); | 22 | cleanMimeCache(); |
22 | } | 23 | } |
23 | 24 | ||
24 | void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) | 25 | void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) |
25 | { | 26 | { |
26 | if (!mime) { | 27 | if (!mime) { |
27 | return; | 28 | return; |
28 | } | 29 | } |
@@ -366,49 +367,49 @@ void Genericwrapper::cleanMimeCache() | |||
366 | bodyCache.clear(); | 367 | bodyCache.clear(); |
367 | qDebug("Genericwrapper: cache cleaned"); | 368 | qDebug("Genericwrapper: cache cleaned"); |
368 | } | 369 | } |
369 | 370 | ||
370 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | 371 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) |
371 | { | 372 | { |
372 | QStringList res; | 373 | QStringList res; |
373 | if (!in_replies || !in_replies->mid_list) return res; | 374 | if (!in_replies || !in_replies->mid_list) return res; |
374 | clistiter * current = 0; | 375 | clistiter * current = 0; |
375 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { | 376 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { |
376 | QString h((char*)current->data); | 377 | QString h((char*)current->data); |
377 | while (h.length()>0 && h[0]=='<') { | 378 | while (h.length()>0 && h[0]=='<') { |
378 | h.remove(0,1); | 379 | h.remove(0,1); |
379 | } | 380 | } |
380 | while (h.length()>0 && h[h.length()-1]=='>') { | 381 | while (h.length()>0 && h[h.length()-1]=='>') { |
381 | h.remove(h.length()-1,1); | 382 | h.remove(h.length()-1,1); |
382 | } | 383 | } |
383 | if (h.length()>0) { | 384 | if (h.length()>0) { |
384 | res.append(h); | 385 | res.append(h); |
385 | } | 386 | } |
386 | } | 387 | } |
387 | return res; | 388 | return res; |
388 | } | 389 | } |
389 | 390 | ||
390 | void Genericwrapper::parseList(QValueList<Opie::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) | 391 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) |
391 | { | 392 | { |
392 | int r; | 393 | int r; |
393 | mailmessage_list * env_list = 0; | 394 | mailmessage_list * env_list = 0; |
394 | r = mailsession_get_messages_list(session,&env_list); | 395 | r = mailsession_get_messages_list(session,&env_list); |
395 | if (r != MAIL_NO_ERROR) { | 396 | if (r != MAIL_NO_ERROR) { |
396 | qDebug("Error message list"); | 397 | qDebug("Error message list"); |
397 | return; | 398 | return; |
398 | } | 399 | } |
399 | r = mailsession_get_envelopes_list(session, env_list); | 400 | r = mailsession_get_envelopes_list(session, env_list); |
400 | if (r != MAIL_NO_ERROR) { | 401 | if (r != MAIL_NO_ERROR) { |
401 | qDebug("Error filling message list"); | 402 | qDebug("Error filling message list"); |
402 | if (env_list) { | 403 | if (env_list) { |
403 | mailmessage_list_free(env_list); | 404 | mailmessage_list_free(env_list); |
404 | } | 405 | } |
405 | return; | 406 | return; |
406 | } | 407 | } |
407 | mailimf_references * refs = 0; | 408 | mailimf_references * refs = 0; |
408 | mailimf_in_reply_to * in_replies = 0; | 409 | mailimf_in_reply_to * in_replies = 0; |
409 | uint32_t i = 0; | 410 | uint32_t i = 0; |
410 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 411 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
411 | mailmessage * msg; | 412 | mailmessage * msg; |
412 | QBitArray mFlags(7); | 413 | QBitArray mFlags(7); |
413 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 414 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
414 | if (msg->msg_fields == NULL) { | 415 | if (msg->msg_fields == NULL) { |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h index f9968d1..f5b9504 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.h +++ b/noncore/net/mail/libmailwrapper/genericwrapper.h | |||
@@ -17,51 +17,51 @@ struct mailimf_mailbox_list; | |||
17 | struct mailimf_mailbox; | 17 | struct mailimf_mailbox; |
18 | struct mailimf_date_time; | 18 | struct mailimf_date_time; |
19 | struct mailimf_group; | 19 | struct mailimf_group; |
20 | struct mailimf_address_list; | 20 | struct mailimf_address_list; |
21 | struct mailsession; | 21 | struct mailsession; |
22 | struct mailstorage; | 22 | struct mailstorage; |
23 | struct mailfolder; | 23 | struct mailfolder; |
24 | struct mailimf_in_reply_to; | 24 | 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 RecMailP&mail,const RecPart&part); | 37 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part); |
38 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part); | 38 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part); |
39 | virtual QString fetchTextPart(const RecMailP&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::OSmartPointer<Folder>&){return 1;} | 41 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;} |
42 | virtual void logout(){}; | 42 | virtual void logout(){}; |
43 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; | 43 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; |
44 | 44 | ||
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(QValueList<Opie::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); | 57 | virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); |
58 | QStringList parseInreplies(mailimf_in_reply_to * in_replies); | 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 071e734..56e7df9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,32 +1,33 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <libetpan/libetpan.h> | 2 | #include <libetpan/libetpan.h> |
3 | #include <qpe/global.h> | 3 | #include <qpe/global.h> |
4 | 4 | ||
5 | #include "imapwrapper.h" | 5 | #include "imapwrapper.h" |
6 | #include "mailtypes.h" | 6 | #include "mailtypes.h" |
7 | #include "logindialog.h" | 7 | #include "logindialog.h" |
8 | 8 | ||
9 | using namespace Opie::Core; | ||
9 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 10 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
10 | : AbstractMail() | 11 | : AbstractMail() |
11 | { | 12 | { |
12 | account = a; | 13 | account = a; |
13 | m_imap = 0; | 14 | m_imap = 0; |
14 | m_Lastmbox = ""; | 15 | m_Lastmbox = ""; |
15 | } | 16 | } |
16 | 17 | ||
17 | IMAPwrapper::~IMAPwrapper() | 18 | IMAPwrapper::~IMAPwrapper() |
18 | { | 19 | { |
19 | logout(); | 20 | logout(); |
20 | } | 21 | } |
21 | 22 | ||
22 | /* to avoid to often select statements in loops etc. | 23 | /* to avoid to often select statements in loops etc. |
23 | we trust that we are logged in and connection is established!*/ | 24 | we trust that we are logged in and connection is established!*/ |
24 | int IMAPwrapper::selectMbox(const QString&mbox) | 25 | int IMAPwrapper::selectMbox(const QString&mbox) |
25 | { | 26 | { |
26 | if (mbox == m_Lastmbox) { | 27 | if (mbox == m_Lastmbox) { |
27 | return MAILIMAP_NO_ERROR; | 28 | return MAILIMAP_NO_ERROR; |
28 | } | 29 | } |
29 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 30 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
30 | if ( err != MAILIMAP_NO_ERROR ) { | 31 | if ( err != MAILIMAP_NO_ERROR ) { |
31 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 32 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
32 | m_Lastmbox = ""; | 33 | m_Lastmbox = ""; |
@@ -184,49 +185,49 @@ void IMAPwrapper::login() | |||
184 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 185 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
185 | if ( err != MAILIMAP_NO_ERROR ) { | 186 | if ( err != MAILIMAP_NO_ERROR ) { |
186 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); | 187 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); |
187 | ok = false; | 188 | ok = false; |
188 | } | 189 | } |
189 | } | 190 | } |
190 | if (!ok) { | 191 | if (!ok) { |
191 | err = mailimap_close( m_imap ); | 192 | err = mailimap_close( m_imap ); |
192 | mailimap_free( m_imap ); | 193 | mailimap_free( m_imap ); |
193 | m_imap = 0; | 194 | m_imap = 0; |
194 | } | 195 | } |
195 | } | 196 | } |
196 | 197 | ||
197 | void IMAPwrapper::logout() | 198 | void IMAPwrapper::logout() |
198 | { | 199 | { |
199 | int err = MAILIMAP_NO_ERROR; | 200 | int err = MAILIMAP_NO_ERROR; |
200 | if (!m_imap) return; | 201 | if (!m_imap) return; |
201 | err = mailimap_logout( m_imap ); | 202 | err = mailimap_logout( m_imap ); |
202 | err = mailimap_close( m_imap ); | 203 | err = mailimap_close( m_imap ); |
203 | mailimap_free( m_imap ); | 204 | mailimap_free( m_imap ); |
204 | m_imap = 0; | 205 | m_imap = 0; |
205 | m_Lastmbox = ""; | 206 | m_Lastmbox = ""; |
206 | } | 207 | } |
207 | 208 | ||
208 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::OSmartPointer<RecMail> > &target ) | 209 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
209 | { | 210 | { |
210 | int err = MAILIMAP_NO_ERROR; | 211 | int err = MAILIMAP_NO_ERROR; |
211 | clist *result = 0; | 212 | clist *result = 0; |
212 | clistcell *current; | 213 | clistcell *current; |
213 | mailimap_fetch_type *fetchType = 0; | 214 | mailimap_fetch_type *fetchType = 0; |
214 | mailimap_set *set = 0; | 215 | mailimap_set *set = 0; |
215 | 216 | ||
216 | login(); | 217 | login(); |
217 | if (!m_imap) { | 218 | if (!m_imap) { |
218 | return; | 219 | return; |
219 | } | 220 | } |
220 | /* select mailbox READONLY for operations */ | 221 | /* select mailbox READONLY for operations */ |
221 | err = selectMbox(mailbox); | 222 | err = selectMbox(mailbox); |
222 | if ( err != MAILIMAP_NO_ERROR ) { | 223 | if ( err != MAILIMAP_NO_ERROR ) { |
223 | return; | 224 | return; |
224 | } | 225 | } |
225 | 226 | ||
226 | int last = m_imap->imap_selection_info->sel_exists; | 227 | int last = m_imap->imap_selection_info->sel_exists; |
227 | 228 | ||
228 | if (last == 0) { | 229 | if (last == 0) { |
229 | Global::statusMessage(tr("Mailbox has no mails")); | 230 | Global::statusMessage(tr("Mailbox has no mails")); |
230 | return; | 231 | return; |
231 | } else { | 232 | } else { |
232 | } | 233 | } |
@@ -245,49 +246,49 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::OSmartPoin | |||
245 | 246 | ||
246 | QString date,subject,from; | 247 | QString date,subject,from; |
247 | 248 | ||
248 | if ( err == MAILIMAP_NO_ERROR ) { | 249 | if ( err == MAILIMAP_NO_ERROR ) { |
249 | mailimap_msg_att * msg_att; | 250 | mailimap_msg_att * msg_att; |
250 | int i = 0; | 251 | int i = 0; |
251 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 252 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
252 | ++i; | 253 | ++i; |
253 | msg_att = (mailimap_msg_att*)current->data; | 254 | msg_att = (mailimap_msg_att*)current->data; |
254 | RecMail*m = parse_list_result(msg_att); | 255 | RecMail*m = parse_list_result(msg_att); |
255 | if (m) { | 256 | if (m) { |
256 | m->setNumber(i); | 257 | m->setNumber(i); |
257 | m->setMbox(mailbox); | 258 | m->setMbox(mailbox); |
258 | m->setWrapper(this); | 259 | m->setWrapper(this); |
259 | target.append(m); | 260 | target.append(m); |
260 | } | 261 | } |
261 | } | 262 | } |
262 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | 263 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); |
263 | } else { | 264 | } else { |
264 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 265 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); |
265 | } | 266 | } |
266 | if (result) mailimap_fetch_list_free(result); | 267 | if (result) mailimap_fetch_list_free(result); |
267 | } | 268 | } |
268 | 269 | ||
269 | QValueList<Opie::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 270 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
270 | { | 271 | { |
271 | const char *path, *mask; | 272 | const char *path, *mask; |
272 | int err = MAILIMAP_NO_ERROR; | 273 | int err = MAILIMAP_NO_ERROR; |
273 | clist *result = 0; | 274 | clist *result = 0; |
274 | clistcell *current = 0; | 275 | clistcell *current = 0; |
275 | clistcell*cur_flag = 0; | 276 | clistcell*cur_flag = 0; |
276 | mailimap_mbx_list_flags*bflags = 0; | 277 | mailimap_mbx_list_flags*bflags = 0; |
277 | 278 | ||
278 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 279 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
279 | login(); | 280 | login(); |
280 | if (!m_imap) { | 281 | if (!m_imap) { |
281 | return folders; | 282 | return folders; |
282 | } | 283 | } |
283 | 284 | ||
284 | /* | 285 | /* |
285 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 286 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
286 | * We must not forget to filter them out in next loop! | 287 | * We must not forget to filter them out in next loop! |
287 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 288 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
288 | */ | 289 | */ |
289 | QString temp; | 290 | QString temp; |
290 | mask = "INBOX" ; | 291 | mask = "INBOX" ; |
291 | mailimap_mailbox_list *list; | 292 | mailimap_mailbox_list *list; |
292 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 293 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
293 | QString del; | 294 | QString del; |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 3bd5967..7448acb 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -2,69 +2,69 @@ | |||
2 | #define __IMAPWRAPPER | 2 | #define __IMAPWRAPPER |
3 | 3 | ||
4 | #include <qlist.h> | 4 | #include <qlist.h> |
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | #include "abstractmail.h" | 6 | #include "abstractmail.h" |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | struct mailimap; | 9 | struct mailimap; |
10 | struct mailimap_body; | 10 | struct mailimap_body; |
11 | struct mailimap_body_type_1part; | 11 | struct mailimap_body_type_1part; |
12 | struct mailimap_body_type_text; | 12 | struct mailimap_body_type_text; |
13 | struct mailimap_body_type_basic; | 13 | 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::OSmartPointer<Folder> >* listFolders(); | 26 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
27 | virtual void listMessages(const QString & mailbox,QValueList<Opie::OSmartPointer<RecMail> >&target ); | 27 | virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::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 RecMailP&mail); | 30 | virtual void deleteMail(const RecMailP&mail); |
31 | virtual void answeredMail(const RecMailP&mail); | 31 | virtual void answeredMail(const RecMailP&mail); |
32 | virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&folder); | 32 | virtual int deleteAllMail(const Opie::Core::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::OSmartPointer<Folder>&fromFolder, | 34 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
35 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 35 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
36 | virtual void mvcpMail(const RecMailP&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 RecMailP&mail); | 38 | virtual RecBody fetchBody(const RecMailP&mail); |
39 | virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part); | 39 | virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part); |
40 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part); | 40 | virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part); |
41 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part); | 41 | virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part); |
42 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 42 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
43 | 43 | ||
44 | virtual int createMbox(const QString&,const Opie::OSmartPointer<Folder>&parentfolder=0, | 44 | virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0, |
45 | const QString& delemiter="/",bool getsubfolder=false); | 45 | const QString& delemiter="/",bool getsubfolder=false); |
46 | virtual int deleteMbox(const Opie::OSmartPointer<Folder>&folder); | 46 | virtual int deleteMbox(const Opie::Core::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 RecMailP&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 RecMailP&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 RecMailP&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 */ |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index 7dd7e58..fd91fe5 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -1,35 +1,36 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | using namespace Opie::Core; | ||
4 | RecMail::RecMail() | 5 | RecMail::RecMail() |
5 | :Opie::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 6 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) |
6 | { | 7 | { |
7 | init(); | 8 | init(); |
8 | } | 9 | } |
9 | 10 | ||
10 | RecMail::RecMail(const RecMail&old) | 11 | RecMail::RecMail(const RecMail&old) |
11 | :Opie::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 12 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
12 | { | 13 | { |
13 | init(); | 14 | init(); |
14 | copy_old(old); | 15 | copy_old(old); |
15 | qDebug("Copy constructor RecMail"); | 16 | qDebug("Copy constructor RecMail"); |
16 | } | 17 | } |
17 | 18 | ||
18 | RecMail::~RecMail() | 19 | RecMail::~RecMail() |
19 | { | 20 | { |
20 | wrapper = 0; | 21 | wrapper = 0; |
21 | } | 22 | } |
22 | 23 | ||
23 | void RecMail::copy_old(const RecMail&old) | 24 | void RecMail::copy_old(const RecMail&old) |
24 | { | 25 | { |
25 | subject = old.subject; | 26 | subject = old.subject; |
26 | date = old.date; | 27 | date = old.date; |
27 | mbox = old.mbox; | 28 | mbox = old.mbox; |
28 | msg_id = old.msg_id; | 29 | msg_id = old.msg_id; |
29 | msg_size = old.msg_size; | 30 | msg_size = old.msg_size; |
30 | msg_number = old.msg_number; | 31 | msg_number = old.msg_number; |
31 | from = old.from; | 32 | from = old.from; |
32 | msg_flags = old.msg_flags; | 33 | msg_flags = old.msg_flags; |
33 | to = old.to; | 34 | to = old.to; |
34 | cc = old.cc; | 35 | cc = old.cc; |
35 | bcc = old.bcc; | 36 | bcc = old.bcc; |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index dc10de6..941556a 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -8,49 +8,49 @@ | |||
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> | 11 | #include <opie2/osmartpointer.h> |
12 | 12 | ||
13 | #include <qbitarray.h> | 13 | #include <qbitarray.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qstringlist.h> | 15 | #include <qstringlist.h> |
16 | #include <qmap.h> | 16 | #include <qmap.h> |
17 | #include <qvaluelist.h> | 17 | #include <qvaluelist.h> |
18 | 18 | ||
19 | class AbstractMail; | 19 | class AbstractMail; |
20 | /* a class to describe mails in a mailbox */ | 20 | /* a class to describe mails in a mailbox */ |
21 | /* Attention! | 21 | /* Attention! |
22 | From programmers point of view it would make sense to | 22 | From programmers point of view it would make sense to |
23 | store the mail body into this class, too. | 23 | store the mail body into this class, too. |
24 | But: not from the point of view of the device. | 24 | But: not from the point of view of the device. |
25 | Mailbodies can be real large. So we request them when | 25 | Mailbodies can be real large. So we request them when |
26 | needed from the mail-wrapper class direct from the server itself | 26 | needed from the mail-wrapper class direct from the server itself |
27 | (imap) or from a file-based cache (pop3?) | 27 | (imap) or from a file-based cache (pop3?) |
28 | So there is no interface "const QString&body()" but you should | 28 | So there is no interface "const QString&body()" but you should |
29 | 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 |
30 | get the body. Same words for the attachments. | 30 | get the body. Same words for the attachments. |
31 | */ | 31 | */ |
32 | class RecMail:public Opie::ORefCount | 32 | class RecMail:public Opie::Core::ORefCount |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | RecMail(); | 35 | RecMail(); |
36 | RecMail(const RecMail&old); | 36 | RecMail(const RecMail&old); |
37 | virtual ~RecMail(); | 37 | virtual ~RecMail(); |
38 | 38 | ||
39 | const unsigned int getNumber()const{return msg_number;} | 39 | const unsigned int getNumber()const{return msg_number;} |
40 | void setNumber(unsigned int number){msg_number=number;} | 40 | void setNumber(unsigned int number){msg_number=number;} |
41 | const QString&getDate()const{ return date; } | 41 | const QString&getDate()const{ return date; } |
42 | void setDate( const QString&a ) { date = a; } | 42 | void setDate( const QString&a ) { date = a; } |
43 | const QString&getFrom()const{ return from; } | 43 | const QString&getFrom()const{ return from; } |
44 | void setFrom( const QString&a ) { from = a; } | 44 | void setFrom( const QString&a ) { from = a; } |
45 | const QString&getSubject()const { return subject; } | 45 | const QString&getSubject()const { return subject; } |
46 | void setSubject( const QString&s ) { subject = s; } | 46 | void setSubject( const QString&s ) { subject = s; } |
47 | const QString&getMbox()const{return mbox;} | 47 | const QString&getMbox()const{return mbox;} |
48 | void setMbox(const QString&box){mbox = box;} | 48 | void setMbox(const QString&box){mbox = box;} |
49 | void setMsgid(const QString&id){msg_id=id;} | 49 | void setMsgid(const QString&id){msg_id=id;} |
50 | const QString&Msgid()const{return msg_id;} | 50 | const QString&Msgid()const{return msg_id;} |
51 | void setReplyto(const QString&reply){replyto=reply;} | 51 | void setReplyto(const QString&reply){replyto=reply;} |
52 | const QString&Replyto()const{return replyto;} | 52 | const QString&Replyto()const{return replyto;} |
53 | void setMsgsize(unsigned int size){msg_size = size;} | 53 | void setMsgsize(unsigned int size){msg_size = size;} |
54 | const unsigned int Msgsize()const{return msg_size;} | 54 | const unsigned int Msgsize()const{return msg_size;} |
55 | 55 | ||
56 | 56 | ||
@@ -60,49 +60,49 @@ public: | |||
60 | const QStringList&CC()const; | 60 | const QStringList&CC()const; |
61 | void setBcc(const QStringList&list); | 61 | void setBcc(const QStringList&list); |
62 | const QStringList&Bcc()const; | 62 | const QStringList&Bcc()const; |
63 | void setInreply(const QStringList&list); | 63 | void setInreply(const QStringList&list); |
64 | const QStringList&Inreply()const; | 64 | const QStringList&Inreply()const; |
65 | void setReferences(const QStringList&list); | 65 | void setReferences(const QStringList&list); |
66 | const QStringList&References()const; | 66 | const QStringList&References()const; |
67 | 67 | ||
68 | const QBitArray&getFlags()const{return msg_flags;} | 68 | const QBitArray&getFlags()const{return msg_flags;} |
69 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 69 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
70 | 70 | ||
71 | void setWrapper(AbstractMail*wrapper); | 71 | void setWrapper(AbstractMail*wrapper); |
72 | AbstractMail* Wrapper(); | 72 | AbstractMail* Wrapper(); |
73 | 73 | ||
74 | protected: | 74 | protected: |
75 | QString subject,date,from,mbox,msg_id,replyto; | 75 | QString subject,date,from,mbox,msg_id,replyto; |
76 | unsigned int msg_number,msg_size; | 76 | unsigned int msg_number,msg_size; |
77 | QBitArray msg_flags; | 77 | QBitArray msg_flags; |
78 | QStringList to,cc,bcc,in_reply_to,references; | 78 | QStringList to,cc,bcc,in_reply_to,references; |
79 | AbstractMail*wrapper; | 79 | AbstractMail*wrapper; |
80 | void init(); | 80 | void init(); |
81 | void copy_old(const RecMail&old); | 81 | void copy_old(const RecMail&old); |
82 | }; | 82 | }; |
83 | 83 | ||
84 | typedef Opie::OSmartPointer<RecMail> RecMailP; | 84 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; |
85 | typedef QMap<QString,QString> part_plist_t; | 85 | typedef QMap<QString,QString> part_plist_t; |
86 | 86 | ||
87 | class RecPart | 87 | class RecPart |
88 | { | 88 | { |
89 | protected: | 89 | protected: |
90 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 90 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
91 | unsigned int m_lines,m_size; | 91 | unsigned int m_lines,m_size; |
92 | part_plist_t m_Parameters; | 92 | part_plist_t m_Parameters; |
93 | /* describes the position in the mail */ | 93 | /* describes the position in the mail */ |
94 | QValueList<int> m_poslist; | 94 | QValueList<int> m_poslist; |
95 | 95 | ||
96 | public: | 96 | public: |
97 | RecPart(); | 97 | RecPart(); |
98 | virtual ~RecPart(); | 98 | virtual ~RecPart(); |
99 | 99 | ||
100 | const QString&Type()const; | 100 | const QString&Type()const; |
101 | void setType(const QString&type); | 101 | void setType(const QString&type); |
102 | const QString&Subtype()const; | 102 | const QString&Subtype()const; |
103 | void setSubtype(const QString&subtype); | 103 | void setSubtype(const QString&subtype); |
104 | const QString&Identifier()const; | 104 | const QString&Identifier()const; |
105 | void setIdentifier(const QString&identifier); | 105 | void setIdentifier(const QString&identifier); |
106 | const QString&Encoding()const; | 106 | const QString&Encoding()const; |
107 | void setEncoding(const QString&encoding); | 107 | void setEncoding(const QString&encoding); |
108 | const QString&Description()const; | 108 | const QString&Description()const; |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp index 9bf2fd3..eddc0b9 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp | |||
@@ -1,47 +1,48 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <sys/stat.h> | 2 | #include <sys/stat.h> |
3 | #include <sys/types.h> | 3 | #include <sys/types.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <fcntl.h> | 5 | #include <fcntl.h> |
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <qdir.h> | 7 | #include <qdir.h> |
8 | 8 | ||
9 | #include "mailwrapper.h" | 9 | #include "mailwrapper.h" |
10 | //#include "logindialog.h" | 10 | //#include "logindialog.h" |
11 | //#include "defines.h" | 11 | //#include "defines.h" |
12 | 12 | ||
13 | #define UNDEFINED 64 | 13 | #define UNDEFINED 64 |
14 | #define MAXLINE 76 | 14 | #define MAXLINE 76 |
15 | #define UTF16MASK 0x03FFUL | 15 | #define UTF16MASK 0x03FFUL |
16 | #define UTF16SHIFT 10 | 16 | #define UTF16SHIFT 10 |
17 | #define UTF16BASE 0x10000UL | 17 | #define UTF16BASE 0x10000UL |
18 | #define UTF16HIGHSTART 0xD800UL | 18 | #define UTF16HIGHSTART 0xD800UL |
19 | #define UTF16HIGHEND 0xDBFFUL | 19 | #define UTF16HIGHEND 0xDBFFUL |
20 | #define UTF16LOSTART 0xDC00UL | 20 | #define UTF16LOSTART 0xDC00UL |
21 | #define UTF16LOEND 0xDFFFUL | 21 | #define UTF16LOEND 0xDFFFUL |
22 | 22 | ||
23 | 23 | ||
24 | using namespace Opie::Core; | ||
24 | Attachment::Attachment( DocLnk lnk ) | 25 | Attachment::Attachment( DocLnk lnk ) |
25 | { | 26 | { |
26 | doc = lnk; | 27 | doc = lnk; |
27 | size = QFileInfo( doc.file() ).size(); | 28 | size = QFileInfo( doc.file() ).size(); |
28 | } | 29 | } |
29 | 30 | ||
30 | Folder::Folder(const QString&tmp_name, const QString&sep ) | 31 | Folder::Folder(const QString&tmp_name, const QString&sep ) |
31 | { | 32 | { |
32 | name = tmp_name; | 33 | name = tmp_name; |
33 | nameDisplay = name; | 34 | nameDisplay = name; |
34 | separator = sep; | 35 | separator = sep; |
35 | prefix = ""; | 36 | prefix = ""; |
36 | } | 37 | } |
37 | 38 | ||
38 | Folder::~Folder() | 39 | Folder::~Folder() |
39 | { | 40 | { |
40 | } | 41 | } |
41 | 42 | ||
42 | const QString& Folder::Separator()const | 43 | const QString& Folder::Separator()const |
43 | { | 44 | { |
44 | return separator; | 45 | return separator; |
45 | } | 46 | } |
46 | 47 | ||
47 | IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&aprefix ) | 48 | IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&aprefix ) |
@@ -134,45 +135,45 @@ QString IMAPFolder::decodeFolderName( const QString &name ) | |||
134 | i = 3; | 135 | i = 3; |
135 | } else { | 136 | } else { |
136 | utf8[0] = 0xf0 | (ucs4 >> 18); | 137 | utf8[0] = 0xf0 | (ucs4 >> 18); |
137 | utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f); | 138 | utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f); |
138 | utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f); | 139 | utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f); |
139 | utf8[3] = 0x80 | (ucs4 & 0x3f); | 140 | utf8[3] = 0x80 | (ucs4 & 0x3f); |
140 | i = 4; | 141 | i = 4; |
141 | } | 142 | } |
142 | /* copy it */ | 143 | /* copy it */ |
143 | for (c = 0; c < i; ++c) { | 144 | for (c = 0; c < i; ++c) { |
144 | dst += utf8[c]; | 145 | dst += utf8[c]; |
145 | } | 146 | } |
146 | } | 147 | } |
147 | } | 148 | } |
148 | /* skip over trailing '-' in modified UTF-7 encoding */ | 149 | /* skip over trailing '-' in modified UTF-7 encoding */ |
149 | if (src[srcPtr] == '-') | 150 | if (src[srcPtr] == '-') |
150 | ++srcPtr; | 151 | ++srcPtr; |
151 | } | 152 | } |
152 | } | 153 | } |
153 | 154 | ||
154 | return QString::fromUtf8( dst.data() ); | 155 | return QString::fromUtf8( dst.data() ); |
155 | } | 156 | } |
156 | 157 | ||
157 | Mail::Mail() | 158 | Mail::Mail() |
158 | :Opie::ORefCount(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") | 159 | :Opie::Core::ORefCount(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") |
159 | { | 160 | { |
160 | } | 161 | } |
161 | 162 | ||
162 | MHFolder::MHFolder(const QString&disp_name,const QString&mbox) | 163 | MHFolder::MHFolder(const QString&disp_name,const QString&mbox) |
163 | : Folder( disp_name,"/" ) | 164 | : Folder( disp_name,"/" ) |
164 | { | 165 | { |
165 | separator = "/"; | 166 | separator = "/"; |
166 | name = mbox; | 167 | name = mbox; |
167 | if (!disp_name.startsWith("/") && disp_name.length()>0) | 168 | if (!disp_name.startsWith("/") && disp_name.length()>0) |
168 | name+="/"; | 169 | name+="/"; |
169 | name+=disp_name; | 170 | name+=disp_name; |
170 | if (disp_name.length()==0) { | 171 | if (disp_name.length()==0) { |
171 | nameDisplay = separator; | 172 | nameDisplay = separator; |
172 | } | 173 | } |
173 | prefix = mbox; | 174 | prefix = mbox; |
174 | } | 175 | } |
175 | 176 | ||
176 | MHFolder::~MHFolder() | 177 | MHFolder::~MHFolder() |
177 | { | 178 | { |
178 | } | 179 | } |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index 6bf0078..542de03 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h | |||
@@ -7,100 +7,100 @@ | |||
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | 8 | ||
9 | #include "settings.h" | 9 | #include "settings.h" |
10 | 10 | ||
11 | #include <opie2/osmartpointer.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::ORefCount | 31 | class Mail:public Opie::Core::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 ); } |
44 | const QString&getName()const { return name; } | 44 | const QString&getName()const { return name; } |
45 | void setName( QString s ) { name = s; } | 45 | void setName( QString s ) { name = s; } |
46 | const QString&getMail()const{ return mail; } | 46 | const QString&getMail()const{ return mail; } |
47 | void setMail( const QString&s ) { mail = s; } | 47 | void setMail( const QString&s ) { mail = s; } |
48 | const QString&getTo()const{ return to; } | 48 | const QString&getTo()const{ return to; } |
49 | void setTo( const QString&s ) { to = s; } | 49 | void setTo( const QString&s ) { to = s; } |
50 | const QString&getCC()const{ return cc; } | 50 | const QString&getCC()const{ return cc; } |
51 | void setCC( const QString&s ) { cc = s; } | 51 | void setCC( const QString&s ) { cc = s; } |
52 | const QString&getBCC()const { return bcc; } | 52 | const QString&getBCC()const { return bcc; } |
53 | void setBCC( const QString&s ) { bcc = s; } | 53 | void setBCC( const QString&s ) { bcc = s; } |
54 | const QString&getMessage()const { return message; } | 54 | const QString&getMessage()const { return message; } |
55 | void setMessage( const QString&s ) { message = s; } | 55 | void setMessage( const QString&s ) { message = s; } |
56 | const QString&getSubject()const { return subject; } | 56 | const QString&getSubject()const { return subject; } |
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::ORefCount | 69 | class Folder:public Opie::Core::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::OSmartPointer<Folder> FolderP; | 85 | typedef Opie::Core::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="" ); |
98 | virtual ~IMAPFolder(); | 98 | virtual ~IMAPFolder(); |
99 | virtual bool may_select()const{return m_MaySelect;} | 99 | virtual bool may_select()const{return m_MaySelect;} |
100 | virtual bool no_inferior()const{return m_NoInferior;} | 100 | virtual bool no_inferior()const{return m_NoInferior;} |
101 | private: | 101 | private: |
102 | static QString decodeFolderName( const QString &name ); | 102 | static QString decodeFolderName( const QString &name ); |
103 | bool m_MaySelect,m_NoInferior; | 103 | bool m_MaySelect,m_NoInferior; |
104 | }; | 104 | }; |
105 | 105 | ||
106 | #endif | 106 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index 5e6b714..4aee0be 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -1,73 +1,74 @@ | |||
1 | #include "mboxwrapper.h" | 1 | #include "mboxwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
8 | 8 | ||
9 | using namespace Opie::Core; | ||
9 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) | 10 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) |
10 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) | 11 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) |
11 | { | 12 | { |
12 | QDir dir(MBOXPath); | 13 | QDir dir(MBOXPath); |
13 | if (!dir.exists()) { | 14 | if (!dir.exists()) { |
14 | dir.mkdir(MBOXPath); | 15 | dir.mkdir(MBOXPath); |
15 | } | 16 | } |
16 | } | 17 | } |
17 | 18 | ||
18 | MBOXwrapper::~MBOXwrapper() | 19 | MBOXwrapper::~MBOXwrapper() |
19 | { | 20 | { |
20 | } | 21 | } |
21 | 22 | ||
22 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) | 23 | void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) |
23 | { | 24 | { |
24 | mailstorage*storage = mailstorage_new(NULL); | 25 | mailstorage*storage = mailstorage_new(NULL); |
25 | QString p = MBOXPath+"/"; | 26 | QString p = MBOXPath+"/"; |
26 | p+=mailbox; | 27 | p+=mailbox; |
27 | 28 | ||
28 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 29 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
29 | mailfolder*folder; | 30 | mailfolder*folder; |
30 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 31 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
31 | r = mailfolder_connect(folder); | 32 | r = mailfolder_connect(folder); |
32 | if (r != MAIL_NO_ERROR) { | 33 | if (r != MAIL_NO_ERROR) { |
33 | qDebug("Error initializing mbox"); | 34 | qDebug("Error initializing mbox"); |
34 | mailfolder_free(folder); | 35 | mailfolder_free(folder); |
35 | mailstorage_free(storage); | 36 | mailstorage_free(storage); |
36 | return; | 37 | return; |
37 | } | 38 | } |
38 | 39 | ||
39 | parseList(target,folder->fld_session,mailbox); | 40 | parseList(target,folder->fld_session,mailbox); |
40 | 41 | ||
41 | mailfolder_disconnect(folder); | 42 | mailfolder_disconnect(folder); |
42 | mailfolder_free(folder); | 43 | mailfolder_free(folder); |
43 | mailstorage_free(storage); | 44 | mailstorage_free(storage); |
44 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 45 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
45 | } | 46 | } |
46 | 47 | ||
47 | QValueList<Opie::OSmartPointer<Folder> >* MBOXwrapper::listFolders() | 48 | QValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders() |
48 | { | 49 | { |
49 | QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >(); | 50 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
50 | QDir dir(MBOXPath); | 51 | QDir dir(MBOXPath); |
51 | if (!dir.exists()) return folders; | 52 | if (!dir.exists()) return folders; |
52 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 53 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
53 | QStringList entries = dir.entryList(); | 54 | QStringList entries = dir.entryList(); |
54 | QStringList::ConstIterator it = entries.begin(); | 55 | QStringList::ConstIterator it = entries.begin(); |
55 | for (;it!=entries.end();++it) { | 56 | for (;it!=entries.end();++it) { |
56 | FolderP inb=new Folder(*it,"/"); | 57 | FolderP inb=new Folder(*it,"/"); |
57 | folders->append(inb); | 58 | folders->append(inb); |
58 | } | 59 | } |
59 | return folders; | 60 | return folders; |
60 | } | 61 | } |
61 | 62 | ||
62 | void MBOXwrapper::deleteMail(const RecMailP & mail) | 63 | void MBOXwrapper::deleteMail(const RecMailP & mail) |
63 | { | 64 | { |
64 | mailstorage*storage = mailstorage_new(NULL); | 65 | mailstorage*storage = mailstorage_new(NULL); |
65 | QString p = MBOXPath+"/"; | 66 | QString p = MBOXPath+"/"; |
66 | p+=mail->getMbox(); | 67 | p+=mail->getMbox(); |
67 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 68 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
68 | mailfolder*folder; | 69 | mailfolder*folder; |
69 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 70 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
70 | r = mailfolder_connect(folder); | 71 | r = mailfolder_connect(folder); |
71 | if (r != MAIL_NO_ERROR) { | 72 | if (r != MAIL_NO_ERROR) { |
72 | qDebug("Error initializing mbox"); | 73 | qDebug("Error initializing mbox"); |
73 | mailfolder_free(folder); | 74 | mailfolder_free(folder); |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index 33eeb1e..a2ecfee 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h | |||
@@ -1,46 +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 encodedString; | 7 | class encodedString; |
8 | struct mailmbox_folder; | 8 | struct mailmbox_folder; |
9 | 9 | ||
10 | class MBOXwrapper : public Genericwrapper | 10 | class MBOXwrapper : public Genericwrapper |
11 | { | 11 | { |
12 | Q_OBJECT | 12 | Q_OBJECT |
13 | 13 | ||
14 | public: | 14 | public: |
15 | MBOXwrapper(const QString & dir,const QString&name); | 15 | MBOXwrapper(const QString & dir,const QString&name); |
16 | virtual ~MBOXwrapper(); | 16 | virtual ~MBOXwrapper(); |
17 | 17 | ||
18 | virtual void listMessages(const QString & mailbox, QValueList<RecMailP>&target ); | 18 | virtual void listMessages(const QString & mailbox, QValueList<RecMailP>&target ); |
19 | virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); | 19 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
20 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 20 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
21 | 21 | ||
22 | virtual void deleteMail(const RecMailP&mail); | 22 | virtual void deleteMail(const RecMailP&mail); |
23 | virtual void answeredMail(const RecMailP&mail); | 23 | virtual void answeredMail(const RecMailP&mail); |
24 | 24 | ||
25 | virtual int createMbox(const QString&folder,const Opie::OSmartPointer<Folder>&f=0, | 25 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, |
26 | const QString&d="",bool s=false); | 26 | const QString&d="",bool s=false); |
27 | virtual int deleteMbox(const Opie::OSmartPointer<Folder>&); | 27 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); |
28 | 28 | ||
29 | 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); |
30 | 30 | ||
31 | virtual RecBody fetchBody( const RecMailP &mail ); | 31 | virtual RecBody fetchBody( const RecMailP &mail ); |
32 | static void mbox_progress( size_t current, size_t maximum ); | 32 | static void mbox_progress( size_t current, size_t maximum ); |
33 | 33 | ||
34 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 34 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
35 | virtual void deleteMails(const QString & FolderName,const QValueList<RecMailP> &target); | 35 | virtual void deleteMails(const QString & FolderName,const QValueList<RecMailP> &target); |
36 | virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&); | 36 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
37 | virtual MAILLIB::ATYPE getType()const; | 37 | virtual MAILLIB::ATYPE getType()const; |
38 | virtual const QString&getName()const; | 38 | virtual const QString&getName()const; |
39 | 39 | ||
40 | protected: | 40 | protected: |
41 | static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target); | 41 | static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target); |
42 | QString MBOXPath; | 42 | QString MBOXPath; |
43 | QString MBOXName; | 43 | QString MBOXName; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | #endif | 46 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index 0b00a2e..21e24a0 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -1,34 +1,37 @@ | |||
1 | #include "mhwrapper.h" | 1 | #include "mhwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | #include <opie2/oprocess.h> | 9 | #include <opie2/oprocess.h> |
10 | 10 | ||
11 | using namespace Opie::Core; | ||
12 | using namespace Opie::Core; | ||
13 | using namespace Opie::Core; | ||
11 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 14 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
12 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 15 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
13 | { | 16 | { |
14 | if (MHPath.length()>0) { | 17 | if (MHPath.length()>0) { |
15 | if (MHPath[MHPath.length()-1]=='/') { | 18 | if (MHPath[MHPath.length()-1]=='/') { |
16 | MHPath=MHPath.left(MHPath.length()-1); | 19 | MHPath=MHPath.left(MHPath.length()-1); |
17 | } | 20 | } |
18 | qDebug(MHPath); | 21 | qDebug(MHPath); |
19 | QDir dir(MHPath); | 22 | QDir dir(MHPath); |
20 | if (!dir.exists()) { | 23 | if (!dir.exists()) { |
21 | dir.mkdir(MHPath); | 24 | dir.mkdir(MHPath); |
22 | } | 25 | } |
23 | init_storage(); | 26 | init_storage(); |
24 | } | 27 | } |
25 | } | 28 | } |
26 | 29 | ||
27 | void MHwrapper::init_storage() | 30 | void MHwrapper::init_storage() |
28 | { | 31 | { |
29 | int r; | 32 | int r; |
30 | QString pre = MHPath; | 33 | QString pre = MHPath; |
31 | if (!m_storage) { | 34 | if (!m_storage) { |
32 | m_storage = mailstorage_new(NULL); | 35 | m_storage = mailstorage_new(NULL); |
33 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 36 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
34 | if (r != MAIL_NO_ERROR) { | 37 | if (r != MAIL_NO_ERROR) { |
@@ -39,67 +42,67 @@ void MHwrapper::init_storage() | |||
39 | } | 42 | } |
40 | } | 43 | } |
41 | r = mailstorage_connect(m_storage); | 44 | r = mailstorage_connect(m_storage); |
42 | if (r!=MAIL_NO_ERROR) { | 45 | if (r!=MAIL_NO_ERROR) { |
43 | qDebug("error connecting storage"); | 46 | qDebug("error connecting storage"); |
44 | mailstorage_free(m_storage); | 47 | mailstorage_free(m_storage); |
45 | m_storage = 0; | 48 | m_storage = 0; |
46 | } | 49 | } |
47 | } | 50 | } |
48 | 51 | ||
49 | void MHwrapper::clean_storage() | 52 | void MHwrapper::clean_storage() |
50 | { | 53 | { |
51 | if (m_storage) { | 54 | if (m_storage) { |
52 | mailstorage_disconnect(m_storage); | 55 | mailstorage_disconnect(m_storage); |
53 | mailstorage_free(m_storage); | 56 | mailstorage_free(m_storage); |
54 | m_storage = 0; | 57 | m_storage = 0; |
55 | } | 58 | } |
56 | } | 59 | } |
57 | 60 | ||
58 | MHwrapper::~MHwrapper() | 61 | MHwrapper::~MHwrapper() |
59 | { | 62 | { |
60 | clean_storage(); | 63 | clean_storage(); |
61 | } | 64 | } |
62 | 65 | ||
63 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target ) | 66 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
64 | { | 67 | { |
65 | init_storage(); | 68 | init_storage(); |
66 | if (!m_storage) { | 69 | if (!m_storage) { |
67 | return; | 70 | return; |
68 | } | 71 | } |
69 | QString f = buildPath(mailbox); | 72 | QString f = buildPath(mailbox); |
70 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 73 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
71 | if (r!=MAIL_NO_ERROR) { | 74 | if (r!=MAIL_NO_ERROR) { |
72 | qDebug("listMessages: error selecting folder!"); | 75 | qDebug("listMessages: error selecting folder!"); |
73 | return; | 76 | return; |
74 | } | 77 | } |
75 | parseList(target,m_storage->sto_session,f); | 78 | parseList(target,m_storage->sto_session,f); |
76 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 79 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
77 | } | 80 | } |
78 | 81 | ||
79 | QValueList<Opie::OSmartPointer<Folder> >* MHwrapper::listFolders() | 82 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
80 | { | 83 | { |
81 | QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >(); | 84 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
82 | /* this is needed! */ | 85 | /* this is needed! */ |
83 | if (m_storage) mailstorage_disconnect(m_storage); | 86 | if (m_storage) mailstorage_disconnect(m_storage); |
84 | init_storage(); | 87 | init_storage(); |
85 | if (!m_storage) { | 88 | if (!m_storage) { |
86 | return folders; | 89 | return folders; |
87 | } | 90 | } |
88 | mail_list*flist = 0; | 91 | mail_list*flist = 0; |
89 | clistcell*current=0; | 92 | clistcell*current=0; |
90 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 93 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
91 | if (r != MAIL_NO_ERROR || !flist) { | 94 | if (r != MAIL_NO_ERROR || !flist) { |
92 | qDebug("error getting folder list"); | 95 | qDebug("error getting folder list"); |
93 | return folders; | 96 | return folders; |
94 | } | 97 | } |
95 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 98 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
96 | QString t = (char*)current->data; | 99 | QString t = (char*)current->data; |
97 | t.replace(0,MHPath.length(),""); | 100 | t.replace(0,MHPath.length(),""); |
98 | folders->append(new MHFolder(t,MHPath)); | 101 | folders->append(new MHFolder(t,MHPath)); |
99 | } | 102 | } |
100 | mail_list_free(flist); | 103 | mail_list_free(flist); |
101 | return folders; | 104 | return folders; |
102 | } | 105 | } |
103 | 106 | ||
104 | void MHwrapper::deleteMail(const RecMailP&mail) | 107 | void MHwrapper::deleteMail(const RecMailP&mail) |
105 | { | 108 | { |
@@ -296,51 +299,51 @@ int MHwrapper::deleteAllMail(const FolderP&tfolder) | |||
296 | } | 299 | } |
297 | 300 | ||
298 | int MHwrapper::deleteMbox(const FolderP&tfolder) | 301 | int MHwrapper::deleteMbox(const FolderP&tfolder) |
299 | { | 302 | { |
300 | init_storage(); | 303 | init_storage(); |
301 | if (!m_storage) { | 304 | if (!m_storage) { |
302 | return 0; | 305 | return 0; |
303 | } | 306 | } |
304 | if (!tfolder) return 0; | 307 | if (!tfolder) return 0; |
305 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | 308 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; |
306 | 309 | ||
307 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 310 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
308 | 311 | ||
309 | if (r != MAIL_NO_ERROR) { | 312 | if (r != MAIL_NO_ERROR) { |
310 | qDebug("error deleting mail box"); | 313 | qDebug("error deleting mail box"); |
311 | return 0; | 314 | return 0; |
312 | } | 315 | } |
313 | QString cmd = "rm -rf "+tfolder->getName(); | 316 | QString cmd = "rm -rf "+tfolder->getName(); |
314 | QStringList command; | 317 | QStringList command; |
315 | command << "/bin/sh"; | 318 | command << "/bin/sh"; |
316 | command << "-c"; | 319 | command << "-c"; |
317 | command << cmd.latin1(); | 320 | command << cmd.latin1(); |
318 | OProcess *process = new OProcess(); | 321 | OProcess *process = new OProcess(); |
319 | 322 | ||
320 | connect(process, SIGNAL(processExited(OProcess*)), | 323 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), |
321 | this, SLOT( processEnded(OProcess*))); | 324 | this, SLOT( processEnded(OProcess*))); |
322 | connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)), | 325 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), |
323 | this, SLOT( oprocessStderr(OProcess*,char*,int))); | 326 | this, SLOT( oprocessStderr(OProcess*,char*,int))); |
324 | 327 | ||
325 | *process << command; | 328 | *process << command; |
326 | removeMboxfailed = false; | 329 | removeMboxfailed = false; |
327 | if(!process->start(OProcess::Block, OProcess::All) ) { | 330 | if(!process->start(OProcess::Block, OProcess::All) ) { |
328 | qDebug("could not start process"); | 331 | qDebug("could not start process"); |
329 | return 0; | 332 | return 0; |
330 | } | 333 | } |
331 | qDebug("mail box deleted"); | 334 | qDebug("mail box deleted"); |
332 | return 1; | 335 | return 1; |
333 | } | 336 | } |
334 | 337 | ||
335 | void MHwrapper::processEnded(OProcess *p) | 338 | void MHwrapper::processEnded(OProcess *p) |
336 | { | 339 | { |
337 | if (p) delete p; | 340 | if (p) delete p; |
338 | } | 341 | } |
339 | 342 | ||
340 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) | 343 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) |
341 | { | 344 | { |
342 | QString lineStr = buffer; | 345 | QString lineStr = buffer; |
343 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); | 346 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); |
344 | removeMboxfailed = true; | 347 | removeMboxfailed = true; |
345 | } | 348 | } |
346 | 349 | ||
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h index 208cf2f..1245507 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.h +++ b/noncore/net/mail/libmailwrapper/mhwrapper.h | |||
@@ -1,60 +1,60 @@ | |||
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 encodedString; | 9 | class encodedString; |
10 | struct mailmbox_folder; | 10 | struct mailmbox_folder; |
11 | class OProcess; | 11 | namespace Opie {namespace Core {class Opie::Core::OProcess;}} |
12 | 12 | ||
13 | class MHwrapper : public Genericwrapper | 13 | class MHwrapper : public Genericwrapper |
14 | { | 14 | { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | public: | 16 | public: |
17 | MHwrapper(const QString & dir,const QString&name); | 17 | MHwrapper(const QString & dir,const QString&name); |
18 | virtual ~MHwrapper(); | 18 | virtual ~MHwrapper(); |
19 | 19 | ||
20 | virtual void listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target ); | 20 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); |
21 | virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); | 21 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
23 | 23 | ||
24 | virtual void deleteMail(const RecMailP&mail); | 24 | virtual void deleteMail(const RecMailP&mail); |
25 | virtual void answeredMail(const RecMailP&mail); | 25 | virtual void answeredMail(const RecMailP&mail); |
26 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 26 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
27 | virtual void mvcpAllMails(const Opie::OSmartPointer<Folder>&fromFolder, | 27 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
28 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 28 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
29 | 29 | ||
30 | virtual int createMbox(const QString&folder,const Opie::OSmartPointer<Folder>&f=0, | 30 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, |
31 | const QString&d="",bool s=false); | 31 | const QString&d="",bool s=false); |
32 | virtual int deleteMbox(const Opie::OSmartPointer<Folder>&); | 32 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); |
33 | 33 | ||
34 | 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); |
35 | 35 | ||
36 | virtual RecBody fetchBody( const RecMailP &mail ); | 36 | virtual RecBody fetchBody( const RecMailP &mail ); |
37 | static void mbox_progress( size_t current, size_t maximum ); | 37 | static void mbox_progress( size_t current, size_t maximum ); |
38 | 38 | ||
39 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 39 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
40 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::OSmartPointer<RecMail> > &target); | 40 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target); |
41 | virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&); | 41 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
42 | virtual MAILLIB::ATYPE getType()const; | 42 | virtual MAILLIB::ATYPE getType()const; |
43 | virtual const QString&getName()const; | 43 | virtual const QString&getName()const; |
44 | 44 | ||
45 | public slots: | 45 | public slots: |
46 | /* for deleting maildirs we are using a system call */ | 46 | /* for deleting maildirs we are using a system call */ |
47 | virtual void oprocessStderr(OProcess*, char *buffer, int ); | 47 | virtual void oprocessStderr(Opie::Core::OProcess*, char *buffer, int ); |
48 | virtual void processEnded(OProcess *); | 48 | virtual void processEnded(Opie::Core::OProcess *); |
49 | protected: | 49 | protected: |
50 | QString buildPath(const QString&p); | 50 | QString buildPath(const QString&p); |
51 | QString MHPath; | 51 | QString MHPath; |
52 | QString MHName; | 52 | QString MHName; |
53 | 53 | ||
54 | void init_storage(); | 54 | void init_storage(); |
55 | void clean_storage(); | 55 | void clean_storage(); |
56 | 56 | ||
57 | bool removeMboxfailed; | 57 | bool removeMboxfailed; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | #endif | 60 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index c0b3eec..9de958d 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -1,37 +1,38 @@ | |||
1 | #include "nntpwrapper.h" | 1 | #include "nntpwrapper.h" |
2 | #include "logindialog.h" | 2 | #include "logindialog.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | 4 | ||
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | 6 | ||
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | 8 | ||
9 | #include <libetpan/libetpan.h> | 9 | #include <libetpan/libetpan.h> |
10 | 10 | ||
11 | 11 | ||
12 | #define HARD_MSG_SIZE_LIMIT 5242880 | 12 | #define HARD_MSG_SIZE_LIMIT 5242880 |
13 | 13 | ||
14 | using namespace Opie::Core; | ||
14 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) | 15 | NNTPwrapper::NNTPwrapper( NNTPaccount *a ) |
15 | : Genericwrapper() { | 16 | : Genericwrapper() { |
16 | account = a; | 17 | account = a; |
17 | m_nntp = NULL; | 18 | m_nntp = NULL; |
18 | msgTempName = a->getFileName()+"_msg_cache"; | 19 | msgTempName = a->getFileName()+"_msg_cache"; |
19 | last_msg_id = 0; | 20 | last_msg_id = 0; |
20 | } | 21 | } |
21 | 22 | ||
22 | NNTPwrapper::~NNTPwrapper() { | 23 | NNTPwrapper::~NNTPwrapper() { |
23 | logout(); | 24 | logout(); |
24 | QFile msg_cache(msgTempName); | 25 | QFile msg_cache(msgTempName); |
25 | if (msg_cache.exists()) { | 26 | if (msg_cache.exists()) { |
26 | msg_cache.remove(); | 27 | msg_cache.remove(); |
27 | } | 28 | } |
28 | } | 29 | } |
29 | 30 | ||
30 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { | 31 | void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { |
31 | qDebug( "NNTP: %i of %i", current, maximum ); | 32 | qDebug( "NNTP: %i of %i", current, maximum ); |
32 | } | 33 | } |
33 | 34 | ||
34 | 35 | ||
35 | RecBody NNTPwrapper::fetchBody( const RecMailP &mail ) { | 36 | RecBody NNTPwrapper::fetchBody( const RecMailP &mail ) { |
36 | int err = NEWSNNTP_NO_ERROR; | 37 | int err = NEWSNNTP_NO_ERROR; |
37 | char *message = 0; | 38 | char *message = 0; |
@@ -75,49 +76,49 @@ RecBody NNTPwrapper::fetchBody( const RecMailP &mail ) { | |||
75 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 76 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
76 | memset(message,0,msg.length()+1); | 77 | memset(message,0,msg.length()+1); |
77 | memcpy(message,msg.latin1(),msg.length()); | 78 | memcpy(message,msg.latin1(),msg.length()); |
78 | /* transform to libetpan stuff */ | 79 | /* transform to libetpan stuff */ |
79 | mailmsg = mailmessage_new(); | 80 | mailmsg = mailmessage_new(); |
80 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 81 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
81 | generic_message_t * msg_data; | 82 | generic_message_t * msg_data; |
82 | msg_data = (generic_message_t *)mailmsg->msg_data; | 83 | msg_data = (generic_message_t *)mailmsg->msg_data; |
83 | msg_data->msg_fetched = 1; | 84 | msg_data->msg_fetched = 1; |
84 | msg_data->msg_message = message; | 85 | msg_data->msg_message = message; |
85 | msg_data->msg_length = strlen(message); | 86 | msg_data->msg_length = strlen(message); |
86 | } | 87 | } |
87 | body = parseMail(mailmsg); | 88 | body = parseMail(mailmsg); |
88 | 89 | ||
89 | /* clean up */ | 90 | /* clean up */ |
90 | if (mailmsg) | 91 | if (mailmsg) |
91 | mailmessage_free(mailmsg); | 92 | mailmessage_free(mailmsg); |
92 | if (message) | 93 | if (message) |
93 | free(message); | 94 | free(message); |
94 | 95 | ||
95 | return body; | 96 | return body; |
96 | } | 97 | } |
97 | 98 | ||
98 | 99 | ||
99 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::OSmartPointer<RecMail> > &target ) | 100 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
100 | { | 101 | { |
101 | login(); | 102 | login(); |
102 | if (!m_nntp) | 103 | if (!m_nntp) |
103 | return; | 104 | return; |
104 | uint32_t res_messages,res_recent,res_unseen; | 105 | 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); | 106 | 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); | 107 | parseList(target,m_nntp->sto_session,which,true); |
107 | } | 108 | } |
108 | 109 | ||
109 | void NNTPwrapper::login() | 110 | void NNTPwrapper::login() |
110 | { | 111 | { |
111 | if (account->getOffline()) | 112 | if (account->getOffline()) |
112 | return; | 113 | return; |
113 | /* we'll hold the line */ | 114 | /* we'll hold the line */ |
114 | if ( m_nntp != NULL ) | 115 | if ( m_nntp != NULL ) |
115 | return; | 116 | return; |
116 | 117 | ||
117 | const char *server, *user, *pass; | 118 | const char *server, *user, *pass; |
118 | QString User,Pass; | 119 | QString User,Pass; |
119 | uint16_t port; | 120 | uint16_t port; |
120 | int err = NEWSNNTP_NO_ERROR; | 121 | int err = NEWSNNTP_NO_ERROR; |
121 | 122 | ||
122 | server = account->getServer().latin1(); | 123 | server = account->getServer().latin1(); |
123 | port = account->getPort().toUInt(); | 124 | port = account->getPort().toUInt(); |
@@ -167,51 +168,51 @@ void NNTPwrapper::login() | |||
167 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, | 168 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, |
168 | (char*)user,(char*)pass,0,0,0); | 169 | (char*)user,(char*)pass,0,0,0); |
169 | 170 | ||
170 | err = mailstorage_connect( m_nntp ); | 171 | err = mailstorage_connect( m_nntp ); |
171 | 172 | ||
172 | if (err != NEWSNNTP_NO_ERROR) { | 173 | if (err != NEWSNNTP_NO_ERROR) { |
173 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); | 174 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); |
174 | // Global::statusMessage(tr("Error initializing folder")); | 175 | // Global::statusMessage(tr("Error initializing folder")); |
175 | mailstorage_free(m_nntp); | 176 | mailstorage_free(m_nntp); |
176 | m_nntp = 0; | 177 | m_nntp = 0; |
177 | 178 | ||
178 | } | 179 | } |
179 | 180 | ||
180 | } | 181 | } |
181 | 182 | ||
182 | void NNTPwrapper::logout() | 183 | void NNTPwrapper::logout() |
183 | { | 184 | { |
184 | int err = NEWSNNTP_NO_ERROR; | 185 | int err = NEWSNNTP_NO_ERROR; |
185 | if ( m_nntp == NULL ) | 186 | if ( m_nntp == NULL ) |
186 | return; | 187 | return; |
187 | mailstorage_free(m_nntp); | 188 | mailstorage_free(m_nntp); |
188 | m_nntp = 0; | 189 | m_nntp = 0; |
189 | } | 190 | } |
190 | 191 | ||
191 | QValueList<Opie::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { | 192 | QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { |
192 | 193 | ||
193 | QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >(); | 194 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
194 | QStringList groups; | 195 | QStringList groups; |
195 | if (account) { | 196 | if (account) { |
196 | groups = account->getGroups(); | 197 | groups = account->getGroups(); |
197 | } | 198 | } |
198 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { | 199 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { |
199 | folders->append(new Folder((*it),".")); | 200 | folders->append(new Folder((*it),".")); |
200 | } | 201 | } |
201 | return folders; | 202 | return folders; |
202 | } | 203 | } |
203 | 204 | ||
204 | /* we made this method in raw nntp access of etpan and not via generic interface | 205 | /* 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 | 206 | * 'cause in that case there will be doubled copy operations. eg. the etpan would |
206 | * copy that stuff into its own structures and we must copy it into useable c++ | 207 | * copy that stuff into its own structures and we must copy it into useable c++ |
207 | * structures for our frontend. this would not make sense, so it is better to reimplement | 208 | * structures for our frontend. this would not make sense, so it is better to reimplement |
208 | * the stuff from generic interface of etpan but copy it direct to qt classes. | 209 | * the stuff from generic interface of etpan but copy it direct to qt classes. |
209 | */ | 210 | */ |
210 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { | 211 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { |
211 | login(); | 212 | login(); |
212 | QStringList res; | 213 | QStringList res; |
213 | clist *result = 0; | 214 | clist *result = 0; |
214 | clistcell *current = 0; | 215 | clistcell *current = 0; |
215 | newsnntp_group_description *group; | 216 | newsnntp_group_description *group; |
216 | 217 | ||
217 | if ( m_nntp ) { | 218 | if ( m_nntp ) { |
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h index a7e4b95..a87a8e8 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.h +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h | |||
@@ -1,48 +1,48 @@ | |||
1 | #ifndef __NNTPWRAPPER | 1 | #ifndef __NNTPWRAPPER |
2 | #define __NNTPWRAPPER | 2 | #define __NNTPWRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | class encodedString; | 9 | class encodedString; |
10 | struct mailstorage; | 10 | 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, QValueList<Opie::OSmartPointer<RecMail> > &target ); | 23 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); |
24 | /* should only get the subscribed one */ | 24 | /* should only get the subscribed one */ |
25 | virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); | 25 | virtual QValueList<Opie::Core::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 RecMailP&mail); | 29 | virtual void deleteMail(const RecMailP&mail); |
30 | virtual void answeredMail(const RecMailP&mail); | 30 | virtual void answeredMail(const RecMailP&mail); |
31 | virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&); | 31 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
32 | 32 | ||
33 | virtual RecBody fetchBody( const RecMailP &mail ); | 33 | virtual RecBody fetchBody( const RecMailP &mail ); |
34 | virtual encodedString* fetchRawBody(const RecMailP&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 | }; |
47 | 47 | ||
48 | #endif | 48 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 6737d6c..f5694fe 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,36 +1,37 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | //#include <qstring.h> | 8 | //#include <qstring.h> |
9 | 9 | ||
10 | /* we don't fetch messages larger than 5 MB */ | 10 | /* we don't fetch messages larger than 5 MB */ |
11 | #define HARD_MSG_SIZE_LIMIT 5242880 | 11 | #define HARD_MSG_SIZE_LIMIT 5242880 |
12 | 12 | ||
13 | using namespace Opie::Core; | ||
13 | POP3wrapper::POP3wrapper( POP3account *a ) | 14 | POP3wrapper::POP3wrapper( POP3account *a ) |
14 | : Genericwrapper() { | 15 | : Genericwrapper() { |
15 | account = a; | 16 | account = a; |
16 | m_pop3 = NULL; | 17 | m_pop3 = NULL; |
17 | msgTempName = a->getFileName()+"_msg_cache"; | 18 | msgTempName = a->getFileName()+"_msg_cache"; |
18 | last_msg_id = 0; | 19 | last_msg_id = 0; |
19 | } | 20 | } |
20 | 21 | ||
21 | POP3wrapper::~POP3wrapper() { | 22 | POP3wrapper::~POP3wrapper() { |
22 | logout(); | 23 | logout(); |
23 | QFile msg_cache(msgTempName); | 24 | QFile msg_cache(msgTempName); |
24 | if (msg_cache.exists()) { | 25 | if (msg_cache.exists()) { |
25 | msg_cache.remove(); | 26 | msg_cache.remove(); |
26 | } | 27 | } |
27 | } | 28 | } |
28 | 29 | ||
29 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { | 30 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { |
30 | qDebug( "POP3: %i of %i", current, maximum ); | 31 | qDebug( "POP3: %i of %i", current, maximum ); |
31 | } | 32 | } |
32 | 33 | ||
33 | RecBody POP3wrapper::fetchBody( const RecMailP &mail ) { | 34 | RecBody POP3wrapper::fetchBody( const RecMailP &mail ) { |
34 | int err = MAILPOP3_NO_ERROR; | 35 | int err = MAILPOP3_NO_ERROR; |
35 | char *message = 0; | 36 | char *message = 0; |
36 | size_t length = 0; | 37 | size_t length = 0; |
@@ -72,49 +73,49 @@ RecBody POP3wrapper::fetchBody( const RecMailP &mail ) { | |||
72 | delete message; | 73 | delete message; |
73 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 74 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
74 | memset(message,0,msg.length()+1); | 75 | memset(message,0,msg.length()+1); |
75 | memcpy(message,msg.latin1(),msg.length()); | 76 | memcpy(message,msg.latin1(),msg.length()); |
76 | /* transform to libetpan stuff */ | 77 | /* transform to libetpan stuff */ |
77 | mailmsg = mailmessage_new(); | 78 | mailmsg = mailmessage_new(); |
78 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 79 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
79 | generic_message_t * msg_data; | 80 | generic_message_t * msg_data; |
80 | msg_data = (generic_message_t *)mailmsg->msg_data; | 81 | msg_data = (generic_message_t *)mailmsg->msg_data; |
81 | msg_data->msg_fetched = 1; | 82 | msg_data->msg_fetched = 1; |
82 | msg_data->msg_message = message; | 83 | msg_data->msg_message = message; |
83 | msg_data->msg_length = strlen(message); | 84 | msg_data->msg_length = strlen(message); |
84 | } | 85 | } |
85 | body = parseMail(mailmsg); | 86 | body = parseMail(mailmsg); |
86 | 87 | ||
87 | /* clean up */ | 88 | /* clean up */ |
88 | if (mailmsg) | 89 | if (mailmsg) |
89 | mailmessage_free(mailmsg); | 90 | mailmessage_free(mailmsg); |
90 | if (message) | 91 | if (message) |
91 | free(message); | 92 | free(message); |
92 | 93 | ||
93 | return body; | 94 | return body; |
94 | } | 95 | } |
95 | 96 | ||
96 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::OSmartPointer<RecMail> > &target ) | 97 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
97 | { | 98 | { |
98 | login(); | 99 | login(); |
99 | if (!m_pop3) | 100 | if (!m_pop3) |
100 | return; | 101 | return; |
101 | uint32_t res_messages,res_recent,res_unseen; | 102 | uint32_t res_messages,res_recent,res_unseen; |
102 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 103 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
103 | parseList(target,m_pop3->sto_session,"INBOX"); | 104 | parseList(target,m_pop3->sto_session,"INBOX"); |
104 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); | 105 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); |
105 | } | 106 | } |
106 | 107 | ||
107 | void POP3wrapper::login() | 108 | void POP3wrapper::login() |
108 | { | 109 | { |
109 | if (account->getOffline()) | 110 | if (account->getOffline()) |
110 | return; | 111 | return; |
111 | /* we'll hold the line */ | 112 | /* we'll hold the line */ |
112 | if ( m_pop3 != NULL ) | 113 | if ( m_pop3 != NULL ) |
113 | return; | 114 | return; |
114 | 115 | ||
115 | const char *server, *user, *pass; | 116 | const char *server, *user, *pass; |
116 | uint16_t port; | 117 | uint16_t port; |
117 | int err = MAILPOP3_NO_ERROR; | 118 | int err = MAILPOP3_NO_ERROR; |
118 | 119 | ||
119 | server = account->getServer().latin1(); | 120 | server = account->getServer().latin1(); |
120 | port = account->getPort().toUInt(); | 121 | port = account->getPort().toUInt(); |
@@ -155,50 +156,50 @@ void POP3wrapper::login() | |||
155 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | 156 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); |
156 | 157 | ||
157 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, | 158 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, |
158 | (char*)user,(char*)pass,0,0,0); | 159 | (char*)user,(char*)pass,0,0,0); |
159 | 160 | ||
160 | 161 | ||
161 | err = mailstorage_connect(m_pop3); | 162 | err = mailstorage_connect(m_pop3); |
162 | if (err != MAIL_NO_ERROR) { | 163 | if (err != MAIL_NO_ERROR) { |
163 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); | 164 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); |
164 | Global::statusMessage(tr("Error initializing folder")); | 165 | Global::statusMessage(tr("Error initializing folder")); |
165 | mailstorage_free(m_pop3); | 166 | mailstorage_free(m_pop3); |
166 | m_pop3 = 0; | 167 | m_pop3 = 0; |
167 | } | 168 | } |
168 | } | 169 | } |
169 | 170 | ||
170 | void POP3wrapper::logout() | 171 | void POP3wrapper::logout() |
171 | { | 172 | { |
172 | if ( m_pop3 == NULL ) | 173 | if ( m_pop3 == NULL ) |
173 | return; | 174 | return; |
174 | mailstorage_free(m_pop3); | 175 | mailstorage_free(m_pop3); |
175 | m_pop3 = 0; | 176 | m_pop3 = 0; |
176 | } | 177 | } |
177 | 178 | ||
178 | 179 | ||
179 | QValueList<Opie::OSmartPointer<Folder> >* POP3wrapper::listFolders() { | 180 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { |
180 | QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); | 181 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); |
181 | FolderP inb=new Folder("INBOX","/"); | 182 | FolderP inb=new Folder("INBOX","/"); |
182 | folders->append(inb); | 183 | folders->append(inb); |
183 | return folders; | 184 | return folders; |
184 | } | 185 | } |
185 | 186 | ||
186 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 187 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
187 | login(); | 188 | login(); |
188 | if (!m_pop3) | 189 | if (!m_pop3) |
189 | return; | 190 | return; |
190 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 191 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
191 | if (err != MAIL_NO_ERROR) { | 192 | if (err != MAIL_NO_ERROR) { |
192 | Global::statusMessage(tr("error deleting mail")); | 193 | Global::statusMessage(tr("error deleting mail")); |
193 | } | 194 | } |
194 | } | 195 | } |
195 | 196 | ||
196 | void POP3wrapper::answeredMail(const RecMailP&) {} | 197 | void POP3wrapper::answeredMail(const RecMailP&) {} |
197 | 198 | ||
198 | int POP3wrapper::deleteAllMail(const FolderP&) { | 199 | int POP3wrapper::deleteAllMail(const FolderP&) { |
199 | login(); | 200 | login(); |
200 | if (!m_pop3) | 201 | if (!m_pop3) |
201 | return 0; | 202 | return 0; |
202 | int res = 1; | 203 | int res = 1; |
203 | 204 | ||
204 | uint32_t result = 0; | 205 | uint32_t result = 0; |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index 31eb6f1..c46b941 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -1,42 +1,42 @@ | |||
1 | #ifndef __POP3WRAPPER | 1 | #ifndef __POP3WRAPPER |
2 | #define __POP3WRAPPER | 2 | #define __POP3WRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | 7 | ||
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, QValueList<Opie::OSmartPointer<RecMail> > &target ); | 20 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); |
21 | virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); | 21 | virtual QValueList<Opie::Core::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 RecMailP&mail); | 25 | virtual void deleteMail(const RecMailP&mail); |
26 | virtual void answeredMail(const RecMailP&mail); | 26 | virtual void answeredMail(const RecMailP&mail); |
27 | virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&); | 27 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
28 | 28 | ||
29 | virtual RecBody fetchBody( const RecMailP &mail ); | 29 | virtual RecBody fetchBody( const RecMailP &mail ); |
30 | virtual encodedString* fetchRawBody(const RecMailP&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 86673aa..e2cea7a 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -1,39 +1,40 @@ | |||
1 | #include "smtpwrapper.h" | 1 | #include "smtpwrapper.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | #include "abstractmail.h" | 3 | #include "abstractmail.h" |
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include "mailtypes.h" | 5 | #include "mailtypes.h" |
6 | #include "sendmailprogress.h" | 6 | #include "sendmailprogress.h" |
7 | 7 | ||
8 | #include <qt.h> | 8 | #include <qt.h> |
9 | 9 | ||
10 | #include <qpe/config.h> | 10 | #include <qpe/config.h> |
11 | #include <qpe/qcopenvelope_qws.h> | 11 | #include <qpe/qcopenvelope_qws.h> |
12 | 12 | ||
13 | #include <libetpan/libetpan.h> | 13 | #include <libetpan/libetpan.h> |
14 | 14 | ||
15 | 15 | ||
16 | using namespace Opie::Core; | ||
16 | progressMailSend*SMTPwrapper::sendProgress = 0; | 17 | progressMailSend*SMTPwrapper::sendProgress = 0; |
17 | 18 | ||
18 | SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) | 19 | SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) |
19 | : Generatemail() | 20 | : Generatemail() |
20 | { | 21 | { |
21 | m_SmtpAccount = aSmtp; | 22 | m_SmtpAccount = aSmtp; |
22 | Config cfg( "mail" ); | 23 | Config cfg( "mail" ); |
23 | cfg.setGroup( "Status" ); | 24 | cfg.setGroup( "Status" ); |
24 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); | 25 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); |
25 | emit queuedMails( m_queuedMail ); | 26 | emit queuedMails( m_queuedMail ); |
26 | connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); | 27 | connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); |
27 | m_smtp = 0; | 28 | m_smtp = 0; |
28 | } | 29 | } |
29 | 30 | ||
30 | SMTPwrapper::~SMTPwrapper() | 31 | SMTPwrapper::~SMTPwrapper() |
31 | { | 32 | { |
32 | disc_server(); | 33 | disc_server(); |
33 | } | 34 | } |
34 | 35 | ||
35 | void SMTPwrapper::emitQCop( int queued ) { | 36 | void SMTPwrapper::emitQCop( int queued ) { |
36 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); | 37 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); |
37 | env << queued; | 38 | env << queued; |
38 | } | 39 | } |
39 | 40 | ||
@@ -291,49 +292,49 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) | |||
291 | QString failuretext = ""; | 292 | QString failuretext = ""; |
292 | 293 | ||
293 | connect_server(); | 294 | connect_server(); |
294 | 295 | ||
295 | result = 1; | 296 | result = 1; |
296 | if (m_smtp) { | 297 | if (m_smtp) { |
297 | err = mailsmtp_send( m_smtp, from, rcpts, data, size ); | 298 | err = mailsmtp_send( m_smtp, from, rcpts, data, size ); |
298 | if ( err != MAILSMTP_NO_ERROR ) { | 299 | if ( err != MAILSMTP_NO_ERROR ) { |
299 | failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); | 300 | failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); |
300 | result = 0; | 301 | result = 0; |
301 | } | 302 | } |
302 | } else { | 303 | } else { |
303 | result = 0; | 304 | result = 0; |
304 | } | 305 | } |
305 | 306 | ||
306 | if (!result) { | 307 | if (!result) { |
307 | storeFailedMail(data,size,failuretext); | 308 | storeFailedMail(data,size,failuretext); |
308 | } else { | 309 | } else { |
309 | qDebug( "Mail sent." ); | 310 | qDebug( "Mail sent." ); |
310 | storeMail(data,size,"Sent"); | 311 | storeMail(data,size,"Sent"); |
311 | } | 312 | } |
312 | return result; | 313 | return result; |
313 | } | 314 | } |
314 | 315 | ||
315 | void SMTPwrapper::sendMail(const Opie::OSmartPointer<Mail>&mail,bool later ) | 316 | void SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later ) |
316 | { | 317 | { |
317 | mailmime * mimeMail; | 318 | mailmime * mimeMail; |
318 | 319 | ||
319 | mimeMail = createMimeMail(mail ); | 320 | mimeMail = createMimeMail(mail ); |
320 | if ( mimeMail == NULL ) { | 321 | if ( mimeMail == NULL ) { |
321 | qDebug( "sendMail: error creating mime mail" ); | 322 | qDebug( "sendMail: error creating mime mail" ); |
322 | } else { | 323 | } else { |
323 | sendProgress = new progressMailSend(); | 324 | sendProgress = new progressMailSend(); |
324 | sendProgress->show(); | 325 | sendProgress->show(); |
325 | sendProgress->setMaxMails(1); | 326 | sendProgress->setMaxMails(1); |
326 | smtpSend( mimeMail,later); | 327 | smtpSend( mimeMail,later); |
327 | qDebug("Clean up done"); | 328 | qDebug("Clean up done"); |
328 | sendProgress->hide(); | 329 | sendProgress->hide(); |
329 | delete sendProgress; | 330 | delete sendProgress; |
330 | sendProgress = 0; | 331 | sendProgress = 0; |
331 | mailmime_free( mimeMail ); | 332 | mailmime_free( mimeMail ); |
332 | } | 333 | } |
333 | } | 334 | } |
334 | 335 | ||
335 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { | 336 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { |
336 | size_t curTok = 0; | 337 | size_t curTok = 0; |
337 | mailimf_fields *fields = 0; | 338 | mailimf_fields *fields = 0; |
338 | mailimf_field*ffrom = 0; | 339 | mailimf_field*ffrom = 0; |
339 | clist *rcpts = 0; | 340 | clist *rcpts = 0; |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h index 71ae35c..6c5bbe8 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.h +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h | |||
@@ -2,62 +2,62 @@ | |||
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/osmartpointer.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::OSmartPointer<Mail>& mail,bool later=false ); | 26 | void sendMail(const Opie::Core::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(); |
39 | void disc_server(); | 39 | void disc_server(); |
40 | int start_smtp_tls(); | 40 | int start_smtp_tls(); |
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,const Opie::OSmartPointer<RecMail>&which); | 53 | int sendQueuedMail(AbstractMail*wrap,const Opie::Core::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 595e7fc..914a11d 100644 --- a/noncore/net/mail/libmailwrapper/storemail.cpp +++ b/noncore/net/mail/libmailwrapper/storemail.cpp | |||
@@ -1,76 +1,77 @@ | |||
1 | #include "storemail.h" | 1 | #include "storemail.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | #include "settings.h" | 3 | #include "settings.h" |
4 | #include "abstractmail.h" | 4 | #include "abstractmail.h" |
5 | 5 | ||
6 | #include <libetpan/libetpan.h> | 6 | #include <libetpan/libetpan.h> |
7 | 7 | ||
8 | #include <qstring.h> | 8 | #include <qstring.h> |
9 | 9 | ||
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | 11 | ||
12 | using namespace Opie::Core; | ||
12 | Storemail::Storemail(Account*aAccount,const QString&aFolder) | 13 | Storemail::Storemail(Account*aAccount,const QString&aFolder) |
13 | : Generatemail() | 14 | : Generatemail() |
14 | { | 15 | { |
15 | wrapper = 0; | 16 | wrapper = 0; |
16 | m_Account = aAccount; | 17 | m_Account = aAccount; |
17 | m_tfolder = aFolder; | 18 | m_tfolder = aFolder; |
18 | wrapper = AbstractMail::getWrapper(m_Account); | 19 | wrapper = AbstractMail::getWrapper(m_Account); |
19 | if (wrapper) { | 20 | if (wrapper) { |
20 | wrapper->createMbox(m_tfolder); | 21 | wrapper->createMbox(m_tfolder); |
21 | } | 22 | } |
22 | } | 23 | } |
23 | 24 | ||
24 | Storemail::Storemail(const QString&dir,const QString&aFolder) | 25 | Storemail::Storemail(const QString&dir,const QString&aFolder) |
25 | : Generatemail() | 26 | : Generatemail() |
26 | { | 27 | { |
27 | wrapper = 0; | 28 | wrapper = 0; |
28 | m_Account = 0; | 29 | m_Account = 0; |
29 | m_tfolder = aFolder; | 30 | m_tfolder = aFolder; |
30 | wrapper = AbstractMail::getWrapper(dir); | 31 | wrapper = AbstractMail::getWrapper(dir); |
31 | if (wrapper) { | 32 | if (wrapper) { |
32 | wrapper->createMbox(m_tfolder); | 33 | wrapper->createMbox(m_tfolder); |
33 | } | 34 | } |
34 | } | 35 | } |
35 | 36 | ||
36 | Storemail::Storemail(const QString&aFolder) | 37 | Storemail::Storemail(const QString&aFolder) |
37 | : Generatemail() | 38 | : Generatemail() |
38 | { | 39 | { |
39 | wrapper = 0; | 40 | wrapper = 0; |
40 | m_Account = 0; | 41 | m_Account = 0; |
41 | m_tfolder = aFolder; | 42 | m_tfolder = aFolder; |
42 | wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); | 43 | wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); |
43 | if (wrapper) { | 44 | if (wrapper) { |
44 | wrapper->createMbox(m_tfolder); | 45 | wrapper->createMbox(m_tfolder); |
45 | } | 46 | } |
46 | } | 47 | } |
47 | 48 | ||
48 | Storemail::~Storemail() | 49 | Storemail::~Storemail() |
49 | { | 50 | { |
50 | } | 51 | } |
51 | 52 | ||
52 | int Storemail::storeMail(const Opie::OSmartPointer<Mail>&mail) | 53 | int Storemail::storeMail(const Opie::Core::OSmartPointer<Mail>&mail) |
53 | { | 54 | { |
54 | if (!wrapper) return 0; | 55 | if (!wrapper) return 0; |
55 | int ret = 1; | 56 | int ret = 1; |
56 | 57 | ||
57 | mailmime * mimeMail = 0; | 58 | mailmime * mimeMail = 0; |
58 | mimeMail = createMimeMail(mail ); | 59 | mimeMail = createMimeMail(mail ); |
59 | if ( mimeMail == NULL ) { | 60 | if ( mimeMail == NULL ) { |
60 | qDebug( "storeMail: error creating mime mail" ); | 61 | qDebug( "storeMail: error creating mime mail" ); |
61 | return 0; | 62 | return 0; |
62 | } | 63 | } |
63 | char *data; | 64 | char *data; |
64 | size_t size; | 65 | size_t size; |
65 | data = 0; | 66 | data = 0; |
66 | 67 | ||
67 | mailmessage * msg = 0; | 68 | mailmessage * msg = 0; |
68 | msg = mime_message_init(mimeMail); | 69 | msg = mime_message_init(mimeMail); |
69 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | 70 | mime_message_set_tmpdir(msg,getenv( "HOME" )); |
70 | int r = mailmessage_fetch(msg,&data,&size); | 71 | int r = mailmessage_fetch(msg,&data,&size); |
71 | mime_message_detach_mime(msg); | 72 | mime_message_detach_mime(msg); |
72 | mailmessage_free(msg); | 73 | mailmessage_free(msg); |
73 | msg = 0; | 74 | msg = 0; |
74 | if (r != MAIL_NO_ERROR || !data) { | 75 | if (r != MAIL_NO_ERROR || !data) { |
75 | qDebug("Error fetching mime..."); | 76 | qDebug("Error fetching mime..."); |
76 | ret = 0; | 77 | ret = 0; |
diff --git a/noncore/net/mail/libmailwrapper/storemail.h b/noncore/net/mail/libmailwrapper/storemail.h index 80c7431..4433de0 100644 --- a/noncore/net/mail/libmailwrapper/storemail.h +++ b/noncore/net/mail/libmailwrapper/storemail.h | |||
@@ -1,29 +1,29 @@ | |||
1 | #ifndef __STORE_MAIL_H | 1 | #ifndef __STORE_MAIL_H |
2 | #define __STORE_MAIL_H | 2 | #define __STORE_MAIL_H |
3 | 3 | ||
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | 5 | ||
6 | #include "generatemail.h" | 6 | #include "generatemail.h" |
7 | 7 | ||
8 | class Account; | 8 | 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::OSmartPointer<Mail>&mail); | 21 | int storeMail(const Opie::Core::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 |