This commit is contained in:
warren%netscape.com 1999-07-01 07:52:08 +00:00
Родитель 2647c89ca8
Коммит cf763ddb3f
10 изменённых файлов: 595 добавлений и 0 удалений

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

@ -0,0 +1,33 @@
#! 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 = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
MODULE = necko
include $(DEPTH)/config/autoconf.mk
DIRS= \
public \
src \
$(NULL)
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,30 @@
#!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.
#------------------------------------------------------------------------
#
# Makefile to build the pluggable HTTP
#
#------------------------------------------------------------------------
DEPTH=..\..\..
DIRS= \
public \
src \
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,41 @@
#!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.
MODULE = necko
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
XPIDL_MODULE = necko_about
XPIDLSRCS = \
nsIAboutModule.idl \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
# hack until necko lands
ifndef NECKO
PUBLIC = $(DEPTH)/netwerk/dist/include
endif
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,35 @@
#!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.
MODULE = necko
DEPTH = ..\..\..\..
// temporary, until we land:
!ifndef NECKO
include <$(DEPTH)/config/config.mak>
PUBLIC = $(DEPTH)\netwerk\dist\include
!endif
XPIDL_MODULE = necko_about
XPIDLSRCS = \
.\nsIAboutModule.idl \
$(NULL)
include <$(DEPTH)/config/rules.mak>

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

