From 696a2dcfcb65fbb24b709bbae0a18a7854e2d72c Mon Sep 17 00:00:00 2001 From: alwin Date: Sun, 28 Dec 2003 17:32:43 +0000 Subject: reduced to the max... - from address isn't setup any longer within the smtp account (it makes realy no sense, a smtp account describes the connection to a smtp server, not the identity of the sender) - from address is taken from the personal info of the addressbook (thats why this info exists). Of course the user can change it when sending an email. - user can select a from with a selection of the mails given in their personal infos. - in addresspicker: use " " instead of "Filename" - settings ui: switched of the part within the smtp accounts describing the identitiy of user ToDo: a dialog setting up a default signature --- diff --git a/noncore/net/mail/addresspicker.cpp b/noncore/net/mail/addresspicker.cpp index 581de62..7857870 100644 --- a/noncore/net/mail/addresspicker.cpp +++ b/noncore/net/mail/addresspicker.cpp @@ -33,7 +33,7 @@ AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFl if ((*it).defaultEmail().length()!=0) { mails = (*it).emailList(); if ((*it).fileAs().length()>0) { - pre = "\""+(*it).fileAs()+"\" <"; + pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <"; suf = ">"; } else { pre = ""; diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index 73d1a43..13c7900 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "composemail.h" #include "smtpwrapper.h" @@ -12,6 +14,26 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m { settings = s; + QString vfilename = Global::applicationFileName("addressbook", + "businesscard.vcf"); + Contact c; + if (QFile::exists(vfilename)) { + c = Contact::readVCard( vfilename )[0]; + } + + QStringList mails = c.emailList(); + QString defmail = c.defaultEmail(); + + if (defmail.length()!=0) { + fromBox->insertItem(defmail); + } + QStringList::ConstIterator sit = mails.begin(); + for (;sit!=mails.end();++sit) { + if ( (*sit)==defmail) + continue; + fromBox->insertItem((*sit)); + } + senderNameEdit->setText(c.firstName()+" "+c.lastName()); Config cfg( "mail" ); cfg.setGroup( "Compose" ); checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); @@ -20,17 +42,18 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m attList->addColumn( tr( "Size" ) ); QList accounts = settings->getAccounts(); + Account *it; for ( it = accounts.first(); it; it = accounts.next() ) { if ( it->getType().compare( "SMTP" ) == 0 ) { SMTPaccount *smtp = static_cast(it); - fromBox->insertItem( smtp->getMail() ); + smtpAccountBox->insertItem( smtp->getAccountName() ); smtpAccounts.append( smtp ); } } if ( smtpAccounts.count() > 0 ) { - fillValues( fromBox->currentItem() ); + fillValues( smtpAccountBox->currentItem() ); } else { QMessageBox::information( this, tr( "Problem" ), tr( "

Please create an SMTP account first.

