author | jgf <jgf> | 2003-12-09 21:36:56 (UTC) |
---|---|---|
committer | jgf <jgf> | 2003-12-09 21:36:56 (UTC) |
commit | 6b45c1f8e0293914c1328f15a665d2ea0fba7b43 (patch) (unidiff) | |
tree | d87ef7d3147a52429849a6921e7a8f31fde89aa8 /noncore | |
parent | 0a1f6405780b18c9f3d953adcfd072de8fd4dc18 (diff) | |
download | opie-6b45c1f8e0293914c1328f15a665d2ea0fba7b43.zip opie-6b45c1f8e0293914c1328f15a665d2ea0fba7b43.tar.gz opie-6b45c1f8e0293914c1328f15a665d2ea0fba7b43.tar.bz2 |
POP3 support - first steps
-rw-r--r-- | noncore/net/mail/accountview.cpp | 45 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 16 | ||||
-rw-r--r-- | noncore/net/mail/defines.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 74 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 28 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/mail.pro | 18 | ||||
-rw-r--r-- | noncore/net/mail/opie-mail.control | 2 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 74 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.h | 28 | ||||
-rw-r--r-- | noncore/net/mail/settings.cpp | 4 |
11 files changed, 278 insertions, 17 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index df9fc11..6963027 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,17 +1,54 @@ | |||
1 | #include "accountview.h" | 1 | #include "accountview.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | ||
3 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
4 | #include "defines.h" | 5 | #include "defines.h" |
5 | 6 | ||
7 | |||
8 | /** | ||
9 | * POP3 Account stuff | ||
10 | */ | ||
11 | |||
12 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) | ||
13 | : AccountViewItem( parent ) | ||
14 | { | ||
15 | account = a; | ||
16 | wrapper = new POP3wrapper( account ); | ||
17 | setPixmap( 0, PIXMAP_POP3FOLDER ); | ||
18 | setText( 0, account->getAccountName() ); | ||
19 | } | ||
20 | |||
21 | POP3viewItem::~POP3viewItem() | ||
22 | { | ||
23 | delete wrapper; | ||
24 | } | ||
25 | |||
26 | void POP3viewItem::refresh( QList<RecMail> &target ) | ||
27 | { | ||
28 | qDebug( "POP3: refresh" ); | ||
29 | wrapper->listMessages( target ); | ||
30 | } | ||
31 | |||
32 | |||
33 | RecBody POP3viewItem::fetchBody( const RecMail & ) | ||
34 | { | ||
35 | qDebug( "POP3 fetchBody: IMPLEMENT ME!!" ); | ||
36 | return RecBody(); | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * IMAP Account stuff | ||
41 | */ | ||
42 | |||
6 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) | 43 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) |
7 | : AccountViewItem( parent ) | 44 | : AccountViewItem( parent ) |
8 | { | 45 | { |
9 | account = a; | 46 | account = a; |
10 | wrapper = new IMAPwrapper( account ); | 47 | wrapper = new IMAPwrapper( account ); |
11 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 48 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
12 | setText( 0, account->getAccountName() ); | 49 | setText( 0, account->getAccountName() ); |
13 | setOpen( true ); | 50 | setOpen( true ); |
14 | } | 51 | } |
15 | 52 | ||
16 | IMAPviewItem::~IMAPviewItem() | 53 | IMAPviewItem::~IMAPviewItem() |
17 | { | 54 | { |
@@ -60,41 +97,49 @@ IMAPfolderItem::IMAPfolderItem( IMAPFolder *folderInit, IMAPviewItem *parent ) | |||
60 | } | 97 | } |
61 | 98 | ||
62 | void IMAPfolderItem::refresh(QList<RecMail>&target) | 99 | void IMAPfolderItem::refresh(QList<RecMail>&target) |
63 | { | 100 | { |
64 | imap->getWrapper()->listMessages( folder->getName(),target ); | 101 | imap->getWrapper()->listMessages( folder->getName(),target ); |
65 | } | 102 | } |
66 | 103 | ||
67 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | 104 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) |
68 | { | 105 | { |
69 | return imap->getWrapper()->fetchBody(aMail); | 106 | return imap->getWrapper()->fetchBody(aMail); |
70 | } | 107 | } |
71 | 108 | ||
109 | /** | ||
110 | * Generic stuff | ||
111 | */ | ||
112 | |||
72 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 113 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
73 | : QListView( parent, name, flags ) | 114 | : QListView( parent, name, flags ) |
74 | { | 115 | { |
75 | connect( this, SIGNAL( clicked( QListViewItem * ) ), | 116 | connect( this, SIGNAL( clicked( QListViewItem * ) ), |
76 | SLOT( refresh( QListViewItem * ) ) ); | 117 | SLOT( refresh( QListViewItem * ) ) ); |
77 | } | 118 | } |
78 | 119 | ||
79 | void AccountView::populate( QList<Account> list ) | 120 | void AccountView::populate( QList<Account> list ) |
80 | { | 121 | { |
81 | clear(); | 122 | clear(); |
82 | 123 | ||
83 | Account *it; | 124 | Account *it; |
84 | for ( it = list.first(); it; it = list.next() ) { | 125 | for ( it = list.first(); it; it = list.next() ) { |
85 | if ( it->getType().compare( "IMAP" ) == 0 ) { | 126 | if ( it->getType().compare( "IMAP" ) == 0 ) { |
86 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 127 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
87 | qDebug( "added IMAP " + imap->getAccountName() ); | 128 | qDebug( "added IMAP " + imap->getAccountName() ); |
88 | (void) new IMAPviewItem( imap, this ); | 129 | (void) new IMAPviewItem( imap, this ); |
130 | } else if ( it->getType().compare( "POP3" ) == 0 ) { | ||
131 | POP3account *pop3 = static_cast<POP3account *>(it); | ||
132 | qDebug( "added POP3 " + pop3->getAccountName() ); | ||
133 | (void) new POP3viewItem( pop3, this ); | ||
89 | } | 134 | } |
90 | } | 135 | } |
91 | } | 136 | } |
92 | 137 | ||
93 | void AccountView::refresh(QListViewItem *item) { | 138 | void AccountView::refresh(QListViewItem *item) { |
94 | qDebug("AccountView refresh..."); | 139 | qDebug("AccountView refresh..."); |
95 | if ( item ) { | 140 | if ( item ) { |
96 | QList<RecMail> headerlist; | 141 | QList<RecMail> headerlist; |
97 | headerlist.setAutoDelete(true); | 142 | headerlist.setAutoDelete(true); |
98 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 143 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
99 | view->refresh(headerlist); | 144 | view->refresh(headerlist); |
100 | emit refreshMailview(&headerlist); | 145 | emit refreshMailview(&headerlist); |
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 805c2b3..fe832ec 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -1,35 +1,51 @@ | |||
1 | #ifndef ACCOUNTVIEW_H | 1 | #ifndef ACCOUNTVIEW_H |
2 | #define ACCOUNTVIEW_H | 2 | #define ACCOUNTVIEW_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | 6 | ||
7 | #include "settings.h" | 7 | #include "settings.h" |
8 | #include "mailwrapper.h" | 8 | #include "mailwrapper.h" |
9 | 9 | ||
10 | class IMAPwrapper; | 10 | class IMAPwrapper; |
11 | class POP3wrapper; | ||
11 | class RecMail; | 12 | class RecMail; |
12 | class RecBody; | 13 | class RecBody; |
13 | 14 | ||
14 | class AccountViewItem : public QListViewItem | 15 | class AccountViewItem : public QListViewItem |
15 | { | 16 | { |
16 | 17 | ||
17 | public: | 18 | public: |
18 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} | 19 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} |
19 | AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {} | 20 | AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {} |
20 | virtual void refresh(QList<RecMail>&)=0; | 21 | virtual void refresh(QList<RecMail>&)=0; |
21 | virtual RecBody fetchBody(const RecMail&)=0; | 22 | virtual RecBody fetchBody(const RecMail&)=0; |
22 | }; | 23 | }; |
23 | 24 | ||
25 | class POP3viewItem : public AccountViewItem | ||
26 | { | ||
27 | |||
28 | public: | ||
29 | POP3viewItem( POP3account *a, QListView *parent ); | ||
30 | ~POP3viewItem(); | ||
31 | virtual void refresh( QList<RecMail> &target ); | ||
32 | virtual RecBody fetchBody(const RecMail & ); | ||
33 | |||
34 | private: | ||
35 | POP3account *account; | ||
36 | POP3wrapper *wrapper; | ||
37 | |||
38 | }; | ||
39 | |||
24 | class IMAPviewItem : public AccountViewItem | 40 | class IMAPviewItem : public AccountViewItem |
25 | { | 41 | { |
26 | 42 | ||
27 | public: | 43 | public: |
28 | IMAPviewItem( IMAPaccount *a, QListView *parent ); | 44 | IMAPviewItem( IMAPaccount *a, QListView *parent ); |
29 | ~IMAPviewItem(); | 45 | ~IMAPviewItem(); |
30 | virtual void refresh(QList<RecMail>&); | 46 | virtual void refresh(QList<RecMail>&); |
31 | virtual RecBody fetchBody(const RecMail&); | 47 | virtual RecBody fetchBody(const RecMail&); |
32 | IMAPwrapper *getWrapper(); | 48 | IMAPwrapper *getWrapper(); |
33 | 49 | ||
34 | private: | 50 | private: |
35 | IMAPaccount *account; | 51 | IMAPaccount *account; |
diff --git a/noncore/net/mail/defines.h b/noncore/net/mail/defines.h index 853454d..679459d 100644 --- a/noncore/net/mail/defines.h +++ b/noncore/net/mail/defines.h | |||
@@ -4,33 +4,35 @@ | |||
4 | #include <qpe/resource.h> | 4 | #include <qpe/resource.h> |
5 | 5 | ||
6 | #define USER_AGENT "OpieMail v0.0.1-alpha" | 6 | #define USER_AGENT "OpieMail v0.0.1-alpha" |
7 | 7 | ||
8 | #define PIC_COMPOSEMAIL "opiemail/composemail" | 8 | #define PIC_COMPOSEMAIL "opiemail/composemail" |
9 | #define PIC_SENDQUEUED "opiemail/sendqueued" | 9 | #define PIC_SENDQUEUED "opiemail/sendqueued" |
10 | #define PIC_SHOWFOLDERS "opiemail/showfolders" | 10 | #define PIC_SHOWFOLDERS "opiemail/showfolders" |
11 | #define PIC_SEARCHMAILS "opiemail/searchmails" | 11 | #define PIC_SEARCHMAILS "opiemail/searchmails" |
12 | #define PIC_EDITSETTINGS "opiemail/editsettings" | 12 | #define PIC_EDITSETTINGS "opiemail/editsettings" |
13 | #define PIC_EDITACCOUNTS "opiemail/editaccounts" | 13 | #define PIC_EDITACCOUNTS "opiemail/editaccounts" |
14 | #define PIC_SYNC "opiemail/sync" | 14 | #define PIC_SYNC "opiemail/sync" |
15 | #define PIC_IMAPFOLDER "opiemail/imapfolder" | 15 | #define PIC_IMAPFOLDER "opiemail/imapfolder" |
16 | #define PIC_POP3FOLDER "opiemail/pop3folder" | ||
16 | 17 | ||
17 | #define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) | 18 | #define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) |
18 | #define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) | 19 | #define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) |
19 | #define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) | 20 | #define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) |
20 | #define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) | 21 | #define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) |
21 | #define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) | 22 | #define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) |
22 | #define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) | 23 | #define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) |
23 | #define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) ) | 24 | #define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) ) |
24 | 25 | ||
25 | #define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) | 26 | #define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) |
27 | #define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) | ||
26 | 28 | ||
27 | #define IMAP_PORT "143" | 29 | #define IMAP_PORT "143" |
28 | #define IMAP_SSL_PORT "993" | 30 | #define IMAP_SSL_PORT "993" |
29 | #define SMTP_PORT "25" | 31 | #define SMTP_PORT "25" |
30 | #define SMTP_SSL_PORT "465" | 32 | #define SMTP_SSL_PORT "465" |
31 | #define POP3_PORT "110" | 33 | #define POP3_PORT "110" |
32 | #define POP3_SSL_PORT "995" | 34 | #define POP3_SSL_PORT "995" |
33 | #define NNTP_PORT "119" | 35 | #define NNTP_PORT "119" |
34 | #define NNTP_SSL_PORT "563" | 36 | #define NNTP_SSL_PORT "563" |
35 | 37 | ||
36 | #endif | 38 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp new file mode 100644 index 0000000..08e97f4 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -0,0 +1,74 @@ | |||
1 | |||
2 | #include "pop3wrapper.h" | ||
3 | #include "mailtypes.h" | ||
4 | #include <libetpan/mailpop3.h> | ||
5 | |||
6 | POP3wrapper::POP3wrapper( POP3account *a ) | ||
7 | { | ||
8 | account = a; | ||
9 | } | ||
10 | |||
11 | POP3wrapper::~POP3wrapper() | ||
12 | { | ||
13 | logout(); | ||
14 | } | ||
15 | |||
16 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | ||
17 | { | ||
18 | qDebug( "POP3: %i of %i", current, maximum ); | ||
19 | } | ||
20 | |||
21 | void POP3wrapper::listMessages( QList<RecMail> &target ) | ||
22 | { | ||
23 | login(); | ||
24 | //TODO: list messages | ||
25 | logout(); | ||
26 | } | ||
27 | |||
28 | void POP3wrapper::login() | ||
29 | { | ||
30 | logout(); | ||
31 | const char *server, *user, *pass; | ||
32 | uint16_t port; | ||
33 | int err = MAILPOP3_NO_ERROR; | ||
34 | |||
35 | server = account->getServer().latin1(); | ||
36 | port = account->getPort().toUInt(); | ||
37 | user = account->getUser().latin1(); | ||
38 | pass = account->getPassword().latin1(); | ||
39 | |||
40 | m_pop3 = mailpop3_new( 20, &pop3_progress ); | ||
41 | |||
42 | // connect | ||
43 | err = mailpop3_socket_connect( m_pop3, (char *) server, port ); | ||
44 | if ( err != MAILPOP3_NO_ERROR ) { | ||
45 | qDebug( "pop3: error connecting to %s\n reason: %s", server, | ||
46 | m_pop3->response ); | ||
47 | mailpop3_free( m_pop3 ); | ||
48 | m_pop3 = NULL; | ||
49 | return; | ||
50 | } | ||
51 | qDebug( "POP3: connected!" ); | ||
52 | |||
53 | // login | ||
54 | // TODO: decide if apop or plain login should be used | ||
55 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); | ||
56 | if ( err != MAILPOP3_NO_ERROR ) { | ||
57 | qDebug( "pop3: error logging in: %s", m_pop3->response ); | ||
58 | logout(); | ||
59 | return; | ||
60 | } | ||
61 | |||
62 | qDebug( "POP3: logged in!" ); | ||
63 | } | ||
64 | |||
65 | void POP3wrapper::logout() | ||
66 | { | ||
67 | int err = MAILPOP3_NO_ERROR; | ||
68 | if ( !m_pop3 ) return; | ||
69 | err = mailpop3_quit( m_pop3 ); | ||
70 | mailpop3_free( m_pop3 ); | ||
71 | m_pop3 = NULL; | ||
72 | } | ||
73 | |||
74 | |||
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h new file mode 100644 index 0000000..b791409 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef __POP3WRAPPER | ||
2 | #define __POP3WRAPPER | ||
3 | |||
4 | #include "mailwrapper.h" | ||
5 | |||
6 | class RecMail; | ||
7 | |||
8 | class POP3wrapper : public QObject | ||
9 | { | ||
10 | Q_OBJECT | ||
11 | |||
12 | public: | ||
13 | POP3wrapper( POP3account *a ); | ||
14 | virtual ~POP3wrapper(); | ||
15 | void listMessages( QList<RecMail> &target ); | ||
16 | static void pop3_progress( size_t current, size_t maximum ); | ||
17 | |||
18 | protected: | ||
19 | void login(); | ||
20 | void logout(); | ||
21 | |||
22 | private: | ||
23 | POP3account *account; | ||
24 | mailpop3 *m_pop3; | ||
25 | |||
26 | }; | ||
27 | |||
28 | #endif | ||
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index 9632301..b580954 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp | |||
@@ -123,25 +123,24 @@ IMAPaccount::IMAPaccount( QString filename ) | |||
123 | accountName = "New IMAP Account"; | 123 | accountName = "New IMAP Account"; |
124 | ssl = false; | 124 | ssl = false; |
125 | type = "IMAP"; | 125 | type = "IMAP"; |
126 | port = IMAP_PORT; | 126 | port = IMAP_PORT; |
127 | } | 127 | } |
128 | 128 | ||
129 | QString IMAPaccount::getUniqueFileName() | 129 | QString IMAPaccount::getUniqueFileName() |
130 | { | 130 | { |
131 | int num = 0; | 131 | int num = 0; |
132 | QString unique; | 132 | QString unique; |
133 | 133 | ||
134 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 134 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
135 | QStringList::Iterator it; | ||
136 | 135 | ||
137 | QStringList imap = dir.entryList( "imap-*" ); | 136 | QStringList imap = dir.entryList( "imap-*" ); |
138 | do { | 137 | do { |
139 | unique.setNum( num++ ); | 138 | unique.setNum( num++ ); |
140 | } while ( imap.contains( "imap-" + unique ) > 0 ); | 139 | } while ( imap.contains( "imap-" + unique ) > 0 ); |
141 | 140 | ||
142 | return unique; | 141 | return unique; |
143 | } | 142 | } |
144 | 143 | ||
145 | void IMAPaccount::read() | 144 | void IMAPaccount::read() |
146 | { | 145 | { |
147 | Config *conf = new Config( getFileName(), Config::File ); | 146 | Config *conf = new Config( getFileName(), Config::File ); |
@@ -201,25 +200,24 @@ POP3account::POP3account( QString filename ) | |||
201 | accountName = "New POP3 Account"; | 200 | accountName = "New POP3 Account"; |
202 | ssl = false; | 201 | ssl = false; |
203 | type = "POP3"; | 202 | type = "POP3"; |
204 | port = POP3_PORT; | 203 | port = POP3_PORT; |
205 | } | 204 | } |
206 | 205 | ||
207 | QString POP3account::getUniqueFileName() | 206 | QString POP3account::getUniqueFileName() |
208 | { | 207 | { |
209 | int num = 0; | 208 | int num = 0; |
210 | QString unique; | 209 | QString unique; |
211 | 210 | ||
212 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 211 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
213 | QStringList::Iterator it; | ||
214 | 212 | ||
215 | QStringList imap = dir.entryList( "pop3-*" ); | 213 | QStringList imap = dir.entryList( "pop3-*" ); |
216 | do { | 214 | do { |
217 | unique.setNum( num++ ); | 215 | unique.setNum( num++ ); |
218 | } while ( imap.contains( "pop3-" + unique ) > 0 ); | 216 | } while ( imap.contains( "pop3-" + unique ) > 0 ); |
219 | 217 | ||
220 | return unique; | 218 | return unique; |
221 | } | 219 | } |
222 | 220 | ||
223 | void POP3account::read() | 221 | void POP3account::read() |
224 | { | 222 | { |
225 | Config *conf = new Config( getFileName(), Config::File ); | 223 | Config *conf = new Config( getFileName(), Config::File ); |
@@ -279,25 +277,24 @@ SMTPaccount::SMTPaccount( QString filename ) | |||
279 | useBCC = false; | 277 | useBCC = false; |
280 | useReply = false; | 278 | useReply = false; |
281 | type = "SMTP"; | 279 | type = "SMTP"; |
282 | port = SMTP_PORT; | 280 | port = SMTP_PORT; |
283 | } | 281 | } |
284 | 282 | ||
285 | QString SMTPaccount::getUniqueFileName() | 283 | QString SMTPaccount::getUniqueFileName() |
286 | { | 284 | { |
287 | int num = 0; | 285 | int num = 0; |
288 | QString unique; | 286 | QString unique; |
289 | 287 | ||
290 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 288 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
291 | QStringList::Iterator it; | ||
292 | 289 | ||
293 | QStringList imap = dir.entryList( "smtp-*" ); | 290 | QStringList imap = dir.entryList( "smtp-*" ); |
294 | do { | 291 | do { |
295 | unique.setNum( num++ ); | 292 | unique.setNum( num++ ); |
296 | } while ( imap.contains( "smtp-" + unique ) > 0 ); | 293 | } while ( imap.contains( "smtp-" + unique ) > 0 ); |
297 | 294 | ||
298 | return unique; | 295 | return unique; |
299 | } | 296 | } |
300 | 297 | ||
301 | void SMTPaccount::read() | 298 | void SMTPaccount::read() |
302 | { | 299 | { |
303 | Config *conf = new Config( getFileName(), Config::File ); | 300 | Config *conf = new Config( getFileName(), Config::File ); |
@@ -375,25 +372,24 @@ NNTPaccount::NNTPaccount( QString filename ) | |||
375 | ssl = false; | 372 | ssl = false; |
376 | login = false; | 373 | login = false; |
377 | type = "NNTP"; | 374 | type = "NNTP"; |
378 | port = NNTP_PORT; | 375 | port = NNTP_PORT; |
379 | } | 376 | } |
380 | 377 | ||
381 | QString NNTPaccount::getUniqueFileName() | 378 | QString NNTPaccount::getUniqueFileName() |
382 | { | 379 | { |
383 | int num = 0; | 380 | int num = 0; |
384 | QString unique; | 381 | QString unique; |
385 | 382 | ||
386 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 383 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
387 | QStringList::Iterator it; | ||
388 | 384 | ||
389 | QStringList imap = dir.entryList( "nntp-*" ); | 385 | QStringList imap = dir.entryList( "nntp-*" ); |
390 | do { | 386 | do { |
391 | unique.setNum( num++ ); | 387 | unique.setNum( num++ ); |
392 | } while ( imap.contains( "nntp-" + unique ) > 0 ); | 388 | } while ( imap.contains( "nntp-" + unique ) > 0 ); |
393 | 389 | ||
394 | return unique; | 390 | return unique; |
395 | } | 391 | } |
396 | 392 | ||
397 | void NNTPaccount::read() | 393 | void NNTPaccount::read() |
398 | { | 394 | { |
399 | Config *conf = new Config( getFileName(), Config::File ); | 395 | Config *conf = new Config( getFileName(), Config::File ); |
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index 55d95ba..d333829 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro | |||
@@ -1,43 +1,45 @@ | |||
1 | CONFIG += qt warn_on debug quick-app | 1 | CONFIG += qt warn_on debug quick-app |
2 | 2 | ||
3 | HEADERS = defines.h \ | 3 | HEADERS = defines.h \ |
4 | logindialog.h \ | 4 | logindialog.h \ |
5 | settings.h \ | 5 | settings.h \ |
6 | editaccounts.h \ | 6 | editaccounts.h \ |
7 | mailwrapper.h \ | 7 | mailwrapper.h \ |
8 | composemail.h \ | 8 | composemail.h \ |
9 | accountview.h \ | 9 | accountview.h \ |
10 | mainwindow.h \ | 10 | mainwindow.h \ |
11 | viewmail.h \ | 11 | viewmail.h \ |
12 | viewmailbase.h \ | 12 | viewmailbase.h \ |
13 | opiemail.h \ | 13 | opiemail.h \ |
14 | imapwrapper.h \ | 14 | imapwrapper.h \ |
15 | mailtypes.h \ | 15 | mailtypes.h \ |
16 | mailistviewitem.h | 16 | mailistviewitem.h \ |
17 | pop3wrapper.h | ||
17 | 18 | ||
18 | SOURCES = main.cpp \ | 19 | SOURCES = main.cpp \ |
19 | opiemail.cpp \ | 20 | opiemail.cpp \ |
20 | mainwindow.cpp \ | 21 | mainwindow.cpp \ |
21 | accountview.cpp \ | 22 | accountview.cpp \ |
22 | composemail.cpp \ | 23 | composemail.cpp \ |
23 | mailwrapper.cpp \ | 24 | mailwrapper.cpp \ |
24 | imapwrapper.cpp \ | 25 | imapwrapper.cpp \ |
25 | addresspicker.cpp \ | 26 | addresspicker.cpp \ |
26 | editaccounts.cpp \ | 27 | editaccounts.cpp \ |
27 | logindialog.cpp \ | 28 | logindialog.cpp \ |
28 | viewmail.cpp \ | 29 | viewmail.cpp \ |
29 | viewmailbase.cpp \ | 30 | viewmailbase.cpp \ |
30 | settings.cpp \ | 31 | settings.cpp \ |
31 | mailtypes.cpp | 32 | mailtypes.cpp \ |
33 | pop3wrapper.cpp | ||
32 | 34 | ||
33 | INTERFACES = editaccountsui.ui \ | 35 | INTERFACES = editaccountsui.ui \ |
34 | selectmailtypeui.ui \ | 36 | selectmailtypeui.ui \ |
35 | imapconfigui.ui \ | 37 | imapconfigui.ui \ |
36 | pop3configui.ui \ | 38 | pop3configui.ui \ |
37 | nntpconfigui.ui \ | 39 | nntpconfigui.ui \ |
38 | smtpconfigui.ui \ | 40 | smtpconfigui.ui \ |
39 | addresspickerui.ui \ | 41 | addresspickerui.ui \ |
40 | logindialogui.ui \ | 42 | logindialogui.ui \ |
41 | composemailui.ui | 43 | composemailui.ui |
42 | 44 | ||
43 | INCLUDEPATH += $(OPIEDIR)/include | 45 | INCLUDEPATH += $(OPIEDIR)/include |
diff --git a/noncore/net/mail/opie-mail.control b/noncore/net/mail/opie-mail.control index a93067f..afe0947 100644 --- a/noncore/net/mail/opie-mail.control +++ b/noncore/net/mail/opie-mail.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-mail | 1 | Package: opie-mail |
2 | Files: bin/opiemail apps/1Pim/opiemail.desktop pics/mail/*.png | 2 | Files: bin/opiemail apps/1Pim/opiemail.desktop pics/mail/*.png |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Juergen Graf <jgf@openbsd.de> | 5 | Maintainer: Juergen Graf <jgf@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: 0.0.1-$SUB_VERSION | 7 | Version: 0.0.1-$SUB_VERSION |
8 | Depends: task-opie-minimal, libopie1 | 8 | Depends: task-opie-minimal, libopie1 |
9 | Description: Opie's mail and news client (POP3, IMAP and NNTP) | 9 | Description: Opie's mail and news client (POP3, IMAP and NNTP) |
10 | License: LGPL | 10 | License: LGPL |
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp new file mode 100644 index 0000000..08e97f4 --- a/dev/null +++ b/noncore/net/mail/pop3wrapper.cpp | |||
@@ -0,0 +1,74 @@ | |||
1 | |||
2 | #include "pop3wrapper.h" | ||
3 | #include "mailtypes.h" | ||
4 | #include <libetpan/mailpop3.h> | ||
5 | |||
6 | POP3wrapper::POP3wrapper( POP3account *a ) | ||
7 | { | ||
8 | account = a; | ||
9 | } | ||
10 | |||
11 | POP3wrapper::~POP3wrapper() | ||
12 | { | ||
13 | logout(); | ||
14 | } | ||
15 | |||
16 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | ||
17 | { | ||
18 | qDebug( "POP3: %i of %i", current, maximum ); | ||
19 | } | ||
20 | |||
21 | void POP3wrapper::listMessages( QList<RecMail> &target ) | ||
22 | { | ||
23 | login(); | ||
24 | //TODO: list messages | ||
25 | logout(); | ||
26 | } | ||
27 | |||
28 | void POP3wrapper::login() | ||
29 | { | ||
30 | logout(); | ||
31 | const char *server, *user, *pass; | ||
32 | uint16_t port; | ||
33 | int err = MAILPOP3_NO_ERROR; | ||
34 | |||
35 | server = account->getServer().latin1(); | ||
36 | port = account->getPort().toUInt(); | ||
37 | user = account->getUser().latin1(); | ||
38 | pass = account->getPassword().latin1(); | ||
39 | |||
40 | m_pop3 = mailpop3_new( 20, &pop3_progress ); | ||
41 | |||
42 | // connect | ||
43 | err = mailpop3_socket_connect( m_pop3, (char *) server, port ); | ||
44 | if ( err != MAILPOP3_NO_ERROR ) { | ||
45 | qDebug( "pop3: error connecting to %s\n reason: %s", server, | ||
46 | m_pop3->response ); | ||
47 | mailpop3_free( m_pop3 ); | ||
48 | m_pop3 = NULL; | ||
49 | return; | ||
50 | } | ||
51 | qDebug( "POP3: connected!" ); | ||
52 | |||
53 | // login | ||
54 | // TODO: decide if apop or plain login should be used | ||
55 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); | ||
56 | if ( err != MAILPOP3_NO_ERROR ) { | ||
57 | qDebug( "pop3: error logging in: %s", m_pop3->response ); | ||
58 | logout(); | ||
59 | return; | ||
60 | } | ||
61 | |||
62 | qDebug( "POP3: logged in!" ); | ||
63 | } | ||
64 | |||
65 | void POP3wrapper::logout() | ||
66 | { | ||
67 | int err = MAILPOP3_NO_ERROR; | ||
68 | if ( !m_pop3 ) return; | ||
69 | err = mailpop3_quit( m_pop3 ); | ||
70 | mailpop3_free( m_pop3 ); | ||
71 | m_pop3 = NULL; | ||
72 | } | ||
73 | |||
74 | |||
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h new file mode 100644 index 0000000..b791409 --- a/dev/null +++ b/noncore/net/mail/pop3wrapper.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef __POP3WRAPPER | ||
2 | #define __POP3WRAPPER | ||
3 | |||
4 | #include "mailwrapper.h" | ||
5 | |||
6 | class RecMail; | ||
7 | |||
8 | class POP3wrapper : public QObject | ||
9 | { | ||
10 | Q_OBJECT | ||
11 | |||
12 | public: | ||
13 | POP3wrapper( POP3account *a ); | ||
14 | virtual ~POP3wrapper(); | ||
15 | void listMessages( QList<RecMail> &target ); | ||
16 | static void pop3_progress( size_t current, size_t maximum ); | ||
17 | |||
18 | protected: | ||
19 | void login(); | ||
20 | void logout(); | ||
21 | |||
22 | private: | ||
23 | POP3account *account; | ||
24 | mailpop3 *m_pop3; | ||
25 | |||
26 | }; | ||
27 | |||
28 | #endif | ||
diff --git a/noncore/net/mail/settings.cpp b/noncore/net/mail/settings.cpp index 9632301..b580954 100644 --- a/noncore/net/mail/settings.cpp +++ b/noncore/net/mail/settings.cpp | |||
@@ -123,25 +123,24 @@ IMAPaccount::IMAPaccount( QString filename ) | |||
123 | accountName = "New IMAP Account"; | 123 | accountName = "New IMAP Account"; |
124 | ssl = false; | 124 | ssl = false; |
125 | type = "IMAP"; | 125 | type = "IMAP"; |
126 | port = IMAP_PORT; | 126 | port = IMAP_PORT; |
127 | } | 127 | } |
128 | 128 | ||
129 | QString IMAPaccount::getUniqueFileName() | 129 | QString IMAPaccount::getUniqueFileName() |
130 | { | 130 | { |
131 | int num = 0; | 131 | int num = 0; |
132 | QString unique; | 132 | QString unique; |
133 | 133 | ||
134 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 134 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
135 | QStringList::Iterator it; | ||
136 | 135 | ||
137 | QStringList imap = dir.entryList( "imap-*" ); | 136 | QStringList imap = dir.entryList( "imap-*" ); |
138 | do { | 137 | do { |
139 | unique.setNum( num++ ); | 138 | unique.setNum( num++ ); |
140 | } while ( imap.contains( "imap-" + unique ) > 0 ); | 139 | } while ( imap.contains( "imap-" + unique ) > 0 ); |
141 | 140 | ||
142 | return unique; | 141 | return unique; |
143 | } | 142 | } |
144 | 143 | ||
145 | void IMAPaccount::read() | 144 | void IMAPaccount::read() |
146 | { | 145 | { |
147 | Config *conf = new Config( getFileName(), Config::File ); | 146 | Config *conf = new Config( getFileName(), Config::File ); |
@@ -201,25 +200,24 @@ POP3account::POP3account( QString filename ) | |||
201 | accountName = "New POP3 Account"; | 200 | accountName = "New POP3 Account"; |
202 | ssl = false; | 201 | ssl = false; |
203 | type = "POP3"; | 202 | type = "POP3"; |
204 | port = POP3_PORT; | 203 | port = POP3_PORT; |
205 | } | 204 | } |
206 | 205 | ||
207 | QString POP3account::getUniqueFileName() | 206 | QString POP3account::getUniqueFileName() |
208 | { | 207 | { |
209 | int num = 0; | 208 | int num = 0; |
210 | QString unique; | 209 | QString unique; |
211 | 210 | ||
212 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 211 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
213 | QStringList::Iterator it; | ||
214 | 212 | ||
215 | QStringList imap = dir.entryList( "pop3-*" ); | 213 | QStringList imap = dir.entryList( "pop3-*" ); |
216 | do { | 214 | do { |
217 | unique.setNum( num++ ); | 215 | unique.setNum( num++ ); |
218 | } while ( imap.contains( "pop3-" + unique ) > 0 ); | 216 | } while ( imap.contains( "pop3-" + unique ) > 0 ); |
219 | 217 | ||
220 | return unique; | 218 | return unique; |
221 | } | 219 | } |
222 | 220 | ||
223 | void POP3account::read() | 221 | void POP3account::read() |
224 | { | 222 | { |
225 | Config *conf = new Config( getFileName(), Config::File ); | 223 | Config *conf = new Config( getFileName(), Config::File ); |
@@ -279,25 +277,24 @@ SMTPaccount::SMTPaccount( QString filename ) | |||
279 | useBCC = false; | 277 | useBCC = false; |
280 | useReply = false; | 278 | useReply = false; |
281 | type = "SMTP"; | 279 | type = "SMTP"; |
282 | port = SMTP_PORT; | 280 | port = SMTP_PORT; |
283 | } | 281 | } |
284 | 282 | ||
285 | QString SMTPaccount::getUniqueFileName() | 283 | QString SMTPaccount::getUniqueFileName() |
286 | { | 284 | { |
287 | int num = 0; | 285 | int num = 0; |
288 | QString unique; | 286 | QString unique; |
289 | 287 | ||
290 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 288 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
291 | QStringList::Iterator it; | ||
292 | 289 | ||
293 | QStringList imap = dir.entryList( "smtp-*" ); | 290 | QStringList imap = dir.entryList( "smtp-*" ); |
294 | do { | 291 | do { |
295 | unique.setNum( num++ ); | 292 | unique.setNum( num++ ); |
296 | } while ( imap.contains( "smtp-" + unique ) > 0 ); | 293 | } while ( imap.contains( "smtp-" + unique ) > 0 ); |
297 | 294 | ||
298 | return unique; | 295 | return unique; |
299 | } | 296 | } |
300 | 297 | ||
301 | void SMTPaccount::read() | 298 | void SMTPaccount::read() |
302 | { | 299 | { |
303 | Config *conf = new Config( getFileName(), Config::File ); | 300 | Config *conf = new Config( getFileName(), Config::File ); |
@@ -375,25 +372,24 @@ NNTPaccount::NNTPaccount( QString filename ) | |||
375 | ssl = false; | 372 | ssl = false; |
376 | login = false; | 373 | login = false; |
377 | type = "NNTP"; | 374 | type = "NNTP"; |
378 | port = NNTP_PORT; | 375 | port = NNTP_PORT; |
379 | } | 376 | } |
380 | 377 | ||
381 | QString NNTPaccount::getUniqueFileName() | 378 | QString NNTPaccount::getUniqueFileName() |
382 | { | 379 | { |
383 | int num = 0; | 380 | int num = 0; |
384 | QString unique; | 381 | QString unique; |
385 | 382 | ||
386 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 383 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
387 | QStringList::Iterator it; | ||
388 | 384 | ||
389 | QStringList imap = dir.entryList( "nntp-*" ); | 385 | QStringList imap = dir.entryList( "nntp-*" ); |
390 | do { | 386 | do { |
391 | unique.setNum( num++ ); | 387 | unique.setNum( num++ ); |
392 | } while ( imap.contains( "nntp-" + unique ) > 0 ); | 388 | } while ( imap.contains( "nntp-" + unique ) > 0 ); |
393 | 389 | ||
394 | return unique; | 390 | return unique; |
395 | } | 391 | } |
396 | 392 | ||
397 | void NNTPaccount::read() | 393 | void NNTPaccount::read() |
398 | { | 394 | { |
399 | Config *conf = new Config( getFileName(), Config::File ); | 395 | Config *conf = new Config( getFileName(), Config::File ); |