-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 20 | ||||
-rw-r--r-- | noncore/net/mail/editaccounts.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 95 | ||||
-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 | 328 |
6 files changed, 347 insertions, 110 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 @@ -312,13 +312,23 @@ POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, data = account; fillValues(); - 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 ) { + // 2 is ssl connection + if ( index == 2 ) { portLine->setText( POP3_SSL_PORT ); + } else if ( index == 3 ) { + portLine->setText( POP3_PORT ); + CommandEdit->show(); } else { portLine->setText( POP3_PORT ); } @@ -329,7 +339,7 @@ void POP3config::fillValues() accountLine->setText( data->getAccountName() ); serverLine->setText( data->getServer() ); portLine->setText( data->getPort() ); - sslBox->setChecked( data->getSSL() ); + ComboBox1->setCurrentItem( data->ConnectionType() ); userLine->setText( data->getUser() ); passLine->setText( data->getPassword() ); } @@ -339,7 +349,7 @@ void POP3config::accept() data->setAccountName( accountLine->text() ); data->setServer( serverLine->text() ); data->setPort( portLine->text() ); - data->setSSL( sslBox->isChecked() ); + data->setConnectionType( ComboBox1->currentItem() ); data->setUser( userLine->text() ); data->setPassword( passLine->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 @@ -98,7 +98,7 @@ public slots: void fillValues(); protected slots: - void slotSSL( bool enabled ); + void slotConnectionToggle( int index ); void accept(); private: 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 @@ -11,8 +11,7 @@ #define HARD_MSG_SIZE_LIMIT 5242880 POP3wrapper::POP3wrapper( POP3account *a ) - : Genericwrapper() -{ +: Genericwrapper() { account = a; m_pop3 = NULL; m_folder = NULL; @@ -20,8 +19,7 @@ POP3wrapper::POP3wrapper( POP3account *a ) last_msg_id = 0; } -POP3wrapper::~POP3wrapper() -{ +POP3wrapper::~POP3wrapper() { logout(); QFile msg_cache(msgTempName); if (msg_cache.exists()) { @@ -29,13 +27,11 @@ 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; size_t length = 0; @@ -90,27 +86,30 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) body = parseMail(mailmsg); /* 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); parseList(target,m_folder->fld_session,"INBOX"); Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); } -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; uint16_t port; @@ -136,14 +135,29 @@ void POP3wrapper::login() pass = account->getPassword().latin1(); } - bool ssl = account->getSSL(); + // bool ssl = account->getSSL(); m_pop3=mailstorage_new(NULL); - int conntype = (ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); + + 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); if (m_folder==0) { @@ -163,10 +177,10 @@ 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; mailstorage_free(m_pop3); @@ -174,8 +188,7 @@ void POP3wrapper::logout() } -QList<Folder>* POP3wrapper::listFolders() -{ +QList<Folder>* POP3wrapper::listFolders() { QList<Folder> * folders = new QList<Folder>(); folders->setAutoDelete( false ); Folder*inb=new Folder("INBOX","/"); @@ -183,24 +196,22 @@ QList<Folder>* POP3wrapper::listFolders() return folders; } -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) { Global::statusMessage(tr("error deleting 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; uint32_t result = 0; @@ -220,38 +231,36 @@ int POP3wrapper::deleteAllMail(const Folder*) return res; } -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); } -encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) -{ +encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) { char*target=0; size_t length=0; encodedString*res = 0; mailmessage * mailmsg = 0; 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); } return res; } -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 @@ -108,6 +108,7 @@ Account::Account() accountName = "changeMe"; type = "changeMe"; ssl = false; + connectionType = 1; } void Account::remove() @@ -122,6 +123,7 @@ IMAPaccount::IMAPaccount() file = IMAPaccount::getUniqueFileName(); accountName = "New IMAP Account"; ssl = false; + connectionType = 1; type = "IMAP"; port = IMAP_PORT; } @@ -132,6 +134,7 @@ IMAPaccount::IMAPaccount( QString filename ) file = filename; accountName = "New IMAP Account"; ssl = false; + connectionType = 1; type = "IMAP"; port = IMAP_PORT; } @@ -203,6 +206,7 @@ POP3account::POP3account() file = POP3account::getUniqueFileName(); accountName = "New POP3 Account"; ssl = false; + connectionType = 1; type = "POP3"; port = POP3_PORT; } @@ -213,6 +217,7 @@ POP3account::POP3account( QString filename ) file = filename; accountName = "New POP3 Account"; ssl = false; + connectionType = 1; type = "POP3"; port = POP3_PORT; } @@ -240,6 +245,7 @@ void POP3account::read() server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); + connectionType = conf->readNumEntry( "ConnectionType" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); offline = conf->readBoolEntry("Offline",false); @@ -257,6 +263,7 @@ void POP3account::save() conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); + conf->writeEntry( "ConnectionType", connectionType ); conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); conf->writeEntry( "Offline",offline); 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 @@ -31,6 +31,10 @@ public: void setSSL( bool b ) { ssl = b; } 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;} @@ -41,6 +45,7 @@ public: protected: QString accountName, type, server, port, user, password; 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 @@ -11,7 +11,7 @@ <rect> <x>0</x> <y>0</y> - <width>236</width> + <width>232</width> <height>320</height> </rect> </property> @@ -25,103 +25,315 @@ <property> <name>layoutSpacing</name> </property> - <grid> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout12</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>3</x> + <y>3</y> + <width>226</width> + <height>32</height> + </rect> + </property> + <hbox> <property stdset="1"> <name>margin</name> - <number>4</number> + <number>0</number> </property> <property stdset="1"> <name>spacing</name> - <number>3</number> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>accountLabel</cstring> </property> - <widget row="6" column="1" > + <property stdset="1"> + <name>text</name> + <string>Account</string> + </property> + </widget> + <widget> <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>userLine</cstring> + <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 row="7" column="0" > + <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>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <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>passLabel</cstring> + <cstring>serverLabel</cstring> </property> <property stdset="1"> <name>text</name> - <string>Password</string> + <string>Server</string> </property> </widget> - <widget row="7" column="1" > - <class>QLineEdit</class> + <widget> + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>passLine</cstring> + <cstring>portLabel</cstring> </property> <property stdset="1"> - <name>echoMode</name> - <enum>Password</enum> + <name>text</name> + <string>Port</string> </property> </widget> - <widget row="3" column="1" > + </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>portLine</cstring> + <cstring>serverLine</cstring> </property> </widget> - <widget row="2" column="1" > + <widget> <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>serverLine</cstring> + <cstring>portLine</cstring> </property> </widget> - <widget row="2" column="0" > + </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>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> + <cstring>TextLabel1</cstring> </property> <property stdset="1"> <name>text</name> - <string>Server</string> + <string>Use secure sockets:</string> </property> </widget> - <widget row="4" column="1" > - <class>QCheckBox</class> + <widget> + <class>QComboBox</class> <property stdset="1"> <name>name</name> - <cstring>sslBox</cstring> + <cstring>ComboBox1</cstring> </property> + </widget> + </vbox> + </widget> + <widget> + <class>QLayoutWidget</class> <property stdset="1"> - <name>text</name> - <string>Use SSL</string> + <name>name</name> + <cstring>Layout6</cstring> </property> - </widget> - <widget row="3" column="0" > + <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>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <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>portLabel</cstring> + <cstring>userLabel</cstring> </property> <property stdset="1"> <name>text</name> - <string>Port</string> + <string>User</string> </property> </widget> - <widget row="6" column="0" > + <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>userLabel</cstring> + <cstring>passLabel</cstring> </property> <property stdset="1"> <name>text</name> - <string>User</string> + <string>Password</string> </property> </widget> - <spacer row="8" column="1" > + </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> @@ -142,57 +354,51 @@ </size> </property> </spacer> - <widget row="5" column="0" rowspan="1" colspan="2" > - <class>Line</class> + <widget> + <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>line2</cstring> + <cstring>CommandEdit</cstring> </property> <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - </widget> - <widget row="0" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>accountLabel</cstring> + <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>Account</string> + <string>ssh $SERVER exec imapd</string> </property> </widget> - <widget row="0" column="1" > - <class>QLineEdit</class> + <widget> + <class>Line</class> <property stdset="1"> <name>name</name> - <cstring>accountLine</cstring> - </property> - <property> - <name>toolTip</name> - <string>Name of the Account</string> + <cstring>line2</cstring> </property> - </widget> - <widget row="1" column="0" rowspan="1" colspan="2" > - <class>Line</class> <property stdset="1"> - <name>name</name> - <cstring>line1</cstring> + <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> - </grid> </widget> <tabstops> <tabstop>accountLine</tabstop> <tabstop>serverLine</tabstop> <tabstop>portLine</tabstop> - <tabstop>sslBox</tabstop> <tabstop>userLine</tabstop> <tabstop>passLine</tabstop> </tabstops> |