author | jgf <jgf> | 2003-12-09 21:36:56 (UTC) |
---|---|---|
committer | jgf <jgf> | 2003-12-09 21:36:56 (UTC) |
commit | 6b45c1f8e0293914c1328f15a665d2ea0fba7b43 (patch) (side-by-side diff) | |
tree | d87ef7d3147a52429849a6921e7a8f31fde89aa8 | |
parent | 0a1f6405780b18c9f3d953adcfd072de8fd4dc18 (diff) | |
download | opie-6b45c1f8e0293914c1328f15a665d2ea0fba7b43.zip opie-6b45c1f8e0293914c1328f15a665d2ea0fba7b43.tar.gz opie-6b45c1f8e0293914c1328f15a665d2ea0fba7b43.tar.bz2 |
POP3 support - first steps
-rw-r--r-- | noncore/net/mail/accountview.cpp | 45 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 16 | ||||
-rw-r--r-- | noncore/net/mail/defines.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 74 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 28 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/mail.pro | 18 | ||||
-rw-r--r-- | noncore/net/mail/opie-mail.control | 2 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 74 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.h | 28 | ||||
-rw-r--r-- | noncore/net/mail/settings.cpp | 4 |
11 files changed, 278 insertions, 17 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index df9fc11..6963027 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp @@ -1,29 +1,66 @@ #include "accountview.h" #include "imapwrapper.h" +#include "pop3wrapper.h" #include "mailtypes.h" #include "defines.h" + +/** + * POP3 Account stuff + */ + +POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) + : AccountViewItem( parent ) +{ + account = a; + wrapper = new POP3wrapper( account ); + setPixmap( 0, PIXMAP_POP3FOLDER ); + setText( 0, account->getAccountName() ); +} + +POP3viewItem::~POP3viewItem() +{ + delete wrapper; +} + +void POP3viewItem::refresh( QList<RecMail> &target ) +{ + qDebug( "POP3: refresh" ); + wrapper->listMessages( target ); +} + + +RecBody POP3viewItem::fetchBody( const RecMail & ) +{ + qDebug( "POP3 fetchBody: IMPLEMENT ME!!" ); + return RecBody(); +} + +/** + * IMAP Account stuff + */ + IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) : AccountViewItem( parent ) { account = a; wrapper = new IMAPwrapper( account ); setPixmap( 0, PIXMAP_IMAPFOLDER ); setText( 0, account->getAccountName() ); setOpen( true ); } IMAPviewItem::~IMAPviewItem() { delete wrapper; } IMAPwrapper *IMAPviewItem::getWrapper() { return wrapper; } void IMAPviewItem::refresh(QList<RecMail>&) { QList<IMAPFolder> *folders = wrapper->listFolders(); @@ -48,65 +85,73 @@ RecBody IMAPviewItem::fetchBody(const RecMail&) IMAPfolderItem::~IMAPfolderItem() { delete folder; } IMAPfolderItem::IMAPfolderItem( IMAPFolder *folderInit, IMAPviewItem *parent ) : AccountViewItem( parent ) { folder = folderInit; imap = parent; setPixmap( 0, PIXMAP_IMAPFOLDER ); setText( 0, folder->getDisplayName() ); } void IMAPfolderItem::refresh(QList<RecMail>&target) { imap->getWrapper()->listMessages( folder->getName(),target ); } RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) { return imap->getWrapper()->fetchBody(aMail); } +/** + * Generic stuff + */ + AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) : QListView( parent, name, flags ) { connect( this, SIGNAL( clicked( QListViewItem * ) ), SLOT( refresh( QListViewItem * ) ) ); } void AccountView::populate( QList<Account> list ) { clear(); Account *it; for ( it = list.first(); it; it = list.next() ) { if ( it->getType().compare( "IMAP" ) == 0 ) { IMAPaccount *imap = static_cast<IMAPaccount *>(it); qDebug( "added IMAP " + imap->getAccountName() ); (void) new IMAPviewItem( imap, this ); + } else if ( it->getType().compare( "POP3" ) == 0 ) { + POP3account *pop3 = static_cast<POP3account *>(it); + qDebug( "added POP3 " + pop3->getAccountName() ); + (void) new POP3viewItem( pop3, this ); } } } void AccountView::refresh(QListViewItem *item) { qDebug("AccountView refresh..."); if ( item ) { QList<RecMail> headerlist; headerlist.setAutoDelete(true); AccountViewItem *view = static_cast<AccountViewItem *>(item); view->refresh(headerlist); emit refreshMailview(&headerlist); } } void AccountView::refreshAll() { } RecBody AccountView::fetchBody(const RecMail&aMail) { QListViewItem*item = selectedItem (); if (!item) return RecBody(); 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,47 +1,63 @@ #ifndef ACCOUNTVIEW_H #define ACCOUNTVIEW_H #include <qlistview.h> #include <qlist.h> #include "settings.h" #include "mailwrapper.h" class IMAPwrapper; +class POP3wrapper; class RecMail; class RecBody; class AccountViewItem : public QListViewItem { public: AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {} virtual void refresh(QList<RecMail>&)=0; virtual RecBody fetchBody(const RecMail&)=0; }; +class POP3viewItem : public AccountViewItem +{ + +public: + POP3viewItem( POP3account *a, QListView *parent ); + ~POP3viewItem(); + virtual void refresh( QList<RecMail> &target ); + virtual RecBody fetchBody(const RecMail & ); + +private: + POP3account *account; + POP3wrapper *wrapper; + +}; + class IMAPviewItem : public AccountViewItem { public: IMAPviewItem( IMAPaccount *a, QListView *parent ); ~IMAPviewItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); IMAPwrapper *getWrapper(); private: IMAPaccount *account; IMAPwrapper *wrapper; }; class IMAPfolderItem : public AccountViewItem { public: IMAPfolderItem( IMAPFolder *folder, IMAPviewItem *parent ); ~IMAPfolderItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); 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 @@ #ifndef DEFINE_CONSTANTS_H #define DEFINE_CONSTANTS_H #include <qpe/resource.h> #define USER_AGENT "OpieMail v0.0.1-alpha" #define PIC_COMPOSEMAIL "opiemail/composemail" #define PIC_SENDQUEUED "opiemail/sendqueued" #define PIC_SHOWFOLDERS "opiemail/showfolders" #define PIC_SEARCHMAILS "opiemail/searchmails" #define PIC_EDITSETTINGS "opiemail/editsettings" #define PIC_EDITACCOUNTS "opiemail/editaccounts" #define PIC_SYNC "opiemail/sync" #define PIC_IMAPFOLDER "opiemail/imapfolder" +#define PIC_POP3FOLDER "opiemail/pop3folder" #define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) #define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) #define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) #define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) #define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) #define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) #define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) ) #define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) +#define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) #define IMAP_PORT "143" #define IMAP_SSL_PORT "993" #define SMTP_PORT "25" #define SMTP_SSL_PORT "465" #define POP3_PORT "110" #define POP3_SSL_PORT "995" #define NNTP_PORT "119" #define NNTP_SSL_PORT "563" #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 @@ + +#include "pop3wrapper.h" +#include "mailtypes.h" +#include <libetpan/mailpop3.h> + +POP3wrapper::POP3wrapper( POP3account *a ) +{ + account = a; +} + +POP3wrapper::~POP3wrapper() +{ + logout(); +} + +void POP3wrapper::pop3_progress( size_t current, size_t maximum ) +{ + qDebug( "POP3: %i of %i", current, maximum ); +} + +void POP3wrapper::listMessages( QList<RecMail> &target ) +{ + login(); + //TODO: list messages + logout(); +} + +void POP3wrapper::login() +{ + logout(); + const char *server, *user, *pass; + uint16_t port; + int err = MAILPOP3_NO_ERROR; + + server = account->getServer().latin1(); + port = account->getPort().toUInt(); + user = account->getUser().latin1(); + pass = account->getPassword().latin1(); + + m_pop3 = mailpop3_new( 20, &pop3_progress ); + + // connect + err = mailpop3_socket_connect( m_pop3, (char *) server, port ); + if ( err != MAILPOP3_NO_ERROR ) { + qDebug( "pop3: error connecting to %s\n reason: %s", server, + m_pop3->response ); + mailpop3_free( m_pop3 ); + m_pop3 = NULL; + return; + } + qDebug( "POP3: connected!" ); + + // login + // TODO: decide if apop or plain login should be used + err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); + if ( err != MAILPOP3_NO_ERROR ) { + qDebug( "pop3: error logging in: %s", m_pop3->response ); + logout(); + return; + } + + qDebug( "POP3: logged in!" ); +} + +void POP3wrapper::logout() +{ + int err = MAILPOP3_NO_ERROR; + if ( !m_pop3 ) return; + err = mailpop3_quit( m_pop3 ); + mailpop3_free( m_pop3 ); + m_pop3 = NULL; +} + + 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 @@ +#ifndef __POP3WRAPPER +#define __POP3WRAPPER + +#include "mailwrapper.h" + +class RecMail; + +class POP3wrapper : public QObject +{ + Q_OBJECT + +public: + POP3wrapper( POP3account *a ); + virtual ~POP3wrapper(); + void listMessages( QList<RecMail> &target ); + static void pop3_progress( size_t current, size_t maximum ); + +protected: + void login(); + void logout(); + +private: + POP3account *account; + mailpop3 *m_pop3; + +}; + +#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 @@ -111,49 +111,48 @@ IMAPaccount::IMAPaccount() { file = IMAPaccount::getUniqueFileName(); accountName = "New IMAP Account"; ssl = false; type = "IMAP"; port = IMAP_PORT; } IMAPaccount::IMAPaccount( QString filename ) : Account() { file = filename; accountName = "New IMAP Account"; ssl = false; type = "IMAP"; port = IMAP_PORT; } QString IMAPaccount::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); - QStringList::Iterator it; QStringList imap = dir.entryList( "imap-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "imap-" + unique ) > 0 ); return unique; } void IMAPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "IMAP Account" ); accountName = conf->readEntry( "Account","" ); if (accountName.isNull()) accountName = ""; server = conf->readEntry( "Server","" ); if (server.isNull()) server=""; port = conf->readEntry( "Port","" ); if (port.isNull()) port="143"; ssl = conf->readBoolEntry( "SSL",false ); user = conf->readEntry( "User","" ); if (user.isNull()) user = ""; password = conf->readEntryCrypt( "Password","" ); if (password.isNull()) password = ""; @@ -189,49 +188,48 @@ POP3account::POP3account() { file = POP3account::getUniqueFileName(); accountName = "New POP3 Account"; ssl = false; type = "POP3"; port = POP3_PORT; } POP3account::POP3account( QString filename ) : Account() { file = filename; accountName = "New POP3 Account"; ssl = false; type = "POP3"; port = POP3_PORT; } QString POP3account::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); - QStringList::Iterator it; QStringList imap = dir.entryList( "pop3-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "pop3-" + unique ) > 0 ); return unique; } void POP3account::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "POP3 Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); } void POP3account::save() { qDebug( "saving " + getFileName() ); @@ -267,49 +265,48 @@ SMTPaccount::SMTPaccount() type = "SMTP"; port = SMTP_PORT; } SMTPaccount::SMTPaccount( QString filename ) : Account() { file = filename; accountName = "New SMTP Account"; ssl = false; login = false; useCC = false; useBCC = false; useReply = false; type = "SMTP"; port = SMTP_PORT; } QString SMTPaccount::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); - QStringList::Iterator it; QStringList imap = dir.entryList( "smtp-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "smtp-" + unique ) > 0 ); return unique; } void SMTPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "SMTP Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); login = conf->readBoolEntry( "Login" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); useCC = conf->readBoolEntry( "useCC" ); useBCC = conf->readBoolEntry( "useBCC" ); useReply = conf->readBoolEntry( "useReply" ); name = conf->readEntry( "Name" ); @@ -363,49 +360,48 @@ NNTPaccount::NNTPaccount() accountName = "New NNTP Account"; ssl = false; login = false; type = "NNTP"; port = NNTP_PORT; } NNTPaccount::NNTPaccount( QString filename ) : Account() { file = filename; accountName = "New NNTP Account"; ssl = false; login = false; type = "NNTP"; port = NNTP_PORT; } QString NNTPaccount::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); - QStringList::Iterator it; QStringList imap = dir.entryList( "nntp-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "nntp-" + unique ) > 0 ); return unique; } void NNTPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "NNTP Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); login = conf->readBoolEntry( "Login" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); } void NNTPaccount::save() { 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 @@ CONFIG += qt warn_on debug quick-app HEADERS = defines.h \ logindialog.h \ settings.h \ editaccounts.h \ mailwrapper.h \ composemail.h \ accountview.h \ mainwindow.h \ - viewmail.h \ - viewmailbase.h \ + viewmail.h \ + viewmailbase.h \ opiemail.h \ - imapwrapper.h \ - mailtypes.h \ - mailistviewitem.h + imapwrapper.h \ + mailtypes.h \ + mailistviewitem.h \ + pop3wrapper.h SOURCES = main.cpp \ opiemail.cpp \ mainwindow.cpp \ accountview.cpp \ composemail.cpp \ mailwrapper.cpp \ imapwrapper.cpp \ addresspicker.cpp \ editaccounts.cpp \ logindialog.cpp \ - viewmail.cpp \ - viewmailbase.cpp \ + viewmail.cpp \ + viewmailbase.cpp \ settings.cpp \ - mailtypes.cpp + mailtypes.cpp \ + pop3wrapper.cpp INTERFACES = editaccountsui.ui \ selectmailtypeui.ui \ imapconfigui.ui \ pop3configui.ui \ nntpconfigui.ui \ smtpconfigui.ui \ addresspickerui.ui \ logindialogui.ui \ composemailui.ui INCLUDEPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie -letpan -lssl -lcrypto -ldb TARGET = opiemail include ( $(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 @@ Package: opie-mail Files: bin/opiemail apps/1Pim/opiemail.desktop pics/mail/*.png Priority: optional Section: opie/applications -Maintainer: Juergen Graf <jgf@openbsd.de> +Maintainer: Juergen Graf <jgf@handhelds.org> Architecture: arm Version: 0.0.1-$SUB_VERSION Depends: task-opie-minimal, libopie1 Description: Opie's mail and news client (POP3, IMAP and NNTP) License: LGPL diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp new file mode 100644 index 0000000..08e97f4 --- a/dev/null +++ b/noncore/net/mail/pop3wrapper.cpp @@ -0,0 +1,74 @@ + +#include "pop3wrapper.h" +#include "mailtypes.h" +#include <libetpan/mailpop3.h> + +POP3wrapper::POP3wrapper( POP3account *a ) +{ + account = a; +} + +POP3wrapper::~POP3wrapper() +{ + logout(); +} + +void POP3wrapper::pop3_progress( size_t current, size_t maximum ) +{ + qDebug( "POP3: %i of %i", current, maximum ); +} + +void POP3wrapper::listMessages( QList<RecMail> &target ) +{ + login(); + //TODO: list messages + logout(); +} + +void POP3wrapper::login() +{ + logout(); + const char *server, *user, *pass; + uint16_t port; + int err = MAILPOP3_NO_ERROR; + + server = account->getServer().latin1(); + port = account->getPort().toUInt(); + user = account->getUser().latin1(); + pass = account->getPassword().latin1(); + + m_pop3 = mailpop3_new( 20, &pop3_progress ); + + // connect + err = mailpop3_socket_connect( m_pop3, (char *) server, port ); + if ( err != MAILPOP3_NO_ERROR ) { + qDebug( "pop3: error connecting to %s\n reason: %s", server, + m_pop3->response ); + mailpop3_free( m_pop3 ); + m_pop3 = NULL; + return; + } + qDebug( "POP3: connected!" ); + + // login + // TODO: decide if apop or plain login should be used + err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); + if ( err != MAILPOP3_NO_ERROR ) { + qDebug( "pop3: error logging in: %s", m_pop3->response ); + logout(); + return; + } + + qDebug( "POP3: logged in!" ); +} + +void POP3wrapper::logout() +{ + int err = MAILPOP3_NO_ERROR; + if ( !m_pop3 ) return; + err = mailpop3_quit( m_pop3 ); + mailpop3_free( m_pop3 ); + m_pop3 = NULL; +} + + 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 @@ +#ifndef __POP3WRAPPER +#define __POP3WRAPPER + +#include "mailwrapper.h" + +class RecMail; + +class POP3wrapper : public QObject +{ + Q_OBJECT + +public: + POP3wrapper( POP3account *a ); + virtual ~POP3wrapper(); + void listMessages( QList<RecMail> &target ); + static void pop3_progress( size_t current, size_t maximum ); + +protected: + void login(); + void logout(); + +private: + POP3account *account; + mailpop3 *m_pop3; + +}; + +#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 @@ -111,49 +111,48 @@ IMAPaccount::IMAPaccount() { file = IMAPaccount::getUniqueFileName(); accountName = "New IMAP Account"; ssl = false; type = "IMAP"; port = IMAP_PORT; } IMAPaccount::IMAPaccount( QString filename ) : Account() { file = filename; accountName = "New IMAP Account"; ssl = false; type = "IMAP"; port = IMAP_PORT; } QString IMAPaccount::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); - QStringList::Iterator it; QStringList imap = dir.entryList( "imap-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "imap-" + unique ) > 0 ); return unique; } void IMAPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "IMAP Account" ); accountName = conf->readEntry( "Account","" ); if (accountName.isNull()) accountName = ""; server = conf->readEntry( "Server","" ); if (server.isNull()) server=""; port = conf->readEntry( "Port","" ); if (port.isNull()) port="143"; ssl = conf->readBoolEntry( "SSL",false ); user = conf->readEntry( "User","" ); if (user.isNull()) user = ""; password = conf->readEntryCrypt( "Password","" ); if (password.isNull()) password = ""; @@ -189,49 +188,48 @@ POP3account::POP3account() { file = POP3account::getUniqueFileName(); accountName = "New POP3 Account"; ssl = false; type = "POP3"; port = POP3_PORT; } POP3account::POP3account( QString filename ) : Account() { file = filename; accountName = "New POP3 Account"; ssl = false; type = "POP3"; port = POP3_PORT; } QString POP3account::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); - QStringList::Iterator it; QStringList imap = dir.entryList( "pop3-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "pop3-" + unique ) > 0 ); return unique; } void POP3account::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "POP3 Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); } void POP3account::save() { qDebug( "saving " + getFileName() ); @@ -267,49 +265,48 @@ SMTPaccount::SMTPaccount() type = "SMTP"; port = SMTP_PORT; } SMTPaccount::SMTPaccount( QString filename ) : Account() { file = filename; accountName = "New SMTP Account"; ssl = false; login = false; useCC = false; useBCC = false; useReply = false; type = "SMTP"; port = SMTP_PORT; } QString SMTPaccount::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); - QStringList::Iterator it; QStringList imap = dir.entryList( "smtp-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "smtp-" + unique ) > 0 ); return unique; } void SMTPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "SMTP Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); login = conf->readBoolEntry( "Login" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); useCC = conf->readBoolEntry( "useCC" ); useBCC = conf->readBoolEntry( "useBCC" ); useReply = conf->readBoolEntry( "useReply" ); name = conf->readEntry( "Name" ); @@ -363,49 +360,48 @@ NNTPaccount::NNTPaccount() accountName = "New NNTP Account"; ssl = false; login = false; type = "NNTP"; port = NNTP_PORT; } NNTPaccount::NNTPaccount( QString filename ) : Account() { file = filename; accountName = "New NNTP Account"; ssl = false; login = false; type = "NNTP"; port = NNTP_PORT; } QString NNTPaccount::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); - QStringList::Iterator it; QStringList imap = dir.entryList( "nntp-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "nntp-" + unique ) > 0 ); return unique; } void NNTPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "NNTP Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); login = conf->readBoolEntry( "Login" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); } void NNTPaccount::save() { |