Renamed nsTypicalUrl to nsStandardUrl.

This commit is contained in:
warren%netscape.com 1999-05-01 02:08:18 +00:00
parent 9907679d08
commit 234d6bcc23
10 changed files with 107 additions and 130 deletions

View File

@ -25,45 +25,6 @@
#undef GetPort // Windows (sigh)
////////////////////////////////////////////////////////////////////////////////
// The "Typical URL" Implementation
// XXX regenerate:
#define NS_ITYPICALURL_IID \
{ /* 5053f850-f11e-11d2-9322-000000000000 */ \
0x5053f850, \
0xf11e, \
0x11d2, \
{0x93, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} \
}
// XXX regenerate:
#define NS_TYPICALURL_CID \
{ /* 8ffae6d0-ee37-11d2-9322-000000000000 */ \
0x8ffae6d0, \
0xee37, \
0x11d2, \
{0x93, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} \
}
/**
* The nsITypicalUrl interface defines the initializer for a URL
* implementation that only supports the accessors of nsIUrl.
*
* Protocol writers can obtain one by calling the component manager
* to create an instance of a typical URL by the CID, and then call
* the Init routine on it and finally QueryInterface to get the nsIUrl
* to return.
*/
class nsIUrl;
class nsITypicalUrl : public nsISupports
{
public:
NS_IMETHOD Init(const char* spec, nsIUrl* baseUrl) = 0;
};
#define NS_IURL_IID \
{ /* 82c1b000-ea35-11d2-931b-00104ba0fd40 */ \
0x82c1b000, \
@ -73,7 +34,7 @@ public:
}
/**
* The nsIURI class is an interface to the URI behaviour for parsing
* The nsIUrl class is an interface to the URL behaviour for parsing
* portions out of a URI. This follows Tim Berners-Lee's URI spec at-
*
* http://www.w3.org/Addressing/URI/URI_Overview.html
@ -102,7 +63,13 @@ class nsIUrl : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IURL_IID);
// Core parsing functions
/**
* Parses a URL spec (a string) relative to a base URL.
* Any defaults not specified in the spec (because it is a relative
* spec) are pulled from the base. The baseUrl can be null in which
* case the spec must be an absolute URL.
*/
NS_IMETHOD Init(const char* spec, nsIUrl* baseUrl) = 0;
/**
* The Scheme is the protocol that this URI refers to.
@ -170,11 +137,35 @@ public:
};
extern nsresult NS_NewURL(nsIUrl** aInstancePtrResult, const char *aSpec, nsIUrl* aBaseUrl);
////////////////////////////////////////////////////////////////////////////////
extern nsresult NS_NewConnection(nsIUrl* url,
nsISupports* eventSink,
nsIConnectionGroup* group,
nsIProtocolConnection* *result);
/**
* Protocol writers can obtain a default nsIUrl implementation by calling the
* component manager with NS_STANDARDURL_CID. The implementation returned will
* only implement the set of accessors specified by nsIUrl. After obtaining the
* instance from the component manager, the Init routine must be called on it
* to initialize it from the user's URL spec.
*/
#define NS_STANDARDURL_CID \
{ /* 46fc2a26-ff66-11d2-8ccb-0060b0fc14a3 */ \
0x46fc2a26, \
0xff66, \
0x11d2, \
{0x8c, 0xcb, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
}
////////////////////////////////////////////////////////////////////////////////
extern nsresult
NS_NewURL(nsIUrl** aInstancePtrResult, const char *aSpec, nsIUrl* aBaseUrl);
extern nsresult
NS_NewConnection(nsIUrl* url,
nsISupports* eventSink,
nsIConnectionGroup* group,
nsIProtocolConnection* *result);
////////////////////////////////////////////////////////////////////////////////
#endif /* nsIIUrl_h___ */

View File

@ -32,15 +32,15 @@ CPPSRCS = \
nsSocketTransport.cpp \
nsSocketTransportService.cpp \
nsNetService.cpp \
nsUrl.cpp \
nsStandardUrl.cpp \
$(NULL)
EXPORTS = \
nsConnectionGroup.h \
nsNetService.h \
nsFileTransportService.h \
EXPORTS = \
nsConnectionGroup.h \
nsNetService.h \
nsFileTransportService.h \
nsSocketTransportService.h \
nsUrl.h \
nsStandardUrl.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

View File

@ -21,12 +21,12 @@ LCFLAGS = -DWIN32_LEAN_AND_MEAN -D_IMPL_NS_NET
LIBRARY_NAME=netwerkbase_s
EXPORTS = \
nsConnectionGroup.h \
nsNetService.h \
nsFileTransportService.h \
EXPORTS = \
nsConnectionGroup.h \
nsNetService.h \
nsFileTransportService.h \
nsSocketTransportService.h \
nsUrl.h \
nsStandardUrl.h \
$(NULL)
CPP_OBJS = \
@ -38,7 +38,7 @@ CPP_OBJS = \
.\$(OBJDIR)\nsSocketTransport.obj \
.\$(OBJDIR)\nsSocketTransportService.obj \
.\$(OBJDIR)\nsNetService.obj \
.\$(OBJDIR)\nsUrl.obj \
.\$(OBJDIR)\nsStandardUrl.obj \
$(NULL)
LINCS = \

View File

@ -16,23 +16,23 @@
* Reserved.
*/
#include "nsUrl.h"
#include "nsStandardUrl.h"
#include "nscore.h"
#include "nsCRT.h"
#include "nsString.h"
#include "prmem.h"
#include "prprf.h"
static NS_DEFINE_CID(kTypicalUrlCID, NS_TYPICALURL_CID);
static NS_DEFINE_CID(kThisTypicalUrlImplementationCID,
NS_THIS_TYPICALURL_IMPLEMENTATION_CID);
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kThisStandardUrlImplementationCID,
NS_THIS_STANDARDURL_IMPLEMENTATION_CID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
////////////////////////////////////////////////////////////////////////////////
// nsUrl methods:
// nsStandardUrl methods:
nsUrl::nsUrl(nsISupports* outer)
nsStandardUrl::nsStandardUrl(nsISupports* outer)
: mScheme(nsnull),
mPreHost(nsnull),
mHost(nsnull),
@ -45,7 +45,7 @@ nsUrl::nsUrl(nsISupports* outer)
NS_INIT_AGGREGATED(outer);
}
nsUrl::~nsUrl()
nsStandardUrl::~nsStandardUrl()
{
if (mScheme) delete[] mScheme;
if (mPreHost) delete[] mPreHost;
@ -56,30 +56,25 @@ nsUrl::~nsUrl()
}
NS_IMETHODIMP
nsUrl::Init(const char* aSpec,
nsStandardUrl::Init(const char* aSpec,
nsIUrl* aBaseUrl)
{
return Parse(aSpec, aBaseUrl);
}
NS_IMPL_AGGREGATED(nsUrl);
NS_IMPL_AGGREGATED(nsStandardUrl);
NS_IMETHODIMP
nsUrl::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
nsStandardUrl::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
{
NS_ASSERTION(aInstancePtr, "no instance pointer");
if (aIID.Equals(kThisTypicalUrlImplementationCID) || // used by Equals
if (aIID.Equals(kThisStandardUrlImplementationCID) || // used by Equals
aIID.Equals(nsIUrl::GetIID()) ||
aIID.Equals(kISupportsIID)) {
*aInstancePtr = NS_STATIC_CAST(nsIUrl*, this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsITypicalUrl::GetIID())) {
*aInstancePtr = NS_STATIC_CAST(nsITypicalUrl*, this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
@ -87,84 +82,84 @@ nsUrl::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
// nsIUrl methods:
NS_IMETHODIMP
nsUrl::GetScheme(const char* *result)
nsStandardUrl::GetScheme(const char* *result)
{
*result = mScheme;
return NS_OK;
}
NS_IMETHODIMP
nsUrl::SetScheme(const char* scheme)
nsStandardUrl::SetScheme(const char* scheme)
{
mScheme = nsCRT::strdup(scheme);
return NS_OK;
}
NS_IMETHODIMP
nsUrl::GetPreHost(const char* *result)
nsStandardUrl::GetPreHost(const char* *result)
{
*result = mPreHost;
return NS_OK;
}
NS_IMETHODIMP
nsUrl::SetPreHost(const char* preHost)
nsStandardUrl::SetPreHost(const char* preHost)
{
mPreHost = nsCRT::strdup(preHost);
return NS_OK;
}
NS_IMETHODIMP
nsUrl::GetHost(const char* *result)
nsStandardUrl::GetHost(const char* *result)
{
*result = mHost;
return NS_OK;
}
NS_IMETHODIMP
nsUrl::SetHost(const char* host)
nsStandardUrl::SetHost(const char* host)
{
mHost = nsCRT::strdup(host);
return NS_OK;
}
NS_IMETHODIMP
nsUrl::GetPort(PRInt32 *result)
nsStandardUrl::GetPort(PRInt32 *result)
{
*result = mPort;
return NS_OK;
}
NS_IMETHODIMP
nsUrl::SetPort(PRInt32 port)
nsStandardUrl::SetPort(PRInt32 port)
{
mPort = port;
return NS_OK;
}
NS_IMETHODIMP
nsUrl::GetPath(const char* *result)
nsStandardUrl::GetPath(const char* *result)
{
*result = mPath;
return NS_OK;
}
NS_IMETHODIMP
nsUrl::SetPath(const char* path)
nsStandardUrl::SetPath(const char* path)
{
mPath = nsCRT::strdup(path);
return NS_OK;
}
NS_IMETHODIMP
nsUrl::Equals(nsIUrl* other)
nsStandardUrl::Equals(nsIUrl* other)
{
PRBool eq = PR_FALSE;
if (other) {
// NS_LOCK_INSTANCE();
nsUrl* otherUrl;
nsStandardUrl* otherUrl;
nsresult rv =
other->QueryInterface(kThisTypicalUrlImplementationCID,
other->QueryInterface(kThisStandardUrlImplementationCID,
(void**)&otherUrl);
if (NS_SUCCEEDED(rv)) {
eq = PRBool((0 == PL_strcmp(mScheme, otherUrl->mScheme)) &&
@ -179,9 +174,9 @@ nsUrl::Equals(nsIUrl* other)
}
NS_IMETHODIMP
nsUrl::Clone(nsIUrl* *result)
nsStandardUrl::Clone(nsIUrl* *result)
{
nsUrl* url = new nsUrl(nsnull); // XXX outer?
nsStandardUrl* url = new nsStandardUrl(nsnull); // XXX outer?
if (url == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
url->mScheme = nsCRT::strdup(mScheme);
@ -210,7 +205,7 @@ nsUrl::Clone(nsIUrl* *result)
}
NS_IMETHODIMP
nsUrl::ToNewCString(char* *result)
nsStandardUrl::ToNewCString(char* *result)
{
nsAutoString string;
// NS_LOCK_INSTANCE();
@ -257,7 +252,7 @@ nsUrl::ToNewCString(char* *result)
// XXX don't bother with ref's
// XXX null pointer checks are incomplete
nsresult
nsUrl::Parse(const char* spec, nsIUrl* aBaseUrl)
nsStandardUrl::Parse(const char* spec, nsIUrl* aBaseUrl)
{
// XXX hack!
nsString specStr(spec);
@ -550,7 +545,7 @@ nsUrl::Parse(const char* spec, nsIUrl* aBaseUrl)
}
void
nsUrl::ReconstructSpec()
nsStandardUrl::ReconstructSpec()
{
PR_FREEIF(mSpec);

View File

@ -16,14 +16,14 @@
* Reserved.
*/
#ifndef nsUrl_h__
#define nsUrl_h__
#ifndef nsStandardUrl_h__
#define nsStandardUrl_h__
#include "nsIUrl.h"
#include "nsAgg.h"
// XXX regenerate:
#define NS_THIS_TYPICALURL_IMPLEMENTATION_CID \
#define NS_THIS_STANDARDURL_IMPLEMENTATION_CID \
{ /* 905ed480-f11f-11d2-9322-000000000000 */ \
0x905ed480, \
0xf11f, \
@ -31,7 +31,7 @@
{0x93, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} \
}
class nsUrl : public nsIUrl, public nsITypicalUrl
class nsStandardUrl : public nsIUrl
{
public:
NS_DECL_AGGREGATED
@ -39,6 +39,8 @@ public:
////////////////////////////////////////////////////////////////////////////
// nsIUrl methods:
NS_IMETHOD Init(const char* spec, nsIUrl* baseUrl);
NS_IMETHOD GetScheme(const char* *result);
NS_IMETHOD SetScheme(const char* scheme);
@ -60,15 +62,10 @@ public:
NS_IMETHOD ToNewCString(char* *result);
////////////////////////////////////////////////////////////////////////////
// nsITypicalUrl methods:
// nsStandardUrl methods:
NS_IMETHOD Init(const char* spec, nsIUrl* baseUrl);
////////////////////////////////////////////////////////////////////////////
// nsUrl methods:
nsUrl(nsISupports* outer);
virtual ~nsUrl();
nsStandardUrl(nsISupports* outer);
virtual ~nsStandardUrl();
protected:
nsresult Parse(const char* spec, nsIUrl* aBaseUrl);
@ -85,4 +82,4 @@ protected:
char* mSpec; // XXX go away
};
#endif // nsUrl_h__
#endif // nsStandardUrl_h__

View File

@ -28,8 +28,8 @@
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kTypicalUrlCID, NS_TYPICALURL_CID);
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
////////////////////////////////////////////////////////////////////////////////
@ -118,11 +118,11 @@ nsNetFactory::CreateInstance(nsISupports *aOuter,
}
inst = NS_STATIC_CAST(nsISocketTransportService*, trans);
}
else if (mClassID.Equals(kTypicalUrlCID)) {
nsUrl* url = new nsUrl(aOuter);
else if (mClassID.Equals(kStandardUrlCID)) {
nsStandardUrl* url = new nsStandardUrl(aOuter);
if (url == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
inst = NS_STATIC_CAST(nsITypicalUrl*, url);
inst = NS_STATIC_CAST(nsIUrl*, url);
}
else {
return NS_ERROR_NO_INTERFACE;
@ -145,8 +145,6 @@ nsresult nsNetFactory::LockFactory(PRBool aLock)
extern "C" PR_IMPLEMENT(nsresult)
NSGetFactory(nsISupports* aServMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (aFactory == nsnull)
@ -187,9 +185,9 @@ NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
aPath, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) return rv;;
rv = compMgr->RegisterComponent(kTypicalUrlCID,
"Typical URL Implementation",
"component://netscape/network/typcial-url",
rv = compMgr->RegisterComponent(kStandardUrlCID,
"Standard URL Implementation",
"component://netscape/network/standard-url",
aPath, PR_TRUE, PR_TRUE);
return rv;
}
@ -211,7 +209,7 @@ NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
rv = compMgr->UnregisterComponent(kSocketTransportServiceCID, aPath);
if (NS_FAILED(rv)) return rv;;
rv = compMgr->UnregisterComponent(kTypicalUrlCID, aPath);
rv = compMgr->UnregisterComponent(kStandardUrlCID, aPath);
return rv;
}

View File

@ -104,8 +104,6 @@ nsresult nsNetFactory::LockFactory(PRBool aLock)
extern "C" PR_IMPLEMENT(nsresult)
NSGetFactory(nsISupports* aServMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (aFactory == nsnull)

View File

@ -23,7 +23,7 @@
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
static NS_DEFINE_CID(kTypicalUrlCID, NS_TYPICALURL_CID);
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
////////////////////////////////////////////////////////////////////////////////
@ -79,12 +79,12 @@ nsFtpProtocolHandler::NewUrl(const char* aSpec,
{
nsresult rv;
// Ftp URLs (currently) have no additional structure beyond that provided by typical
// Ftp URLs (currently) have no additional structure beyond that provided by standard
// URLs, so there is no "outer" given to CreateInstance
nsITypicalUrl* url;
rv = nsComponentManager::CreateInstance(kTypicalUrlCID, nsnull,
nsITypicalUrl::GetIID(),
nsIUrl* url;
rv = nsComponentManager::CreateInstance(kStandardUrlCID, nsnull,
nsIUrl::GetIID(),
(void**)&url);
if (NS_FAILED(rv)) return rv;

View File

@ -104,8 +104,6 @@ nsresult nsNetFactory::LockFactory(PRBool aLock)
extern "C" PR_IMPLEMENT(nsresult)
NSGetFactory(nsISupports* aServMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (aFactory == nsnull)

View File

@ -26,7 +26,7 @@
#include "nsITransport.h"
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kTypicalUrlCID, NS_TYPICALURL_CID);
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
////////////////////////////////////////////////////////////////////////////////
@ -93,12 +93,12 @@ nsHttpProtocolHandler::NewUrl(const char* aSpec,
{
nsresult rv;
// http URLs (currently) have no additional structure beyond that provided by typical
// http URLs (currently) have no additional structure beyond that provided by standard
// URLs, so there is no "outer" given to CreateInstance
nsITypicalUrl* url;
rv = nsComponentManager::CreateInstance(kTypicalUrlCID, nsnull,
nsITypicalUrl::GetIID(),
nsIUrl* url;
rv = nsComponentManager::CreateInstance(kStandardUrlCID, nsnull,
nsIUrl::GetIID(),
(void**)&url);
if (NS_FAILED(rv)) return rv;