author | harlekin <harlekin> | 2004-01-08 17:42:16 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-01-08 17:42:16 (UTC) |
commit | eeb69efb4e0639429e5f6fd15e65b1b6fbaa5c35 (patch) (side-by-side diff) | |
tree | d14fa40cddeceb1b04dafa209841727811c6e71c /noncore/net/mail/libmailwrapper | |
parent | c0a0d53fb92f8a1723c57580a5fd0ade66574ec4 (diff) | |
download | opie-eeb69efb4e0639429e5f6fd15e65b1b6fbaa5c35.zip opie-eeb69efb4e0639429e5f6fd15e65b1b6fbaa5c35.tar.gz opie-eeb69efb4e0639429e5f6fd15e65b1b6fbaa5c35.tar.bz2 |
added support for pop3 tls
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 @@ -12,6 +12,5 @@ POP3wrapper::POP3wrapper( POP3account *a ) - : Genericwrapper() -{ +: Genericwrapper() { account = a; m_pop3 = NULL; @@ -21,6 +20,5 @@ POP3wrapper::POP3wrapper( POP3account *a ) } -POP3wrapper::~POP3wrapper() -{ +POP3wrapper::~POP3wrapper() { logout(); QFile msg_cache(msgTempName); @@ -30,11 +28,9 @@ 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 ); } -RecBody POP3wrapper::fetchBody( const RecMail &mail ) -{ +RecBody POP3wrapper::fetchBody( const RecMail &mail ) { int err = MAILPOP3_NO_ERROR; char *message = 0; @@ -91,14 +87,16 @@ 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); return body; } -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; mailsession_status_folder(m_folder->fld_session,"INBOX",&res_messages,&res_recent,&res_unseen); @@ -107,9 +105,10 @@ 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; const char *server, *user, *pass; @@ -120,28 +119,43 @@ void POP3wrapper::login() port = account->getPort().toUInt(); - 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); + + m_folder = mailfolder_new(m_pop3, NULL, NULL); @@ -164,8 +178,8 @@ 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); m_folder = 0; @@ -175,6 +189,5 @@ void POP3wrapper::logout() -QList<Folder>* POP3wrapper::listFolders() -{ +QList<Folder>* POP3wrapper::listFolders() { QList<Folder> * folders = new QList<Folder>(); folders->setAutoDelete( false ); @@ -184,8 +197,8 @@ 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()); if (err != MAIL_NO_ERROR) { @@ -194,12 +207,10 @@ 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; @@ -221,17 +232,16 @@ int POP3wrapper::deleteAllMail(const Folder*) } -void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) -{ +void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { login(); target_stat.message_count = 0; target_stat.message_unseen = 0; 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; size_t length=0; @@ -240,5 +250,6 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); err = mailmessage_fetch(mailmsg,&target,&length); - if (mailmsg) mailmessage_free(mailmsg); + if (mailmsg) + mailmessage_free(mailmsg); if (target) { res = new encodedString(target,length); @@ -247,11 +258,9 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) } -const QString&POP3wrapper::getType()const -{ +const QString&POP3wrapper::getType()const { return account->getType(); } -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 @@ -109,4 +109,5 @@ Account::Account() type = "changeMe"; ssl = false; + connectionType = 1; } @@ -123,4 +124,5 @@ IMAPaccount::IMAPaccount() accountName = "New IMAP Account"; ssl = false; + connectionType = 1; type = "IMAP"; port = IMAP_PORT; @@ -133,4 +135,5 @@ IMAPaccount::IMAPaccount( QString filename ) accountName = "New IMAP Account"; ssl = false; + connectionType = 1; type = "IMAP"; port = IMAP_PORT; @@ -204,4 +207,5 @@ POP3account::POP3account() accountName = "New POP3 Account"; ssl = false; + connectionType = 1; type = "POP3"; port = POP3_PORT; @@ -214,4 +218,5 @@ POP3account::POP3account( QString filename ) accountName = "New POP3 Account"; ssl = false; + connectionType = 1; type = "POP3"; port = POP3_PORT; @@ -241,4 +246,5 @@ void POP3account::read() port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); + connectionType = conf->readNumEntry( "ConnectionType" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); @@ -258,4 +264,5 @@ void POP3account::save() conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); + conf->writeEntry( "ConnectionType", connectionType ); conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); 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 @@ -32,4 +32,8 @@ public: bool getSSL() { return ssl; } + void setConnectionType( int x ) { connectionType = x; } + int ConnectionType() { return connectionType; } + + void setOffline(bool b) {offline = b;} bool getOffline()const{return offline;} @@ -42,4 +46,5 @@ protected: QString accountName, type, server, port, user, password; bool ssl; + int connectionType; bool offline; }; |