зеркало из https://github.com/mozilla/gecko-dev.git
Fixes for compose back end problems - Bug #: 25610 29806 30048 30744 31207 31589
This commit is contained in:
Родитель
75649f6bed
Коммит
2ec0c6b8e6
|
@ -166,3 +166,6 @@ noIdentities=You don't have any email identities yet. Create one with the Accou
|
|||
|
||||
## @name NS_MSG_POSTING_MESSAGE
|
||||
12551=Posting message...
|
||||
|
||||
## @name NS_MSG_ATTACHMENT_TYPE_MISMATCH
|
||||
12552=<Image Signature Omitted>
|
||||
|
|
|
@ -53,7 +53,7 @@ nsresult NS_NewMsgCompFields(const nsIID &aIID, void ** aInstancePtrResult)
|
|||
}
|
||||
|
||||
/* the following macro actually implement addref, release and query interface for our component. */
|
||||
NS_IMPL_ISUPPORTS(nsMsgCompFields, NS_GET_IID(nsIMsgCompFields));
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS(nsMsgCompFields, NS_GET_IID(nsIMsgCompFields));
|
||||
|
||||
nsMsgCompFields::nsMsgCompFields()
|
||||
{
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "nsAbBaseCID.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
#include "nsIAddrBookSession.h"
|
||||
#include "nsIMimeService.h"
|
||||
|
||||
// Defines....
|
||||
static NS_DEFINE_CID(kMsgQuoteCID, NS_MSGQUOTE_CID);
|
||||
|
@ -68,6 +69,7 @@ static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
|
|||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kAddressBookDBCID, NS_ADDRDATABASE_CID);
|
||||
static NS_DEFINE_CID(kMsgRecipientArrayCID, NS_MSGRECIPIENTARRAY_CID);
|
||||
static NS_DEFINE_CID(kMimeServiceCID, NS_MIMESERVICE_CID);
|
||||
|
||||
static PRInt32 GetReplyOnTop()
|
||||
{
|
||||
|
@ -112,6 +114,7 @@ nsMsgCompose::nsMsgCompose()
|
|||
m_compFields = new nsMsgCompFields;
|
||||
NS_IF_ADDREF(m_compFields);
|
||||
mType = nsIMsgCompType::New;
|
||||
mCiteReference = "";
|
||||
|
||||
// Get the default charset from pref, use this as a mail charset.
|
||||
char * default_mail_charset = nsMsgI18NGetDefaultMailCharset();
|
||||
|
@ -247,7 +250,11 @@ nsresult nsMsgCompose::ConvertAndLoadComposeWindow(nsIEditorShell *aEditorShell,
|
|||
|
||||
if (!aBuf.IsEmpty())
|
||||
{
|
||||
aEditorShell->InsertAsQuotation(aBuf.GetUnicode(), getter_AddRefs(nodeInserted));
|
||||
if (mCiteReference != "")
|
||||
aEditorShell->InsertAsCitedQuotation(aBuf.GetUnicode(), mCiteReference.GetUnicode(),
|
||||
nsString("UTF-8").GetUnicode(), getter_AddRefs(nodeInserted));
|
||||
else
|
||||
aEditorShell->InsertAsQuotation(aBuf.GetUnicode(), getter_AddRefs(nodeInserted));
|
||||
}
|
||||
|
||||
if (!aSignature.IsEmpty())
|
||||
|
@ -904,6 +911,10 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI,
|
|||
case nsIMsgCompType::ReplyAll:
|
||||
{
|
||||
mQuotingToFollow = PR_TRUE;
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
prefs->GetBoolPref("mail.auto_quote", &mQuotingToFollow);
|
||||
|
||||
// get an original charset, used for a label, UTF-8 is used for the internal processing
|
||||
if (!aCharset.Equals(""))
|
||||
m_compFields->SetCharacterSet(nsCAutoString(aCharset));
|
||||
|
@ -919,7 +930,7 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI,
|
|||
rv = message->GetAuthor(getter_Copies(author));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
m_compFields->SetTo(author);
|
||||
|
||||
|
||||
nsString authorStr(author);
|
||||
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(authorStr, encodedCharset, decodedString)))
|
||||
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString)))
|
||||
|
@ -1033,6 +1044,15 @@ QuotingOutputStreamListener::QuotingOutputStreamListener(const PRUnichar * origi
|
|||
{
|
||||
nsresult rv;
|
||||
nsAutoString author;
|
||||
|
||||
// Setup the cite information....
|
||||
char *msgID = nsnull;
|
||||
if (NS_SUCCEEDED(originalMsg->GetMessageId(&msgID)) && msgID)
|
||||
{
|
||||
mCiteReference = msgID;
|
||||
PR_FREEIF(msgID);
|
||||
}
|
||||
|
||||
rv = originalMsg->GetMime2DecodedAuthor(&author);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
@ -1102,6 +1122,10 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIChannel *aChannel, n
|
|||
{
|
||||
MSG_ComposeType type = mComposeObj->GetMessageType();
|
||||
|
||||
// Assign cite information if available...
|
||||
if (mCiteReference != "")
|
||||
mComposeObj->mCiteReference = mCiteReference;
|
||||
|
||||
if (mHeaders && (type == nsIMsgCompType::Reply || type == nsIMsgCompType::ReplyAll))
|
||||
{
|
||||
nsIMsgCompFields *compFields = nsnull;
|
||||
|
@ -1758,11 +1782,18 @@ nsMsgCompose::ProcessSignature(nsIMsgIdentity *identity, nsString *aMsgBody)
|
|||
// look at the signature file first...if the extension is .htm or
|
||||
// .html, we assume its HTML, otherwise, we assume it is plain text
|
||||
//
|
||||
nsAutoString urlStr;
|
||||
// ...and that's not all! What we will also do now is look and see if
|
||||
// the file is an image file. If it is an image file, then we should
|
||||
// insert the correct HTML into the composer to have it work, but if we
|
||||
// are doing plain text compose, we should insert some sort of message
|
||||
// saying "Image Signature Omitted" or something.
|
||||
//
|
||||
nsAutoString urlStr;
|
||||
nsCOMPtr<nsIFileSpec> sigFileSpec;
|
||||
PRBool useSigFile = PR_FALSE;
|
||||
PRBool htmlSig = PR_FALSE;
|
||||
nsAutoString sigData = "";
|
||||
PRBool imageSig = PR_FALSE;
|
||||
nsAutoString sigData = "";
|
||||
|
||||
if (identity)
|
||||
{
|
||||
|
@ -1794,18 +1825,71 @@ nsMsgCompose::ProcessSignature(nsIMsgIdentity *identity, nsString *aMsgBody)
|
|||
|
||||
if ( (fileExt) && (*fileExt) )
|
||||
{
|
||||
htmlSig = ( (!PL_strcasecmp(fileExt, "HTM")) || (!PL_strcasecmp(fileExt, "HTML")) );
|
||||
// Now, most importantly, we need to figure out what the content type is for
|
||||
// this signature...if we can't, we assume text
|
||||
rv = NS_OK;
|
||||
char *sigContentType = nsnull;
|
||||
NS_WITH_SERVICE(nsIMIMEService, mimeFinder, kMimeServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && mimeFinder && fileExt)
|
||||
{
|
||||
mimeFinder->GetTypeFromExtension(fileExt, &(sigContentType));
|
||||
PR_FREEIF(fileExt);
|
||||
}
|
||||
|
||||
if (sigContentType)
|
||||
{
|
||||
imageSig = (!PL_strncasecmp(sigContentType, "image/", 6));
|
||||
if (!imageSig)
|
||||
htmlSig = (!PL_strcasecmp(sigContentType, TEXT_HTML));
|
||||
}
|
||||
else
|
||||
htmlSig = ( (!PL_strcasecmp(fileExt, "HTM")) || (!PL_strcasecmp(fileExt, "HTML")) );
|
||||
|
||||
PR_FREEIF(fileExt);
|
||||
PR_FREEIF(sigContentType);
|
||||
}
|
||||
|
||||
// is this a text sig with an HTML editor?
|
||||
if ( (m_composeHTML) && (!htmlSig) )
|
||||
ConvertTextToHTML(testSpec, sigData);
|
||||
// is this a HTML sig with a text window?
|
||||
else if ( (!m_composeHTML) && (htmlSig) )
|
||||
ConvertHTMLToText(testSpec, sigData);
|
||||
else // We have a match...
|
||||
LoadDataFromFile(testSpec, sigData); // Get the data!
|
||||
// If we have an image signature, then we should put in the appropriate
|
||||
// HTML for inclusion, otherwise, just mention something about it.
|
||||
if (imageSig)
|
||||
{
|
||||
if (m_composeHTML)
|
||||
{
|
||||
aMsgBody->Append("<PRE>");
|
||||
aMsgBody->Append(CRLF);
|
||||
aMsgBody->Append("-- ");
|
||||
aMsgBody->Append(CRLF);
|
||||
aMsgBody->Append("</PRE>");
|
||||
aMsgBody->Append("<IMG SRC=\"file:///");
|
||||
aMsgBody->Append(testSpec);
|
||||
aMsgBody->Append("\" BORDER=0>");
|
||||
}
|
||||
else
|
||||
{
|
||||
PRUnichar *omitString = ComposeGetStringByID(NS_MSG_ATTACHMENT_TYPE_MISMATCH);
|
||||
if (omitString)
|
||||
{
|
||||
aMsgBody->Append("-- ");
|
||||
aMsgBody->Append(CRLF);
|
||||
aMsgBody->Append(omitString);
|
||||
aMsgBody->Append(CRLF);
|
||||
}
|
||||
PR_FREEIF(omitString);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
// is this a text sig with an HTML editor?
|
||||
if ( (m_composeHTML) && (!htmlSig) )
|
||||
ConvertTextToHTML(testSpec, sigData);
|
||||
// is this a HTML sig with a text window?
|
||||
else if ( (!m_composeHTML) && (htmlSig) )
|
||||
ConvertHTMLToText(testSpec, sigData);
|
||||
else // We have a match...
|
||||
LoadDataFromFile(testSpec, sigData); // Get the data!
|
||||
}
|
||||
|
||||
// Now that sigData holds data...if any, append it to the body in a nice
|
||||
// looking manner
|
||||
|
|
|
@ -116,6 +116,7 @@ class nsMsgCompose : public nsIMsgCompose
|
|||
PRBool mEntityConversionDone;
|
||||
|
||||
// Deal with quoting issues...
|
||||
nsString mCiteReference;
|
||||
nsCOMPtr<nsIMsgQuote> mQuote;
|
||||
PRBool mQuotingToFollow; // Quoting indicator
|
||||
nsMsgDocumentStateListener *mDocumentListener;
|
||||
|
@ -154,6 +155,7 @@ private:
|
|||
PRBool mQuoteHeaders;
|
||||
nsCOMPtr<nsIMimeHeaders> mHeaders;
|
||||
nsCOMPtr<nsIMsgIdentity> mIdentity;
|
||||
nsString mCiteReference;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -83,6 +83,7 @@
|
|||
|
||||
#define NS_MSG_SENDING_MESSAGE NS_MSG_GENERATE_SUCCESS(12550)
|
||||
#define NS_MSG_POSTING_MESSAGE NS_MSG_GENERATE_SUCCESS(12551)
|
||||
#define NS_MSG_ATTACHMENT_TYPE_MISMATCH NS_MSG_GENERATE_FAILURE(12552)
|
||||
|
||||
NS_BEGIN_EXTERN_C
|
||||
|
||||
|
|
|
@ -796,7 +796,7 @@ static int OutputAdvancedVcard(MimeObject *obj, VObject *v)
|
|||
status = OutputFont(obj, PR_FALSE, "-1", NULL);
|
||||
if (status < 0) return status;
|
||||
char *tString = VCardGetStringByID(VCARD_LDAP_USEHTML);
|
||||
status = WriteLineToStream (obj, tString, PR_TRUE);
|
||||
status = WriteLineToStream (obj, tString, PR_FALSE);
|
||||
PR_FREEIF(tString);
|
||||
if (status < 0) return status;
|
||||
status = OutputFont(obj, PR_TRUE, NULL, NULL);
|
||||
|
@ -1433,7 +1433,7 @@ static int WriteOutEachVCardPhoneProperty (MimeObject *obj, VObject* o)
|
|||
PR_FREEIF (attribName);
|
||||
return status;
|
||||
}
|
||||
status = WriteLineToStream (obj, attribName, PR_TRUE);
|
||||
status = WriteLineToStream (obj, attribName, PR_FALSE);
|
||||
if (status < 0) {
|
||||
PR_FREEIF (attribName);
|
||||
return status;
|
||||
|
|
|
@ -716,6 +716,11 @@ nsMimeBaseEmitter::DumpSubjectFromDate()
|
|||
OutputGenericHeader(HEADER_FROM);
|
||||
OutputGenericHeader(HEADER_DATE);
|
||||
|
||||
// If we are Quoting a message, then we should dump the To: also
|
||||
if ( ( mFormat == nsMimeOutput::nsMimeMessageQuoting ) ||
|
||||
( mFormat == nsMimeOutput::nsMimeMessageBodyQuoting ) )
|
||||
OutputGenericHeader(HEADER_TO);
|
||||
|
||||
mHTMLHeaders.Append("</TABLE>");
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -48,7 +48,9 @@
|
|||
#include "nsIMsgCompose.h"
|
||||
#include "nsMsgI18N.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
#include "nsIMsgMessageService.h"
|
||||
#include "nsMsgUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
//
|
||||
// Header strings...
|
||||
|
@ -1271,7 +1273,8 @@ mime_parse_stream_complete (nsMIMESession *stream)
|
|||
{
|
||||
if( PL_strcasestr(mdd->messageBody->type, "text/html") != NULL )
|
||||
composeFormat = nsIMsgCompFormat::HTML;
|
||||
else if ( PL_strcasestr(mdd->messageBody->type, "text/plain") != NULL )
|
||||
else if ( ( PL_strcasestr(mdd->messageBody->type, "text/plain") != NULL ) ||
|
||||
( PL_strcasecmp(mdd->messageBody->type, "text") == 0 ) )
|
||||
composeFormat = nsIMsgCompFormat::PlainText;
|
||||
}
|
||||
else
|
||||
|
@ -1597,7 +1600,7 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
|
|||
PR_FREEIF(contLoc);
|
||||
|
||||
mdd->curAttachment = newAttachment;
|
||||
newAttachment->type = MimeHeaders_get ( headers, HEADER_CONTENT_TYPE, PR_TRUE, PR_FALSE );
|
||||
newAttachment->type = MimeHeaders_get ( headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE );
|
||||
|
||||
//
|
||||
// This is to handle the degenerated Apple Double attachment.
|
||||
|
@ -1797,19 +1800,29 @@ mime_bridge_create_draft_stream(
|
|||
if (!mdd)
|
||||
return nsnull;
|
||||
|
||||
char *urlString;
|
||||
if (NS_SUCCEEDED(uri->GetSpec(&urlString)))
|
||||
{
|
||||
if ((urlString) && (*urlString))
|
||||
{
|
||||
mdd->url_name = nsCRT::strdup(urlString);
|
||||
if (!(mdd->url_name))
|
||||
{
|
||||
PR_FREEIF(mdd);
|
||||
return nsnull;
|
||||
}
|
||||
// first, convert the rdf msg uri into a url that represents the message...
|
||||
char *turl;
|
||||
if (NS_FAILED(uri->GetSpec(&turl)))
|
||||
return nsnull;
|
||||
|
||||
PR_FREEIF(urlString);
|
||||
nsIMsgMessageService * msgService = nsnull;
|
||||
nsresult rv = GetMessageServiceFromURI(turl, &msgService);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
rv = msgService->GetUrlForUri(turl, getter_AddRefs(aURL));
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
nsXPIDLCString urlString;
|
||||
if (NS_SUCCEEDED(aURL->GetSpec(getter_Copies(urlString))))
|
||||
{
|
||||
mdd->url_name = nsCRT::strdup(urlString);
|
||||
if (!(mdd->url_name))
|
||||
{
|
||||
PR_FREEIF(mdd);
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1834,7 +1847,7 @@ mime_bridge_create_draft_stream(
|
|||
mdd->options->decompose_file_output_fn = mime_decompose_file_output_fn;
|
||||
mdd->options->decompose_file_close_fn = mime_decompose_file_close_fn;
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), (nsISupports**)&(mdd->options->prefs));
|
||||
rv = nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), (nsISupports**)&(mdd->options->prefs));
|
||||
if (! (mdd->options->prefs && NS_SUCCEEDED(rv)))
|
||||
{
|
||||
PR_FREEIF(mdd);
|
||||
|
|
|
@ -46,6 +46,9 @@ static int MimeInlineTextPlainFlowed_parse_eof (MimeObject *, PRBool);
|
|||
|
||||
static MimeInlineTextPlainFlowedExData *MimeInlineTextPlainFlowedExDataList = 0;
|
||||
|
||||
extern "C" char *MimeTextBuildPrefixCSS(PRInt32 quotedSizeSetting, // mail.quoted_size
|
||||
PRInt32 quotedStyleSetting, // mail.quoted_style
|
||||
char *citationColor); // mail.citation_color
|
||||
|
||||
|
||||
static int
|
||||
|
@ -91,6 +94,20 @@ MimeInlineTextPlainFlowed_parse_begin (MimeObject *obj)
|
|||
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to get the mail.fixed_width_messages pref");
|
||||
}
|
||||
|
||||
MimeInlineTextPlainFlowed *text = (MimeInlineTextPlainFlowed *) obj;
|
||||
|
||||
// Ok, first get the quoting settings.
|
||||
text->mQuotedSizeSetting = 0; // mail.quoted_size
|
||||
text->mQuotedStyleSetting = 0; // mail.quoted_style
|
||||
text->mCitationColor = nsnull; // mail.citation_color
|
||||
|
||||
if (prefs)
|
||||
{
|
||||
prefs->GetIntPref("mail.quoted_size", &(text->mQuotedSizeSetting));
|
||||
prefs->GetIntPref("mail.quoted_style", &(text->mQuotedStyleSetting));
|
||||
prefs->CopyCharPref("mail.citation_color", &(text->mCitationColor));
|
||||
}
|
||||
|
||||
// Link it up.
|
||||
exdata->next = MimeInlineTextPlainFlowedExDataList;
|
||||
MimeInlineTextPlainFlowedExDataList = exdata;
|
||||
|
@ -156,6 +173,13 @@ MimeInlineTextPlainFlowed_parse_eof (MimeObject *obj, PRBool abort_p)
|
|||
quotelevel--;
|
||||
}
|
||||
|
||||
// Make sure we close out any <DIV>'s if they are open!
|
||||
MimeInlineTextPlainFlowed *text = (MimeInlineTextPlainFlowed *) obj;
|
||||
PR_FREEIF(text->mCitationColor);
|
||||
|
||||
// Close out the block quote
|
||||
status = MimeObject_write(obj, "</DIV>", 6, PR_FALSE);
|
||||
|
||||
if(fixedwidthfont)
|
||||
{
|
||||
// *don't work* status = MimeObject_write(obj, "</div>", 6, PR_FALSE);
|
||||
|
@ -388,7 +412,18 @@ MimeInlineTextPlainFlowed_parse_line (char *line, PRInt32 length, MimeObject *ob
|
|||
*outlinep='t'; outlinep++;
|
||||
*outlinep='t'; outlinep++;
|
||||
*outlinep='>'; outlinep++;
|
||||
}
|
||||
}
|
||||
|
||||
// This is to have us observe the user pref settings for citations
|
||||
MimeInlineTextPlainFlowed *tObj = (MimeInlineTextPlainFlowed *) obj;
|
||||
char *openDiv = MimeTextBuildPrefixCSS(tObj->mQuotedSizeSetting,
|
||||
tObj->mQuotedStyleSetting,
|
||||
tObj->mCitationColor);
|
||||
if (openDiv)
|
||||
{
|
||||
status = MimeObject_write(obj, openDiv, nsCRT::strlen(openDiv), PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
}
|
||||
while(quoteleveldiff<0) {
|
||||
quoteleveldiff++;
|
||||
|
|
|
@ -42,7 +42,10 @@ struct MimeInlineTextPlainFlowedClass {
|
|||
extern MimeInlineTextPlainFlowedClass mimeInlineTextPlainFlowedClass;
|
||||
|
||||
struct MimeInlineTextPlainFlowed {
|
||||
MimeInlineText text;
|
||||
MimeInlineText text;
|
||||
PRInt32 mQuotedSizeSetting; // mail.quoted_size
|
||||
PRInt32 mQuotedStyleSetting; // mail.quoted_style
|
||||
char *mCitationColor; // mail.citation_color
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "mimemoz2.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPref.h"
|
||||
#include "prprf.h"
|
||||
|
||||
static NS_DEFINE_CID(kTXTToHTMLConvCID, MOZITXTTOHTMLCONV_CID);
|
||||
static NS_DEFINE_CID(kCPrefServiceCID, NS_PREF_CID);
|
||||
|
@ -56,6 +57,58 @@ MimeInlineTextPlainClassInitialize(MimeInlineTextPlainClass *clazz)
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
char *
|
||||
MimeTextBuildPrefixCSS(PRInt32 quotedSizeSetting, // mail.quoted_size
|
||||
PRInt32 quotedStyleSetting, // mail.quoted_style
|
||||
char *citationColor) // mail.citation_color
|
||||
{
|
||||
char *openDiv = nsnull;
|
||||
nsCString formatString;
|
||||
|
||||
formatString = "<DIV name=\"text-cite\" style=\"";
|
||||
|
||||
switch (quotedStyleSetting)
|
||||
{
|
||||
case 0: // regular
|
||||
break;
|
||||
case 1: // bold
|
||||
formatString.Append("font-weight: bold; ");
|
||||
break;
|
||||
case 2: // italic
|
||||
formatString.Append("font-style: italic; ");
|
||||
break;
|
||||
case 3: // bold-italic
|
||||
formatString.Append("font-weight: bold; font-style: italic; ");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (quotedSizeSetting)
|
||||
{
|
||||
case 0: // regular
|
||||
break;
|
||||
case 1: // bigger
|
||||
formatString.Append("font-size: bigger; ");
|
||||
break;
|
||||
case 2: // smaller
|
||||
formatString.Append("font-size: smaller; ");
|
||||
break;
|
||||
}
|
||||
|
||||
if (citationColor)
|
||||
{
|
||||
formatString.Append("color: %s;\">");
|
||||
openDiv = PR_smprintf(formatString, citationColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
formatString.Append("\">");
|
||||
openDiv = formatString.ToNewCString();
|
||||
}
|
||||
|
||||
return openDiv;
|
||||
}
|
||||
|
||||
static int
|
||||
MimeInlineTextPlain_parse_begin (MimeObject *obj)
|
||||
{
|
||||
|
@ -70,6 +123,7 @@ MimeInlineTextPlain_parse_begin (MimeObject *obj)
|
|||
obj->options->write_html_p &&
|
||||
obj->options->output_fn)
|
||||
{
|
||||
MimeInlineTextPlain *text = (MimeInlineTextPlain *) obj;
|
||||
char* strs[4];
|
||||
char* s;
|
||||
strs[0] = "<PRE>";
|
||||
|
@ -77,6 +131,20 @@ MimeInlineTextPlain_parse_begin (MimeObject *obj)
|
|||
strs[2] = "<PRE WRAP>";
|
||||
strs[3] = "<PRE WRAP style=\"font-family: serif;\">";
|
||||
|
||||
// Ok, first get the quoting settings.
|
||||
text->mInsideQuote = PR_FALSE;
|
||||
text->mQuotedSizeSetting = 0; // mail.quoted_size
|
||||
text->mQuotedStyleSetting = 0; // mail.quoted_style
|
||||
text->mCitationColor = nsnull; // mail.citation_color
|
||||
|
||||
nsIPref *prefs = GetPrefServiceManager(obj->options);
|
||||
if (prefs)
|
||||
{
|
||||
prefs->GetIntPref("mail.quoted_size", &(text->mQuotedSizeSetting));
|
||||
prefs->GetIntPref("mail.quoted_style", &(text->mQuotedStyleSetting));
|
||||
prefs->CopyCharPref("mail.citation_color", &(text->mCitationColor));
|
||||
}
|
||||
|
||||
// For quoting, keep it simple...
|
||||
if ( (obj->options->format_out == nsMimeOutput::nsMimeMessageQuoting) ||
|
||||
(obj->options->format_out == nsMimeOutput::nsMimeMessageBodyQuoting) )
|
||||
|
@ -124,7 +192,18 @@ MimeInlineTextPlain_parse_eof (MimeObject *obj, PRBool abort_p)
|
|||
status = MimeObject_write(obj, s, nsCRT::strlen(s), PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
|
||||
/* text/plain objects always have separators before and after them.
|
||||
// Make sure we close out any <DIV>'s if they are open!
|
||||
MimeInlineTextPlain *text = (MimeInlineTextPlain *) obj;
|
||||
PR_FREEIF(text->mCitationColor);
|
||||
|
||||
if (text->mInsideQuote)
|
||||
{
|
||||
char *closeDiv = "</DIV>";
|
||||
status = MimeObject_write(obj, closeDiv, nsCRT::strlen(closeDiv), PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
/* text/plain objects always have separators before and after them.
|
||||
Note that this is not the case for text/enriched objects.
|
||||
*/
|
||||
status = MimeObject_write_separator(obj);
|
||||
|
@ -180,7 +259,39 @@ MimeInlineTextPlain_parse_line (char *line, PRInt32 length, MimeObject *obj)
|
|||
obj->options->force_user_charset ||
|
||||
obj->options->format_out == nsMimeOutput::nsMimeMessageSaveAs
|
||||
) );
|
||||
|
||||
|
||||
// Before we do any other processing, we should figure out if we need to
|
||||
// put this information in a <DIV> tag
|
||||
MimeInlineTextPlain *text = (MimeInlineTextPlain *) obj;
|
||||
if (text->mInsideQuote)
|
||||
{
|
||||
if (line[0] != '>')
|
||||
{
|
||||
char *closeDiv = "</DIV>";
|
||||
status = MimeObject_write(obj, closeDiv, nsCRT::strlen(closeDiv), PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
text->mInsideQuote = PR_FALSE;
|
||||
}
|
||||
}
|
||||
else if ( (line[0] == '>') &&
|
||||
( (obj) &&
|
||||
obj->options->format_out != nsMimeOutput::nsMimeMessageQuoting &&
|
||||
obj->options->format_out != nsMimeOutput::nsMimeMessageBodyQuoting ) )
|
||||
{
|
||||
|
||||
char *openDiv = MimeTextBuildPrefixCSS(text->mQuotedSizeSetting,
|
||||
text->mQuotedStyleSetting,
|
||||
text->mCitationColor);
|
||||
if (openDiv)
|
||||
{
|
||||
status = MimeObject_write(obj, openDiv, nsCRT::strlen(openDiv), PR_FALSE);
|
||||
if (status < 0) return status;
|
||||
text->mInsideQuote = PR_TRUE;
|
||||
}
|
||||
|
||||
PR_FREEIF(openDiv);
|
||||
}
|
||||
|
||||
if (!skipConversion)
|
||||
{
|
||||
nsString strline(line, length);
|
||||
|
|
|
@ -39,7 +39,11 @@ struct MimeInlineTextPlainClass {
|
|||
extern MimeInlineTextPlainClass mimeInlineTextPlainClass;
|
||||
|
||||
struct MimeInlineTextPlain {
|
||||
MimeInlineText text;
|
||||
MimeInlineText text;
|
||||
PRBool mInsideQuote;
|
||||
PRInt32 mQuotedSizeSetting; // mail.quoted_size
|
||||
PRInt32 mQuotedStyleSetting; // mail.quoted_style
|
||||
char *mCitationColor; // mail.citation_color
|
||||
};
|
||||
|
||||
#endif /* _MIMETPLA_H_ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче