diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-06-30 20:41:24 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-06-30 20:41:24 -0500 |
commit | f1f9c9b90c6b27b58cddc021281c345de365685b (patch) | |
tree | c1aeef2eb9fd6ab58d6d7a323067617398c6c8bf | |
parent | e4cc0ead9fb403ee429406eaaacda0afae5dd006 (diff) | |
download | tdepim-f1f9c9b90c6b27b58cddc021281c345de365685b.tar.gz tdepim-f1f9c9b90c6b27b58cddc021281c345de365685b.zip |
If a message is replied to from an incoming account, and an outgoing account is available with the same name, set that outgoing account as the default transport
This resolves Bug 1239
-rw-r--r-- | kmail/kmcommands.cpp | 17 | ||||
-rw-r--r-- | kmail/kmcomposewin.cpp | 17 | ||||
-rw-r--r-- | kmail/kmmessage.cpp | 7 | ||||
-rw-r--r-- | kmail/kmmessage.h | 8 |
4 files changed, 45 insertions, 4 deletions
diff --git a/kmail/kmcommands.cpp b/kmail/kmcommands.cpp index e3be3b119..d4fead489 100644 --- a/kmail/kmcommands.cpp +++ b/kmail/kmcommands.cpp @@ -1115,7 +1115,22 @@ KMCommand::Result KMReplyToCommand::execute() if ( !msg || !msg->codec() ) { return Failed; } - KMMessage *reply = msg->createReply( KMail::ReplySmart, mSelection ); + + // Find the account that held the original message + TQString accountName; + KMFolder* parentFolder = msg->parent(); + if (parentFolder) { + KMFolderDir* parentFolderDir = parentFolder->parent(); + while (parentFolderDir) { + TQString prettyURL = parentFolderDir->prettyURL(); + if (prettyURL != "") { + accountName = prettyURL; + } + parentFolderDir = parentFolderDir->parent(); + } + } + + KMMessage *reply = msg->createReply( KMail::ReplySmart, mSelection, false, true, TQString(), accountName ); KMail::Composer * win = KMail::makeComposer( reply ); win->setCharset( msg->codec()->mimeName(), true ); win->setReplyFocus(); diff --git a/kmail/kmcomposewin.cpp b/kmail/kmcomposewin.cpp index d7e96b26a..27a76c727 100644 --- a/kmail/kmcomposewin.cpp +++ b/kmail/kmcomposewin.cpp @@ -1980,8 +1980,23 @@ void KMComposeWin::setMsg(KMMessage* newMsg, bool mayAutoSign, TQString transport = newMsg->headerField("X-KMail-Transport"); const bool stickyTransport = mBtnTransport->isChecked() && !mIgnoreStickyFields; - if (!stickyTransport && !transport.isEmpty()) + if (!stickyTransport && !transport.isEmpty()) { setTransport( transport ); + } + + // If we are using the default transport, and the originating account name of the original message matches the name of a valid transport, use setTransport() to set it + // See Bug 1239 + if (transport.isEmpty() && !mMsg->originatingAccountName().isEmpty()) { + TQString transportCandidate = mMsg->originatingAccountName(); + bool transportFound = false; + for ( int i = 0; i < mTransport->count(); ++i ) { + if ( mTransport->text(i) == transportCandidate ) { + transportFound = true; + setTransport(transportCandidate); + break; + } + } + } if (!mBtnFcc->isChecked()) { diff --git a/kmail/kmmessage.cpp b/kmail/kmmessage.cpp index ba8fba5af..c33fdf6a2 100644 --- a/kmail/kmmessage.cpp +++ b/kmail/kmmessage.cpp @@ -867,7 +867,8 @@ KMMessage* KMMessage::createReply( KMail::ReplyStrategy replyStrategy, TQString selection /* = TQString() */, bool noQuote /* = false */, bool allowDecryption /* = true */, - const TQString &tmpl /* = TQString() */ ) + const TQString &tmpl /* = TQString() */, + const TQString &originatingAccount /* = TQString() */ ) { KMMessage* msg = new KMMessage; TQString mailingListStr, replyToStr, toStr; @@ -1048,6 +1049,10 @@ KMMessage* KMMessage::createReply( KMail::ReplyStrategy replyStrategy, } } + if (!originatingAccount.isEmpty()) { + msg->setOriginatingAccountName(originatingAccount); + } + msg->setTo(toStr); refStr = getRefStr(); diff --git a/kmail/kmmessage.h b/kmail/kmmessage.h index a16006575..3a61a11fc 100644 --- a/kmail/kmmessage.h +++ b/kmail/kmmessage.h @@ -164,7 +164,8 @@ public: KMMessage* createReply( KMail::ReplyStrategy replyStrategy = KMail::ReplySmart, TQString selection=TQString(), bool noQuote = false, bool allowDecryption = true, - const TQString &tmpl = TQString() ); + const TQString &tmpl = TQString(), + const TQString &originatingAccount = TQString() ); /** Create a new message that is a redirect to this message, filling all required header fields with the proper values. The returned message @@ -802,6 +803,10 @@ public: TQString fileName() const { return mFileName; } void setFileName(const TQString& file) { if(mFileName != file) { mFileName=file; setDirty(true); } } + /** Get/set originating account name. */ + TQString originatingAccountName() const { return mOriginatingAccountName; } + void setOriginatingAccountName(const TQString& account) { if(mOriginatingAccountName != account) { mOriginatingAccountName=account; setDirty(true); } } + /** Get/set size of message in the folder including the whole header in bytes. Can be 0, if the message is not in a folder. The setting of mMsgSize = mMsgLength = sz is needed for popFilter*/ @@ -960,6 +965,7 @@ private: const TQTextCodec * mOverrideCodec; TQString mFileName; + TQString mOriginatingAccountName; off_t mFolderOffset; size_t mMsgSize, mMsgLength; time_t mDate; |