diff --git a/mozilla/base/src/nsByteBuffer.cpp b/mozilla/base/src/nsByteBuffer.cpp index bd3c9b72467..167c9842a0b 100644 --- a/mozilla/base/src/nsByteBuffer.cpp +++ b/mozilla/base/src/nsByteBuffer.cpp @@ -23,25 +23,25 @@ class ByteBufferImpl : public nsIByteBuffer { public: - ByteBufferImpl(PRInt32 aBufferSize); + ByteBufferImpl(PRUint32 aBufferSize); ~ByteBufferImpl(); NS_DECL_ISUPPORTS - virtual PRInt32 GetLength() const; - virtual PRInt32 GetBufferSize() const; + virtual PRUint32 GetLength(void) const; + virtual PRUint32 GetBufferSize(void) const; virtual char* GetBuffer() const; - virtual PRBool Grow(PRInt32 aNewSize); + virtual PRBool Grow(PRUint32 aNewSize); virtual PRInt32 Fill(nsresult* aErrorCode, nsIInputStream* aStream, - PRInt32 aKeep); + PRUint32 aKeep); char* mBuffer; - PRInt32 mSpace; - PRInt32 mLength; + PRUint32 mSpace; + PRUint32 mLength; }; -ByteBufferImpl::ByteBufferImpl(PRInt32 aBufferSize) +ByteBufferImpl::ByteBufferImpl(PRUint32 aBufferSize) { - if (PRUint32(aBufferSize) < MIN_BUFFER_SIZE) { + if (aBufferSize < MIN_BUFFER_SIZE) { aBufferSize = MIN_BUFFER_SIZE; } mSpace = aBufferSize; @@ -62,24 +62,24 @@ ByteBufferImpl::~ByteBufferImpl() mLength = 0; } -PRInt32 ByteBufferImpl::GetLength() const +PRUint32 ByteBufferImpl::GetLength(void) const { return mLength; } -PRInt32 ByteBufferImpl::GetBufferSize() const +PRUint32 ByteBufferImpl::GetBufferSize(void) const { return mSpace; } -char* ByteBufferImpl::GetBuffer() const +char* ByteBufferImpl::GetBuffer(void) const { return mBuffer; } -PRBool ByteBufferImpl::Grow(PRInt32 aNewSize) +PRBool ByteBufferImpl::Grow(PRUint32 aNewSize) { - if (PRUint32(aNewSize) < MIN_BUFFER_SIZE) { + if (aNewSize < MIN_BUFFER_SIZE) { aNewSize = MIN_BUFFER_SIZE; } char* newbuf = new char[aNewSize]; @@ -95,10 +95,10 @@ PRBool ByteBufferImpl::Grow(PRInt32 aNewSize) } PRInt32 ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream, - PRInt32 aKeep) + PRUint32 aKeep) { NS_PRECONDITION(nsnull != aStream, "null stream"); - NS_PRECONDITION(PRUint32(aKeep) <= PRUint32(mLength), "illegal keep count"); + NS_PRECONDITION(aKeep <= mLength, "illegal keep count"); if ((nsnull == aStream) || (PRUint32(aKeep) > PRUint32(mLength))) { // whoops *aErrorCode = NS_BASE_STREAM_ILLEGAL_ARGS; @@ -112,8 +112,8 @@ PRInt32 ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream, // Read in some new data mLength = aKeep; - PRInt32 amount = mSpace - aKeep; - PRInt32 nb; + PRUint32 amount = mSpace - aKeep; + PRUint32 nb; *aErrorCode = aStream->Read(mBuffer, aKeep, amount, &nb); if (NS_SUCCEEDED(*aErrorCode)) { mLength += nb; @@ -125,7 +125,7 @@ PRInt32 ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream, NS_BASE nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult, nsISupports* aOuter, - PRInt32 aBufferSize) + PRUint32 aBufferSize) { if (nsnull != aOuter) { return NS_ERROR_NO_AGGREGATION; diff --git a/mozilla/base/src/nsCRT.cpp b/mozilla/base/src/nsCRT.cpp index 830caf58f65..c40633879ca 100644 --- a/mozilla/base/src/nsCRT.cpp +++ b/mozilla/base/src/nsCRT.cpp @@ -366,6 +366,15 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRInt32 n) return 0; } +PRUnichar* nsCRT::strdup(const PRUnichar* str) +{ + PRInt32 len = nsCRT::strlen(str) + 1; // add one for null + PRUnichar* rslt = new PRUnichar[len]; + if (rslt == NULL) return NULL; + nsCRT::memcpy(rslt, str, len * sizeof(PRUnichar)); + return rslt; +} + PRUint32 nsCRT::HashValue(const PRUnichar* us) { PRUint32 rv = 0; diff --git a/mozilla/base/src/nsCRT.h b/mozilla/base/src/nsCRT.h index 6c7ef58baa3..88c24886783 100644 --- a/mozilla/base/src/nsCRT.h +++ b/mozilla/base/src/nsCRT.h @@ -71,6 +71,10 @@ public: return PRInt32(PL_strncasecmp(s1, s2, aMaxLen)); } + static char* strdup(const char* str) { + return PL_strdup(str); + } + /// Like strlen except for ucs2 strings static PRInt32 strlen(const PRUnichar* s); @@ -98,6 +102,8 @@ public: static PRInt32 strncasecmp(const PRUnichar* s1, const char* s2, PRInt32 aMaxLen); + static PRUnichar* strdup(const PRUnichar* str); + /// Compute a hashcode for a ucs2 string static PRUint32 HashValue(const PRUnichar* s1); diff --git a/mozilla/base/src/nsIBaseStream.h b/mozilla/base/src/nsIBaseStream.h index 06efd0fad4f..1b716332f4a 100644 --- a/mozilla/base/src/nsIBaseStream.h +++ b/mozilla/base/src/nsIBaseStream.h @@ -38,19 +38,18 @@ public: /** Error codes */ //@{ -// XXX fix up the values so they are not total hacks... MMP /// End of file -#define NS_BASE_STREAM_EOF 0x80001001 +#define NS_BASE_STREAM_EOF NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 1) /// Stream closed -#define NS_BASE_STREAM_CLOSED 0x80001002 +#define NS_BASE_STREAM_CLOSED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 2) /// Error from the operating system -#define NS_BASE_STREAM_OSERROR 0x80001003 +#define NS_BASE_STREAM_OSERROR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 3) /// Illegal arguments -#define NS_BASE_STREAM_ILLEGAL_ARGS 0x80001004 +#define NS_BASE_STREAM_ILLEGAL_ARGS NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 4) /// For unichar streams -#define NS_BASE_STREAM_NO_CONVERTER 0x80001005 +#define NS_BASE_STREAM_NO_CONVERTER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 5) /// For unichar streams -#define NS_BASE_STREAM_BAD_CONVERSION 0x80001006 +#define NS_BASE_STREAM_BAD_CONVERSION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 6) //@} diff --git a/mozilla/base/src/nsIByteBuffer.h b/mozilla/base/src/nsIByteBuffer.h index 43a04c29342..b27d8fd52f3 100644 --- a/mozilla/base/src/nsIByteBuffer.h +++ b/mozilla/base/src/nsIByteBuffer.h @@ -31,26 +31,27 @@ class nsIInputStream; class nsIByteBuffer : public nsISupports { public: /** @return length of buffer, i.e. how many bytes are currently in it. */ - virtual PRInt32 GetLength() const = 0; + virtual PRUint32 GetLength(void) const = 0; /** @return number of bytes allocated in the buffer */ - virtual PRInt32 GetBufferSize() const = 0; + virtual PRUint32 GetBufferSize(void) const = 0; /** @return the buffer */ - virtual char* GetBuffer() const = 0; + virtual char* GetBuffer(void) const = 0; /** Grow buffer to aNewSize bytes. */ - virtual PRBool Grow(PRInt32 aNewSize) = 0; + virtual PRBool Grow(PRUint32 aNewSize) = 0; /** Fill the buffer with data from aStream. Don't grow the buffer, only * read until length of buffer equals buffer size. */ virtual PRInt32 Fill(nsresult* aErrorCode, nsIInputStream* aStream, - PRInt32 aKeep) = 0; + PRUint32 aKeep) = 0; }; /** Create a new byte buffer using the given buffer size. */ extern NS_BASE nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult, nsISupports* aOuter, - PRInt32 aBufferSize = 0); + PRUint32 aBufferSize = 0); #endif /* nsIByteBuffer_h___ */ + diff --git a/mozilla/base/src/nsIInputStream.h b/mozilla/base/src/nsIInputStream.h index 37c942927f3..a1c5b6167d5 100644 --- a/mozilla/base/src/nsIInputStream.h +++ b/mozilla/base/src/nsIInputStream.h @@ -35,7 +35,7 @@ public: * @return error status */ NS_IMETHOD - GetLength(PRInt32 *aLength) = 0; + GetLength(PRUint32 *aLength) = 0; /** Read data from the stream. * @param aErrorCode the error code if an error occurs @@ -48,7 +48,7 @@ public: * @return error status */ NS_IMETHOD - Read(char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aReadCount) = 0; + Read(char* aBuf, PRUint32 aOffset, PRUint32 aCount, PRUint32 *aReadCount) = 0; }; #endif /* nsInputStream_h___ */ diff --git a/mozilla/base/src/nsIOutputStream.h b/mozilla/base/src/nsIOutputStream.h index ad032f52767..795416092d3 100644 --- a/mozilla/base/src/nsIOutputStream.h +++ b/mozilla/base/src/nsIOutputStream.h @@ -39,7 +39,7 @@ public: * @return error status */ NS_IMETHOD - Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aWriteCount) = 0; + Write(const char* aBuf, PRUint32 aOffset, PRUint32 aCount, PRUint32 *aWriteCount) = 0; }; diff --git a/mozilla/base/src/nsIUnicharBuffer.h b/mozilla/base/src/nsIUnicharBuffer.h index a5f57d7886b..4ce3a0cab54 100644 --- a/mozilla/base/src/nsIUnicharBuffer.h +++ b/mozilla/base/src/nsIUnicharBuffer.h @@ -41,6 +41,6 @@ public: extern NS_BASE nsresult NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult, nsISupports* aOuter, - PRInt32 aBufferSize = 0); + PRUint32 aBufferSize = 0); #endif /* nsIUnicharBuffer_h___ */ diff --git a/mozilla/base/src/nsIUnicharInputStream.h b/mozilla/base/src/nsIUnicharInputStream.h index ecd21b775d4..24de6710310 100644 --- a/mozilla/base/src/nsIUnicharInputStream.h +++ b/mozilla/base/src/nsIUnicharInputStream.h @@ -43,9 +43,9 @@ enum nsCharSetID { class nsIUnicharInputStream : public nsISupports { public: NS_IMETHOD Read(PRUnichar* aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount) = 0; + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount) = 0; NS_IMETHOD Close() = 0; }; @@ -66,12 +66,12 @@ public: * aDst; aSrcLen is updated to indicate how much data was used in * the source buffer. */ - virtual PRInt32 Convert(PRUnichar* aDst, - PRInt32 aDstOffset, - PRInt32& aDstLen, - const char* aSrc, - PRInt32 aSrcOffset, - PRInt32& aSrcLen) = 0; + NS_IMETHOD Convert(PRUnichar* aDst, + PRUint32 aDstOffset, + PRUint32& aDstLen, + const char* aSrc, + PRUint32 aSrcOffset, + PRUint32& aSrcLen) = 0; }; /** Create a new nsUnicharInputStream that provides a converter for the diff --git a/mozilla/base/src/nsString.cpp b/mozilla/base/src/nsString.cpp index 0191c9d1b50..fc7aac58e72 100644 --- a/mozilla/base/src/nsString.cpp +++ b/mozilla/base/src/nsString.cpp @@ -886,7 +886,7 @@ nsString& nsString::Append(float aFloat){ * @param aCount -- number of chars to copy * @return number of chars copied */ -PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) { +PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) const { return Mid(aCopy,0,aCount); } @@ -901,7 +901,7 @@ PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) { * @param anOffset -- position where copying begins * @return number of chars copied */ -PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) { +PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) const { if(anOffsetRead(mBuffer, aKeep, amount, &nb); + PRUint32 nb; + NS_ASSERTION(aKeep >= 0, "unsigned madness"); + NS_ASSERTION(amount >= 0, "unsigned madness"); + *aErrorCode = aStream->Read(mBuffer, (PRUint32)aKeep, (PRUint32)amount, &nb); if (NS_SUCCEEDED(*aErrorCode)) { mLength += nb; } @@ -127,7 +129,7 @@ PRInt32 UnicharBufferImpl::Fill(nsresult* aErrorCode, NS_BASE nsresult NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult, nsISupports* aOuter, - PRInt32 aBufferSize) + PRUint32 aBufferSize) { if (nsnull != aOuter) { return NS_ERROR_NO_AGGREGATION; diff --git a/mozilla/base/src/nsUnicharInputStream.cpp b/mozilla/base/src/nsUnicharInputStream.cpp index 73dca958566..feb1be7d6e3 100644 --- a/mozilla/base/src/nsUnicharInputStream.cpp +++ b/mozilla/base/src/nsUnicharInputStream.cpp @@ -37,14 +37,14 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD Read(PRUnichar* aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount); + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount); NS_IMETHOD Close(); nsString* mString; - PRInt32 mPos; - PRInt32 mLen; + PRUint32 mPos; + PRUint32 mLen; }; StringUnicharInputStream::StringUnicharInputStream(nsString* aString) @@ -63,16 +63,17 @@ StringUnicharInputStream::~StringUnicharInputStream() } nsresult StringUnicharInputStream::Read(PRUnichar* aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount) + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount) { if (mPos >= mLen) { *aReadCount = 0; return (nsresult)-1; } const PRUnichar* us = mString->GetUnicode(); - PRInt32 amount = mLen - mPos; + NS_ASSERTION(mLen >= mPos, "unsigned madness"); + PRUint32 amount = mLen - mPos; if (amount > aCount) { amount = aCount; } @@ -119,12 +120,12 @@ public: IsoLatin1Converter(); NS_DECL_ISUPPORTS - virtual PRInt32 Convert(PRUnichar* aDst, - PRInt32 aDstOffset, - PRInt32& aDstLen, - const char* aSrc, - PRInt32 aSrcOffset, - PRInt32& aSrcLen); + NS_IMETHOD Convert(PRUnichar* aDst, + PRUint32 aDstOffset, + PRUint32& aDstLen, + const char* aSrc, + PRUint32 aSrcOffset, + PRUint32& aSrcLen); }; IsoLatin1Converter::IsoLatin1Converter() @@ -135,14 +136,14 @@ IsoLatin1Converter::IsoLatin1Converter() NS_DEFINE_IID(kIB2UConverterIID, NS_IB2UCONVERTER_IID); NS_IMPL_ISUPPORTS(IsoLatin1Converter,kIB2UConverterIID); -PRInt32 IsoLatin1Converter::Convert(PRUnichar* aDst, - PRInt32 aDstOffset, - PRInt32& aDstLen, +nsresult IsoLatin1Converter::Convert(PRUnichar* aDst, + PRUint32 aDstOffset, + PRUint32& aDstLen, const char* aSrc, - PRInt32 aSrcOffset, - PRInt32& aSrcLen) + PRUint32 aSrcOffset, + PRUint32& aSrcLen) { - PRInt32 amount = aSrcLen; + PRUint32 amount = aSrcLen; if (aSrcLen > aDstLen) { amount = aDstLen; } @@ -181,14 +182,14 @@ class ConverterInputStream : public nsIUnicharInputStream { public: ConverterInputStream(nsIInputStream* aStream, nsIB2UConverter* aConverter, - PRInt32 aBufSize); + PRUint32 aBufSize); ~ConverterInputStream(); NS_DECL_ISUPPORTS NS_IMETHOD Read(PRUnichar* aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount); + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount); NS_IMETHOD Close(); protected: @@ -197,15 +198,15 @@ protected: nsIInputStream* mInput; nsIB2UConverter* mConverter; nsIByteBuffer* mByteData; - PRInt32 mByteDataOffset; + PRUint32 mByteDataOffset; nsIUnicharBuffer* mUnicharData; - PRInt32 mUnicharDataOffset; - PRInt32 mUnicharDataLength; + PRUint32 mUnicharDataOffset; + PRUint32 mUnicharDataLength; }; ConverterInputStream::ConverterInputStream(nsIInputStream* aStream, nsIB2UConverter* aConverter, - PRInt32 aBufferSize) + PRUint32 aBufferSize) { NS_INIT_REFCNT(); mInput = aStream; aStream->AddRef(); @@ -250,11 +251,12 @@ nsresult ConverterInputStream::Close() } nsresult ConverterInputStream::Read(PRUnichar* aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount) + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount) { - PRInt32 rv = mUnicharDataLength - mUnicharDataOffset; + NS_ASSERTION(mUnicharDataLength >= mUnicharDataOffset, "unsigned madness"); + PRUint32 rv = mUnicharDataLength - mUnicharDataOffset; nsresult errorCode; if (0 == rv) { // Fill the unichar buffer @@ -282,7 +284,8 @@ PRInt32 ConverterInputStream::Fill(nsresult * aErrorCode) return -1; } - PRInt32 remainder = mByteData->GetLength() - mByteDataOffset; + NS_ASSERTION(mByteData->GetLength() >= mByteDataOffset, "unsigned madness"); + PRUint32 remainder = mByteData->GetLength() - mByteDataOffset; mByteDataOffset = remainder; PRInt32 nb = mByteData->Fill(aErrorCode, mInput, remainder); if (nb <= 0) { @@ -296,8 +299,8 @@ PRInt32 ConverterInputStream::Fill(nsresult * aErrorCode) NS_ASSERTION(remainder + nb == mByteData->GetLength(), "bad nb"); // Now convert as much of the byte buffer to unicode as possible - PRInt32 dstLen = mUnicharData->GetBufferSize(); - PRInt32 srcLen = remainder + nb; + PRUint32 dstLen = mUnicharData->GetBufferSize(); + PRUint32 srcLen = remainder + nb; *aErrorCode = mConverter->Convert(mUnicharData->GetBuffer(), 0, dstLen, mByteData->GetBuffer(), 0, srcLen); mUnicharDataOffset = 0; diff --git a/mozilla/base/tests/CvtURL.cpp b/mozilla/base/tests/CvtURL.cpp index f3f50f47626..87edf6a20ef 100644 --- a/mozilla/base/tests/CvtURL.cpp +++ b/mozilla/base/tests/CvtURL.cpp @@ -55,8 +55,9 @@ int main(int argc, char** argv) } // Get an input stream from the url - PRInt32 ec; - nsIInputStream* in = url->Open(&ec); + nsresult ec; + nsIInputStream* in; + ec = NS_OpenURL(url, &in); if (nsnull == in) { printf("open of url('%s') failed: error=%x\n", urlName, ec); return -1; @@ -75,7 +76,7 @@ int main(int argc, char** argv) PRInt32 count = 0; for (;;) { PRUnichar buf[1000]; - PRInt32 nb; + PRUint32 nb; ec = uin->Read(buf, 0, 1000, &nb); if (ec < 0) { if (ec != NS_BASE_STREAM_EOF) { diff --git a/mozilla/build/mac/NGLayoutBuildList.pm b/mozilla/build/mac/NGLayoutBuildList.pm index c150fbf48f9..93758256011 100644 --- a/mozilla/build/mac/NGLayoutBuildList.pm +++ b/mozilla/build/mac/NGLayoutBuildList.pm @@ -212,6 +212,7 @@ sub BuildDist() InstallFromManifest(":mozilla:lib:liblayer:include:MANIFEST", "$distdirectory:layers:"); #NETWORK + InstallFromManifest(":mozilla:network:public:MANIFEST", "$distdirectory:network:"); InstallFromManifest(":mozilla:network:cache:MANIFEST", "$distdirectory:network:"); InstallFromManifest(":mozilla:network:client:MANIFEST", "$distdirectory:network:"); InstallFromManifest(":mozilla:network:cnvts:MANIFEST", "$distdirectory:network:"); diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 5034366c42d..2426cf56b60 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -568,9 +568,7 @@ nsDocument::StartDocumentLoad(nsIURL *aURL, mDocumentURL = aURL; NS_ADDREF(aURL); - mDocumentURLGroup = aURL->GetURLGroup(); - - return NS_OK; + return aURL->GetURLGroup(&mDocumentURLGroup); } const nsString* nsDocument::GetDocumentTitle() const diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 1a67f949c79..0ae9fc60a1d 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -71,7 +71,7 @@ static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID static NS_DEFINE_IID(kIDOMHTMLOptionElementIID, NS_IDOMHTMLOPTIONELEMENT_IID); static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID); static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTML_CONTENT_SINK_IID); -static NS_DEFINE_IID(kIHTTPUrlIID, NS_IHTTPURL_IID); +static NS_DEFINE_IID(kIHTTPURLIID, NS_IHTTPURL_IID); static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID); static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID); static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID); @@ -301,12 +301,12 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg); - NS_IMETHOD GetBindInfo(nsIURL* aURL); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo); NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, - PRInt32 aLength); + PRUint32 aLength); protected: nsIURL* mURL; @@ -1381,9 +1381,11 @@ HTMLContentSink::Init(nsIDocument* aDoc, mCurrentContext->Begin(eHTMLTag_html, mRoot); mContextStack.AppendElement(mCurrentContext); + const char* spec; + (void)aURL->GetSpec(&spec); SINK_TRACE(SINK_TRACE_CALLS, ("HTMLContentSink::Init: this=%p url='%s'", - this, aURL->GetSpec())); + this, spec)); return NS_OK; } @@ -1906,8 +1908,9 @@ HTMLContentSink::StartLayout() // If the document we are loading has a reference or it is a top level // frameset document, disable the scroll bars on the views. - const char* ref = mDocumentURL->GetRef(); - if (nsnull != ref) { + const char* ref; + nsresult rv = mDocumentURL->GetRef(&ref); + if (rv == NS_OK) { mRef = new nsString(ref); } PRBool topLevelFrameset = PR_FALSE; @@ -2200,7 +2203,8 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode) if ((0 == type.Length()) || type.EqualsIgnoreCase("text/css")) { nsIURL* url = nsnull; nsAutoString absURL; - nsIURLGroup* urlGroup = mDocumentURL->GetURLGroup(); + nsIURLGroup* urlGroup; + (void)mDocumentURL->GetURLGroup(&urlGroup); result = NS_MakeAbsoluteURL(mDocumentURL, mBaseHREF, href, absURL); if (NS_OK != result) { return result; @@ -2210,7 +2214,7 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode) NS_RELEASE(urlGroup); } else { - result = NS_NewURL(&url, nsnull, absURL); + result = NS_NewURL(&url, absURL); } if (NS_OK != result) { return result; @@ -2269,8 +2273,8 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode) mHead->AppendChildTo(it, PR_FALSE); // If we are processing an HTTP url, handle meta http-equiv cases - nsIHttpUrl* httpUrl = nsnull; - rv = mDocumentURL->QueryInterface(kIHTTPUrlIID, (void **)&httpUrl); + nsIHttpURL* httpUrl = nsnull; + rv = mDocumentURL->QueryInterface(kIHTTPURLIID, (void **)&httpUrl); if (NS_OK == rv) { nsAutoString header; it->GetAttribute(nsHTMLAtoms::httpEquiv, header); @@ -2363,7 +2367,7 @@ HTMLContentSink::EvaluateScript(nsString& aScript, nsIURL* docURL = mDocument->GetDocumentURL(); const char* url; if (docURL) { - url = docURL->GetSpec(); + (void)docURL->GetSpec(&url); } PRBool isUndefined; @@ -2443,7 +2447,8 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) // Use the SRC attribute value to open an accumulating stream nsIURL* url = nsnull; nsAutoString absURL; - nsIURLGroup* urlGroup = mDocumentURL->GetURLGroup(); + nsIURLGroup* urlGroup; + (void)mDocumentURL->GetURLGroup(&urlGroup); rv = NS_MakeAbsoluteURL(mDocumentURL, mBaseHREF, src, absURL); if (NS_OK != rv) { return rv; @@ -2453,7 +2458,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) NS_RELEASE(urlGroup); } else { - rv = NS_NewURL(&url, nsnull, absURL); + rv = NS_NewURL(&url, absURL); } if (NS_OK != rv) { return rv; @@ -2576,7 +2581,8 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) // XXX what does nav do? // Use the SRC attribute value to open an accumulating stream nsAutoString absURL; - nsIURLGroup* urlGroup = mDocumentURL->GetURLGroup(); + nsIURLGroup* urlGroup; + (void)mDocumentURL->GetURLGroup(&urlGroup); rv = NS_MakeAbsoluteURL(mDocumentURL, mBaseHREF, src, absURL); if (NS_OK != rv) { return rv; @@ -2586,7 +2592,7 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) NS_RELEASE(urlGroup); } else { - rv = NS_NewURL(&url, nsnull, absURL); + rv = NS_NewURL(&url, absURL); } if (NS_OK != rv) { return rv; @@ -2755,7 +2761,7 @@ nsAccumulatingURLLoader::nsAccumulatingURLLoader(nsIURL* aURL, nsresult rv; if (aURL) { - rv = aURL->Open(this); + rv = NS_OpenURL(aURL, this); if ((NS_OK != rv) && (nsnull != mFunc)) { (*mFunc)(this, *mData, mRef, rv); } @@ -2782,22 +2788,22 @@ nsAccumulatingURLLoader::OnStartBinding(nsIURL* aURL, NS_IMETHODIMP nsAccumulatingURLLoader::OnProgress(nsIURL* aURL, - PRInt32 aProgress, - PRInt32 aProgressMax) + PRUint32 aProgress, + PRUint32 aProgressMax) { return NS_OK; } NS_IMETHODIMP -nsAccumulatingURLLoader::OnStatus(nsIURL* aURL, const nsString &aMsg) +nsAccumulatingURLLoader::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { return NS_OK; } NS_IMETHODIMP nsAccumulatingURLLoader::OnStopBinding(nsIURL* aURL, - PRInt32 aStatus, - const nsString &aMsg) + nsresult aStatus, + const PRUnichar* aMsg) { (*mFunc)(this, *mData, mRef, aStatus); @@ -2805,7 +2811,7 @@ nsAccumulatingURLLoader::OnStopBinding(nsIURL* aURL, } NS_IMETHODIMP -nsAccumulatingURLLoader::GetBindInfo(nsIURL* aURL) +nsAccumulatingURLLoader::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo) { return NS_OK; } @@ -2815,11 +2821,11 @@ nsAccumulatingURLLoader::GetBindInfo(nsIURL* aURL) NS_IMETHODIMP nsAccumulatingURLLoader::OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, - PRInt32 aLength) + PRUint32 aLength) { nsresult rv = NS_OK; char buffer[BUF_SIZE]; - PRInt32 len, lenRead; + PRUint32 len, lenRead; aIStream->GetLength(&len); diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 45501fa24e9..19e40820032 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -227,10 +227,11 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL, static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - rv = nsRepository::CreateInstance(kCParserCID, - nsnull, - kCParserIID, - (void **)&mParser); + if (rv == NS_OK) + rv = nsRepository::CreateInstance(kCParserCID, + nsnull, + kCParserIID, + (void **)&mParser); if (NS_OK == rv) { nsIHTMLContentSink* sink; @@ -615,7 +616,8 @@ nsHTMLDocument::GetDomain(nsString& aDomain) // PCB: This is the domain name of the server that produced this document. Can we just // extract it from the URL? What about proxy servers, etc.? if (nsnull != mDocumentURL) { - const char* hostName = mDocumentURL->GetHost(); + const char* hostName; + nsresult rslt = mDocumentURL->GetHost(&hostName); aDomain.SetString(hostName); } else { aDomain.SetLength(0); @@ -627,7 +629,10 @@ NS_IMETHODIMP nsHTMLDocument::GetURL(nsString& aURL) { if (nsnull != mDocumentURL) { - mDocumentURL->ToString(aURL); + PRUnichar* str; + mDocumentURL->ToString(&str); + aURL = str; + delete str; } return NS_OK; } diff --git a/mozilla/content/html/document/src/nsImageDocument.cpp b/mozilla/content/html/document/src/nsImageDocument.cpp index 4dbafa00fca..467db7dd70f 100644 --- a/mozilla/content/html/document/src/nsImageDocument.cpp +++ b/mozilla/content/html/document/src/nsImageDocument.cpp @@ -77,13 +77,13 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, - const nsString& aMsg); - NS_IMETHOD GetBindInfo(nsIURL* aURL); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, + const PRUnichar* aMsg); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo); NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream* aStream, - PRInt32 aCount); + PRUint32 aCount); nsImageDocument* mDocument; nsIStreamListener* mNextStream; @@ -115,8 +115,8 @@ ImageListener::OnStartBinding(nsIURL* aURL, const char *aContentType) } NS_IMETHODIMP -ImageListener::OnProgress(nsIURL* aURL, PRInt32 aProgress, - PRInt32 aProgressMax) +ImageListener::OnProgress(nsIURL* aURL, PRUint32 aProgress, + PRUint32 aProgressMax) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; @@ -125,7 +125,7 @@ ImageListener::OnProgress(nsIURL* aURL, PRInt32 aProgress, } NS_IMETHODIMP -ImageListener::OnStatus(nsIURL* aURL, const nsString &aMsg) +ImageListener::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; @@ -134,8 +134,8 @@ ImageListener::OnStatus(nsIURL* aURL, const nsString &aMsg) } NS_IMETHODIMP -ImageListener::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, - const nsString& aMsg) +ImageListener::OnStopBinding(nsIURL* aURL, nsresult aStatus, + const PRUnichar* aMsg) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; @@ -144,17 +144,17 @@ ImageListener::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, } NS_IMETHODIMP -ImageListener::GetBindInfo(nsIURL* aURL) +ImageListener::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->GetBindInfo(aURL); + return mNextStream->GetBindInfo(aURL, aInfo); } NS_IMETHODIMP ImageListener::OnDataAvailable(nsIURL* aURL, nsIInputStream* aStream, - PRInt32 aCount) + PRUint32 aCount) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; @@ -246,7 +246,7 @@ nsImageDocument::StartImageLoad(nsIURL* aURL, nsIStreamListener*& aListener) cx->GetImageGroup(group); if (nsnull != group) { const char* spec; - spec = aURL->GetSpec(); + (void)aURL->GetSpec(&spec); nscolor black = NS_RGB(0, 0, 0); nsIStreamListener* listener = nsnull; rv = group->GetImageFromStream(spec, nsnull, &mBlack, @@ -309,9 +309,10 @@ nsImageDocument::CreateSyntheticDocument() } image->SetDocument(this, PR_FALSE); - nsAutoString src; - mDocumentURL->ToString(src); + PRUnichar* src; + mDocumentURL->ToString(&src); nsHTMLValue val(src); + delete src; image->SetAttribute(nsHTMLAtoms::src, val, PR_FALSE); image->SetAttribute(nsHTMLAtoms::alt, val, PR_FALSE); diff --git a/mozilla/content/html/style/src/nsCSSParser.cpp b/mozilla/content/html/style/src/nsCSSParser.cpp index 2237f531f94..94da05588b5 100644 --- a/mozilla/content/html/style/src/nsCSSParser.cpp +++ b/mozilla/content/html/style/src/nsCSSParser.cpp @@ -720,7 +720,7 @@ PRBool CSSParserImpl::ProcessImport(PRInt32& aErrorCode, const nsString& aURLSpe // the url that follows a "?" char* cp = aURLSpec.ToNewCString(); nsIURL* url; - aErrorCode = NS_NewURL(&url, mURL, cp); + aErrorCode = NS_NewURL(&url, cp, mURL); delete [] cp; if (NS_FAILED(aErrorCode)) { // import url is bad @@ -730,9 +730,9 @@ PRBool CSSParserImpl::ProcessImport(PRInt32& aErrorCode, const nsString& aURLSpe if (PR_FALSE == mSheet->ContainsStyleSheet(url)) { // don't allow circular references - PRInt32 ec; - nsIInputStream* in = url->Open(&ec); - if (nsnull == in) { + nsIInputStream* in; + nsresult rv = NS_OpenURL(url, &in); + if (rv != NS_OK) { // failure to make connection // XXX log this somewhere for easier web page debugging } diff --git a/mozilla/content/html/style/src/nsCSSScanner.cpp b/mozilla/content/html/style/src/nsCSSScanner.cpp index 51fc7a7c412..a055aa5c73e 100644 --- a/mozilla/content/html/style/src/nsCSSScanner.cpp +++ b/mozilla/content/html/style/src/nsCSSScanner.cpp @@ -129,7 +129,7 @@ PRInt32 nsCSSScanner::Read(PRInt32& aErrorCode) } if (mOffset == mCount) { mOffset = 0; - aErrorCode = mInput->Read(mBuffer, 0, BUFFER_SIZE, &mCount); + aErrorCode = mInput->Read(mBuffer, 0, BUFFER_SIZE, (PRUint32*)&mCount); if (NS_FAILED(aErrorCode)) { mCount = 0; return -1; diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp index d3dbd968918..69896d1a2c7 100644 --- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp @@ -1547,16 +1547,17 @@ nsresult CSSStyleSheetImpl::GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& a void CSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { - nsAutoString buffer; + PRUnichar* buffer; PRInt32 index; // Indent for (index = aIndent; --index >= 0; ) fputs(" ", out); fputs("CSS Style Sheet: ", out); - mURL->ToString(buffer); + mURL->ToString(&buffer); fputs(buffer, out); fputs("\n", out); + delete buffer; const nsICSSStyleSheet* child = mFirstChild; while (nsnull != child) { @@ -1659,7 +1660,10 @@ NS_IMETHODIMP CSSStyleSheetImpl::GetHref(nsString& aHref) { if (mURL.IsNotNull()) { - mURL->ToString(aHref); + PRUnichar* str; + mURL->ToString(&str); + aHref = str; + delete str; } else { aHref.SetLength(0); diff --git a/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp index 0b0481c7a8f..489cafacb9a 100644 --- a/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLCSSStyleSheet.cpp @@ -315,16 +315,16 @@ HTMLCSSStyleSheetImpl::SetOwningDocument(nsIDocument* aDocument) void HTMLCSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { - nsAutoString buffer; + PRUnichar* buffer; // Indent for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); fputs("HTML CSS Style Sheet: ", out); - mURL->ToString(buffer); + mURL->ToString(&buffer); fputs(buffer, out); fputs("\n", out); - + delete buffer; } diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp index 3a9882133f5..654d46ae470 100644 --- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp @@ -2687,16 +2687,16 @@ HTMLStyleSheetImpl::StyleRuleRemoved(nsIPresContext* aPresContext, void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { - nsAutoString buffer; + PRUnichar* buffer; // Indent for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); fputs("HTML Style Sheet: ", out); - mURL->ToString(buffer); + mURL->ToString(&buffer); fputs(buffer, out); fputs("\n", out); - + delete buffer; } // XXX For convenience and backwards compatibility diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 88312ee65f9..cc8cbb58b4d 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -834,15 +834,15 @@ nsXMLContentSink::AddProcessingInstruction(const nsIParserNode& aNode) return result; } NS_RELEASE(docURL); - result = NS_NewURL(&url, nsnull, absURL); + result = NS_NewURL(&url, absURL); if (NS_OK != result) { return result; } - PRInt32 ec; - nsIInputStream* iin = url->Open(&ec); - if (nsnull == iin) { + nsIInputStream* iin; + result = NS_OpenURL(url, &iin); + if (NS_OK != result) { NS_RELEASE(url); - return (nsresult) ec;/* XXX fix url->Open */ + return result; } result = NS_NewConverterStream(&uin, nsnull, iin); NS_RELEASE(iin); @@ -1066,7 +1066,8 @@ nsXMLContentSink::StartLayout() // If the document we are loading has a reference or it is a top level // frameset document, disable the scroll bars on the views. - const char* ref = mDocumentURL->GetRef(); + const char* ref; + (void)mDocumentURL->GetRef(&ref); PRBool topLevelFrameset = PR_FALSE; if (mWebShell) { nsIWebShell* rootWebShell; @@ -1129,7 +1130,7 @@ nsXMLContentSink::EvaluateScript(nsString& aScript, PRUint32 aLineNo) nsIURL* mDocURL = mDocument->GetDocumentURL(); const char* mURL; if (mDocURL) { - mURL = mDocURL->GetSpec(); + (void)mDocURL->GetSpec(&mURL); } nsAutoString val; @@ -1240,19 +1241,19 @@ nsXMLContentSink::ProcessStartSCRIPTTag(const nsIParserNode& aNode) return rv; } NS_RELEASE(docURL); - rv = NS_NewURL(&url, nsnull, absURL); + rv = NS_NewURL(&url, absURL); if (NS_OK != rv) { return rv; } - PRInt32 ec; - nsIInputStream* iin = url->Open(&ec); - if (nsnull == iin) { + nsIInputStream* iin; + rv = NS_OpenURL(url, &iin); + if (NS_OK != rv) { NS_RELEASE(url); - return (nsresult) ec;/* XXX fix url->Open */ + return rv; } // Drain the stream by reading from it a chunk at a time - PRInt32 nb; + PRUint32 nb; nsresult err; do { char buf[SCRIPT_BUF_SIZE]; diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index e0c4f9ff4fe..b884842baf1 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -238,9 +238,9 @@ public: // nsIStreamObserver NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg); // nsINetSupport interface methods NS_IMETHOD_(void) Alert(const nsString &aText); @@ -1857,10 +1857,14 @@ nsWebShell::OnConnectionsComplete() url = document->GetDocumentURL(); if (nsnull != url) { - urlString = url->GetSpec(); + const char* spec; + rv = url->GetSpec(&spec); /* XXX: The load status needs to be passed in... */ - rv = mContainer->EndLoadURL(this, urlString, /* XXX */ 0 ); + if (rv == NS_OK) { + urlString = spec; + rv = mContainer->EndLoadURL(this, urlString, /* XXX */ 0 ); + } NS_RELEASE(url); } NS_RELEASE(document); @@ -1945,7 +1949,10 @@ nsWebShell::RefreshURL(nsIURL* aURL, PRInt32 millis, PRBool repeat) data->mShell = this; NS_ADDREF(data->mShell); - data->mUrlSpec = aURL->GetSpec(); + const char* spec; + rv = aURL->GetSpec(&spec); + + data->mUrlSpec = spec; data->mDelay = millis; data->mRepeat = repeat; @@ -2003,7 +2010,7 @@ nsWebShell::OnStartBinding(nsIURL* aURL, const char *aContentType) NS_IMETHODIMP -nsWebShell::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) +nsWebShell::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult rv = NS_OK; @@ -2012,7 +2019,9 @@ nsWebShell::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) } if (nsnull != mContainer) { - nsAutoString urlString(aURL->GetSpec()); + const char* spec; + (void)aURL->GetSpec(&spec); + nsAutoString urlString(spec); rv = mContainer->ProgressLoadURL(this, urlString, aProgress, aProgressMax); } @@ -2031,7 +2040,7 @@ nsWebShell::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) NS_IMETHODIMP -nsWebShell::OnStatus(nsIURL* aURL, const nsString &aMsg) +nsWebShell::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { nsresult rv = NS_OK; @@ -2053,7 +2062,7 @@ nsWebShell::OnStatus(nsIURL* aURL, const nsString &aMsg) NS_IMETHODIMP -nsWebShell::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg) +nsWebShell::OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg) { nsresult rv = NS_OK; diff --git a/mozilla/dom/src/base/nsGlobalWindow.h b/mozilla/dom/src/base/nsGlobalWindow.h index 5b4b697f03c..197659f29eb 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.h +++ b/mozilla/dom/src/base/nsGlobalWindow.h @@ -250,6 +250,8 @@ protected: void *mScriptObject; }; +class nsIURL; + class LocationImpl : public nsIScriptObjectOwner, public nsIDOMLocation { protected: @@ -284,9 +286,7 @@ public: NS_IMETHOD Replace(const nsString& aUrl); protected: - nsresult ConcatenateAndSet(const char *aProtocol, const char *aHost, - PRInt32 aPort, const char *aFile, - const char *aRef, const char *aSearch); + nsresult SetURL(nsIURL* aURL); nsIWebShell *mWebShell; void *mScriptObject; diff --git a/mozilla/dom/src/base/nsLocation.cpp b/mozilla/dom/src/base/nsLocation.cpp index 806c42cdf27..461374686c7 100644 --- a/mozilla/dom/src/base/nsLocation.cpp +++ b/mozilla/dom/src/base/nsLocation.cpp @@ -95,41 +95,14 @@ LocationImpl::SetWebShell(nsIWebShell *aWebShell) mWebShell = aWebShell; } -nsresult -LocationImpl::ConcatenateAndSet(const char *aProtocol, - const char *aHost, - PRInt32 aPort, - const char *aFile, - const char *aRef, - const char *aSearch) +nsresult +LocationImpl::SetURL(nsIURL* aURL) { - nsAutoString href; - - href.SetString(aProtocol); - href.Append("://"); - if (nsnull != aHost) { - href.Append(aHost); - if (0 < aPort) { - href.Append(':'); - href.Append(aPort, 10); - } - } - href.Append(aFile); - if (nsnull != aRef) { - if ('#' != *aRef) { - href.Append('#'); - } - href.Append(aRef); - } - if (nsnull != aSearch) { - if ('?' != *aSearch) { - href.Append('?'); - } - href.Append(aSearch); - } - if (nsnull != mWebShell) { - return mWebShell->LoadURL(href, nsnull, PR_TRUE); + const char* spec; + aURL->GetSpec(&spec); + nsAutoString s = spec; + return mWebShell->LoadURL(s, nsnull, PR_TRUE); } else { return NS_OK; @@ -148,8 +121,8 @@ LocationImpl::GetHash(nsString& aHash) if (NS_OK == result) { result = NS_NewURL(&url, href); if (NS_OK == result) { - ref = url->GetRef(); - if ((nsnull != ref) && ('\0' != *ref)) { + result = url->GetRef(&ref); + if (result == NS_OK && (nsnull != ref) && ('\0' != *ref)) { aHash.SetString("#"); aHash.Append(ref); } @@ -175,11 +148,8 @@ LocationImpl::SetHash(const nsString& aHash) result = NS_NewURL(&url, href); if (NS_OK == result) { char *buf = aHash.ToNewCString(); - - result = ConcatenateAndSet(url->GetProtocol(), url->GetHost(), - url->GetPort(), url->GetFile(), - buf, url->GetSearch()); - + url->SetRef(buf); + SetURL(url); delete buf; NS_IF_RELEASE(url); } @@ -199,11 +169,16 @@ LocationImpl::GetHost(nsString& aHost) if (NS_OK == result) { result = NS_NewURL(&url, href); if (NS_OK == result) { - aHost.SetString(url->GetHost()); - PRInt32 port = url->GetPort(); - if (-1 != port) { - aHost.Append(":"); - aHost.Append(port, 10); + const char* host; + result = url->GetHost(&host); + if (result == NS_OK) { + aHost.SetString(host); + PRUint32 port; + (void)url->GetHostPort(&port); + if (-1 != port) { + aHost.Append(":"); + aHost.Append(port, 10); + } } NS_IF_RELEASE(url); } @@ -224,10 +199,8 @@ LocationImpl::SetHost(const nsString& aHost) result = NS_NewURL(&url, href); if (NS_OK == result) { char *buf = aHost.ToNewCString(); - - result = ConcatenateAndSet(url->GetProtocol(), buf, - -1, url->GetFile(), - url->GetRef(), url->GetSearch()); + url->SetHost(buf); + SetURL(url); delete buf; NS_IF_RELEASE(url); } @@ -247,7 +220,10 @@ LocationImpl::GetHostname(nsString& aHostname) if (NS_OK == result) { result = NS_NewURL(&url, href); if (NS_OK == result) { - aHostname.SetString(url->GetHost()); + const char* host; + result = url->GetHost(&host); + if (result == NS_OK) + aHostname.SetString(host); NS_IF_RELEASE(url); } } @@ -267,10 +243,8 @@ LocationImpl::SetHostname(const nsString& aHostname) result = NS_NewURL(&url, href); if (NS_OK == result) { char *buf = aHostname.ToNewCString(); - - result = ConcatenateAndSet(url->GetProtocol(), buf, - url->GetPort(), url->GetFile(), - url->GetRef(), url->GetSearch()); + url->SetHost(buf); + SetURL(url); delete buf; NS_IF_RELEASE(url); } @@ -306,9 +280,11 @@ LocationImpl::SetHref(const nsString& aHref) if (NS_OK == result) { result = NS_NewURL(&oldUrl, oldHref); if (NS_OK == result) { - result = NS_NewURL(&newUrl, oldUrl, aHref); + result = NS_NewURL(&newUrl, aHref, oldUrl); if (NS_OK == result) { - newHref.SetString(newUrl->GetSpec()); + const char* spec; + result = newUrl->GetSpec(&spec); + newHref.SetString(spec); NS_RELEASE(newUrl); } NS_RELEASE(oldUrl); @@ -333,7 +309,10 @@ LocationImpl::GetPathname(nsString& aPathname) if (NS_OK == result) { result = NS_NewURL(&url, href); if (NS_OK == result) { - aPathname.SetString(url->GetFile()); + const char* file; + result = url->GetFile(&file); + if (result == NS_OK) + aPathname.SetString(file); NS_IF_RELEASE(url); } } @@ -353,10 +332,8 @@ LocationImpl::SetPathname(const nsString& aPathname) result = NS_NewURL(&url, href); if (NS_OK == result) { char *buf = aPathname.ToNewCString(); - - result = ConcatenateAndSet(url->GetProtocol(), url->GetHost(), - url->GetPort(), buf, - url->GetRef(), url->GetSearch()); + url->SetFile(buf); + SetURL(url); delete buf; NS_IF_RELEASE(url); } @@ -377,7 +354,8 @@ LocationImpl::GetPort(nsString& aPort) result = NS_NewURL(&url, href); if (NS_OK == result) { aPort.SetLength(0); - PRInt32 port = url->GetPort(); + PRUint32 port; + (void)url->GetHostPort(&port); if (-1 != port) { aPort.Append(port, 10); } @@ -410,10 +388,8 @@ LocationImpl::SetPort(const nsString& aPort) port = atol(buf); } } - - result = ConcatenateAndSet(url->GetProtocol(), url->GetHost(), - port, url->GetFile(), - url->GetRef(), url->GetSearch()); + url->SetHostPort(port); + SetURL(url); delete buf; NS_IF_RELEASE(url); } @@ -433,8 +409,12 @@ LocationImpl::GetProtocol(nsString& aProtocol) if (NS_OK == result) { result = NS_NewURL(&url, href); if (NS_OK == result) { - aProtocol.SetString(url->GetProtocol()); - aProtocol.Append(":"); + const char* protocol; + result = url->GetProtocol(&protocol); + if (result == NS_OK) { + aProtocol.SetString(protocol); + aProtocol.Append(":"); + } NS_IF_RELEASE(url); } } @@ -454,10 +434,8 @@ LocationImpl::SetProtocol(const nsString& aProtocol) result = NS_NewURL(&url, href); if (NS_OK == result) { char *buf = aProtocol.ToNewCString(); - - result = ConcatenateAndSet(buf, url->GetHost(), - url->GetPort(), url->GetFile(), - url->GetRef(), url->GetSearch()); + url->SetProtocol(buf); + SetURL(url); delete buf; NS_IF_RELEASE(url); } @@ -477,8 +455,9 @@ LocationImpl::GetSearch(nsString& aSearch) if (NS_OK == result) { result = NS_NewURL(&url, href); if (NS_OK == result) { - const char *search = url->GetSearch(); - if ((nsnull != search) && ('\0' != *search)) { + const char *search; + result = url->GetSearch(&search); + if (result == NS_OK && (nsnull != search) && ('\0' != *search)) { aSearch.SetString("?"); aSearch.Append(search); } @@ -504,11 +483,8 @@ LocationImpl::SetSearch(const nsString& aSearch) result = NS_NewURL(&url, href); if (NS_OK == result) { char *buf = aSearch.ToNewCString(); - - result = ConcatenateAndSet(url->GetProtocol(), url->GetHost(), - url->GetPort(), url->GetFile(), - url->GetRef(), buf); - + url->SetSearch(buf); + SetURL(url); delete buf; NS_IF_RELEASE(url); } diff --git a/mozilla/dom/src/jsurl/jsurl.cpp b/mozilla/dom/src/jsurl/jsurl.cpp index 6f0386ed971..6d155697fa3 100644 --- a/mozilla/dom/src/jsurl/jsurl.cpp +++ b/mozilla/dom/src/jsurl/jsurl.cpp @@ -145,7 +145,7 @@ evaluate_script(URL_Struct* urls, const char *what, JSConData *con_data) NS_RELEASE(con_info); if (nsnull != url) { - viewer = url->GetContainer(); + (void)url->GetContainer(&viewer); NS_RELEASE(url); } // Now see if the container supports nsIScriptContextOwner... diff --git a/mozilla/gfx/src/nsDeviceContext.cpp b/mozilla/gfx/src/nsDeviceContext.cpp index 0ac3a68212b..fad864db149 100644 --- a/mozilla/gfx/src/nsDeviceContext.cpp +++ b/mozilla/gfx/src/nsDeviceContext.cpp @@ -449,7 +449,7 @@ public: PRUint32 StringKey::HashValue(void) const { PRUint32 hash = 0; - PRUnichar* string = mString; + PRUnichar* string = mString; PRUnichar ch; while ((ch = *string++) != 0) { // FYI: hash = hash*37 + ch diff --git a/mozilla/gfx/src/nsImageNetContextAsync.cpp b/mozilla/gfx/src/nsImageNetContextAsync.cpp index b95bf031b24..028e2b7e6f6 100644 --- a/mozilla/gfx/src/nsImageNetContextAsync.cpp +++ b/mozilla/gfx/src/nsImageNetContextAsync.cpp @@ -32,7 +32,10 @@ #include "plstr.h" #include "il_strm.h" #include "merrors.h" +#include "nsINetService.h" +static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID); +static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID); static NS_DEFINE_IID(kIImageNetContextIID, IL_INETCONTEXT_IID); static NS_DEFINE_IID(kIURLIID, NS_IURL_IID); @@ -89,12 +92,12 @@ public: ImageConsumer(ilIURL *aURL, ImageNetContextImpl *aContext); - NS_IMETHOD GetBindInfo(nsIURL* aURL); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 Progress, PRUint32 ProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg); + NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUint32 length); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); void Interrupt(); @@ -131,19 +134,19 @@ NS_DEFINE_IID(kIStreamNotificationIID, NS_ISTREAMLISTENER_IID); NS_IMPL_ISUPPORTS(ImageConsumer,kIStreamNotificationIID); NS_IMETHODIMP -ImageConsumer::GetBindInfo(nsIURL* aURL) +ImageConsumer::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo) { return 0; } NS_IMETHODIMP -ImageConsumer::OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax) +ImageConsumer::OnProgress(nsIURL* aURL, PRUint32 Progress, PRUint32 ProgressMax) { return 0; } NS_IMETHODIMP -ImageConsumer::OnStatus(nsIURL* aURL, const nsString& aMsg) +ImageConsumer::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { return 0; } @@ -178,10 +181,10 @@ ImageConsumer::OnStartBinding(nsIURL* aURL, const char *aContentType) NS_IMETHODIMP -ImageConsumer::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length) +ImageConsumer::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUint32 length) { - PRInt32 max_read; - PRInt32 bytes_read = 0, str_length; + PRUint32 max_read; + PRUint32 bytes_read = 0, str_length; ilINetReader *reader = mURL->GetReader(); if (mInterrupted || mStatus != 0) { @@ -192,9 +195,9 @@ ImageConsumer::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 l } nsresult err = 0; - PRInt32 nb; + PRUint32 nb; do { - max_read = (PRInt32)reader->WriteReady(); + max_read = reader->WriteReady(); if (0 == max_read) { break; } @@ -227,7 +230,7 @@ ImageConsumer::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 l } } - reader->Write((const unsigned char *)mBuffer, nb); + reader->Write((const unsigned char *)mBuffer, (int32)nb); } while(nb != 0); if ((NS_OK != err) && (NS_BASE_STREAM_EOF != err)) { @@ -269,7 +272,7 @@ ImageConsumer::KeepPumpingStream(nsITimer *aTimer, void *aClosure) } NS_IMETHODIMP -ImageConsumer::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg) +ImageConsumer::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg) { if (mTimer != nsnull) { NS_RELEASE(mTimer); @@ -282,7 +285,7 @@ ImageConsumer::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg) // Since we're still holding on to the stream, there's still data // that needs to be read. So, pump the stream ourselves. if((mStream != nsnull) && (status == NS_BINDING_SUCCEEDED)) { - PRInt32 str_length; + PRUint32 str_length; nsresult err = mStream->GetLength(&str_length); if (err == NS_OK) { err = OnDataAvailable(aURL, mStream, str_length); @@ -484,7 +487,8 @@ ImageNetContextImpl::GetURL (ilIURL * aURL, mRequests->AppendElement((void *)ic); } else { - if (nsurl->Open(ic) == NS_OK) { + nsresult rv = NS_OpenURL(nsurl, ic); + if (rv == NS_OK) { mRequests->AppendElement((void *)ic); } else { diff --git a/mozilla/gfx/src/nsImageNetContextSync.cpp b/mozilla/gfx/src/nsImageNetContextSync.cpp index 04603b3f854..27c8cd018b4 100644 --- a/mozilla/gfx/src/nsImageNetContextSync.cpp +++ b/mozilla/gfx/src/nsImageNetContextSync.cpp @@ -185,7 +185,7 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL, // Read the URL data char buf[2048]; - PRInt32 count; + PRUint32 count; nsresult result; PRBool first = PR_TRUE; @@ -194,7 +194,7 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL, if (first == PR_TRUE) { PRInt32 ilErr; - ilErr = aReader->FirstWrite((const unsigned char *)buf, count); + ilErr = aReader->FirstWrite((const unsigned char *)buf, (int32)count); first = PR_FALSE; // If FirstWrite fails then the image type cannot be determined if (ilErr != 0) { @@ -203,7 +203,7 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL, } } - aReader->Write((const unsigned char *)buf, count); + aReader->Write((const unsigned char *)buf, (int32)count); // Get the next block result = stream->Read(buf, 0, sizeof(buf), &count); diff --git a/mozilla/gfx/src/nsImageURL.cpp b/mozilla/gfx/src/nsImageURL.cpp index e62b3cbd7ce..eacc2f42381 100644 --- a/mozilla/gfx/src/nsImageURL.cpp +++ b/mozilla/gfx/src/nsImageURL.cpp @@ -32,11 +32,13 @@ static NS_DEFINE_IID(kIImageURLIID, IL_IURL_IID); class ImageURLImpl : public ilIURL { public: - ImageURLImpl(const char *aURL, nsIURLGroup* aURLGroup); + ImageURLImpl(void); ~ImageURLImpl(); NS_DECL_ISUPPORTS + nsresult Init(const char *aURL, nsIURLGroup* aURLGroup); + virtual void SetReader(ilINetReader *aReader); virtual ilINetReader *GetReader(); @@ -58,15 +60,22 @@ private: ilINetReader *mReader; }; -ImageURLImpl::ImageURLImpl(const char *aURL, nsIURLGroup* aURLGroup) +ImageURLImpl::ImageURLImpl(void) + : mURL(nsnull), mReader(nsnull) { NS_INIT_REFCNT(); - if (nsnull != aURLGroup) { - aURLGroup->CreateURL(&mURL, nsnull, aURL, nsnull); - } else { - NS_NewURL(&mURL, nsnull, aURL); - } - mReader = nsnull; +} + +nsresult +ImageURLImpl::Init(const char *aURL, nsIURLGroup* aURLGroup) +{ + nsresult rv; + if (nsnull != aURLGroup) { + rv = aURLGroup->CreateURL(&mURL, nsnull, aURL, nsnull); + } else { + rv = NS_NewURL(&mURL, aURL); + } + return rv; } ImageURLImpl::~ImageURLImpl() @@ -143,7 +152,9 @@ const char* ImageURLImpl::GetAddress() { if (mURL != nsnull) { - return mURL->GetSpec(); + const char* spec; + mURL->GetSpec(&spec); + return spec; } else { return nsnull; @@ -162,8 +173,8 @@ ImageURLImpl::SetBackgroundLoad(PRBool aBgload) nsILoadAttribs* loadAttributes; if (nsnull != mURL) { - loadAttributes = mURL->GetLoadAttribs(); - if (nsnull != loadAttributes) { + nsresult rv = mURL->GetLoadAttribs(&loadAttributes); + if (rv == NS_OK && nsnull != loadAttributes) { if (aBgload) { loadAttributes->SetLoadType(nsURLLoadBackground); } else { @@ -194,10 +205,15 @@ NS_NewImageURL(ilIURL **aInstancePtrResult, const char *aURL, return NS_ERROR_NULL_POINTER; } - ilIURL *url = new ImageURLImpl(aURL, aURLGroup); + ImageURLImpl *url = new ImageURLImpl(); if (url == nsnull) { return NS_ERROR_OUT_OF_MEMORY; } + nsresult rv = url->Init(aURL, aURLGroup); + if (rv != NS_OK) { + delete url; + return rv; + } return url->QueryInterface(kIImageURLIID, (void **) aInstancePtrResult); } diff --git a/mozilla/htmlparser/robot/nsDebugRobot.cpp b/mozilla/htmlparser/robot/nsDebugRobot.cpp index c452bd8a0f0..3a9774555aa 100644 --- a/mozilla/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/htmlparser/robot/nsDebugRobot.cpp @@ -126,13 +126,13 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax) { return NS_OK; } - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg) { return NS_OK; } + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 Progress, PRUint32 ProgressMax) { return NS_OK; } + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { return NS_OK; } NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType) { return NS_OK; } - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); }; -NS_IMETHODIMP CStreamListener::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg) +NS_IMETHODIMP CStreamListener::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg) { fputs("done.\n",stdout); g_bReadyForNextUrl = PR_TRUE; @@ -242,16 +242,24 @@ extern "C" NS_EXPORT int DebugRobot( parser->Parse(url, pl,PR_TRUE);/* XXX hook up stream listener here! */ while (!g_bReadyForNextUrl) { - if (yieldProc != NULL) - (*yieldProc)(url->GetSpec()); + if (yieldProc != NULL) { + const char* spec; + (void)url->GetSpec(&spec); + (*yieldProc)(spec); + } } g_bReadyForNextUrl = PR_FALSE; if (ww) { ww->SetObserver(pl); - ww->LoadURL(nsString(url->GetSpec()));/* XXX hook up stream listener here! */ + const char* spec; + (void)url->GetSpec(&spec); + ww->LoadURL(nsString(spec));/* XXX hook up stream listener here! */ while (!g_bReadyForNextUrl) { - if (yieldProc != NULL) - (*yieldProc)(url->GetSpec()); + if (yieldProc != NULL) { + const char* spec; + (void)url->GetSpec(&spec); + (*yieldProc)(spec); + } } } diff --git a/mozilla/htmlparser/robot/nsRobotSink.cpp b/mozilla/htmlparser/robot/nsRobotSink.cpp index c6691e3b7f1..40ab8b295a4 100644 --- a/mozilla/htmlparser/robot/nsRobotSink.cpp +++ b/mozilla/htmlparser/robot/nsRobotSink.cpp @@ -316,11 +316,14 @@ void RobotSink::ProcessLink(const nsString& aLink) nsIURL* docURL = mDocumentURL; if (nsnull != docURL) { nsIURL* absurl; - nsresult rv = NS_NewURL(&absurl, docURL, aLink); + nsresult rv = NS_NewURL(&absurl, aLink, docURL); if (NS_OK == rv) { absURLSpec.Truncate(); - absurl->ToString(absURLSpec); + PRUnichar* str; + absurl->ToString(&str); + absURLSpec = str; NS_RELEASE(absurl); + delete str; } } diff --git a/mozilla/htmlparser/src/nsIParserFilter.h b/mozilla/htmlparser/src/nsIParserFilter.h index b6fc986ee77..fc42af97d06 100644 --- a/mozilla/htmlparser/src/nsIParserFilter.h +++ b/mozilla/htmlparser/src/nsIParserFilter.h @@ -41,7 +41,7 @@ class CToken; class nsIParserFilter : public nsISupports { public: - NS_IMETHOD RawBuffer(char * buffer, int * buffer_length) = 0; + NS_IMETHOD RawBuffer(char * buffer, PRUint32 * buffer_length) = 0; NS_IMETHOD WillAddToken(CToken & token) = 0; diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp index ae2f1a176c3..5c974b9973b 100644 --- a/mozilla/htmlparser/src/nsParser.cpp +++ b/mozilla/htmlparser/src/nsParser.cpp @@ -626,7 +626,10 @@ PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamObserver* aListener,PRBool aVerify mDTDVerification=aVerifyEnabled; if(aURL) { - nsAutoString theName(aURL->GetSpec()); + const char* spec; + nsresult rv = aURL->GetSpec(&spec); + if (rv != NS_OK) return rv; + nsAutoString theName(spec); CParserContext* cp=new CParserContext(new CScanner(theName,PR_FALSE),aURL,aListener); PushContext(*cp); status=NS_OK; @@ -841,7 +844,7 @@ CToken* nsParser::PushToken(CToken* theToken) { * @param * @return error code -- 0 if ok, non-zero if error. */ -nsresult nsParser::GetBindInfo(nsIURL* aURL){ +nsresult nsParser::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo){ nsresult result=0; return result; } @@ -854,7 +857,7 @@ nsresult nsParser::GetBindInfo(nsIURL* aURL){ * @return error code -- 0 if ok, non-zero if error. */ nsresult -nsParser::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) +nsParser::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult result=0; if (nsnull != mObserver) { @@ -871,7 +874,7 @@ nsParser::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) * @return error code -- 0 if ok, non-zero if error. */ nsresult -nsParser::OnStatus(nsIURL* aURL, const nsString &aMsg) +nsParser::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { nsresult result=0; if (nsnull != mObserver) { @@ -908,7 +911,7 @@ nsresult nsParser::OnStartBinding(nsIURL* aURL, const char *aSourceType){ * @param length is the number of bytes waiting input * @return error code (usually 0) */ -nsresult nsParser::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length){ +nsresult nsParser::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUint32 length){ /* if (nsnull != mListener) { //Rick potts removed this. //Does it need to be here? @@ -924,7 +927,7 @@ nsresult nsParser::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt } } - int len=1; //init to a non-zero value + PRUint32 len=1; //init to a non-zero value if(!mParserContext->mTransferBuffer) mParserContext->mTransferBuffer = new char[CParserContext::eTransferBufferSize+1]; @@ -979,7 +982,7 @@ nsresult nsParser::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt * @param * @return */ -nsresult nsParser::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg){ +nsresult nsParser::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg){ mStreamListenerState=eOnStop; mStreamStatus=status; nsresult result; diff --git a/mozilla/htmlparser/src/nsParser.h b/mozilla/htmlparser/src/nsParser.h index 06aa1af0d6e..7aa215aff6b 100644 --- a/mozilla/htmlparser/src/nsParser.h +++ b/mozilla/htmlparser/src/nsParser.h @@ -202,12 +202,12 @@ friend class CTokenHandler; // These methods are callback methods used by // net lib to let us know about our inputstream. //********************************************* - NS_IMETHOD GetBindInfo(nsIURL* aURL); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMmsg); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 Progress, PRUint32 ProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMmsg); NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg); + NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUint32 length); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); protected: diff --git a/mozilla/htmlparser/src/nsScanner.cpp b/mozilla/htmlparser/src/nsScanner.cpp index 7a8368375f6..5c1c6c8363c 100644 --- a/mozilla/htmlparser/src/nsScanner.cpp +++ b/mozilla/htmlparser/src/nsScanner.cpp @@ -130,7 +130,7 @@ CScanner::~CScanner() { * @param * @return */ -PRInt32 CScanner::RewindToMark(void){ +PRUint32 CScanner::RewindToMark(void){ mOffset=mMarkPos; return mOffset; } @@ -145,7 +145,7 @@ PRInt32 CScanner::RewindToMark(void){ * @param * @return */ -PRInt32 CScanner::Mark(void){ +PRUint32 CScanner::Mark(void){ if((mOffset>0) && (mOffset>eBufferSizeThreshold)) { mBuffer.Cut(0,mOffset); //delete chars up to mark position mOffset=0; @@ -175,7 +175,7 @@ PRBool CScanner::Append(nsString& aBuffer) { * @param * @return */ -PRBool CScanner::Append(const char* aBuffer, PRInt32 aLen){ +PRBool CScanner::Append(const char* aBuffer, PRUint32 aLen){ mBuffer.Append(aBuffer,aLen); mTotalRead+=aLen; return PR_TRUE; @@ -238,7 +238,7 @@ nsresult CScanner::FillBuffer(void) { nsresult CScanner::Eof() { nsresult theError=NS_OK; - if(mOffset>=mBuffer.Length()) { + if(mOffset>=(PRUint32)mBuffer.Length()) { theError=FillBuffer(); } @@ -261,11 +261,11 @@ nsresult CScanner::Eof() { nsresult CScanner::GetChar(PRUnichar& aChar) { nsresult result=NS_OK; - if(mOffset>=mBuffer.Length()) + if(mOffset>=(PRUint32)mBuffer.Length()) result=Eof(); if(NS_OK == result) { - aChar=mBuffer[mOffset++]; + aChar=mBuffer[(PRInt32)mOffset++]; } return result; } @@ -282,11 +282,11 @@ nsresult CScanner::GetChar(PRUnichar& aChar) { nsresult CScanner::Peek(PRUnichar& aChar) { nsresult result=NS_OK; - if(mOffset>=mBuffer.Length()) + if(mOffset>=(PRUint32)mBuffer.Length()) result=Eof(); if(NS_OK == result) { - aChar=mBuffer[mOffset]; + aChar=mBuffer[(PRInt32)mOffset]; } return result; } diff --git a/mozilla/htmlparser/src/nsScanner.h b/mozilla/htmlparser/src/nsScanner.h index 5950f5122a1..d9e577c05ee 100644 --- a/mozilla/htmlparser/src/nsScanner.h +++ b/mozilla/htmlparser/src/nsScanner.h @@ -199,7 +199,7 @@ class CScanner { * @param * @return */ - PRInt32 Mark(void); + PRUint32 Mark(void); /** * Resets current offset position of input stream to marked position. @@ -211,7 +211,7 @@ class CScanner { * @param * @return */ - PRInt32 RewindToMark(void); + PRUint32 RewindToMark(void); /** @@ -230,7 +230,7 @@ class CScanner { * @param * @return */ - PRBool Append(const char* aBuffer, PRInt32 aLen); + PRBool Append(const char* aBuffer, PRUint32 aLen); PRBool Append(const PRUnichar* aBuffer, PRInt32 aLen); @@ -270,9 +270,9 @@ class CScanner { fstream* mFileStream; nsString mBuffer; nsString mFilename; - PRInt32 mOffset; - PRInt32 mMarkPos; - PRInt32 mTotalRead; + PRUint32 mOffset; + PRUint32 mMarkPos; + PRUint32 mTotalRead; PRBool mOwnsStream; PRBool mIncremental; }; diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index df5c9ab21ca..1f283ec384b 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -472,8 +472,10 @@ nsPresContext::GetImageGroup(nsIImageGroup*& aGroupResult) // Initialize the image group - nsIURLGroup* urlGroup = mBaseURL->GetURLGroup(); - rv = mImageGroup->Init(mDeviceContext, urlGroup); + nsIURLGroup* urlGroup; + rv = mBaseURL->GetURLGroup(&urlGroup); + if (rv == NS_OK) + rv = mImageGroup->Init(mDeviceContext, urlGroup); NS_IF_RELEASE(urlGroup); if (NS_OK != rv) { return rv; diff --git a/mozilla/layout/base/src/nsDocument.cpp b/mozilla/layout/base/src/nsDocument.cpp index 5034366c42d..2426cf56b60 100644 --- a/mozilla/layout/base/src/nsDocument.cpp +++ b/mozilla/layout/base/src/nsDocument.cpp @@ -568,9 +568,7 @@ nsDocument::StartDocumentLoad(nsIURL *aURL, mDocumentURL = aURL; NS_ADDREF(aURL); - mDocumentURLGroup = aURL->GetURLGroup(); - - return NS_OK; + return aURL->GetURLGroup(&mDocumentURLGroup); } const nsString* nsDocument::GetDocumentTitle() const diff --git a/mozilla/layout/base/src/nsFrameUtil.cpp b/mozilla/layout/base/src/nsFrameUtil.cpp index b617f0a1b36..8323bfbe2c7 100644 --- a/mozilla/layout/base/src/nsFrameUtil.cpp +++ b/mozilla/layout/base/src/nsFrameUtil.cpp @@ -471,14 +471,14 @@ nsFrameUtil::LoadFrameRegressionData(nsIURL* aURL, nsIXMLContent** aResult) // XXX since the parser can't sync load data, we do it right here nsAutoString theWholeDarnThing; - PRInt32 ec; - nsIInputStream* iin = aURL->Open(&ec); - if (nsnull == iin) { - return (nsresult) ec;/* XXX fix url->Open */ + nsIInputStream* iin; + rv = NS_OpenURL(aURL, &iin); + if (NS_OK != rv) { + return rv; } for (;;) { char buf[4000]; - PRInt32 rc; + PRUint32 rc; rv = iin->Read(buf, 0, sizeof(buf), &rc); if (NS_FAILED(rv) || (rc <= 0)) { break; diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index df5c9ab21ca..1f283ec384b 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -472,8 +472,10 @@ nsPresContext::GetImageGroup(nsIImageGroup*& aGroupResult) // Initialize the image group - nsIURLGroup* urlGroup = mBaseURL->GetURLGroup(); - rv = mImageGroup->Init(mDeviceContext, urlGroup); + nsIURLGroup* urlGroup; + rv = mBaseURL->GetURLGroup(&urlGroup); + if (rv == NS_OK) + rv = mImageGroup->Init(mDeviceContext, urlGroup); NS_IF_RELEASE(urlGroup); if (NS_OK != rv) { return rv; diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 51c5d2880fa..c7df54a4f23 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -368,8 +368,10 @@ nsTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext, if (nsnull != doc) { docURL = doc->GetDocumentURL(); NS_RELEASE(doc); - URLName = (char*)PR_Malloc(PL_strlen(docURL->GetSpec())+1); - PL_strcpy(URLName, docURL->GetSpec()); + const char* spec; + (void)docURL->GetSpec(&spec); + URLName = (char*)PR_Malloc(PL_strlen(spec)+1); + PL_strcpy(URLName, spec); NS_RELEASE(docURL); } diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 98e4a529305..c9ac4754a71 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -67,9 +67,9 @@ public: // nsIStreamObserver NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); protected: @@ -878,7 +878,7 @@ TempObserver::QueryInterface(const nsIID& aIID, NS_IMETHODIMP -TempObserver::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) +TempObserver::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { #if 0 fputs("[progress ", stdout); @@ -890,7 +890,7 @@ TempObserver::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) } NS_IMETHODIMP -TempObserver::OnStatus(nsIURL* aURL, const nsString& aMsg) +TempObserver::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { #if 0 fputs("[status ", stdout); @@ -913,7 +913,7 @@ TempObserver::OnStartBinding(nsIURL* aURL, const char *aContentType) } NS_IMETHODIMP -TempObserver::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg) +TempObserver::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg) { #if 0 fputs("Done loading ", stdout); diff --git a/mozilla/layout/generic/nsFrameUtil.cpp b/mozilla/layout/generic/nsFrameUtil.cpp index b617f0a1b36..8323bfbe2c7 100644 --- a/mozilla/layout/generic/nsFrameUtil.cpp +++ b/mozilla/layout/generic/nsFrameUtil.cpp @@ -471,14 +471,14 @@ nsFrameUtil::LoadFrameRegressionData(nsIURL* aURL, nsIXMLContent** aResult) // XXX since the parser can't sync load data, we do it right here nsAutoString theWholeDarnThing; - PRInt32 ec; - nsIInputStream* iin = aURL->Open(&ec); - if (nsnull == iin) { - return (nsresult) ec;/* XXX fix url->Open */ + nsIInputStream* iin; + rv = NS_OpenURL(aURL, &iin); + if (NS_OK != rv) { + return rv; } for (;;) { char buf[4000]; - PRInt32 rc; + PRUint32 rc; rv = iin->Read(buf, 0, sizeof(buf), &rc); if (NS_FAILED(rv) || (rc <= 0)) { break; diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 5aa5e11861e..e538bda2269 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -1270,13 +1270,13 @@ NS_IMETHODIMP nsPluginInstanceOwner :: GetDocumentBase(const char* *result) nsIDocument *doc = shell->GetDocument(); nsIURL *docURL = doc->GetDocumentURL(); - *result = docURL->GetSpec(); + nsresult rv = docURL->GetSpec(result); NS_RELEASE(shell); NS_RELEASE(docURL); NS_RELEASE(doc); - return NS_OK; + return rv; } else { diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 5aa5e11861e..e538bda2269 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -1270,13 +1270,13 @@ NS_IMETHODIMP nsPluginInstanceOwner :: GetDocumentBase(const char* *result) nsIDocument *doc = shell->GetDocument(); nsIURL *docURL = doc->GetDocumentURL(); - *result = docURL->GetSpec(); + nsresult rv = docURL->GetSpec(result); NS_RELEASE(shell); NS_RELEASE(docURL); NS_RELEASE(doc); - return NS_OK; + return rv; } else { diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 98e4a529305..c9ac4754a71 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -67,9 +67,9 @@ public: // nsIStreamObserver NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); protected: @@ -878,7 +878,7 @@ TempObserver::QueryInterface(const nsIID& aIID, NS_IMETHODIMP -TempObserver::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) +TempObserver::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { #if 0 fputs("[progress ", stdout); @@ -890,7 +890,7 @@ TempObserver::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) } NS_IMETHODIMP -TempObserver::OnStatus(nsIURL* aURL, const nsString& aMsg) +TempObserver::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { #if 0 fputs("[status ", stdout); @@ -913,7 +913,7 @@ TempObserver::OnStartBinding(nsIURL* aURL, const char *aContentType) } NS_IMETHODIMP -TempObserver::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg) +TempObserver::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg) { #if 0 fputs("Done loading ", stdout); diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index 1a67f949c79..0ae9fc60a1d 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -71,7 +71,7 @@ static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID static NS_DEFINE_IID(kIDOMHTMLOptionElementIID, NS_IDOMHTMLOPTIONELEMENT_IID); static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID); static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTML_CONTENT_SINK_IID); -static NS_DEFINE_IID(kIHTTPUrlIID, NS_IHTTPURL_IID); +static NS_DEFINE_IID(kIHTTPURLIID, NS_IHTTPURL_IID); static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID); static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID); static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID); @@ -301,12 +301,12 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg); - NS_IMETHOD GetBindInfo(nsIURL* aURL); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo); NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, - PRInt32 aLength); + PRUint32 aLength); protected: nsIURL* mURL; @@ -1381,9 +1381,11 @@ HTMLContentSink::Init(nsIDocument* aDoc, mCurrentContext->Begin(eHTMLTag_html, mRoot); mContextStack.AppendElement(mCurrentContext); + const char* spec; + (void)aURL->GetSpec(&spec); SINK_TRACE(SINK_TRACE_CALLS, ("HTMLContentSink::Init: this=%p url='%s'", - this, aURL->GetSpec())); + this, spec)); return NS_OK; } @@ -1906,8 +1908,9 @@ HTMLContentSink::StartLayout() // If the document we are loading has a reference or it is a top level // frameset document, disable the scroll bars on the views. - const char* ref = mDocumentURL->GetRef(); - if (nsnull != ref) { + const char* ref; + nsresult rv = mDocumentURL->GetRef(&ref); + if (rv == NS_OK) { mRef = new nsString(ref); } PRBool topLevelFrameset = PR_FALSE; @@ -2200,7 +2203,8 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode) if ((0 == type.Length()) || type.EqualsIgnoreCase("text/css")) { nsIURL* url = nsnull; nsAutoString absURL; - nsIURLGroup* urlGroup = mDocumentURL->GetURLGroup(); + nsIURLGroup* urlGroup; + (void)mDocumentURL->GetURLGroup(&urlGroup); result = NS_MakeAbsoluteURL(mDocumentURL, mBaseHREF, href, absURL); if (NS_OK != result) { return result; @@ -2210,7 +2214,7 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode) NS_RELEASE(urlGroup); } else { - result = NS_NewURL(&url, nsnull, absURL); + result = NS_NewURL(&url, absURL); } if (NS_OK != result) { return result; @@ -2269,8 +2273,8 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode) mHead->AppendChildTo(it, PR_FALSE); // If we are processing an HTTP url, handle meta http-equiv cases - nsIHttpUrl* httpUrl = nsnull; - rv = mDocumentURL->QueryInterface(kIHTTPUrlIID, (void **)&httpUrl); + nsIHttpURL* httpUrl = nsnull; + rv = mDocumentURL->QueryInterface(kIHTTPURLIID, (void **)&httpUrl); if (NS_OK == rv) { nsAutoString header; it->GetAttribute(nsHTMLAtoms::httpEquiv, header); @@ -2363,7 +2367,7 @@ HTMLContentSink::EvaluateScript(nsString& aScript, nsIURL* docURL = mDocument->GetDocumentURL(); const char* url; if (docURL) { - url = docURL->GetSpec(); + (void)docURL->GetSpec(&url); } PRBool isUndefined; @@ -2443,7 +2447,8 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) // Use the SRC attribute value to open an accumulating stream nsIURL* url = nsnull; nsAutoString absURL; - nsIURLGroup* urlGroup = mDocumentURL->GetURLGroup(); + nsIURLGroup* urlGroup; + (void)mDocumentURL->GetURLGroup(&urlGroup); rv = NS_MakeAbsoluteURL(mDocumentURL, mBaseHREF, src, absURL); if (NS_OK != rv) { return rv; @@ -2453,7 +2458,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) NS_RELEASE(urlGroup); } else { - rv = NS_NewURL(&url, nsnull, absURL); + rv = NS_NewURL(&url, absURL); } if (NS_OK != rv) { return rv; @@ -2576,7 +2581,8 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) // XXX what does nav do? // Use the SRC attribute value to open an accumulating stream nsAutoString absURL; - nsIURLGroup* urlGroup = mDocumentURL->GetURLGroup(); + nsIURLGroup* urlGroup; + (void)mDocumentURL->GetURLGroup(&urlGroup); rv = NS_MakeAbsoluteURL(mDocumentURL, mBaseHREF, src, absURL); if (NS_OK != rv) { return rv; @@ -2586,7 +2592,7 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) NS_RELEASE(urlGroup); } else { - rv = NS_NewURL(&url, nsnull, absURL); + rv = NS_NewURL(&url, absURL); } if (NS_OK != rv) { return rv; @@ -2755,7 +2761,7 @@ nsAccumulatingURLLoader::nsAccumulatingURLLoader(nsIURL* aURL, nsresult rv; if (aURL) { - rv = aURL->Open(this); + rv = NS_OpenURL(aURL, this); if ((NS_OK != rv) && (nsnull != mFunc)) { (*mFunc)(this, *mData, mRef, rv); } @@ -2782,22 +2788,22 @@ nsAccumulatingURLLoader::OnStartBinding(nsIURL* aURL, NS_IMETHODIMP nsAccumulatingURLLoader::OnProgress(nsIURL* aURL, - PRInt32 aProgress, - PRInt32 aProgressMax) + PRUint32 aProgress, + PRUint32 aProgressMax) { return NS_OK; } NS_IMETHODIMP -nsAccumulatingURLLoader::OnStatus(nsIURL* aURL, const nsString &aMsg) +nsAccumulatingURLLoader::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { return NS_OK; } NS_IMETHODIMP nsAccumulatingURLLoader::OnStopBinding(nsIURL* aURL, - PRInt32 aStatus, - const nsString &aMsg) + nsresult aStatus, + const PRUnichar* aMsg) { (*mFunc)(this, *mData, mRef, aStatus); @@ -2805,7 +2811,7 @@ nsAccumulatingURLLoader::OnStopBinding(nsIURL* aURL, } NS_IMETHODIMP -nsAccumulatingURLLoader::GetBindInfo(nsIURL* aURL) +nsAccumulatingURLLoader::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo) { return NS_OK; } @@ -2815,11 +2821,11 @@ nsAccumulatingURLLoader::GetBindInfo(nsIURL* aURL) NS_IMETHODIMP nsAccumulatingURLLoader::OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, - PRInt32 aLength) + PRUint32 aLength) { nsresult rv = NS_OK; char buffer[BUF_SIZE]; - PRInt32 len, lenRead; + PRUint32 len, lenRead; aIStream->GetLength(&len); diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp index 45501fa24e9..19e40820032 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp @@ -227,10 +227,11 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL, static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - rv = nsRepository::CreateInstance(kCParserCID, - nsnull, - kCParserIID, - (void **)&mParser); + if (rv == NS_OK) + rv = nsRepository::CreateInstance(kCParserCID, + nsnull, + kCParserIID, + (void **)&mParser); if (NS_OK == rv) { nsIHTMLContentSink* sink; @@ -615,7 +616,8 @@ nsHTMLDocument::GetDomain(nsString& aDomain) // PCB: This is the domain name of the server that produced this document. Can we just // extract it from the URL? What about proxy servers, etc.? if (nsnull != mDocumentURL) { - const char* hostName = mDocumentURL->GetHost(); + const char* hostName; + nsresult rslt = mDocumentURL->GetHost(&hostName); aDomain.SetString(hostName); } else { aDomain.SetLength(0); @@ -627,7 +629,10 @@ NS_IMETHODIMP nsHTMLDocument::GetURL(nsString& aURL) { if (nsnull != mDocumentURL) { - mDocumentURL->ToString(aURL); + PRUnichar* str; + mDocumentURL->ToString(&str); + aURL = str; + delete str; } return NS_OK; } diff --git a/mozilla/layout/html/document/src/nsImageDocument.cpp b/mozilla/layout/html/document/src/nsImageDocument.cpp index 4dbafa00fca..467db7dd70f 100644 --- a/mozilla/layout/html/document/src/nsImageDocument.cpp +++ b/mozilla/layout/html/document/src/nsImageDocument.cpp @@ -77,13 +77,13 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, - const nsString& aMsg); - NS_IMETHOD GetBindInfo(nsIURL* aURL); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, + const PRUnichar* aMsg); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo); NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream* aStream, - PRInt32 aCount); + PRUint32 aCount); nsImageDocument* mDocument; nsIStreamListener* mNextStream; @@ -115,8 +115,8 @@ ImageListener::OnStartBinding(nsIURL* aURL, const char *aContentType) } NS_IMETHODIMP -ImageListener::OnProgress(nsIURL* aURL, PRInt32 aProgress, - PRInt32 aProgressMax) +ImageListener::OnProgress(nsIURL* aURL, PRUint32 aProgress, + PRUint32 aProgressMax) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; @@ -125,7 +125,7 @@ ImageListener::OnProgress(nsIURL* aURL, PRInt32 aProgress, } NS_IMETHODIMP -ImageListener::OnStatus(nsIURL* aURL, const nsString &aMsg) +ImageListener::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; @@ -134,8 +134,8 @@ ImageListener::OnStatus(nsIURL* aURL, const nsString &aMsg) } NS_IMETHODIMP -ImageListener::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, - const nsString& aMsg) +ImageListener::OnStopBinding(nsIURL* aURL, nsresult aStatus, + const PRUnichar* aMsg) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; @@ -144,17 +144,17 @@ ImageListener::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, } NS_IMETHODIMP -ImageListener::GetBindInfo(nsIURL* aURL) +ImageListener::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->GetBindInfo(aURL); + return mNextStream->GetBindInfo(aURL, aInfo); } NS_IMETHODIMP ImageListener::OnDataAvailable(nsIURL* aURL, nsIInputStream* aStream, - PRInt32 aCount) + PRUint32 aCount) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; @@ -246,7 +246,7 @@ nsImageDocument::StartImageLoad(nsIURL* aURL, nsIStreamListener*& aListener) cx->GetImageGroup(group); if (nsnull != group) { const char* spec; - spec = aURL->GetSpec(); + (void)aURL->GetSpec(&spec); nscolor black = NS_RGB(0, 0, 0); nsIStreamListener* listener = nsnull; rv = group->GetImageFromStream(spec, nsnull, &mBlack, @@ -309,9 +309,10 @@ nsImageDocument::CreateSyntheticDocument() } image->SetDocument(this, PR_FALSE); - nsAutoString src; - mDocumentURL->ToString(src); + PRUnichar* src; + mDocumentURL->ToString(&src); nsHTMLValue val(src); + delete src; image->SetAttribute(nsHTMLAtoms::src, val, PR_FALSE); image->SetAttribute(nsHTMLAtoms::alt, val, PR_FALSE); diff --git a/mozilla/layout/html/forms/src/nsFormFrame.cpp b/mozilla/layout/html/forms/src/nsFormFrame.cpp index 1594b0f7325..501078b3e24 100644 --- a/mozilla/layout/html/forms/src/nsFormFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormFrame.cpp @@ -609,8 +609,10 @@ void nsFormFrame::ProcessAsURLEncoded(PRBool isPost, nsString& aData, nsIFormCon if (nsnull != doc) { docURL = doc->GetDocumentURL(); NS_RELEASE(doc); - URLName = (char*)PR_Malloc(PL_strlen(docURL->GetSpec())+1); - PL_strcpy(URLName, docURL->GetSpec()); + const char* spec; + (void)docURL->GetSpec(&spec); + URLName = (char*)PR_Malloc(PL_strlen(spec)+1); + PL_strcpy(URLName, spec); } #endif diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index 51c5d2880fa..c7df54a4f23 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -368,8 +368,10 @@ nsTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext, if (nsnull != doc) { docURL = doc->GetDocumentURL(); NS_RELEASE(doc); - URLName = (char*)PR_Malloc(PL_strlen(docURL->GetSpec())+1); - PL_strcpy(URLName, docURL->GetSpec()); + const char* spec; + (void)docURL->GetSpec(&spec); + URLName = (char*)PR_Malloc(PL_strlen(spec)+1); + PL_strcpy(URLName, spec); NS_RELEASE(docURL); } diff --git a/mozilla/layout/html/style/src/nsCSSParser.cpp b/mozilla/layout/html/style/src/nsCSSParser.cpp index 2237f531f94..94da05588b5 100644 --- a/mozilla/layout/html/style/src/nsCSSParser.cpp +++ b/mozilla/layout/html/style/src/nsCSSParser.cpp @@ -720,7 +720,7 @@ PRBool CSSParserImpl::ProcessImport(PRInt32& aErrorCode, const nsString& aURLSpe // the url that follows a "?" char* cp = aURLSpec.ToNewCString(); nsIURL* url; - aErrorCode = NS_NewURL(&url, mURL, cp); + aErrorCode = NS_NewURL(&url, cp, mURL); delete [] cp; if (NS_FAILED(aErrorCode)) { // import url is bad @@ -730,9 +730,9 @@ PRBool CSSParserImpl::ProcessImport(PRInt32& aErrorCode, const nsString& aURLSpe if (PR_FALSE == mSheet->ContainsStyleSheet(url)) { // don't allow circular references - PRInt32 ec; - nsIInputStream* in = url->Open(&ec); - if (nsnull == in) { + nsIInputStream* in; + nsresult rv = NS_OpenURL(url, &in); + if (rv != NS_OK) { // failure to make connection // XXX log this somewhere for easier web page debugging } diff --git a/mozilla/layout/html/style/src/nsCSSScanner.cpp b/mozilla/layout/html/style/src/nsCSSScanner.cpp index 51fc7a7c412..a055aa5c73e 100644 --- a/mozilla/layout/html/style/src/nsCSSScanner.cpp +++ b/mozilla/layout/html/style/src/nsCSSScanner.cpp @@ -129,7 +129,7 @@ PRInt32 nsCSSScanner::Read(PRInt32& aErrorCode) } if (mOffset == mCount) { mOffset = 0; - aErrorCode = mInput->Read(mBuffer, 0, BUFFER_SIZE, &mCount); + aErrorCode = mInput->Read(mBuffer, 0, BUFFER_SIZE, (PRUint32*)&mCount); if (NS_FAILED(aErrorCode)) { mCount = 0; return -1; diff --git a/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp b/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp index d3dbd968918..69896d1a2c7 100644 --- a/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp @@ -1547,16 +1547,17 @@ nsresult CSSStyleSheetImpl::GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& a void CSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { - nsAutoString buffer; + PRUnichar* buffer; PRInt32 index; // Indent for (index = aIndent; --index >= 0; ) fputs(" ", out); fputs("CSS Style Sheet: ", out); - mURL->ToString(buffer); + mURL->ToString(&buffer); fputs(buffer, out); fputs("\n", out); + delete buffer; const nsICSSStyleSheet* child = mFirstChild; while (nsnull != child) { @@ -1659,7 +1660,10 @@ NS_IMETHODIMP CSSStyleSheetImpl::GetHref(nsString& aHref) { if (mURL.IsNotNull()) { - mURL->ToString(aHref); + PRUnichar* str; + mURL->ToString(&str); + aHref = str; + delete str; } else { aHref.SetLength(0); diff --git a/mozilla/layout/html/style/src/nsHTMLCSSStyleSheet.cpp b/mozilla/layout/html/style/src/nsHTMLCSSStyleSheet.cpp index 0b0481c7a8f..489cafacb9a 100644 --- a/mozilla/layout/html/style/src/nsHTMLCSSStyleSheet.cpp +++ b/mozilla/layout/html/style/src/nsHTMLCSSStyleSheet.cpp @@ -315,16 +315,16 @@ HTMLCSSStyleSheetImpl::SetOwningDocument(nsIDocument* aDocument) void HTMLCSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { - nsAutoString buffer; + PRUnichar* buffer; // Indent for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); fputs("HTML CSS Style Sheet: ", out); - mURL->ToString(buffer); + mURL->ToString(&buffer); fputs(buffer, out); fputs("\n", out); - + delete buffer; } diff --git a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp index 3a9882133f5..654d46ae470 100644 --- a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp @@ -2687,16 +2687,16 @@ HTMLStyleSheetImpl::StyleRuleRemoved(nsIPresContext* aPresContext, void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { - nsAutoString buffer; + PRUnichar* buffer; // Indent for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); fputs("HTML Style Sheet: ", out); - mURL->ToString(buffer); + mURL->ToString(&buffer); fputs(buffer, out); fputs("\n", out); - + delete buffer; } // XXX For convenience and backwards compatibility diff --git a/mozilla/layout/html/tests/TestAttributes.cpp b/mozilla/layout/html/tests/TestAttributes.cpp index 9273e9edb83..258ac161076 100644 --- a/mozilla/layout/html/tests/TestAttributes.cpp +++ b/mozilla/layout/html/tests/TestAttributes.cpp @@ -204,11 +204,11 @@ int main(int argc, char** argv) // Create a unicode string static const char* srcStr = "This is some meaningless text about nothing at all"; PRInt32 rv2; - PRInt32 origSrcLen = nsCRT::strlen((char *)srcStr); + PRUint32 origSrcLen = nsCRT::strlen((char *)srcStr); const int BUFFER_LENGTH = 100; PRUnichar destStr[BUFFER_LENGTH]; - PRInt32 srcLen = origSrcLen; - PRInt32 destLen = BUFFER_LENGTH; + PRUint32 srcLen = origSrcLen; + PRUint32 destLen = BUFFER_LENGTH; rv2 = converter->Convert(destStr,0,destLen,srcStr,0,srcLen); if ((NS_OK != rv2) || (srcLen < origSrcLen)) { printf("Failed to convert all characters to unicode.\n"); diff --git a/mozilla/layout/html/tests/TestCSSParser.cpp b/mozilla/layout/html/tests/TestCSSParser.cpp index 2deda7b1180..7af78ed1a41 100644 --- a/mozilla/layout/html/tests/TestCSSParser.cpp +++ b/mozilla/layout/html/tests/TestCSSParser.cpp @@ -105,17 +105,17 @@ int main(int argc, char** argv) char* urlName = argv[i]; // Create url object nsIURL* url; - rv = NS_NewURL(&url, nsnull, urlName); + rv = NS_NewURL(&url, urlName); if (NS_OK != rv) { printf("invalid URL: '%s'\n", urlName); return -1; } // Get an input stream from the url - PRInt32 ec; - nsIInputStream* in = url->Open(&ec); - if (nsnull == in) { - printf("open of url('%s') failed: error=%x\n", urlName, ec); + nsIInputStream* in; + rv = NS_OpenURL(url, &in); + if (rv != NS_OK) { + printf("open of url('%s') failed: error=%x\n", urlName, rv); continue; } diff --git a/mozilla/layout/html/tests/TestCSSScanner.cpp b/mozilla/layout/html/tests/TestCSSScanner.cpp index 80e47a7b87f..a790a999550 100644 --- a/mozilla/layout/html/tests/TestCSSScanner.cpp +++ b/mozilla/layout/html/tests/TestCSSScanner.cpp @@ -32,17 +32,17 @@ int main(int argc, char** argv) // Create url object char* urlName = argv[1]; nsIURL* url; - nsresult rv = NS_NewURL(&url, nsnull, urlName); + nsresult rv = NS_NewURL(&url, urlName); if (NS_OK != rv) { printf("invalid URL: '%s'\n", urlName); return -1; } // Get an input stream from the url - PRInt32 ec; - nsIInputStream* in = url->Open(&ec); - if (nsnull == in) { - printf("open of url('%s') failed: error=%x\n", urlName, ec); + nsIInputStream* in; + rv = NS_OpenURL(url, &in); + if (rv != NS_OK) { + printf("open of url('%s') failed: error=%x\n", urlName, rv); return -1; } @@ -60,6 +60,7 @@ int main(int argc, char** argv) // Scan the file and dump out the tokens nsCSSToken tok; + PRInt32 ec; for (;;) { char buf[20]; if (!css->Next(ec, tok)) { diff --git a/mozilla/layout/style/nsCSSParser.cpp b/mozilla/layout/style/nsCSSParser.cpp index 2237f531f94..94da05588b5 100644 --- a/mozilla/layout/style/nsCSSParser.cpp +++ b/mozilla/layout/style/nsCSSParser.cpp @@ -720,7 +720,7 @@ PRBool CSSParserImpl::ProcessImport(PRInt32& aErrorCode, const nsString& aURLSpe // the url that follows a "?" char* cp = aURLSpec.ToNewCString(); nsIURL* url; - aErrorCode = NS_NewURL(&url, mURL, cp); + aErrorCode = NS_NewURL(&url, cp, mURL); delete [] cp; if (NS_FAILED(aErrorCode)) { // import url is bad @@ -730,9 +730,9 @@ PRBool CSSParserImpl::ProcessImport(PRInt32& aErrorCode, const nsString& aURLSpe if (PR_FALSE == mSheet->ContainsStyleSheet(url)) { // don't allow circular references - PRInt32 ec; - nsIInputStream* in = url->Open(&ec); - if (nsnull == in) { + nsIInputStream* in; + nsresult rv = NS_OpenURL(url, &in); + if (rv != NS_OK) { // failure to make connection // XXX log this somewhere for easier web page debugging } diff --git a/mozilla/layout/style/nsCSSScanner.cpp b/mozilla/layout/style/nsCSSScanner.cpp index 51fc7a7c412..a055aa5c73e 100644 --- a/mozilla/layout/style/nsCSSScanner.cpp +++ b/mozilla/layout/style/nsCSSScanner.cpp @@ -129,7 +129,7 @@ PRInt32 nsCSSScanner::Read(PRInt32& aErrorCode) } if (mOffset == mCount) { mOffset = 0; - aErrorCode = mInput->Read(mBuffer, 0, BUFFER_SIZE, &mCount); + aErrorCode = mInput->Read(mBuffer, 0, BUFFER_SIZE, (PRUint32*)&mCount); if (NS_FAILED(aErrorCode)) { mCount = 0; return -1; diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp index d3dbd968918..69896d1a2c7 100644 --- a/mozilla/layout/style/nsCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsCSSStyleSheet.cpp @@ -1547,16 +1547,17 @@ nsresult CSSStyleSheetImpl::GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& a void CSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { - nsAutoString buffer; + PRUnichar* buffer; PRInt32 index; // Indent for (index = aIndent; --index >= 0; ) fputs(" ", out); fputs("CSS Style Sheet: ", out); - mURL->ToString(buffer); + mURL->ToString(&buffer); fputs(buffer, out); fputs("\n", out); + delete buffer; const nsICSSStyleSheet* child = mFirstChild; while (nsnull != child) { @@ -1659,7 +1660,10 @@ NS_IMETHODIMP CSSStyleSheetImpl::GetHref(nsString& aHref) { if (mURL.IsNotNull()) { - mURL->ToString(aHref); + PRUnichar* str; + mURL->ToString(&str); + aHref = str; + delete str; } else { aHref.SetLength(0); diff --git a/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp b/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp index 0b0481c7a8f..489cafacb9a 100644 --- a/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLCSSStyleSheet.cpp @@ -315,16 +315,16 @@ HTMLCSSStyleSheetImpl::SetOwningDocument(nsIDocument* aDocument) void HTMLCSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { - nsAutoString buffer; + PRUnichar* buffer; // Indent for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); fputs("HTML CSS Style Sheet: ", out); - mURL->ToString(buffer); + mURL->ToString(&buffer); fputs(buffer, out); fputs("\n", out); - + delete buffer; } diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index 3a9882133f5..654d46ae470 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -2687,16 +2687,16 @@ HTMLStyleSheetImpl::StyleRuleRemoved(nsIPresContext* aPresContext, void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { - nsAutoString buffer; + PRUnichar* buffer; // Indent for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); fputs("HTML Style Sheet: ", out); - mURL->ToString(buffer); + mURL->ToString(&buffer); fputs(buffer, out); fputs("\n", out); - + delete buffer; } // XXX For convenience and backwards compatibility diff --git a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp index 88312ee65f9..cc8cbb58b4d 100644 --- a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp @@ -834,15 +834,15 @@ nsXMLContentSink::AddProcessingInstruction(const nsIParserNode& aNode) return result; } NS_RELEASE(docURL); - result = NS_NewURL(&url, nsnull, absURL); + result = NS_NewURL(&url, absURL); if (NS_OK != result) { return result; } - PRInt32 ec; - nsIInputStream* iin = url->Open(&ec); - if (nsnull == iin) { + nsIInputStream* iin; + result = NS_OpenURL(url, &iin); + if (NS_OK != result) { NS_RELEASE(url); - return (nsresult) ec;/* XXX fix url->Open */ + return result; } result = NS_NewConverterStream(&uin, nsnull, iin); NS_RELEASE(iin); @@ -1066,7 +1066,8 @@ nsXMLContentSink::StartLayout() // If the document we are loading has a reference or it is a top level // frameset document, disable the scroll bars on the views. - const char* ref = mDocumentURL->GetRef(); + const char* ref; + (void)mDocumentURL->GetRef(&ref); PRBool topLevelFrameset = PR_FALSE; if (mWebShell) { nsIWebShell* rootWebShell; @@ -1129,7 +1130,7 @@ nsXMLContentSink::EvaluateScript(nsString& aScript, PRUint32 aLineNo) nsIURL* mDocURL = mDocument->GetDocumentURL(); const char* mURL; if (mDocURL) { - mURL = mDocURL->GetSpec(); + (void)mDocURL->GetSpec(&mURL); } nsAutoString val; @@ -1240,19 +1241,19 @@ nsXMLContentSink::ProcessStartSCRIPTTag(const nsIParserNode& aNode) return rv; } NS_RELEASE(docURL); - rv = NS_NewURL(&url, nsnull, absURL); + rv = NS_NewURL(&url, absURL); if (NS_OK != rv) { return rv; } - PRInt32 ec; - nsIInputStream* iin = url->Open(&ec); - if (nsnull == iin) { + nsIInputStream* iin; + rv = NS_OpenURL(url, &iin); + if (NS_OK != rv) { NS_RELEASE(url); - return (nsresult) ec;/* XXX fix url->Open */ + return rv; } // Drain the stream by reading from it a chunk at a time - PRInt32 nb; + PRUint32 nb; nsresult err; do { char buf[SCRIPT_BUF_SIZE]; diff --git a/mozilla/modules/plugin/base/src/ns4xPlugin.cpp b/mozilla/modules/plugin/base/src/ns4xPlugin.cpp index 142eb606ca4..12a5bcf58fb 100644 --- a/mozilla/modules/plugin/base/src/ns4xPlugin.cpp +++ b/mozilla/modules/plugin/base/src/ns4xPlugin.cpp @@ -481,12 +481,12 @@ ns4xPlugin::_write(NPP npp, NPStream *pstream, int32 len, void *buffer) nsIOutputStream* stream = wrapper->GetStream(); - PRInt32 count = 0; + PRUint32 count = 0; nsresult rv = stream->Write((char *)buffer, 0, len, &count); NS_RELEASE(stream); - return count; + return (int32)count; } nsresult NP_EXPORT diff --git a/mozilla/modules/plugin/base/src/ns4xPluginStream.cpp b/mozilla/modules/plugin/base/src/ns4xPluginStream.cpp index edeb366d756..9820237499d 100644 --- a/mozilla/modules/plugin/base/src/ns4xPluginStream.cpp +++ b/mozilla/modules/plugin/base/src/ns4xPluginStream.cpp @@ -156,11 +156,11 @@ NS_IMETHODIMP ns4xPluginStream::Initialize(ns4xPluginInstance* instance, return error; } -NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRInt32 offset, PRInt32 len, PRInt32 *aWriteCount) +NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRUint32 offset, PRUint32 len, PRUint32 *aWriteCount) { const NPPluginFuncs *callbacks; NPP npp; - PRInt32 remaining = len; + PRUint32 remaining = len; fInstance->GetCallbacks(&callbacks); fInstance->GetNPP(&npp); @@ -170,7 +170,7 @@ NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRInt32 offset, PRInt3 while (remaining > 0) { - PRInt32 numtowrite; + PRUint32 numtowrite; if (callbacks->writeready != NULL) { @@ -182,7 +182,7 @@ NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRInt32 offset, PRInt3 numtowrite = remaining; } else - numtowrite = len; + numtowrite = (int32)len; *aWriteCount = CallNPP_WriteProc(callbacks->write, npp, diff --git a/mozilla/modules/plugin/base/src/ns4xPluginStream.h b/mozilla/modules/plugin/base/src/ns4xPluginStream.h index 548ac02ec16..5a88fab984d 100644 --- a/mozilla/modules/plugin/base/src/ns4xPluginStream.h +++ b/mozilla/modules/plugin/base/src/ns4xPluginStream.h @@ -57,7 +57,7 @@ public: // (Corresponds to NPP_Write and NPN_Write.) NS_IMETHOD - Write(const char* buffer, PRInt32 offset, PRInt32 len, PRInt32 *aWriteCount); + Write(const char* buffer, PRUint32 offset, PRUint32 len, PRUint32 *aWriteCount); // (Corresponds to NPP_NewStream's stype return parameter.) NS_IMETHOD diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 4733e0f7497..8ce4bc875a8 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +/* -*- 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 @@ -153,18 +153,18 @@ public: NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg); //nsIStreamListener interface - NS_IMETHOD GetBindInfo(nsIURL* aURL); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo); NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, - PRInt32 aLength); + PRUint32 aLength); //locals @@ -189,7 +189,7 @@ private: PRUint32 mBufSize; void *mNotifyData; nsIPluginHost *mHost; - PRInt32 mLength; + PRUint32 mLength; PRBool mGotProgress; nsPluginStreamType mStreamType; #ifdef USE_CACHE @@ -227,7 +227,9 @@ nsPluginStreamListener :: nsPluginStreamListener() nsPluginStreamListener :: ~nsPluginStreamListener() { #ifdef NS_DEBUG -printf("killing stream for %s\n", mURL ? mURL->GetSpec() : "(unknown URL)"); + const char* spec; + (void)mURL->GetSpec(&spec); + printf("killing stream for %s\n", mURL ? spec : "(unknown URL)"); #endif NS_IF_RELEASE(mURL); NS_IF_RELEASE(mOwner); @@ -304,7 +306,9 @@ nsresult nsPluginStreamListener :: QueryInterface(const nsIID& aIID, nsresult nsPluginStreamListener :: Initialize(nsIURL *aURL, nsIPluginInstance *aInstance, void *aNotifyData) { #ifdef NS_DEBUG -printf("created stream for %s\n", aURL->GetSpec()); + const char* spec; + (void)aURL->GetSpec(&spec); + printf("created stream for %s\n", spec); #endif mURL = aURL; NS_ADDREF(mURL); @@ -321,7 +325,9 @@ nsresult nsPluginStreamListener :: Initialize(nsIURL *aURL, nsIPluginInstanceOwn nsIPluginHost *aHost, void *aNotifyData) { #ifdef NS_DEBUG -printf("created stream for %s\n", aURL->GetSpec()); + const char* spec; + (void)aURL->GetSpec(&spec); + printf("created stream for %s\n", spec); #endif mURL = aURL; NS_ADDREF(mURL); @@ -401,7 +407,6 @@ NS_IMETHODIMP nsPluginStreamListener :: OnStartBinding(nsIURL* aURL, const char (nsnull != instance) && (PR_FALSE == mBound)) rv = SetUpStreamPeer(aURL, instance, aContentType); - NS_IF_RELEASE(instance); mBound = PR_TRUE; @@ -409,7 +414,7 @@ NS_IMETHODIMP nsPluginStreamListener :: OnStartBinding(nsIURL* aURL, const char return rv; } -NS_IMETHODIMP nsPluginStreamListener :: OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) +NS_IMETHODIMP nsPluginStreamListener :: OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult rv = NS_OK; if ((aProgress == 0) && (nsnull == mPeer)) @@ -439,12 +444,12 @@ NS_IMETHODIMP nsPluginStreamListener :: OnProgress(nsIURL* aURL, PRInt32 aProgre return rv; } -NS_IMETHODIMP nsPluginStreamListener :: OnStatus(nsIURL* aURL, const nsString &aMsg) +NS_IMETHODIMP nsPluginStreamListener :: OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { return NS_OK; } -NS_IMETHODIMP nsPluginStreamListener :: OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg) +NS_IMETHODIMP nsPluginStreamListener :: OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg) { nsresult rv; nsPluginReason reason = nsPluginReason_NoReason; @@ -533,12 +538,13 @@ NS_IMETHODIMP nsPluginStreamListener :: OnStopBinding(nsIURL* aURL, PRInt32 aSta const char *url; if (nsnull != mURL) - url = mURL->GetSpec(); + rv = mURL->GetSpec(&url); else url = ""; //XXX target is bad. MMP - instance->URLNotify(url, "", reason, mNotifyData); + if (url) + instance->URLNotify(url, "", reason, mNotifyData); } NS_RELEASE(instance); @@ -548,15 +554,15 @@ NS_IMETHODIMP nsPluginStreamListener :: OnStopBinding(nsIURL* aURL, PRInt32 aSta return rv; } -NS_IMETHODIMP nsPluginStreamListener :: GetBindInfo(nsIURL* aURL) +NS_IMETHODIMP nsPluginStreamListener :: GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo) { return NS_OK; } NS_IMETHODIMP nsPluginStreamListener :: OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, - PRInt32 aLength) + PRUint32 aLength) { - if ((PRUint32)aLength > mBufSize) + if (aLength > mBufSize) { if (nsnull != mBuffer) PR_Free((void *)mBuffer); @@ -567,7 +573,7 @@ NS_IMETHODIMP nsPluginStreamListener :: OnDataAvailable(nsIURL* aURL, nsIInputSt if ((nsnull != mBuffer) && (nsnull != mStream)) { - PRInt32 readlen; + PRUint32 readlen; aIStream->Read((char *)mBuffer, 0, aLength, &readlen); #ifdef USE_CACHE @@ -1326,7 +1332,9 @@ nsresult nsPluginHostImpl :: InstantiatePlugin(const char *aMimeType, nsIURL *aU if ((nsnull == plugins) && (nsnull != aURL)) { - const char *name = aURL->GetSpec(); + const char *name; + nsresult rv = aURL->GetSpec(&name); + if (rv != NS_OK) return rv; PRInt32 len = PL_strlen(name); //find the plugin by filename extension. @@ -1583,6 +1591,8 @@ NS_IMETHODIMP nsPluginHostImpl :: NewPluginStream(const nsString& aURL, { nsIURL *url; nsPluginStreamListener *listener = (nsPluginStreamListener *)new nsPluginStreamListener(); + if (listener == NULL) + return NS_ERROR_OUT_OF_MEMORY; nsresult rv; if (aURL.Length() <= 0) @@ -1594,8 +1604,9 @@ NS_IMETHODIMP nsPluginHostImpl :: NewPluginStream(const nsString& aURL, { rv = listener->Initialize(url, aInstance, aNotifyData); - if (NS_OK == rv) - rv = url->Open(listener); + if (NS_OK == rv) { + rv = NS_OpenURL(url, listener); + } NS_RELEASE(url); } @@ -1620,8 +1631,9 @@ NS_IMETHODIMP nsPluginHostImpl :: NewPluginStream(const nsString& aURL, { rv = listener->Initialize(url, aOwner, (nsIPluginHost *)this, aNotifyData); - if (NS_OK == rv) - rv = url->Open(listener); + if (NS_OK == rv) { + rv = NS_OpenURL(url, listener); + } NS_RELEASE(url); } diff --git a/mozilla/modules/plugin/base/src/nsPluginStreamPeer.cpp b/mozilla/modules/plugin/base/src/nsPluginStreamPeer.cpp index c99c9c6678a..9d805136c1f 100644 --- a/mozilla/modules/plugin/base/src/nsPluginStreamPeer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginStreamPeer.cpp @@ -85,9 +85,10 @@ NS_IMETHODIMP nsPluginStreamPeer :: GetURL(const char* *result) { if (nsnull == mURLSpec) { - nsString string; - - mURL->ToString(string); + PRUnichar* str; + mURL->ToString(&str); + nsString string = str; + delete str; mURLSpec = (char *)PR_Malloc(string.Length() + 1); @@ -165,4 +166,4 @@ nsresult nsPluginStreamPeer :: SetReason(nsPluginReason aReason) { mReason = aReason; return NS_OK; -} \ No newline at end of file +} diff --git a/mozilla/modules/plugin/nglsrc/ns4xPlugin.cpp b/mozilla/modules/plugin/nglsrc/ns4xPlugin.cpp index 142eb606ca4..12a5bcf58fb 100644 --- a/mozilla/modules/plugin/nglsrc/ns4xPlugin.cpp +++ b/mozilla/modules/plugin/nglsrc/ns4xPlugin.cpp @@ -481,12 +481,12 @@ ns4xPlugin::_write(NPP npp, NPStream *pstream, int32 len, void *buffer) nsIOutputStream* stream = wrapper->GetStream(); - PRInt32 count = 0; + PRUint32 count = 0; nsresult rv = stream->Write((char *)buffer, 0, len, &count); NS_RELEASE(stream); - return count; + return (int32)count; } nsresult NP_EXPORT diff --git a/mozilla/modules/plugin/nglsrc/ns4xPluginStream.cpp b/mozilla/modules/plugin/nglsrc/ns4xPluginStream.cpp index edeb366d756..9820237499d 100644 --- a/mozilla/modules/plugin/nglsrc/ns4xPluginStream.cpp +++ b/mozilla/modules/plugin/nglsrc/ns4xPluginStream.cpp @@ -156,11 +156,11 @@ NS_IMETHODIMP ns4xPluginStream::Initialize(ns4xPluginInstance* instance, return error; } -NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRInt32 offset, PRInt32 len, PRInt32 *aWriteCount) +NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRUint32 offset, PRUint32 len, PRUint32 *aWriteCount) { const NPPluginFuncs *callbacks; NPP npp; - PRInt32 remaining = len; + PRUint32 remaining = len; fInstance->GetCallbacks(&callbacks); fInstance->GetNPP(&npp); @@ -170,7 +170,7 @@ NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRInt32 offset, PRInt3 while (remaining > 0) { - PRInt32 numtowrite; + PRUint32 numtowrite; if (callbacks->writeready != NULL) { @@ -182,7 +182,7 @@ NS_IMETHODIMP ns4xPluginStream::Write(const char* buffer, PRInt32 offset, PRInt3 numtowrite = remaining; } else - numtowrite = len; + numtowrite = (int32)len; *aWriteCount = CallNPP_WriteProc(callbacks->write, npp, diff --git a/mozilla/modules/plugin/nglsrc/ns4xPluginStream.h b/mozilla/modules/plugin/nglsrc/ns4xPluginStream.h index 548ac02ec16..5a88fab984d 100644 --- a/mozilla/modules/plugin/nglsrc/ns4xPluginStream.h +++ b/mozilla/modules/plugin/nglsrc/ns4xPluginStream.h @@ -57,7 +57,7 @@ public: // (Corresponds to NPP_Write and NPN_Write.) NS_IMETHOD - Write(const char* buffer, PRInt32 offset, PRInt32 len, PRInt32 *aWriteCount); + Write(const char* buffer, PRUint32 offset, PRUint32 len, PRUint32 *aWriteCount); // (Corresponds to NPP_NewStream's stype return parameter.) NS_IMETHOD diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp index 4733e0f7497..8ce4bc875a8 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +/* -*- 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 @@ -153,18 +153,18 @@ public: NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg); //nsIStreamListener interface - NS_IMETHOD GetBindInfo(nsIURL* aURL); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo); NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, - PRInt32 aLength); + PRUint32 aLength); //locals @@ -189,7 +189,7 @@ private: PRUint32 mBufSize; void *mNotifyData; nsIPluginHost *mHost; - PRInt32 mLength; + PRUint32 mLength; PRBool mGotProgress; nsPluginStreamType mStreamType; #ifdef USE_CACHE @@ -227,7 +227,9 @@ nsPluginStreamListener :: nsPluginStreamListener() nsPluginStreamListener :: ~nsPluginStreamListener() { #ifdef NS_DEBUG -printf("killing stream for %s\n", mURL ? mURL->GetSpec() : "(unknown URL)"); + const char* spec; + (void)mURL->GetSpec(&spec); + printf("killing stream for %s\n", mURL ? spec : "(unknown URL)"); #endif NS_IF_RELEASE(mURL); NS_IF_RELEASE(mOwner); @@ -304,7 +306,9 @@ nsresult nsPluginStreamListener :: QueryInterface(const nsIID& aIID, nsresult nsPluginStreamListener :: Initialize(nsIURL *aURL, nsIPluginInstance *aInstance, void *aNotifyData) { #ifdef NS_DEBUG -printf("created stream for %s\n", aURL->GetSpec()); + const char* spec; + (void)aURL->GetSpec(&spec); + printf("created stream for %s\n", spec); #endif mURL = aURL; NS_ADDREF(mURL); @@ -321,7 +325,9 @@ nsresult nsPluginStreamListener :: Initialize(nsIURL *aURL, nsIPluginInstanceOwn nsIPluginHost *aHost, void *aNotifyData) { #ifdef NS_DEBUG -printf("created stream for %s\n", aURL->GetSpec()); + const char* spec; + (void)aURL->GetSpec(&spec); + printf("created stream for %s\n", spec); #endif mURL = aURL; NS_ADDREF(mURL); @@ -401,7 +407,6 @@ NS_IMETHODIMP nsPluginStreamListener :: OnStartBinding(nsIURL* aURL, const char (nsnull != instance) && (PR_FALSE == mBound)) rv = SetUpStreamPeer(aURL, instance, aContentType); - NS_IF_RELEASE(instance); mBound = PR_TRUE; @@ -409,7 +414,7 @@ NS_IMETHODIMP nsPluginStreamListener :: OnStartBinding(nsIURL* aURL, const char return rv; } -NS_IMETHODIMP nsPluginStreamListener :: OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) +NS_IMETHODIMP nsPluginStreamListener :: OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult rv = NS_OK; if ((aProgress == 0) && (nsnull == mPeer)) @@ -439,12 +444,12 @@ NS_IMETHODIMP nsPluginStreamListener :: OnProgress(nsIURL* aURL, PRInt32 aProgre return rv; } -NS_IMETHODIMP nsPluginStreamListener :: OnStatus(nsIURL* aURL, const nsString &aMsg) +NS_IMETHODIMP nsPluginStreamListener :: OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { return NS_OK; } -NS_IMETHODIMP nsPluginStreamListener :: OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg) +NS_IMETHODIMP nsPluginStreamListener :: OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg) { nsresult rv; nsPluginReason reason = nsPluginReason_NoReason; @@ -533,12 +538,13 @@ NS_IMETHODIMP nsPluginStreamListener :: OnStopBinding(nsIURL* aURL, PRInt32 aSta const char *url; if (nsnull != mURL) - url = mURL->GetSpec(); + rv = mURL->GetSpec(&url); else url = ""; //XXX target is bad. MMP - instance->URLNotify(url, "", reason, mNotifyData); + if (url) + instance->URLNotify(url, "", reason, mNotifyData); } NS_RELEASE(instance); @@ -548,15 +554,15 @@ NS_IMETHODIMP nsPluginStreamListener :: OnStopBinding(nsIURL* aURL, PRInt32 aSta return rv; } -NS_IMETHODIMP nsPluginStreamListener :: GetBindInfo(nsIURL* aURL) +NS_IMETHODIMP nsPluginStreamListener :: GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo) { return NS_OK; } NS_IMETHODIMP nsPluginStreamListener :: OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, - PRInt32 aLength) + PRUint32 aLength) { - if ((PRUint32)aLength > mBufSize) + if (aLength > mBufSize) { if (nsnull != mBuffer) PR_Free((void *)mBuffer); @@ -567,7 +573,7 @@ NS_IMETHODIMP nsPluginStreamListener :: OnDataAvailable(nsIURL* aURL, nsIInputSt if ((nsnull != mBuffer) && (nsnull != mStream)) { - PRInt32 readlen; + PRUint32 readlen; aIStream->Read((char *)mBuffer, 0, aLength, &readlen); #ifdef USE_CACHE @@ -1326,7 +1332,9 @@ nsresult nsPluginHostImpl :: InstantiatePlugin(const char *aMimeType, nsIURL *aU if ((nsnull == plugins) && (nsnull != aURL)) { - const char *name = aURL->GetSpec(); + const char *name; + nsresult rv = aURL->GetSpec(&name); + if (rv != NS_OK) return rv; PRInt32 len = PL_strlen(name); //find the plugin by filename extension. @@ -1583,6 +1591,8 @@ NS_IMETHODIMP nsPluginHostImpl :: NewPluginStream(const nsString& aURL, { nsIURL *url; nsPluginStreamListener *listener = (nsPluginStreamListener *)new nsPluginStreamListener(); + if (listener == NULL) + return NS_ERROR_OUT_OF_MEMORY; nsresult rv; if (aURL.Length() <= 0) @@ -1594,8 +1604,9 @@ NS_IMETHODIMP nsPluginHostImpl :: NewPluginStream(const nsString& aURL, { rv = listener->Initialize(url, aInstance, aNotifyData); - if (NS_OK == rv) - rv = url->Open(listener); + if (NS_OK == rv) { + rv = NS_OpenURL(url, listener); + } NS_RELEASE(url); } @@ -1620,8 +1631,9 @@ NS_IMETHODIMP nsPluginHostImpl :: NewPluginStream(const nsString& aURL, { rv = listener->Initialize(url, aOwner, (nsIPluginHost *)this, aNotifyData); - if (NS_OK == rv) - rv = url->Open(listener); + if (NS_OK == rv) { + rv = NS_OpenURL(url, listener); + } NS_RELEASE(url); } diff --git a/mozilla/modules/plugin/nglsrc/nsPluginStreamPeer.cpp b/mozilla/modules/plugin/nglsrc/nsPluginStreamPeer.cpp index c99c9c6678a..9d805136c1f 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginStreamPeer.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginStreamPeer.cpp @@ -85,9 +85,10 @@ NS_IMETHODIMP nsPluginStreamPeer :: GetURL(const char* *result) { if (nsnull == mURLSpec) { - nsString string; - - mURL->ToString(string); + PRUnichar* str; + mURL->ToString(&str); + nsString string = str; + delete str; mURLSpec = (char *)PR_Malloc(string.Length() + 1); @@ -165,4 +166,4 @@ nsresult nsPluginStreamPeer :: SetReason(nsPluginReason aReason) { mReason = aReason; return NS_OK; -} \ No newline at end of file +} diff --git a/mozilla/network/Makefile.in b/mozilla/network/Makefile.in index 28b1f42d710..e5156b2a974 100644 --- a/mozilla/network/Makefile.in +++ b/mozilla/network/Makefile.in @@ -35,7 +35,7 @@ DIRS = \ util ifdef MODULAR_NETLIB -DIRS += module +DIRS += public module endif ifdef NU_CACHE diff --git a/mozilla/network/makefile.win b/mozilla/network/makefile.win index e57ca92df33..e5ff5d95d2c 100644 --- a/mozilla/network/makefile.win +++ b/mozilla/network/makefile.win @@ -38,6 +38,7 @@ DIRS= \ cnvts \ client \ !ifdef MODULAR_NETLIB + public \ module \ !endif $(NULL) diff --git a/mozilla/network/module/MANIFEST b/mozilla/network/module/MANIFEST index 5277288c187..bdf20e5ec03 100644 --- a/mozilla/network/module/MANIFEST +++ b/mozilla/network/module/MANIFEST @@ -12,4 +12,6 @@ nsIHttpUrl.h nsIRefreshUrl.h nsIConnectionInfo.h nsILoadAttribs.h -nsIURLGroup.h \ No newline at end of file +nsIURLGroup.h +nsIProtocolURLFactory.h + diff --git a/mozilla/network/module/Makefile b/mozilla/network/module/Makefile new file mode 100644 index 00000000000..31766cdbd28 --- /dev/null +++ b/mozilla/network/module/Makefile @@ -0,0 +1,77 @@ +#!gmake +# +# 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. + +DEPTH = ../.. + +MODULE = netlib +LIBRARY_NAME = netlib + +CPPSRCS = \ + nsNetService.cpp \ + nsNetThread.cpp \ + nsRelatedLinks.cpp \ + nsNetStream.cpp \ + nsURL.cpp \ + nsHttpUrl.cpp \ + nsStubContext.cpp \ + nsNetStubs.cpp \ + nsNetIDs.cpp \ + nsLoadAttribs.cpp \ + nsNetFactory.cpp \ + nsHttpURLFactory.cpp \ + $(NULL) + +REQUIRES = raptor js dbm nspr security pref xpcom util img \ + layer network netcache fileurl ftpurl abouturl \ + httpurl gophurl remoturl netcnvts netlib + +EXPORTS = nsINetService.h \ + nsINetSupport.h \ + nsIRelatedLinks.h \ + nsINetlibURL.h \ + nsIProtocolURLFactory.h \ + $(NULL) + +include $(DEPTH)/config/config.mk + +include $(DEPTH)/config/rules.mk + +$(LIBRARY): \ + $(OBJS) + +install:: + $(INSTALL) res/gopher-audio.gif $(DIST)/bin/res/network + $(INSTALL) res/gopher-binary.gif $(DIST)/bin/res/network + $(INSTALL) res/gopher-find.gif $(DIST)/bin/res/network + $(INSTALL) res/gopher-image.gif $(DIST)/bin/res/network + $(INSTALL) res/gopher-menu.gif $(DIST)/bin/res/network + $(INSTALL) res/gopher-movie.gif $(DIST)/bin/res/network + $(INSTALL) res/gopher-telnet.gif $(DIST)/bin/res/network + $(INSTALL) res/gopher-text.gif $(DIST)/bin/res/network + $(INSTALL) res/gopher-unknown.gif $(DIST)/bin/res/network + +clobber:: + rm -f $(DIST)/bin/res/network/gopher-audio.gif + rm -f $(DIST)/bin/res/network/gopher-binary.gif + rm -f $(DIST)/bin/res/network/gopher-find.gif + rm -f $(DIST)/bin/res/network/gopher-image.gif + rm -f $(DIST)/bin/res/network/gopher-menu.gif + rm -f $(DIST)/bin/res/network/gopher-movie.gif + rm -f $(DIST)/bin/res/network/gopher-telnet.gif + rm -f $(DIST)/bin/res/network/gopher-text.gif + rm -f $(DIST)/bin/res/network/gopher-unknown.gif + diff --git a/mozilla/network/module/Makefile.in b/mozilla/network/module/Makefile.in index 658b780ed66..4bd47956144 100644 --- a/mozilla/network/module/Makefile.in +++ b/mozilla/network/module/Makefile.in @@ -35,25 +35,20 @@ CPPSRCS = \ nsStubContext.cpp \ nsNetStubs.cpp \ nsNetIDs.cpp \ - nsLoadAttribs.cpp \ - nsNetFactory.cpp \ + nsLoadAttribs.cpp \ + nsNetFactory.cpp \ + nsHttpURLFactory.cpp \ $(NULL) -REQUIRES = raptor js dbm security pref xpcom util img \ +REQUIRES = raptor js dbm nspr security pref xpcom util img \ layer network netcache fileurl ftpurl abouturl \ - httpurl gophurl remoturl netcnvts + httpurl gophurl remoturl netcnvts netlib -EXPORTS = nsIStreamListener.h \ - nsINetService.h \ - nsINetSupport.h \ - nsIURL.h \ +EXPORTS = nsINetService.h \ + nsINetSupport.h \ nsIRelatedLinks.h \ - nsIPostToServer.h \ - nsIHttpUrl.h \ - nsIRefreshUrl.h \ - nsIConnectionInfo.h \ - nsILoadAttribs.h \ - nsIURLGroup.h \ + nsINetlibURL.h \ + nsIProtocolURLFactory.h \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/mozilla/network/module/makefile.win b/mozilla/network/module/makefile.win index 31804c501f3..bbbcf82d2c8 100644 --- a/mozilla/network/module/makefile.win +++ b/mozilla/network/module/makefile.win @@ -22,18 +22,14 @@ IGNORE_MANIFEST = 1 #// #//------------------------------------------------------------------------ MODULE = netlib -EXPORTS = nsIStreamListener.h \ - nsINetService.h \ +EXPORTS = nsINetService.h \ nsINetSupport.h \ - nsIURL.h \ - nsIPostToServer.h \ - nsIHttpUrl.h \ nsIRelatedLinks.h \ - nsIRefreshUrl.h \ - nsIConnectionInfo.h \ - nsINetFile.h \ - nsILoadAttribs.h \ + nsINetlibURL.h \ nsIURLGroup.h \ + nsIConnectionInfo.h \ + nsIRefreshUrl.h \ + nsIProtocolURLFactory.h \ $(NULL) DIRS = tests @@ -67,7 +63,6 @@ OBJS= \ .\$(OBJDIR)\nsNetThread.obj \ .\$(OBJDIR)\nsNetStream.obj \ .\$(OBJDIR)\nsRelatedLinks.obj \ - .\$(OBJDIR)\nsURL.obj \ .\$(OBJDIR)\nsHttpUrl.obj \ .\$(OBJDIR)\nsStubContext.obj \ .\$(OBJDIR)\nsNetStubs.obj \ @@ -75,6 +70,7 @@ OBJS= \ .\$(OBJDIR)\nsNetFile.obj \ .\$(OBJDIR)\nsLoadAttribs.obj \ .\$(OBJDIR)\nsNetFactory.obj \ + .\$(OBJDIR)\nsHttpURLFactory.obj \ $(NULL) #//------------------------------------------------------------------------ @@ -127,6 +123,7 @@ LLIBS=$(LLIBS) $(LIBNSPR) \ $(NULL) LINCS=$(LINCS) -I. \ + -I..\public \ -I$(PUBLIC)\raptor \ -I$(PUBLIC)\security \ -I$(PUBLIC)\pref \ @@ -145,6 +142,7 @@ LINCS=$(LINCS) -I. \ -I$(PUBLIC)\gophurl \ -I$(PUBLIC)\httpurl \ -I$(PUBLIC)\remoturl \ + -I$(PUBLIC)\netlib \ $(NULL) # clobber and clobber_all will remove the following garbage: diff --git a/mozilla/network/module/nsHttpURLFactory.cpp b/mozilla/network/module/nsHttpURLFactory.cpp new file mode 100644 index 00000000000..92f60215698 --- /dev/null +++ b/mozilla/network/module/nsHttpURLFactory.cpp @@ -0,0 +1,118 @@ +/* -*- 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 "nsIProtocolURLFactory.h" +#include "nsHttpUrl.h" +#include "nsINetService.h" +#include "nsIServiceManager.h" +#include "nsString.h" + +class nsHttpURLFactory : public nsIProtocolURLFactory +{ +public: + + NS_DECL_ISUPPORTS + + //////////////////////////////////////////////////////////////////////////// + // nsIProtocolURLFactory: + + NS_IMETHOD CreateURL(nsIURL* *aResult, + const nsString& aSpec, + const nsIURL* aContextURL = nsnull, + nsISupports* aContainer = nsnull, + nsIURLGroup* aGroup = nsnull); + + //////////////////////////////////////////////////////////////////////////// + // nsHttpURLFactory: + + nsHttpURLFactory(void); + virtual ~nsHttpURLFactory(void); + +protected: + +}; + +nsHttpURLFactory::nsHttpURLFactory(void) +{ + NS_INIT_REFCNT(); +} + +nsHttpURLFactory::~nsHttpURLFactory(void) +{ +} + +static NS_DEFINE_IID(kIProtocolURLFactoryIID, NS_IPROTOCOLURLFACTORY_IID); +NS_IMPL_ISUPPORTS(nsHttpURLFactory, kIProtocolURLFactoryIID); + +NS_IMETHODIMP +nsHttpURLFactory::CreateURL(nsIURL* *aResult, + const nsString& aSpec, + const nsIURL* aContextURL, + nsISupports* aContainer, + nsIURLGroup* aGroup) +{ + nsHttpUrlImpl* url = new nsHttpUrlImpl(aContainer, aGroup); + if (url == NULL) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(url); + nsresult err = url->ParseURL(aSpec, aContextURL); + if (err != NS_OK) + return err; + *aResult = url; + return NS_OK; +} + +static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID); +static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID); + +// XXX temporarily, until we have pluggable protocols... +extern "C" NS_NET nsresult +NS_InitializeHttpURLFactory(nsINetService* inet) +{ + nsresult rv; + nsHttpURLFactory* urlf = new nsHttpURLFactory(); + if (urlf == NULL) + return NS_ERROR_OUT_OF_MEMORY; +#if 0 + nsINetService *inet = nsnull; + rv = nsServiceManager::GetService(kNetServiceCID, + kINetServiceIID, + (nsISupports **)&inet); + if (rv != NS_OK) return rv; +#endif + rv = inet->RegisterProtocol(*new nsString("http"), urlf, NULL); + if (rv != NS_OK) goto done; + inet->RegisterProtocol(*new nsString("https"), urlf, NULL); + if (rv != NS_OK) goto done; + + // XXX Hacks until we have real urlf objects for these... + inet->RegisterProtocol(*new nsString("resource"), urlf, NULL); + if (rv != NS_OK) goto done; + inet->RegisterProtocol(*new nsString("file"), urlf, NULL); + if (rv != NS_OK) goto done; + inet->RegisterProtocol(*new nsString("javascript"), urlf, NULL); + if (rv != NS_OK) goto done; + + done: +#if 0 + nsServiceManager::ReleaseService(kNetServiceCID, inet); +#endif + return rv; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/network/module/nsHttpUrl.cpp b/mozilla/network/module/nsHttpUrl.cpp index 17b481a3e90..1cc6107fdd7 100644 --- a/mozilla/network/module/nsHttpUrl.cpp +++ b/mozilla/network/module/nsHttpUrl.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 4; 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 @@ -16,113 +16,104 @@ * Reserved. */ -#include "nsAgg.h" +#ifdef XP_PC +#include // for InterlockedIncrement +#endif +#include "nsHttpUrl.h" #include "nsIProtocolConnection.h" -#include "nsIHttpUrl.h" -#include "nsIPostToServer.h" +#include "nsIURLGroup.h" +#include "nsString.h" - #include "nsINetService.h" /* XXX: NS_FALSE */ +#include "nsINetService.h" /* XXX: NS_FALSE */ #include "nsNetStream.h" -#include "net.h" #include "prmem.h" #include "plstr.h" +#include "nsCRT.h" MWContext *new_stub_context(URL_Struct *URL_s); static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID); +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIHttpURLIID, NS_IHTTPURL_IID); +static NS_DEFINE_IID(kIURLIID, NS_IURL_IID); +static NS_DEFINE_IID(kIPostToServerIID, NS_IPOSTTOSERVER_IID); +static NS_DEFINE_IID(kIProtocolConnectionIID, NS_IPROTOCOLCONNECTION_IID); - -class nsHttpUrlImpl : public nsIProtocolConnection, - public nsIPostToServer, - public nsIHttpUrl +nsHttpUrlImpl::nsHttpUrlImpl(nsISupports* aContainer, nsIURLGroup* aGroup) { -public: - typedef enum { - Send_None, - Send_File, - Send_Data, - Send_DataFromFile - } SendType; - -public: - nsHttpUrlImpl(nsISupports* outer); - - /* Aggregated nsISupports interface... */ - NS_DECL_AGGREGATED - - /* nsIProtocolConnection interface... */ - NS_IMETHOD InitializeURLInfo(URL_Struct_ *URL_s); - NS_IMETHOD GetURLInfo(URL_Struct_** aResult); - - /* nsIPostToServer interface... */ - NS_IMETHOD SendFile(const char *aFile); - NS_IMETHOD SendData(const char *aBuffer, PRInt32 aLength); - NS_IMETHOD SendDataFromFile(const char *aFile); - - /* Handle http-equiv meta tags. */ - NS_IMETHOD AddMimeHeader(const char *name, const char *value); - - /* Here's our link to the netlib world.... */ - URL_Struct *m_URL_s; - - /* nsIHttpUrl interface... */ - - -static nsISupports* NewHttpUrlImpl(nsISupports *outer); - -protected: - virtual ~nsHttpUrlImpl(); - - nsresult PostFile(const char *aFile); - - SendType m_PostType; - char *m_PostBuffer; - PRInt32 m_PostBufferLength; -}; - - - -nsHttpUrlImpl::nsHttpUrlImpl(nsISupports* outer) -{ - NS_INIT_AGGREGATED(outer); - + NS_INIT_REFCNT(); + m_PostType = Send_None; m_PostBuffer = nsnull; m_PostBufferLength = 0; m_URL_s = nsnull; -} + + mProtocol = nsnull; + mHost = nsnull; + mFile = nsnull; + mRef = nsnull; + mPort = -1; + mSpec = nsnull; + mSearch = nsnull; + mPostData = nsnull; + mContainer = nsnull; + mURLGroup = aGroup; + + NS_NewLoadAttribs(&mLoadAttribs); + NS_IF_ADDREF(mURLGroup); + + mContainer = aContainer; + NS_IF_ADDREF(mContainer); + // ParseURL(aSpec, aURL); // XXX whh +} + nsHttpUrlImpl::~nsHttpUrlImpl() { - if (nsnull != m_PostBuffer) PR_Free(m_PostBuffer); + NS_IF_RELEASE(mContainer); + NS_IF_RELEASE(mLoadAttribs); + NS_IF_RELEASE(mURLGroup); + NS_IF_RELEASE(mPostData); + + PR_FREEIF(mSpec); + PR_FREEIF(mProtocol); + PR_FREEIF(mHost); + PR_FREEIF(mFile); + PR_FREEIF(mRef); + PR_FREEIF(mSearch); + PR_FREEIF(m_PostBuffer); if (nsnull != m_URL_s) { NET_DropURLStruct(m_URL_s); } } + +NS_IMPL_THREADSAFE_ADDREF(nsHttpUrlImpl); +NS_IMPL_THREADSAFE_RELEASE(nsHttpUrlImpl); - - -NS_IMPL_AGGREGATED(nsHttpUrlImpl) - -nsresult nsHttpUrlImpl::AggregatedQueryInterface(const nsIID &aIID, - void** aInstancePtr) +nsresult nsHttpUrlImpl::QueryInterface(const nsIID &aIID, void** aInstancePtr) { if (NULL == aInstancePtr) { return NS_ERROR_NULL_POINTER; } - - static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); - static NS_DEFINE_IID(kIProtocolConnectionIID, NS_IPROTOCOLCONNECTION_IID); - static NS_DEFINE_IID(kIPostToServerIID, NS_IPOSTTOSERVER_IID); - static NS_DEFINE_IID(kIHttpUrlIID, NS_IHTTPURL_IID); - if (aIID.Equals(kIProtocolConnectionIID)) { - *aInstancePtr = (void*) ((nsIProtocolConnection*)this); + + static NS_DEFINE_IID(kINetlibURLIID, NS_INETLIBURL_IID); + static NS_DEFINE_IID(kIPostToServerIID, NS_IPOSTTOSERVER_IID); + static NS_DEFINE_IID(kIsThreadsafeIID, NS_ISTHREADSAFE_IID); + if (aIID.Equals(kIHttpURLIID) || + aIID.Equals(kIsThreadsafeIID) || + aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) ((nsIHttpURL*)this); AddRef(); return NS_OK; } - if (aIID.Equals(kIHttpUrlIID)) { - *aInstancePtr = (void*) ((nsIHttpUrl*)this); + if (aIID.Equals(kIURLIID)) { + *aInstancePtr = (void*) ((nsIURL*)this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kINetlibURLIID)) { + *aInstancePtr = (void*) ((nsINetlibURL*)this); AddRef(); return NS_OK; } @@ -131,20 +122,15 @@ nsresult nsHttpUrlImpl::AggregatedQueryInterface(const nsIID &aIID, AddRef(); return NS_OK; } - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*) ((nsISupports *)&fAggregated); - AddRef(); - return NS_OK; - } - + return NS_NOINTERFACE; } -NS_METHOD nsHttpUrlImpl::InitializeURLInfo(URL_Struct *URL_s) +NS_METHOD nsHttpUrlImpl::SetURLInfo(URL_Struct *URL_s) { nsresult result = NS_OK; - + /* Hook us up with the world. */ m_URL_s = URL_s; NET_HoldURLStruct(URL_s); @@ -154,7 +140,7 @@ NS_METHOD nsHttpUrlImpl::InitializeURLInfo(URL_Struct *URL_s) if (nsnull != URL_s->post_data) { PR_Free(URL_s->post_data); } - + /* * Store the new POST data into the URL_Struct */ @@ -165,18 +151,17 @@ NS_METHOD nsHttpUrlImpl::InitializeURLInfo(URL_Struct *URL_s) * Is the request a POST or PUT */ URL_s->method = (Send_File == m_PostType) ? URL_PUT_METHOD : URL_POST_METHOD; - + /* Reset the local post state... */ m_PostType = Send_None; m_PostBuffer = nsnull; /* The URL_Struct owns the memory now... */ m_PostBufferLength = 0; } - + return result; } - - -NS_METHOD nsHttpUrlImpl::GetURLInfo(URL_Struct_** aResult) + +NS_METHOD nsHttpUrlImpl::GetURLInfo(URL_Struct_** aResult) const { nsresult rv; @@ -191,7 +176,6 @@ NS_METHOD nsHttpUrlImpl::GetURLInfo(URL_Struct_** aResult) return rv; } - NS_METHOD nsHttpUrlImpl::SendFile(const char *aFile) { nsresult result; @@ -216,7 +200,7 @@ NS_METHOD nsHttpUrlImpl::SendDataFromFile(const char *aFile) } -NS_METHOD nsHttpUrlImpl::SendData(const char *aBuffer, PRInt32 aLength) +NS_METHOD nsHttpUrlImpl::SendData(const char *aBuffer, PRUint32 aLength) { nsresult result = NS_OK; @@ -245,7 +229,6 @@ done: return result; } - NS_METHOD nsHttpUrlImpl::AddMimeHeader(const char *name, const char *value) { MWContext *stubContext=NULL; @@ -328,41 +311,602 @@ done: return result; } +//////////////////////////////////////////////////////////////////////////////// -nsISupports* nsHttpUrlImpl::NewHttpUrlImpl(nsISupports* aOuter) +// XXX recode to use nsString api's + +// XXX don't bother with port numbers +// XXX don't bother with ref's +// XXX null pointer checks are incomplete +nsresult nsHttpUrlImpl::ParseURL(const nsString& aSpec, const nsIURL* aURL) { - nsHttpUrlImpl* it; - nsISupports *result = nsnull; + // XXX hack! + char* cSpec = aSpec.ToNewCString(); - it = new nsHttpUrlImpl(aOuter); - if (nsnull != it) { - if (nsnull != aOuter) { - result = &it->fAggregated; - } else { - result = (nsIProtocolConnection *)it; + const char* uProtocol = nsnull; + const char* uHost = nsnull; + const char* uFile = nsnull; + PRUint32 uPort; + if (nsnull != aURL) { + nsresult rslt = aURL->GetProtocol(&uProtocol); + if (rslt != NS_OK) return rslt; + rslt = aURL->GetHost(&uHost); + if (rslt != NS_OK) return rslt; + rslt = aURL->GetFile(&uFile); + if (rslt != NS_OK) return rslt; + rslt = aURL->GetHostPort(&uPort); + if (rslt != NS_OK) return rslt; + } + + NS_LOCK_INSTANCE(); + + PR_FREEIF(mProtocol); + PR_FREEIF(mHost); + PR_FREEIF(mFile); + PR_FREEIF(mRef); + PR_FREEIF(mSearch); + mPort = -1; + + if (nsnull == cSpec) { + if (nsnull == aURL) { + NS_UNLOCK_INSTANCE(); + return NS_ERROR_ILLEGAL_VALUE; + } + mProtocol = (nsnull != uProtocol) ? PL_strdup(uProtocol) : nsnull; + mHost = (nsnull != uHost) ? PL_strdup(uHost) : nsnull; + mPort = uPort; + mFile = (nsnull != uFile) ? PL_strdup(uFile) : nsnull; + + NS_UNLOCK_INSTANCE(); + return NS_OK; + } + + // Strip out reference and search info + char* ref = strpbrk(cSpec, "#?"); + if (nsnull != ref) { + char* search = nsnull; + if ('#' == *ref) { + search = PL_strchr(ref + 1, '?'); + if (nsnull != search) { + *search++ = '\0'; + } + + PRIntn hashLen = PL_strlen(ref + 1); + if (0 != hashLen) { + mRef = (char*) PR_Malloc(hashLen + 1); + PL_strcpy(mRef, ref + 1); + } + } + else { + search = ref + 1; } - result->AddRef(); + if (nsnull != search) { + // The rest is the search + PRIntn searchLen = PL_strlen(search); + if (0 != searchLen) { + mSearch = (char*) PR_Malloc(searchLen + 1); + PL_strcpy(mSearch, search); + } + } + + // XXX Terminate string at start of reference or search + *ref = '\0'; } - return result; -} - - - -extern "C" NS_NET nsresult NS_NewHttpUrl(nsISupports** aInstancePtrResult, - nsISupports* aOuter) -{ - NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; + // The URL is considered absolute if and only if it begins with a + // protocol spec. A protocol spec is an alphanumeric string of 1 or + // more characters that is terminated with a colon. + PRBool isAbsolute = PR_FALSE; + char* cp; + char* ap = cSpec; + char ch; + while (0 != (ch = *ap)) { + if (((ch >= 'a') && (ch <= 'z')) || + ((ch >= 'A') && (ch <= 'Z')) || + ((ch >= '0') && (ch <= '9'))) { + ap++; + continue; + } + if ((ch == ':') && (ap - cSpec >= 2)) { + isAbsolute = PR_TRUE; + cp = ap; + break; + } + break; } - *aInstancePtrResult = nsHttpUrlImpl::NewHttpUrlImpl(aOuter); - if (nsnull == *aInstancePtrResult) { - return NS_ERROR_OUT_OF_MEMORY; + if (!isAbsolute) { + // relative spec + if (nsnull == aURL) { + delete cSpec; + + NS_UNLOCK_INSTANCE(); + return NS_ERROR_ILLEGAL_VALUE; + } + + // keep protocol and host + mProtocol = (nsnull != uProtocol) ? PL_strdup(uProtocol) : nsnull; + mHost = (nsnull != uHost) ? PL_strdup(uHost) : nsnull; + mPort = uPort; + + // figure out file name + PRInt32 len = PL_strlen(cSpec) + 1; + if ((len > 1) && (cSpec[0] == '/')) { + // Relative spec is absolute to the server + mFile = PL_strdup(cSpec); + } else { + if (cSpec[0] != '\0') { + // Strip out old tail component and put in the new one + char* dp = PL_strrchr(uFile, '/'); + if (!dp) { + delete cSpec; + NS_UNLOCK_INSTANCE(); + return NS_ERROR_ILLEGAL_VALUE; + } + PRInt32 dirlen = (dp + 1) - uFile; + mFile = (char*) PR_Malloc(dirlen + len); + PL_strncpy(mFile, uFile, dirlen); + PL_strcpy(mFile + dirlen, cSpec); + } + else { + mFile = PL_strdup(uFile); + } + } + + /* Stolen from netlib's mkparse.c. + * + * modifies a url of the form /foo/../foo1 -> /foo1 + * and /foo/./foo1 -> /foo/foo1 + */ + char *fwdPtr = mFile; + char *urlPtr = mFile; + + for(; *fwdPtr != '\0'; fwdPtr++) + { + + if(*fwdPtr == '/' && *(fwdPtr+1) == '.' && *(fwdPtr+2) == '/') + { + /* remove ./ + */ + fwdPtr += 1; + } + else if(*fwdPtr == '/' && *(fwdPtr+1) == '.' && *(fwdPtr+2) == '.' && + (*(fwdPtr+3) == '/' || *(fwdPtr+3) == '\0')) + { + /* remove foo/.. + */ + /* reverse the urlPtr to the previous slash + */ + if(urlPtr != mFile) + urlPtr--; /* we must be going back at least one */ + for(;*urlPtr != '/' && urlPtr != mFile; urlPtr--) + ; /* null body */ + + /* forward the fwd_prt past the ../ + */ + fwdPtr += 2; + } + else + { + /* copy the url incrementaly + */ + *urlPtr++ = *fwdPtr; + } + } + + *urlPtr = '\0'; /* terminate the url */ + + // Now that we've resolved the relative URL, we need to reconstruct + // a URL spec from the components. + ReconstructSpec(); + } else { + // absolute spec + + PR_FREEIF(mSpec); + PRInt32 slen = aSpec.Length(); + mSpec = (char *) PR_Malloc(slen + 1); + aSpec.ToCString(mSpec, slen+1); + + // get protocol first + PRInt32 plen = cp - cSpec; + mProtocol = (char*) PR_Malloc(plen + 1); + PL_strncpy(mProtocol, cSpec, plen); + mProtocol[plen] = 0; + cp++; // eat : in protocol + + // skip over one, two or three slashes + if (*cp == '/') { + cp++; + if (*cp == '/') { + cp++; + if (*cp == '/') { + cp++; + } + } + } else { + delete cSpec; + + NS_UNLOCK_INSTANCE(); + return NS_ERROR_ILLEGAL_VALUE; + } + + +#if defined(XP_UNIX) || defined (XP_MAC) + // Always leave the top level slash for absolute file paths under Mac and UNIX. + // The code above sometimes results in stripping all of slashes + // off. This only happens when a previously stripped url is asked to be + // parsed again. Under Win32 this is not a problem since file urls begin + // with a drive letter not a slash. This problem show's itself when + // nested documents such as iframes within iframes are parsed. + + if (PL_strcmp(mProtocol, "file") == 0) { + if (*cp != '/') { + cp--; + } + } +#endif /* XP_UNIX */ + + const char* cp0 = cp; + if ((PL_strcmp(mProtocol, "resource") == 0) || + (PL_strcmp(mProtocol, "file") == 0)) { + // resource/file url's do not have host names. + // The remainder of the string is the file name + PRInt32 flen = PL_strlen(cp); + mFile = (char*) PR_Malloc(flen + 1); + PL_strcpy(mFile, cp); + +#ifdef NS_WIN32 + if (PL_strcmp(mProtocol, "file") == 0) { + // If the filename starts with a "x|" where is an single + // character then we assume it's a drive name and change the + // vertical bar back to a ":" + if ((flen >= 2) && (mFile[1] == '|')) { + mFile[1] = ':'; + } + } +#endif /* NS_WIN32 */ + } else { + // Host name follows protocol for http style urls + cp = PL_strpbrk(cp, "/:"); + + if (nsnull == cp) { + // There is only a host name + PRInt32 hlen = PL_strlen(cp0); + mHost = (char*) PR_Malloc(hlen + 1); + PL_strcpy(mHost, cp0); + } + else { + PRInt32 hlen = cp - cp0; + mHost = (char*) PR_Malloc(hlen + 1); + PL_strncpy(mHost, cp0, hlen); + mHost[hlen] = 0; + + if (':' == *cp) { + // We have a port number + cp0 = cp+1; + cp = PL_strchr(cp, '/'); + mPort = strtol(cp0, (char **)nsnull, 10); + } + } + + if (nsnull == cp) { + // There is no file name + // Set filename to "/" + mFile = (char*) PR_Malloc(2); + mFile[0] = '/'; + mFile[1] = 0; + } + else { + // The rest is the file name + PRInt32 flen = PL_strlen(cp); + mFile = (char*) PR_Malloc(flen + 1); + PL_strcpy(mFile, cp); + } + } } +//printf("protocol='%s' host='%s' file='%s'\n", mProtocol, mHost, mFile); + delete cSpec; + + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +void +nsHttpUrlImpl::ReconstructSpec(void) +{ + PR_FREEIF(mSpec); + + char portBuffer[10]; + if (-1 != mPort) { + PR_snprintf(portBuffer, 10, ":%d", mPort); + } + else { + portBuffer[0] = '\0'; + } + + PRInt32 plen = PL_strlen(mProtocol) + PL_strlen(mHost) + + PL_strlen(portBuffer) + PL_strlen(mFile) + 4; + if (mRef) { + plen += 1 + PL_strlen(mRef); + } + if (mSearch) { + plen += 1 + PL_strlen(mSearch); + } + + mSpec = (char *) PR_Malloc(plen + 1); + PR_snprintf(mSpec, plen, "%s://%s%s%s", + mProtocol, ((nsnull != mHost) ? mHost : ""), portBuffer, + mFile); + + if (mRef) { + PL_strcat(mSpec, "#"); + PL_strcat(mSpec, mRef); + } + if (mSearch) { + PL_strcat(mSpec, "?"); + PL_strcat(mSpec, mSearch); + } +} + +//////////////////////////////////////////////////////////////////////////////// + +PRBool nsHttpUrlImpl::Equals(const nsIURL* aURL) const +{ + PRBool bIsEqual; + nsHttpUrlImpl* other; + NS_LOCK_INSTANCE(); + if (((nsIURL*)aURL)->QueryInterface(kIHttpURLIID, (void**)other) == NS_OK) { + bIsEqual = PRBool((0 == PL_strcmp(mProtocol, other->mProtocol)) && + (0 == PL_strcasecmp(mHost, other->mHost)) && + (0 == PL_strcmp(mFile, other->mFile))); + } + else + bIsEqual = PR_FALSE; + NS_UNLOCK_INSTANCE(); + return bIsEqual; +} + +nsresult nsHttpUrlImpl::GetProtocol(const char* *result) const +{ + NS_LOCK_INSTANCE(); + *result = mProtocol; + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::SetProtocol(const char *aNewProtocol) +{ + NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened"); + NS_LOCK_INSTANCE(); + mProtocol = nsCRT::strdup(aNewProtocol); + ReconstructSpec(); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::GetHost(const char* *result) const +{ + NS_LOCK_INSTANCE(); + *result = mHost; + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::SetHost(const char *aNewHost) +{ + NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened"); + NS_LOCK_INSTANCE(); + mHost = nsCRT::strdup(aNewHost); + ReconstructSpec(); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::GetFile(const char* *result) const +{ + NS_LOCK_INSTANCE(); + *result = mFile; + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::SetFile(const char *aNewFile) +{ + NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened"); + NS_LOCK_INSTANCE(); + mFile = nsCRT::strdup(aNewFile); + ReconstructSpec(); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::GetSpec(const char* *result) const +{ + NS_LOCK_INSTANCE(); + *result = mSpec; + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::SetSpec(const char *aNewSpec) +{ + // XXX is this right, or should we call ParseURL? + nsresult rv = NS_OK; +// NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened"); + NS_LOCK_INSTANCE(); +// rv = ParseURL(aNewSpec); + mSpec = nsCRT::strdup(aNewSpec); + NS_UNLOCK_INSTANCE(); + return rv; +} + +nsresult nsHttpUrlImpl::GetRef(const char* *result) const +{ + NS_LOCK_INSTANCE(); + *result = mRef; + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::SetRef(const char *aNewRef) +{ + NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened"); + NS_LOCK_INSTANCE(); + mRef = nsCRT::strdup(aNewRef); + ReconstructSpec(); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::GetHostPort(PRUint32 *result) const +{ + NS_LOCK_INSTANCE(); + *result = mPort; + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::SetHostPort(PRUint32 aNewPort) +{ + NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened"); + NS_LOCK_INSTANCE(); + mPort = aNewPort; + ReconstructSpec(); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::GetSearch(const char* *result) const +{ + NS_LOCK_INSTANCE(); + *result = mSearch; + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::SetSearch(const char *aNewSearch) +{ + NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened"); + NS_LOCK_INSTANCE(); + mSearch = nsCRT::strdup(aNewSearch); + ReconstructSpec(); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::GetContainer(nsISupports* *result) const +{ + NS_LOCK_INSTANCE(); + *result = mContainer; + NS_IF_ADDREF(mContainer); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::SetContainer(nsISupports* container) +{ + NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened"); + NS_LOCK_INSTANCE(); + NS_IF_RELEASE(mContainer); + mContainer = container; + NS_IF_ADDREF(mContainer); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::GetLoadAttribs(nsILoadAttribs* *result) const +{ + NS_LOCK_INSTANCE(); + *result = mLoadAttribs; + NS_IF_ADDREF(mLoadAttribs); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::SetLoadAttribs(nsILoadAttribs* aLoadAttribs) +{ + NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened"); + NS_LOCK_INSTANCE(); + NS_IF_RELEASE(mLoadAttribs); + mLoadAttribs = aLoadAttribs; + NS_IF_ADDREF(mLoadAttribs); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::GetURLGroup(nsIURLGroup* *result) const +{ + NS_LOCK_INSTANCE(); + *result = mURLGroup; + NS_IF_ADDREF(mURLGroup); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::SetURLGroup(nsIURLGroup* group) +{ + NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened"); + NS_LOCK_INSTANCE(); + NS_IF_RELEASE(mURLGroup); + mURLGroup = group; + NS_IF_ADDREF(mURLGroup); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::SetPostHeader(const char* name, const char* value) +{ + NS_LOCK_INSTANCE(); + // XXX + PR_ASSERT(0); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::SetPostData(nsIInputStream* input) +{ + NS_LOCK_INSTANCE(); + mPostData = input; + input->AddRef(); + NS_UNLOCK_INSTANCE(); + return NS_OK; +} + +nsresult nsHttpUrlImpl::ToString(PRUnichar* *unichars) const +{ + nsString& aString = *new nsString(); + NS_LOCK_INSTANCE(); + + // XXX Special-case javascript: URLs for the moment. + // This code will go away when we actually start doing + // protocol-specific parsing. + if (PL_strcmp(mProtocol, "javascript") == 0) { + aString.SetString(mSpec); + } else { + aString.SetLength(0); + aString.Append(mProtocol); + aString.Append("://"); + if (nsnull != mHost) { + aString.Append(mHost); + if (0 < mPort) { + aString.Append(':'); + aString.Append(mPort, 10); + } + } + aString.Append(mFile); + if (nsnull != mRef) { + aString.Append('#'); + aString.Append(mRef); + } + if (nsnull != mSearch) { + aString.Append('?'); + aString.Append(mSearch); + } + } + NS_UNLOCK_INSTANCE(); + *unichars = aString.ToNewUnicode(); return NS_OK; } diff --git a/mozilla/network/module/nsHttpUrl.h b/mozilla/network/module/nsHttpUrl.h new file mode 100644 index 00000000000..c8869acfcc8 --- /dev/null +++ b/mozilla/network/module/nsHttpUrl.h @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; 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. + */ + +#ifndef nsHttpUrl_h__ +#define nsHttpUrl_h__ + +#include "nsIURL.h" +#include "nsINetlibURL.h" +#include "nsIHttpURL.h" +#include "nsIPostToServer.h" + +class nsHttpUrlImpl : public nsIURL, public nsINetlibURL, public nsIHttpURL, + public nsIPostToServer // XXX for now +{ +public: + // from nsIURL: + + NS_IMETHOD_(PRBool) Equals(const nsIURL *aURL) const; + NS_IMETHOD GetSpec(const char* *result) const; + NS_IMETHOD SetSpec(const char* spec); + NS_IMETHOD GetProtocol(const char* *result) const; + NS_IMETHOD SetProtocol(const char* protocol); + NS_IMETHOD GetHost(const char* *result) const; + NS_IMETHOD SetHost(const char* host); + NS_IMETHOD GetHostPort(PRUint32 *result) const; + NS_IMETHOD SetHostPort(PRUint32 port); + NS_IMETHOD GetFile(const char* *result) const; + NS_IMETHOD SetFile(const char* file); + NS_IMETHOD GetRef(const char* *result) const; + NS_IMETHOD SetRef(const char* ref); + NS_IMETHOD GetSearch(const char* *result) const; + NS_IMETHOD SetSearch(const char* search); + NS_IMETHOD GetContainer(nsISupports* *result) const; + NS_IMETHOD SetContainer(nsISupports* container); + NS_IMETHOD GetLoadAttribs(nsILoadAttribs* *result) const; + NS_IMETHOD SetLoadAttribs(nsILoadAttribs* loadAttribs); + NS_IMETHOD GetURLGroup(nsIURLGroup* *result) const; + NS_IMETHOD SetURLGroup(nsIURLGroup* group); + NS_IMETHOD SetPostHeader(const char* name, const char* value); + NS_IMETHOD SetPostData(nsIInputStream* input); + NS_IMETHOD ToString(PRUnichar* *aString) const; + + // from nsINetlibURL: + + NS_IMETHOD GetURLInfo(URL_Struct_ **aResult) const; + NS_IMETHOD SetURLInfo(URL_Struct_ *URL_s); + + // nsHttpUrlImpl: + + typedef enum { + Send_None, + Send_File, + Send_Data, + Send_DataFromFile + } SendType; + + nsHttpUrlImpl(nsISupports* aContainer, nsIURLGroup* aGroup); + + NS_DECL_ISUPPORTS + + /* nsIPostToServer interface... */ + NS_IMETHOD SendFile(const char *aFile); + NS_IMETHOD SendData(const char *aBuffer, PRUint32 aLength); + NS_IMETHOD SendDataFromFile(const char *aFile); + + /* nsIHttpUrl interface... */ + + /* Handle http-equiv meta tags. */ + NS_IMETHOD AddMimeHeader(const char *name, const char *value); + + nsresult ParseURL(const nsString& aSpec, const nsIURL* aURL = nsnull); + +protected: + virtual ~nsHttpUrlImpl(); + + nsresult PostFile(const char *aFile); + void ReconstructSpec(void); + + /* Here's our link to the netlib world.... */ + URL_Struct *m_URL_s; + + SendType m_PostType; + char *m_PostBuffer; + PRInt32 m_PostBufferLength; + + char* mSpec; + char* mProtocol; + char* mHost; + char* mFile; + char* mRef; + char* mSearch; + PRInt32 mPort; + nsIInputStream* mPostData; + nsISupports* mContainer; + nsILoadAttribs* mLoadAttribs; + nsIURLGroup* mURLGroup; +}; + +#endif // nsHttpUrl_h__ diff --git a/mozilla/network/module/nsIHttpUrl.h b/mozilla/network/module/nsIHttpUrl.h deleted file mode 100644 index 938d73aadd6..00000000000 --- a/mozilla/network/module/nsIHttpUrl.h +++ /dev/null @@ -1,60 +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. - */ - -#ifndef nsIHttpUrl_h___ -#define nsIHttpUrl_h___ - -#include "nscore.h" -#include "nsISupports.h" - -#include "nspr.h" - - - -/* 1A0B6FA1-EA25-11d1-BEAE-00805F8A66DC */ - -#define NS_IHTTPURL_IID \ -{ 0x1a0b6fa1, 0xea25, 0x11d1, \ - { 0xbe, 0xae, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0xdc } } - - -struct nsIHttpUrl : public nsISupports -{ - /** - * Parse the mime header into the url struct. - * This method is intended to be used when an HTML META tag is encoutered - * with the type http-equiv. In this case, the http-equiv header should - * be added to the url in netlib, immediately after the http-equiv meta - * tag is encoutered. - * - * @param shell The shell loading this url. - * @param url The url to parse the mime header into. - * @param name The name of the mime header. - * @param value The value of the mime header. - */ - NS_IMETHOD AddMimeHeader(const char *name, const char *value) = 0; -}; - - - -/** Create a new HttpUrl. */ -extern "C" NS_NET nsresult NS_NewHttpUrl(nsISupports** aInstancePtrResult, - nsISupports* aOuter); - - -#endif /* nsIHttpUrl_h___ */ diff --git a/mozilla/network/module/nsILoadAttribs.h b/mozilla/network/module/nsILoadAttribs.h deleted file mode 100644 index 2463875708f..00000000000 --- a/mozilla/network/module/nsILoadAttribs.h +++ /dev/null @@ -1,84 +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 "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ - -#ifndef nsILoadAttribs_h___ -#define nsILoadAttribs_h___ - -#include "nscore.h" -#include "prtypes.h" -#include "nsISupports.h" - -// Class ID for an implementation of nsILoadAttribs -// {8942D321-48D3-11d2-9E7A-006008BF092E} -#define NS_ILOAD_ATTRIBS_IID \ - { 0x8942d321, 0x48d3, 0x11d2,{0x9e, 0x7a, 0x00, 0x60, 0x08, 0xbf, 0x09, 0x2e}} - -/* - * The nsReloadType represents the following: - * nsURLReload - normal reload (uses cache) - * nsURLReloadBypassCache - bypass the cache - * nsURLReloadBypassCacheAndProxy - bypass the proxy (not yet implemented) - */ -typedef enum { - nsURLReload = 0, - nsURLReloadBypassCache, - nsURLReloadBypassProxy, - nsURLReloadBypassCacheAndProxy, - nsURLReloadMax -} nsURLReloadType; - -/* - * The nsLoadType represents the following: - * nsURLLoadNormal - Load the URL normally. - * nsURLLoadBackground - Supress all notifications when loading the URL. - */ -typedef enum { - nsURLLoadNormal = 0, - nsURLLoadBackground, - nsURLLoadMax -} nsURLLoadType; - -// Defining attributes of a url's load behavior. -class nsILoadAttribs : public nsISupports { -public: - // Copy the state of another nsILoadAttribs instance. - NS_IMETHOD Clone(nsILoadAttribs* aLoadAttribs) = 0; - - // Bypass Proxy. - NS_IMETHOD SetBypassProxy(PRBool aBypass) = 0; - NS_IMETHOD GetBypassProxy(PRBool *aBypass) = 0; - - // Local IP address. - NS_IMETHOD SetLocalIP(const PRUint32 aLocalIP) = 0; - NS_IMETHOD GetLocalIP(PRUint32 *aLocalIP) = 0; - - // Reload method. - NS_IMETHOD SetReloadType(nsURLReloadType aType) = 0; - NS_IMETHOD GetReloadType(nsURLReloadType* aResult) = 0; - - // Load method - NS_IMETHOD SetLoadType(nsURLLoadType aType) = 0; - NS_IMETHOD GetLoadType(nsURLLoadType* aResult) = 0; -}; - -/* Creation routines. */ - -extern NS_NET nsresult NS_NewLoadAttribs(nsILoadAttribs** aInstancePtrResult); - -#endif // nsILoadAttribs_h___ diff --git a/mozilla/network/module/nsINetService.h b/mozilla/network/module/nsINetService.h index e8b8f383d5d..d02a97a4a4d 100644 --- a/mozilla/network/module/nsINetService.h +++ b/mozilla/network/module/nsINetService.h @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 4; 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 @@ -23,11 +23,13 @@ #include "nsISupports.h" #include "nsIURL.h" #include "nsIStreamListener.h" - #ifdef SingleSignon #include "lo_ele.h" #endif +class nsIProtocolURLFactory; +class nsIProtocol; + /* XXX: This should be moved to ns/xpcom/src/nserror.h */ #define NS_OK 0 #define NS_FALSE 1 @@ -207,6 +209,25 @@ struct nsINetService : public nsISupports * @return Returns NS_OK if successful, or NS_FALSE if an error occurred. */ NS_IMETHOD SetCustomUserAgent(nsString aCustom)=0; + + // Managing pluggable protocols: + + NS_IMETHOD RegisterProtocol(const nsString& aName, + nsIProtocolURLFactory* aProtocolURLFactory, + nsIProtocol* aProtocol) = 0; + + NS_IMETHOD UnregisterProtocol(const nsString& aName) = 0; + + NS_IMETHOD GetProtocol(const nsString& aName, + nsIProtocolURLFactory* *aProtocolURLFactory, + nsIProtocol* *aProtocol) = 0; + + NS_IMETHOD CreateURL(nsIURL* *aURLResult, + const nsString& aSpec, + const nsIURL* aContextURL = nsnull, + nsISupports* aContainer = nsnull, + nsIURLGroup* aGroup = nsnull) = 0; + }; diff --git a/mozilla/network/module/nsINetlibURL.h b/mozilla/network/module/nsINetlibURL.h new file mode 100644 index 00000000000..f8fe9b4f29b --- /dev/null +++ b/mozilla/network/module/nsINetlibURL.h @@ -0,0 +1,49 @@ +/* -*- 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. + */ + +#ifndef nsINetlibURL_h___ +#define nsINetlibURL_h___ + +#include "nsIURL.h" +#include "net.h" + +/* forward declaration */ +struct URL_Struct_; + +#define NS_INETLIBURL_IID \ +{ /* bcf62ef0-3267-11d2-8163-006008119d7a */ \ + 0xbcf62ef0, \ + 0x3267, \ + 0x11d2, \ + {0x81, 0x63, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \ +} + +/** + * The nsINetlibURL interface provides browser-private access to URL + * internals and integration with netlib without exposing the + * implementation. + */ +class nsINetlibURL : public nsISupports { +public: + + NS_IMETHOD GetURLInfo(URL_Struct_ **aResult) const = 0; + NS_IMETHOD SetURLInfo(URL_Struct_ *URL_s) = 0; + +}; + +#endif /* nsINetlibURL_h___ */ diff --git a/mozilla/network/module/nsIPostToServer.h b/mozilla/network/module/nsIProtocol.h similarity index 51% rename from mozilla/network/module/nsIPostToServer.h rename to mozilla/network/module/nsIProtocol.h index 50e7756a8cd..9cb866fb288 100644 --- a/mozilla/network/module/nsIPostToServer.h +++ b/mozilla/network/module/nsIProtocol.h @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- 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 @@ -16,30 +16,27 @@ * Reserved. */ -#ifndef nsIPostToServer_h___ -#define nsIPostToServer_h___ +#ifndef nsIProtocol_h___ +#define nsIProtocol_h___ -#include "nscore.h" #include "nsISupports.h" +#include "nscore.h" -#include "nspr.h" +#define NS_IPROTOCOL_IID \ +{ /* 677d9a90-93ee-11d2-816a-006008119d7a */ \ + 0x677d9a90, \ + 0x93ee, \ + 0x11d2, \ + {0x81, 0x6a, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \ +} - -/* EADF7B41-EBC0-11d1-BEAE-00805F8A66DC */ -#define NS_IPOSTTOSERVER_IID \ -{ 0xeadf7b41, 0xebc0, 0x11d1, \ - { 0xbe, 0xae, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0xdc } } - - - -struct nsIPostToServer : public nsISupports +class nsIProtocol : public nsISupports { - NS_IMETHOD SendFile(const char *aFile) = 0; - NS_IMETHOD SendData(const char *aBuffer, PRInt32 aLength) = 0; - NS_IMETHOD SendDataFromFile(const char *aFile) = 0; +public: + + // XXX Other methods will follow when we work out pluggable protocols, + // but for now, this is just a means to parse and construct URL objects. + }; -#define NS_IPOSTTOSERVER_ALREADY_POSTING 1 - - -#endif /* nsIPostToServer_h___ */ +#endif /* nsIIProtocol_h___ */ diff --git a/mozilla/network/module/nsIProtocolURLFactory.h b/mozilla/network/module/nsIProtocolURLFactory.h new file mode 100644 index 00000000000..2ad4a118425 --- /dev/null +++ b/mozilla/network/module/nsIProtocolURLFactory.h @@ -0,0 +1,57 @@ +/* -*- 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. + */ + +#ifndef nsIProtocolURLFactory_h___ +#define nsIProtocolURLFactory_h___ + +#include "nsISupports.h" +#include "nscore.h" + +class nsString; +class nsIURL; +class nsIURLGroup; + +#define NS_IPROTOCOLURLFACTORY_IID \ +{ /* aed57ad0-705e-11d2-8166-006008119d7a */ \ + 0xaed57ad0, \ + 0x705e, \ + 0x11d2, \ + {0x81, 0x66, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \ +} + +/** + * nsIProtocolURLFactory deals with protocol-specific URL parsing. It + * constructs a URL that implements the nsIURL interface and that gets + * loaded by a corresponding protocol handler. + * + * Note that one nsIProtocolURLFactory implementation might handle the + * URL syntax for several different protocols, e.g. http, https, file -- + * all of these protocol's URL syntax looks the same. + */ +class nsIProtocolURLFactory : public nsISupports +{ +public: + + NS_IMETHOD CreateURL(nsIURL* *aResult, + const nsString& aSpec, + const nsIURL* aContextURL = nsnull, + nsISupports* aContainer = nsnull, + nsIURLGroup* aGroup = nsnull) = 0; +}; + +#endif /* nsIIProtocolURLFactory_h___ */ diff --git a/mozilla/network/module/nsIStreamListener.h b/mozilla/network/module/nsIStreamListener.h deleted file mode 100644 index fd64f0baff2..00000000000 --- a/mozilla/network/module/nsIStreamListener.h +++ /dev/null @@ -1,121 +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. - */ - -#ifndef nsIStreamListener_h___ -#define nsIStreamListener_h___ - -#include "prtypes.h" -#include "nsISupports.h" - -/* forward declaration */ -class nsIInputStream; -class nsString; -class nsIURL; - - -/* 97566110-ff60-11d1-beb9-00805f8a66dc */ -#define NS_ISTREAMOBSERVER_IID \ -{ 0x97566110, 0xff60, 0x11d1, \ - {0xbe, 0xb9, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc} } - - -class nsIStreamObserver : public nsISupports { -public: - /** - * Notify the observer that the URL has started to load. This method is - * called only once, at the beginning of a URL load.

- * - * @return The return value is currently ignored. In the future it may be - * used to cancel the URL load.. - */ - NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType) = 0; - - /** - * Notify the observer that progress as occurred for the URL load.
- */ - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) = 0; - - /** - * Notify the observer with a status message for the URL load.
- */ - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg) = 0; - - /** - * Notify the observer that the URL has finished loading. This method is - * called once when the networking library has finished processing the - * URL transaction initiatied via the nsINetService::Open(...) call.

- * - * This method is called regardless of whether the URL loaded successfully.

- * - * @param status Status code for the URL load. - * @param msg A text string describing the error. - * @return The return value is currently ignored. - */ - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg) = 0; -}; - -/* Generic status codes for OnStopBinding */ -#define NS_BINDING_SUCCEEDED NS_OK -#define NS_BINDING_FAILED ((nsresult)-1) -#define NS_BINDING_ABORTED ((nsresult)-2) - - - - - -/* 45d234d0-c6c9-11d1-bea2-00805f8a66dc */ -#define NS_ISTREAMLISTENER_IID \ -{ 0x45d234d0, 0xc6c9, 0x11d1, \ - {0xbe, 0xa2, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc} } - -/** - * The nsIStreamListener interface provides the necessary notifications - * during both synchronous and asynchronous URL loading. - * This is a preliminary interface which will change over time! - *

- * An instance of this interface is passed to nsINetService::Open(...) to - * allow the client to receive status and notifications during the loading - * of the URL. - *

- * Over time this interface will provide the same functionality as the - * IBindStatusCallback interface in the MS INET-SDK... - */ -class nsIStreamListener : public nsIStreamObserver { -public: - /** - * Return information regarding the current URL load.
- * - * This method is currently not called. - */ - NS_IMETHOD GetBindInfo(nsIURL* aURL) = 0; - - /** - * Notify the client that data is available in the input stream. This - * method is called whenver data is written into the input stream by the - * networking library...

- * - * @param pIStream The input stream containing the data. This stream can - * be either a blocking or non-blocking stream. - * @param length The amount of data that was just pushed into the stream. - * @return The return value is currently ignored. - */ - NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, - PRInt32 aLength) = 0; -}; - -#endif /* nsIStreamListener_h___ */ diff --git a/mozilla/network/module/nsIURL.h b/mozilla/network/module/nsIURL.h deleted file mode 100644 index 76f1d70df80..00000000000 --- a/mozilla/network/module/nsIURL.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- 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. - */ -#ifndef nsIURL_h___ -#define nsIURL_h___ - -#include "nscore.h" -#include "nsISupports.h" -#include "nsILoadAttribs.h" - -class nsIInputStream; -class nsIStreamListener; -class nsString; -class nsIURLGroup; - -#define NS_IURL_IID \ -{ 0x6ecb2900, 0x93b5, 0x11d1, \ - {0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} } - -/** - * TEMPORARY INTERFACE; this will will be - * going away - */ -class nsIURL : public nsISupports { -public: - /** Open the url for reading and return a new input stream for the - * url. The caller must release the input stream when done with it. - */ - virtual nsIInputStream* Open(PRInt32* aErrorCode) = 0; - virtual nsresult Open(nsIStreamListener *) = 0; - - /** Equality operator */ - virtual PRBool operator==(const nsIURL& aURL) const = 0; - - - virtual nsresult Set(const char *aNewSpec) = 0; - - virtual nsresult SetLoadAttribs(nsILoadAttribs *aLoadAttrib) = 0; - - /** Accessors */ - //@{ - /** - @return protocol part of the URL */ - virtual const char* GetProtocol() const = 0; - - /** @return host part of the URL */ - virtual const char* GetHost() const = 0; - - /** @return file part of the URL */ - virtual const char* GetFile() const = 0; - - /** @return ref part of the URL */ - virtual const char* GetRef() const = 0; - - /** @return search part of the URL */ - virtual const char* GetSearch() const = 0; - - /** @return string originally used to construct the URL */ - virtual const char* GetSpec() const = 0; - - /** @return ref part of the URL */ - virtual PRInt32 GetPort() const = 0; - - /** @return the nsISupports pointer to a container */ - virtual nsISupports* GetContainer() const = 0; - - /** @return the loadAttributes pointer */ - virtual nsILoadAttribs* GetLoadAttribs() const = 0; - - /** @return the nsIURLGroup associated with the URL (if any) */ - virtual nsIURLGroup* GetURLGroup() const = 0; - //@} - - /** Write the URL to aString, overwriting previous contents. */ - virtual void ToString(nsString& aString) const = 0; -}; - -/** Create a new URL from aSpec. */ -extern NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult, - const nsString& aSpec); - -/** Create a new URL, interpreting aSpec as relative to aURL (if non-null). */ -extern NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult, - const nsIURL* aURL, - const nsString& aSpec, - nsISupports* container = nsnull, - nsIURLGroup* aGroup = nsnull); - -/** - * Utility routine to take a url (may be nsnull) and a base url (may - * be empty), and a url spec and combine them properly into a new - * absolute url. - */ -extern NS_NET nsresult NS_MakeAbsoluteURL(nsIURL* aURL, - const nsString& aBaseURL, - const nsString& aSpec, - nsString& aResult); - -#endif /* nsIURL_h___ */ diff --git a/mozilla/network/module/nsIURLGroup.h b/mozilla/network/module/nsIURLGroup.h index 4db405df8cf..c9b7280886a 100644 --- a/mozilla/network/module/nsIURLGroup.h +++ b/mozilla/network/module/nsIURLGroup.h @@ -28,13 +28,11 @@ class nsIInputStream; class nsIStreamListener; class nsILoadAttribs; - /* {a4071430-5263-11d2-929b-00105a1b0d64} */ #define NS_IURLGROUP_IID \ { 0xa4071430, 0x5263, 0x11d2, \ {0x92, 0x9b, 0x00, 0x10, 0x5a, 0x1b, 0x0d, 0x64} } - class nsIURLGroup : public nsISupports { public: diff --git a/mozilla/network/module/nsNetService.cpp b/mozilla/network/module/nsNetService.cpp index f18e81791ab..9b76be01c82 100644 --- a/mozilla/network/module/nsNetService.cpp +++ b/mozilla/network/module/nsNetService.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "License"); you may not use this file except in @@ -38,7 +38,12 @@ extern "C" { #include "plstr.h" #include "nsString.h" +#include "nsINetlibURL.h" #include "nsIProtocolConnection.h" +#include "nsIProtocolURLFactory.h" +#include "nsIProtocol.h" +#include "nsIServiceManager.h" +#include "nsCRT.h" #ifdef XP_PC #include @@ -113,7 +118,7 @@ extern const char *XP_AppPlatform; } /* end of extern "C" */ -static NS_DEFINE_IID(kIProtocolConnectionIID, NS_IPROTOCOLCONNECTION_IID); +static NS_DEFINE_IID(kINetlibURLIID, NS_INETLIBURL_IID); nsNetlibService::nsNetlibService() @@ -184,10 +189,13 @@ nsNetlibService::nsNetlibService() if (XP_AppVersion) PR_Free((char *)XP_AppVersion); XP_AppVersion = PL_strdup(buf); + + mProtocols = new nsHashtable(); + PR_ASSERT(mProtocols); } -NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID); +static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID); NS_IMPL_THREADSAFE_ISUPPORTS(nsNetlibService,kINetServiceIID); @@ -208,6 +216,8 @@ nsNetlibService::~nsNetlibService() mNetlibThread->Stop(); delete mNetlibThread; } + + delete mProtocols; } @@ -215,7 +225,8 @@ nsNetlibService::~nsNetlibService() void nsNetlibService::SetupURLStruct(nsIURL *aUrl, URL_Struct *aURL_s) { nsresult rv; - nsILoadAttribs* loadAttribs = aUrl->GetLoadAttribs(); + nsILoadAttribs* loadAttribs; + rv = aUrl->GetLoadAttribs(&loadAttribs); /* If this url has load attributes, setup the underlying url struct @@ -276,12 +287,12 @@ void nsNetlibService::SetupURLStruct(nsIURL *aUrl, URL_Struct *aURL_s) } } -nsresult nsNetlibService::OpenStream(nsIURL *aUrl, +nsresult nsNetlibService::OpenStream(nsIURL *aUrl, nsIStreamListener *aConsumer) { URL_Struct *URL_s; nsConnectionInfo *pConn; - nsIProtocolConnection *pProtocol; + nsINetlibURL *netlibURL; nsresult result; nsIStreamListener* consumer; @@ -308,17 +319,25 @@ nsresult nsNetlibService::OpenStream(nsIURL *aUrl, /* * XXX: Rewrite the resource: URL into a file: URL */ - if (PL_strcmp(aUrl->GetProtocol(), "resource") == 0) { + const char* protocol; + result = aUrl->GetProtocol(&protocol); + NS_ASSERTION(result == NS_OK, "deal with this"); + if (PL_strcmp(protocol, "resource") == 0) { char* fileName; - - fileName = mangleResourceIntoFileURL(aUrl->GetFile()); - aUrl->Set(fileName); + const char* file; + result = aUrl->GetFile(&file); + NS_ASSERTION(result == NS_OK, "deal with this"); + fileName = mangleResourceIntoFileURL(file); + aUrl->SetSpec(fileName); PR_Free(fileName); } /* Create the URLStruct... */ - URL_s = NET_CreateURLStruct(aUrl->GetSpec(), NET_NORMAL_RELOAD); + const char* spec = NULL; + result = aUrl->GetSpec(&spec); + NS_ASSERTION(result == NS_OK, "deal with this"); + URL_s = NET_CreateURLStruct(spec, NET_NORMAL_RELOAD); if (NULL == URL_s) { NS_RELEASE(pConn); return NS_FALSE; @@ -342,10 +361,10 @@ nsresult nsNetlibService::OpenStream(nsIURL *aUrl, * XXX: Currently the return value form InitializeURLInfo(...) is * ignored... Should the connection abort if it fails? */ - result = aUrl->QueryInterface(kIProtocolConnectionIID, (void**)&pProtocol); + result = aUrl->QueryInterface(kINetlibURLIID, (void**)&netlibURL); if (NS_OK == result) { - pProtocol->InitializeURLInfo(URL_s); - NS_RELEASE(pProtocol); + netlibURL->SetURLInfo(URL_s); + NS_RELEASE(netlibURL); } /* Create a new Context and set its reference count to one.. */ @@ -375,13 +394,13 @@ nsresult nsNetlibService::OpenStream(nsIURL *aUrl, nsresult nsNetlibService::OpenBlockingStream(nsIURL *aUrl, - nsIStreamListener *aConsumer, - nsIInputStream **aNewStream) + nsIStreamListener *aConsumer, + nsIInputStream **aNewStream) { URL_Struct *URL_s; nsConnectionInfo *pConn; nsNetlibStream *pBlockingStream; - nsIProtocolConnection *pProtocol; + nsINetlibURL *netlibURL; nsIStreamListener* consumer = nsnull; nsresult result; @@ -424,17 +443,25 @@ nsresult nsNetlibService::OpenBlockingStream(nsIURL *aUrl, /* * XXX: Rewrite the resource: URL into a file: URL */ - if (PL_strcmp(aUrl->GetProtocol(), "resource") == 0) { + const char* protocol; + result = aUrl->GetProtocol(&protocol); + NS_ASSERTION(result == NS_OK, "deal with this"); + if (PL_strcmp(protocol, "resource") == 0) { char* fileName; - - fileName = mangleResourceIntoFileURL(aUrl->GetFile()); - aUrl->Set(fileName); + const char* file; + result = aUrl->GetFile(&file); + NS_ASSERTION(result == NS_OK, "deal with this"); + fileName = mangleResourceIntoFileURL(file); + aUrl->SetSpec(fileName); PR_Free(fileName); } /* Create the URLStruct... */ - URL_s = NET_CreateURLStruct(aUrl->GetSpec(), NET_NORMAL_RELOAD); + const char* spec = NULL; + result = aUrl->GetSpec(&spec); + NS_ASSERTION(result == NS_OK, "deal with this"); + URL_s = NET_CreateURLStruct(spec, NET_NORMAL_RELOAD); if (NULL == URL_s) { NS_RELEASE(pBlockingStream); NS_RELEASE(pConn); @@ -474,10 +501,10 @@ nsresult nsNetlibService::OpenBlockingStream(nsIURL *aUrl, * XXX: Currently the return value form InitializeURLInfo(...) is * ignored... Should the connection abort if it fails? */ - result = aUrl->QueryInterface(kIProtocolConnectionIID, (void**)&pProtocol); + result = aUrl->QueryInterface(kINetlibURLIID, (void**)&netlibURL); if (NS_OK == result) { - pProtocol->InitializeURLInfo(URL_s); - NS_RELEASE(pProtocol); + netlibURL->SetURLInfo(URL_s); + NS_RELEASE(netlibURL); } /* printf("+++ Loading %s\n", aUrl); */ @@ -514,6 +541,8 @@ loser: return NS_FALSE; } +static NS_DEFINE_IID(kIProtocolConnectionIID, NS_IPROTOCOLCONNECTION_IID); + NS_IMETHODIMP nsNetlibService::InterruptStream(nsIURL* aURL) { @@ -552,7 +581,9 @@ nsNetlibService::GetCookieString(nsIURL *aURL, nsString& aCookie) // XXX How safe is it to create a stub context without a URL_Struct? MWContext *stubContext = new_stub_context(nsnull); - const char *spec = aURL->GetSpec(); + const char *spec = NULL; + nsresult result = aURL->GetSpec(&spec); + NS_ASSERTION(result == NS_OK, "deal with this"); char *cookie = NET_GetCookie(stubContext, (char *)spec); if (nsnull != cookie) { @@ -573,7 +604,9 @@ nsNetlibService::SetCookieString(nsIURL *aURL, const nsString& aCookie) // XXX How safe is it to create a stub context without a URL_Struct? MWContext *stubContext = new_stub_context(nsnull); - const char *spec = aURL->GetSpec(); + const char *spec = NULL; + nsresult result = aURL->GetSpec(&spec); + NS_ASSERTION(result == NS_OK, "deal with this"); char *cookie = aCookie.ToNewCString(); NET_SetCookieString(stubContext, (char *)spec, cookie); @@ -733,6 +766,7 @@ NS_IMETHODIMP nsNetlibService::SetCustomUserAgent(nsString aCustom) { PRInt32 inIdx; + PRUnichar junkChar = '['; // damn emacs PRUnichar inChar = ']'; if (!XP_AppVersion || (0 >= aCustom.Length()) ) @@ -751,6 +785,217 @@ nsNetlibService::SetCustomUserAgent(nsString aCustom) } +//////////////////////////////////////////////////////////////////////////////// + +class nsStringHashKey : public nsHashKey +{ +public: + nsStringHashKey(const nsString& aName) + : mName(aName) + { + } + + virtual ~nsStringHashKey(void) + { + } + + virtual PRUint32 HashValue(void) const; + virtual PRBool Equals(const nsHashKey *aKey) const; + virtual nsHashKey *Clone(void) const; + +protected: + const nsString& mName; +}; + +PRUint32 nsStringHashKey::HashValue(void) const +{ + return nsCRT::HashValue(mName); +} + +PRBool nsStringHashKey::Equals(const nsHashKey *aKey) const +{ + const nsStringHashKey* other = (const nsStringHashKey*)aKey; + return mName.EqualsIgnoreCase(other->mName); +} + +nsHashKey *nsStringHashKey::Clone(void) const +{ + return new nsStringHashKey(mName); +} + +struct nsProtocolPair { + nsIProtocolURLFactory* mProtocolURLFactory; + nsIProtocol* mProtocol; +}; + +NS_IMETHODIMP +nsNetlibService::RegisterProtocol(const nsString& aName, + nsIProtocolURLFactory* aProtocolURLFactory, + nsIProtocol* aProtocol) +{ + nsStringHashKey* key = new nsStringHashKey(aName); + if (key == NULL) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(aProtocolURLFactory); + NS_IF_ADDREF(aProtocol); // XXX remove IF + nsProtocolPair* pair = new nsProtocolPair; + if (pair == NULL) { + delete key; + return NS_ERROR_OUT_OF_MEMORY; + } + pair->mProtocolURLFactory = aProtocolURLFactory; + pair->mProtocol = aProtocol; + void* result = mProtocols->Put(key, pair); + return NS_OK; +} + +NS_IMETHODIMP +nsNetlibService::UnregisterProtocol(const nsString& aName) +{ + nsStringHashKey key(aName); + nsProtocolPair* pair = (nsProtocolPair*)mProtocols->Remove(&key); + NS_RELEASE(pair->mProtocolURLFactory); + NS_IF_RELEASE(pair->mProtocol); // XXX remove IF + delete pair; + return NS_OK; +} + +NS_IMETHODIMP +nsNetlibService::GetProtocol(const nsString& aName, + nsIProtocolURLFactory* *aProtocolURLFactory, + nsIProtocol* *aProtocol) +{ + nsStringHashKey key(aName); + nsProtocolPair* pair = (nsProtocolPair*)mProtocols->Get(&key); + if (pair == NULL) + return NS_ERROR_FAILURE; + if (aProtocolURLFactory) + *aProtocolURLFactory = pair->mProtocolURLFactory; + if (aProtocol) + *aProtocol = pair->mProtocol; + return NS_OK; +} + +NS_IMETHODIMP +nsNetlibService::CreateURL(nsIURL* *aURL, + const nsString& aSpec, + const nsIURL* aContextURL, + nsISupports* aContainer, + nsIURLGroup* aGroup) +{ + nsAutoString protoName; + PRInt32 pos = aSpec.Find(':'); + if (pos >= 0) { + aSpec.Left(protoName, pos); + } + else if (aContextURL) { + const char* str; + aContextURL->GetProtocol(&str); + protoName = str; + } + else { + protoName = "http"; + } + nsIProtocolURLFactory* protocolURLFactory; + nsresult err = GetProtocol(protoName, &protocolURLFactory, NULL); + if (err != NS_OK) return err; + + return protocolURLFactory->CreateURL(aURL, aSpec, aContextURL, aContainer, aGroup); +} + +static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID); + +NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult, + const nsString& aSpec, + const nsIURL* aURL, + nsISupports* aContainer, + nsIURLGroup* aGroup) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + + nsINetService *inet = nsnull; + nsresult rv = nsServiceManager::GetService(kNetServiceCID, + kINetServiceIID, + (nsISupports **)&inet); + if (rv != NS_OK) return rv; + + rv = inet->CreateURL(aInstancePtrResult, aSpec, aURL, aContainer, aGroup); + + nsServiceManager::ReleaseService(kNetServiceCID, inet); + return rv; +} + +NS_NET nsresult NS_MakeAbsoluteURL(nsIURL* aURL, + const nsString& aBaseURL, + const nsString& aSpec, + nsString& aResult) +{ + nsString* string; + nsIURL* base = nsnull; + if (0 < aBaseURL.Length()) { + nsresult err = NS_NewURL(&base, aBaseURL); + if (err != NS_OK) return err; + } + else { + const char* str; + aURL->GetSpec(&str); + nsresult err = NS_NewURL(&base, str); + if (err != NS_OK) return err; + } + nsIURL* url = nsnull; + nsresult err = NS_NewURL(&url, aSpec, base); + if (err != NS_OK) goto done; + + PRUnichar* str; + err = url->ToString(&str); + if (err) goto done; + string = new nsString(str); + delete str; + if (string == NULL) + err = NS_ERROR_OUT_OF_MEMORY; + else + aResult = *string; + + done: + NS_IF_RELEASE(url); + NS_IF_RELEASE(base); + return err; +} + +NS_NET nsresult NS_OpenURL(nsIURL* aURL, nsIStreamListener* aConsumer) +{ + nsINetService *inet = nsnull; + nsresult rv = nsServiceManager::GetService(kNetServiceCID, + kINetServiceIID, + (nsISupports **)&inet); + if (rv != NS_OK) return rv; + + rv = inet->OpenStream(aURL, aConsumer); + + nsServiceManager::ReleaseService(kNetServiceCID, inet); + return rv; +} + +NS_NET nsresult NS_OpenURL(nsIURL* aURL, nsIInputStream* *aNewStream, + nsIStreamListener* aConsumer) +{ + nsINetService *inet = nsnull; + nsresult rv = nsServiceManager::GetService(kNetServiceCID, + kINetServiceIID, + (nsISupports **)&inet); + if (rv != NS_OK) return rv; + + rv = inet->OpenBlockingStream(aURL, aConsumer, aNewStream); + + nsServiceManager::ReleaseService(kNetServiceCID, inet); + return rv; +} + +//////////////////////////////////////////////////////////////////////////////// + void nsNetlibService::SchedulePollingTimer() { #if !defined(NETLIB_THREAD) @@ -900,6 +1145,9 @@ NS_NET nsresult NS_NewINetService(nsINetService** aInstancePtrResult, return gNetlibService->QueryInterface(kINetServiceIID, (void**)aInstancePtrResult); } +extern "C" NS_NET nsresult +NS_InitializeHttpURLFactory(nsINetService* inet); + NS_NET nsresult NS_InitINetService() { /* XXX: For now only allow a single instance of the Netlib Service */ @@ -908,6 +1156,8 @@ NS_NET nsresult NS_InitINetService() if (nsnull == gNetlibService) { return NS_ERROR_OUT_OF_MEMORY; } + // XXX temporarily, until we have pluggable protocols... + NS_InitializeHttpURLFactory(gNetlibService); } NS_ADDREF(gNetlibService); diff --git a/mozilla/network/module/nsNetService.h b/mozilla/network/module/nsNetService.h index 1cb117c90e2..c8ea384918f 100644 --- a/mozilla/network/module/nsNetService.h +++ b/mozilla/network/module/nsNetService.h @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "License"); you may not use this file except in @@ -25,6 +25,7 @@ #include "nsIPref.h" #include "nsINetService.h" #include "nsNetThread.h" +#include "nsHashtable.h" #include "net.h" class nsITimer; @@ -37,7 +38,8 @@ public: nsNetlibService(); /* Implementation of the nsINetService interface */ - NS_IMETHOD OpenStream(nsIURL *aUrl, nsIStreamListener *aConsumer); + NS_IMETHOD OpenStream(nsIURL *aUrl, + nsIStreamListener *aConsumer); NS_IMETHOD OpenBlockingStream(nsIURL *aUrl, nsIStreamListener *aConsumer, nsIInputStream **aNewStream); @@ -66,6 +68,18 @@ public: NS_IMETHOD GetPlatform(nsString& aPlatform); NS_IMETHOD GetUserAgent(nsString& aUA); NS_IMETHOD SetCustomUserAgent(nsString aCustom); + NS_IMETHOD RegisterProtocol(const nsString& aName, + nsIProtocolURLFactory* aProtocolURLFactory, + nsIProtocol* aProtocol); + NS_IMETHOD UnregisterProtocol(const nsString& aName); + NS_IMETHOD GetProtocol(const nsString& aName, + nsIProtocolURLFactory* *aProtocolURLFactory, + nsIProtocol* *aProtocol); + NS_IMETHOD CreateURL(nsIURL* *aURL, + const nsString& aSpec, + const nsIURL* aContextURL = nsnull, + nsISupports* aContainer = nsnull, + nsIURLGroup* aGroup = nsnull); protected: virtual ~nsNetlibService(); @@ -90,6 +104,8 @@ private: nsITimer* mPollingTimer; nsNetlibThread* mNetlibThread; + + nsHashtable* mProtocols; }; diff --git a/mozilla/network/module/nsNetStream.cpp b/mozilla/network/module/nsNetStream.cpp index 75a1fb0494d..c3c7dc24805 100644 --- a/mozilla/network/module/nsNetStream.cpp +++ b/mozilla/network/module/nsNetStream.cpp @@ -208,24 +208,27 @@ nsBufferedStream::~nsBufferedStream() } -PRInt32 nsBufferedStream::GetAvailableSpace(PRInt32 *aErrorCode) +nsresult nsBufferedStream::GetAvailableSpace(PRUint32 *aCount) { - PRInt32 size = 0; + nsresult err; + PRUint32 size = 0; if (m_bIsClosed) { - *aErrorCode = NS_BASE_STREAM_EOF; + err = NS_BASE_STREAM_EOF; } else { - *aErrorCode = NS_OK; + err = NS_OK; LockStream(); + NS_ASSERTION(m_BufferLength >= m_WriteOffset, "unsigned madness"); size = m_BufferLength - m_WriteOffset; UnlockStream(); } - return size; + *aCount = size; + return err; } -nsresult nsBufferedStream::GetLength(PRInt32 *aLength) +nsresult nsBufferedStream::GetLength(PRUint32 *aLength) { LockStream(); *aLength = m_WriteOffset; @@ -236,11 +239,11 @@ nsresult nsBufferedStream::GetLength(PRInt32 *aLength) nsresult nsBufferedStream::Write(const char *aBuf, - PRInt32 aOffset, - PRInt32 aLen, - PRInt32 *aWriteCount) + PRUint32 aOffset, + PRUint32 aLen, + PRUint32 *aWriteCount) { - PRInt32 bytesFree; + PRUint32 bytesFree; nsresult rv = NS_OK; LockStream(); @@ -259,6 +262,7 @@ nsresult nsBufferedStream::Write(const char *aBuf, if (!m_bIsClosed && aBuf) { /* Grow the buffer if necessary */ + NS_ASSERTION(m_BufferLength >= m_WriteOffset, "unsigned madness"); bytesFree = m_BufferLength - m_WriteOffset; if (aLen > bytesFree) { char *newBuffer; @@ -298,9 +302,9 @@ done: nsresult nsBufferedStream::Read(char *aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount) + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount) { nsresult rv = NS_OK; @@ -346,7 +350,7 @@ done: return rv; } -nsAsyncStream::nsAsyncStream(PRInt32 buffer_size) +nsAsyncStream::nsAsyncStream(PRUint32 buffer_size) { m_BufferLength = buffer_size; @@ -373,24 +377,26 @@ nsAsyncStream::~nsAsyncStream() } -PRInt32 nsAsyncStream::GetAvailableSpace(PRInt32 *aErrorCode) +nsresult nsAsyncStream::GetAvailableSpace(PRUint32 *aCount) { + nsresult err; PRInt32 size = 0; if (m_bIsClosed) { - *aErrorCode = NS_BASE_STREAM_EOF; + err = NS_BASE_STREAM_EOF; } else { - *aErrorCode = NS_OK; + err = NS_OK; LockStream(); size = m_BufferLength - m_DataLength; UnlockStream(); } - return size; + *aCount = size; + return err; } -nsresult nsAsyncStream::GetLength(PRInt32 *aLength) +nsresult nsAsyncStream::GetLength(PRUint32 *aLength) { LockStream(); *aLength = m_DataLength; @@ -401,11 +407,11 @@ nsresult nsAsyncStream::GetLength(PRInt32 *aLength) nsresult nsAsyncStream::Write(const char *aBuf, - PRInt32 aOffset, - PRInt32 aLen, - PRInt32 *aWriteCount) + PRUint32 aOffset, + PRUint32 aLen, + PRUint32 *aWriteCount) { - PRInt32 bytesFree; + PRUint32 bytesFree; nsresult rv = NS_OK; LockStream(); @@ -428,6 +434,7 @@ nsresult nsAsyncStream::Write(const char *aBuf, } /* Do not store more data than there is space for... */ + NS_ASSERTION(m_BufferLength >= m_DataLength, "unsigned madness"); bytesFree = m_BufferLength - m_DataLength; if (aLen > bytesFree) { aLen = bytesFree; @@ -461,9 +468,9 @@ done: nsresult nsAsyncStream::Read(char *aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount) + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount) { nsresult rv = NS_OK; @@ -571,24 +578,26 @@ nsresult nsBlockingStream::Close() return NS_OK; } -PRInt32 nsBlockingStream::GetAvailableSpace(PRInt32 *aErrorCode) +nsresult nsBlockingStream::GetAvailableSpace(PRUint32 *aCount) { + nsresult err; PRInt32 size = 0; if (m_bIsClosed) { - *aErrorCode = NS_BASE_STREAM_EOF; + err = NS_BASE_STREAM_EOF; } else { - *aErrorCode = NS_OK; + err = NS_OK; LockStream(); size = m_BufferLength - m_DataLength; UnlockStream(); } - return size; + *aCount = size; + return err; } -nsresult nsBlockingStream::GetLength(PRInt32 *aLength) +nsresult nsBlockingStream::GetLength(PRUint32 *aLength) { LockStream(); *aLength = m_DataLength; @@ -599,11 +608,11 @@ nsresult nsBlockingStream::GetLength(PRInt32 *aLength) nsresult nsBlockingStream::Write(const char *aBuf, - PRInt32 aOffset, - PRInt32 aLen, - PRInt32 *aWriteCount) + PRUint32 aOffset, + PRUint32 aLen, + PRUint32 *aWriteCount) { - PRInt32 bytesFree; + PRUint32 bytesFree; nsresult rv = NS_OK; LockStream(); @@ -626,6 +635,7 @@ nsresult nsBlockingStream::Write(const char *aBuf, } /* Do not store more data than there is space for... */ + NS_ASSERTION(m_BufferLength >= m_DataLength, "unsigned madness"); bytesFree = m_BufferLength - m_DataLength; if (aLen > bytesFree) { aLen = bytesFree; @@ -633,9 +643,10 @@ nsresult nsBlockingStream::Write(const char *aBuf, /* Storing the data will cause m_WriteOffset to wrap */ if (m_WriteOffset + aLen > m_BufferLength) { - PRInt32 delta; + PRUint32 delta; /* Store the first chunk through the end of the buffer */ + NS_ASSERTION(m_BufferLength >= m_WriteOffset, "unsigned madness"); delta = m_BufferLength - m_WriteOffset; memcpy(&m_Buffer[m_WriteOffset], aBuf, delta); @@ -664,9 +675,9 @@ done: nsresult nsBlockingStream::Read(char *aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount) + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount) { nsresult rv = NS_OK; @@ -732,9 +743,11 @@ done: } -PRInt32 nsBlockingStream::ReadBuffer(char *aBuf, PRInt32 aCount) +PRInt32 nsBlockingStream::ReadBuffer(char *aBuf, PRUint32 aCount) { - PRInt32 bytesRead = 0; + if (aCount == 0) return 0; /* avoid calling LockStream, memcpy, etc. */ + + PRUint32 bytesRead = 0; LockStream(); diff --git a/mozilla/network/module/nsNetStream.h b/mozilla/network/module/nsNetStream.h index 2373e4609b2..a7e42f33ebb 100644 --- a/mozilla/network/module/nsNetStream.h +++ b/mozilla/network/module/nsNetStream.h @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 4; 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 @@ -72,7 +72,7 @@ public: nsNetlibStream(void); - virtual PRInt32 GetAvailableSpace(PRInt32 *aErrorCode) = 0; + NS_IMETHOD GetAvailableSpace(PRUint32 *aCount) = 0; /* From nsIBaseStream interface */ NS_IMETHOD Close(void); @@ -97,32 +97,32 @@ class nsBufferedStream : public nsNetlibStream { public: nsBufferedStream(void); - virtual PRInt32 GetAvailableSpace(PRInt32 *aErrorCode); + NS_IMETHOD GetAvailableSpace(PRUint32 *aCount); /* nsIInputStream interface */ - NS_IMETHOD GetLength(PRInt32 *aLength); + NS_IMETHOD GetLength(PRUint32 *aLength); NS_IMETHOD Read(char *aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount); + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount); /* nsIOutputStream interface */ NS_IMETHOD Write(const char *aBuf, - PRInt32 aOffset, - PRInt32 aLen, - PRInt32 *aWriteCount); + PRUint32 aOffset, + PRUint32 aLen, + PRUint32 *aWriteCount); protected: virtual ~nsBufferedStream(); private: char *m_Buffer; - PRInt32 m_BufferLength; + PRUint32 m_BufferLength; - PRInt32 m_DataLength; - PRInt32 m_ReadOffset; - PRInt32 m_WriteOffset; + PRUint32 m_DataLength; + PRUint32 m_ReadOffset; + PRUint32 m_WriteOffset; }; @@ -133,34 +133,34 @@ private: class nsAsyncStream : public nsNetlibStream { public: - nsAsyncStream(PRInt32 buffer_size); + nsAsyncStream(PRUint32 buffer_size); - virtual PRInt32 GetAvailableSpace(PRInt32 *aErrorCode); + NS_IMETHOD GetAvailableSpace(PRUint32 *aCount); /* nsIInputStream interface */ - NS_IMETHOD GetLength(PRInt32 *aLength); + NS_IMETHOD GetLength(PRUint32 *aLength); NS_IMETHOD Read(char *aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadLength); + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadLength); /* nsIOutputStream interface */ NS_IMETHOD Write(const char *aBuf, - PRInt32 aOffset, - PRInt32 aLen, - PRInt32 *aWriteLength); + PRUint32 aOffset, + PRUint32 aLen, + PRUint32 *aWriteLength); protected: virtual ~nsAsyncStream(); private: char *m_Buffer; - PRInt32 m_BufferLength; + PRUint32 m_BufferLength; - PRInt32 m_DataLength; - PRInt32 m_ReadOffset; - PRInt32 m_WriteOffset; + PRUint32 m_DataLength; + PRUint32 m_ReadOffset; + PRUint32 m_WriteOffset; }; @@ -172,37 +172,37 @@ class nsBlockingStream : public nsNetlibStream { public: nsBlockingStream(void); - virtual PRInt32 GetAvailableSpace(PRInt32 *aErrorCode); + NS_IMETHOD GetAvailableSpace(PRUint32 *aCount); /* nsIBaseStream interface */ NS_IMETHOD Close(void); /* nsIInputStream interface */ - NS_IMETHOD GetLength(PRInt32 *aLength); + NS_IMETHOD GetLength(PRUint32 *aLength); NS_IMETHOD Read(char *aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadLength); - + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadLength); + /* nsIOutputStream interface */ NS_IMETHOD Write(const char *aBuf, - PRInt32 aOffset, - PRInt32 aLen, - PRInt32 *aWriteLength); - + PRUint32 aOffset, + PRUint32 aLen, + PRUint32 *aWriteLength); + protected: virtual ~nsBlockingStream(); - PRInt32 ReadBuffer(char *aBuf, PRInt32 aCount); + PRInt32 ReadBuffer(char *aBuf, PRUint32 aCount); private: char *m_Buffer; - PRInt32 m_BufferLength; - - PRInt32 m_DataLength; - PRInt32 m_ReadOffset; - PRInt32 m_WriteOffset; + PRUint32 m_BufferLength; + + PRUint32 m_DataLength; + PRUint32 m_ReadOffset; + PRUint32 m_WriteOffset; }; #endif /* net_strm_h___ */ diff --git a/mozilla/network/module/nsNetStubs.cpp b/mozilla/network/module/nsNetStubs.cpp index 5b3c5dfd7b2..484a0ccfeae 100644 --- a/mozilla/network/module/nsNetStubs.cpp +++ b/mozilla/network/module/nsNetStubs.cpp @@ -418,8 +418,8 @@ void FE_SetRefreshURLTimer(MWContext *pContext, URL_Struct *URL_s) if (nsnull != pConn->pURL) { nsISupports* container; - container = pConn->pURL->GetContainer(); - if (nsnull != container) { + rv = pConn->pURL->GetContainer(&container); + if (rv == NS_OK) { rv = container->QueryInterface(kRefreshURLIID, (void**)&IRefreshURL); if(NS_SUCCEEDED(rv)) { nsIURL* newURL; diff --git a/mozilla/network/module/nsNetThread.cpp b/mozilla/network/module/nsNetThread.cpp index 0c184601e73..d4c07953805 100644 --- a/mozilla/network/module/nsNetThread.cpp +++ b/mozilla/network/module/nsNetThread.cpp @@ -47,6 +47,7 @@ extern "C" { #include "netcache.h" #include "cvactive.h" +#include "nsCRT.h" void RL_Init(); @@ -316,12 +317,12 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg); - NS_IMETHOD GetBindInfo(nsIURL* aURL); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* info); NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, - PRInt32 aLength); + PRUint32 aLength); void SetStatus(nsresult aStatus); nsresult GetStatus(); @@ -492,17 +493,17 @@ OnStartBindingProxyEvent::HandleEvent() struct OnProgressProxyEvent : public StreamListenerProxyEvent { OnProgressProxyEvent(nsStreamListenerProxy* aProxy, nsIURL* aURL, - PRInt32 aProgress, PRInt32 aProgressMax); + PRUint32 aProgress, PRUint32 aProgressMax); NS_IMETHOD HandleEvent(); - PRInt32 mProgress; - PRInt32 mProgressMax; + PRUint32 mProgress; + PRUint32 mProgressMax; }; OnProgressProxyEvent::OnProgressProxyEvent(nsStreamListenerProxy* aProxy, nsIURL* aURL, - PRInt32 aProgress, - PRInt32 aProgressMax) + PRUint32 aProgress, + PRUint32 aProgressMax) : StreamListenerProxyEvent(aProxy, aURL) { mProgress = aProgress; @@ -520,24 +521,26 @@ OnProgressProxyEvent::HandleEvent() struct OnStatusProxyEvent : public StreamListenerProxyEvent { OnStatusProxyEvent(nsStreamListenerProxy* aProxy, nsIURL* aURL, - const nsString& aMsg); + const PRUnichar* aMsg); NS_IMETHOD HandleEvent(); - nsString mMsg; + PRUnichar* mMsg; }; OnStatusProxyEvent::OnStatusProxyEvent(nsStreamListenerProxy* aProxy, nsIURL* aURL, - const nsString& aMsg) + const PRUnichar* aMsg) : StreamListenerProxyEvent(aProxy, aURL) { - mMsg = aMsg; + mMsg = nsCRT::strdup(aMsg); } NS_IMETHODIMP OnStatusProxyEvent::HandleEvent() { return mProxy->mRealListener->OnStatus(mURL, mMsg); + delete mMsg; + mMsg = nsnull; } @@ -546,27 +549,29 @@ OnStatusProxyEvent::HandleEvent() struct OnStopBindingProxyEvent : public StreamListenerProxyEvent { OnStopBindingProxyEvent(nsStreamListenerProxy* aProxy, nsIURL* aURL, - PRInt32 aStatus, const nsString& aMsg); + nsresult aStatus, const PRUnichar* aMsg); NS_IMETHOD HandleEvent(); - PRInt32 mStatus; - nsString mMsg; + nsresult mStatus; + PRUnichar* mMsg; }; OnStopBindingProxyEvent::OnStopBindingProxyEvent(nsStreamListenerProxy* aProxy, nsIURL* aURL, - PRInt32 aStatus, - const nsString& aMsg) + nsresult aStatus, + const PRUnichar* aMsg) : StreamListenerProxyEvent(aProxy, aURL) { mStatus = aStatus; - mMsg = aMsg; + mMsg = nsCRT::strdup(aMsg); } NS_IMETHODIMP OnStopBindingProxyEvent::HandleEvent() { return mProxy->mRealListener->OnStopBinding(mURL, mStatus, mMsg); + delete mMsg; + mMsg = nsnull; } @@ -575,18 +580,18 @@ OnStopBindingProxyEvent::HandleEvent() struct OnDataAvailableProxyEvent : public StreamListenerProxyEvent { OnDataAvailableProxyEvent(nsStreamListenerProxy* aProxy, nsIURL* aURL, - nsIInputStream* aStream, PRInt32 aLength); + nsIInputStream* aStream, PRUint32 aLength); virtual ~OnDataAvailableProxyEvent(); NS_IMETHOD HandleEvent(); nsIInputStream* mStream; - PRInt32 mLength; + PRUint32 mLength; }; OnDataAvailableProxyEvent::OnDataAvailableProxyEvent(nsStreamListenerProxy* aProxy, nsIURL* aURL, nsIInputStream* aStream, - PRInt32 aLength) + PRUint32 aLength) : StreamListenerProxyEvent(aProxy, aURL) { mStream = aStream; @@ -668,8 +673,8 @@ nsStreamListenerProxy::OnStartBinding(nsIURL* aURL, const char *aContentType) } NS_IMETHODIMP -nsStreamListenerProxy::OnProgress(nsIURL* aURL, PRInt32 aProgress, - PRInt32 aProgressMax) +nsStreamListenerProxy::OnProgress(nsIURL* aURL, PRUint32 aProgress, + PRUint32 aProgressMax) { nsresult rv; @@ -692,7 +697,7 @@ nsStreamListenerProxy::OnProgress(nsIURL* aURL, PRInt32 aProgress, } NS_IMETHODIMP -nsStreamListenerProxy::OnStatus(nsIURL* aURL, const nsString &aMsg) +nsStreamListenerProxy::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { nsresult rv; @@ -715,8 +720,8 @@ nsStreamListenerProxy::OnStatus(nsIURL* aURL, const nsString &aMsg) } NS_IMETHODIMP -nsStreamListenerProxy::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, - const nsString &aMsg) +nsStreamListenerProxy::OnStopBinding(nsIURL* aURL, nsresult aStatus, + const PRUnichar* aMsg) { nsresult rv; @@ -741,7 +746,7 @@ nsStreamListenerProxy::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, /*--------------------------------------------------------------------------*/ NS_IMETHODIMP -nsStreamListenerProxy::GetBindInfo(nsIURL* aURL) +nsStreamListenerProxy::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* info) { nsresult rv; @@ -749,14 +754,14 @@ nsStreamListenerProxy::GetBindInfo(nsIURL* aURL) PR_ASSERT(0); rv = NS_ERROR_FAILURE; } else { - rv = mRealListener->GetBindInfo(aURL); + rv = mRealListener->GetBindInfo(aURL, info); } return rv; } NS_IMETHODIMP nsStreamListenerProxy::OnDataAvailable(nsIURL* aURL, nsIInputStream *aIStream, - PRInt32 aLength) + PRUint32 aLength) { nsresult rv; @@ -872,4 +877,4 @@ net_CallExitRoutineProxy(Net_GetUrlExitFunc* exit_routine, if (nsnull != ev) { ev->Fire(); } -} \ No newline at end of file +} diff --git a/mozilla/network/module/nsStubContext.cpp b/mozilla/network/module/nsStubContext.cpp index 4c4d39d0c49..ca0577c60dc 100644 --- a/mozilla/network/module/nsStubContext.cpp +++ b/mozilla/network/module/nsStubContext.cpp @@ -82,8 +82,8 @@ static nsINetSupport *getNetSupport(URL_Struct *URL_s) nsISupports *container; /* The nsINetSupport interface will be implemented by the container */ - container = pConn->pURL->GetContainer(); - if (nsnull != container) { + nsresult err = pConn->pURL->GetContainer(&container); + if (err == NS_OK) { container->QueryInterface(kINetSupportIID, (void **) &netSupport); NS_RELEASE(container); } @@ -285,7 +285,8 @@ PRIVATE void stub_GraphProgressInit(MWContext *context, if (nsnull != (pListener = getStreamListener(URL_s))) { nsConnectionInfo *pConn = (nsConnectionInfo *) URL_s->fe_data; - pListener->OnProgress(pConn->pURL, 0, content_length); + NS_ASSERTION(content_length >= 0, "negative content_length"); + pListener->OnProgress(pConn->pURL, 0, (PRUint32)content_length); NS_RELEASE(pListener); } } @@ -304,8 +305,10 @@ PRIVATE void stub_GraphProgress(MWContext *context, if (nsnull != (pListener = getStreamListener(URL_s))) { nsConnectionInfo *pConn = (nsConnectionInfo *) URL_s->fe_data; - pListener->OnProgress(pConn->pURL, bytes_received, - content_length); + NS_ASSERTION(bytes_received >= 0, "negative bytes_received"); + NS_ASSERTION(content_length >= 0, "negative content_length"); + pListener->OnProgress(pConn->pURL, (PRUint32)bytes_received, + (PRUint32)content_length); NS_RELEASE(pListener); } } @@ -328,8 +331,10 @@ PRIVATE void stub_GraphProgressDestroy(MWContext *context, if (nsnull != (pListener = getStreamListener(URL_s))) { nsConnectionInfo *pConn = (nsConnectionInfo *) URL_s->fe_data; - pListener->OnProgress(pConn->pURL, total_bytes_read, - content_length); + NS_ASSERTION(total_bytes_read >= 0, "negative total_bytes_read"); + NS_ASSERTION(content_length >= 0, "negative content_length"); + pListener->OnProgress(pConn->pURL, (PRUint32)total_bytes_read, + (PRUint32)content_length); // XXX The comment above no longer applies, and this function does // get called... NS_RELEASE(pListener); @@ -604,7 +609,7 @@ void stub_abort(NET_StreamClass *stream, int status) int stub_put_block(NET_StreamClass *stream, const char *buffer, int32 length) { - PRInt32 bytesWritten; + PRUint32 bytesWritten; nsresult errorCode; nsConnectionInfo *pConn = GetConnectionInfoFromStream(stream); @@ -616,7 +621,8 @@ int stub_put_block(NET_StreamClass *stream, const char *buffer, int32 length) * is interrupted... In this case, Netlib will call put_block(...) * with the string "Transfer Interrupted!" */ - errorCode = pConn->pNetStream->Write(buffer, 0, length, &bytesWritten); + NS_ASSERTION(length >= 0, "negative length"); + errorCode = pConn->pNetStream->Write(buffer, 0, (PRUint32)length, &bytesWritten); /* Abort the connection... */ if (NS_BASE_STREAM_EOF == errorCode) { @@ -628,7 +634,8 @@ int stub_put_block(NET_StreamClass *stream, const char *buffer, int32 length) } /* Abort the connection if an error occurred... */ - if (NS_FAILED(errorCode) || (bytesWritten != length)) { + NS_ASSERTION(bytesWritten >= 0, "negative bytesWritten"); + if (NS_FAILED(errorCode) || ((int32)bytesWritten != length)) { return -1; } return 1; @@ -636,12 +643,12 @@ int stub_put_block(NET_StreamClass *stream, const char *buffer, int32 length) unsigned int stub_is_write_ready(NET_StreamClass *stream) { - PRInt32 errorCode; - unsigned int free_space = 0; + nsresult errorCode; + PRUint32 free_space = 0; URL_Struct *URL_s = (URL_Struct *)stream->data_object; nsConnectionInfo *pConn = GetConnectionInfoFromStream(stream); - free_space = (unsigned int)pConn->pNetStream->GetAvailableSpace(&errorCode); + errorCode = pConn->pNetStream->GetAvailableSpace(&free_space); /* * If the InputStream has been closed... Return 1 byte available so @@ -652,7 +659,7 @@ unsigned int stub_is_write_ready(NET_StreamClass *stream) } TRACEMSG(("+++ stream is_write_ready. Returning %d\n", free_space)); - return free_space; + return (int)free_space; } @@ -705,7 +712,7 @@ NET_NGLayoutConverter(FO_Present_Types format_out, * the cached info in the URL object... */ if ((URL_s->address_modified) && (NULL != pConn->pURL)) { - pConn->pURL->Set(URL_s->address); + pConn->pURL->SetSpec(URL_s->address); } /* diff --git a/mozilla/network/module/nsURL.cpp b/mozilla/network/module/nsURL.cpp index 21e56659a4a..f7a34791bbd 100644 --- a/mozilla/network/module/nsURL.cpp +++ b/mozilla/network/module/nsURL.cpp @@ -18,9 +18,10 @@ #include "nsIURL.h" #include "nsIInputStream.h" #include "nsINetService.h" -#include "nsIServiceManager.h" #include "nsIURLGroup.h" #include "nsIHttpUrl.h" /* NS_NewHttpUrl(...) */ +#include "nsINetlibURL.h" +#include "nsIPostToServer.h" #include "nsString.h" #include @@ -39,6 +40,42 @@ class URLImpl : public nsIURL { public: + + // from nsIURL: + + NS_IMETHOD Open(nsIInputStream* *result); + NS_IMETHOD Open(nsIStreamListener* listener); + NS_IMETHOD_(PRBool) Equals(const nsIURL *aURL); + NS_IMETHOD GetSpec(const char* *result); + NS_IMETHOD SetSpec(const char* spec); + NS_IMETHOD GetProtocol(const char* *result); + NS_IMETHOD SetProtocol(const char* protocol); + NS_IMETHOD GetHost(const char* *result); + NS_IMETHOD SetHost(const char* host); + NS_IMETHOD GetHostPort(PRUint32 *result); + NS_IMETHOD SetHostPort(PRUint32 port); + NS_IMETHOD GetFile(const char* *result); + NS_IMETHOD SetFile(const char* file); + NS_IMETHOD GetRef(const char* *result); + NS_IMETHOD SetRef(const char* ref); + NS_IMETHOD GetSearch(const char* *result); + NS_IMETHOD SetSearch(const char* search); + NS_IMETHOD GetContainer(nsISupports* *result); + NS_IMETHOD SetContainer(nsISupports* container); + NS_IMETHOD GetLoadAttribs(nsILoadAttribs* *result); + NS_IMETHOD SetLoadAttribs(nsILoadAttribs* loadAttribs); + NS_IMETHOD GetGroup(nsIURLGroup* *result); + NS_IMETHOD SetGroup(nsIURLGroup* group); + NS_IMETHOD SetPostHeader(const char* name, const char* value); + NS_IMETHOD SetPostData(nsIInputStream* input); + NS_IMETHOD ToString(PRUnichar* *aString); + + // from nsINetlibURL: + + NS_IMETHOD InitializeURLInfo(URL_Struct_ *URL_s); + + // URLImpl: + URLImpl(const nsIURL* aURL, const nsString& aSpec, nsISupports* container = nsnull, @@ -47,77 +84,19 @@ public: NS_DECL_ISUPPORTS - virtual nsIInputStream* Open(PRInt32* aErrorCode); - virtual nsresult Open(nsIStreamListener *aListener); - - virtual PRBool operator==(const nsIURL& aURL) const; - virtual nsresult Set(const char *aNewSpec); - virtual nsresult SetLoadAttribs(nsILoadAttribs *aLoadAttrib); - - virtual const char* GetProtocol() const; - virtual const char* GetHost() const; - virtual const char* GetFile() const; - virtual const char* GetRef() const; - virtual const char* GetSearch() const; - virtual const char* GetSpec() const; - virtual PRInt32 GetPort() const; - virtual nsISupports* GetContainer() const; - virtual nsILoadAttribs* GetLoadAttribs() const; - virtual nsIURLGroup* GetURLGroup() const; - - virtual void ToString(nsString& aString) const; - - char* mSpec; - char* mProtocol; - char* mHost; - char* mFile; - char* mRef; - char* mSearch; - nsISupports* mContainer; - nsILoadAttribs* mLoadAttribs; - nsIURLGroup* mURLGroup; - - PRInt32 mPort; - - nsISupports* mProtocolUrl; - - nsresult ParseURL(const nsIURL* aURL, const nsString& aSpec); - void CreateProtocolURL(); - -private: - void Init(nsISupports *aContainer, nsIURLGroup* aGroup); +protected: + nsINetlibURL* mProtocolUrl; + + nsINetlibURL* GetProtocolURL(const nsString& aSpec, const nsIURL* aURL); }; URLImpl::URLImpl(const nsIURL* aURL, const nsString& aSpec, nsISupports* aContainer, nsIURLGroup* aGroup) -{ - Init(aContainer, aGroup); - ParseURL(aURL, aSpec); -} - -void URLImpl::Init(nsISupports* aContainer, nsIURLGroup* aGroup) { NS_INIT_REFCNT(); - mProtocolUrl = nsnull; - - mProtocol = nsnull; - mHost = nsnull; - mFile = nsnull; - mRef = nsnull; - mSearch = nsnull; - mPort = -1; - mSpec = nsnull; - - NS_NewLoadAttribs(&mLoadAttribs); - - mURLGroup = aGroup; - NS_IF_ADDREF(mURLGroup); - - mContainer = aContainer; - NS_IF_ADDREF(mContainer); + mProtocolUrl = GetProtocolURL(aSpec, aURL); } - NS_IMPL_THREADSAFE_ADDREF(URLImpl) NS_IMPL_THREADSAFE_RELEASE(URLImpl) @@ -137,7 +116,7 @@ nsresult URLImpl::QueryInterface(const nsIID &aIID, void** aInstancePtr) return NS_OK; } if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*) ((nsISupports *)this); + *aInstancePtr = (void*) ((nsIURL *)this); NS_ADDREF_THIS(); return NS_OK; } @@ -145,9 +124,6 @@ nsresult URLImpl::QueryInterface(const nsIID &aIID, void** aInstancePtr) * Check for aggregated interfaces... */ NS_LOCK_INSTANCE(); - if (nsnull == mProtocolUrl) { - CreateProtocolURL(); - } if (nsnull != mProtocolUrl) { rv = mProtocolUrl->QueryInterface(aIID, aInstancePtr); } @@ -170,566 +146,239 @@ nsresult URLImpl::QueryInterface(const nsIID &aIID, void** aInstancePtr) URLImpl::~URLImpl() { NS_IF_RELEASE(mProtocolUrl); - NS_IF_RELEASE(mContainer); - NS_IF_RELEASE(mLoadAttribs); - NS_IF_RELEASE(mURLGroup); - - PR_FREEIF(mSpec); - PR_FREEIF(mProtocol); - PR_FREEIF(mHost); - PR_FREEIF(mFile); - PR_FREEIF(mRef); - PR_FREEIF(mSearch); } -nsresult URLImpl::Set(const char *aNewSpec) +nsINetlibURL* URLImpl::GetProtocolURL(const nsString& aSpec, const nsIURL* aURL) { - return ParseURL(nsnull, aNewSpec); + // XXX this is cheating -- there really should be a table-driven thing here + // based on the protocol part of aSpec + + nsresult err; + nsINetlibURL* result; + // XXX parse aSpec, aURL + err = NS_NewHttpURL((nsISupports**)&result, (nsIURL*)this); // XXX cast + return result; +} + +//////////////////////////////////////////////////////////////////////////////// + +PRBool URLImpl::Equals(const nsIURL* aURL) +{ + if (mProtocolUrl) + return mProtocolUrl->Equals(aURL); + else + return PR_FALSE; +} + +nsresult URLImpl::GetProtocol(const char* *result) +{ + if (mProtocolUrl) + return mProtocolUrl->GetProtocol(result); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::SetProtocol(const char *aNewProtocol) +{ + if (mProtocolUrl) + return mProtocolUrl->SetProtocol(aNewProtocol); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::GetHost(const char* *result) +{ + if (mProtocolUrl) + return mProtocolUrl->GetHost(result); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::SetHost(const char *aNewHost) +{ + if (mProtocolUrl) + return mProtocolUrl->SetHost(aNewHost); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::GetFile(const char* *result) +{ + if (mProtocolUrl) + return mProtocolUrl->GetFile(result); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::SetFile(const char *aNewFile) +{ + if (mProtocolUrl) + return mProtocolUrl->SetFile(aNewFile); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::GetSpec(const char* *result) +{ + if (mProtocolUrl) + return mProtocolUrl->GetSpec(result); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::SetSpec(const char *aNewSpec) +{ + if (mProtocolUrl) + return mProtocolUrl->SetSpec(aNewSpec); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::GetRef(const char* *result) +{ + if (mProtocolUrl) + return mProtocolUrl->GetRef(result); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::SetRef(const char* ref) +{ + if (mProtocolUrl) + return mProtocolUrl->SetRef(ref); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::GetHostPort(PRUint32 *result) +{ + if (mProtocolUrl) + return mProtocolUrl->GetHostPort(result); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::SetHostPort(PRUint32 port) +{ + if (mProtocolUrl) + return mProtocolUrl->SetHostPort(port); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::GetSearch(const char* *result) +{ + if (mProtocolUrl) + return mProtocolUrl->GetSearch(result); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::SetSearch(const char* search) +{ + if (mProtocolUrl) + return mProtocolUrl->SetSearch(search); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::GetContainer(nsISupports* *result) +{ + if (mProtocolUrl) + return mProtocolUrl->GetContainer(result); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::SetContainer(nsISupports* container) +{ + if (mProtocolUrl) + return mProtocolUrl->SetContainer(container); + else + return NS_ERROR_FAILURE; } -nsresult URLImpl::SetLoadAttribs(nsILoadAttribs *aLoadAttrib) +nsresult URLImpl::GetLoadAttribs(nsILoadAttribs* *result) { - NS_LOCK_INSTANCE(); - mLoadAttribs = aLoadAttrib; - NS_IF_ADDREF(mLoadAttribs); - NS_UNLOCK_INSTANCE(); - - return NS_OK; + if (mProtocolUrl) + return mProtocolUrl->GetLoadAttribs(result); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::SetLoadAttribs(nsILoadAttribs* loadAttribs) +{ + if (mProtocolUrl) + return mProtocolUrl->SetLoadAttribs(loadAttribs); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::GetGroup(nsIURLGroup* *result) +{ + if (mProtocolUrl) + return mProtocolUrl->GetGroup(result); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::SetGroup(nsIURLGroup* group) +{ + if (mProtocolUrl) + return mProtocolUrl->SetGroup(group); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::SetPostHeader(const char* name, const char* value) +{ + if (mProtocolUrl) + return mProtocolUrl->SetPostHeader(name, value); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::SetPostData(nsIInputStream* input) +{ + if (mProtocolUrl) + return mProtocolUrl->SetPostData(input); + else + return NS_ERROR_FAILURE; +} + +nsresult URLImpl::ToString(PRUnichar* *aString) +{ + if (mProtocolUrl) + return mProtocolUrl->ToString(aString); + else + return NS_ERROR_FAILURE; } - -PRBool URLImpl::operator==(const nsIURL& aURL) const +nsresult URLImpl::Open(nsIInputStream* *aStream) { - PRBool bIsEqual; - URLImpl& other = (URLImpl&)aURL; // XXX ? - - NS_LOCK_INSTANCE(); - bIsEqual = PRBool((0 == PL_strcmp(mProtocol, other.mProtocol)) && - (0 == PL_strcasecmp(mHost, other.mHost)) && - (0 == PL_strcmp(mFile, other.mFile))); - NS_UNLOCK_INSTANCE(); - - return bIsEqual; -} - -const char* URLImpl::GetProtocol() const -{ - const char* protocol; - - NS_LOCK_INSTANCE(); - protocol = mProtocol; - NS_UNLOCK_INSTANCE(); - - return protocol; -} - -const char* URLImpl::GetHost() const -{ - const char* host; - - NS_LOCK_INSTANCE(); - host = mHost; - NS_UNLOCK_INSTANCE(); - - return host; -} - -const char* URLImpl::GetFile() const -{ - const char* file; - - NS_LOCK_INSTANCE(); - file = mFile; - NS_UNLOCK_INSTANCE(); - - return file; -} - -const char* URLImpl::GetSpec() const -{ - const char* spec; - - NS_LOCK_INSTANCE(); - spec = mSpec; - NS_UNLOCK_INSTANCE(); - - return spec; -} - -const char* URLImpl::GetRef() const -{ - const char* ref; - - NS_LOCK_INSTANCE(); - ref = mRef; - NS_UNLOCK_INSTANCE(); - - return ref; -} - -const char* URLImpl::GetSearch() const -{ - const char* search; - - NS_LOCK_INSTANCE(); - search = mSearch; - NS_UNLOCK_INSTANCE(); - - return search; -} - -PRInt32 URLImpl::GetPort() const -{ - PRInt32 port; - - NS_LOCK_INSTANCE(); - port = mPort; - NS_UNLOCK_INSTANCE(); - - return port; -} - -nsISupports* URLImpl::GetContainer() const -{ - nsISupports* container; - - NS_LOCK_INSTANCE(); - container = mContainer; - NS_IF_ADDREF(container); - NS_UNLOCK_INSTANCE(); - - return container; -} - -nsILoadAttribs* URLImpl::GetLoadAttribs() const -{ - nsILoadAttribs* loadAttribs; - - NS_LOCK_INSTANCE(); - loadAttribs = mLoadAttribs; - NS_IF_ADDREF(loadAttribs); - NS_UNLOCK_INSTANCE(); - - return loadAttribs; -} - -nsIURLGroup* URLImpl::GetURLGroup() const -{ - nsIURLGroup* group; - - NS_LOCK_INSTANCE(); - group = mURLGroup; - NS_IF_ADDREF(group); - NS_UNLOCK_INSTANCE(); - - return group; -} - -void URLImpl::ToString(nsString& aString) const -{ - NS_LOCK_INSTANCE(); - - // XXX Special-case javascript: URLs for the moment. - // This code will go away when we actually start doing - // protocol-specific parsing. - if (PL_strcmp(mProtocol, "javascript") == 0) { - aString.SetString(mSpec); - } else { - aString.SetLength(0); - aString.Append(mProtocol); - aString.Append("://"); - if (nsnull != mHost) { - aString.Append(mHost); - if (0 < mPort) { - aString.Append(':'); - aString.Append(mPort, 10); - } - } - aString.Append(mFile); - if (nsnull != mRef) { - aString.Append('#'); - aString.Append(mRef); - } - if (nsnull != mSearch) { - aString.Append('?'); - aString.Append(mSearch); - } - } - NS_UNLOCK_INSTANCE(); -} - -// XXX recode to use nsString api's - -// XXX don't bother with port numbers -// XXX don't bother with ref's -// XXX null pointer checks are incomplete -nsresult URLImpl::ParseURL(const nsIURL* aURL, const nsString& aSpec) -{ - // XXX hack! - char* cSpec = aSpec.ToNewCString(); - - const char* uProtocol = nsnull; - const char* uHost = nsnull; - const char* uFile = nsnull; - PRInt32 uPort = -1; - if (nsnull != aURL) { - uProtocol = aURL->GetProtocol(); - uHost = aURL->GetHost(); - uFile = aURL->GetFile(); - uPort = aURL->GetPort(); - } - - NS_LOCK_INSTANCE(); - - PR_FREEIF(mProtocol); - PR_FREEIF(mHost); - PR_FREEIF(mFile); - PR_FREEIF(mRef); - PR_FREEIF(mSearch); - mPort = -1; - PR_FREEIF(mSpec); - - if (nsnull == cSpec) { - if (nsnull == aURL) { - NS_UNLOCK_INSTANCE(); - return NS_ERROR_ILLEGAL_VALUE; - } - mProtocol = (nsnull != uProtocol) ? PL_strdup(uProtocol) : nsnull; - mHost = (nsnull != uHost) ? PL_strdup(uHost) : nsnull; - mPort = uPort; - mFile = (nsnull != uFile) ? PL_strdup(uFile) : nsnull; - - NS_UNLOCK_INSTANCE(); - return NS_OK; - } - - // Strip out reference and search info - char* ref = strpbrk(cSpec, "#?"); - if (nsnull != ref) { - char* search = nsnull; - if ('#' == *ref) { - search = PL_strchr(ref + 1, '?'); - if (nsnull != search) { - *search++ = '\0'; - } - - PRIntn hashLen = PL_strlen(ref + 1); - if (0 != hashLen) { - mRef = (char*) PR_Malloc(hashLen + 1); - PL_strcpy(mRef, ref + 1); - } - } - else { - search = ref + 1; - } - - if (nsnull != search) { - // The rest is the search - PRIntn searchLen = PL_strlen(search); - if (0 != searchLen) { - mSearch = (char*) PR_Malloc(searchLen + 1); - PL_strcpy(mSearch, search); - } - } - - // XXX Terminate string at start of reference or search - *ref = '\0'; - } - - // The URL is considered absolute if and only if it begins with a - // protocol spec. A protocol spec is an alphanumeric string of 1 or - // more characters that is terminated with a colon. - PRBool isAbsolute = PR_FALSE; - char* cp; - char* ap = cSpec; - char ch; - while (0 != (ch = *ap)) { - if (((ch >= 'a') && (ch <= 'z')) || - ((ch >= 'A') && (ch <= 'Z')) || - ((ch >= '0') && (ch <= '9'))) { - ap++; - continue; - } - if ((ch == ':') && (ap - cSpec >= 2)) { - isAbsolute = PR_TRUE; - cp = ap; - break; - } - break; - } - - if (!isAbsolute) { - // relative spec - if (nsnull == aURL) { - delete cSpec; - - NS_UNLOCK_INSTANCE(); - return NS_ERROR_ILLEGAL_VALUE; - } - - // keep protocol and host - mProtocol = (nsnull != uProtocol) ? PL_strdup(uProtocol) : nsnull; - mHost = (nsnull != uHost) ? PL_strdup(uHost) : nsnull; - mPort = uPort; - - // figure out file name - PRInt32 len = PL_strlen(cSpec) + 1; - if ((len > 1) && (cSpec[0] == '/')) { - // Relative spec is absolute to the server - mFile = PL_strdup(cSpec); - } else { - if (cSpec[0] != '\0') { - // Strip out old tail component and put in the new one - char* dp = PL_strrchr(uFile, '/'); - if (!dp) { - delete cSpec; - NS_UNLOCK_INSTANCE(); - return NS_ERROR_ILLEGAL_VALUE; - } - PRInt32 dirlen = (dp + 1) - uFile; - mFile = (char*) PR_Malloc(dirlen + len); - PL_strncpy(mFile, uFile, dirlen); - PL_strcpy(mFile + dirlen, cSpec); - } - else { - mFile = PL_strdup(uFile); - } - } - - /* Stolen from netlib's mkparse.c. - * - * modifies a url of the form /foo/../foo1 -> /foo1 - * and /foo/./foo1 -> /foo/foo1 - */ - char *fwdPtr = mFile; - char *urlPtr = mFile; - - for(; *fwdPtr != '\0'; fwdPtr++) - { - - if(*fwdPtr == '/' && *(fwdPtr+1) == '.' && *(fwdPtr+2) == '/') - { - /* remove ./ - */ - fwdPtr += 1; - } - else if(*fwdPtr == '/' && *(fwdPtr+1) == '.' && *(fwdPtr+2) == '.' && - (*(fwdPtr+3) == '/' || *(fwdPtr+3) == '\0')) - { - /* remove foo/.. - */ - /* reverse the urlPtr to the previous slash - */ - if(urlPtr != mFile) - urlPtr--; /* we must be going back at least one */ - for(;*urlPtr != '/' && urlPtr != mFile; urlPtr--) - ; /* null body */ - - /* forward the fwd_prt past the ../ - */ - fwdPtr += 2; - } - else - { - /* copy the url incrementaly - */ - *urlPtr++ = *fwdPtr; - } - } - - *urlPtr = '\0'; /* terminate the url */ - - // Now that we've resolved the relative URL, we need to reconstruct - // a URL spec from the components. - char portBuffer[10]; - if (-1 != mPort) { - PR_snprintf(portBuffer, 10, ":%d", mPort); - } - else { - portBuffer[0] = '\0'; - } - - PRInt32 plen = PL_strlen(mProtocol) + PL_strlen(mHost) + - PL_strlen(portBuffer) + PL_strlen(mFile) + 4; - if (mRef) { - plen += 1 + PL_strlen(mRef); - } - if (mSearch) { - plen += 1 + PL_strlen(mSearch); - } - - mSpec = (char *) PR_Malloc(plen + 1); - PR_snprintf(mSpec, plen, "%s://%s%s%s", - mProtocol, ((nsnull != mHost) ? mHost : ""), portBuffer, - mFile); - - if (mRef) { - PL_strcat(mSpec, "#"); - PL_strcat(mSpec, mRef); - } - if (mSearch) { - PL_strcat(mSpec, "?"); - PL_strcat(mSpec, mSearch); - } - } else { - // absolute spec - PRInt32 slen = aSpec.Length(); - mSpec = (char *) PR_Malloc(slen + 1); - aSpec.ToCString(mSpec, slen+1); - - // get protocol first - PRInt32 plen = cp - cSpec; - mProtocol = (char*) PR_Malloc(plen + 1); - PL_strncpy(mProtocol, cSpec, plen); - mProtocol[plen] = 0; - cp++; // eat : in protocol - - // skip over one, two or three slashes - if (*cp == '/') { - cp++; - if (*cp == '/') { - cp++; - if (*cp == '/') { - cp++; - } - } - } else { - delete cSpec; - - NS_UNLOCK_INSTANCE(); - return NS_ERROR_ILLEGAL_VALUE; - } - - -#if defined(XP_UNIX) || defined (XP_MAC) - // Always leave the top level slash for absolute file paths under Mac and UNIX. - // The code above sometimes results in stripping all of slashes - // off. This only happens when a previously stripped url is asked to be - // parsed again. Under Win32 this is not a problem since file urls begin - // with a drive letter not a slash. This problem show's itself when - // nested documents such as iframes within iframes are parsed. - - if (PL_strcmp(mProtocol, "file") == 0) { - if (*cp != '/') { - cp--; - } - } -#endif /* XP_UNIX */ - - const char* cp0 = cp; - if ((PL_strcmp(mProtocol, "resource") == 0) || - (PL_strcmp(mProtocol, "file") == 0)) { - // resource/file url's do not have host names. - // The remainder of the string is the file name - PRInt32 flen = PL_strlen(cp); - mFile = (char*) PR_Malloc(flen + 1); - PL_strcpy(mFile, cp); - -#ifdef NS_WIN32 - if (PL_strcmp(mProtocol, "file") == 0) { - // If the filename starts with a "x|" where is an single - // character then we assume it's a drive name and change the - // vertical bar back to a ":" - if ((flen >= 2) && (mFile[1] == '|')) { - mFile[1] = ':'; - } - } -#endif /* NS_WIN32 */ - } else { - // Host name follows protocol for http style urls - cp = PL_strpbrk(cp, "/:"); - - if (nsnull == cp) { - // There is only a host name - PRInt32 hlen = PL_strlen(cp0); - mHost = (char*) PR_Malloc(hlen + 1); - PL_strcpy(mHost, cp0); - } - else { - PRInt32 hlen = cp - cp0; - mHost = (char*) PR_Malloc(hlen + 1); - PL_strncpy(mHost, cp0, hlen); - mHost[hlen] = 0; - - if (':' == *cp) { - // We have a port number - cp0 = cp+1; - cp = PL_strchr(cp, '/'); - mPort = strtol(cp0, (char **)nsnull, 10); - } - } - - if (nsnull == cp) { - // There is no file name - // Set filename to "/" - mFile = (char*) PR_Malloc(2); - mFile[0] = '/'; - mFile[1] = 0; - } - else { - // The rest is the file name - PRInt32 flen = PL_strlen(cp); - mFile = (char*) PR_Malloc(flen + 1); - PL_strcpy(mFile, cp); - } - } - } - -//printf("protocol='%s' host='%s' file='%s'\n", mProtocol, mHost, mFile); - delete cSpec; - - NS_UNLOCK_INSTANCE(); - return NS_OK; -} - -static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID); -static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID); - -nsIInputStream* URLImpl::Open(PRInt32* aErrorCode) -{ - nsresult rv; - nsIInputStream* in = nsnull; - nsINetService *inet = nsnull; - - rv = nsServiceManager::GetService(kNetServiceCID, - kINetServiceIID, - (nsISupports **)&inet); - if (NS_OK == rv) { - rv = inet->OpenBlockingStream(this, NULL, &in); - nsServiceManager::ReleaseService(kNetServiceCID, inet); - } - - *aErrorCode = rv; - return in; + if (mProtocolUrl) + return mProtocolUrl->Open(aStream); + else + return NS_ERROR_FAILURE; } nsresult URLImpl::Open(nsIStreamListener *aListener) { - nsINetService *inet = nsnull; - nsresult rv; - - if (nsnull != mURLGroup) { - rv = mURLGroup->OpenStream(this, aListener); - } else { - rv = nsServiceManager::GetService(kNetServiceCID, - kINetServiceIID, - (nsISupports **)&inet); - if (NS_OK == rv) { - rv = inet->OpenStream(this, aListener); - nsServiceManager::ReleaseService(kNetServiceCID, inet); - } - } - return rv; + if (mProtocolUrl) + return mProtocolUrl->Open(aListener); + else + return NS_ERROR_FAILURE; } - -void URLImpl::CreateProtocolURL() +nsresult URLImpl::InitializeURLInfo(URL_Struct_ *URL_s) { - nsresult result; - - result = NS_NewHttpUrl(&mProtocolUrl, this); + if (mProtocolUrl) + return mProtocolUrl->InitializeURLInfo(URL_s); + else + return NS_ERROR_FAILURE; } - + +//////////////////////////////////////////////////////////////////////////////// NS_NET nsresult NS_NewURL(nsIURL** aInstancePtrResult, const nsString& aSpec) @@ -766,10 +415,16 @@ NS_NET nsresult NS_MakeAbsoluteURL(nsIURL* aURL, if (0 < aBaseURL.Length()) { URLImpl base(nsnull, aBaseURL); URLImpl url(&base, aSpec); - url.ToString(aResult); + PRUnichar* str; + url.ToString(&str); + aResult = *new nsString(str); + delete str; } else { URLImpl url(aURL, aSpec); - url.ToString(aResult); + PRUnichar* str; + url.ToString(&str); + aResult = *new nsString(str); + delete str; } return NS_OK; } diff --git a/mozilla/network/module/tests/nettest.cpp b/mozilla/network/module/tests/nettest.cpp index 29d5763c5b9..3d67ccab117 100644 --- a/mozilla/network/module/tests/nettest.cpp +++ b/mozilla/network/module/tests/nettest.cpp @@ -76,12 +76,12 @@ public: TestConsumer(); - NS_IMETHOD GetBindInfo(nsIURL* aURL); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* info); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 Progress, PRUint32 ProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg); + NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUint32 length); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); protected: ~TestConsumer(); @@ -106,7 +106,7 @@ TestConsumer::~TestConsumer() } -NS_IMETHODIMP TestConsumer::GetBindInfo(nsIURL* aURL) +NS_IMETHODIMP TestConsumer::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* info) { if (bTraceEnabled) { printf("\n+++ TestConsumer::GetBindInfo: URL: %p\n", aURL); @@ -115,8 +115,8 @@ NS_IMETHODIMP TestConsumer::GetBindInfo(nsIURL* aURL) return 0; } -NS_IMETHODIMP TestConsumer::OnProgress(nsIURL* aURL, PRInt32 Progress, - PRInt32 ProgressMax) +NS_IMETHODIMP TestConsumer::OnProgress(nsIURL* aURL, PRUint32 Progress, + PRUint32 ProgressMax) { if (bTraceEnabled) { printf("\n+++ TestConsumer::OnProgress: URL: %p - %d of total %d\n", aURL, Progress, ProgressMax); @@ -125,11 +125,14 @@ NS_IMETHODIMP TestConsumer::OnProgress(nsIURL* aURL, PRInt32 Progress, return 0; } -NS_IMETHODIMP TestConsumer::OnStatus(nsIURL* aURL, const nsString& aMsg) +NS_IMETHODIMP TestConsumer::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { if (bTraceEnabled) { printf("\n+++ TestConsumer::OnStatus: "); - fputs(aMsg, stdout); + nsString str(aMsg); + char* c = str.ToNewCString(); + fputs(c, stdout); + free(c); fputs("\n", stdout); } @@ -146,9 +149,9 @@ NS_IMETHODIMP TestConsumer::OnStartBinding(nsIURL* aURL, const char *aContentTyp } -NS_IMETHODIMP TestConsumer::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length) +NS_IMETHODIMP TestConsumer::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUint32 length) { - PRInt32 len; + PRUint32 len; if (bTraceEnabled) { printf("\n+++ TestConsumer::OnDataAvailable: URL: %p, %d bytes available...\n", aURL, length); @@ -157,7 +160,7 @@ NS_IMETHODIMP TestConsumer::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStre do { nsresult err; char buffer[80]; - int i; + PRUint32 i; err = pIStream->Read(buffer, 0, 80, &len); if (err == NS_OK) { @@ -171,7 +174,7 @@ NS_IMETHODIMP TestConsumer::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStre } -NS_IMETHODIMP TestConsumer::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg) +NS_IMETHODIMP TestConsumer::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg) { if (bTraceEnabled) { printf("\n+++ TestConsumer::OnStopBinding... URL: %p status: %d\n", aURL, status); @@ -189,10 +192,10 @@ nsresult ReadStreamSynchronously(nsIInputStream* aIn) char buffer[1024]; if (nsnull != aIn) { - int len; + PRUint32 len; do { - int i; + PRUint32 i; rv = aIn->Read(buffer, 0, sizeof(buffer), &len); for (i=0; iOpen(pConsumer); + result = NS_OpenURL(pURL, pConsumer); /* If the open failed, then do not drop into the message loop... */ if (NS_OK != result) { @@ -284,7 +287,7 @@ int main(int argc, char **argv) else { nsIInputStream *in; - in = pURL->Open((PRInt32*)&result); + result = NS_OpenURL(pURL, &in); ReadStreamSynchronously(in); NS_IF_RELEASE(in); urlLoaded = 1; diff --git a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp index c452bd8a0f0..3a9774555aa 100644 --- a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp @@ -126,13 +126,13 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax) { return NS_OK; } - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg) { return NS_OK; } + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 Progress, PRUint32 ProgressMax) { return NS_OK; } + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { return NS_OK; } NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType) { return NS_OK; } - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); }; -NS_IMETHODIMP CStreamListener::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg) +NS_IMETHODIMP CStreamListener::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg) { fputs("done.\n",stdout); g_bReadyForNextUrl = PR_TRUE; @@ -242,16 +242,24 @@ extern "C" NS_EXPORT int DebugRobot( parser->Parse(url, pl,PR_TRUE);/* XXX hook up stream listener here! */ while (!g_bReadyForNextUrl) { - if (yieldProc != NULL) - (*yieldProc)(url->GetSpec()); + if (yieldProc != NULL) { + const char* spec; + (void)url->GetSpec(&spec); + (*yieldProc)(spec); + } } g_bReadyForNextUrl = PR_FALSE; if (ww) { ww->SetObserver(pl); - ww->LoadURL(nsString(url->GetSpec()));/* XXX hook up stream listener here! */ + const char* spec; + (void)url->GetSpec(&spec); + ww->LoadURL(nsString(spec));/* XXX hook up stream listener here! */ while (!g_bReadyForNextUrl) { - if (yieldProc != NULL) - (*yieldProc)(url->GetSpec()); + if (yieldProc != NULL) { + const char* spec; + (void)url->GetSpec(&spec); + (*yieldProc)(spec); + } } } diff --git a/mozilla/parser/htmlparser/robot/nsRobotSink.cpp b/mozilla/parser/htmlparser/robot/nsRobotSink.cpp index c6691e3b7f1..40ab8b295a4 100644 --- a/mozilla/parser/htmlparser/robot/nsRobotSink.cpp +++ b/mozilla/parser/htmlparser/robot/nsRobotSink.cpp @@ -316,11 +316,14 @@ void RobotSink::ProcessLink(const nsString& aLink) nsIURL* docURL = mDocumentURL; if (nsnull != docURL) { nsIURL* absurl; - nsresult rv = NS_NewURL(&absurl, docURL, aLink); + nsresult rv = NS_NewURL(&absurl, aLink, docURL); if (NS_OK == rv) { absURLSpec.Truncate(); - absurl->ToString(absURLSpec); + PRUnichar* str; + absurl->ToString(&str); + absURLSpec = str; NS_RELEASE(absurl); + delete str; } } diff --git a/mozilla/parser/htmlparser/src/nsIParserFilter.h b/mozilla/parser/htmlparser/src/nsIParserFilter.h index b6fc986ee77..fc42af97d06 100644 --- a/mozilla/parser/htmlparser/src/nsIParserFilter.h +++ b/mozilla/parser/htmlparser/src/nsIParserFilter.h @@ -41,7 +41,7 @@ class CToken; class nsIParserFilter : public nsISupports { public: - NS_IMETHOD RawBuffer(char * buffer, int * buffer_length) = 0; + NS_IMETHOD RawBuffer(char * buffer, PRUint32 * buffer_length) = 0; NS_IMETHOD WillAddToken(CToken & token) = 0; diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp index ae2f1a176c3..5c974b9973b 100644 --- a/mozilla/parser/htmlparser/src/nsParser.cpp +++ b/mozilla/parser/htmlparser/src/nsParser.cpp @@ -626,7 +626,10 @@ PRInt32 nsParser::Parse(nsIURL* aURL,nsIStreamObserver* aListener,PRBool aVerify mDTDVerification=aVerifyEnabled; if(aURL) { - nsAutoString theName(aURL->GetSpec()); + const char* spec; + nsresult rv = aURL->GetSpec(&spec); + if (rv != NS_OK) return rv; + nsAutoString theName(spec); CParserContext* cp=new CParserContext(new CScanner(theName,PR_FALSE),aURL,aListener); PushContext(*cp); status=NS_OK; @@ -841,7 +844,7 @@ CToken* nsParser::PushToken(CToken* theToken) { * @param * @return error code -- 0 if ok, non-zero if error. */ -nsresult nsParser::GetBindInfo(nsIURL* aURL){ +nsresult nsParser::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo){ nsresult result=0; return result; } @@ -854,7 +857,7 @@ nsresult nsParser::GetBindInfo(nsIURL* aURL){ * @return error code -- 0 if ok, non-zero if error. */ nsresult -nsParser::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) +nsParser::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult result=0; if (nsnull != mObserver) { @@ -871,7 +874,7 @@ nsParser::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) * @return error code -- 0 if ok, non-zero if error. */ nsresult -nsParser::OnStatus(nsIURL* aURL, const nsString &aMsg) +nsParser::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { nsresult result=0; if (nsnull != mObserver) { @@ -908,7 +911,7 @@ nsresult nsParser::OnStartBinding(nsIURL* aURL, const char *aSourceType){ * @param length is the number of bytes waiting input * @return error code (usually 0) */ -nsresult nsParser::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length){ +nsresult nsParser::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUint32 length){ /* if (nsnull != mListener) { //Rick potts removed this. //Does it need to be here? @@ -924,7 +927,7 @@ nsresult nsParser::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt } } - int len=1; //init to a non-zero value + PRUint32 len=1; //init to a non-zero value if(!mParserContext->mTransferBuffer) mParserContext->mTransferBuffer = new char[CParserContext::eTransferBufferSize+1]; @@ -979,7 +982,7 @@ nsresult nsParser::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt * @param * @return */ -nsresult nsParser::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg){ +nsresult nsParser::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg){ mStreamListenerState=eOnStop; mStreamStatus=status; nsresult result; diff --git a/mozilla/parser/htmlparser/src/nsParser.h b/mozilla/parser/htmlparser/src/nsParser.h index 06aa1af0d6e..7aa215aff6b 100644 --- a/mozilla/parser/htmlparser/src/nsParser.h +++ b/mozilla/parser/htmlparser/src/nsParser.h @@ -202,12 +202,12 @@ friend class CTokenHandler; // These methods are callback methods used by // net lib to let us know about our inputstream. //********************************************* - NS_IMETHOD GetBindInfo(nsIURL* aURL); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMmsg); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 Progress, PRUint32 ProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMmsg); NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg); + NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUint32 length); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); protected: diff --git a/mozilla/parser/htmlparser/src/nsScanner.cpp b/mozilla/parser/htmlparser/src/nsScanner.cpp index 7a8368375f6..5c1c6c8363c 100644 --- a/mozilla/parser/htmlparser/src/nsScanner.cpp +++ b/mozilla/parser/htmlparser/src/nsScanner.cpp @@ -130,7 +130,7 @@ CScanner::~CScanner() { * @param * @return */ -PRInt32 CScanner::RewindToMark(void){ +PRUint32 CScanner::RewindToMark(void){ mOffset=mMarkPos; return mOffset; } @@ -145,7 +145,7 @@ PRInt32 CScanner::RewindToMark(void){ * @param * @return */ -PRInt32 CScanner::Mark(void){ +PRUint32 CScanner::Mark(void){ if((mOffset>0) && (mOffset>eBufferSizeThreshold)) { mBuffer.Cut(0,mOffset); //delete chars up to mark position mOffset=0; @@ -175,7 +175,7 @@ PRBool CScanner::Append(nsString& aBuffer) { * @param * @return */ -PRBool CScanner::Append(const char* aBuffer, PRInt32 aLen){ +PRBool CScanner::Append(const char* aBuffer, PRUint32 aLen){ mBuffer.Append(aBuffer,aLen); mTotalRead+=aLen; return PR_TRUE; @@ -238,7 +238,7 @@ nsresult CScanner::FillBuffer(void) { nsresult CScanner::Eof() { nsresult theError=NS_OK; - if(mOffset>=mBuffer.Length()) { + if(mOffset>=(PRUint32)mBuffer.Length()) { theError=FillBuffer(); } @@ -261,11 +261,11 @@ nsresult CScanner::Eof() { nsresult CScanner::GetChar(PRUnichar& aChar) { nsresult result=NS_OK; - if(mOffset>=mBuffer.Length()) + if(mOffset>=(PRUint32)mBuffer.Length()) result=Eof(); if(NS_OK == result) { - aChar=mBuffer[mOffset++]; + aChar=mBuffer[(PRInt32)mOffset++]; } return result; } @@ -282,11 +282,11 @@ nsresult CScanner::GetChar(PRUnichar& aChar) { nsresult CScanner::Peek(PRUnichar& aChar) { nsresult result=NS_OK; - if(mOffset>=mBuffer.Length()) + if(mOffset>=(PRUint32)mBuffer.Length()) result=Eof(); if(NS_OK == result) { - aChar=mBuffer[mOffset]; + aChar=mBuffer[(PRInt32)mOffset]; } return result; } diff --git a/mozilla/parser/htmlparser/src/nsScanner.h b/mozilla/parser/htmlparser/src/nsScanner.h index 5950f5122a1..d9e577c05ee 100644 --- a/mozilla/parser/htmlparser/src/nsScanner.h +++ b/mozilla/parser/htmlparser/src/nsScanner.h @@ -199,7 +199,7 @@ class CScanner { * @param * @return */ - PRInt32 Mark(void); + PRUint32 Mark(void); /** * Resets current offset position of input stream to marked position. @@ -211,7 +211,7 @@ class CScanner { * @param * @return */ - PRInt32 RewindToMark(void); + PRUint32 RewindToMark(void); /** @@ -230,7 +230,7 @@ class CScanner { * @param * @return */ - PRBool Append(const char* aBuffer, PRInt32 aLen); + PRBool Append(const char* aBuffer, PRUint32 aLen); PRBool Append(const PRUnichar* aBuffer, PRInt32 aLen); @@ -270,9 +270,9 @@ class CScanner { fstream* mFileStream; nsString mBuffer; nsString mFilename; - PRInt32 mOffset; - PRInt32 mMarkPos; - PRInt32 mTotalRead; + PRUint32 mOffset; + PRUint32 mMarkPos; + PRUint32 mTotalRead; PRBool mOwnsStream; PRBool mIncremental; }; diff --git a/mozilla/rdf/src/netglue.cpp b/mozilla/rdf/src/netglue.cpp index 3cdf35af2f6..203634ce1db 100644 --- a/mozilla/rdf/src/netglue.cpp +++ b/mozilla/rdf/src/netglue.cpp @@ -34,15 +34,15 @@ public: NS_METHOD GetBindInfo(nsIURL* aURL); - NS_METHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax); + NS_METHOD OnProgress(nsIURL* aURL, PRUint32 Progress, PRUint32 ProgressMax); - NS_METHOD OnStatus(nsIURL* aURL, const nsString& aMsg); + NS_METHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); NS_METHOD OnStartBinding(nsIURL* aURL, const char *aContentType); NS_METHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length); - NS_METHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg); + NS_METHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); protected: // rdfStreamListener::rdfStreamListener(); @@ -70,15 +70,15 @@ rdfStreamListener::GetBindInfo(nsIURL* aURL) NS_METHOD rdfStreamListener::OnProgress(nsIURL* aURL, - PRInt32 Progress, - PRInt32 ProgressMax) + PRUint32 Progress, + PRUint32 ProgressMax) { return NS_OK; } NS_METHOD rdfStreamListener::OnStatus(nsIURL* aURL, - const nsString& aMsg) + const PRUnichar* aMsg) { return NS_OK; } @@ -114,8 +114,8 @@ rdfStreamListener::OnDataAvailable(nsIURL* aURL, NS_METHOD rdfStreamListener::OnStopBinding(nsIURL* aURL, - PRInt32 status, - const nsString& aMsg) + nsresult status, + const PRUnichar* aMsg) { nsresult result = NS_OK; diff --git a/mozilla/rdf/src/nsRDFContentSink.cpp b/mozilla/rdf/src/nsRDFContentSink.cpp index b497728366d..86cc95f3dcb 100644 --- a/mozilla/rdf/src/nsRDFContentSink.cpp +++ b/mozilla/rdf/src/nsRDFContentSink.cpp @@ -228,8 +228,11 @@ rdf_FullyQualifyURI(const nsIURL* base, nsString& spec) // This is a fairly heavy-handed way to do this, but...I don't // like typing. nsIURL* url; - if (NS_SUCCEEDED(NS_NewURL(&url, base, spec))) { - url->ToString(spec); + if (NS_SUCCEEDED(NS_NewURL(&url, spec, base))) { + PRUnichar* str; + url->ToString(&str); + spec = str; + delete str; url->Release(); } } @@ -702,7 +705,10 @@ nsRDFContentSink::GetIdAboutAttribute(const nsIParserNode& aNode, } if (attr.Equals(kTagRDF_ID)) { - mDocumentURL->ToString(rResource); + PRUnichar* str; + mDocumentURL->ToString(&str); + rResource = str; + delete str; nsAutoString tag = aNode.GetValueAt(i); rdf_StripAndConvert(tag); @@ -717,7 +723,10 @@ nsRDFContentSink::GetIdAboutAttribute(const nsIParserNode& aNode, } // Otherwise, we couldn't find anything, so just gensym one... - mDocumentURL->ToString(rResource); + PRUnichar* str; + mDocumentURL->ToString(&str); + rResource = str; + delete str; rResource.Append("#anonymous$"); rResource.Append(mGenSym++, 10); return NS_OK; diff --git a/mozilla/rdf/src/nsRDFDocument.cpp b/mozilla/rdf/src/nsRDFDocument.cpp index 1f46631481f..294b170cb93 100644 --- a/mozilla/rdf/src/nsRDFDocument.cpp +++ b/mozilla/rdf/src/nsRDFDocument.cpp @@ -195,7 +195,7 @@ nsRDFDocument::StartDocumentLoad(nsIURL *aURL, mDocumentURL = aURL; NS_ADDREF(aURL); - mDocumentURLGroup = aURL->GetURLGroup(); + (void)aURL->GetURLGroup(&mDocumentURLGroup); rv = nsRepository::CreateInstance(kParserCID, nsnull, diff --git a/mozilla/rdf/src/nsRDFDocumentContentSink.cpp b/mozilla/rdf/src/nsRDFDocumentContentSink.cpp index 3f30ca1f397..2709dc2c7f2 100644 --- a/mozilla/rdf/src/nsRDFDocumentContentSink.cpp +++ b/mozilla/rdf/src/nsRDFDocumentContentSink.cpp @@ -152,7 +152,8 @@ nsRDFDocumentContentSink::StartLayout(void) // If the document we are loading has a reference or it is a top level // frameset document, disable the scroll bars on the views. - const char* ref = mDocumentURL->GetRef(); + const char* ref; + (void)mDocumentURL->GetRef(&ref); PRBool topLevelFrameset = PR_FALSE; if (mWebShell) { nsIWebShell* rootWebShell; @@ -355,15 +356,15 @@ static const char kCSSType[] = "text/css"; return rv; } NS_RELEASE(docURL); - rv = NS_NewURL(&url, nsnull, absURL); + rv = NS_NewURL(&url, absURL); if (NS_OK != rv) { return rv; } - PRInt32 ec; - nsIInputStream* iin = url->Open(&ec); - if (nsnull == iin) { + nsIInputStream* iin; + rv = NS_OpenURL(url, &iin); + if (NS_OK != rv) { NS_RELEASE(url); - return (nsresult) ec;/* XXX fix url->Open */ + return rv; } rv = NS_NewConverterStream(&uin, nsnull, iin); NS_RELEASE(iin); diff --git a/mozilla/rdf/src/nsStreamDataSource.cpp b/mozilla/rdf/src/nsStreamDataSource.cpp index 81fc61a22da..0d813488cc2 100644 --- a/mozilla/rdf/src/nsStreamDataSource.cpp +++ b/mozilla/rdf/src/nsStreamDataSource.cpp @@ -119,7 +119,7 @@ StreamDataSourceImpl::Init(const nsString& uri) if (NS_FAILED(parser->Parse(mURL))) goto done; - if (NS_FAILED(mURL->Open(lsnr))) + if (NS_FAILED(NS_OpenURL(mURL, lsnr))) goto done; done: diff --git a/mozilla/string/obsolete/nsString.cpp b/mozilla/string/obsolete/nsString.cpp index 0191c9d1b50..fc7aac58e72 100644 --- a/mozilla/string/obsolete/nsString.cpp +++ b/mozilla/string/obsolete/nsString.cpp @@ -886,7 +886,7 @@ nsString& nsString::Append(float aFloat){ * @param aCount -- number of chars to copy * @return number of chars copied */ -PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) { +PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) const { return Mid(aCopy,0,aCount); } @@ -901,7 +901,7 @@ PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) { * @param anOffset -- position where copying begins * @return number of chars copied */ -PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) { +PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) const { if(anOffsetOpen(&ec); - if (nsnull != in) { + nsIInputStream* in; + rv = NS_OpenURL(uaURL, &in); + if (rv == NS_OK) { // Translate the input using the argument character set id into unicode nsIUnicharInputStream* uin; rv = NS_NewConverterStream(&uin, nsnull, in); @@ -615,7 +615,7 @@ nsresult nsDocFactoryImpl::InitUAStyleSheet() NS_RELEASE(in); } else { - printf("open of %s failed: error=%x\n", UA_CSS_URL, ec); + printf("open of %s failed: error=%x\n", UA_CSS_URL, rv); rv = NS_ERROR_ILLEGAL_VALUE; // XXX need a better error code here } @@ -978,12 +978,12 @@ nsDocLoaderImpl::CreateURL(nsIURL** aInstancePtrResult, if (nsnull == aInstancePtrResult) { rv = NS_ERROR_NULL_POINTER; } else { - rv = NS_NewURL(&url, aBaseURL, aURLSpec, aContainer, this); + rv = NS_NewURL(&url, aURLSpec, aBaseURL, aContainer, this); if (NS_SUCCEEDED(rv)) { nsILoadAttribs* loadAttributes; - loadAttributes = url->GetLoadAttribs(); - if (nsnull != loadAttributes) { + rv = url->GetLoadAttribs(&loadAttributes); + if (rv == NS_OK) { loadAttributes->Clone(m_LoadAttrib); NS_RELEASE(loadAttributes); } @@ -1019,8 +1019,8 @@ nsDocLoaderImpl::OpenStream(nsIURL *aUrl, nsIStreamListener *aConsumer) /* Update the URL counters... */ nsILoadAttribs* loadAttributes; - loadAttributes = aUrl->GetLoadAttribs(); - if (nsnull != loadAttributes) { + rv = aUrl->GetLoadAttribs(&loadAttributes); + if (rv == NS_OK) { rv = loadAttributes->GetLoadType(&loadType); if (NS_FAILED(rv)) { loadType = nsURLLoadNormal; @@ -1103,8 +1103,8 @@ void nsDocLoaderImpl::LoadURLComplete(nsIURL* aURL, nsISupports* aBindInfo, PRIn nsILoadAttribs* loadAttributes; nsURLLoadType loadType = nsURLLoadNormal; - loadAttributes = aURL->GetLoadAttribs(); - if (nsnull != loadAttributes) { + rv = aURL->GetLoadAttribs(&loadAttributes); + if (rv == NS_OK) { rv = loadAttributes->GetLoadType(&loadType); if (NS_FAILED(rv)) { loadType = nsURLLoadNormal; @@ -1374,9 +1374,13 @@ nsresult nsDocumentBindInfo::Stop(void) { nsresult rv; nsINetService* inet; + const char* spec; - PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, - ("DocLoader - Stop(...) called for %s.\n", m_Url->GetSpec())); + if (m_Url == nsnull) return NS_OK; + rv = m_Url->GetSpec(&spec); + if (rv == NS_OK) + PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, + ("DocLoader - Stop(...) called for %s.\n", spec)); /* * Mark the IStreamListener as being aborted... If more data is pushed @@ -1397,28 +1401,30 @@ nsresult nsDocumentBindInfo::Stop(void) } -NS_METHOD nsDocumentBindInfo::GetBindInfo(nsIURL* aURL) +NS_METHOD nsDocumentBindInfo::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo) { nsresult rv = NS_OK; NS_PRECONDITION(nsnull !=m_NextStream, "DocLoader: No stream for document"); if (nsnull != m_NextStream) { - rv = m_NextStream->GetBindInfo(aURL); + rv = m_NextStream->GetBindInfo(aURL, aInfo); } return rv; } -NS_METHOD nsDocumentBindInfo::OnProgress(nsIURL* aURL, PRInt32 aProgress, - PRInt32 aProgressMax) +NS_METHOD nsDocumentBindInfo::OnProgress(nsIURL* aURL, PRUint32 aProgress, + PRUint32 aProgressMax) { nsresult rv = NS_OK; + const char* spec; + (void)aURL->GetSpec(&spec); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader - OnProgress(...) called for %s. Progress: %d. ProgressMax: %d\n", - aURL->GetSpec(), aProgress, aProgressMax)); + spec, aProgress, aProgressMax)); /* Pass the notification out to the next stream listener... */ if (nsnull != m_NextStream) { @@ -1435,7 +1441,7 @@ NS_METHOD nsDocumentBindInfo::OnProgress(nsIURL* aURL, PRInt32 aProgress, } -NS_METHOD nsDocumentBindInfo::OnStatus(nsIURL* aURL, const nsString& aMsg) +NS_METHOD nsDocumentBindInfo::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { nsresult rv = NS_OK; @@ -1458,10 +1464,12 @@ NS_METHOD nsDocumentBindInfo::OnStartBinding(nsIURL* aURL, const char *aContentT { nsresult rv = NS_OK; nsIContentViewer* viewer = nsnull; + const char* spec; + (void)aURL->GetSpec(&spec); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader - OnStartBinding(...) called for %s. Content-type is %s\n", - aURL->GetSpec(), aContentType)); + spec, aContentType)); /* If the binding has been canceled via Stop() then abort the load... */ if (NS_BINDING_ABORTED == mStatus) { @@ -1524,13 +1532,15 @@ done: NS_METHOD nsDocumentBindInfo::OnDataAvailable(nsIURL* aURL, - nsIInputStream *aStream, PRInt32 aLength) + nsIInputStream *aStream, PRUint32 aLength) { nsresult rv = NS_OK; + const char* spec; + (void)aURL->GetSpec(&spec); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader - OnDataAvailable(...) called for %s. Bytes available: %d.\n", - aURL->GetSpec(), aLength)); + spec, aLength)); /* If the binding has been canceled via Stop() then abort the load... */ if (NS_BINDING_ABORTED == mStatus) { @@ -1561,14 +1571,16 @@ done: } -NS_METHOD nsDocumentBindInfo::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, - const nsString& aMsg) +NS_METHOD nsDocumentBindInfo::OnStopBinding(nsIURL* aURL, nsresult aStatus, + const PRUnichar* aMsg) { nsresult rv = NS_OK; + const char* spec; + (void)aURL->GetSpec(&spec); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader - OnStopBinding(...) called for %s. Status: %d.\n", - aURL->GetSpec(), aStatus)); + spec, aStatus)); if (nsnull != m_NextStream) { rv = m_NextStream->OnStopBinding(aURL, aStatus, aMsg); diff --git a/mozilla/webshell/embed/ActiveX/WebShellContainer.cpp b/mozilla/webshell/embed/ActiveX/WebShellContainer.cpp index 5219e08e402..7a75c97cbed 100644 --- a/mozilla/webshell/embed/ActiveX/WebShellContainer.cpp +++ b/mozilla/webshell/embed/ActiveX/WebShellContainer.cpp @@ -210,7 +210,7 @@ CWebShellContainer::OnStartBinding(nsIURL* aURL, const char *aContentType) NS_IMETHODIMP -CWebShellContainer::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) +CWebShellContainer::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { ATLTRACE(_T("CWebShellContainer::OnProgress()\n")); return NS_OK; @@ -218,7 +218,7 @@ CWebShellContainer::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgres NS_IMETHODIMP -CWebShellContainer::OnStatus(nsIURL* aURL, const nsString &aMsg) +CWebShellContainer::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { ATLTRACE(_T("CWebShellContainer::OnStatus()\n")); @@ -233,7 +233,7 @@ CWebShellContainer::OnStatus(nsIURL* aURL, const nsString &aMsg) NS_IMETHODIMP -CWebShellContainer::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg) +CWebShellContainer::OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg) { ATLTRACE(_T("CWebShellContainer::OnStopBinding()\n")); return NS_OK; diff --git a/mozilla/webshell/embed/ActiveX/WebShellContainer.h b/mozilla/webshell/embed/ActiveX/WebShellContainer.h index b83cc688f69..16dd9b6e20f 100644 --- a/mozilla/webshell/embed/ActiveX/WebShellContainer.h +++ b/mozilla/webshell/embed/ActiveX/WebShellContainer.h @@ -57,8 +57,8 @@ public: // nsIStreamObserver NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg); }; #endif diff --git a/mozilla/webshell/src/nsDocLoader.cpp b/mozilla/webshell/src/nsDocLoader.cpp index cabfb4546ba..f09308c7063 100644 --- a/mozilla/webshell/src/nsDocLoader.cpp +++ b/mozilla/webshell/src/nsDocLoader.cpp @@ -123,12 +123,12 @@ public: nsresult Stop(void); /* nsIStreamListener interface methods... */ - NS_IMETHOD GetBindInfo(nsIURL* aURL); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *aStream, PRInt32 aLength); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString& aMsg); + NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *aStream, PRUint32 aLength); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg); nsresult GetStatus(void) { return mStatus; } @@ -590,12 +590,12 @@ nsresult nsDocFactoryImpl::InitUAStyleSheet() if (nsnull == gUAStyleSheet) { // snarf one nsIURL* uaURL; - rv = NS_NewURL(&uaURL, nsnull, nsString(UA_CSS_URL)); // XXX this bites, fix it + rv = NS_NewURL(&uaURL, nsString(UA_CSS_URL)); // XXX this bites, fix it if (NS_OK == rv) { // Get an input stream from the url - PRInt32 ec; - nsIInputStream* in = uaURL->Open(&ec); - if (nsnull != in) { + nsIInputStream* in; + rv = NS_OpenURL(uaURL, &in); + if (rv == NS_OK) { // Translate the input using the argument character set id into unicode nsIUnicharInputStream* uin; rv = NS_NewConverterStream(&uin, nsnull, in); @@ -615,7 +615,7 @@ nsresult nsDocFactoryImpl::InitUAStyleSheet() NS_RELEASE(in); } else { - printf("open of %s failed: error=%x\n", UA_CSS_URL, ec); + printf("open of %s failed: error=%x\n", UA_CSS_URL, rv); rv = NS_ERROR_ILLEGAL_VALUE; // XXX need a better error code here } @@ -978,12 +978,12 @@ nsDocLoaderImpl::CreateURL(nsIURL** aInstancePtrResult, if (nsnull == aInstancePtrResult) { rv = NS_ERROR_NULL_POINTER; } else { - rv = NS_NewURL(&url, aBaseURL, aURLSpec, aContainer, this); + rv = NS_NewURL(&url, aURLSpec, aBaseURL, aContainer, this); if (NS_SUCCEEDED(rv)) { nsILoadAttribs* loadAttributes; - loadAttributes = url->GetLoadAttribs(); - if (nsnull != loadAttributes) { + rv = url->GetLoadAttribs(&loadAttributes); + if (rv == NS_OK) { loadAttributes->Clone(m_LoadAttrib); NS_RELEASE(loadAttributes); } @@ -1019,8 +1019,8 @@ nsDocLoaderImpl::OpenStream(nsIURL *aUrl, nsIStreamListener *aConsumer) /* Update the URL counters... */ nsILoadAttribs* loadAttributes; - loadAttributes = aUrl->GetLoadAttribs(); - if (nsnull != loadAttributes) { + rv = aUrl->GetLoadAttribs(&loadAttributes); + if (rv == NS_OK) { rv = loadAttributes->GetLoadType(&loadType); if (NS_FAILED(rv)) { loadType = nsURLLoadNormal; @@ -1103,8 +1103,8 @@ void nsDocLoaderImpl::LoadURLComplete(nsIURL* aURL, nsISupports* aBindInfo, PRIn nsILoadAttribs* loadAttributes; nsURLLoadType loadType = nsURLLoadNormal; - loadAttributes = aURL->GetLoadAttribs(); - if (nsnull != loadAttributes) { + rv = aURL->GetLoadAttribs(&loadAttributes); + if (rv == NS_OK) { rv = loadAttributes->GetLoadType(&loadType); if (NS_FAILED(rv)) { loadType = nsURLLoadNormal; @@ -1374,9 +1374,13 @@ nsresult nsDocumentBindInfo::Stop(void) { nsresult rv; nsINetService* inet; + const char* spec; - PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, - ("DocLoader - Stop(...) called for %s.\n", m_Url->GetSpec())); + if (m_Url == nsnull) return NS_OK; + rv = m_Url->GetSpec(&spec); + if (rv == NS_OK) + PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, + ("DocLoader - Stop(...) called for %s.\n", spec)); /* * Mark the IStreamListener as being aborted... If more data is pushed @@ -1397,28 +1401,30 @@ nsresult nsDocumentBindInfo::Stop(void) } -NS_METHOD nsDocumentBindInfo::GetBindInfo(nsIURL* aURL) +NS_METHOD nsDocumentBindInfo::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo) { nsresult rv = NS_OK; NS_PRECONDITION(nsnull !=m_NextStream, "DocLoader: No stream for document"); if (nsnull != m_NextStream) { - rv = m_NextStream->GetBindInfo(aURL); + rv = m_NextStream->GetBindInfo(aURL, aInfo); } return rv; } -NS_METHOD nsDocumentBindInfo::OnProgress(nsIURL* aURL, PRInt32 aProgress, - PRInt32 aProgressMax) +NS_METHOD nsDocumentBindInfo::OnProgress(nsIURL* aURL, PRUint32 aProgress, + PRUint32 aProgressMax) { nsresult rv = NS_OK; + const char* spec; + (void)aURL->GetSpec(&spec); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader - OnProgress(...) called for %s. Progress: %d. ProgressMax: %d\n", - aURL->GetSpec(), aProgress, aProgressMax)); + spec, aProgress, aProgressMax)); /* Pass the notification out to the next stream listener... */ if (nsnull != m_NextStream) { @@ -1435,7 +1441,7 @@ NS_METHOD nsDocumentBindInfo::OnProgress(nsIURL* aURL, PRInt32 aProgress, } -NS_METHOD nsDocumentBindInfo::OnStatus(nsIURL* aURL, const nsString& aMsg) +NS_METHOD nsDocumentBindInfo::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { nsresult rv = NS_OK; @@ -1458,10 +1464,12 @@ NS_METHOD nsDocumentBindInfo::OnStartBinding(nsIURL* aURL, const char *aContentT { nsresult rv = NS_OK; nsIContentViewer* viewer = nsnull; + const char* spec; + (void)aURL->GetSpec(&spec); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader - OnStartBinding(...) called for %s. Content-type is %s\n", - aURL->GetSpec(), aContentType)); + spec, aContentType)); /* If the binding has been canceled via Stop() then abort the load... */ if (NS_BINDING_ABORTED == mStatus) { @@ -1524,13 +1532,15 @@ done: NS_METHOD nsDocumentBindInfo::OnDataAvailable(nsIURL* aURL, - nsIInputStream *aStream, PRInt32 aLength) + nsIInputStream *aStream, PRUint32 aLength) { nsresult rv = NS_OK; + const char* spec; + (void)aURL->GetSpec(&spec); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader - OnDataAvailable(...) called for %s. Bytes available: %d.\n", - aURL->GetSpec(), aLength)); + spec, aLength)); /* If the binding has been canceled via Stop() then abort the load... */ if (NS_BINDING_ABORTED == mStatus) { @@ -1561,14 +1571,16 @@ done: } -NS_METHOD nsDocumentBindInfo::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, - const nsString& aMsg) +NS_METHOD nsDocumentBindInfo::OnStopBinding(nsIURL* aURL, nsresult aStatus, + const PRUnichar* aMsg) { nsresult rv = NS_OK; + const char* spec; + (void)aURL->GetSpec(&spec); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader - OnStopBinding(...) called for %s. Status: %d.\n", - aURL->GetSpec(), aStatus)); + spec, aStatus)); if (nsnull != m_NextStream) { rv = m_NextStream->OnStopBinding(aURL, aStatus, aMsg); diff --git a/mozilla/webshell/src/nsPluginViewer.cpp b/mozilla/webshell/src/nsPluginViewer.cpp index e3f0b85d895..0c03864b272 100644 --- a/mozilla/webshell/src/nsPluginViewer.cpp +++ b/mozilla/webshell/src/nsPluginViewer.cpp @@ -58,13 +58,13 @@ public: // nsIStreamListener NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, - const nsString& aMsg); - NS_IMETHOD GetBindInfo(nsIURL* aURL); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, + const PRUnichar* aMsg); + NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo); NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream* aStream, - PRInt32 aCount); + PRUint32 aCount); PluginViewerImpl* mViewer; nsIStreamListener* mNextStream; @@ -317,11 +317,13 @@ PluginViewerImpl::CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds, win->ws_info = nsnull; //XXX need to figure out what this is. MMP #endif - nsAutoString fullurl; - mURL->ToString(fullurl); + PRUnichar* fullurl; + mURL->ToString(&fullurl); char* ct = mContentType.ToNewCString(); - rv = aHost->InstantiatePlugin(ct, fullurl, aResult, mOwner); + nsAutoString str = fullurl; + rv = aHost->InstantiatePlugin(ct, str, aResult, mOwner); + delete fullurl; delete ct; } @@ -489,8 +491,8 @@ PluginListener::OnStartBinding(nsIURL* aURL, const char *aContentType) } NS_IMETHODIMP -PluginListener::OnProgress(nsIURL* aURL, PRInt32 aProgress, - PRInt32 aProgressMax) +PluginListener::OnProgress(nsIURL* aURL, PRUint32 aProgress, + PRUint32 aProgressMax) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; @@ -499,7 +501,7 @@ PluginListener::OnProgress(nsIURL* aURL, PRInt32 aProgress, } NS_IMETHODIMP -PluginListener::OnStatus(nsIURL* aURL, const nsString &aMsg) +PluginListener::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; @@ -508,8 +510,8 @@ PluginListener::OnStatus(nsIURL* aURL, const nsString &aMsg) } NS_IMETHODIMP -PluginListener::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, - const nsString& aMsg) +PluginListener::OnStopBinding(nsIURL* aURL, nsresult aStatus, + const PRUnichar* aMsg) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; @@ -518,17 +520,17 @@ PluginListener::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, } NS_IMETHODIMP -PluginListener::GetBindInfo(nsIURL* aURL) +PluginListener::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - return mNextStream->GetBindInfo(aURL); + return mNextStream->GetBindInfo(aURL, aInfo); } NS_IMETHODIMP PluginListener::OnDataAvailable(nsIURL* aURL, nsIInputStream* aStream, - PRInt32 aCount) + PRUint32 aCount) { if (nsnull == mNextStream) { return NS_ERROR_FAILURE; @@ -643,7 +645,9 @@ NS_IMETHODIMP pluginInstanceOwner :: GetURL(const char *aURL, const char *aTarge { nsAutoString uniurl = nsAutoString(aURL); nsAutoString unitarget = nsAutoString(aTarget); - nsAutoString base = nsAutoString(url->GetSpec()); + const char* spec; + (void)url->GetSpec(&spec); + nsAutoString base = nsAutoString(spec); nsAutoString fullurl; // Create an absolute URL diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index e0c4f9ff4fe..b884842baf1 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -238,9 +238,9 @@ public: // nsIStreamObserver NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg); // nsINetSupport interface methods NS_IMETHOD_(void) Alert(const nsString &aText); @@ -1857,10 +1857,14 @@ nsWebShell::OnConnectionsComplete() url = document->GetDocumentURL(); if (nsnull != url) { - urlString = url->GetSpec(); + const char* spec; + rv = url->GetSpec(&spec); /* XXX: The load status needs to be passed in... */ - rv = mContainer->EndLoadURL(this, urlString, /* XXX */ 0 ); + if (rv == NS_OK) { + urlString = spec; + rv = mContainer->EndLoadURL(this, urlString, /* XXX */ 0 ); + } NS_RELEASE(url); } NS_RELEASE(document); @@ -1945,7 +1949,10 @@ nsWebShell::RefreshURL(nsIURL* aURL, PRInt32 millis, PRBool repeat) data->mShell = this; NS_ADDREF(data->mShell); - data->mUrlSpec = aURL->GetSpec(); + const char* spec; + rv = aURL->GetSpec(&spec); + + data->mUrlSpec = spec; data->mDelay = millis; data->mRepeat = repeat; @@ -2003,7 +2010,7 @@ nsWebShell::OnStartBinding(nsIURL* aURL, const char *aContentType) NS_IMETHODIMP -nsWebShell::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) +nsWebShell::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { nsresult rv = NS_OK; @@ -2012,7 +2019,9 @@ nsWebShell::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) } if (nsnull != mContainer) { - nsAutoString urlString(aURL->GetSpec()); + const char* spec; + (void)aURL->GetSpec(&spec); + nsAutoString urlString(spec); rv = mContainer->ProgressLoadURL(this, urlString, aProgress, aProgressMax); } @@ -2031,7 +2040,7 @@ nsWebShell::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) NS_IMETHODIMP -nsWebShell::OnStatus(nsIURL* aURL, const nsString &aMsg) +nsWebShell::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { nsresult rv = NS_OK; @@ -2053,7 +2062,7 @@ nsWebShell::OnStatus(nsIURL* aURL, const nsString &aMsg) NS_IMETHODIMP -nsWebShell::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg) +nsWebShell::OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg) { nsresult rv = NS_OK; diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index d63e7aa73f4..bfcbbb4b7ad 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -1783,13 +1783,16 @@ nsBrowserWindow::FocusAvailable(nsIWebShell* aFocusedWebShell) NS_IMETHODIMP nsBrowserWindow::OnProgress(nsIURL* aURL, - PRInt32 aProgress, - PRInt32 aProgressMax) + PRUint32 aProgress, + PRUint32 aProgressMax) { if (mStatus) { nsAutoString url; if (nsnull != aURL) { - aURL->ToString(url); + PRUnichar* str; + aURL->ToString(&str); + url = str; + delete str; } url.Append(": progress "); url.Append(aProgress, 10); @@ -1805,7 +1808,7 @@ nsBrowserWindow::OnProgress(nsIURL* aURL, } NS_IMETHODIMP -nsBrowserWindow::OnStatus(nsIURL* aURL, const nsString& aMsg) +nsBrowserWindow::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { if (mStatus) { PRUint32 size; @@ -1820,7 +1823,10 @@ nsBrowserWindow::OnStartBinding(nsIURL* aURL, const char *aContentType) if (mStatus) { nsAutoString url; if (nsnull != aURL) { - aURL->ToString(url); + PRUnichar* str; + aURL->ToString(&str); + url = str; + delete str; } url.Append(": start"); PRUint32 size; @@ -1831,13 +1837,16 @@ nsBrowserWindow::OnStartBinding(nsIURL* aURL, const char *aContentType) NS_IMETHODIMP nsBrowserWindow::OnStopBinding(nsIURL* aURL, - PRInt32 status, - const nsString& aMsg) + nsresult status, + const PRUnichar* aMsg) { if (mStatus) { nsAutoString url; if (nsnull != aURL) { - aURL->ToString(url); + PRUnichar* str; + aURL->ToString(&str); + url = str; + delete str; } url.Append(": stop"); PRUint32 size; @@ -2587,7 +2596,8 @@ nsBrowserWindow::DoDebugSave() if (rv == NS_OK) { - const char* name = url->GetFile(); + const char* name; + rv = url->GetFile(&name); path = name; doSave = GetSaveFileNameFromFileSelector(mWindow, path); diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.h b/mozilla/webshell/tests/viewer/nsBrowserWindow.h index f864217d53c..dd5dd21cdd6 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.h +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.h @@ -87,9 +87,9 @@ public: // nsIStreamObserver NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString &aMsg); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); // nsIWebShellContainer NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason); diff --git a/mozilla/webshell/tests/viewer/nsViewerApp.cpp b/mozilla/webshell/tests/viewer/nsViewerApp.cpp index d2ee65ef0c0..4751a08c22c 100644 --- a/mozilla/webshell/tests/viewer/nsViewerApp.cpp +++ b/mozilla/webshell/tests/viewer/nsViewerApp.cpp @@ -905,7 +905,8 @@ nsViewerApp::CreateRobot(nsBrowserWindow* aWindow) if (nsnull != shell) { nsIDocument* doc = shell->GetDocument(); if (nsnull!=doc) { - const char * str = doc->GetDocumentURL()->GetSpec(); + const char * str; + nsresult rv = doc->GetDocumentURL()->GetSpec(&str); nsVoidArray * gWorkList = new nsVoidArray(); gWorkList->AppendElement(new nsString(str)); #if defined(XP_PC) && defined(NS_DEBUG) diff --git a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp index a9472ea32ad..2d561ee44a5 100644 --- a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp +++ b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp @@ -202,34 +202,38 @@ nsWebCrawler::OnStartBinding(nsIURL* aURL, const char *aContentType) { if (mVerbose) { printf("Crawler: starting "); - nsAutoString tmp; - aURL->ToString(tmp); - fputs(tmp, stdout); + PRUnichar* tmp; + aURL->ToString(&tmp); + nsAutoString tmp2 = tmp; + fputs(tmp2, stdout); + delete tmp; printf("\n"); } return NS_OK; } NS_IMETHODIMP -nsWebCrawler::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) +nsWebCrawler::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax) { return NS_OK; } NS_IMETHODIMP -nsWebCrawler::OnStatus(nsIURL* aURL, const nsString& aMsg) +nsWebCrawler::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { return NS_OK; } NS_IMETHODIMP -nsWebCrawler::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg) +nsWebCrawler::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg) { if (mVerbose) { printf("Crawler: stopping "); - nsAutoString tmp; - aURL->ToString(tmp); - fputs(tmp, stdout); + PRUnichar* tmp; + aURL->ToString(&tmp); + nsAutoString tmp2 = tmp; + fputs(tmp2, stdout); + delete tmp; printf("\n"); } return NS_OK; @@ -286,8 +290,11 @@ nsWebCrawler:: EndLoadURL(nsIWebShell* aShell, PerformRegressionTest(regressionFileName); } } - else - printf("could not open output file for %s\n", url->GetFile()); + else { + const char* file; + (void)url->GetFile(&file); + printf("could not open output file for %s\n", file); + } NS_RELEASE(url); } } @@ -332,7 +339,9 @@ nsWebCrawler::GetOutputFile(nsIURL *aURL, nsString& aOutputName) if (nsnull!=aURL) { char *inputFileName; - nsAutoString inputFileFullPath(aURL->GetFile()); + const char* file; + (void)aURL->GetFile(&file); + nsAutoString inputFileFullPath(file); PRInt32 fileNameOffset = inputFileFullPath.RFind('/'); if (-1==fileNameOffset) { @@ -509,8 +518,9 @@ nsWebCrawler::OkToLoad(const nsString& aURLSpec) nsIURL* url; nsresult rv = NS_NewURL(&url, aURLSpec); if (NS_OK == rv) { - const char* host = url->GetHost(); - if (nsnull != host) { + const char* host; + rv = url->GetHost(&host); + if (rv == NS_OK) { PRInt32 hostlen = PL_strlen(host); // Check domains to avoid diff --git a/mozilla/webshell/tests/viewer/nsWebCrawler.h b/mozilla/webshell/tests/viewer/nsWebCrawler.h index 13a645522e3..e6709c52581 100644 --- a/mozilla/webshell/tests/viewer/nsWebCrawler.h +++ b/mozilla/webshell/tests/viewer/nsWebCrawler.h @@ -42,9 +42,9 @@ public: // nsIStreamObserver NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); // Add a url to load void AddURL(const nsString& aURL); diff --git a/mozilla/widget/src/windows/nsRadioGroup.cpp b/mozilla/widget/src/windows/nsRadioGroup.cpp index 58f39934e01..a1b91817496 100644 --- a/mozilla/widget/src/windows/nsRadioGroup.cpp +++ b/mozilla/widget/src/windows/nsRadioGroup.cpp @@ -173,7 +173,10 @@ NS_METHOD nsRadioGroup::SetName(const nsString &aName) { mName.SetLength(0); mName.Append(aName); - mRadioGroupHashtable->Put(new nsStringHashKey(aName), this); + nsStringHashKey* key = new nsStringHashKey(aName); + if (key == NULL) + return NS_ERROR_OUT_OF_MEMORY; + mRadioGroupHashtable->Put(key, this); return NS_OK; } diff --git a/mozilla/xpcom/components/nsServiceManager.cpp b/mozilla/xpcom/components/nsServiceManager.cpp index c122394eaa0..68cbaff3169 100644 --- a/mozilla/xpcom/components/nsServiceManager.cpp +++ b/mozilla/xpcom/components/nsServiceManager.cpp @@ -205,8 +205,8 @@ nsServiceManagerImpl::QueryInterface(const nsIID& aIID, void* *aInstancePtr) nsresult nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, - nsISupports* *result, - nsIShutdownListener* shutdownListener) + nsISupports* *result, + nsIShutdownListener* shutdownListener) { nsresult err = NS_OK; PR_CEnterMonitor(this); diff --git a/mozilla/xpcom/ds/nsByteBuffer.cpp b/mozilla/xpcom/ds/nsByteBuffer.cpp index bd3c9b72467..167c9842a0b 100644 --- a/mozilla/xpcom/ds/nsByteBuffer.cpp +++ b/mozilla/xpcom/ds/nsByteBuffer.cpp @@ -23,25 +23,25 @@ class ByteBufferImpl : public nsIByteBuffer { public: - ByteBufferImpl(PRInt32 aBufferSize); + ByteBufferImpl(PRUint32 aBufferSize); ~ByteBufferImpl(); NS_DECL_ISUPPORTS - virtual PRInt32 GetLength() const; - virtual PRInt32 GetBufferSize() const; + virtual PRUint32 GetLength(void) const; + virtual PRUint32 GetBufferSize(void) const; virtual char* GetBuffer() const; - virtual PRBool Grow(PRInt32 aNewSize); + virtual PRBool Grow(PRUint32 aNewSize); virtual PRInt32 Fill(nsresult* aErrorCode, nsIInputStream* aStream, - PRInt32 aKeep); + PRUint32 aKeep); char* mBuffer; - PRInt32 mSpace; - PRInt32 mLength; + PRUint32 mSpace; + PRUint32 mLength; }; -ByteBufferImpl::ByteBufferImpl(PRInt32 aBufferSize) +ByteBufferImpl::ByteBufferImpl(PRUint32 aBufferSize) { - if (PRUint32(aBufferSize) < MIN_BUFFER_SIZE) { + if (aBufferSize < MIN_BUFFER_SIZE) { aBufferSize = MIN_BUFFER_SIZE; } mSpace = aBufferSize; @@ -62,24 +62,24 @@ ByteBufferImpl::~ByteBufferImpl() mLength = 0; } -PRInt32 ByteBufferImpl::GetLength() const +PRUint32 ByteBufferImpl::GetLength(void) const { return mLength; } -PRInt32 ByteBufferImpl::GetBufferSize() const +PRUint32 ByteBufferImpl::GetBufferSize(void) const { return mSpace; } -char* ByteBufferImpl::GetBuffer() const +char* ByteBufferImpl::GetBuffer(void) const { return mBuffer; } -PRBool ByteBufferImpl::Grow(PRInt32 aNewSize) +PRBool ByteBufferImpl::Grow(PRUint32 aNewSize) { - if (PRUint32(aNewSize) < MIN_BUFFER_SIZE) { + if (aNewSize < MIN_BUFFER_SIZE) { aNewSize = MIN_BUFFER_SIZE; } char* newbuf = new char[aNewSize]; @@ -95,10 +95,10 @@ PRBool ByteBufferImpl::Grow(PRInt32 aNewSize) } PRInt32 ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream, - PRInt32 aKeep) + PRUint32 aKeep) { NS_PRECONDITION(nsnull != aStream, "null stream"); - NS_PRECONDITION(PRUint32(aKeep) <= PRUint32(mLength), "illegal keep count"); + NS_PRECONDITION(aKeep <= mLength, "illegal keep count"); if ((nsnull == aStream) || (PRUint32(aKeep) > PRUint32(mLength))) { // whoops *aErrorCode = NS_BASE_STREAM_ILLEGAL_ARGS; @@ -112,8 +112,8 @@ PRInt32 ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream, // Read in some new data mLength = aKeep; - PRInt32 amount = mSpace - aKeep; - PRInt32 nb; + PRUint32 amount = mSpace - aKeep; + PRUint32 nb; *aErrorCode = aStream->Read(mBuffer, aKeep, amount, &nb); if (NS_SUCCEEDED(*aErrorCode)) { mLength += nb; @@ -125,7 +125,7 @@ PRInt32 ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream, NS_BASE nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult, nsISupports* aOuter, - PRInt32 aBufferSize) + PRUint32 aBufferSize) { if (nsnull != aOuter) { return NS_ERROR_NO_AGGREGATION; diff --git a/mozilla/xpcom/ds/nsCRT.cpp b/mozilla/xpcom/ds/nsCRT.cpp index 830caf58f65..c40633879ca 100644 --- a/mozilla/xpcom/ds/nsCRT.cpp +++ b/mozilla/xpcom/ds/nsCRT.cpp @@ -366,6 +366,15 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRInt32 n) return 0; } +PRUnichar* nsCRT::strdup(const PRUnichar* str) +{ + PRInt32 len = nsCRT::strlen(str) + 1; // add one for null + PRUnichar* rslt = new PRUnichar[len]; + if (rslt == NULL) return NULL; + nsCRT::memcpy(rslt, str, len * sizeof(PRUnichar)); + return rslt; +} + PRUint32 nsCRT::HashValue(const PRUnichar* us) { PRUint32 rv = 0; diff --git a/mozilla/xpcom/ds/nsCRT.h b/mozilla/xpcom/ds/nsCRT.h index 6c7ef58baa3..88c24886783 100644 --- a/mozilla/xpcom/ds/nsCRT.h +++ b/mozilla/xpcom/ds/nsCRT.h @@ -71,6 +71,10 @@ public: return PRInt32(PL_strncasecmp(s1, s2, aMaxLen)); } + static char* strdup(const char* str) { + return PL_strdup(str); + } + /// Like strlen except for ucs2 strings static PRInt32 strlen(const PRUnichar* s); @@ -98,6 +102,8 @@ public: static PRInt32 strncasecmp(const PRUnichar* s1, const char* s2, PRInt32 aMaxLen); + static PRUnichar* strdup(const PRUnichar* str); + /// Compute a hashcode for a ucs2 string static PRUint32 HashValue(const PRUnichar* s1); diff --git a/mozilla/xpcom/ds/nsIByteBuffer.h b/mozilla/xpcom/ds/nsIByteBuffer.h index 43a04c29342..b27d8fd52f3 100644 --- a/mozilla/xpcom/ds/nsIByteBuffer.h +++ b/mozilla/xpcom/ds/nsIByteBuffer.h @@ -31,26 +31,27 @@ class nsIInputStream; class nsIByteBuffer : public nsISupports { public: /** @return length of buffer, i.e. how many bytes are currently in it. */ - virtual PRInt32 GetLength() const = 0; + virtual PRUint32 GetLength(void) const = 0; /** @return number of bytes allocated in the buffer */ - virtual PRInt32 GetBufferSize() const = 0; + virtual PRUint32 GetBufferSize(void) const = 0; /** @return the buffer */ - virtual char* GetBuffer() const = 0; + virtual char* GetBuffer(void) const = 0; /** Grow buffer to aNewSize bytes. */ - virtual PRBool Grow(PRInt32 aNewSize) = 0; + virtual PRBool Grow(PRUint32 aNewSize) = 0; /** Fill the buffer with data from aStream. Don't grow the buffer, only * read until length of buffer equals buffer size. */ virtual PRInt32 Fill(nsresult* aErrorCode, nsIInputStream* aStream, - PRInt32 aKeep) = 0; + PRUint32 aKeep) = 0; }; /** Create a new byte buffer using the given buffer size. */ extern NS_BASE nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult, nsISupports* aOuter, - PRInt32 aBufferSize = 0); + PRUint32 aBufferSize = 0); #endif /* nsIByteBuffer_h___ */ + diff --git a/mozilla/xpcom/ds/nsIUnicharBuffer.h b/mozilla/xpcom/ds/nsIUnicharBuffer.h index a5f57d7886b..4ce3a0cab54 100644 --- a/mozilla/xpcom/ds/nsIUnicharBuffer.h +++ b/mozilla/xpcom/ds/nsIUnicharBuffer.h @@ -41,6 +41,6 @@ public: extern NS_BASE nsresult NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult, nsISupports* aOuter, - PRInt32 aBufferSize = 0); + PRUint32 aBufferSize = 0); #endif /* nsIUnicharBuffer_h___ */ diff --git a/mozilla/xpcom/ds/nsString.cpp b/mozilla/xpcom/ds/nsString.cpp index 0191c9d1b50..fc7aac58e72 100644 --- a/mozilla/xpcom/ds/nsString.cpp +++ b/mozilla/xpcom/ds/nsString.cpp @@ -886,7 +886,7 @@ nsString& nsString::Append(float aFloat){ * @param aCount -- number of chars to copy * @return number of chars copied */ -PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) { +PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) const { return Mid(aCopy,0,aCount); } @@ -901,7 +901,7 @@ PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) { * @param anOffset -- position where copying begins * @return number of chars copied */ -PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) { +PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) const { if(anOffsetRead(mBuffer, aKeep, amount, &nb); + PRUint32 nb; + NS_ASSERTION(aKeep >= 0, "unsigned madness"); + NS_ASSERTION(amount >= 0, "unsigned madness"); + *aErrorCode = aStream->Read(mBuffer, (PRUint32)aKeep, (PRUint32)amount, &nb); if (NS_SUCCEEDED(*aErrorCode)) { mLength += nb; } @@ -127,7 +129,7 @@ PRInt32 UnicharBufferImpl::Fill(nsresult* aErrorCode, NS_BASE nsresult NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult, nsISupports* aOuter, - PRInt32 aBufferSize) + PRUint32 aBufferSize) { if (nsnull != aOuter) { return NS_ERROR_NO_AGGREGATION; diff --git a/mozilla/xpcom/io/nsIBaseStream.h b/mozilla/xpcom/io/nsIBaseStream.h index 06efd0fad4f..1b716332f4a 100644 --- a/mozilla/xpcom/io/nsIBaseStream.h +++ b/mozilla/xpcom/io/nsIBaseStream.h @@ -38,19 +38,18 @@ public: /** Error codes */ //@{ -// XXX fix up the values so they are not total hacks... MMP /// End of file -#define NS_BASE_STREAM_EOF 0x80001001 +#define NS_BASE_STREAM_EOF NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 1) /// Stream closed -#define NS_BASE_STREAM_CLOSED 0x80001002 +#define NS_BASE_STREAM_CLOSED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 2) /// Error from the operating system -#define NS_BASE_STREAM_OSERROR 0x80001003 +#define NS_BASE_STREAM_OSERROR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 3) /// Illegal arguments -#define NS_BASE_STREAM_ILLEGAL_ARGS 0x80001004 +#define NS_BASE_STREAM_ILLEGAL_ARGS NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 4) /// For unichar streams -#define NS_BASE_STREAM_NO_CONVERTER 0x80001005 +#define NS_BASE_STREAM_NO_CONVERTER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 5) /// For unichar streams -#define NS_BASE_STREAM_BAD_CONVERSION 0x80001006 +#define NS_BASE_STREAM_BAD_CONVERSION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 6) //@} diff --git a/mozilla/xpcom/io/nsIInputStream.h b/mozilla/xpcom/io/nsIInputStream.h index 37c942927f3..a1c5b6167d5 100644 --- a/mozilla/xpcom/io/nsIInputStream.h +++ b/mozilla/xpcom/io/nsIInputStream.h @@ -35,7 +35,7 @@ public: * @return error status */ NS_IMETHOD - GetLength(PRInt32 *aLength) = 0; + GetLength(PRUint32 *aLength) = 0; /** Read data from the stream. * @param aErrorCode the error code if an error occurs @@ -48,7 +48,7 @@ public: * @return error status */ NS_IMETHOD - Read(char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aReadCount) = 0; + Read(char* aBuf, PRUint32 aOffset, PRUint32 aCount, PRUint32 *aReadCount) = 0; }; #endif /* nsInputStream_h___ */ diff --git a/mozilla/xpcom/io/nsIOutputStream.h b/mozilla/xpcom/io/nsIOutputStream.h index ad032f52767..795416092d3 100644 --- a/mozilla/xpcom/io/nsIOutputStream.h +++ b/mozilla/xpcom/io/nsIOutputStream.h @@ -39,7 +39,7 @@ public: * @return error status */ NS_IMETHOD - Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aWriteCount) = 0; + Write(const char* aBuf, PRUint32 aOffset, PRUint32 aCount, PRUint32 *aWriteCount) = 0; }; diff --git a/mozilla/xpcom/io/nsIUnicharInputStream.h b/mozilla/xpcom/io/nsIUnicharInputStream.h index ecd21b775d4..24de6710310 100644 --- a/mozilla/xpcom/io/nsIUnicharInputStream.h +++ b/mozilla/xpcom/io/nsIUnicharInputStream.h @@ -43,9 +43,9 @@ enum nsCharSetID { class nsIUnicharInputStream : public nsISupports { public: NS_IMETHOD Read(PRUnichar* aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount) = 0; + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount) = 0; NS_IMETHOD Close() = 0; }; @@ -66,12 +66,12 @@ public: * aDst; aSrcLen is updated to indicate how much data was used in * the source buffer. */ - virtual PRInt32 Convert(PRUnichar* aDst, - PRInt32 aDstOffset, - PRInt32& aDstLen, - const char* aSrc, - PRInt32 aSrcOffset, - PRInt32& aSrcLen) = 0; + NS_IMETHOD Convert(PRUnichar* aDst, + PRUint32 aDstOffset, + PRUint32& aDstLen, + const char* aSrc, + PRUint32 aSrcOffset, + PRUint32& aSrcLen) = 0; }; /** Create a new nsUnicharInputStream that provides a converter for the diff --git a/mozilla/xpcom/io/nsUnicharInputStream.cpp b/mozilla/xpcom/io/nsUnicharInputStream.cpp index 73dca958566..feb1be7d6e3 100644 --- a/mozilla/xpcom/io/nsUnicharInputStream.cpp +++ b/mozilla/xpcom/io/nsUnicharInputStream.cpp @@ -37,14 +37,14 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD Read(PRUnichar* aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount); + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount); NS_IMETHOD Close(); nsString* mString; - PRInt32 mPos; - PRInt32 mLen; + PRUint32 mPos; + PRUint32 mLen; }; StringUnicharInputStream::StringUnicharInputStream(nsString* aString) @@ -63,16 +63,17 @@ StringUnicharInputStream::~StringUnicharInputStream() } nsresult StringUnicharInputStream::Read(PRUnichar* aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount) + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount) { if (mPos >= mLen) { *aReadCount = 0; return (nsresult)-1; } const PRUnichar* us = mString->GetUnicode(); - PRInt32 amount = mLen - mPos; + NS_ASSERTION(mLen >= mPos, "unsigned madness"); + PRUint32 amount = mLen - mPos; if (amount > aCount) { amount = aCount; } @@ -119,12 +120,12 @@ public: IsoLatin1Converter(); NS_DECL_ISUPPORTS - virtual PRInt32 Convert(PRUnichar* aDst, - PRInt32 aDstOffset, - PRInt32& aDstLen, - const char* aSrc, - PRInt32 aSrcOffset, - PRInt32& aSrcLen); + NS_IMETHOD Convert(PRUnichar* aDst, + PRUint32 aDstOffset, + PRUint32& aDstLen, + const char* aSrc, + PRUint32 aSrcOffset, + PRUint32& aSrcLen); }; IsoLatin1Converter::IsoLatin1Converter() @@ -135,14 +136,14 @@ IsoLatin1Converter::IsoLatin1Converter() NS_DEFINE_IID(kIB2UConverterIID, NS_IB2UCONVERTER_IID); NS_IMPL_ISUPPORTS(IsoLatin1Converter,kIB2UConverterIID); -PRInt32 IsoLatin1Converter::Convert(PRUnichar* aDst, - PRInt32 aDstOffset, - PRInt32& aDstLen, +nsresult IsoLatin1Converter::Convert(PRUnichar* aDst, + PRUint32 aDstOffset, + PRUint32& aDstLen, const char* aSrc, - PRInt32 aSrcOffset, - PRInt32& aSrcLen) + PRUint32 aSrcOffset, + PRUint32& aSrcLen) { - PRInt32 amount = aSrcLen; + PRUint32 amount = aSrcLen; if (aSrcLen > aDstLen) { amount = aDstLen; } @@ -181,14 +182,14 @@ class ConverterInputStream : public nsIUnicharInputStream { public: ConverterInputStream(nsIInputStream* aStream, nsIB2UConverter* aConverter, - PRInt32 aBufSize); + PRUint32 aBufSize); ~ConverterInputStream(); NS_DECL_ISUPPORTS NS_IMETHOD Read(PRUnichar* aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount); + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount); NS_IMETHOD Close(); protected: @@ -197,15 +198,15 @@ protected: nsIInputStream* mInput; nsIB2UConverter* mConverter; nsIByteBuffer* mByteData; - PRInt32 mByteDataOffset; + PRUint32 mByteDataOffset; nsIUnicharBuffer* mUnicharData; - PRInt32 mUnicharDataOffset; - PRInt32 mUnicharDataLength; + PRUint32 mUnicharDataOffset; + PRUint32 mUnicharDataLength; }; ConverterInputStream::ConverterInputStream(nsIInputStream* aStream, nsIB2UConverter* aConverter, - PRInt32 aBufferSize) + PRUint32 aBufferSize) { NS_INIT_REFCNT(); mInput = aStream; aStream->AddRef(); @@ -250,11 +251,12 @@ nsresult ConverterInputStream::Close() } nsresult ConverterInputStream::Read(PRUnichar* aBuf, - PRInt32 aOffset, - PRInt32 aCount, - PRInt32 *aReadCount) + PRUint32 aOffset, + PRUint32 aCount, + PRUint32 *aReadCount) { - PRInt32 rv = mUnicharDataLength - mUnicharDataOffset; + NS_ASSERTION(mUnicharDataLength >= mUnicharDataOffset, "unsigned madness"); + PRUint32 rv = mUnicharDataLength - mUnicharDataOffset; nsresult errorCode; if (0 == rv) { // Fill the unichar buffer @@ -282,7 +284,8 @@ PRInt32 ConverterInputStream::Fill(nsresult * aErrorCode) return -1; } - PRInt32 remainder = mByteData->GetLength() - mByteDataOffset; + NS_ASSERTION(mByteData->GetLength() >= mByteDataOffset, "unsigned madness"); + PRUint32 remainder = mByteData->GetLength() - mByteDataOffset; mByteDataOffset = remainder; PRInt32 nb = mByteData->Fill(aErrorCode, mInput, remainder); if (nb <= 0) { @@ -296,8 +299,8 @@ PRInt32 ConverterInputStream::Fill(nsresult * aErrorCode) NS_ASSERTION(remainder + nb == mByteData->GetLength(), "bad nb"); // Now convert as much of the byte buffer to unicode as possible - PRInt32 dstLen = mUnicharData->GetBufferSize(); - PRInt32 srcLen = remainder + nb; + PRUint32 dstLen = mUnicharData->GetBufferSize(); + PRUint32 srcLen = remainder + nb; *aErrorCode = mConverter->Convert(mUnicharData->GetBuffer(), 0, dstLen, mByteData->GetBuffer(), 0, srcLen); mUnicharDataOffset = 0; diff --git a/mozilla/xpcom/src/nsServiceManager.cpp b/mozilla/xpcom/src/nsServiceManager.cpp index c122394eaa0..68cbaff3169 100644 --- a/mozilla/xpcom/src/nsServiceManager.cpp +++ b/mozilla/xpcom/src/nsServiceManager.cpp @@ -205,8 +205,8 @@ nsServiceManagerImpl::QueryInterface(const nsIID& aIID, void* *aInstancePtr) nsresult nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, - nsISupports* *result, - nsIShutdownListener* shutdownListener) + nsISupports* *result, + nsIShutdownListener* shutdownListener) { nsresult err = NS_OK; PR_CEnterMonitor(this); diff --git a/mozilla/xpcom/string/obsolete/nsString.cpp b/mozilla/xpcom/string/obsolete/nsString.cpp index 0191c9d1b50..fc7aac58e72 100644 --- a/mozilla/xpcom/string/obsolete/nsString.cpp +++ b/mozilla/xpcom/string/obsolete/nsString.cpp @@ -886,7 +886,7 @@ nsString& nsString::Append(float aFloat){ * @param aCount -- number of chars to copy * @return number of chars copied */ -PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) { +PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) const { return Mid(aCopy,0,aCount); } @@ -901,7 +901,7 @@ PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) { * @param anOffset -- position where copying begins * @return number of chars copied */ -PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) { +PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) const { if(anOffsetOpen(&ec); + nsresult ec; + nsIInputStream* in; + ec = NS_OpenURL(url, &in); if (nsnull == in) { printf("open of url('%s') failed: error=%x\n", urlName, ec); return -1; @@ -75,7 +76,7 @@ int main(int argc, char** argv) PRInt32 count = 0; for (;;) { PRUnichar buf[1000]; - PRInt32 nb; + PRUint32 nb; ec = uin->Read(buf, 0, 1000, &nb); if (ec < 0) { if (ec != NS_BASE_STREAM_EOF) { diff --git a/mozilla/xpfe/xpviewer/src/nsBrowserWindow.cpp b/mozilla/xpfe/xpviewer/src/nsBrowserWindow.cpp index e7d995382e4..df9e96c55f7 100644 --- a/mozilla/xpfe/xpviewer/src/nsBrowserWindow.cpp +++ b/mozilla/xpfe/xpviewer/src/nsBrowserWindow.cpp @@ -2468,13 +2468,16 @@ nsBrowserWindow::FocusAvailable(nsIWebShell* aFocusedWebShell) //---------------------------------------- NS_IMETHODIMP nsBrowserWindow::OnProgress(nsIURL* aURL, - PRInt32 aProgress, - PRInt32 aProgressMax) + PRUint32 aProgress, + PRUint32 aProgressMax) { if (mStatusBar) { nsAutoString url; if (nsnull != aURL) { - aURL->ToString(url); + PRUnichar* str; + aURL->ToString(&str); + url = str; + delete str; } url.Append(": progress "); url.Append(aProgress, 10); @@ -2490,7 +2493,7 @@ nsBrowserWindow::OnProgress(nsIURL* aURL, //---------------------------------------- NS_IMETHODIMP -nsBrowserWindow::OnStatus(nsIURL* aURL, const nsString& aMsg) +nsBrowserWindow::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { SetStatus(aMsg); return NS_OK; @@ -2503,7 +2506,10 @@ nsBrowserWindow::OnStartBinding(nsIURL* aURL, const char *aContentType) if (mStatusBar) { nsAutoString url; if (nsnull != aURL) { - aURL->ToString(url); + PRUnichar* str; + aURL->ToString(&str); + url = str; + delete str; } url.Append(": start"); SetStatus(url); @@ -2514,12 +2520,15 @@ nsBrowserWindow::OnStartBinding(nsIURL* aURL, const char *aContentType) //---------------------------------------- NS_IMETHODIMP nsBrowserWindow::OnStopBinding(nsIURL* aURL, - PRInt32 status, - const nsString& aMsg) + nsresult status, + const PRUnichar* aMsg) { nsAutoString url; if (nsnull != aURL) { - aURL->ToString(url); + PRUnichar* str; + aURL->ToString(&str); + url = str; + delete str; } url.Append(": stop"); SetStatus(url); @@ -3189,7 +3198,8 @@ nsBrowserWindow::DoDebugSave() if (rv == NS_OK) { - const char* name = url->GetFile(); + const char* name; + (void)url->GetFile(&name); path = name; doSave = GetSaveFileNameFromFileSelector(mWindow, path); diff --git a/mozilla/xpfe/xpviewer/src/nsBrowserWindow.h b/mozilla/xpfe/xpviewer/src/nsBrowserWindow.h index 06ad1869782..30412d32934 100644 --- a/mozilla/xpfe/xpviewer/src/nsBrowserWindow.h +++ b/mozilla/xpfe/xpviewer/src/nsBrowserWindow.h @@ -101,9 +101,9 @@ public: // nsIStreamObserver NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString &aMsg); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); // nsIWebShellContainer NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason); diff --git a/mozilla/xpfe/xpviewer/src/nsViewerApp.cpp b/mozilla/xpfe/xpviewer/src/nsViewerApp.cpp index c4007a89239..d6016613f9e 100644 --- a/mozilla/xpfe/xpviewer/src/nsViewerApp.cpp +++ b/mozilla/xpfe/xpviewer/src/nsViewerApp.cpp @@ -921,7 +921,8 @@ nsViewerApp::CreateRobot(nsBrowserWindow* aWindow) if (nsnull != shell) { nsIDocument* doc = shell->GetDocument(); if (nsnull!=doc) { - const char * str = doc->GetDocumentURL()->GetSpec(); + const char * str; + (void)doc->GetDocumentURL()->GetSpec(&str); nsVoidArray * gWorkList = new nsVoidArray(); gWorkList->AppendElement(new nsString(str)); #if defined(XP_PC_ROBOT) && defined(NS_DEBUG) diff --git a/mozilla/xpfe/xpviewer/src/nsXPBaseWindow.cpp b/mozilla/xpfe/xpviewer/src/nsXPBaseWindow.cpp index de564f60b8d..8aee8787dec 100644 --- a/mozilla/xpfe/xpviewer/src/nsXPBaseWindow.cpp +++ b/mozilla/xpfe/xpviewer/src/nsXPBaseWindow.cpp @@ -556,14 +556,14 @@ NS_IMETHODIMP nsXPBaseWindow::NewWebShell(PRUint32 aChromeMask, NS_IMETHODIMP nsXPBaseWindow::OnProgress(nsIURL* aURL, - PRInt32 aProgress, - PRInt32 aProgressMax) + PRUint32 aProgress, + PRUint32 aProgressMax) { return NS_OK; } //---------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::OnStatus(nsIURL* aURL, const nsString& aMsg) +NS_IMETHODIMP nsXPBaseWindow::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) { return NS_OK; } @@ -575,7 +575,7 @@ NS_IMETHODIMP nsXPBaseWindow::OnStartBinding(nsIURL* aURL, const char *aContentT } //---------------------------------------- -NS_IMETHODIMP nsXPBaseWindow::OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg) +NS_IMETHODIMP nsXPBaseWindow::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg) { return NS_OK; } diff --git a/mozilla/xpfe/xpviewer/src/nsXPBaseWindow.h b/mozilla/xpfe/xpviewer/src/nsXPBaseWindow.h index 1d1faddd1e0..ec84eeace08 100644 --- a/mozilla/xpfe/xpviewer/src/nsXPBaseWindow.h +++ b/mozilla/xpfe/xpviewer/src/nsXPBaseWindow.h @@ -89,9 +89,9 @@ public: // nsIStreamObserver NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); - NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); - NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg); - NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString &aMsg); + NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg); // nsIWebShellContainer NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason);