From 9dab851f4ee271b74bc116d7cd779da9fedab5d4 Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Fri, 17 Sep 1999 16:12:41 +0000 Subject: [PATCH] NOT IN BUILD - adding boilerplate for jar protocol handler git-svn-id: svn://10.0.0.236/trunk@47973 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libjar/nsIJARChannel.idl | 32 +++++ mozilla/modules/libjar/nsJARChannel.h | 43 +++++++ .../modules/libjar/nsJARProtocolHandler.cpp | 113 ++++++++++++++++++ mozilla/modules/libjar/nsJARProtocolHandler.h | 60 ++++++++++ mozilla/netwerk/protocol/jar/Makefile.in | 33 +++++ mozilla/netwerk/protocol/jar/makefile.win | 30 +++++ .../netwerk/protocol/jar/public/Makefile.in | 41 +++++++ .../netwerk/protocol/jar/public/makefile.win | 30 +++++ .../protocol/jar/public/nsIJARChannel.idl | 32 +++++ .../netwerk/protocol/jar/public/nsIJARURL.idl | 44 +++++++ mozilla/netwerk/protocol/jar/src/Makefile.in | 46 +++++++ mozilla/netwerk/protocol/jar/src/makefile.win | 51 ++++++++ .../netwerk/protocol/jar/src/nsJARChannel.h | 43 +++++++ .../protocol/jar/src/nsJARProtocolFactory.cpp | 86 +++++++++++++ .../protocol/jar/src/nsJARProtocolHandler.cpp | 113 ++++++++++++++++++ .../protocol/jar/src/nsJARProtocolHandler.h | 60 ++++++++++ 16 files changed, 857 insertions(+) create mode 100644 mozilla/modules/libjar/nsIJARChannel.idl create mode 100644 mozilla/modules/libjar/nsJARChannel.h create mode 100644 mozilla/modules/libjar/nsJARProtocolHandler.cpp create mode 100644 mozilla/modules/libjar/nsJARProtocolHandler.h create mode 100644 mozilla/netwerk/protocol/jar/Makefile.in create mode 100644 mozilla/netwerk/protocol/jar/makefile.win create mode 100644 mozilla/netwerk/protocol/jar/public/Makefile.in create mode 100644 mozilla/netwerk/protocol/jar/public/makefile.win create mode 100644 mozilla/netwerk/protocol/jar/public/nsIJARChannel.idl create mode 100644 mozilla/netwerk/protocol/jar/public/nsIJARURL.idl create mode 100644 mozilla/netwerk/protocol/jar/src/Makefile.in create mode 100644 mozilla/netwerk/protocol/jar/src/makefile.win create mode 100644 mozilla/netwerk/protocol/jar/src/nsJARChannel.h create mode 100644 mozilla/netwerk/protocol/jar/src/nsJARProtocolFactory.cpp create mode 100644 mozilla/netwerk/protocol/jar/src/nsJARProtocolHandler.cpp create mode 100644 mozilla/netwerk/protocol/jar/src/nsJARProtocolHandler.h diff --git a/mozilla/modules/libjar/nsIJARChannel.idl b/mozilla/modules/libjar/nsIJARChannel.idl new file mode 100644 index 00000000000..4ae4575795b --- /dev/null +++ b/mozilla/modules/libjar/nsIJARChannel.idl @@ -0,0 +1,32 @@ +/* -*- Mode: IDL; 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 "nsIChannel.idl" + +[scriptable, uuid(692303c0-2f83-11d3-8cd0-0060b0fc14a3)] +interface nsIJARChannel : nsIChannel +{ + +}; + +%{C++ + +#define NS_JAR_CHANNEL_PROGID "component://netscape/network/protocol/jar" +#define NS_JAR_CHANNEL_PROGID_LENGTH 41 + +%} diff --git a/mozilla/modules/libjar/nsJARChannel.h b/mozilla/modules/libjar/nsJARChannel.h new file mode 100644 index 00000000000..aca4d74b9e2 --- /dev/null +++ b/mozilla/modules/libjar/nsJARChannel.h @@ -0,0 +1,43 @@ +/* -*- 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 __nsjarchannel__h___ +#define __nsjarchannel__h___ + +#include "nsIURI.h" + +class nsJARChannel : nsIJARChannel { +public: + // nsISupports + NS_DECL_ISUPPORTS + + // nsIChannel + NS_DECL_NSICHANNEL + + // nsIJARChannel + NS_DECL_NSIJARCHANNEL + + // nsJARChannel + nsJARChannel(); + virtual ~nsJARChannel(); + +private: + nsIURI *mURI; +}; + +#endif // __nsjarchannel__h___ \ No newline at end of file diff --git a/mozilla/modules/libjar/nsJARProtocolHandler.cpp b/mozilla/modules/libjar/nsJARProtocolHandler.cpp new file mode 100644 index 00000000000..4e08d4f2ee9 --- /dev/null +++ b/mozilla/modules/libjar/nsJARProtocolHandler.cpp @@ -0,0 +1,113 @@ +/* -*- 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 "nsJARProtocolHandler.h" +#include "nsIURI.h" +#include "nsIIOService.h" +#include "nsCRT.h" +#include "nsIComponentManager.h" +#include "nsIServiceManager.h" +#include "nsIJARChannel.h" + +static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); + +//////////////////////////////////////////////////////////////////////////////// + +nsJARProtocolHandler::nsJARProtocolHandler() +{ + NS_INIT_REFCNT(); +} + +nsresult +nsJARProtocolHandler::Init() +{ + return NS_OK; +} + +nsJARProtocolHandler::~nsJARProtocolHandler() +{ +} + +NS_IMPL_ISUPPORTS(nsJARProtocolHandler, nsIProtocolHandler::GetIID()); + +NS_METHOD +nsJARProtocolHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) +{ + if (aOuter) + return NS_ERROR_NO_AGGREGATION; + + nsJARProtocolHandler* ph = new nsJARProtocolHandler(); + 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 +nsJARProtocolHandler::GetScheme(char* *result) +{ + *result = nsCRT::strdup("jar"); + if (*result == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; +} + +NS_IMETHODIMP +nsJARProtocolHandler::GetDefaultPort(PRInt32 *result) +{ + *result = -1; // no port for JAR: URLs + return NS_OK; +} + +NS_IMETHODIMP +nsJARProtocolHandler::MakeAbsolute(const char* aSpec, + nsIURI* aBaseURI, + char* *result) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +// JAR urls have the following syntax +// +// jar:!/(entry) +// +// EXAMPLE: jar:http://www.big.com/blue.jar!/ocean.html +NS_IMETHODIMP +nsJARProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, + nsIURI **result) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsJARProtocolHandler::NewChannel(const char* verb, nsIURI* uri, + nsIEventSinkGetter* eventSinkGetter, + nsIChannel* *result) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/modules/libjar/nsJARProtocolHandler.h b/mozilla/modules/libjar/nsJARProtocolHandler.h new file mode 100644 index 00000000000..c03b036e4f5 --- /dev/null +++ b/mozilla/modules/libjar/nsJARProtocolHandler.h @@ -0,0 +1,60 @@ +/* -*- 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 nsJARProtocolHandler_h___ +#define nsJARProtocolHandler_h___ + +#include "nsIProtocolHandler.h" + +#define NS_JARPROTOCOLHANDLER_CID \ +{ /* 9e3b6c90-2f75-11d3-8cd0-0060b0fc14a3 */ \ + 0x9e3b6c90, \ + 0x2f75, \ + 0x11d3, \ + {0x8c, 0xd0, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \ +} + +class nsJARProtocolHandler : 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, + nsIChannel **_retval); + + // nsJARProtocolHandler methods: + nsJARProtocolHandler(); + virtual ~nsJARProtocolHandler(); + + static NS_METHOD + Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); + + nsresult Init(); + +protected: +}; + +#endif /* nsJARProtocolHandler_h___ */ diff --git a/mozilla/netwerk/protocol/jar/Makefile.in b/mozilla/netwerk/protocol/jar/Makefile.in new file mode 100644 index 00000000000..c650f31169c --- /dev/null +++ b/mozilla/netwerk/protocol/jar/Makefile.in @@ -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 diff --git a/mozilla/netwerk/protocol/jar/makefile.win b/mozilla/netwerk/protocol/jar/makefile.win new file mode 100644 index 00000000000..cbc2799d56e --- /dev/null +++ b/mozilla/netwerk/protocol/jar/makefile.win @@ -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> diff --git a/mozilla/netwerk/protocol/jar/public/Makefile.in b/mozilla/netwerk/protocol/jar/public/Makefile.in new file mode 100644 index 00000000000..6517b3d3e91 --- /dev/null +++ b/mozilla/netwerk/protocol/jar/public/Makefile.in @@ -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 = \ + nsIJARChannel.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 diff --git a/mozilla/netwerk/protocol/jar/public/makefile.win b/mozilla/netwerk/protocol/jar/public/makefile.win new file mode 100644 index 00000000000..dbc2cc038af --- /dev/null +++ b/mozilla/netwerk/protocol/jar/public/makefile.win @@ -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. + +MODULE = necko + +DEPTH = ..\..\..\.. +include <$(DEPTH)/config/config.mak> + +XPIDL_MODULE = necko_about + +XPIDLSRCS = \ + .\nsIJARChannel.idl \ + $(NULL) + +include <$(DEPTH)/config/rules.mak> + diff --git a/mozilla/netwerk/protocol/jar/public/nsIJARChannel.idl b/mozilla/netwerk/protocol/jar/public/nsIJARChannel.idl new file mode 100644 index 00000000000..4ae4575795b --- /dev/null +++ b/mozilla/netwerk/protocol/jar/public/nsIJARChannel.idl @@ -0,0 +1,32 @@ +/* -*- Mode: IDL; 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 "nsIChannel.idl" + +[scriptable, uuid(692303c0-2f83-11d3-8cd0-0060b0fc14a3)] +interface nsIJARChannel : nsIChannel +{ + +}; + +%{C++ + +#define NS_JAR_CHANNEL_PROGID "component://netscape/network/protocol/jar" +#define NS_JAR_CHANNEL_PROGID_LENGTH 41 + +%} diff --git a/mozilla/netwerk/protocol/jar/public/nsIJARURL.idl b/mozilla/netwerk/protocol/jar/public/nsIJARURL.idl new file mode 100644 index 00000000000..8d31d861fb0 --- /dev/null +++ b/mozilla/netwerk/protocol/jar/public/nsIJARURL.idl @@ -0,0 +1,44 @@ +/* -*- Mode: IDL; 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 "nsIURI.idl" +#include "nsIEnumerator.idl" + +// JAR URLs have the following syntax +// +// jar:!/(entry) +// +// EXAMPLE: jar:http://www.big.com/blue.jar!/ocean.html + +[scriptable, uuid(35cef9b0-6d18-11d3-a17f-0050041caf44)] +interface nsIJARURI : nsIURI { + + // Enumerates all the entries in the JAR (the root URI). + // ARGUMENTS: + // aRoot - a string representing the root dir to enumerate from + // or null to enumerate the whole thing. + nsISimpleEnumerator EnumerateEntries(in string aRoot); + + // Returns the root URI (the one for the actual JAR file) for this JAR. + // eg http://www.big.com/blue.jar + nsIURI GetRootURI(); + + // Returns the entry specified for this JAR URI. + // eg ocean.html + string GetEntry(); +}; \ No newline at end of file diff --git a/mozilla/netwerk/protocol/jar/src/Makefile.in b/mozilla/netwerk/protocol/jar/src/Makefile.in new file mode 100644 index 00000000000..7262b9279cf --- /dev/null +++ b/mozilla/netwerk/protocol/jar/src/Makefile.in @@ -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_jar + +IS_COMPONENT = 1 + +include $(DEPTH)/config/autoconf.mk + +CPPSRCS = \ + nsJARProtocolHandler.cpp \ + nsJARProtocolFactory.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 diff --git a/mozilla/netwerk/protocol/jar/src/makefile.win b/mozilla/netwerk/protocol/jar/src/makefile.win new file mode 100644 index 00000000000..024848eb777 --- /dev/null +++ b/mozilla/netwerk/protocol/jar/src/makefile.win @@ -0,0 +1,51 @@ +#!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 + +IS_COMPONENT=1 +MAKE_OBJ_TYPE=DLL +DLLNAME=necko_jar +DLL=.\$(OBJDIR)\$(DLLNAME).dll + +LLIBS= $(LLIBS) \ + $(LIBNSPR) \ + $(DIST)\lib\xpcom.lib \ + $(NULL) + +CPP_OBJS= \ + .\$(OBJDIR)\nsJARProtocolHandler.obj \ + .\$(OBJDIR)\nsJARProtocolFactory.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 + diff --git a/mozilla/netwerk/protocol/jar/src/nsJARChannel.h b/mozilla/netwerk/protocol/jar/src/nsJARChannel.h new file mode 100644 index 00000000000..aca4d74b9e2 --- /dev/null +++ b/mozilla/netwerk/protocol/jar/src/nsJARChannel.h @@ -0,0 +1,43 @@ +/* -*- 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 __nsjarchannel__h___ +#define __nsjarchannel__h___ + +#include "nsIURI.h" + +class nsJARChannel : nsIJARChannel { +public: + // nsISupports + NS_DECL_ISUPPORTS + + // nsIChannel + NS_DECL_NSICHANNEL + + // nsIJARChannel + NS_DECL_NSIJARCHANNEL + + // nsJARChannel + nsJARChannel(); + virtual ~nsJARChannel(); + +private: + nsIURI *mURI; +}; + +#endif // __nsjarchannel__h___ \ No newline at end of file diff --git a/mozilla/netwerk/protocol/jar/src/nsJARProtocolFactory.cpp b/mozilla/netwerk/protocol/jar/src/nsJARProtocolFactory.cpp new file mode 100644 index 00000000000..509b8621b97 --- /dev/null +++ b/mozilla/netwerk/protocol/jar/src/nsJARProtocolFactory.cpp @@ -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 "nsJARProtocolHandler.h" +#include "nscore.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); +static NS_DEFINE_CID(kJARProtocolHandlerCID, NS_JARPROTOCOLHANDLER_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(kJARProtocolHandlerCID)) { + rv = NS_NewGenericFactory(&fact, nsJARProtocolHandler::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(kJARProtocolHandlerCID, + "JAR Protocol Handler", + NS_NETWORK_PROTOCOL_PROGID_PREFIX "JAR", + 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(kJARProtocolHandlerCID, aPath); + if (NS_FAILED(rv)) return rv; + + return rv; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/protocol/jar/src/nsJARProtocolHandler.cpp b/mozilla/netwerk/protocol/jar/src/nsJARProtocolHandler.cpp new file mode 100644 index 00000000000..4e08d4f2ee9 --- /dev/null +++ b/mozilla/netwerk/protocol/jar/src/nsJARProtocolHandler.cpp @@ -0,0 +1,113 @@ +/* -*- 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 "nsJARProtocolHandler.h" +#include "nsIURI.h" +#include "nsIIOService.h" +#include "nsCRT.h" +#include "nsIComponentManager.h" +#include "nsIServiceManager.h" +#include "nsIJARChannel.h" + +static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); + +//////////////////////////////////////////////////////////////////////////////// + +nsJARProtocolHandler::nsJARProtocolHandler() +{ + NS_INIT_REFCNT(); +} + +nsresult +nsJARProtocolHandler::Init() +{ + return NS_OK; +} + +nsJARProtocolHandler::~nsJARProtocolHandler() +{ +} + +NS_IMPL_ISUPPORTS(nsJARProtocolHandler, nsIProtocolHandler::GetIID()); + +NS_METHOD +nsJARProtocolHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) +{ + if (aOuter) + return NS_ERROR_NO_AGGREGATION; + + nsJARProtocolHandler* ph = new nsJARProtocolHandler(); + 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 +nsJARProtocolHandler::GetScheme(char* *result) +{ + *result = nsCRT::strdup("jar"); + if (*result == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; +} + +NS_IMETHODIMP +nsJARProtocolHandler::GetDefaultPort(PRInt32 *result) +{ + *result = -1; // no port for JAR: URLs + return NS_OK; +} + +NS_IMETHODIMP +nsJARProtocolHandler::MakeAbsolute(const char* aSpec, + nsIURI* aBaseURI, + char* *result) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +// JAR urls have the following syntax +// +// jar:!/(entry) +// +// EXAMPLE: jar:http://www.big.com/blue.jar!/ocean.html +NS_IMETHODIMP +nsJARProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, + nsIURI **result) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsJARProtocolHandler::NewChannel(const char* verb, nsIURI* uri, + nsIEventSinkGetter* eventSinkGetter, + nsIChannel* *result) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/protocol/jar/src/nsJARProtocolHandler.h b/mozilla/netwerk/protocol/jar/src/nsJARProtocolHandler.h new file mode 100644 index 00000000000..c03b036e4f5 --- /dev/null +++ b/mozilla/netwerk/protocol/jar/src/nsJARProtocolHandler.h @@ -0,0 +1,60 @@ +/* -*- 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 nsJARProtocolHandler_h___ +#define nsJARProtocolHandler_h___ + +#include "nsIProtocolHandler.h" + +#define NS_JARPROTOCOLHANDLER_CID \ +{ /* 9e3b6c90-2f75-11d3-8cd0-0060b0fc14a3 */ \ + 0x9e3b6c90, \ + 0x2f75, \ + 0x11d3, \ + {0x8c, 0xd0, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \ +} + +class nsJARProtocolHandler : 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, + nsIChannel **_retval); + + // nsJARProtocolHandler methods: + nsJARProtocolHandler(); + virtual ~nsJARProtocolHandler(); + + static NS_METHOD + Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); + + nsresult Init(); + +protected: +}; + +#endif /* nsJARProtocolHandler_h___ */