New changes for mime emitters.

This commit is contained in:
rhp%netscape.com 1999-04-01 01:03:33 +00:00
Родитель aa739f4776
Коммит 7f01fe97cd
4 изменённых файлов: 60 добавлений и 4 удалений

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

@ -19,6 +19,7 @@ DEPTH = ../../../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
CSS = mailheader-micro.css mailheader-normal.css mailheader-all.css
IS_COMPONENT=1
@ -45,3 +46,5 @@ include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk
install:: $(LIBRARY_NAME)
$(INSTALL) $(CSS) $(DIST)/bin/res

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

@ -34,7 +34,10 @@ DEPTH=..\..\..\..
# New build system where zip dll is build indepenant of java stubs.
#//
#//------------------------------------------------------------------------
MODULE = xmlemitter
MODULE = xmlemitter
CSS1 = mailheader-micro.css
CSS2 = mailheader-normal.css
CSS3 = mailheader-all.css
REQUIRES=
#EXPORTS =\
# .\nsMimeEmitter.h \
@ -122,6 +125,9 @@ include <$(DEPTH)/config/rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
$(MAKE_INSTALL) .\$(CSS1) $(DIST)\bin\res
$(MAKE_INSTALL) .\$(CSS2) $(DIST)\bin\res
$(MAKE_INSTALL) .\$(CSS3) $(DIST)\bin\res
clobber::
rm -f $(DIST)\bin\$(DLLNAME).dll

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

@ -21,6 +21,12 @@
#include "plstr.h"
#include "nsEmitterUtils.h"
#include "nsMailHeaders.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
// For the new pref API's
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
/*
* This function will be used by the factory to generate an
@ -72,12 +78,24 @@ nsMimeEmitter::nsMimeEmitter()
mLogFile = NULL; /* Temp file to put generated XML into. */
mReallyOutput = PR_FALSE;
#endif
nsresult rv = nsServiceManager::GetService(kPrefCID, kIPrefIID, (nsISupports**)&(mPrefs));
if (! (mPrefs && NS_SUCCEEDED(rv)))
return;
mPrefs->Startup("prefs.js");
mHeaderDisplayType = AllHeaders;
mPrefs->GetIntPref("mail.show_headers", &mHeaderDisplayType);
}
nsMimeEmitter::~nsMimeEmitter(void)
{
if (mBufferMgr)
delete mBufferMgr;
// Release the prefs service
if (mPrefs)
nsServiceManager::ReleaseService(kPrefCID, mPrefs);
}
// Set the output stream for processed data.
@ -143,9 +161,14 @@ nsMimeEmitter::Complete()
nsresult
nsMimeEmitter::WriteXMLHeader(const char *msgID)
{
UtilityWrite("<?xml version=\"1.0\"?>");
UtilityWrite("<?xml-stylesheet href=\"resource:/res/mail.css\" type=\"text/css\"?>");
if (mHeaderDisplayType == MicroHeaders)
UtilityWrite("<?xml-stylesheet href=\"resource:/res/mailheader-micro.css\" type=\"text/css\"?>");
else if (mHeaderDisplayType == NormalHeaders)
UtilityWrite("<?xml-stylesheet href=\"resource:/res/mailheader-normal.css\" type=\"text/css\"?>");
else /* AllHeaders */
UtilityWrite("<?xml-stylesheet href=\"resource:/res/mailheader-all.css\" type=\"text/css\"?>");
UtilityWrite("<message id=\"");
UtilityWrite(msgID);
@ -158,17 +181,29 @@ nsMimeEmitter::WriteXMLHeader(const char *msgID)
nsresult
nsMimeEmitter::WriteXMLTag(const char *tagName, const char *value)
{
if ( (!value) || (!*value) )
return NS_OK;
char *newValue = nsEscapeHTML(value);
if (!newValue)
return NS_OK;
UtilityWrite("<headertag>");
UtilityWrite("<");
UtilityWrite(tagName);
UtilityWrite(">");
UtilityWrite(tagName);
UtilityWrite(": ");
UtilityWrite(value);
UtilityWrite(newValue);
UtilityWrite("</");
UtilityWrite(tagName);
UtilityWrite(">");
UtilityWrite("</headertag>");
return NS_OK;
}

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

@ -23,6 +23,14 @@
#include "nsMimeRebuffer.h"
#include "nsINetOStream.h"
#include "nsIMimeEmitter.h"
#include "nsIPref.h"
typedef enum {
MicroHeaders = 0,
NormalHeaders,
AllHeaders
} HeaderDisplayTypes;
class nsMimeEmitter : public nsIMimeEmitter {
public:
@ -78,6 +86,10 @@ protected:
PRBool mXMLHeaderStarted;
PRUint32 mAttachCount;
nsIPref *mPrefs; /* Connnection to prefs service manager */
int32 mHeaderDisplayType;
#ifdef DEBUG
PRBool mReallyOutput;
PRFileDesc *mLogFile; /* Temp file to put generated HTML into. */