diff --git a/mozilla/content/build/nsContentDLF.cpp b/mozilla/content/build/nsContentDLF.cpp index f8a08dc722d..ee58ad3ea44 100644 --- a/mozilla/content/build/nsContentDLF.cpp +++ b/mozilla/content/build/nsContentDLF.cpp @@ -593,9 +593,16 @@ RegisterTypes(nsIComponentManager* aCompMgr, #ifdef NOISY_REGISTRY printf("Register %s => %s\n", contractid, aPath); #endif - rv = aCompMgr->RegisterComponentWithType(kDocumentFactoryImplCID, "Layout", - contractid, aPath, aLocation, - PR_TRUE, PR_TRUE, aType); + + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(aCompMgr, &rv); + if (NS_FAILED(rv)) + return rv; + + rv = obsoleteManager->RegisterComponentWithType(kDocumentFactoryImplCID, "Layout", + contractid, aPath, aLocation, + PR_TRUE, PR_TRUE, aType); if (NS_FAILED(rv)) break; // add the MIME types layotu can handle to the handlers category. @@ -663,5 +670,13 @@ nsContentDLF::UnregisterDocumentFactories(nsIComponentManager* aCompMgr, const nsModuleComponentInfo* aInfo) { // XXXwaterson seems like this leaves the registry pretty dirty. - return aCompMgr->UnregisterComponentSpec(kDocumentFactoryImplCID, aPath); + + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsresult rv; + nsCOMPtr obsoleteManager = do_QueryInterface(aCompMgr, &rv); + if (NS_FAILED(rv)) + return rv; + + return obsoleteManager->UnregisterComponentSpec(kDocumentFactoryImplCID, aPath); } diff --git a/mozilla/directory/xpcom/datasource/nsLDAPDataSource.js b/mozilla/directory/xpcom/datasource/nsLDAPDataSource.js index b4018824c30..e09119f91f9 100644 --- a/mozilla/directory/xpcom/datasource/nsLDAPDataSource.js +++ b/mozilla/directory/xpcom/datasource/nsLDAPDataSource.js @@ -1357,7 +1357,9 @@ var nsLDAPDataSourceModule = { registerSelf: function (compMgr, fileSpec, location, type) { debug("*** Registering LDAP datasource components" + " (all right -- a JavaScript module!)\n"); - + + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.registerComponentWithType( NS_LDAPDATASOURCE_CID, 'LDAP RDF DataSource', diff --git a/mozilla/embedding/base/nsEmbedAPI.cpp b/mozilla/embedding/base/nsEmbedAPI.cpp index df1fcafd0c5..0f1c89a99c0 100644 --- a/mozilla/embedding/base/nsEmbedAPI.cpp +++ b/mozilla/embedding/base/nsEmbedAPI.cpp @@ -111,7 +111,7 @@ nsresult NS_InitEmbedding(nsILocalFile *mozBinDirectory, // XXX hack method NS_SetupRegistry(); - rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, + rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); if (NS_FAILED(rv)) { diff --git a/mozilla/embedding/components/ui/helperAppDlg/nsHelperAppDlg.js b/mozilla/embedding/components/ui/helperAppDlg/nsHelperAppDlg.js index 42d1bfe27c5..2856447c758 100644 --- a/mozilla/embedding/components/ui/helperAppDlg/nsHelperAppDlg.js +++ b/mozilla/embedding/components/ui/helperAppDlg/nsHelperAppDlg.js @@ -581,6 +581,8 @@ var module = { this.firstTime = false; throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN; } + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.registerComponentWithType( this.cid, "Mozilla Helper App Launcher Dialog", this.contractId, diff --git a/mozilla/extensions/irc/js/lib/chatzilla-service.js b/mozilla/extensions/irc/js/lib/chatzilla-service.js index 36532fbcbce..584d80f5fa1 100644 --- a/mozilla/extensions/irc/js/lib/chatzilla-service.js +++ b/mozilla/extensions/irc/js/lib/chatzilla-service.js @@ -281,6 +281,9 @@ ChatzillaModule.registerSelf = function (compMgr, fileSpec, location, type) { dump("*** Registering -chat handler.\n"); + + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.registerComponentWithType(CLINE_SERVICE_CID, "Chatzilla CommandLine Service", CLINE_SERVICE_CONTRACTID, fileSpec, @@ -309,6 +312,9 @@ function (compMgr, fileSpec, location, type) ChatzillaModule.unregisterSelf = function(compMgr, fileSpec, location) { + + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.unregisterComponentSpec(CLINE_SERVICE_CID, fileSpec); catman = Components.classes["@mozilla.org/categorymanager;1"] .getService(nsICategoryManager); diff --git a/mozilla/extensions/venkman/js/venkman-service.js b/mozilla/extensions/venkman/js/venkman-service.js index f068edcbd0b..3467b126436 100644 --- a/mozilla/extensions/venkman/js/venkman-service.js +++ b/mozilla/extensions/venkman/js/venkman-service.js @@ -76,6 +76,9 @@ Module.registerSelf = function (compMgr, fileSpec, location, type) { dump("*** Registering -venkman handler.\n"); + + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.registerComponentWithType(CLINE_SERVICE_CID, "Venkman CommandLine Service", CLINE_SERVICE_CTRID, fileSpec, @@ -91,6 +94,8 @@ function (compMgr, fileSpec, location, type) Module.unregisterSelf = function(compMgr, fileSpec, location) { + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.unregisterComponentSpec(CLINE_SERVICE_CID, fileSpec); catman = Components.classes[CATMAN_CTRID].getService(nsICategoryManager); catman.deleteCategoryEntry("command-line-argument-handlers", diff --git a/mozilla/extensions/xml-rpc/src/nsDictionary.js b/mozilla/extensions/xml-rpc/src/nsDictionary.js index b827f4fe25c..14a838c87e4 100644 --- a/mozilla/extensions/xml-rpc/src/nsDictionary.js +++ b/mozilla/extensions/xml-rpc/src/nsDictionary.js @@ -18,9 +18,9 @@ /* * nsDictionary XPCOM component - * Version: $Revision: 1.4 $ + * Version: $Revision: 1.5 $ * - * $Id: nsDictionary.js,v 1.4 2000-09-13 23:51:27 rayw%netscape.com Exp $ + * $Id: nsDictionary.js,v 1.5 2001-12-19 00:11:33 dougt%netscape.com Exp $ */ /* @@ -83,6 +83,7 @@ nsDictionary.prototype= { /* nsDictionary Module (for XPCOM registration) */ var nsDictionaryModule = { registerSelf: function(compMgr, fileSpec, location, type) { + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); compMgr.registerComponentWithType(DICTIONARY_CID, "nsDictionary JS component", DICTIONARY_CONTRACTID, fileSpec, location, true, true, type); diff --git a/mozilla/extensions/xml-rpc/src/nsXmlRpcClient.js b/mozilla/extensions/xml-rpc/src/nsXmlRpcClient.js index bc44bfcfcba..25b515ca4b3 100644 --- a/mozilla/extensions/xml-rpc/src/nsXmlRpcClient.js +++ b/mozilla/extensions/xml-rpc/src/nsXmlRpcClient.js @@ -20,9 +20,9 @@ /* * nsXmlRpcClient XPCOM component - * Version: $Revision: 1.18 $ + * Version: $Revision: 1.19 $ * - * $Id: nsXmlRpcClient.js,v 1.18 2001-11-30 08:04:24 samuel%sieb.net Exp $ + * $Id: nsXmlRpcClient.js,v 1.19 2001-12-19 00:11:33 dougt%netscape.com Exp $ */ /* @@ -1176,6 +1176,8 @@ PushbackInputStream.prototype = { /* nsXmlRpcClient Module (for XPCOM registration) */ var nsXmlRpcClientModule = { registerSelf: function(compMgr, fileSpec, location, type) { + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.registerComponentWithType(XMLRPCCLIENT_CID, 'XML-RPC Client JS component', XMLRPCCLIENT_CONTRACTID, fileSpec, location, true, true, type); diff --git a/mozilla/extensions/xmlterm/ui/xmlterm-service.js b/mozilla/extensions/xmlterm/ui/xmlterm-service.js index 7fe74a6d269..15e2a33e503 100644 --- a/mozilla/extensions/xmlterm/ui/xmlterm-service.js +++ b/mozilla/extensions/xmlterm/ui/xmlterm-service.js @@ -323,6 +323,9 @@ XMLtermModule.registerSelf = function (compMgr, fileSpec, location, type) { dump("*** Registering -terminal handler.\n"); + + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.registerComponentWithType(XMLTERMCLINE_SERVICE_CID, "XMLterm CommandLine Service", XMLTERMCLINE_SERVICE_CONTRACTID, fileSpec, @@ -351,6 +354,7 @@ function (compMgr, fileSpec, location, type) XMLtermModule.unregisterSelf = function(compMgr, fileSpec, location) { + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); compMgr.unregisterComponentSpec(XMLTERMCLINE_SERVICE_CID, fileSpec); catman = Components.classes["@mozilla.org/categorymanager;1"] .getService(nsICategoryManager); diff --git a/mozilla/htmlparser/tests/outsinks/Convert.cpp b/mozilla/htmlparser/tests/outsinks/Convert.cpp index 78073ac67b1..98c388692af 100644 --- a/mozilla/htmlparser/tests/outsinks/Convert.cpp +++ b/mozilla/htmlparser/tests/outsinks/Convert.cpp @@ -298,7 +298,7 @@ Usage: %s [-i intype] [-o outtype] [-f flags] [-w wrapcol] [-c comparison_file] } else file = stdin; - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, 0); + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, 0); NS_SetupRegistry(); // Read in the string: very inefficient, but who cares? diff --git a/mozilla/intl/strres/tests/StringBundleTest.cpp b/mozilla/intl/strres/tests/StringBundleTest.cpp index 42aa458cec2..0ca797a4a8e 100644 --- a/mozilla/intl/strres/tests/StringBundleTest.cpp +++ b/mozilla/intl/strres/tests/StringBundleTest.cpp @@ -142,7 +142,7 @@ getUILangCountry(PRUnichar** aUILang, PRUnichar** aCountry) //////////////////////////////////////////////////////////////////////////////////////////////////// nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); // startup netlib: diff --git a/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp b/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp index 102442931a9..5cadee28f93 100644 --- a/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp +++ b/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp @@ -815,9 +815,13 @@ mozJSComponentLoader::AttemptRegistration(nsIFile *component, nsXPIDLCString registryLocation; nsresult rv; nsIModule *module; - - rv = mCompMgr->RegistryLocationForSpec(component, - getter_Copies(registryLocation)); + + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(mCompMgr, &rv); + if (obsoleteManager) + rv = obsoleteManager->RegistryLocationForSpec(component, + getter_Copies(registryLocation)); if (NS_FAILED(rv)) return rv; @@ -886,9 +890,13 @@ mozJSComponentLoader::UnregisterComponent(nsIFile *component) nsXPIDLCString registryLocation; nsresult rv; nsIModule *module; - - rv = mCompMgr->RegistryLocationForSpec(component, - getter_Copies(registryLocation)); + + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(mCompMgr, &rv); + if (obsoleteManager) + rv = obsoleteManager->RegistryLocationForSpec(component, + getter_Copies(registryLocation)); if (NS_FAILED(rv)) return rv; @@ -1130,8 +1138,13 @@ mozJSComponentLoader::GlobalForLocation(const char *aLocation, } if (!component) { - if (NS_FAILED(mCompMgr->SpecForRegistryLocation(aLocation, - &component))) + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(mCompMgr, &rv); + if (obsoleteManager) + return nsnull; + + if (NS_FAILED(obsoleteManager->SpecForRegistryLocation(aLocation, &component))) return nsnull; needRelease = PR_TRUE; } diff --git a/mozilla/js/src/xpconnect/shell/xpcshell.cpp b/mozilla/js/src/xpconnect/shell/xpcshell.cpp index fbeaccd8cc9..b47082f39b1 100644 --- a/mozilla/js/src/xpconnect/shell/xpcshell.cpp +++ b/mozilla/js/src/xpconnect/shell/xpcshell.cpp @@ -80,7 +80,7 @@ static void SetupRegistry() { - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsnull); + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull); } /***************************************************************************/ diff --git a/mozilla/js/src/xpconnect/src/xpccomponents.cpp b/mozilla/js/src/xpconnect/src/xpccomponents.cpp index 820f7680720..1a3e7af9369 100644 --- a/mozilla/js/src/xpconnect/src/xpccomponents.cpp +++ b/mozilla/js/src/xpconnect/src/xpccomponents.cpp @@ -369,8 +369,8 @@ nsXPCComponents_Classes::NewEnumerate(nsIXPConnectWrappedNative *wrapper, { case JSENUMERATE_INIT: { - nsIComponentManager* compMgr; - if(NS_FAILED(NS_GetGlobalComponentManager(&compMgr)) || + nsIComponentManagerObsolete* compMgr; + if(NS_FAILED(NS_GetGlobalComponentManager((nsIComponentManager**)&compMgr)) || !compMgr || NS_FAILED(compMgr->EnumerateContractIDs(&e)) || !e || NS_FAILED(e->First())) @@ -529,8 +529,8 @@ nsXPCComponents_ClassesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper, { case JSENUMERATE_INIT: { - nsIComponentManager* compMgr; - if(NS_FAILED(NS_GetGlobalComponentManager(&compMgr)) || + nsIComponentManagerObsolete* compMgr; + if(NS_FAILED(NS_GetGlobalComponentManager((nsIComponentManager**)&compMgr)) || !compMgr || NS_FAILED(compMgr->EnumerateCLSIDs(&e)) || !e || NS_FAILED(e->First())) @@ -590,8 +590,8 @@ IsRegisteredCLSID(const char* str) if(!id.Parse(str)) return PR_FALSE; - nsIComponentManager* compMgr; - if(NS_FAILED(NS_GetGlobalComponentManager(&compMgr)) || + nsIComponentManagerObsolete* compMgr; + if(NS_FAILED(NS_GetGlobalComponentManager((nsIComponentManager**)&compMgr)) || !compMgr || NS_FAILED(compMgr->IsRegistered(id, ®istered))) return PR_FALSE; @@ -1612,17 +1612,7 @@ NS_IMETHODIMP nsXPCComponents::GetManager(nsIComponentManager * *aManager) { NS_ASSERTION(aManager, "bad param"); - - nsIComponentManager* cm; - if(NS_FAILED(NS_GetGlobalComponentManager(&cm))) - { - *aManager = nsnull; - return NS_ERROR_FAILURE; - } - NS_IF_ADDREF(cm); - *aManager = cm; - - return NS_OK; + return NS_GetComponentManager(aManager); } /**********************************************/ diff --git a/mozilla/js/src/xpconnect/src/xpcconvert.cpp b/mozilla/js/src/xpconnect/src/xpcconvert.cpp index 56d867b2a71..ba3aa152895 100644 --- a/mozilla/js/src/xpconnect/src/xpcconvert.cpp +++ b/mozilla/js/src/xpconnect/src/xpcconvert.cpp @@ -1109,8 +1109,8 @@ XPCConvert::JSValToXPCException(XPCCallContext& ccx, else { nsISupportsDouble* data; - nsIComponentManager* cm; - if(NS_FAILED(NS_GetGlobalComponentManager(&cm)) || !cm || + nsCOMPtr cm; + if(NS_FAILED(NS_GetComponentManager(getter_AddRefs(cm))) || !cm || NS_FAILED(cm->CreateInstanceByContractID( NS_SUPPORTS_DOUBLE_CONTRACTID, nsnull, diff --git a/mozilla/js/src/xpconnect/tests/TestXPC.cpp b/mozilla/js/src/xpconnect/tests/TestXPC.cpp index 2f7c725ff5c..b6b5606b8fc 100644 --- a/mozilla/js/src/xpconnect/tests/TestXPC.cpp +++ b/mozilla/js/src/xpconnect/tests/TestXPC.cpp @@ -59,7 +59,7 @@ static void SetupRegistry() { - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsnull); + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull); } /***************************************************************************/ diff --git a/mozilla/layout/build/nsContentDLF.cpp b/mozilla/layout/build/nsContentDLF.cpp index f8a08dc722d..ee58ad3ea44 100644 --- a/mozilla/layout/build/nsContentDLF.cpp +++ b/mozilla/layout/build/nsContentDLF.cpp @@ -593,9 +593,16 @@ RegisterTypes(nsIComponentManager* aCompMgr, #ifdef NOISY_REGISTRY printf("Register %s => %s\n", contractid, aPath); #endif - rv = aCompMgr->RegisterComponentWithType(kDocumentFactoryImplCID, "Layout", - contractid, aPath, aLocation, - PR_TRUE, PR_TRUE, aType); + + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(aCompMgr, &rv); + if (NS_FAILED(rv)) + return rv; + + rv = obsoleteManager->RegisterComponentWithType(kDocumentFactoryImplCID, "Layout", + contractid, aPath, aLocation, + PR_TRUE, PR_TRUE, aType); if (NS_FAILED(rv)) break; // add the MIME types layotu can handle to the handlers category. @@ -663,5 +670,13 @@ nsContentDLF::UnregisterDocumentFactories(nsIComponentManager* aCompMgr, const nsModuleComponentInfo* aInfo) { // XXXwaterson seems like this leaves the registry pretty dirty. - return aCompMgr->UnregisterComponentSpec(kDocumentFactoryImplCID, aPath); + + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsresult rv; + nsCOMPtr obsoleteManager = do_QueryInterface(aCompMgr, &rv); + if (NS_FAILED(rv)) + return rv; + + return obsoleteManager->UnregisterComponentSpec(kDocumentFactoryImplCID, aPath); } diff --git a/mozilla/mailnews/addrbook/src/nsLDAPPrefsService.js b/mozilla/mailnews/addrbook/src/nsLDAPPrefsService.js index f23d6e3bcc4..ebcd3ae1bca 100644 --- a/mozilla/mailnews/addrbook/src/nsLDAPPrefsService.js +++ b/mozilla/mailnews/addrbook/src/nsLDAPPrefsService.js @@ -278,6 +278,8 @@ var nsLDAPPrefsModule = new Object(); nsLDAPPrefsModule.registerSelf = function (compMgr, fileSpec, location, type) { + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.registerComponentWithType(NS_LDAPPREFSSERVICE_CID, "nsLDAPPrefs Service", NS_LDAPPREFSSERVICE_CONTRACTID, fileSpec, @@ -287,6 +289,7 @@ function (compMgr, fileSpec, location, type) nsLDAPPrefsModule.unregisterSelf = function(compMgr, fileSpec, location) { + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); compMgr.unregisterComponentSpec(NS_LDAPPREFSSERVICE_CID, fileSpec); } diff --git a/mozilla/mailnews/extensions/smime/src/smime-service.js b/mozilla/mailnews/extensions/smime/src/smime-service.js index 083bd27010e..235bffb623c 100644 --- a/mozilla/mailnews/extensions/smime/src/smime-service.js +++ b/mozilla/mailnews/extensions/smime/src/smime-service.js @@ -66,6 +66,7 @@ SMIMEModule.registerSelf = function (compMgr, fileSpec, location, type) { dump("*** Registering smime account manager extension.\n"); + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); compMgr.registerComponentWithType(SMIME_EXTENSION_SERVICE_CID, "SMIME Account Manager Extension Service", SMIME_EXTENSION_SERVICE_CONTRACTID, fileSpec, @@ -79,6 +80,7 @@ function (compMgr, fileSpec, location, type) SMIMEModule.unregisterSelf = function(compMgr, fileSpec, location) { + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); compMgr.unregisterComponentSpec(SMIME_EXTENSION_SERVICE_CID, fileSpec); catman = Components.classes["@mozilla.org/categorymanager;1"].getService(nsICategoryManager); catman.deleteCategoryEntry("mailnews-accountmanager-extensions", diff --git a/mozilla/mailnews/mime/emitters/src/nsMimeXULEmitter.cpp b/mozilla/mailnews/mime/emitters/src/nsMimeXULEmitter.cpp index 750278a5139..6069b4bf7ca 100644 --- a/mozilla/mailnews/mime/emitters/src/nsMimeXULEmitter.cpp +++ b/mozilla/mailnews/mime/emitters/src/nsMimeXULEmitter.cpp @@ -232,12 +232,7 @@ nsMimeXULEmitter::GetStatusObjForContractID(nsCString aContractID) if (NS_FAILED(rv)) return nsnull; - nsCID cid; - rv = comMgr->ContractIDToClassID(aContractID.get(), &cid); - if (NS_FAILED(rv)) - return nsnull; - - rv = comMgr->CreateInstance(cid, nsnull, NS_GET_IID(nsIMimeMiscStatus), (void**)&obj); + rv = comMgr->CreateInstanceByContractID(aContractID.get(), nsnull, NS_GET_IID(nsIMimeMiscStatus), (void**)&obj); if (NS_FAILED(rv)) return nsnull; else diff --git a/mozilla/modules/libpref/src/init/all.js b/mozilla/modules/libpref/src/init/all.js index e3b89b9b41e..c015cc71bef 100644 --- a/mozilla/modules/libpref/src/init/all.js +++ b/mozilla/modules/libpref/src/init/all.js @@ -399,9 +399,7 @@ pref("network.http.proxy.ssl.connect",true); // Idle timeout for ftp control connections - 5 minute default pref("network.ftp.idleConnectionTimeout", 300); -// until the directory view has an owner -// necko will produce html -- dougt -pref("network.dir.generate_html", true); +pref("network.dir.generate_html", false); // sspitzer: change this back to "news" when we get to beta. // for now, set this to news.mozilla.org because you can only diff --git a/mozilla/modules/libreg/src/reg.c b/mozilla/modules/libreg/src/reg.c index 618b4e49904..e155444a9fc 100644 --- a/mozilla/modules/libreg/src/reg.c +++ b/mozilla/modules/libreg/src/reg.c @@ -2405,6 +2405,121 @@ VR_INTERFACE(REGERR) NR_RegOpen( char *filename, HREG *hReg ) +static REGERR NR_RegOpen( char *filename, HREG *hReg ) +{ + REGERR status = REGERR_OK; + REGFILE *pReg; + REGHANDLE *pHandle; + + XP_ASSERT( regStartCount > 0 ); + + /* initialize output handle in case of error */ + if ( hReg == NULL ) { + return REGERR_PARAM; + } + *hReg = NULL; + + /* Look for named file in list of open registries */ + filename = nr_GetRegName( filename ); + if (filename == NULL) { + filename = ""; + } + pReg = vr_findRegFile( filename ); + + /* if registry not already open */ + if (pReg == NULL) { + + /* ...then open it */ + pReg = (REGFILE*)XP_ALLOC( sizeof(REGFILE) ); + if ( pReg == NULL ) { + status = REGERR_MEMORY; + goto bail; + } + XP_MEMSET(pReg, 0, sizeof(REGFILE)); + + pReg->inInit = TRUE; + pReg->filename = XP_STRDUP(filename); + if (pReg->filename == NULL) { + XP_FREE( pReg ); + status = REGERR_MEMORY; + goto bail; + } + + status = nr_OpenFile( filename, &(pReg->fh) ); + if (status == REGERR_READONLY) { + /* Open, but read only */ + pReg->readOnly = TRUE; + status = REGERR_OK; + } + if ( status != REGERR_OK ) { + XP_FREE( pReg->filename ); + XP_FREE( pReg ); + + goto bail; + } + + /* ...read and validate the header */ + status = nr_ReadHdr( pReg ); + if ( status != REGERR_OK ) { + nr_CloseFile( &(pReg->fh) ); + XP_FREE( pReg->filename ); + XP_FREE( pReg ); + goto bail; + } + + /* ...other misc initialization */ + pReg->refCount = 0; + +#ifndef STANDALONE_REGISTRY + pReg->uniqkey = PR_Now(); +#endif + + status = nr_InitStdRkeys( pReg ); + if ( status == REGERR_OK ) { + /* ...and add it to the list */ + nr_AddNode( pReg ); + } + else { + nr_CloseFile( &(pReg->fh) ); + XP_FREE( pReg->filename ); + XP_FREE( pReg ); + goto bail; + } + +#ifndef STANDALONE_REGISTRY + pReg->lock = PR_NewLock(); +#endif + + /* now done with everything that needs to protect the header */ + pReg->inInit = FALSE; + } + + /* create a new handle to the regfile */ + pHandle = (REGHANDLE*)XP_ALLOC( sizeof(REGHANDLE) ); + if ( pHandle == NULL ) { + /* we can't create the handle */ + if ( pReg->refCount == 0 ) { + /* we've just opened it so close it and remove node */ + nr_CloseFile( &(pReg->fh) ); + nr_DeleteNode( pReg ); + } + + status = REGERR_MEMORY; + goto bail; + } + + pHandle->magic = MAGIC_NUMBER; + pHandle->pReg = pReg; + + /* success: bump the reference count and return the handle */ + pReg->refCount++; + *hReg = (void*)pHandle; + +bail: + return status; + +} /* nr_RegOpen */ + /* --------------------------------------------------------------------- * NR_RegClose - Close a netscape XP registry diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 9d488d83a33..e6e009d103e 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -85,6 +85,7 @@ #include "nsICachingChannel.h" #include "nsHashtable.h" #include "nsIProxyInfo.h" +#include "nsObsoleteModuleLoading.h" #include "nsPluginLogging.h" #include "nsDirectoryServiceDefs.h" @@ -2644,7 +2645,7 @@ nsresult nsPluginHostImpl::ReloadPlugins(PRBool reloadPages) mPluginsLoaded = PR_FALSE; //refresh the component registry first - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsnull); + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull); // load them again nsresult rv = LoadPlugins(); @@ -3547,6 +3548,11 @@ nsresult nsPluginHostImpl::RegisterPluginMimeTypesWithLayout(nsPluginTag * plugi pluginTag->mFileName)); nsresult rv = NS_OK; + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(compManager, &rv); + if (!obsoleteManager) + return rv; for(int i = 0; i < pluginTag->mVariants; i++) { @@ -3555,12 +3561,13 @@ nsresult nsPluginHostImpl::RegisterPluginMimeTypesWithLayout(nsPluginTag * plugi nsCAutoString contractid(NS_DOCUMENT_LOADER_FACTORY_CONTRACTID_PREFIX "view;1?type="); contractid += pluginTag->mMimeTypeArray[i]; - rv = compManager->RegisterComponentSpec(kPluginDocLoaderFactoryCID, - "Plugin Loader Stub", - contractid.get(), - path, - PR_TRUE, - PR_FALSE); + + rv = obsoleteManager->RegisterComponentSpec(kPluginDocLoaderFactoryCID, + "Plugin Loader Stub", + contractid.get(), + path, + PR_TRUE, + PR_FALSE); PLUGIN_LOG(PLUGIN_LOG_NOISY, ("nsPluginHostImpl::RegisterPluginMimeTypesWithLayout mime=%s, plugin=%s\n", @@ -4630,10 +4637,15 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins() // retrieve a path for layout module. Needed for plugin mime types registration nsCOMPtr layoutPath; nsCOMPtr compManager = do_GetService(kComponentManagerCID, &rv); - if (NS_SUCCEEDED(rv) && compManager) + + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(compManager); + + if (NS_SUCCEEDED(rv) && compManager && obsoleteManager) { PRBool gotLayoutPath; - if (NS_SUCCEEDED(compManager->SpecForRegistryLocation(REL_PLUGIN_DLL, getter_AddRefs(layoutPath)))) + if (NS_SUCCEEDED(obsoleteManager->SpecForRegistryLocation(REL_PLUGIN_DLL, getter_AddRefs(layoutPath)))) gotLayoutPath = PR_TRUE; else gotLayoutPath = PR_FALSE; @@ -4739,7 +4751,11 @@ cidToDllname(nsIComponentManager* aComponentManager, nsIRegistry* aRegistry, rv = aRegistry->GetBytesUTF8(cidKey, "InprocServer", &count, &library); if (NS_SUCCEEDED(rv)) { nsCOMPtr file; - rv = aComponentManager->SpecForRegistryLocation(NS_REINTERPRET_CAST(const char*, library), + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(aComponentManager, &rv); + if (obsoleteManager) + rv = obsoleteManager->SpecForRegistryLocation(NS_REINTERPRET_CAST(const char*, library), getter_AddRefs(file)); if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/netwerk/base/src/nsFilters.js b/mozilla/netwerk/base/src/nsFilters.js index a77163a208e..135db650065 100644 --- a/mozilla/netwerk/base/src/nsFilters.js +++ b/mozilla/netwerk/base/src/nsFilters.js @@ -67,6 +67,7 @@ var filterModule = new Object(); filterModule.registerSelf = function (compMgr, fileSpec, location, type) { dump("*** Registering Web Filters (a Javascript module!)\n"); + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); compMgr.registerComponentWithType(kFILTERS_CID, "Javascript Web Filters", kFILTERS_CONTRACTID, diff --git a/mozilla/netwerk/base/src/nsProxyAutoConfig.js b/mozilla/netwerk/base/src/nsProxyAutoConfig.js index 1449ee2da86..d637cecc1ae 100644 --- a/mozilla/netwerk/base/src/nsProxyAutoConfig.js +++ b/mozilla/netwerk/base/src/nsProxyAutoConfig.js @@ -188,6 +188,7 @@ var pacModule = new Object(); pacModule.registerSelf = function (compMgr, fileSpec, location, type) { + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); compMgr.registerComponentWithType(kPAC_CID, "Proxy Auto Config", kPAC_CONTRACTID, diff --git a/mozilla/netwerk/base/tests/urltest.cpp b/mozilla/netwerk/base/tests/urltest.cpp index 9dbab12b541..3bb3c3a07d5 100644 --- a/mozilla/netwerk/base/tests/urltest.cpp +++ b/mozilla/netwerk/base/tests/urltest.cpp @@ -252,7 +252,7 @@ int main(int argc, char **argv) return 0; } - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, "./components"); + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, "./components"); testURL(argv[1]); return 0; diff --git a/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp b/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp index cf5e974639c..84a3295e91c 100644 --- a/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp +++ b/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp @@ -169,14 +169,8 @@ nsResProtocolHandler::SetSpecialDir(const char *root, const char *dir) rv = NS_GetSpecialDirectory(dir, getter_AddRefs(file)); if (NS_FAILED(rv)) return rv; - nsXPIDLCString spec; - rv = file->GetURL(getter_Copies(spec)); - if (NS_FAILED(rv)) return rv; - - LOG(("root=\"%s\" -> baseURI=%s\n", root, spec.get())); - nsCOMPtr uri; - mIOService->NewURI(spec, nsnull, getter_AddRefs(uri)); + mIOService->NewFileURI(file, getter_AddRefs(uri)); return SetSubstitution(root, uri); } diff --git a/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp b/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp index fc42a48c2d5..96b04d15492 100644 --- a/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp +++ b/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp @@ -439,10 +439,6 @@ nsStreamConverterService::Convert(nsIInputStream *aFromStream, contractID.AppendWithConversion(aToType); const char *cContractID = contractID.get(); - nsIComponentManager *comMgr; - rv = NS_GetGlobalComponentManager(&comMgr); - if (NS_FAILED(rv)) return rv; - nsCOMPtr converter(do_CreateInstance(cContractID, &rv)); if (NS_FAILED(rv)) { // couldn't go direct, let's try walking the graph of converters. @@ -542,10 +538,6 @@ nsStreamConverterService::AsyncConvertData(const PRUnichar *aFromType, contractID.AppendWithConversion(aToType); const char *cContractID = contractID.get(); - nsIComponentManager *comMgr; - rv = NS_GetGlobalComponentManager(&comMgr); - if (NS_FAILED(rv)) return rv; - nsCOMPtr listener(do_CreateInstance(cContractID, &rv)); if (NS_FAILED(rv)) { // couldn't go direct, let's try walking the graph of converters. diff --git a/mozilla/netwerk/streamconv/test/TestStreamConv.cpp b/mozilla/netwerk/streamconv/test/TestStreamConv.cpp index 0525589fc2b..50f01a453c4 100644 --- a/mozilla/netwerk/streamconv/test/TestStreamConv.cpp +++ b/mozilla/netwerk/streamconv/test/TestStreamConv.cpp @@ -151,7 +151,7 @@ main(int argc, char* argv[]) eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ); - rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); if (NS_FAILED(rv)) return rv; nsCOMPtr catman = diff --git a/mozilla/netwerk/test/TestCacheBlockFiles.cpp b/mozilla/netwerk/test/TestCacheBlockFiles.cpp index 03ca5ade990..a083de80b72 100644 --- a/mozilla/netwerk/test/TestCacheBlockFiles.cpp +++ b/mozilla/netwerk/test/TestCacheBlockFiles.cpp @@ -216,7 +216,7 @@ main(void) if (NS_FAILED(rv)) return rv; // Register components - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsnull); + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull); // Get default directory diff --git a/mozilla/netwerk/test/TestCacheMgr.cpp b/mozilla/netwerk/test/TestCacheMgr.cpp index fb7d7d7ff2d..2c88594a748 100644 --- a/mozilla/netwerk/test/TestCacheMgr.cpp +++ b/mozilla/netwerk/test/TestCacheMgr.cpp @@ -544,7 +544,7 @@ FillCache(nsINetDataCacheManager *aCache, PRUint32 aFlags, PRUint32 aCacheCapaci nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/netwerk/test/TestFileInput.cpp b/mozilla/netwerk/test/TestFileInput.cpp index 1fafa4c4b44..7db7ccc4616 100644 --- a/mozilla/netwerk/test/TestFileInput.cpp +++ b/mozilla/netwerk/test/TestFileInput.cpp @@ -395,7 +395,7 @@ ParallelReadTest(char* dirName, nsIFileTransportService* fts) nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/netwerk/test/TestFileInput2.cpp b/mozilla/netwerk/test/TestFileInput2.cpp index 2083357c1b8..b612f0a0e93 100644 --- a/mozilla/netwerk/test/TestFileInput2.cpp +++ b/mozilla/netwerk/test/TestFileInput2.cpp @@ -445,7 +445,7 @@ Test(CreateFun create, PRUint32 count, nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/netwerk/test/TestFileTransport.cpp b/mozilla/netwerk/test/TestFileTransport.cpp index 5009ec2f6c5..472edbd8394 100644 --- a/mozilla/netwerk/test/TestFileTransport.cpp +++ b/mozilla/netwerk/test/TestFileTransport.cpp @@ -342,7 +342,7 @@ NS_IMPL_ISUPPORTS1(MyOpenObserver, nsIRequestObserver); nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/netwerk/test/TestHttp.cpp b/mozilla/netwerk/test/TestHttp.cpp index 0cfa67d05a6..ccf23d962ed 100644 --- a/mozilla/netwerk/test/TestHttp.cpp +++ b/mozilla/netwerk/test/TestHttp.cpp @@ -126,7 +126,7 @@ MyNotifications::OnProgress(nsIRequest *req, nsISupports *ctx, nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/netwerk/test/TestMakeAbs.cpp b/mozilla/netwerk/test/TestMakeAbs.cpp index 732fd938dbc..822d5ad663d 100644 --- a/mozilla/netwerk/test/TestMakeAbs.cpp +++ b/mozilla/netwerk/test/TestMakeAbs.cpp @@ -46,7 +46,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/netwerk/test/TestPageLoad.cpp b/mozilla/netwerk/test/TestPageLoad.cpp index 99f53e3d4a6..0f692c3df99 100644 --- a/mozilla/netwerk/test/TestPageLoad.cpp +++ b/mozilla/netwerk/test/TestPageLoad.cpp @@ -268,7 +268,7 @@ MyNotifications::OnProgress(nsIRequest *req, nsISupports *ctx, nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/netwerk/test/TestPerf.cpp b/mozilla/netwerk/test/TestPerf.cpp index 5c96751fe59..784fd23a3a7 100644 --- a/mozilla/netwerk/test/TestPerf.cpp +++ b/mozilla/netwerk/test/TestPerf.cpp @@ -227,7 +227,7 @@ main(int argc, char **argv) return -1; } - rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL); + rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL); if (NS_FAILED(rv)) return -1; // cache the io service diff --git a/mozilla/netwerk/test/TestRawCache.cpp b/mozilla/netwerk/test/TestRawCache.cpp index 5b4c927c7d0..35101ab6d87 100644 --- a/mozilla/netwerk/test/TestRawCache.cpp +++ b/mozilla/netwerk/test/TestRawCache.cpp @@ -685,7 +685,7 @@ FillCache(nsINetDataCache *cache) nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/netwerk/test/TestRes.cpp b/mozilla/netwerk/test/TestRes.cpp index 1d60ad209f5..adb98e30fa5 100644 --- a/mozilla/netwerk/test/TestRes.cpp +++ b/mozilla/netwerk/test/TestRes.cpp @@ -245,7 +245,7 @@ TestAsyncRead(const char* url) nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/netwerk/test/TestSocketInput.cpp b/mozilla/netwerk/test/TestSocketInput.cpp index 318836b819b..dc4c99ee0cc 100644 --- a/mozilla/netwerk/test/TestSocketInput.cpp +++ b/mozilla/netwerk/test/TestSocketInput.cpp @@ -136,7 +136,7 @@ InputTestConsumer::OnStopRequest(nsIRequest *request, nsISupports* context, nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/netwerk/test/TestSocketTransport.cpp b/mozilla/netwerk/test/TestSocketTransport.cpp index 6ef8207832b..4c8ec34ce58 100644 --- a/mozilla/netwerk/test/TestSocketTransport.cpp +++ b/mozilla/netwerk/test/TestSocketTransport.cpp @@ -582,7 +582,7 @@ void TimerCallback(nsITimer* aTimer, void* aClosure) nsresult NS_AutoregisterComponents(); nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/netwerk/test/TestUpload.cpp b/mozilla/netwerk/test/TestUpload.cpp index 8a1eda897fa..c360be578c5 100644 --- a/mozilla/netwerk/test/TestUpload.cpp +++ b/mozilla/netwerk/test/TestUpload.cpp @@ -56,7 +56,7 @@ static nsIEventQueue* gEventQ = nsnull; nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } //----------------------------------------------------------------------------- diff --git a/mozilla/netwerk/test/TestWriteStream.cpp b/mozilla/netwerk/test/TestWriteStream.cpp index e4b037a0063..f329d24d98c 100644 --- a/mozilla/netwerk/test/TestWriteStream.cpp +++ b/mozilla/netwerk/test/TestWriteStream.cpp @@ -197,7 +197,7 @@ TestSyncWrites(char* filenamePrefix, PRUint32 startPosition, PRInt32 length) nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/netwerk/test/urltest.cpp b/mozilla/netwerk/test/urltest.cpp index c3c33109966..c4354560664 100644 --- a/mozilla/netwerk/test/urltest.cpp +++ b/mozilla/netwerk/test/urltest.cpp @@ -395,7 +395,7 @@ int doMakeAbsTest(const char* i_URL = 0, const char* i_relativePortion=0) nsresult NS_AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; } diff --git a/mozilla/parser/htmlparser/tests/outsinks/Convert.cpp b/mozilla/parser/htmlparser/tests/outsinks/Convert.cpp index 78073ac67b1..98c388692af 100644 --- a/mozilla/parser/htmlparser/tests/outsinks/Convert.cpp +++ b/mozilla/parser/htmlparser/tests/outsinks/Convert.cpp @@ -298,7 +298,7 @@ Usage: %s [-i intype] [-o outtype] [-f flags] [-w wrapcol] [-c comparison_file] } else file = stdin; - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, 0); + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, 0); NS_SetupRegistry(); // Read in the string: very inefficient, but who cares? diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index 449992678a2..b11337b3d74 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -420,11 +420,29 @@ nsrefcnt nsViewManager::Release(void) return mRefCnt; } -static nsresult CreateRegion(nsIComponentManager* componentManager, nsIRegion* *result) +nsresult +nsViewManager::CreateRegion(nsIRegion* *result) { - *result = nsnull; + nsresult rv; + + if (!mRegionFactory) { + nsCOMPtr compMgr; + rv = NS_GetComponentManager(getter_AddRefs(compMgr)); + + if (NS_SUCCEEDED(rv)) + rv = compMgr->GetClassObject(kRegionCID, + NS_GET_IID(nsIFactory), + getter_AddRefs(mRegionFactory)); + + if (!mRegionFactory) { + *result = nsnull; + return NS_ERROR_FAILURE; + } + } + + nsIRegion* region = nsnull; - nsresult rv = componentManager->CreateInstance(kRegionCID, nsnull, NS_GET_IID(nsIRegion), (void**)®ion); + rv = mRegionFactory->CreateInstance(nsnull, NS_GET_IID(nsIRegion), (void**)®ion); if (NS_SUCCEEDED(rv)) { rv = region->Init(); *result = region; @@ -462,14 +480,10 @@ NS_IMETHODIMP nsViewManager::Init(nsIDeviceContext* aContext) // create regions mOpaqueRgn = nsnull; mTmpRgn = nsnull; - - nsIComponentManager* componentManager = nsnull; - rv = NS_GetGlobalComponentManager(&componentManager); - if (NS_SUCCEEDED(rv)) { - CreateRegion(componentManager, &mOpaqueRgn); - CreateRegion(componentManager, &mTmpRgn); - } - + + CreateRegion(&mOpaqueRgn); + CreateRegion(&mTmpRgn); + if (nsnull == mEventQueue) { // Cache the event queue of the current UI thread nsCOMPtr eventService = @@ -1747,12 +1761,9 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS // printf("refreshing: view: %x, %d, %d, %d, %d\n", view, damrect.x, damrect.y, damrect.width, damrect.height); // Refresh the view if (mRefreshEnabled) { - nsIComponentManager* componentManager = nsnull; - nsresult rv = NS_GetGlobalComponentManager(&componentManager); nsCOMPtr rgn; + nsresult rv = CreateRegion(getter_AddRefs(rgn)); if (NS_SUCCEEDED(rv)) { - rv = CreateRegion(componentManager, getter_AddRefs(rgn)); - if (NS_SUCCEEDED(rv)) { // Eventually we would like the platform paint event to include a region // we can use. This could improve paint performance when the invalid area // is more complicated than a rectangle. Right now the event's region field @@ -1761,9 +1772,9 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS rgn->SetTo(damrect.x, damrect.y, damrect.width, damrect.height); Refresh(view, ((nsPaintEvent*)aEvent)->renderingContext, rgn, updateFlags); doDefault = PR_FALSE; - } } } + // since we got an NS_PAINT event, we need to // draw something so we don't get blank areas. diff --git a/mozilla/view/src/nsViewManager.h b/mozilla/view/src/nsViewManager.h index d5e65273b17..7815a370bec 100644 --- a/mozilla/view/src/nsViewManager.h +++ b/mozilla/view/src/nsViewManager.h @@ -407,6 +407,9 @@ private: nsISupportsArray *mCompositeListeners; void DestroyZTreeNode(DisplayZTreeNode* aNode); + + nsresult CreateRegion(nsIRegion* *result); + nsCOMPtr mRegionFactory; protected: nsView *mRootView; nscoord mX; diff --git a/mozilla/webshell/tests/viewer/nsViewerApp.cpp b/mozilla/webshell/tests/viewer/nsViewerApp.cpp index bd99faab7df..047343106b3 100644 --- a/mozilla/webshell/tests/viewer/nsViewerApp.cpp +++ b/mozilla/webshell/tests/viewer/nsViewerApp.cpp @@ -255,7 +255,7 @@ NS_METHOD nsTestFormProcessor::ProvideContent(const nsString& aFormType, nsresult nsViewerApp::AutoregisterComponents() { - nsresult rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, + nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); return rv; diff --git a/mozilla/xpcom/build/nsXPCOM.h b/mozilla/xpcom/build/nsXPCOM.h index 82df7e6a6ab..e311e583aba 100644 --- a/mozilla/xpcom/build/nsXPCOM.h +++ b/mozilla/xpcom/build/nsXPCOM.h @@ -40,6 +40,7 @@ #include "nscore.h" +class nsIComponentManager; class nsIServiceManager; class nsIFile; class nsIDirectoryServiceProvider; @@ -110,6 +111,19 @@ NS_ShutdownXPCOM(nsIServiceManager* servMgr); extern "C" NS_COM nsresult NS_GetServiceManager(nsIServiceManager* *result); +/** + * Public Method to access to the component manager. + * + * @status FROZEN + * @param result Interface pointer to the service + * + * @return NS_OK for success; + * other error codes indicate a failure during initialisation. + * + */ +extern "C" NS_COM nsresult +NS_GetComponentManager(nsIComponentManager* *result); + /** * Public Method to access to the memory manager. See nsIMemory * diff --git a/mozilla/xpcom/build/nsXPComInit.cpp b/mozilla/xpcom/build/nsXPComInit.cpp index 6dc944b5bbd..cceb311e8ab 100644 --- a/mozilla/xpcom/build/nsXPComInit.cpp +++ b/mozilla/xpcom/build/nsXPComInit.cpp @@ -183,8 +183,13 @@ RegisterGenericFactory(nsIComponentManager* compMgr, nsIGenericFactory* fact; rv = NS_NewGenericFactory(&fact, info); if (NS_FAILED(rv)) return rv; - rv = compMgr->RegisterFactory(info->mCID, info->mDescription, - info->mContractID, fact, PR_TRUE); + + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(compMgr, &rv); + if (obsoleteManager) + rv = obsoleteManager->RegisterFactory(info->mCID, info->mDescription, + info->mContractID, fact, PR_TRUE); NS_RELEASE(fact); return rv; } diff --git a/mozilla/xpcom/components/MANIFEST b/mozilla/xpcom/components/MANIFEST index e51972d5681..e6e3ba02826 100644 --- a/mozilla/xpcom/components/MANIFEST +++ b/mozilla/xpcom/components/MANIFEST @@ -5,3 +5,6 @@ nsComponentManagerUtils.h nsStaticComponent.h nsIServiceManagerObsolete.h nsIServiceManagerUtils.h +nsComponentManagerObsolete.h +nsIComponentManagerUtils.h +nsObsoleteModuleLoading.h diff --git a/mozilla/xpcom/components/MANIFEST_IDL b/mozilla/xpcom/components/MANIFEST_IDL index a4e53b69048..539ac9f3af3 100644 --- a/mozilla/xpcom/components/MANIFEST_IDL +++ b/mozilla/xpcom/components/MANIFEST_IDL @@ -3,6 +3,7 @@ nsICategoryManager.idl nsIClassInfo.idl nsIComponentLoader.idl nsIComponentManager.idl +nsIComponentManagerObsolete.idl nsIFactory.idl nsIRegistry.idl nsIServiceManager.idl diff --git a/mozilla/xpcom/components/makefile.win b/mozilla/xpcom/components/makefile.win index b08d196a632..c00ec6a73ea 100644 --- a/mozilla/xpcom/components/makefile.win +++ b/mozilla/xpcom/components/makefile.win @@ -32,7 +32,9 @@ REQUIRES = mozreg \ ## exports EXPORTS = \ + nsComponentManagerObsolete.h \ nsComponentManagerUtils.h \ + nsIComponentManagerUtils.h \ nsIGenericFactory.h \ nsIRegistryUtils.h \ nsIServiceManagerObsolete.h \ @@ -41,6 +43,7 @@ EXPORTS = \ nsNativeComponentLoader.h \ nsStaticComponent.h \ xcDll.h \ + nsObsoleteModuleLoading.h \ $(NULL) XPIDLSRCS = \ @@ -49,6 +52,7 @@ XPIDLSRCS = \ .\nsIClassInfo.idl \ .\nsIComponentLoader.idl \ .\nsIComponentManager.idl \ + .\nsIComponentManagerObsolete.idl \ .\nsIFactory.idl \ .\nsIModule.idl \ .\nsIRegistry.idl \ @@ -74,6 +78,7 @@ LCFLAGS = $(LCFLAGS) -DENABLE_STATIC_COMPONENT_LOADER CPP_OBJS = \ .\$(OBJDIR)\nsComponentManager.obj \ + .\$(OBJDIR)\nsComponentManagerObsolete.obj \ .\$(OBJDIR)\nsGenericFactory.obj \ .\$(OBJDIR)\nsNativeComponentLoader.obj \ .\$(OBJDIR)\nsServiceManagerObsolete.obj \ diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp index eccac7d203f..c1ecc767a21 100644 --- a/mozilla/xpcom/components/nsComponentManager.cpp +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -41,6 +41,7 @@ #include "nsCOMPtr.h" #include "nsComponentManager.h" +#include "nsComponentManagerObsolete.h" #include "nsICategoryManager.h" #include "nsIEnumerator.h" @@ -455,11 +456,14 @@ nsFactoryEntry::ReInit(const nsCID &aClass, nsIFactory *aFactory) nsComponentManagerImpl::nsComponentManagerImpl() - : mMon(NULL), - mRegistry(NULL), mPrePopulationDone(PR_FALSE), - mNativeComponentLoader(0), - mStaticComponentLoader(0), - mShuttingDown(NS_SHUTDOWN_NEVERHAPPENED), mLoaderData(nsnull) + : + mMon(NULL), + mRegistry(NULL), + mPrePopulationDone(PR_FALSE), + mNativeComponentLoader(0), + mStaticComponentLoader(0), + mShuttingDown(NS_SHUTDOWN_NEVERHAPPENED), + mLoaderData(nsnull) { NS_INIT_REFCNT(); mFactories.ops = nsnull; @@ -510,7 +514,6 @@ nsresult nsComponentManagerImpl::Init(void) 0.875, PL_DHASH_MIN_ALPHA(&mContractIDs, 2)); } - if (mMon == NULL) { mMon = PR_NewMonitor(); if (mMon == NULL) @@ -614,7 +617,6 @@ nsresult nsComponentManagerImpl::Shutdown(void) NS_IF_RELEASE(mStaticComponentLoader); #endif - // Destroy the Lock if (mMon) PR_DestroyMonitor(mMon); @@ -639,12 +641,13 @@ nsComponentManagerImpl::~nsComponentManagerImpl() PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, ("nsComponentManager: Destroyed.")); } -NS_IMPL_THREADSAFE_ISUPPORTS5(nsComponentManagerImpl, +NS_IMPL_THREADSAFE_ISUPPORTS6(nsComponentManagerImpl, nsIComponentManager, nsIServiceManager, nsISupportsWeakReference, nsIInterfaceRequestor, - nsIServiceManagerObsolete) + nsIServiceManagerObsolete, + nsIComponentManagerObsolete) //////////////////////////////////////////////////////////////////////////////// // nsComponentManagerImpl: Platform methods @@ -1229,6 +1232,7 @@ nsComponentManagerImpl::HashContractID(const char *aContractID, nsFactoryEntry * return NS_ERROR_NULL_POINTER; nsAutoMonitor mon(mMon); + nsContractIDTableEntry* contractIDTableEntry = NS_STATIC_CAST(nsContractIDTableEntry*, PL_DHashTableOperate(&mContractIDs, aContractID, @@ -1283,6 +1287,7 @@ nsComponentManagerImpl::GetFactoryEntry(const char *aContractID, int checkRegist { nsFactoryEntry *fe = nsnull; { + nsAutoMonitor mon(mMon); nsContractIDTableEntry* contractIDTableEntry = @@ -1461,6 +1466,34 @@ nsComponentManagerImpl::GetClassObject(const nsCID &aClass, const nsIID &aIID, return rv; } + +nsresult +nsComponentManagerImpl::GetClassObjectByContractID(const char *contractID, + const nsIID &aIID, + void **aResult) +{ + nsresult rv; + + nsCOMPtr factory; + + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + PR_LogPrint("nsComponentManager: GetClassObject(%s)", contractID); + } + + PR_ASSERT(aResult != NULL); + + rv = FindFactory(contractID, getter_AddRefs(factory)); + if (NS_FAILED(rv)) return rv; + + rv = factory->QueryInterface(aIID, aResult); + + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tGetClassObject() %s", NS_SUCCEEDED(rv) ? "succeeded" : "FAILED")); + + return rv; +} + /** * ContractIDToClassID() * @@ -1675,16 +1708,14 @@ FreeServiceContractIDEntryEnumerate(PLDHashTable *aTable, nsresult nsComponentManagerImpl::FreeServices() { + nsAutoMonitor mon(mMon); + if (mFactories.ops) { - PR_EnterMonitor(mMon); PL_DHashTableEnumerate(&mFactories, FreeServiceFactoryEntryEnumerate, nsnull); - PR_ExitMonitor(mMon); } if (mContractIDs.ops) { - PR_EnterMonitor(mMon); PL_DHashTableEnumerate(&mContractIDs, FreeServiceContractIDEntryEnumerate, nsnull); - PR_ExitMonitor(mMon); } return NS_OK; @@ -1726,7 +1757,9 @@ nsComponentManagerImpl::GetService(const nsCID& aClass, // CreateInstance, because it invokes user code which could try to re-enter // the service manager: mon.Exit(); + rv = CreateInstance(aClass, NULL, aIID, getter_AddRefs(service)); + mon.Enter(); if (NS_FAILED(rv)) @@ -1790,6 +1823,7 @@ nsComponentManagerImpl::UnregisterService(const nsCID& aClass) nsFactoryEntry* entry = nsnull; nsAutoMonitor mon(mMon); + nsFactoryTableEntry* factoryTableEntry = NS_STATIC_CAST(nsFactoryTableEntry*, PL_DHashTableOperate(&mFactories, &aClass, @@ -1809,6 +1843,7 @@ nsComponentManagerImpl::UnregisterService(const nsCID& aClass) NS_IMETHODIMP nsComponentManagerImpl::RegisterService(const char* aContractID, nsISupports* aService) { + nsAutoMonitor mon(mMon); // check to see if we have a factory entry for the service @@ -1904,7 +1939,7 @@ NS_IMETHODIMP nsComponentManagerImpl::IsServiceInstantiatedByContractID(const ch nsFactoryEntry *entry = nsnull; { nsAutoMonitor mon(mMon); - + nsContractIDTableEntry* contractIDTableEntry = NS_STATIC_CAST(nsContractIDTableEntry*, PL_DHashTableOperate(&mContractIDs, aContractID, @@ -1928,6 +1963,7 @@ NS_IMETHODIMP nsComponentManagerImpl::UnregisterService(const char* aContractID) { nsresult rv = NS_OK; + nsAutoMonitor mon(mMon); nsFactoryEntry *entry = nsnull; @@ -1983,7 +2019,9 @@ nsComponentManagerImpl::GetServiceByContractID(const char* aContractID, // CreateInstance, because it invokes user code which could try to re-enter // the service manager: mon.Exit(); + rv = CreateInstanceByContractID(aContractID, NULL, aIID, getter_AddRefs(service)); + mon.Enter(); if (NS_FAILED(rv)) @@ -2191,9 +2229,10 @@ nsComponentManagerImpl::RegisterFactory(const nsCID &aClass, PRBool aReplace) { nsFactoryEntry *entry = nsnull; - nsIDKey key(aClass); + nsAutoMonitor mon(mMon); + entry = GetFactoryEntry(aClass, key, 0 /* dont check registry */); @@ -2349,6 +2388,7 @@ nsComponentManagerImpl::RegisterComponentCommon(const nsCID &aClass, nsIDKey key(aClass); nsAutoMonitor mon(mMon); + nsFactoryEntry *entry = GetFactoryEntry(aClass, !mPrePopulationDone); // Normalize proid and classname @@ -2574,6 +2614,7 @@ nsComponentManagerImpl::UnregisterFactory(const nsCID &aClass, if (old->factory.get() == aFactory) { nsAutoMonitor mon(mMon); + PL_DHashTableOperate(&mFactories, &aClass, PL_DHASH_REMOVE); old = NULL; res = NS_OK; @@ -2595,7 +2636,7 @@ nsComponentManagerImpl::UnregisterComponent(const nsCID &aClass, NS_ENSURE_ARG_POINTER(registryName); - PR_EnterMonitor(mMon); + nsAutoMonitor mon(mMon); // Remove any stored factory entries nsIDKey key(aClass); @@ -2614,8 +2655,6 @@ nsComponentManagerImpl::UnregisterComponent(const nsCID &aClass, delete [] cidString; #endif - PR_ExitMonitor(mMon); - PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, ("nsComponentManager: Factory unregister(%s) %s.", registryName, NS_SUCCEEDED(rv) ? "succeeded" : "FAILED")); @@ -2646,7 +2685,7 @@ nsComponentManagerImpl::UnloadLibraries(nsIServiceManager *serviceMgr, PRInt32 a { nsresult rv = NS_OK; - PR_EnterMonitor(mMon); + nsAutoMonitor mon(mMon); PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, ("nsComponentManager: Unloading Libraries.")); @@ -2664,9 +2703,6 @@ nsComponentManagerImpl::UnloadLibraries(nsIServiceManager *serviceMgr, PRInt32 a // UnloadAll the native loader rv = mNativeComponentLoader->UnloadAll(aWhen); - - PR_ExitMonitor(mMon); - return rv; } @@ -3237,6 +3273,9 @@ nsComponentManagerImpl::AddLoaderType(const char *typeStr) NS_COM nsresult NS_GetGlobalComponentManager(nsIComponentManager* *result) { +#ifdef DEBUG_dougt + // NS_WARNING("DEPRECATED FUNCTION: Use NS_GetComponentManager"); +#endif nsresult rv = NS_OK; if (nsComponentManagerImpl::gComponentManager == NULL) @@ -3248,12 +3287,38 @@ NS_GetGlobalComponentManager(nsIComponentManager* *result) if (NS_SUCCEEDED(rv)) { // NO ADDREF since this is never intended to be released. - *result = nsComponentManagerImpl::gComponentManager; + // See nsComponentManagerObsolete.h for the reason for such + // casting uglyness + *result = (nsIComponentManager*)(void*)(nsIComponentManagerObsolete*) nsComponentManagerImpl::gComponentManager; } return rv; } + + + +NS_COM nsresult +NS_GetComponentManager(nsIComponentManager* *result) +{ + nsresult rv = NS_OK; + + if (nsComponentManagerImpl::gComponentManager == NULL) + { + // XPCOM needs initialization. + rv = NS_InitXPCOM2(nsnull, nsnull, nsnull); + } + + if (NS_FAILED(rv)) + return rv; + + + *result = NS_STATIC_CAST(nsIComponentManager*, + nsComponentManagerImpl::gComponentManager); + NS_IF_ADDREF(*result); + return NS_OK; +} + NS_COM nsresult NS_GetServiceManager(nsIServiceManager* *result) { @@ -3276,233 +3341,3 @@ NS_GetServiceManager(nsIServiceManager* *result) } - -//////////////////////////////////////////////////////////////////////////////// -// Global component manager interface - -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::GetClassObject(const nsCID &aClass, const nsIID &aIID, - void **aResult) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->GetClassObject(aClass, aIID, aResult); -} - -nsresult -nsComponentManager::ContractIDToClassID(const char *aContractID, - nsCID *aClass) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->ContractIDToClassID(aContractID, aClass); -} - -nsresult -nsComponentManager::CLSIDToContractID(nsCID *aClass, - char* *aClassName, - char* *aContractID) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->CLSIDToContractID(*aClass, aClassName, aContractID); -} - -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 *aContractID, - nsISupports *aDelegate, - const nsIID &aIID, - void **aResult) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->CreateInstanceByContractID(aContractID, aDelegate, aIID, aResult); -} - -nsresult -nsComponentManager::RegisterFactory(const nsCID &aClass, - const char *aClassName, - const char *aContractID, - nsIFactory *aFactory, - PRBool aReplace) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->RegisterFactory(aClass, aClassName, aContractID, - aFactory, aReplace); -} - -nsresult -nsComponentManager::RegisterComponent(const nsCID &aClass, - const char *aClassName, - const char *aContractID, - const char *aLibraryPersistentDescriptor, - PRBool aReplace, - PRBool aPersist) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->RegisterComponent(aClass, aClassName, aContractID, - aLibraryPersistentDescriptor, aReplace, aPersist); -} - -nsresult -nsComponentManager::RegisterComponentSpec(const nsCID &aClass, - const char *aClassName, - const char *aContractID, - nsIFile *aLibrary, - PRBool aReplace, - PRBool aPersist) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->RegisterComponentSpec(aClass, aClassName, aContractID, - aLibrary, aReplace, aPersist); -} - -nsresult -nsComponentManager::RegisterComponentLib(const nsCID &aClass, - const char *aClassName, - const char *aContractID, - const char *adllName, - PRBool aReplace, - PRBool aPersist) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->RegisterComponentLib(aClass, aClassName, aContractID, - adllName, 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::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::UnregisterComponentSpec(const nsCID &aClass, - nsIFile *aLibrarySpec) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->UnregisterComponentSpec(aClass, aLibrarySpec); -} - -nsresult -nsComponentManager::FreeLibraries(void) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->FreeLibraries(); -} - -nsresult -nsComponentManager::AutoRegister(PRInt32 when, nsIFile *directory) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->AutoRegister(when, directory); -} - -nsresult -nsComponentManager::AutoRegisterComponent(PRInt32 when, - nsIFile *fullname) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->AutoRegisterComponent(when, fullname); -} - -nsresult -nsComponentManager::AutoUnregisterComponent(PRInt32 when, - nsIFile *fullname) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->AutoUnregisterComponent(when, fullname); -} - -nsresult -nsComponentManager::IsRegistered(const nsCID &aClass, - PRBool *aRegistered) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->IsRegistered(aClass, aRegistered); -} - -nsresult -nsComponentManager::EnumerateCLSIDs(nsIEnumerator** aEnumerator) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->EnumerateCLSIDs(aEnumerator); -} - -nsresult -nsComponentManager::EnumerateContractIDs(nsIEnumerator** aEnumerator) -{ - nsIComponentManager* cm; - nsresult rv = NS_GetGlobalComponentManager(&cm); - if (NS_FAILED(rv)) return rv; - return cm->EnumerateContractIDs(aEnumerator); -} - diff --git a/mozilla/xpcom/components/nsComponentManager.h b/mozilla/xpcom/components/nsComponentManager.h index 80f375d4940..f51c021e0f8 100644 --- a/mozilla/xpcom/components/nsComponentManager.h +++ b/mozilla/xpcom/components/nsComponentManager.h @@ -43,6 +43,7 @@ #include "nsIComponentLoader.h" #include "nsNativeComponentLoader.h" #include "nsIComponentManager.h" +#include "nsIComponentManagerObsolete.h" #include "nsIServiceManager.h" #include "nsIFactory.h" #include "nsRegistry.h" @@ -79,19 +80,32 @@ extern const char XPCOM_LIB_PREFIX[]; //////////////////////////////////////////////////////////////////////////////// + class nsComponentManagerImpl : public nsIComponentManager, public nsIServiceManager, public nsSupportsWeakReference, public nsIInterfaceRequestor, - public nsIServiceManagerObsolete + public nsIServiceManagerObsolete, + public nsIComponentManagerObsolete { public: NS_DECL_ISUPPORTS NS_DECL_NSIINTERFACEREQUESTOR - NS_DECL_NSICOMPONENTMANAGER - NS_DECL_NSISERVICEMANAGER + // Since the nsIComponentManagerObsolete and nsIComponentManager share some of the + // same interface function name, we have to manually define the functions here. + // The only function that is in nsIComponentManagerObsolete and is in nsIComponentManager + // is GetClassObjectContractID. + // + // nsIComponentManager function not in nsIComponentManagerObsolete: + NS_IMETHOD GetClassObjectByContractID(const char *aContractID, + const nsIID &aIID, + void **_retval); + + NS_DECL_NSICOMPONENTMANAGEROBSOLETE + NS_DECL_NSISERVICEMANAGER + // nsIServiceManagerObsolete NS_IMETHOD RegisterService(const nsCID& aClass, nsISupports* aService); @@ -196,6 +210,7 @@ protected: PLDHashTable mFactories; PLDHashTable mContractIDs; PRMonitor* mMon; + nsIRegistry* mRegistry; nsRegistryKey mXPCOMKey; nsRegistryKey mClassesKey; diff --git a/mozilla/xpcom/components/nsComponentManagerObsolete.cpp b/mozilla/xpcom/components/nsComponentManagerObsolete.cpp new file mode 100644 index 00000000000..09b2569005c --- /dev/null +++ b/mozilla/xpcom/components/nsComponentManagerObsolete.cpp @@ -0,0 +1,271 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is XPCOM + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +//////////////////////////////////////////////////////////////////////////////// +// Global Static Component Manager Methods +// (for when you need to link with xpcom) + +#include "nsIComponentManagerObsolete.h" +#include "nsComponentManagerObsolete.h" + + +nsresult +nsComponentManager::Initialize(void) +{ + return NS_OK; +} + +nsresult +nsComponentManager::FindFactory(const nsCID &aClass, + nsIFactory **aFactory) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->FindFactory(aClass, aFactory); +} + +nsresult +nsComponentManager::GetClassObject(const nsCID &aClass, const nsIID &aIID, + void **aResult) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->GetClassObject(aClass, aIID, aResult); +} + +nsresult +nsComponentManager::ContractIDToClassID(const char *aContractID, + nsCID *aClass) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->ContractIDToClassID(aContractID, aClass); +} + +nsresult +nsComponentManager::CLSIDToContractID(nsCID *aClass, + char* *aClassName, + char* *aContractID) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->CLSIDToContractID(*aClass, aClassName, aContractID); +} + +nsresult +nsComponentManager::CreateInstance(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->CreateInstance(aClass, aDelegate, aIID, aResult); +} + +nsresult +nsComponentManager::CreateInstance(const char *aContractID, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->CreateInstanceByContractID(aContractID, aDelegate, aIID, aResult); +} + +nsresult +nsComponentManager::RegisterFactory(const nsCID &aClass, + const char *aClassName, + const char *aContractID, + nsIFactory *aFactory, + PRBool aReplace) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->RegisterFactory(aClass, aClassName, aContractID, + aFactory, aReplace); +} + +nsresult +nsComponentManager::RegisterComponent(const nsCID &aClass, + const char *aClassName, + const char *aContractID, + const char *aLibraryPersistentDescriptor, + PRBool aReplace, + PRBool aPersist) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->RegisterComponent(aClass, aClassName, aContractID, + aLibraryPersistentDescriptor, aReplace, aPersist); +} + +nsresult +nsComponentManager::RegisterComponentSpec(const nsCID &aClass, + const char *aClassName, + const char *aContractID, + nsIFile *aLibrary, + PRBool aReplace, + PRBool aPersist) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->RegisterComponentSpec(aClass, aClassName, aContractID, + aLibrary, aReplace, aPersist); +} + +nsresult +nsComponentManager::RegisterComponentLib(const nsCID &aClass, + const char *aClassName, + const char *aContractID, + const char *adllName, + PRBool aReplace, + PRBool aPersist) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->RegisterComponentLib(aClass, aClassName, aContractID, + adllName, aReplace, aPersist); +} + +nsresult +nsComponentManager::UnregisterFactory(const nsCID &aClass, + nsIFactory *aFactory) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->UnregisterFactory(aClass, aFactory); +} + +nsresult +nsComponentManager::UnregisterComponent(const nsCID &aClass, + const char *aLibrary) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->UnregisterComponent(aClass, aLibrary); +} + +nsresult +nsComponentManager::UnregisterComponentSpec(const nsCID &aClass, + nsIFile *aLibrarySpec) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->UnregisterComponentSpec(aClass, aLibrarySpec); +} + +nsresult +nsComponentManager::FreeLibraries(void) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->FreeLibraries(); +} + +nsresult +nsComponentManager::AutoRegister(PRInt32 when, nsIFile *directory) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->AutoRegister(when, directory); +} + +nsresult +nsComponentManager::AutoRegisterComponent(PRInt32 when, + nsIFile *fullname) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->AutoRegisterComponent(when, fullname); +} + +nsresult +nsComponentManager::AutoUnregisterComponent(PRInt32 when, + nsIFile *fullname) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->AutoUnregisterComponent(when, fullname); +} + +nsresult +nsComponentManager::IsRegistered(const nsCID &aClass, + PRBool *aRegistered) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->IsRegistered(aClass, aRegistered); +} + +nsresult +nsComponentManager::EnumerateCLSIDs(nsIEnumerator** aEnumerator) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->EnumerateCLSIDs(aEnumerator); +} + +nsresult +nsComponentManager::EnumerateContractIDs(nsIEnumerator** aEnumerator) +{ + nsIComponentManagerObsolete* cm; + nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm); + if (NS_FAILED(rv)) return rv; + return cm->EnumerateContractIDs(aEnumerator); +} + diff --git a/mozilla/xpcom/components/nsComponentManagerObsolete.h b/mozilla/xpcom/components/nsComponentManagerObsolete.h new file mode 100644 index 00000000000..726abd325e3 --- /dev/null +++ b/mozilla/xpcom/components/nsComponentManagerObsolete.h @@ -0,0 +1,185 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is XPCOM + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +#ifndef nsComponentManagerObsolete_h___ +#define nsComponentManagerObsolete_h___ + +#include "nsIComponentManager.h" +#include "nsIComponentManagerObsolete.h" + +class nsIEnumerator; +class nsIFactory; +class nsIFile; +//////////////////////////////////////////////////////////////////// +// +// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING +// +// Functions, classes, interfaces and types in this file are +// obsolete. Use at your own risk. +// Please see nsIComponentManager.idl for the supported interface +// to the component manager. +// +//////////////////////////////////////////////////////////////////// + + + +//////////////////////////////////////////////////////////////////// +// God save me from this evilness. Below is a very bad +// function. Its out var is really a nsIComponentManagerObsolete +// but it has been cast to a nsIComponentManager. +// The reason for such uglyness is that this function is require for +// backward compatiblity of some plugins. This funciton will +// be removed at some point. +//////////////////////////////////////////////////////////////////// + +extern NS_COM nsresult +NS_GetGlobalComponentManager(nsIComponentManager* *result); + + + + +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); + + // Get the singleton class object that implements the CID aClass + static nsresult GetClassObject(const nsCID &aClass, const nsIID &aIID, + void **aResult); + + // Finds a class ID for a specific Program ID + static nsresult ContractIDToClassID(const char *aContractID, + nsCID *aClass); + + // Finds a Program ID for a specific class ID + // caller frees the result with delete[] + static nsresult CLSIDToContractID(nsCID *aClass, + char* *aClassName, + char* *aContractID); + + // 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 ContractID + static nsresult CreateInstance(const char *aContractID, + 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 *aContractID, + nsIFactory *aFactory, + PRBool aReplace); + + // Manually register a dynamically loaded component. + // The libraryPersistentDescriptor is what gets passed to the library + // self register function from ComponentManager. The format of this string + // is the same as nsIFile::GetPath() + // + // This function will go away in favour of RegisterComponentSpec. In fact, + // it internally turns around and calls RegisterComponentSpec. + static nsresult RegisterComponent(const nsCID &aClass, + const char *aClassName, + const char *aContractID, + const char *aLibraryPersistentDescriptor, + PRBool aReplace, + PRBool aPersist); + + // Register a component using its FileSpec as its identification + // This is the more prevalent use. + static nsresult RegisterComponentSpec(const nsCID &aClass, + const char *aClassName, + const char *aContractID, + nsIFile *aLibrary, + PRBool aReplace, + PRBool aPersist); + + // Register a component using its dllName. This could be a dll name with + // no path so that LD_LIBRARY_PATH on unix or PATH on win can load it. Or + // this could be a code fragment name on the Mac. + static nsresult RegisterComponentLib(const nsCID &aClass, + const char *aClassName, + const char *aContractID, + const char *adllName, + PRBool aReplace, + PRBool aPersist); + + + // Manually unregister a factory for a class + static nsresult UnregisterFactory(const nsCID &aClass, + nsIFactory *aFactory); + + // Manually unregister a dynamically loaded component + static nsresult UnregisterComponent(const nsCID &aClass, + const char *aLibrary); + + // Manually unregister a dynamically loaded component + static nsresult UnregisterComponentSpec(const nsCID &aClass, + nsIFile *aLibrarySpec); + + // Unload dynamically loaded factories that are not in use + static nsresult FreeLibraries(void); + ////////////////////////////////////////////////////////////////////////////// + // DLL registration support + + // If directory is NULL, then AutoRegister will try registering components + // in the default components directory. + static nsresult AutoRegister(PRInt32 when, nsIFile* directory); + static nsresult AutoRegisterComponent(PRInt32 when, nsIFile *component); + static nsresult AutoUnregisterComponent(PRInt32 when, nsIFile *component); + + // Is the given CID currently registered? + static nsresult IsRegistered(const nsCID &aClass, + PRBool *aRegistered); + + // Get an enumeration of all the CIDs + static nsresult EnumerateCLSIDs(nsIEnumerator** aEmumerator); + + // Get an enumeration of all the ContractIDs + static nsresult EnumerateContractIDs(nsIEnumerator** aEmumerator); + +}; + + +#endif diff --git a/mozilla/xpcom/components/nsComponentManagerUtils.h b/mozilla/xpcom/components/nsComponentManagerUtils.h index 049d7d05670..50f540983da 100644 --- a/mozilla/xpcom/components/nsComponentManagerUtils.h +++ b/mozilla/xpcom/components/nsComponentManagerUtils.h @@ -28,32 +28,6 @@ #include "nsCOMPtr.h" #endif -#ifndef OBSOLETE_MODULE_LOADING -/* - * Prototypes for dynamic library export functions. Your DLL/DSO needs to export - * these methods to play in the component world. - * - * THIS IS OBSOLETE. Look at nsIModule.idl - */ - -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, - const nsCID &aClass, - const char *aClassName, - const char *aContractID, - 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 *aContractID, - nsIFactory **aFactory); -typedef PRBool (*nsCanUnloadProc)(nsISupports* aServMgr); -typedef nsresult (*nsRegisterProc)(nsISupports* aServMgr, const char *path); -typedef nsresult (*nsUnregisterProc)(nsISupports* aServMgr, const char *path); -#endif /* OBSOLETE_MODULE_LOADING */ #define NS_COMPONENTMANAGER_CID \ { /* 91775d60-d5dc-11d2-92fb-00e09805570f */ \ @@ -63,163 +37,43 @@ typedef nsresult (*nsUnregisterProc)(nsISupports* aServMgr, const char *path); {0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \ } -#define NS_COMPONENTMANAGER_CONTRACTID "@mozilla.org/xpcom/componentmanager;1" - -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 { +class NS_COM nsCreateInstanceByCID : public nsCOMPtr_helper +{ public: - static nsresult Initialize(void); - - // Finds a factory for a specific class ID - static nsresult FindFactory(const nsCID &aClass, - nsIFactory **aFactory); - - // Get the singleton class object that implements the CID aClass - static nsresult GetClassObject(const nsCID &aClass, const nsIID &aIID, - void **aResult); - - // Finds a class ID for a specific Program ID - static nsresult ContractIDToClassID(const char *aContractID, - nsCID *aClass); - - // Finds a Program ID for a specific class ID - // caller frees the result with delete[] - static nsresult CLSIDToContractID(nsCID *aClass, - char* *aClassName, - char* *aContractID); - - // 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 ContractID - static nsresult CreateInstance(const char *aContractID, - 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 *aContractID, - nsIFactory *aFactory, - PRBool aReplace); - - // Manually register a dynamically loaded component. - // The libraryPersistentDescriptor is what gets passed to the library - // self register function from ComponentManager. The format of this string - // is the same as nsIFile::GetPath() - // - // This function will go away in favour of RegisterComponentSpec. In fact, - // it internally turns around and calls RegisterComponentSpec. - static nsresult RegisterComponent(const nsCID &aClass, - const char *aClassName, - const char *aContractID, - const char *aLibraryPersistentDescriptor, - PRBool aReplace, - PRBool aPersist); - - // Register a component using its FileSpec as its identification - // This is the more prevalent use. - static nsresult RegisterComponentSpec(const nsCID &aClass, - const char *aClassName, - const char *aContractID, - nsIFile *aLibrary, - PRBool aReplace, - PRBool aPersist); - - // Register a component using its dllName. This could be a dll name with - // no path so that LD_LIBRARY_PATH on unix or PATH on win can load it. Or - // this could be a code fragment name on the Mac. - static nsresult RegisterComponentLib(const nsCID &aClass, - const char *aClassName, - const char *aContractID, - const char *adllName, - PRBool aReplace, - PRBool aPersist); - - - // Manually unregister a factory for a class - static nsresult UnregisterFactory(const nsCID &aClass, - nsIFactory *aFactory); - - // Manually unregister a dynamically loaded component - static nsresult UnregisterComponent(const nsCID &aClass, - const char *aLibrary); - - // Manually unregister a dynamically loaded component - static nsresult UnregisterComponentSpec(const nsCID &aClass, - nsIFile *aLibrarySpec); - - // Unload dynamically loaded factories that are not in use - static nsresult FreeLibraries(void); - ////////////////////////////////////////////////////////////////////////////// - // DLL registration support - - // If directory is NULL, then AutoRegister will try registering components - // in the default components directory. - static nsresult AutoRegister(PRInt32 when, nsIFile* directory); - static nsresult AutoRegisterComponent(PRInt32 when, nsIFile *component); - static nsresult AutoUnregisterComponent(PRInt32 when, nsIFile *component); - - // Is the given CID currently registered? - static nsresult IsRegistered(const nsCID &aClass, - PRBool *aRegistered); - - // Get an enumeration of all the CIDs - static nsresult EnumerateCLSIDs(nsIEnumerator** aEmumerator); + nsCreateInstanceByCID( const nsCID& aCID, nsISupports* aOuter, nsresult* aErrorPtr ) + : mCID(aCID), + mOuter(aOuter), + mErrorPtr(aErrorPtr) + { + // nothing else to do here + } - // Get an enumeration of all the ContractIDs - static nsresult EnumerateContractIDs(nsIEnumerator** aEmumerator); - + virtual nsresult operator()( const nsIID&, void** ) const; + +private: + const nsCID& mCID; + nsISupports* mOuter; + nsresult* mErrorPtr; }; - -class NS_COM nsCreateInstanceByCID : public nsCOMPtr_helper - { - public: - nsCreateInstanceByCID( const nsCID& aCID, nsISupports* aOuter, nsresult* aErrorPtr ) - : mCID(aCID), - mOuter(aOuter), - mErrorPtr(aErrorPtr) - { - // nothing else to do here - } - - virtual nsresult operator()( const nsIID&, void** ) const; - - private: - const nsCID& mCID; - nsISupports* mOuter; - nsresult* mErrorPtr; - }; - class NS_COM nsCreateInstanceByContractID : public nsCOMPtr_helper - { - public: - nsCreateInstanceByContractID( const char* aContractID, nsISupports* aOuter, nsresult* aErrorPtr ) - : mContractID(aContractID), - mOuter(aOuter), - mErrorPtr(aErrorPtr) +{ +public: + nsCreateInstanceByContractID( const char* aContractID, nsISupports* aOuter, nsresult* aErrorPtr ) + : mContractID(aContractID), + mOuter(aOuter), + mErrorPtr(aErrorPtr) { // nothing else to do here } - - virtual nsresult operator()( const nsIID&, void** ) const; - - private: - const char* mContractID; - nsISupports* mOuter; - nsresult* mErrorPtr; - }; + + virtual nsresult operator()( const nsIID&, void** ) const; + +private: + const char* mContractID; + nsISupports* mOuter; + nsresult* mErrorPtr; +}; class NS_COM nsCreateInstanceFromCategory : public nsCOMPtr_helper { @@ -234,7 +88,7 @@ public: } virtual nsresult operator()( const nsIID&, void** ) const; virtual ~nsCreateInstanceFromCategory() {}; - + private: const char *mCategory; const char *mEntry; @@ -245,30 +99,30 @@ private: inline const nsCreateInstanceByCID do_CreateInstance( const nsCID& aCID, nsresult* error = 0 ) - { - return nsCreateInstanceByCID(aCID, 0, error); - } +{ + return nsCreateInstanceByCID(aCID, 0, error); +} inline const nsCreateInstanceByCID do_CreateInstance( const nsCID& aCID, nsISupports* aOuter, nsresult* error = 0 ) - { - return nsCreateInstanceByCID(aCID, aOuter, error); - } +{ + return nsCreateInstanceByCID(aCID, aOuter, error); +} inline const nsCreateInstanceByContractID do_CreateInstance( const char* aContractID, nsresult* error = 0 ) - { - return nsCreateInstanceByContractID(aContractID, 0, error); - } +{ + return nsCreateInstanceByContractID(aContractID, 0, error); +} inline const nsCreateInstanceByContractID do_CreateInstance( const char* aContractID, nsISupports* aOuter, nsresult* error = 0 ) - { - return nsCreateInstanceByContractID(aContractID, aOuter, error); - } +{ + return nsCreateInstanceByContractID(aContractID, aOuter, error); +} inline const nsCreateInstanceFromCategory @@ -293,26 +147,26 @@ nsresult CallCreateInstance( const nsCID &aClass, nsISupports *aDelegate, DestinationType** aDestination ) - { +{ NS_PRECONDITION(aDestination, "null parameter"); - + return nsComponentManager::CreateInstance(aClass, aDelegate, - NS_GET_IID(DestinationType), - NS_REINTERPRET_CAST(void**, aDestination)); - } + NS_GET_IID(DestinationType), + NS_REINTERPRET_CAST(void**, aDestination)); +} template inline nsresult CallCreateInstance( const nsCID &aClass, DestinationType** aDestination ) - { +{ NS_PRECONDITION(aDestination, "null parameter"); - + return nsComponentManager::CreateInstance(aClass, nsnull, - NS_GET_IID(DestinationType), - NS_REINTERPRET_CAST(void**, aDestination)); - } + NS_GET_IID(DestinationType), + NS_REINTERPRET_CAST(void**, aDestination)); +} template inline @@ -320,28 +174,29 @@ nsresult CallCreateInstance( const char *aContractID, nsISupports *aDelegate, DestinationType** aDestination ) - { +{ NS_PRECONDITION(aContractID, "null parameter"); NS_PRECONDITION(aDestination, "null parameter"); - - return nsComponentManager::CreateInstance(aContractID, aDelegate, - NS_GET_IID(DestinationType), - NS_REINTERPRET_CAST(void**, aDestination)); - } + + return nsComponentManager::CreateInstance(aContractID, + aDelegate, + NS_GET_IID(DestinationType), + NS_REINTERPRET_CAST(void**, aDestination)); +} template inline nsresult CallCreateInstance( const char *aContractID, DestinationType** aDestination ) - { +{ NS_PRECONDITION(aContractID, "null parameter"); NS_PRECONDITION(aDestination, "null parameter"); - + return nsComponentManager::CreateInstance(aContractID, nsnull, - NS_GET_IID(DestinationType), - NS_REINTERPRET_CAST(void**, aDestination)); - } + NS_GET_IID(DestinationType), + NS_REINTERPRET_CAST(void**, aDestination)); +} /* keys for registry use */ extern const char xpcomKeyName[]; @@ -352,3 +207,5 @@ extern const char nativeComponentType[]; extern const char staticComponentType[]; #endif /* nsComponentManagerUtils_h__ */ + + diff --git a/mozilla/xpcom/components/nsGenericFactory.cpp b/mozilla/xpcom/components/nsGenericFactory.cpp index e20643604ec..174752218ca 100644 --- a/mozilla/xpcom/components/nsGenericFactory.cpp +++ b/mozilla/xpcom/components/nsGenericFactory.cpp @@ -43,7 +43,7 @@ #include "nsCRT.h" #include "nsCOMPtr.h" #include "nsIComponentManager.h" - +#include "nsIComponentManagerObsolete.h" nsGenericFactory::nsGenericFactory(nsModuleComponentInfo *info) : mInfo(info) { @@ -358,11 +358,15 @@ nsGenericModule::RegisterSelf(nsIComponentManager *aCompMgr, for (PRUint32 i = 0; i < mComponentCount; i++) { // Register the component only if it has a constructor if (cp->mConstructor) { - rv = aCompMgr->RegisterComponentWithType(cp->mCID, - cp->mDescription, - cp->mContractID, aPath, - registryLocation, PR_TRUE, - PR_TRUE, componentType); + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(aCompMgr, &rv); + if (obsoleteManager) + rv = obsoleteManager->RegisterComponentWithType(cp->mCID, + cp->mDescription, + cp->mContractID, aPath, + registryLocation, PR_TRUE, + PR_TRUE, componentType); if (NS_FAILED(rv)) { #ifdef DEBUG printf("nsGenericModule %s: unable to register %s component => %x\n", @@ -405,8 +409,15 @@ nsGenericModule::UnregisterSelf(nsIComponentManager* aCompMgr, { cp->mUnregisterSelfProc(aCompMgr, aPath, registryLocation, cp); } + // Unregister the component - nsresult rv = aCompMgr->UnregisterComponentSpec(cp->mCID, aPath); + + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsresult rv; + nsCOMPtr obsoleteManager = do_QueryInterface(aCompMgr, &rv); + if (obsoleteManager) + rv = obsoleteManager->UnregisterComponentSpec(cp->mCID, aPath); if (NS_FAILED(rv)) { #ifdef DEBUG printf("nsGenericModule %s: unable to unregister %s component => %x\n", diff --git a/mozilla/xpcom/components/nsIComponentManager.idl b/mozilla/xpcom/components/nsIComponentManager.idl index 873ba8a97c4..c6a3295c02f 100644 --- a/mozilla/xpcom/components/nsIComponentManager.idl +++ b/mozilla/xpcom/components/nsIComponentManager.idl @@ -1,75 +1,78 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License 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 + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the - * NPL. + * License. * - * 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. + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead +` * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/** + * The nsIComponentManager interface. + * @status FROZEN */ #include "nsISupports.idl" -#include "nsIFactory.idl" -interface nsIFile; -interface nsIEnumerator; +interface nsIFactory; -[scriptable, uuid(8458a740-d5dc-11d2-92fb-00e09805570f)] +[scriptable, uuid(a88e5a60-205a-4bb1-94e1-2628daf51eae)] interface nsIComponentManager : nsISupports -{ +{ /** - * findFactory + * getClassObject * * Returns the factory object that can be used to create instances of * CID aClass * * @param aClass The classid of the factory that is being requested */ - nsIFactory findFactory(in nsCIDRef aClass); + void getClassObject(in nsCIDRef aClass, + in nsIIDRef aIID, + [iid_is(aIID),retval] out nsQIResult result); /** - * getClassObject + * getClassObjectByContractID * - * @param aClass : CID of the class whose class object is requested - * @param aIID : IID of an interface that the class object is known to - * to implement. nsISupports and nsIFactory are known to - * be implemented by the class object. + * Returns the factory object that can be used to create instances of + * CID aClass + * + * @param aClass The classid of the factory that is being requested */ - [noscript] voidPtr getClassObject(in nsCIDRef aClass, in nsIIDRef aIID); + void getClassObjectByContractID(in string aContractID, + in nsIIDRef aIID, + [iid_is(aIID),retval] out nsQIResult result); - /** - * contractIDToClassID - * - * Get the ClassID for a given ContractID. Many ClassIDs may implement a - * ContractID. In such a situation, this returns the preferred ClassID, which - * happens to be the last registered ClassID. - * - * @param aContractID : Contractid for which ClassID is requested - * @return aClass : ClassID return - */ - [notxpcom] nsresult contractIDToClassID(in string aContractID, out nsCID aClass); - /** - * classIDToContractid - * - * Get the ContractID for a given ClassID. A ClassIDs may implement multiple - * ContractIDs. This function return the last registered ContractID. - * - * @param aClass : ClassID for which ContractID is requested. - * @return aClassName : returns class name asssociated with aClass - * @return : ContractID last registered for aClass - */ - string CLSIDToContractID(in nsCIDRef aClass, out string aClassName); - - /** + /** * createInstance * * Create an instance of the CID aClass and return the interface aIID. @@ -78,255 +81,31 @@ interface nsIComponentManager : nsISupports * @param aDelegate : Used for aggregation * @param aIID : IID of interface requested */ - [noscript] voidPtr createInstance(in nsCIDRef aClass, - in nsISupports aDelegate, - in nsIIDRef aIID); + void createInstance(in nsCIDRef aClass, + in nsISupports aDelegate, + in nsIIDRef aIID, + [iid_is(aIID),retval] out nsQIResult result); /** * createInstanceByContractID * * Create an instance of the CID that implements aContractID and return the - * interface aIID. This is a convenience function that effectively does - * ContractIDToClassID() followed by CreateInstance(). + * interface aIID. * * @param aContractID : aContractID of object instance requested * @param aDelegate : Used for aggregation * @param aIID : IID of interface requested */ - [noscript] voidPtr createInstanceByContractID(in string aContractID, - in nsISupports aDelegate, - in nsIIDRef IID); - /** - * registryLocationForSpec - * - * Given a file specification, return the registry representation of - * the filename. Files that are found relative to the components - * directory will have a registry representation - * "rel:" while filenames that are not, will have - * "abs:". - */ - string registryLocationForSpec(in nsIFile aSpec); - - /** - * specForRegistyLocation - * - * Create a file specification for the registry representation (rel:/abs:) - * got via registryLocationForSpec. - */ - nsIFile specForRegistryLocation(in string aLocation); - - /** - * registerFactory - * - * Register a factory and ContractID associated with CID aClass - * - * @param aClass : CID of object - * @param aClassName : Class Name of CID - * @param aContractID : ContractID associated with CID aClass - * @param aFactory : Factory that will be registered for CID aClass - * @param aReplace : Boolean that indicates whether to replace a previous - * registration for the CID aClass. - */ - void registerFactory(in nsCIDRef aClass, in string aClassName, - in string aContractID, in nsIFactory aFactory, - in boolean aReplace); - - /** - * registerComponent - * - * Register a native dll module via its registry representation as returned - * by registryLocationForSpec() as the container of CID implemenation - * aClass and associate aContractID and aClassName to the CID aClass. Native - * dll component type is assumed. - * - * @param aClass : CID implemenation contained in module - * @param aClassName : Class name associated with CID aClass - * @param aContractID : ContractID associated with CID aClass - * @param aLocation : Location of module (dll). Format of this is the - * registry representation as returned by - * registryLocationForSpec() - * @param aReplace : Boolean that indicates whether to replace a previous - * module registration for aClass. - * @param aPersist : Remember this registration across sessions. - */ - void registerComponent(in nsCIDRef aClass, in string aClassName, - in string aContractID, in string aLocation, - in boolean aReplace, in boolean aPersist); - - /** - * registerComponentWithType - * - * Register a module's location via its registry representation - * as returned by registryLocationForSpec() as the container of CID implemenation - * aClass of type aType and associate aContractID and aClassName to the CID aClass. - * - * @param aClass : CID implemenation contained in module - * @param aClassName : Class name associated with CID aClass - * @param aContractID : ContractID associated with CID aClass - * @param aSpec : Filename spec for module's location. - * @param aLocation : Location of module of type aType. Format of this string - * is the registry representation as returned by - * registryLocationForSpec() - * @param aReplace : Boolean that indicates whether to replace a previous - * loader registration for aClass. - * @param aPersist : Remember this registration across sessions. - * @param aType : Component Type of CID aClass. - */ - void registerComponentWithType(in nsCIDRef aClass, in string aClassName, - in string aContractID, in nsIFile aSpec, - in string aLocation, in boolean aReplace, - in boolean aPersist, in string aType); - - /** - * registerComponentSpec - * - * Register a native dll module via its file specification as the container - * of CID implemenation aClass and associate aContractID and aClassName to the - * CID aClass. Native dll component type is assumed. - * - * @param aClass : CID implemenation contained in module - * @param aClassName : Class name associated with CID aClass - * @param aContractID : ContractID associated with CID aClass - * @param aLibrary : File specification Location of module (dll). - * @param aReplace : Boolean that indicates whether to replace a previous - * module registration for aClass. - * @param aPersist : Remember this registration across sessions. - */ - void registerComponentSpec(in nsCIDRef aClass, in string aClassName, - in string aContractID, in nsIFile aLibrary, - in boolean aReplace, in boolean aPersist); - - /** - * registerComponentLib - * - * Register a native dll module via its dll name (not full path) as the - * container of CID implemenation aClass and associate aContractID and aClassName - * to the CID aClass. Native dll component type is assumed and the system - * services will be used to load this dll. - * - * @param aClass : CID implemenation contained in module - * @param aClassName : Class name associated with CID aClass - * @param aContractID : ContractID associated with CID aClass - * @param aDllNameLocation : Dll name of module. - * @param aReplace : Boolean that indicates whether to replace a previous - * module registration for aClass. - * @param aPersist : Remember this registration across sessions. - */ - void registerComponentLib(in nsCIDRef aClass, in string aClassName, - in string aContractID, in string aDllName, - in boolean aReplace, in boolean aPersist); - - /** - * unregisterFactory - * - * Unregister a factory associated with CID aClass. - * - * @param aClass : ClassID being unregistered - * @param aFactory : Factory previously registered to create instances of - * ClassID aClass. - */ - void unregisterFactory(in nsCIDRef aClass, in nsIFactory aFactory); - - /** - * unregisterComponent - * - * Disassociate module aLocation represented as registry location as returned - * by registryLocationForSpec() as containing ClassID aClass. - * - * @param aClass : ClassID being unregistered - * @param aLocation : Location of module. Format of this is the registry - * representation as returned by registryLocationForSpec(). - * Components of any type will be unregistered. - */ - void unregisterComponent(in nsCIDRef aClass, in string aLocation); - - /** - * unregisterComponentSpec - * - * Disassociate module references by file specification aLibrarySpec as - * containing ClassID aClass. - */ - void unregisterComponentSpec(in nsCIDRef aClass, in nsIFile aLibrarySpec); - - /** - * freeLibraries - * - * Enumerates all loaded modules and unloads unused modules. - */ - void freeLibraries(); - - /** - * ID values for 'when' - */ - const long NS_Startup = 0; - const long NS_Script = 1; - const long NS_Timer = 2; - const long NS_Shutdown = 3; - - /** - * autoRegister - * - * Enumerates directory looking for modules of all types and registers - * modules who have changed (modtime or size) since the last time - * autoRegister() was invoked. - * - * @param when : ID values of when the call is being made. - * @param directory : Directory the will be enumerated. - */ - void autoRegister(in long when, in nsIFile directory); - - /** - * autoRegisterComponent - * - * Loads module using appropriate loader and gives it an opportunity to - * register its CIDs if module's modtime or size changed since the last - * time this was called. - * - * @param when : ID values of when the call is being made. - * @param aFileLocation : File specification of module. - */ - void autoRegisterComponent(in long when, in nsIFile aFileLocation); - - /** - * autoUnregisterComponent - * - * Loads module using approriate loader and gives it an opportunity to - * unregister its CIDs - */ - void autoUnregisterComponent(in long when, in nsIFile aFileLocation); - - /** - * isRegistered - * - * Returns true if a factory or module is registered for CID aClass. - * - * @param aClass : ClassID queried for registeration - * @return : true if a factory or module is registered for CID aClass. - * false otherwise. - */ - boolean isRegistered(in nsCIDRef aClass); - - /** - * enumerateCLSIDs - * - * Enumerate the list of all registered ClassIDs. - * - * @return : enumerator for ClassIDs. - */ - nsIEnumerator enumerateCLSIDs(); - - /** - * enumerateContractIDs - * - * Enumerate the list of all registered ContractIDs. - * - * @return : enumerator for ContractIDs. - */ - nsIEnumerator enumerateContractIDs(); + void createInstanceByContractID(in string aContractID, + in nsISupports aDelegate, + in nsIIDRef aIID, + [iid_is(aIID),retval] out nsQIResult result); }; -%{ C++ -/* include after the class def'n, because it needs to see it. */ -#include "nsComponentManagerUtils.h" -%} C++ +%{ C++ +#ifndef MOZILLA_STRICT_API +#include "nsComponentManagerUtils.h" +#include "nsComponentManagerObsolete.h" +#endif +%} C++ diff --git a/mozilla/xpcom/components/nsIComponentManagerObsolete.idl b/mozilla/xpcom/components/nsIComponentManagerObsolete.idl new file mode 100644 index 00000000000..02252359e5d --- /dev/null +++ b/mozilla/xpcom/components/nsIComponentManagerObsolete.idl @@ -0,0 +1,332 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (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 "nsISupports.idl" +#include "nsIFactory.idl" + +interface nsIFile; +interface nsIEnumerator; + +[scriptable, uuid(8458a740-d5dc-11d2-92fb-00e09805570f)] +interface nsIComponentManagerObsolete : nsISupports +{ + /** + * findFactory + * + * Returns the factory object that can be used to create instances of + * CID aClass + * + * @param aClass The classid of the factory that is being requested + */ + nsIFactory findFactory(in nsCIDRef aClass); + + /** + * getClassObject + * + * @param aClass : CID of the class whose class object is requested + * @param aIID : IID of an interface that the class object is known to + * to implement. nsISupports and nsIFactory are known to + * be implemented by the class object. + */ + [noscript] voidPtr getClassObject(in nsCIDRef aClass, in nsIIDRef aIID); + + /** + * contractIDToClassID + * + * Get the ClassID for a given ContractID. Many ClassIDs may implement a + * ContractID. In such a situation, this returns the preferred ClassID, which + * happens to be the last registered ClassID. + * + * @param aContractID : Contractid for which ClassID is requested + * @return aClass : ClassID return + */ + [notxpcom] nsresult contractIDToClassID(in string aContractID, out nsCID aClass); + + /** + * classIDToContractid + * + * Get the ContractID for a given ClassID. A ClassIDs may implement multiple + * ContractIDs. This function return the last registered ContractID. + * + * @param aClass : ClassID for which ContractID is requested. + * @return aClassName : returns class name asssociated with aClass + * @return : ContractID last registered for aClass + */ + string CLSIDToContractID(in nsCIDRef aClass, out string aClassName); + + /** + * createInstance + * + * Create an instance of the CID aClass and return the interface aIID. + * + * @param aClass : ClassID of object instance requested + * @param aDelegate : Used for aggregation + * @param aIID : IID of interface requested + */ + [noscript] voidPtr createInstance(in nsCIDRef aClass, + in nsISupports aDelegate, + in nsIIDRef aIID); + + /** + * createInstanceByContractID + * + * Create an instance of the CID that implements aContractID and return the + * interface aIID. This is a convenience function that effectively does + * ContractIDToClassID() followed by CreateInstance(). + * + * @param aContractID : aContractID of object instance requested + * @param aDelegate : Used for aggregation + * @param aIID : IID of interface requested + */ + [noscript] voidPtr createInstanceByContractID(in string aContractID, + in nsISupports aDelegate, + in nsIIDRef IID); + /** + * registryLocationForSpec + * + * Given a file specification, return the registry representation of + * the filename. Files that are found relative to the components + * directory will have a registry representation + * "rel:" while filenames that are not, will have + * "abs:". + */ + string registryLocationForSpec(in nsIFile aSpec); + + /** + * specForRegistyLocation + * + * Create a file specification for the registry representation (rel:/abs:) + * got via registryLocationForSpec. + */ + nsIFile specForRegistryLocation(in string aLocation); + + /** + * registerFactory + * + * Register a factory and ContractID associated with CID aClass + * + * @param aClass : CID of object + * @param aClassName : Class Name of CID + * @param aContractID : ContractID associated with CID aClass + * @param aFactory : Factory that will be registered for CID aClass + * @param aReplace : Boolean that indicates whether to replace a previous + * registration for the CID aClass. + */ + void registerFactory(in nsCIDRef aClass, in string aClassName, + in string aContractID, in nsIFactory aFactory, + in boolean aReplace); + + /** + * registerComponent + * + * Register a native dll module via its registry representation as returned + * by registryLocationForSpec() as the container of CID implemenation + * aClass and associate aContractID and aClassName to the CID aClass. Native + * dll component type is assumed. + * + * @param aClass : CID implemenation contained in module + * @param aClassName : Class name associated with CID aClass + * @param aContractID : ContractID associated with CID aClass + * @param aLocation : Location of module (dll). Format of this is the + * registry representation as returned by + * registryLocationForSpec() + * @param aReplace : Boolean that indicates whether to replace a previous + * module registration for aClass. + * @param aPersist : Remember this registration across sessions. + */ + void registerComponent(in nsCIDRef aClass, in string aClassName, + in string aContractID, in string aLocation, + in boolean aReplace, in boolean aPersist); + + /** + * registerComponentWithType + * + * Register a module's location via its registry representation + * as returned by registryLocationForSpec() as the container of CID implemenation + * aClass of type aType and associate aContractID and aClassName to the CID aClass. + * + * @param aClass : CID implemenation contained in module + * @param aClassName : Class name associated with CID aClass + * @param aContractID : ContractID associated with CID aClass + * @param aSpec : Filename spec for module's location. + * @param aLocation : Location of module of type aType. Format of this string + * is the registry representation as returned by + * registryLocationForSpec() + * @param aReplace : Boolean that indicates whether to replace a previous + * loader registration for aClass. + * @param aPersist : Remember this registration across sessions. + * @param aType : Component Type of CID aClass. + */ + void registerComponentWithType(in nsCIDRef aClass, in string aClassName, + in string aContractID, in nsIFile aSpec, + in string aLocation, in boolean aReplace, + in boolean aPersist, in string aType); + + /** + * registerComponentSpec + * + * Register a native dll module via its file specification as the container + * of CID implemenation aClass and associate aContractID and aClassName to the + * CID aClass. Native dll component type is assumed. + * + * @param aClass : CID implemenation contained in module + * @param aClassName : Class name associated with CID aClass + * @param aContractID : ContractID associated with CID aClass + * @param aLibrary : File specification Location of module (dll). + * @param aReplace : Boolean that indicates whether to replace a previous + * module registration for aClass. + * @param aPersist : Remember this registration across sessions. + */ + void registerComponentSpec(in nsCIDRef aClass, in string aClassName, + in string aContractID, in nsIFile aLibrary, + in boolean aReplace, in boolean aPersist); + + /** + * registerComponentLib + * + * Register a native dll module via its dll name (not full path) as the + * container of CID implemenation aClass and associate aContractID and aClassName + * to the CID aClass. Native dll component type is assumed and the system + * services will be used to load this dll. + * + * @param aClass : CID implemenation contained in module + * @param aClassName : Class name associated with CID aClass + * @param aContractID : ContractID associated with CID aClass + * @param aDllNameLocation : Dll name of module. + * @param aReplace : Boolean that indicates whether to replace a previous + * module registration for aClass. + * @param aPersist : Remember this registration across sessions. + */ + void registerComponentLib(in nsCIDRef aClass, in string aClassName, + in string aContractID, in string aDllName, + in boolean aReplace, in boolean aPersist); + + /** + * unregisterFactory + * + * Unregister a factory associated with CID aClass. + * + * @param aClass : ClassID being unregistered + * @param aFactory : Factory previously registered to create instances of + * ClassID aClass. + */ + void unregisterFactory(in nsCIDRef aClass, in nsIFactory aFactory); + + /** + * unregisterComponent + * + * Disassociate module aLocation represented as registry location as returned + * by registryLocationForSpec() as containing ClassID aClass. + * + * @param aClass : ClassID being unregistered + * @param aLocation : Location of module. Format of this is the registry + * representation as returned by registryLocationForSpec(). + * Components of any type will be unregistered. + */ + void unregisterComponent(in nsCIDRef aClass, in string aLocation); + + /** + * unregisterComponentSpec + * + * Disassociate module references by file specification aLibrarySpec as + * containing ClassID aClass. + */ + void unregisterComponentSpec(in nsCIDRef aClass, in nsIFile aLibrarySpec); + + /** + * freeLibraries + * + * Enumerates all loaded modules and unloads unused modules. + */ + void freeLibraries(); + + /** + * ID values for 'when' + */ + const long NS_Startup = 0; + const long NS_Script = 1; + const long NS_Timer = 2; + const long NS_Shutdown = 3; + + /** + * autoRegister + * + * Enumerates directory looking for modules of all types and registers + * modules who have changed (modtime or size) since the last time + * autoRegister() was invoked. + * + * @param when : ID values of when the call is being made. + * @param directory : Directory the will be enumerated. + */ + void autoRegister(in long when, in nsIFile directory); + + /** + * autoRegisterComponent + * + * Loads module using appropriate loader and gives it an opportunity to + * register its CIDs if module's modtime or size changed since the last + * time this was called. + * + * @param when : ID values of when the call is being made. + * @param aFileLocation : File specification of module. + */ + void autoRegisterComponent(in long when, in nsIFile aFileLocation); + + /** + * autoUnregisterComponent + * + * Loads module using approriate loader and gives it an opportunity to + * unregister its CIDs + */ + void autoUnregisterComponent(in long when, in nsIFile aFileLocation); + + /** + * isRegistered + * + * Returns true if a factory or module is registered for CID aClass. + * + * @param aClass : ClassID queried for registeration + * @return : true if a factory or module is registered for CID aClass. + * false otherwise. + */ + boolean isRegistered(in nsCIDRef aClass); + + /** + * enumerateCLSIDs + * + * Enumerate the list of all registered ClassIDs. + * + * @return : enumerator for ClassIDs. + */ + nsIEnumerator enumerateCLSIDs(); + + /** + * enumerateContractIDs + * + * Enumerate the list of all registered ContractIDs. + * + * @return : enumerator for ContractIDs. + */ + nsIEnumerator enumerateContractIDs(); +}; + +%{ C++ +/* include after the class def'n, because it needs to see it. */ +#include "nsComponentManagerUtils.h" +%} C++ + diff --git a/mozilla/xpcom/components/nsIComponentManagerUtils.h b/mozilla/xpcom/components/nsIComponentManagerUtils.h new file mode 100644 index 00000000000..64fab080780 --- /dev/null +++ b/mozilla/xpcom/components/nsIComponentManagerUtils.h @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is XPCOM + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsIComponentManagerUtils_h__ +#define nsIComponentManagerUtils_h__ + + + +#endif diff --git a/mozilla/xpcom/components/nsNativeComponentLoader.cpp b/mozilla/xpcom/components/nsNativeComponentLoader.cpp index f8132308021..a29ecf7b58e 100644 --- a/mozilla/xpcom/components/nsNativeComponentLoader.cpp +++ b/mozilla/xpcom/components/nsNativeComponentLoader.cpp @@ -44,6 +44,10 @@ #include "nsIObserverService.h" +#ifndef OBSOLETE_MODULE_LOADING +#include "nsObsoleteModuleLoading.h" +#endif + #if defined(XP_MAC) // sdagley dougt fix #include #include @@ -372,7 +376,7 @@ nsFreeLibrary(nsDll *dll, nsIServiceManager *serviceMgr, PRInt32 when) // When shutting down, whether we can unload the dll or not, // we will shutdown the dll to release any memory it has got - if (when == nsIComponentManager::NS_Shutdown) + if (when == nsIComponentManagerObsolete::NS_Shutdown) { dll->Shutdown(); } @@ -426,7 +430,7 @@ nsFreeLibraryEnum(nsHashKey *aKey, void *aData, void* closure) struct freeLibrariesClosure *callData = (struct freeLibrariesClosure *) closure; nsFreeLibrary(dll, (callData ? callData->serviceMgr : NULL), - (callData ? callData->when : nsIComponentManager::NS_Timer)); + (callData ? callData->when : nsIComponentManagerObsolete::NS_Timer)); return PR_TRUE; } @@ -634,7 +638,13 @@ nsNativeComponentLoader::SelfUnregisterDll(nsDll *dll) if (NS_FAILED(res)) return res; // Get registry location for spec nsXPIDLCString registryName; - res = mCompMgr->RegistryLocationForSpec(fs, getter_Copies(registryName)); + + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(mCompMgr, &res); + if (obsoleteManager) + res = obsoleteManager->RegistryLocationForSpec(fs, getter_Copies(registryName)); + if (NS_FAILED(res)) return res; mobj->UnregisterSelf(mCompMgr, fs, registryName); } @@ -662,8 +672,12 @@ nsNativeComponentLoader::AutoUnregisterComponent(PRInt32 when, nsresult rv = NS_ERROR_FAILURE; nsXPIDLCString persistentDescriptor; - rv = mCompMgr->RegistryLocationForSpec(component, - getter_Copies(persistentDescriptor)); + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(mCompMgr, &rv); + if (obsoleteManager) + rv = obsoleteManager->RegistryLocationForSpec(component, + getter_Copies(persistentDescriptor)); if (NS_FAILED(rv)) return rv; // Notify observers, if any, of autoregistration work @@ -784,8 +798,12 @@ nsNativeComponentLoader::AutoRegisterComponent(PRInt32 when, return NS_OK; nsXPIDLCString persistentDescriptor; - rv = mCompMgr->RegistryLocationForSpec(component, - getter_Copies(persistentDescriptor)); + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(mCompMgr, &rv); + if (obsoleteManager) + rv = obsoleteManager->RegistryLocationForSpec(component, + getter_Copies(persistentDescriptor)); if (NS_FAILED(rv)) return rv; @@ -1132,8 +1150,12 @@ nsNativeComponentLoader::CreateDll(nsIFile *aSpec, const char *aLocation, dll = new nsDll(aLocation+4, 1 /* dumb magic flag */); if (!dll) return NS_ERROR_OUT_OF_MEMORY; } else { - rv = mCompMgr->SpecForRegistryLocation(aLocation, - getter_AddRefs(spec)); + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(mCompMgr, &rv); + if (obsoleteManager) + rv = obsoleteManager->SpecForRegistryLocation(aLocation, + getter_AddRefs(spec)); if (NS_FAILED(rv)) return rv; } diff --git a/mozilla/xpcom/components/nsObsoleteModuleLoading.h b/mozilla/xpcom/components/nsObsoleteModuleLoading.h new file mode 100644 index 00000000000..da3e7a43922 --- /dev/null +++ b/mozilla/xpcom/components/nsObsoleteModuleLoading.h @@ -0,0 +1,27 @@ + +#ifndef OBSOLETE_MODULE_LOADING +/* + * Prototypes for dynamic library export functions. Your DLL/DSO needs to export + * these methods to play in the component world. + * + * THIS IS OBSOLETE. Look at nsIModule.idl + */ + +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, + const nsCID &aClass, + const char *aClassName, + const char *aContractID, + 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 *aContractID, + nsIFactory **aFactory); +typedef PRBool (*nsCanUnloadProc)(nsISupports* aServMgr); +typedef nsresult (*nsRegisterProc)(nsISupports* aServMgr, const char *path); +typedef nsresult (*nsUnregisterProc)(nsISupports* aServMgr, const char *path); +#endif /* OBSOLETE_MODULE_LOADING */ diff --git a/mozilla/xpcom/components/nsServiceManagerObsolete.cpp b/mozilla/xpcom/components/nsServiceManagerObsolete.cpp index 08ff9eb53e5..14228950c53 100644 --- a/mozilla/xpcom/components/nsServiceManagerObsolete.cpp +++ b/mozilla/xpcom/components/nsServiceManagerObsolete.cpp @@ -1,3 +1,40 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is XPCOM + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + #include "nsIServiceManager.h" #include "nsIServiceManagerObsolete.h" #include "nsComponentManager.h" diff --git a/mozilla/xpcom/components/xcDll.cpp b/mozilla/xpcom/components/xcDll.cpp index d6a84411509..3ed80223188 100644 --- a/mozilla/xpcom/components/xcDll.cpp +++ b/mozilla/xpcom/components/xcDll.cpp @@ -418,8 +418,8 @@ nsresult nsDll::GetDllSpec(nsIFile **fsobj) nsresult nsDll::GetModule(nsISupports *servMgr, nsIModule **cobj) { - nsIComponentManager *compMgr; - nsresult rv = NS_GetGlobalComponentManager(&compMgr); + nsCOMPtr compMgr; + nsresult rv = NS_GetComponentManager(getter_AddRefs(compMgr)); NS_ASSERTION(compMgr, "Global Component Manager is null" ); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/xpcom/glue/nsComponentManagerUtils.h b/mozilla/xpcom/glue/nsComponentManagerUtils.h index 049d7d05670..50f540983da 100644 --- a/mozilla/xpcom/glue/nsComponentManagerUtils.h +++ b/mozilla/xpcom/glue/nsComponentManagerUtils.h @@ -28,32 +28,6 @@ #include "nsCOMPtr.h" #endif -#ifndef OBSOLETE_MODULE_LOADING -/* - * Prototypes for dynamic library export functions. Your DLL/DSO needs to export - * these methods to play in the component world. - * - * THIS IS OBSOLETE. Look at nsIModule.idl - */ - -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, - const nsCID &aClass, - const char *aClassName, - const char *aContractID, - 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 *aContractID, - nsIFactory **aFactory); -typedef PRBool (*nsCanUnloadProc)(nsISupports* aServMgr); -typedef nsresult (*nsRegisterProc)(nsISupports* aServMgr, const char *path); -typedef nsresult (*nsUnregisterProc)(nsISupports* aServMgr, const char *path); -#endif /* OBSOLETE_MODULE_LOADING */ #define NS_COMPONENTMANAGER_CID \ { /* 91775d60-d5dc-11d2-92fb-00e09805570f */ \ @@ -63,163 +37,43 @@ typedef nsresult (*nsUnregisterProc)(nsISupports* aServMgr, const char *path); {0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \ } -#define NS_COMPONENTMANAGER_CONTRACTID "@mozilla.org/xpcom/componentmanager;1" - -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 { +class NS_COM nsCreateInstanceByCID : public nsCOMPtr_helper +{ public: - static nsresult Initialize(void); - - // Finds a factory for a specific class ID - static nsresult FindFactory(const nsCID &aClass, - nsIFactory **aFactory); - - // Get the singleton class object that implements the CID aClass - static nsresult GetClassObject(const nsCID &aClass, const nsIID &aIID, - void **aResult); - - // Finds a class ID for a specific Program ID - static nsresult ContractIDToClassID(const char *aContractID, - nsCID *aClass); - - // Finds a Program ID for a specific class ID - // caller frees the result with delete[] - static nsresult CLSIDToContractID(nsCID *aClass, - char* *aClassName, - char* *aContractID); - - // 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 ContractID - static nsresult CreateInstance(const char *aContractID, - 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 *aContractID, - nsIFactory *aFactory, - PRBool aReplace); - - // Manually register a dynamically loaded component. - // The libraryPersistentDescriptor is what gets passed to the library - // self register function from ComponentManager. The format of this string - // is the same as nsIFile::GetPath() - // - // This function will go away in favour of RegisterComponentSpec. In fact, - // it internally turns around and calls RegisterComponentSpec. - static nsresult RegisterComponent(const nsCID &aClass, - const char *aClassName, - const char *aContractID, - const char *aLibraryPersistentDescriptor, - PRBool aReplace, - PRBool aPersist); - - // Register a component using its FileSpec as its identification - // This is the more prevalent use. - static nsresult RegisterComponentSpec(const nsCID &aClass, - const char *aClassName, - const char *aContractID, - nsIFile *aLibrary, - PRBool aReplace, - PRBool aPersist); - - // Register a component using its dllName. This could be a dll name with - // no path so that LD_LIBRARY_PATH on unix or PATH on win can load it. Or - // this could be a code fragment name on the Mac. - static nsresult RegisterComponentLib(const nsCID &aClass, - const char *aClassName, - const char *aContractID, - const char *adllName, - PRBool aReplace, - PRBool aPersist); - - - // Manually unregister a factory for a class - static nsresult UnregisterFactory(const nsCID &aClass, - nsIFactory *aFactory); - - // Manually unregister a dynamically loaded component - static nsresult UnregisterComponent(const nsCID &aClass, - const char *aLibrary); - - // Manually unregister a dynamically loaded component - static nsresult UnregisterComponentSpec(const nsCID &aClass, - nsIFile *aLibrarySpec); - - // Unload dynamically loaded factories that are not in use - static nsresult FreeLibraries(void); - ////////////////////////////////////////////////////////////////////////////// - // DLL registration support - - // If directory is NULL, then AutoRegister will try registering components - // in the default components directory. - static nsresult AutoRegister(PRInt32 when, nsIFile* directory); - static nsresult AutoRegisterComponent(PRInt32 when, nsIFile *component); - static nsresult AutoUnregisterComponent(PRInt32 when, nsIFile *component); - - // Is the given CID currently registered? - static nsresult IsRegistered(const nsCID &aClass, - PRBool *aRegistered); - - // Get an enumeration of all the CIDs - static nsresult EnumerateCLSIDs(nsIEnumerator** aEmumerator); + nsCreateInstanceByCID( const nsCID& aCID, nsISupports* aOuter, nsresult* aErrorPtr ) + : mCID(aCID), + mOuter(aOuter), + mErrorPtr(aErrorPtr) + { + // nothing else to do here + } - // Get an enumeration of all the ContractIDs - static nsresult EnumerateContractIDs(nsIEnumerator** aEmumerator); - + virtual nsresult operator()( const nsIID&, void** ) const; + +private: + const nsCID& mCID; + nsISupports* mOuter; + nsresult* mErrorPtr; }; - -class NS_COM nsCreateInstanceByCID : public nsCOMPtr_helper - { - public: - nsCreateInstanceByCID( const nsCID& aCID, nsISupports* aOuter, nsresult* aErrorPtr ) - : mCID(aCID), - mOuter(aOuter), - mErrorPtr(aErrorPtr) - { - // nothing else to do here - } - - virtual nsresult operator()( const nsIID&, void** ) const; - - private: - const nsCID& mCID; - nsISupports* mOuter; - nsresult* mErrorPtr; - }; - class NS_COM nsCreateInstanceByContractID : public nsCOMPtr_helper - { - public: - nsCreateInstanceByContractID( const char* aContractID, nsISupports* aOuter, nsresult* aErrorPtr ) - : mContractID(aContractID), - mOuter(aOuter), - mErrorPtr(aErrorPtr) +{ +public: + nsCreateInstanceByContractID( const char* aContractID, nsISupports* aOuter, nsresult* aErrorPtr ) + : mContractID(aContractID), + mOuter(aOuter), + mErrorPtr(aErrorPtr) { // nothing else to do here } - - virtual nsresult operator()( const nsIID&, void** ) const; - - private: - const char* mContractID; - nsISupports* mOuter; - nsresult* mErrorPtr; - }; + + virtual nsresult operator()( const nsIID&, void** ) const; + +private: + const char* mContractID; + nsISupports* mOuter; + nsresult* mErrorPtr; +}; class NS_COM nsCreateInstanceFromCategory : public nsCOMPtr_helper { @@ -234,7 +88,7 @@ public: } virtual nsresult operator()( const nsIID&, void** ) const; virtual ~nsCreateInstanceFromCategory() {}; - + private: const char *mCategory; const char *mEntry; @@ -245,30 +99,30 @@ private: inline const nsCreateInstanceByCID do_CreateInstance( const nsCID& aCID, nsresult* error = 0 ) - { - return nsCreateInstanceByCID(aCID, 0, error); - } +{ + return nsCreateInstanceByCID(aCID, 0, error); +} inline const nsCreateInstanceByCID do_CreateInstance( const nsCID& aCID, nsISupports* aOuter, nsresult* error = 0 ) - { - return nsCreateInstanceByCID(aCID, aOuter, error); - } +{ + return nsCreateInstanceByCID(aCID, aOuter, error); +} inline const nsCreateInstanceByContractID do_CreateInstance( const char* aContractID, nsresult* error = 0 ) - { - return nsCreateInstanceByContractID(aContractID, 0, error); - } +{ + return nsCreateInstanceByContractID(aContractID, 0, error); +} inline const nsCreateInstanceByContractID do_CreateInstance( const char* aContractID, nsISupports* aOuter, nsresult* error = 0 ) - { - return nsCreateInstanceByContractID(aContractID, aOuter, error); - } +{ + return nsCreateInstanceByContractID(aContractID, aOuter, error); +} inline const nsCreateInstanceFromCategory @@ -293,26 +147,26 @@ nsresult CallCreateInstance( const nsCID &aClass, nsISupports *aDelegate, DestinationType** aDestination ) - { +{ NS_PRECONDITION(aDestination, "null parameter"); - + return nsComponentManager::CreateInstance(aClass, aDelegate, - NS_GET_IID(DestinationType), - NS_REINTERPRET_CAST(void**, aDestination)); - } + NS_GET_IID(DestinationType), + NS_REINTERPRET_CAST(void**, aDestination)); +} template inline nsresult CallCreateInstance( const nsCID &aClass, DestinationType** aDestination ) - { +{ NS_PRECONDITION(aDestination, "null parameter"); - + return nsComponentManager::CreateInstance(aClass, nsnull, - NS_GET_IID(DestinationType), - NS_REINTERPRET_CAST(void**, aDestination)); - } + NS_GET_IID(DestinationType), + NS_REINTERPRET_CAST(void**, aDestination)); +} template inline @@ -320,28 +174,29 @@ nsresult CallCreateInstance( const char *aContractID, nsISupports *aDelegate, DestinationType** aDestination ) - { +{ NS_PRECONDITION(aContractID, "null parameter"); NS_PRECONDITION(aDestination, "null parameter"); - - return nsComponentManager::CreateInstance(aContractID, aDelegate, - NS_GET_IID(DestinationType), - NS_REINTERPRET_CAST(void**, aDestination)); - } + + return nsComponentManager::CreateInstance(aContractID, + aDelegate, + NS_GET_IID(DestinationType), + NS_REINTERPRET_CAST(void**, aDestination)); +} template inline nsresult CallCreateInstance( const char *aContractID, DestinationType** aDestination ) - { +{ NS_PRECONDITION(aContractID, "null parameter"); NS_PRECONDITION(aDestination, "null parameter"); - + return nsComponentManager::CreateInstance(aContractID, nsnull, - NS_GET_IID(DestinationType), - NS_REINTERPRET_CAST(void**, aDestination)); - } + NS_GET_IID(DestinationType), + NS_REINTERPRET_CAST(void**, aDestination)); +} /* keys for registry use */ extern const char xpcomKeyName[]; @@ -352,3 +207,5 @@ extern const char nativeComponentType[]; extern const char staticComponentType[]; #endif /* nsComponentManagerUtils_h__ */ + + diff --git a/mozilla/xpcom/glue/nsGenericFactory.cpp b/mozilla/xpcom/glue/nsGenericFactory.cpp index e20643604ec..174752218ca 100644 --- a/mozilla/xpcom/glue/nsGenericFactory.cpp +++ b/mozilla/xpcom/glue/nsGenericFactory.cpp @@ -43,7 +43,7 @@ #include "nsCRT.h" #include "nsCOMPtr.h" #include "nsIComponentManager.h" - +#include "nsIComponentManagerObsolete.h" nsGenericFactory::nsGenericFactory(nsModuleComponentInfo *info) : mInfo(info) { @@ -358,11 +358,15 @@ nsGenericModule::RegisterSelf(nsIComponentManager *aCompMgr, for (PRUint32 i = 0; i < mComponentCount; i++) { // Register the component only if it has a constructor if (cp->mConstructor) { - rv = aCompMgr->RegisterComponentWithType(cp->mCID, - cp->mDescription, - cp->mContractID, aPath, - registryLocation, PR_TRUE, - PR_TRUE, componentType); + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(aCompMgr, &rv); + if (obsoleteManager) + rv = obsoleteManager->RegisterComponentWithType(cp->mCID, + cp->mDescription, + cp->mContractID, aPath, + registryLocation, PR_TRUE, + PR_TRUE, componentType); if (NS_FAILED(rv)) { #ifdef DEBUG printf("nsGenericModule %s: unable to register %s component => %x\n", @@ -405,8 +409,15 @@ nsGenericModule::UnregisterSelf(nsIComponentManager* aCompMgr, { cp->mUnregisterSelfProc(aCompMgr, aPath, registryLocation, cp); } + // Unregister the component - nsresult rv = aCompMgr->UnregisterComponentSpec(cp->mCID, aPath); + + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsresult rv; + nsCOMPtr obsoleteManager = do_QueryInterface(aCompMgr, &rv); + if (obsoleteManager) + rv = obsoleteManager->UnregisterComponentSpec(cp->mCID, aPath); if (NS_FAILED(rv)) { #ifdef DEBUG printf("nsGenericModule %s: unable to unregister %s component => %x\n", diff --git a/mozilla/xpcom/io/nsLocalFileMac.cpp b/mozilla/xpcom/io/nsLocalFileMac.cpp index 450f591229e..17170868bba 100644 --- a/mozilla/xpcom/io/nsLocalFileMac.cpp +++ b/mozilla/xpcom/io/nsLocalFileMac.cpp @@ -2469,18 +2469,19 @@ NS_IMETHODIMP nsLocalFile::GetURL(char * *aURL) // Escape the path with the directory mask rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath); if (NS_SUCCEEDED(rv)) { - - escPath.Insert("file:///", 0); - + if (escPath[escPath.Length() - 1] != '/') { PRBool dir; rv = IsDirectory(&dir); NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); - if (NS_SUCCEEDED(rv) && dir && escPath[escPath.Length() - 1] != '/') { - // make sure we have a trailing slash - escPath += "/"; - } - *aURL = ToNewCString(escPath); - rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY; + if (NS_SUCCEEDED(rv) && dir && ) { + // make sure we have a trailing slash + escPath += "/"; + } + } + escPath.Insert("file:///", 0); + + *aURL = ToNewCString(escPath); + rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } } CRTFREEIF(ePath); diff --git a/mozilla/xpcom/io/nsLocalFileUnix.cpp b/mozilla/xpcom/io/nsLocalFileUnix.cpp index 628e2bd1fe0..e5a479cf72c 100644 --- a/mozilla/xpcom/io/nsLocalFileUnix.cpp +++ b/mozilla/xpcom/io/nsLocalFileUnix.cpp @@ -1492,16 +1492,18 @@ NS_IMETHODIMP nsLocalFile::GetURL(char * *aURL) // Escape the path with the directory mask rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath); if (NS_SUCCEEDED(rv)) { - + if (escPath[escPath.Length() - 1] != '/') { + PRBool dir; + rv = IsDirectory(&dir); + NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); + if (NS_SUCCEEDED(rv) && dir && ) { + // make sure we have a trailing slash + escPath += "/"; + } + } + escPath.Insert("file://", 0); - PRBool dir; - rv = IsDirectory(&dir); - NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); - if (NS_SUCCEEDED(rv) && dir && escPath[escPath.Length() - 1] != '/') { - // make sure we have a trailing slash - escPath += "/"; - } *aURL = ToNewCString(escPath); rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/xpcom/io/nsLocalFileWin.cpp b/mozilla/xpcom/io/nsLocalFileWin.cpp index 5af5b9721da..df016a57a41 100644 --- a/mozilla/xpcom/io/nsLocalFileWin.cpp +++ b/mozilla/xpcom/io/nsLocalFileWin.cpp @@ -300,7 +300,6 @@ nsLocalFile::MakeDirty() // this function will walk the native path of |this| resolving any symbolic // links found. The new resulting path will be placed into mResolvedPath. //---------------------------------------------------------------------------------------- - nsresult nsLocalFile::ResolvePath(const char* workingPath, PRBool resolveTerminal, char** resolvedPath) { @@ -589,13 +588,10 @@ NS_IMETHODIMP nsLocalFile::Clone(nsIFile **file) { nsresult rv; - char * aFilePath; - GetPath(&aFilePath); - + nsCOMPtr localFile; - rv = NS_NewLocalFile(aFilePath, mFollowSymlinks, getter_AddRefs(localFile)); - nsMemory::Free(aFilePath); + rv = NS_NewLocalFile(mWorkingPath.get(), mFollowSymlinks, getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv) && localFile) { @@ -1862,19 +1858,19 @@ NS_IMETHODIMP nsLocalFile::GetURL(char * *aURL) // Escape the path with the directory mask rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath); if (NS_SUCCEEDED(rv)) { - - escPath.Insert("file:///", 0); - - PRBool dir; - rv = IsDirectory(&dir); - NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); - if (NS_SUCCEEDED(rv) && dir && escPath[escPath.Length() - 1] != '/') { - // make sure we have a trailing slash - escPath += "/"; + if (escPath[escPath.Length() - 1] != '/') { + PRBool dir; + rv = IsDirectory(&dir); + NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); + if (NS_SUCCEEDED(rv) && dir) { + // make sure we have a trailing slash + escPath += "/"; + } } + escPath.Insert("file:///", 0); *aURL = ToNewCString(escPath); rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY; - } + } } CRTFREEIF(ePath); return rv; diff --git a/mozilla/xpcom/macbuild/XPCOMIDL.xml b/mozilla/xpcom/macbuild/XPCOMIDL.xml index 1dba84e9a35..3dd483cf867 100644 --- a/mozilla/xpcom/macbuild/XPCOMIDL.xml +++ b/mozilla/xpcom/macbuild/XPCOMIDL.xml @@ -906,6 +906,13 @@ Text + + Name + nsIComponentManagerObsolete.idl + MacOS + Text + + Name nsIRunnable.idl @@ -1343,6 +1350,13 @@ nsIComponentLoader.idl MacOS + + Name + nsIComponentManagerObsolete.idl + MacOS + Text + + Name nsIComponentManager.idl @@ -2453,6 +2467,13 @@ Text + + Name + nsIComponentManagerObsolete.idl + MacOS + Text + + Name nsIRunnable.idl @@ -2895,6 +2916,11 @@ nsIComponentManager.idl MacOS + + Name + nsIComponentManagerObsolete.idl + MacOS + Name nsIRunnable.idl @@ -3221,6 +3247,12 @@ nsIComponentManager.idl MacOS + + headers + Name + nsIComponentManagerObsolete.idl + MacOS + headers Name diff --git a/mozilla/xpcom/macbuild/xpcomPPC.xml b/mozilla/xpcom/macbuild/xpcomPPC.xml index 480dd491c49..a3602f2c3e9 100644 --- a/mozilla/xpcom/macbuild/xpcomPPC.xml +++ b/mozilla/xpcom/macbuild/xpcomPPC.xml @@ -1156,6 +1156,13 @@ Text Debug + + Name + nsComponentManagerObsolete.cpp + MacOS + Text + Debug + Name nsEmptyEnumerator.cpp @@ -1974,6 +1981,11 @@ nsComponentManager.cpp MacOS + + Name + nsComponentManagerObsolete.cpp + MacOS + Name nsEmptyEnumerator.cpp @@ -3596,6 +3608,13 @@ Text Debug + + Name + nsComponentManagerObsolete.cpp + MacOS + Text + Debug + Name nsEmptyEnumerator.cpp @@ -4419,6 +4438,11 @@ nsComponentManager.cpp MacOS + + Name + nsComponentManagerObsolete.cpp + MacOS + Name nsEmptyEnumerator.cpp @@ -5054,6 +5078,12 @@ nsComponentManager.cpp MacOS + + xpcom.shlb + Name + nsComponentManagerObsolete.cpp + MacOS + xpcom.shlb Name diff --git a/mozilla/xpcom/proxy/src/nsProxyEvent.cpp b/mozilla/xpcom/proxy/src/nsProxyEvent.cpp index 57036a1e9b7..2bb50105ae0 100644 --- a/mozilla/xpcom/proxy/src/nsProxyEvent.cpp +++ b/mozilla/xpcom/proxy/src/nsProxyEvent.cpp @@ -41,6 +41,7 @@ #include "xptcall.h" #include "nsIComponentManager.h" +#include "nsComponentManagerObsolete.h" #include "nsIServiceManager.h" #include "nsMemory.h" #include "nsIEventQueueService.h" diff --git a/mozilla/xpcom/proxy/src/nsProxyObjectManager.cpp b/mozilla/xpcom/proxy/src/nsProxyObjectManager.cpp index 7ea45734aea..7c947ea2ff8 100644 --- a/mozilla/xpcom/proxy/src/nsProxyObjectManager.cpp +++ b/mozilla/xpcom/proxy/src/nsProxyObjectManager.cpp @@ -55,6 +55,7 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" +#include "nsComponentManagerObsolete.h" #include "nsCOMPtr.h" #include "nsIEventQueueService.h" diff --git a/mozilla/xpcom/proxy/tests/proxytests.cpp b/mozilla/xpcom/proxy/tests/proxytests.cpp index a2d3482a32e..8774e001db3 100644 --- a/mozilla/xpcom/proxy/tests/proxytests.cpp +++ b/mozilla/xpcom/proxy/tests/proxytests.cpp @@ -58,7 +58,7 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); extern "C" void NS_SetupRegistry() { - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL /* default */); + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); } diff --git a/mozilla/xpcom/sample/nsSample.cpp b/mozilla/xpcom/sample/nsSample.cpp index 55a44f3de16..b47b0620b63 100644 --- a/mozilla/xpcom/sample/nsSample.cpp +++ b/mozilla/xpcom/sample/nsSample.cpp @@ -53,7 +53,7 @@ nsSampleImpl::nsSampleImpl() : mValue(nsnull) { - NS_INIT_REFCNT(); + NS_INIT_ISUPPORTS(); mValue = PL_strdup("initial value"); } diff --git a/mozilla/xpcom/sample/nsSample.js b/mozilla/xpcom/sample/nsSample.js index 18b47867d5f..989724f11d4 100644 --- a/mozilla/xpcom/sample/nsSample.js +++ b/mozilla/xpcom/sample/nsSample.js @@ -65,6 +65,7 @@ var myModule = { throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN; } dump("*** Registering sample JS components\n"); + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); compMgr.registerComponentWithType(this.myCID, "Sample JS Component", this.myProgID, fileSpec, diff --git a/mozilla/xpcom/sample/nsTestSample.cpp b/mozilla/xpcom/sample/nsTestSample.cpp index 78be36285e4..77747f2c79b 100644 --- a/mozilla/xpcom/sample/nsTestSample.cpp +++ b/mozilla/xpcom/sample/nsTestSample.cpp @@ -72,7 +72,7 @@ main(void) // To break free from such dependencies, we can GetService() the component // manager from the service manager that is returned from NS_InitXPCOM(). // We feel that linkage dependency to XPCOM library is inevitable. - (void) nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsnull); + (void) nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull); // Create an instance of our component nsCOMPtr mysample = do_CreateInstance(NS_SAMPLE_CONTRACTID, &rv); diff --git a/mozilla/xpcom/tests/PropertiesTest.cpp b/mozilla/xpcom/tests/PropertiesTest.cpp index ad56e1bf1be..e9f2b4bafd0 100644 --- a/mozilla/xpcom/tests/PropertiesTest.cpp +++ b/mozilla/xpcom/tests/PropertiesTest.cpp @@ -83,7 +83,7 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); extern "C" void NS_SetupRegistry() { - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); // startup netlib: diff --git a/mozilla/xpcom/tests/RegFactory.cpp b/mozilla/xpcom/tests/RegFactory.cpp index f6ee222d1a7..252312a9ae9 100644 --- a/mozilla/xpcom/tests/RegFactory.cpp +++ b/mozilla/xpcom/tests/RegFactory.cpp @@ -71,7 +71,7 @@ nsresult Register(const char *path) if (NS_FAILED(res)) return res; res = spec->SetNativePath((char *)path); if (NS_FAILED(res)) return res; - res = nsComponentManager::AutoRegisterComponent(nsIComponentManager::NS_Startup, spec); + res = nsComponentManager::AutoRegisterComponent(nsIComponentManagerObsolete::NS_Startup, spec); return res; } @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) if (argc <= 1) { nsresult rv = nsComponentManager::AutoRegister( - nsIComponentManager::NS_Startup, + nsIComponentManagerObsolete::NS_Startup, NULL /* default location */); ret = (NS_FAILED(rv)) ? -1 : 0; } diff --git a/mozilla/xpcom/tests/TestFactory.cpp b/mozilla/xpcom/tests/TestFactory.cpp index 5d8ccc43010..3441fa39812 100644 --- a/mozilla/xpcom/tests/TestFactory.cpp +++ b/mozilla/xpcom/tests/TestFactory.cpp @@ -48,7 +48,7 @@ NS_DEFINE_CID(kTestLoadedFactoryCID, NS_TESTLOADEDFACTORY_CID); int main(int argc, char **argv) { nsresult rv; - rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, + rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/xpcom/tests/nsIFileEnumerator.cpp b/mozilla/xpcom/tests/nsIFileEnumerator.cpp index 550107445c2..a980a41ced4 100644 --- a/mozilla/xpcom/tests/nsIFileEnumerator.cpp +++ b/mozilla/xpcom/tests/nsIFileEnumerator.cpp @@ -63,7 +63,7 @@ main(int argc, char* argv[]) rv = NS_InitXPCOM2(nsnull, nsnull, nsnull); if (NS_FAILED(rv)) return -1; - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL); + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL); if (argc > 1 && argv[1] != nsnull) { diff --git a/mozilla/xpcom/tests/nsIFileTest.cpp b/mozilla/xpcom/tests/nsIFileTest.cpp index 6e9f49176da..be2803b217e 100644 --- a/mozilla/xpcom/tests/nsIFileTest.cpp +++ b/mozilla/xpcom/tests/nsIFileTest.cpp @@ -66,7 +66,7 @@ void GetPaths(nsILocalFile* file) extern "C" void NS_SetupRegistry() { - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, NULL); + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL); } void InitTest(const char* creationPath, const char* appendPath) diff --git a/mozilla/xpcom/tests/windows/TestHelloXPLoop.cpp b/mozilla/xpcom/tests/windows/TestHelloXPLoop.cpp index 198c9018d4c..3803bc126b0 100644 --- a/mozilla/xpcom/tests/windows/TestHelloXPLoop.cpp +++ b/mozilla/xpcom/tests/windows/TestHelloXPLoop.cpp @@ -57,7 +57,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prevInstance, LPSTR lpszCmdLine, return -1; } - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsnull); + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull); nsCOMPtr nativeAppService(do_GetService(kNativeAppCID, &rv)); diff --git a/mozilla/xpcom/threads/makefile.win b/mozilla/xpcom/threads/makefile.win index 45455aee694..9a30819f7bb 100644 --- a/mozilla/xpcom/threads/makefile.win +++ b/mozilla/xpcom/threads/makefile.win @@ -32,7 +32,7 @@ REQUIRES = string \ EXPORTS = \ nsAutoLock.h \ plevent.h \ - nsProcess.h \ + nsProcess.h \ nsITimer.h \ nsITimerCallback.h \ $(NULL) diff --git a/mozilla/xpcom/tools/registry/regxpcom.cpp b/mozilla/xpcom/tools/registry/regxpcom.cpp index 667b72b97c4..2baf4d2988d 100644 --- a/mozilla/xpcom/tools/registry/regxpcom.cpp +++ b/mozilla/xpcom/tools/registry/regxpcom.cpp @@ -68,7 +68,7 @@ nsresult Register(const char *path) rv = spec->InitWithPath(path); if (NS_FAILED(rv)) return rv; - rv = nsComponentManager::AutoRegisterComponent(nsIComponentManager::NS_Startup, spec); + rv = nsComponentManager::AutoRegisterComponent(nsIComponentManagerObsolete::NS_Startup, spec); return rv; } @@ -88,7 +88,7 @@ nsresult Unregister(const char *path) rv = spec->InitWithPath(path); if (NS_FAILED(rv)) return rv; - rv = nsComponentManager::AutoUnregisterComponent(nsIComponentManager::NS_Startup, spec); + rv = nsComponentManager::AutoUnregisterComponent(nsIComponentManagerObsolete::NS_Startup, spec); return rv; } @@ -189,7 +189,7 @@ int main(int argc, char *argv[]) if (argc <= 1) { nsresult rv = nsComponentManager::AutoRegister( - nsIComponentManager::NS_Startup, + nsIComponentManagerObsolete::NS_Startup, NULL /* default location */); ret = (NS_FAILED(rv)) ? -1 : 0; } diff --git a/mozilla/xpfe/appshell/src/nsCloseAllWindows.js b/mozilla/xpfe/appshell/src/nsCloseAllWindows.js index 06e3f61747f..502718a90e6 100644 --- a/mozilla/xpfe/appshell/src/nsCloseAllWindows.js +++ b/mozilla/xpfe/appshell/src/nsCloseAllWindows.js @@ -92,6 +92,7 @@ var module = { this.firstTime = false; throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN; } + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); compMgr.registerComponentWithType( this.cid, "Close All Windows", this.contractId, diff --git a/mozilla/xpfe/bootstrap/nsSetupRegistry.cpp b/mozilla/xpfe/bootstrap/nsSetupRegistry.cpp index fce4f81df8a..08cb1fee399 100644 --- a/mozilla/xpfe/bootstrap/nsSetupRegistry.cpp +++ b/mozilla/xpfe/bootstrap/nsSetupRegistry.cpp @@ -52,7 +52,7 @@ extern "C" void NS_SetupRegistry_1( PRBool needAutoreg ) { if ( needAutoreg ) - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */); /* diff --git a/mozilla/xpfe/components/console/jsconsole-clhandler.js b/mozilla/xpfe/components/console/jsconsole-clhandler.js index f09e621d672..0c13211a3ed 100644 --- a/mozilla/xpfe/components/console/jsconsole-clhandler.js +++ b/mozilla/xpfe/components/console/jsconsole-clhandler.js @@ -58,6 +58,8 @@ jsConsoleHandler.prototype = { /* jsConsoleHandler Module (for XPCOM registration) */ var jsConsoleHandlerModule = { registerSelf: function(compMgr, fileSpec, location, type) { + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.registerComponentWithType(JSCONSOLEHANDLER_CID, 'JS Console Commandline Handler component', JSCONSOLEHANDLER_CONTRACTID, fileSpec, @@ -70,6 +72,7 @@ var jsConsoleHandlerModule = { }, unregisterSelf: function(compMgr, fileSpec, location) { + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); compMgr.unregisterComponentSpec(JSCONSOLEHANDLER_CID, fileSpec); var catman = Components.classes["@mozilla.org/categorymanager;1"] .getService(Components.interfaces.nsICategoryManager); diff --git a/mozilla/xpfe/components/filepicker/src/nsFilePicker.js b/mozilla/xpfe/components/filepicker/src/nsFilePicker.js index 03d6ca753da..84a5eaca08e 100644 --- a/mozilla/xpfe/components/filepicker/src/nsFilePicker.js +++ b/mozilla/xpfe/components/filepicker/src/nsFilePicker.js @@ -207,6 +207,8 @@ filePickerModule.registerSelf = function (compMgr, fileSpec, location, type) { debug("registering (all right -- a JavaScript module!)"); + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.registerComponentWithType(FILEPICKER_CID, "FilePicker JS Component", FILEPICKER_CONTRACTID, fileSpec, location, true, true, type); diff --git a/mozilla/xpfe/components/filepicker/src/nsFilePicker.js.in b/mozilla/xpfe/components/filepicker/src/nsFilePicker.js.in index 03d6ca753da..84a5eaca08e 100644 --- a/mozilla/xpfe/components/filepicker/src/nsFilePicker.js.in +++ b/mozilla/xpfe/components/filepicker/src/nsFilePicker.js.in @@ -207,6 +207,8 @@ filePickerModule.registerSelf = function (compMgr, fileSpec, location, type) { debug("registering (all right -- a JavaScript module!)"); + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.registerComponentWithType(FILEPICKER_CID, "FilePicker JS Component", FILEPICKER_CONTRACTID, fileSpec, location, true, true, type); diff --git a/mozilla/xpfe/components/sidebar/src/nsSidebar.js b/mozilla/xpfe/components/sidebar/src/nsSidebar.js index 927bfb0b72c..a7c9c4427e0 100644 --- a/mozilla/xpfe/components/sidebar/src/nsSidebar.js +++ b/mozilla/xpfe/components/sidebar/src/nsSidebar.js @@ -345,6 +345,8 @@ sidebarModule.registerSelf = function (compMgr, fileSpec, location, type) { debug("registering (all right -- a JavaScript module!)"); + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); + compMgr.registerComponentWithType(SIDEBAR_CID, "Sidebar JS Component", SIDEBAR_CONTRACTID, fileSpec, location, true, true, type); diff --git a/mozilla/xpfe/components/startup/src/nsCloseAllWindows.js b/mozilla/xpfe/components/startup/src/nsCloseAllWindows.js index 06e3f61747f..502718a90e6 100644 --- a/mozilla/xpfe/components/startup/src/nsCloseAllWindows.js +++ b/mozilla/xpfe/components/startup/src/nsCloseAllWindows.js @@ -92,6 +92,7 @@ var module = { this.firstTime = false; throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN; } + compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete); compMgr.registerComponentWithType( this.cid, "Close All Windows", this.contractId, diff --git a/mozilla/xpinstall/src/nsSoftwareUpdate.cpp b/mozilla/xpinstall/src/nsSoftwareUpdate.cpp index 3b0fbda810f..aaec175b7b4 100644 --- a/mozilla/xpinstall/src/nsSoftwareUpdate.cpp +++ b/mozilla/xpinstall/src/nsSoftwareUpdate.cpp @@ -435,7 +435,7 @@ nsSoftwareUpdate::StartupTasks( PRBool *needAutoreg ) // is not the actual BuildID, or if we couldn't get the BuildID if ( autoReg || NS_FAILED(rv) || buildID != NS_BUILD_ID ) { - rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup,0); + rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,0); if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/xpinstall/standalone/standalone.cpp b/mozilla/xpinstall/standalone/standalone.cpp index 48465320b16..422aae13346 100644 --- a/mozilla/xpinstall/standalone/standalone.cpp +++ b/mozilla/xpinstall/standalone/standalone.cpp @@ -63,7 +63,7 @@ static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID); extern "C" void NS_SetupRegistry() { - nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, + nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull /* default */); } /***************************************************************************/ diff --git a/mozilla/xpinstall/stub/xpistub.cpp b/mozilla/xpinstall/stub/xpistub.cpp index ac8a40174e7..3edf06fe2dd 100644 --- a/mozilla/xpinstall/stub/xpistub.cpp +++ b/mozilla/xpinstall/stub/xpistub.cpp @@ -155,10 +155,10 @@ PR_PUBLIC_API(nsresult) XPI_Init( return rv; #if defined(XP_UNIX) || defined(XP_MAC) - rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, + rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, compDir); #else - rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, + rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull); #endif if (NS_FAILED(rv))