From 76cf4990cb4171a747ac31e9832f4ee694ced2cc Mon Sep 17 00:00:00 2001 From: harlekin Date: Sat, 10 Jan 2004 00:32:04 +0000 Subject: new connection setting stuff for imap too --- 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 @@ -266,13 +266,22 @@ IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, 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 ) { - portLine->setText( IMAP_SSL_PORT ); + if ( index == 2 ) { + portLine->setText( IMAP_SSL_PORT ); + } else if ( index == 3 ) { + portLine->setText( IMAP_PORT ); + CommandEdit->show(); } else { portLine->setText( IMAP_PORT ); } @@ -283,7 +292,7 @@ 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()); @@ -294,7 +303,7 @@ 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()); 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 @@ -79,7 +79,7 @@ public slots: void fillValues(); protected slots: - void slotSSL( bool enabled ); + void slotConnectionToggle( int index ); void accept(); private: 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 @@ -11,8 +11,8 @@ 0 0 - 228 - 320 + 425 + 428 @@ -32,30 +32,8 @@ spacing - 2 + 3 - - QLabel - - name - userLabel - - - text - User - - - - QCheckBox - - name - sslBox - - - text - Use SSL - - QLineEdit @@ -63,24 +41,6 @@ serverLine - - QLineEdit - - name - userLine - - - - QLabel - - name - passLabel - - - text - Password - - QLabel @@ -110,18 +70,40 @@ portLine - + QLineEdit name - passLine + accountLine + + + toolTip + Name of the Account + + + QLabel - echoMode - Password + name + accountLabel + + + text + Account + + + + Line + + name + line1 + + + orientation + Horizontal - + name spacer @@ -142,58 +124,54 @@ - + QLineEdit name - accountLine - - - toolTip - Name of the Account + userLine - - QLabel + + QLineEdit name - accountLabel + passLine - text - Account + echoMode + Password - - Line + + QLabel name - line1 + prefixLabel - orientation - Horizontal + text + Prefix - + QLineEdit name prefixLine - + QLabel name - prefixLabel + userLabel text - Prefix + User - + Line name @@ -218,7 +196,7 @@ layoutSpacing - + Line name @@ -229,13 +207,52 @@ Horizontal + + QLabel + + name + passLabel + + + text + Password + + + + QLineEdit + + name + CommandEdit + + + text + ssh $SERVER exec + + + + QComboBox + + name + ComboBox1 + + + + QLabel + + name + TextLabel1 + + + text + Use secure sockets: + + accountLine serverLine portLine - sslBox userLine passLine 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 @@ -80,8 +80,18 @@ void IMAPwrapper::login() 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 ); @@ -369,7 +379,7 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); qDebug(da.toString()); -#endif +#endif } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { size = item->att_data.att_static->att_data.att_rfc822_size; } @@ -408,7 +418,7 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) if ( err != MAILIMAP_NO_ERROR ) { return body; } - + /* the range has to start at 1!!! not with 0!!!! */ set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); fetchAtt = mailimap_fetch_att_new_bodystructure(); @@ -495,9 +505,9 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList } } set = mailimap_set_new_single(mail.getNumber()); - + clist*id_list = 0; - + /* if path == empty then its a request for the whole rfc822 mail and generates a "fetch (body[])" statement on imap server */ if (path.count()>0 ) { @@ -510,17 +520,17 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList section_part = mailimap_section_part_new(id_list); section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); } - + section = mailimap_section_new(section_spec); fetch_att = mailimap_fetch_att_new_body_section(section); fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); - + clist*result = 0; - + err = mailimap_fetch( m_imap, set, fetchType, &result ); mailimap_set_free( set ); mailimap_fetch_type_free( fetchType ); - + if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { mailimap_msg_att * msg_att; msg_att = (mailimap_msg_att*)current->data; @@ -535,7 +545,7 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); } } - } + } } else { qDebug("error fetching text: %s",m_imap->imap_response); } @@ -664,11 +674,11 @@ void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*w qDebug("Message part"); /* we set this type to text/plain */ target_part.setLines(which->bd_lines); - fillBodyFields(target_part,which->bd_fields); + fillBodyFields(target_part,which->bd_fields); } void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) -{ +{ if (!which) return; QString sub = which->bd_media_subtype; target_part.setSubtype(sub.lower()); @@ -680,7 +690,7 @@ void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*whi if (param) { target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); } - } + } } } 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 @@ -164,6 +164,7 @@ void IMAPaccount::read() 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 = ""; @@ -186,6 +187,7 @@ void IMAPaccount::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( "MailPrefix",prefix); -- cgit v0.9.0.2