IDLized stream interfaces. Required rename of overloaded Write method (now WriteFrom).

This commit is contained in:
warren%netscape.com 1999-06-03 21:50:47 +00:00
Родитель e8cc8caf69
Коммит 447b069ddb
34 изменённых файлов: 254 добавлений и 846 удалений

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

@ -447,7 +447,8 @@ public:
fflush(stdout);
return NS_OK;
}
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount)
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -1,472 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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.
*/
#include "stdio.h"
#include "nsMimeRebuffer.h"
#include "nsMimeEmitter.h"
#include "plstr.h"
#include "nsEmitterUtils.h"
#include "nsMailHeaders.h"
/*
* This function will be used by the factory to generate an
* mime object class object....
*/
nsresult NS_NewMimeEmitter(nsIMimeEmitter ** aInstancePtrResult)
{
/* note this new macro for assertions...they can take
a string describing the assertion */
nsresult result = NS_OK;
NS_PRECONDITION(nsnull != aInstancePtrResult, "nsnull ptr");
if (nsnull != aInstancePtrResult)
{
nsMimeEmitter *obj = new nsMimeEmitter();
if (obj)
return obj->QueryInterface(nsIMimeEmitter::GetIID(), (void**) aInstancePtrResult);
else
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
}
else
return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/
}
/*
* The following macros actually implement addref, release and
* query interface for our component.
*/
NS_IMPL_ADDREF(nsMimeEmitter)
NS_IMPL_RELEASE(nsMimeEmitter)
NS_IMPL_QUERY_INTERFACE(nsMimeEmitter, nsIMimeEmitter::GetIID()); /* we need to pass in the interface ID of this interface */
/*
* nsIMimeEmitter definitions....
*/
nsMimeEmitter::nsMimeEmitter()
{
/* the following macro is used to initialize the ref counting data */
NS_INIT_REFCNT();
mOutStream = NULL;
mBufferMgr = NULL;
mTotalWritten = 0;
mTotalRead = 0;
mDocHeader = PR_FALSE;
mAttachContentType = NULL;
#ifdef DEBUG_rhp
mLogFile = NULL; /* Temp file to put generated HTML into. */
mReallyOutput = PR_FALSE;
#endif
}
nsMimeEmitter::~nsMimeEmitter(void)
{
if (mBufferMgr)
delete mBufferMgr;
}
// Set the output stream for processed data.
nsresult
nsMimeEmitter::SetOutputStream(nsINetOStream *outStream)
{
return NS_OK;
}
// Note - these is setup only...you should not write
// anything to the stream since these may be image data
// output streams, etc...
nsresult
nsMimeEmitter::Initialize(nsINetOStream *outStream)
{
mOutStream = outStream;
// Create rebuffering object
mBufferMgr = new MimeRebuffer();
// Counters for output stream
mTotalWritten = 0;
mTotalRead = 0;
#ifdef DEBUG_rhp
PR_Delete("C:\\email.html");
mLogFile = PR_Open("C:\\email.html", PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE, 493);
#endif /* DEBUG */
return NS_OK;
}
// Note - this is teardown only...you should not write
// anything to the stream since these may be image data
// output streams, etc...
nsresult
nsMimeEmitter::Complete()
{
#ifdef DEBUG_rhp
mReallyOutput = PR_FALSE;
#endif
// If we are here and still have data to write, we should try
// to flush it...if we try and fail, we should probably return
// an error!
PRUint32 written;
if (mBufferMgr->GetSize() > 0)
Write("", 0, &written);
printf("TOTAL WRITTEN = %d\n", mTotalWritten);
printf("LEFTOVERS = %d\n", mBufferMgr->GetSize());
#ifdef DEBUG_rhp
if (mLogFile)
PR_Close(mLogFile);
#endif
return NS_OK;
}
// Header handling routines.
nsresult
nsMimeEmitter::StartHeader(PRBool rootMailHeader, PRBool headerOnly, const char *msgID,
const char *outCharset)
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
mDocHeader = rootMailHeader;
if (mDocHeader)
{
if ( (!headerOnly) && (outCharset) && (*outCharset) )
{
UtilityWrite("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=");
UtilityWrite(outCharset);
UtilityWrite("\">");
}
UtilityWrite("<BLOCKQUOTE><table BORDER=0>");
}
else
UtilityWrite("<BLOCKQUOTE><table BORDER=0 BGCOLOR=\"#CCCCCC\" >");
return NS_OK;
}
nsresult
nsMimeEmitter::AddHeaderField(const char *field, const char *value)
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
if ( (!field) || (!value) )
return NS_OK;
char *newValue = nsEscapeHTML(value);
if (!newValue)
return NS_OK;
UtilityWrite("<TR>");
UtilityWrite("<td>");
UtilityWrite("<div align=right>");
UtilityWrite("<B>");
UtilityWrite(field);
UtilityWrite(":");
UtilityWrite("</B>");
UtilityWrite("</div>");
UtilityWrite("</td>");
UtilityWrite("<td>");
UtilityWrite(newValue);
UtilityWrite("</td>");
UtilityWrite("</TR>");
PR_FREEIF(newValue);
return NS_OK;
}
nsresult
nsMimeEmitter::EndHeader()
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
UtilityWrite("</TABLE></BLOCKQUOTE>");
return NS_OK;
}
nsresult
nsMimeEmitter::ProcessContentType(const char *ct)
{
if (mAttachContentType)
{
PR_FREEIF(mAttachContentType);
mAttachContentType = NULL;
}
if ( (!ct) || (!*ct) )
return NS_OK;
char *slash = PL_strchr(ct, '/');
if (!slash)
mAttachContentType = PL_strdup(ct);
else
{
PRInt32 size = (PL_strlen(ct) + 4 + 1);
mAttachContentType = (char *)PR_MALLOC( size );
if (!mAttachContentType)
return NS_ERROR_OUT_OF_MEMORY;
memset(mAttachContentType, 0, size);
PL_strcpy(mAttachContentType, ct);
char *newSlash = PL_strchr(mAttachContentType, '/');
*newSlash = '\0';
PL_strcat(mAttachContentType, "%2F");
PL_strcat(mAttachContentType, (slash + 1));
}
return NS_OK;
}
// Attachment handling routines
nsresult
nsMimeEmitter::StartAttachment(const char *name, const char *contentType, const char *url)
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
PR_FREEIF(mAttachContentType);
mAttachContentType = NULL;
ProcessContentType(contentType);
UtilityWrite("<CENTER>");
UtilityWrite("<table BORDER CELLSPACING=0>");
UtilityWrite("<tr>");
UtilityWrite("<td>");
if (mAttachContentType)
{
UtilityWrite("<a href=\"");
UtilityWrite(url);
UtilityWrite("&outformat=");
UtilityWrite(mAttachContentType);
UtilityWrite("\" target=new>");
}
UtilityWrite("<img SRC=\"resource:/res/network/gopher-unknown.gif\" BORDER=0 ALIGN=ABSCENTER>");
UtilityWrite(name);
if (mAttachContentType)
UtilityWrite("</a>");
UtilityWrite("</td>");
UtilityWrite("<td>");
UtilityWrite("<table BORDER=0 BGCOLOR=\"#FFFFCC\">");
return NS_OK;
}
nsresult
nsMimeEmitter::AddAttachmentField(const char *field, const char *value)
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
// Don't let bad things happen
if ( (!value) || (!*value) )
return NS_OK;
char *newValue = nsEscapeHTML(value);
PRBool linkIt = (!PL_strcmp(HEADER_X_MOZILLA_PART_URL, field));
//
// For now, let's not output the long URL field, but when prefs are
// working this will change.
//
if (linkIt)
return NS_OK;
UtilityWrite("<TR>");
UtilityWrite("<td>");
UtilityWrite("<div align=right>");
UtilityWrite("<B>");
UtilityWrite(field);
UtilityWrite(":");
UtilityWrite("</B>");
UtilityWrite("</div>");
UtilityWrite("</td>");
UtilityWrite("<td>");
if (linkIt)
{
UtilityWrite("<a href=\"");
UtilityWrite(value);
if (mAttachContentType)
{
UtilityWrite("&outformat=");
UtilityWrite(mAttachContentType);
}
UtilityWrite("\" target=new>");
}
UtilityWrite(newValue);
if (linkIt)
UtilityWrite("</a>");
UtilityWrite("</td>");
UtilityWrite("</TR>");
PR_FREEIF(newValue);
return NS_OK;
}
nsresult
nsMimeEmitter::EndAttachment()
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
PR_FREEIF(mAttachContentType);
UtilityWrite("</TABLE>");
UtilityWrite("</td>");
UtilityWrite("</tr>");
UtilityWrite("</TABLE>");
UtilityWrite("</CENTER>");
UtilityWrite("<BR>");
return NS_OK;
}
// Attachment handling routines
nsresult
nsMimeEmitter::StartBody(PRBool bodyOnly, const char *msgID, const char *outCharset)
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
if ((bodyOnly) && (outCharset) && (*outCharset))
{
UtilityWrite("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=");
UtilityWrite(outCharset);
UtilityWrite("\">");
}
return NS_OK;
}
nsresult
nsMimeEmitter::WriteBody(const char *buf, PRUint32 size, PRUint32 *amountWritten)
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
Write(buf, size, amountWritten);
return NS_OK;
}
nsresult
nsMimeEmitter::EndBody()
{
#ifdef DEBUG_rhp
mReallyOutput = PR_FALSE;
#endif
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// These are routines necessary for the C based routines in libmime
// to access the new world streams.
////////////////////////////////////////////////////////////////////////////////
nsresult
nsMimeEmitter::Write(const char *buf, PRUint32 size, PRUint32 *amountWritten)
{
unsigned int written = 0;
PRUint32 rc, aReadyCount = 0;
#ifdef DEBUG_rhp
if ((mLogFile) && (mReallyOutput))
PR_Write(mLogFile, buf, size);
#endif
//
// Make sure that the buffer we are "pushing" into has enough room
// for the write operation. If not, we have to buffer, return, and get
// it on the next time through
//
*amountWritten = 0;
rc = mOutStream->WriteReady(&aReadyCount);
// First, handle any old buffer data...
if (mBufferMgr->GetSize() > 0)
{
if (aReadyCount >= mBufferMgr->GetSize())
{
rc += mOutStream->Write(mBufferMgr->GetBuffer(),
mBufferMgr->GetSize(), &written);
mTotalWritten += written;
mBufferMgr->ReduceBuffer(written);
}
else
{
rc += mOutStream->Write(mBufferMgr->GetBuffer(),
aReadyCount, &written);
mTotalWritten += written;
mBufferMgr->ReduceBuffer(written);
mBufferMgr->IncreaseBuffer(buf, size);
return rc;
}
}
// Now, deal with the new data the best way possible...
rc = mOutStream->WriteReady(&aReadyCount);
if (aReadyCount >= size)
{
rc += mOutStream->Write(buf, size, &written);
mTotalWritten += written;
*amountWritten = written;
return rc;
}
else
{
rc += mOutStream->Write(buf, aReadyCount, &written);
mTotalWritten += written;
mBufferMgr->IncreaseBuffer(buf+written, (size-written));
*amountWritten = written;
return rc;
}
}
nsresult
nsMimeEmitter::UtilityWrite(const char *buf)
{
PRInt32 tmpLen = PL_strlen(buf);
PRUint32 written;
Write(buf, tmpLen, &written);
#ifdef DEBUG
// Write("\r\n", 2, &written);
#endif
return NS_OK;
}

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

@ -1,322 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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.
*/
#include "stdio.h"
#include "nsMimeRebuffer.h"
#include "nsMimeEmitter.h"
#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
* mime object class object....
*/
nsresult NS_NewMimeEmitter(nsIMimeEmitter ** aInstancePtrResult)
{
/* note this new macro for assertions...they can take
a string describing the assertion */
//nsresult result = NS_OK;
NS_PRECONDITION(nsnull != aInstancePtrResult, "nsnull ptr");
if (nsnull != aInstancePtrResult)
{
nsMimeEmitter *obj = new nsMimeEmitter();
if (obj)
return obj->QueryInterface(nsIMimeEmitter::GetIID(), (void**) aInstancePtrResult);
else
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
}
else
return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/
}
/*
* The following macros actually implement addref, release and
* query interface for our component.
*/
NS_IMPL_ADDREF(nsMimeEmitter)
NS_IMPL_RELEASE(nsMimeEmitter)
NS_IMPL_QUERY_INTERFACE(nsMimeEmitter, nsIMimeEmitter::GetIID()); /* we need to pass in the interface ID of this interface */
/*
* nsIMimeEmitter definitions....
*/
nsMimeEmitter::nsMimeEmitter()
{
/* the following macro is used to initialize the ref counting data */
NS_INIT_REFCNT();
mOutStream = NULL;
mBufferMgr = NULL;
mTotalWritten = 0;
mTotalRead = 0;
#ifdef DEBUG_rhp
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;
}
nsMimeEmitter::~nsMimeEmitter(void)
{
if (mBufferMgr)
delete mBufferMgr;
// Release the prefs service
if (mPrefs)
nsServiceManager::ReleaseService(kPrefCID, mPrefs);
}
// Set the output stream for processed data.
nsresult
nsMimeEmitter::SetOutputStream(nsINetOStream *outStream)
{
return NS_OK;
}
// Note - these is setup only...you should not write
// anything to the stream since these may be image data
// output streams, etc...
nsresult
nsMimeEmitter::Initialize(nsINetOStream *outStream)
{
mOutStream = outStream;
// Create rebuffering object
mBufferMgr = new MimeRebuffer();
// Counters for output stream
mTotalWritten = 0;
mTotalRead = 0;
#ifdef DEBUG_rhp
PR_Delete("C:\\mail.raw");
mLogFile = PR_Open("C:\\mail.raw", PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE, 493);
#endif /* DEBUG */
return NS_OK;
}
// Note - this is teardown only...you should not write
// anything to the stream since these may be image data
// output streams, etc...
nsresult
nsMimeEmitter::Complete()
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
// If we are here and still have data to write, we should try
// to flush it...if we try and fail, we should probably return
// an error!
PRUint32 written;
if (mBufferMgr->GetSize() > 0)
Write("", 0, &written);
printf("TOTAL WRITTEN = %d\n", mTotalWritten);
printf("LEFTOVERS = %d\n", mBufferMgr->GetSize());
#ifdef DEBUG_rhp
if (mLogFile)
PR_Close(mLogFile);
#endif
return NS_OK;
}
// Header handling routines.
nsresult
nsMimeEmitter::StartHeader(PRBool rootMailHeader, PRBool headerOnly, const char *msgID,
const char *outCharset)
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
return NS_OK;
}
nsresult
nsMimeEmitter::AddHeaderField(const char *field, const char *value)
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
return NS_OK;
}
nsresult
nsMimeEmitter::EndHeader()
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
return NS_OK;
}
// Attachment handling routines
nsresult
nsMimeEmitter::StartAttachment(const char *name, const char *contentType, const char *url)
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
return NS_OK;
}
nsresult
nsMimeEmitter::AddAttachmentField(const char *field, const char *value)
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
return NS_OK;
}
nsresult
nsMimeEmitter::EndAttachment()
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
return NS_OK;
}
// Attachment handling routines
nsresult
nsMimeEmitter::StartBody(PRBool bodyOnly, const char *msgID, const char *outCharset)
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
return NS_OK;
}
nsresult
nsMimeEmitter::WriteBody(const char *buf, PRUint32 size, PRUint32 *amountWritten)
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
Write(buf, size, amountWritten);
return NS_OK;
}
nsresult
nsMimeEmitter::EndBody()
{
#ifdef DEBUG_rhp
mReallyOutput = PR_TRUE;
#endif
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// These are routines necessary for the C based routines in libmime
// to access the new world streams.
////////////////////////////////////////////////////////////////////////////////
nsresult
nsMimeEmitter::Write(const char *buf, PRUint32 size, PRUint32 *amountWritten)
{
unsigned int written = 0;
PRUint32 rc, aReadyCount = 0;
#ifdef DEBUG_rhp
if ((mLogFile) && (mReallyOutput))
PR_Write(mLogFile, buf, size);
#endif
//
// Make sure that the buffer we are "pushing" into has enough room
// for the write operation. If not, we have to buffer, return, and get
// it on the next time through
//
*amountWritten = 0;
rc = mOutStream->WriteReady(&aReadyCount);
// First, handle any old buffer data...
if (mBufferMgr->GetSize() > 0)
{
if (aReadyCount >= mBufferMgr->GetSize())
{
rc += mOutStream->Write(mBufferMgr->GetBuffer(),
mBufferMgr->GetSize(), &written);
mTotalWritten += written;
mBufferMgr->ReduceBuffer(written);
}
else
{
rc += mOutStream->Write(mBufferMgr->GetBuffer(),
aReadyCount, &written);
mTotalWritten += written;
mBufferMgr->ReduceBuffer(written);
mBufferMgr->IncreaseBuffer(buf, size);
return rc;
}
}
// Now, deal with the new data the best way possible...
rc = mOutStream->WriteReady(&aReadyCount);
if (aReadyCount >= size)
{
rc += mOutStream->Write(buf, size, &written);
mTotalWritten += written;
*amountWritten = written;
return rc;
}
else
{
rc += mOutStream->Write(buf, aReadyCount, &written);
mTotalWritten += written;
mBufferMgr->IncreaseBuffer(buf+written, (size-written));
*amountWritten = written;
return rc;
}
}
nsresult
nsMimeEmitter::UtilityWrite(const char *buf)
{
PRInt32 tmpLen = PL_strlen(buf);
PRUint32 written;
Write(buf, tmpLen, &written);
#ifdef DEBUG
// Write("\r\n", 2, &written);
#endif
return NS_OK;
}

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

@ -24,6 +24,7 @@
#include "mimemoz2.h"
#include "nsIMimeEmitter.h"
#include "nsRepository.h"
#include "nscore.h"
// Need this for FO_NGLAYOUT
#include "net.h"

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

@ -56,7 +56,8 @@ public:
NS_IMETHOD Write(const char *aBuf,
PRUint32 aLen,
PRUint32 *aWriteLength);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHOD Flush(void) {

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

@ -31,7 +31,6 @@ XPIDLSRCS= \
EXPORTS = \
nsIMsgOfflineNewsState.h \
nsINNTPArticleList.h \
nsINNTPCategory.h \
nsINNTPCategoryContainer.h \
nsINNTPHost.h \

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

@ -22,6 +22,7 @@
#include "nntpCore.h"
#include "nsNNTPProtocol.h"
#include "nsINNTPArticleList.h"
#include "nsIOutputStream.h"
#include "nsIInputStream.h"
#include "nsFileStream.h"

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

@ -35,6 +35,7 @@
#include "nsISecurityContext.h"
#include "xpgetstr.h"
#include "lcglue.h"
#include "nscore.h"
extern "C" int XP_PROGRESS_STARTING_JAVA;
extern "C" int XP_PROGRESS_STARTING_JAVA_DONE;

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

@ -216,7 +216,8 @@ public:
NS_IMETHOD
Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -21,6 +21,7 @@
#include "prlog.h"
#include "prmem.h"
#include "nscore.h"
class ns4xPluginStreamListener : public nsIPluginStreamListener {

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

@ -166,7 +166,8 @@ public:
NS_IMETHOD
Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -21,6 +21,7 @@
#include "prlog.h"
#include "prmem.h"
#include "nscore.h"
class ns4xPluginStreamListener : public nsIPluginStreamListener {

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

@ -166,7 +166,8 @@ public:
NS_IMETHOD
Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -216,7 +216,8 @@ public:
NS_IMETHOD
Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -676,7 +676,8 @@ public:
NS_IMETHOD
Write(const char* aBuf, PRInt32 aCount, PRInt32 *resultingCount);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -43,7 +43,8 @@ public:
NS_IMETHOD
Write(const char* aBuf, PRInt32 aCount, PRInt32 *resultingCount);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -26,7 +26,7 @@
#include "nsIComponentManager.h"
#include "nsNetConverterStream.h"
#include "nsCOMPtr.h"
#include "nscore.h"
static NS_DEFINE_CID(kINetPluginCID, NS_INET_PLUGIN_CID);

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

@ -48,7 +48,8 @@ public:
PRUint32 aLen,
PRUint32 *aWriteLength);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -113,7 +113,8 @@ public:
PRUint32 aLen,
PRUint32 *aWriteCount);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -157,7 +158,8 @@ public:
PRUint32 aLen,
PRUint32 *aWriteLength);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -203,7 +205,8 @@ public:
PRUint32 aLen,
PRUint32 *aWriteLength);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -154,7 +154,8 @@ public:
return NS_OK;
}
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -135,7 +135,8 @@ public:
return NS_OK;
}
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount) {
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 count,
PRUint32 *aWriteCount) {
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -19,6 +19,9 @@
/* Root idl declarations to be used by all. */
%{C++
#include "prtime.h"
/*
* Start commenting out the C++ versions of the below in the output header
*/
@ -30,6 +33,7 @@ typedef octet PRUint8 ;
typedef unsigned short PRUint16 ;
typedef unsigned long PRUint32 ;
typedef unsigned long long PRUint64 ;
typedef unsigned long long PRTime ;
typedef short PRInt16 ;
typedef long PRInt32 ;
typedef long long PRInt64 ;
@ -38,6 +42,7 @@ typedef unsigned long nsrefcnt ;
typedef unsigned long nsresult ;
[ptr] native voidStar(void);
[ptr] native charStar(char);
[ref, nsid] native nsIDRef(nsID);
[ref, nsid] native nsIIDRef(nsIID);

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

@ -30,8 +30,11 @@ MODULE = xpcom
XPIDL_MODULE = xpcom_io
XPIDLSRCS = \
nsIFileSpec.idl \
XPIDLSRCS = \
nsIFileSpec.idl \
nsIBaseStream.idl \
nsIInputStream.idl \
nsIOutputStream.idl \
$(NULL)
CPPSRCS = \
@ -54,11 +57,8 @@ EXPORTS = \
nsFileSpecImpl.h \
nsFileSpecStreaming.h \
nsFileStream.h \
nsIBaseStream.h \
nsIByteBufferInputStream.h \
nsIFileStream.h \
nsIInputStream.h \
nsIOutputStream.h \
nsIStringStream.h \
nsIUnicharInputStream.h \
nsSpecialSystemDirectory.h \

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

@ -29,11 +29,8 @@ EXPORTS = \
nsFileSpecImpl.h \
nsFileSpecStreaming.h \
nsFileStream.h \
nsIBaseStream.h \
nsIByteBufferInputStream.h \
nsIFileStream.h \
nsIInputStream.h \
nsIOutputStream.h \
nsIStringStream.h \
nsIUnicharInputStream.h \
nsSpecialSystemDirectory.h \
@ -42,20 +39,12 @@ EXPORTS = \
NO_XPT_GEN=1
XPIDL_MODULE = xpcom_io
XPIDLSRCS = \
.\nsIFileSpec.idl \
$(NULL)
xXPIDLSRCS = \
.\nsIUri.idl \
.\nsIUrl.idl \
.\nsIIOService.idl \
.\nsIIOSpec.idl \
.\nsIFileSpec.idl \
.\nsIStreamObserver.idl \
.\nsIBaseStream.idl \
.\nsIInputStream.idl \
.\nsIOutputStream.idl \
XPIDLSRCS = \
.\nsIFileSpec.idl \
.\nsIBaseStream.idl \
.\nsIInputStream.idl \
.\nsIOutputStream.idl \
.\nsIBufferInputStream.idl \
$(NULL)
################################################################################

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

@ -189,11 +189,11 @@ NS_IMETHODIMP
nsByteBufferInputStream::Fill(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount)
{
nsDummyBufferStream in(aBuf, aCount);
return Fill(&in, aWriteCount);
return Fill(&in, aCount, aWriteCount);
}
NS_IMETHODIMP
nsByteBufferInputStream::Fill(nsIInputStream* stream, PRUint32 *aWriteCount)
nsByteBufferInputStream::Fill(nsIInputStream* stream, PRUint32 aCount, PRUint32 *aWriteCount)
{
nsresult rv = NS_OK;
@ -201,9 +201,6 @@ nsByteBufferInputStream::Fill(nsIInputStream* stream, PRUint32 *aWriteCount)
return NS_BASE_STREAM_CLOSED;
*aWriteCount = 0;
PRUint32 aCount;
rv = stream->GetLength(&aCount);
if (NS_FAILED(rv)) return rv;
if (mBlocking)
PR_CEnterMonitor(this);
@ -349,15 +346,17 @@ nsByteBufferOutputStream::Close(void)
}
NS_IMETHODIMP
nsByteBufferOutputStream::Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount)
nsByteBufferOutputStream::Write(const char* aBuf, PRUint32 aCount,
PRUint32 *aWriteCount)
{
return mInputStream->Fill(aBuf, aCount, aWriteCount);
}
NS_IMETHODIMP
nsByteBufferOutputStream::Write(nsIInputStream* fromStream, PRUint32 *aWriteCount)
nsByteBufferOutputStream::WriteFrom(nsIInputStream* fromStream, PRUint32 aCount,
PRUint32 *aWriteCount)
{
return mInputStream->Fill(fromStream, aWriteCount);
return mInputStream->Fill(fromStream, aCount, aWriteCount);
}
NS_IMETHODIMP

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

@ -35,8 +35,10 @@ public:
NS_IMETHOD Close(void);
// nsIOutputStream methods:
NS_IMETHOD Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount);
NS_IMETHOD Write(const char* aBuf, PRUint32 aCount,
PRUint32 *aWriteCount);
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 aCount,
PRUint32 *aWriteCount);
NS_IMETHOD Flush(void);
// nsByteBufferOutputStream methods:
@ -62,7 +64,7 @@ public:
NS_IMETHOD Read(char* aBuf, PRUint32 aCount, PRUint32 *aReadCount);
// nsIByteBufferInputStream methods:
NS_IMETHOD Fill(nsIInputStream* stream, PRUint32 *aWriteCount);
NS_IMETHOD Fill(nsIInputStream* stream, PRUint32 aCount, PRUint32 *aWriteCount);
NS_IMETHOD Fill(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
// nsByteBufferInputStream methods:

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

@ -0,0 +1,45 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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.
*/
#include "nsISupports.idl"
[scriptable, uuid(6ccb17a0-e95e-11d1-beae-00805f8a66dc)]
interface nsIBaseStream : nsISupports
{
void Close();
};
/** Error codes */
%{C++
//@{
/// End of file
#define NS_BASE_STREAM_EOF NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 1)
/// Stream closed
#define NS_BASE_STREAM_CLOSED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 2)
/// Error from the operating system
#define NS_BASE_STREAM_OSERROR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 3)
/// Illegal arguments
#define NS_BASE_STREAM_ILLEGAL_ARGS NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 4)
/// For unichar streams
#define NS_BASE_STREAM_NO_CONVERTER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 5)
/// For unichar streams
#define NS_BASE_STREAM_BAD_CONVERSION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 6)
#define NS_BASE_STREAM_WOULD_BLOCK NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_BASE, 7)
//@}
%}

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

@ -0,0 +1,47 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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.
*/
#include "nsIInputStream.idl"
[scriptable, uuid(93e9a230-1955-11d3-933b-000064657374)]
interface nsIBufferInputStream : nsIInputStream
{
/**
* Returns a pointer to the buffer underlying an input stream.
* @param startPosition - the position relative to the start of
* the available data for which the segment is to be returned.
* If the startPosition is >= the available amount of data
* (returned by GetLength), NULL is returned for the bufferSegment.
* @param bufferSegment - returns the buffer, starting from the
* "read cursor" location.
* @param bufferSegmentSize - the number of contiguous bytes
* that can be read from this location.
* Note that the bufferSegmentSize may be less than the available
* amount of data (returned by GetLength) if the buffer input
* stream is internally represented by discontiguous segments.
*/
void GetBuffer(in unsigned long startPosition,
out charStar bufferSegment,
out unsigned long bufferSegmentSize);
/**
* Returns the position of a string in the buffer. Returns -1 if
* not found.
*/
long Find(in charStar aString);
};

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

@ -154,7 +154,8 @@ class FileImpl
*aWriteCount = bytesWrit;
return NS_OK;
}
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount)
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 aCount,
PRUint32 *aWriteCount)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -0,0 +1,40 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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.
*/
#include "nsIBaseStream.idl"
[scriptable, uuid(022396f0-93b5-11d1-895b-006008911b81)]
interface nsIInputStream : nsIBaseStream
{
/** Return the number of bytes in the stream
* @param aLength out parameter to hold the length
* of the stream. if an error occurs, the length
* will be undefined
* @return error status
*/
unsigned long GetLength();
/** Read data from the stream.
* @param aBuf the buffer into which the data is read
* @param aCount the maximum number of bytes to read
* @return aReadCount out parameter to hold the number of
* bytes read, eof if 0. if an error occurs, the
* read count will be undefined
*/
unsigned long Read(in charStar buf, in unsigned long count);
};

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

