зеркало из https://github.com/mozilla/pjs.git
New quoting functionality
This commit is contained in:
Родитель
592245f004
Коммит
2878f72dc2
|
@ -27,6 +27,7 @@ XPIDLSRCS = \
|
||||||
nsIMsgComposeService.idl \
|
nsIMsgComposeService.idl \
|
||||||
nsIMsgCompose.idl \
|
nsIMsgCompose.idl \
|
||||||
nsIMsgCompFields.idl \
|
nsIMsgCompFields.idl \
|
||||||
|
nsIMsgQuote.idl \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
EXPORTS = \
|
EXPORTS = \
|
||||||
|
|
|
@ -22,6 +22,7 @@ XPIDLSRCS = \
|
||||||
.\nsIMsgComposeService.idl \
|
.\nsIMsgComposeService.idl \
|
||||||
.\nsIMsgCompose.idl \
|
.\nsIMsgCompose.idl \
|
||||||
.\nsIMsgCompFields.idl \
|
.\nsIMsgCompFields.idl \
|
||||||
|
.\nsIMsgQuote.idl \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
|
@ -44,6 +44,7 @@ EXPORTS = \
|
||||||
nsMsgAttachmentHandler.h \
|
nsMsgAttachmentHandler.h \
|
||||||
nsMsgPrompts.h \
|
nsMsgPrompts.h \
|
||||||
nsMsgTransition.h \
|
nsMsgTransition.h \
|
||||||
|
nsMsgQuote.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
CPPSRCS = \
|
CPPSRCS = \
|
||||||
|
@ -68,6 +69,7 @@ CPPSRCS = \
|
||||||
nsMsgPrompts.cpp \
|
nsMsgPrompts.cpp \
|
||||||
nsMsgComposeService.cpp \
|
nsMsgComposeService.cpp \
|
||||||
nsMsgCompose.cpp \
|
nsMsgCompose.cpp \
|
||||||
|
nsMsgQuote.cpp \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||||
|
|
|
@ -34,6 +34,7 @@ EXPORTS= nsSmtpUrl.h \
|
||||||
nsMsgComposeService.h \
|
nsMsgComposeService.h \
|
||||||
nsMsgCompose.h \
|
nsMsgCompose.h \
|
||||||
nsMsgCompFields.h \
|
nsMsgCompFields.h \
|
||||||
|
nsMsgQuote.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -62,6 +63,7 @@ CPP_OBJS= .\$(OBJDIR)\nsMsgCompFields.obj \
|
||||||
.\$(OBJDIR)\nsMsgI18N.obj \
|
.\$(OBJDIR)\nsMsgI18N.obj \
|
||||||
.\$(OBJDIR)\nsMsgAttachmentHandler.obj \
|
.\$(OBJDIR)\nsMsgAttachmentHandler.obj \
|
||||||
.\$(OBJDIR)\nsMsgPrompts.obj \
|
.\$(OBJDIR)\nsMsgPrompts.obj \
|
||||||
|
.\$(OBJDIR)\nsMsgQuote.obj \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -557,22 +557,22 @@ void
|
||||||
nsMsgAttachmentHandler::AnalyzeSnarfedFile(void)
|
nsMsgAttachmentHandler::AnalyzeSnarfedFile(void)
|
||||||
{
|
{
|
||||||
char chunk[256];
|
char chunk[256];
|
||||||
PRFileDesc *fileHdl = NULL;
|
|
||||||
PRInt32 numRead = 0;
|
PRInt32 numRead = 0;
|
||||||
|
|
||||||
|
|
||||||
if (m_file_name && *m_file_name)
|
if (m_file_name && *m_file_name)
|
||||||
{
|
{
|
||||||
fileHdl = PR_Open(m_file_name, PR_RDONLY, 0);
|
nsFileSpec aPath(m_file_name);
|
||||||
if (fileHdl)
|
nsInputFileStream fileHdl(aPath, PR_RDONLY, 0);
|
||||||
|
if (fileHdl.is_open())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
numRead = PR_Read(fileHdl, chunk, 256);
|
numRead = fileHdl.read(chunk, 256);
|
||||||
if (numRead > 0)
|
if (numRead > 0)
|
||||||
AnalyzeDataChunk(chunk, numRead);
|
AnalyzeDataChunk(chunk, numRead);
|
||||||
}
|
}
|
||||||
while (numRead > 0);
|
while (numRead > 0);
|
||||||
PR_Close(fileHdl);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -546,7 +546,8 @@ mime_generate_headers (nsMsgCompFields *fields,
|
||||||
pNetService->GetAppCodeName(aNSStr);
|
pNetService->GetAppCodeName(aNSStr);
|
||||||
sCStr = aNSStr.ToNewCString();
|
sCStr = aNSStr.ToNewCString();
|
||||||
if (sCStr) {
|
if (sCStr) {
|
||||||
PUSH_STRING ("X-Mailer: ");
|
// PUSH_STRING ("X-Mailer: "); // To be more standards compliant
|
||||||
|
PUSH_STRING ("User-Agent: ");
|
||||||
PUSH_STRING(sCStr);
|
PUSH_STRING(sCStr);
|
||||||
delete [] sCStr;
|
delete [] sCStr;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
#include "nsMsgSend.h"
|
#include "nsMsgSend.h"
|
||||||
#include "nsIMessenger.h" //temporary!
|
#include "nsIMessenger.h" //temporary!
|
||||||
#include "nsIMessage.h" //temporary!
|
#include "nsIMessage.h" //temporary!
|
||||||
|
#include "nsMsgQuote.h"
|
||||||
|
#include "nsIPref.h"
|
||||||
|
|
||||||
#ifdef XP_UNIX
|
#ifdef XP_UNIX
|
||||||
#define TEMP_PATH_DIR "/usr/tmp/"
|
#define TEMP_PATH_DIR "/usr/tmp/"
|
||||||
|
@ -69,6 +70,7 @@ nsMsgCompose::nsMsgCompose()
|
||||||
|
|
||||||
nsMsgCompose::~nsMsgCompose()
|
nsMsgCompose::~nsMsgCompose()
|
||||||
{
|
{
|
||||||
|
NS_RELEASE(m_editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -406,28 +408,19 @@ nsresult nsMsgCompose::CloseWindow()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompose::GetEditor(nsIEditorShell * *aEditor)
|
||||||
nsresult nsMsgCompose::GetEditor(nsIEditorShell * *aEditor)
|
{
|
||||||
{
|
*aEditor = m_editor;
|
||||||
*aEditor = nsnull;
|
return NS_OK;
|
||||||
return NS_OK;
|
}
|
||||||
}
|
|
||||||
|
nsresult nsMsgCompose::SetEditor(nsIEditorShell * aEditor)
|
||||||
|
{
|
||||||
nsresult nsMsgCompose::SetEditor(nsIEditorShell * aEditor)
|
m_editor = aEditor;
|
||||||
{
|
NS_ADDREF(m_editor);
|
||||||
nsresult rv;
|
return NS_OK;
|
||||||
/*
|
}
|
||||||
if (aEditor)
|
|
||||||
rv = aEditor->QueryInterface(nsIEditorShell::GetIID(), (void **)&m_editor);
|
|
||||||
else
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
*/
|
|
||||||
m_editor = aEditor;
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
nsresult nsMsgCompose::GetDomWindow(nsIDOMWindow * *aDomWindow)
|
nsresult nsMsgCompose::GetDomWindow(nsIDOMWindow * *aDomWindow)
|
||||||
{
|
{
|
||||||
|
@ -520,11 +513,13 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI, MSG_Compo
|
||||||
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(cString, encodedCharset, decodedString)))
|
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(cString, encodedCharset, decodedString)))
|
||||||
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString)))
|
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString)))
|
||||||
{
|
{
|
||||||
m_compFields->SetTo(aCString, NULL);
|
m_compFields->SetCc(aCString, NULL);
|
||||||
PR_Free(aCString);
|
PR_Free(aCString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HackToGetBody(1);
|
|
||||||
|
QuoteOriginalMessage(originalMsgURI, 1);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSGCOMP_TYPE_ForwardAsAttachment:
|
case MSGCOMP_TYPE_ForwardAsAttachment:
|
||||||
|
@ -547,11 +542,11 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI, MSG_Compo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == MSGCOMP_TYPE_ForwardAsAttachment)
|
if (type == MSGCOMP_TYPE_ForwardAsAttachment)
|
||||||
HackToGetBody(0);
|
QuoteOriginalMessage(originalMsgURI, 0);
|
||||||
else if (type == MSGCOMP_TYPE_ForwardInline)
|
else if (type == MSGCOMP_TYPE_ForwardInline)
|
||||||
HackToGetBody(2);
|
QuoteOriginalMessage(originalMsgURI, 2);
|
||||||
else
|
else
|
||||||
HackToGetBody(1);
|
QuoteOriginalMessage(originalMsgURI, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -560,6 +555,147 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI, MSG_Compo
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// THIS IS THE CLASS THAT IS THE STREAM CONSUMER OF THE HTML OUPUT
|
||||||
|
// FROM LIBMIME. THIS IS FOR QUOTING
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
QuotingOutputStreamImpl::~QuotingOutputStreamImpl()
|
||||||
|
{
|
||||||
|
if (mComposeObj)
|
||||||
|
NS_RELEASE(mComposeObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
QuotingOutputStreamImpl::QuotingOutputStreamImpl(void)
|
||||||
|
{
|
||||||
|
mComposeObj = nsnull;
|
||||||
|
mMsgBody = "<br><BLOCKQUOTE TYPE=CITE><html><br>--- Original Message ---<br><br>";
|
||||||
|
NS_INIT_REFCNT();
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
QuotingOutputStreamImpl::Close(void)
|
||||||
|
{
|
||||||
|
if (mComposeObj)
|
||||||
|
{
|
||||||
|
mMsgBody += "</html></BLOCKQUOTE>";
|
||||||
|
nsIMsgCompFields *aCompFields;
|
||||||
|
mComposeObj->GetCompFields(&aCompFields);
|
||||||
|
if (aCompFields)
|
||||||
|
aCompFields->SetBody(nsAutoCString(mMsgBody), NULL);
|
||||||
|
|
||||||
|
nsIEditorShell *aEditor = nsnull;
|
||||||
|
mComposeObj->GetEditor(&aEditor);
|
||||||
|
|
||||||
|
if (aEditor)
|
||||||
|
{
|
||||||
|
if (mMsgBody.Length())
|
||||||
|
{
|
||||||
|
// This is ugly...but hopefully effective...
|
||||||
|
nsString fileName(TEMP_PATH_DIR);
|
||||||
|
fileName += TEMP_MESSAGE_OUT;
|
||||||
|
|
||||||
|
nsFileSpec aPath(fileName);
|
||||||
|
nsOutputFileStream tempFile(aPath);
|
||||||
|
|
||||||
|
if (tempFile.is_open())
|
||||||
|
{
|
||||||
|
tempFile.write(nsAutoCString(mMsgBody), mMsgBody.Length());
|
||||||
|
tempFile.close();
|
||||||
|
|
||||||
|
nsAutoString urlStr = nsFileURL(aPath).GetURLString();
|
||||||
|
aEditor->LoadUrl(urlStr.GetUnicode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
QuotingOutputStreamImpl::Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount)
|
||||||
|
{
|
||||||
|
char *newBuf = (char *)PR_Malloc(aCount + 1);
|
||||||
|
*aWriteCount = 0;
|
||||||
|
if (!newBuf)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
*aWriteCount = aCount;
|
||||||
|
|
||||||
|
nsCRT::memcpy(newBuf, aBuf, aCount);
|
||||||
|
newBuf[aCount] = '\0';
|
||||||
|
mMsgBody += newBuf;
|
||||||
|
printf("%s", newBuf);
|
||||||
|
PR_FREEIF(newBuf);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
QuotingOutputStreamImpl::Flush(void)
|
||||||
|
{
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
QuotingOutputStreamImpl::SetComposeObj(nsMsgCompose *obj)
|
||||||
|
{
|
||||||
|
mComposeObj = obj;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS(QuotingOutputStreamImpl, nsIOutputStream::GetIID());
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// END OF QUOTING CONSUMER STREAM
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// net service definitions....
|
||||||
|
static NS_DEFINE_CID(kMsgQuoteCID, NS_MSGQUOTE_CID);
|
||||||
|
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsMsgCompose::QuoteOriginalMessage(const PRUnichar *originalMsgURI, PRInt32 what) // New template
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
//
|
||||||
|
// For now, you need to set a pref to do the new quoting
|
||||||
|
//
|
||||||
|
PRBool newQuoting = PR_FALSE;
|
||||||
|
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
|
||||||
|
if (NS_SUCCEEDED(rv) && prefs)
|
||||||
|
{
|
||||||
|
rv = prefs->GetBoolPref("mail.new_quoting", &newQuoting);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!newQuoting)
|
||||||
|
{
|
||||||
|
HackToGetBody(what);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a mime parser (nsIStreamConverter)!
|
||||||
|
rv = nsComponentManager::CreateInstance(kMsgQuoteCID,
|
||||||
|
NULL, nsIMsgQuote::GetIID(),
|
||||||
|
(void **) getter_AddRefs(mQuote));
|
||||||
|
if (NS_FAILED(rv) || !mQuote)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
// Create the consumer output stream.. this will receive all the HTML from libmime
|
||||||
|
mOutStream = do_QueryInterface(new QuotingOutputStreamImpl());
|
||||||
|
if (!mOutStream)
|
||||||
|
{
|
||||||
|
printf("Failed to create nsIOutputStream\n");
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_ADDREF(this);
|
||||||
|
mOutStream->SetComposeObj(this);
|
||||||
|
|
||||||
|
// mBaseStream = do_QueryInterface(mOutStream);
|
||||||
|
return mQuote->QuoteMessage(originalMsgURI, mOutStream);
|
||||||
|
}
|
||||||
|
|
||||||
void nsMsgCompose::HackToGetBody(PRInt32 what)
|
void nsMsgCompose::HackToGetBody(PRInt32 what)
|
||||||
{
|
{
|
||||||
char *buffer = (char *) PR_CALLOC(16384);
|
char *buffer = (char *) PR_CALLOC(16384);
|
||||||
|
|
|
@ -21,7 +21,10 @@
|
||||||
#include "nsMsgCompFields.h"
|
#include "nsMsgCompFields.h"
|
||||||
#include "nsIWebShell.h"
|
#include "nsIWebShell.h"
|
||||||
#include "nsIWebShellWindow.h"
|
#include "nsIWebShellWindow.h"
|
||||||
|
#include "nsIOutputStream.h"
|
||||||
|
#include "nsIMsgQuote.h"
|
||||||
|
|
||||||
|
class QuotingOutputStreamImpl;
|
||||||
|
|
||||||
class nsMsgCompose : public nsIMsgCompose
|
class nsMsgCompose : public nsIMsgCompose
|
||||||
{
|
{
|
||||||
|
@ -56,9 +59,10 @@ class nsMsgCompose : public nsIMsgCompose
|
||||||
NS_IMETHOD CloseWindow();
|
NS_IMETHOD CloseWindow();
|
||||||
|
|
||||||
/* attribute nsIDOMEditorAppCore editor; */
|
/* attribute nsIDOMEditorAppCore editor; */
|
||||||
NS_IMETHOD GetEditor(nsIEditorShell * *aEditor);
|
/* attribute nsIEditorShell editor; */
|
||||||
NS_IMETHOD SetEditor(nsIEditorShell * aEditor);
|
NS_IMETHOD GetEditor(nsIEditorShell * *aEditor);
|
||||||
|
NS_IMETHOD SetEditor(nsIEditorShell * aEditor);
|
||||||
|
|
||||||
/* readonly attribute nsIDOMWindow domWindow; */
|
/* readonly attribute nsIDOMWindow domWindow; */
|
||||||
NS_IMETHOD GetDomWindow(nsIDOMWindow * *aDomWindow);
|
NS_IMETHOD GetDomWindow(nsIDOMWindow * *aDomWindow);
|
||||||
|
|
||||||
|
@ -71,19 +75,49 @@ class nsMsgCompose : public nsIMsgCompose
|
||||||
/* readonly attribute long wrapLength; */
|
/* readonly attribute long wrapLength; */
|
||||||
NS_IMETHOD GetWrapLength(PRInt32 *aWrapLength);
|
NS_IMETHOD GetWrapLength(PRInt32 *aWrapLength);
|
||||||
/******/
|
/******/
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
nsresult CreateMessage(const PRUnichar * originalMsgURI, MSG_ComposeType type, MSG_ComposeFormat format, nsISupports* object);
|
nsresult CreateMessage(const PRUnichar * originalMsgURI, MSG_ComposeType type, MSG_ComposeFormat format, nsISupports* object);
|
||||||
void HackToGetBody(PRInt32 what); //Temporary
|
void HackToGetBody(PRInt32 what); //Temporary
|
||||||
|
|
||||||
|
nsresult QuoteOriginalMessage(const PRUnichar * originalMsgURI, PRInt32 what); // New template
|
||||||
|
|
||||||
|
nsIEditorShell* m_editor;
|
||||||
nsIDOMWindow* m_window;
|
nsIDOMWindow* m_window;
|
||||||
nsIWebShell* m_webShell;
|
nsIWebShell* m_webShell;
|
||||||
nsIWebShellWindow* m_webShellWin;
|
nsIWebShellWindow* m_webShellWin;
|
||||||
nsIEditorShell* m_editor;
|
|
||||||
nsCOMPtr<nsMsgCompFields> m_compFields;
|
nsCOMPtr<nsMsgCompFields> m_compFields;
|
||||||
PRBool m_composeHTML;
|
PRBool m_composeHTML;
|
||||||
|
nsCOMPtr<QuotingOutputStreamImpl> mOutStream;
|
||||||
|
nsCOMPtr<nsIOutputStream> mBaseStream;
|
||||||
|
nsCOMPtr<nsIMsgQuote> mQuote;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// THIS IS THE CLASS THAT IS THE STREAM CONSUMER OF THE HTML OUPUT
|
||||||
|
// FROM LIBMIME. THIS IS FOR QUOTING
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
class QuotingOutputStreamImpl : public nsIOutputStream
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QuotingOutputStreamImpl(void);
|
||||||
|
virtual ~QuotingOutputStreamImpl(void);
|
||||||
|
|
||||||
|
// nsISupports interface
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
|
// nsIBaseStream interface
|
||||||
|
NS_IMETHOD Close(void);
|
||||||
|
|
||||||
|
// nsIOutputStream interface
|
||||||
|
NS_IMETHOD Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
|
||||||
|
|
||||||
|
NS_IMETHOD Flush(void);
|
||||||
|
|
||||||
|
NS_IMETHOD SetComposeObj(nsMsgCompose *obj);
|
||||||
|
|
||||||
|
private:
|
||||||
|
nsMsgCompose *mComposeObj;
|
||||||
|
nsString mMsgBody;
|
||||||
|
};
|
||||||
|
|
|
@ -20,4 +20,4 @@ nsMimeHtmlEmitter.h
|
||||||
nsMimeXmlEmitter.h
|
nsMimeXmlEmitter.h
|
||||||
nsMimeRawEmitter.h
|
nsMimeRawEmitter.h
|
||||||
nsEmitterUtils.h
|
nsEmitterUtils.h
|
||||||
|
nsMimeRebuffer.h
|
||||||
|
|
|
@ -21,15 +21,7 @@
|
||||||
#include "prmem.h"
|
#include "prmem.h"
|
||||||
#include "plstr.h"
|
#include "plstr.h"
|
||||||
|
|
||||||
extern "C" char *nsEscapeHTML(const char *string);
|
extern "C" PRBool EmitThisHeaderForPrefSetting(PRInt32 dispType, const char *header);
|
||||||
|
|
||||||
// mscott - I'm dumping this enum here for lack of a better
|
|
||||||
// common header file shared by nsMimeRawEmitter & nsMimeXmlEmitter
|
|
||||||
typedef enum {
|
|
||||||
MicroHeaders = 0,
|
|
||||||
NormalHeaders,
|
|
||||||
AllHeaders
|
|
||||||
} HeaderDisplayTypes;
|
|
||||||
|
|
||||||
#endif // _nsEmitterUtils_h_
|
#endif // _nsEmitterUtils_h_
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,9 @@ protected:
|
||||||
// For content type...
|
// For content type...
|
||||||
char *mAttachContentType;
|
char *mAttachContentType;
|
||||||
|
|
||||||
|
// For Header display
|
||||||
|
PRBool mHeaderDisplayType;
|
||||||
|
|
||||||
#ifdef DEBUG_rhp
|
#ifdef DEBUG_rhp
|
||||||
PRBool mReallyOutput;
|
PRBool mReallyOutput;
|
||||||
PRFileDesc *mLogFile; /* Temp file to put generated HTML into. */
|
PRFileDesc *mLogFile; /* Temp file to put generated HTML into. */
|
||||||
|
|
|
@ -23,6 +23,12 @@
|
||||||
#include "prtypes.h"
|
#include "prtypes.h"
|
||||||
#include "nsINetOStream.h"
|
#include "nsINetOStream.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
MicroHeaders = 0,
|
||||||
|
NormalHeaders,
|
||||||
|
AllHeaders
|
||||||
|
} HeaderDisplayTypes;
|
||||||
|
|
||||||
// {D01D7B59-DCCD-11d2-A411-00805F613C79}
|
// {D01D7B59-DCCD-11d2-A411-00805F613C79}
|
||||||
#define NS_IMIME_EMITTER_IID \
|
#define NS_IMIME_EMITTER_IID \
|
||||||
{ 0xd01d7b59, 0xdccd, 0x11d2, \
|
{ 0xd01d7b59, 0xdccd, 0x11d2, \
|
||||||
|
|
|
@ -26,6 +26,11 @@
|
||||||
{ 0xc9cdf8e5, 0x95fa, 0x11d2, \
|
{ 0xc9cdf8e5, 0x95fa, 0x11d2, \
|
||||||
{ 0x88, 0x7, 0x0, 0x80, 0x5f, 0x5a, 0x1f, 0xb8 } }
|
{ 0x88, 0x7, 0x0, 0x80, 0x5f, 0x5a, 0x1f, 0xb8 } }
|
||||||
|
|
||||||
|
// {588595CB-2012-11d3-8EF0-00A024A7D144}
|
||||||
|
#define NS_STREAM_CONVERTER_CID \
|
||||||
|
{ 0x588595cb, 0x2012, 0x11d3, \
|
||||||
|
{ 0x8e, 0xf0, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } };
|
||||||
|
|
||||||
class nsIStreamConverter : public nsIStreamListener {
|
class nsIStreamConverter : public nsIStreamListener {
|
||||||
public:
|
public:
|
||||||
static const nsIID& GetIID() { static nsIID iid = NS_ISTREAM_CONVERTER_IID; return iid; }
|
static const nsIID& GetIID() { static nsIID iid = NS_ISTREAM_CONVERTER_IID; return iid; }
|
||||||
|
@ -34,7 +39,7 @@ public:
|
||||||
// This is the output stream where the stream converter will write processed data after
|
// This is the output stream where the stream converter will write processed data after
|
||||||
// conversion.
|
// conversion.
|
||||||
//
|
//
|
||||||
NS_IMETHOD SetOutputStream(nsIOutputStream *outStream) = 0;
|
NS_IMETHOD SetOutputStream(nsIOutputStream *outStream, char *url) = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// The output listener can be set to allow for the flexibility of having the stream converter
|
// The output listener can be set to allow for the flexibility of having the stream converter
|
||||||
|
@ -43,6 +48,12 @@ public:
|
||||||
// the responsibility of the client of the stream converter to handle the resulting data.
|
// the responsibility of the client of the stream converter to handle the resulting data.
|
||||||
//
|
//
|
||||||
NS_IMETHOD SetOutputListener(nsIStreamListener *outListner) = 0;
|
NS_IMETHOD SetOutputListener(nsIStreamListener *outListner) = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// This is needed by libmime for MHTML link processing...the url is the URL string associated
|
||||||
|
// with this input stream
|
||||||
|
//
|
||||||
|
NS_IMETHOD SetStreamURL(char *url) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsIStreamConverter_h_ */
|
#endif /* nsIStreamConverter_h_ */
|
||||||
|
|
|
@ -62,8 +62,9 @@
|
||||||
#define HEADER_SENDER "Sender"
|
#define HEADER_SENDER "Sender"
|
||||||
#define HEADER_SUBJECT "Subject"
|
#define HEADER_SUBJECT "Subject"
|
||||||
#define HEADER_TO "To"
|
#define HEADER_TO "To"
|
||||||
#define HEADER_APPROVED_BY "Approved-By"
|
#define HEADER_APPROVED_BY "Approved-By"
|
||||||
#define HEADER_X_MAILER "X-Mailer"
|
#define HEADER_X_MAILER "X-Mailer"
|
||||||
|
#define HEADER_USER_AGENT "User-Agent"
|
||||||
#define HEADER_X_NEWSREADER "X-Newsreader"
|
#define HEADER_X_NEWSREADER "X-Newsreader"
|
||||||
#define HEADER_X_POSTING_SOFTWARE "X-Posting-Software"
|
#define HEADER_X_POSTING_SOFTWARE "X-Posting-Software"
|
||||||
#define HEADER_X_MOZILLA_STATUS "X-Mozilla-Status"
|
#define HEADER_X_MOZILLA_STATUS "X-Mozilla-Status"
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
# The contents of this file are subject to the Netscape Public License
|
||||||
|
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||||
|
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||||
|
# http://www.mozilla.org/NPL/
|
||||||
|
#
|
||||||
|
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||||
|
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||||
|
# for the specific language governing rights and limitations under the
|
||||||
|
# NPL.
|
||||||
|
#
|
||||||
|
# The Initial Developer of this code under the NPL is Netscape
|
||||||
|
# Communications Corporation. Portions created by Netscape are
|
||||||
|
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||||
|
# Reserved.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
nsMimeTypes.h
|
|
@ -26,6 +26,7 @@ MODULE=mime
|
||||||
LIBRARY_NAME=mime
|
LIBRARY_NAME=mime
|
||||||
IS_COMPONENT=1
|
IS_COMPONENT=1
|
||||||
EXPORTS =\
|
EXPORTS =\
|
||||||
|
nsMimeTypes.h \
|
||||||
nsMimeObjectClassAccess.h \
|
nsMimeObjectClassAccess.h \
|
||||||
nsMimeConverter.h \
|
nsMimeConverter.h \
|
||||||
mimetext.h \
|
mimetext.h \
|
||||||
|
@ -85,13 +86,15 @@ CPPSRCS = \
|
||||||
comi18n.cpp \
|
comi18n.cpp \
|
||||||
nsMimeTransition.cpp \
|
nsMimeTransition.cpp \
|
||||||
nsMsgHeaderParser.cpp \
|
nsMsgHeaderParser.cpp \
|
||||||
|
nsStreamConverter.cpp \
|
||||||
|
nsMimeEmitter2.cpp \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
CSRCS = \
|
CSRCS = \
|
||||||
oldi18n.c \
|
oldi18n.c \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
EXTRA_DSO_LDOPTS = \
|
EXTRA_DSO_LDOPTS = \
|
||||||
-L$(DIST)/bin \
|
-L$(DIST)/bin \
|
||||||
$(NSPR_LIBS) \
|
$(NSPR_LIBS) \
|
||||||
-lmozjs \
|
-lmozjs \
|
||||||
|
|
|
@ -23,6 +23,7 @@ include <$(DEPTH)\config\config.mak>
|
||||||
## exports
|
## exports
|
||||||
|
|
||||||
EXPORTS = \
|
EXPORTS = \
|
||||||
|
nsMimeTypes.h \
|
||||||
nsMimeObjectClassAccess.h \
|
nsMimeObjectClassAccess.h \
|
||||||
nsMimeConverter.h \
|
nsMimeConverter.h \
|
||||||
mimetext.h \
|
mimetext.h \
|
||||||
|
@ -98,6 +99,8 @@ OBJS= \
|
||||||
.\$(OBJDIR)\mimemoz2.obj \
|
.\$(OBJDIR)\mimemoz2.obj \
|
||||||
.\$(OBJDIR)\nsMsgHeaderParser.obj \
|
.\$(OBJDIR)\nsMsgHeaderParser.obj \
|
||||||
.\$(OBJDIR)\nsMimeURLUtils.obj \
|
.\$(OBJDIR)\nsMimeURLUtils.obj \
|
||||||
|
.\$(OBJDIR)\nsStreamConverter.obj \
|
||||||
|
.\$(OBJDIR)\nsMimeEmitter2.obj \
|
||||||
#
|
#
|
||||||
# THIS WILL NEED WORK AFTER WE GET A LIBMSG MORE XP-COM-afied
|
# THIS WILL NEED WORK AFTER WE GET A LIBMSG MORE XP-COM-afied
|
||||||
# .\$(OBJDIR)\mimedrft.obj \
|
# .\$(OBJDIR)\mimedrft.obj \
|
||||||
|
@ -124,4 +127,4 @@ include <$(DEPTH)/config/rules.mak>
|
||||||
|
|
||||||
install:: $(DLL)
|
install:: $(DLL)
|
||||||
$(MAKE_INSTALL) $(LIBNAME).$(DLL_SUFFIX) $(DIST)\bin\components
|
$(MAKE_INSTALL) $(LIBNAME).$(DLL_SUFFIX) $(DIST)\bin\components
|
||||||
$(MAKE_INSTALL) $(LIBNAME).$(LIB_SUFFIX) $(DIST)\lib
|
$(MAKE_INSTALL) $(LIBNAME).$(LIB_SUFFIX) $(DIST)\lib
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* Reserved.
|
* Reserved.
|
||||||
*/
|
*/
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsIURL.h"
|
||||||
#include "mimeebod.h"
|
#include "mimeebod.h"
|
||||||
#include "prmem.h"
|
#include "prmem.h"
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
|
|
|
@ -1887,12 +1887,6 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo
|
||||||
int i;
|
int i;
|
||||||
PRBool wrote_any_p = PR_FALSE;
|
PRBool wrote_any_p = PR_FALSE;
|
||||||
|
|
||||||
nsIMimeEmitter *mimeEmitter = GetMimeEmitter(opt);
|
|
||||||
|
|
||||||
// No emitter, no point.
|
|
||||||
if (!mimeEmitter)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
PR_ASSERT(hdrs);
|
PR_ASSERT(hdrs);
|
||||||
if (!hdrs)
|
if (!hdrs)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1992,10 +1986,10 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo
|
||||||
status = MimeHeaders_write_random_header_1(hdrs, name, c2, opt, PR_FALSE);
|
status = MimeHeaders_write_random_header_1(hdrs, name, c2, opt, PR_FALSE);
|
||||||
****************************************/
|
****************************************/
|
||||||
if (attachment)
|
if (attachment)
|
||||||
status = mimeEmitter->AddAttachmentField(name,
|
status = mimeEmitterAddAttachmentField(opt, name,
|
||||||
MimeHeaders_convert_header_value(opt, &c2));
|
MimeHeaders_convert_header_value(opt, &c2));
|
||||||
else
|
else
|
||||||
status = mimeEmitter->AddHeaderField(name,
|
status = mimeEmitterAddHeaderField(opt, name,
|
||||||
MimeHeaders_convert_header_value(opt, &c2));
|
MimeHeaders_convert_header_value(opt, &c2));
|
||||||
|
|
||||||
PR_Free(name);
|
PR_Free(name);
|
||||||
|
@ -2500,13 +2494,12 @@ MimeHeaders_write_attachment_box(MimeHeaders *hdrs,
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
nsIMimeEmitter *mimeEmitter = GetMimeEmitter(opt);
|
mimeEmitterStartAttachment(opt, lname, content_type, lname_url);
|
||||||
mimeEmitter->StartAttachment(lname, content_type, lname_url);
|
|
||||||
|
|
||||||
status = MimeHeaders_write_all_headers (hdrs, opt, TRUE);
|
status = MimeHeaders_write_all_headers (hdrs, opt, TRUE);
|
||||||
mimeEmitter->AddAttachmentField(HEADER_X_MOZILLA_PART_URL, lname_url);
|
mimeEmitterAddAttachmentField(opt, HEADER_X_MOZILLA_PART_URL, lname_url);
|
||||||
|
|
||||||
mimeEmitter->EndAttachment();
|
mimeEmitterEndAttachment(opt);
|
||||||
|
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
return status;
|
return status;
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsIEventQueueService.h"
|
#include "nsIEventQueueService.h"
|
||||||
#include "nsMimeStringResources.h"
|
#include "nsMimeStringResources.h"
|
||||||
|
#include "nsStreamConverter.h"
|
||||||
|
|
||||||
#ifdef MOZ_SECURITY
|
#ifdef MOZ_SECURITY
|
||||||
#include HG01944
|
#include HG01944
|
||||||
|
@ -228,20 +229,35 @@ mime_convert_rfc1522 (const char *input_line, PRInt32 input_length,
|
||||||
static int
|
static int
|
||||||
mime_output_fn(char *buf, PRInt32 size, void *stream_closure)
|
mime_output_fn(char *buf, PRInt32 size, void *stream_closure)
|
||||||
{
|
{
|
||||||
PRUint32 written;
|
PRUint32 written = 0;
|
||||||
struct mime_stream_data *msd = (struct mime_stream_data *) stream_closure;
|
struct mime_stream_data *msd = (struct mime_stream_data *) stream_closure;
|
||||||
PR_ASSERT(msd->pluginObj);
|
if ( ( (!msd->pluginObj) && (!msd->pluginObj2)) && ( (!msd->output_emitter) && (msd->output_emitter2)) )
|
||||||
if ( (!msd->pluginObj) || (!msd->output_emitter) )
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// Now, write to the WriteBody method if this is a message body and not
|
// Now, write to the WriteBody method if this is a message body and not
|
||||||
// a part retrevial
|
// a part retrevial
|
||||||
if (!msd->options->part_to_load)
|
if (!msd->options->part_to_load)
|
||||||
{
|
{
|
||||||
msd->output_emitter->WriteBody(buf, (PRUint32) size, &written);
|
if (msd->output_emitter)
|
||||||
|
{
|
||||||
|
msd->output_emitter->WriteBody(buf, (PRUint32) size, &written);
|
||||||
|
}
|
||||||
|
else if (msd->output_emitter2)
|
||||||
|
{
|
||||||
|
msd->output_emitter2->WriteBody(buf, (PRUint32) size, &written);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
msd->output_emitter->Write(buf, (PRUint32) size, &written);
|
{
|
||||||
|
if (msd->output_emitter)
|
||||||
|
{
|
||||||
|
msd->output_emitter->Write(buf, (PRUint32) size, &written);
|
||||||
|
}
|
||||||
|
else if (msd->output_emitter2)
|
||||||
|
{
|
||||||
|
msd->output_emitter2->Write(buf, (PRUint32) size, &written);
|
||||||
|
}
|
||||||
|
}
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,10 +541,10 @@ mime_output_init_fn (const char *type,
|
||||||
|
|
||||||
// Now, all of this stream creation is done outside of libmime, so this
|
// Now, all of this stream creation is done outside of libmime, so this
|
||||||
// is just a check of the pluginObj member and returning accordingly.
|
// is just a check of the pluginObj member and returning accordingly.
|
||||||
if (msd->pluginObj)
|
if ( (!msd->pluginObj) && (!msd->pluginObj2))
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return -1;
|
return -1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* If we've converted to HTML, then we've already done charset conversion,
|
/* If we've converted to HTML, then we've already done charset conversion,
|
||||||
so label this data as "internal/parser" to prevent it from being passed
|
so label this data as "internal/parser" to prevent it from being passed
|
||||||
|
@ -610,7 +626,10 @@ mime_image_begin(const char *image_url, const char *content_type,
|
||||||
// RICHIE_URL return 0;
|
// RICHIE_URL return 0;
|
||||||
// RICHIE_URL }
|
// RICHIE_URL }
|
||||||
|
|
||||||
mid->istream = (nsMIMESession *) msd->pluginObj;
|
if (msd->pluginObj)
|
||||||
|
mid->istream = (nsMIMESession *) msd->pluginObj;
|
||||||
|
else
|
||||||
|
mid->istream = (nsMIMESession *) msd->pluginObj2;
|
||||||
return mid;
|
return mid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,7 +718,8 @@ mime_image_write_buffer(char *buf, PRInt32 size, void *image_closure)
|
||||||
(struct mime_image_stream_data *) image_closure;
|
(struct mime_image_stream_data *) image_closure;
|
||||||
struct mime_stream_data *msd = mid->msd;
|
struct mime_stream_data *msd = mid->msd;
|
||||||
|
|
||||||
if ( (!msd->pluginObj) || (!msd->output_emitter) )
|
if ( ( (!msd->pluginObj) && (!msd->output_emitter) ) &&
|
||||||
|
( (!msd->pluginObj2) && (!msd->output_emitter2) ) )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1009,17 +1029,6 @@ extern int MIME_HasAttachments(MWContext *context)
|
||||||
**************************************************************
|
**************************************************************
|
||||||
**************************************************************/
|
**************************************************************/
|
||||||
|
|
||||||
nsIMimeEmitter *
|
|
||||||
GetMimeEmitter(MimeDisplayOptions *opt)
|
|
||||||
{
|
|
||||||
mime_stream_data *msd = (mime_stream_data *)opt->stream_closure;
|
|
||||||
if (!msd)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
nsIMimeEmitter *ptr = (nsIMimeEmitter *)(msd->output_emitter);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the connnection to prefs service manager */
|
/* Get the connnection to prefs service manager */
|
||||||
nsIPref *
|
nsIPref *
|
||||||
GetPrefServiceManager(MimeDisplayOptions *opt)
|
GetPrefServiceManager(MimeDisplayOptions *opt)
|
||||||
|
@ -1049,6 +1058,8 @@ mime_bridge_destroy_stream(void *newStream)
|
||||||
void *
|
void *
|
||||||
mime_bridge_create_stream(MimePluginInstance *newPluginObj,
|
mime_bridge_create_stream(MimePluginInstance *newPluginObj,
|
||||||
nsIMimeEmitter *newEmitter,
|
nsIMimeEmitter *newEmitter,
|
||||||
|
nsStreamConverter *newPluginObj2,
|
||||||
|
nsMimeEmitter2 *newEmitter2,
|
||||||
const char *urlString,
|
const char *urlString,
|
||||||
int format_out)
|
int format_out)
|
||||||
{
|
{
|
||||||
|
@ -1095,21 +1106,25 @@ mime_bridge_create_stream(MimePluginInstance *newPluginObj,
|
||||||
|
|
||||||
// Assign the new mime emitter - will handle output operations
|
// Assign the new mime emitter - will handle output operations
|
||||||
msd->output_emitter = newEmitter;
|
msd->output_emitter = newEmitter;
|
||||||
|
msd->output_emitter2 = newEmitter2;
|
||||||
|
|
||||||
// RICHIE_URL (msd->url)->address = PL_strdup(urlString);
|
// RICHIE_URL (msd->url)->address = PL_strdup(urlString);
|
||||||
|
|
||||||
msd->url_name = PL_strdup(urlString);
|
if (urlString)
|
||||||
if (!(msd->url_name))
|
|
||||||
{
|
{
|
||||||
delete msd->output_emitter;
|
msd->url_name = PL_strdup(urlString);
|
||||||
// RICHIE_URL PR_FREEIF(msd->url);
|
if (!(msd->url_name))
|
||||||
PR_FREEIF(msd);
|
{
|
||||||
return NULL;
|
// RICHIE_URL PR_FREEIF(msd->url);
|
||||||
|
PR_FREEIF(msd);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msd->context = context; // SHERRY - need to wax this soon
|
msd->context = context; // SHERRY - need to wax this soon
|
||||||
msd->format_out = format_out; // output format
|
msd->format_out = format_out; // output format
|
||||||
msd->pluginObj = newPluginObj; // the plugin object pointer
|
msd->pluginObj = newPluginObj; // the plugin object pointer
|
||||||
|
msd->pluginObj2 = newPluginObj2; // the plugin object pointer
|
||||||
|
|
||||||
msd->options = PR_NEW(MimeDisplayOptions);
|
msd->options = PR_NEW(MimeDisplayOptions);
|
||||||
if (!msd->options)
|
if (!msd->options)
|
||||||
|
@ -1510,3 +1525,214 @@ MimeGetStringByID(PRInt32 stringID)
|
||||||
PR_snprintf(buf, sizeof(buf), "[StringID %d?]", stringID);
|
PR_snprintf(buf, sizeof(buf), "[StringID %d?]", stringID);
|
||||||
return PL_strdup(buf);
|
return PL_strdup(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// To support 2 types of emitters...we need these routines :-(
|
||||||
|
nsIMimeEmitter *
|
||||||
|
GetMimeEmitter(MimeDisplayOptions *opt)
|
||||||
|
{
|
||||||
|
mime_stream_data *msd = (mime_stream_data *)opt->stream_closure;
|
||||||
|
if (!msd)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
nsIMimeEmitter *ptr = (nsIMimeEmitter *)(msd->output_emitter);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
mime_stream_data *
|
||||||
|
GetMSD(MimeDisplayOptions *opt)
|
||||||
|
{
|
||||||
|
if (!opt)
|
||||||
|
return nsnull;
|
||||||
|
mime_stream_data *msd = (mime_stream_data *)opt->stream_closure;
|
||||||
|
return msd;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" nsresult
|
||||||
|
mimeEmitterAddAttachmentField(MimeDisplayOptions *opt, const char *field, const char *value)
|
||||||
|
{
|
||||||
|
mime_stream_data *msd = GetMSD(opt);
|
||||||
|
if (!msd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (msd->output_emitter)
|
||||||
|
{
|
||||||
|
nsIMimeEmitter *emitter = (nsIMimeEmitter *)msd->output_emitter;
|
||||||
|
return emitter->AddAttachmentField(field, value);
|
||||||
|
}
|
||||||
|
else if (msd->output_emitter2)
|
||||||
|
{
|
||||||
|
nsMimeEmitter2 *emitter2 = (nsMimeEmitter2 *)msd->output_emitter2;
|
||||||
|
return emitter2->AddAttachmentField(field, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" nsresult
|
||||||
|
mimeEmitterAddHeaderField(MimeDisplayOptions *opt, const char *field, const char *value)
|
||||||
|
{
|
||||||
|
mime_stream_data *msd = GetMSD(opt);
|
||||||
|
if (!msd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (msd->output_emitter)
|
||||||
|
{
|
||||||
|
nsIMimeEmitter *emitter = (nsIMimeEmitter *)msd->output_emitter;
|
||||||
|
return emitter->AddHeaderField(field, value);
|
||||||
|
}
|
||||||
|
else if (msd->output_emitter2)
|
||||||
|
{
|
||||||
|
nsMimeEmitter2 *emitter2 = (nsMimeEmitter2 *)msd->output_emitter2;
|
||||||
|
return emitter2->AddHeaderField(field, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" nsresult
|
||||||
|
mimeEmitterStartAttachment(MimeDisplayOptions *opt, const char *name, const char *contentType, const char *url)
|
||||||
|
{
|
||||||
|
mime_stream_data *msd = GetMSD(opt);
|
||||||
|
if (!msd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (msd->output_emitter)
|
||||||
|
{
|
||||||
|
nsIMimeEmitter *emitter = (nsIMimeEmitter *)msd->output_emitter;
|
||||||
|
return emitter->StartAttachment(name, contentType, url);
|
||||||
|
}
|
||||||
|
else if (msd->output_emitter2)
|
||||||
|
{
|
||||||
|
nsMimeEmitter2 *emitter2 = (nsMimeEmitter2 *)msd->output_emitter2;
|
||||||
|
return emitter2->StartAttachment(name, contentType, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" nsresult
|
||||||
|
mimeEmitterEndAttachment(MimeDisplayOptions *opt)
|
||||||
|
{
|
||||||
|
mime_stream_data *msd = GetMSD(opt);
|
||||||
|
if (!msd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (msd->output_emitter)
|
||||||
|
{
|
||||||
|
nsIMimeEmitter *emitter = (nsIMimeEmitter *)msd->output_emitter;
|
||||||
|
return emitter->EndAttachment();
|
||||||
|
}
|
||||||
|
else if (msd->output_emitter2)
|
||||||
|
{
|
||||||
|
nsMimeEmitter2 *emitter2 = (nsMimeEmitter2 *)msd->output_emitter2;
|
||||||
|
return emitter2->EndAttachment();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" nsresult
|
||||||
|
mimeEmitterStartBody(MimeDisplayOptions *opt, PRBool bodyOnly, const char *msgID, const char *outCharset)
|
||||||
|
{
|
||||||
|
mime_stream_data *msd = GetMSD(opt);
|
||||||
|
if (!msd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (msd->output_emitter)
|
||||||
|
{
|
||||||
|
nsIMimeEmitter *emitter = (nsIMimeEmitter *)msd->output_emitter;
|
||||||
|
return emitter->StartBody(bodyOnly, msgID, outCharset);
|
||||||
|
}
|
||||||
|
else if (msd->output_emitter2)
|
||||||
|
{
|
||||||
|
nsMimeEmitter2 *emitter2 = (nsMimeEmitter2 *)msd->output_emitter2;
|
||||||
|
return emitter2->StartBody(bodyOnly, msgID, outCharset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" nsresult
|
||||||
|
mimeEmitterEndBody(MimeDisplayOptions *opt)
|
||||||
|
{
|
||||||
|
mime_stream_data *msd = GetMSD(opt);
|
||||||
|
if (!msd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (msd->output_emitter)
|
||||||
|
{
|
||||||
|
nsIMimeEmitter *emitter = (nsIMimeEmitter *)msd->output_emitter;
|
||||||
|
return emitter->EndBody();
|
||||||
|
}
|
||||||
|
else if (msd->output_emitter2)
|
||||||
|
{
|
||||||
|
nsMimeEmitter2 *emitter2 = (nsMimeEmitter2 *)msd->output_emitter2;
|
||||||
|
return emitter2->EndBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" nsresult
|
||||||
|
mimeEmitterEndHeader(MimeDisplayOptions *opt)
|
||||||
|
{
|
||||||
|
mime_stream_data *msd = GetMSD(opt);
|
||||||
|
if (!msd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (msd->output_emitter)
|
||||||
|
{
|
||||||
|
nsIMimeEmitter *emitter = (nsIMimeEmitter *)msd->output_emitter;
|
||||||
|
return emitter->EndHeader();
|
||||||
|
}
|
||||||
|
else if (msd->output_emitter2)
|
||||||
|
{
|
||||||
|
nsMimeEmitter2 *emitter2 = (nsMimeEmitter2 *)msd->output_emitter2;
|
||||||
|
return emitter2->EndHeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" nsresult
|
||||||
|
mimeEmitterStartHeader(MimeDisplayOptions *opt, PRBool rootMailHeader, PRBool headerOnly, const char *msgID,
|
||||||
|
const char *outCharset)
|
||||||
|
{
|
||||||
|
mime_stream_data *msd = GetMSD(opt);
|
||||||
|
if (!msd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (msd->output_emitter)
|
||||||
|
{
|
||||||
|
nsIMimeEmitter *emitter = (nsIMimeEmitter *)msd->output_emitter;
|
||||||
|
return emitter->StartHeader(rootMailHeader, headerOnly, msgID, outCharset);
|
||||||
|
}
|
||||||
|
else if (msd->output_emitter2)
|
||||||
|
{
|
||||||
|
nsMimeEmitter2 *emitter2 = (nsMimeEmitter2 *)msd->output_emitter2;
|
||||||
|
return emitter2->StartHeader(rootMailHeader, headerOnly, msgID, outCharset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" nsresult
|
||||||
|
mimeSetNewURL(nsMIMESession *stream, char *url)
|
||||||
|
{
|
||||||
|
if ( (!stream) || (!url) || (!*url) )
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
mime_stream_data *msd = (mime_stream_data *)stream->data_object;
|
||||||
|
if (!msd)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
char *tmpPtr = PL_strdup(url);
|
||||||
|
if (!tmpPtr)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
PR_FREEIF(msd->url_name);
|
||||||
|
msd->url_name = PL_strdup(tmpPtr);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
|
@ -25,7 +25,9 @@ extern "C" {
|
||||||
|
|
||||||
#include "prtypes.h"
|
#include "prtypes.h"
|
||||||
#include "plugin_inst.h"
|
#include "plugin_inst.h"
|
||||||
|
#include "nsStreamConverter.h"
|
||||||
#include "nsIMimeEmitter.h"
|
#include "nsIMimeEmitter.h"
|
||||||
|
#include "nsMimeEmitter2.h"
|
||||||
|
|
||||||
// SHERRY - Need to get these out of here eventually
|
// SHERRY - Need to get these out of here eventually
|
||||||
|
|
||||||
|
@ -97,6 +99,7 @@ struct mime_stream_data { /* This struct is the state we pass around
|
||||||
int format_out;
|
int format_out;
|
||||||
MWContext *context; /* Must REMOVE this entry. */
|
MWContext *context; /* Must REMOVE this entry. */
|
||||||
void *pluginObj; /* The new XP-COM stream converter object */
|
void *pluginObj; /* The new XP-COM stream converter object */
|
||||||
|
void *pluginObj2; /* The new XP-COM stream converter object */
|
||||||
nsMIMESession *istream; /* Holdover - new stream we're writing out image data-if any. */
|
nsMIMESession *istream; /* Holdover - new stream we're writing out image data-if any. */
|
||||||
MimeObject *obj; /* The root parser object */
|
MimeObject *obj; /* The root parser object */
|
||||||
MimeDisplayOptions *options; /* Data for communicating with libmime.a */
|
MimeDisplayOptions *options; /* Data for communicating with libmime.a */
|
||||||
|
@ -104,7 +107,8 @@ struct mime_stream_data { /* This struct is the state we pass around
|
||||||
/* These are used by FO_QUOTE_HTML_MESSAGE stuff only: */
|
/* These are used by FO_QUOTE_HTML_MESSAGE stuff only: */
|
||||||
PRInt16 lastcsid; /* csid corresponding to above. */
|
PRInt16 lastcsid; /* csid corresponding to above. */
|
||||||
PRInt16 outcsid; /* csid passed to EDT_PasteQuoteINTL */
|
PRInt16 outcsid; /* csid passed to EDT_PasteQuoteINTL */
|
||||||
nsIMimeEmitter *output_emitter; /* Output emitter engine for libmime */
|
nsIMimeEmitter *output_emitter; /* Output emitter engine for libmime */
|
||||||
|
nsMimeEmitter2 *output_emitter2; /* Output emitter 2 engine for libmime */
|
||||||
nsIPref *prefs; /* Connnection to prefs service manager */
|
nsIPref *prefs; /* Connnection to prefs service manager */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,6 +119,8 @@ struct mime_stream_data { /* This struct is the state we pass around
|
||||||
// Create bridge stream for libmime
|
// Create bridge stream for libmime
|
||||||
void *mime_bridge_create_stream(MimePluginInstance *newPluginObj,
|
void *mime_bridge_create_stream(MimePluginInstance *newPluginObj,
|
||||||
nsIMimeEmitter *newEmitter,
|
nsIMimeEmitter *newEmitter,
|
||||||
|
nsStreamConverter *newPluginObj2,
|
||||||
|
nsMimeEmitter2 *newEmitter2,
|
||||||
const char *urlString,
|
const char *urlString,
|
||||||
int format_out);
|
int format_out);
|
||||||
|
|
||||||
|
@ -129,6 +135,18 @@ extern "C" void mime_display_stream_abort (nsMIMESession *stream, int
|
||||||
// To get the mime emitter...
|
// To get the mime emitter...
|
||||||
extern "C" nsIMimeEmitter *GetMimeEmitter(MimeDisplayOptions *opt);
|
extern "C" nsIMimeEmitter *GetMimeEmitter(MimeDisplayOptions *opt);
|
||||||
|
|
||||||
|
// To support 2 types of emitters...we need these routines :-(
|
||||||
|
extern "C" nsresult mimeSetNewURL(nsMIMESession *stream, char *url);
|
||||||
|
extern "C" nsresult mimeEmitterAddAttachmentField(MimeDisplayOptions *opt, const char *field, const char *value);
|
||||||
|
extern "C" nsresult mimeEmitterAddHeaderField(MimeDisplayOptions *opt, const char *field, const char *value);
|
||||||
|
extern "C" nsresult mimeEmitterStartAttachment(MimeDisplayOptions *opt, const char *name, const char *contentType, const char *url);
|
||||||
|
extern "C" nsresult mimeEmitterEndAttachment(MimeDisplayOptions *opt);
|
||||||
|
extern "C" nsresult mimeEmitterStartBody(MimeDisplayOptions *opt, PRBool bodyOnly, const char *msgID, const char *outCharset);
|
||||||
|
extern "C" nsresult mimeEmitterEndBody(MimeDisplayOptions *opt);
|
||||||
|
extern "C" nsresult mimeEmitterEndHeader(MimeDisplayOptions *opt);
|
||||||
|
extern "C" nsresult mimeEmitterStartHeader(MimeDisplayOptions *opt, PRBool rootMailHeader, PRBool headerOnly, const char *msgID,
|
||||||
|
const char *outCharset);
|
||||||
|
|
||||||
/* To Get the connnection to prefs service manager */
|
/* To Get the connnection to prefs service manager */
|
||||||
extern "C" nsIPref *GetPrefServiceManager(MimeDisplayOptions *opt);
|
extern "C" nsIPref *GetPrefServiceManager(MimeDisplayOptions *opt);
|
||||||
|
|
||||||
|
|
|
@ -346,7 +346,7 @@ MakeAbsoluteURL(char * absolute_url, char * relative_url)
|
||||||
nsMimeURLUtils myUtil;
|
nsMimeURLUtils myUtil;
|
||||||
char *retString;
|
char *retString;
|
||||||
|
|
||||||
if (myUtil.MakeAbsoluteURL(absolute_url, relative_url, &retString) == NS_OK)
|
if (NS_SUCCEEDED(myUtil.MakeAbsoluteURL(absolute_url, relative_url, &retString)))
|
||||||
return retString;
|
return retString;
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -396,11 +396,6 @@ HG09091
|
||||||
// we need to figure out the content type/charset of the part
|
// we need to figure out the content type/charset of the part
|
||||||
//
|
//
|
||||||
PRBool outer_p = !obj->headers; /* is this the outermost message? */
|
PRBool outer_p = !obj->headers; /* is this the outermost message? */
|
||||||
nsIMimeEmitter *mimeEmitter = GetMimeEmitter(obj->options);
|
|
||||||
|
|
||||||
// No emitter, no point.
|
|
||||||
if (!mimeEmitter)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(outer_p) &&
|
(outer_p) &&
|
||||||
|
@ -420,7 +415,7 @@ HG09091
|
||||||
if (!obj->options->force_user_charset) /* Only convert if the user prefs is false */
|
if (!obj->options->force_user_charset) /* Only convert if the user prefs is false */
|
||||||
outCharset = "UTF-8";
|
outCharset = "UTF-8";
|
||||||
|
|
||||||
mimeEmitter->StartBody((obj->options->headers == MimeHeadersNone), msgID, outCharset);
|
mimeEmitterStartBody(obj->options, (obj->options->headers == MimeHeadersNone), msgID, outCharset);
|
||||||
PR_FREEIF(msgID);
|
PR_FREEIF(msgID);
|
||||||
PR_FREEIF(lct);
|
PR_FREEIF(lct);
|
||||||
PR_FREEIF(charset);
|
PR_FREEIF(charset);
|
||||||
|
@ -447,10 +442,6 @@ MimeMessage_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||||
|
|
||||||
// Once we get to the end of parsing the message, we will notify
|
// Once we get to the end of parsing the message, we will notify
|
||||||
// the emitter that we are done the the body.
|
// the emitter that we are done the the body.
|
||||||
nsIMimeEmitter *mimeEmitter = GetMimeEmitter(obj->options);
|
|
||||||
// No emitter, no point.
|
|
||||||
if (!mimeEmitter)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
// Mark the end of the mail body if we are actually emitting the
|
// Mark the end of the mail body if we are actually emitting the
|
||||||
// body of the message (i.e. not Header ONLY)
|
// body of the message (i.e. not Header ONLY)
|
||||||
|
@ -459,7 +450,7 @@ MimeMessage_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||||
( obj->options && (obj->options->part_to_load == NULL) ) &&
|
( obj->options && (obj->options->part_to_load == NULL) ) &&
|
||||||
(obj->options->headers != MimeHeadersOnly)
|
(obj->options->headers != MimeHeadersOnly)
|
||||||
)
|
)
|
||||||
mimeEmitter->EndBody();
|
mimeEmitterEndBody(obj->options);
|
||||||
|
|
||||||
if (outer_p &&
|
if (outer_p &&
|
||||||
obj->options &&
|
obj->options &&
|
||||||
|
@ -541,7 +532,6 @@ static int
|
||||||
MimeMessage_write_headers_html (MimeObject *obj)
|
MimeMessage_write_headers_html (MimeObject *obj)
|
||||||
{
|
{
|
||||||
MimeMessage *msg = (MimeMessage *) obj;
|
MimeMessage *msg = (MimeMessage *) obj;
|
||||||
nsIMimeEmitter *mimeEmitter = GetMimeEmitter(obj->options);
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
#ifdef MOZ_SECURITY
|
#ifdef MOZ_SECURITY
|
||||||
|
@ -553,10 +543,6 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||||
|
|
||||||
PR_ASSERT(obj->output_p && obj->options->write_html_p);
|
PR_ASSERT(obj->output_p && obj->options->write_html_p);
|
||||||
|
|
||||||
// No emitter - no point!
|
|
||||||
if (!mimeEmitter)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
// To support the no header option! Make sure we are not
|
// To support the no header option! Make sure we are not
|
||||||
// suppressing headers on included email messages...
|
// suppressing headers on included email messages...
|
||||||
if ( (obj->options->headers == MimeHeadersNone) &&
|
if ( (obj->options->headers == MimeHeadersNone) &&
|
||||||
|
@ -568,7 +554,7 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||||
status = MimeObject_output_init (obj, TEXT_HTML);
|
status = MimeObject_output_init (obj, TEXT_HTML);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
{
|
{
|
||||||
mimeEmitter->EndHeader();
|
mimeEmitterEndHeader(obj->options);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
PR_ASSERT(obj->options->state->first_data_written_p);
|
PR_ASSERT(obj->options->state->first_data_written_p);
|
||||||
|
@ -577,7 +563,7 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||||
// Start the header parsing by the emitter
|
// Start the header parsing by the emitter
|
||||||
char *msgID = MimeHeaders_get (msg->hdrs, HEADER_MESSAGE_ID,
|
char *msgID = MimeHeaders_get (msg->hdrs, HEADER_MESSAGE_ID,
|
||||||
PR_FALSE, PR_FALSE);
|
PR_FALSE, PR_FALSE);
|
||||||
mimeEmitter->StartHeader(
|
mimeEmitterStartHeader(obj->options,
|
||||||
(obj == obj->options->state->root),
|
(obj == obj->options->state->root),
|
||||||
(obj->options->headers == MimeHeadersOnly),
|
(obj->options->headers == MimeHeadersOnly),
|
||||||
msgID,
|
msgID,
|
||||||
|
@ -592,7 +578,7 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||||
status = MimeHeaders_write_all_headers (msg->hdrs, obj->options, FALSE);
|
status = MimeHeaders_write_all_headers (msg->hdrs, obj->options, FALSE);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
{
|
{
|
||||||
mimeEmitter->EndHeader();
|
mimeEmitterEndHeader(obj->options);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -627,14 +613,14 @@ MimeMessage_write_headers_html (MimeObject *obj)
|
||||||
PR_Free(html);
|
PR_Free(html);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
{
|
{
|
||||||
mimeEmitter->EndHeader();
|
mimeEmitterEndHeader(obj->options);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mimeEmitter->EndHeader();
|
mimeEmitterEndHeader(obj->options);
|
||||||
|
|
||||||
if (obj->options->headers == MimeHeadersOnly)
|
if (obj->options->headers == MimeHeadersOnly)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "nsIComponentManager.h"
|
#include "nsIComponentManager.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsStreamConverter.h"
|
||||||
|
|
||||||
#include "nsINetPlugin.h"
|
#include "nsINetPlugin.h"
|
||||||
#include "nsIComponentManager.h"
|
#include "nsIComponentManager.h"
|
||||||
|
@ -41,9 +42,10 @@ static NS_DEFINE_CID(kCMimeMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCE
|
||||||
static NS_DEFINE_CID(kCMimeConverterCID, NS_MIME_CONVERTER_CID);
|
static NS_DEFINE_CID(kCMimeConverterCID, NS_MIME_CONVERTER_CID);
|
||||||
|
|
||||||
// These are necessary for the new stream converter/plugin interface...
|
// These are necessary for the new stream converter/plugin interface...
|
||||||
static NS_DEFINE_CID(kINetPluginCID, NS_INET_PLUGIN_CID);
|
static NS_DEFINE_CID(kINetPluginCID, NS_INET_PLUGIN_CID);
|
||||||
static NS_DEFINE_CID(kINetPluginMIMECID, NS_INET_PLUGIN_MIME_CID);
|
static NS_DEFINE_CID(kINetPluginMIMECID, NS_INET_PLUGIN_MIME_CID);
|
||||||
static NS_DEFINE_IID(kINetPluginIID, NS_INET_PLUGIN_IID);
|
static NS_DEFINE_IID(kINetPluginIID, NS_INET_PLUGIN_IID);
|
||||||
|
static NS_DEFINE_CID(kIStreamConverterCID, NS_STREAM_CONVERTER_CID);
|
||||||
|
|
||||||
#include "nsMsgHeaderParser.h"
|
#include "nsMsgHeaderParser.h"
|
||||||
static NS_DEFINE_CID(kCMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
|
static NS_DEFINE_CID(kCMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
|
||||||
|
@ -163,6 +165,12 @@ nsresult nsMimeFactory::CreateInstance(nsISupports *aOuter, const nsIID &aIID, v
|
||||||
if (res != NS_OK) // was there a problem creating the object ?
|
if (res != NS_OK) // was there a problem creating the object ?
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
else if (mClassID.Equals(kIStreamConverterCID))
|
||||||
|
{
|
||||||
|
res = NS_NewStreamConverter((nsIStreamConverter **) &inst);
|
||||||
|
if (res != NS_OK) // was there a problem creating the object ?
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
// End of checking the interface ID code....
|
// End of checking the interface ID code....
|
||||||
if (inst)
|
if (inst)
|
||||||
|
@ -252,6 +260,11 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *
|
||||||
PR_TRUE, PR_TRUE);
|
PR_TRUE, PR_TRUE);
|
||||||
if (NS_FAILED(rv)) finalResult = rv;
|
if (NS_FAILED(rv)) finalResult = rv;
|
||||||
|
|
||||||
|
// Stream converter interface for use in quoting.
|
||||||
|
rv = compMgr->RegisterComponent(kIStreamConverterCID, NULL, NULL, path,
|
||||||
|
PR_TRUE, PR_TRUE);
|
||||||
|
if (NS_FAILED(rv)) finalResult = rv;
|
||||||
|
|
||||||
return finalResult;
|
return finalResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,6 +286,8 @@ extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char
|
||||||
if (NS_FAILED(rv)) finalResult = rv;
|
if (NS_FAILED(rv)) finalResult = rv;
|
||||||
rv = compMgr->UnregisterComponent(kCIMimeURLUtilsCID, path);
|
rv = compMgr->UnregisterComponent(kCIMimeURLUtilsCID, path);
|
||||||
if (NS_FAILED(rv)) finalResult = rv;
|
if (NS_FAILED(rv)) finalResult = rv;
|
||||||
|
rv = compMgr->UnregisterComponent(kIStreamConverterCID, path);
|
||||||
|
if (NS_FAILED(rv)) finalResult = rv;
|
||||||
|
|
||||||
return finalResult;
|
return finalResult;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,3 +45,133 @@ NET_cinfo_find_info_by_type (char *uri)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// THIS IS ONLY HERE UNTIL I CAN GET THE INTERNAL EMITTER OUT OF
|
||||||
|
// LIBMIME
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
#include "nsIMimeEmitter.h"
|
||||||
|
#include "nsMailHeaders.h"
|
||||||
|
|
||||||
|
extern "C" PRBool
|
||||||
|
EmitThisHeaderForPrefSetting(PRInt32 dispType, const char *header)
|
||||||
|
{
|
||||||
|
if (AllHeaders == dispType)
|
||||||
|
return PR_TRUE;
|
||||||
|
|
||||||
|
if ((!header) || (!*header))
|
||||||
|
return PR_FALSE;
|
||||||
|
|
||||||
|
if (MicroHeaders == dispType)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
(!PL_strcmp(header, HEADER_SUBJECT)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_FROM)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_DATE))
|
||||||
|
)
|
||||||
|
return PR_TRUE;
|
||||||
|
else
|
||||||
|
return PR_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NormalHeaders == dispType)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
(!PL_strcmp(header, HEADER_TO)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_SUBJECT)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_SENDER)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_RESENT_TO)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_RESENT_SENDER)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_RESENT_FROM)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_RESENT_CC)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_REPLY_TO)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_REFERENCES)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_NEWSGROUPS)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_MESSAGE_ID)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_FROM)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_FOLLOWUP_TO)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_CC)) ||
|
||||||
|
(!PL_strcmp(header, HEADER_BCC))
|
||||||
|
)
|
||||||
|
return PR_TRUE;
|
||||||
|
else
|
||||||
|
return PR_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "nsMimeRebuffer.h"
|
||||||
|
#include "prmem.h"
|
||||||
|
|
||||||
|
MimeRebuffer::MimeRebuffer(void)
|
||||||
|
{
|
||||||
|
mSize = 0;
|
||||||
|
mBuf = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MimeRebuffer::~MimeRebuffer(void)
|
||||||
|
{
|
||||||
|
if (mBuf)
|
||||||
|
{
|
||||||
|
PR_FREEIF(mBuf);
|
||||||
|
mBuf = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PRUint32
|
||||||
|
MimeRebuffer::GetSize()
|
||||||
|
{
|
||||||
|
return mSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRUint32
|
||||||
|
MimeRebuffer::IncreaseBuffer(const char *addBuf, PRUint32 size)
|
||||||
|
{
|
||||||
|
if ( (!addBuf) || (size == 0) )
|
||||||
|
return mSize;
|
||||||
|
|
||||||
|
mBuf = (char *)PR_Realloc(mBuf, size + mSize);
|
||||||
|
if (!mBuf)
|
||||||
|
{
|
||||||
|
mSize = 0;
|
||||||
|
return mSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(mBuf+mSize, addBuf, size);
|
||||||
|
mSize += size;
|
||||||
|
return mSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRUint32
|
||||||
|
MimeRebuffer::ReduceBuffer(PRUint32 numBytes)
|
||||||
|
{
|
||||||
|
if (numBytes == 0)
|
||||||
|
return mSize;
|
||||||
|
|
||||||
|
if (!mBuf)
|
||||||
|
{
|
||||||
|
mSize = 0;
|
||||||
|
return mSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numBytes >= mSize)
|
||||||
|
{
|
||||||
|
PR_FREEIF(mBuf);
|
||||||
|
mBuf = NULL;
|
||||||
|
mSize = 0;
|
||||||
|
return mSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(mBuf, mBuf+numBytes, (mSize - numBytes));
|
||||||
|
mSize -= numBytes;
|
||||||
|
return mSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
MimeRebuffer::GetBuffer()
|
||||||
|
{
|
||||||
|
return mBuf;
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||||
* Reserved.
|
* Reserved.
|
||||||
*/
|
*/
|
||||||
|
#include "nsIURL.h"
|
||||||
#include "plugin_inst.h"
|
#include "plugin_inst.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
#include "nscore.h"
|
#include "nscore.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
|
||||||
// Need this for FO_NGLAYOUT
|
// RICHIE - Need this for FO_NGLAYOUT
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -214,14 +215,14 @@ MimePluginInstance::Initialize(nsINetOStream* stream, const char *stream_name)
|
||||||
nsIMimeEmitter::GetIID(),
|
nsIMimeEmitter::GetIID(),
|
||||||
(void **) getter_AddRefs(mEmitter));
|
(void **) getter_AddRefs(mEmitter));
|
||||||
|
|
||||||
if (NS_FAILED(res) || (!mEmitter))
|
if ((NS_FAILED(res)) || (!mEmitter))
|
||||||
{
|
{
|
||||||
NS_ASSERTION(PR_FALSE, "unable to create the correct converter");
|
NS_ASSERTION(PR_FALSE, "unable to create the correct converter");
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
mEmitter->Initialize(stream);
|
mEmitter->Initialize(stream);
|
||||||
mBridgeStream = mime_bridge_create_stream(this, mEmitter, stream_name, format_out);
|
mBridgeStream = mime_bridge_create_stream(this, mEmitter, nsnull, nsnull, stream_name, format_out);
|
||||||
if (!mBridgeStream)
|
if (!mBridgeStream)
|
||||||
{
|
{
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
@ -293,7 +294,9 @@ nsresult MimePluginInstance::InternalCleanup(void)
|
||||||
//
|
//
|
||||||
// Now complete the emitter and do necessary cleanup!
|
// Now complete the emitter and do necessary cleanup!
|
||||||
//
|
//
|
||||||
|
#ifdef DEBUG_rhp
|
||||||
printf("TOTAL READ = %d\n", mTotalRead);
|
printf("TOTAL READ = %d\n", mTotalRead);
|
||||||
|
#endif
|
||||||
if (mEmitter)
|
if (mEmitter)
|
||||||
{
|
{
|
||||||
mEmitter->Complete();
|
mEmitter->Complete();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче