Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 137 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.h | 5 |
3 files changed, 85 insertions, 64 deletions
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 67bde38..f5eca4a 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp @@ -13,4 +13,3 @@ POP3wrapper::POP3wrapper( POP3account *a ) - : Genericwrapper() -{ +: Genericwrapper() { account = a; @@ -22,4 +21,3 @@ POP3wrapper::POP3wrapper( POP3account *a ) -POP3wrapper::~POP3wrapper() -{ +POP3wrapper::~POP3wrapper() { logout(); @@ -31,4 +29,3 @@ POP3wrapper::~POP3wrapper() -void POP3wrapper::pop3_progress( size_t current, size_t maximum ) -{ +void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { qDebug( "POP3: %i of %i", current, maximum ); @@ -36,4 +33,3 @@ void POP3wrapper::pop3_progress( size_t current, size_t maximum ) -RecBody POP3wrapper::fetchBody( const RecMail &mail ) -{ +RecBody POP3wrapper::fetchBody( const RecMail &mail ) { int err = MAILPOP3_NO_ERROR; @@ -92,4 +88,6 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) /* clean up */ - if (mailmsg) mailmessage_free(mailmsg); - if (message) free(message); + if (mailmsg) + mailmessage_free(mailmsg); + if (message) + free(message); @@ -98,6 +96,6 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) -void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) -{ +void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { login(); - if (!m_pop3) return; + if (!m_pop3) + return; uint32_t res_messages,res_recent,res_unseen; @@ -108,7 +106,8 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) -void POP3wrapper::login() -{ - if (account->getOffline()) return; +void POP3wrapper::login() { + if (account->getOffline()) + return; /* we'll hold the line */ - if ( m_pop3 != NULL ) return; + if ( m_pop3 != NULL ) + return; @@ -121,26 +120,41 @@ void POP3wrapper::login() - if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { - LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); - login.show(); - if ( QDialog::Accepted == login.exec() ) { - // ok - user = login.getUser().latin1(); - pass = login.getPassword().latin1(); - } else { - // cancel - qDebug( "POP3: Login canceled" ); - return; - } - } else { - user = account->getUser().latin1(); - pass = account->getPassword().latin1(); - } - - bool ssl = account->getSSL(); + if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { + LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); + login.show(); + if ( QDialog::Accepted == login.exec() ) { + // ok + user = login.getUser().latin1(); + pass = login.getPassword().latin1(); + } else { + // cancel + qDebug( "POP3: Login canceled" ); + return; + } + } else { + user = account->getUser().latin1(); + pass = account->getPassword().latin1(); + } + + // bool ssl = account->getSSL(); m_pop3=mailstorage_new(NULL); - int conntype = (ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); - - pop3_mailstorage_init(m_pop3,(char*)server,port,NULL,conntype,POP3_AUTH_TYPE_PLAIN, - (char*)user,(char*)pass,0,0,0); + + int conntypeset = account->ConnectionType(); + int conntype = 0; + if ( conntypeset == 3 ) { + conntype = CONNECTION_TYPE_COMMAND; + } else if ( conntypeset == 2 ) { + conntype = CONNECTION_TYPE_TLS; + } else if ( conntypeset == 1 ) { + conntype = CONNECTION_TYPE_STARTTLS; + } else if ( conntypeset == 0 ) { + conntype = CONNECTION_TYPE_TRY_STARTTLS; + } + + //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); + + pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, + (char*)user,(char*)pass,0,0,0); + + @@ -165,6 +179,6 @@ void POP3wrapper::login() -void POP3wrapper::logout() -{ +void POP3wrapper::logout() { int err = MAILPOP3_NO_ERROR; - if ( m_pop3 == NULL ) return; + if ( m_pop3 == NULL ) + return; mailfolder_free(m_folder); @@ -176,4 +190,3 @@ void POP3wrapper::logout() -QList<Folder>* POP3wrapper::listFolders() -{ +QList<Folder>* POP3wrapper::listFolders() { QList<Folder> * folders = new QList<Folder>(); @@ -185,6 +198,6 @@ QList<Folder>* POP3wrapper::listFolders() -void POP3wrapper::deleteMail(const RecMail&mail) -{ +void POP3wrapper::deleteMail(const RecMail&mail) { login(); - if (!m_pop3) return; + if (!m_pop3) + return; int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); @@ -195,10 +208,8 @@ void POP3wrapper::deleteMail(const RecMail&mail) -void POP3wrapper::answeredMail(const RecMail&) -{ -} +void POP3wrapper::answeredMail(const RecMail&) {} -int POP3wrapper::deleteAllMail(const Folder*) -{ +int POP3wrapper::deleteAllMail(const Folder*) { login(); - if (!m_pop3) return 0; + if (!m_pop3) + return 0; int res = 1; @@ -222,4 +233,3 @@ int POP3wrapper::deleteAllMail(const Folder*) -void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) -{ +void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { login(); @@ -228,9 +238,9 @@ void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) target_stat.message_recent = 0; - if (!m_pop3) return; + if (!m_pop3) + return; int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, - &target_stat.message_recent,&target_stat.message_unseen); + &target_stat.message_recent,&target_stat.message_unseen); } -encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) -{ +encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) { char*target=0; @@ -241,3 +251,4 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) err = mailmessage_fetch(mailmsg,&target,&length); - if (mailmsg) mailmessage_free(mailmsg); + if (mailmsg) + mailmessage_free(mailmsg); if (target) { @@ -248,4 +259,3 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) -const QString&POP3wrapper::getType()const -{ +const QString&POP3wrapper::getType()const { return account->getType(); @@ -253,4 +263,3 @@ const QString&POP3wrapper::getType()const -const QString&POP3wrapper::getName()const -{ +const QString&POP3wrapper::getName()const { return account->getAccountName(); diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index 02a80a3..83e51e3 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp @@ -110,2 +110,3 @@ Account::Account() ssl = false; + connectionType = 1; } @@ -124,2 +125,3 @@ IMAPaccount::IMAPaccount() ssl = false; + connectionType = 1; type = "IMAP"; @@ -134,2 +136,3 @@ IMAPaccount::IMAPaccount( QString filename ) ssl = false; + connectionType = 1; type = "IMAP"; @@ -205,2 +208,3 @@ POP3account::POP3account() ssl = false; + connectionType = 1; type = "POP3"; @@ -215,2 +219,3 @@ POP3account::POP3account( QString filename ) ssl = false; + connectionType = 1; type = "POP3"; @@ -242,2 +247,3 @@ void POP3account::read() ssl = conf->readBoolEntry( "SSL" ); + connectionType = conf->readNumEntry( "ConnectionType" ); user = conf->readEntry( "User" ); @@ -259,2 +265,3 @@ void POP3account::save() conf->writeEntry( "SSL", ssl ); + conf->writeEntry( "ConnectionType", connectionType ); conf->writeEntry( "User", user ); diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h index 2104997..8d7df92 100644 --- a/noncore/net/mail/libmailwrapper/settings.h +++ b/noncore/net/mail/libmailwrapper/settings.h @@ -33,2 +33,6 @@ public: + void setConnectionType( int x ) { connectionType = x; } + int ConnectionType() { return connectionType; } + + void setOffline(bool b) {offline = b;} @@ -43,2 +47,3 @@ protected: bool ssl; + int connectionType; bool offline; |