зеркало из https://github.com/mozilla/gecko-dev.git
Removed obsolete necko util stuff. Can't remove the macbuild stuff yet because it's really building timers.
This commit is contained in:
Родитель
08a160e41d
Коммит
6105a4546e
|
@ -1,32 +0,0 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.org 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.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.org 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.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH = ..\..
|
||||
|
||||
MODULE = necko
|
||||
|
||||
DIRS= \
|
||||
public \
|
||||
src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
|
@ -1,5 +0,0 @@
|
|||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
nsIBlockingNotification.h
|
|
@ -1,37 +0,0 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.org 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.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = necko
|
||||
|
||||
EXPORTS = \
|
||||
nsNeckoUtil.h \
|
||||
nsIBlockingNotification.h \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.org 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.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
MODULE = necko
|
||||
|
||||
DEPTH = ..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
EXPORTS = \
|
||||
nsNeckoUtil.h \
|
||||
nsIBlockingNotification.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
$(DEPTH)\netwerk\dist\include:
|
||||
-mkdir $(DEPTH)\netwerk\dist
|
||||
-mkdir $(DEPTH)\netwerk\dist\include
|
||||
|
|
@ -1,71 +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.1 (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.org 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIBlockingCallback_h___
|
||||
#define nsIBlockingCallback_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "prthread.h"
|
||||
|
||||
/* forward declarations... */
|
||||
class nsIURI;
|
||||
|
||||
/* 7a3e0350-d724-11d2-99db-0080c7cb1080 */
|
||||
#define NS_IBLOCKINGNOTIFICATION_IID \
|
||||
{ 0x7a3e0350, 0xd724, 0x11d2, \
|
||||
{0x99, 0xdb, 0x00, 0x80, 0xc7, 0xcb, 0x10, 0x80} }
|
||||
|
||||
|
||||
class nsIBlockingNotification : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD IsBlocked(nsIURI *aUrl, PRBool *aResult) = 0;
|
||||
NS_IMETHOD Resume(nsIURI *aUrl, void *aExtraInfo) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* bd697440-d724-11d2-99db-0080c7cb1080 */
|
||||
#define NS_IBLOCKINGNOTIFICATION_OBSERVER_IID \
|
||||
{ 0xbd697440, 0xd724, 0x11d2, \
|
||||
{0x99, 0xdb, 0x00, 0x80, 0xc7, 0xcb, 0x10, 0x80} }
|
||||
|
||||
|
||||
class nsIBlockingNotificationObserver : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD Notify(nsIBlockingNotification *aCaller,
|
||||
nsIURI *aUrl,
|
||||
PRThread *aThread,
|
||||
PRInt32 aCode,
|
||||
void *aExtraInfo) = 0;
|
||||
|
||||
NS_IMETHOD CancelNotify(nsIURI *aUrl) = 0;
|
||||
};
|
||||
|
||||
|
||||
/* Generic status codes for nsIBlockingNotificationObserver::Notify(...) */
|
||||
#define NS_NOTIFY_SUCCEEDED NS_OK
|
||||
#define NS_NOTIFY_BLOCKED NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_NETWORK, 10)
|
||||
|
||||
#endif /* nsIBlockingCallback_h___ */
|
|
@ -1,87 +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.1 (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.org 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIUnicharStreamLoader_h___
|
||||
#define nsIUnicharStreamLoader_h___
|
||||
|
||||
// XXX NECKO this interface belongs outside necko. I've temporarily ( ;) ) added it
|
||||
// to the necko util lib to satisfy the NECKO build. It needs to be factored out.
|
||||
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_IUNICHARSTREAMLOADER_IID \
|
||||
{0xa6cf90d8, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
class nsIUnicharStreamLoader;
|
||||
class nsIURI;
|
||||
class nsILoadGroup;
|
||||
|
||||
/**
|
||||
* Funtion registered with the stream loader. This function is called
|
||||
* when the stream is done loading (or has aborted).
|
||||
*
|
||||
* @param aLoader the loader
|
||||
* @param aData the result of the load as a unicode character string
|
||||
* @param aRef the opaque data passed to the loader
|
||||
* @param aStatus the completion status of the stream
|
||||
*/
|
||||
typedef void (*nsStreamCompleteFunc)(nsIUnicharStreamLoader* aLoader,
|
||||
nsString& aData,
|
||||
void* aRef,
|
||||
nsresult aStatus);
|
||||
|
||||
/**
|
||||
* The purpose of this interface is to provide a mechanism for a
|
||||
* byte stream to be loaded asynchronously from a URL, the stream
|
||||
* data to be accumulated, and the result to be returned as a
|
||||
* unicode character string.
|
||||
*/
|
||||
class nsIUnicharStreamLoader : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Get the number of bytes read so far.
|
||||
*
|
||||
* @param aNumBytes out parameter to get number of unicode
|
||||
* characters read.
|
||||
*/
|
||||
NS_IMETHOD GetNumCharsRead(PRInt32* aNumChars) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Start loading the specified URL and accumulating the stream data.
|
||||
* When the stream is completed, the result is sent to the complete
|
||||
* function as a unicode character string.
|
||||
*
|
||||
* @param aInstancePtrResult new stream loader
|
||||
* @param aURL the URL to load
|
||||
* @param aFunc the function to call on termination of stream loading
|
||||
* @param aRef an opaque value that will later be sent to the termination
|
||||
* function
|
||||
*/
|
||||
extern nsresult NS_NewUnicharStreamLoader(nsIUnicharStreamLoader** aInstancePtrResult,
|
||||
nsIURI* aURL, nsILoadGroup* aLoadGroup,
|
||||
nsStreamCompleteFunc aFunc,
|
||||
void* aRef);
|
||||
|
||||
#endif /* nsIUnicharStreamLoader_h___ */
|
|
@ -1,111 +0,0 @@
|
|||
/* -*- 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.1 (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.org 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsNeckoUtil_h__
|
||||
#define nsNeckoUtil_h__
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "netCore.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#define NECKO_EXPORT(returnType) PR_PUBLIC_API(returnType)
|
||||
#else
|
||||
#define NECKO_EXPORT(returnType) returnType
|
||||
#endif
|
||||
|
||||
// Warning: These functions should NOT be defined with NS_NET because
|
||||
// the intention is that they'll be linked with the library/DLL that
|
||||
// uses them. NS_NET is for DLL imports.
|
||||
|
||||
extern nsresult
|
||||
NS_NewURI(nsIURI* *result, const char* spec, nsIURI* baseURI = nsnull);
|
||||
|
||||
extern nsresult
|
||||
NS_NewURI(nsIURI* *result, const nsString& spec, nsIURI* baseURI = nsnull);
|
||||
|
||||
extern nsresult
|
||||
NS_OpenURI(nsIChannel* *result, nsIURI* uri,
|
||||
nsILoadGroup *aGroup = nsnull,
|
||||
nsIInterfaceRequestor *notificationCallbacks = nsnull,
|
||||
nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL);
|
||||
|
||||
extern nsresult
|
||||
NS_OpenURI(nsIInputStream* *result, nsIURI* uri,
|
||||
nsILoadGroup *aGroup = nsnull,
|
||||
nsIInterfaceRequestor *notificationCallbacks = nsnull,
|
||||
nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL);
|
||||
|
||||
extern nsresult
|
||||
NS_OpenURI(nsIStreamListener* aConsumer, nsISupports* context, nsIURI* uri,
|
||||
nsILoadGroup *aGroup = nsnull,
|
||||
nsIInterfaceRequestor *notificationCallbacks = nsnull,
|
||||
nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL);
|
||||
|
||||
extern nsresult
|
||||
NS_MakeAbsoluteURI(const char* spec, nsIURI* baseURI, char* *result);
|
||||
|
||||
extern nsresult
|
||||
NS_MakeAbsoluteURI(const nsString& spec, nsIURI* baseURI, nsString& result);
|
||||
|
||||
extern nsresult
|
||||
NS_NewLoadGroup(nsISupports* outer, nsIStreamObserver* observer,
|
||||
nsILoadGroup* *result);
|
||||
|
||||
extern nsresult
|
||||
NS_NewPostDataStream(PRBool isFile, const char *data, PRUint32 encodeFlags,
|
||||
nsIInputStream **result);
|
||||
|
||||
inline nsresult
|
||||
NS_NewInputStreamChannel(nsIURI* uri,
|
||||
const char *contentType,
|
||||
PRInt32 contentLength,
|
||||
nsIInputStream *inStr,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIInterfaceRequestor* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **result)
|
||||
{
|
||||
nsresult rv;
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return serv->NewInputStreamChannel(uri,
|
||||
contentType,
|
||||
contentLength,
|
||||
inStr,
|
||||
aGroup,
|
||||
notificationCallbacks,
|
||||
loadAttributes,
|
||||
originalURI,
|
||||
result);
|
||||
}
|
||||
|
||||
#endif // nsNeckoUtil_h__
|
|
@ -1,42 +0,0 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.org 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.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = necko
|
||||
LIBRARY_NAME = neckoutil_s
|
||||
|
||||
CPPSRCS = \
|
||||
nsNeckoUtil.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
override NO_SHARED_LIB=1
|
||||
override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.org 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.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
MODULE = necko
|
||||
|
||||
DEPTH = ..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
LCFLAGS = -DWIN32_LEAN_AND_MEAN -D_IMPL_NS_NET
|
||||
|
||||
LIBRARY_NAME=neckoutil_s
|
||||
|
||||
CPP_OBJS = \
|
||||
.\$(OBJDIR)\nsNeckoUtil.obj \
|
||||
$(NULL)
|
||||
|
||||
INCS = $(INCS) \
|
||||
-I$(DEPTH)\dist\include \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
|
@ -1,225 +0,0 @@
|
|||
/* -*- 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.1 (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.org 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsNeckoUtil.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kLoadGroupCID, NS_LOADGROUP_CID);
|
||||
|
||||
NECKO_EXPORT(nsresult)
|
||||
NS_NewURI(nsIURI* *result, const char* spec, nsIURI* baseURI)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = serv->NewURI(spec, baseURI, result);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NECKO_EXPORT(nsresult)
|
||||
NS_NewURI(nsIURI* *result, const nsString& spec, nsIURI* baseURI)
|
||||
{
|
||||
// XXX if the string is unicode, GetBuffer() returns null.
|
||||
// XXX we need a strategy to deal w/ unicode specs (if there should
|
||||
// XXX even be such a thing)
|
||||
char* specStr = spec.ToNewCString(); // this forces a single byte char*
|
||||
if (specStr == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsresult rv = NS_NewURI(result, specStr, baseURI);
|
||||
nsAllocator::Free(specStr);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NECKO_EXPORT(nsresult)
|
||||
NS_OpenURI(nsIChannel* *result, nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIInterfaceRequestor *notificationCallbacks,
|
||||
nsLoadFlags loadAttributes)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIChannel* channel;
|
||||
rv = serv->NewChannelFromURI("load", uri, aGroup, notificationCallbacks,
|
||||
loadAttributes, nsnull, &channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = channel;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NECKO_EXPORT(nsresult)
|
||||
NS_OpenURI(nsIInputStream* *result, nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIInterfaceRequestor *notificationCallbacks,
|
||||
nsLoadFlags loadAttributes)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIChannel* channel;
|
||||
|
||||
rv = NS_OpenURI(&channel, uri, aGroup, notificationCallbacks, loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIInputStream* inStr;
|
||||
rv = channel->OpenInputStream(0, -1, &inStr);
|
||||
NS_RELEASE(channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = inStr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NECKO_EXPORT(nsresult)
|
||||
NS_OpenURI(nsIStreamListener* aConsumer, nsISupports* context, nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIInterfaceRequestor *notificationCallbacks,
|
||||
nsLoadFlags loadAttributes)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIChannel* channel;
|
||||
|
||||
rv = NS_OpenURI(&channel, uri, aGroup, notificationCallbacks, loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->AsyncRead(0, -1, context, aConsumer);
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// XXX copied from nsIOService.cpp (for now):
|
||||
static nsresult
|
||||
GetScheme(const char* inURI, char* *scheme)
|
||||
{
|
||||
// search for something up to a colon, and call it the scheme
|
||||
NS_ASSERTION(inURI, "null pointer");
|
||||
if (!inURI) return NS_ERROR_NULL_POINTER;
|
||||
char c;
|
||||
const char* URI = inURI;
|
||||
PRUint8 length = 0;
|
||||
// skip leading white space
|
||||
while (nsString::IsSpace(*URI))
|
||||
URI++;
|
||||
while ((c = *URI++) != '\0') {
|
||||
if (c == ':') {
|
||||
char* newScheme = (char *)nsAllocator::Alloc(length+1);
|
||||
if (newScheme == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCRT::memcpy(newScheme, inURI, length);
|
||||
newScheme[length] = '\0';
|
||||
*scheme = newScheme;
|
||||
return NS_OK;
|
||||
}
|
||||
else if (nsString::IsAlpha(c)) {
|
||||
length++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
}
|
||||
|
||||
NECKO_EXPORT(nsresult)
|
||||
NS_MakeAbsoluteURI(const char* aSpec, nsIURI* aBaseURI, char* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(aBaseURI, "It doesn't make sense to not supply a base URI");
|
||||
|
||||
if (aSpec == nsnull)
|
||||
return aBaseURI->GetSpec(result);
|
||||
|
||||
char* scheme;
|
||||
rv = GetScheme(aSpec, &scheme);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAllocator::Free(scheme);
|
||||
// if aSpec has a scheme, then it's already absolute
|
||||
*result = nsCRT::strdup(aSpec);
|
||||
return (*result == nsnull) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
return aBaseURI->Resolve(aSpec, result);
|
||||
}
|
||||
|
||||
NECKO_EXPORT(nsresult)
|
||||
NS_MakeAbsoluteURI(const nsString& spec, nsIURI* baseURI, nsString& result)
|
||||
{
|
||||
char* resultStr;
|
||||
char* specStr = spec.ToNewCString();
|
||||
if (!specStr) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult rv = NS_MakeAbsoluteURI(specStr, baseURI, &resultStr);
|
||||
nsAllocator::Free(specStr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
result = resultStr;
|
||||
nsAllocator::Free(resultStr);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NECKO_EXPORT(nsresult)
|
||||
NS_NewLoadGroup(nsISupports* outer, nsIStreamObserver* observer,
|
||||
nsILoadGroup* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsILoadGroup* group;
|
||||
rv = nsComponentManager::CreateInstance(kLoadGroupCID, outer,
|
||||
NS_GET_IID(nsILoadGroup),
|
||||
(void**)&group);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = group->Init(observer);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(group);
|
||||
return rv;
|
||||
}
|
||||
*result = group;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NECKO_EXPORT(nsresult)
|
||||
NS_NewPostDataStream(PRBool isFile, const char *data, PRUint32 encodeFlags,
|
||||
nsIInputStream **result)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIProtocolHandler> handler;
|
||||
rv = serv->GetProtocolHandler("http", getter_AddRefs(handler));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIHTTPProtocolHandler> http = do_QueryInterface(handler, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return http->NewPostDataStream(isFile, data, encodeFlags, result);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -1,223 +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.1 (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.org 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// XXX NECKO this class belongs outside necko. I've temporarily ( ;) ) added it
|
||||
// to the necko util lib to satisfy the NECKO build. It needs to be factored out.
|
||||
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
#include "nsIBufferInputStream.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIChannel.h"
|
||||
|
||||
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
static NS_DEFINE_IID(kIUnicharStreamLoaderIID, NS_IUNICHARSTREAMLOADER_IID);
|
||||
|
||||
class nsUnicharStreamLoader : public nsIUnicharStreamLoader,
|
||||
public nsIStreamListener
|
||||
{
|
||||
public:
|
||||
nsUnicharStreamLoader(nsIURI* aURL, nsILoadGroup* aLoadGroup,
|
||||
nsStreamCompleteFunc aFunc,
|
||||
void* aRef, nsresult *rv);
|
||||
virtual ~nsUnicharStreamLoader();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIUnicharStreamLoader methods
|
||||
NS_IMETHOD GetNumCharsRead(PRInt32* aNumBytes);
|
||||
|
||||
// nsIStreamObserver methods
|
||||
NS_DECL_NSISTREAMOBSERVER
|
||||
|
||||
// nsIStreamListener methods
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
||||
#if 0
|
||||
NS_IMETHOD GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo);
|
||||
#endif // 0
|
||||
|
||||
protected:
|
||||
nsStreamCompleteFunc mFunc;
|
||||
void* mRef;
|
||||
nsString* mData;
|
||||
/// nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
};
|
||||
|
||||
|
||||
nsUnicharStreamLoader::nsUnicharStreamLoader(nsIURI* aURL, nsILoadGroup* aLoadGroup,
|
||||
nsStreamCompleteFunc aFunc,
|
||||
void* aRef, nsresult *rv)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mFunc = aFunc;
|
||||
mRef = aRef;
|
||||
mData = new nsString();
|
||||
/// mLoadGroup = aLoadGroup;
|
||||
|
||||
// XXX This is vile vile vile!!!
|
||||
if (aURL) {
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
*rv = NS_OpenURI(getter_AddRefs(channel), aURL, aLoadGroup);
|
||||
if (NS_FAILED(*rv) && (nsnull != mFunc)) {
|
||||
// Thou shalt not call out of scope whilst ones refcnt is zero
|
||||
mRefCnt = 999;
|
||||
(*mFunc)(this, *mData, mRef, *rv);
|
||||
mRefCnt = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/// *rv = mLoadGroup->AddChannel(channel, nsnull);
|
||||
/// if (NS_FAILED(*rv)) return;
|
||||
|
||||
*rv = channel->AsyncRead(0, -1, nsnull, this);
|
||||
if (NS_FAILED(*rv)) return;
|
||||
}
|
||||
}
|
||||
|
||||
nsUnicharStreamLoader::~nsUnicharStreamLoader()
|
||||
{
|
||||
if (nsnull != mData) {
|
||||
delete mData;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsUnicharStreamLoader)
|
||||
NS_IMPL_RELEASE(nsUnicharStreamLoader)
|
||||
|
||||
nsresult
|
||||
nsUnicharStreamLoader::QueryInterface(const nsIID &aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIStreamListenerIID)) {
|
||||
nsIStreamListener* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIUnicharStreamLoaderIID)) {
|
||||
nsIUnicharStreamLoader* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
nsIUnicharStreamLoader* tmp = this;
|
||||
nsISupports* tmp2 = tmp;
|
||||
*aInstancePtr = (void*) tmp2;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUnicharStreamLoader::GetNumCharsRead(PRInt32* aNumBytes)
|
||||
{
|
||||
if (nsnull != mData) {
|
||||
*aNumBytes = mData->Length();
|
||||
}
|
||||
else {
|
||||
*aNumBytes = 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUnicharStreamLoader::OnStartRequest(nsIChannel* channel, nsISupports *ctxt)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUnicharStreamLoader::OnStopRequest(nsIChannel* channel, nsISupports *ctxt,
|
||||
nsresult status, const PRUnichar *errorMsg)
|
||||
{
|
||||
(*mFunc)(this, *mData, mRef, status);
|
||||
/// return mLoadGroup->RemoveChannel(channel, ctxt, status, errorMsg);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define BUF_SIZE 1024
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUnicharStreamLoader::OnDataAvailable(nsIChannel* channel, nsISupports *ctxt,
|
||||
nsIInputStream *inStr,
|
||||
PRUint32 sourceOffset, PRUint32 count)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
char buffer[BUF_SIZE];
|
||||
PRUint32 len, lenRead;
|
||||
|
||||
inStr->Available(&len);
|
||||
|
||||
while (len > 0) {
|
||||
if (len < BUF_SIZE) {
|
||||
lenRead = len;
|
||||
}
|
||||
else {
|
||||
lenRead = BUF_SIZE;
|
||||
}
|
||||
|
||||
rv = inStr->Read(buffer, lenRead, &lenRead);
|
||||
if (NS_FAILED(rv) || lenRead == 0) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
mData->Append(buffer, lenRead);
|
||||
len -= lenRead;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern NECKO_EXPORT(nsresult)
|
||||
NS_NewUnicharStreamLoader(nsIUnicharStreamLoader** aInstancePtrResult,
|
||||
nsIURI* aURL,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsStreamCompleteFunc aFunc,
|
||||
void* aRef)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsUnicharStreamLoader* it =
|
||||
new nsUnicharStreamLoader(aURL, aLoadGroup, aFunc, aRef, &rv);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
return it->QueryInterface(kIUnicharStreamLoaderIID,
|
||||
(void **) aInstancePtrResult);
|
||||
}
|
Загрузка…
Ссылка в новой задаче