|
|
|
|
@ -31,6 +31,7 @@ |
|
|
|
|
#include <qlayout.h> |
|
|
|
|
#include <qcombobox.h> |
|
|
|
|
#include <qlineedit.h> |
|
|
|
|
#include <qtextcodec.h> |
|
|
|
|
|
|
|
|
|
#include <assert.h> |
|
|
|
|
|
|
|
|
|
@ -1181,12 +1182,70 @@ KMFilterActionForward::KMFilterActionForward() |
|
|
|
|
|
|
|
|
|
KMFilterAction::ReturnCode KMFilterActionForward::process(KMMessage* aMsg) const |
|
|
|
|
{ |
|
|
|
|
KMMessage* msg; |
|
|
|
|
if ( mParameter.isEmpty() ) |
|
|
|
|
return ErrorButGoOn; |
|
|
|
|
|
|
|
|
|
msg = aMsg->createForward(); |
|
|
|
|
// Create the forwarded message by hand to make forwarding of messages with
|
|
|
|
|
// attachments work.
|
|
|
|
|
// Note: This duplicates a lot of code from KMMessage::createForward() and
|
|
|
|
|
// KMComposeWin::applyChanges().
|
|
|
|
|
// ### FIXME: Remove the code duplication again.
|
|
|
|
|
|
|
|
|
|
KMMessage* msg = new KMMessage; |
|
|
|
|
|
|
|
|
|
msg->initFromMessage( aMsg ); |
|
|
|
|
|
|
|
|
|
QString st = QString::fromUtf8( aMsg->createForwardBody() ); |
|
|
|
|
QCString |
|
|
|
|
encoding = KMMsgBase::autoDetectCharset( aMsg->charset(), |
|
|
|
|
KMMessage::preferredCharsets(), |
|
|
|
|
st ); |
|
|
|
|
if( encoding.isEmpty() ) |
|
|
|
|
encoding = "utf-8"; |
|
|
|
|
QCString str = KMMsgBase::codecForName( encoding )->fromUnicode( st ); |
|
|
|
|
|
|
|
|
|
msg->setCharset( encoding ); |
|
|
|
|
msg->setTo( mParameter ); |
|
|
|
|
msg->setSubject( "Fwd: " + aMsg->subject() ); |
|
|
|
|
|
|
|
|
|
bool isQP = kernel->msgSender()->sendQuotedPrintable(); |
|
|
|
|
|
|
|
|
|
if( aMsg->numBodyParts() == 0 ) |
|
|
|
|
{ |
|
|
|
|
msg->setAutomaticFields( true ); |
|
|
|
|
msg->setHeaderField( "Content-Type", "text/plain" ); |
|
|
|
|
msg->setCteStr( isQP ? "quoted-printable": "8bit" ); |
|
|
|
|
msg->setCharset( encoding ); |
|
|
|
|
if( isQP ) |
|
|
|
|
msg->setBodyEncoded( str ); |
|
|
|
|
else |
|
|
|
|
msg->setBody( str ); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
KMMessagePart bodyPart, msgPart; |
|
|
|
|
|
|
|
|
|
msg->removeHeaderField( "Content-Type" ); |
|
|
|
|
msg->removeHeaderField( "Content-Transfer-Encoding" ); |
|
|
|
|
msg->setAutomaticFields( true ); |
|
|
|
|
msg->setBody( "This message is in MIME format.\n\n" ); |
|
|
|
|
|
|
|
|
|
bodyPart.setTypeStr( "text" ); |
|
|
|
|
bodyPart.setSubtypeStr( "plain" ); |
|
|
|
|
bodyPart.setCteStr( isQP ? "quoted-printable": "8bit" ); |
|
|
|
|
bodyPart.setCharset( encoding ); |
|
|
|
|
bodyPart.setBodyEncoded( str ); |
|
|
|
|
msg->addBodyPart( &bodyPart ); |
|
|
|
|
|
|
|
|
|
for( int i = 0; i < aMsg->numBodyParts(); i++ ) |
|
|
|
|
{ |
|
|
|
|
aMsg->bodyPart( i, &msgPart ); |
|
|
|
|
if( i > 0 || qstricmp( msgPart.typeStr(), "text" ) != 0 ) |
|
|
|
|
msg->addBodyPart( &msgPart ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
msg->cleanupHeader(); |
|
|
|
|
msg->link( aMsg, KMMsgStatusForwarded ); |
|
|
|
|
|
|
|
|
|
if ( !kernel->msgSender()->send(msg) ) { |
|
|
|
|
kdDebug(5006) << "KMFilterAction: could not forward message (sending failed)" << endl; |
|
|
|
|
|