Providing register and unregister hook per component in the generic

module. r=alecf
This commit is contained in:
dp%netscape.com 2000-01-11 21:18:55 +00:00
Родитель c0a53ad72f
Коммит 331dbeb0cd
4 изменённых файлов: 58 добавлений и 0 удалений

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

@ -218,6 +218,18 @@ nsGenericModule::RegisterSelf(nsIComponentManager *aCompMgr,
#endif
break;
}
// Call the registration hook of the component, if any
if (cp->mRegisterSelfProc)
{
rv = cp->mRegisterSelfProc(aCompMgr, aPath, registryLocation, componentType);
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("nsGenericModule %s: Register hook for %s component returned error => %x\n",
mModuleName?mModuleName:"(null)", cp->mDescription?cp->mDescription:"(null)", rv);
#endif
break;
}
}
cp++;
}
@ -234,6 +246,12 @@ nsGenericModule::UnregisterSelf(nsIComponentManager* aCompMgr,
#endif
nsModuleComponentInfo* cp = mComponents;
for (PRUint32 i = 0; i < mComponentCount; i++) {
// Call the unregistration hook of the component, if any
if (cp->mUnregisterSelfProc)
{
cp->mUnregisterSelfProc(aCompMgr, aPath, registryLocation);
}
// Unregister the component
nsresult rv = aCompMgr->UnregisterComponentSpec(cp->mCID, aPath);
if (NS_FAILED(rv)) {
#ifdef DEBUG

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

@ -72,6 +72,15 @@ NS_NewGenericFactory(nsIGenericFactory* *result,
#include "nsIModule.h"
typedef NS_CALLBACK(NSRegisterSelfProcPtr) (nsIComponentManager *aCompMgr,
nsIFileSpec *aPath,
const char *registryLocation,
const char *componentType);
typedef NS_CALLBACK(NSUnregisterSelfProcPtr) (nsIComponentManager *aCompMgr,
nsIFileSpec *aPath,
const char *registryLocation);
/**
* Use this type to define a list of module component info to pass to
* NS_NewGenericModule. E.g.:
@ -83,6 +92,8 @@ struct nsModuleComponentInfo {
nsCID mCID;
const char* mProgID;
nsIGenericFactory::ConstructorProcPtr mConstructor;
NSRegisterSelfProcPtr mRegisterSelfProc;
NSUnregisterSelfProcPtr mUnregisterSelfProc;
};
typedef void (PR_CALLBACK *nsModuleDestructorProc) (nsIModule *self);

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

@ -218,6 +218,18 @@ nsGenericModule::RegisterSelf(nsIComponentManager *aCompMgr,
#endif
break;
}
// Call the registration hook of the component, if any
if (cp->mRegisterSelfProc)
{
rv = cp->mRegisterSelfProc(aCompMgr, aPath, registryLocation, componentType);
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("nsGenericModule %s: Register hook for %s component returned error => %x\n",
mModuleName?mModuleName:"(null)", cp->mDescription?cp->mDescription:"(null)", rv);
#endif
break;
}
}
cp++;
}
@ -234,6 +246,12 @@ nsGenericModule::UnregisterSelf(nsIComponentManager* aCompMgr,
#endif
nsModuleComponentInfo* cp = mComponents;
for (PRUint32 i = 0; i < mComponentCount; i++) {
// Call the unregistration hook of the component, if any
if (cp->mUnregisterSelfProc)
{
cp->mUnregisterSelfProc(aCompMgr, aPath, registryLocation);
}
// Unregister the component
nsresult rv = aCompMgr->UnregisterComponentSpec(cp->mCID, aPath);
if (NS_FAILED(rv)) {
#ifdef DEBUG

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

@ -72,6 +72,15 @@ NS_NewGenericFactory(nsIGenericFactory* *result,
#include "nsIModule.h"
typedef NS_CALLBACK(NSRegisterSelfProcPtr) (nsIComponentManager *aCompMgr,
nsIFileSpec *aPath,
const char *registryLocation,
const char *componentType);
typedef NS_CALLBACK(NSUnregisterSelfProcPtr) (nsIComponentManager *aCompMgr,
nsIFileSpec *aPath,
const char *registryLocation);
/**
* Use this type to define a list of module component info to pass to
* NS_NewGenericModule. E.g.:
@ -83,6 +92,8 @@ struct nsModuleComponentInfo {
nsCID mCID;
const char* mProgID;
nsIGenericFactory::ConstructorProcPtr mConstructor;
NSRegisterSelfProcPtr mRegisterSelfProc;
NSUnregisterSelfProcPtr mUnregisterSelfProc;
};
typedef void (PR_CALLBACK *nsModuleDestructorProc) (nsIModule *self);