" ), @@ -38,7 +61,7 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m return; } - connect( fromBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); + connect( smtpAccountBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); @@ -108,8 +131,8 @@ void ComposeMail::pickAddressReply() void ComposeMail::fillValues( int current ) { +#if 0 SMTPaccount *smtp = smtpAccounts.at( current ); - ccLine->clear(); if ( smtp->getUseCC() ) { ccLine->setText( smtp->getCC() ); @@ -122,8 +145,8 @@ void ComposeMail::fillValues( int current ) if ( smtp->getUseReply() ) { replyLine->setText( smtp->getReply() ); } - sigMultiLine->setText( smtp->getSignature() ); +#endif } void ComposeMail::slotAdjustColumns() @@ -163,14 +186,14 @@ void ComposeMail::accept() qDebug( "Send later" ); } - +#if 0 qDebug( "Sending Mail with " + - smtpAccounts.at( fromBox->currentItem() )->getAccountName() ); + smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); +#endif Mail *mail = new Mail(); - SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() ); - mail->setMail( smtp->getMail() ); - mail->setName( smtp->getName() ); + SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); + mail->setMail(fromBox->currentText()); if ( !toLine->text().isEmpty() ) { mail->setTo( toLine->text() ); @@ -178,7 +201,7 @@ void ComposeMail::accept() qDebug( "No Reciever spezified -> returning" ); return; } - + mail->setName(senderNameEdit->text()); mail->setCC( ccLine->text() ); mail->setBCC( bccLine->text() ); mail->setReply( replyLine->text() ); @@ -188,6 +211,7 @@ void ComposeMail::accept() txt.append( "\n--\n" ); txt.append( sigMultiLine->text() ); } + qDebug(txt); mail->setMessage( txt ); AttachViewItem *it = (AttachViewItem *) attList->firstChild(); while ( it != NULL ) { @@ -196,8 +220,8 @@ void ComposeMail::accept() } SMTPwrapper wrapper( settings ); - wrapper.sendMail( *mail,checkBoxLater->isChecked() ); - + wrapper.sendMail( *mail,smtp,checkBoxLater->isChecked() ); + QDialog::accept(); } diff --git a/noncore/net/mail/composemailui.ui b/noncore/net/mail/composemailui.ui index 4d225e4..aebdf67 100644 --- a/noncore/net/mail/composemailui.ui +++ b/noncore/net/mail/composemailui.ui @@ -11,7 +11,7 @@ 0 0 - 260 + 252 360 @@ -28,22 +28,67 @@ margin - 3 + 1 spacing - 3 + 1 - QCheckBox + QLayoutWidget name - checkBoxLater + Layout4 - - text - send later + + layoutSpacing + + + margin + 0 + + + spacing + 3 + + + QCheckBox + + name + checkBoxLater + + + text + send later + + + + QLabel + + name + accountLabel + + + text + use: + + + + QComboBox + + name + smtpAccountBox + + + sizePolicy + + 3 + 0 + + + + QTabWidget @@ -67,77 +112,174 @@ title Mail - + margin - -1 + 1 spacing - -1 + 1 - - QLineEdit + + QLayoutWidget name - subjectLine + Layout10 + + layoutSpacing + + + + margin + 0 + + + spacing + 1 + + + QLayoutWidget + + name + Layout9 + + + layoutSpacing + + + + margin + 0 + + + spacing + 3 + + + QComboBox + + name + fromBox + + + sizePolicy + + 3 + 0 + + + + editable + true + + + duplicatesEnabled + false + + + + QLineEdit + + name + senderNameEdit + + + sizePolicy + + 0 + 0 + + + + minimumSize + + 70 + 0 + + + + maximumSize + + 70 + 32767 + + + + + + + QLineEdit + + name + subjectLine + + + sizePolicy + + 3 + 0 + + + + + QLineEdit + + name + toLine + + + sizePolicy + + 3 + 0 + + + + + QLabel + + name + subjectLabel + + + text + Subject + + + + QLabel + + name + fromLabel + + + text + From + + + + QPushButton + + name + toButton + + + text + To + + + - + QMultiLineEdit name message - - QLabel - - name - subjectLabel - - - text - Subject - - - - QLabel - - name - fromLabel - - - text - From - - - - QLineEdit - - name - toLine - - - - QComboBox - - name - fromBox - - - - QPushButton - - name - toButton - - - text - To - - - + QWidget diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index 1246037..de36e0d 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp @@ -355,9 +355,6 @@ SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, { data = account; - connect( ccBox, SIGNAL( toggled( bool ) ), ccLine, SLOT( setEnabled( bool ) ) ); - connect( bccBox, SIGNAL( toggled( bool ) ), bccLine, SLOT( setEnabled( bool ) ) ); - connect( replyBox, SIGNAL( toggled( bool ) ), replyLine, SLOT( setEnabled( bool ) ) ); connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); @@ -384,16 +381,6 @@ void SMTPconfig::fillValues() loginBox->setChecked( data->getLogin() ); userLine->setText( data->getUser() ); passLine->setText( data->getPassword() ); - nameLine->setText( data->getName() ); - mailLine->setText( data->getMail() ); - orgLine->setText( data->getOrg() ); - ccBox->setChecked( data->getUseCC() ); - ccLine->setText( data->getCC() ); - bccBox->setChecked( data->getUseBCC() ); - bccLine->setText( data->getBCC() ); - replyBox->setChecked( data->getUseReply() ); - replyLine->setText( data->getReply() ); - sigMultiLine->setText( data->getSignature() ); } void SMTPconfig::accept() @@ -405,16 +392,6 @@ void SMTPconfig::accept() data->setLogin( loginBox->isChecked() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); - data->setName( nameLine->text() ); - data->setMail( mailLine->text() ); - data->setOrg( orgLine->text() ); - data->setCC( ccLine->text() ); - data->setUseCC( ccBox->isChecked() ); - data->setBCC( bccLine->text() ); - data->setUseBCC( bccBox->isChecked() ); - data->setReply( replyLine->text() ); - data->setUseReply( replyBox->isChecked() ); - data->setSignature( sigMultiLine->text() ); QDialog::accept(); } diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index b580954..17aa1b0 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp @@ -273,9 +273,6 @@ SMTPaccount::SMTPaccount( QString filename ) accountName = "New SMTP Account"; ssl = false; login = false; - useCC = false; - useBCC = false; - useReply = false; type = "SMTP"; port = SMTP_PORT; } @@ -306,17 +303,6 @@ void SMTPaccount::read() login = conf->readBoolEntry( "Login" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); - useCC = conf->readBoolEntry( "useCC" ); - useBCC = conf->readBoolEntry( "useBCC" ); - useReply = conf->readBoolEntry( "useReply" ); - name = conf->readEntry( "Name" ); - mail = conf->readEntry( "Mail" ); - org = conf->readEntry( "Org" ); - cc = conf->readEntry( "CC" ); - bcc = conf->readEntry( "BCC" ); - reply = conf->readEntry( "Reply" ); - signature = conf->readEntry( "Signature" ); - signature = signature.replace( QRegExp( "
" ), "\n" ); } void SMTPaccount::save() @@ -333,17 +319,6 @@ void SMTPaccount::save() conf->writeEntry( "Login", login ); conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); - conf->writeEntry( "useCC", useCC ); - conf->writeEntry( "useBCC", useBCC ); - conf->writeEntry( "useReply", useReply ); - conf->writeEntry( "Name", name ); - conf->writeEntry( "Mail", mail ); - conf->writeEntry( "Org", org ); - conf->writeEntry( "CC", cc ); - conf->writeEntry( "BCC", bcc ); - conf->writeEntry( "Reply", reply ); - conf->writeEntry( "Signature", - signature.replace( QRegExp( "\\n" ), "
" ) ); conf->write(); } diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h index 22184a5..caa5dfc 100644 --- a/noncore/net/mail/libmailwrapper/settings.h +++ b/noncore/net/mail/libmailwrapper/settings.h @@ -93,26 +93,6 @@ public: virtual void save(); virtual QString getFileName(); - void setName( QString str ) { name = str; } - QString getName() { return name; } - void setMail( QString str ) { mail = str; } - QString getMail() { return mail; } - void setOrg( QString str ) { org = str; } - QString getOrg() { return org; } - void setUseCC( bool b ) { useCC = b; } - bool getUseCC() { return useCC; } - void setCC( QString str ) { cc = str; } - QString getCC() { return cc; } - void setUseBCC( bool b ) { useBCC = b; } - bool getUseBCC() { return useBCC; } - void setBCC( QString str ) { bcc = str; } - QString getBCC() { return bcc; } - void setUseReply( bool b ) { useReply = b; } - bool getUseReply() { return useReply; } - void setReply( QString str ) { reply = str; } - QString getReply() { return reply; } - void setSignature( QString str ) { signature = str; } - QString getSignature() { return signature; } void setLogin( bool b ) { login = b; } bool getLogin() { return login; } diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index 521cd0a..30c0707 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp @@ -128,9 +128,9 @@ mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { mailimf_fields *fields; mailimf_field *xmailer; - mailimf_mailbox *sender, *fromBox; - mailimf_mailbox_list *from; - mailimf_address_list *to, *cc, *bcc, *reply; + mailimf_mailbox *sender=0,*fromBox=0; + mailimf_mailbox_list *from=0; + mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; char *subject = strdup( mail.getSubject().latin1() ); int err; @@ -167,22 +167,22 @@ mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) return fields; // Success :) err_free_xmailer: - mailimf_field_free( xmailer ); + if (xmailer) mailimf_field_free( xmailer ); err_free_fields: - mailimf_fields_free( fields ); + if (fields) mailimf_fields_free( fields ); err_free_reply: - mailimf_address_list_free( reply ); - mailimf_address_list_free( bcc ); - mailimf_address_list_free( cc ); - mailimf_address_list_free( to ); + if (reply) mailimf_address_list_free( reply ); + if (bcc) mailimf_address_list_free( bcc ); + if (cc) mailimf_address_list_free( cc ); + if (to) mailimf_address_list_free( to ); err_free_from: - mailimf_mailbox_list_free( from ); + if (from) mailimf_mailbox_list_free( from ); err_free_fromBox: mailimf_mailbox_free( fromBox ); err_free_sender: - mailimf_mailbox_free( sender ); + if (sender) mailimf_mailbox_free( sender ); err_free: - free( subject ); + if (subject) free( subject ); qDebug( "createImfFields - error" ); return NULL; // Error :( @@ -206,7 +206,7 @@ mailmime *SMTPwrapper::buildTxtPart(const QString&str ) err = clist_append( content->ct_parameters, param ); if ( err != MAILIMF_NO_ERROR ) goto err_free_content; - fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_QUOTED_PRINTABLE); + fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); if ( fields == NULL ) goto err_free_content; txtPart = mailmime_new_empty( content, fields ); @@ -462,26 +462,6 @@ char *SMTPwrapper::getFrom( mailmime *mail ) return getFrom(ffrom); } -SMTPaccount *SMTPwrapper::getAccount(const QString&name ) -{ - SMTPaccount *smtp; - - QList list = settings->getAccounts(); - Account *it; - for ( it = list.first(); it; it = list.next() ) { - if ( it->getType().compare( "SMTP" ) == 0 ) { - smtp = static_cast(it); - if ( smtp->getName()== name ) { - qDebug( "SMTPaccount found for" ); - qDebug( name ); - return smtp; - } - } - } - - return NULL; -} - void SMTPwrapper::progress( size_t current, size_t maximum ) { if (SMTPwrapper::sendProgress) { @@ -613,12 +593,16 @@ free_mem: return result; } -void SMTPwrapper::sendMail(const Mail&mail,bool later ) +void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) { mailmime * mimeMail; - SMTPaccount *smtp = getAccount(mail.getName()); + SMTPaccount *smtp = aSmtp; + if (!later && !smtp) { + qDebug("Didn't get any send method - giving up"); + return; + } mimeMail = createMimeMail(mail ); if ( mimeMail == NULL ) { qDebug( "sendMail: error creating mime mail" ); diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h index f734fa4..0535983 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.h +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h @@ -27,7 +27,7 @@ class SMTPwrapper : public QObject public: SMTPwrapper( Settings *s ); virtual ~SMTPwrapper(){} - void sendMail(const Mail& mail,bool later=false ); + void sendMail(const Mail& mail,SMTPaccount*smtp,bool later=false ); bool flushOutbox(SMTPaccount*smtp); static progressMailSend*sendProgress; @@ -42,7 +42,6 @@ protected: mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); clist *createRcptList( mailimf_fields *fields ); - SMTPaccount *getAccount(const QString&from ); static void storeMail(char*mail, size_t length, const QString&box); static QString mailsmtpError( int err ); diff --git a/noncore/net/mail/settings.cpp b/noncore/net/mail/settings.cpp index b580954..17aa1b0 100644 --- a/noncore/net/mail/settings.cpp +++ b/noncore/net/mail/settings.cpp @@ -273,9 +273,6 @@ SMTPaccount::SMTPaccount( QString filename ) accountName = "New SMTP Account"; ssl = false; login = false; - useCC = false; - useBCC = false; - useReply = false; type = "SMTP"; port = SMTP_PORT; } @@ -306,17 +303,6 @@ void SMTPaccount::read() login = conf->readBoolEntry( "Login" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); - useCC = conf->readBoolEntry( "useCC" ); - useBCC = conf->readBoolEntry( "useBCC" ); - useReply = conf->readBoolEntry( "useReply" ); - name = conf->readEntry( "Name" ); - mail = conf->readEntry( "Mail" ); - org = conf->readEntry( "Org" ); - cc = conf->readEntry( "CC" ); - bcc = conf->readEntry( "BCC" ); - reply = conf->readEntry( "Reply" ); - signature = conf->readEntry( "Signature" ); - signature = signature.replace( QRegExp( "
" ), "\n" ); } void SMTPaccount::save() @@ -333,17 +319,6 @@ void SMTPaccount::save() conf->writeEntry( "Login", login ); conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); - conf->writeEntry( "useCC", useCC ); - conf->writeEntry( "useBCC", useBCC ); - conf->writeEntry( "useReply", useReply ); - conf->writeEntry( "Name", name ); - conf->writeEntry( "Mail", mail ); - conf->writeEntry( "Org", org ); - conf->writeEntry( "CC", cc ); - conf->writeEntry( "BCC", bcc ); - conf->writeEntry( "Reply", reply ); - conf->writeEntry( "Signature", - signature.replace( QRegExp( "\\n" ), "
" ) ); conf->write(); } diff --git a/noncore/net/mail/settings.h b/noncore/net/mail/settings.h index 22184a5..caa5dfc 100644 --- a/noncore/net/mail/settings.h +++ b/noncore/net/mail/settings.h @@ -93,26 +93,6 @@ public: virtual void save(); virtual QString getFileName(); - void setName( QString str ) { name = str; } - QString getName() { return name; } - void setMail( QString str ) { mail = str; } - QString getMail() { return mail; } - void setOrg( QString str ) { org = str; } - QString getOrg() { return org; } - void setUseCC( bool b ) { useCC = b; } - bool getUseCC() { return useCC; } - void setCC( QString str ) { cc = str; } - QString getCC() { return cc; } - void setUseBCC( bool b ) { useBCC = b; } - bool getUseBCC() { return useBCC; } - void setBCC( QString str ) { bcc = str; } - QString getBCC() { return bcc; } - void setUseReply( bool b ) { useReply = b; } - bool getUseReply() { return useReply; } - void setReply( QString str ) { reply = str; } - QString getReply() { return reply; } - void setSignature( QString str ) { signature = str; } - QString getSignature() { return signature; } void setLogin( bool b ) { login = b; } bool getLogin() { return login; } diff --git a/noncore/net/mail/smtpconfigui.ui b/noncore/net/mail/smtpconfigui.ui index 2cae8d6..f5ce8cb 100644 --- a/noncore/net/mail/smtpconfigui.ui +++ b/noncore/net/mail/smtpconfigui.ui @@ -11,8 +11,8 @@ 0 0 - 253 - 342 + 241 + 321 @@ -28,453 +28,225 @@ margin - 0 + 2 spacing - 0 + 2 - QTabWidget + QLayoutWidget name - smtpTab - - - caption - - - - layoutMargin + Layout4 layoutSpacing - - QWidget + - name - serverTab + margin + 0 - - title - Server - - + + spacing + 2 + + + QLabel - margin - 4 + name + accountLabel - spacing - 3 + text + Account + + + + QLineEdit + + name + passLine + + + enabled + false + + + echoMode + Password + + + + QCheckBox + + name + sslBox + + + text + Use SSL + + + + QCheckBox + + name + loginBox + + + text + Use Login + + + + QLineEdit + + name + accountLine + + + toolTip + Name of the Account + + + + QLineEdit + + name + serverLine + + + toolTip + Name of the SMTP Server + + + + QLineEdit + + name + userLine + + + enabled + false + + + + QLabel + + name + passLabel - - QLabel - - name - portLabel - - - text - Port - - - - QLineEdit - - name - serverLine - - - toolTip - Name of the SMTP Server - - - - QLabel - - name - serverLabel - - - text - Server - - - - QLineEdit - - name - portLine - - - toolTip - Port of the SMTP Server - - - - QLabel - - name - accountLabel - - - text - Account - - - - QLineEdit - - name - accountLine - - - toolTip - Name of the Account - - - - Line - - name - line1 - - - orientation - Horizontal - - - - QCheckBox - - name - sslBox - - - text - Use SSL - - - - Line - - name - line2 - - - orientation - Horizontal - - - - QLineEdit - - name - passLine - - - enabled - false - - - echoMode - Password - - - - QCheckBox - - name - loginBox - - - text - Use Login - - - - QLabel - - name - passLabel - - - text - Password - - - - QLabel - - name - userLabel - - - text - User - - - - QLineEdit - - name - userLine - - - enabled - false - - - - - name - spacer - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - - - QWidget - - name - identityTab - - - title - Identity - - - margin - 4 + text + Password + + + QLabel - spacing - 3 + name + portLabel - - QMultiLineEdit - - name - sigMultiLine - - - - - name - Spacer3 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - toolTip - Name of the Account - - - - QLabel - - name - sigLabel - - - text - Signature - - - - QLineEdit - - name - replyLine - - - enabled - false - - - - QLineEdit - - name - bccLine - - - enabled - false - - - - QLineEdit - - name - ccLine - - - enabled - false - - - - QCheckBox - - name - bccBox - - - text - BCC - - - - QCheckBox - - name - replyBox - - - text - Reply-To - - - - QCheckBox - - name - ccBox - - - text - CC - - - - QLabel - - name - mailLabel - - - text - E-Mail - - - - QLineEdit - - name - nameLine - - - toolTip - Your Full Name - - - - QLabel - - name - nameLabel - - - text - Name - - - - QLabel - - name - orgLabel - - - text - Org. - - - layoutMargin - - - layoutSpacing - - - - QLineEdit - - name - orgLine - - - toolTip - Your Organisation - - - - QLineEdit - - name - mailLine - - - toolTip - Your E-Mail Adress - - - - Line - - name - line3 - - - orientation - Horizontal - - - - Line - - name - line4 - - - orientation - Horizontal - - - - + + text + Port + + + + QLabel + + name + serverLabel + + + text + Server + + + + QLineEdit + + name + portLine + + + toolTip + Port of the SMTP Server + + + + Line + + name + line1 + + + sizePolicy + + 3 + 0 + + + + orientation + Horizontal + + + + QLabel + + name + userLabel + + + text + User + + + + Line + + name + line2 + + + sizePolicy + + 3 + 0 + + + + orientation + Horizontal + + +
+ + + name + spacer + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + @@ -485,16 +257,5 @@ loginBox userLine passLine - smtpTab - nameLine - mailLine - orgLine - ccBox - ccLine - bccBox - bccLine - replyBox - replyLine - sigMultiLine diff --git a/noncore/net/mail/smtpwrapper.cpp b/noncore/net/mail/smtpwrapper.cpp index 521cd0a..30c0707 100644 --- a/noncore/net/mail/smtpwrapper.cpp +++ b/noncore/net/mail/smtpwrapper.cpp @@ -128,9 +128,9 @@ mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { mailimf_fields *fields; mailimf_field *xmailer; - mailimf_mailbox *sender, *fromBox; - mailimf_mailbox_list *from; - mailimf_address_list *to, *cc, *bcc, *reply; + mailimf_mailbox *sender=0,*fromBox=0; + mailimf_mailbox_list *from=0; + mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; char *subject = strdup( mail.getSubject().latin1() ); int err; @@ -167,22 +167,22 @@ mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) return fields; // Success :) err_free_xmailer: - mailimf_field_free( xmailer ); + if (xmailer) mailimf_field_free( xmailer ); err_free_fields: - mailimf_fields_free( fields ); + if (fields) mailimf_fields_free( fields ); err_free_reply: - mailimf_address_list_free( reply ); - mailimf_address_list_free( bcc ); - mailimf_address_list_free( cc ); - mailimf_address_list_free( to ); + if (reply) mailimf_address_list_free( reply ); + if (bcc) mailimf_address_list_free( bcc ); + if (cc) mailimf_address_list_free( cc ); + if (to) mailimf_address_list_free( to ); err_free_from: - mailimf_mailbox_list_free( from ); + if (from) mailimf_mailbox_list_free( from ); err_free_fromBox: mailimf_mailbox_free( fromBox ); err_free_sender: - mailimf_mailbox_free( sender ); + if (sender) mailimf_mailbox_free( sender ); err_free: - free( subject ); + if (subject) free( subject ); qDebug( "createImfFields - error" ); return NULL; // Error :( @@ -206,7 +206,7 @@ mailmime *SMTPwrapper::buildTxtPart(const QString&str ) err = clist_append( content->ct_parameters, param ); if ( err != MAILIMF_NO_ERROR ) goto err_free_content; - fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_QUOTED_PRINTABLE); + fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); if ( fields == NULL ) goto err_free_content; txtPart = mailmime_new_empty( content, fields ); @@ -462,26 +462,6 @@ char *SMTPwrapper::getFrom( mailmime *mail ) return getFrom(ffrom); } -SMTPaccount *SMTPwrapper::getAccount(const QString&name ) -{ - SMTPaccount *smtp; - - QList list = settings->getAccounts(); - Account *it; - for ( it = list.first(); it; it = list.next() ) { - if ( it->getType().compare( "SMTP" ) == 0 ) { - smtp = static_cast(it); - if ( smtp->getName()== name ) { - qDebug( "SMTPaccount found for" ); - qDebug( name ); - return smtp; - } - } - } - - return NULL; -} - void SMTPwrapper::progress( size_t current, size_t maximum ) { if (SMTPwrapper::sendProgress) { @@ -613,12 +593,16 @@ free_mem: return result; } -void SMTPwrapper::sendMail(const Mail&mail,bool later ) +void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) { mailmime * mimeMail; - SMTPaccount *smtp = getAccount(mail.getName()); + SMTPaccount *smtp = aSmtp; + if (!later && !smtp) { + qDebug("Didn't get any send method - giving up"); + return; + } mimeMail = createMimeMail(mail ); if ( mimeMail == NULL ) { qDebug( "sendMail: error creating mime mail" ); diff --git a/noncore/net/mail/smtpwrapper.h b/noncore/net/mail/smtpwrapper.h index f734fa4..0535983 100644 --- a/noncore/net/mail/smtpwrapper.h +++ b/noncore/net/mail/smtpwrapper.h @@ -27,7 +27,7 @@ class SMTPwrapper : public QObject public: SMTPwrapper( Settings *s ); virtual ~SMTPwrapper(){} - void sendMail(const Mail& mail,bool later=false ); + void sendMail(const Mail& mail,SMTPaccount*smtp,bool later=false ); bool flushOutbox(SMTPaccount*smtp); static progressMailSend*sendProgress; @@ -42,7 +42,6 @@ protected: mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); clist *createRcptList( mailimf_fields *fields ); - SMTPaccount *getAccount(const QString&from ); static void storeMail(char*mail, size_t length, const QString&box); static QString mailsmtpError( int err ); -- cgit v0.9.0.2