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
@@ -1,115 +1,160 @@
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{
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
16IMAPviewItem::~IMAPviewItem() 53IMAPviewItem::~IMAPviewItem()
17{ 54{
18 delete wrapper; 55 delete wrapper;
19} 56}
20 57
21IMAPwrapper *IMAPviewItem::getWrapper() 58IMAPwrapper *IMAPviewItem::getWrapper()
22{ 59{
23 return wrapper; 60 return wrapper;
24} 61}
25 62
26void IMAPviewItem::refresh(QList<RecMail>&) 63void IMAPviewItem::refresh(QList<RecMail>&)
27{ 64{
28 QList<IMAPFolder> *folders = wrapper->listFolders(); 65 QList<IMAPFolder> *folders = wrapper->listFolders();
29 66
30 QListViewItem *child = firstChild(); 67 QListViewItem *child = firstChild();
31 while ( child ) { 68 while ( child ) {
32 QListViewItem *tmp = child; 69 QListViewItem *tmp = child;
33 child = child->nextSibling(); 70 child = child->nextSibling();
34 delete tmp; 71 delete tmp;
35 } 72 }
36 73
37 IMAPFolder *it; 74 IMAPFolder *it;
38 for ( it = folders->first(); it; it = folders->next() ) { 75 for ( it = folders->first(); it; it = folders->next() ) {
39 (void) new IMAPfolderItem( it, this ); 76 (void) new IMAPfolderItem( it, this );
40 } 77 }
41} 78}
42 79
43RecBody IMAPviewItem::fetchBody(const RecMail&) 80RecBody IMAPviewItem::fetchBody(const RecMail&)
44{ 81{
45 return RecBody(); 82 return RecBody();
46} 83}
47 84
48IMAPfolderItem::~IMAPfolderItem() 85IMAPfolderItem::~IMAPfolderItem()
49{ 86{
50 delete folder; 87 delete folder;
51} 88}
52 89
53IMAPfolderItem::IMAPfolderItem( IMAPFolder *folderInit, IMAPviewItem *parent ) 90IMAPfolderItem::IMAPfolderItem( IMAPFolder *folderInit, IMAPviewItem *parent )
54 : AccountViewItem( parent ) 91 : AccountViewItem( parent )
55{ 92{
56 folder = folderInit; 93 folder = folderInit;
57 imap = parent; 94 imap = parent;
58 setPixmap( 0, PIXMAP_IMAPFOLDER ); 95 setPixmap( 0, PIXMAP_IMAPFOLDER );
59 setText( 0, folder->getDisplayName() ); 96 setText( 0, folder->getDisplayName() );
60} 97}
61 98
62void IMAPfolderItem::refresh(QList<RecMail>&target) 99void 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
67RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) 104RecBody 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
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{
75 connect( this, SIGNAL( clicked( QListViewItem * ) ), 116 connect( this, SIGNAL( clicked( QListViewItem * ) ),
76 SLOT( refresh( QListViewItem * ) ) ); 117 SLOT( refresh( QListViewItem * ) ) );
77} 118}
78 119
79void AccountView::populate( QList<Account> list ) 120void 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
93void AccountView::refresh(QListViewItem *item) { 138void 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);
101 } 146 }
102} 147}
103 148
104void AccountView::refreshAll() 149void AccountView::refreshAll()
105{ 150{
106 151
107} 152}
108 153
109RecBody AccountView::fetchBody(const RecMail&aMail) 154RecBody AccountView::fetchBody(const RecMail&aMail)
110{ 155{
111 QListViewItem*item = selectedItem (); 156 QListViewItem*item = selectedItem ();
112 if (!item) return RecBody(); 157 if (!item) return RecBody();
113 AccountViewItem *view = static_cast<AccountViewItem *>(item); 158 AccountViewItem *view = static_cast<AccountViewItem *>(item);
114 return view->fetchBody(aMail); 159 return view->fetchBody(aMail);
115} 160}
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,72 +1,88 @@
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
10class IMAPwrapper; 10class IMAPwrapper;
11class POP3wrapper;
11class RecMail; 12class RecMail;
12class RecBody; 13class RecBody;
13 14
14class AccountViewItem : public QListViewItem 15class AccountViewItem : public QListViewItem
15{ 16{
16 17
17public: 18public:
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
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
27public: 43public:
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
34private: 50private:
35 IMAPaccount *account; 51 IMAPaccount *account;
36 IMAPwrapper *wrapper; 52 IMAPwrapper *wrapper;
37 53
38}; 54};
39 55
40class IMAPfolderItem : public AccountViewItem 56class IMAPfolderItem : public AccountViewItem
41{ 57{
42 58
43public: 59public:
44 IMAPfolderItem( IMAPFolder *folder, IMAPviewItem *parent ); 60 IMAPfolderItem( IMAPFolder *folder, IMAPviewItem *parent );
45 ~IMAPfolderItem(); 61 ~IMAPfolderItem();
46 virtual void refresh(QList<RecMail>&); 62 virtual void refresh(QList<RecMail>&);
47 virtual RecBody fetchBody(const RecMail&); 63 virtual RecBody fetchBody(const RecMail&);
48 64
49private: 65private:
50 IMAPFolder *folder; 66 IMAPFolder *folder;
51 IMAPviewItem *imap; 67 IMAPviewItem *imap;
52 68
53}; 69};
54 70
55class AccountView : public QListView 71class AccountView : public QListView
56{ 72{
57 Q_OBJECT 73 Q_OBJECT
58 74
59public: 75public:
60 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 76 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
61 void populate( QList<Account> list ); 77 void populate( QList<Account> list );
62 RecBody fetchBody(const RecMail&aMail); 78 RecBody fetchBody(const RecMail&aMail);
63 79
64public slots: 80public slots:
65 void refreshAll(); 81 void refreshAll();
66 void refresh(QListViewItem *item); 82 void refresh(QListViewItem *item);
67 83
68signals: 84signals:
69 void refreshMailview(QList<RecMail>*); 85 void refreshMailview(QList<RecMail>*);
70}; 86};
71 87
72#endif 88#endif
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
@@ -1,36 +1,38 @@
1#ifndef DEFINE_CONSTANTS_H 1#ifndef DEFINE_CONSTANTS_H
2#define DEFINE_CONSTANTS_H 2#define DEFINE_CONSTANTS_H
3 3
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
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
@@ -39,394 +39,390 @@ void Settings::delAccount( Account *account )
39void Settings::updateAccounts() 39void Settings::updateAccounts()
40{ 40{
41 accounts.clear(); 41 accounts.clear();
42 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 42 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
43 QStringList::Iterator it; 43 QStringList::Iterator it;
44 44
45 QStringList imap = dir.entryList( "imap-*" ); 45 QStringList imap = dir.entryList( "imap-*" );
46 for ( it = imap.begin(); it != imap.end(); it++ ) { 46 for ( it = imap.begin(); it != imap.end(); it++ ) {
47 qDebug( "Added IMAP account" ); 47 qDebug( "Added IMAP account" );
48 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); 48 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") );
49 accounts.append( account ); 49 accounts.append( account );
50 } 50 }
51 51
52 QStringList pop3 = dir.entryList( "pop3-*" ); 52 QStringList pop3 = dir.entryList( "pop3-*" );
53 for ( it = pop3.begin(); it != pop3.end(); it++ ) { 53 for ( it = pop3.begin(); it != pop3.end(); it++ ) {
54 qDebug( "Added POP account" ); 54 qDebug( "Added POP account" );
55 POP3account *account = new POP3account( (*it).replace(0, 5, "") ); 55 POP3account *account = new POP3account( (*it).replace(0, 5, "") );
56 accounts.append( account ); 56 accounts.append( account );
57 } 57 }
58 58
59 QStringList smtp = dir.entryList( "smtp-*" ); 59 QStringList smtp = dir.entryList( "smtp-*" );
60 for ( it = smtp.begin(); it != smtp.end(); it++ ) { 60 for ( it = smtp.begin(); it != smtp.end(); it++ ) {
61 qDebug( "Added SMTP account" ); 61 qDebug( "Added SMTP account" );
62 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); 62 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") );
63 accounts.append( account ); 63 accounts.append( account );
64 } 64 }
65 65
66 QStringList nntp = dir.entryList( "nntp-*" ); 66 QStringList nntp = dir.entryList( "nntp-*" );
67 for ( it = nntp.begin(); it != nntp.end(); it++ ) { 67 for ( it = nntp.begin(); it != nntp.end(); it++ ) {
68 qDebug( "Added NNTP account" ); 68 qDebug( "Added NNTP account" );
69 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); 69 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") );
70 accounts.append( account ); 70 accounts.append( account );
71 } 71 }
72 72
73 readAccounts(); 73 readAccounts();
74} 74}
75 75
76void Settings::saveAccounts() 76void Settings::saveAccounts()
77{ 77{
78 checkDirectory(); 78 checkDirectory();
79 Account *it; 79 Account *it;
80 80
81 for ( it = accounts.first(); it; it = accounts.next() ) { 81 for ( it = accounts.first(); it; it = accounts.next() ) {
82 it->save(); 82 it->save();
83 } 83 }
84} 84}
85 85
86void Settings::readAccounts() 86void Settings::readAccounts()
87{ 87{
88 checkDirectory(); 88 checkDirectory();
89 Account *it; 89 Account *it;
90 90
91 for ( it = accounts.first(); it; it = accounts.next() ) { 91 for ( it = accounts.first(); it; it = accounts.next() ) {
92 it->read(); 92 it->read();
93 } 93 }
94} 94}
95 95
96Account::Account() 96Account::Account()
97{ 97{
98 accountName = "changeMe"; 98 accountName = "changeMe";
99 type = "changeMe"; 99 type = "changeMe";
100 ssl = false; 100 ssl = false;
101} 101}
102 102
103void Account::remove() 103void Account::remove()
104{ 104{
105 QFile file( getFileName() ); 105 QFile file( getFileName() );
106 file.remove(); 106 file.remove();
107} 107}
108 108
109IMAPaccount::IMAPaccount() 109IMAPaccount::IMAPaccount()
110 : Account() 110 : Account()
111{ 111{
112 file = IMAPaccount::getUniqueFileName(); 112 file = IMAPaccount::getUniqueFileName();
113 accountName = "New IMAP Account"; 113 accountName = "New IMAP Account";
114 ssl = false; 114 ssl = false;
115 type = "IMAP"; 115 type = "IMAP";
116 port = IMAP_PORT; 116 port = IMAP_PORT;
117} 117}
118 118
119IMAPaccount::IMAPaccount( QString filename ) 119IMAPaccount::IMAPaccount( QString filename )
120 : Account() 120 : Account()
121{ 121{
122 file = filename; 122 file = 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
129QString IMAPaccount::getUniqueFileName() 129QString 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
145void IMAPaccount::read() 144void IMAPaccount::read()
146{ 145{
147 Config *conf = new Config( getFileName(), Config::File ); 146 Config *conf = new Config( getFileName(), Config::File );
148 conf->setGroup( "IMAP Account" ); 147 conf->setGroup( "IMAP Account" );
149 accountName = conf->readEntry( "Account","" ); 148 accountName = conf->readEntry( "Account","" );
150 if (accountName.isNull()) accountName = ""; 149 if (accountName.isNull()) accountName = "";
151 server = conf->readEntry( "Server","" ); 150 server = conf->readEntry( "Server","" );
152 if (server.isNull()) server=""; 151 if (server.isNull()) server="";
153 port = conf->readEntry( "Port","" ); 152 port = conf->readEntry( "Port","" );
154 if (port.isNull()) port="143"; 153 if (port.isNull()) port="143";
155 ssl = conf->readBoolEntry( "SSL",false ); 154 ssl = conf->readBoolEntry( "SSL",false );
156 user = conf->readEntry( "User","" ); 155 user = conf->readEntry( "User","" );
157 if (user.isNull()) user = ""; 156 if (user.isNull()) user = "";
158 password = conf->readEntryCrypt( "Password","" ); 157 password = conf->readEntryCrypt( "Password","" );
159 if (password.isNull()) password = ""; 158 if (password.isNull()) password = "";
160 prefix = conf->readEntry("MailPrefix",""); 159 prefix = conf->readEntry("MailPrefix","");
161 if (prefix.isNull()) prefix = ""; 160 if (prefix.isNull()) prefix = "";
162} 161}
163 162
164void IMAPaccount::save() 163void IMAPaccount::save()
165{ 164{
166 qDebug( "saving " + getFileName() ); 165 qDebug( "saving " + getFileName() );
167 Settings::checkDirectory(); 166 Settings::checkDirectory();
168 167
169 Config *conf = new Config( getFileName(), Config::File ); 168 Config *conf = new Config( getFileName(), Config::File );
170 conf->setGroup( "IMAP Account" ); 169 conf->setGroup( "IMAP Account" );
171 conf->writeEntry( "Account", accountName ); 170 conf->writeEntry( "Account", accountName );
172 conf->writeEntry( "Server", server ); 171 conf->writeEntry( "Server", server );
173 conf->writeEntry( "Port", port ); 172 conf->writeEntry( "Port", port );
174 conf->writeEntry( "SSL", ssl ); 173 conf->writeEntry( "SSL", ssl );
175 conf->writeEntry( "User", user ); 174 conf->writeEntry( "User", user );
176 conf->writeEntryCrypt( "Password", password ); 175 conf->writeEntryCrypt( "Password", password );
177 conf->writeEntry( "MailPrefix",prefix); 176 conf->writeEntry( "MailPrefix",prefix);
178 conf->write(); 177 conf->write();
179} 178}
180 179
181 180
182QString IMAPaccount::getFileName() 181QString IMAPaccount::getFileName()
183{ 182{
184 return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; 183 return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file;
185} 184}
186 185
187POP3account::POP3account() 186POP3account::POP3account()
188 : Account() 187 : Account()
189{ 188{
190 file = POP3account::getUniqueFileName(); 189 file = POP3account::getUniqueFileName();
191 accountName = "New POP3 Account"; 190 accountName = "New POP3 Account";
192 ssl = false; 191 ssl = false;
193 type = "POP3"; 192 type = "POP3";
194 port = POP3_PORT; 193 port = POP3_PORT;
195} 194}
196 195
197POP3account::POP3account( QString filename ) 196POP3account::POP3account( QString filename )
198 : Account() 197 : Account()
199{ 198{
200 file = filename; 199 file = 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
207QString POP3account::getUniqueFileName() 206QString 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
223void POP3account::read() 221void POP3account::read()
224{ 222{
225 Config *conf = new Config( getFileName(), Config::File ); 223 Config *conf = new Config( getFileName(), Config::File );
226 conf->setGroup( "POP3 Account" ); 224 conf->setGroup( "POP3 Account" );
227 accountName = conf->readEntry( "Account" ); 225 accountName = conf->readEntry( "Account" );
228 server = conf->readEntry( "Server" ); 226 server = conf->readEntry( "Server" );
229 port = conf->readEntry( "Port" ); 227 port = conf->readEntry( "Port" );
230 ssl = conf->readBoolEntry( "SSL" ); 228 ssl = conf->readBoolEntry( "SSL" );
231 user = conf->readEntry( "User" ); 229 user = conf->readEntry( "User" );
232 password = conf->readEntryCrypt( "Password" ); 230 password = conf->readEntryCrypt( "Password" );
233} 231}
234 232
235void POP3account::save() 233void POP3account::save()
236{ 234{
237 qDebug( "saving " + getFileName() ); 235 qDebug( "saving " + getFileName() );
238 Settings::checkDirectory(); 236 Settings::checkDirectory();
239 237
240 Config *conf = new Config( getFileName(), Config::File ); 238 Config *conf = new Config( getFileName(), Config::File );
241 conf->setGroup( "POP3 Account" ); 239 conf->setGroup( "POP3 Account" );
242 conf->writeEntry( "Account", accountName ); 240 conf->writeEntry( "Account", accountName );
243 conf->writeEntry( "Server", server ); 241 conf->writeEntry( "Server", server );
244 conf->writeEntry( "Port", port ); 242 conf->writeEntry( "Port", port );
245 conf->writeEntry( "SSL", ssl ); 243 conf->writeEntry( "SSL", ssl );
246 conf->writeEntry( "User", user ); 244 conf->writeEntry( "User", user );
247 conf->writeEntryCrypt( "Password", password ); 245 conf->writeEntryCrypt( "Password", password );
248 conf->write(); 246 conf->write();
249} 247}
250 248
251 249
252QString POP3account::getFileName() 250QString POP3account::getFileName()
253{ 251{
254 return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; 252 return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file;
255} 253}
256 254
257SMTPaccount::SMTPaccount() 255SMTPaccount::SMTPaccount()
258 : Account() 256 : Account()
259{ 257{
260 file = SMTPaccount::getUniqueFileName(); 258 file = SMTPaccount::getUniqueFileName();
261 accountName = "New SMTP Account"; 259 accountName = "New SMTP Account";
262 ssl = false; 260 ssl = false;
263 login = false; 261 login = false;
264 useCC = false; 262 useCC = false;
265 useBCC = false; 263 useBCC = false;
266 useReply = false; 264 useReply = false;
267 type = "SMTP"; 265 type = "SMTP";
268 port = SMTP_PORT; 266 port = SMTP_PORT;
269} 267}
270 268
271SMTPaccount::SMTPaccount( QString filename ) 269SMTPaccount::SMTPaccount( QString filename )
272 : Account() 270 : Account()
273{ 271{
274 file = filename; 272 file = filename;
275 accountName = "New SMTP Account"; 273 accountName = "New SMTP Account";
276 ssl = false; 274 ssl = false;
277 login = false; 275 login = false;
278 useCC = false; 276 useCC = false;
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
285QString SMTPaccount::getUniqueFileName() 283QString 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
301void SMTPaccount::read() 298void SMTPaccount::read()
302{ 299{
303 Config *conf = new Config( getFileName(), Config::File ); 300 Config *conf = new Config( getFileName(), Config::File );
304 conf->setGroup( "SMTP Account" ); 301 conf->setGroup( "SMTP Account" );
305 accountName = conf->readEntry( "Account" ); 302 accountName = conf->readEntry( "Account" );
306 server = conf->readEntry( "Server" ); 303 server = conf->readEntry( "Server" );
307 port = conf->readEntry( "Port" ); 304 port = conf->readEntry( "Port" );
308 ssl = conf->readBoolEntry( "SSL" ); 305 ssl = conf->readBoolEntry( "SSL" );
309 login = conf->readBoolEntry( "Login" ); 306 login = conf->readBoolEntry( "Login" );
310 user = conf->readEntry( "User" ); 307 user = conf->readEntry( "User" );
311 password = conf->readEntryCrypt( "Password" ); 308 password = conf->readEntryCrypt( "Password" );
312 useCC = conf->readBoolEntry( "useCC" ); 309 useCC = conf->readBoolEntry( "useCC" );
313 useBCC = conf->readBoolEntry( "useBCC" ); 310 useBCC = conf->readBoolEntry( "useBCC" );
314 useReply = conf->readBoolEntry( "useReply" ); 311 useReply = conf->readBoolEntry( "useReply" );
315 name = conf->readEntry( "Name" ); 312 name = conf->readEntry( "Name" );
316 mail = conf->readEntry( "Mail" ); 313 mail = conf->readEntry( "Mail" );
317 org = conf->readEntry( "Org" ); 314 org = conf->readEntry( "Org" );
318 cc = conf->readEntry( "CC" ); 315 cc = conf->readEntry( "CC" );
319 bcc = conf->readEntry( "BCC" ); 316 bcc = conf->readEntry( "BCC" );
320 reply = conf->readEntry( "Reply" ); 317 reply = conf->readEntry( "Reply" );
321 signature = conf->readEntry( "Signature" ); 318 signature = conf->readEntry( "Signature" );
322 signature = signature.replace( QRegExp( "<br>" ), "\n" ); 319 signature = signature.replace( QRegExp( "<br>" ), "\n" );
323} 320}
324 321
325void SMTPaccount::save() 322void SMTPaccount::save()
326{ 323{
327 qDebug( "saving " + getFileName() ); 324 qDebug( "saving " + getFileName() );
328 Settings::checkDirectory(); 325 Settings::checkDirectory();
329 326
330 Config *conf = new Config( getFileName(), Config::File ); 327 Config *conf = new Config( getFileName(), Config::File );
331 conf->setGroup( "SMTP Account" ); 328 conf->setGroup( "SMTP Account" );
332 conf->writeEntry( "Account", accountName ); 329 conf->writeEntry( "Account", accountName );
333 conf->writeEntry( "Server", server ); 330 conf->writeEntry( "Server", server );
334 conf->writeEntry( "Port", port ); 331 conf->writeEntry( "Port", port );
335 conf->writeEntry( "SSL", ssl ); 332 conf->writeEntry( "SSL", ssl );
336 conf->writeEntry( "Login", login ); 333 conf->writeEntry( "Login", login );
337 conf->writeEntry( "User", user ); 334 conf->writeEntry( "User", user );
338 conf->writeEntryCrypt( "Password", password ); 335 conf->writeEntryCrypt( "Password", password );
339 conf->writeEntry( "useCC", useCC ); 336 conf->writeEntry( "useCC", useCC );
340 conf->writeEntry( "useBCC", useBCC ); 337 conf->writeEntry( "useBCC", useBCC );
341 conf->writeEntry( "useReply", useReply ); 338 conf->writeEntry( "useReply", useReply );
342 conf->writeEntry( "Name", name ); 339 conf->writeEntry( "Name", name );
343 conf->writeEntry( "Mail", mail ); 340 conf->writeEntry( "Mail", mail );
344 conf->writeEntry( "Org", org ); 341 conf->writeEntry( "Org", org );
345 conf->writeEntry( "CC", cc ); 342 conf->writeEntry( "CC", cc );
346 conf->writeEntry( "BCC", bcc ); 343 conf->writeEntry( "BCC", bcc );
347 conf->writeEntry( "Reply", reply ); 344 conf->writeEntry( "Reply", reply );
348 conf->writeEntry( "Signature", 345 conf->writeEntry( "Signature",
349 signature.replace( QRegExp( "\\n" ), "<br>" ) ); 346 signature.replace( QRegExp( "\\n" ), "<br>" ) );
350 conf->write(); 347 conf->write();
351} 348}
352 349
353 350
354QString SMTPaccount::getFileName() 351QString SMTPaccount::getFileName()
355{ 352{
356 return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; 353 return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file;
357} 354}
358 355
359NNTPaccount::NNTPaccount() 356NNTPaccount::NNTPaccount()
360 : Account() 357 : Account()
361{ 358{
362 file = NNTPaccount::getUniqueFileName(); 359 file = NNTPaccount::getUniqueFileName();
363 accountName = "New NNTP Account"; 360 accountName = "New NNTP Account";
364 ssl = false; 361 ssl = false;
365 login = false; 362 login = false;
366 type = "NNTP"; 363 type = "NNTP";
367 port = NNTP_PORT; 364 port = NNTP_PORT;
368} 365}
369 366
370NNTPaccount::NNTPaccount( QString filename ) 367NNTPaccount::NNTPaccount( QString filename )
371 : Account() 368 : Account()
372{ 369{
373 file = filename; 370 file = filename;
374 accountName = "New NNTP Account"; 371 accountName = "New NNTP Account";
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
381QString NNTPaccount::getUniqueFileName() 378QString 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
397void NNTPaccount::read() 393void NNTPaccount::read()
398{ 394{
399 Config *conf = new Config( getFileName(), Config::File ); 395 Config *conf = new Config( getFileName(), Config::File );
400 conf->setGroup( "NNTP Account" ); 396 conf->setGroup( "NNTP Account" );
401 accountName = conf->readEntry( "Account" ); 397 accountName = conf->readEntry( "Account" );
402 server = conf->readEntry( "Server" ); 398 server = conf->readEntry( "Server" );
403 port = conf->readEntry( "Port" ); 399 port = conf->readEntry( "Port" );
404 ssl = conf->readBoolEntry( "SSL" ); 400 ssl = conf->readBoolEntry( "SSL" );
405 login = conf->readBoolEntry( "Login" ); 401 login = conf->readBoolEntry( "Login" );
406 user = conf->readEntry( "User" ); 402 user = conf->readEntry( "User" );
407 password = conf->readEntryCrypt( "Password" ); 403 password = conf->readEntryCrypt( "Password" );
408} 404}
409 405
410void NNTPaccount::save() 406void NNTPaccount::save()
411{ 407{
412 qDebug( "saving " + getFileName() ); 408 qDebug( "saving " + getFileName() );
413 Settings::checkDirectory(); 409 Settings::checkDirectory();
414 410
415 Config *conf = new Config( getFileName(), Config::File ); 411 Config *conf = new Config( getFileName(), Config::File );
416 conf->setGroup( "NNTP Account" ); 412 conf->setGroup( "NNTP Account" );
417 conf->writeEntry( "Account", accountName ); 413 conf->writeEntry( "Account", accountName );
418 conf->writeEntry( "Server", server ); 414 conf->writeEntry( "Server", server );
419 conf->writeEntry( "Port", port ); 415 conf->writeEntry( "Port", port );
420 conf->writeEntry( "SSL", ssl ); 416 conf->writeEntry( "SSL", ssl );
421 conf->writeEntry( "Login", login ); 417 conf->writeEntry( "Login", login );
422 conf->writeEntry( "User", user ); 418 conf->writeEntry( "User", user );
423 conf->writeEntryCrypt( "Password", password ); 419 conf->writeEntryCrypt( "Password", password );
424 conf->write(); 420 conf->write();
425} 421}
426 422
427 423
428QString NNTPaccount::getFileName() 424QString NNTPaccount::getFileName()
429{ 425{
430 return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; 426 return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file;
431} 427}
432 428
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,47 +1,49 @@
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
43INCLUDEPATH += $(OPIEDIR)/include 45INCLUDEPATH += $(OPIEDIR)/include
44 LIBS += -lqpe -lopie -letpan -lssl -lcrypto -ldb 46 LIBS += -lqpe -lopie -letpan -lssl -lcrypto -ldb
45TARGET = opiemail 47TARGET = opiemail
46 48
47include ( $(OPIEDIR)/include.pro ) 49include ( $(OPIEDIR)/include.pro )
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 @@
1Package: opie-mail 1Package: 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
9Description: Opie's mail and news client (POP3, IMAP and NNTP) 9Description: Opie's mail and news client (POP3, IMAP and NNTP)
10License: LGPL 10License: 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
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
@@ -39,394 +39,390 @@ void Settings::delAccount( Account *account )
39void Settings::updateAccounts() 39void Settings::updateAccounts()
40{ 40{
41 accounts.clear(); 41 accounts.clear();
42 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 42 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
43 QStringList::Iterator it; 43 QStringList::Iterator it;
44 44
45 QStringList imap = dir.entryList( "imap-*" ); 45 QStringList imap = dir.entryList( "imap-*" );
46 for ( it = imap.begin(); it != imap.end(); it++ ) { 46 for ( it = imap.begin(); it != imap.end(); it++ ) {
47 qDebug( "Added IMAP account" ); 47 qDebug( "Added IMAP account" );
48 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); 48 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") );
49 accounts.append( account ); 49 accounts.append( account );
50 } 50 }
51 51
52 QStringList pop3 = dir.entryList( "pop3-*" ); 52 QStringList pop3 = dir.entryList( "pop3-*" );
53 for ( it = pop3.begin(); it != pop3.end(); it++ ) { 53 for ( it = pop3.begin(); it != pop3.end(); it++ ) {
54 qDebug( "Added POP account" ); 54 qDebug( "Added POP account" );
55 POP3account *account = new POP3account( (*it).replace(0, 5, "") ); 55 POP3account *account = new POP3account( (*it).replace(0, 5, "") );
56 accounts.append( account ); 56 accounts.append( account );
57 } 57 }
58 58
59 QStringList smtp = dir.entryList( "smtp-*" ); 59 QStringList smtp = dir.entryList( "smtp-*" );
60 for ( it = smtp.begin(); it != smtp.end(); it++ ) { 60 for ( it = smtp.begin(); it != smtp.end(); it++ ) {
61 qDebug( "Added SMTP account" ); 61 qDebug( "Added SMTP account" );
62 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); 62 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") );
63 accounts.append( account ); 63 accounts.append( account );
64 } 64 }
65 65
66 QStringList nntp = dir.entryList( "nntp-*" ); 66 QStringList nntp = dir.entryList( "nntp-*" );
67 for ( it = nntp.begin(); it != nntp.end(); it++ ) { 67 for ( it = nntp.begin(); it != nntp.end(); it++ ) {
68 qDebug( "Added NNTP account" ); 68 qDebug( "Added NNTP account" );
69 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); 69 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") );
70 accounts.append( account ); 70 accounts.append( account );
71 } 71 }
72 72
73 readAccounts(); 73 readAccounts();
74} 74}
75 75
76void Settings::saveAccounts() 76void Settings::saveAccounts()
77{ 77{
78 checkDirectory(); 78 checkDirectory();
79 Account *it; 79 Account *it;
80 80
81 for ( it = accounts.first(); it; it = accounts.next() ) { 81 for ( it = accounts.first(); it; it = accounts.next() ) {
82 it->save(); 82 it->save();
83 } 83 }
84} 84}
85 85
86void Settings::readAccounts() 86void Settings::readAccounts()
87{ 87{
88 checkDirectory(); 88 checkDirectory();
89 Account *it; 89 Account *it;
90 90
91 for ( it = accounts.first(); it; it = accounts.next() ) { 91 for ( it = accounts.first(); it; it = accounts.next() ) {
92 it->read(); 92 it->read();
93 } 93 }
94} 94}
95 95
96Account::Account() 96Account::Account()
97{ 97{
98 accountName = "changeMe"; 98 accountName = "changeMe";
99 type = "changeMe"; 99 type = "changeMe";
100 ssl = false; 100 ssl = false;
101} 101}
102 102
103void Account::remove() 103void Account::remove()
104{ 104{
105 QFile file( getFileName() ); 105 QFile file( getFileName() );
106 file.remove(); 106 file.remove();
107} 107}
108 108
109IMAPaccount::IMAPaccount() 109IMAPaccount::IMAPaccount()
110 : Account() 110 : Account()
111{ 111{
112 file = IMAPaccount::getUniqueFileName(); 112 file = IMAPaccount::getUniqueFileName();
113 accountName = "New IMAP Account"; 113 accountName = "New IMAP Account";
114 ssl = false; 114 ssl = false;
115 type = "IMAP"; 115 type = "IMAP";
116 port = IMAP_PORT; 116 port = IMAP_PORT;
117} 117}
118 118
119IMAPaccount::IMAPaccount( QString filename ) 119IMAPaccount::IMAPaccount( QString filename )
120 : Account() 120 : Account()
121{ 121{
122 file = filename; 122 file = 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
129QString IMAPaccount::getUniqueFileName() 129QString 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
145void IMAPaccount::read() 144void IMAPaccount::read()
146{ 145{
147 Config *conf = new Config( getFileName(), Config::File ); 146 Config *conf = new Config( getFileName(), Config::File );
148 conf->setGroup( "IMAP Account" ); 147 conf->setGroup( "IMAP Account" );
149 accountName = conf->readEntry( "Account","" ); 148 accountName = conf->readEntry( "Account","" );
150 if (accountName.isNull()) accountName = ""; 149 if (accountName.isNull()) accountName = "";
151 server = conf->readEntry( "Server","" ); 150 server = conf->readEntry( "Server","" );
152 if (server.isNull()) server=""; 151 if (server.isNull()) server="";
153 port = conf->readEntry( "Port","" ); 152 port = conf->readEntry( "Port","" );
154 if (port.isNull()) port="143"; 153 if (port.isNull()) port="143";
155 ssl = conf->readBoolEntry( "SSL",false ); 154 ssl = conf->readBoolEntry( "SSL",false );
156 user = conf->readEntry( "User","" ); 155 user = conf->readEntry( "User","" );
157 if (user.isNull()) user = ""; 156 if (user.isNull()) user = "";
158 password = conf->readEntryCrypt( "Password","" ); 157 password = conf->readEntryCrypt( "Password","" );
159 if (password.isNull()) password = ""; 158 if (password.isNull()) password = "";
160 prefix = conf->readEntry("MailPrefix",""); 159 prefix = conf->readEntry("MailPrefix","");
161 if (prefix.isNull()) prefix = ""; 160 if (prefix.isNull()) prefix = "";
162} 161}
163 162
164void IMAPaccount::save() 163void IMAPaccount::save()
165{ 164{
166 qDebug( "saving " + getFileName() ); 165 qDebug( "saving " + getFileName() );
167 Settings::checkDirectory(); 166 Settings::checkDirectory();
168 167
169 Config *conf = new Config( getFileName(), Config::File ); 168 Config *conf = new Config( getFileName(), Config::File );
170 conf->setGroup( "IMAP Account" ); 169 conf->setGroup( "IMAP Account" );
171 conf->writeEntry( "Account", accountName ); 170 conf->writeEntry( "Account", accountName );
172 conf->writeEntry( "Server", server ); 171 conf->writeEntry( "Server", server );
173 conf->writeEntry( "Port", port ); 172 conf->writeEntry( "Port", port );
174 conf->writeEntry( "SSL", ssl ); 173 conf->writeEntry( "SSL", ssl );
175 conf->writeEntry( "User", user ); 174 conf->writeEntry( "User", user );
176 conf->writeEntryCrypt( "Password", password ); 175 conf->writeEntryCrypt( "Password", password );
177 conf->writeEntry( "MailPrefix",prefix); 176 conf->writeEntry( "MailPrefix",prefix);
178 conf->write(); 177 conf->write();
179} 178}
180 179
181 180
182QString IMAPaccount::getFileName() 181QString IMAPaccount::getFileName()
183{ 182{
184 return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; 183 return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file;
185} 184}
186 185
187POP3account::POP3account() 186POP3account::POP3account()
188 : Account() 187 : Account()
189{ 188{
190 file = POP3account::getUniqueFileName(); 189 file = POP3account::getUniqueFileName();
191 accountName = "New POP3 Account"; 190 accountName = "New POP3 Account";
192 ssl = false; 191 ssl = false;
193 type = "POP3"; 192 type = "POP3";
194 port = POP3_PORT; 193 port = POP3_PORT;
195} 194}
196 195
197POP3account::POP3account( QString filename ) 196POP3account::POP3account( QString filename )
198 : Account() 197 : Account()
199{ 198{
200 file = filename; 199 file = 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
207QString POP3account::getUniqueFileName() 206QString 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
223void POP3account::read() 221void POP3account::read()
224{ 222{
225 Config *conf = new Config( getFileName(), Config::File ); 223 Config *conf = new Config( getFileName(), Config::File );
226 conf->setGroup( "POP3 Account" ); 224 conf->setGroup( "POP3 Account" );
227 accountName = conf->readEntry( "Account" ); 225 accountName = conf->readEntry( "Account" );
228 server = conf->readEntry( "Server" ); 226 server = conf->readEntry( "Server" );
229 port = conf->readEntry( "Port" ); 227 port = conf->readEntry( "Port" );
230 ssl = conf->readBoolEntry( "SSL" ); 228 ssl = conf->readBoolEntry( "SSL" );
231 user = conf->readEntry( "User" ); 229 user = conf->readEntry( "User" );
232 password = conf->readEntryCrypt( "Password" ); 230 password = conf->readEntryCrypt( "Password" );
233} 231}
234 232
235void POP3account::save() 233void POP3account::save()
236{ 234{
237 qDebug( "saving " + getFileName() ); 235 qDebug( "saving " + getFileName() );
238 Settings::checkDirectory(); 236 Settings::checkDirectory();
239 237
240 Config *conf = new Config( getFileName(), Config::File ); 238 Config *conf = new Config( getFileName(), Config::File );
241 conf->setGroup( "POP3 Account" ); 239 conf->setGroup( "POP3 Account" );
242 conf->writeEntry( "Account", accountName ); 240 conf->writeEntry( "Account", accountName );
243 conf->writeEntry( "Server", server ); 241 conf->writeEntry( "Server", server );
244 conf->writeEntry( "Port", port ); 242 conf->writeEntry( "Port", port );
245 conf->writeEntry( "SSL", ssl ); 243 conf->writeEntry( "SSL", ssl );
246 conf->writeEntry( "User", user ); 244 conf->writeEntry( "User", user );
247 conf->writeEntryCrypt( "Password", password ); 245 conf->writeEntryCrypt( "Password", password );
248 conf->write(); 246 conf->write();
249} 247}
250 248
251 249
252QString POP3account::getFileName() 250QString POP3account::getFileName()
253{ 251{
254 return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; 252 return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file;
255} 253}
256 254
257SMTPaccount::SMTPaccount() 255SMTPaccount::SMTPaccount()
258 : Account() 256 : Account()
259{ 257{
260 file = SMTPaccount::getUniqueFileName(); 258 file = SMTPaccount::getUniqueFileName();
261 accountName = "New SMTP Account"; 259 accountName = "New SMTP Account";
262 ssl = false; 260 ssl = false;
263 login = false; 261 login = false;
264 useCC = false; 262 useCC = false;
265 useBCC = false; 263 useBCC = false;
266 useReply = false; 264 useReply = false;
267 type = "SMTP"; 265 type = "SMTP";
268 port = SMTP_PORT; 266 port = SMTP_PORT;
269} 267}
270 268
271SMTPaccount::SMTPaccount( QString filename ) 269SMTPaccount::SMTPaccount( QString filename )
272 : Account() 270 : Account()
273{ 271{
274 file = filename; 272 file = filename;
275 accountName = "New SMTP Account"; 273 accountName = "New SMTP Account";
276 ssl = false; 274 ssl = false;
277 login = false; 275 login = false;
278 useCC = false; 276 useCC = false;
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
285QString SMTPaccount::getUniqueFileName() 283QString 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
301void SMTPaccount::read() 298void SMTPaccount::read()
302{ 299{
303 Config *conf = new Config( getFileName(), Config::File ); 300 Config *conf = new Config( getFileName(), Config::File );
304 conf->setGroup( "SMTP Account" ); 301 conf->setGroup( "SMTP Account" );
305 accountName = conf->readEntry( "Account" ); 302 accountName = conf->readEntry( "Account" );
306 server = conf->readEntry( "Server" ); 303 server = conf->readEntry( "Server" );
307 port = conf->readEntry( "Port" ); 304 port = conf->readEntry( "Port" );
308 ssl = conf->readBoolEntry( "SSL" ); 305 ssl = conf->readBoolEntry( "SSL" );
309 login = conf->readBoolEntry( "Login" ); 306 login = conf->readBoolEntry( "Login" );
310 user = conf->readEntry( "User" ); 307 user = conf->readEntry( "User" );
311 password = conf->readEntryCrypt( "Password" ); 308 password = conf->readEntryCrypt( "Password" );
312 useCC = conf->readBoolEntry( "useCC" ); 309 useCC = conf->readBoolEntry( "useCC" );
313 useBCC = conf->readBoolEntry( "useBCC" ); 310 useBCC = conf->readBoolEntry( "useBCC" );
314 useReply = conf->readBoolEntry( "useReply" ); 311 useReply = conf->readBoolEntry( "useReply" );
315 name = conf->readEntry( "Name" ); 312 name = conf->readEntry( "Name" );
316 mail = conf->readEntry( "Mail" ); 313 mail = conf->readEntry( "Mail" );
317 org = conf->readEntry( "Org" ); 314 org = conf->readEntry( "Org" );
318 cc = conf->readEntry( "CC" ); 315 cc = conf->readEntry( "CC" );
319 bcc = conf->readEntry( "BCC" ); 316 bcc = conf->readEntry( "BCC" );
320 reply = conf->readEntry( "Reply" ); 317 reply = conf->readEntry( "Reply" );
321 signature = conf->readEntry( "Signature" ); 318 signature = conf->readEntry( "Signature" );
322 signature = signature.replace( QRegExp( "<br>" ), "\n" ); 319 signature = signature.replace( QRegExp( "<br>" ), "\n" );
323} 320}
324 321
325void SMTPaccount::save() 322void SMTPaccount::save()
326{ 323{
327 qDebug( "saving " + getFileName() ); 324 qDebug( "saving " + getFileName() );
328 Settings::checkDirectory(); 325 Settings::checkDirectory();
329 326
330 Config *conf = new Config( getFileName(), Config::File ); 327 Config *conf = new Config( getFileName(), Config::File );
331 conf->setGroup( "SMTP Account" ); 328 conf->setGroup( "SMTP Account" );
332 conf->writeEntry( "Account", accountName ); 329 conf->writeEntry( "Account", accountName );
333 conf->writeEntry( "Server", server ); 330 conf->writeEntry( "Server", server );
334 conf->writeEntry( "Port", port ); 331 conf->writeEntry( "Port", port );
335 conf->writeEntry( "SSL", ssl ); 332 conf->writeEntry( "SSL", ssl );
336 conf->writeEntry( "Login", login ); 333 conf->writeEntry( "Login", login );
337 conf->writeEntry( "User", user ); 334 conf->writeEntry( "User", user );
338 conf->writeEntryCrypt( "Password", password ); 335 conf->writeEntryCrypt( "Password", password );
339 conf->writeEntry( "useCC", useCC ); 336 conf->writeEntry( "useCC", useCC );
340 conf->writeEntry( "useBCC", useBCC ); 337 conf->writeEntry( "useBCC", useBCC );
341 conf->writeEntry( "useReply", useReply ); 338 conf->writeEntry( "useReply", useReply );
342 conf->writeEntry( "Name", name ); 339 conf->writeEntry( "Name", name );
343 conf->writeEntry( "Mail", mail ); 340 conf->writeEntry( "Mail", mail );
344 conf->writeEntry( "Org", org ); 341 conf->writeEntry( "Org", org );
345 conf->writeEntry( "CC", cc ); 342 conf->writeEntry( "CC", cc );
346 conf->writeEntry( "BCC", bcc ); 343 conf->writeEntry( "BCC", bcc );
347 conf->writeEntry( "Reply", reply ); 344 conf->writeEntry( "Reply", reply );
348 conf->writeEntry( "Signature", 345 conf->writeEntry( "Signature",
349 signature.replace( QRegExp( "\\n" ), "<br>" ) ); 346 signature.replace( QRegExp( "\\n" ), "<br>" ) );
350 conf->write(); 347 conf->write();
351} 348}
352 349
353 350
354QString SMTPaccount::getFileName() 351QString SMTPaccount::getFileName()
355{ 352{
356 return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; 353 return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file;
357} 354}
358 355
359NNTPaccount::NNTPaccount() 356NNTPaccount::NNTPaccount()
360 : Account() 357 : Account()
361{ 358{
362 file = NNTPaccount::getUniqueFileName(); 359 file = NNTPaccount::getUniqueFileName();
363 accountName = "New NNTP Account"; 360 accountName = "New NNTP Account";
364 ssl = false; 361 ssl = false;
365 login = false; 362 login = false;
366 type = "NNTP"; 363 type = "NNTP";
367 port = NNTP_PORT; 364 port = NNTP_PORT;
368} 365}
369 366
370NNTPaccount::NNTPaccount( QString filename ) 367NNTPaccount::NNTPaccount( QString filename )
371 : Account() 368 : Account()
372{ 369{
373 file = filename; 370 file = filename;
374 accountName = "New NNTP Account"; 371 accountName = "New NNTP Account";
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
381QString NNTPaccount::getUniqueFileName() 378QString 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
397void NNTPaccount::read() 393void NNTPaccount::read()
398{ 394{
399 Config *conf = new Config( getFileName(), Config::File ); 395 Config *conf = new Config( getFileName(), Config::File );
400 conf->setGroup( "NNTP Account" ); 396 conf->setGroup( "NNTP Account" );
401 accountName = conf->readEntry( "Account" ); 397 accountName = conf->readEntry( "Account" );
402 server = conf->readEntry( "Server" ); 398 server = conf->readEntry( "Server" );
403 port = conf->readEntry( "Port" ); 399 port = conf->readEntry( "Port" );
404 ssl = conf->readBoolEntry( "SSL" ); 400 ssl = conf->readBoolEntry( "SSL" );
405 login = conf->readBoolEntry( "Login" ); 401 login = conf->readBoolEntry( "Login" );
406 user = conf->readEntry( "User" ); 402 user = conf->readEntry( "User" );
407 password = conf->readEntryCrypt( "Password" ); 403 password = conf->readEntryCrypt( "Password" );
408} 404}
409 405
410void NNTPaccount::save() 406void NNTPaccount::save()
411{ 407{
412 qDebug( "saving " + getFileName() ); 408 qDebug( "saving " + getFileName() );
413 Settings::checkDirectory(); 409 Settings::checkDirectory();
414 410
415 Config *conf = new Config( getFileName(), Config::File ); 411 Config *conf = new Config( getFileName(), Config::File );
416 conf->setGroup( "NNTP Account" ); 412 conf->setGroup( "NNTP Account" );
417 conf->writeEntry( "Account", accountName ); 413 conf->writeEntry( "Account", accountName );
418 conf->writeEntry( "Server", server ); 414 conf->writeEntry( "Server", server );
419 conf->writeEntry( "Port", port ); 415 conf->writeEntry( "Port", port );
420 conf->writeEntry( "SSL", ssl ); 416 conf->writeEntry( "SSL", ssl );
421 conf->writeEntry( "Login", login ); 417 conf->writeEntry( "Login", login );
422 conf->writeEntry( "User", user ); 418 conf->writeEntry( "User", user );
423 conf->writeEntryCrypt( "Password", password ); 419 conf->writeEntryCrypt( "Password", password );
424 conf->write(); 420 conf->write();
425} 421}
426 422
427 423
428QString NNTPaccount::getFileName() 424QString NNTPaccount::getFileName()
429{ 425{
430 return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; 426 return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file;
431} 427}
432 428