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 | |
parent | c0a0d53fb92f8a1723c57580a5fd0ade66574ec4 (diff) | |
download | opie-eeb69efb4e0639429e5f6fd15e65b1b6fbaa5c35.zip opie-eeb69efb4e0639429e5f6fd15e65b1b6fbaa5c35.tar.gz opie-eeb69efb4e0639429e5f6fd15e65b1b6fbaa5c35.tar.bz2 |
added support for pop3 tls
-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 22 | ||||
-rw-r--r-- | noncore/net/mail/editaccounts.h | 2 | ||||
-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 | ||||
-rw-r--r-- | noncore/net/mail/pop3configui.ui | 494 |
6 files changed, 452 insertions, 215 deletions
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index de36e0d..439b619 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp @@ -314,9 +314,19 @@ POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, - connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); + connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) ); + ComboBox1->insertItem( "Only if available", 0 ); + ComboBox1->insertItem( "Always, Negotiated", 1 ); + ComboBox1->insertItem( "Connect on secure port", 2 ); + ComboBox1->insertItem( "Run command instead", 3 ); + CommandEdit->hide(); + ComboBox1->setCurrentItem( data->ConnectionType() ); } -void POP3config::slotSSL( bool enabled ) +void POP3config::slotConnectionToggle( int index ) { - if ( enabled ) { - portLine->setText( POP3_SSL_PORT ); + // 2 is ssl connection + if ( index == 2 ) { + portLine->setText( POP3_SSL_PORT ); + } else if ( index == 3 ) { + portLine->setText( POP3_PORT ); + CommandEdit->show(); } else { @@ -331,3 +341,3 @@ void POP3config::fillValues() portLine->setText( data->getPort() ); - sslBox->setChecked( data->getSSL() ); + ComboBox1->setCurrentItem( data->ConnectionType() ); userLine->setText( data->getUser() ); @@ -341,3 +351,3 @@ void POP3config::accept() data->setPort( portLine->text() ); - data->setSSL( sslBox->isChecked() ); + data->setConnectionType( ComboBox1->currentItem() ); data->setUser( userLine->text() ); diff --git a/noncore/net/mail/editaccounts.h b/noncore/net/mail/editaccounts.h index 6022eef..fb4be71 100644 --- a/noncore/net/mail/editaccounts.h +++ b/noncore/net/mail/editaccounts.h @@ -100,3 +100,3 @@ public slots: protected slots: - void slotSSL( bool enabled ); + void slotConnectionToggle( int index ); void accept(); 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; diff --git a/noncore/net/mail/pop3configui.ui b/noncore/net/mail/pop3configui.ui index 8fdb4ba..95cbdc2 100644 --- a/noncore/net/mail/pop3configui.ui +++ b/noncore/net/mail/pop3configui.ui @@ -13,3 +13,3 @@ <y>0</y> - <width>236</width> + <width>232</width> <height>320</height> @@ -27,164 +27,371 @@ </property> - <grid> + <widget> + <class>QLayoutWidget</class> <property stdset="1"> - <name>margin</name> - <number>4</number> + <name>name</name> + <cstring>Layout12</cstring> </property> <property stdset="1"> - <name>spacing</name> - <number>3</number> + <name>geometry</name> + <rect> + <x>3</x> + <y>3</y> + <width>226</width> + <height>32</height> + </rect> </property> - <widget row="6" column="1" > - <class>QLineEdit</class> + <hbox> <property stdset="1"> - <name>name</name> - <cstring>userLine</cstring> + <name>margin</name> + <number>0</number> </property> - </widget> - <widget row="7" column="0" > - <class>QLabel</class> <property stdset="1"> - <name>name</name> - <cstring>passLabel</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Password</string> - </property> - </widget> - <widget row="7" column="1" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>passLine</cstring> - </property> - <property stdset="1"> - <name>echoMode</name> - <enum>Password</enum> - </property> - </widget> - <widget row="3" column="1" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>portLine</cstring> - </property> - </widget> - <widget row="2" column="1" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>serverLine</cstring> - </property> - </widget> - <widget row="2" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>serverLabel</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Server</string> - </property> - </widget> - <widget row="4" column="1" > - <class>QCheckBox</class> - <property stdset="1"> - <name>name</name> - <cstring>sslBox</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Use SSL</string> - </property> - </widget> - <widget row="3" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>portLabel</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Port</string> - </property> - </widget> - <widget row="6" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>userLabel</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>User</string> - </property> - </widget> - <spacer row="8" column="1" > - <property> - <name>name</name> - <cstring>spacer</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Vertical</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - <widget row="5" column="0" rowspan="1" colspan="2" > - <class>Line</class> - <property stdset="1"> - <name>name</name> - <cstring>line2</cstring> + <name>spacing</name> + <number>6</number> </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>accountLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Account</string> + </property> + </widget> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>accountLine</cstring> + </property> + <property> + <name>toolTip</name> + <string>Name of the Account</string> + </property> + </widget> + </hbox> + </widget> + <widget> + <class>Line</class> + <property stdset="1"> + <name>name</name> + <cstring>line1</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>3</x> + <y>38</y> + <width>226</width> + <height>16</height> + </rect> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout11</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>3</x> + <y>44</y> + <width>226</width> + <height>70</height> + </rect> + </property> + <hbox> <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> + <name>margin</name> + <number>0</number> </property> - </widget> - <widget row="0" column="0" > - <class>QLabel</class> <property stdset="1"> - <name>name</name> - <cstring>accountLabel</cstring> + <name>spacing</name> + <number>6</number> </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout9</cstring> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>serverLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Server</string> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>portLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Port</string> + </property> + </widget> + </vbox> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout10</cstring> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>serverLine</cstring> + </property> + </widget> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>portLine</cstring> + </property> + </widget> + </vbox> + </widget> + </hbox> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout13</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>3</x> + <y>117</y> + <width>226</width> + <height>64</height> + </rect> + </property> + <vbox> <property stdset="1"> - <name>text</name> - <string>Account</string> + <name>margin</name> + <number>0</number> </property> - </widget> - <widget row="0" column="1" > - <class>QLineEdit</class> <property stdset="1"> - <name>name</name> - <cstring>accountLine</cstring> + <name>spacing</name> + <number>6</number> </property> - <property> - <name>toolTip</name> - <string>Name of the Account</string> - </property> - </widget> - <widget row="1" column="0" rowspan="1" colspan="2" > - <class>Line</class> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Use secure sockets:</string> + </property> + </widget> + <widget> + <class>QComboBox</class> + <property stdset="1"> + <name>name</name> + <cstring>ComboBox1</cstring> + </property> + </widget> + </vbox> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout6</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>3</x> + <y>223</y> + <width>226</width> + <height>70</height> + </rect> + </property> + <hbox> <property stdset="1"> - <name>name</name> - <cstring>line1</cstring> + <name>margin</name> + <number>0</number> </property> <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> + <name>spacing</name> + <number>6</number> </property> - </widget> - </grid> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout4</cstring> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>userLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>User</string> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>passLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Password</string> + </property> + </widget> + </vbox> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout5</cstring> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>userLine</cstring> + </property> + </widget> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>passLine</cstring> + </property> + <property stdset="1"> + <name>echoMode</name> + <enum>Password</enum> + </property> + </widget> + </vbox> + </widget> + </hbox> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>spacer</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>CommandEdit</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>180</y> + <width>226</width> + <height>30</height> + </rect> + </property> + <property stdset="1"> + <name>text</name> + <string>ssh $SERVER exec imapd</string> + </property> + </widget> + <widget> + <class>Line</class> + <property stdset="1"> + <name>name</name> + <cstring>line2</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>3</x> + <y>204</y> + <width>226</width> + <height>16</height> + </rect> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + </widget> </widget> @@ -194,3 +401,2 @@ <tabstop>portLine</tabstop> - <tabstop>sslBox</tabstop> <tabstop>userLine</tabstop> |