summaryrefslogtreecommitdiff
authorjgf <jgf>2003-12-09 21:36:56 (UTC)
committer jgf <jgf>2003-12-09 21:36:56 (UTC)
commit6b45c1f8e0293914c1328f15a665d2ea0fba7b43 (patch) (unidiff)
treed87ef7d3147a52429849a6921e7a8f31fde89aa8
parent0a1f6405780b18c9f3d953adcfd072de8fd4dc18 (diff)
downloadopie-6b45c1f8e0293914c1328f15a665d2ea0fba7b43.zip
opie-6b45c1f8e0293914c1328f15a665d2ea0fba7b43.tar.gz
opie-6b45c1f8e0293914c1328f15a665d2ea0fba7b43.tar.bz2
POP3 support - first steps
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
@@ -2,2 +2,3 @@
2#include "imapwrapper.h" 2#include "imapwrapper.h"
3#include "pop3wrapper.h"
3#include "mailtypes.h" 4#include "mailtypes.h"
@@ -5,2 +6,38 @@
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 )
@@ -71,2 +108,6 @@ RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
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 )
@@ -88,2 +129,6 @@ void AccountView::populate( QList<Account> list )
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 }
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
@@ -10,2 +10,3 @@
10class IMAPwrapper; 10class IMAPwrapper;
11class POP3wrapper;
11class RecMail; 12class RecMail;
@@ -23,2 +24,17 @@ public:
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
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
@@ -15,2 +15,3 @@
15#define PIC_IMAPFOLDER "opiemail/imapfolder" 15#define PIC_IMAPFOLDER "opiemail/imapfolder"
16#define PIC_POP3FOLDER "opiemail/pop3folder"
16 17
@@ -25,2 +26,3 @@
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
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
@@ -134,3 +134,2 @@ QString IMAPaccount::getUniqueFileName()
134 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 134 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
135 QStringList::Iterator it;
136 135
@@ -212,3 +211,2 @@ QString POP3account::getUniqueFileName()
212 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 211 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
213 QStringList::Iterator it;
214 212
@@ -290,3 +288,2 @@ QString SMTPaccount::getUniqueFileName()
290 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 288 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
291 QStringList::Iterator it;
292 289
@@ -386,3 +383,2 @@ QString NNTPaccount::getUniqueFileName()
386 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 383 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
387 QStringList::Iterator it;
388 384
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
@@ -10,8 +10,9 @@ HEADERS = defines.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
@@ -27,6 +28,7 @@ SOURCES = main.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
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
@@ -4,3 +4,3 @@ Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Juergen Graf <jgf@openbsd.de> 5Maintainer: Juergen Graf <jgf@handhelds.org>
6Architecture: arm 6Architecture: arm
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
@@ -134,3 +134,2 @@ QString IMAPaccount::getUniqueFileName()
134 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 134 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
135 QStringList::Iterator it;
136 135
@@ -212,3 +211,2 @@ QString POP3account::getUniqueFileName()
212 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 211 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
213 QStringList::Iterator it;
214 212
@@ -290,3 +288,2 @@ QString SMTPaccount::getUniqueFileName()
290 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 288 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
291 QStringList::Iterator it;
292 289
@@ -386,3 +383,2 @@ QString NNTPaccount::getUniqueFileName()
386 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 383 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
387 QStringList::Iterator it;
388 384