nsIUrl.h = now is a subclass of nsITypicalUrl explicitly

nsUrl.h = nsIUrl change reflected.
nsNetService.cpp = NS_NewUrl() helper routine added
This commit is contained in:
valeski%netscape.com 1999-04-28 20:05:23 +00:00
parent e70b38df5f
commit 23d9668b0b
3 changed files with 74 additions and 38 deletions

View File

@ -20,9 +20,49 @@
#define nsIUrl_h___
#include "nsISupports.h"
#include "nscore.h"
#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, \
@ -56,8 +96,8 @@
* This class pretty much "final" and there shouldn't be anything added.
* If you do feel something belongs here, please do send me a mail. Thanks!
*/
class nsIUrl : public nsISupports
{
class nsIUrl : public nsITypicalUrl {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IURL_IID);
@ -129,40 +169,6 @@ public:
};
////////////////////////////////////////////////////////////////////////////////
// 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 nsITypicalUrl : public nsISupports
{
public:
NS_IMETHOD Init(const char* spec, nsIUrl* baseUrl) = 0;
};
extern nsresult NS_NewURL(nsIUrl** aInstancePtrResult, const char *aSpec, nsIUrl* aBaseUrl);
#endif /* nsIIUrl_h___ */

View File

@ -222,6 +222,36 @@ nsNetService::HasActiveConnections()
#endif
}
//////////////////////////
//// HELPER ROUTINES
//////////////////////////
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
nsresult NS_NewURL(nsIUrl** aInstancePtrResult,
const char *aSpec,
nsIUrl* aBaseUrl)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
nsINetService *inet = nsnull;
nsresult rv = nsServiceManager::GetService(kNetServiceCID,
kINetServiceIID,
(nsISupports **)&inet);
if (NS_FAILED(rv)) return rv;
rv = inet->NewUrl(aSpec, aBaseUrl, aInstancePtrResult);
if (NS_FAILED(rv)) return rv;
nsServiceManager::ReleaseService(kNetServiceCID, inet);
return rv;
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -31,7 +31,7 @@
{0x93, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} \
}
class nsUrl : public nsIUrl, public nsITypicalUrl
class nsUrl : public nsIUrl
{
public:
NS_DECL_AGGREGATED