From dc3aaf2ae07c1ea79d99039174f6572361f919e9 Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Tue, 7 Jun 2005 19:07:04 +0000 Subject: [PATCH] Bug #260482 --> custom mail headers (e.g. In-Reply-To) cannot be passed from command line Patch by: kmccarty@princeton.edu r=bienvenu sr=mscott a=sspitzer --- mailnews/compose/src/nsMsgComposeService.cpp | 4 +++- mailnews/compose/src/nsSmtpUrl.cpp | 24 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mailnews/compose/src/nsMsgComposeService.cpp b/mailnews/compose/src/nsMsgComposeService.cpp index 088eb19e476..3eee0cb1d04 100644 --- a/mailnews/compose/src/nsMsgComposeService.cpp +++ b/mailnews/compose/src/nsMsgComposeService.cpp @@ -506,6 +506,7 @@ NS_IMETHODIMP nsMsgComposeService::GetParamsForMailto(nsIURI * aURI, nsIMsgCompo nsXPIDLCString aSubjectPart; nsXPIDLCString aBodyPart; nsXPIDLCString aNewsgroup; + nsXPIDLCString aRefPart; nsXPIDLCString aHTMLBodyPart; // we are explictly not allowing attachments to be specified in mailto: urls @@ -516,7 +517,7 @@ NS_IMETHODIMP nsMsgComposeService::GetParamsForMailto(nsIURI * aURI, nsIMsgCompo nsnull /* follow */, nsnull /* organization */, nsnull /* reply to part */, getter_Copies(aSubjectPart), getter_Copies(aBodyPart), getter_Copies(aHTMLBodyPart) /* html part */, - nsnull /* a ref part */, nsnull /* attachment part, must always null, see #99055 */, + getter_Copies(aRefPart), nsnull /* attachment part, must always null, see #99055 */, nsnull /* priority */, getter_Copies(aNewsgroup), nsnull /* host */, &requestedComposeFormat); @@ -585,6 +586,7 @@ NS_IMETHODIMP nsMsgComposeService::GetParamsForMailto(nsIURI * aURI, nsIMsgCompo pMsgCompFields->SetCc(NS_ConvertUTF8toUTF16(aCcPart)); pMsgCompFields->SetBcc(NS_ConvertUTF8toUTF16(aBccPart)); pMsgCompFields->SetNewsgroups(aNewsgroup); + pMsgCompFields->SetReferences(aRefPart); pMsgCompFields->SetSubject(NS_ConvertUTF8toUTF16(aSubjectPart)); pMsgCompFields->SetBody(composeHTMLFormat ? sanitizedBody : rawBody); pMsgComposeParams->SetComposeFields(pMsgCompFields); diff --git a/mailnews/compose/src/nsSmtpUrl.cpp b/mailnews/compose/src/nsSmtpUrl.cpp index 84c53e4eef1..e55586d0ab4 100644 --- a/mailnews/compose/src/nsSmtpUrl.cpp +++ b/mailnews/compose/src/nsSmtpUrl.cpp @@ -68,6 +68,7 @@ NS_IMPL_ISUPPORTS2(nsMailtoUrl, nsIMailtoUrl, nsIURI) nsresult nsMailtoUrl::ParseMailtoUrl(char * searchPart) { char *rest = searchPart; + nsCAutoString inReplyToPart; // okay, first, free up all of our old search part state..... CleanupMailtoState(); @@ -146,6 +147,11 @@ nsresult nsMailtoUrl::ParseMailtoUrl(char * searchPart) mFormat = nsIMsgCompFormat::HTML; } break; + case 'I': + if (!nsCRT::strcasecmp (token, "in-reply-to")) + inReplyToPart = value; + break; + case 'N': if (!nsCRT::strcasecmp (token, "newsgroups")) m_newsgroupPart = value; @@ -192,6 +198,24 @@ nsresult nsMailtoUrl::ParseMailtoUrl(char * searchPart) } // while we still have part of the url to parse... } // if rest && *rest + // Ensure that References and In-Reply-To are consistent... + if (!inReplyToPart.IsEmpty()) + { + if (m_referencePart.IsEmpty()) + m_referencePart = inReplyToPart; + else + { + const char * lastRef = strrchr(m_referencePart.get(), '<'); + nsCAutoString lastReference; + lastReference = lastRef ? lastRef : m_referencePart.get(); + if (lastReference != inReplyToPart) + { + m_referencePart += " "; + m_referencePart += inReplyToPart; + } + } + } + nsCOMPtr mimeConverter = do_GetService(NS_MIME_CONVERTER_CONTRACTID); char *decodedString;