From 947ace5c9f23f7ff3a70dc915a9cc0f5c1f688c2 Mon Sep 17 00:00:00 2001 From: "ducarroz%netscape.com" Date: Fri, 3 Sep 1999 22:13:36 +0000 Subject: [PATCH] Put " wrote:" at the beginning of a reply instance of "--- Original Message ---". Last part of bug 12080 git-svn-id: svn://10.0.0.236/trunk@45936 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mailnews/compose/src/nsMsgCompose.cpp | 46 ++++++++++++++----- mozilla/mailnews/compose/src/nsMsgCompose.h | 3 +- mozilla/mailnews/compose/src/nsMsgCreate.h | 3 ++ 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/mozilla/mailnews/compose/src/nsMsgCompose.cpp b/mozilla/mailnews/compose/src/nsMsgCompose.cpp index f80cc8e683c..569b24019aa 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompose.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCompose.cpp @@ -38,6 +38,7 @@ #include "nsMsgComposeStringBundle.h" #include "nsSpecialSystemDirectory.h" #include "nsMsgSend.h" +#include "nsMsgCreate.h" // XXX temporary so we can use the current identity hack -alecf #include "nsIMsgMailSession.h" @@ -707,11 +708,40 @@ QuotingOutputStreamListener::~QuotingOutputStreamListener() NS_RELEASE(mComposeObj); } -QuotingOutputStreamListener::QuotingOutputStreamListener(void) +QuotingOutputStreamListener::QuotingOutputStreamListener(const PRUnichar * originalMsgURI, PRBool quoteHeaders) { mComposeObj = nsnull; -// mMsgBody = "

--- Original Message ---

"; - mMsgBody = "

--- Original Message ---

"; + mQuoteHeaders = quoteHeaders; + + nsCOMPtr originalMsg = getter_AddRefs(GetIMessageFromURI(originalMsgURI)); + if (originalMsg && !quoteHeaders) + { + nsresult rv; + nsString author; + rv = originalMsg->GetMime2DecodedAuthor(&author); + if (NS_SUCCEEDED(rv)) + { + char * authorName = nsnull; + nsCOMPtr parser; + nsComponentManager::CreateInstance(kHeaderParserCID, + nsnull, + nsCOMTypeInfo::GetIID(), + getter_AddRefs(parser)); + if (parser) + if (NS_SUCCEEDED(parser->ExtractHeaderAddressName(nsnull, nsAutoCString(author), &authorName))) + { + mMsgBody = "

"; + mMsgBody += authorName; + mMsgBody += " wrote:
"; + } + if (authorName) + PL_strfree(authorName); + } + } + + if (mMsgBody.IsEmpty()) + mMsgBody = "

--- Original Message ---
"; + NS_INIT_REFCNT(); } @@ -858,13 +888,6 @@ QuotingOutputStreamListener::SetComposeObj(nsMsgCompose *obj) return NS_OK; } -nsresult -QuotingOutputStreamListener::SetQuoteHeaders(PRBool quoteHeaders) -{ - mQuoteHeaders = quoteHeaders; - return NS_OK; -} - NS_IMPL_ISUPPORTS(QuotingOutputStreamListener, nsCOMTypeInfo::GetIID()); //////////////////////////////////////////////////////////////////////////////////// // END OF QUOTING LISTENER @@ -899,7 +922,7 @@ nsMsgCompose::QuoteOriginalMessage(const PRUnichar *originalMsgURI, PRInt32 what return NS_ERROR_FAILURE; // Create the consumer output stream.. this will receive all the HTML from libmime - mQuoteStreamListener = new QuotingOutputStreamListener(); + mQuoteStreamListener = new QuotingOutputStreamListener(originalMsgURI, what != 1); if (!mQuoteStreamListener) { @@ -910,7 +933,6 @@ nsMsgCompose::QuoteOriginalMessage(const PRUnichar *originalMsgURI, PRInt32 what NS_ADDREF(this); mQuoteStreamListener->SetComposeObj(this); - mQuoteStreamListener->SetQuoteHeaders(what != 1); return mQuote->QuoteMessage(originalMsgURI, what != 1, mQuoteStreamListener); } diff --git a/mozilla/mailnews/compose/src/nsMsgCompose.h b/mozilla/mailnews/compose/src/nsMsgCompose.h index 347e22e4453..b5dc30fd2ab 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompose.h +++ b/mozilla/mailnews/compose/src/nsMsgCompose.h @@ -146,7 +146,7 @@ class nsMsgCompose : public nsIMsgCompose class QuotingOutputStreamListener : public nsIStreamListener { public: - QuotingOutputStreamListener(void); + QuotingOutputStreamListener(const PRUnichar *originalMsgURI, PRBool quoteHeaders); virtual ~QuotingOutputStreamListener(void); // nsISupports interface @@ -162,7 +162,6 @@ public: NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg); NS_IMETHOD SetComposeObj(nsMsgCompose *obj); - NS_IMETHOD SetQuoteHeaders(PRBool quoteHeaders); NS_IMETHOD ConvertToPlainText(); private: diff --git a/mozilla/mailnews/compose/src/nsMsgCreate.h b/mozilla/mailnews/compose/src/nsMsgCreate.h index 343703c1ccc..3100f817edb 100644 --- a/mozilla/mailnews/compose/src/nsMsgCreate.h +++ b/mozilla/mailnews/compose/src/nsMsgCreate.h @@ -55,4 +55,7 @@ public: // Will be used by factory to generate a nsMsgQuote class... nsresult NS_NewMsgDraft(const nsIID &aIID, void ** aInstancePtrResult); +nsIMessage * GetIMessageFromURI(const PRUnichar *msgURI); + + #endif /* _nsMsgCreate_H_ */