@ -0,0 +1,53 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
#include "nsIBaseStream.idl"
#include "nsIInputStream.idl"
[scriptable, uuid(7f13b870-e95f-11d1-beae-00805f8a66dc)]
interface nsIOutputStream : nsIBaseStream
{
/** Write data into the stream.
* @param aBuf the buffer from which the data is read
* @param aCount the maximum number of bytes to write
* @return aWriteCount out parameter to hold the number of
* bytes written. if an error occurs, the writecount
* is undefined
*/
unsigned long Write(in string buf, in unsigned long count);
/**
* Writes data into the stream from an input stream.
* Implementer's note: This method is defined by this interface in order
* to allow the output stream to efficiently copy the data from the input
* stream into its internal buffer (if any). If this method was provide
* as an external facility, a separate char* buffer would need to be used
* in order to call the output stream's other Write method.
* @param fromStream the stream from which the data is read
* @param count the maximun number of bytes to write
* @return aWriteCount out parameter to hold the number of
* bytes written. if an error occurs, the writecount
* is undefined
*/
unsigned long WriteFrom(in nsIInputStream inStr, in unsigned long count);
/**
* Flushes the stream.
*/
void Flush();
};

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

@ -110,7 +110,8 @@ class BasicStringImpl
*aWriteCount = bytesWrit;
return NS_OK;
}
NS_IMETHOD Write(nsIInputStream* fromStream, PRUint32 *aWriteCount)
NS_IMETHOD WriteFrom(nsIInputStream* fromStream, PRUint32 aCount,
PRUint32 *aWriteCount)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -19,6 +19,8 @@
#define nsIUnicharInputStream_h___
#include "nsIInputStream.h"
#include "nscore.h"
class nsString;
#define NS_IUNICHAR_INPUT_STREAM_IID \

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

@ -137,7 +137,7 @@ XPTHeader *getHeader(const char *filename, nsIAllocator *al) {
}
if (flen > 0) {
PRInt32 howmany = PR_Read(in, whole, flen);
PRUint32 howmany = PR_Read(in, whole, flen);
if (howmany < 0) {
NS_ERROR("FAILED: reading typelib file");
goto out;