-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 15 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 5 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/libmailwrapper.pro | 16 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 4 |
7 files changed, 46 insertions, 17 deletions
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index ca9caed..a070fb0 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -1,55 +1,57 @@ | |||
1 | #ifndef __abstract_mail_ | 1 | #ifndef __abstract_mail_ |
2 | #define __abstract_mail_ | 2 | #define __abstract_mail_ |
3 | 3 | ||
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | #include "settings.h" | 5 | #include "settings.h" |
6 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | class RecPart; | 9 | class RecPart; |
10 | class IMAPwrapper; | 10 | class IMAPwrapper; |
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class Folder; | 12 | class Folder; |
13 | class encodedString; | 13 | class encodedString; |
14 | struct folderStat; | 14 | struct folderStat; |
15 | 15 | ||
16 | class AbstractMail:public QObject | 16 | class AbstractMail:public QObject |
17 | { | 17 | { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
20 | AbstractMail(){}; | 20 | AbstractMail(){}; |
21 | virtual ~AbstractMail(){} | 21 | virtual ~AbstractMail(){} |
22 | virtual QList<Folder>* listFolders()=0; | 22 | virtual QList<Folder>* listFolders()=0; |
23 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 23 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | 24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; |
25 | virtual RecBody fetchBody(const RecMail&mail)=0; | 25 | virtual RecBody fetchBody(const RecMail&mail)=0; |
26 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; | 26 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; |
27 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | 27 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; |
28 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | 28 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; |
29 | 29 | ||
30 | virtual void deleteMail(const RecMail&mail)=0; | 30 | virtual void deleteMail(const RecMail&mail)=0; |
31 | virtual void answeredMail(const RecMail&mail)=0; | 31 | virtual void answeredMail(const RecMail&mail)=0; |
32 | virtual void cleanMimeCache(){}; | 32 | virtual int deleteAllMail(const Folder*)=0; |
33 | virtual int deleteAllMail(const Folder*){return 1;} | 33 | virtual int deleteMbox(const Folder*)=0; |
34 | virtual int deleteMbox(const Folder*){return 1;} | 34 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
35 | 35 | ||
36 | virtual void cleanMimeCache(){}; | ||
36 | /* mail box methods */ | 37 | /* mail box methods */ |
37 | /* parameter is the box to create. | 38 | /* parameter is the box to create. |
38 | * if the implementing subclass has prefixes, | 39 | * if the implementing subclass has prefixes, |
39 | * them has to be appended automatic. | 40 | * them has to be appended automatic. |
40 | */ | 41 | */ |
41 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 42 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
42 | 43 | virtual void logout()=0; | |
44 | |||
43 | static AbstractMail* getWrapper(IMAPaccount *a); | 45 | static AbstractMail* getWrapper(IMAPaccount *a); |
44 | static AbstractMail* getWrapper(POP3account *a); | 46 | static AbstractMail* getWrapper(POP3account *a); |
45 | /* mbox only! */ | 47 | /* mbox only! */ |
46 | static AbstractMail* getWrapper(const QString&a); | 48 | static AbstractMail* getWrapper(const QString&a); |
47 | 49 | ||
48 | static QString defaultLocalfolder(); | 50 | static QString defaultLocalfolder(); |
49 | 51 | ||
50 | protected: | 52 | protected: |
51 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 53 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
52 | static QString convert_String(const char*text); | 54 | static QString convert_String(const char*text); |
53 | static QString gen_attachment_id(); | 55 | static QString gen_attachment_id(); |
54 | }; | 56 | }; |
55 | #endif | 57 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h index 32b75c8..1d65c0a 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.h +++ b/noncore/net/mail/libmailwrapper/genericwrapper.h | |||
@@ -1,59 +1,62 @@ | |||
1 | #ifndef __GENERIC_WRAPPER_H | 1 | #ifndef __GENERIC_WRAPPER_H |
2 | #define __GENERIC_WRAPPER_H | 2 | #define __GENERIC_WRAPPER_H |
3 | 3 | ||
4 | #include "abstractmail.h" | 4 | #include "abstractmail.h" |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | class RecMail; | 9 | class RecMail; |
10 | class RecBody; | 10 | class RecBody; |
11 | class encodedString; | 11 | class encodedString; |
12 | struct mailpop3; | 12 | struct mailpop3; |
13 | struct mailmessage; | 13 | struct mailmessage; |
14 | struct mailmime; | 14 | struct mailmime; |
15 | struct mailmime_mechanism; | 15 | struct mailmime_mechanism; |
16 | struct mailimf_mailbox_list; | 16 | 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 | 22 | ||
23 | /* this class hold just the funs shared between | 23 | /* this class hold just the funs shared between |
24 | * mbox and pop3 (later mh, too) mail access. | 24 | * mbox and pop3 (later mh, too) mail access. |
25 | * it is not desigend to make a instance of it! | 25 | * it is not desigend to make a instance of it! |
26 | */ | 26 | */ |
27 | class Genericwrapper : public AbstractMail | 27 | class Genericwrapper : public AbstractMail |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | Genericwrapper(); | 31 | Genericwrapper(); |
32 | virtual ~Genericwrapper(); | 32 | virtual ~Genericwrapper(); |
33 | 33 | ||
34 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 34 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
35 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 35 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
37 | virtual void cleanMimeCache(); | 37 | virtual void cleanMimeCache(); |
38 | virtual int deleteMbox(const Folder*){return 1;} | ||
39 | virtual void logout(){}; | ||
40 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; | ||
38 | 41 | ||
39 | protected: | 42 | protected: |
40 | RecMail *parseHeader( const char *header ); | 43 | RecMail *parseHeader( const char *header ); |
41 | RecBody parseMail( mailmessage * msg ); | 44 | RecBody parseMail( mailmessage * msg ); |
42 | QString parseMailboxList( mailimf_mailbox_list *list ); | 45 | QString parseMailboxList( mailimf_mailbox_list *list ); |
43 | QString parseMailbox( mailimf_mailbox *box ); | 46 | QString parseMailbox( mailimf_mailbox *box ); |
44 | QString parseGroup( mailimf_group *group ); | 47 | QString parseGroup( mailimf_group *group ); |
45 | QString parseAddressList( mailimf_address_list *list ); | 48 | QString parseAddressList( mailimf_address_list *list ); |
46 | QString parseDateTime( mailimf_date_time *date ); | 49 | QString parseDateTime( mailimf_date_time *date ); |
47 | 50 | ||
48 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); | 51 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); |
49 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); | 52 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); |
50 | static void fillParameters(RecPart&target,clist*parameters); | 53 | static void fillParameters(RecPart&target,clist*parameters); |
51 | static QString getencoding(mailmime_mechanism*aEnc); | 54 | static QString getencoding(mailmime_mechanism*aEnc); |
52 | virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox); | 55 | virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox); |
53 | 56 | ||
54 | QString msgTempName; | 57 | QString msgTempName; |
55 | unsigned int last_msg_id; | 58 | unsigned int last_msg_id; |
56 | QMap<QString,encodedString*> bodyCache; | 59 | QMap<QString,encodedString*> bodyCache; |
57 | }; | 60 | }; |
58 | 61 | ||
59 | #endif | 62 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index f1d42c2..0c1e05e 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,115 +1,115 @@ | |||
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 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 9 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
10 | : AbstractMail() | 10 | : AbstractMail() |
11 | { | 11 | { |
12 | account = a; | 12 | account = a; |
13 | m_imap = 0; | 13 | m_imap = 0; |
14 | } | 14 | } |
15 | 15 | ||
16 | IMAPwrapper::~IMAPwrapper() | 16 | IMAPwrapper::~IMAPwrapper() |
17 | { | 17 | { |
18 | logout(); | 18 | logout(); |
19 | } | 19 | } |
20 | 20 | ||
21 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 21 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
22 | { | 22 | { |
23 | qDebug( "IMAP: %i of %i", current, maximum ); | 23 | qDebug( "IMAP: %i of %i", current, maximum ); |
24 | } | 24 | } |
25 | 25 | ||
26 | void IMAPwrapper::login() | 26 | void IMAPwrapper::login() |
27 | { | 27 | { |
28 | const char *server, *user, *pass; | 28 | const char *server, *user, *pass; |
29 | uint16_t port; | 29 | uint16_t port; |
30 | int err = MAILIMAP_NO_ERROR; | 30 | int err = MAILIMAP_NO_ERROR; |
31 | 31 | ||
32 | /* we are connected this moment */ | 32 | /* we are connected this moment */ |
33 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 33 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
34 | if (m_imap) { | 34 | if (m_imap) { |
35 | err = mailimap_noop(m_imap); | 35 | err = mailimap_noop(m_imap); |
36 | if (err!=MAILIMAP_NO_ERROR) { | 36 | if (err!=MAILIMAP_NO_ERROR) { |
37 | logout(); | 37 | logout(); |
38 | } else { | 38 | } else { |
39 | mailstream_flush(m_imap->imap_stream); | 39 | mailstream_flush(m_imap->imap_stream); |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | server = account->getServer().latin1(); | 43 | server = account->getServer().latin1(); |
44 | port = account->getPort().toUInt(); | 44 | port = account->getPort().toUInt(); |
45 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 45 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
46 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 46 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
47 | login.show(); | 47 | login.show(); |
48 | if ( QDialog::Accepted == login.exec() ) { | 48 | if ( QDialog::Accepted == login.exec() ) { |
49 | // ok | 49 | // ok |
50 | user = strdup( login.getUser().latin1() ); | 50 | user = login.getUser().latin1(); |
51 | pass = strdup( login.getPassword().latin1() ); | 51 | pass = login.getPassword().latin1(); |
52 | } else { | 52 | } else { |
53 | // cancel | 53 | // cancel |
54 | qDebug( "IMAP: Login canceled" ); | 54 | qDebug( "IMAP: Login canceled" ); |
55 | return; | 55 | return; |
56 | } | 56 | } |
57 | } else { | 57 | } else { |
58 | user = account->getUser().latin1(); | 58 | user = account->getUser().latin1(); |
59 | pass = account->getPassword().latin1(); | 59 | pass = account->getPassword().latin1(); |
60 | } | 60 | } |
61 | 61 | ||
62 | m_imap = mailimap_new( 20, &imap_progress ); | 62 | m_imap = mailimap_new( 20, &imap_progress ); |
63 | 63 | ||
64 | /* connect */ | 64 | /* connect */ |
65 | if (account->getSSL()) { | 65 | if (account->getSSL()) { |
66 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | 66 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); |
67 | } else { | 67 | } else { |
68 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 68 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
69 | } | 69 | } |
70 | 70 | ||
71 | if ( err != MAILIMAP_NO_ERROR && | 71 | if ( err != MAILIMAP_NO_ERROR && |
72 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 72 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
73 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 73 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
74 | QString failure = ""; | 74 | QString failure = ""; |
75 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 75 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
76 | failure="Connection refused"; | 76 | failure="Connection refused"; |
77 | } else { | 77 | } else { |
78 | failure="Unknown failure"; | 78 | failure="Unknown failure"; |
79 | } | 79 | } |
80 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); | 80 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); |
81 | mailimap_free( m_imap ); | 81 | mailimap_free( m_imap ); |
82 | m_imap = 0; | 82 | m_imap = 0; |
83 | return; | 83 | return; |
84 | } | 84 | } |
85 | 85 | ||
86 | /* login */ | 86 | /* login */ |
87 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 87 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
88 | if ( err != MAILIMAP_NO_ERROR ) { | 88 | if ( err != MAILIMAP_NO_ERROR ) { |
89 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); | 89 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); |
90 | err = mailimap_close( m_imap ); | 90 | err = mailimap_close( m_imap ); |
91 | mailimap_free( m_imap ); | 91 | mailimap_free( m_imap ); |
92 | m_imap = 0; | 92 | m_imap = 0; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void IMAPwrapper::logout() | 96 | void IMAPwrapper::logout() |
97 | { | 97 | { |
98 | int err = MAILIMAP_NO_ERROR; | 98 | int err = MAILIMAP_NO_ERROR; |
99 | if (!m_imap) return; | 99 | if (!m_imap) return; |
100 | err = mailimap_logout( m_imap ); | 100 | err = mailimap_logout( m_imap ); |
101 | err = mailimap_close( m_imap ); | 101 | err = mailimap_close( m_imap ); |
102 | mailimap_free( m_imap ); | 102 | mailimap_free( m_imap ); |
103 | m_imap = 0; | 103 | m_imap = 0; |
104 | } | 104 | } |
105 | 105 | ||
106 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | 106 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) |
107 | { | 107 | { |
108 | const char *mb = 0; | 108 | const char *mb = 0; |
109 | int err = MAILIMAP_NO_ERROR; | 109 | int err = MAILIMAP_NO_ERROR; |
110 | clist *result = 0; | 110 | clist *result = 0; |
111 | clistcell *current; | 111 | clistcell *current; |
112 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; | 112 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; |
113 | mailimap_fetch_type *fetchType = 0; | 113 | mailimap_fetch_type *fetchType = 0; |
114 | mailimap_set *set = 0; | 114 | mailimap_set *set = 0; |
115 | 115 | ||
@@ -913,64 +913,75 @@ int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const | |||
913 | return 0; | 913 | return 0; |
914 | } | 914 | } |
915 | } | 915 | } |
916 | qDebug("Creating %s",pre.latin1()); | 916 | qDebug("Creating %s",pre.latin1()); |
917 | int res = mailimap_create(m_imap,pre.latin1()); | 917 | int res = mailimap_create(m_imap,pre.latin1()); |
918 | if (res != MAILIMAP_NO_ERROR) { | 918 | if (res != MAILIMAP_NO_ERROR) { |
919 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 919 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
920 | return 0; | 920 | return 0; |
921 | } | 921 | } |
922 | return 1; | 922 | return 1; |
923 | } | 923 | } |
924 | 924 | ||
925 | int IMAPwrapper::deleteMbox(const Folder*folder) | 925 | int IMAPwrapper::deleteMbox(const Folder*folder) |
926 | { | 926 | { |
927 | if (!folder) return 0; | 927 | if (!folder) return 0; |
928 | login(); | 928 | login(); |
929 | if (!m_imap) {return 0;} | 929 | if (!m_imap) {return 0;} |
930 | int res = mailimap_delete(m_imap,folder->getName()); | 930 | int res = mailimap_delete(m_imap,folder->getName()); |
931 | if (res != MAILIMAP_NO_ERROR) { | 931 | if (res != MAILIMAP_NO_ERROR) { |
932 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 932 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
933 | return 0; | 933 | return 0; |
934 | } | 934 | } |
935 | return 1; | 935 | return 1; |
936 | } | 936 | } |
937 | 937 | ||
938 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 938 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
939 | { | 939 | { |
940 | mailimap_status_att_list * att_list =0; | 940 | mailimap_status_att_list * att_list =0; |
941 | mailimap_mailbox_data_status * status=0; | 941 | mailimap_mailbox_data_status * status=0; |
942 | clistiter * cur = 0; | 942 | clistiter * cur = 0; |
943 | int r = 0; | 943 | int r = 0; |
944 | int res = 0; | 944 | int res = 0; |
945 | target_stat.message_count = 0; | 945 | target_stat.message_count = 0; |
946 | target_stat.message_unseen = 0; | 946 | target_stat.message_unseen = 0; |
947 | target_stat.message_recent = 0; | 947 | target_stat.message_recent = 0; |
948 | login(); | 948 | login(); |
949 | if (!m_imap) { | 949 | if (!m_imap) { |
950 | return; | 950 | return; |
951 | } | 951 | } |
952 | att_list = mailimap_status_att_list_new_empty(); | 952 | att_list = mailimap_status_att_list_new_empty(); |
953 | if (!att_list) return; | 953 | if (!att_list) return; |
954 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 954 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
955 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 955 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
956 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 956 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
957 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 957 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
958 | for (cur = clist_begin(status->st_info_list); | 958 | for (cur = clist_begin(status->st_info_list); |
959 | cur != NULL ; cur = clist_next(cur)) { | 959 | cur != NULL ; cur = clist_next(cur)) { |
960 | mailimap_status_info * status_info; | 960 | mailimap_status_info * status_info; |
961 | status_info = (mailimap_status_info *)clist_content(cur); | 961 | status_info = (mailimap_status_info *)clist_content(cur); |
962 | switch (status_info->st_att) { | 962 | switch (status_info->st_att) { |
963 | case MAILIMAP_STATUS_ATT_MESSAGES: | 963 | case MAILIMAP_STATUS_ATT_MESSAGES: |
964 | target_stat.message_count = status_info->st_value; | 964 | target_stat.message_count = status_info->st_value; |
965 | break; | 965 | break; |
966 | case MAILIMAP_STATUS_ATT_RECENT: | 966 | case MAILIMAP_STATUS_ATT_RECENT: |
967 | target_stat.message_recent = status_info->st_value; | 967 | target_stat.message_recent = status_info->st_value; |
968 | break; | 968 | break; |
969 | case MAILIMAP_STATUS_ATT_UNSEEN: | 969 | case MAILIMAP_STATUS_ATT_UNSEEN: |
970 | target_stat.message_unseen = status_info->st_value; | 970 | target_stat.message_unseen = status_info->st_value; |
971 | break; | 971 | break; |
972 | } | 972 | } |
973 | } | 973 | } |
974 | mailimap_mailbox_data_status_free(status); | 974 | mailimap_mailbox_data_status_free(status); |
975 | mailimap_status_att_list_free(att_list); | 975 | mailimap_status_att_list_free(att_list); |
976 | } | 976 | } |
977 | |||
978 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | ||
979 | { | ||
980 | login(); | ||
981 | if (!m_imap) return; | ||
982 | if (!msg) return; | ||
983 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | ||
984 | if (r != MAILIMAP_NO_ERROR) { | ||
985 | Global::statusMessage("Error storing mail!"); | ||
986 | } | ||
987 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 8f5a2b5..a97f12d 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -1,68 +1,69 @@ | |||
1 | #ifndef __IMAPWRAPPER | 1 | #ifndef __IMAPWRAPPER |
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 QList<Folder>* listFolders(); | 26 | virtual QList<Folder>* listFolders(); |
27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); | 27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
29 | 29 | ||
30 | virtual void deleteMail(const RecMail&mail); | 30 | virtual void deleteMail(const RecMail&mail); |
31 | virtual void answeredMail(const RecMail&mail); | 31 | virtual void answeredMail(const RecMail&mail); |
32 | virtual int deleteAllMail(const Folder*folder); | 32 | virtual int deleteAllMail(const Folder*folder); |
33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | ||
33 | 34 | ||
34 | virtual RecBody fetchBody(const RecMail&mail); | 35 | virtual RecBody fetchBody(const RecMail&mail); |
35 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
36 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 37 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
37 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 38 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
38 | 39 | ||
39 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 40 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
40 | virtual int deleteMbox(const Folder*folder); | 41 | virtual int deleteMbox(const Folder*folder); |
41 | 42 | ||
42 | static void imap_progress( size_t current, size_t maximum ); | 43 | static void imap_progress( size_t current, size_t maximum ); |
43 | 44 | ||
45 | virtual void logout(); | ||
44 | protected: | 46 | protected: |
45 | RecMail*parse_list_result(mailimap_msg_att*); | 47 | RecMail*parse_list_result(mailimap_msg_att*); |
46 | void login(); | 48 | void login(); |
47 | void logout(); | ||
48 | 49 | ||
49 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 50 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
50 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); | 51 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); |
51 | 52 | ||
52 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 53 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
53 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 54 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
54 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 55 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
55 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 56 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
56 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); | 57 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); |
57 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 58 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
58 | 59 | ||
59 | /* just helpers */ | 60 | /* just helpers */ |
60 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 61 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
61 | static QStringList address_list_to_stringlist(clist*list); | 62 | static QStringList address_list_to_stringlist(clist*list); |
62 | 63 | ||
63 | 64 | ||
64 | IMAPaccount *account; | 65 | IMAPaccount *account; |
65 | mailimap *m_imap; | 66 | mailimap *m_imap; |
66 | }; | 67 | }; |
67 | 68 | ||
68 | #endif | 69 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/libmailwrapper.pro b/noncore/net/mail/libmailwrapper/libmailwrapper.pro index 4b4a4f1..18583bb 100644 --- a/noncore/net/mail/libmailwrapper/libmailwrapper.pro +++ b/noncore/net/mail/libmailwrapper/libmailwrapper.pro | |||
@@ -1,44 +1,46 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on debug | 2 | CONFIG += qt warn_on debug |
3 | 3 | ||
4 | HEADERS = mailwrapper.h \ | 4 | HEADERS = mailwrapper.h \ |
5 | imapwrapper.h \ | 5 | imapwrapper.h \ |
6 | mailtypes.h \ | 6 | mailtypes.h \ |
7 | pop3wrapper.h \ | 7 | pop3wrapper.h \ |
8 | abstractmail.h \ | 8 | abstractmail.h \ |
9 | smtpwrapper.h \ | 9 | smtpwrapper.h \ |
10 | genericwrapper.h \ | 10 | genericwrapper.h \ |
11 | mboxwrapper.h \ | 11 | mboxwrapper.h \ |
12 | settings.h \ | 12 | settings.h \ |
13 | logindialog.h \ | 13 | logindialog.h \ |
14 | sendmailprogress.h | 14 | sendmailprogress.h \ |
15 | statusmail.h | ||
15 | 16 | ||
16 | SOURCES = imapwrapper.cpp \ | 17 | SOURCES = imapwrapper.cpp \ |
17 | mailwrapper.cpp \ | 18 | mailwrapper.cpp \ |
18 | mailtypes.cpp \ | 19 | mailtypes.cpp \ |
19 | pop3wrapper.cpp \ | 20 | pop3wrapper.cpp \ |
20 | abstractmail.cpp \ | 21 | abstractmail.cpp \ |
21 | smtpwrapper.cpp \ | 22 | smtpwrapper.cpp \ |
22 | genericwrapper.cpp \ | 23 | genericwrapper.cpp \ |
23 | mboxwrapper.cpp \ | 24 | mboxwrapper.cpp \ |
24 | settings.cpp \ | 25 | settings.cpp \ |
25 | logindialog.cpp \ | 26 | logindialog.cpp \ |
26 | sendmailprogress.cpp | 27 | sendmailprogress.cpp \ |
28 | statusmail.cpp | ||
27 | 29 | ||
28 | INTERFACES = logindialogui.ui \ | 30 | INTERFACES = logindialogui.ui \ |
29 | sendmailprogressui.ui | 31 | sendmailprogressui.ui |
30 | 32 | ||
31 | 33 | ||
32 | INCLUDEPATH += $(OPIEDIR)/include | 34 | INCLUDEPATH += $(OPIEDIR)/include |
33 | 35 | ||
34 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) | 36 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) |
35 | contains( CONFTEST, y ){ | 37 | contains( CONFTEST, y ){ |
36 | LIBS += -lqpe -letpan -lssl -lcrypto -liconv | 38 | LIBS += -lqpe -letpan -lssl -lcrypto -liconv |
37 | }else{ | 39 | }else{ |
38 | LIBS += -lqpe -letpan -lssl -lcrypto | 40 | LIBS += -lqpe -letpan -lssl -lcrypto |
39 | } | 41 | } |
40 | 42 | ||
41 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) | 43 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) |
42 | TARGET = mailwrapper | 44 | TARGET = mailwrapper |
43 | 45 | ||
44 | include ( $(OPIEDIR)/include.pro ) | 46 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index d76d82a..b4eca6f 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -166,64 +166,72 @@ void POP3wrapper::logout() | |||
166 | if ( m_pop3 == NULL ) return; | 166 | if ( m_pop3 == NULL ) return; |
167 | mailfolder_free(m_folder); | 167 | mailfolder_free(m_folder); |
168 | m_folder = 0; | 168 | m_folder = 0; |
169 | mailstorage_free(m_pop3); | 169 | mailstorage_free(m_pop3); |
170 | m_pop3 = 0; | 170 | m_pop3 = 0; |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | QList<Folder>* POP3wrapper::listFolders() | 174 | QList<Folder>* POP3wrapper::listFolders() |
175 | { | 175 | { |
176 | QList<Folder> * folders = new QList<Folder>(); | 176 | QList<Folder> * folders = new QList<Folder>(); |
177 | folders->setAutoDelete( false ); | 177 | folders->setAutoDelete( false ); |
178 | Folder*inb=new Folder("INBOX","/"); | 178 | Folder*inb=new Folder("INBOX","/"); |
179 | folders->append(inb); | 179 | folders->append(inb); |
180 | return folders; | 180 | return folders; |
181 | } | 181 | } |
182 | 182 | ||
183 | void POP3wrapper::deleteMail(const RecMail&mail) | 183 | void POP3wrapper::deleteMail(const RecMail&mail) |
184 | { | 184 | { |
185 | login(); | 185 | login(); |
186 | if (!m_pop3) return; | 186 | if (!m_pop3) return; |
187 | int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); | 187 | int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); |
188 | if (err != MAIL_NO_ERROR) { | 188 | if (err != MAIL_NO_ERROR) { |
189 | Global::statusMessage(tr("error deleting mail")); | 189 | Global::statusMessage(tr("error deleting mail")); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | void POP3wrapper::answeredMail(const RecMail&) | 193 | void POP3wrapper::answeredMail(const RecMail&) |
194 | { | 194 | { |
195 | } | 195 | } |
196 | 196 | ||
197 | int POP3wrapper::deleteAllMail(const Folder*) | 197 | int POP3wrapper::deleteAllMail(const Folder*) |
198 | { | 198 | { |
199 | login(); | 199 | login(); |
200 | if (!m_pop3) return 0; | 200 | if (!m_pop3) return 0; |
201 | int res = 1; | 201 | int res = 1; |
202 | 202 | ||
203 | uint32_t result = 0; | 203 | uint32_t result = 0; |
204 | int err = mailsession_messages_number(m_folder->fld_session,NULL,&result); | 204 | int err = mailsession_messages_number(m_folder->fld_session,NULL,&result); |
205 | if (err != MAIL_NO_ERROR) { | 205 | if (err != MAIL_NO_ERROR) { |
206 | Global::statusMessage(tr("Error getting folder info")); | 206 | Global::statusMessage(tr("Error getting folder info")); |
207 | return 0; | 207 | return 0; |
208 | } | 208 | } |
209 | for (unsigned int i = 0; i < result; ++i) { | 209 | for (unsigned int i = 0; i < result; ++i) { |
210 | err = mailsession_remove_message(m_folder->fld_session,i+1); | 210 | err = mailsession_remove_message(m_folder->fld_session,i+1); |
211 | if (err != MAIL_NO_ERROR) { | 211 | if (err != MAIL_NO_ERROR) { |
212 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 212 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
213 | res=0; | 213 | res=0; |
214 | } | 214 | } |
215 | break; | 215 | break; |
216 | } | 216 | } |
217 | return res; | 217 | return res; |
218 | } | 218 | } |
219 | 219 | ||
220 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) | 220 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) |
221 | { | 221 | { |
222 | login(); | 222 | login(); |
223 | target_stat.message_count = 0; | 223 | target_stat.message_count = 0; |
224 | target_stat.message_unseen = 0; | 224 | target_stat.message_unseen = 0; |
225 | target_stat.message_recent = 0; | 225 | target_stat.message_recent = 0; |
226 | if (!m_pop3) return; | 226 | if (!m_pop3) return; |
227 | int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, | 227 | int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, |
228 | &target_stat.message_recent,&target_stat.message_unseen); | 228 | &target_stat.message_recent,&target_stat.message_unseen); |
229 | } | 229 | } |
230 | |||
231 | void POP3wrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) | ||
232 | { | ||
233 | mailmessage * mailmsg = 0; | ||
234 | int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); | ||
235 | err = mailmessage_fetch(mailmsg,target,length); | ||
236 | if (mailmsg) mailmessage_free(mailmsg); | ||
237 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index 536cadc..9cba101 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -1,39 +1,41 @@ | |||
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 | struct mailstorage; | 8 | struct mailstorage; |
9 | struct mailfolder; | 9 | struct mailfolder; |
10 | 10 | ||
11 | class POP3wrapper : public Genericwrapper | 11 | class POP3wrapper : public Genericwrapper |
12 | { | 12 | { |
13 | Q_OBJECT | 13 | Q_OBJECT |
14 | 14 | ||
15 | public: | 15 | public: |
16 | POP3wrapper( POP3account *a ); | 16 | POP3wrapper( POP3account *a ); |
17 | virtual ~POP3wrapper(); | 17 | virtual ~POP3wrapper(); |
18 | /* mailbox will be ignored */ | 18 | /* mailbox will be ignored */ |
19 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 19 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
20 | virtual QList<Folder>* listFolders(); | 20 | virtual QList<Folder>* listFolders(); |
21 | /* mailbox will be ignored */ | 21 | /* mailbox will be ignored */ |
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 RecMail&mail); | 24 | virtual void deleteMail(const RecMail&mail); |
25 | virtual void answeredMail(const RecMail&mail); | 25 | virtual void answeredMail(const RecMail&mail); |
26 | virtual int deleteAllMail(const Folder*); | 26 | virtual int deleteAllMail(const Folder*); |
27 | 27 | ||
28 | virtual RecBody fetchBody( const RecMail &mail ); | 28 | virtual RecBody fetchBody( const RecMail &mail ); |
29 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); | ||
30 | virtual void logout(); | ||
31 | |||
29 | static void pop3_progress( size_t current, size_t maximum ); | 32 | static void pop3_progress( size_t current, size_t maximum ); |
30 | 33 | ||
31 | protected: | 34 | protected: |
32 | void login(); | 35 | void login(); |
33 | void logout(); | ||
34 | POP3account *account; | 36 | POP3account *account; |
35 | mailstorage*m_pop3; | 37 | mailstorage*m_pop3; |
36 | mailfolder*m_folder; | 38 | mailfolder*m_folder; |
37 | }; | 39 | }; |
38 | 40 | ||
39 | #endif | 41 | #endif |