Fix for quoting problem - Bug #17983 - r: alecf

This commit is contained in:
rhp%netscape.com 1999-11-09 03:05:10 +00:00
Родитель 302bb5c02a
Коммит f4a331f24b
4 изменённых файлов: 53 добавлений и 75 удалений

Просмотреть файл

@ -751,7 +751,8 @@ mime_generate_attachment_headers (const char *type, const char *encoding,
PRBool /*digest_p*/,
nsMsgAttachmentHandler * /*ma*/,
const char *charset,
const char *content_id)
const char *content_id,
PRBool aBodyDocument)
{
nsresult rv;
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
@ -796,22 +797,23 @@ mime_generate_attachment_headers (const char *type, const char *encoding,
}
}
// Add format=flowed as in RFC 2646 unless asked to not do that.
PRBool sendFlowed = PR_TRUE; /* rhp - add this */
if(type && !PL_strcasecmp(type, "text/plain") && prefs)
// Only do this if we are in the body of a message
if (aBodyDocument)
{
prefs->GetBoolPref("mail.send_plaintext_flowed", &sendFlowed);
if (sendFlowed)
PUSH_STRING ("; format=flowed");
else
// Add format=flowed as in RFC 2646 unless asked to not do that.
PRBool sendFlowed = PR_TRUE; /* rhp - add this */
if(type && !PL_strcasecmp(type, "text/plain") && prefs)
{
// This is the same as no format at all.
PUSH_STRING ("; format=fixed");
prefs->GetBoolPref("mail.send_plaintext_flowed", &sendFlowed);
if (sendFlowed)
PUSH_STRING ("; format=flowed");
else
{
// This is the same as no format at all.
PUSH_STRING ("; format=fixed");
}
}
}
}
if (x_mac_type && *x_mac_type) {
PUSH_STRING ("; x-mac-type=\"");
@ -2138,6 +2140,7 @@ ERROR_OUT:
#include "nsParserCIID.h"
#include "nsHTMLToTXTSinkStream.h"
#include "CNavDTD.h"
#include "nsICharsetConverterManager.h"
nsresult
ConvertBufToPlainText(nsString &aConBuf, const char *charSet)
@ -2161,14 +2164,6 @@ ConvertBufToPlainText(nsString &aConBuf, const char *charSet)
sink->DoFragment(PR_TRUE);
parser->SetContentSink(sink);
// Set the charset...
//
if (charSet)
{
nsAutoString cSet(charSet);
parser->SetDocumentCharset(cSet, kCharsetFromMetaTag);
}
nsIDTD* dtd = nsnull;
rv = NS_NewNavHTMLDTD(&dtd);
if (NS_SUCCEEDED(rv))
@ -2181,11 +2176,15 @@ ConvertBufToPlainText(nsString &aConBuf, const char *charSet)
}
NS_RELEASE(parser);
//
// Now assign the results if we worked!
// Now if we get here, we need to get from ASCII text to
// UTF-8 format or there is a problem downstream...
//
if (NS_SUCCEEDED(rv))
{
aConBuf = convertedText;
}
}
return rv;

Просмотреть файл

@ -76,7 +76,8 @@ char *mime_generate_attachment_headers (const char *type,
PRBool digest_p,
nsMsgAttachmentHandler *ma,
const char *charset,
const char *content_id);
const char *content_id,
PRBool aBodyDocument);
char *msg_generate_message_id (nsIMsgIdentity*);

Просмотреть файл