@ -0,0 +1,41 @@
/* -*- 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 "nsISupports.idl"
interface nsIChannel;
interface nsIURI;
interface nsIEventSinkGetter;
interface nsIEventQueue;
[scriptable, uuid(692303c0-2f83-11d3-8cd0-0060b0fc14a3)]
interface nsIAboutModule : nsISupports
{
nsIChannel NewChannel(in string verb,
in nsIURI aURI,
in nsIEventSinkGetter eventSinkGetter,
in nsIEventQueue eventQueue);
};
%{C++
#define NS_ABOUT_MODULE_PROGID "component://netscape/network/protocol/about"
#define NS_ABOUT_MODULE_PROGID_PREFIX NS_ABOUT_MODULE_PROGID "?what="
#define NS_ABOUT_MODULE_PROGID_LENGTH 49 // nsCRT::strlen(NS_ABOUT_MODULE_PROGID_PREFIX)
%}

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

@ -0,0 +1,46 @@
# 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 = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
MODULE = necko
LIBRARY_NAME = necko_about
IS_COMPONENT = 1
include $(DEPTH)/config/autoconf.mk
CPPSRCS = \
nsAboutProtocolHandler.cpp \
nsAboutProtocolFactory.cpp \
$(NULL)
REQUIRES = xpcom necko
include $(topsrcdir)/config/config.mk
# hack until necko lands
ifndef NECKO
PUBLIC = $(DEPTH)/netwerk/dist/include
endif
TARGET = $(LIBARY)
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,60 @@
#!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=necko
// temporary, until we land:
!ifndef NECKO
include <$(DEPTH)/config/config.mak>
PUBLIC = $(DEPTH)\netwerk\dist\include
!endif
IS_COMPONENT=1
MAKE_OBJ_TYPE=DLL
DLLNAME=necko_about
DLL=.\$(OBJDIR)\$(DLLNAME).dll
LLIBS= $(LLIBS) \
$(LIBNSPR) \
$(DIST)\lib\plc3.lib \
$(DIST)\lib\xpcom.lib \
$(NULL)
MISCDEP=$(LLIBS)
CPP_OBJS= \
.\$(OBJDIR)\nsAboutProtocolHandler.obj \
.\$(OBJDIR)\nsAboutProtocolFactory.obj \
$(NULL)
LOCAL_INCLUDES=-I.
INCLUDES = $(LOCAL_INCLUDES)
REQUIRES= necko
INCS = $(INCS) \
-I$(DEPTH)\dist\include \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) $(DLL) $(DIST)\bin\components
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib

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

@ -0,0 +1,86 @@
/* -*- 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.
*/
#include "nsIGenericFactory.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsAboutProtocolHandler.h"
#include "nscore.h"
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
static NS_DEFINE_CID(kAboutProtocolHandlerCID, NS_ABOUTPROTOCOLHANDLER_CID);
////////////////////////////////////////////////////////////////////////////////
// return the proper factory to the caller
extern "C" PR_IMPLEMENT(nsresult)
NSGetFactory(nsISupports* aServMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
nsresult rv;
if (aFactory == nsnull)
return NS_ERROR_NULL_POINTER;
nsIGenericFactory* fact;
if (aClass.Equals(kAboutProtocolHandlerCID)) {
rv = NS_NewGenericFactory(&fact, nsAboutProtocolHandler::Create);
}
else {
rv = NS_ERROR_FAILURE;
}
if (NS_SUCCEEDED(rv))
*aFactory = fact;
return rv;
}
extern "C" PR_IMPLEMENT(nsresult)
NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
{
nsresult rv;
NS_WITH_SERVICE1(nsIComponentManager, compMgr, aServMgr, kComponentManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = compMgr->RegisterComponent(kAboutProtocolHandlerCID,
"About Protocol Handler",
NS_NETWORK_PROTOCOL_PROGID_PREFIX "about",
aPath, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) return rv;;
return rv;
}
extern "C" PR_IMPLEMENT(nsresult)
NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
{
nsresult rv;
NS_WITH_SERVICE1(nsIComponentManager, compMgr, aServMgr, kComponentManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = compMgr->UnregisterComponent(kAboutProtocolHandlerCID, aPath);
if (NS_FAILED(rv)) return rv;
return rv;
}
////////////////////////////////////////////////////////////////////////////////

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

@ -0,0 +1,162 @@
/* -*- 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 "nsAboutProtocolHandler.h"
#include "nsIURI.h"
#include "nsIIOService.h"
#include "nsCRT.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIAboutModule.h"
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
////////////////////////////////////////////////////////////////////////////////
nsAboutProtocolHandler::nsAboutProtocolHandler()
{
NS_INIT_REFCNT();
}
nsresult
nsAboutProtocolHandler::Init()
{
return NS_OK;
}
nsAboutProtocolHandler::~nsAboutProtocolHandler()
{
}
NS_IMPL_ISUPPORTS(nsAboutProtocolHandler, nsIProtocolHandler::GetIID());
NS_METHOD
nsAboutProtocolHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsAboutProtocolHandler* ph = new nsAboutProtocolHandler();
if (ph == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(ph);
nsresult rv = ph->Init();
if (NS_SUCCEEDED(rv)) {
rv = ph->QueryInterface(aIID, aResult);
}
NS_RELEASE(ph);
return rv;
}
////////////////////////////////////////////////////////////////////////////////
// nsIProtocolHandler methods:
NS_IMETHODIMP
nsAboutProtocolHandler::GetScheme(char* *result)
{
*result = nsCRT::strdup("about");
if (*result == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsAboutProtocolHandler::GetDefaultPort(PRInt32 *result)
{
*result = -1; // no port for about: URLs
return NS_OK;
}
NS_IMETHODIMP
nsAboutProtocolHandler::MakeAbsolute(const char* aSpec,
nsIURI* aBaseURI,
char* *result)
{
// presumably, there's no such thing as a relative about: URI,
// so just copy the input spec
char* dup = nsCRT::strdup(aSpec);
if (dup == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
*result = dup;
return NS_OK;
}
NS_IMETHODIMP
nsAboutProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result)
{
nsresult rv;
// about: URIs are implemented by the "Simple URI" implementation
nsIURI* url;
if (aBaseURI) {
rv = aBaseURI->Clone(&url);
}
else {
rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull,
nsIURI::GetIID(),
(void**)&url);
}
if (NS_FAILED(rv)) return rv;
rv = url->SetSpec((char*)aSpec);
if (NS_FAILED(rv)) {
NS_RELEASE(url);
return rv;
}
*result = url;
return rv;
}
NS_IMETHODIMP
nsAboutProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsIEventSinkGetter* eventSinkGetter,
nsIEventQueue* eventQueue,
nsIChannel* *result)
{
// about:what you ask?
nsresult rv;
char* what;
rv = uri->GetPath(&what);
if (NS_FAILED(rv)) return rv;
// look up a handler to deal with "what"
nsAutoString progID(NS_ABOUT_MODULE_PROGID_PREFIX);
nsAutoString whatStr(what);
nsCRT::free(what);
// only take up to a question-mark if there is one:
PRInt32 amt = whatStr.Find("?");
progID.Append(what, amt); // if amt == -1, take it all
NS_WITH_SERVICE(nsIAboutModule, aboutMod, progID.GetBuffer(), &rv);
if (NS_SUCCEEDED(rv)) {
// The standard return case:
return aboutMod->NewChannel(verb, uri, eventSinkGetter,
eventQueue, result);
}
// mumble...
return rv;
}
////////////////////////////////////////////////////////////////////////////////

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

@ -0,0 +1,61 @@
/* -*- 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 nsAboutProtocolHandler_h___
#define nsAboutProtocolHandler_h___
#include "nsIProtocolHandler.h"
#define NS_ABOUTPROTOCOLHANDLER_CID \
{ /* 9e3b6c90-2f75-11d3-8cd0-0060b0fc14a3 */ \
0x9e3b6c90, \
0x2f75, \
0x11d3, \
{0x8c, 0xd0, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
}
class nsAboutProtocolHandler : public nsIProtocolHandler
{
public:
NS_DECL_ISUPPORTS
// nsIProtocolHandler methods:
NS_IMETHOD GetScheme(char * *aScheme);
NS_IMETHOD GetDefaultPort(PRInt32 *aDefaultPort);
NS_IMETHOD MakeAbsolute(const char *aRelativeSpec, nsIURI *aBaseURI,
char **_retval);
NS_IMETHOD NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **_retval);
NS_IMETHOD NewChannel(const char* verb, nsIURI* url,
nsIEventSinkGetter *eventSinkGetter,
nsIEventQueue *eventQueue,
nsIChannel **_retval);
// nsAboutProtocolHandler methods:
nsAboutProtocolHandler();
virtual ~nsAboutProtocolHandler();
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
nsresult Init();
protected:
};
#endif /* nsAboutProtocolHandler_h___ */