зеркало из https://github.com/mozilla/pjs.git
Landing M6 XPCOM Code cleanup branch
This commit is contained in:
Родитель
9e675bb870
Коммит
3371f4c197
|
@ -23,29 +23,6 @@
|
|||
extern "C" NS_EXPORT nsresult
|
||||
NS_RegistryGetFactory(nsISupports* servMgr, nsIFactory** aFactory);
|
||||
|
||||
#ifndef XP_MAC
|
||||
// including this on mac causes odd link errors in static initialization
|
||||
// stuff that we (pinkerton & scc) don't yet understand. If you want to
|
||||
// turn this on for mac, talk to one of us.
|
||||
#include <iostream.h>
|
||||
#endif
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <Files.h>
|
||||
#include <Memory.h>
|
||||
#include <Processes.h>
|
||||
#include <TextUtils.h>
|
||||
#ifndef PR_PATH_SEPARATOR
|
||||
#define PR_PATH_SEPARATOR ':'
|
||||
#endif
|
||||
#elif defined(XP_UNIX)
|
||||
#ifndef PR_PATH_SEPARATOR
|
||||
#define PR_PATH_SEPARATOR ':' // nspr doesn't like sun386i?
|
||||
#endif
|
||||
#else
|
||||
#include "private/primpl.h" // XXX for PR_PATH_SEPARATOR
|
||||
#endif
|
||||
|
||||
#include "plstr.h"
|
||||
#include "prlink.h"
|
||||
#include "prsystem.h"
|
||||
|
@ -125,13 +102,14 @@ nsFactoryEntry::Init(nsHashtable* dllCollection,
|
|||
nsCStringKey key(aLibrary);
|
||||
|
||||
// If dll not already in dllCollection, add it.
|
||||
// PR_EnterMonitor(mMon);
|
||||
dll = (nsDll *) dllCollection->Get(&key);
|
||||
// PR_ExitMonitor(mMon);
|
||||
|
||||
if (dll == NULL) {
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: New dll \"%s\".", aLibrary));
|
||||
#endif /* NS_DEBUG */
|
||||
|
||||
// Add a new Dll into the nsDllStore
|
||||
dll = new nsDll(aLibrary, lastModTime, fileSize);
|
||||
|
@ -139,24 +117,28 @@ nsFactoryEntry::Init(nsHashtable* dllCollection,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (dll->GetStatus() != DLL_OK) {
|
||||
// Cant create a nsDll. Backoff.
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: New dll status error. \"%s\".", aLibrary));
|
||||
#endif /* NS_DEBUG */
|
||||
delete dll;
|
||||
dll = NULL;
|
||||
}
|
||||
else {
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Adding New dll \"%s\" to mDllStore.",
|
||||
aLibrary));
|
||||
#endif /* NS_DEBUG */
|
||||
|
||||
// PR_EnterMonitor(mMon);
|
||||
dllCollection->Put(&key, (void *)dll);
|
||||
// PR_ExitMonitor(mMon);
|
||||
}
|
||||
}
|
||||
else {
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Found in mDllStore \"%s\".", aLibrary));
|
||||
#endif /* NS_DEBUG */
|
||||
// XXX We found the dll in the dllCollection.
|
||||
// XXX Consistency check: dll needs to have the same
|
||||
// XXX lastModTime and fileSize. If not that would mean
|
||||
|
@ -200,12 +182,12 @@ nsComponentManagerImpl::nsComponentManagerImpl()
|
|||
nsresult nsComponentManagerImpl::Init(void)
|
||||
{
|
||||
if (mFactories == NULL) {
|
||||
mFactories = new nsHashtable(256, PR_TRUE);
|
||||
mFactories = new nsHashtable(256, /* Thread Safe */ PR_TRUE);
|
||||
if (mFactories == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (mProgIDs == NULL) {
|
||||
mProgIDs = new nsHashtable(256, PR_TRUE);
|
||||
mProgIDs = new nsHashtable(256, /* Thread Safe */ PR_TRUE);
|
||||
if (mProgIDs == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -215,7 +197,7 @@ nsresult nsComponentManagerImpl::Init(void)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (mDllStore == NULL) {
|
||||
mDllStore = new nsHashtable(256, PR_TRUE);
|
||||
mDllStore = new nsHashtable(256, /* Thead Safe */ PR_TRUE);
|
||||
if (mDllStore == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -284,9 +266,10 @@ nsresult nsComponentManagerImpl::Init(void)
|
|||
if (PR_Access(dotMozillaDir, PR_ACCESS_EXISTS) != PR_SUCCESS)
|
||||
{
|
||||
PR_MkDir(dotMozillaDir, NS_MOZILLA_DIR_PERMISSION);
|
||||
printf("nsComponentManager: Creating Directory %s\n", dotMozillaDir);
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Creating Directory %s", dotMozillaDir));
|
||||
#endif /* NS_DEBUG */
|
||||
}
|
||||
}
|
||||
#endif /* XP_UNIX */
|
||||
|
@ -300,9 +283,9 @@ nsresult nsComponentManagerImpl::Init(void)
|
|||
// Check the version of registry. Nuke old versions.
|
||||
PlatformVersionCheck();
|
||||
|
||||
// Open common registry keys here to speed access
|
||||
// Do this after PlatformVersionCheck as it may re-create our keys
|
||||
nsresult rv;
|
||||
// Open common registry keys here to speed access
|
||||
// Do this after PlatformVersionCheck as it may re-create our keys
|
||||
nsresult rv;
|
||||
rv = mRegistry->AddSubtree(nsIRegistry::Common, xpcomKeyName, &mXPCOMKey);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -376,54 +359,66 @@ nsComponentManagerImpl::PlatformVersionCheck()
|
|||
|
||||
// If there is a version mismatch or no version string, we got an old registry.
|
||||
// Delete the old repository hierarchies and recreate version string
|
||||
if (err != NS_OK || PL_strcmp(buf, NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING))
|
||||
if (NS_FAILED(err) || PL_strcmp(buf, NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING))
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Registry version mismatch (%s vs %s). Nuking xpcom "
|
||||
"registry hierarchy.", buf, NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING));
|
||||
#endif /* NS_DEBUG */
|
||||
|
||||
// Delete the XPCOM and CLSID hierarchy
|
||||
nsIRegistry::Key netscapeKey;
|
||||
rv = mRegistry->GetSubtree(nsIRegistry::Common,netscapeKeyName, &netscapeKey);
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Failed To Get Subtree (%s)",netscapeKeyName));
|
||||
#endif /* NS_DEBUG */
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = mRegistry->RemoveSubtreeRaw(netscapeKey, xpcomBaseName);
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Failed To Nuke Subtree (%s)",xpcomKeyName));
|
||||
#endif /* NS_DEBUG */
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = mRegistry->RemoveSubtreeRaw(netscapeKey, xpcomBaseName);
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Failed To Nuke Subtree (%s)",xpcomKeyName));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
rv = mRegistry->GetSubtree(nsIRegistry::Common,classesKeyName, &netscapeKey);
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Failed To Get Subtree (%s)",classesKeyName));
|
||||
#endif /* NS_DEBUG */
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = mRegistry->RemoveSubtreeRaw(netscapeKey, classIDKeyName);
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Failed To Nuke Subtree (%s/%s)",classesKeyName,classIDKeyName));
|
||||
#endif /* NS_DEBUG */
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = mRegistry->RemoveSubtreeRaw(netscapeKey, classIDKeyName);
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Failed To Nuke Subtree (%s/%s)",classesKeyName,classIDKeyName));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// Recreate XPCOM and CLSID keys
|
||||
rv = mRegistry->AddSubtree(nsIRegistry::Common,xpcomKeyName, &xpcomKey);
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Failed To Add Subtree (%s)",xpcomKeyName));
|
||||
#endif /* NS_DEBUG */
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
@ -431,8 +426,10 @@ nsComponentManagerImpl::PlatformVersionCheck()
|
|||
rv = mRegistry->AddSubtree(nsIRegistry::Common,classesClassIDKeyName, NULL);
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Failed To Add Subtree (%s)",classesClassIDKeyName));
|
||||
#endif /* NS_DEBUG */
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
@ -440,16 +437,20 @@ nsComponentManagerImpl::PlatformVersionCheck()
|
|||
rv = mRegistry->SetString(xpcomKey,versionValueName, NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING);
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Failed To Set String (Version) Under (%s)",xpcomKeyName));
|
||||
#endif /* NS_DEBUG */
|
||||
return rv;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: platformVersionCheck() passed."));
|
||||
#endif /* NS_DEBUG */
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -822,25 +823,30 @@ nsComponentManagerImpl::LoadFactory(nsFactoryEntry *aEntry,
|
|||
if (aEntry->dll->IsLoaded() == PR_FALSE)
|
||||
{
|
||||
// Load the dll
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: + Loading \"%s\".", aEntry->dll->GetFullPath()));
|
||||
#endif /* NS_DEBUG */
|
||||
if (aEntry->dll->Load() == PR_FALSE)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ERROR,
|
||||
("nsComponentManager: Library load unsuccessful."));
|
||||
#endif /* NS_DEBUG */
|
||||
|
||||
char errorMsg[1024] = "Cannot get error from nspr. Not enough memory.";
|
||||
if (PR_GetErrorTextLength() < (int) sizeof(errorMsg))
|
||||
PR_GetErrorText(errorMsg);
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Load(%s) FAILED with error:%s", aEntry->dll->GetFullPath(), errorMsg));
|
||||
#if defined(XP_UNIX) || defined(XP_PC)
|
||||
#endif /* NS_DEBUG */
|
||||
|
||||
// Put the error message on the screen.
|
||||
printf("**************************************************\n"
|
||||
"nsComponentManager: Load(%s) FAILED with error: %s\n"
|
||||
"**************************************************\n",
|
||||
aEntry->dll->GetFullPath(), errorMsg);
|
||||
#endif
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -877,8 +883,10 @@ nsComponentManagerImpl::LoadFactory(nsFactoryEntry *aEntry,
|
|||
delete[] progID;
|
||||
return rv;
|
||||
}
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ERROR,
|
||||
("nsComponentManager: NSGetFactory entrypoint not found."));
|
||||
#endif /* NS_DEBUG */
|
||||
return NS_ERROR_FACTORY_NOT_LOADED;
|
||||
}
|
||||
|
||||
|
@ -916,27 +924,30 @@ nsComponentManagerImpl::FindFactory(const nsCID &aClass,
|
|||
#ifdef USE_REGISTRY
|
||||
if (entry == NULL)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("\t\tnot found in factory cache. Looking in registry"));
|
||||
#endif /* NS_DEBUG */
|
||||
nsresult rv = PlatformFind(aClass, &entry);
|
||||
|
||||
// XXX This should go into PlatformFind(), and PlatformFind()
|
||||
// should just become a static method on nsComponentManager.
|
||||
|
||||
// If we got one, cache it in our hashtable
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("\t\tfound in registry."));
|
||||
#endif /* NS_DEBUG */
|
||||
mFactories->Put(&key, entry);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("\t\tfound in factory cache."));
|
||||
#endif /* NS_DEBUG */
|
||||
}
|
||||
#endif
|
||||
#endif /* USE_REGISTRY */
|
||||
|
||||
PR_ExitMonitor(mMon);
|
||||
|
||||
|
@ -954,9 +965,11 @@ nsComponentManagerImpl::FindFactory(const nsCID &aClass,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
|
||||
("\t\tFindFactory() %s",
|
||||
NS_SUCCEEDED(res) ? "succeeded" : "FAILED"));
|
||||
#endif /* NS_DEBUG */
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -1104,14 +1117,18 @@ nsComponentManagerImpl::CreateInstance(const nsCID &aClass,
|
|||
{
|
||||
res = factory->CreateInstance(aDelegate, aIID, aResult);
|
||||
NS_RELEASE(factory);
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("\t\tFactory CreateInstance() %s.",
|
||||
NS_SUCCEEDED(res) ? "succeeded" : "FAILED"));
|
||||
#endif /* NS_DEBUG */
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("\t\tCreateInstance() FAILED."));
|
||||
#endif /* NS_DEBUG */
|
||||
return NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
}
|
||||
|
||||
|
@ -1138,56 +1155,6 @@ nsComponentManagerImpl::CreateInstance(const char *aProgID,
|
|||
return CreateInstance(clsid, aDelegate, aIID, aResult);
|
||||
}
|
||||
|
||||
#if 0
|
||||
nsresult
|
||||
nsComponentManagerImpl::CreateInstance2(const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void *aSignature,
|
||||
void **aResult)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS))
|
||||
{
|
||||
char *buf = aClass.ToString();
|
||||
PR_LogPrint("nsComponentManager: Creating Instance.");
|
||||
PR_LogPrint("nsComponentManager: + %s.",
|
||||
buf);
|
||||
PR_LogPrint("nsComponentManager: + Signature = %p.",
|
||||
aSignature);
|
||||
delete [] buf;
|
||||
}
|
||||
#endif
|
||||
if (aResult == NULL)
|
||||
{
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = NULL;
|
||||
|
||||
nsIFactory *factory = NULL;
|
||||
|
||||
nsresult res = FindFactory(aClass, &factory);
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
nsIFactory2 *factory2 = NULL;
|
||||
res = NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT;
|
||||
|
||||
factory->QueryInterface(kFactory2IID, (void **) &factory2);
|
||||
|
||||
if (factory2 != NULL)
|
||||
{
|
||||
res = factory2->CreateInstance2(aDelegate, aIID, aSignature, aResult);
|
||||
NS_RELEASE(factory2);
|
||||
}
|
||||
|
||||
NS_RELEASE(factory);
|
||||
return res;
|
||||
}
|
||||
|
||||
return NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
/**
|
||||
* RegisterFactory()
|
||||
|
@ -1231,14 +1198,18 @@ nsComponentManagerImpl::RegisterFactory(const nsCID &aClass,
|
|||
NS_RELEASE(old);
|
||||
if (!aReplace)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
|
||||
("\t\tFactory already registered."));
|
||||
#endif /* NS_DEBUG */
|
||||
return NS_ERROR_FACTORY_EXISTS;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
|
||||
("\t\tdeleting old Factory Entry."));
|
||||
#endif /* NS_DEBUG */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1272,15 +1243,19 @@ nsComponentManagerImpl::RegisterFactory(const nsCID &aClass,
|
|||
// CreateInstance(..progid..) is the more used one.
|
||||
//
|
||||
PR_ExitMonitor(mMon);
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
|
||||
("\t\tFactory register succeeded. PROGID->CLSID mapping failed."));
|
||||
#endif /* NS_DEBUG */
|
||||
return (rv);
|
||||
}
|
||||
}
|
||||
PR_ExitMonitor(mMon);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
|
||||
("\t\tFactory register succeeded."));
|
||||
#endif /* NS_DEBUG */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1312,14 +1287,18 @@ nsComponentManagerImpl::RegisterComponent(const nsCID &aClass,
|
|||
NS_RELEASE(old);
|
||||
if (!aReplace)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
|
||||
("\t\tFactory already registered."));
|
||||
#endif /* NS_DEBUG */
|
||||
return NS_ERROR_FACTORY_EXISTS;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
|
||||
("\t\tdeleting registered Factory."));
|
||||
#endif /* NS_DEBUG */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1389,9 +1368,11 @@ nsComponentManagerImpl::RegisterComponent(const nsCID &aClass,
|
|||
}
|
||||
|
||||
PR_ExitMonitor(mMon);
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
|
||||
("\t\tFactory register %s.",
|
||||
rv == NS_OK ? "succeeded" : "failed"));
|
||||
#endif /* NS_DEBUG */
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1425,9 +1406,11 @@ nsComponentManagerImpl::UnregisterFactory(const nsCID &aClass,
|
|||
|
||||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
|
||||
("nsComponentManager: ! Factory unregister %s.",
|
||||
res == NS_OK ? "succeeded" : "failed"));
|
||||
NS_SUCCEEDED(res) ? "succeeded" : "failed"));
|
||||
#endif /* NS_DEBUG */
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -1479,63 +1462,11 @@ nsComponentManagerImpl::UnregisterComponent(const nsCID &aClass,
|
|||
|
||||
PR_ExitMonitor(mMon);
|
||||
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
|
||||
("nsComponentManager: ! Factory unregister %s.",
|
||||
res == NS_OK ? "succeeded" : "failed"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManagerImpl::UnregisterFactory(const nsCID &aClass,
|
||||
const char *aLibrary)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS))
|
||||
{
|
||||
char *buf = aClass.ToString();
|
||||
PR_LogPrint("nsComponentManager: Unregistering Factory.");
|
||||
PR_LogPrint("nsComponentManager: + %s in \"%s\".", buf, aLibrary);
|
||||
delete [] buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsIDKey key(aClass);
|
||||
nsFactoryEntry *old = (nsFactoryEntry *) mFactories->Get(&key);
|
||||
|
||||
nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
|
||||
PR_EnterMonitor(mMon);
|
||||
|
||||
if (old != NULL && old->dll != NULL)
|
||||
{
|
||||
if (old->dll->GetFullPath() != NULL &&
|
||||
#ifdef XP_UNIX
|
||||
PL_strcasecmp(old->dll->GetFullPath(), aLibrary)
|
||||
#else
|
||||
PL_strcmp(old->dll->GetFullPath(), aLibrary)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
nsFactoryEntry *entry = (nsFactoryEntry *) mFactories->Remove(&key);
|
||||
delete entry;
|
||||
res = NS_OK;
|
||||
}
|
||||
#ifdef USE_REGISTRY
|
||||
// XXX temp hack until we get the dll to give us the entire
|
||||
// XXX NSQuickRegisterClassData
|
||||
QuickRegisterData cregd = {0};
|
||||
cregd.CIDString = aClass.ToString();
|
||||
res = PlatformUnregister(&cregd, aLibrary);
|
||||
delete [] (char *)cregd.CIDString;
|
||||
#endif
|
||||
}
|
||||
|
||||
PR_ExitMonitor(mMon);
|
||||
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
|
||||
("nsComponentManager: ! Factory unregister %s.",
|
||||
res == NS_OK ? "succeeded" : "failed"));
|
||||
NS_SUCCEEDED(res) ? "succeeded" : "failed"));
|
||||
#endif /* NS_DEBUG */
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -1551,9 +1482,12 @@ nsFreeLibraryEnum(nsHashKey *aKey, void *aData, void* closure)
|
|||
nsCanUnloadProc proc = (nsCanUnloadProc) entry->dll->FindSymbol("NSCanUnload");
|
||||
if (proc != NULL) {
|
||||
nsresult rv = proc(serviceMgr);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: + Unloading \"%s\".", entry->dll->GetFullPath()));
|
||||
#endif /* NS_DEBUG */
|
||||
entry->dll->Unload();
|
||||
}
|
||||
}
|
||||
|
@ -1567,8 +1501,10 @@ nsComponentManagerImpl::FreeLibraries(void)
|
|||
{
|
||||
PR_EnterMonitor(mMon);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Freeing Libraries."));
|
||||
#endif /* NS_DEBUG */
|
||||
|
||||
nsIServiceManager* serviceMgr = NULL;
|
||||
nsresult rv = nsServiceManager::GetGlobalServiceManager(&serviceMgr);
|
||||
|
@ -1601,79 +1537,24 @@ nsComponentManagerImpl::FreeLibraries(void)
|
|||
nsresult
|
||||
nsComponentManagerImpl::AutoRegister(RegistrationTime when, const char* dir)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (dir != NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Autoregistration begins. dir = %s", dir));
|
||||
SyncComponentsInDir(when, dir);
|
||||
printf("nsComponentManager: Autoregistration begins. dir = %s\n", dir);
|
||||
#endif /* DEBUG */
|
||||
rv = SyncComponentsInDir(when, dir);
|
||||
#ifdef DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Autoregistration ends.", dir));
|
||||
("nsComponentManager: Autoregistration ends. dir = %s", dir));
|
||||
printf("nsComponentManager: Autoregistration ends. dir = %s\n", dir);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
// The below code is being moved out into the applications using using
|
||||
// nsSpecialSystemDirectory platform by platform.
|
||||
|
||||
// get info for the the current process to determine the directory its located in
|
||||
CInfoPBRec catInfo;
|
||||
Handle pathH;
|
||||
OSErr err;
|
||||
ProcessSerialNumber psn;
|
||||
ProcessInfoRec pInfo;
|
||||
FSSpec appFSSpec;
|
||||
FSSpec tempSpec;
|
||||
long theDirID;
|
||||
Str255 name;
|
||||
|
||||
if (!(err = GetCurrentProcess(&psn)))
|
||||
{
|
||||
// initialize ProcessInfoRec before calling GetProcessInformation() or die horribly.
|
||||
pInfo.processName = nil;
|
||||
pInfo.processAppSpec = &tempSpec;
|
||||
pInfo.processInfoLength = sizeof(ProcessInfoRec);
|
||||
if (!(err = GetProcessInformation(&psn, &pInfo)))
|
||||
{
|
||||
appFSSpec = *(pInfo.processAppSpec);
|
||||
if ((pathH = NewHandle(1)) != NULL)
|
||||
{
|
||||
**pathH = '\0'; // initially null terminate the string
|
||||
HNoPurge(pathH);
|
||||
HUnlock(pathH);
|
||||
theDirID = appFSSpec.parID;
|
||||
do
|
||||
{
|
||||
catInfo.dirInfo.ioCompletion = NULL;
|
||||
catInfo.dirInfo.ioNamePtr = (StringPtr)&name;
|
||||
catInfo.dirInfo.ioVRefNum = appFSSpec.vRefNum;
|
||||
catInfo.dirInfo.ioDrDirID = theDirID;
|
||||
catInfo.dirInfo.ioFDirIndex = -1; // -1 = query dir in ioDrDirID
|
||||
if (!(err = PBGetCatInfoSync(&catInfo)))
|
||||
{
|
||||
// build up a Unix style pathname due to NSPR
|
||||
// XXX Note: this breaks if any of the parent
|
||||
// directories contain a "slash" (blame NSPR)
|
||||
|
||||
Munger(pathH, 0L, NULL, 0L, (const void *)&name[1], (long)name[0]); // prepend dir name
|
||||
Munger(pathH, 0L, NULL, 0L, "/", 1); // prepend slash
|
||||
|
||||
// move up to parent directory
|
||||
theDirID = catInfo.dirInfo.ioDrParID;
|
||||
}
|
||||
} while ((!err) && (catInfo.dirInfo.ioDrDirID != 2)); // 2 = root
|
||||
if (!err)
|
||||
{
|
||||
Munger(pathH, GetHandleSize(pathH)-1, NULL, 0L, "/components", 11); // append "/components"
|
||||
HLock(pathH);
|
||||
SyncComponentsInDir(when, (const char *)(*pathH));
|
||||
HUnlock(pathH);
|
||||
}
|
||||
DisposeHandle(pathH);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* XP_MAC */
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1770,10 +1651,14 @@ nsComponentManagerImpl::AutoRegisterComponent(RegistrationTime when, const char
|
|||
nsresult rv = NS_OK;
|
||||
if (dll == NULL)
|
||||
{
|
||||
// XXX Create nsDll for this from registry and
|
||||
// XXX add it to our dll cache mDllStore.
|
||||
// Create nsDll for this from registry and
|
||||
// add it to our dll cache mDllStore.
|
||||
#ifdef USE_REGISTRY
|
||||
rv = PlatformCreateDll(fullname, &dll);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
mDllStore->Put(&key, (void *) dll);
|
||||
}
|
||||
#endif /* USE_REGISTRY */
|
||||
}
|
||||
|
||||
|
@ -1782,9 +1667,11 @@ nsComponentManagerImpl::AutoRegisterComponent(RegistrationTime when, const char
|
|||
// Make sure the dll is OK
|
||||
if (dll->GetStatus() != NS_OK)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: + nsDll not NS_OK \"%s\". Skipping...",
|
||||
dll->GetFullPath()));
|
||||
#endif /* NS_DEBUG */
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -1793,9 +1680,11 @@ nsComponentManagerImpl::AutoRegisterComponent(RegistrationTime when, const char
|
|||
(dll->GetSize() == statbuf.size))
|
||||
{
|
||||
// Dll hasn't changed. Skip.
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: + nsDll not changed \"%s\". Skipping...",
|
||||
dll->GetFullPath()));
|
||||
#endif /* NS_DEBUG */
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1815,9 +1704,11 @@ nsComponentManagerImpl::AutoRegisterComponent(RegistrationTime when, const char
|
|||
PRBool res = proc(this /*, PR_TRUE*/);
|
||||
if (res)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: + Unloading \"%s\".",
|
||||
dll->GetFullPath()));
|
||||
#endif /* NS_DEBUG */
|
||||
dll->Unload();
|
||||
}
|
||||
else
|
||||
|
@ -1825,10 +1716,12 @@ nsComponentManagerImpl::AutoRegisterComponent(RegistrationTime when, const char
|
|||
// THIS IS THE WORST SITUATION TO BE IN.
|
||||
// Dll doesn't want to be unloaded. Cannot re-register
|
||||
// this dll.
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: *** Dll already loaded. "
|
||||
"Cannot unload either. Hence cannot re-register "
|
||||
"\"%s\". Skipping...", dll->GetFullPath()));
|
||||
#endif /* NS_DEBUG */
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -1836,10 +1729,12 @@ nsComponentManagerImpl::AutoRegisterComponent(RegistrationTime when, const char
|
|||
// dll doesn't have a CanUnload proc. Guess it is
|
||||
// ok to unload it.
|
||||
dll->Unload();
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: + Unloading \"%s\". (no CanUnloadProc).",
|
||||
dll->GetFullPath()));
|
||||
|
||||
#endif /* NS_DEBUG */
|
||||
}
|
||||
|
||||
} // dll isloaded
|
||||
|
@ -1850,9 +1745,11 @@ nsComponentManagerImpl::AutoRegisterComponent(RegistrationTime when, const char
|
|||
// We went through all the above to make sure the dll
|
||||
// is unloaded. And here we are with the dll still
|
||||
// loaded. Whoever taught dp programming...
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Dll still loaded. Cannot re-register "
|
||||
"\"%s\". Skipping...", dll->GetFullPath()));
|
||||
#endif /* NS_DEBUG */
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} // dll != NULL
|
||||
|
@ -1876,9 +1773,11 @@ nsComponentManagerImpl::AutoRegisterComponent(RegistrationTime when, const char
|
|||
nsresult ret = NS_OK;
|
||||
if (NS_FAILED(res))
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Autoregistration FAILED for "
|
||||
"\"%s\". Skipping...", dll->GetFullPath()));
|
||||
#endif /* NS_DEBUG */
|
||||
// Mark dll as not xpcom dll along with modified time and size in
|
||||
// the registry so that we wont need to load the dll again every
|
||||
// session until the dll changes.
|
||||
|
@ -1889,9 +1788,11 @@ nsComponentManagerImpl::AutoRegisterComponent(RegistrationTime when, const char
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: Autoregistration Passed for "
|
||||
"\"%s\". Skipping...", dll->GetFullPath()));
|
||||
"\"%s\".", dll->GetFullPath()));
|
||||
#endif /* NS_DEBUG */
|
||||
// Marking dll along with modified time and size in the
|
||||
// registry happens at PlatformRegister(). No need to do it
|
||||
// here again.
|
||||
|
@ -1920,15 +1821,16 @@ nsComponentManagerImpl::SelfRegisterDll(nsDll *dll)
|
|||
char errorMsg[1024] = "Cannot get error from nspr. Not enough memory.";
|
||||
if (PR_GetErrorTextLength() < (int) sizeof(errorMsg))
|
||||
PR_GetErrorText(errorMsg);
|
||||
#ifdef NS_DEBUG
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
|
||||
("nsComponentManager: SelfRegisterDll(%s) Load FAILED with error:%s", dll->GetFullPath(), errorMsg));
|
||||
#if defined(XP_UNIX) || defined(XP_PC)
|
||||
#endif /* NS_DEBUG */
|
||||
// Put the error message on the screen.
|
||||
// For now this message is also for optimized builds. Hence no ifdef DEBUG
|
||||
printf("**************************************************\n"
|
||||
"nsComponentManager: Load(%s) FAILED with error: %s\n"
|
||||
"**************************************************\n",
|
||||
dll->GetFullPath(), errorMsg);
|
||||
#endif
|
||||
|
||||
return(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
|
|
@ -81,15 +81,6 @@ public:
|
|||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
// Creates a class instance for a specific class ID
|
||||
/*
|
||||
NS_IMETHOD CreateInstance2(const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void *aSignature,
|
||||
void **aResult);
|
||||
*/
|
||||
|
||||
// Manually registry a factory for a class
|
||||
NS_IMETHOD RegisterFactory(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
|
@ -109,10 +100,6 @@ public:
|
|||
NS_IMETHOD UnregisterFactory(const nsCID &aClass,
|
||||
nsIFactory *aFactory);
|
||||
|
||||
// Manually unregister a dynamically loaded factory for a class
|
||||
NS_IMETHOD UnregisterFactory(const nsCID &aClass,
|
||||
const char *aLibrary);
|
||||
|
||||
// Manually unregister a dynamically loaded component
|
||||
NS_IMETHOD UnregisterComponent(const nsCID &aClass,
|
||||
const char *aLibrary);
|
||||
|
@ -128,13 +115,13 @@ public:
|
|||
// ".dso", // Unix
|
||||
// ".so", // Unix
|
||||
// ".sl", // Unix: HP
|
||||
// "_dll", // Mac
|
||||
// ".shlb", // Mac
|
||||
// ".dlm", // new for all platforms
|
||||
//
|
||||
// Directory and fullname are what NSPR will accept. For eg.
|
||||
// WIN y:/home/dp/mozilla/dist/bin
|
||||
// UNIX /home/dp/mozilla/dist/bin
|
||||
// MAC /Hard drive/mozilla/dist/apprunner
|
||||
// MAC /Hard drive/mozilla/dist/bin
|
||||
// WIN y:\Hard drive\mozilla\dist\bin (or) y:/Hard drive/mozilla/dist/bin
|
||||
// UNIX /Hard drive/mozilla/dist/bin
|
||||
//
|
||||
NS_IMETHOD AutoRegister(RegistrationTime when, const char* directory);
|
||||
NS_IMETHOD AutoRegisterComponent(RegistrationTime when, const char *fullname);
|
||||
|
@ -175,9 +162,9 @@ protected:
|
|||
PRMonitor* mMon;
|
||||
nsHashtable* mDllStore;
|
||||
nsIRegistry* mRegistry;
|
||||
nsIRegistry::Key mXPCOMKey;
|
||||
nsIRegistry::Key mClassesKey;
|
||||
nsIRegistry::Key mCLSIDKey;
|
||||
nsIRegistry::Key mXPCOMKey;
|
||||
nsIRegistry::Key mClassesKey;
|
||||
nsIRegistry::Key mCLSIDKey;
|
||||
};
|
||||
|
||||
#define NS_MAX_FILENAME_LEN 1024
|
||||
|
|
|
@ -99,15 +99,6 @@ public:
|
|||
const nsIID &aIID,
|
||||
void **aResult) = 0;
|
||||
|
||||
// Creates a class instance for a specific class ID
|
||||
/*
|
||||
NS_IMETHOD CreateInstance2(const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void *aSignature,
|
||||
void **aResult) = 0;
|
||||
*/
|
||||
|
||||
// Manually registry a factory for a class
|
||||
NS_IMETHOD RegisterFactory(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
|
@ -127,10 +118,6 @@ public:
|
|||
NS_IMETHOD UnregisterFactory(const nsCID &aClass,
|
||||
nsIFactory *aFactory) = 0;
|
||||
|
||||
// Manually unregister a dynamically loaded factory for a class
|
||||
NS_IMETHOD UnregisterFactory(const nsCID &aClass,
|
||||
const char *aLibrary) = 0;
|
||||
|
||||
// Manually unregister a dynamically loaded component
|
||||
NS_IMETHOD UnregisterComponent(const nsCID &aClass,
|
||||
const char *aLibrary) = 0;
|
||||
|
@ -146,13 +133,13 @@ public:
|
|||
// ".dso", // Unix
|
||||
// ".so", // Unix
|
||||
// ".sl", // Unix: HP
|
||||
// "_dll", // Mac
|
||||
// ".shlb", // Mac
|
||||
// ".dlm", // new for all platforms
|
||||
//
|
||||
// Directory and fullname are what NSPR will accept. For eg.
|
||||
// WIN y:/home/dp/mozilla/dist/bin
|
||||
// UNIX /home/dp/mozilla/dist/bin
|
||||
// MAC /Hard drive/mozilla/dist/apprunner
|
||||
// MAC /Hard drive/mozilla/dist/bin
|
||||
// WIN y:\Hard drive\mozilla\dist\bin (or) y:/Hard drive/mozilla/dist/bin
|
||||
// UNIX /Hard drive/mozilla/dist/bin
|
||||
//
|
||||
enum RegistrationTime {
|
||||
NS_Startup = 0,
|
||||
|
@ -222,10 +209,6 @@ public:
|
|||
static nsresult UnregisterFactory(const nsCID &aClass,
|
||||
nsIFactory *aFactory);
|
||||
|
||||
// Manually unregister a dynamically loaded factory for a class
|
||||
static nsresult UnregisterFactory(const nsCID &aClass,
|
||||
const char *aLibrary);
|
||||
|
||||
// Manually unregister a dynamically loaded component
|
||||
static nsresult UnregisterComponent(const nsCID &aClass,
|
||||
const char *aLibrary);
|
||||
|
|
|
@ -42,27 +42,4 @@ public:
|
|||
NS_IMETHOD LockFactory(PRBool aLock) = 0;
|
||||
};
|
||||
|
||||
#if 0
|
||||
/* Excluding IFactory2 until there is proof of its use - dp */
|
||||
/**
|
||||
* nsIFactory2 allows passing in a signature token when creating an
|
||||
* instance. This allows instance recycling.
|
||||
*/
|
||||
|
||||
// {19997C41-A343-11d1-B665-00805F8A2676}
|
||||
#define NS_IFACTORY2_IID \
|
||||
{ 0x19997c41, 0xa343, 0x11d1, \
|
||||
{ 0xb6, 0x65, 0x0, 0x80, 0x5f, 0x8a, 0x26, 0x76 } }
|
||||
|
||||
class nsIFactory2: public nsIFactory {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IFACTORY2_IID; return iid; }
|
||||
|
||||
NS_IMETHOD CreateInstance2(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void *aSignature,
|
||||
void **aResult) = 0;
|
||||
};
|
||||
#endif /* 0 */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -118,16 +118,6 @@ nsComponentManager::UnregisterFactory(const nsCID &aClass,
|
|||
return cm->UnregisterFactory(aClass, aFactory);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::UnregisterFactory(const nsCID &aClass,
|
||||
const char *aLibrary)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->UnregisterFactory(aClass, aLibrary);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::UnregisterComponent(const nsCID &aClass,
|
||||
const char *aLibrary)
|
||||
|
|
|
@ -134,8 +134,8 @@ PRBool nsDll::Load(void)
|
|||
{
|
||||
m_instance = PR_LoadLibrary(macFileName);
|
||||
}
|
||||
PL_strfree(macFileName);
|
||||
}
|
||||
|
||||
#else
|
||||
// This is the only right way of doing this...
|
||||
m_instance = PR_LoadLibrary(m_fullpath);
|
||||
|
|
|
@ -1,247 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* 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 nsIComponentManager_h__
|
||||
#define nsIComponentManager_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsCom.h"
|
||||
#include "nsID.h"
|
||||
#include "nsError.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIFactory.h"
|
||||
|
||||
/*
|
||||
* Prototypes for dynamic library export functions. Your DLL/DSO needs to export
|
||||
* these methods to play in the component world.
|
||||
*/
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory);
|
||||
extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr);
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *fullpath);
|
||||
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char *fullpath);
|
||||
|
||||
typedef nsresult (*nsFactoryProc)(nsISupports* aServMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory);
|
||||
typedef PRBool (*nsCanUnloadProc)(nsISupports* aServMgr);
|
||||
typedef nsresult (*nsRegisterProc)(nsISupports* aServMgr, const char *path);
|
||||
typedef nsresult (*nsUnregisterProc)(nsISupports* aServMgr, const char *path);
|
||||
|
||||
#define NS_ICOMPONENTMANAGER_IID \
|
||||
{ /* 8458a740-d5dc-11d2-92fb-00e09805570f */ \
|
||||
0x8458a740, \
|
||||
0xd5dc, \
|
||||
0x11d2, \
|
||||
{0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \
|
||||
}
|
||||
|
||||
#define NS_COMPONENTMANAGER_CID \
|
||||
{ /* 91775d60-d5dc-11d2-92fb-00e09805570f */ \
|
||||
0x91775d60, \
|
||||
0xd5dc, \
|
||||
0x11d2, \
|
||||
{0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \
|
||||
}
|
||||
|
||||
/*
|
||||
* nsIComponentManager interface
|
||||
*/
|
||||
|
||||
class nsIComponentManager : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICOMPONENTMANAGER_IID)
|
||||
|
||||
NS_IMETHOD FindFactory(const nsCID &aClass,
|
||||
nsIFactory **aFactory) = 0;
|
||||
|
||||
// Finds a class ID for a specific Program ID
|
||||
NS_IMETHOD ProgIDToCLSID(const char *aProgID,
|
||||
nsCID *aClass) = 0;
|
||||
|
||||
// Finds a Program ID for a specific class ID
|
||||
// caller frees the result with delete[]
|
||||
NS_IMETHOD CLSIDToProgID(nsCID *aClass,
|
||||
char* *aClassName,
|
||||
char* *aProgID) = 0;
|
||||
|
||||
// Creates a class instance for a specific class ID
|
||||
NS_IMETHOD CreateInstance(const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult) = 0;
|
||||
|
||||
// Convenience routine, creates a class instance for a specific ProgID
|
||||
NS_IMETHOD CreateInstance(const char *aProgID,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult) = 0;
|
||||
|
||||
// Creates a class instance for a specific class ID
|
||||
/*
|
||||
NS_IMETHOD CreateInstance2(const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void *aSignature,
|
||||
void **aResult) = 0;
|
||||
*/
|
||||
|
||||
// Manually registry a factory for a class
|
||||
NS_IMETHOD RegisterFactory(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory *aFactory,
|
||||
PRBool aReplace) = 0;
|
||||
|
||||
// Manually register a dynamically loaded component.
|
||||
NS_IMETHOD RegisterComponent(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
const char *aLibrary,
|
||||
PRBool aReplace,
|
||||
PRBool aPersist) = 0;
|
||||
|
||||
// Manually unregister a factory for a class
|
||||
NS_IMETHOD UnregisterFactory(const nsCID &aClass,
|
||||
nsIFactory *aFactory) = 0;
|
||||
|
||||
// Manually unregister a dynamically loaded factory for a class
|
||||
NS_IMETHOD UnregisterFactory(const nsCID &aClass,
|
||||
const char *aLibrary) = 0;
|
||||
|
||||
// Manually unregister a dynamically loaded component
|
||||
NS_IMETHOD UnregisterComponent(const nsCID &aClass,
|
||||
const char *aLibrary) = 0;
|
||||
|
||||
// Unload dynamically loaded factories that are not in use
|
||||
NS_IMETHOD FreeLibraries(void) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// DLL registration support
|
||||
// Autoregistration will try only files with these extensions.
|
||||
// All extensions are case insensitive.
|
||||
// ".dll", // Windows
|
||||
// ".dso", // Unix
|
||||
// ".so", // Unix
|
||||
// ".sl", // Unix: HP
|
||||
// "_dll", // Mac
|
||||
// ".dlm", // new for all platforms
|
||||
//
|
||||
// Directory and fullname are what NSPR will accept. For eg.
|
||||
// WIN y:/home/dp/mozilla/dist/bin
|
||||
// UNIX /home/dp/mozilla/dist/bin
|
||||
// MAC /Hard drive/mozilla/dist/apprunner
|
||||
//
|
||||
enum RegistrationTime {
|
||||
NS_Startup = 0,
|
||||
NS_Script = 1,
|
||||
NS_Timer = 2
|
||||
};
|
||||
|
||||
NS_IMETHOD AutoRegister(RegistrationTime when, const char* directory) = 0;
|
||||
NS_IMETHOD AutoRegisterComponent(RegistrationTime when, const char *fullname) = 0;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern NS_COM nsresult
|
||||
NS_GetGlobalComponentManager(nsIComponentManager* *result);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Global Static Component Manager Methods
|
||||
// (for when you need to link with xpcom)
|
||||
|
||||
class NS_COM nsComponentManager {
|
||||
public:
|
||||
static nsresult Initialize(void);
|
||||
|
||||
// Finds a factory for a specific class ID
|
||||
static nsresult FindFactory(const nsCID &aClass,
|
||||
nsIFactory **aFactory);
|
||||
|
||||
// Finds a class ID for a specific Program ID
|
||||
static nsresult ProgIDToCLSID(const char *aProgID,
|
||||
nsCID *aClass);
|
||||
|
||||
// Finds a Program ID for a specific class ID
|
||||
// caller frees the result with delete[]
|
||||
static nsresult CLSIDToProgID(nsCID *aClass,
|
||||
char* *aClassName,
|
||||
char* *aProgID);
|
||||
|
||||
// Creates a class instance for a specific class ID
|
||||
static nsresult CreateInstance(const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
// Convenience routine, creates a class instance for a specific ProgID
|
||||
static nsresult CreateInstance(const char *aProgID,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
// Manually registry a factory for a class
|
||||
static nsresult RegisterFactory(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory *aFactory,
|
||||
PRBool aReplace);
|
||||
|
||||
// Manually register a dynamically loaded component.
|
||||
static nsresult RegisterComponent(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
const char *aLibrary,
|
||||
PRBool aReplace,
|
||||
PRBool aPersist);
|
||||
|
||||
// Manually unregister a factory for a class
|
||||
static nsresult UnregisterFactory(const nsCID &aClass,
|
||||
nsIFactory *aFactory);
|
||||
|
||||
// Manually unregister a dynamically loaded factory for a class
|
||||
static nsresult UnregisterFactory(const nsCID &aClass,
|
||||
const char *aLibrary);
|
||||
|
||||
// Manually unregister a dynamically loaded component
|
||||
static nsresult UnregisterComponent(const nsCID &aClass,
|
||||
const char *aLibrary);
|
||||
|
||||
// Unload dynamically loaded factories that are not in use
|
||||
static nsresult FreeLibraries(void);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// DLL registration support
|
||||
static nsresult AutoRegister(nsIComponentManager::RegistrationTime when,
|
||||
const char* directory);
|
||||
static nsresult AutoRegisterComponent(nsIComponentManager::RegistrationTime when,
|
||||
const char *fullname);
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
|
@ -42,27 +42,4 @@ public:
|
|||
NS_IMETHOD LockFactory(PRBool aLock) = 0;
|
||||
};
|
||||
|
||||
#if 0
|
||||
/* Excluding IFactory2 until there is proof of its use - dp */
|
||||
/**
|
||||
* nsIFactory2 allows passing in a signature token when creating an
|
||||
* instance. This allows instance recycling.
|
||||
*/
|
||||
|
||||
// {19997C41-A343-11d1-B665-00805F8A2676}
|
||||
#define NS_IFACTORY2_IID \
|
||||
{ 0x19997c41, 0xa343, 0x11d1, \
|
||||
{ 0xb6, 0x65, 0x0, 0x80, 0x5f, 0x8a, 0x26, 0x76 } }
|
||||
|
||||
class nsIFactory2: public nsIFactory {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IFACTORY2_IID; return iid; }
|
||||
|
||||
NS_IMETHOD CreateInstance2(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void *aSignature,
|
||||
void **aResult) = 0;
|
||||
};
|
||||
#endif /* 0 */
|
||||
|
||||
#endif
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,255 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; 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 nsComponentManager_h__
|
||||
#define nsComponentManager_h__
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "prtime.h"
|
||||
#include "prmon.h"
|
||||
|
||||
class nsFactoryEntry;
|
||||
class nsDll;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
*** Quick Registration NOT FOR PUBLIC CONSUMPTION ***
|
||||
*
|
||||
* Quick Registration
|
||||
*
|
||||
* For quick registration, dlls can define
|
||||
* NSQuickRegisterClassData g_NSQuickRegisterData[];
|
||||
* and export the symbol "g_NSQuickRegisterData"
|
||||
*
|
||||
* Quick registration is tried only if the symbol "NSRegisterSelf"
|
||||
* is not found. If it is found but fails registration, quick registration
|
||||
* will not kick in.
|
||||
*
|
||||
* The array is terminated by having a NULL last element. Specifically, the
|
||||
* array will be assumed to end when
|
||||
* (g_NSQuickRegisterData[i].classIdStr == NULL)
|
||||
*
|
||||
*/
|
||||
#define NS_QUICKREGISTER_DATA_SYMBOL "g_NSQuickRegisterData"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsComponentManagerImpl : public nsIComponentManager {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIComponentManager methods:
|
||||
NS_IMETHOD FindFactory(const nsCID &aClass,
|
||||
nsIFactory **aFactory);
|
||||
|
||||
// Finds a class ID for a specific Program ID
|
||||
NS_IMETHOD ProgIDToCLSID(const char *aProgID,
|
||||
nsCID *aClass);
|
||||
|
||||
// Finds a Program ID for a specific class ID
|
||||
// caller frees the result with delete[]
|
||||
NS_IMETHOD CLSIDToProgID(nsCID *aClass,
|
||||
char* *aClassName,
|
||||
char* *aProgID);
|
||||
|
||||
// Creates a class instance for a specific class ID
|
||||
NS_IMETHOD CreateInstance(const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
// Convenience routine, creates a class instance for a specific ProgID
|
||||
NS_IMETHOD CreateInstance(const char *aProgID,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
// Creates a class instance for a specific class ID
|
||||
/*
|
||||
NS_IMETHOD CreateInstance2(const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void *aSignature,
|
||||
void **aResult);
|
||||
*/
|
||||
|
||||
// Manually registry a factory for a class
|
||||
NS_IMETHOD RegisterFactory(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory *aFactory,
|
||||
PRBool aReplace);
|
||||
|
||||
// Manually register a dynamically loaded component.
|
||||
NS_IMETHOD RegisterComponent(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
const char *aLibrary,
|
||||
PRBool aReplace,
|
||||
PRBool aPersist);
|
||||
|
||||
// Manually unregister a factory for a class
|
||||
NS_IMETHOD UnregisterFactory(const nsCID &aClass,
|
||||
nsIFactory *aFactory);
|
||||
|
||||
// Manually unregister a dynamically loaded factory for a class
|
||||
NS_IMETHOD UnregisterFactory(const nsCID &aClass,
|
||||
const char *aLibrary);
|
||||
|
||||
// Manually unregister a dynamically loaded component
|
||||
NS_IMETHOD UnregisterComponent(const nsCID &aClass,
|
||||
const char *aLibrary);
|
||||
|
||||
// Unload dynamically loaded factories that are not in use
|
||||
NS_IMETHOD FreeLibraries(void);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// DLL registration support
|
||||
// Autoregistration will try only files with these extensions.
|
||||
// All extensions are case insensitive.
|
||||
// ".dll", // Windows
|
||||
// ".dso", // Unix
|
||||
// ".so", // Unix
|
||||
// ".sl", // Unix: HP
|
||||
// "_dll", // Mac
|
||||
// ".dlm", // new for all platforms
|
||||
//
|
||||
// Directory and fullname are what NSPR will accept. For eg.
|
||||
// WIN y:/home/dp/mozilla/dist/bin
|
||||
// UNIX /home/dp/mozilla/dist/bin
|
||||
// MAC /Hard drive/mozilla/dist/apprunner
|
||||
//
|
||||
NS_IMETHOD AutoRegister(RegistrationTime when, const char* directory);
|
||||
NS_IMETHOD AutoRegisterComponent(RegistrationTime when, const char *fullname);
|
||||
|
||||
// nsComponentManagerImpl methods:
|
||||
nsComponentManagerImpl();
|
||||
virtual ~nsComponentManagerImpl();
|
||||
|
||||
static nsComponentManagerImpl* gComponentManager;
|
||||
nsresult Init(void);
|
||||
|
||||
protected:
|
||||
nsresult LoadFactory(nsFactoryEntry *aEntry, nsIFactory **aFactory);
|
||||
|
||||
nsresult SyncComponentsInDir(RegistrationTime when, const char *directory);
|
||||
nsresult SelfRegisterDll(nsDll *dll);
|
||||
nsresult SelfUnregisterDll(nsDll *dll);
|
||||
nsresult HashProgID(const char *aprogID, const nsCID &aClass);
|
||||
|
||||
nsresult PlatformVersionCheck();
|
||||
nsresult PlatformCreateDll(const char *fullname, nsDll* *result);
|
||||
nsresult PlatformMarkNoComponents(nsDll *dll);
|
||||
struct QuickRegisterData {
|
||||
const char *CIDString; // {98765-8776-8958758759-958785}
|
||||
const char *className; // "Layout Engine"
|
||||
const char *progID; // "Gecko.LayoutEngine.1"
|
||||
};
|
||||
nsresult PlatformRegister(QuickRegisterData* regd, nsDll *dll);
|
||||
nsresult PlatformUnregister(QuickRegisterData* regd, const char *aLibrary);
|
||||
nsresult PlatformFind(const nsCID &aCID, nsFactoryEntry* *result);
|
||||
nsresult PlatformProgIDToCLSID(const char *aProgID, nsCID *aClass);
|
||||
nsresult PlatformCLSIDToProgID(nsCID *aClass, char* *aClassName, char* *aProgID);
|
||||
void PlatformGetFileInfo(nsIRegistry::Key Key,PRTime *lastModifiedTime,PRUint32 *fileSize);
|
||||
|
||||
protected:
|
||||
nsHashtable* mFactories;
|
||||
nsHashtable* mProgIDs;
|
||||
PRMonitor* mMon;
|
||||
nsHashtable* mDllStore;
|
||||
nsIRegistry* mRegistry;
|
||||
nsIRegistry::Key mXPCOMKey;
|
||||
nsIRegistry::Key mClassesKey;
|
||||
nsIRegistry::Key mCLSIDKey;
|
||||
};
|
||||
|
||||
#define NS_MAX_FILENAME_LEN 1024
|
||||
|
||||
#define NS_ERROR_IS_DIR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, 24)
|
||||
|
||||
#ifdef XP_UNIX
|
||||
/* The default registry on the unix system is $HOME/.mozilla/registry per
|
||||
* vr_findGlobalRegName(). vr_findRegFile() will create the registry file
|
||||
* if it doesn't exist. But it wont create directories.
|
||||
*
|
||||
* Hence we need to create the directory if it doesn't exist already.
|
||||
*
|
||||
* Why create it here as opposed to the app ?
|
||||
* ------------------------------------------
|
||||
* The app cannot create the directory in main() as most of the registry
|
||||
* and initialization happens due to use of static variables.
|
||||
* And we dont want to be dependent on the order in which
|
||||
* these static stuff happen.
|
||||
*
|
||||
* Permission for the $HOME/.mozilla will be Read,Write,Execute
|
||||
* for user only. Nothing to group and others.
|
||||
*/
|
||||
#define NS_MOZILLA_DIR_NAME ".mozilla"
|
||||
#define NS_MOZILLA_DIR_PERMISSION 00700
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
/**
|
||||
* When using the registry we put a version number in it.
|
||||
* If the version number that is in the registry doesn't match
|
||||
* the following, we ignore the registry. This lets news versions
|
||||
* of the software deal with old formats of registry and not
|
||||
*
|
||||
* alpha0.20 : First time we did versioning
|
||||
* alpha0.30 : Changing autoreg to begin registration from ./components on unix
|
||||
* alpha0.40 : repository -> component manager
|
||||
* alpha0.50 : using nsIRegistry
|
||||
*/
|
||||
#define NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING "alpha0.50"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Class: nsFactoryEntry()
|
||||
*
|
||||
* There are two types of FactoryEntries.
|
||||
*
|
||||
* 1. {CID, dll} mapping.
|
||||
* Factory is a consequence of the dll. These can be either session
|
||||
* specific or persistent based on whether we write this
|
||||
* to the registry or not.
|
||||
*
|
||||
* 2. {CID, factory} mapping
|
||||
* These are strictly session specific and in memory only.
|
||||
*/
|
||||
|
||||
class nsFactoryEntry {
|
||||
public:
|
||||
nsFactoryEntry();
|
||||
nsFactoryEntry(const nsCID &aClass, nsIFactory *aFactory);
|
||||
~nsFactoryEntry();
|
||||
|
||||
nsresult Init(nsHashtable* dllHashtable, const nsCID &aClass, const char *aLibrary,
|
||||
PRTime lastModTime, PRUint32 fileSize);
|
||||
|
||||
nsCID cid;
|
||||
nsIFactory *factory;
|
||||
|
||||
// DO NOT DELETE THIS. Many nsFactoryEntry(s) could be sharing the same Dll.
|
||||
// This gets deleted from the dllStore going away.
|
||||
nsDll *dll;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // nsComponentManager_h__
|
|
@ -1,168 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; 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 "nsIComponentManager.h"
|
||||
|
||||
nsresult
|
||||
nsComponentManager::Initialize(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::FindFactory(const nsCID &aClass,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->FindFactory(aClass, aFactory);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::ProgIDToCLSID(const char *aProgID,
|
||||
nsCID *aClass)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->ProgIDToCLSID(aProgID, aClass);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::CLSIDToProgID(nsCID *aClass,
|
||||
char* *aClassName,
|
||||
char* *aProgID)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->CLSIDToProgID(aClass, aClassName, aProgID);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::CreateInstance(const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->CreateInstance(aClass, aDelegate, aIID, aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::CreateInstance(const char *aProgID,
|
||||
nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->CreateInstance(aProgID, aDelegate, aIID, aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::RegisterFactory(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory *aFactory,
|
||||
PRBool aReplace)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->RegisterFactory(aClass, aClassName, aProgID,
|
||||
aFactory, aReplace);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::RegisterComponent(const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
const char *aLibrary,
|
||||
PRBool aReplace,
|
||||
PRBool aPersist)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->RegisterComponent(aClass, aClassName, aProgID,
|
||||
aLibrary, aReplace, aPersist);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::UnregisterFactory(const nsCID &aClass,
|
||||
nsIFactory *aFactory)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->UnregisterFactory(aClass, aFactory);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::UnregisterFactory(const nsCID &aClass,
|
||||
const char *aLibrary)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->UnregisterFactory(aClass, aLibrary);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::UnregisterComponent(const nsCID &aClass,
|
||||
const char *aLibrary)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->UnregisterComponent(aClass, aLibrary);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::FreeLibraries(void)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->FreeLibraries();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::AutoRegister(nsIComponentManager::RegistrationTime when,
|
||||
const char* directory)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->AutoRegister(when, directory);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComponentManager::AutoRegisterComponent(nsIComponentManager::RegistrationTime when,
|
||||
const char *fullname)
|
||||
{
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return cm->AutoRegisterComponent(when, fullname);
|
||||
}
|
|
@ -134,8 +134,8 @@ PRBool nsDll::Load(void)
|
|||
{
|
||||
m_instance = PR_LoadLibrary(macFileName);
|
||||
}
|
||||
PL_strfree(macFileName);
|
||||
}
|
||||
|
||||
#else
|
||||
// This is the only right way of doing this...
|
||||
m_instance = PR_LoadLibrary(m_fullpath);
|
||||
|
|
Загрузка…
Ссылка в новой задаче