@ -44,6 +44,7 @@
#include "nsMsgPrompts.h"
#include "nsMimeTypes.h"
#include "nsICharsetConverterManager.h"
#include "nsTextFormater.h"
// XXX temporary so we can use the current identity hack -alecf
#include "nsIMsgMailSession.h"
@ -111,46 +112,6 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CI
nsresult
ConvertAndLoadComposeWindow(nsIEditorShell *aEditor, nsString aBuf, PRBool aQuoted, PRBool aHTMLEditor)
{
nsresult res;
nsString inputCharset("UTF-8");
nsIUnicodeDecoder *decoder = nsnull;
PRInt32 unicharLength = 0;
PRUnichar *unicodeInputString = nsnull; // Unicode version of input
char *inputString = nsnull; // original string...
PRInt32 inputStringLength;
// Get the service for charset conversion...
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
if (NS_FAILED(res) || !ccm)
return NS_ERROR_FAILURE;
// Get the decoder to go from UTF-8 to Unicode...
ccm->GetUnicodeDecoder(&inputCharset, &decoder);
if (!decoder)
return NS_ERROR_FAILURE;
// This could go away if we could get the aBuf in oneByteChar format...
inputString = aBuf.ToNewCString();
inputStringLength = (PRInt32) nsCRT::strlen(inputString);
// Get the maximum output length and create the output buffer...
res = decoder->GetMaxLength(inputString, inputStringLength, &unicharLength);
unicodeInputString = (PRUnichar *) PR_Malloc((unicharLength + 1) * sizeof(PRUnichar));
if (!unicodeInputString)
{
PR_FREEIF(inputString);
return NS_ERROR_FAILURE;
}
nsCRT::memset(unicodeInputString, 0, ((unicharLength + 1) * sizeof(PRUnichar)));
res = decoder->Convert(inputString, &inputStringLength, unicodeInputString, &unicharLength);
if (NS_FAILED(res))
{
PR_FREEIF(inputString);
PR_FREEIF(unicodeInputString);
return NS_ERROR_FAILURE;
}
// Now, insert it into the editor...
//
// Akkana: There is a problem inserting converted unicode text into
@ -163,18 +124,17 @@ ConvertAndLoadComposeWindow(nsIEditorShell *aEditor, nsString aBuf, PRBool aQuot
// "if (aQuoted)"
//
// RICHIE SHERRY if (aQuoted)
//
if ( (aQuoted) && (aHTMLEditor) )
aEditor->InsertAsQuotation(unicodeInputString);
aEditor->InsertAsQuotation(aBuf.GetUnicode());
else
{
if (aHTMLEditor)
aEditor->InsertSource(unicodeInputString);
aEditor->InsertSource(aBuf.GetUnicode());
else
aEditor->InsertText(unicodeInputString);
aEditor->InsertText(aBuf.GetUnicode());
}
PR_FREEIF(inputString);
PR_FREEIF(unicodeInputString);
return NS_OK;
}
@ -906,8 +866,8 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIChannel * /* aChanne
}
NS_IMETHODIMP QuotingOutputStreamListener::OnDataAvailable(nsIChannel * /* aChannel */,
nsISupports *ctxt, nsIInputStream *inStr,
PRUint32 sourceOffset, PRUint32 count)
nsISupports *ctxt, nsIInputStream *inStr,
PRUint32 sourceOffset, PRUint32 count)
{
nsresult rv = NS_OK;
if (!inStr)
@ -924,7 +884,22 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnDataAvailable(nsIChannel * /* aChan
newBuf[count] = '\0';
if (NS_SUCCEEDED(rv) && numWritten > 0)
{
mMsgBody += newBuf;
// RICHIE SHERRY
// Going to try to change this from a simple append to converting the
// data to UCS-2 before appending to the mMsgBody
//
// USED TO BE THIS mMsgBody += newBuf;
PRUnichar *u = nsnull;
nsAutoString fmt("%s");
u = nsTextFormater::smprintf(fmt.GetUnicode(), newBuf); // this converts UTF-8 to UCS-2
if (u)
{
mMsgBody.Append(u);
PR_FREEIF(u);
}
else
mMsgBody += newBuf;
}
PR_FREEIF(newBuf);

Просмотреть файл

@ -740,7 +740,8 @@ nsMsgComposeAndSend::GatherMimeAttachments()
m_digest_p,
m_plaintext,
mCompFields->GetCharacterSet(),
nsnull);
nsnull,
PR_TRUE);
if (!hdrs)
goto FAILMEM;
status = plainpart->SetOtherHeaders(hdrs);
@ -948,7 +949,8 @@ nsMsgComposeAndSend::GatherMimeAttachments()
m_digest_p,
nsnull, /* no "ma"! */
mCompFields->GetCharacterSet(),
nsnull);
nsnull,
PR_TRUE);
if (!hdrs)
goto FAILMEM;
status = mainbody->AppendOtherHeaders(hdrs);
@ -1169,7 +1171,8 @@ nsMsgComposeAndSend::PreProcessPart(nsMsgAttachmentHandler *ma,
// we determine from
// the file or none
// at all!
ma->m_content_id);
ma->m_content_id,
PR_FALSE);
if (!hdrs)
return 0;