summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp45
-rw-r--r--noncore/net/mail/accountview.h16
-rw-r--r--noncore/net/mail/defines.h2
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp74
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h28
-rw-r--r--noncore/net/mail/libmailwrapper/settings.cpp4
-rw-r--r--noncore/net/mail/mail.pro18
-rw-r--r--noncore/net/mail/opie-mail.control2
-rw-r--r--noncore/net/mail/pop3wrapper.cpp74
-rw-r--r--noncore/net/mail/pop3wrapper.h28
-rw-r--r--noncore/net/mail/settings.cpp4
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,8 +1,45 @@
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
12POP3viewItem::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
21POP3viewItem::~POP3viewItem()
22{
23 delete wrapper;
24}
25
26void POP3viewItem::refresh( QList<RecMail> &target )
27{
28 qDebug( "POP3: refresh" );
29 wrapper->listMessages( target );
30}
31
32
33RecBody POP3viewItem::fetchBody( const RecMail & )
34{
35 qDebug( "POP3 fetchBody: IMPLEMENT ME!!" );
36 return RecBody();
37}
38
39/**
40 * IMAP Account stuff
41 */
42
6IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) 43IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent )
7 : AccountViewItem( parent ) 44 : AccountViewItem( parent )
8{ 45{
@@ -69,6 +106,10 @@ RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
69 return imap->getWrapper()->fetchBody(aMail); 106 return imap->getWrapper()->fetchBody(aMail);
70} 107}
71 108
109/**
110 * Generic stuff
111 */
112
72AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 113AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
73 : QListView( parent, name, flags ) 114 : QListView( parent, name, flags )
74{ 115{
@@ -86,6 +127,10 @@ void AccountView::populate( QList<Account> list )
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}
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
@@ -8,6 +8,7 @@
8#include "mailwrapper.h" 8#include "mailwrapper.h"
9 9
10class IMAPwrapper; 10class IMAPwrapper;
11class POP3wrapper;
11class RecMail; 12class RecMail;
12class RecBody; 13class RecBody;
13 14
@@ -21,6 +22,21 @@ public:
21 virtual RecBody fetchBody(const RecMail&)=0; 22 virtual RecBody fetchBody(const RecMail&)=0;
22}; 23};
23 24
25class POP3viewItem : public AccountViewItem
26{
27
28public:
29 POP3viewItem( POP3account *a, QListView *parent );
30 ~POP3viewItem();
31 virtual void refresh( QList<RecMail> &target );
32 virtual RecBody fetchBody(const RecMail & );
33
34private:
35 POP3account *account;
36 POP3wrapper *wrapper;
37
38};
39
24class IMAPviewItem : public AccountViewItem 40class IMAPviewItem : public AccountViewItem
25{ 41{
26 42
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
@@ -13,6 +13,7 @@
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 ) )
@@ -23,6 +24,7 @@
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"
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
6POP3wrapper::POP3wrapper( POP3account *a )
7{
8 account = a;
9}
10
11POP3wrapper::~POP3wrapper()
12{
13 logout();
14}
15
16void POP3wrapper::pop3_progress( size_t current, size_t maximum )
17{
18 qDebug( "POP3: %i of %i", current, maximum );
19}
20
21void POP3wrapper::listMessages( QList<RecMail> &target )
22{
23 login();
24 //TODO: list messages
25 logout();
26}
27
28void 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
65void 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
6class RecMail;
7
8class POP3wrapper : public QObject
9{
10 Q_OBJECT
11
12public:
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
18protected:
19 void login();
20 void logout();
21
22private:
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
@@ -132,7 +132,6 @@ QString IMAPaccount::getUniqueFileName()
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 {
@@ -210,7 +209,6 @@ QString POP3account::getUniqueFileName()
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 {
@@ -288,7 +286,6 @@ QString SMTPaccount::getUniqueFileName()
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 {
@@ -384,7 +381,6 @@ QString NNTPaccount::getUniqueFileName()
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 {
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
@@ -8,12 +8,13 @@ HEADERS = defines.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 \
@@ -25,10 +26,11 @@ SOURCES = main.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 \
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
@@ -2,7 +2,7 @@ Package: opie-mail
2Files: bin/opiemail apps/1Pim/opiemail.desktop pics/mail/*.png 2Files: bin/opiemail apps/1Pim/opiemail.desktop pics/mail/*.png
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Juergen Graf <jgf@openbsd.de> 5Maintainer: Juergen Graf <jgf@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 0.0.1-$SUB_VERSION 7Version: 0.0.1-$SUB_VERSION
8Depends: task-opie-minimal, libopie1 8Depends: task-opie-minimal, libopie1
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
6POP3wrapper::POP3wrapper( POP3account *a )
7{
8 account = a;
9}
10
11POP3wrapper::~POP3wrapper()
12{
13 logout();
14}
15
16void POP3wrapper::pop3_progress( size_t current, size_t maximum )
17{
18 qDebug( "POP3: %i of %i", current, maximum );
19}
20
21void POP3wrapper::listMessages( QList<RecMail> &target )
22{
23 login();
24 //TODO: list messages
25 logout();
26}
27
28void 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
65void 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
6class RecMail;
7
8class POP3wrapper : public QObject
9{
10 Q_OBJECT
11
12public:
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
18protected:
19 void login();
20 void logout();
21
22private:
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
@@ -132,7 +132,6 @@ QString IMAPaccount::getUniqueFileName()
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 {
@@ -210,7 +209,6 @@ QString POP3account::getUniqueFileName()
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 {
@@ -288,7 +286,6 @@ QString SMTPaccount::getUniqueFileName()
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 {
@@ -384,7 +381,6 @@ QString NNTPaccount::getUniqueFileName()
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 {