Commit 6deca879 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix Bug 125468 - Can't set identity when redirecting mail

FIXED-IN: 4.10
BUG: 125468
parent f72f6f72
......@@ -1011,6 +1011,8 @@ KMCommand::Result KMRedirectCommand::execute()
? MessageSender::SendImmediate
: MessageSender::SendLater;
const int identity = dlg->identity();
int transportId = dlg->transportId();
const QString to = dlg->to();
foreach( const Akonadi::Item &item, retrievedMsgs() ) {
const KMime::Message::Ptr msg = MessageCore::Util::message( item );
......@@ -1021,13 +1023,14 @@ KMCommand::Result KMRedirectCommand::execute()
factory.setIdentityManager( KMKernel::self()->identityManager() );
factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
const MailTransport::TransportAttribute *transportAttribute = item.attribute<MailTransport::TransportAttribute>();
int transportId = -1;
if ( transportAttribute ) {
transportId = transportAttribute->transportId();
const MailTransport::Transport *transport = MailTransport::TransportManager::self()->transportById( transportId );
if ( !transport ) {
transportId = -1;
if(transportId == -1) {
const MailTransport::TransportAttribute *transportAttribute = item.attribute<MailTransport::TransportAttribute>();
if ( transportAttribute ) {
transportId = transportAttribute->transportId();
const MailTransport::Transport *transport = MailTransport::TransportManager::self()->transportById( transportId );
if ( !transport ) {
transportId = -1;
}
}
}
......@@ -1036,7 +1039,7 @@ KMCommand::Result KMRedirectCommand::execute()
if ( sentAttribute && ( sentAttribute->sentBehaviour() == MailTransport::SentBehaviourAttribute::MoveToCollection ) )
fcc = QString::number( sentAttribute->moveToCollection().id() );
const KMime::Message::Ptr newMsg = factory.createRedirect( to, transportId, fcc );
const KMime::Message::Ptr newMsg = factory.createRedirect( to, transportId, fcc, identity );
if ( !newMsg )
return Failed;
......
......@@ -36,6 +36,14 @@
#include <Akonadi/Contact/EmailAddressSelectionDialog>
#include <KPIMUtils/Email>
#include <KDE/KPIMIdentities/Identity>
#include <KDE/KPIMIdentities/IdentityCombo>
#include <KDE/KPIMIdentities/IdentityManager>
#include <KDE/Mailtransport/Transport>
#include <KDE/Mailtransport/TransportComboBox>
#include <KDE/Mailtransport/TransportManager>
#include <KIconLoader>
#include <KLocale>
......@@ -69,6 +77,8 @@ class RedirectDialog::Private
QString mResentTo;
RedirectDialog::SendMode mSendMode;
KPIMIdentities::IdentityCombo *mComboboxIdentity;
MailTransport::TransportComboBox *mTransportCombobox;
};
void RedirectDialog::Private::slotUser1()
......@@ -148,6 +158,14 @@ RedirectDialog::RedirectDialog( SendMode mode, QWidget *parent )
d->mLabelTo->setBuddy( d->mBtnTo );
d->mEditTo->setFocus();
hbox = new KHBox( vbox );
new QLabel(i18n("Identity:"),hbox);
d->mComboboxIdentity = new KPIMIdentities::IdentityCombo(KernelIf->identityManager(),hbox);
hbox = new KHBox(vbox);
new QLabel(i18n("Transport:"),hbox);
d->mTransportCombobox = new MailTransport::TransportComboBox( hbox );
setButtonGuiItem( User1, KGuiItem( i18n( "&Send Now" ), "mail-send" ) );
setButtonGuiItem( User2, KGuiItem( i18n( "Send &Later" ), "mail-queue" ) );
connect( this, SIGNAL(user1Clicked()), this, SLOT(slotUser1()) );
......@@ -171,6 +189,16 @@ RedirectDialog::SendMode RedirectDialog::sendMode() const
return d->mSendMode;
}
int RedirectDialog::transportId() const
{
return d->mTransportCombobox->currentTransportId();
}
int RedirectDialog::identity() const
{
return d->mComboboxIdentity->currentIdentity();
}
void RedirectDialog::accept()
{
d->mResentTo = d->mEditTo->text();
......
......@@ -80,6 +80,10 @@ class MAILCOMMON_EXPORT RedirectDialog : public KDialog
*/
SendMode sendMode() const;
int transportId() const;
int identity() const;
protected:
virtual void accept();
......
......@@ -483,7 +483,7 @@ KMime::Message::Ptr MessageFactory::createResend()
return msg;
}
KMime::Message::Ptr MessageFactory::createRedirect( const QString &toStr, int transportId, const QString& fcc )
KMime::Message::Ptr MessageFactory::createRedirect( const QString &toStr, int transportId, const QString& fcc, int identity )
{
if ( !m_origMsg )
return KMime::Message::Ptr();
......@@ -493,10 +493,12 @@ KMime::Message::Ptr MessageFactory::createRedirect( const QString &toStr, int tr
msg->setContent( m_origMsg->encodedContent() );
msg->parse();
uint id = 0;
QString strId = msg->headerByType( "X-KMail-Identity" ) ? msg->headerByType( "X-KMail-Identity" )->asUnicodeString().trimmed() : QString::fromLocal8Bit("");
if ( !strId.isEmpty())
id = strId.toUInt();
uint id = identity;
if(id == -1) {
QString strId = msg->headerByType( "X-KMail-Identity" ) ? msg->headerByType( "X-KMail-Identity" )->asUnicodeString().trimmed() : QString::fromLocal8Bit("");
if ( !strId.isEmpty())
id = strId.toUInt();
}
const KPIMIdentities::Identity & ident =
m_identityManager->identityForUoidOrDefault( id );
......
......@@ -102,7 +102,7 @@ public:
user, mail is not changed and the reply-to field is set to
the email address of the original sender.
*/
KMime::Message::Ptr createRedirect( const QString &toStr, int transportId = -1, const QString& fcc = QString() );
KMime::Message::Ptr createRedirect(const QString &toStr, int transportId = -1, const QString& fcc = QString() , int identity = -1);
KMime::Message::Ptr createResend();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment