-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 19 | ||||
-rw-r--r-- | noncore/net/mail/editaccounts.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/imapconfigui.ui | 159 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 2 |
5 files changed, 116 insertions, 78 deletions
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index 9fc97e8..1cb202e 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp @@ -221,125 +221,134 @@ void EditAccounts::slotAdjustColumns() { int currPage = configTab->currentPageIndex(); configTab->showPage( mailTab ); mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); mailList->setColumnWidth( 1, 50 ); configTab->showPage( newsTab ); newsList->setColumnWidth( 0, newsList->visibleWidth() ); configTab->setCurrentPage( currPage ); } void EditAccounts::accept() { settings->saveAccounts(); QDialog::accept(); } /** * SelectMailType */ SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) : SelectMailTypeUI( parent, name, modal, flags ) { selected = selection; selected->replace( 0, selected->length(), typeBox->currentText() ); connect( typeBox, SIGNAL( activated( const QString & ) ), SLOT( slotSelection( const QString & ) ) ); } void SelectMailType::slotSelection( const QString &sel ) { selected->replace( 0, selected->length(), sel ); } /** * IMAPconfig */ IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) : IMAPconfigUI( parent, name, modal, flags ) { 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 IMAPconfig::slotSSL( bool enabled ) +void IMAPconfig::slotConnectionToggle( int index ) { - if ( enabled ) { + if ( index == 2 ) { portLine->setText( IMAP_SSL_PORT ); + } else if ( index == 3 ) { + portLine->setText( IMAP_PORT ); + CommandEdit->show(); } else { portLine->setText( IMAP_PORT ); } } void IMAPconfig::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() ); prefixLine->setText(data->getPrefix()); } void IMAPconfig::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() ); data->setPrefix(prefixLine->text()); QDialog::accept(); } /** * POP3config */ POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) : POP3configUI( parent, name, modal, flags ) { data = account; fillValues(); 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::slotConnectionToggle( int index ) { // 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 ); } } void POP3config::fillValues() { accountLine->setText( data->getAccountName() ); serverLine->setText( data->getServer() ); portLine->setText( data->getPort() ); ComboBox1->setCurrentItem( data->ConnectionType() ); userLine->setText( data->getUser() ); passLine->setText( data->getPassword() ); } diff --git a/noncore/net/mail/editaccounts.h b/noncore/net/mail/editaccounts.h index d51e299..d8e1219 100644 --- a/noncore/net/mail/editaccounts.h +++ b/noncore/net/mail/editaccounts.h @@ -34,97 +34,97 @@ public: public slots: void slotNewAccount( const QString &type ); void slotEditAccount( Account *account ); void slotDeleteAccount( Account * account ); void slotAdjustColumns(); protected slots: void slotFillLists(); void slotNewMail(); void slotEditMail(); void slotDeleteMail(); void slotNewNews(); void slotEditNews(); void slotDeleteNews(); void accept(); private: Settings *settings; }; class SelectMailType : public SelectMailTypeUI { Q_OBJECT public: SelectMailType( QString *selection = 0, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); private slots: void slotSelection( const QString &sel ); private: QString *selected; }; class IMAPconfig : public IMAPconfigUI { Q_OBJECT public: IMAPconfig( IMAPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); public slots: void fillValues(); protected slots: - void slotSSL( bool enabled ); + void slotConnectionToggle( int index ); void accept(); private: IMAPaccount *data; }; class POP3config : public POP3configUI { Q_OBJECT public: POP3config( POP3account *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); public slots: void fillValues(); protected slots: void slotConnectionToggle( int index ); void accept(); private: POP3account *data; }; class SMTPconfig : public SMTPconfigUI { Q_OBJECT public: SMTPconfig( SMTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); public slots: void fillValues(); protected slots: void slotConnectionToggle( int index ); void accept(); private: SMTPaccount *data; }; class NNTPconfig : public NNTPconfigUI { Q_OBJECT diff --git a/noncore/net/mail/imapconfigui.ui b/noncore/net/mail/imapconfigui.ui index ac0297f..a96c1a2 100644 --- a/noncore/net/mail/imapconfigui.ui +++ b/noncore/net/mail/imapconfigui.ui @@ -1,242 +1,259 @@ <!DOCTYPE UI><UI> <class>IMAPconfigUI</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>IMAPconfigUI</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>228</width> - <height>320</height> + <width>425</width> + <height>428</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Configure IMAP</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <grid> <property stdset="1"> <name>margin</name> <number>3</number> </property> <property stdset="1"> <name>spacing</name> - <number>2</number> - </property> - <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> - <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> + <number>3</number> </property> - </widget> <widget row="2" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>serverLine</cstring> </property> </widget> - <widget row="6" column="1" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>userLine</cstring> - </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="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="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="3" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>portLine</cstring> </property> </widget> - <widget row="7" column="1" > + <widget row="0" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>passLine</cstring> + <cstring>accountLine</cstring> + </property> + <property> + <name>toolTip</name> + <string>Name of the Account</string> </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> <property stdset="1"> - <name>echoMode</name> - <enum>Password</enum> + <name>name</name> + <cstring>accountLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Account</string> + </property> + </widget> + <widget row="1" column="0" rowspan="1" colspan="2" > + <class>Line</class> + <property stdset="1"> + <name>name</name> + <cstring>line1</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> </property> </widget> - <spacer row="10" column="1" > + <spacer row="12" 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="0" column="1" > + <widget row="8" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>accountLine</cstring> - </property> - <property> - <name>toolTip</name> - <string>Name of the Account</string> + <cstring>userLine</cstring> </property> </widget> - <widget row="0" column="0" > - <class>QLabel</class> + <widget row="9" column="1" > + <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>accountLabel</cstring> + <cstring>passLine</cstring> </property> <property stdset="1"> - <name>text</name> - <string>Account</string> + <name>echoMode</name> + <enum>Password</enum> </property> </widget> - <widget row="1" column="0" rowspan="1" colspan="2" > - <class>Line</class> + <widget row="11" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>line1</cstring> + <cstring>prefixLabel</cstring> </property> <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> + <name>text</name> + <string>Prefix</string> </property> </widget> - <widget row="9" column="1" > + <widget row="11" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>prefixLine</cstring> </property> </widget> - <widget row="9" column="0" > + <widget row="8" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>prefixLabel</cstring> + <cstring>userLabel</cstring> </property> <property stdset="1"> <name>text</name> - <string>Prefix</string> + <string>User</string> </property> </widget> - <widget row="5" column="0" rowspan="1" colspan="2" > + <widget row="7" column="0" rowspan="1" colspan="2" > <class>Line</class> <property stdset="1"> <name>name</name> <cstring>line2</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>caption</name> <string></string> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> </widget> - <widget row="8" column="0" rowspan="1" colspan="2" > + <widget row="10" column="0" rowspan="1" colspan="2" > <class>Line</class> <property stdset="1"> <name>name</name> <cstring>Line3</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> </widget> + <widget row="9" 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="6" column="0" rowspan="1" colspan="2" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>CommandEdit</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>ssh $SERVER exec</string> + </property> + </widget> + <widget row="5" column="0" rowspan="1" colspan="2" > + <class>QComboBox</class> + <property stdset="1"> + <name>name</name> + <cstring>ComboBox1</cstring> + </property> + </widget> + <widget row="4" column="0" rowspan="1" colspan="2" > + <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> </grid> </widget> <tabstops> <tabstop>accountLine</tabstop> <tabstop>serverLine</tabstop> <tabstop>portLine</tabstop> - <tabstop>sslBox</tabstop> <tabstop>userLine</tabstop> <tabstop>passLine</tabstop> </tabstops> </UI> diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 4b633ea..1c22c26 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp @@ -35,98 +35,108 @@ int IMAPwrapper::selectMbox(const QString&mbox) m_Lastmbox = mbox; return err; } void IMAPwrapper::imap_progress( size_t current, size_t maximum ) { qDebug( "IMAP: %i of %i", current, maximum ); } void IMAPwrapper::login() { const char *server, *user, *pass; uint16_t port; int err = MAILIMAP_NO_ERROR; if (account->getOffline()) return; /* we are connected this moment */ /* TODO: setup a timer holding the line or if connection closed - delete the value */ if (m_imap) { err = mailimap_noop(m_imap); if (err!=MAILIMAP_NO_ERROR) { logout(); } else { mailstream_flush(m_imap->imap_stream); return; } } server = account->getServer().latin1(); 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( "IMAP: Login canceled" ); return; } } else { user = account->getUser().latin1(); pass = account->getPassword().latin1(); } m_imap = mailimap_new( 20, &imap_progress ); + + /* connect */ - if (account->getSSL()) { + + bool ssl = false; + + if ( account->ConnectionType() == 2 ) { + ssl = true; + } + + if ( ssl ) { + qDebug( "using ssl" ); err = mailimap_ssl_connect( m_imap, (char*)server, port ); } else { err = mailimap_socket_connect( m_imap, (char*)server, port ); } if ( err != MAILIMAP_NO_ERROR && err != MAILIMAP_NO_ERROR_AUTHENTICATED && err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { QString failure = ""; if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { failure="Connection refused"; } else { failure="Unknown failure"; } Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); mailimap_free( m_imap ); m_imap = 0; return; } /* login */ err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); if ( err != MAILIMAP_NO_ERROR ) { Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); err = mailimap_close( m_imap ); mailimap_free( m_imap ); m_imap = 0; } } void IMAPwrapper::logout() { int err = MAILIMAP_NO_ERROR; if (!m_imap) return; err = mailimap_logout( m_imap ); err = mailimap_close( m_imap ); mailimap_free( m_imap ); m_imap = 0; m_Lastmbox = ""; } void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) { int err = MAILIMAP_NO_ERROR; clist *result = 0; clistcell *current; mailimap_fetch_type *fetchType = 0; mailimap_set *set = 0; diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index 7b6a58d..3279f39 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp @@ -119,118 +119,120 @@ void Account::remove() IMAPaccount::IMAPaccount() : Account() { file = IMAPaccount::getUniqueFileName(); accountName = "New IMAP Account"; ssl = false; connectionType = 1; type = "IMAP"; port = IMAP_PORT; } IMAPaccount::IMAPaccount( QString filename ) : Account() { file = filename; accountName = "New IMAP Account"; ssl = false; connectionType = 1; type = "IMAP"; port = IMAP_PORT; } QString IMAPaccount::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 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"; + connectionType = conf->readNumEntry( "ConnectionType" ); ssl = conf->readBoolEntry( "SSL",false ); user = conf->readEntry( "User","" ); if (user.isNull()) user = ""; password = conf->readEntryCrypt( "Password","" ); if (password.isNull()) password = ""; prefix = conf->readEntry("MailPrefix",""); if (prefix.isNull()) prefix = ""; offline = conf->readBoolEntry("Offline",false); delete conf; } void IMAPaccount::save() { qDebug( "saving " + getFileName() ); Settings::checkDirectory(); Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "IMAP Account" ); conf->writeEntry( "Account", accountName ); 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( "MailPrefix",prefix); conf->writeEntry( "Offline",offline); conf->write(); delete conf; } QString IMAPaccount::getFileName() { return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; } POP3account::POP3account() : Account() { file = POP3account::getUniqueFileName(); accountName = "New POP3 Account"; ssl = false; connectionType = 1; type = "POP3"; port = POP3_PORT; } POP3account::POP3account( QString filename ) : Account() { file = filename; accountName = "New POP3 Account"; ssl = false; connectionType = 1; type = "POP3"; port = POP3_PORT; } QString POP3account::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); QStringList imap = dir.entryList( "pop3-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "pop3-" + unique ) > 0 ); |