-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 21 | ||||
-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 | 36 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 2 |
5 files changed, 129 insertions, 91 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 @@ -257,53 +257,62 @@ void SelectMailType::slotSelection( const QString &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 ) { - 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 ); } } 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 ) 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 @@ -70,25 +70,25 @@ private: 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: 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 @@ -2,94 +2,54 @@ <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> + <number>3</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> - </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" > @@ -101,142 +61,199 @@ <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 @@ -71,26 +71,36 @@ void IMAPwrapper::login() } 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 { @@ -360,25 +370,25 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); if (addresslist.count()) { m->setReplyto(addresslist.first()); } } m->setMsgid(QString(head->env_message_id)); } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { #if 0 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; 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; } } /* msg is already deleted */ if (mFlags.testBit(FLAG_DELETED) && m) { delete m; m = 0; } if (m) { m->setFlags(mFlags); m->setMsgsize(size); @@ -399,25 +409,25 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) mailimap_body*body_desc = 0; mb = mail.getMbox().latin1(); login(); if (!m_imap) { return body; } err = selectMbox(mail.getMbox()); 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(); fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 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; mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; @@ -486,65 +496,65 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> login(); if (!m_imap) { return res; } if (!internal_call) { err = selectMbox(mail.getMbox()); if ( err != MAILIMAP_NO_ERROR ) { return res; } } 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 <id> (body[])" statement on imap server */ if (path.count()>0 ) { id_list = clist_new(); for (unsigned j=0; j < path.count();++j) { uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); *p_id = path[j]; clist_append(id_list,p_id); } 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; mailimap_msg_att_item*msg_att_item; for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { msg_att_item = (mailimap_msg_att_item*)clist_content(cur); if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; /* detach - we take over the content */ msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; 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); } if (result) mailimap_fetch_list_free(result); return res; } /* current_recursion is for recursive calls. current_count means the position inside the internal loop! */ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, int current_recursion,QValueList<int>recList,int current_count) { @@ -655,41 +665,41 @@ void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text fillBodyFields(target_part,which->bd_fields); } void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) { if (!which) { return; } target_part.setSubtype("rfc822"); 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()); if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { clistcell*cur = 0; mailimap_single_body_fld_param*param=0; for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { param = (mailimap_single_body_fld_param*)cur->data; if (param) { target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); } - } + } } } void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) { if (!which) { return; } QString type,sub; switch (which->bd_media_basic->med_type) { case MAILIMAP_MEDIA_BASIC_APPLICATION: type = "application"; 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 @@ -155,46 +155,48 @@ QString IMAPaccount::getUniqueFileName() } 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; |