Add nsIComponentManager::registerComponentWithType.

Take advantage of IDLized nsIComponentManager to fix up nsIComponentLoader.idl
and make nsIModule scriptable.
This commit is contained in:
shaver%netscape.com 1999-09-06 16:43:09 +00:00
parent 55cd2133a6
commit 0a5c997f1a
5 changed files with 41 additions and 27 deletions

View File

@ -77,7 +77,7 @@ const char nativeComponentType[]="application/x-mozilla-native";
// We define a CID that is used to indicate the non-existence of a
// progid in the hash table.
#define NS_NO_CID { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
static NS_DEFINE_CID(kNoCID, NS_NO_CID);
static NS_DEFINE_CID(kNoCID, NS_NO_CID);
// Build is using USE_NSREG to turn off xpcom using registry
// but internally we use USE_REGISTRY. Map them propertly.
@ -1309,6 +1309,26 @@ nsComponentManagerImpl::RegisterComponent(const nsCID &aClass,
aReplace, aPersist, nativeComponentType);
}
nsresult
nsComponentManagerImpl::RegisterComponentWithType(const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFileSpec *aSpec,
PRBool aReplace,
PRBool aPersist,
const char *aType)
{
nsresult rv = NS_OK;
char *registryName;
rv = mNativeComponentLoader->RegistryNameForSpec(aSpec, &registryName);
if (NS_FAILED(rv))
return rv;
return RegisterComponentCommon(aClass, aClassName, aProgID, registryName,
aReplace, aPersist,
aType);
}
/*
* Register a component, using whatever they stuck in the FileSpec.
@ -1321,17 +1341,9 @@ nsComponentManagerImpl::RegisterComponentSpec(const nsCID &aClass,
PRBool aReplace,
PRBool aPersist)
{
nsresult rv = NS_OK;
char *registryName;
rv = mNativeComponentLoader->RegistryNameForSpec(aLibrarySpec,
&registryName);
if (NS_FAILED(rv))
return rv;
return RegisterComponentCommon(aClass, aClassName, aProgID, registryName,
aReplace, aPersist,
nativeComponentType);
return RegisterComponentWithType(aClass, aClassName, aProgID, aLibrarySpec,
aReplace, aPersist,
nativeComponentType);
}
/*

View File

@ -19,6 +19,7 @@
#include "nsISupports.idl"
#include "nsIFactory.idl"
#include "nsIFileSpec.idl"
#include "nsIComponentManager.idl"
[object, uuid(c073cfc0-567c-11d3-aec1-0000f8e25c06)]
interface nsIComponentLoader : nsISupports {
@ -32,10 +33,10 @@ interface nsIComponentLoader : nsISupports {
/**
* Initialize the loader.
*
* We use nsISupports here because nsIComponentManager and nsIRegistry
* aren't IDLized yet.
* We use nsISupports here because nsIRegistry isn't IDLized yet.
* Should we pass in a service manager reference too/instead?
*/
void Init(in nsISupports aCompMgr, in nsISupports aRegistry);
void Init(in nsIComponentManager aCompMgr, in nsISupports aRegistry);
/**
* Called when a component of the appropriate type is registered,

View File

@ -48,6 +48,13 @@ interface nsIComponentManager : nsISupports
void registerComponent(in nsCIDRef aClass, in string aClassName,
in string aProgID, in string aLocation,
in boolean aReplace, in boolean aPersist);
void registerComponentWithType(in nsCIDRef aClass,
in string aClassName,
in string aProgID,
in nsIFileSpec aSpec,
in boolean aReplace,
in boolean aPersist,
in string aType);
void registerComponentSpec(in nsCIDRef aClass, in string aClassName,
in string aProgID, in nsIFileSpec aLibrary,
in boolean aReplace, in boolean aPersist);

View File

@ -19,15 +19,9 @@
#include "nsISupports.idl"
#include "nsIFactory.idl"
#include "nsIFileSpec.idl"
#include "nsIComponentManager.idl"
%{C++
#include "nsIComponentManager.h"
%}
// Once we idl component manager, this can be removed
[ptr] native nsIComponentManager(nsIComponentManager);
[uuid(7392D032-5371-11d3-994E-00805FD26FEE)]
[scriptable, uuid(7392D032-5371-11d3-994E-00805FD26FEE)]
interface nsIModule : nsISupports
{
// Object Instance Creation.
@ -35,7 +29,7 @@ interface nsIModule : nsISupports
// create new objects.
// SingletonFactory can be queried off the Class Object. Services can be created
// using the singletonfactory.
void GetClassObject(in nsIComponentManager aCompMgr, in nsCIDRef aClass,
[noscript] void GetClassObject(in nsIComponentManager aCompMgr, in nsCIDRef aClass,
in nsIIDRef aIID, out voidStar return_ClassObject);
// Component registration

View File

@ -181,7 +181,7 @@ nsNativeComponentLoader::GetFactory(const nsIID & aCID,
}
NS_IMETHODIMP
nsNativeComponentLoader::Init(nsISupports *aCompMgr, nsISupports *aReg)
nsNativeComponentLoader::Init(nsIComponentManager *aCompMgr, nsISupports *aReg)
{
nsresult rv;
@ -189,9 +189,9 @@ nsNativeComponentLoader::Init(nsISupports *aCompMgr, nsISupports *aReg)
fprintf(stderr, "nNCL: Init()\n");
#endif
mCompMgr = do_QueryInterface(aCompMgr);
mCompMgr = aCompMgr;
mRegistry = do_QueryInterface(aReg);
if (!mCompMgr || !mRegistry)
if (!mCompMgr.get() || !mRegistry)
return NS_ERROR_INVALID_ARG;
rv = mRegistry->GetSubtree(nsIRegistry::Common, xpcomKeyName,