From a6e809fb0552b2fd6e095289e1fa90b7f3f4e748 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Mon, 9 Nov 2009 23:22:07 +0000 Subject: [PATCH] when sending to multiple recipients with encryption, use the right headers svn path=/branches/work/akonadi-ports/kdepim/; revision=1046925 --- newcomposerwin.cpp | 49 +++++++++++++++++++++++++--------------------- newcomposerwin.h | 6 +++++- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/newcomposerwin.cpp b/newcomposerwin.cpp index b89b90a43..feb521396 100644 --- a/newcomposerwin.cpp +++ b/newcomposerwin.cpp @@ -2371,16 +2371,15 @@ void KMComposeWin::slotAutoSaveComposeResult( KJob *job ) void KMComposeWin::queueMessage( KMime::Message::Ptr message ) { - using Message::InfoPart; Q_ASSERT( mComposer ); - const InfoPart *infoPart = mComposer->infoPart(); + const Message::InfoPart *infoPart = mComposer->infoPart(); MailTransport::MessageQueueJob *qjob = new MailTransport::MessageQueueJob( this ); qjob->setMessage( message ); qjob->setTransportId( infoPart->transportId() ); // TODO dispatch mode. // TODO sent-mail collection - fillQueueJobHeaders( qjob, message ); + fillQueueJobHeaders( qjob, message, infoPart ); connect( qjob, SIGNAL(result(KJob*)), this, SLOT(slotQueueResult(KJob*)) ); mPendingQueueJobs++; @@ -2389,29 +2388,35 @@ void KMComposeWin::queueMessage( KMime::Message::Ptr message ) kDebug() << "Queued a message."; } -void KMComposeWin::fillQueueJobHeaders( MailTransport::MessageQueueJob* qjob, KMime::Message::Ptr message ) +void KMComposeWin::fillQueueJobHeaders( MailTransport::MessageQueueJob* qjob, KMime::Message::Ptr message, const Message::InfoPart* infoPart ) { - QStringList to, cc, bcc; - foreach( QByteArray address, message->to()->addresses() ) { - to << QString::fromUtf8( address ); - } + qjob->setFrom( infoPart->from() ); + + if( mEncryptAction->isChecked() && !infoPart->bcc().isEmpty() ) // have to deal with multiple message contents + { + // if the bcc isn't empty, then we send it to the bcc because this is the bcc-only encrypted body + if( !message->bcc()->addresses().isEmpty() ) { + QStringList bcc; + foreach( QByteArray address, message->bcc()->addresses() ) { + bcc << QString::fromUtf8( address ); + } + kDebug() << "sending with-bcc encr mail to a secondary recipient:" << bcc; + qjob->setTo( bcc ); + } else { + // the main mail in the encrypted set, just don't set the bccs here + qjob->setTo( infoPart->to() ); + qjob->setCc( infoPart->cc() ); - foreach( QByteArray address, message->cc()->addresses() ) { - cc << QString::fromUtf8( address ); - } + kDebug() << "sending with-bcc encrypted mail to orig recipients:" <to() << infoPart->cc(); - foreach( QByteArray address, message->bcc()->addresses() ) { - bcc << QString::fromUtf8( address ); + } + } else { + // continue as normal + kDebug() << "no bccs"; + qjob->setTo( infoPart->to() ); + qjob->setCc( infoPart->cc() ); + qjob->setBcc( infoPart->bcc() ); } - - // NOTE what to do if there is more than one From address? - // it is supported in KMime::Headers::From, but not in the MessageQueueJob - qjob->setFrom( QString::fromUtf8( message->from()->addresses().first() ) ); - - qjob->setTo( to ); - qjob->setCc( cc ); - qjob->setBcc( bcc ); - } void KMComposeWin::slotQueueResult( KJob *job ) diff --git a/newcomposerwin.h b/newcomposerwin.h index 2ec4277db..538e7b0a2 100644 --- a/newcomposerwin.h +++ b/newcomposerwin.h @@ -128,6 +128,10 @@ namespace MailTransport{ class MessageQueueJob; } +namespace Message { + class InfoPart; +} + //----------------------------------------------------------------------------- class KMComposeWin : public KMail::Composer { @@ -768,7 +772,7 @@ class KMComposeWin : public KMail::Composer /** * Fills in headers for message going into queue. Just sets from/to/bcc/cc */ - void fillQueueJobHeaders( MailTransport::MessageQueueJob* qjob, KMime::Message::Ptr message ); + void fillQueueJobHeaders( MailTransport::MessageQueueJob* qjob, KMime::Message::Ptr message, const Message::InfoPart* infoPart ); private slots: void slotCompletionModeChanged( KGlobalSettings::Completion );