diff --git a/mozilla/base/public/nsFileSpec.h b/mozilla/base/public/nsFileSpec.h index 41f1bbff0ec..1f5a33eee18 100644 --- a/mozilla/base/public/nsFileSpec.h +++ b/mozilla/base/public/nsFileSpec.h @@ -303,7 +303,7 @@ class NS_BASE nsFileSpec relativePath(inRelativePath); return *this + relativePath; } - void operator += (const char* inRelativePath); + void operator += (const char* inRelativePath); // Concatenate the relative path to this directory. // Used for constructing the filespec of a descendant. // This must be a directory for this to work. This differs @@ -312,7 +312,7 @@ class NS_BASE nsFileSpec // away its leaf information, whereas this one assumes // this is a directory, and the relative path starts // "below" this. - void operator += (const nsString& inRelativePath) + void operator += (const nsString& inRelativePath) { const nsAutoCString relativePath(inRelativePath); *this += relativePath; diff --git a/mozilla/base/src/nsBaseDLL.cpp b/mozilla/base/src/nsBaseDLL.cpp index df3c430f17e..b36dd7479a0 100644 --- a/mozilla/base/src/nsBaseDLL.cpp +++ b/mozilla/base/src/nsBaseDLL.cpp @@ -20,7 +20,10 @@ #include "nscore.h" #include "nsIProperties.h" #include "nsProperties.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" +#include "nsIServiceManager.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); PRInt32 gLockCount = 0; @@ -29,28 +32,26 @@ NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char* path) { - nsresult ret; + nsresult rv; - ret = nsRepository::RegisterComponent(kPropertiesCID, NULL, NULL, - path, PR_TRUE, PR_TRUE); - if (NS_FAILED(ret)) { - return ret; - } + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; - return ret; + rv = compMgr->RegisterComponent(kPropertiesCID, NULL, NULL, + path, PR_TRUE, PR_TRUE); + return rv; } extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char* path) { - nsresult ret; + nsresult rv; - ret = nsRepository::UnregisterFactory(kPropertiesCID, path); - if (NS_FAILED(ret)) { - return ret; - } + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; - return ret; + rv = compMgr->UnregisterFactory(kPropertiesCID, path); + return rv; } extern "C" NS_EXPORT nsresult diff --git a/mozilla/base/tests/PropertiesTest.cpp b/mozilla/base/tests/PropertiesTest.cpp index a780f7a7a3a..484df199998 100644 --- a/mozilla/base/tests/PropertiesTest.cpp +++ b/mozilla/base/tests/PropertiesTest.cpp @@ -24,7 +24,7 @@ #include "nsIProperties.h" #include "nsIServiceManager.h" #include "nsIURL.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #ifdef XP_PC #include "plevent.h" #endif @@ -60,9 +60,9 @@ extern "C" void NS_SetupRegistry(); int main(int argc, char *argv[]) { - nsRepository::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, + nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, + nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); #ifdef XP_MAC // have not build this on PC and UNIX yet so make it #ifdef XP_MAC NS_SetupRegistry(); @@ -102,7 +102,7 @@ main(int argc, char *argv[]) return 1; } nsIProperties *props = nsnull; - ret = nsRepository::CreateInstance(kPropertiesCID, NULL, + ret = nsComponentManager::CreateInstance(kPropertiesCID, NULL, kIPropertiesIID, (void**) &props); if (NS_FAILED(ret)) { printf("create nsIProperties failed\n"); diff --git a/mozilla/caps/src/nsCCapsManager.cpp b/mozilla/caps/src/nsCCapsManager.cpp index 59955c15302..0e923b06263 100644 --- a/mozilla/caps/src/nsCCapsManager.cpp +++ b/mozilla/caps/src/nsCCapsManager.cpp @@ -15,7 +15,7 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsCapsEnums.h" #include "nsCCapsManager.h" #include "nsICodebasePrincipal.h" diff --git a/mozilla/caps/src/nsCCapsManagerFactory.cpp b/mozilla/caps/src/nsCCapsManagerFactory.cpp index 2df2d98235d..07e9ea57f91 100644 --- a/mozilla/caps/src/nsCCapsManagerFactory.cpp +++ b/mozilla/caps/src/nsCCapsManagerFactory.cpp @@ -22,7 +22,7 @@ #include "nsCCapsManager.h" #include "nsCCapsManagerFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); @@ -137,7 +137,7 @@ nsCCapsManagerFactory::nsCCapsManagerFactory(void) if ( (err == NS_OK) && (m_pNSIFactory != NULL) ) { NS_DEFINE_CID(kCCapsManagerCID, NS_CCAPSMANAGER_CID); - nsRepository::RegisterFactory(kCCapsManagerCID, 0, 0, + nsComponentManager::RegisterFactory(kCCapsManagerCID, 0, 0, m_pNSIFactory, PR_FALSE); } } @@ -147,7 +147,7 @@ nsCCapsManagerFactory::~nsCCapsManagerFactory() if(mRefCnt == 0) { NS_DEFINE_CID(kCCapsManagerCID, NS_CCAPSMANAGER_CID); - nsRepository::UnregisterFactory(kCCapsManagerCID, (nsIFactory *)m_pNSIFactory); + nsComponentManager::UnregisterFactory(kCCapsManagerCID, (nsIFactory *)m_pNSIFactory); } } diff --git a/mozilla/config/rules.mak b/mozilla/config/rules.mak index eaddfc709c0..c856a8ecf22 100644 --- a/mozilla/config/rules.mak +++ b/mozilla/config/rules.mak @@ -471,6 +471,11 @@ unmangle:: $(DIRS) -$(MAKE_UNMANGLE) +alltags:: + echo Making emacs tags + c:\\mksnt\\find . -name dist -prune -o ( -name '*.[hc]' -o -name '*.cpp' ) -print | c:\\mksnt\\xargs etags -a + + #//------------------------------------------------------------------------ #// #// Rule to create the object directory (if necessary) @@ -628,3 +633,4 @@ CFLAGS = $(CFLAGS) -DNO_JNI_STUBS !endif !endif # CONFIG_RULES_MAK + diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index baea07dd3c3..192984ad6a1 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -45,7 +45,7 @@ #include "nsIDOMHTMLOptionElement.h" #include "nsIFormControl.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIScrollableView.h" #include "nsHTMLAtoms.h" diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 159f37a5080..4653ce7c85c 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -46,7 +46,7 @@ #include "nsINetService.h" #include "nsIServiceManager.h" #include "nsIFormManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsParserCIID.h" #include "nsIDOMHTMLElement.h" #include "nsIDOMHTMLMapElement.h" @@ -334,7 +334,7 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL, static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); if (rv == NS_OK) - rv = nsRepository::CreateInstance(kCParserCID, + rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&mParser); @@ -1244,7 +1244,7 @@ nsHTMLDocument::Open(JSContext *cx, jsval *argv, PRUint32 argc) static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - result = nsRepository::CreateInstance(kCParserCID, + result = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&mParser); diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 6ea00b3c3fa..9d9c1f95bbd 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -953,7 +953,7 @@ nsXMLContentSink::LoadXSLStyleSheet(const nsIURL* aUrl) static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); // Create the XML parser - rv = nsRepository::CreateInstance(kCParserCID, + rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index a4e836548b8..7b801c568e7 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -34,7 +34,7 @@ #include "nsIHTMLStyleSheet.h" #include "nsIHTMLCSSStyleSheet.h" #include "nsIStyleSet.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIDOMComment.h" #include "nsIDOMElement.h" #include "nsIDOMText.h" @@ -279,7 +279,7 @@ nsXMLDocument::StartDocumentLoad(nsIURL *aUrl, static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - rv = nsRepository::CreateInstance(kCParserCID, + rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&mParser); diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index e492b48ba75..62c0beff61b 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -86,6 +86,7 @@ #include "nsIStyleRule.h" #include "nsIURL.h" #include "rdfutil.h" +#include "prlog.h" // The XUL interfaces implemented by the RDF content node. #include "nsIDOMXULElement.h" @@ -344,7 +345,7 @@ RDFElementImpl::RDFElementImpl(PRInt32 aNameSpaceID, nsIAtom* aTag) kStyleAtom = NS_NewAtom("style"); kContainerAtom = NS_NewAtom("container"); - rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &gNameSpaceManager); @@ -1008,7 +1009,7 @@ RDFElementImpl::GetListenerManager(nsIEventListenerManager** aResult) *aResult = mListenerManager; return NS_OK; } - nsresult rv = nsRepository::CreateInstance(kEventListenerManagerCID, + nsresult rv = nsComponentManager::CreateInstance(kEventListenerManagerCID, nsnull, kIEventListenerManagerIID, (void**) aResult); @@ -1022,7 +1023,7 @@ RDFElementImpl::GetListenerManager(nsIEventListenerManager** aResult) NS_IMETHODIMP RDFElementImpl::GetNewListenerManager(nsIEventListenerManager **aResult) { - return nsRepository::CreateInstance(kEventListenerManagerCID, + return nsComponentManager::CreateInstance(kEventListenerManagerCID, nsnull, kIEventListenerManagerIID, (void**) aResult); diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 74538709f72..2a309f228af 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -81,10 +81,11 @@ #include "plhash.h" #include "plstr.h" #include "rdfutil.h" - +#include "prlog.h" #include "nsILineBreakerFactory.h" #include "nsLWBrkCIID.h" + //////////////////////////////////////////////////////////////////////// static NS_DEFINE_IID(kICSSParserIID, NS_ICSS_PARSER_IID); // XXX grr.. @@ -640,7 +641,7 @@ XULDocumentImpl::XULDocumentImpl(void) nsresult rv; // construct a selection object - if (NS_FAILED(rv = nsRepository::CreateInstance(kRangeListCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRangeListCID, nsnull, kIDOMSelectionIID, (void**) &mSelection))) { @@ -803,7 +804,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, // Create an HTML style sheet for the HTML content. nsIHTMLStyleSheet* sheet; - if (NS_SUCCEEDED(rv = nsRepository::CreateInstance(kHTMLStyleSheetCID, + if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kHTMLStyleSheetCID, nsnull, kIHTMLStyleSheetIID, (void**) &sheet))) { @@ -824,7 +825,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, // Create an inline style sheet for inline content that contains a style // attribute. nsIHTMLCSSStyleSheet* inlineSheet; - if (NS_SUCCEEDED(rv = nsRepository::CreateInstance(kHTMLCSSStyleSheetCID, + if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kHTMLCSSStyleSheetCID, nsnull, kIHTMLCSSStyleSheetIID, (void**) &inlineSheet))) { @@ -845,7 +846,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, // Create a composite data source that'll tie together local and // remote stores. nsIRDFCompositeDataSource* db; - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFCompositeDataSourceCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFCompositeDataSourceCID, nsnull, kIRDFCompositeDataSourceIID, (void**) &db))) { @@ -855,7 +856,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, // Create a XUL content model builder NS_IF_RELEASE(mXULBuilder); - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFXULBuilderCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFXULBuilderCID, nsnull, kIRDFContentModelBuilderIID, (void**) &mXULBuilder))) { @@ -881,7 +882,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, // XXX This needs to be cloned across windows, and the final // instance needs to be flushed to disk. It may be that this is // really an RDFXML data source... - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, nsnull, kIRDFDataSourceIID, (void**) &mLocalDataSource))) { @@ -909,7 +910,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, // meantime, add us as an nsIRDFXMLDataSourceObserver so that // we'll be notified when we need to load style sheets, etc. NS_IF_RELEASE(mDocumentDataSource); - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, nsnull, kIRDFDataSourceIID, (void**) &mDocumentDataSource))) { @@ -928,7 +929,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, } nsCOMPtr sink; - if (NS_FAILED(rv = nsRepository::CreateInstance(kXULContentSinkCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kXULContentSinkCID, nsnull, kIXULContentSinkIID, (void**) getter_AddRefs(sink)))) { @@ -946,7 +947,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, } } - if (NS_FAILED(rv = nsRepository::CreateInstance(kParserCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kParserCID, nsnull, kIParserIID, (void**) &mParser))) { @@ -960,7 +961,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, } nsCOMPtr dtd; - if (NS_FAILED(rv = nsRepository::CreateInstance(kWellFormedDTDCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kWellFormedDTDCID, nsnull, kIDTDIID, (void**) getter_AddRefs(dtd)))) { @@ -1078,7 +1079,7 @@ XULDocumentImpl::CreateShell(nsIPresContext* aContext, nsresult rv; nsIPresShell* shell; - if (NS_FAILED(rv = nsRepository::CreateInstance(kPresShellCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kPresShellCID, nsnull, kIPresShellIID, (void**) &shell))) @@ -2821,7 +2822,7 @@ XULDocumentImpl::LoadCSSStyleSheet(nsIURL* url) } nsICSSParser* parser; - rv = nsRepository::CreateInstance(kCSSParserCID, + rv = nsComponentManager::CreateInstance(kCSSParserCID, nsnull, kICSSParserIID, (void**) &parser); @@ -2887,7 +2888,7 @@ XULDocumentImpl::Init(void) return rv; // Create a namespace manager so we can manage tags - if (NS_FAILED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &mNameSpaceManager))) diff --git a/mozilla/content/xul/templates/src/nsXULSortService.cpp b/mozilla/content/xul/templates/src/nsXULSortService.cpp index 88b8039743e..d3a5d5576bf 100644 --- a/mozilla/content/xul/templates/src/nsXULSortService.cpp +++ b/mozilla/content/xul/templates/src/nsXULSortService.cpp @@ -217,7 +217,7 @@ XULSortServiceImpl::XULSortServiceImpl(void) // Register the XUL and RDF namespaces: these'll just retrieve // the IDs if they've already been registered by someone else. nsINameSpaceManager* mgr; - if (NS_SUCCEEDED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &mgr))) diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp index 487f77569c4..0874286aa4a 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -160,7 +160,7 @@ RDFGenericBuilderImpl::RDFGenericBuilderImpl(void) // Register the XUL and RDF namespaces: these'll just retrieve // the IDs if they've already been registered by someone else. - if (NS_SUCCEEDED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &gNameSpaceManager))) { diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 367197c8e24..d6afbdcdcbc 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -30,7 +30,7 @@ #include "nsIDocumentLoaderObserver.h" #include "nsDOMEvent.h" #include "nsIPresContext.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIEventQueueService.h" #include "nsXPComCIID.h" @@ -771,7 +771,7 @@ nsWebShell::Init(nsNativeWidget aNativeParent, mDocLoader->AddObserver((nsIDocumentLoaderObserver*)this); // Create device context - rv = nsRepository::CreateInstance(kDeviceContextCID, nsnull, + rv = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull, kIDeviceContextIID, (void **)&mDeviceContext); if (NS_FAILED(rv)) { @@ -788,7 +788,7 @@ nsWebShell::Init(nsNativeWidget aNativeParent, mDeviceContext->SetGamma(1.0f); // Create a Native window for the shell container... - rv = nsRepository::CreateInstance(kChildCID, nsnull, kIWidgetIID, (void**)&mWindow); + rv = nsComponentManager::CreateInstance(kChildCID, nsnull, kIWidgetIID, (void**)&mWindow); if (NS_FAILED(rv)) { goto done; } diff --git a/mozilla/dom/public/nsDOMCID.h b/mozilla/dom/public/nsDOMCID.h index 35c840dfd5c..1ddcaf299fa 100644 --- a/mozilla/dom/public/nsDOMCID.h +++ b/mozilla/dom/public/nsDOMCID.h @@ -21,7 +21,7 @@ #include "nsISupports.h" #include "nsIFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #define NS_DOM_SCRIPT_OBJECT_FACTORY_CID \ { /* 9eb760f0-4380-11d2-b328-00805f8a3859 */ \ diff --git a/mozilla/dom/src/base/nsJSUtils.cpp b/mozilla/dom/src/base/nsJSUtils.cpp index f841fbe3b94..17c947f6bbb 100644 --- a/mozilla/dom/src/base/nsJSUtils.cpp +++ b/mozilla/dom/src/base/nsJSUtils.cpp @@ -32,7 +32,7 @@ #include "nsIScriptGlobalObject.h" #include "nsString.h" #include "nsIScriptNameSpaceManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); @@ -78,7 +78,7 @@ nsJSUtils::nsLookupGlobalName(nsISupports* aSupports, result = manager->LookupName(name, PR_FALSE, classID); NS_RELEASE(manager); if (NS_OK == result) { - result = nsRepository::CreateInstance(classID, + result = nsComponentManager::CreateInstance(classID, nsnull, kISupportsIID, (void **)&native); @@ -284,7 +284,7 @@ nsJSUtils::nsGlobalResolve(JSContext* aContext, result = manager->LookupName(name, PR_FALSE, classID); NS_RELEASE(manager); if (NS_OK == result) { - result = nsRepository::CreateInstance(classID, + result = nsComponentManager::CreateInstance(classID, nsnull, kISupportsIID, (void **)&native); diff --git a/mozilla/dom/src/html/nsJSHTMLImageElement.cpp b/mozilla/dom/src/html/nsJSHTMLImageElement.cpp index 7e5d59c94f3..a091c19afeb 100644 --- a/mozilla/dom/src/html/nsJSHTMLImageElement.cpp +++ b/mozilla/dom/src/html/nsJSHTMLImageElement.cpp @@ -29,7 +29,7 @@ #include "nsIDOMImage.h" #include "nsIDOMHTMLImageElement.h" #include "nsIScriptNameSpaceManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsDOMCID.h" @@ -483,7 +483,7 @@ HTMLImageElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r return JS_FALSE; } - result = nsRepository::CreateInstance(classID, + result = nsComponentManager::CreateInstance(classID, nsnull, kIDOMHTMLImageElementIID, (void **)&nativeThis); diff --git a/mozilla/dom/tools/JSStubGen.cpp b/mozilla/dom/tools/JSStubGen.cpp index a03775c621f..e66f042ccdf 100644 --- a/mozilla/dom/tools/JSStubGen.cpp +++ b/mozilla/dom/tools/JSStubGen.cpp @@ -99,7 +99,7 @@ static const char *kIncludeDefaultsStr = "\n" static const char *kIncludeStr = "#include \"nsIDOM%s.h\"\n"; static const char *kIncludeConstructorStr = "#include \"nsIScriptNameSpaceManager.h\"\n" -"#include \"nsRepository.h\"\n" +"#include \"nsComponentManager.h\"\n" "#include \"nsDOMCID.h\"\n"; static PRIntn @@ -1269,7 +1269,7 @@ static const char *kConstructorBeginStr = " return JS_FALSE;\n" " }\n" "\n" -" result = nsRepository::CreateInstance(classID,\n" +" result = nsComponentManager::CreateInstance(classID,\n" " nsnull,\n" " kIDOM%sIID,\n" " (void **)&nativeThis);\n" diff --git a/mozilla/editor/base/nsEditFactory.cpp b/mozilla/editor/base/nsEditFactory.cpp index a98a3026284..843d4b09df9 100644 --- a/mozilla/editor/base/nsEditFactory.cpp +++ b/mozilla/editor/base/nsEditFactory.cpp @@ -20,7 +20,7 @@ #include "nsIEditor.h" #include "nsEditor.h" #include "nsEditorCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); @@ -119,7 +119,7 @@ nsEditFactory::nsEditFactory(const nsCID &aClass) nsEditFactory::~nsEditFactory() { - //nsRepository::UnregisterFactory(mCID, (nsIFactory *)this); //we are out of ref counts anyway + //nsComponentManager::UnregisterFactory(mCID, (nsIFactory *)this); //we are out of ref counts anyway } diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index b28deed9f8c..da1cd460714 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -90,6 +90,8 @@ static NS_DEFINE_IID(kChangeAttributeTxnIID,CHANGE_ATTRIBUTE_TXN_IID); static NS_DEFINE_IID(kSplitElementTxnIID, SPLIT_ELEMENT_TXN_IID); static NS_DEFINE_IID(kJoinElementTxnIID, JOIN_ELEMENT_TXN_IID); +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); + #ifdef XP_PC #define TRANSACTION_MANAGER_DLL "txmgr.dll" #else @@ -128,12 +130,13 @@ PRMonitor *getEditorMonitor() //if more than one person asks for the monitor at return ns_editlock; } +nsIComponentManager* gCompMgr = NULL; /* we must be good providers of factories ect. this is where to put ALL editor exports */ //BEGIN EXPORTS -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServiceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServMgr, const nsCID & aClass, const char *aClassName, const char *aProgID, @@ -145,6 +148,9 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServiceMgr, *aFactory = nsnull; + nsresult rv = aServMgr->QueryInterface(nsIComponentManager::IID(), (void**)&gCompMgr); + if (NS_FAILED(rv)) return rv; + if (aClass.Equals(kEditorCID)) { return GetEditFactory(aFactory, aClass); } @@ -160,7 +166,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServiceMgr, extern "C" NS_EXPORT PRBool -NSCanUnload(nsISupports* serviceMgr) +NSCanUnload(nsISupports* aServMgr) { return nsEditor::gInstanceCount; //I have no idea. I am copying code here } @@ -168,40 +174,33 @@ NSCanUnload(nsISupports* serviceMgr) extern "C" NS_EXPORT nsresult -NSRegisterSelf(nsISupports* serviceMgr, const char *path) +NSRegisterSelf(nsISupports* aServMgr, const char *path) { - nsresult result = NS_ERROR_UNEXPECTED; - //this will register the editor classes with the xpcom dll. - result = nsRepository::RegisterComponent(kEditorCID, NULL, NULL, path, - PR_TRUE, PR_TRUE); - if (NS_SUCCEEDED(result)) - { - result = nsRepository::RegisterComponent(kTextEditorCID, NULL, NULL, path, - PR_TRUE, PR_TRUE); - if (NS_SUCCEEDED(result)) - { - result = nsRepository::RegisterComponent(kHTMLEditorCID, NULL, NULL, path, - PR_TRUE, PR_TRUE); - } - } + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kEditorCID, NULL, NULL, path, + PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kTextEditorCID, NULL, NULL, path, + PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kHTMLEditorCID, NULL, NULL, path, + PR_TRUE, PR_TRUE); return result; } extern "C" NS_EXPORT nsresult -NSUnregisterSelf(nsISupports* serviceMgr, const char *path) +NSUnregisterSelf(nsISupports* aServMgr, const char *path) { - nsresult result = NS_ERROR_UNEXPECTED; - result = nsRepository::UnregisterFactory(kIEditFactoryIID, path); - - - if (NS_SUCCEEDED(result)) - { - result = nsRepository::UnregisterFactory(kITextEditFactoryIID, path); - if (NS_SUCCEEDED(result)) - { - result = nsRepository::UnregisterFactory(kIHTMLEditFactoryIID, path); - } - } + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterFactory(kIEditFactoryIID, path); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterFactory(kITextEditFactoryIID, path); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterFactory(kIHTMLEditFactoryIID, path); return result; } @@ -333,16 +332,16 @@ nsEditor::EnableUndo(PRBool aEnable) nsresult result=NS_OK; /** -- temp code until the txn mgr auto-registers -- **/ - nsRepository::RegisterComponent(kCTransactionManagerFactoryCID, NULL, NULL, - TRANSACTION_MANAGER_DLL, PR_FALSE, PR_FALSE); + gCompMgr->RegisterComponent(kCTransactionManagerFactoryCID, NULL, NULL, + TRANSACTION_MANAGER_DLL, PR_FALSE, PR_FALSE); /** -- end temp code -- **/ if (PR_TRUE==aEnable) { if (!mTxnMgr) { - result = nsRepository::CreateInstance(kCTransactionManagerFactoryCID, - nsnull, - kITransactionManagerIID, (void **)&txnMgr); + result = gCompMgr->CreateInstance(kCTransactionManagerFactoryCID, + nsnull, + kITransactionManagerIID, (void **)&txnMgr); if (NS_FAILED(result) || !txnMgr) { printf("ERROR: Failed to get TransactionManager instance.\n"); return NS_ERROR_NOT_AVAILABLE; diff --git a/mozilla/editor/base/nsEditor.h b/mozilla/editor/base/nsEditor.h index 8b786cf45ea..f771f2fc765 100644 --- a/mozilla/editor/base/nsEditor.h +++ b/mozilla/editor/base/nsEditor.h @@ -28,7 +28,7 @@ #include "nsCOMPtr.h" #include "nsITransactionManager.h" #include "TransactionFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" class nsIDOMCharacterData; class nsIDOMRange; diff --git a/mozilla/editor/base/nsHTMLEditFactory.cpp b/mozilla/editor/base/nsHTMLEditFactory.cpp index a6cf453db5a..7928a37ffde 100644 --- a/mozilla/editor/base/nsHTMLEditFactory.cpp +++ b/mozilla/editor/base/nsHTMLEditFactory.cpp @@ -21,7 +21,7 @@ #include "nsHTMLEditor.h" #include "nsEditor.h" #include "nsEditorCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); @@ -121,7 +121,7 @@ nsHTMLEditFactory::nsHTMLEditFactory(const nsCID &aClass) nsHTMLEditFactory::~nsHTMLEditFactory() { - //nsRepository::UnregisterFactory(mCID, (nsIFactory *)this); //we are out of ref counts anyway + //nsComponentManager::UnregisterFactory(mCID, (nsIFactory *)this); //we are out of ref counts anyway } diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index afc23a98c7c..01f6fc9b3f5 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -25,7 +25,7 @@ #include "nsIDOMMouseListener.h" #include "nsEditorCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsITableCellLayout.h" //For GetColIndexForCell diff --git a/mozilla/editor/base/nsTextEditFactory.cpp b/mozilla/editor/base/nsTextEditFactory.cpp index 725a1974706..2b54a42bd0b 100644 --- a/mozilla/editor/base/nsTextEditFactory.cpp +++ b/mozilla/editor/base/nsTextEditFactory.cpp @@ -21,7 +21,7 @@ #include "nsTextEditor.h" #include "nsEditor.h" #include "nsEditorCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); @@ -123,5 +123,5 @@ nsTextEditFactory::nsTextEditFactory(const nsCID &aClass) nsTextEditFactory::~nsTextEditFactory() { - //nsRepository::UnregisterFactory(mCID, (nsIFactory *)this); //we are out of ref counts anyway + //nsComponentManager::UnregisterFactory(mCID, (nsIFactory *)this); //we are out of ref counts anyway } diff --git a/mozilla/editor/base/nsTextEditor.cpp b/mozilla/editor/base/nsTextEditor.cpp index 44408c96d64..8eed1fa9943 100644 --- a/mozilla/editor/base/nsTextEditor.cpp +++ b/mozilla/editor/base/nsTextEditor.cpp @@ -66,7 +66,7 @@ class nsIFrame; #include "CreateElementTxn.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" static NS_DEFINE_IID(kIDOMEventReceiverIID, NS_IDOMEVENTRECEIVER_IID); @@ -289,7 +289,7 @@ NS_IMETHODIMP nsTextEditor::GetTextProperty(nsIAtom *aProperty, PRBool &aAny, PR { nsCOMPtr range( do_QueryInterface(currentItem) ); nsCOMPtr iter; - result = nsRepository::CreateInstance(kCContentIteratorCID, nsnull, + result = nsComponentManager::CreateInstance(kCContentIteratorCID, nsnull, kIContentIteratorIID, getter_AddRefs(iter)); if ((NS_SUCCEEDED(result)) && iter) @@ -538,7 +538,7 @@ NS_IMETHODIMP nsTextEditor::OutputText(nsString& aOutputString) static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - rv = nsRepository::CreateInstance(kCParserCID, + rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); @@ -606,7 +606,7 @@ NS_IMETHODIMP nsTextEditor::OutputHTML(nsString& aOutputString) static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - rv = nsRepository::CreateInstance(kCParserCID, + rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); @@ -834,7 +834,7 @@ nsTextEditor::SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange, // create style nodes for all the content between the start and end nodes nsCOMPtriter; - result = nsRepository::CreateInstance(kCContentIteratorCID, nsnull, + result = nsComponentManager::CreateInstance(kCContentIteratorCID, nsnull, kIContentIteratorIID, getter_AddRefs(iter)); if ((NS_SUCCEEDED(result)) && iter) { diff --git a/mozilla/editor/guimgr/src/nsGuiManagerFactory.cpp b/mozilla/editor/guimgr/src/nsGuiManagerFactory.cpp index 7018a05c01c..f837049e103 100644 --- a/mozilla/editor/guimgr/src/nsGuiManagerFactory.cpp +++ b/mozilla/editor/guimgr/src/nsGuiManagerFactory.cpp @@ -20,7 +20,7 @@ #include "nsEditGuiManager.h" #include "nsGuiManagerFactory.h" #include "nsIEditor.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsCOMPtr.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -119,7 +119,7 @@ nsGuiManagerFactory::nsGuiManagerFactory(nsIFactory **aFactory) nsGuiManagerFactory::~nsGuiManagerFactory() { - nsRepository::UnregisterFactory(kIGuiManagerFactoryIID, (nsIFactory *)this); //we are out of ref counts anyway + nsComponentManager::UnregisterFactory(kIGuiManagerFactoryIID, (nsIFactory *)this); //we are out of ref counts anyway } extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path) diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index b28deed9f8c..da1cd460714 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -90,6 +90,8 @@ static NS_DEFINE_IID(kChangeAttributeTxnIID,CHANGE_ATTRIBUTE_TXN_IID); static NS_DEFINE_IID(kSplitElementTxnIID, SPLIT_ELEMENT_TXN_IID); static NS_DEFINE_IID(kJoinElementTxnIID, JOIN_ELEMENT_TXN_IID); +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); + #ifdef XP_PC #define TRANSACTION_MANAGER_DLL "txmgr.dll" #else @@ -128,12 +130,13 @@ PRMonitor *getEditorMonitor() //if more than one person asks for the monitor at return ns_editlock; } +nsIComponentManager* gCompMgr = NULL; /* we must be good providers of factories ect. this is where to put ALL editor exports */ //BEGIN EXPORTS -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServiceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServMgr, const nsCID & aClass, const char *aClassName, const char *aProgID, @@ -145,6 +148,9 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServiceMgr, *aFactory = nsnull; + nsresult rv = aServMgr->QueryInterface(nsIComponentManager::IID(), (void**)&gCompMgr); + if (NS_FAILED(rv)) return rv; + if (aClass.Equals(kEditorCID)) { return GetEditFactory(aFactory, aClass); } @@ -160,7 +166,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServiceMgr, extern "C" NS_EXPORT PRBool -NSCanUnload(nsISupports* serviceMgr) +NSCanUnload(nsISupports* aServMgr) { return nsEditor::gInstanceCount; //I have no idea. I am copying code here } @@ -168,40 +174,33 @@ NSCanUnload(nsISupports* serviceMgr) extern "C" NS_EXPORT nsresult -NSRegisterSelf(nsISupports* serviceMgr, const char *path) +NSRegisterSelf(nsISupports* aServMgr, const char *path) { - nsresult result = NS_ERROR_UNEXPECTED; - //this will register the editor classes with the xpcom dll. - result = nsRepository::RegisterComponent(kEditorCID, NULL, NULL, path, - PR_TRUE, PR_TRUE); - if (NS_SUCCEEDED(result)) - { - result = nsRepository::RegisterComponent(kTextEditorCID, NULL, NULL, path, - PR_TRUE, PR_TRUE); - if (NS_SUCCEEDED(result)) - { - result = nsRepository::RegisterComponent(kHTMLEditorCID, NULL, NULL, path, - PR_TRUE, PR_TRUE); - } - } + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kEditorCID, NULL, NULL, path, + PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kTextEditorCID, NULL, NULL, path, + PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kHTMLEditorCID, NULL, NULL, path, + PR_TRUE, PR_TRUE); return result; } extern "C" NS_EXPORT nsresult -NSUnregisterSelf(nsISupports* serviceMgr, const char *path) +NSUnregisterSelf(nsISupports* aServMgr, const char *path) { - nsresult result = NS_ERROR_UNEXPECTED; - result = nsRepository::UnregisterFactory(kIEditFactoryIID, path); - - - if (NS_SUCCEEDED(result)) - { - result = nsRepository::UnregisterFactory(kITextEditFactoryIID, path); - if (NS_SUCCEEDED(result)) - { - result = nsRepository::UnregisterFactory(kIHTMLEditFactoryIID, path); - } - } + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterFactory(kIEditFactoryIID, path); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterFactory(kITextEditFactoryIID, path); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterFactory(kIHTMLEditFactoryIID, path); return result; } @@ -333,16 +332,16 @@ nsEditor::EnableUndo(PRBool aEnable) nsresult result=NS_OK; /** -- temp code until the txn mgr auto-registers -- **/ - nsRepository::RegisterComponent(kCTransactionManagerFactoryCID, NULL, NULL, - TRANSACTION_MANAGER_DLL, PR_FALSE, PR_FALSE); + gCompMgr->RegisterComponent(kCTransactionManagerFactoryCID, NULL, NULL, + TRANSACTION_MANAGER_DLL, PR_FALSE, PR_FALSE); /** -- end temp code -- **/ if (PR_TRUE==aEnable) { if (!mTxnMgr) { - result = nsRepository::CreateInstance(kCTransactionManagerFactoryCID, - nsnull, - kITransactionManagerIID, (void **)&txnMgr); + result = gCompMgr->CreateInstance(kCTransactionManagerFactoryCID, + nsnull, + kITransactionManagerIID, (void **)&txnMgr); if (NS_FAILED(result) || !txnMgr) { printf("ERROR: Failed to get TransactionManager instance.\n"); return NS_ERROR_NOT_AVAILABLE; diff --git a/mozilla/editor/libeditor/base/nsEditor.h b/mozilla/editor/libeditor/base/nsEditor.h index 8b786cf45ea..f771f2fc765 100644 --- a/mozilla/editor/libeditor/base/nsEditor.h +++ b/mozilla/editor/libeditor/base/nsEditor.h @@ -28,7 +28,7 @@ #include "nsCOMPtr.h" #include "nsITransactionManager.h" #include "TransactionFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" class nsIDOMCharacterData; class nsIDOMRange; diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index afc23a98c7c..01f6fc9b3f5 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -25,7 +25,7 @@ #include "nsIDOMMouseListener.h" #include "nsEditorCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsITableCellLayout.h" //For GetColIndexForCell diff --git a/mozilla/editor/txmgr/src/nsTransactionManagerFactory.cpp b/mozilla/editor/txmgr/src/nsTransactionManagerFactory.cpp index 564757bffaa..2f1e292c4cd 100644 --- a/mozilla/editor/txmgr/src/nsTransactionManagerFactory.cpp +++ b/mozilla/editor/txmgr/src/nsTransactionManagerFactory.cpp @@ -19,7 +19,8 @@ #include "nscore.h" #include "nsIFactory.h" #include "nsISupports.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" +#include "nsIServiceManager.h" #include "nsTransactionManagerCID.h" #include "nsTransactionManager.h" @@ -27,6 +28,7 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); static NS_DEFINE_CID(kCTransactionManagerFactoryCID, NS_TRANSACTION_MANAGER_FACTORY_CID); +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); class nsTransactionManagerFactory : public nsIFactory { @@ -113,7 +115,7 @@ nsresult nsTransactionManagerFactory::LockFactory(PRBool aLock) } // return the proper factory to the caller -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, const nsCID &aClass, const char *aClassName, const char *aProgID, @@ -132,15 +134,25 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); } -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *path) { - return nsRepository::RegisterComponent(kCTransactionManagerFactoryCID, - NULL, NULL, path, - PR_TRUE, PR_TRUE); + nsresult rv; + + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + + return compMgr->RegisterComponent(kCTransactionManagerFactoryCID, + NULL, NULL, path, + PR_TRUE, PR_TRUE); } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char *path) { - return nsRepository::UnregisterFactory(kCTransactionManagerFactoryCID, path); + nsresult rv; + + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + + return compMgr->UnregisterFactory(kCTransactionManagerFactoryCID, path); } diff --git a/mozilla/editor/txmgr/tests/TestTXMgr.cpp b/mozilla/editor/txmgr/tests/TestTXMgr.cpp index d110578ffd5..506988e6af6 100644 --- a/mozilla/editor/txmgr/tests/TestTXMgr.cpp +++ b/mozilla/editor/txmgr/tests/TestTXMgr.cpp @@ -19,7 +19,7 @@ #include #include "nsITransactionManager.h" #include "nsTransactionManagerCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" static PRInt32 sConstructorCount = 0; static PRInt32 sDestructorCount = 0; @@ -865,7 +865,7 @@ quick_test(TestTransactionFactory *factory) nsITransaction *r1 = 0, *r2 = 0; nsresult result; - result = nsRepository::CreateInstance(kCTransactionManagerFactoryCID, nsnull, + result = nsComponentManager::CreateInstance(kCTransactionManagerFactoryCID, nsnull, kITransactionManagerIID, (void **)&mgr); if (NS_FAILED(result) || !mgr) { @@ -2734,7 +2734,7 @@ quick_batch_test(TestTransactionFactory *factory) nsITransaction *r1 = 0, *r2 = 0; nsresult result; - result = nsRepository::CreateInstance(kCTransactionManagerFactoryCID, nsnull, + result = nsComponentManager::CreateInstance(kCTransactionManagerFactoryCID, nsnull, kITransactionManagerIID, (void **)&mgr); if (NS_FAILED(result) || !mgr) { @@ -4348,7 +4348,7 @@ stress_test(TestTransactionFactory *factory, PRInt32 iterations) nsITransaction *tx = 0; nsresult result; - result = nsRepository::CreateInstance(kCTransactionManagerFactoryCID, nsnull, + result = nsComponentManager::CreateInstance(kCTransactionManagerFactoryCID, nsnull, kITransactionManagerIID, (void **)&mgr); if (NS_FAILED(result) || !mgr) { @@ -4542,7 +4542,7 @@ main (int argc, char *argv[]) { nsresult result; - nsRepository::RegisterComponent(kCTransactionManagerFactoryCID, NULL, NULL, + nsComponentManager::RegisterComponent(kCTransactionManagerFactoryCID, NULL, NULL, TRANSACTION_MANAGER_DLL, PR_FALSE, PR_FALSE); result = simple_test(); diff --git a/mozilla/gfx/public/nsGfxCIID.h b/mozilla/gfx/public/nsGfxCIID.h index f55a17a4af9..c17fd7d1a7f 100644 --- a/mozilla/gfx/public/nsGfxCIID.h +++ b/mozilla/gfx/public/nsGfxCIID.h @@ -21,7 +21,7 @@ #include "nsISupports.h" #include "nsIFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #define NS_IMAGE_CID \ { 0x6049b260, 0xc1e6, 0x11d1, \ diff --git a/mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.cpp b/mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.cpp index d3ab20f536e..24683e89dd8 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.cpp +++ b/mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.cpp @@ -65,7 +65,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: CreateDeviceContextSpec(nsIDevice nsresult rv = NS_ERROR_FAILURE; nsIDeviceContextSpec *devSpec = nsnull; - nsRepository::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec); + nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec); if (nsnull != devSpec){ if (NS_OK == ((nsDeviceContextSpecGTK *)devSpec)->Init(aQuiet)){ diff --git a/mozilla/gfx/src/mac/nsDeviceContextSpecFactoryM.cpp b/mozilla/gfx/src/mac/nsDeviceContextSpecFactoryM.cpp index f9e2030edb5..1e78db881cd 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextSpecFactoryM.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextSpecFactoryM.cpp @@ -65,7 +65,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: CreateDeviceContextSpec(nsIDevice nsresult rv = NS_ERROR_FAILURE; nsIDeviceContextSpec *devSpec = nsnull; - nsRepository::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec); + nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec); if (nsnull != devSpec){ if (NS_OK == ((nsDeviceContextSpecMac *)devSpec)->Init(aQuiet)){ diff --git a/mozilla/gfx/src/motif/nsRenderingContextMotif.cpp b/mozilla/gfx/src/motif/nsRenderingContextMotif.cpp index e714778b45a..21fb87bb66d 100644 --- a/mozilla/gfx/src/motif/nsRenderingContextMotif.cpp +++ b/mozilla/gfx/src/motif/nsRenderingContextMotif.cpp @@ -530,7 +530,7 @@ NS_IMETHODIMP nsRenderingContextMotif :: GetClipRegion(nsIRegion **aRegion) static NS_DEFINE_IID(kCRegionCID, NS_REGION_CID); static NS_DEFINE_IID(kIRegionIID, NS_IREGION_IID); - nsresult rv = nsRepository::CreateInstance(kCRegionCID, + nsresult rv = nsComponentManager::CreateInstance(kCRegionCID, nsnull, kIRegionIID, (void **)aRegion); diff --git a/mozilla/gfx/src/nsDeviceContext.cpp b/mozilla/gfx/src/nsDeviceContext.cpp index 3be29498769..f2dbfd5b8d8 100644 --- a/mozilla/gfx/src/nsDeviceContext.cpp +++ b/mozilla/gfx/src/nsDeviceContext.cpp @@ -26,6 +26,7 @@ #include "il_util.h" #include "nsVoidArray.h" #include "nsIFontMetrics.h" +#include "nsHashtable.h" class nsFontCache { @@ -180,7 +181,7 @@ NS_IMETHODIMP DeviceContextImpl :: CreateRenderingContext(nsIView *aView, nsIRen static NS_DEFINE_IID(kRCIID, NS_IRENDERING_CONTEXT_IID); aContext = nsnull; - rv = nsRepository::CreateInstance(kRCCID, nsnull, kRCIID, (void **)&pContext); + rv = nsComponentManager::CreateInstance(kRCCID, nsnull, kRCIID, (void **)&pContext); if (NS_OK == rv) { rv = InitRenderingContext(pContext, win); @@ -203,7 +204,7 @@ NS_IMETHODIMP DeviceContextImpl :: CreateRenderingContext(nsIWidget *aWidget, ns static NS_DEFINE_IID(kRCIID, NS_IRENDERING_CONTEXT_IID); aContext = nsnull; - rv = nsRepository::CreateInstance(kRCCID, nsnull, kRCIID, (void **)&pContext); + rv = nsComponentManager::CreateInstance(kRCCID, nsnull, kRCIID, (void **)&pContext); if (NS_OK == rv) { rv = InitRenderingContext(pContext, aWidget); @@ -658,7 +659,7 @@ nsresult nsFontCache :: GetMetricsFor(const nsFont& aFont, nsIFontMetrics *&aMet static NS_DEFINE_IID(kFontMetricsIID, NS_IFONT_METRICS_IID); nsIFontMetrics* fm; - nsresult rv = nsRepository::CreateInstance(kFontMetricsCID, nsnull, + nsresult rv = nsComponentManager::CreateInstance(kFontMetricsCID, nsnull, kFontMetricsIID, (void **)&fm); if (NS_OK != rv) { aMetrics = nsnull; diff --git a/mozilla/gfx/src/nsImageRenderer.cpp b/mozilla/gfx/src/nsImageRenderer.cpp index 99f6eefa1d9..1c7bf645096 100644 --- a/mozilla/gfx/src/nsImageRenderer.cpp +++ b/mozilla/gfx/src/nsImageRenderer.cpp @@ -81,7 +81,7 @@ ImageRendererImpl::NewPixmap(void* aDisplayContext, static NS_DEFINE_IID(kImageIID, NS_IIMAGE_IID); // Create a new image object - rv = nsRepository::CreateInstance(kImageCID, nsnull, kImageIID, (void **)&img); + rv = nsComponentManager::CreateInstance(kImageCID, nsnull, kImageIID, (void **)&img); if (NS_OK != rv) { // XXX What about error handling? return; diff --git a/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp b/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp index adffdf1efa0..37616ba0ba0 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp +++ b/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp @@ -93,7 +93,7 @@ printf("printer: driver %s, device %s\n", driver, device); nsIDeviceContextSpec *devspec = nsnull; - nsRepository::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devspec); + nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devspec); if (nsnull != devspec) { diff --git a/mozilla/gfx/tests/btest/BitTest.cpp b/mozilla/gfx/tests/btest/BitTest.cpp index 4f0a4e3cbfd..d79411f7208 100644 --- a/mozilla/gfx/tests/btest/BitTest.cpp +++ b/mozilla/gfx/tests/btest/BitTest.cpp @@ -291,7 +291,7 @@ nsIDeviceContext *dx = nsnull; gSobits = (HBITMAP)::SelectObject(gSrcdc, gSrcbits); gDobits = (HBITMAP)::SelectObject(gDestdc, gDestbits); - rv = nsRepository::CreateInstance(kBlenderCID, nsnull, kBlenderIID, (void **)&gImageblender); + rv = nsComponentManager::CreateInstance(kBlenderCID, nsnull, kBlenderIID, (void **)&gImageblender); //gImageblender->Init(gSrcdc,gDestdc); gImageblender->Init(dx); } @@ -1109,7 +1109,7 @@ static HWND CreateTopLevel(const char* clazz, const char* title,int aWidth, int nsRect rect(0, 0, aWidth, aHeight); - nsresult rv = nsRepository::CreateInstance(kCChildWindowIID, NULL, kIWidgetIID, (void**)&gWindow); + nsresult rv = nsComponentManager::CreateInstance(kCChildWindowIID, NULL, kIWidgetIID, (void**)&gWindow); if (NS_OK == rv) @@ -1118,9 +1118,9 @@ static HWND CreateTopLevel(const char* clazz, const char* title,int aWidth, int } // something for input - nsRepository::RegisterComponent(kCTextFieldCID, NULL, NULL, "raptorwidget.dll", PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCTextFieldCID, NULL, NULL, "raptorwidget.dll", PR_FALSE, PR_FALSE); rect.SetRect(25, 370, 40, 25); - nsRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&gBlendMessage); + nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&gBlendMessage); nsIWidget* widget = nsnull; if (NS_OK == gBlendMessage->QueryInterface(kIWidgetIID,(void**)&widget)) @@ -1132,7 +1132,7 @@ static HWND CreateTopLevel(const char* clazz, const char* title,int aWidth, int gBlendMessage->SetText("50",size); rect.SetRect(70,370,40,25); - nsRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&gQualMessage); + nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&gQualMessage); if (NS_OK == gQualMessage->QueryInterface(kIWidgetIID,(void**)&widget)) { widget->Create(gWindow, rect, nsnull, nsnull); @@ -1155,9 +1155,9 @@ WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, int nCmdShow { gInstance = instance; - nsRepository::RegisterComponent(kCWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCChildWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCChildWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); static NS_DEFINE_IID(kCRenderingContextIID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kCDeviceContextIID, NS_DEVICE_CONTEXT_CID); @@ -1165,11 +1165,11 @@ WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, int nCmdShow static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID); static NS_DEFINE_IID(kCBlenderIID, NS_BLENDER_CID); - nsRepository::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCImageIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCBlenderIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCImageIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCBlenderIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); if (!prevInstance) { WNDCLASS wndClass; diff --git a/mozilla/htmlparser/robot/nsDebugRobot.cpp b/mozilla/htmlparser/robot/nsDebugRobot.cpp index 3a9774555aa..34a0645a9e1 100644 --- a/mozilla/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/htmlparser/robot/nsDebugRobot.cpp @@ -24,7 +24,7 @@ #include "nsIURL.h" #include "nsIStreamListener.h" #include "nsIDTDDebug.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsParserCIID.h" static NS_DEFINE_IID(kIRobotSinkObserverIID, NS_IROBOTSINKOBSERVER_IID); @@ -216,7 +216,7 @@ extern "C" NS_EXPORT int DebugRobot( static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - rv = nsRepository::CreateInstance(kCParserCID, + rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); diff --git a/mozilla/htmlparser/robot/test/RobotMain.cpp b/mozilla/htmlparser/robot/test/RobotMain.cpp index a5d4cade6d6..31c9b411606 100644 --- a/mozilla/htmlparser/robot/test/RobotMain.cpp +++ b/mozilla/htmlparser/robot/test/RobotMain.cpp @@ -2,7 +2,7 @@ #include "nsVoidArray.h" #include "nsIWebShell.h" #include "nsString.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsParserCIID.h" #ifdef XP_PC @@ -22,7 +22,7 @@ int main(int argc, char **argv) } static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - nsRepository::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); return DebugRobot(gWorkList, nsnull); } diff --git a/mozilla/htmlparser/src/SelfTest.cpp b/mozilla/htmlparser/src/SelfTest.cpp index 9e737675287..2e61491ec73 100644 --- a/mozilla/htmlparser/src/SelfTest.cpp +++ b/mozilla/htmlparser/src/SelfTest.cpp @@ -28,7 +28,7 @@ #include "nsHTMLDelegate.h" #include "nsIParser.h" #include "nsHTMLContentSink.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsParserCIID.h" #ifdef XP_PC @@ -117,7 +117,7 @@ void parseFile (const char* aFilename,int size) static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - nsresult rv = nsRepository::CreateInstance(kCParserCID, + nsresult rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); @@ -203,7 +203,7 @@ int main(int argc, char* argv []) else _getcwd(buffer,_MAX_PATH); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - nsRepository::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); walkDirectoryTree(buffer); return 0; diff --git a/mozilla/htmlparser/src/nsExpatDTD.cpp b/mozilla/htmlparser/src/nsExpatDTD.cpp index 510b1494326..19e6a12e40f 100644 --- a/mozilla/htmlparser/src/nsExpatDTD.cpp +++ b/mozilla/htmlparser/src/nsExpatDTD.cpp @@ -40,6 +40,7 @@ #include "prtypes.h" //this is here for debug reasons... #include "prio.h" #include "plstr.h" +#include "prlog.h" #ifdef XP_PC #include //this is here for debug reasons... diff --git a/mozilla/htmlparser/src/nsParserCIID.h b/mozilla/htmlparser/src/nsParserCIID.h index 79ddfe66a26..b2c7a4a1abe 100644 --- a/mozilla/htmlparser/src/nsParserCIID.h +++ b/mozilla/htmlparser/src/nsParserCIID.h @@ -21,7 +21,7 @@ #include "nsISupports.h" #include "nsIFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #define NS_PARSER_IID \ {0x2ce606b0, 0xbee6, 0x11d1, \ diff --git a/mozilla/htmlparser/tests/logparse/logparse.cpp b/mozilla/htmlparser/tests/logparse/logparse.cpp index 077fef30ddc..8fb498e2f73 100644 --- a/mozilla/htmlparser/tests/logparse/logparse.cpp +++ b/mozilla/htmlparser/tests/logparse/logparse.cpp @@ -16,7 +16,7 @@ * Corporation. Portions created by Netscape are Copyright (C) 1998 * Netscape Communications Corporation. All Rights Reserved. */ -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsParserCIID.h" #include "nsIParser.h" #include "nsILoggingSink.h" @@ -44,8 +44,8 @@ static NS_DEFINE_IID(kILoggingSinkIID, NS_ILOGGING_SINK_IID); static void SetupRegistry() { - nsRepository::RegisterComponent(kParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kLoggingSinkCID, NULL, NULL, PARSER_DLL,PR_FALSE,PR_FALSE); + nsComponentManager::RegisterComponent(kParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kLoggingSinkCID, NULL, NULL, PARSER_DLL,PR_FALSE,PR_FALSE); } //---------------------------------------------------------------------- @@ -61,7 +61,7 @@ nsresult GenerateBaselineFile(const char* aSourceFilename,const char* aBaselineF // Create a parser nsIParser* parser; - nsresult rv = nsRepository::CreateInstance(kParserCID,nsnull,kIParserIID,(void**)&parser); + nsresult rv = nsComponentManager::CreateInstance(kParserCID,nsnull,kIParserIID,(void**)&parser); if (NS_OK != rv) { cout << "Unable to create a parser (" << rv << ")" < compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; // // register the generic factory // - res = nsRepository::RegisterComponent(kLocaleFactoryCID,NULL,NULL,path,PR_TRUE,PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: RegisterFactory failed."); - if (res!=NS_OK) return res; + rv = compMgr->RegisterComponent(kLocaleFactoryCID,NULL,NULL,path,PR_TRUE,PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: RegisterFactory failed."); + if (rv!=NS_OK) return rv; // // register the collation factory // - res = nsRepository::RegisterComponent(kCollationFactoryCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register CollationFactory failed."); - if (NS_FAILED(res)) return res; + rv = compMgr->RegisterComponent(kCollationFactoryCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: Register CollationFactory failed."); + if (NS_FAILED(rv)) return rv; // // register the collation interface // - res = nsRepository::RegisterComponent(kCollationCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register Collation failed."); - if (NS_FAILED(res)) return res; + rv = compMgr->RegisterComponent(kCollationCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: Register Collation failed."); + if (NS_FAILED(rv)) return rv; // // register the date time formatter // - res = nsRepository::RegisterComponent(kDateTimeFormatCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register DateTimeFormat failed."); - if (NS_FAILED(res)) return res; + rv = compMgr->RegisterComponent(kDateTimeFormatCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: Register DateTimeFormat failed."); + if (NS_FAILED(rv)) return rv; return NS_OK; } extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; - res = nsRepository::UnregisterFactory(kLocaleFactoryCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kLocaleFactoryCID, path); + if (rv!=NS_OK) return rv; - res = nsRepository::UnregisterFactory(kCollationFactoryCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kCollationFactoryCID, path); + if (rv!=NS_OK) return rv; - res = nsRepository::UnregisterFactory(kCollationCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kCollationCID, path); + if (rv!=NS_OK) return rv; - res = nsRepository::UnregisterFactory(kDateTimeFormatCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kDateTimeFormatCID, path); + if (rv!=NS_OK) return rv; return NS_OK; } diff --git a/mozilla/intl/locale/src/nsCollation.cpp b/mozilla/intl/locale/src/nsCollation.cpp index a7fa0ce1a5e..8e1dc90e3e5 100644 --- a/mozilla/intl/locale/src/nsCollation.cpp +++ b/mozilla/intl/locale/src/nsCollation.cpp @@ -19,7 +19,7 @@ #define NS_IMPL_IDS #include "nsIServiceManager.h" #include "nsICharsetConverterManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsCollation.h" #include "nsCollationCID.h" #include "nsUnicharUtilCIID.h" @@ -40,7 +40,7 @@ nsresult nsCollationFactory::CreateCollation(nsILocale* locale, nsICollation** i nsICollation *inst; nsresult res; - res = nsRepository::CreateInstance(kCollationCID, NULL, kICollationIID, (void**) &inst); + res = nsComponentManager::CreateInstance(kCollationCID, NULL, kICollationIID, (void**) &inst); if (NS_FAILED(res)) { return res; } @@ -59,7 +59,7 @@ NS_DEFINE_IID(kCaseConversionIID, NS_ICASECONVERSION_IID); nsCollation::nsCollation() { mCaseConversion = NULL; - nsresult res = nsRepository::CreateInstance(kUnicharUtilCID, NULL, kCaseConversionIID, (void**) &mCaseConversion); + nsresult res = nsComponentManager::CreateInstance(kUnicharUtilCID, NULL, kCaseConversionIID, (void**) &mCaseConversion); NS_ASSERTION(NS_SUCCEEDED(res), "CreateInstance failed for kCaseConversionIID"); } diff --git a/mozilla/intl/locale/src/unix/nsLocaleSO.cpp b/mozilla/intl/locale/src/unix/nsLocaleSO.cpp index 5a585171853..750fcb7a2a9 100644 --- a/mozilla/intl/locale/src/unix/nsLocaleSO.cpp +++ b/mozilla/intl/locale/src/unix/nsLocaleSO.cpp @@ -17,7 +17,8 @@ * Netscape Communications Corporation. All Rights Reserved. */ -#include "nsRepository.h" +#include "nsIComponentManager.h" +#include "nsCOMPtr.h" #include "nsIFactory.h" #include "nsILocaleFactory.h" @@ -29,6 +30,9 @@ #include "nsDateTimeFormatCID.h" #include "nsCollationCID.h" #include "nsLocaleSO.h" +#include "nsIServiceManager.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); // // kLocaleFactory for the nsILocaleFactory interface @@ -97,56 +101,60 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, return res; } -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char * path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; // // register the generic factory // - res = nsRepository::RegisterComponent(kLocaleFactoryCID,NULL,NULL,path,PR_TRUE,PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: RegisterFactory failed."); - if (res!=NS_OK) return res; + rv = compMgr->RegisterComponent(kLocaleFactoryCID,NULL,NULL,path,PR_TRUE,PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: RegisterFactory failed."); + if (rv!=NS_OK) return rv; // // register the collation factory // - res = nsRepository::RegisterComponent(kCollationFactoryCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register CollationFactory failed."); - if (NS_FAILED(res)) return res; + rv = compMgr->RegisterComponent(kCollationFactoryCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: Register CollationFactory failed."); + if (NS_FAILED(rv)) return rv; // // register the collation interface // - res = nsRepository::RegisterComponent(kCollationCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register Collation failed."); - if (NS_FAILED(res)) return res; + rv = compMgr->RegisterComponent(kCollationCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: Register Collation failed."); + if (NS_FAILED(rv)) return rv; // // register the date time formatter // - res = nsRepository::RegisterComponent(kDateTimeFormatCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register DateTimeFormat failed."); - if (NS_FAILED(res)) return res; + rv = compMgr->RegisterComponent(kDateTimeFormatCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: Register DateTimeFormat failed."); + if (NS_FAILED(rv)) return rv; return NS_OK; } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char * path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; - res = nsRepository::UnregisterFactory(kLocaleFactoryCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kLocaleFactoryCID, path); + if (rv!=NS_OK) return rv; - res = nsRepository::UnregisterFactory(kCollationFactoryCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kCollationFactoryCID, path); + if (rv!=NS_OK) return rv; - res = nsRepository::UnregisterFactory(kCollationCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kCollationCID, path); + if (rv!=NS_OK) return rv; - res = nsRepository::UnregisterFactory(kDateTimeFormatCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kDateTimeFormatCID, path); + if (rv!=NS_OK) return rv; return NS_OK; } diff --git a/mozilla/intl/locale/src/windows/nsCollationWin.cpp b/mozilla/intl/locale/src/windows/nsCollationWin.cpp index b7224aeffe7..936b7d6ba87 100644 --- a/mozilla/intl/locale/src/windows/nsCollationWin.cpp +++ b/mozilla/intl/locale/src/windows/nsCollationWin.cpp @@ -18,7 +18,7 @@ #include "nsCollationWin.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsLocaleCID.h" #include "nsIWin32Locale.h" #include @@ -62,7 +62,7 @@ nsresult nsCollationWin::Initialize(nsILocale* locale) } nsIWin32Locale* win32Locale; - res = nsRepository::CreateInstance(kWin32LocaleFactoryCID, NULL, kIWin32LocaleIID, (void**)&win32Locale); + res = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID, NULL, kIWin32LocaleIID, (void**)&win32Locale); if (NS_FAILED(res)) { return res; } diff --git a/mozilla/intl/locale/src/windows/nsDateTimeFormatWin.cpp b/mozilla/intl/locale/src/windows/nsDateTimeFormatWin.cpp index a2d8c486c6c..6c1f1758298 100644 --- a/mozilla/intl/locale/src/windows/nsDateTimeFormatWin.cpp +++ b/mozilla/intl/locale/src/windows/nsDateTimeFormatWin.cpp @@ -17,7 +17,7 @@ */ #include "nsDateTimeFormatWin.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsLocaleCID.h" #include "nsIWin32Locale.h" @@ -106,7 +106,7 @@ nsresult nsDateTimeFormatWin::FormatTMTime(nsILocale* locale, } nsIWin32Locale* win32Locale; - res = nsRepository::CreateInstance(kWin32LocaleFactoryCID, NULL, kIWin32LocaleIID, (void**)&win32Locale); + res = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID, NULL, kIWin32LocaleIID, (void**)&win32Locale); if (NS_FAILED(res)) { return res; } diff --git a/mozilla/intl/locale/src/windows/nsLocaleDLL.cpp b/mozilla/intl/locale/src/windows/nsLocaleDLL.cpp index 6811bfc5139..db59986bc36 100644 --- a/mozilla/intl/locale/src/windows/nsLocaleDLL.cpp +++ b/mozilla/intl/locale/src/windows/nsLocaleDLL.cpp @@ -17,7 +17,8 @@ * Netscape Communications Corporation. All Rights Reserved. */ -#include "nsRepository.h" +#include "nsIComponentManager.h" +#include "nsCOMPtr.h" #include "nsIFactory.h" #include "nsILocaleFactory.h" @@ -30,6 +31,10 @@ #include "nsIWin32LocaleFactory.h" #include "nsDateTimeFormatCID.h" #include "nsCollationCID.h" +#include "nsIServiceManager.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); + // // kLocaleFactory for the nsILocaleFactory interface and friends // @@ -113,66 +118,70 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, return res; } -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char * path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; // // register the generic factory // - res = nsRepository::RegisterComponent(kLocaleFactoryCID,NULL,NULL,path,PR_TRUE,PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: RegisterFactory failed."); - if (res!=NS_OK) return res; + rv = compMgr->RegisterComponent(kLocaleFactoryCID,NULL,NULL,path,PR_TRUE,PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: RegisterFactory failed."); + if (rv!=NS_OK) return rv; // // register the windows specific factory // - res = nsRepository::RegisterComponent(kWin32LocaleFactoryCID,NULL,NULL,path,PR_TRUE,PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register nsIWin32LocaleFactory failed."); - if (res!=NS_OK) return res; + rv = compMgr->RegisterComponent(kWin32LocaleFactoryCID,NULL,NULL,path,PR_TRUE,PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: Register nsIWin32LocaleFactory failed."); + if (rv!=NS_OK) return rv; // // register the collation factory // - res = nsRepository::RegisterComponent(kCollationFactoryCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register CollationFactory failed."); - if (NS_FAILED(res)) return res; + rv = compMgr->RegisterComponent(kCollationFactoryCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: Register CollationFactory failed."); + if (NS_FAILED(rv)) return rv; // // register the collation interface // - res = nsRepository::RegisterComponent(kCollationCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register Collation failed."); - if (NS_FAILED(res)) return res; + rv = compMgr->RegisterComponent(kCollationCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: Register Collation failed."); + if (NS_FAILED(rv)) return rv; // // register the date time formatter // - res = nsRepository::RegisterComponent(kDateTimeFormatCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register DateTimeFormat failed."); - if (NS_FAILED(res)) return res; + rv = compMgr->RegisterComponent(kDateTimeFormatCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + NS_ASSERTION(rv==NS_OK,"nsLocaleTest: Register DateTimeFormat failed."); + if (NS_FAILED(rv)) return rv; return NS_OK; } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char * path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; - res = nsRepository::UnregisterFactory(kLocaleFactoryCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kLocaleFactoryCID, path); + if (rv!=NS_OK) return rv; - res = nsRepository::UnregisterFactory(kWin32LocaleFactoryCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kWin32LocaleFactoryCID, path); + if (rv!=NS_OK) return rv; - res = nsRepository::UnregisterFactory(kCollationFactoryCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kCollationFactoryCID, path); + if (rv!=NS_OK) return rv; - res = nsRepository::UnregisterFactory(kCollationCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kCollationCID, path); + if (rv!=NS_OK) return rv; - res = nsRepository::UnregisterFactory(kDateTimeFormatCID, path); - if (res!=NS_OK) return res; + rv = compMgr->UnregisterFactory(kDateTimeFormatCID, path); + if (rv!=NS_OK) return rv; return NS_OK; } diff --git a/mozilla/intl/locale/tests/LocaleSelfTest.cpp b/mozilla/intl/locale/tests/LocaleSelfTest.cpp index 7906ee9ed0f..82bc41a9d38 100644 --- a/mozilla/intl/locale/tests/LocaleSelfTest.cpp +++ b/mozilla/intl/locale/tests/LocaleSelfTest.cpp @@ -20,7 +20,7 @@ #include #define NS_IMPL_IDS #include "nsISupports.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsILocale.h" #include "nsILocaleFactory.h" @@ -167,7 +167,7 @@ static void TestCollation(nsILocale *locale) cout << "Start nsICollation Test \n"; cout << "==============================\n"; - res = nsRepository::CreateInstance(kCollationFactoryCID, + res = nsComponentManager::CreateInstance(kCollationFactoryCID, NULL, kICollationFactoryIID, (void**) &f); @@ -179,7 +179,7 @@ static void TestCollation(nsILocale *locale) f->Release(); } - res = nsRepository::CreateInstance(kCollationFactoryCID, + res = nsComponentManager::CreateInstance(kCollationFactoryCID, NULL, kICollationFactoryIID, (void**) &f); @@ -467,7 +467,7 @@ static void TestSort(nsILocale *locale, nsCollationStrength collationStrength, F cout << "Start sort Test \n"; cout << "==============================\n"; - res = nsRepository::CreateInstance(kCollationFactoryCID, + res = nsComponentManager::CreateInstance(kCollationFactoryCID, NULL, kICollationFactoryIID, (void**) &factoryInst); @@ -582,7 +582,7 @@ static void TestDateTimeFormat(nsILocale *locale) nsIDateTimeFormat *t = NULL; nsresult res; - res = nsRepository::CreateInstance(kDateTimeFormatCID, + res = nsComponentManager::CreateInstance(kDateTimeFormatCID, NULL, kIDateTimeFormatIID, (void**) &t); @@ -594,7 +594,7 @@ static void TestDateTimeFormat(nsILocale *locale) t->Release(); } - res = nsRepository::CreateInstance(kDateTimeFormatCID, + res = nsComponentManager::CreateInstance(kDateTimeFormatCID, NULL, kIDateTimeFormatIID, (void**) &t); @@ -684,7 +684,7 @@ static nsresult NewLocale(const nsString* localeName, nsILocale** locale) nsILocaleFactory* localeFactory; nsresult res; - res = nsRepository::FindFactory(kLocaleFactoryCID, (nsIFactory**)&localeFactory); + res = nsComponentManager::FindFactory(kLocaleFactoryCID, (nsIFactory**)&localeFactory); if (NS_FAILED(res) || localeFactory == nsnull) cout << "FindFactory nsILocaleFactory failed\n"; res = localeFactory->NewLocale(localeName, locale); @@ -719,25 +719,25 @@ int main(int argc, char** argv) { nsresult res; #if !XP_PC - res = nsRepository::RegisterComponent(kCollationFactoryCID, NULL, NULL, LOCALE_DLL_NAME, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kCollationFactoryCID, NULL, NULL, LOCALE_DLL_NAME, PR_FALSE, PR_FALSE); if (NS_FAILED(res)) cout << "RegisterComponent failed\n"; - res = nsRepository::RegisterComponent(kCollationCID, NULL, NULL, LOCALE_DLL_NAME, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kCollationCID, NULL, NULL, LOCALE_DLL_NAME, PR_FALSE, PR_FALSE); if (NS_FAILED(res)) cout << "RegisterComponent failed\n"; - res = nsRepository::RegisterComponent(kDateTimeFormatCID, NULL, NULL, LOCALE_DLL_NAME, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kDateTimeFormatCID, NULL, NULL, LOCALE_DLL_NAME, PR_FALSE, PR_FALSE); if (NS_FAILED(res)) cout << "RegisterComponent failed\n"; - res = nsRepository::RegisterComponent(kCharsetConverterManagerCID, NULL, NULL, UCONV_DLL, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kCharsetConverterManagerCID, NULL, NULL, UCONV_DLL, PR_FALSE, PR_FALSE); if (NS_FAILED(res)) cout << "RegisterComponent failed\n"; - res = nsRepository::RegisterComponent(kLatin1ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kLatin1ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); if (NS_FAILED(res)) cout << "RegisterComponent failed\n"; - res = nsRepository::RegisterComponent(kUnicharUtilCID, NULL, NULL, UNICHARUTIL_DLL_NAME, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kUnicharUtilCID, NULL, NULL, UNICHARUTIL_DLL_NAME, PR_FALSE, PR_FALSE); if (NS_FAILED(res)) cout << "RegisterComponent failed\n"; - res = nsRepository::RegisterComponent(kLocaleFactoryCID, NULL, NULL, LOCALE_DLL_NAME, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kLocaleFactoryCID, NULL, NULL, LOCALE_DLL_NAME, PR_FALSE, PR_FALSE); NS_ASSERTION(res==NS_OK,"nsLocaleTest: RegisterComponent failed."); #endif @@ -748,7 +748,7 @@ int main(int argc, char** argv) { #if 0 nsILocaleFactory* localeFactory; - res = nsRepository::FindFactory(kLocaleFactoryCID, (nsIFactory**)&localeFactory); + res = nsComponentManager::FindFactory(kLocaleFactoryCID, (nsIFactory**)&localeFactory); if (NS_FAILED(res) || localeFactory == nsnull) cout << "FindFactory nsILocaleFactory failed\n"; res = localeFactory->GetSystemLocale(&locale); @@ -820,11 +820,11 @@ int main(int argc, char** argv) { cout << "Finish All The Test Cases\n"; #if !XP_PC - res = nsRepository::FreeLibraries(); + res = nsComponentManager::FreeLibraries(); if(NS_FAILED(res)) - cout << "nsRepository failed\n"; + cout << "nsComponentManager failed\n"; else - cout << "nsRepository FreeLibraries Done\n"; + cout << "nsComponentManager FreeLibraries Done\n"; #endif return 0; diff --git a/mozilla/intl/locale/tests/nsLocaleTest.cpp b/mozilla/intl/locale/tests/nsLocaleTest.cpp index 3a69a6e9586..a69497647bc 100644 --- a/mozilla/intl/locale/tests/nsLocaleTest.cpp +++ b/mozilla/intl/locale/tests/nsLocaleTest.cpp @@ -19,7 +19,7 @@ #include "nsILocale.h" #include "nsILocaleFactory.h" #include "nsLocaleCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #ifdef XP_PC #include "nsIWin32Locale.h" #include @@ -62,7 +62,7 @@ factory_create_interface(void) nsILocaleFactory* localeFactory; nsIFactory* genericFactory; - result = nsRepository::CreateInstance(kLocaleFactoryCID, + result = nsComponentManager::CreateInstance(kLocaleFactoryCID, NULL, kILocaleFactoryIID, (void**)&localeFactory); @@ -71,7 +71,7 @@ factory_create_interface(void) localeFactory->Release(); - result = nsRepository::CreateInstance(kLocaleFactoryCID, + result = nsComponentManager::CreateInstance(kLocaleFactoryCID, NULL, kIFactoryIID, (void**)&genericFactory); @@ -89,7 +89,7 @@ factory_test_isupports(void) nsISupports* genericInterface1, *genericInterface2; nsIFactory* genericFactory1, *genericFactory2; - result = nsRepository::FindFactory(kLocaleFactoryCID, + result = nsComponentManager::FindFactory(kLocaleFactoryCID, (nsIFactory**)&localeFactory); NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed."); NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_create_interface failed"); @@ -146,7 +146,7 @@ factory_new_locale(void) int i; nsString** catagoryList, **valueList; - result = nsRepository::FindFactory(kLocaleFactoryCID, + result = nsComponentManager::FindFactory(kLocaleFactoryCID, (nsIFactory**)&localeFactory); NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed."); NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_create_interface failed"); @@ -222,7 +222,7 @@ factory_get_locale(void) nsString* catagory; nsString* value; - result = nsRepository::FindFactory(kLocaleFactoryCID, + result = nsComponentManager::FindFactory(kLocaleFactoryCID, (nsIFactory**)&localeFactory); NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed."); NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_create_interface failed"); @@ -290,7 +290,7 @@ win32factory_create_interface(void) nsIFactory* factory; nsIWin32Locale* win32Locale; - result = nsRepository::CreateInstance(kWin32LocaleFactoryCID, + result = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID, NULL, kIFactoryIID, (void**)&factory); @@ -299,7 +299,7 @@ win32factory_create_interface(void) factory->Release(); - result = nsRepository::CreateInstance(kWin32LocaleFactoryCID, + result = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID, NULL, kIWin32LocaleIID, (void**)&win32Locale); @@ -323,7 +323,7 @@ win32locale_test(void) locale = new nsString("en-US"); loc_id = 0; - result = nsRepository::CreateInstance(kWin32LocaleFactoryCID, + result = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID, NULL, kIWin32LocaleIID, (void**)&win32Locale); @@ -377,7 +377,7 @@ main(int argc, char** argv) // // register the Locale Factory // - res = nsRepository::RegisterComponent(kLocaleFactoryCID, + res = nsComponentManager::RegisterComponent(kLocaleFactoryCID, NULL, NULL, LOCALE_DLL_NAME, @@ -390,7 +390,7 @@ main(int argc, char** argv) // // register the Windows specific factory // - res = nsRepository::RegisterComponent(kWin32LocaleFactoryCID, + res = nsComponentManager::RegisterComponent(kWin32LocaleFactoryCID, NULL, NULL, LOCALE_DLL_NAME, diff --git a/mozilla/intl/lwbrk/src/nsLWBrk.cpp b/mozilla/intl/lwbrk/src/nsLWBrk.cpp index 3be6284165f..b0c742e2f6d 100644 --- a/mozilla/intl/lwbrk/src/nsLWBrk.cpp +++ b/mozilla/intl/lwbrk/src/nsLWBrk.cpp @@ -18,13 +18,16 @@ #include "pratom.h" #include "nsISupports.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" +#include "nsCOMPtr.h" #include "nsIFactory.h" #include "nsLWBrkCIID.h" #include "nsILineBreakerFactory.h" #include "nsIWordBreakerFactory.h" #include "nsLWBreakerFImp.h" +#include "nsIServiceManager.h" +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); NS_DEFINE_CID(kLWBrkCID, NS_LWBRK_CID); @@ -79,7 +82,7 @@ nsresult nsLWBrkFactory::CreateInstance(nsISupports *aDelegate, return res; } -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, const nsCID &aClass, const char *aClassName, const char *aProgID, @@ -100,17 +103,25 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, return NS_NOINTERFACE; } -extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) { +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *path) { - return nsRepository::RegisterComponent(kLWBrkCID, NULL, NULL, path, - PR_TRUE, PR_TRUE); + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + + return compMgr->RegisterComponent(kLWBrkCID, NULL, NULL, path, + PR_TRUE, PR_TRUE); } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char *path) { - return nsRepository::UnregisterFactory(kLWBrkCID, path); + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + + return compMgr->UnregisterFactory(kLWBrkCID, path); } diff --git a/mozilla/intl/lwbrk/tests/TestLineBreak.cpp b/mozilla/intl/lwbrk/tests/TestLineBreak.cpp index 12627d5055f..312e0348c6f 100644 --- a/mozilla/intl/lwbrk/tests/TestLineBreak.cpp +++ b/mozilla/intl/lwbrk/tests/TestLineBreak.cpp @@ -16,7 +16,7 @@ * Reserved. */ #include -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsISupports.h" #include "nsIServiceManager.h" #include "nsILineBreakerFactory.h" @@ -373,7 +373,7 @@ PRBool TestWordBreaker() extern "C" void NS_SetupRegistry() { - nsRepository::RegisterComponent(kLWBrkCID, NULL, NULL, LWBRK_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kLWBrkCID, NULL, NULL, LWBRK_DLL, PR_FALSE, PR_FALSE); } void SamplePrintWordWithBreak(); @@ -579,12 +579,12 @@ int main(int argc, char** argv) { // -------------------------------------------- cout << "Finish All The Test Cases\n"; nsresult res = NS_OK; - res = nsRepository::FreeLibraries(); + res = nsComponentManager::FreeLibraries(); if(NS_FAILED(res)) - cout << "nsRepository failed\n"; + cout << "nsComponentManager failed\n"; else - cout << "nsRepository FreeLibraries Done\n"; + cout << "nsComponentManager FreeLibraries Done\n"; if(lbok && wbok) cout << "Line/Word Break Test\nOK\n"; else diff --git a/mozilla/intl/strres/src/nsStringBundle.cpp b/mozilla/intl/strres/src/nsStringBundle.cpp index e1990b51c3f..2bd036fce1c 100644 --- a/mozilla/intl/strres/src/nsStringBundle.cpp +++ b/mozilla/intl/strres/src/nsStringBundle.cpp @@ -24,11 +24,15 @@ #include "nscore.h" #include "nsILocale.h" #include "nsINetService.h" -#include "nsIServiceManager.h" #include "nsIURL.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" +#include "nsIServiceManager.h" +#include "nsCOMPtr.h" #include "nsString.h" #include "pratom.h" +#include "nsIServiceManager.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static PRInt32 gLockCount = 0; @@ -66,19 +70,25 @@ nsStringBundle::nsStringBundle(nsIURL* aURL, nsILocale* aLocale, *aResult = nsServiceManager::GetService(kNetServiceCID, kINetServiceIID, (nsISupports**) &pNetService); if (NS_FAILED(*aResult)) { +#ifdef NS_DEBUG printf("cannot get net service\n"); +#endif return; } nsIInputStream *in = nsnull; *aResult = pNetService->OpenBlockingStream(aURL, nsnull, &in); if (NS_FAILED(*aResult)) { +#ifdef NS_DEBUG printf("cannot open stream\n"); +#endif return; } - *aResult = nsRepository::CreateInstance(kPropertiesCID, NULL, + *aResult = nsComponentManager::CreateInstance(kPropertiesCID, NULL, kIPropertiesIID, (void**) &mProps); if (NS_FAILED(*aResult)) { +#ifdef NS_DEBUG printf("create nsIProperties failed\n"); +#endif return; } *aResult = mProps->Load(in); @@ -208,34 +218,38 @@ nsStringBundleServiceFactory::LockFactory(PRBool aLock) } extern "C" NS_EXPORT nsresult -NSRegisterSelf(nsISupports* serviceMgr, const char* path) +NSRegisterSelf(nsISupports* aServMgr, const char* path) { - nsresult ret; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; - ret = nsRepository::RegisterComponent(kStringBundleServiceCID, NULL, NULL, path, + rv = compMgr->RegisterComponent(kStringBundleServiceCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - if (NS_FAILED(ret)) { - return ret; + if (NS_FAILED(rv)) { + return rv; } - return ret; + return rv; } extern "C" NS_EXPORT nsresult -NSUnregisterSelf(nsISupports* serviceMgr, const char* path) +NSUnregisterSelf(nsISupports* aServMgr, const char* path) { - nsresult ret; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; - ret = nsRepository::UnregisterFactory(kStringBundleServiceCID, path); - if (NS_FAILED(ret)) { - return ret; + rv = compMgr->UnregisterFactory(kStringBundleServiceCID, path); + if (NS_FAILED(rv)) { + return rv; } - return ret; + return rv; } extern "C" NS_EXPORT nsresult -NSGetFactory(nsISupports* serviceMgr, +NSGetFactory(nsISupports* aServMgr, const nsCID &aClass, const char *aClassName, const char *aProgID, diff --git a/mozilla/intl/strres/tests/StringBundleTest.cpp b/mozilla/intl/strres/tests/StringBundleTest.cpp index 378c0b61fba..375bcc925f9 100644 --- a/mozilla/intl/strres/tests/StringBundleTest.cpp +++ b/mozilla/intl/strres/tests/StringBundleTest.cpp @@ -21,7 +21,7 @@ #include "nsILocale.h" #include "nsINetService.h" #include "nsIServiceManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsXPComCIID.h" #define TEST_URL "resource:/res/strres.properties" @@ -49,7 +49,7 @@ main(int argc, char *argv[]) return 1; } - nsRepository::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, + nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); nsIEventQueueService* pEventQueueService = nsnull; ret = nsServiceManager::GetService(kEventQueueServiceCID, @@ -64,7 +64,7 @@ main(int argc, char *argv[]) return 1; } - nsRepository::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); nsINetService* pNetService = nsnull; ret = nsServiceManager::GetService(kNetServiceCID, kINetServiceIID, (nsISupports**) &pNetService); diff --git a/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp b/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp index 99edf01b56b..869785fb794 100644 --- a/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp +++ b/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp @@ -21,7 +21,7 @@ #include "pratom.h" #include "nsString.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsICharsetConverterManager.h" #include "nsICharsetConverterInfo.h" #include "nsIUnicodeEncoder.h" @@ -264,7 +264,7 @@ nsCharsetConverterManager::GetICharsetConverterInfo(ConverterInfo * aArray, nsIFactory * factory; nsICharsetConverterInfo * info; - res=nsRepository::FindFactory(*(aArray[aIndex].mCID), &factory); + res=nsComponentManager::FindFactory(*(aArray[aIndex].mCID), &factory); if (NS_FAILED(res)) goto reduceArray; res=factory->QueryInterface(kICharsetConverterInfoIID, (void ** )&info); @@ -300,7 +300,7 @@ nsresult nsCharsetConverterManager::GetCharsetConverter( *aResult = NULL; for (PRInt32 i=0; iEqualsIgnoreCase(*(aArray[i].mCharset))) { - res = nsRepository::CreateInstance(*(aArray[i].mCID),NULL,*aCID,aResult); + res = nsComponentManager::CreateInstance(*(aArray[i].mCID),NULL,*aCID,aResult); break; } diff --git a/mozilla/intl/uconv/src/nsUConvDll.cpp b/mozilla/intl/uconv/src/nsUConvDll.cpp index 57b37d9da8b..b90e1b3524e 100644 --- a/mozilla/intl/uconv/src/nsUConvDll.cpp +++ b/mozilla/intl/uconv/src/nsUConvDll.cpp @@ -17,7 +17,8 @@ * Netscape Communications Corporation. All Rights Reserved. */ -#include "nsRepository.h" +#include "nsIComponentManager.h" +#include "nsCOMPtr.h" #include "nsICharsetConverterManager.h" #include "nsCharsetConverterManager.h" #include "nsIUnicodeEncodeHelper.h" @@ -26,6 +27,9 @@ #include "nsPlatformCharsetFactory.h" #include "nsICharsetAlias.h" #include "nsCharsetAliasFactory.h" +#include "nsIServiceManager.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); //---------------------------------------------------------------------- // Global functions and data [declaration] @@ -38,12 +42,12 @@ extern "C" PRInt32 g_LockCount = 0; NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, const nsCID &aClass, const char *aClassName, const char *aProgID, @@ -102,40 +106,44 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, return NS_NOINTERFACE; } -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char * path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; - res = nsRepository::RegisterComponent(kUnicodeEncodeHelperCID, NULL, NULL, + rv = compMgr->RegisterComponent(kUnicodeEncodeHelperCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; + if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) return rv; - res = nsRepository::RegisterComponent(kCharsetAliasCID, NULL, NULL, path, + rv = compMgr->RegisterComponent(kCharsetAliasCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; + if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) return rv; - res = nsRepository::RegisterComponent(kCharsetConverterManagerCID, NULL, NULL, + rv = compMgr->RegisterComponent(kCharsetConverterManagerCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; + if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) return rv; - res = nsRepository::RegisterComponent(kPlatformCharsetCID, NULL, NULL, path, + rv = compMgr->RegisterComponent(kPlatformCharsetCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - return res; + return rv; } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char * path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; - res = nsRepository::UnregisterFactory(kUnicodeEncodeHelperCID, path); - if(NS_FAILED(res)) return res; + rv = compMgr->UnregisterFactory(kUnicodeEncodeHelperCID, path); + if(NS_FAILED(rv)) return rv; - res = nsRepository::UnregisterFactory(kCharsetAliasCID, path); - if(NS_FAILED(res)) return res; + rv = compMgr->UnregisterFactory(kCharsetAliasCID, path); + if(NS_FAILED(rv)) return rv; - res = nsRepository::UnregisterFactory(kCharsetConverterManagerCID, path); - if(NS_FAILED(res)) return res; + rv = compMgr->UnregisterFactory(kCharsetConverterManagerCID, path); + if(NS_FAILED(rv)) return rv; - res = nsRepository::UnregisterFactory(kPlatformCharsetCID, path); - return res; + rv = compMgr->UnregisterFactory(kPlatformCharsetCID, path); + return rv; } diff --git a/mozilla/intl/uconv/src/nsUnicodeDecodeUtil.cpp b/mozilla/intl/uconv/src/nsUnicodeDecodeUtil.cpp index 14a7746fa9d..27a00cf7998 100644 --- a/mozilla/intl/uconv/src/nsUnicodeDecodeUtil.cpp +++ b/mozilla/intl/uconv/src/nsUnicodeDecodeUtil.cpp @@ -19,7 +19,7 @@ #include "pratom.h" #include "nsUConvDll.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsUnicodeDecodeUtil.h" #include "nsIUnicodeDecoder.h" diff --git a/mozilla/intl/uconv/tests/nsTestUConv.cpp b/mozilla/intl/uconv/tests/nsTestUConv.cpp index 7ebaeadf7e6..79e7e1bbb7d 100644 --- a/mozilla/intl/uconv/tests/nsTestUConv.cpp +++ b/mozilla/intl/uconv/tests/nsTestUConv.cpp @@ -21,6 +21,7 @@ #include #include +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsISupports.h" #include "nsICharsetConverterManager.h" @@ -80,25 +81,25 @@ nsresult setupRegistry() { nsresult res; - res = nsRepository::RegisterComponent(kCharsetConverterManagerCID, NULL, NULL, UCONV_DLL, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kCharsetConverterManagerCID, NULL, NULL, UCONV_DLL, PR_FALSE, PR_FALSE); if (NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; - res = nsRepository::RegisterComponent(kLatin1ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kLatin1ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); if (NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; - res = nsRepository::RegisterComponent(kCP1253ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kCP1253ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); if (NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; - res = nsRepository::RegisterComponent(kISO88597ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kISO88597ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); if (NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; - res = nsRepository::RegisterComponent(kSJIS2UnicodeCID, NULL, NULL, UCVJA_DLL, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kSJIS2UnicodeCID, NULL, NULL, UCVJA_DLL, PR_FALSE, PR_FALSE); if (NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; - res = nsRepository::RegisterComponent(kISO2022JPToUnicodeCID, NULL, NULL, UCVJA2_DLL, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kISO2022JPToUnicodeCID, NULL, NULL, UCVJA2_DLL, PR_FALSE, PR_FALSE); if (NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; - res = nsRepository::RegisterComponent(kPlatformCharsetCID, NULL, NULL, UCONV_DLL, PR_FALSE, PR_FALSE); + res = nsComponentManager::RegisterComponent(kPlatformCharsetCID, NULL, NULL, UCONV_DLL, PR_FALSE, PR_FALSE); if (NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; return NS_OK; diff --git a/mozilla/intl/uconv/ucvja/nsSJIS2Unicode.cpp b/mozilla/intl/uconv/ucvja/nsSJIS2Unicode.cpp index bb8afcc3fbb..e1ab9a51bc8 100644 --- a/mozilla/intl/uconv/ucvja/nsSJIS2Unicode.cpp +++ b/mozilla/intl/uconv/ucvja/nsSJIS2Unicode.cpp @@ -18,7 +18,7 @@ */ #include "pratom.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsSJIS2Unicode.h" #include "nsUCVJADll.h" @@ -74,7 +74,7 @@ NS_IMETHODIMP nsSJIS2Unicode::Convert(PRUnichar * aDest, PRInt32 aDestOffset, if(nsnull == mUtil) { nsresult res = NS_OK; - res = nsRepository::CreateInstance( + res = nsComponentManager::CreateInstance( kCharsetConverterManagerCID, NULL, kIUnicodeDecodeUtilIID, diff --git a/mozilla/intl/uconv/ucvja/nsUCVJADll.cpp b/mozilla/intl/uconv/ucvja/nsUCVJADll.cpp index c75ae1b1186..401297edd7a 100644 --- a/mozilla/intl/uconv/ucvja/nsUCVJADll.cpp +++ b/mozilla/intl/uconv/ucvja/nsUCVJADll.cpp @@ -20,11 +20,14 @@ #define NS_IMPL_IDS #include "pratom.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIFactory.h" #include "nsICharsetConverterInfo.h" #include "nsUCVJACID.h" #include "nsSJIS2Unicode.h" +#include "nsIServiceManager.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); // just for NS_IMPL_IDS; this is a good, central place to implement GUIDs #include "nsIUnicodeDecoder.h" @@ -110,12 +113,12 @@ public: NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, const nsCID &aClass, const char *aClassName, const char *aProgID, @@ -144,29 +147,33 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, return NS_NOINTERFACE; } -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char * path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; for (PRUint32 i=0; iRegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL, path, PR_TRUE, PR_TRUE); - if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; + if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) return rv; } - return res; + return rv; } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char * path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; for (PRUint32 i=0; iUnregisterFactory(*(g_FactoryData[i].mCID), path); + if(NS_FAILED(rv)) return rv; } - return res; + return rv; } //---------------------------------------------------------------------- diff --git a/mozilla/intl/uconv/ucvja2/nsEUCJPToUnicode.cpp b/mozilla/intl/uconv/ucvja2/nsEUCJPToUnicode.cpp index 7eff0fc1dea..57a74ec0b7d 100644 --- a/mozilla/intl/uconv/ucvja2/nsEUCJPToUnicode.cpp +++ b/mozilla/intl/uconv/ucvja2/nsEUCJPToUnicode.cpp @@ -18,7 +18,7 @@ */ #include "pratom.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsEUCJPToUnicode.h" #include "nsUCVJA2Dll.h" @@ -101,7 +101,7 @@ NS_IMETHODIMP nsEUCJPToUnicode::Convert(PRUnichar * aDest, PRInt32 aDestOffset, if(nsnull == mUtil) { nsresult res = NS_OK; - res = nsRepository::CreateInstance( + res = nsComponentManager::CreateInstance( kCharsetConverterManagerCID, NULL, kIUnicodeDecodeUtilIID, diff --git a/mozilla/intl/uconv/ucvja2/nsISO2022JPToUnicode.cpp b/mozilla/intl/uconv/ucvja2/nsISO2022JPToUnicode.cpp index 2d3c7aa8007..f93c7db25d5 100644 --- a/mozilla/intl/uconv/ucvja2/nsISO2022JPToUnicode.cpp +++ b/mozilla/intl/uconv/ucvja2/nsISO2022JPToUnicode.cpp @@ -18,7 +18,7 @@ */ #include "pratom.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsISO2022JPToUnicode.h" #include "nsUCVJA2Dll.h" @@ -81,7 +81,7 @@ nsresult nsISO2022JPToUnicode::ConvertBuffer(const char ** aSrc, if (mHelper == nsnull) { // XXX change the helper object to have its own CID! - res = nsRepository::CreateInstance(kCharsetConverterManagerCID, NULL, + res = nsComponentManager::CreateInstance(kCharsetConverterManagerCID, NULL, kIUnicodeDecodeUtilIID, (void**) & mHelper); if (NS_FAILED(res)) return res; diff --git a/mozilla/intl/uconv/ucvja2/nsUCVJA2Dll.cpp b/mozilla/intl/uconv/ucvja2/nsUCVJA2Dll.cpp index ff5d6cba7d1..987b22b5eb6 100644 --- a/mozilla/intl/uconv/ucvja2/nsUCVJA2Dll.cpp +++ b/mozilla/intl/uconv/ucvja2/nsUCVJA2Dll.cpp @@ -20,12 +20,15 @@ #define NS_IMPL_IDS #include "pratom.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIFactory.h" #include "nsICharsetConverterInfo.h" #include "nsUCVJA2CID.h" #include "nsEUCJPToUnicode.h" #include "nsISO2022JPToUnicode.h" +#include "nsIServiceManager.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); // just for NS_IMPL_IDS; this is a good, central place to implement GUIDs #include "nsIUnicodeDecoder.h" @@ -129,12 +132,12 @@ public: NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, const nsCID &aClass, const char *aClassName, const char *aProgID, @@ -163,29 +166,33 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, return NS_NOINTERFACE; } -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char * path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; for (PRUint32 i=0; iRegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL, path, PR_TRUE, PR_TRUE); - if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; + if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) return rv; } - return res; + return rv; } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char * path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; for (PRUint32 i=0; iUnregisterFactory(*(g_FactoryData[i].mCID), path); + if(NS_FAILED(rv)) return rv; } - return res; + return rv; } //---------------------------------------------------------------------- diff --git a/mozilla/intl/uconv/ucvlatin/ns1ByteToUnicodeBase.cpp b/mozilla/intl/uconv/ucvlatin/ns1ByteToUnicodeBase.cpp index b4ac58f88e9..8e599512bac 100644 --- a/mozilla/intl/uconv/ucvlatin/ns1ByteToUnicodeBase.cpp +++ b/mozilla/intl/uconv/ucvlatin/ns1ByteToUnicodeBase.cpp @@ -19,7 +19,7 @@ #include "pratom.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIUnicodeDecoder.h" #include "nsIUnicodeDecodeUtil.h" #include "nsICharsetConverterManager.h" @@ -46,7 +46,7 @@ NS_IMETHODIMP ns1ByteToUnicodeBase::Convert(PRUnichar * aDest, PRInt32 aDestOffs if(nsnull == mUtil) { nsresult res = NS_OK; - res = nsRepository::CreateInstance( + res = nsComponentManager::CreateInstance( kCharsetConverterManagerCID, NULL, kIUnicodeDecodeUtilIID, diff --git a/mozilla/intl/uconv/ucvlatin/ns1ByteToUnicodeBase.h b/mozilla/intl/uconv/ucvlatin/ns1ByteToUnicodeBase.h index 90a4ba14509..a0a67686bb5 100644 --- a/mozilla/intl/uconv/ucvlatin/ns1ByteToUnicodeBase.h +++ b/mozilla/intl/uconv/ucvlatin/ns1ByteToUnicodeBase.h @@ -20,7 +20,7 @@ #ifndef ns1ByteToUnicodeBase_h__ #define ns1ByteToUnicodeBase_h__ -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIUnicodeDecoder.h" #include "nsIUnicodeDecodeUtil.h" diff --git a/mozilla/intl/uconv/ucvlatin/nsUCvLatinDll.cpp b/mozilla/intl/uconv/ucvlatin/nsUCvLatinDll.cpp index daafbeb7543..89844d6dae3 100644 --- a/mozilla/intl/uconv/ucvlatin/nsUCvLatinDll.cpp +++ b/mozilla/intl/uconv/ucvlatin/nsUCvLatinDll.cpp @@ -20,7 +20,7 @@ #define NS_IMPL_IDS #include "pratom.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIFactory.h" #include "nsICharsetConverterInfo.h" #include "nsUCvLatinCID.h" @@ -28,6 +28,9 @@ #include "nsISO88597ToUnicode.h" #include "nsCP1253ToUnicode.h" #include "nsUnicodeToLatin1.h" +#include "nsIServiceManager.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); // just for NS_IMPL_IDS; this is a good, central place to implement GUIDs #include "nsIUnicodeEncoder.h" @@ -133,12 +136,12 @@ public: NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, const nsCID &aClass, const char *aClassName, const char *aProgID, @@ -167,29 +170,33 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, return NS_NOINTERFACE; } -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char * path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; for (PRUint32 i=0; iRegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL, path, PR_TRUE, PR_TRUE); - if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res; + if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) return rv; } - return res; + return rv; } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char * path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path) { - nsresult res; + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; for (PRUint32 i=0; iUnregisterFactory(*(g_FactoryData[i].mCID), path); + if(NS_FAILED(rv)) return rv; } - return res; + return rv; } //---------------------------------------------------------------------- diff --git a/mozilla/intl/uconv/ucvlatin/nsUCvLatinSupport.cpp b/mozilla/intl/uconv/ucvlatin/nsUCvLatinSupport.cpp index d69b429aee4..8f927f0c8d6 100644 --- a/mozilla/intl/uconv/ucvlatin/nsUCvLatinSupport.cpp +++ b/mozilla/intl/uconv/ucvlatin/nsUCvLatinSupport.cpp @@ -18,7 +18,7 @@ */ #include "pratom.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsUCvLatinSupport.h" #include "nsUCvLatinDll.h" @@ -296,7 +296,7 @@ NS_IMETHODIMP nsTableEncoderSupport::ConvertNoBuffNoErr( nsresult res; if (mHelper == nsnull) { - res = nsRepository::CreateInstance(kUnicodeEncodeHelperCID, NULL, + res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL, kIUnicodeEncodeHelperIID, (void**) & mHelper); if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER; diff --git a/mozilla/intl/unicharutil/src/nsUnicharUtilFactory.cpp b/mozilla/intl/unicharutil/src/nsUnicharUtilFactory.cpp index 3c403227a06..90476492033 100644 --- a/mozilla/intl/unicharutil/src/nsUnicharUtilFactory.cpp +++ b/mozilla/intl/unicharutil/src/nsUnicharUtilFactory.cpp @@ -19,12 +19,14 @@ #include "pratom.h" #include "nsUUDll.h" #include "nsISupports.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIFactory.h" #include "nsUnicharUtilCIID.h" #include "nsICaseConversion.h" #include "nsCaseConversionImp2.h" +#include "nsIServiceManager.h" +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); NS_DEFINE_IID(kFactoryIID, NS_IFACTORY_IID); NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID); @@ -82,7 +84,7 @@ nsresult nsUnicharUtilFactory::CreateInstance(nsISupports *aDelegate, return res; } -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, const nsCID &aClass, const char *aClassName, const char *aProgID, @@ -103,16 +105,24 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, return NS_NOINTERFACE; } -extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) { +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *path) { - return nsRepository::RegisterComponent(kUnicharUtilCID, NULL, NULL, path, - PR_TRUE, PR_TRUE); + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + + return compMgr->RegisterComponent(kUnicharUtilCID, NULL, NULL, path, + PR_TRUE, PR_TRUE); } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char *path) { - return nsRepository::UnregisterFactory(kUnicharUtilCID, path); + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + + return compMgr->UnregisterFactory(kUnicharUtilCID, path); } diff --git a/mozilla/intl/unicharutil/tests/UnicharSelfTest.cpp b/mozilla/intl/unicharutil/tests/UnicharSelfTest.cpp index 6b883a6f899..5395913eb3a 100644 --- a/mozilla/intl/unicharutil/tests/UnicharSelfTest.cpp +++ b/mozilla/intl/unicharutil/tests/UnicharSelfTest.cpp @@ -18,6 +18,7 @@ #include #include "nsISupports.h" #include "nsIServiceManager.h" +#include "nsIComponentManager.h" #include "nsICaseConversion.h" #include "nsUnicharUtilCIID.h" @@ -347,7 +348,7 @@ void TestCaseConversion() void RegisterFactories() { nsresult res; - res = nsRepository::RegisterComponent(kUnicharUtilCID, + res = nsComponentManager::RegisterComponent(kUnicharUtilCID, NULL, NULL, UNICHARUTIL_DLL_NAME, @@ -370,11 +371,11 @@ int main(int argc, char** argv) { // -------------------------------------------- cout << "Finish All The Test Cases\n"; nsresult res = NS_OK; - res = nsRepository::FreeLibraries(); + res = nsComponentManager::FreeLibraries(); if(NS_FAILED(res)) - cout << "nsRepository failed\n"; + cout << "nsComponentManager failed\n"; else - cout << "nsRepository FreeLibraries Done\n"; + cout << "nsComponentManager FreeLibraries Done\n"; return 0; } diff --git a/mozilla/js/src/liveconnect/nsCLiveconnectFactory.cpp b/mozilla/js/src/liveconnect/nsCLiveconnectFactory.cpp index e0adc384849..9bf0d72b455 100644 --- a/mozilla/js/src/liveconnect/nsCLiveconnectFactory.cpp +++ b/mozilla/js/src/liveconnect/nsCLiveconnectFactory.cpp @@ -29,7 +29,7 @@ #include "nsCLiveconnect.h" #include "nsCLiveconnectFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); diff --git a/mozilla/js/src/xpconnect/test/TestXPC.cpp b/mozilla/js/src/xpconnect/test/TestXPC.cpp index 19af1e8d02c..af71ea3783d 100644 --- a/mozilla/js/src/xpconnect/test/TestXPC.cpp +++ b/mozilla/js/src/xpconnect/test/TestXPC.cpp @@ -46,7 +46,7 @@ static NS_DEFINE_IID(kAllocatorCID, NS_ALLOCATOR_CID); static void RegAllocator() { - nsRepository::RegisterComponent(kAllocatorCID, NULL, NULL, XPCOM_DLL, + nsComponentManager::RegisterComponent(kAllocatorCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); } @@ -650,4 +650,4 @@ void Datom(JSAtom *atom) { if (atom) DumpAtom(&atom->entry, 0, gErrFile); } void Dobj(nsISupports* p, int depth) {if(p)XPC_DUMP(p,depth);} void Dxpc(int depth) {Dobj(XPC_GetXPConnect(), depth);} JS_END_EXTERN_C -#endif \ No newline at end of file +#endif diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index a3298810c65..3ef785dbb6e 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -557,7 +557,7 @@ PresShell::Init(nsIDocument* aDocument, NS_ADDREF(aStyleSet); nsCOMPtrdomselection; - nsresult result = nsRepository::CreateInstance(kRangeListCID, nsnull, + nsresult result = nsComponentManager::CreateInstance(kRangeListCID, nsnull, kIDOMSelectionIID, getter_AddRefs(domselection)); if (!NS_SUCCEEDED(result)) @@ -570,7 +570,7 @@ PresShell::Init(nsIDocument* aDocument, // XXX This code causes the document object (and the entire content model) to be leaked... #if 0 nsCOMPtrrange; - if (NS_SUCCEEDED(nsRepository::CreateInstance(kCRangeCID, nsnull, kIDOMRangeIID, getter_AddRefs(range)))){ //create an irange + if (NS_SUCCEEDED(nsComponentManager::CreateInstance(kCRangeCID, nsnull, kIDOMRangeIID, getter_AddRefs(range)))){ //create an irange nsCOMPtrdoc(GetDocument()); nsCOMPtrdomDoc(doc); if (domDoc){ @@ -1493,7 +1493,7 @@ PresShell::DoCopy(nsISelectionMgr* aSelectionMgr) static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - nsresult rv = nsRepository::CreateInstance(kCParserCID, + nsresult rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); @@ -2200,7 +2200,7 @@ PresShell::VerifyIncrementalReflow() void* nativeParentWidget = rootWidget->GetNativeData(NS_NATIVE_WIDGET); // Create a new view manager. - rv = nsRepository::CreateInstance(kViewManagerCID, nsnull, kIViewManagerIID, + rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull, kIViewManagerIID, (void**) &vm); if ((NS_OK != rv) || (NS_OK != vm->Init(dc))) { NS_ASSERTION(NS_OK == rv, "failed to create view manager"); @@ -2212,7 +2212,7 @@ PresShell::VerifyIncrementalReflow() // Create a view nsRect tbounds; mPresContext->GetVisibleArea(tbounds); - rv = nsRepository::CreateInstance(kScrollingViewCID, nsnull, kIViewIID, + rv = nsComponentManager::CreateInstance(kScrollingViewCID, nsnull, kIViewIID, (void **) &view); if ((NS_OK != rv) || (NS_OK != view->Init(vm, tbounds, nsnull))) { NS_ASSERTION(NS_OK == rv, "failed to create scroll view"); diff --git a/mozilla/layout/base/src/nsRangeList.cpp b/mozilla/layout/base/src/nsRangeList.cpp index b0c227defe1..86630ee9d4d 100644 --- a/mozilla/layout/base/src/nsRangeList.cpp +++ b/mozilla/layout/base/src/nsRangeList.cpp @@ -26,7 +26,7 @@ #include "nsIFrameSelection.h" #include "nsIDOMSelection.h" #include "nsIFocusTracker.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsLayoutCID.h" #include "nsIContent.h" #include "nsIDOMNode.h" @@ -1187,7 +1187,7 @@ nsRangeList::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset) Clear(); nsCOMPtr range; - result = nsRepository::CreateInstance(kRangeCID, nsnull, + result = nsComponentManager::CreateInstance(kRangeCID, nsnull, kIDOMRangeIID, getter_AddRefs(range)); if (NS_FAILED(result)) diff --git a/mozilla/layout/build/nsLayoutCID.h b/mozilla/layout/build/nsLayoutCID.h index 743a5b7cc72..0a1a26c5e27 100644 --- a/mozilla/layout/build/nsLayoutCID.h +++ b/mozilla/layout/build/nsLayoutCID.h @@ -21,7 +21,7 @@ #include "nsISupports.h" #include "nsIFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #define NS_HTMLDOCUMENT_CID \ { /* 5d0fcdd0-4daa-11d2-b328-00805f8a3859 */ \ diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index ba3c2c85b20..81d3b1aa740 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -30,7 +30,7 @@ #include "nsIFileWidget.h" #include "nsITextWidget.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIView.h" #include "nsHTMLParts.h" #include "nsIDOMHTMLInputElement.h" diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp index c619f43d117..b0629e30ab2 100644 --- a/mozilla/layout/forms/nsFileControlFrame.cpp +++ b/mozilla/layout/forms/nsFileControlFrame.cpp @@ -30,7 +30,7 @@ #include "nsIFileWidget.h" #include "nsITextWidget.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIView.h" #include "nsHTMLParts.h" #include "nsIDOMHTMLInputElement.h" @@ -157,7 +157,7 @@ void nsFileControlFrame::MouseClicked(nsIPresContext* aPresContext) nsIFileWidget *fileWidget; nsString title("FileWidget Title mode = save"); - nsRepository::CreateInstance(kCFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget); + nsComponentManager::CreateInstance(kCFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget); nsString titles[] = {"all files"}; nsString filters[] = {"*.*"}; diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp index 1be50e114a7..3f1efcd84c6 100644 --- a/mozilla/layout/forms/nsFormControlFrame.cpp +++ b/mozilla/layout/forms/nsFormControlFrame.cpp @@ -31,7 +31,7 @@ #include "nsCoord.h" #include "nsWidgetsCID.h" #include "nsViewsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsGUIEvent.h" #include "nsDOMEvent.h" #include "nsIFontMetrics.h" @@ -255,7 +255,7 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext, nsIView* view = nsnull; GetView(&view); if (nsnull == view) { - result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); + result = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); if (!NS_SUCCEEDED(result)) { NS_ASSERTION(0, "Could not create view for form control"); aStatus = NS_FRAME_NOT_COMPLETE; diff --git a/mozilla/layout/forms/nsFormControlHelper.cpp b/mozilla/layout/forms/nsFormControlHelper.cpp index 48a26214394..55c0f717ec2 100644 --- a/mozilla/layout/forms/nsFormControlHelper.cpp +++ b/mozilla/layout/forms/nsFormControlHelper.cpp @@ -31,7 +31,7 @@ #include "nsCoord.h" #include "nsWidgetsCID.h" #include "nsViewsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsGUIEvent.h" #include "nsDOMEvent.h" #include "nsIFontMetrics.h" diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp index f6d15684bdf..3cbeb6393e9 100644 --- a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp @@ -40,7 +40,7 @@ #include "nsIHTMLAttributes.h" #include "nsGenericHTMLElement.h" #include "nsIWidget.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIView.h" #include "nsIViewManager.h" #include "nsViewsCID.h" @@ -519,7 +519,7 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext& aPresContext, nsIView* view; GetView(&view); if (!view) { - nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); + nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); nsCOMPtr presShell; aPresContext.GetShell(getter_AddRefs(presShell)); nsCOMPtr viewMan; diff --git a/mozilla/layout/forms/nsImageControlFrame.cpp b/mozilla/layout/forms/nsImageControlFrame.cpp index 5cb3105d4de..58528e685c6 100644 --- a/mozilla/layout/forms/nsImageControlFrame.cpp +++ b/mozilla/layout/forms/nsImageControlFrame.cpp @@ -187,7 +187,7 @@ nsImageControlFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIView* view; GetView(&view); if (!view) { - nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); + nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); nsCOMPtr presShell; aPresContext.GetShell(getter_AddRefs(presShell)); nsCOMPtr viewMan; diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index abcbab39acc..6ab326734d2 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -44,7 +44,7 @@ #include "nsIDeviceContext.h" #include "nsIFontMetrics.h" #include "nsILookAndFeel.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #ifdef SingleSignon #include "nsIDocument.h" @@ -110,7 +110,7 @@ nsTextControlFrame::GetVerticalInsidePadding(float aPixToTwip, PRInt32 vertPad; PRInt32 shouldUseVertPad; nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_TextAreaVerticalInsidePadding, padTextArea); lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_TextFieldVerticalInsidePadding, padTextField); // These two (below) are really only needed for GTK @@ -154,7 +154,7 @@ nsTextControlFrame::GetHorizontalInsidePadding(nsIPresContext& aPresContext, PRInt32 shouldUsePadMinText; nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_TextFieldHorizontalInsidePadding, padTextField); lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_TextAreaHorizontalInsidePadding, padTextArea); lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextHorizontalInsideMinimumPadding, padMinText); diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index f85834df77f..0b96d699c36 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -23,7 +23,7 @@ #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsHTMLIIDs.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIStreamListener.h" #include "nsIURL.h" #include "nsIDocument.h" @@ -647,7 +647,7 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext& aPresContext, nsIContent* content; GetParentContent(content); - rv = nsRepository::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, + rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&mWebShell); if (NS_OK != rv) { NS_ASSERTION(0, "could not create web widget"); @@ -704,7 +704,7 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext& aPresContext, // create, init, set the parent of the view nsIView* view; - rv = nsRepository::CreateInstance(kCViewCID, nsnull, kIViewIID, + rv = nsComponentManager::CreateInstance(kCViewCID, nsnull, kIViewIID, (void **)&view); if (NS_OK != rv) { NS_ASSERTION(0, "Could not create view for nsHTMLFrame"); diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index b52b061fd33..c227a26c4be 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -24,7 +24,7 @@ #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsHTMLIIDs.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIStreamListener.h" #include "nsIURL.h" #include "nsIDocument.h" @@ -42,7 +42,7 @@ #include "nsHTMLParts.h" #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" // masks for mEdgeVisibility #define LEFT_VIS 0x0001 #define RIGHT_VIS 0x0002 @@ -838,7 +838,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, // create the view. a view is needed since it needs to be a mouse grabber nsIView* view; - nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, + nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); nsCOMPtr presShell; aPresContext.GetShell(getter_AddRefs(presShell)); @@ -1530,7 +1530,7 @@ nsHTMLFramesetBorderFrame::Paint(nsIPresContext& aPresContext, nscolor sdwColor = NS_RGB(128,128,128); nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, bgColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetForeground, fgColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DShadow, sdwColor); diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index b608f89837c..25e4695569b 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -230,7 +230,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext& aPresContext, static NS_DEFINE_IID(kViewCID, NS_VIEW_CID); static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID); - nsresult result = nsRepository::CreateInstance(kViewCID, + nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 35cf6f0526d..999182ec8da 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -317,7 +317,7 @@ nsObjectFrame::CreateWidget(nscoord aWidth, nscoord aHeight, PRBool aViewOnly) // Create our view and widget nsresult result = - nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, + nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); if (NS_OK != result) { return result; @@ -532,7 +532,7 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext, nsRect r = nsRect(x, y, width, height); static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); - nsresult rv = nsRepository::CreateInstance(aWidgetCID, nsnull, kIWidgetIID, + nsresult rv = nsComponentManager::CreateInstance(aWidgetCID, nsnull, kIWidgetIID, (void**)&mWidget); // XXX use rv! nsIWidget *parent; diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp index b608f89837c..25e4695569b 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -230,7 +230,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext& aPresContext, static NS_DEFINE_IID(kViewCID, NS_VIEW_CID); static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID); - nsresult result = nsRepository::CreateInstance(kViewCID, + nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 35cf6f0526d..999182ec8da 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -317,7 +317,7 @@ nsObjectFrame::CreateWidget(nscoord aWidth, nscoord aHeight, PRBool aViewOnly) // Create our view and widget nsresult result = - nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, + nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); if (NS_OK != result) { return result; @@ -532,7 +532,7 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext, nsRect r = nsRect(x, y, width, height); static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); - nsresult rv = nsRepository::CreateInstance(aWidgetCID, nsnull, kIWidgetIID, + nsresult rv = nsComponentManager::CreateInstance(aWidgetCID, nsnull, kIWidgetIID, (void**)&mWidget); // XXX use rv! nsIWidget *parent; diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index a3298810c65..3ef785dbb6e 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -557,7 +557,7 @@ PresShell::Init(nsIDocument* aDocument, NS_ADDREF(aStyleSet); nsCOMPtrdomselection; - nsresult result = nsRepository::CreateInstance(kRangeListCID, nsnull, + nsresult result = nsComponentManager::CreateInstance(kRangeListCID, nsnull, kIDOMSelectionIID, getter_AddRefs(domselection)); if (!NS_SUCCEEDED(result)) @@ -570,7 +570,7 @@ PresShell::Init(nsIDocument* aDocument, // XXX This code causes the document object (and the entire content model) to be leaked... #if 0 nsCOMPtrrange; - if (NS_SUCCEEDED(nsRepository::CreateInstance(kCRangeCID, nsnull, kIDOMRangeIID, getter_AddRefs(range)))){ //create an irange + if (NS_SUCCEEDED(nsComponentManager::CreateInstance(kCRangeCID, nsnull, kIDOMRangeIID, getter_AddRefs(range)))){ //create an irange nsCOMPtrdoc(GetDocument()); nsCOMPtrdomDoc(doc); if (domDoc){ @@ -1493,7 +1493,7 @@ PresShell::DoCopy(nsISelectionMgr* aSelectionMgr) static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - nsresult rv = nsRepository::CreateInstance(kCParserCID, + nsresult rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); @@ -2200,7 +2200,7 @@ PresShell::VerifyIncrementalReflow() void* nativeParentWidget = rootWidget->GetNativeData(NS_NATIVE_WIDGET); // Create a new view manager. - rv = nsRepository::CreateInstance(kViewManagerCID, nsnull, kIViewManagerIID, + rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull, kIViewManagerIID, (void**) &vm); if ((NS_OK != rv) || (NS_OK != vm->Init(dc))) { NS_ASSERTION(NS_OK == rv, "failed to create view manager"); @@ -2212,7 +2212,7 @@ PresShell::VerifyIncrementalReflow() // Create a view nsRect tbounds; mPresContext->GetVisibleArea(tbounds); - rv = nsRepository::CreateInstance(kScrollingViewCID, nsnull, kIViewIID, + rv = nsComponentManager::CreateInstance(kScrollingViewCID, nsnull, kIViewIID, (void **) &view); if ((NS_OK != rv) || (NS_OK != view->Init(vm, tbounds, nsnull))) { NS_ASSERTION(NS_OK == rv, "failed to create scroll view"); diff --git a/mozilla/layout/html/base/src/nsScrollFrame.cpp b/mozilla/layout/html/base/src/nsScrollFrame.cpp index a979365ab02..5c9eb614873 100644 --- a/mozilla/layout/html/base/src/nsScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsScrollFrame.cpp @@ -146,7 +146,7 @@ nsScrollFrame::CreateScrollingView() parentView->GetViewManager(viewManager); // Create the scrolling view - nsresult rv = nsRepository::CreateInstance(kScrollingViewCID, + nsresult rv = nsComponentManager::CreateInstance(kScrollingViewCID, nsnull, kIViewIID, (void **)&view); diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index f85834df77f..0b96d699c36 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -23,7 +23,7 @@ #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsHTMLIIDs.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIStreamListener.h" #include "nsIURL.h" #include "nsIDocument.h" @@ -647,7 +647,7 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext& aPresContext, nsIContent* content; GetParentContent(content); - rv = nsRepository::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, + rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&mWebShell); if (NS_OK != rv) { NS_ASSERTION(0, "could not create web widget"); @@ -704,7 +704,7 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext& aPresContext, // create, init, set the parent of the view nsIView* view; - rv = nsRepository::CreateInstance(kCViewCID, nsnull, kIViewIID, + rv = nsComponentManager::CreateInstance(kCViewCID, nsnull, kIViewIID, (void **)&view); if (NS_OK != rv) { NS_ASSERTION(0, "Could not create view for nsHTMLFrame"); diff --git a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp index b52b061fd33..c227a26c4be 100644 --- a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp @@ -24,7 +24,7 @@ #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsHTMLIIDs.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIStreamListener.h" #include "nsIURL.h" #include "nsIDocument.h" @@ -42,7 +42,7 @@ #include "nsHTMLParts.h" #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" // masks for mEdgeVisibility #define LEFT_VIS 0x0001 #define RIGHT_VIS 0x0002 @@ -838,7 +838,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, // create the view. a view is needed since it needs to be a mouse grabber nsIView* view; - nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, + nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); nsCOMPtr presShell; aPresContext.GetShell(getter_AddRefs(presShell)); @@ -1530,7 +1530,7 @@ nsHTMLFramesetBorderFrame::Paint(nsIPresContext& aPresContext, nscolor sdwColor = NS_RGB(128,128,128); nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, bgColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetForeground, fgColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DShadow, sdwColor); diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index baea07dd3c3..192984ad6a1 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -45,7 +45,7 @@ #include "nsIDOMHTMLOptionElement.h" #include "nsIFormControl.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIScrollableView.h" #include "nsHTMLAtoms.h" diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp index 159f37a5080..4653ce7c85c 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp @@ -46,7 +46,7 @@ #include "nsINetService.h" #include "nsIServiceManager.h" #include "nsIFormManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsParserCIID.h" #include "nsIDOMHTMLElement.h" #include "nsIDOMHTMLMapElement.h" @@ -334,7 +334,7 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL, static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); if (rv == NS_OK) - rv = nsRepository::CreateInstance(kCParserCID, + rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&mParser); @@ -1244,7 +1244,7 @@ nsHTMLDocument::Open(JSContext *cx, jsval *argv, PRUint32 argc) static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - result = nsRepository::CreateInstance(kCParserCID, + result = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&mParser); diff --git a/mozilla/layout/html/forms/src/nsButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsButtonControlFrame.cpp index 67b4f02caa1..d28cd35bcfb 100644 --- a/mozilla/layout/html/forms/src/nsButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsButtonControlFrame.cpp @@ -169,7 +169,7 @@ nsButtonControlFrame::GetVerticalInsidePadding(float aPixToTwip, { float pad; nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_ButtonVerticalInsidePadding, pad); NS_RELEASE(lookAndFeel); } @@ -189,7 +189,7 @@ nsButtonControlFrame::GetHorizontalInsidePadding(nsIPresContext& aPresContext, PRInt32 padQuirks; PRInt32 padQuirksOffset; nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_ButtonHorizontalInsidePadding, pad); lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ButtonHorizontalInsidePaddingNavQuirks, padQuirks); lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks, padQuirksOffset); diff --git a/mozilla/layout/html/forms/src/nsCheckboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsCheckboxControlFrame.cpp index adda462b198..e9e0e8a5e6b 100644 --- a/mozilla/layout/html/forms/src/nsCheckboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsCheckboxControlFrame.cpp @@ -36,7 +36,7 @@ #include "nsIDOMHTMLInputElement.h" #include "nsCSSRendering.h" #include "nsILookAndFeel.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #define NS_DEFAULT_CHECKBOX_SIZE 12 @@ -155,7 +155,7 @@ nsCheckboxControlFrame::GetCheckboxSize(float aPixToTwip) const { nsILookAndFeel * lookAndFeel; PRInt32 checkboxSize = 0; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetric_CheckboxSize, checkboxSize); NS_RELEASE(lookAndFeel); } diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index ba3c2c85b20..81d3b1aa740 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -30,7 +30,7 @@ #include "nsIFileWidget.h" #include "nsITextWidget.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIView.h" #include "nsHTMLParts.h" #include "nsIDOMHTMLInputElement.h" diff --git a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp index c619f43d117..b0629e30ab2 100644 --- a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp @@ -30,7 +30,7 @@ #include "nsIFileWidget.h" #include "nsITextWidget.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIView.h" #include "nsHTMLParts.h" #include "nsIDOMHTMLInputElement.h" @@ -157,7 +157,7 @@ void nsFileControlFrame::MouseClicked(nsIPresContext* aPresContext) nsIFileWidget *fileWidget; nsString title("FileWidget Title mode = save"); - nsRepository::CreateInstance(kCFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget); + nsComponentManager::CreateInstance(kCFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget); nsString titles[] = {"all files"}; nsString filters[] = {"*.*"}; diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp index 1be50e114a7..3f1efcd84c6 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp @@ -31,7 +31,7 @@ #include "nsCoord.h" #include "nsWidgetsCID.h" #include "nsViewsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsGUIEvent.h" #include "nsDOMEvent.h" #include "nsIFontMetrics.h" @@ -255,7 +255,7 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext, nsIView* view = nsnull; GetView(&view); if (nsnull == view) { - result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); + result = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); if (!NS_SUCCEEDED(result)) { NS_ASSERTION(0, "Could not create view for form control"); aStatus = NS_FRAME_NOT_COMPLETE; diff --git a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp index 48a26214394..55c0f717ec2 100644 --- a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp @@ -31,7 +31,7 @@ #include "nsCoord.h" #include "nsWidgetsCID.h" #include "nsViewsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsGUIEvent.h" #include "nsDOMEvent.h" #include "nsIFontMetrics.h" diff --git a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index f6d15684bdf..3cbeb6393e9 100644 --- a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -40,7 +40,7 @@ #include "nsIHTMLAttributes.h" #include "nsGenericHTMLElement.h" #include "nsIWidget.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIView.h" #include "nsIViewManager.h" #include "nsViewsCID.h" @@ -519,7 +519,7 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext& aPresContext, nsIView* view; GetView(&view); if (!view) { - nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); + nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); nsCOMPtr presShell; aPresContext.GetShell(getter_AddRefs(presShell)); nsCOMPtr viewMan; diff --git a/mozilla/layout/html/forms/src/nsImageControlFrame.cpp b/mozilla/layout/html/forms/src/nsImageControlFrame.cpp index 5cb3105d4de..58528e685c6 100644 --- a/mozilla/layout/html/forms/src/nsImageControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsImageControlFrame.cpp @@ -187,7 +187,7 @@ nsImageControlFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIView* view; GetView(&view); if (!view) { - nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); + nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); nsCOMPtr presShell; aPresContext.GetShell(getter_AddRefs(presShell)); nsCOMPtr viewMan; diff --git a/mozilla/layout/html/forms/src/nsLabelFrame.cpp b/mozilla/layout/html/forms/src/nsLabelFrame.cpp index fb844dfb3cd..1dc6baa21c3 100644 --- a/mozilla/layout/html/forms/src/nsLabelFrame.cpp +++ b/mozilla/layout/html/forms/src/nsLabelFrame.cpp @@ -41,7 +41,7 @@ #include "nsIHTMLAttributes.h" #include "nsGenericHTMLElement.h" #include "nsIWidget.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIView.h" #include "nsIViewManager.h" #include "nsViewsCID.h" @@ -423,7 +423,7 @@ nsLabelFrame::Reflow(nsIPresContext& aPresContext, nsIView* view; GetView(&view); if (!view) { - nsresult result = nsRepository::CreateInstance(kViewCID, nsnull, kIViewIID, + nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); nsCOMPtr presShell; aPresContext.GetShell(getter_AddRefs(presShell)); diff --git a/mozilla/layout/html/forms/src/nsRadioControlFrame.cpp b/mozilla/layout/html/forms/src/nsRadioControlFrame.cpp index 4c2e078e747..843c4fa6172 100644 --- a/mozilla/layout/html/forms/src/nsRadioControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsRadioControlFrame.cpp @@ -39,7 +39,7 @@ #include "nsIDOMHTMLInputElement.h" #include "nsINameSpaceManager.h" #include "nsILookAndFeel.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" static NS_DEFINE_IID(kIRadioIID, NS_IRADIOBUTTON_IID); static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID); @@ -87,7 +87,7 @@ nsRadioControlFrame::GetRadioboxSize(float aPixToTwip) const { nsILookAndFeel * lookAndFeel; PRInt32 radioboxSize = 0; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetric_RadioboxSize, radioboxSize); NS_RELEASE(lookAndFeel); } diff --git a/mozilla/layout/html/forms/src/nsSelectControlFrame.cpp b/mozilla/layout/html/forms/src/nsSelectControlFrame.cpp index daf136cd01d..9cf7f4e50fb 100644 --- a/mozilla/layout/html/forms/src/nsSelectControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsSelectControlFrame.cpp @@ -48,7 +48,7 @@ #include "nsIDeviceContext.h" #include "nsIFontMetrics.h" #include "nsILookAndFeel.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" static NS_DEFINE_IID(kIDOMHTMLSelectElementIID, NS_IDOMHTMLSELECTELEMENT_IID); static NS_DEFINE_IID(kIDOMHTMLOptionElementIID, NS_IDOMHTMLOPTIONELEMENT_IID); @@ -219,7 +219,7 @@ nsSelectControlFrame::GetVerticalInsidePadding(float aPixToTwip, PRInt32 padInside; PRInt32 shouldUsePadInside; nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_ListVerticalInsidePadding, pad); // These two (below) are really only needed for GTK lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ListVerticalInsidePadding, padInside); @@ -254,7 +254,7 @@ nsSelectControlFrame::GetHorizontalInsidePadding(nsIPresContext& aPresContext, PRInt32 padMin; PRInt32 shouldUsePadMin; nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_ListHorizontalInsidePadding, pad); lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ListHorizontalInsideMinimumPadding, padMin); // This one (below) is really only needed for GTK diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index abcbab39acc..6ab326734d2 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -44,7 +44,7 @@ #include "nsIDeviceContext.h" #include "nsIFontMetrics.h" #include "nsILookAndFeel.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #ifdef SingleSignon #include "nsIDocument.h" @@ -110,7 +110,7 @@ nsTextControlFrame::GetVerticalInsidePadding(float aPixToTwip, PRInt32 vertPad; PRInt32 shouldUseVertPad; nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_TextAreaVerticalInsidePadding, padTextArea); lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_TextFieldVerticalInsidePadding, padTextField); // These two (below) are really only needed for GTK @@ -154,7 +154,7 @@ nsTextControlFrame::GetHorizontalInsidePadding(nsIPresContext& aPresContext, PRInt32 shouldUsePadMinText; nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_TextFieldHorizontalInsidePadding, padTextField); lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_TextAreaHorizontalInsidePadding, padTextArea); lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextHorizontalInsideMinimumPadding, padMinText); diff --git a/mozilla/layout/html/tests/TestCSSParser.cpp b/mozilla/layout/html/tests/TestCSSParser.cpp index 60057c7b898..826027a7ce4 100644 --- a/mozilla/layout/html/tests/TestCSSParser.cpp +++ b/mozilla/layout/html/tests/TestCSSParser.cpp @@ -27,7 +27,7 @@ // XXX begin bad code #include "plevent.h" #include "nsINetService.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIEventQueueService.h" #include "nsXPComCIID.h" @@ -56,8 +56,8 @@ static void Usage(void) int main(int argc, char** argv) { - nsRepository::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); nsresult rv; PRBool verbose = PR_FALSE; diff --git a/mozilla/layout/html/tests/TestInlineFrame.cpp b/mozilla/layout/html/tests/TestInlineFrame.cpp index b45bab7e72d..cd6f7090386 100644 --- a/mozilla/layout/html/tests/TestInlineFrame.cpp +++ b/mozilla/layout/html/tests/TestInlineFrame.cpp @@ -1579,7 +1579,7 @@ int main(int argc, char** argv) static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID); static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID); - nsresult rv = nsRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&dx); + nsresult rv = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&dx); if (NS_OK == rv) { dx->Init(nsull); diff --git a/mozilla/layout/html/tests/table/TableContentTest/TableContentTest.cpp b/mozilla/layout/html/tests/table/TableContentTest/TableContentTest.cpp index 09614a77968..0869e66aa19 100644 --- a/mozilla/layout/html/tests/table/TableContentTest/TableContentTest.cpp +++ b/mozilla/layout/html/tests/table/TableContentTest/TableContentTest.cpp @@ -425,7 +425,7 @@ GeometryTest::GeometryTest(BasicTest *aDoc) static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID); static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID); - nsresult rv = nsRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&dx); + nsresult rv = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&dx); if (NS_OK == rv) { dx->Init(nsnull); @@ -449,7 +449,7 @@ GeometryTest::GeometryTest(BasicTest *aDoc) static NS_DEFINE_IID(kViewManagerCID, NS_VIEW_MANAGER_CID); static NS_DEFINE_IID(kIViewManagerIID, NS_IVIEWMANAGER_IID); - status = nsRepository::CreateInstance(kViewManagerCID, + status = nsComponentManager::CreateInstance(kViewManagerCID, nsnull, kIViewManagerIID, (void **)&vm); @@ -467,7 +467,7 @@ GeometryTest::GeometryTest(BasicTest *aDoc) static NS_DEFINE_IID(kScrollingViewCID, NS_SCROLLING_VIEW_CID); static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID); - status = nsRepository::CreateInstance(kScrollingViewCID, + status = nsComponentManager::CreateInstance(kScrollingViewCID, nsnull, kIViewIID, (void **)&rootView); diff --git a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp index 6ea00b3c3fa..9d9c1f95bbd 100644 --- a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp @@ -953,7 +953,7 @@ nsXMLContentSink::LoadXSLStyleSheet(const nsIURL* aUrl) static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); // Create the XML parser - rv = nsRepository::CreateInstance(kCParserCID, + rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); diff --git a/mozilla/layout/xml/document/src/nsXMLDocument.cpp b/mozilla/layout/xml/document/src/nsXMLDocument.cpp index a4e836548b8..7b801c568e7 100644 --- a/mozilla/layout/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/layout/xml/document/src/nsXMLDocument.cpp @@ -34,7 +34,7 @@ #include "nsIHTMLStyleSheet.h" #include "nsIHTMLCSSStyleSheet.h" #include "nsIStyleSet.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIDOMComment.h" #include "nsIDOMElement.h" #include "nsIDOMText.h" @@ -279,7 +279,7 @@ nsXMLDocument::StartDocumentLoad(nsIURL *aUrl, static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - rv = nsRepository::CreateInstance(kCParserCID, + rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&mParser); diff --git a/mozilla/layout/xul/base/src/nsTitledButtonFrame.cpp b/mozilla/layout/xul/base/src/nsTitledButtonFrame.cpp index ce7e8186bae..39af1b86922 100644 --- a/mozilla/layout/xul/base/src/nsTitledButtonFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTitledButtonFrame.cpp @@ -1107,7 +1107,7 @@ NS_IMETHODIMP nsTitledButtonFrame::CreateMenu(nsIPopUpMenu * aPopUpMenu, nsString & aMenuName) { // Create and place back button - nsresult rv = nsRepository::CreateInstance(kPopUpMenuCID, nsnull, kIPopUpMenuIID, + nsresult rv = nsComponentManager::CreateInstance(kPopUpMenuCID, nsnull, kIPopUpMenuIID, (void**)&mPopUpMenu); if (NS_OK != rv) return rv; @@ -1165,7 +1165,7 @@ NS_IMETHODIMP nsWebShellWindow::LoadMenuItem( menuitemElement->GetAttribute(nsAutoString("cmd"), menuitemCmd); // Create nsMenuItem nsIMenuItem * pnsMenuItem = nsnull; - nsresult rv = nsRepository::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&pnsMenuItem); + nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&pnsMenuItem); if (NS_OK == rv) { pnsMenuItem->Create(pParentMenu); //, menuitemName, 0); // Set nsMenuItem Name @@ -1219,7 +1219,7 @@ void nsWebShellWindow::LoadSubMenu( // Create nsMenu nsIMenu * pnsMenu = nsnull; - nsresult rv = nsRepository::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&pnsMenu); + nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&pnsMenu); if (NS_OK == rv) { // Call Create pnsMenu->Create(pParentMenu, menuName); @@ -1264,7 +1264,7 @@ void nsTitledButtonFrame::CreatePopUpMenu() } // Create and place back button - nsresult rv = nsRepository::CreateInstance(kPopUpMenuCID, nsnull, kIPopUpMenuIID, + nsresult rv = nsComponentManager::CreateInstance(kPopUpMenuCID, nsnull, kIPopUpMenuIID, (void**)&mPopUpMenu); if (NS_OK == rv) { nsIWidget * menuParentWidget; @@ -1301,7 +1301,7 @@ NS_METHOD nsTitledButtonFrame::AddMenuItem(const nsString& aMenuLabel, PRInt32 a CreatePopUpMenu(); nsIMenuItem * menuItem = nsnull; - nsresult rv = nsRepository::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&menuItem); + nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&menuItem); menuItem->Create(mPopUpMenu, aMenuLabel, aCommand); if (NS_OK == rv) { mPopUpMenu->AddItem(menuItem); diff --git a/mozilla/modules/libpref/src/nsPref.cpp b/mozilla/modules/libpref/src/nsPref.cpp index 61875fefe13..daa3b63c648 100644 --- a/mozilla/modules/libpref/src/nsPref.cpp +++ b/mozilla/modules/libpref/src/nsPref.cpp @@ -20,12 +20,15 @@ #include "prefapi.h" #define NS_IMPL_IDS #include "nsIFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIPref.h" #ifdef XP_MAC #include "nsINetSupport.h" #include "nsIStreamListener.h" #endif +#include "nsIServiceManager.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); class nsPref: public nsIPref { NS_DECL_ISUPPORTS @@ -610,14 +613,22 @@ extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *path) { - return nsRepository::RegisterComponent(kPrefCID, NULL, NULL, path, - PR_TRUE, PR_TRUE); + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + + return compMgr->RegisterComponent(kPrefCID, NULL, NULL, path, + PR_TRUE, PR_TRUE); } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char *path) { - return nsRepository::UnregisterFactory(kPrefCID, path); + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + + return compMgr->UnregisterFactory(kPrefCID, path); } diff --git a/mozilla/modules/libreg/xpcom/nsRegistry.cpp b/mozilla/modules/libreg/xpcom/nsRegistry.cpp index aed006362e9..ee6533ebcb2 100644 --- a/mozilla/modules/libreg/xpcom/nsRegistry.cpp +++ b/mozilla/modules/libreg/xpcom/nsRegistry.cpp @@ -1168,7 +1168,7 @@ nsRegistryFactory::LockFactory(PRBool aLock) } // This is a temporary hack; needs work to support dynamic binding -// via nsRepository and support for multiple factories per DLL. +// via nsComponentManager and support for multiple factories per DLL. extern "C" NS_EXPORT nsresult nsRegistry_GetFactory(const nsCID &cid, nsISupports* servMgr, nsIFactory** aFactory ) { nsresult rv = NS_OK; diff --git a/mozilla/modules/oji/src/nsCJVMManagerFactory.cpp b/mozilla/modules/oji/src/nsCJVMManagerFactory.cpp index 1a65e196f2e..a8c5fff36fc 100644 --- a/mozilla/modules/oji/src/nsCJVMManagerFactory.cpp +++ b/mozilla/modules/oji/src/nsCJVMManagerFactory.cpp @@ -23,7 +23,7 @@ #include "nsJVMManager.h" #include "nsCJVMManagerFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -147,7 +147,7 @@ nsCJVMManagerFactory::nsCJVMManagerFactory(void) if ( (err == NS_OK) && (m_pNSIFactory != NULL) ) { NS_DEFINE_CID(kCJVMManagerCID, NS_CCAPSMANAGER_CID); - nsRepository::RegisterFactory(kCJVMManagerCID, NULL, NULL, + nsComponentManager::RegisterFactory(kCJVMManagerCID, NULL, NULL, m_pNSIFactory, PR_FALSE); } #endif @@ -161,7 +161,7 @@ nsCJVMManagerFactory::~nsCJVMManagerFactory() if(mRefCnt == 0) { NS_DEFINE_CID(kCJVMManagerCID, NS_CCAPSMANAGER_CID); - nsRepository::UnregisterFactory(kCJVMManagerCID, (nsIFactory *)m_pNSIFactory); + nsComponentManager::UnregisterFactory(kCJVMManagerCID, (nsIFactory *)m_pNSIFactory); } #endif diff --git a/mozilla/modules/oji/src/nsJVMManager.cpp b/mozilla/modules/oji/src/nsJVMManager.cpp index 33e2ba3b969..8864737a681 100644 --- a/mozilla/modules/oji/src/nsJVMManager.cpp +++ b/mozilla/modules/oji/src/nsJVMManager.cpp @@ -596,7 +596,7 @@ nsJVMManager::MaybeStartupLiveConnect(void) if (!registeredLiveConnectFactory) { NS_DEFINE_CID(kCLiveconnectCID, NS_CLIVECONNECT_CID); registeredLiveConnectFactory = - (nsRepository::RegisterComponent(kCLiveconnectCID, NULL, NULL, + (nsComponentManager::RegisterComponent(kCLiveconnectCID, NULL, NULL, (const char *)JSJDLL, PR_FALSE, PR_FALSE) == NS_OK); } diff --git a/mozilla/modules/plugin/base/public/nsplugin.h b/mozilla/modules/plugin/base/public/nsplugin.h index e7e2cc4bcdb..181a01500e3 100644 --- a/mozilla/modules/plugin/base/public/nsplugin.h +++ b/mozilla/modules/plugin/base/public/nsplugin.h @@ -81,7 +81,7 @@ #define NEW_PLUGIN_STREAM_API -#include "nsRepository.h" // for NSGetFactory +#include "nsIComponentManager.h" // for NSGetFactory //////////////////////////////////////////////////////////////////////////////// /** @@ -96,7 +96,7 @@ * object is returned to the plugin manager, instances on the page are created * by calling nsIPlugin::CreateInstance. */ -// (Declared in nsRepository.h) +// (Declared in nsComponentManager.h) //extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, // const nsCID &aClass, // const char *aClassName, diff --git a/mozilla/modules/plugin/base/src/nsPluginFactory.cpp b/mozilla/modules/plugin/base/src/nsPluginFactory.cpp index b95a9b66d12..10feef3dc54 100644 --- a/mozilla/modules/plugin/base/src/nsPluginFactory.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginFactory.cpp @@ -158,7 +158,7 @@ NSGetFactory(nsISupports* serviceMgr, return NS_ERROR_NULL_POINTER; } - nsIServiceManager *pnsIServiceManager = NULL; + nsIServiceManager *pnsIServiceManager = NULL; if (NS_FAILED(serviceMgr->QueryInterface(kIServiceManagerIID, (void**) &pnsIServiceManager))) return NS_ERROR_FAILURE; diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h index a6d57a6455c..fba4d6bb92f 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h @@ -27,6 +27,7 @@ #include "prlink.h" #include "nsIFileUtilities.h" #include "nsPluginsDir.h" +#include "nsIServiceManager.h" class ns4xPlugin; class nsFileSpec; diff --git a/mozilla/modules/plugin/base/src/nsPluginsCID.h b/mozilla/modules/plugin/base/src/nsPluginsCID.h index dc547fc32f3..ecc1e7a46e2 100644 --- a/mozilla/modules/plugin/base/src/nsPluginsCID.h +++ b/mozilla/modules/plugin/base/src/nsPluginsCID.h @@ -21,7 +21,7 @@ #include "nsISupports.h" #include "nsIFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #define NS_PLUGIN_HOST_CID \ { 0xadea1880, 0x1a8e, 0x11d2, \ diff --git a/mozilla/modules/plugin/nglsrc/nsPluginFactory.cpp b/mozilla/modules/plugin/nglsrc/nsPluginFactory.cpp index b95a9b66d12..10feef3dc54 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginFactory.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginFactory.cpp @@ -158,7 +158,7 @@ NSGetFactory(nsISupports* serviceMgr, return NS_ERROR_NULL_POINTER; } - nsIServiceManager *pnsIServiceManager = NULL; + nsIServiceManager *pnsIServiceManager = NULL; if (NS_FAILED(serviceMgr->QueryInterface(kIServiceManagerIID, (void**) &pnsIServiceManager))) return NS_ERROR_FAILURE; diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h index a6d57a6455c..fba4d6bb92f 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h @@ -27,6 +27,7 @@ #include "prlink.h" #include "nsIFileUtilities.h" #include "nsPluginsDir.h" +#include "nsIServiceManager.h" class ns4xPlugin; class nsFileSpec; diff --git a/mozilla/modules/plugin/nglsrc/nsPluginsCID.h b/mozilla/modules/plugin/nglsrc/nsPluginsCID.h index dc547fc32f3..ecc1e7a46e2 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginsCID.h +++ b/mozilla/modules/plugin/nglsrc/nsPluginsCID.h @@ -21,7 +21,7 @@ #include "nsISupports.h" #include "nsIFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #define NS_PLUGIN_HOST_CID \ { 0xadea1880, 0x1a8e, 0x11d2, \ diff --git a/mozilla/modules/plugin/public/nsplugin.h b/mozilla/modules/plugin/public/nsplugin.h index e7e2cc4bcdb..181a01500e3 100644 --- a/mozilla/modules/plugin/public/nsplugin.h +++ b/mozilla/modules/plugin/public/nsplugin.h @@ -81,7 +81,7 @@ #define NEW_PLUGIN_STREAM_API -#include "nsRepository.h" // for NSGetFactory +#include "nsIComponentManager.h" // for NSGetFactory //////////////////////////////////////////////////////////////////////////////// /** @@ -96,7 +96,7 @@ * object is returned to the plugin manager, instances on the page are created * by calling nsIPlugin::CreateInstance. */ -// (Declared in nsRepository.h) +// (Declared in nsComponentManager.h) //extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, // const nsCID &aClass, // const char *aClassName, diff --git a/mozilla/modules/plugin/src/nsFileUtilities.cpp b/mozilla/modules/plugin/src/nsFileUtilities.cpp index f3e1023afc8..1d5b33dddc3 100644 --- a/mozilla/modules/plugin/src/nsFileUtilities.cpp +++ b/mozilla/modules/plugin/src/nsFileUtilities.cpp @@ -17,7 +17,7 @@ */ #include "nsFileUtilities.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "xp.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/modules/plugin/src/nsPluginManager.cpp b/mozilla/modules/plugin/src/nsPluginManager.cpp index 6704e1beb45..ab0673a864c 100644 --- a/mozilla/modules/plugin/src/nsPluginManager.cpp +++ b/mozilla/modules/plugin/src/nsPluginManager.cpp @@ -225,7 +225,7 @@ nsPluginManager::GetCapsManager(const nsIID& aIID) NS_DEFINE_CID(kCCapsManagerCID, NS_CCAPSMANAGER_CID); nsresult err = NS_OK; - err = nsRepository::CreateInstance(kCCapsManagerCID, + err = nsComponentManager::CreateInstance(kCCapsManagerCID, (nsIPluginManager*)this, /* outer */ kISupportsIID, (void **)&fCapsManager); @@ -266,7 +266,7 @@ nsPluginManager::GetLiveconnect(const nsIID& aIID) threadAttached = PR_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL); } NS_DEFINE_CID(kCLiveconnectCID, NS_CLIVECONNECT_CID); - err = nsRepository::CreateInstance(kCLiveconnectCID, + err = nsComponentManager::CreateInstance(kCLiveconnectCID, (nsIPluginManager*)this, /* outer */ kISupportsIID, (void **)&fLiveconnect); @@ -1036,21 +1036,21 @@ np_RegisterPluginMgr(void) return NS_ERROR_OUT_OF_MEMORY; pluginFact->AddRef(); - nsRepository::RegisterFactory(kPluginManagerCID, NULL, NULL, pluginFact, PR_TRUE); + nsComponentManager::RegisterFactory(kPluginManagerCID, NULL, NULL, pluginFact, PR_TRUE); pluginFact->AddRef(); - nsRepository::RegisterFactory(kJNIEnvCID, NULL, NULL, pluginFact, PR_TRUE); + nsComponentManager::RegisterFactory(kJNIEnvCID, NULL, NULL, pluginFact, PR_TRUE); #if 0 pluginFact->AddRef(); - nsRepository::RegisterFactory(kJRIEnvCID, NULL, NULL, pluginFact, PR_TRUE); + nsComponentManager::RegisterFactory(kJRIEnvCID, NULL, NULL, pluginFact, PR_TRUE); #endif pluginFact->AddRef(); - nsRepository::RegisterFactory(kMallocCID, NULL, NULL, pluginFact, PR_TRUE); + nsComponentManager::RegisterFactory(kMallocCID, NULL, NULL, pluginFact, PR_TRUE); pluginFact->AddRef(); - nsRepository::RegisterFactory(kFileUtilitiesCID, NULL, NULL, pluginFact, PR_TRUE); + nsComponentManager::RegisterFactory(kFileUtilitiesCID, NULL, NULL, pluginFact, PR_TRUE); return NS_OK; } diff --git a/mozilla/modules/plugin/src/nsplugin.cpp b/mozilla/modules/plugin/src/nsplugin.cpp index e581c04ad1e..4d195ae77b6 100644 --- a/mozilla/modules/plugin/src/nsplugin.cpp +++ b/mozilla/modules/plugin/src/nsplugin.cpp @@ -281,7 +281,7 @@ nsPluginManager::GetCapsManager(const nsIID& aIID) NS_DEFINE_CID(kCCapsManagerCID, NS_CCAPSMANAGER_CID); nsresult err = NS_OK; - err = nsRepository::CreateInstance(kCCapsManagerCID, + err = nsComponentManager::CreateInstance(kCCapsManagerCID, (nsIPluginManager*)this, /* outer */ kISupportsIID, (void **)&fCapsManager); @@ -322,7 +322,7 @@ nsPluginManager::GetLiveconnect(const nsIID& aIID) threadAttached = PR_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL); } NS_DEFINE_CID(kCLiveconnectCID, NS_CLIVECONNECT_CID); - err = nsRepository::CreateInstance(kCLiveconnectCID, + err = nsComponentManager::CreateInstance(kCLiveconnectCID, (nsIPluginManager*)this, /* outer */ kISupportsIID, (void **)&fLiveconnect); diff --git a/mozilla/network/cnvts/cvplugin.cpp b/mozilla/network/cnvts/cvplugin.cpp index ac7cc1c00a5..0b140fd9a1b 100644 --- a/mozilla/network/cnvts/cvplugin.cpp +++ b/mozilla/network/cnvts/cvplugin.cpp @@ -23,7 +23,7 @@ #include "plstr.h" #include "nsINetPlugin.h" #include "nsINetPluginInstance.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsNetConverterStream.h" @@ -188,13 +188,13 @@ NET_PluginStream(int fmt, void* data_obj, URL_Struct* URL_s, MWContext* w) return NULL; } - if (nsRepository::ProgIDToCLSID(mime_type, &classID) != NS_OK) + if (nsComponentManager::ProgIDToCLSID(mime_type, &classID) != NS_OK) { unregister_converter(mime_type, (void *)URL_s); return NULL; } - nsRepository::CreateInstance(classID, (nsISupports *)nsnull, kINetPluginInstanceIID, (void **)&plugin_inst); + nsComponentManager::CreateInstance(classID, (nsISupports *)nsnull, kINetPluginInstanceIID, (void **)&plugin_inst); if (plugin_inst == NULL) { diff --git a/mozilla/network/module/nsNetFactory.cpp b/mozilla/network/module/nsNetFactory.cpp index bfb60137ab5..aa91d27e849 100644 --- a/mozilla/network/module/nsNetFactory.cpp +++ b/mozilla/network/module/nsNetFactory.cpp @@ -22,7 +22,7 @@ #include "nsINetService.h" #include "nsNetService.h" #include "nsIServiceManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" /* This implementation of the network service factory is presently * only taking advantage of the service retrieval benefit that the diff --git a/mozilla/network/module/nsNetService.cpp b/mozilla/network/module/nsNetService.cpp index a5733ee8ae4..abb0517db8d 100644 --- a/mozilla/network/module/nsNetService.cpp +++ b/mozilla/network/module/nsNetService.cpp @@ -17,7 +17,7 @@ * Netscape Communications Corporation. All Rights Reserved. */ -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsITimer.h" #include "nsNetService.h" #include "nsNetStream.h" diff --git a/mozilla/network/module/nsNetThread.cpp b/mozilla/network/module/nsNetThread.cpp index f251d265357..3111c5c8dee 100644 --- a/mozilla/network/module/nsNetThread.cpp +++ b/mozilla/network/module/nsNetThread.cpp @@ -17,7 +17,7 @@ * Netscape Communications Corporation. All Rights Reserved. */ #include "nscore.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nspr.h" #include "plevent.h" diff --git a/mozilla/network/module/nsSocketTransport.cpp b/mozilla/network/module/nsSocketTransport.cpp index 4532ec81f8d..aee3c9b66fe 100644 --- a/mozilla/network/module/nsSocketTransport.cpp +++ b/mozilla/network/module/nsSocketTransport.cpp @@ -15,7 +15,7 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsNetStream.h" #include "nsSocketTransport.h" #include "nsINetService.h" @@ -394,4 +394,4 @@ nsresult nsSocketTransport::CloseCurrentConnection() m_url = nsnull; PR_FREEIF(m_hostName); return rv; -} \ No newline at end of file +} diff --git a/mozilla/network/module/nsSocketTransport.h b/mozilla/network/module/nsSocketTransport.h index 1cf8bd037a1..bd0504871f9 100644 --- a/mozilla/network/module/nsSocketTransport.h +++ b/mozilla/network/module/nsSocketTransport.h @@ -19,7 +19,7 @@ #ifndef nsSocketTransport_h__ #define nsSocketTransport_h__ -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsITransport.h" #include "nsIStreamListener.h" #include "nsIInputStream.h" diff --git a/mozilla/network/module/tests/nettest.cpp b/mozilla/network/module/tests/nettest.cpp index 51f3b84b475..e68b72d2556 100644 --- a/mozilla/network/module/tests/nettest.cpp +++ b/mozilla/network/module/tests/nettest.cpp @@ -30,7 +30,7 @@ #include "nsIInputStream.h" #include "nsIURL.h" #include "nsINetService.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIEventQueueService.h" #include "nsXPComCIID.h" @@ -231,8 +231,8 @@ int main(int argc, char **argv) return 0; } - nsRepository::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); // Create the Event Queue for this thread... pEventQService = nsnull; diff --git a/mozilla/network/module/tests/transportTest.cpp b/mozilla/network/module/tests/transportTest.cpp index d2b5a4858d1..23eecf68d16 100644 --- a/mozilla/network/module/tests/transportTest.cpp +++ b/mozilla/network/module/tests/transportTest.cpp @@ -43,7 +43,7 @@ #include "nsITransport.h" #include "nsIURL.h" #include "nsINetService.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsString.h" @@ -312,8 +312,8 @@ int main() int i; PL_InitializeEventsLib(""); - nsRepository::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); // Create the Event Queue for this thread... nsIEventQueueService *pEventQService = nsnull; diff --git a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp index 3a9774555aa..34a0645a9e1 100644 --- a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp @@ -24,7 +24,7 @@ #include "nsIURL.h" #include "nsIStreamListener.h" #include "nsIDTDDebug.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsParserCIID.h" static NS_DEFINE_IID(kIRobotSinkObserverIID, NS_IROBOTSINKOBSERVER_IID); @@ -216,7 +216,7 @@ extern "C" NS_EXPORT int DebugRobot( static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - rv = nsRepository::CreateInstance(kCParserCID, + rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); diff --git a/mozilla/parser/htmlparser/robot/test/RobotMain.cpp b/mozilla/parser/htmlparser/robot/test/RobotMain.cpp index a5d4cade6d6..31c9b411606 100644 --- a/mozilla/parser/htmlparser/robot/test/RobotMain.cpp +++ b/mozilla/parser/htmlparser/robot/test/RobotMain.cpp @@ -2,7 +2,7 @@ #include "nsVoidArray.h" #include "nsIWebShell.h" #include "nsString.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsParserCIID.h" #ifdef XP_PC @@ -22,7 +22,7 @@ int main(int argc, char **argv) } static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - nsRepository::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); return DebugRobot(gWorkList, nsnull); } diff --git a/mozilla/parser/htmlparser/src/SelfTest.cpp b/mozilla/parser/htmlparser/src/SelfTest.cpp index 9e737675287..2e61491ec73 100644 --- a/mozilla/parser/htmlparser/src/SelfTest.cpp +++ b/mozilla/parser/htmlparser/src/SelfTest.cpp @@ -28,7 +28,7 @@ #include "nsHTMLDelegate.h" #include "nsIParser.h" #include "nsHTMLContentSink.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsParserCIID.h" #ifdef XP_PC @@ -117,7 +117,7 @@ void parseFile (const char* aFilename,int size) static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - nsresult rv = nsRepository::CreateInstance(kCParserCID, + nsresult rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); @@ -203,7 +203,7 @@ int main(int argc, char* argv []) else _getcwd(buffer,_MAX_PATH); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - nsRepository::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); walkDirectoryTree(buffer); return 0; diff --git a/mozilla/parser/htmlparser/src/nsExpatDTD.cpp b/mozilla/parser/htmlparser/src/nsExpatDTD.cpp index 510b1494326..19e6a12e40f 100644 --- a/mozilla/parser/htmlparser/src/nsExpatDTD.cpp +++ b/mozilla/parser/htmlparser/src/nsExpatDTD.cpp @@ -40,6 +40,7 @@ #include "prtypes.h" //this is here for debug reasons... #include "prio.h" #include "plstr.h" +#include "prlog.h" #ifdef XP_PC #include //this is here for debug reasons... diff --git a/mozilla/parser/htmlparser/src/nsParserCIID.h b/mozilla/parser/htmlparser/src/nsParserCIID.h index 79ddfe66a26..b2c7a4a1abe 100644 --- a/mozilla/parser/htmlparser/src/nsParserCIID.h +++ b/mozilla/parser/htmlparser/src/nsParserCIID.h @@ -21,7 +21,7 @@ #include "nsISupports.h" #include "nsIFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #define NS_PARSER_IID \ {0x2ce606b0, 0xbee6, 0x11d1, \ diff --git a/mozilla/parser/htmlparser/tests/logparse/logparse.cpp b/mozilla/parser/htmlparser/tests/logparse/logparse.cpp index 077fef30ddc..8fb498e2f73 100644 --- a/mozilla/parser/htmlparser/tests/logparse/logparse.cpp +++ b/mozilla/parser/htmlparser/tests/logparse/logparse.cpp @@ -16,7 +16,7 @@ * Corporation. Portions created by Netscape are Copyright (C) 1998 * Netscape Communications Corporation. All Rights Reserved. */ -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsParserCIID.h" #include "nsIParser.h" #include "nsILoggingSink.h" @@ -44,8 +44,8 @@ static NS_DEFINE_IID(kILoggingSinkIID, NS_ILOGGING_SINK_IID); static void SetupRegistry() { - nsRepository::RegisterComponent(kParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kLoggingSinkCID, NULL, NULL, PARSER_DLL,PR_FALSE,PR_FALSE); + nsComponentManager::RegisterComponent(kParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kLoggingSinkCID, NULL, NULL, PARSER_DLL,PR_FALSE,PR_FALSE); } //---------------------------------------------------------------------- @@ -61,7 +61,7 @@ nsresult GenerateBaselineFile(const char* aSourceFilename,const char* aBaselineF // Create a parser nsIParser* parser; - nsresult rv = nsRepository::CreateInstance(kParserCID,nsnull,kIParserIID,(void**)&parser); + nsresult rv = nsComponentManager::CreateInstance(kParserCID,nsnull,kIParserIID,(void**)&parser); if (NS_OK != rv) { cout << "Unable to create a parser (" << rv << ")" <GetURI(&dsName); + if (NS_FAILED(rv)) return; rv = GetSubject(&subRes); if (NS_FAILED(rv)) return; rv = subRes->GetValue(&subject); @@ -406,8 +409,8 @@ public: value = PR_smprintf("", valueNode); } if (value == nsnull) return; - printf("RDF %s: datasource=0x%x\n subject: %s\n pred: %s\n value: %s\n", - msg, ds, subject, predicate, value); + printf("RDF %s: datasource=%s\n subject: %s\n pred: %s\n value: %s\n", + msg, dsName, subject, predicate, value); NS_RELEASE(predRes); NS_RELEASE(subRes); PR_smprintf_free(value); diff --git a/mozilla/rdf/base/src/nsRDFService.cpp b/mozilla/rdf/base/src/nsRDFService.cpp index 4df0c07756e..5f0f2f6a976 100644 --- a/mozilla/rdf/base/src/nsRDFService.cpp +++ b/mozilla/rdf/base/src/nsRDFService.cpp @@ -35,7 +35,7 @@ #include "nsIRDFService.h" #include "nsIRDFResourceFactory.h" #include "nsString.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "plhash.h" #include "plstr.h" #include "prprf.h" @@ -553,7 +553,7 @@ ServiceImpl::GetResource(const char* aURI, nsIRDFResource** aResource) NS_RELEASE(fact); } #else - rv = nsRepository::CreateInstance(NS_RDF_RESOURCE_FACTORY_PROGID, + rv = nsComponentManager::CreateInstance(NS_RDF_RESOURCE_FACTORY_PROGID, nsnull, nsIRDFResource::GetIID(), (void**)&result); #endif @@ -592,7 +592,7 @@ ServiceImpl::GetResource(const char* aURI, nsIRDFResource** aResource) NS_RELEASE(fact); } #else - rv = nsRepository::CreateInstance(progID, nsnull, + rv = nsComponentManager::CreateInstance(progID, nsnull, nsIRDFResource::GetIID(), (void**)&result); #endif @@ -613,7 +613,7 @@ ServiceImpl::GetResource(const char* aURI, nsIRDFResource** aResource) NS_RELEASE(fact); } #else - rv = nsRepository::CreateInstance(NS_RDF_RESOURCE_FACTORY_PROGID, + rv = nsComponentManager::CreateInstance(NS_RDF_RESOURCE_FACTORY_PROGID, nsnull, nsIRDFResource::GetIID(), (void**)&result); #endif @@ -908,7 +908,7 @@ ServiceImpl::GetDataSource(const char* uri, nsIRDFDataSource** aDataSource) NS_RELEASE(fact); } #else - rv = nsRepository::CreateInstance(progID, nsnull, + rv = nsComponentManager::CreateInstance(progID, nsnull, nsIRDFDataSource::GetIID(), (void**)aDataSource); #endif diff --git a/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp b/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp index 9c4174a59e7..ea0fddd72cb 100644 --- a/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp +++ b/mozilla/rdf/base/src/nsRDFXMLDataSource.cpp @@ -65,6 +65,7 @@ #include "prio.h" #include "prthread.h" #include "rdfutil.h" +#include "prlog.h" //////////////////////////////////////////////////////////////////////// @@ -360,7 +361,7 @@ RDFXMLDataSourceImpl::RDFXMLDataSourceImpl(void) mNameSpaces(nsnull) { nsresult rv; - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, nsnull, kIRDFDataSourceIID, (void**) &mInner))) @@ -531,13 +532,13 @@ static const char kResourceURIPrefix[] = "resource:"; if (NS_FAILED(rv = rdfService->RegisterDataSource(this))) goto done; - if (NS_FAILED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &ns))) goto done; - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFContentSinkCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFContentSinkCID, nsnull, kIRDFContentSinkIID, (void**) &sink))) @@ -551,7 +552,7 @@ static const char kResourceURIPrefix[] = "resource:"; if (NS_FAILED(rv = sink->SetDataSource(this))) goto done; - if (NS_FAILED(rv = nsRepository::CreateInstance(kParserCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kParserCID, nsnull, kIParserIID, (void**) &parser))) @@ -562,7 +563,7 @@ static const char kResourceURIPrefix[] = "resource:"; // XXX this should eventually be kRDFDTDCID (oh boy, that's a // pretty identifier). The RDF DTD will be a much more // RDF-resilient parser. - if (NS_FAILED(rv = nsRepository::CreateInstance(kWellFormedDTDCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kWellFormedDTDCID, nsnull, kIDTDIID, (void**) &dtd))) diff --git a/mozilla/rdf/build/nsRDFFactory.cpp b/mozilla/rdf/build/nsRDFFactory.cpp index d54103fb3a5..6f1c51a7807 100644 --- a/mozilla/rdf/build/nsRDFFactory.cpp +++ b/mozilla/rdf/build/nsRDFFactory.cpp @@ -35,10 +35,12 @@ #include "nsRDFBuiltInDataSources.h" #include "nsIRDFFileSystem.h" #include "nsRDFCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "rdf.h" #include "nsIXULSortService.h" +#include "nsIServiceManager.h" +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); @@ -244,7 +246,7 @@ nsresult RDFFactoryImpl::LockFactory(PRBool aLock) // return the proper factory to the caller extern "C" PR_IMPLEMENT(nsresult) -NSGetFactory(nsISupports* serviceMgr, +NSGetFactory(nsISupports* aServMgr, const nsCID &aClass, const char *aClassName, const char *aProgID, @@ -266,116 +268,154 @@ NSGetFactory(nsISupports* serviceMgr, extern "C" PR_IMPLEMENT(nsresult) -NSRegisterSelf(nsISupports* serviceMgr, const char* aPath) +NSRegisterSelf(nsISupports* aServMgr , const char* aPath) { nsresult rv; - // XXX return error codes! + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; // register our build-in datasources: - rv = nsRepository::RegisterComponent(kRDFBookmarkDataSourceCID, + rv = compMgr->RegisterComponent(kRDFBookmarkDataSourceCID, "Bookmarks", NS_RDF_DATASOURCE_PROGID_PREFIX "bookmarks", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kRDFFileSystemDataSourceCID, - "RDF File System Data Source", - NS_RDF_DATASOURCE_PROGID_PREFIX "files", - aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kRDFHistoryDataSourceCID, - "RDF History Data Source", - NS_RDF_DATASOURCE_PROGID_PREFIX "history", - aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kRDFCompositeDataSourceCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kRDFCompositeDataSourceCID, "RDF Composite Data Source", NS_RDF_DATASOURCE_PROGID_PREFIX "composite-datasource", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kRDFInMemoryDataSourceCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kRDFFileSystemDataSourceCID, + "RDF File System Data Source", + NS_RDF_DATASOURCE_PROGID_PREFIX "files", + aPath, PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kRDFHistoryDataSourceCID, + "RDF History Data Source", + NS_RDF_DATASOURCE_PROGID_PREFIX "history", + aPath, PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kRDFInMemoryDataSourceCID, "RDF In-Memory Data Source", NS_RDF_DATASOURCE_PROGID_PREFIX "in-memory-datasource", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kRDFXMLDataSourceCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kRDFXMLDataSourceCID, "RDF XML Data Source", NS_RDF_DATASOURCE_PROGID_PREFIX "xml-datasource", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kXULDataSourceCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kXULDataSourceCID, "XUL Data Source", NS_RDF_DATASOURCE_PROGID_PREFIX "xul-datasource", aPath, PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) return rv; // register our built-in resource factories: - rv = nsRepository::RegisterComponent(kRDFDefaultResourceCID, + rv = compMgr->RegisterComponent(kRDFDefaultResourceCID, "RDF Default Resource Factory", NS_RDF_RESOURCE_FACTORY_PROGID, // default resource factory has no name= part aPath, PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) return rv; // register all the other rdf components: - rv = nsRepository::RegisterComponent(kRDFContentSinkCID, + rv = compMgr->RegisterComponent(kRDFContentSinkCID, "RDF Content Sink", NS_RDF_PROGID "|content-sink", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kRDFHTMLBuilderCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kRDFHTMLBuilderCID, "RDF HTML Builder", NS_RDF_PROGID "|html-builder", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kRDFServiceCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kRDFServiceCID, "RDF Service", NS_RDF_PROGID "|rdf-service", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kXULSortServiceCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kXULSortServiceCID, "XUL Sort Service", NS_RDF_PROGID "|xul-sort-service", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kRDFTreeBuilderCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kRDFTreeBuilderCID, "RDF Tree Builder", NS_RDF_PROGID "|tree-builder", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kRDFMenuBuilderCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kRDFMenuBuilderCID, "RDF Menu Builder", NS_RDF_PROGID "|menu-builder", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kRDFToolbarBuilderCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kRDFToolbarBuilderCID, "RDF Toolbar Builder", NS_RDF_PROGID "|toolbar-builder", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kRDFXULBuilderCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kRDFXULBuilderCID, "RDF XUL Builder", NS_RDF_PROGID "|xul-builder", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kXULContentSinkCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kXULContentSinkCID, "XUL Content Sink", NS_RDF_PROGID "|xul-content-sink", aPath, PR_TRUE, PR_TRUE); - rv = nsRepository::RegisterComponent(kXULDocumentCID, + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kXULDocumentCID, "XUL Document", NS_RDF_PROGID "|xul-document", aPath, PR_TRUE, PR_TRUE); - return NS_OK; + return rv; } extern "C" PR_IMPLEMENT(nsresult) -NSUnregisterSelf(nsISupports* serviceMgr, const char* aPath) +NSUnregisterSelf(nsISupports* aServMgr, const char* aPath) { nsresult rv; - // XXX return error codes! + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; - rv = nsRepository::UnregisterComponent(kRDFBookmarkDataSourceCID, aPath); - rv = nsRepository::UnregisterComponent(kRDFFileSystemDataSourceCID,aPath); - rv = nsRepository::UnregisterComponent(kRDFHistoryDataSourceCID, aPath); - rv = nsRepository::UnregisterComponent(kRDFCompositeDataSourceCID, aPath); - rv = nsRepository::UnregisterComponent(kRDFInMemoryDataSourceCID, aPath); - rv = nsRepository::UnregisterComponent(kRDFXMLDataSourceCID, aPath); - rv = nsRepository::UnregisterComponent(kXULDataSourceCID, aPath); + rv = compMgr->UnregisterComponent(kRDFBookmarkDataSourceCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kRDFFileSystemDataSourceCID,aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kRDFHistoryDataSourceCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kRDFCompositeDataSourceCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kRDFInMemoryDataSourceCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kRDFXMLDataSourceCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kXULDataSourceCID, aPath); + if (NS_FAILED(rv)) return rv; - rv = nsRepository::UnregisterComponent(kRDFDefaultResourceCID, aPath); + rv = compMgr->UnregisterComponent(kRDFDefaultResourceCID, aPath); + if (NS_FAILED(rv)) return rv; - rv = nsRepository::UnregisterComponent(kRDFContentSinkCID, aPath); - rv = nsRepository::UnregisterComponent(kRDFHTMLBuilderCID, aPath); - rv = nsRepository::UnregisterComponent(kRDFServiceCID, aPath); - rv = nsRepository::UnregisterComponent(kRDFTreeBuilderCID, aPath); - rv = nsRepository::UnregisterComponent(kRDFXULBuilderCID, aPath); - rv = nsRepository::UnregisterComponent(kXULContentSinkCID, aPath); - rv = nsRepository::UnregisterComponent(kXULDocumentCID, aPath); - - return NS_OK; + rv = compMgr->UnregisterComponent(kRDFContentSinkCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kRDFHTMLBuilderCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kRDFServiceCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kXULSortServiceCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kRDFTreeBuilderCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kRDFMenuBuilderCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kRDFToolbarBuilderCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kRDFXULBuilderCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kXULContentSinkCID, aPath); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterComponent(kXULDocumentCID, aPath); + return rv; } diff --git a/mozilla/rdf/content/src/nsRDFContentUtils.cpp b/mozilla/rdf/content/src/nsRDFContentUtils.cpp index 4d6ec0f8ee8..00f5cbeb779 100644 --- a/mozilla/rdf/content/src/nsRDFContentUtils.cpp +++ b/mozilla/rdf/content/src/nsRDFContentUtils.cpp @@ -31,6 +31,7 @@ #include "nsLayoutCID.h" #include "nsRDFContentUtils.h" #include "nsString.h" +#include "prlog.h" static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID); static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID); @@ -70,7 +71,7 @@ nsRDFContentUtils::AttachTextNode(nsIContent* parent, nsIRDFNode* value) goto error; } - if (NS_FAILED(rv = nsRepository::CreateInstance(kTextNodeCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kTextNodeCID, nsnull, kIContentIID, (void**) &node))) diff --git a/mozilla/rdf/content/src/nsRDFElement.cpp b/mozilla/rdf/content/src/nsRDFElement.cpp index e492b48ba75..62c0beff61b 100644 --- a/mozilla/rdf/content/src/nsRDFElement.cpp +++ b/mozilla/rdf/content/src/nsRDFElement.cpp @@ -86,6 +86,7 @@ #include "nsIStyleRule.h" #include "nsIURL.h" #include "rdfutil.h" +#include "prlog.h" // The XUL interfaces implemented by the RDF content node. #include "nsIDOMXULElement.h" @@ -344,7 +345,7 @@ RDFElementImpl::RDFElementImpl(PRInt32 aNameSpaceID, nsIAtom* aTag) kStyleAtom = NS_NewAtom("style"); kContainerAtom = NS_NewAtom("container"); - rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &gNameSpaceManager); @@ -1008,7 +1009,7 @@ RDFElementImpl::GetListenerManager(nsIEventListenerManager** aResult) *aResult = mListenerManager; return NS_OK; } - nsresult rv = nsRepository::CreateInstance(kEventListenerManagerCID, + nsresult rv = nsComponentManager::CreateInstance(kEventListenerManagerCID, nsnull, kIEventListenerManagerIID, (void**) aResult); @@ -1022,7 +1023,7 @@ RDFElementImpl::GetListenerManager(nsIEventListenerManager** aResult) NS_IMETHODIMP RDFElementImpl::GetNewListenerManager(nsIEventListenerManager **aResult) { - return nsRepository::CreateInstance(kEventListenerManagerCID, + return nsComponentManager::CreateInstance(kEventListenerManagerCID, nsnull, kIEventListenerManagerIID, (void**) aResult); diff --git a/mozilla/rdf/content/src/nsRDFGenericBuilder.cpp b/mozilla/rdf/content/src/nsRDFGenericBuilder.cpp index 487f77569c4..0874286aa4a 100644 --- a/mozilla/rdf/content/src/nsRDFGenericBuilder.cpp +++ b/mozilla/rdf/content/src/nsRDFGenericBuilder.cpp @@ -160,7 +160,7 @@ RDFGenericBuilderImpl::RDFGenericBuilderImpl(void) // Register the XUL and RDF namespaces: these'll just retrieve // the IDs if they've already been registered by someone else. - if (NS_SUCCEEDED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &gNameSpaceManager))) { diff --git a/mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp b/mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp index a8e4587320c..255c52b52da 100644 --- a/mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp +++ b/mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp @@ -39,6 +39,7 @@ #include "nsISupportsArray.h" #include "nsRDFContentUtils.h" #include "rdfutil.h" +#include "prlog.h" //////////////////////////////////////////////////////////////////////// diff --git a/mozilla/rdf/content/src/nsRDFXULBuilder.cpp b/mozilla/rdf/content/src/nsRDFXULBuilder.cpp index e158bcfee40..2f6f072c914 100644 --- a/mozilla/rdf/content/src/nsRDFXULBuilder.cpp +++ b/mozilla/rdf/content/src/nsRDFXULBuilder.cpp @@ -270,7 +270,7 @@ RDFXULBuilderImpl::RDFXULBuilderImpl(void) if (gRefCnt++ == 0) { nsresult rv; - if (NS_SUCCEEDED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &gNameSpaceManager))) { @@ -1676,7 +1676,7 @@ RDFXULBuilderImpl::CreateBuilder(const nsCID& aBuilderCID, nsIContent* aElement, // construct a new builder nsCOMPtr builder; - if (NS_FAILED(rv = nsRepository::CreateInstance(aBuilderCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(aBuilderCID, nsnull, kIRDFContentModelBuilderIID, (void**) getter_AddRefs(builder)))) { @@ -1691,7 +1691,7 @@ RDFXULBuilderImpl::CreateBuilder(const nsCID& aBuilderCID, nsIContent* aElement, // create a database for the builder nsCOMPtr db; - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFCompositeDataSourceCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFCompositeDataSourceCID, nsnull, kIRDFCompositeDataSourceIID, (void**) getter_AddRefs(db)))) { diff --git a/mozilla/rdf/content/src/nsXULDocument.cpp b/mozilla/rdf/content/src/nsXULDocument.cpp index 74538709f72..2a309f228af 100644 --- a/mozilla/rdf/content/src/nsXULDocument.cpp +++ b/mozilla/rdf/content/src/nsXULDocument.cpp @@ -81,10 +81,11 @@ #include "plhash.h" #include "plstr.h" #include "rdfutil.h" - +#include "prlog.h" #include "nsILineBreakerFactory.h" #include "nsLWBrkCIID.h" + //////////////////////////////////////////////////////////////////////// static NS_DEFINE_IID(kICSSParserIID, NS_ICSS_PARSER_IID); // XXX grr.. @@ -640,7 +641,7 @@ XULDocumentImpl::XULDocumentImpl(void) nsresult rv; // construct a selection object - if (NS_FAILED(rv = nsRepository::CreateInstance(kRangeListCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRangeListCID, nsnull, kIDOMSelectionIID, (void**) &mSelection))) { @@ -803,7 +804,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, // Create an HTML style sheet for the HTML content. nsIHTMLStyleSheet* sheet; - if (NS_SUCCEEDED(rv = nsRepository::CreateInstance(kHTMLStyleSheetCID, + if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kHTMLStyleSheetCID, nsnull, kIHTMLStyleSheetIID, (void**) &sheet))) { @@ -824,7 +825,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, // Create an inline style sheet for inline content that contains a style // attribute. nsIHTMLCSSStyleSheet* inlineSheet; - if (NS_SUCCEEDED(rv = nsRepository::CreateInstance(kHTMLCSSStyleSheetCID, + if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kHTMLCSSStyleSheetCID, nsnull, kIHTMLCSSStyleSheetIID, (void**) &inlineSheet))) { @@ -845,7 +846,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, // Create a composite data source that'll tie together local and // remote stores. nsIRDFCompositeDataSource* db; - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFCompositeDataSourceCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFCompositeDataSourceCID, nsnull, kIRDFCompositeDataSourceIID, (void**) &db))) { @@ -855,7 +856,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, // Create a XUL content model builder NS_IF_RELEASE(mXULBuilder); - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFXULBuilderCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFXULBuilderCID, nsnull, kIRDFContentModelBuilderIID, (void**) &mXULBuilder))) { @@ -881,7 +882,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, // XXX This needs to be cloned across windows, and the final // instance needs to be flushed to disk. It may be that this is // really an RDFXML data source... - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, nsnull, kIRDFDataSourceIID, (void**) &mLocalDataSource))) { @@ -909,7 +910,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, // meantime, add us as an nsIRDFXMLDataSourceObserver so that // we'll be notified when we need to load style sheets, etc. NS_IF_RELEASE(mDocumentDataSource); - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, nsnull, kIRDFDataSourceIID, (void**) &mDocumentDataSource))) { @@ -928,7 +929,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, } nsCOMPtr sink; - if (NS_FAILED(rv = nsRepository::CreateInstance(kXULContentSinkCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kXULContentSinkCID, nsnull, kIXULContentSinkIID, (void**) getter_AddRefs(sink)))) { @@ -946,7 +947,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, } } - if (NS_FAILED(rv = nsRepository::CreateInstance(kParserCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kParserCID, nsnull, kIParserIID, (void**) &mParser))) { @@ -960,7 +961,7 @@ XULDocumentImpl::StartDocumentLoad(nsIURL *aURL, } nsCOMPtr dtd; - if (NS_FAILED(rv = nsRepository::CreateInstance(kWellFormedDTDCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kWellFormedDTDCID, nsnull, kIDTDIID, (void**) getter_AddRefs(dtd)))) { @@ -1078,7 +1079,7 @@ XULDocumentImpl::CreateShell(nsIPresContext* aContext, nsresult rv; nsIPresShell* shell; - if (NS_FAILED(rv = nsRepository::CreateInstance(kPresShellCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kPresShellCID, nsnull, kIPresShellIID, (void**) &shell))) @@ -2821,7 +2822,7 @@ XULDocumentImpl::LoadCSSStyleSheet(nsIURL* url) } nsICSSParser* parser; - rv = nsRepository::CreateInstance(kCSSParserCID, + rv = nsComponentManager::CreateInstance(kCSSParserCID, nsnull, kICSSParserIID, (void**) &parser); @@ -2887,7 +2888,7 @@ XULDocumentImpl::Init(void) return rv; // Create a namespace manager so we can manage tags - if (NS_FAILED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &mNameSpaceManager))) diff --git a/mozilla/rdf/content/src/nsXULElement.cpp b/mozilla/rdf/content/src/nsXULElement.cpp index e492b48ba75..62c0beff61b 100644 --- a/mozilla/rdf/content/src/nsXULElement.cpp +++ b/mozilla/rdf/content/src/nsXULElement.cpp @@ -86,6 +86,7 @@ #include "nsIStyleRule.h" #include "nsIURL.h" #include "rdfutil.h" +#include "prlog.h" // The XUL interfaces implemented by the RDF content node. #include "nsIDOMXULElement.h" @@ -344,7 +345,7 @@ RDFElementImpl::RDFElementImpl(PRInt32 aNameSpaceID, nsIAtom* aTag) kStyleAtom = NS_NewAtom("style"); kContainerAtom = NS_NewAtom("container"); - rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &gNameSpaceManager); @@ -1008,7 +1009,7 @@ RDFElementImpl::GetListenerManager(nsIEventListenerManager** aResult) *aResult = mListenerManager; return NS_OK; } - nsresult rv = nsRepository::CreateInstance(kEventListenerManagerCID, + nsresult rv = nsComponentManager::CreateInstance(kEventListenerManagerCID, nsnull, kIEventListenerManagerIID, (void**) aResult); @@ -1022,7 +1023,7 @@ RDFElementImpl::GetListenerManager(nsIEventListenerManager** aResult) NS_IMETHODIMP RDFElementImpl::GetNewListenerManager(nsIEventListenerManager **aResult) { - return nsRepository::CreateInstance(kEventListenerManagerCID, + return nsComponentManager::CreateInstance(kEventListenerManagerCID, nsnull, kIEventListenerManagerIID, (void**) aResult); diff --git a/mozilla/rdf/content/src/nsXULSortService.cpp b/mozilla/rdf/content/src/nsXULSortService.cpp index 88b8039743e..d3a5d5576bf 100644 --- a/mozilla/rdf/content/src/nsXULSortService.cpp +++ b/mozilla/rdf/content/src/nsXULSortService.cpp @@ -217,7 +217,7 @@ XULSortServiceImpl::XULSortServiceImpl(void) // Register the XUL and RDF namespaces: these'll just retrieve // the IDs if they've already been registered by someone else. nsINameSpaceManager* mgr; - if (NS_SUCCEEDED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &mgr))) diff --git a/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp b/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp index 487f77569c4..0874286aa4a 100644 --- a/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp +++ b/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp @@ -160,7 +160,7 @@ RDFGenericBuilderImpl::RDFGenericBuilderImpl(void) // Register the XUL and RDF namespaces: these'll just retrieve // the IDs if they've already been registered by someone else. - if (NS_SUCCEEDED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + if (NS_SUCCEEDED(rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &gNameSpaceManager))) { diff --git a/mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp b/mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp index 562e75bcaf7..6d01a4fa518 100644 --- a/mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp +++ b/mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp @@ -37,6 +37,8 @@ #include "prio.h" #include "rdf.h" #include "rdfutil.h" +#include "prlog.h" +#include "nsIComponentManager.h" //////////////////////////////////////////////////////////////////////// @@ -641,7 +643,7 @@ BookmarkDataSourceImpl::Init(const char* uri) { nsresult rv; - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, nsnull, kIRDFDataSourceIID, (void**) &mInner))) diff --git a/mozilla/rdf/datasource/src/nsXULContentSink.cpp b/mozilla/rdf/datasource/src/nsXULContentSink.cpp index b7e94c14b66..929ecfb05fb 100644 --- a/mozilla/rdf/datasource/src/nsXULContentSink.cpp +++ b/mozilla/rdf/datasource/src/nsXULContentSink.cpp @@ -570,7 +570,7 @@ XULContentSinkImpl::LoadStyleSheet(nsIURL* aURL, { nsresult rv; nsCOMPtr parser; - if (NS_FAILED(rv = nsRepository::CreateInstance(kCSSParserCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kCSSParserCID, nsnull, nsICSSParser::GetIID(), (void**) getter_AddRefs(parser)))) { diff --git a/mozilla/rdf/datasource/src/nsXULDataSource.cpp b/mozilla/rdf/datasource/src/nsXULDataSource.cpp index 9aa1f33db55..3fcd9071a83 100644 --- a/mozilla/rdf/datasource/src/nsXULDataSource.cpp +++ b/mozilla/rdf/datasource/src/nsXULDataSource.cpp @@ -52,6 +52,7 @@ #include "prio.h" #include "prthread.h" #include "rdfutil.h" +#include "prlog.h" //////////////////////////////////////////////////////////////////////// @@ -256,7 +257,7 @@ XULDataSourceImpl::XULDataSourceImpl(void) mNameSpaces(nsnull) { nsresult rv; - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFInMemoryDataSourceCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, nsnull, kIRDFDataSourceIID, (void**) &mInner))) @@ -362,13 +363,13 @@ static const char kResourceURIPrefix[] = "resource:"; if (NS_FAILED(rv = rdfService->RegisterDataSource(this))) goto done; - if (NS_FAILED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID, nsnull, kINameSpaceManagerIID, (void**) &ns))) goto done; - if (NS_FAILED(rv = nsRepository::CreateInstance(kXULContentSinkCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kXULContentSinkCID, nsnull, kIRDFContentSinkIID, (void**) &sink))) @@ -382,7 +383,7 @@ static const char kResourceURIPrefix[] = "resource:"; if (NS_FAILED(rv = sink->SetDataSource(this))) goto done; - if (NS_FAILED(rv = nsRepository::CreateInstance(kParserCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kParserCID, nsnull, kIParserIID, (void**) &parser))) @@ -393,7 +394,7 @@ static const char kResourceURIPrefix[] = "resource:"; // XXX this should eventually be kRDFDTDCID (oh boy, that's a // pretty identifier). The RDF DTD will be a much more // RDF-resilient parser. - if (NS_FAILED(rv = nsRepository::CreateInstance(kWellFormedDTDCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kWellFormedDTDCID, nsnull, kIDTDIID, (void**) &dtd))) diff --git a/mozilla/rdf/tests/localfile/localfile.cpp b/mozilla/rdf/tests/localfile/localfile.cpp index 1e8e909800c..fec0c3621b5 100644 --- a/mozilla/rdf/tests/localfile/localfile.cpp +++ b/mozilla/rdf/tests/localfile/localfile.cpp @@ -56,7 +56,7 @@ #include "nsParserCIID.h" #include "nsRDFCID.h" #include "nsRDFCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsXPComCIID.h" #include "plevent.h" #include "plstr.h" @@ -126,20 +126,20 @@ static nsresult SetupRegistry(void) { // netlib - nsRepository::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); // parser - nsRepository::RegisterComponent(kParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kWellFormedDTDCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kWellFormedDTDCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); // layout - nsRepository::RegisterComponent(kNameSpaceManagerCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kNameSpaceManagerCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); // dom - nsRepository::RegisterComponent(kScriptNameSetRegistryCID, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kScriptNameSetRegistryCID, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); // xpcom - nsRepository::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); return NS_OK; } @@ -183,7 +183,7 @@ main(int argc, char** argv) // Create a stream data source and initialize it on argv[1], which // is hopefully a "file:" URL. (Actually, we can do _any_ kind of // URL, but only a "file:" URL will be written back to disk.) - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFXMLDataSourceCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFXMLDataSourceCID, nsnull, kIRDFXMLDataSourceIID, (void**) &ds))) diff --git a/mozilla/rdf/tests/rdfsink/rdfsink.cpp b/mozilla/rdf/tests/rdfsink/rdfsink.cpp index 85768fcffb7..312e9b6fe3f 100644 --- a/mozilla/rdf/tests/rdfsink/rdfsink.cpp +++ b/mozilla/rdf/tests/rdfsink/rdfsink.cpp @@ -36,7 +36,7 @@ #include "nsParserCIID.h" #include "nsRDFCID.h" #include "nsRDFCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsXPComCIID.h" #include "plevent.h" #include "plstr.h" @@ -110,20 +110,20 @@ static nsresult SetupRegistry(void) { // netlib - nsRepository::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); // parser - nsRepository::RegisterComponent(kParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kWellFormedDTDCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kWellFormedDTDCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); // layout - nsRepository::RegisterComponent(kNameSpaceManagerCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kNameSpaceManagerCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); // dom - nsRepository::RegisterComponent(kScriptNameSetRegistryCID, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kScriptNameSetRegistryCID, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); // xpcom - nsRepository::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); return NS_OK; } @@ -199,7 +199,7 @@ main(int argc, char** argv) // Create a stream data source and initialize it on argv[1], which // is hopefully a "file:" URL. (Actually, we can do _any_ kind of // URL, but only a "file:" URL will be written back to disk.) - if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFXMLDataSourceCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFXMLDataSourceCID, nsnull, kIRDFXMLDataSourceIID, (void**) &ds))) { diff --git a/mozilla/rdf/util/src/nsRDFResource.cpp b/mozilla/rdf/util/src/nsRDFResource.cpp index 4b2da760c28..659331e5458 100644 --- a/mozilla/rdf/util/src/nsRDFResource.cpp +++ b/mozilla/rdf/util/src/nsRDFResource.cpp @@ -21,6 +21,7 @@ #include "nsIServiceManager.h" #include "nsIRDFService.h" #include "nsRDFCID.h" +#include "prlog.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); @@ -74,7 +75,7 @@ nsRDFResource::QueryInterface(REFNSIID iid, void** result) iid.Equals(nsIRDFNode::GetIID()) || iid.Equals(kISupportsIID)) { *result = NS_STATIC_CAST(nsIRDFResource*, this); - AddRef(); + NS_ADDREF_THIS(); return NS_OK; } @@ -91,7 +92,8 @@ nsRDFResource::Init(const char* uri) if (mURI == nsnull) return NS_ERROR_OUT_OF_MEMORY; - return gRDFService->RegisterResource(this, PR_TRUE); + // don't replace an existing resource with the same URI automatically + return gRDFService->RegisterResource(this, PR_FALSE); } NS_IMETHODIMP diff --git a/mozilla/silentdl/nsJSSilentDownloadTask.cpp b/mozilla/silentdl/nsJSSilentDownloadTask.cpp index 9aed4b83e25..e0491388f61 100644 --- a/mozilla/silentdl/nsJSSilentDownloadTask.cpp +++ b/mozilla/silentdl/nsJSSilentDownloadTask.cpp @@ -28,7 +28,7 @@ #include "nsString.h" #include "nsIDOMSilentDownloadTask.h" #include "nsIScriptNameSpaceManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsDOMCID.h" @@ -543,7 +543,7 @@ SilentDownloadTask(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval return JS_FALSE; } - result = nsRepository::CreateInstance(classID, + result = nsComponentManager::CreateInstance(classID, nsnull, kIDOMSilentDownloadTaskIID, (void **)&nativeThis); diff --git a/mozilla/silentdl/nsSilentDownload.cpp b/mozilla/silentdl/nsSilentDownload.cpp index 70a795ff016..c7da8109bd6 100644 --- a/mozilla/silentdl/nsSilentDownload.cpp +++ b/mozilla/silentdl/nsSilentDownload.cpp @@ -25,7 +25,7 @@ #include "nsIFactory.h" #include "nsISupports.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIScriptObjectOwner.h" #include "nsIScriptGlobalObject.h" @@ -58,6 +58,9 @@ #include "nsIBrowserWindow.h" #include "nsIWebShell.h" +#include "nsIServiceManager.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); // Globals @@ -428,10 +431,10 @@ nsSilentDownloadManager::Startup() /* Create an instance of INet so that we can see if the network is busy */ /************************************************************************/ - result = nsRepository::CreateInstance(kInetServiceCID, - nsnull, - kInetServiceIID, - (void**)&gInetService); + result = nsComponentManager::CreateInstance(kInetServiceCID, + nsnull, + kInetServiceIID, + (void**)&gInetService); if (result != NS_OK) return result; @@ -637,9 +640,9 @@ nsSilentDownloadTask::LoadScript(void) if (mWindow == nsnull) { - nsresult rv = nsRepository::CreateInstance(kBrowserWindowCID, nsnull, - kIBrowserWindowIID, - (void**) &mWindow); + nsresult rv = nsComponentManager::CreateInstance(kBrowserWindowCID, nsnull, + kIBrowserWindowIID, + (void**) &mWindow); if (rv == NS_OK) { nsRect rect(0, 0, 275, 300); @@ -1424,35 +1427,49 @@ nsSilentDownloadListener::SetSilentDownloadInfo(nsIDOMSilentDownloadTask* con) //////////////////////////////////////////////////////////////////////////////// extern "C" NS_EXPORT PRBool -NSCanUnload(nsISupports* serviceMgr) +NSCanUnload(nsISupports* aServMgr) { return PRBool (gInstanceCnt == 0 && gLockCnt == 0); } extern "C" NS_EXPORT nsresult -NSRegisterSelf(nsISupports* serviceMgr, const char *path) +NSRegisterSelf(nsISupports* aServMgr, const char *path) { + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + +#ifdef NS_DEBUG printf("*** SilentDownload is being registered\n"); - nsRepository::RegisterComponent(kSilentDownloadCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - nsRepository::RegisterComponent(kSilentDownloadTaskCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - return NS_OK; +#endif + + rv = compMgr->RegisterComponent(kSilentDownloadCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) return rv; + rv = compMgr->RegisterComponent(kSilentDownloadTaskCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + return rv; } extern "C" NS_EXPORT nsresult -NSUnregisterSelf(nsISupports* serviceMgr, const char *path) +NSUnregisterSelf(nsISupports* aServMgr, const char *path) { + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + +#ifdef NS_DEBUG printf("*** SilentDownload is being unregistered\n"); +#endif - nsRepository::UnregisterFactory(kSilentDownloadCID, path); - nsRepository::UnregisterFactory(kSilentDownloadTaskCID, path); - - return NS_OK; + rv = compMgr->UnregisterFactory(kSilentDownloadCID, path); + if (NS_FAILED(rv)) return rv; + rv = compMgr->UnregisterFactory(kSilentDownloadTaskCID, path); + return rv; } extern "C" NS_EXPORT nsresult -NSGetFactory(nsISupports* serviceMgr, +NSGetFactory(nsISupports* aServMgr, const nsCID &aClass, const char *aClassName, const char *aProgID, diff --git a/mozilla/silentdl/nsSilentDownloadPrivate.h b/mozilla/silentdl/nsSilentDownloadPrivate.h index e22d7771939..6de7c0f413c 100644 --- a/mozilla/silentdl/nsSilentDownloadPrivate.h +++ b/mozilla/silentdl/nsSilentDownloadPrivate.h @@ -42,25 +42,6 @@ #include "prio.h" -//////////////////////////////////////////////////////////////////////////////// -// DLL Entry Points: -//////////////////////////////////////////////////////////////////////////////// -extern "C" NS_EXPORT nsresult -NSGetFactory(nsISupports* serviceMgr, - const nsCID &aClass, - const char *aClassName, - const char *aProgID, - nsIFactory **aFactory); - -extern "C" NS_EXPORT PRBool -NSCanUnload(nsISupports* serviceMgr); - -extern "C" NS_EXPORT nsresult -NSRegisterSelf(nsISupports* serviceMgr, const char *path); - -extern "C" NS_EXPORT nsresult -NSUnregisterSelf(nsISupports* serviceMgr, const char *path); - //////////////////////////////////////////////////////////////////////////////// // nsSilentDownloadListener: //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index f4afcc03c4d..2d012652833 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -345,7 +345,7 @@ nsDocFactoryImpl::CreateDefaultDocument(nsIURL* aURL, /* * Create the HTML document... */ - rv = nsRepository::CreateInstance(kCHTMLDocumentCID, + rv = nsComponentManager::CreateInstance(kCHTMLDocumentCID, nsnull, kIDocumentIID, (void **)&doc); @@ -404,7 +404,7 @@ nsDocFactoryImpl::CreateXMLDocument(nsIURL* aURL, /* * Create the image document... */ - rv = nsRepository::CreateInstance(kCXMLDocumentCID, + rv = nsComponentManager::CreateInstance(kCXMLDocumentCID, nsnull, kIDocumentIID, (void **)&doc); @@ -463,7 +463,7 @@ nsDocFactoryImpl::CreateRDFDocument(const char* aContentType, nsIURL* aURL, /* * Create the image document... */ - if (NS_FAILED(rv = nsRepository::CreateInstance(kCXULDocumentCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kCXULDocumentCID, nsnull, kIDocumentIID, (void **)&doc))) @@ -518,7 +518,7 @@ nsDocFactoryImpl::CreateImageDocument(nsIURL* aURL, /* * Create the image document... */ - rv = nsRepository::CreateInstance(kCImageDocumentCID, + rv = nsComponentManager::CreateInstance(kCImageDocumentCID, nsnull, kIDocumentIID, (void **)&doc); diff --git a/mozilla/view/public/nsViewsCID.h b/mozilla/view/public/nsViewsCID.h index d557944b22b..9f789de678e 100644 --- a/mozilla/view/public/nsViewsCID.h +++ b/mozilla/view/public/nsViewsCID.h @@ -21,7 +21,7 @@ #include "nsISupports.h" #include "nsIFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #define NS_VIEW_MANAGER_CID \ { 0xc95f1831, 0xc376, 0x11d1, \ diff --git a/mozilla/view/src/nsScrollingView.cpp b/mozilla/view/src/nsScrollingView.cpp index fda9013e59f..fb1d5ae73b0 100644 --- a/mozilla/view/src/nsScrollingView.cpp +++ b/mozilla/view/src/nsScrollingView.cpp @@ -248,7 +248,7 @@ NS_IMETHODIMP CornerView :: Paint(nsIRenderingContext& rc, const nsRect& rect, if (nsnull == mLookAndFeel) { - nsRepository::CreateInstance(kLookAndFeelCID, nsnull, + nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void **)&mLookAndFeel); } diff --git a/mozilla/view/src/nsView.cpp b/mozilla/view/src/nsView.cpp index 33593dc31fd..3d08953395e 100644 --- a/mozilla/view/src/nsView.cpp +++ b/mozilla/view/src/nsView.cpp @@ -26,7 +26,7 @@ #include "nsIScrollbar.h" #include "nsGUIEvent.h" #include "nsIDeviceContext.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIRenderingContext.h" #include "nsTransform2D.h" #include "nsIScrollableView.h" @@ -648,7 +648,7 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect, nsIBlender *blender = nsnull; nsresult rv; - rv = nsRepository::CreateInstance(kBlenderCID, nsnull, kIBlenderIID, (void **)&blender); + rv = nsComponentManager::CreateInstance(kBlenderCID, nsnull, kIBlenderIID, (void **)&blender); if (NS_OK == rv) { @@ -1251,7 +1251,7 @@ nsresult nsView :: LoadWidget(const nsCID &aClassIID) nsresult rv; static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); - rv = nsRepository::CreateInstance(aClassIID, nsnull, kIWidgetIID, (void**)&mWindow); + rv = nsComponentManager::CreateInstance(aClassIID, nsnull, kIWidgetIID, (void**)&mWindow); if (NS_OK == rv) { diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index 5508411f78d..674507a13ea 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -112,7 +112,7 @@ nsViewManager :: ~nsViewManager() static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kIRenderingContextIID, NS_IRENDERING_CONTEXT_IID); - nsresult rv = nsRepository::CreateInstance(kRenderingContextCID, + nsresult rv = nsComponentManager::CreateInstance(kRenderingContextCID, nsnull, kIRenderingContextIID, (void **)&rc); @@ -231,10 +231,10 @@ NS_IMETHODIMP nsViewManager :: Init(nsIDeviceContext* aContext) mKeyGrabber = nsnull; //create regions - nsRepository::CreateInstance(kRegionCID, nsnull, kIRegionIID, (void **)&mTransRgn); - nsRepository::CreateInstance(kRegionCID, nsnull, kIRegionIID, (void **)&mOpaqueRgn); - nsRepository::CreateInstance(kRegionCID, nsnull, kIRegionIID, (void **)&mTRgn); - nsRepository::CreateInstance(kRegionCID, nsnull, kIRegionIID, (void **)&mRCRgn); + nsComponentManager::CreateInstance(kRegionCID, nsnull, kIRegionIID, (void **)&mTransRgn); + nsComponentManager::CreateInstance(kRegionCID, nsnull, kIRegionIID, (void **)&mOpaqueRgn); + nsComponentManager::CreateInstance(kRegionCID, nsnull, kIRegionIID, (void **)&mTRgn); + nsComponentManager::CreateInstance(kRegionCID, nsnull, kIRegionIID, (void **)&mRCRgn); if (nsnull != mTransRgn) mTransRgn->Init(); @@ -749,7 +749,7 @@ for (cnt = 0; cnt < flatlen; cnt += FLATVIEW_INC) if (nsnull == mBlender) { - if (NS_OK == nsRepository::CreateInstance(kBlenderCID, nsnull, kIBlenderIID, (void **)&mBlender)) + if (NS_OK == nsComponentManager::CreateInstance(kBlenderCID, nsnull, kIBlenderIID, (void **)&mBlender)) mBlender->Init(mContext); } @@ -2003,7 +2003,7 @@ void nsViewManager :: AddRectToDirtyRegion(nsIView* aView, const nsRect &aRect) static NS_DEFINE_IID(kIRegionIID, NS_IREGION_IID); // The view doesn't have a dirty region so create one - nsresult rv = nsRepository::CreateInstance(kRegionCID, + nsresult rv = nsComponentManager::CreateInstance(kRegionCID, nsnull, kIRegionIID, (void **)&dirtyRegion); diff --git a/mozilla/webshell/embed/ActiveX/MozillaBrowser.cpp b/mozilla/webshell/embed/ActiveX/MozillaBrowser.cpp index 5bc23652c45..673ac0cce21 100644 --- a/mozilla/webshell/embed/ActiveX/MozillaBrowser.cpp +++ b/mozilla/webshell/embed/ActiveX/MozillaBrowser.cpp @@ -241,7 +241,7 @@ HRESULT CMozillaBrowser::CreateWebShell() #ifdef USE_NGPREF // Load preferences - rv = nsRepository::CreateInstance(kPrefCID, NULL, kIPrefIID, (void **) &m_pIPref); + rv = nsComponentManager::CreateInstance(kPrefCID, NULL, kIPrefIID, (void **) &m_pIPref); if (NS_OK != rv) { NG_ASSERT(0); @@ -252,7 +252,7 @@ HRESULT CMozillaBrowser::CreateWebShell() #endif // Create the web shell object - rv = nsRepository::CreateInstance(kWebShellCID, nsnull, + rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&m_pIWebShell); if (NS_OK != rv) diff --git a/mozilla/webshell/embed/ActiveX/StdAfx.h b/mozilla/webshell/embed/ActiveX/StdAfx.h index 3bf853a6a4a..9dd6bfd2c48 100644 --- a/mozilla/webshell/embed/ActiveX/StdAfx.h +++ b/mozilla/webshell/embed/ActiveX/StdAfx.h @@ -73,7 +73,7 @@ typedef long int32; #include "prthread.h" #include "prprf.h" #include "plevent.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIEventQueueService.h" #include "nsXPComCIID.h" diff --git a/mozilla/webshell/src/nsComFactory.cpp b/mozilla/webshell/src/nsComFactory.cpp index 5eedde27333..00b09fb8f07 100644 --- a/mozilla/webshell/src/nsComFactory.cpp +++ b/mozilla/webshell/src/nsComFactory.cpp @@ -21,7 +21,7 @@ // // This is a terrible hack which *must* go away soon!!! -// We need some other mechanism to prime the nsRepository... +// We need some other mechanism to prime the nsComponentManager... // #include "../tests/viewer/nsSetupRegistry.cpp" diff --git a/mozilla/webshell/src/nsDocLoader.cpp b/mozilla/webshell/src/nsDocLoader.cpp index f4afcc03c4d..2d012652833 100644 --- a/mozilla/webshell/src/nsDocLoader.cpp +++ b/mozilla/webshell/src/nsDocLoader.cpp @@ -345,7 +345,7 @@ nsDocFactoryImpl::CreateDefaultDocument(nsIURL* aURL, /* * Create the HTML document... */ - rv = nsRepository::CreateInstance(kCHTMLDocumentCID, + rv = nsComponentManager::CreateInstance(kCHTMLDocumentCID, nsnull, kIDocumentIID, (void **)&doc); @@ -404,7 +404,7 @@ nsDocFactoryImpl::CreateXMLDocument(nsIURL* aURL, /* * Create the image document... */ - rv = nsRepository::CreateInstance(kCXMLDocumentCID, + rv = nsComponentManager::CreateInstance(kCXMLDocumentCID, nsnull, kIDocumentIID, (void **)&doc); @@ -463,7 +463,7 @@ nsDocFactoryImpl::CreateRDFDocument(const char* aContentType, nsIURL* aURL, /* * Create the image document... */ - if (NS_FAILED(rv = nsRepository::CreateInstance(kCXULDocumentCID, + if (NS_FAILED(rv = nsComponentManager::CreateInstance(kCXULDocumentCID, nsnull, kIDocumentIID, (void **)&doc))) @@ -518,7 +518,7 @@ nsDocFactoryImpl::CreateImageDocument(nsIURL* aURL, /* * Create the image document... */ - rv = nsRepository::CreateInstance(kCImageDocumentCID, + rv = nsComponentManager::CreateInstance(kCImageDocumentCID, nsnull, kIDocumentIID, (void **)&doc); diff --git a/mozilla/webshell/src/nsDocumentViewer.cpp b/mozilla/webshell/src/nsDocumentViewer.cpp index 475f2fc57f3..c7f5df5e84c 100644 --- a/mozilla/webshell/src/nsDocumentViewer.cpp +++ b/mozilla/webshell/src/nsDocumentViewer.cpp @@ -474,7 +474,7 @@ NS_IMETHODIMP DocumentViewerImpl::Print(void) { nsIDeviceContextSpecFactory *factory = nsnull; - nsRepository::CreateInstance(kDeviceContextSpecFactoryCID, nsnull, + nsComponentManager::CreateInstance(kDeviceContextSpecFactoryCID, nsnull, kIDeviceContextSpecFactoryIID, (void **)&factory); if (nsnull != factory) @@ -514,7 +514,7 @@ NS_IMETHODIMP DocumentViewerImpl::Print(void) { nsresult rv; - rv = nsRepository::CreateInstance(kViewManagerCID, + rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull, kIViewManagerIID, (void **)&vm); @@ -527,7 +527,7 @@ NS_IMETHODIMP DocumentViewerImpl::Print(void) // Create a child window of the parent that is our "root view/window" // Create a view - rv = nsRepository::CreateInstance(kViewCID, + rv = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view); @@ -610,7 +610,7 @@ nsresult DocumentViewerImpl::MakeWindow(nsNativeWidget aNativeParent, { nsresult rv; - rv = nsRepository::CreateInstance(kViewManagerCID, + rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull, kIViewManagerIID, (void **)&mViewManager); @@ -629,7 +629,7 @@ nsresult DocumentViewerImpl::MakeWindow(nsNativeWidget aNativeParent, // Create a child window of the parent that is our "root view/window" // Create a view - rv = nsRepository::CreateInstance(kViewCID, + rv = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&mView); diff --git a/mozilla/webshell/src/nsPluginViewer.cpp b/mozilla/webshell/src/nsPluginViewer.cpp index dfe506b82d3..6ef2d9b31b7 100644 --- a/mozilla/webshell/src/nsPluginViewer.cpp +++ b/mozilla/webshell/src/nsPluginViewer.cpp @@ -24,7 +24,7 @@ #include "nsIPluginInstance.h" #include "nsIStreamListener.h" #include "nsIURL.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsWidgetsCID.h" #include "nsILinkHandler.h" #include "nsIWebShell.h" @@ -345,7 +345,7 @@ PluginViewerImpl::MakeWindow(nsNativeWidget aParent, const nsRect& aBounds) { nsresult rv = - nsRepository::CreateInstance(kChildWindowCID, nsnull, kIWidgetIID, + nsComponentManager::CreateInstance(kChildWindowCID, nsnull, kIWidgetIID, (void**)&mWindow); if (NS_OK != rv) { return rv; diff --git a/mozilla/webshell/src/nsThrobber.cpp b/mozilla/webshell/src/nsThrobber.cpp index a61ef01d627..ee15b5f9539 100644 --- a/mozilla/webshell/src/nsThrobber.cpp +++ b/mozilla/webshell/src/nsThrobber.cpp @@ -27,7 +27,7 @@ #include "nsFont.h" #include "nsIRenderingContext.h" #include "nsIFontMetrics.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsWidgetsCID.h" #include "nsCRT.h" #include "prprf.h" @@ -335,7 +335,7 @@ nsThrobber::Init(nsIWidget* aParent, const nsRect& aBounds, const nsString& aFil mNumImages = aNumImages; // Create widget - nsresult rv = nsRepository::CreateInstance(kChildCID, nsnull, kIWidgetIID, (void**)&mWidget); + nsresult rv = nsComponentManager::CreateInstance(kChildCID, nsnull, kIWidgetIID, (void**)&mWidget); if (NS_OK != rv) { return rv; } diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 367197c8e24..d6afbdcdcbc 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -30,7 +30,7 @@ #include "nsIDocumentLoaderObserver.h" #include "nsDOMEvent.h" #include "nsIPresContext.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIEventQueueService.h" #include "nsXPComCIID.h" @@ -771,7 +771,7 @@ nsWebShell::Init(nsNativeWidget aNativeParent, mDocLoader->AddObserver((nsIDocumentLoaderObserver*)this); // Create device context - rv = nsRepository::CreateInstance(kDeviceContextCID, nsnull, + rv = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull, kIDeviceContextIID, (void **)&mDeviceContext); if (NS_FAILED(rv)) { @@ -788,7 +788,7 @@ nsWebShell::Init(nsNativeWidget aNativeParent, mDeviceContext->SetGamma(1.0f); // Create a Native window for the shell container... - rv = nsRepository::CreateInstance(kChildCID, nsnull, kIWidgetIID, (void**)&mWindow); + rv = nsComponentManager::CreateInstance(kChildCID, nsnull, kIWidgetIID, (void**)&mWindow); if (NS_FAILED(rv)) { goto done; } diff --git a/mozilla/webshell/tests/imgtest/ImageTest.cpp b/mozilla/webshell/tests/imgtest/ImageTest.cpp index 566f4e54481..fd29379f6fb 100644 --- a/mozilla/webshell/tests/imgtest/ImageTest.cpp +++ b/mozilla/webshell/tests/imgtest/ImageTest.cpp @@ -338,7 +338,7 @@ static HWND CreateTopLevel(const char* clazz, const char* title, nsRect rect(0, 0, aWidth, aHeight); - nsresult rv = nsRepository::CreateInstance(kCChildWindowIID, NULL, kIWidgetIID, (void**)&gWindow); + nsresult rv = nsComponentManager::CreateInstance(kCChildWindowIID, NULL, kIWidgetIID, (void**)&gWindow); if (NS_OK == rv) { gWindow->Create((nsNativeWidget)window, rect, MyHandleEvent, NULL); @@ -357,19 +357,19 @@ WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, int nCmdShow { gInstance = instance; - nsRepository::RegisterComponent(kCWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCChildWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCChildWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); static NS_DEFINE_IID(kCRenderingContextIID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kCDeviceContextIID, NS_DEVICE_CONTEXT_CID); static NS_DEFINE_IID(kCFontMetricsIID, NS_FONT_METRICS_CID); static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID); - nsRepository::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCImageIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCImageIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); if (!prevInstance) { WNDCLASS wndClass; diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index 58958b16d29..fae35d3fe63 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -38,13 +38,13 @@ #include "nsIURL.h" #include "nsIFileWidget.h" #include "nsILookAndFeel.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIFactory.h" #include "nsCRT.h" #include "nsWidgetsCID.h" #include "nsViewerApp.h" #include "prprf.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsParserCIID.h" #include "nsIEnumerator.h" #include "nsCOMPtr.h" @@ -533,7 +533,7 @@ static PRBool GetFileNameFromFileSelector(nsIWidget* aParentWindow, PRBool selectedFileName = PR_FALSE; nsIFileWidget *fileWidget; nsString title("Open HTML"); - nsresult rv = nsRepository::CreateInstance(kFileWidgetCID, + nsresult rv = nsComponentManager::CreateInstance(kFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget); @@ -795,7 +795,7 @@ nsBrowserWindow::DoFind() nsString title("Find"); nsXPBaseWindow * dialog = nsnull; - nsresult rv = nsRepository::CreateInstance(kXPBaseWindowCID, nsnull, + nsresult rv = nsComponentManager::CreateInstance(kXPBaseWindowCID, nsnull, kIXPBaseWindowIID, (void**) &dialog); if (rv == NS_OK) { @@ -951,7 +951,7 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell, mAllowPlugins = aAllowPlugins; // Create top level window - nsresult rv = nsRepository::CreateInstance(kWindowCID, nsnull, kIWindowIID, + nsresult rv = nsComponentManager::CreateInstance(kWindowCID, nsnull, kIWindowIID, (void**)&mWindow); if (NS_OK != rv) { return rv; @@ -965,7 +965,7 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell, mWindow->GetClientBounds(r); // Create web shell - rv = nsRepository::CreateInstance(kWebShellCID, nsnull, + rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&mWebShell); if (NS_OK != rv) { @@ -1029,7 +1029,7 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell, mAllowPlugins = aAllowPlugins; // Create top level window - nsresult rv = nsRepository::CreateInstance(kWindowCID, nsnull, kIWidgetIID, + nsresult rv = nsComponentManager::CreateInstance(kWindowCID, nsnull, kIWidgetIID, (void**)&mWindow); if (NS_OK != rv) { return rv; @@ -1040,7 +1040,7 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell, mWindow->GetClientBounds(r); // Create web shell - rv = nsRepository::CreateInstance(kWebShellCID, nsnull, + rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&mWebShell); if (NS_OK != rv) { @@ -1114,7 +1114,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) NS_RELEASE(dc); // Create and place back button - rv = nsRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID, + rv = nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mBack); if (NS_OK != rv) { return rv; @@ -1133,7 +1133,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) // Create and place forward button r.SetRect(BUTTON_WIDTH, 0, BUTTON_WIDTH, BUTTON_HEIGHT); - rv = nsRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID, + rv = nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mForward); if (NS_OK != rv) { return rv; @@ -1152,7 +1152,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) r.SetRect(2*BUTTON_WIDTH, 0, aWidth - 2*BUTTON_WIDTH - THROBBER_WIDTH, BUTTON_HEIGHT); - rv = nsRepository::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, + rv = nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mLocation); if (NS_OK != rv) { return rv; @@ -1171,7 +1171,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) // Create and place throbber r.SetRect(aWidth - THROBBER_WIDTH, 0, THROBBER_WIDTH, THROBBER_HEIGHT); - rv = nsRepository::CreateInstance(kThrobberCID, nsnull, kIThrobberIID, + rv = nsComponentManager::CreateInstance(kThrobberCID, nsnull, kIThrobberIID, (void**)&mThrobber); if (NS_OK != rv) { return rv; @@ -1196,7 +1196,7 @@ nsBrowserWindow::CreateStatusBar(PRInt32 aWidth) NS_RELEASE(dc); nsRect r(0, 0, aWidth, THROBBER_HEIGHT); - rv = nsRepository::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, + rv = nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mStatus); if (NS_OK != rv) { return rv; @@ -1229,7 +1229,7 @@ nsBrowserWindow::Layout(PRInt32 aWidth, PRInt32 aHeight) { nscoord txtHeight; nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); NS_RELEASE(lookAndFeel); } else { @@ -1896,7 +1896,7 @@ void nsBrowserWindow::DoPrintSetup() nsString title("Print Setup"); nsXPBaseWindow * dialog = nsnull; - nsresult rv = nsRepository::CreateInstance(kXPBaseWindowCID, nsnull, + nsresult rv = nsComponentManager::CreateInstance(kXPBaseWindowCID, nsnull, kIXPBaseWindowIID, (void**) &dialog); if (rv == NS_OK) { @@ -1977,7 +1977,7 @@ void nsBrowserWindow::DoTableInspector() nsString title("Table Inspector"); nsXPBaseWindow * xpWin = nsnull; - nsresult rv = nsRepository::CreateInstance(kXPBaseWindowCID, nsnull, + nsresult rv = nsComponentManager::CreateInstance(kXPBaseWindowCID, nsnull, kIXPBaseWindowIID, (void**) &xpWin); if (rv == NS_OK) { @@ -2010,7 +2010,7 @@ void nsBrowserWindow::DoImageInspector() nsString title("Image Inspector"); nsXPBaseWindow * xpWin = nsnull; - nsresult rv = nsRepository::CreateInstance(kXPBaseWindowCID, nsnull, kIXPBaseWindowIID, (void**) &xpWin); + nsresult rv = nsComponentManager::CreateInstance(kXPBaseWindowCID, nsnull, kIXPBaseWindowIID, (void**) &xpWin); if (rv == NS_OK) { xpWin->Init(eXPBaseWindowType_dialog, mAppShell, nsnull, printHTML, title, rect, PRUint32(~0), PR_FALSE); xpWin->SetVisible(PR_TRUE); @@ -2381,7 +2381,7 @@ static PRBool GetSaveFileNameFromFileSelector(nsIWidget* aParentWindow, PRBool selectedFileName = PR_FALSE; nsIFileWidget *fileWidget; nsString title("Save HTML"); - nsresult rv = nsRepository::CreateInstance(kFileWidgetCID, + nsresult rv = nsComponentManager::CreateInstance(kFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget); @@ -2448,7 +2448,7 @@ nsBrowserWindow::DoDebugSave() static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - nsresult rv = nsRepository::CreateInstance(kCParserCID, + nsresult rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); diff --git a/mozilla/webshell/tests/viewer/nsEditorMode.cpp b/mozilla/webshell/tests/viewer/nsEditorMode.cpp index 60a3d247c35..5fb48a99e8c 100644 --- a/mozilla/webshell/tests/viewer/nsEditorMode.cpp +++ b/mozilla/webshell/tests/viewer/nsEditorMode.cpp @@ -23,7 +23,7 @@ #include "nsITextEditor.h" #include "nsEditorCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "resources.h" @@ -66,7 +66,7 @@ nsresult NS_InitEditorMode(nsIDOMDocument *aDOMDocument, nsIPresShell* aPresShel result = nsServiceManager::GetService(kTextEditorCID, kITextEditorIID, &isup); */ - result = nsRepository::CreateInstance(kHTMLEditorCID, + result = nsComponentManager::CreateInstance(kHTMLEditorCID, nsnull, kIHTMLEditorIID, (void **)&gEditor); if (NS_FAILED(result)) diff --git a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp index 33a30459e65..ad5d59c4387 100644 --- a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp +++ b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp @@ -18,7 +18,7 @@ */ #define NS_IMPL_IDS #include "nsIPref.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsWidgetsCID.h" #include "nsGfxCIID.h" #include "nsViewsCID.h" @@ -254,118 +254,118 @@ static NS_DEFINE_IID(kLWBrkCID, NS_LWBRK_CID); extern "C" void NS_SetupRegistry() { - nsRepository::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kAllocatorCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kGenericFactoryCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kLookAndFeelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCHScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDialogCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCLabelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCComboBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCFileWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCListBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCRadioButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCTextAreaCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCTextFieldCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCCheckButtonIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCChildIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCAppShellCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCToolkitCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCImageIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCRegionIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCBlenderIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDeviceContextSpecCID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDeviceContextSpecFactoryCID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCViewManagerCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCScrollingViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kWebShellCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDocLoaderServiceCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kThrobberCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kPrefCID, NULL, NULL, PREF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCPluginHostCID, NULL, NULL, PLUGIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kWellFormedDTDCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDOMScriptObjectFactory, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCScriptNameSetRegistry, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCHTMLDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCXMLDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCImageDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCHTMLImageElement, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kNameSpaceManagerCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kIEditFactoryIID, NULL, NULL, EDITOR_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kITextEditFactoryIID, NULL, NULL, EDITOR_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kIHTMLEditFactoryIID, NULL, NULL, EDITOR_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCEventListenerManagerCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kAllocatorCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kGenericFactoryCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kLookAndFeelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCHScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDialogCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCLabelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCComboBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCFileWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCListBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRadioButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCTextAreaCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCTextFieldCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCCheckButtonIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCChildIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCAppShellCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCToolkitCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCImageIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRegionIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCBlenderIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDeviceContextSpecCID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDeviceContextSpecFactoryCID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCViewManagerCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCScrollingViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kWebShellCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDocLoaderServiceCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kThrobberCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kPrefCID, NULL, NULL, PREF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCPluginHostCID, NULL, NULL, PLUGIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kWellFormedDTDCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDOMScriptObjectFactory, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCScriptNameSetRegistry, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCHTMLDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCXMLDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCImageDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCHTMLImageElement, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kNameSpaceManagerCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kIEditFactoryIID, NULL, NULL, EDITOR_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kITextEditFactoryIID, NULL, NULL, EDITOR_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kIHTMLEditFactoryIID, NULL, NULL, EDITOR_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCEventListenerManagerCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); #if defined(XP_MAC) || defined (XP_UNIX) // XXX somebody please make dynamic registration work on Mac - nsRepository::RegisterComponent(kRDFBookMarkDataSourceCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kRDFCompositeDataSourceCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kRDFHTMLBuilderCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kRDFInMemoryDataSourceCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kRDFServiceCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kRDFTreeBuilderCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kRDFContentSinkCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kRDFXMLDataSourceCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kRDFXULBuilderCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kXULDataSourceCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kXULDocumentCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kXULContentSinkCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kRDFBookMarkDataSourceCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kRDFCompositeDataSourceCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kRDFHTMLBuilderCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kRDFInMemoryDataSourceCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kRDFServiceCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kRDFTreeBuilderCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kRDFContentSinkCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kRDFXMLDataSourceCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kRDFXULBuilderCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kXULDataSourceCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kXULDocumentCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kXULContentSinkCID, NULL, NULL, RDF_DLL, PR_FALSE, PR_FALSE); #endif - nsRepository::RegisterComponent(kCSSParserCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kPresShellCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kHTMLStyleSheetCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kHTMLCSSStyleSheetCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kTextNodeCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kSelectionCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kRangeCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kRangeListCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kContentIteratorCID,NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kSubtreeIteratorCID,NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kFrameUtilCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCSSParserCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kPresShellCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kHTMLStyleSheetCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kHTMLCSSStyleSheetCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kTextNodeCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kSelectionCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kRangeCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kRangeListCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kContentIteratorCID,NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kSubtreeIteratorCID,NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kFrameUtilCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCharsetConverterManagerCID, NULL, NULL, UCONV_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCharsetAliasCID, NULL, NULL, UCONV_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kLatin1ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kISO88597ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCP1253ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kSJIS2UnicodeCID, NULL, NULL, UCVJA_DLL, PR_FALSE, PR_FALSE); - // nsRepository::RegisterComponent(kEUCJPToUnicodeCID, NULL, NULL, UCVJA2_DLL, PR_FALSE, PR_FALSE); - // nsRepository::RegisterComponent(kISO2022JPToUnicodeCID, NULL, NULL, UCVJA2_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCharsetConverterManagerCID, NULL, NULL, UCONV_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCharsetAliasCID, NULL, NULL, UCONV_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kLatin1ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kISO88597ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCP1253ToUnicodeCID, NULL, NULL, UCVLATIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kSJIS2UnicodeCID, NULL, NULL, UCVJA_DLL, PR_FALSE, PR_FALSE); + // nsComponentManager::RegisterComponent(kEUCJPToUnicodeCID, NULL, NULL, UCVJA2_DLL, PR_FALSE, PR_FALSE); + // nsComponentManager::RegisterComponent(kISO2022JPToUnicodeCID, NULL, NULL, UCVJA2_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kPlatformCharsetCID, NULL, NULL, UCONV_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kPlatformCharsetCID, NULL, NULL, UCONV_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kStringBundleServiceCID, NULL, NULL, STRRES_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kStringBundleServiceCID, NULL, NULL, STRRES_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kUnicharUtilCID, NULL, NULL, UNICHARUTIL_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kUnicharUtilCID, NULL, NULL, UNICHARUTIL_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kPropertiesCID, NULL, NULL, BASE_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kPropertiesCID, NULL, NULL, BASE_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCollationCID, NULL, NULL, NSLOCALE_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCollationFactoryCID, NULL, NULL, NSLOCALE_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kDateTimeFormatCID, NULL, NULL, NSLOCALE_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kLocaleCID, NULL, NULL, NSLOCALE_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kLocaleFactoryCID, NULL, NULL, NSLOCALE_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCollationCID, NULL, NULL, NSLOCALE_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCollationFactoryCID, NULL, NULL, NSLOCALE_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kDateTimeFormatCID, NULL, NULL, NSLOCALE_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kLocaleCID, NULL, NULL, NSLOCALE_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kLocaleFactoryCID, NULL, NULL, NSLOCALE_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kLWBrkCID, NULL, NULL, LWBRK_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kLWBrkCID, NULL, NULL, LWBRK_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCPluginManagerCID, NULL, NULL, PLUGIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCPluginManagerCID, NULL, NULL, PLUGIN_DLL, PR_FALSE, PR_FALSE); #if defined(XP_PC) || defined(XP_MAC) - nsRepository::RegisterComponent(kCapsManagerCID, NULL, NULL, CAPS_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kLiveconnectCID, NULL, NULL, LIVECONNECT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kJVMManagerCID, NULL, NULL, OJI_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCapsManagerCID, NULL, NULL, CAPS_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kLiveconnectCID, NULL, NULL, LIVECONNECT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kJVMManagerCID, NULL, NULL, OJI_DLL, PR_FALSE, PR_FALSE); #endif - nsRepository::RegisterComponent(kCMenuBarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCMenuCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCMenuItemCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - //nsRepository::RegisterComponent(kCXULCommandCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCMenuBarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCMenuCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCMenuItemCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + //nsComponentManager::RegisterComponent(kCXULCommandCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); } diff --git a/mozilla/webshell/tests/viewer/nsViewerApp.cpp b/mozilla/webshell/tests/viewer/nsViewerApp.cpp index 987a34a070a..7d22f506d3e 100644 --- a/mozilla/webshell/tests/viewer/nsViewerApp.cpp +++ b/mozilla/webshell/tests/viewer/nsViewerApp.cpp @@ -28,7 +28,7 @@ #include "nsIAppShell.h" #include "nsIPref.h" #include "nsINetService.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIEventQueueService.h" #include "nsXPComCIID.h" @@ -179,10 +179,10 @@ nsViewerApp::SetupRegistry() // Register our browser window factory nsIFactory* bwf; NS_NewBrowserWindowFactory(&bwf); - nsRepository::RegisterFactory(kBrowserWindowCID, 0, 0, bwf, PR_FALSE); + nsComponentManager::RegisterFactory(kBrowserWindowCID, 0, 0, bwf, PR_FALSE); NS_NewXPBaseWindowFactory(&bwf); - nsRepository::RegisterFactory(kXPBaseWindowCID, 0, 0, bwf, PR_FALSE); + nsComponentManager::RegisterFactory(kXPBaseWindowCID, 0, 0, bwf, PR_FALSE); return NS_OK; } @@ -214,7 +214,7 @@ nsViewerApp::Initialize(int argc, char** argv) } // Create widget application shell - rv = nsRepository::CreateInstance(kAppShellCID, nsnull, kIAppShellIID, + rv = nsComponentManager::CreateInstance(kAppShellCID, nsnull, kIAppShellIID, (void**)&mAppShell); if (NS_OK != rv) { return rv; @@ -223,7 +223,7 @@ nsViewerApp::Initialize(int argc, char** argv) mAppShell->SetDispatchListener((nsDispatchListener*) this); // Load preferences - rv = nsRepository::CreateInstance(kPrefCID, NULL, kIPrefIID, + rv = nsComponentManager::CreateInstance(kPrefCID, NULL, kIPrefIID, (void **) &mPrefs); if (NS_OK != rv) { return rv; @@ -289,7 +289,7 @@ nsViewerApp::Initialize(int argc, char** argv) } #endif - rv = nsRepository::CreateInstance(kSilentDownloadCID, + rv = nsComponentManager::CreateInstance(kSilentDownloadCID, nsnull, kISilentDownloadIID, (void**) &silentDownload); @@ -576,7 +576,7 @@ nsViewerApp::OpenWindow() // browser window. For the time being the reference is released by the // browser event handling code during processing of the NS_DESTROY event... nsBrowserWindow* bw = nsnull; - nsresult rv = nsRepository::CreateInstance(kBrowserWindowCID, nsnull, + nsresult rv = nsComponentManager::CreateInstance(kBrowserWindowCID, nsnull, kIBrowserWindowIID, (void**) &bw); if (NS_FAILED(rv)) { @@ -643,7 +643,7 @@ nsViewerApp::ViewSource(nsString& aURL) // browser window. For the time being the reference is released by the // browser event handling code during processing of the NS_DESTROY event... nsBrowserWindow* bw = nsnull; - nsresult rv = nsRepository::CreateInstance(kBrowserWindowCID, nsnull, + nsresult rv = nsComponentManager::CreateInstance(kBrowserWindowCID, nsnull, kIBrowserWindowIID, (void**) &bw); if (NS_FAILED(rv)) { @@ -663,7 +663,7 @@ nsViewerApp::OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow) { // Create browser window nsBrowserWindow* bw = nsnull; - nsresult rv = nsRepository::CreateInstance(kBrowserWindowCID, nsnull, + nsresult rv = nsComponentManager::CreateInstance(kBrowserWindowCID, nsnull, kIBrowserWindowIID, (void**) &bw); if (NS_FAILED(rv)) { @@ -874,7 +874,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) nsRect rect; rect.SetRect(0, 0, dialogWidth, 162); - nsRepository::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mRobotDialog); + nsComponentManager::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mRobotDialog); if (nsnull == mRobotDialog) return FALSE; @@ -886,7 +886,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) nscolor textFGColor = NS_RGB(255,255,255); nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); lookAndFeel->GetColor(nsILookAndFeel::eColor_TextBackground, textBGColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_TextForeground, textFGColor); @@ -898,7 +898,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) // Create Update CheckButton rect.SetRect(x, y, 150, 24); - nsRepository::CreateInstance(kCheckButtonCID, nsnull, kICheckButtonIID, (void**)&mUpdateChkBtn); + nsComponentManager::CreateInstance(kCheckButtonCID, nsnull, kICheckButtonIID, (void**)&mUpdateChkBtn); NS_CreateCheckButton(mRobotDialog, mUpdateChkBtn,rect,HandleRobotEvent,&font); mUpdateChkBtn->SetLabel("Update Display (Visual)"); mUpdateChkBtn->SetState(PR_TRUE); @@ -907,7 +907,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) // Create Label w = 115; rect.SetRect(x, y+3, w, 24); - nsRepository::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); + nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); NS_CreateLabel(mRobotDialog,label,rect,HandleRobotEvent,&font); label->SetAlignment(eAlign_Right); label->SetLabel("Verfication Directory:"); @@ -916,7 +916,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) // Create TextField nsIWidget* widget = nsnull; rect.SetRect(x, y, 225, txtHeight); - nsRepository::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mVerDirTxt); + nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mVerDirTxt); NS_CreateTextWidget(mRobotDialog,mVerDirTxt,rect,HandleRobotEvent,&font); if (mVerDirTxt && NS_OK == mVerDirTxt->QueryInterface(kIWidgetIID,(void**)&widget)) { @@ -932,7 +932,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) x = 5; w = 55; rect.SetRect(x, y+4, w, 24); - nsRepository::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); + nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); NS_CreateLabel(mRobotDialog,label,rect,HandleRobotEvent,&font); label->SetAlignment(eAlign_Right); label->SetLabel("Stop after:"); @@ -940,7 +940,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) // Create TextField rect.SetRect(x, y, 75, txtHeight); - nsRepository::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mStopAfterTxt); + nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mStopAfterTxt); NS_CreateTextWidget(mRobotDialog,mStopAfterTxt,rect,HandleRobotEvent,&font); if (mStopAfterTxt && NS_OK == mStopAfterTxt->QueryInterface(kIWidgetIID,(void**)&widget)) { @@ -952,7 +952,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) w = 75; rect.SetRect(x, y+4, w, 24); - nsRepository::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); + nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); NS_CreateLabel(mRobotDialog,label,rect,HandleRobotEvent,&font); label->SetAlignment(eAlign_Left); label->SetLabel("(page loads)"); @@ -964,14 +964,14 @@ PRBool CreateRobotDialog(nsIWidget * aParent) nscoord xx = (dialogWidth - (2*w)) / 3; // Create Find Start Button rect.SetRect(xx, y, w, 24); - nsRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mStartBtn); + nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mStartBtn); NS_CreateButton(mRobotDialog,mStartBtn,rect,HandleRobotEvent,&font); mStartBtn->SetLabel("Start"); xx += w + xx; // Create Cancel Button rect.SetRect(xx, y, w, 24); - nsRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mCancelBtn); + nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mCancelBtn); NS_CreateButton(mRobotDialog,mCancelBtn,rect,HandleRobotEvent,&font); mCancelBtn->SetLabel("Cancel"); @@ -1229,7 +1229,7 @@ PRBool CreateSiteDialog(nsIWidget * aParent) if (mSiteDialog == nsnull) { nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { //lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); //lookAndFeel->GetColor(nsILookAndFeel::eColor_TextBackground, textBGColor); //lookAndFeel->GetColor(nsILookAndFeel::eColor_TextForeground, textFGColor); @@ -1252,7 +1252,7 @@ PRBool CreateSiteDialog(nsIWidget * aParent) rect.SetRect(0, 0, dialogWidth, 125); nsIWidget* widget = nsnull; - nsRepository::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mSiteDialog); + nsComponentManager::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mSiteDialog); if (nsnull == mSiteDialog) return FALSE; @@ -1270,7 +1270,7 @@ PRBool CreateSiteDialog(nsIWidget * aParent) // Create Label w = 50; rect.SetRect(x, y+3, w, 24); - nsRepository::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); + nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); NS_CreateLabel(mSiteDialog,label,rect,HandleSiteEvent,&font); label->SetAlignment(eAlign_Right); label->SetLabel("Site:"); @@ -1278,7 +1278,7 @@ PRBool CreateSiteDialog(nsIWidget * aParent) w = 250; rect.SetRect(x, y+3, w, 24); - nsRepository::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&mSiteLabel); + nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&mSiteLabel); NS_CreateLabel(mSiteDialog,mSiteLabel,rect,HandleSiteEvent,&font); mSiteLabel->SetAlignment(eAlign_Left); mSiteLabel->SetLabel(""); @@ -1289,21 +1289,21 @@ PRBool CreateSiteDialog(nsIWidget * aParent) x = spacing; // Create Previous Button rect.SetRect(x, y, w, 24); - nsRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSitePrevBtn); + nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSitePrevBtn); NS_CreateButton(mSiteDialog,mSitePrevBtn,rect,HandleSiteEvent,&font); mSitePrevBtn->SetLabel("<< Previous"); x += spacing + w; // Create Next Button rect.SetRect(x, y, w, 24); - nsRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteNextBtn); + nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteNextBtn); NS_CreateButton(mSiteDialog,mSiteNextBtn,rect,HandleSiteEvent,&font); mSiteNextBtn->SetLabel("Next >>"); x += spacing + w; // Create Cancel Button rect.SetRect(x, y, w, 24); - nsRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteCancelBtn); + nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteCancelBtn); NS_CreateButton(mSiteDialog,mSiteCancelBtn,rect,HandleSiteEvent,&font); mSiteCancelBtn->SetLabel("Cancel"); } diff --git a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp index 1106adde24e..fb96edfb58c 100644 --- a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp +++ b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp @@ -33,7 +33,7 @@ #include "nsITimer.h" #include "nsIAtom.h" #include "nsIFrameUtil.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsLayoutCID.h" #include "nsRect.h" #include "plhash.h" @@ -780,7 +780,7 @@ nsWebCrawler::PerformRegressionTest(const nsString& aOutputName) { // First load the trees nsIFrameUtil* fu; - nsresult rv = nsRepository::CreateInstance(kFrameUtilCID, nsnull, + nsresult rv = nsComponentManager::CreateInstance(kFrameUtilCID, nsnull, kIFrameUtilIID, (void **)&fu); if (NS_FAILED(rv)) { printf("Can't find nsIFrameUtil implementation\n"); diff --git a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp index 55298cda496..b138780f8c5 100644 --- a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp @@ -33,7 +33,7 @@ #include "nsIWidget.h" #include "nsIDOMDocument.h" #include "nsIURL.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIFactory.h" #include "nsCRT.h" #include "nsWidgetsCID.h" @@ -213,10 +213,10 @@ nsresult nsXPBaseWindow::Init(nsXPBaseWindowType aType, // Create top level window nsresult rv; if (aType == eXPBaseWindowType_window) { - rv = nsRepository::CreateInstance(kWindowCID, nsnull, kIWidgetIID, + rv = nsComponentManager::CreateInstance(kWindowCID, nsnull, kIWidgetIID, (void**)&mWindow); } else { - rv= nsRepository::CreateInstance(kDialogCID, nsnull, kIWidgetIID, + rv= nsComponentManager::CreateInstance(kDialogCID, nsnull, kIWidgetIID, (void**)&mWindow); } @@ -235,7 +235,7 @@ nsresult nsXPBaseWindow::Init(nsXPBaseWindowType aType, mWindow->GetBounds(r); // Create web shell - rv = nsRepository::CreateInstance(kWebShellCID, nsnull, + rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&mWebShell); if (NS_OK != rv) { diff --git a/mozilla/widget/src/gtk/nsWidget.cpp b/mozilla/widget/src/gtk/nsWidget.cpp index 07f53744dc0..c93e3a31cf5 100644 --- a/mozilla/widget/src/gtk/nsWidget.cpp +++ b/mozilla/widget/src/gtk/nsWidget.cpp @@ -20,7 +20,7 @@ #include "nsIDeviceContext.h" #include "nsIAppShell.h" #include "nsGfxCIID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsGtkEventHandler.h" #include "nsIFontMetrics.h" #include @@ -43,7 +43,7 @@ nsWidget::nsWidget() // get the proper color from the look and feel code nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetColor(nsILookAndFeel::eColor_WindowBackground, mBackground); } mWidget = nsnull; diff --git a/mozilla/widget/src/gtk/nsWindow.cpp b/mozilla/widget/src/gtk/nsWindow.cpp index 6a23de219fc..ebc06ef2909 100644 --- a/mozilla/widget/src/gtk/nsWindow.cpp +++ b/mozilla/widget/src/gtk/nsWindow.cpp @@ -425,7 +425,7 @@ PRBool nsWindow::OnPaint(nsPaintEvent &event) event.renderingContext = nsnull; static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID); - if (NS_OK == nsRepository::CreateInstance(kRenderingContextCID, + if (NS_OK == nsComponentManager::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&event.renderingContext)) diff --git a/mozilla/widget/src/gtk2/nsDeviceContextSpecFactoryG.cpp b/mozilla/widget/src/gtk2/nsDeviceContextSpecFactoryG.cpp index d3ab20f536e..24683e89dd8 100644 --- a/mozilla/widget/src/gtk2/nsDeviceContextSpecFactoryG.cpp +++ b/mozilla/widget/src/gtk2/nsDeviceContextSpecFactoryG.cpp @@ -65,7 +65,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: CreateDeviceContextSpec(nsIDevice nsresult rv = NS_ERROR_FAILURE; nsIDeviceContextSpec *devSpec = nsnull; - nsRepository::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec); + nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec); if (nsnull != devSpec){ if (NS_OK == ((nsDeviceContextSpecGTK *)devSpec)->Init(aQuiet)){ diff --git a/mozilla/widget/src/mac/nsDeviceContextSpecFactoryM.cpp b/mozilla/widget/src/mac/nsDeviceContextSpecFactoryM.cpp index f9e2030edb5..1e78db881cd 100644 --- a/mozilla/widget/src/mac/nsDeviceContextSpecFactoryM.cpp +++ b/mozilla/widget/src/mac/nsDeviceContextSpecFactoryM.cpp @@ -65,7 +65,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: CreateDeviceContextSpec(nsIDevice nsresult rv = NS_ERROR_FAILURE; nsIDeviceContextSpec *devSpec = nsnull; - nsRepository::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec); + nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec); if (nsnull != devSpec){ if (NS_OK == ((nsDeviceContextSpecMac *)devSpec)->Init(aQuiet)){ diff --git a/mozilla/widget/src/motif/nsWindow.cpp b/mozilla/widget/src/motif/nsWindow.cpp index 767d4aa415f..8cb1cf75990 100644 --- a/mozilla/widget/src/motif/nsWindow.cpp +++ b/mozilla/widget/src/motif/nsWindow.cpp @@ -209,7 +209,7 @@ void nsWindow::InitDeviceContext(nsIDeviceContext *aContext, static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID); //res = !NS_OK; - res = nsRepository::CreateInstance(kDeviceContextCID, + res = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&mContext); @@ -398,7 +398,7 @@ void nsWindow::CreateWindow(nsNativeWidget aNativeParent, static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID); static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID); - res = nsRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&mContext); + res = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&mContext); if (NS_OK == res) mContext->Init(nsnull); @@ -1076,7 +1076,7 @@ nsIRenderingContext* nsWindow::GetRenderingContext() static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID); - res = nsRepository::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&ctx); + res = nsComponentManager::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&ctx); if (NS_OK == res) ctx->Init(mContext, this); @@ -1353,7 +1353,7 @@ PRBool nsWindow::OnPaint(nsPaintEvent &event) event.renderingContext = nsnull; static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID); - if (NS_OK == nsRepository::CreateInstance(kRenderingContextCID, + if (NS_OK == nsComponentManager::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&event.renderingContext)) diff --git a/mozilla/widget/src/windows/nsButton.cpp b/mozilla/widget/src/windows/nsButton.cpp index 2a19240fa06..9f7a9c7be7d 100644 --- a/mozilla/widget/src/windows/nsButton.cpp +++ b/mozilla/widget/src/windows/nsButton.cpp @@ -26,7 +26,7 @@ #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIDeviceContext.h" #include "nsIFontMetrics.h" @@ -197,7 +197,7 @@ NS_METHOD nsButton::Paint(nsIRenderingContext& aRenderingContext, nscolor sdwColor = NS_RGB(128,128,128); nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, bgColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetForeground, fgColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DShadow, sdwColor); diff --git a/mozilla/widget/src/windows/nsCheckButton.cpp b/mozilla/widget/src/windows/nsCheckButton.cpp index a36c4bc28f8..97f9e495c7e 100644 --- a/mozilla/widget/src/windows/nsCheckButton.cpp +++ b/mozilla/widget/src/windows/nsCheckButton.cpp @@ -26,7 +26,7 @@ #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIDeviceContext.h" diff --git a/mozilla/widget/src/windows/nsComboBox.cpp b/mozilla/widget/src/windows/nsComboBox.cpp index 86bf19b8cae..ce4394e98e1 100644 --- a/mozilla/widget/src/windows/nsComboBox.cpp +++ b/mozilla/widget/src/windows/nsComboBox.cpp @@ -26,7 +26,7 @@ #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIDeviceContext.h" #include "nsIFontMetrics.h" @@ -305,7 +305,7 @@ NS_METHOD nsComboBox::Paint(nsIRenderingContext& aRenderingContext, nscolor hltColor = NS_RGB(240,240,240); nscolor sdwColor = NS_RGB(128,128,128); nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, bgColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetForeground, fgColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DShadow, sdwColor); diff --git a/mozilla/widget/src/windows/nsDeviceContextSpecFactoryW.cpp b/mozilla/widget/src/windows/nsDeviceContextSpecFactoryW.cpp index adffdf1efa0..37616ba0ba0 100644 --- a/mozilla/widget/src/windows/nsDeviceContextSpecFactoryW.cpp +++ b/mozilla/widget/src/windows/nsDeviceContextSpecFactoryW.cpp @@ -93,7 +93,7 @@ printf("printer: driver %s, device %s\n", driver, device); nsIDeviceContextSpec *devspec = nsnull; - nsRepository::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devspec); + nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devspec); if (nsnull != devspec) { diff --git a/mozilla/widget/src/windows/nsRadioButton.cpp b/mozilla/widget/src/windows/nsRadioButton.cpp index 87c0a9e442c..7f45f1876e8 100644 --- a/mozilla/widget/src/windows/nsRadioButton.cpp +++ b/mozilla/widget/src/windows/nsRadioButton.cpp @@ -25,7 +25,7 @@ #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIDeviceContext.h" diff --git a/mozilla/widget/src/windows/nsTextAreaWidget.cpp b/mozilla/widget/src/windows/nsTextAreaWidget.cpp index 22ba221aec2..43820eed15a 100644 --- a/mozilla/widget/src/windows/nsTextAreaWidget.cpp +++ b/mozilla/widget/src/windows/nsTextAreaWidget.cpp @@ -24,7 +24,7 @@ #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIDeviceContext.h" #include "nsIFontMetrics.h" @@ -204,7 +204,7 @@ NS_METHOD nsTextAreaWidget::Paint(nsIRenderingContext& aRenderingContext, nscolor txtBGColor = NS_RGB(255,255,255); nscolor txtFGColor = NS_RGB(0,0,0); nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, bgColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetForeground, fgColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DShadow, sdwColor); diff --git a/mozilla/widget/src/windows/nsTextWidget.cpp b/mozilla/widget/src/windows/nsTextWidget.cpp index d31ceba6479..91b1d607697 100644 --- a/mozilla/widget/src/windows/nsTextWidget.cpp +++ b/mozilla/widget/src/windows/nsTextWidget.cpp @@ -25,7 +25,7 @@ #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIDeviceContext.h" #include "nsIFontMetrics.h" @@ -214,7 +214,7 @@ NS_METHOD nsTextWidget::Paint(nsIRenderingContext& aRenderingContext, nscolor txtBGColor = NS_RGB(255,255,255); nscolor txtFGColor = NS_RGB(0,0,0); nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, bgColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetForeground, fgColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DShadow, sdwColor); diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index 6e2b5e3df68..82e7e716659 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -487,6 +487,7 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent, // nsToolkit* toolkit = (nsToolkit *)mToolkit; + if (toolkit) { if (!toolkit->IsGuiThread()) { DWORD args[7]; args[0] = (DWORD)aParent; @@ -510,6 +511,7 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent, return NS_OK; } } + } HWND parent; if (nsnull != aParent) { // has a nsIWidget parent @@ -2143,7 +2145,7 @@ for (x = 0; x < 10000000; x++); static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID); static NS_DEFINE_IID(kRenderingContextWinIID, NS_IRENDERING_CONTEXT_WIN_IID); - if (NS_OK == nsRepository::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&event.renderingContext)) + if (NS_OK == nsComponentManager::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&event.renderingContext)) { nsIRenderingContextWin *winrc; diff --git a/mozilla/widget/src/xpwidgets/nsBaseWidget.cpp b/mozilla/widget/src/xpwidgets/nsBaseWidget.cpp index f828d532dad..2db616a2520 100644 --- a/mozilla/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/mozilla/widget/src/xpwidgets/nsBaseWidget.cpp @@ -147,7 +147,7 @@ void nsBaseWidget::BaseCreate(nsIWidget *aParent, static NS_DEFINE_IID(kToolkitIID, NS_ITOOLKIT_IID); nsresult res; - res = nsRepository::CreateInstance(kToolkitCID, nsnull, kToolkitIID, (void **)&mToolkit); + res = nsComponentManager::CreateInstance(kToolkitCID, nsnull, kToolkitIID, (void **)&mToolkit); if (NS_OK != res) NS_ASSERTION(PR_FALSE, "Can not create a toolkit in nsBaseWidget::Create"); if (mToolkit) @@ -174,7 +174,7 @@ void nsBaseWidget::BaseCreate(nsIWidget *aParent, static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID); static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID); - res = nsRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&mContext); + res = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&mContext); if (NS_OK == res) mContext->Init(nsnull); @@ -379,7 +379,7 @@ nsIRenderingContext* nsBaseWidget::GetRenderingContext() static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID); - res = nsRepository::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&renderingCtx); + res = nsComponentManager::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&renderingCtx); if (NS_OK == res) renderingCtx->Init(mContext, this); diff --git a/mozilla/widget/src/xpwidgets/nsHTTreeItem.cpp b/mozilla/widget/src/xpwidgets/nsHTTreeItem.cpp index d5ded2f1b18..d73a8532f52 100644 --- a/mozilla/widget/src/xpwidgets/nsHTTreeItem.cpp +++ b/mozilla/widget/src/xpwidgets/nsHTTreeItem.cpp @@ -23,7 +23,7 @@ #include "nsHTTreeItem.h" #include "nsHTTreeDataModel.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIImageObserver.h" #include "nsIImageRequest.h" #include "nsIImageGroup.h" @@ -257,4 +257,4 @@ void nsHTTreeItem::SetContentRectangle(const nsRect& rect, PRUint32 n) nsRect* existingRect = (nsRect*)(mColumnRectArray[n]); *existingRect = rect; } -} \ No newline at end of file +} diff --git a/mozilla/widget/src/xpwidgets/nsMenuButton.cpp b/mozilla/widget/src/xpwidgets/nsMenuButton.cpp index 31d3dc7ec18..7ecd9846696 100644 --- a/mozilla/widget/src/xpwidgets/nsMenuButton.cpp +++ b/mozilla/widget/src/xpwidgets/nsMenuButton.cpp @@ -22,7 +22,7 @@ #include "nsIFontMetrics.h" #include "nsIDeviceContext.h" #include "nsWidgetsCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIWidget.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -88,7 +88,7 @@ void nsMenuButton::CreatePopUpMenu() } // Create and place back button - nsresult rv = nsRepository::CreateInstance(kPopUpMenuCID, nsnull, kIPopUpMenuIID, + nsresult rv = nsComponentManager::CreateInstance(kPopUpMenuCID, nsnull, kIPopUpMenuIID, (void**)&mPopUpMenu); if (NS_OK == rv) { nsIWidget * menuParentWidget; @@ -125,7 +125,7 @@ NS_METHOD nsMenuButton::AddMenuItem(const nsString& aMenuLabel, PRInt32 aCommand CreatePopUpMenu(); nsIMenuItem * menuItem = nsnull; - nsresult rv = nsRepository::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&menuItem); + nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&menuItem); menuItem->Create(mPopUpMenu, aMenuLabel, aCommand); if (NS_OK == rv) { mPopUpMenu->AddItem(menuItem); diff --git a/mozilla/widget/src/xpwidgets/nsToolbar.cpp b/mozilla/widget/src/xpwidgets/nsToolbar.cpp index 82929486f5a..cbe821627d0 100644 --- a/mozilla/widget/src/xpwidgets/nsToolbar.cpp +++ b/mozilla/widget/src/xpwidgets/nsToolbar.cpp @@ -29,7 +29,7 @@ #include "nsIWidget.h" #include "nsIToolbarItemHolder.h" #include "nsImageButton.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIDeviceContext.h" #include "nsCOMPtr.h" diff --git a/mozilla/widget/src/xpwidgets/nsToolbarItemHolder.cpp b/mozilla/widget/src/xpwidgets/nsToolbarItemHolder.cpp index 506b2c85c0c..b901abd44e9 100644 --- a/mozilla/widget/src/xpwidgets/nsToolbarItemHolder.cpp +++ b/mozilla/widget/src/xpwidgets/nsToolbarItemHolder.cpp @@ -19,7 +19,7 @@ #include "nsToolbarItemHolder.h" #include "nsWidgetsCID.h" #include "nsIWidget.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIToolbarItem.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); diff --git a/mozilla/widget/src/xpwidgets/nsToolbarManager.cpp b/mozilla/widget/src/xpwidgets/nsToolbarManager.cpp index f3ba880b7d7..968757507ea 100644 --- a/mozilla/widget/src/xpwidgets/nsToolbarManager.cpp +++ b/mozilla/widget/src/xpwidgets/nsToolbarManager.cpp @@ -23,7 +23,7 @@ #include "nsIRenderingContext.h" #include "nsWidgetsCID.h" #include "nsIWidget.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsImageButton.h" @@ -638,4 +638,4 @@ nsToolbarManager :: OnMouseExit ( ) mGrippyHilighted = kNoGrippyHilighted; } } -} // OnMouseExit \ No newline at end of file +} // OnMouseExit diff --git a/mozilla/widget/src/xpwidgets/nsTreeView.cpp b/mozilla/widget/src/xpwidgets/nsTreeView.cpp index 716c8f54349..436319bb3ce 100644 --- a/mozilla/widget/src/xpwidgets/nsTreeView.cpp +++ b/mozilla/widget/src/xpwidgets/nsTreeView.cpp @@ -18,7 +18,7 @@ #include "nspr.h" #include "nsString.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsFont.h" #include "nsIFontMetrics.h" #include "nsIDeviceContext.h" diff --git a/mozilla/widget/tests/scribble/Scribble.cpp b/mozilla/widget/tests/scribble/Scribble.cpp index 951263c8132..bd4f15ffd78 100644 --- a/mozilla/widget/tests/scribble/Scribble.cpp +++ b/mozilla/widget/tests/scribble/Scribble.cpp @@ -458,10 +458,10 @@ nsresult CreateApplication(int * argc, char ** argv) static NS_DEFINE_IID(kCFontMetricsIID, NS_FONT_METRICS_CID); static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID); - nsRepository::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCImageIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCImageIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); // register widget classes static NS_DEFINE_IID(kCWindowCID, NS_WINDOW_CID); @@ -478,21 +478,21 @@ nsresult CreateApplication(int * argc, char ** argv) static NS_DEFINE_IID(kCTextFieldCID, NS_TEXTFIELD_CID); static NS_DEFINE_IID(kCLookAndFeelCID, NS_LOOKANDFEEL_CID); - nsRepository::RegisterComponent(kCAppShellCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCToolkitCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCWindowCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCChildCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCCheckButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCComboBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCFileWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCListBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCRadioButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCHorzScrollbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCVertScrollbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCTextAreaCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCTextFieldCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCLookAndFeelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCAppShellCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCToolkitCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCWindowCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCChildCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCCheckButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCComboBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCFileWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCListBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRadioButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCHorzScrollbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCVertScrollbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCTextAreaCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCTextFieldCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCLookAndFeelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); //NS_InitToolkit(PR_GetCurrentThread()); @@ -503,25 +503,25 @@ nsresult CreateApplication(int * argc, char ** argv) // Create an application shell nsIAppShell *appShell = nsnull; - nsRepository::CreateInstance(kCAppShellCID, nsnull, kIAppShellIID, + nsComponentManager::CreateInstance(kCAppShellCID, nsnull, kIAppShellIID, (void**)&appShell); appShell->Create(argc, argv); - res = nsRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&scribbleData.mContext); + res = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&scribbleData.mContext); if (NS_OK == res) scribbleData.mContext->Init(nsnull); //nsILookAndFeel *laf; - //nsRepository::CreateInstance(kCLookAndFeelCID, nsnull, kILookAndFeelIID,(void**)&laf); + //nsComponentManager::CreateInstance(kCLookAndFeelCID, nsnull, kILookAndFeelIID,(void**)&laf); // // create the main window // - nsRepository::CreateInstance(kCWindowCID, nsnull, kIWindowIID, + nsComponentManager::CreateInstance(kCWindowCID, nsnull, kIWindowIID, (void **)&(scribbleData.mainWindow)); nsRect rect(100, 100, 600, 700); scribbleData.mainWindow->Create((nsIWidget*)NULL, @@ -538,7 +538,7 @@ nsresult CreateApplication(int * argc, char ** argv) // nsIWidget *controlPane; rect.SetRect(0, 0, 200, 700); - nsRepository::CreateInstance(kCChildCID, nsnull, kIWidgetIID, (void **)&controlPane); + nsComponentManager::CreateInstance(kCChildCID, nsnull, kIWidgetIID, (void **)&controlPane); controlPane->Create(scribbleData.mainWindow, rect, HandleEventControlPane, NULL); //controlPane->SetBackgroundColor(laf->GetColor(nsLAF::WindowBackground)); controlPane->SetBackgroundColor(NS_RGB(100,128,128)); @@ -552,7 +552,7 @@ nsresult CreateApplication(int * argc, char ** argv) // create the "Scribble" radio button rect.SetRect(50, 50, 100, 25); - nsRepository::CreateInstance(kCRadioButtonCID, nsnull, kIRadioButtonIID, (void **)&(scribbleData.scribble)); + nsComponentManager::CreateInstance(kCRadioButtonCID, nsnull, kIRadioButtonIID, (void **)&(scribbleData.scribble)); NS_CreateRadioButton(controlPane,scribbleData.scribble,rect,HandleEventRadioButton); scribbleData.scribble->SetLabel("Scribble"); scribbleData.scribble->SetState(PR_FALSE); @@ -561,7 +561,7 @@ nsresult CreateApplication(int * argc, char ** argv) // create the "Lines" radio button rect.SetRect(50, 75, 100, 25); - nsRepository::CreateInstance(kCRadioButtonCID, nsnull, kIRadioButtonIID, (void **)&(scribbleData.lines)); + nsComponentManager::CreateInstance(kCRadioButtonCID, nsnull, kIRadioButtonIID, (void **)&(scribbleData.lines)); NS_CreateRadioButton(controlPane,scribbleData.lines,rect,HandleEventRadioButton); scribbleData.lines->SetLabel("Lines"); scribbleData.lines->SetState(PR_TRUE); @@ -574,7 +574,7 @@ nsresult CreateApplication(int * argc, char ** argv) rect.SetRect(50, 200, 100, 25); nsIWidget* widget = nsnull; - nsRepository::CreateInstance(kCCheckButtonCID, nsnull, kICheckButtonIID, (void **)&checkButton); + nsComponentManager::CreateInstance(kCCheckButtonCID, nsnull, kICheckButtonIID, (void **)&checkButton); if (NS_OK == checkButton->QueryInterface(kIWidgetIID,(void **)&widget)) { widget->Create(controlPane, rect, HandleEventCheck, NULL); @@ -589,7 +589,7 @@ nsresult CreateApplication(int * argc, char ** argv) // create the "Rectangles" check button rect.SetRect(50, 225, 100, 25); - nsRepository::CreateInstance(kCCheckButtonCID, nsnull, kICheckButtonIID, (void **)&checkButton); + nsComponentManager::CreateInstance(kCCheckButtonCID, nsnull, kICheckButtonIID, (void **)&checkButton); NS_CreateCheckButton(controlPane,checkButton,rect,HandleEventCheck); if (NS_OK == checkButton->QueryInterface(kIWidgetIID,(void**)&widget)) { @@ -602,7 +602,7 @@ nsresult CreateApplication(int * argc, char ** argv) // create the "Images" check button rect.SetRect(50, 250, 100, 25); - nsRepository::CreateInstance(kCCheckButtonCID, nsnull, kICheckButtonIID, (void **)&checkButton); + nsComponentManager::CreateInstance(kCCheckButtonCID, nsnull, kICheckButtonIID, (void **)&checkButton); if (NS_OK == checkButton->QueryInterface(kIWidgetIID,(void **)&widget)) { widget->Create(controlPane, rect, HandleEventCheck, NULL); @@ -624,7 +624,7 @@ nsresult CreateApplication(int * argc, char ** argv) PRUint32 size; nsString initText("0"); - nsRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void **)&(scribbleData.red)); + nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void **)&(scribbleData.red)); if (NS_OK == scribbleData.red->QueryInterface(kIWidgetIID,(void **)&widget)) { widget->Create(controlPane, rect, HandleEventText, NULL); @@ -637,7 +637,7 @@ nsresult CreateApplication(int * argc, char ** argv) // create the "green" text widget rect.SetRect(100, y, 50, TEXT_HEIGHT); - nsRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void **)&(scribbleData.green)); + nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void **)&(scribbleData.green)); if (NS_OK == scribbleData.green->QueryInterface(kIWidgetIID,(void **)&widget)) { widget->Create(controlPane, rect, HandleEventText, NULL); @@ -650,7 +650,7 @@ nsresult CreateApplication(int * argc, char ** argv) // create the "blue" text widget rect.SetRect(100, y, 50, TEXT_HEIGHT); - nsRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void **)&(scribbleData.blue)); + nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void **)&(scribbleData.blue)); if (NS_OK == scribbleData.blue->QueryInterface(kIWidgetIID,(void **)&widget)) { widget->Create(controlPane, rect, HandleEventText, NULL); @@ -665,7 +665,7 @@ nsresult CreateApplication(int * argc, char ** argv) // nsIButton *button; rect.SetRect(50, 500, 100, 25); - nsRepository::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void **)&button); + nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void **)&button); NS_CreateButton(controlPane,button,rect,HandleEventButton); button->SetLabel("Clear"); @@ -676,7 +676,7 @@ nsresult CreateApplication(int * argc, char ** argv) // create the draw pane // rect.SetRect(200, 0, 400, 700); - nsRepository::CreateInstance(kCChildCID, nsnull, kIWidgetIID, (void **)&scribbleData.drawPane); + nsComponentManager::CreateInstance(kCChildCID, nsnull, kIWidgetIID, (void **)&scribbleData.drawPane); scribbleData.drawPane->Create(scribbleData.mainWindow, rect, HandleEventGraphicPane, NULL); //scribbleData.drawPane->SetBackgroundColor(laf->GetColor(nsLAF::WindowBackground)); scribbleData.drawPane->SetBackgroundColor(NS_RGB(255,250,250)); diff --git a/mozilla/widget/tests/widget/nsWidgetTest.cpp b/mozilla/widget/tests/widget/nsWidgetTest.cpp index 82fc5c46ef2..8e3b7ac030b 100644 --- a/mozilla/widget/tests/widget/nsWidgetTest.cpp +++ b/mozilla/widget/tests/widget/nsWidgetTest.cpp @@ -21,7 +21,7 @@ //---- Factory Includes & Stuff -----// #include "nsIFactory.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsGfxCIID.h" #include "nsWidgetsCID.h" @@ -44,7 +44,7 @@ #include "nsIFileWidget.h" #include "nsIDeviceContext.h" #include "nsFont.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsWidgetsCID.h" #include "nsITabWidget.h" #include "nsITooltipWidget.h" @@ -418,7 +418,7 @@ int createTestButton(nsIWidget * aWin, EVENT_CALLBACK aHandleEventFunction) { nsIButton *button; nsRect rect(aX, aY, aWidth, 25); - nsRepository::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void **) &button); + nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void **) &button); NS_CreateButton(aWin,button,rect,aHandleEventFunction); button->SetLabel(aTitle); return aX + aWidth; @@ -435,7 +435,7 @@ nsIButton* createSimpleButton(nsIWidget * aWin, EVENT_CALLBACK aHandleEventFunction) { nsIButton *button; nsRect rect(aX, aY, aWidth, 25); - nsRepository::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button); + nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button); NS_CreateButton(aWin,button,rect,aHandleEventFunction); button->SetLabel(aTitle); return button; @@ -453,7 +453,7 @@ nsITooltipWidget* createTooltipWindow(nsIWidget * aWin, EVENT_CALLBACK aHandleEventFunction) { nsITooltipWidget *tooltip; nsRect rect(aX, aY, aWidth, 40); - nsRepository::CreateInstance(kCTooltipWidgetCID, nsnull, kITooltipWidgetIID, (void**)&tooltip); + nsComponentManager::CreateInstance(kCTooltipWidgetCID, nsnull, kITooltipWidgetIID, (void**)&tooltip); NS_CreateTooltipWidget((nsISupports*)nsnull,tooltip,rect,aHandleEventFunction); nsIWidget* toolTipWidget; @@ -1018,7 +1018,7 @@ nsEventStatus PR_CALLBACK HandleFileButtonEvent(nsGUIEvent *aEvent) nsIFileWidget *fileWidget; nsString title("FileWidget Title mode = save"); - nsRepository::CreateInstance(kCFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget); + nsComponentManager::CreateInstance(kCFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget); nsString titles[] = {"all files","html","executables" }; nsString filters[] = {"*.*", "*.html", "*.exe" }; @@ -1196,36 +1196,36 @@ nsresult WidgetTest(int *argc, char **argv) // register widget classes - nsRepository::RegisterComponent(kCWindowCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCWindowCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCChildCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCCheckButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCComboBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCFileWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCListBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCRadioButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCHorzScrollbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCVertScrollbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCTextAreaCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCTextFieldCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCTabWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCTooltipWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCAppShellCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCChildCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCCheckButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCComboBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCFileWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCListBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRadioButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCHorzScrollbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCVertScrollbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCTextAreaCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCTextFieldCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCTabWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCTooltipWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCAppShellCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); static NS_DEFINE_IID(kCRenderingContextIID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kCDeviceContextIID, NS_DEVICE_CONTEXT_CID); static NS_DEFINE_IID(kCFontMetricsIID, NS_FONT_METRICS_CID); static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID); - nsRepository::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFX_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFX_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFX_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCImageIID, NULL, NULL, GFX_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFX_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFX_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFX_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCImageIID, NULL, NULL, GFX_DLL, PR_FALSE, PR_FALSE); // Create a application shell nsIAppShell *appShell; - nsRepository::CreateInstance(kCAppShellCID, nsnull, kIAppShellIID, (void**)&appShell); + nsComponentManager::CreateInstance(kCAppShellCID, nsnull, kIAppShellIID, (void**)&appShell); if (appShell != nsnull) { fputs("Created AppShell\n", stderr); appShell->Create(argc, argv); @@ -1244,7 +1244,7 @@ nsresult WidgetTest(int *argc, char **argv) // // create the main window // - nsRepository::CreateInstance(kCWindowCID, nsnull, kIWindowIID, (void**)&window); + nsComponentManager::CreateInstance(kCWindowCID, nsnull, kIWindowIID, (void**)&window); nsRect rect(100, 100, 600, 700); window->Create((nsIWidget*) nsnull, rect, HandleEvent, (nsIDeviceContext *) nsnull, @@ -1256,7 +1256,7 @@ nsresult WidgetTest(int *argc, char **argv) // // Create Device Context based on main window // - res = nsRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&deviceContext); + res = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&deviceContext); if (NS_OK == res) { @@ -1286,7 +1286,7 @@ nsresult WidgetTest(int *argc, char **argv) int y = 10; rect.SetRect(x, y, 100, 100); - nsRepository::CreateInstance(kCChildCID, nsnull, kIWidgetIID, (void**)&child); + nsComponentManager::CreateInstance(kCChildCID, nsnull, kIWidgetIID, (void**)&child); #if 0 child->SetBorderStyle(eBorderStyle_dialog); @@ -1306,7 +1306,7 @@ nsresult WidgetTest(int *argc, char **argv) // nsIButton *button; rect.SetRect(x, y, 60, 25); - nsRepository::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button); + nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button); NS_CreateButton(window,button,rect,HandleEvent); nsString label("Slider"); button->SetLabel(label); @@ -1334,7 +1334,7 @@ nsresult WidgetTest(int *argc, char **argv) nsICheckButton * checkButton; rect.SetRect(x, y, 100, 25); - nsRepository::CreateInstance(kCCheckButtonCID, nsnull, kICheckButtonIID, (void**)&checkButton); + nsComponentManager::CreateInstance(kCCheckButtonCID, nsnull, kICheckButtonIID, (void**)&checkButton); NS_CreateCheckButton(window,checkButton,rect,CheckButtonTestHandleEvent); nsString cbLabel("CheckButton"); checkButton->SetLabel(cbLabel); @@ -1355,7 +1355,7 @@ nsresult WidgetTest(int *argc, char **argv) 0, 12); - nsRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&textWidget); + nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&textWidget); NS_CreateTextWidget(window,textWidget,rect,HandleEvent); nsString initialText("0123456789"); @@ -1372,7 +1372,7 @@ nsresult WidgetTest(int *argc, char **argv) nsITextWidget * ptextWidget; rect.SetRect(x, y, 100, TEXT_HEIGHT); - nsRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&ptextWidget); + nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&ptextWidget); NS_CreateTextWidget(window, ptextWidget, rect, HandleEvent); @@ -1406,7 +1406,7 @@ nsresult WidgetTest(int *argc, char **argv) nsITextWidget * rtextWidget; rect.SetRect(x, y, 100, TEXT_HEIGHT); - nsRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&rtextWidget); + nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&rtextWidget); NS_CreateTextWidget(window, rtextWidget, rect, HandleEvent); PRBool old; @@ -1424,7 +1424,7 @@ nsresult WidgetTest(int *argc, char **argv) nsITextAreaWidget * textAreaWidget; rect.SetRect(x, y, 150, 100); - nsRepository::CreateInstance(kCTextAreaCID, nsnull, kITextAreaWidgetIID, (void**)&textAreaWidget); + nsComponentManager::CreateInstance(kCTextAreaCID, nsnull, kITextAreaWidgetIID, (void**)&textAreaWidget); NS_CreateTextAreaWidget(window,textAreaWidget,rect,HandleEvent); nsString textAreaInitialText("Text Area Widget"); textWidgetInstance = textAreaWidget; @@ -1441,7 +1441,7 @@ nsresult WidgetTest(int *argc, char **argv) // create a scrollbar // rect.SetRect(x, 10, 25, 300); - nsRepository::CreateInstance(kCVertScrollbarCID, nsnull, kIScrollbarIID, (void**)&scrollbar); + nsComponentManager::CreateInstance(kCVertScrollbarCID, nsnull, kIScrollbarIID, (void**)&scrollbar); NS_CreateScrollBar(window,scrollbar,rect,HandleEvent); scrollbar->SetMaxRange(300); scrollbar->SetThumbSize(50); @@ -1453,7 +1453,7 @@ nsresult WidgetTest(int *argc, char **argv) // y = 10; rect.SetRect(x, y, 350, TEXT_HEIGHT); - nsRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&statusText); + nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&statusText); statusText->QueryInterface(kIWidgetIID,(void**)&widget); widget->Create(window, rect, HandleEvent, deviceContext); widget->Show(PR_TRUE); @@ -1463,13 +1463,13 @@ nsresult WidgetTest(int *argc, char **argv) // create a Failed Button // rect.SetRect(x, y, 100, 25); - nsRepository::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button); + nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button); NS_CreateButton(window,button,rect,FailedButtonHandleEvent); nsString failedLabel("Failed"); button->SetLabel(failedLabel); rect.SetRect(x, y+30, 150, 25); - nsRepository::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button); + nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button); NS_CreateButton(window,button,rect,DoSelfTests); nsString selfTestLabel("Perform Self Tests"); button->SetLabel(selfTestLabel); @@ -1479,7 +1479,7 @@ nsresult WidgetTest(int *argc, char **argv) // create a Succeeded Button // rect.SetRect(x, y, 100, 25); - nsRepository::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button); + nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button); NS_CreateButton(window,button,rect,SucceededButtonHandleEvent); nsString succeededLabel("Succeeded"); button->SetLabel(succeededLabel); @@ -1490,7 +1490,7 @@ nsresult WidgetTest(int *argc, char **argv) y = saveY; x = saveX; rect.SetRect(x, y, 150, 100); - nsRepository::CreateInstance(kCListBoxCID, nsnull, kIListBoxIID, (void**)&listBox); + nsComponentManager::CreateInstance(kCListBoxCID, nsnull, kIListBoxIID, (void**)&listBox); if (listBox) { NS_CreateListBox(window,listBox,rect,HandleEvent); @@ -1511,7 +1511,7 @@ nsresult WidgetTest(int *argc, char **argv) // create a multi-selection listbox widget // rect.SetRect(x, y, 150, 100); - nsRepository::CreateInstance(kCListBoxCID, nsnull, kIListBoxIID, (void**)&gMultiListBox); + nsComponentManager::CreateInstance(kCListBoxCID, nsnull, kIListBoxIID, (void**)&gMultiListBox); if (gMultiListBox) { // Notice the extra agrument PR_TRUE below which indicates that @@ -1536,7 +1536,7 @@ nsresult WidgetTest(int *argc, char **argv) // create a tab widget // rect.SetRect(300, 500, 200, 50); - nsRepository::CreateInstance(kCTabWidgetCID, nsnull, kITabWidgetIID, (void**)&tabWidget); + nsComponentManager::CreateInstance(kCTabWidgetCID, nsnull, kITabWidgetIID, (void**)&tabWidget); if (tabWidget) { NS_CreateTabWidget(window,tabWidget,rect,HandleTabEvent); @@ -1550,7 +1550,7 @@ nsresult WidgetTest(int *argc, char **argv) nsIRadioButton * radioButton; rect.SetRect(x, y, 120, 25); - nsRepository::CreateInstance(kCRadioButtonCID, nsnull, kIRadioButtonIID, (void**)&radioButton); + nsComponentManager::CreateInstance(kCRadioButtonCID, nsnull, kIRadioButtonIID, (void**)&radioButton); NS_CreateRadioButton(window,radioButton,rect,HandleEvent); nsString rbLabel("RadioButton1"); radioButton->SetLabel(rbLabel); @@ -1562,7 +1562,7 @@ nsresult WidgetTest(int *argc, char **argv) // rect.SetRect(x, y, 120, 25); - nsRepository::CreateInstance(kCRadioButtonCID, nsnull, kIRadioButtonIID, (void**)&radioButton); + nsComponentManager::CreateInstance(kCRadioButtonCID, nsnull, kIRadioButtonIID, (void**)&radioButton); NS_CreateRadioButton(window,radioButton,rect,HandleEvent); nsString rbLabel2("RadioButton2"); radioButton->SetLabel(rbLabel2); @@ -1576,7 +1576,7 @@ nsresult WidgetTest(int *argc, char **argv) // rect.SetRect(x, y, 120, 100); - nsRepository::CreateInstance(kCComboBoxCID, nsnull, kIComboBoxIID, (void**)&comboBox); + nsComponentManager::CreateInstance(kCComboBoxCID, nsnull, kIComboBoxIID, (void**)&comboBox); if (comboBox) { NS_CreateComboBox(window,comboBox,rect,HandleEvent); diff --git a/mozilla/xpcom/base/nsID.h b/mozilla/xpcom/base/nsID.h index 83238da6747..bb19b5fea28 100644 --- a/mozilla/xpcom/base/nsID.h +++ b/mozilla/xpcom/base/nsID.h @@ -85,5 +85,17 @@ struct nsID { extern "C" const nsID _name #endif +/* + * Class IDs + */ + +typedef nsID nsCID; + +// Define an CID +#define NS_DEFINE_CID(_name, _cidspec) \ + const nsCID _name = _cidspec + +#define REFNSCID const nsCID& + #endif diff --git a/mozilla/xpcom/components/mozIClassRegistry.h b/mozilla/xpcom/components/mozIClassRegistry.h index 86dc75f46c5..122932ca935 100644 --- a/mozilla/xpcom/components/mozIClassRegistry.h +++ b/mozilla/xpcom/components/mozIClassRegistry.h @@ -18,7 +18,7 @@ #ifndef __mozIClassRegistry_h #define __mozIClassRegistry_h -#include "nsRepository.h" +#include "nsIComponentManager.h" /*---------------------------- mozIClassRegistry ------------------------------- | This interface provides access to a mapping from mnemonic interface names | @@ -40,7 +40,7 @@ | name of the shared library that contains the implementation. | | | | The class registry object will register those classes with the "repository" | -| (see nsRepository.h) the first time a request is made to create an | +| (see nsComponentManager.h) the first time a request is made to create an | | instance. Subsequent requests will simply be forwarded to the repository | | after the appropriate interface and class IDs are determined. | | | diff --git a/mozilla/xpcom/components/mozRegistry.cpp b/mozilla/xpcom/components/mozRegistry.cpp index e0d7a28c3c2..dae56e6c7d9 100644 --- a/mozilla/xpcom/components/mozRegistry.cpp +++ b/mozilla/xpcom/components/mozRegistry.cpp @@ -1168,7 +1168,7 @@ mozRegistryFactory::LockFactory(PRBool aLock) } // This is a temporary hack; needs work to support dynamic binding -// via nsRepository and support for multiple factories per DLL. +// via nsComponentManager and support for multiple factories per DLL. extern "C" NS_EXPORT nsresult mozRegistry_GetFactory(const nsCID &cid, nsISupports* servMgr, nsIFactory** aFactory ) { nsresult rv = NS_OK; diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp new file mode 100644 index 00000000000..42bfccfa058 --- /dev/null +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -0,0 +1,1948 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsComponentManager.h" +#include "nsIServiceManager.h" +#include + +#ifndef XP_MAC +// including this on mac causes odd link errors in static initialization +// stuff that we (pinkerton & scc) don't yet understand. If you want to +// turn this on for mac, talk to one of us. +#include +#endif + +#ifdef XP_MAC +#include +#include +#include +#include +#include "primpl.h" // XXX for PR_PATH_SEPARATOR +#else +#include "private/primpl.h" // XXX for PR_PATH_SEPARATOR +#endif + +#include "plstr.h" +#include "prlink.h" +#include "prsystem.h" +#include "prprf.h" +#include "xcDllStore.h" +#include "prlog.h" + +#include "nsVector.h" +#include "prcmon.h" +#include "prthread.h" /* XXX: only used for the NSPR initialization hack (rick) */ + +#ifdef NS_DEBUG +PRLogModuleInfo* nsComponentManagerLog = NULL; +#endif + +//////////////////////////////////////////////////////////////////////////////// +// nsFactoryEntry +//////////////////////////////////////////////////////////////////////////////// + +nsFactoryEntry::nsFactoryEntry() + : factory(NULL), dll(NULL) +{ +} + +nsFactoryEntry::nsFactoryEntry(const nsCID &aClass, nsIFactory *aFactory) + : cid(aClass), factory(aFactory), dll(NULL) + +{ +} + +nsFactoryEntry::~nsFactoryEntry(void) +{ + if (factory != NULL) { + NS_RELEASE(factory); + } + // DO NOT DELETE nsDll *dll; +} + +nsresult +nsFactoryEntry::Init(nsDllStore* dllCollection, + const nsCID &aClass, const char *aLibrary, + PRTime lastModTime, PRUint32 fileSize) +{ + if (aLibrary == NULL) { + return NS_OK; + } + cid = aClass; + + // If dll not already in dllCollection, add it. + // PR_EnterMonitor(mMonitor); + dll = dllCollection->Get(aLibrary); + // PR_ExitMonitor(mMonitor); + + if (dll == NULL) { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: New dll \"%s\".", aLibrary)); + + // Add a new Dll into the nsDllStore + dll = new nsDll(aLibrary, lastModTime, fileSize); + if (dll == NULL) + return NS_ERROR_OUT_OF_MEMORY; + if (dll->GetStatus() != DLL_OK) { + // Cant create a nsDll. Backoff. + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: New dll status error. \"%s\".", aLibrary)); + delete dll; + dll = NULL; + } + else { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Adding New dll \"%s\" to mDllStore.", + aLibrary)); + + // PR_EnterMonitor(mMonitor); + dllCollection->Put(aLibrary, dll); + // PR_ExitMonitor(mMonitor); + } + } + else { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Found in mDllStore \"%s\".", aLibrary)); + // XXX We found the dll in the dllCollection. + // XXX Consistency check: dll needs to have the same + // XXX lastModTime and fileSize. If not that would mean + // XXX that the dll wasn't registered properly. + } + return NS_OK; +} + +//////////////////////////////////////////////////////////////////////////////// +// nsComponentManagerImpl +//////////////////////////////////////////////////////////////////////////////// + +nsComponentManagerImpl::nsComponentManagerImpl() + : mFactories(NULL), mProgIDs(NULL), mMonitor(NULL), mDllStore(NULL) +{ + NS_INIT_REFCNT(); +} + +nsresult nsComponentManagerImpl::Init(void) +{ + nsresult rv; + if (mFactories == NULL) { + mFactories = new nsHashtable(); + if (mFactories == NULL) + return NS_ERROR_OUT_OF_MEMORY; + } + if (mProgIDs == NULL) { + mProgIDs = new nsHashtable(); + if (mProgIDs == NULL) + return NS_ERROR_OUT_OF_MEMORY; + } + if (mMonitor == NULL) { + mMonitor = PR_NewMonitor(); + if (mMonitor == NULL) + return NS_ERROR_OUT_OF_MEMORY; + } + if (mDllStore == NULL) { + mDllStore = new nsDllStore(); + if (mDllStore == NULL) + return NS_ERROR_OUT_OF_MEMORY; + } + +#ifdef NS_DEBUG + if (nsComponentManagerLog == NULL) { + nsComponentManagerLog = PR_NewLogModule("nsComponentManager"); + } + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Initialized.")); +#endif + +#ifdef USE_NSREG + NR_StartupRegistry(); // XXX check error? + + // Check the version of registry. Nuke old versions. + rv = PlatformVersionCheck(); + if (NS_FAILED(rv)) return rv; +#endif + + // Initiate autoreg + rv = AutoRegister(NS_Startup, NULL); + if (NS_FAILED(rv)) return rv; + + return NS_OK; +} + +nsComponentManagerImpl::~nsComponentManagerImpl() +{ + if (mFactories) + delete mFactories; + if (mProgIDs) + delete mProgIDs; + if (mMonitor) + PR_DestroyMonitor(mMonitor); + if (mDllStore) + delete mDllStore; +} + +NS_IMPL_ISUPPORTS(nsComponentManagerImpl, nsIComponentManager::GetIID()); + +//////////////////////////////////////////////////////////////////////////////// +// nsComponentManagerImpl: Platform methods +//////////////////////////////////////////////////////////////////////////////// + +#ifdef USE_NSREG +#define USE_REGISTRY + +/* + * PlatformDeleteKey() + * + * Deletes a key sub tree entirely. + */ +nsresult +nsComponentManagerImpl::PlatformDeleteKey(HREG hreg, RKEY rootkey, const char *hierarchy) +{ + REGENUM state = 0; + RKEY key; + char keyname[MAXREGPATHLEN+1]; + int n = sizeof(keyname); + + REGERR err = NR_RegGetKey(hreg, rootkey, (char *)hierarchy, &key); + + if (err != REGERR_OK) + return err; + + keyname[0] = '\0'; + while (NR_RegEnumSubkeys(hreg, key, &state, keyname, n, REGENUM_DEPTH_FIRST) == REGERR_OK) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: ...enum %s", keyname)); + err = NR_RegDeleteKey(hreg, key, keyname); + if (err != REGERR_OK) + { + // Couldn't delete a key. We wont be able to delete the entire + // hierarchy. ABORT. + break; + } + keyname[0] = '\0'; + + // buf in NR_RegEnumSubKeys() causes it to return ./libxpcom.so first then + // subsequently libraptor.so (NOTE without the initial ./ which was there in + // the key). Hence continuing thought the enum and delete will fail with + // not found. Hence, restarting the enum everytime. + state = 0; + } + + if (err == REGERR_OK) + err = NR_RegDeleteKey(hreg, rootkey, (char *)hierarchy); + return err; +} + +/** + * PlatformVersionCheck() + * + * Checks to see if the XPCOM hierarchy in the registry is the same as that of + * the software as defined by NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING + */ +nsresult +nsComponentManagerImpl::PlatformVersionCheck() +{ + HREG hreg; + REGERR err = NR_RegOpen(NULL, &hreg); + + if (err != REGERR_OK) + { + return NS_ERROR_FAILURE; + } + + RKEY xpcomKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + char buf[MAXREGNAMELEN]; + uint32 len = sizeof(buf); + buf[0] = '\0'; + + err = NR_RegGetEntryString(hreg, xpcomKey, "VersionString", buf, len); + + // If there is a version mismatch or no version string, we got an old registry. + // Delete the old repository hierarchies and recreate version string + if (err != REGERR_OK || PL_strcmp(buf, NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING)) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Registry version mismatch (%s vs %s). Nuking xpcom " + "registry hierarchy.", buf, NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING)); + + // Delete the XPCOM and CLSID hierarchy + PlatformDeleteKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM"); + PlatformDeleteKey(hreg, ROOTKEY_COMMON, "Classes/CLSID"); + + // Recreate XPCOM and CLSID keys + NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey); + NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes/CLSID", NULL); + + NR_RegSetEntryString(hreg, xpcomKey, "VersionString", NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING); + } + else { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: platformVersionCheck() passed.")); + } + + NR_RegClose(hreg); + return NS_OK; +} + +/** + * PlatformCreateDll(const char *fullname) + * + * Creates a nsDll from the registry representation of dll 'fullname'. + * Looks under + * ROOTKEY_COMMON/Software/Netscape/XPCOM/fullname + */ +nsresult +nsComponentManagerImpl::PlatformCreateDll(const char *fullname, nsDll* *result) +{ + HREG hreg; + REGERR err = NR_RegOpen(NULL, &hreg); + + if (err != REGERR_OK) { + return NS_ERROR_FAILURE; + } + + RKEY xpcomKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + RKEY key; + err = NR_RegGetKey(hreg, xpcomKey, (char *)fullname, &key); + if (err != REGERR_OK) + { + return NS_ERROR_FAILURE; + } + + PRTime lastModTime = LL_ZERO; + PRUint32 fileSize = 0; + uint32 n = sizeof(lastModTime); + NR_RegGetEntry(hreg, key, "LastModTimeStamp", &lastModTime, &n); + n = sizeof(fileSize); + NR_RegGetEntry(hreg, key, "FileSize", &fileSize, &n); + + nsDll *dll = new nsDll(fullname, lastModTime, fileSize); + if (dll == NULL) + return NS_ERROR_OUT_OF_MEMORY; + + *result = dll; + return NS_OK; +} + +/** + * PlatformMarkNoComponents(nsDll *dll) + * + * Stores the dll name, last modified time, size and 0 for number of + * components in dll in the registry at location + * ROOTKEY_COMMON/Software/Netscape/XPCOM/dllname + */ +nsresult +nsComponentManagerImpl::PlatformMarkNoComponents(nsDll *dll) +{ + HREG hreg; + REGERR err = NR_RegOpen(NULL, &hreg); + + if (err != REGERR_OK) + { + return NS_ERROR_FAILURE; + } + + // XXX Gross. LongLongs dont have a serialization format. This makes + // XXX the registry non-xp. Someone beat on the nspr people to get + // XXX a longlong serialization function please! + RKEY xpcomKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + RKEY key; + err = NR_RegAddKey(hreg, xpcomKey, (char *)dll->GetFullPath(), &key); + + if (err != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + PRTime lastModTime = dll->GetLastModifiedTime(); + PRUint32 fileSize = dll->GetSize(); + + NR_RegSetEntry(hreg, key, "LastModTimeStamp", REGTYPE_ENTRY_BYTES, + &lastModTime, sizeof(lastModTime)); + NR_RegSetEntry(hreg, key, "FileSize", REGTYPE_ENTRY_BYTES, + &fileSize, sizeof(fileSize)); + + char *ncomponentsString = "0"; + + NR_RegSetEntryString(hreg, key, "ComponentsCount", + ncomponentsString); + + NR_RegClose(hreg); + return NS_OK; +} + +nsresult +nsComponentManagerImpl::PlatformRegister(QuickRegisterData* regd, nsDll *dll) +{ + HREG hreg; + // Preconditions + PR_ASSERT(regd != NULL); + PR_ASSERT(regd->CIDString != NULL); + PR_ASSERT(dll != NULL); + + REGERR err = NR_RegOpen(NULL, &hreg); + + if (err != REGERR_OK) + { + return NS_ERROR_FAILURE; + } + + RKEY classesKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + RKEY key; + NR_RegAddKey(hreg, classesKey, "CLSID", &key); + NR_RegAddKey(hreg, key, (char *)regd->CIDString, &key); + + NR_RegSetEntryString(hreg, key, "ClassName", (char *)regd->className); + if (regd->progID) + NR_RegSetEntryString(hreg, key, "ProgID", (char *)(regd->progID)); + char *libName = (char *)dll->GetFullPath(); + NR_RegSetEntryString(hreg, key, "InprocServer", libName); + + if (regd->progID) + { + NR_RegAddKey(hreg, classesKey, (char *)regd->progID, &key); + NR_RegSetEntryString(hreg, key, "CLSID", (char *)regd->CIDString); + } + + // XXX Gross. LongLongs dont have a serialization format. This makes + // XXX the registry non-xp. Someone beat on the nspr people to get + // XXX a longlong serialization function please! + RKEY xpcomKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) + { + NR_RegClose(hreg); + // This aint a fatal error. It causes autoregistration to fail + // and hence the dll would be registered again the next time + // we startup. Let us run with it. + return NS_OK; + } + + NR_RegAddKey(hreg, xpcomKey, (char *)dll->GetFullPath(), &key); + + PRTime lastModTime = dll->GetLastModifiedTime(); + PRUint32 fileSize = dll->GetSize(); + + NR_RegSetEntry(hreg, key, "LastModTimeStamp", REGTYPE_ENTRY_BYTES, + &lastModTime, sizeof(lastModTime)); + NR_RegSetEntry(hreg, key, "FileSize", REGTYPE_ENTRY_BYTES, + &fileSize, sizeof(fileSize)); + + unsigned int nComponents = 0; + char buf[MAXREGNAMELEN]; + uint32 len = sizeof(buf); + + if (NR_RegGetEntryString(hreg, key, "ComponentsCount", buf, len) == REGERR_OK) + { + nComponents = atoi(buf); + } + nComponents++; + PR_snprintf(buf, sizeof(buf), "%d", nComponents); + NR_RegSetEntryString(hreg, key, "ComponentsCount", buf); + + NR_RegClose(hreg); + return err; +} + +nsresult +nsComponentManagerImpl::PlatformUnregister(QuickRegisterData* regd, const char *aLibrary) +{ + HREG hreg; + REGERR err = NR_RegOpen(NULL, &hreg); + + if (err != REGERR_OK) + { + return NS_ERROR_FAILURE; + } + + RKEY classesKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + RKEY key; + NR_RegAddKey(hreg, classesKey, "CLSID", &key); + RKEY cidKey; + NR_RegAddKey(hreg, key, (char *)regd->CIDString, &cidKey); + char progID[MAXREGNAMELEN]; + uint32 plen = sizeof(progID); + if (NR_RegGetEntryString(hreg, cidKey, "ProgID", progID, plen) == REGERR_OK) + { + NR_RegDeleteKey(hreg, classesKey, progID); + } + + NR_RegDeleteKey(hreg, key, (char *)regd->CIDString); + + RKEY xpcomKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) + { + NR_RegClose(hreg); + // This aint a fatal error. It causes autoregistration to fail + // and hence the dll would be registered again the next time + // we startup. Let us run with it. + return NS_OK; + } + + NR_RegGetKey(hreg, xpcomKey, (char *)aLibrary, &key); + + // We need to reduce the ComponentCount by 1. + // If the ComponentCount hits 0, delete the entire key. + int nComponents = 0; + char buf[MAXREGNAMELEN]; + uint32 len = sizeof(buf); + + if (NR_RegGetEntryString(hreg, key, "ComponentsCount", buf, len) == REGERR_OK) + { + nComponents = atoi(buf); + nComponents--; + } + if (nComponents <= 0) + { + NR_RegDeleteKey(hreg, key, (char *)aLibrary); + } + else + { + PR_snprintf(buf, sizeof(buf), "%d", nComponents); + NR_RegSetEntryString(hreg, key, "ComponentsCount", buf); + } + + NR_RegClose(hreg); + return NS_OK; +} + +nsresult +nsComponentManagerImpl::PlatformFind(const nsCID &aCID, nsFactoryEntry* *result) +{ + nsresult rv; + HREG hreg; + REGERR err = NR_RegOpen(NULL, &hreg); + + if (err != REGERR_OK) { + return NS_ERROR_FAILURE; + } + + RKEY classesKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + RKEY key; + NR_RegAddKey(hreg, classesKey, "CLSID", &key); + + nsFactoryEntry *res = NULL; + + RKEY cidKey; + char *cidString = aCID.ToString(); + err = NR_RegGetKey(hreg, key, cidString, &cidKey); + delete [] cidString; + + if (err != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + // Get the library name, modifiedtime and size + PRTime lastModTime = LL_ZERO; + PRUint32 fileSize = 0; + + char buf[MAXREGNAMELEN]; + uint32 len = sizeof(buf); + err = NR_RegGetEntryString(hreg, cidKey, "InprocServer", buf, len); + if (err != REGERR_OK) + { + // Registry inconsistent. No File name for CLSID. + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + char *library = buf; + + // XXX Gross. LongLongs dont have a serialization format. This makes + // XXX the registry non-xp. Someone beat on the nspr people to get + // XXX a longlong serialization function please! + RKEY xpcomKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) == REGERR_OK) + { + if (NR_RegGetKey(hreg, xpcomKey, library, &key) == REGERR_OK) + { + uint32 n = sizeof(lastModTime); + NR_RegGetEntry(hreg, key, "LastModTimeStamp", &lastModTime, &n); + PR_ASSERT(n == sizeof(lastModTime)); + n = sizeof(fileSize); + NR_RegGetEntry(hreg, key, "FileSize", &fileSize, &n); + PR_ASSERT(n == sizeof(fileSize)); + } + } + + res = new nsFactoryEntry; + if (res == NULL) + return NS_ERROR_OUT_OF_MEMORY; + rv = res->Init(mDllStore, aCID, library, lastModTime, fileSize); + if (NS_FAILED(rv)) return rv; + + NR_RegClose(hreg); + + *result = res; + return NS_OK; +} + +nsresult +nsComponentManagerImpl::PlatformProgIDToCLSID(const char *aProgID, nsCID *aClass) +{ + HREG hreg; + nsresult res = NS_ERROR_FAILURE; + + PR_ASSERT(aClass != NULL); + + REGERR err = NR_RegOpen(NULL, &hreg); + if (err != REGERR_OK) + { + return NS_ERROR_FAILURE; + } + + RKEY classesKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + RKEY key; + err = NR_RegGetKey(hreg, classesKey, (char *)aProgID, &key); + if (err != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + char cidString[MAXREGNAMELEN]; + err = NR_RegGetEntryString(hreg, key, "CLSID", cidString, MAXREGNAMELEN); + if (err != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + NR_RegClose(hreg); + + if (!(aClass->Parse(cidString))) + { + return NS_ERROR_FAILURE; + } + res = NS_OK; + return res; +} + +nsresult +nsComponentManagerImpl::PlatformCLSIDToProgID(nsCID *aClass, + char* *aClassName, char* *aProgID) +{ + HREG hreg; + char* classnameString; + char* progidString; + nsresult res = NS_ERROR_FAILURE; + + char* cidStr = aClass->ToString(); + + PR_ASSERT(aClass != NULL); + + REGERR err = NR_RegOpen(NULL, &hreg); + if (err != REGERR_OK) + { + res = NS_ERROR_FAILURE; + goto done1; + } + + RKEY classesKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) + { + res = NS_ERROR_FAILURE; + goto done2; + } + + RKEY key; + err = NR_RegGetKey(hreg, classesKey, cidStr, &key); + if (err != REGERR_OK) + { + res = NS_ERROR_FAILURE; + goto done2; + } + + classnameString = new char[MAXREGNAMELEN]; + if (classnameString == NULL) { + res = NS_ERROR_OUT_OF_MEMORY; + goto done2; + } + err = NR_RegGetEntryString(hreg, key, "ClassName", classnameString, MAXREGNAMELEN); + if (err != REGERR_OK) + { + delete[] classnameString; + res = NS_ERROR_FAILURE; + goto done2; + } + *aClassName = classnameString; + + progidString = new char[MAXREGNAMELEN]; + if (progidString == NULL) { + delete[] classnameString; + res = NS_ERROR_OUT_OF_MEMORY; + goto done2; + } + err = NR_RegGetEntryString(hreg, key, "ProgID", progidString, MAXREGNAMELEN); + if (err != REGERR_OK) + { + delete[] progidString; + delete[] classnameString; + res = NS_ERROR_FAILURE; + goto done2; + } + + *aProgID = progidString; + res = NS_OK; + + done2: + NR_RegClose(hreg); + done1: + delete[] cidStr; + + return res; +} + +#endif // USE_NSREG + +//////////////////////////////////////////////////////////////////////////////// +// nsComponentManagerImpl: Public methods +//////////////////////////////////////////////////////////////////////////////// + +nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = NULL; + +/** + * LoadFactory() + * + * Given a FactoryEntry, this loads the dll if it has to, find the NSGetFactory + * symbol, calls the routine to create a new factory and returns it to the + * caller. + * + * No attempt is made to store the factory in any form anywhere. + */ +nsresult +nsComponentManagerImpl::LoadFactory(nsFactoryEntry *aEntry, + nsIFactory **aFactory) +{ + if (aFactory == NULL) + { + return NS_ERROR_NULL_POINTER; + } + *aFactory = NULL; + + // LoadFactory() cannot be called for entries that are CID<->factory + // mapping entries for the session. + PR_ASSERT(aEntry->dll != NULL); + + if (aEntry->dll->IsLoaded() == PR_FALSE) + { + // Load the dll + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: + Loading \"%s\".", aEntry->dll->GetFullPath())); + if (aEntry->dll->Load() == PR_FALSE) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, + ("nsComponentManager: Library load unsuccessful.")); + return NS_ERROR_FAILURE; + } + } + +#ifdef MOZ_TRACE_XPCOM_REFCNT + // Inform refcnt tracer of new library so that calls through the + // new library can be traced. + nsTraceRefcnt::LoadLibrarySymbols(aEntry->dll->GetFullPath(), aEntry->dll->GetInstance()); +#endif + nsFactoryProc proc = (nsFactoryProc) aEntry->dll->FindSymbol("NSGetFactory"); + if (proc != NULL) + { + char* className = NULL; + char* progID = NULL; + nsresult rv; + + // XXX dp, warren: deal with this! +#if 0 + rv = CLSIDToProgID(&aEntry->cid, &className, &progID); + // if CLSIDToProgID fails, just pass null to NSGetFactory +#endif + + nsIServiceManager* serviceMgr = NULL; + rv = nsServiceManager::GetGlobalServiceManager(&serviceMgr); + if (NS_FAILED(rv)) return rv; + + rv = proc(serviceMgr, aEntry->cid, className, progID, aFactory); + if (NS_FAILED(rv)) return rv; + + if (className) + delete[] className; + if (progID) + delete[] progID; + return rv; + } + PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, + ("nsComponentManager: NSGetFactory entrypoint not found.")); + return NS_ERROR_FACTORY_NOT_LOADED; +} + +/** + * FindFactory() + * + * Given a classID, this finds the factory for this CID by first searching the + * local CID<->factory mapping. Next it searches for a Dll that implements + * this classID and calls LoadFactory() to create the factory. + * + * Again, no attempt is made at storing the factory. + */ +nsresult +nsComponentManagerImpl::FindFactory(const nsCID &aClass, + nsIFactory **aFactory) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: FindFactory(%s)", buf); + delete [] buf; + } +#endif + + PR_ASSERT(aFactory != NULL); + + PR_EnterMonitor(mMonitor); + + nsIDKey key(aClass); + nsFactoryEntry *entry = (nsFactoryEntry*) mFactories->Get(&key); + + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + +#ifdef USE_REGISTRY + if (entry == NULL) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("\t\tnot found in factory cache. Looking in registry")); + nsresult rv = PlatformFind(aClass, &entry); + + // XXX This should go into PlatformFind(), and PlatformFind() + // should just become a static method on nsComponentManager. + + // If we got one, cache it in our hashtable + if (NS_SUCCEEDED(rv)) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("\t\tfound in registry.")); + mFactories->Put(&key, entry); + } + } + else + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("\t\tfound in factory cache.")); + } +#endif + + PR_ExitMonitor(mMonitor); + + if (entry != NULL) + { + if ((entry)->factory == NULL) + { + res = LoadFactory(entry, aFactory); + } + else + { + *aFactory = entry->factory; + NS_ADDREF(*aFactory); + res = NS_OK; + } + } + + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tFindFactory() %s", + NS_SUCCEEDED(res) ? "succeeded" : "FAILED")); + + return res; +} + +/** + * ProgIDToCLSID() + * + * Mapping function from a ProgID to a classID. Directly talks to the registry. + * + * XXX We need to add a cache this translation as this is done a lot. + */ +nsresult +nsComponentManagerImpl::ProgIDToCLSID(const char *aProgID, nsCID *aClass) +{ + NS_PRECONDITION(aProgID != NULL, "null ptr"); + if (! aProgID) + return NS_ERROR_NULL_POINTER; + + NS_PRECONDITION(aClass != NULL, "null ptr"); + if (! aClass) + return NS_ERROR_NULL_POINTER; + + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + +#ifdef USE_REGISTRY + // XXX This isn't quite the best way to do this: we should + // probably move an nsArray into the FactoryEntry class, + // and then have the construct/destructor of the factory entry + // keep the ProgID to CID cache up-to-date. However, doing this + // significantly improves performance, so it'll do for now. + +#define NS_NO_CID { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } } + static NS_DEFINE_CID(kNoCID, NS_NO_CID); + + nsProgIDKey key(aProgID); + nsCID* cid = (nsCID*) mProgIDs->Get(&key); + if (cid) { + if (cid == &kNoCID) { + // we've already tried to map this ProgID to a CLSID, and found + // that there _was_ no such mapping in the registry. + } + else { + *aClass = *cid; + res = NS_OK; + } + } + else { + // This is the first time someone has asked for this + // ProgID. Go to the registry to find the CID. + res = PlatformProgIDToCLSID(aProgID, aClass); + + if (NS_SUCCEEDED(res)) { + // Found it. So put it into the cache. + cid = new nsCID(*aClass); + if (!cid) + return NS_ERROR_OUT_OF_MEMORY; + + mProgIDs->Put(&key, cid); + } + else { + // Didn't find it. Put a special CID in the cache so we + // don't need to hit the registry on subsequent requests + // for the same ProgID. + mProgIDs->Put(&key, (void*) &kNoCID); + } + } +#endif /* USE_REGISTRY */ + +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) { + char *buf; + if (NS_SUCCEEDED(res)) + buf = aClass->ToString(); + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: ProgIDToCLSID(%s)->%s", aProgID, + NS_SUCCEEDED(res) ? buf : "[FAILED]")); + if (NS_SUCCEEDED(res)) + delete [] buf; + } +#endif + + return res; +} + +/** + * CLSIDToProgID() + * + * Translates a classID to a {ProgID, Class Name}. Does direct registry + * access to do the translation. + * + * XXX Would be nice to hook in a cache here too. + */ +nsresult +nsComponentManagerImpl::CLSIDToProgID(nsCID *aClass, + char* *aClassName, + char* *aProgID) +{ + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + +#ifdef USE_REGISTRY + res = PlatformCLSIDToProgID(aClass, aClassName, aProgID); +#endif /* USE_REGISTRY */ + +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass->ToString(); + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("nsComponentManager: CLSIDToProgID(%s)->%s", buf, + NS_SUCCEEDED(res) ? *aProgID : "[FAILED]")); + delete [] buf; + } +#endif + + return res; +} + +/** + * CreateInstance() + * + * Create an instance of an object that implements an interface and belongs + * to the implementation aClass using the factory. The factory is immediately + * released and not held onto for any longer. + */ +nsresult +nsComponentManagerImpl::CreateInstance(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: CreateInstance(%s)", buf); + delete [] buf; + } +#endif + if (aResult == NULL) + { + return NS_ERROR_NULL_POINTER; + } + *aResult = NULL; + + nsIFactory *factory = NULL; + nsresult res = FindFactory(aClass, &factory); + if (NS_SUCCEEDED(res)) + { + res = factory->CreateInstance(aDelegate, aIID, aResult); + NS_RELEASE(factory); + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("\t\tCreateInstance() succeeded.")); + return res; + } + + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("\t\tCreateInstance() FAILED.")); + return NS_ERROR_FACTORY_NOT_REGISTERED; +} + +/** + * CreateInstance() + * + * An overload of CreateInstance() that creates an instance of the object that + * implements the interface aIID and whose implementation has a progID aProgID. + * + * This is only a convenience routine that turns around can calls the + * CreateInstance() with classid and iid. + * + * XXX This is a function overload. We need to remove it. + */ +nsresult +nsComponentManagerImpl::CreateInstance(const char *aProgID, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) +{ + nsCID clsid; + nsresult rv = ProgIDToCLSID(aProgID, &clsid); + if (NS_FAILED(rv)) return rv; + return CreateInstance(clsid, aDelegate, aIID, aResult); +} + +#if 0 +nsresult +nsComponentManagerImpl::CreateInstance2(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void *aSignature, + void **aResult) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: Creating Instance."); + PR_LogPrint("nsComponentManager: + %s.", + buf); + PR_LogPrint("nsComponentManager: + Signature = %p.", + aSignature); + delete [] buf; + } +#endif + if (aResult == NULL) + { + return NS_ERROR_NULL_POINTER; + } + *aResult = NULL; + + nsIFactory *factory = NULL; + + nsresult res = FindFactory(aClass, &factory); + + if (NS_SUCCEEDED(res)) + { + nsIFactory2 *factory2 = NULL; + res = NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT; + + factory->QueryInterface(kFactory2IID, (void **) &factory2); + + if (factory2 != NULL) + { + res = factory2->CreateInstance2(aDelegate, aIID, aSignature, aResult); + NS_RELEASE(factory2); + } + + NS_RELEASE(factory); + return res; + } + + return NS_ERROR_FACTORY_NOT_REGISTERED; +} +#endif /* 0 */ + +/** + * RegisterFactory() + * + * Register a factory to be responsible for creation of implementation of + * classID aClass. Plus creates as association of aClassName and aProgID + * to the classID. If replace is PR_TRUE, we replace any existing registrations + * with this one. + * + * Once registration is complete, we add the class to the factories cache + * that we maintain. The factories cache is the ONLY place where these + * registrations are ever kept. + * + * XXX This uses FindFactory() to test if a factory already exists. This + * XXX has the bad side effect of loading the factory if the previous + * XXX registration was a dll for this class. We might be able to do away + * XXX with such a load. + */ +nsresult +nsComponentManagerImpl::RegisterFactory(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory *aFactory, + PRBool aReplace) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: RegisterFactory(%s, factory), replace = %d.", buf, (int)aReplace); + delete [] buf; + } +#endif + + nsIFactory *old = NULL; + FindFactory(aClass, &old); + + if (old != NULL) + { + NS_RELEASE(old); + if (!aReplace) + { + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tFactory already registered.")); + return NS_ERROR_FACTORY_EXISTS; + } + else + { + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tdeleting old Factory Entry.")); + } + } + + PR_EnterMonitor(mMonitor); + + nsIDKey key(aClass); + nsFactoryEntry* entry = new nsFactoryEntry(aClass, aFactory); + if (entry == NULL) + return NS_ERROR_OUT_OF_MEMORY; + mFactories->Put(&key, entry); + + PR_ExitMonitor(mMonitor); + + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tFactory register succeeded.")); + + return NS_OK; +} + +nsresult +nsComponentManagerImpl::RegisterComponent(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + const char *aLibrary, + PRBool aReplace, + PRBool aPersist) +{ + nsresult rv = NS_OK; +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: RegisterComponent(%s, %s, %s, %s), replace = %d, persist = %d.", + buf, aClassName, aProgID, aLibrary, (int)aReplace, (int)aPersist); + delete [] buf; + } +#endif + + nsIFactory *old = NULL; + FindFactory(aClass, &old); + + if (old != NULL) + { + NS_RELEASE(old); + if (!aReplace) + { + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tFactory already registered.")); + return NS_ERROR_FACTORY_EXISTS; + } + else + { + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tdeleting registered Factory.")); + } + } + + PR_EnterMonitor(mMonitor); + +#ifdef USE_REGISTRY + if (aPersist == PR_TRUE) + { + // Add it to the registry + nsDll *dll = new nsDll(aLibrary); + if (dll == NULL) { + rv = NS_ERROR_OUT_OF_MEMORY; + goto done; + } + // XXX temp hack until we get the dll to give us the entire + // XXX NSQuickRegisterClassData + QuickRegisterData cregd = {0}; + cregd.CIDString = aClass.ToString(); + cregd.className = aClassName; + cregd.progID = aProgID; + PlatformRegister(&cregd, dll); + delete [] (char *)cregd.CIDString; + delete dll; + } + else +#endif + { + nsDll *dll = new nsDll(aLibrary); + if (dll == NULL) { + rv = NS_ERROR_OUT_OF_MEMORY; + goto done; + } + nsIDKey key(aClass); + nsFactoryEntry* entry = new nsFactoryEntry; + delete dll; + if (entry == NULL) { + rv = NS_ERROR_OUT_OF_MEMORY; + goto done; + } + rv = entry->Init(mDllStore, aClass, aLibrary, + dll->GetLastModifiedTime(), dll->GetSize()); + if (NS_FAILED(rv)) + goto done; + mFactories->Put(&key, entry); + } + + done: + PR_ExitMonitor(mMonitor); + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tFactory register succeeded.")); + return rv; +} + +nsresult +nsComponentManagerImpl::UnregisterFactory(const nsCID &aClass, + nsIFactory *aFactory) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: Unregistering Factory."); + PR_LogPrint("nsComponentManager: + %s.", buf); + delete [] buf; + } +#endif + + nsIDKey key(aClass); + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + nsFactoryEntry *old = (nsFactoryEntry *) mFactories->Get(&key); + if (old != NULL) + { + if (old->factory == aFactory) + { + PR_EnterMonitor(mMonitor); + old = (nsFactoryEntry *) mFactories->Remove(&key); + PR_ExitMonitor(mMonitor); + delete old; + res = NS_OK; + } + + } + + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("nsComponentManager: ! Factory unregister %s.", + res == NS_OK ? "succeeded" : "failed")); + + return res; +} + +nsresult +nsComponentManagerImpl::UnregisterComponent(const nsCID &aClass, + const char *aLibrary) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: Unregistering Factory."); + PR_LogPrint("nsComponentManager: + %s in \"%s\".", buf, aLibrary); + delete [] buf; + } +#endif + + nsIDKey key(aClass); + nsFactoryEntry *old = (nsFactoryEntry *) mFactories->Get(&key); + + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + + PR_EnterMonitor(mMonitor); + + if (old != NULL && old->dll != NULL) + { + if (old->dll->GetFullPath() != NULL && +#ifdef XP_UNIX + PL_strcasecmp(old->dll->GetFullPath(), aLibrary) +#else + PL_strcmp(old->dll->GetFullPath(), aLibrary) +#endif + ) + { + nsFactoryEntry *entry = (nsFactoryEntry *) mFactories->Remove(&key); + delete entry; + res = NS_OK; + } +#ifdef USE_REGISTRY + // XXX temp hack until we get the dll to give us the entire + // XXX NSQuickRegisterClassData + QuickRegisterData cregd = {0}; + cregd.CIDString = aClass.ToString(); + res = PlatformUnregister(&cregd, aLibrary); + delete [] (char *)cregd.CIDString; +#endif + } + + PR_ExitMonitor(mMonitor); + + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("nsComponentManager: ! Factory unregister %s.", + res == NS_OK ? "succeeded" : "failed")); + + return res; +} + +nsresult +nsComponentManagerImpl::UnregisterFactory(const nsCID &aClass, + const char *aLibrary) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: Unregistering Factory."); + PR_LogPrint("nsComponentManager: + %s in \"%s\".", buf, aLibrary); + delete [] buf; + } +#endif + + nsIDKey key(aClass); + nsFactoryEntry *old = (nsFactoryEntry *) mFactories->Get(&key); + + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + + PR_EnterMonitor(mMonitor); + + if (old != NULL && old->dll != NULL) + { + if (old->dll->GetFullPath() != NULL && +#ifdef XP_UNIX + PL_strcasecmp(old->dll->GetFullPath(), aLibrary) +#else + PL_strcmp(old->dll->GetFullPath(), aLibrary) +#endif + ) + { + nsFactoryEntry *entry = (nsFactoryEntry *) mFactories->Remove(&key); + delete entry; + res = NS_OK; + } +#ifdef USE_REGISTRY + // XXX temp hack until we get the dll to give us the entire + // XXX NSQuickRegisterClassData + QuickRegisterData cregd = {0}; + cregd.CIDString = aClass.ToString(); + res = PlatformUnregister(&cregd, aLibrary); + delete [] (char *)cregd.CIDString; +#endif + } + + PR_ExitMonitor(mMonitor); + + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("nsComponentManager: ! Factory unregister %s.", + res == NS_OK ? "succeeded" : "failed")); + + return res; +} + +static PRBool +nsFreeLibraryEnum(nsHashKey *aKey, void *aData, void* closure) +{ + nsFactoryEntry *entry = (nsFactoryEntry *) aData; + nsIServiceManager* serviceMgr = (nsIServiceManager*)closure; + + if (entry->dll && entry->dll->IsLoaded() == PR_TRUE) + { + nsCanUnloadProc proc = (nsCanUnloadProc) entry->dll->FindSymbol("NSCanUnload"); + if (proc != NULL) { + nsresult rv = proc(serviceMgr); + if (NS_FAILED(rv)) { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: + Unloading \"%s\".", entry->dll->GetFullPath())); + entry->dll->Unload(); + } + } + } + + return PR_TRUE; +} + +nsresult +nsComponentManagerImpl::FreeLibraries(void) +{ + PR_EnterMonitor(mMonitor); + + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Freeing Libraries.")); + + nsIServiceManager* serviceMgr = NULL; + nsresult rv = nsServiceManager::GetGlobalServiceManager(&serviceMgr); + if (NS_FAILED(rv)) return rv; + mFactories->Enumerate(nsFreeLibraryEnum, serviceMgr); + + PR_ExitMonitor(mMonitor); + + return NS_OK; +} + +//////////////////////////////////////////////////////////////////////////////// + +/** + * AutoRegister(RegistrationInstant, const char *pathlist) + * + * Given a ; separated list of paths, this will ensure proper registration + * of all components. A default pathlist is maintained in the registry at + * \\HKEYROOT_COMMON\\Classes\\PathList + * In addition to looking at the pathlist, the default pathlist is looked at. + * + * This will take care not loading already registered dlls, finding and + * registering new dlls, re-registration of modified dlls + * + */ + +nsresult +nsComponentManagerImpl::AutoRegister(RegistrationTime when, + const char* pathlist) +{ +#ifdef XP_MAC + CInfoPBRec catInfo; + Handle pathH; + OSErr err; + ProcessSerialNumber psn; + ProcessInfoRec pInfo; + FSSpec appFSSpec; + FSSpec tempSpec; + long theDirID; + Str255 name; +#endif + + if (pathlist != NULL) + { + SyncComponentsInPathList(pathlist); + } + +#ifdef XP_MAC + // get info for the the current process to determine the directory its located in + if (!(err = GetCurrentProcess(&psn))) + { + // initialize ProcessInfoRec before calling GetProcessInformation() or die horribly. + pInfo.processName = nil; + pInfo.processAppSpec = &tempSpec; + pInfo.processInfoLength = sizeof(ProcessInfoRec); + if (!(err = GetProcessInformation(&psn, &pInfo))) + { + appFSSpec = *(pInfo.processAppSpec); + if ((pathH = NewHandle(1)) != NULL) + { + **pathH = '\0'; // initially null terminate the string + HNoPurge(pathH); + HUnlock(pathH); + theDirID = appFSSpec.parID; + do + { + catInfo.dirInfo.ioCompletion = NULL; + catInfo.dirInfo.ioNamePtr = (StringPtr)&name; + catInfo.dirInfo.ioVRefNum = appFSSpec.vRefNum; + catInfo.dirInfo.ioDrDirID = theDirID; + catInfo.dirInfo.ioFDirIndex = -1; // -1 = query dir in ioDrDirID + if (!(err = PBGetCatInfoSync(&catInfo))) + { + // build up a Unix style pathname due to NSPR + // XXX Note: this breaks if any of the parent + // directories contain a "slash" (blame NSPR) + + Munger(pathH, 0L, NULL, 0L, (const void *)&name[1], (long)name[0]); // prepend dir name + Munger(pathH, 0L, NULL, 0L, "/", 1); // prepend slash + + // move up to parent directory + theDirID = catInfo.dirInfo.ioDrParID; + } + } while ((!err) && (catInfo.dirInfo.ioDrDirID != 2)); // 2 = root + if (!err) + { + Munger(pathH, GetHandleSize(pathH)-1, NULL, 0L, "/components", 11); // append "/components" + HLock(pathH); + SyncComponentsInPathList((const char *)(*pathH)); + HUnlock(pathH); + } + DisposeHandle(pathH); + } + } + } +#else + //XXX get default pathlist from registry + //XXX Temporary hack. Registering components from current directory +#ifdef XP_UNIX + const char *defaultPathList = "./components"; +#else + // XXX This will change to ./components very soon + const char *defaultPathList = "."; +#endif + SyncComponentsInPathList(defaultPathList); +#endif + return NS_OK; +} + +nsresult +nsComponentManagerImpl::AddToDefaultPathList(const char *pathlist) +{ + //XXX add pathlist to the defaultpathlist in the registry + return NS_ERROR_FAILURE; +} + +nsresult +nsComponentManagerImpl::SyncComponentsInPathList(const char *pathlist) +{ + char *paths = PL_strdup(pathlist); + + if (paths == NULL || *paths == '\0') + return(NS_ERROR_FAILURE); + + char *pathsMem = paths; + while (paths != NULL) + { + char *nextpath = PL_strchr(paths, PR_PATH_SEPARATOR); + if (nextpath != NULL) *nextpath = '\0'; + SyncComponentsInDir(paths); + paths = nextpath; + } + PL_strfree(pathsMem); + return NS_OK; +} + +nsresult +nsComponentManagerImpl::SyncComponentsInDir(const char *dir) +{ + PRDir *prdir = PR_OpenDir(dir); + if (prdir == NULL) + return NS_ERROR_FAILURE; + + // Create a buffer that has dir/ in it so we can append + // the filename each time in the loop + char fullname[NS_MAX_FILENAME_LEN]; + PL_strncpyz(fullname, dir, sizeof(fullname)); + unsigned int n = strlen(fullname); + if (n+1 < sizeof(fullname)) + { +#ifdef XP_WIN + fullname[n] = PR_GetDirectorySeparator(); +#else + fullname[n] = '/'; +#endif + n++; + } + char *filepart = fullname + n; + + PRDirEntry *dirent = NULL; + while ((dirent = PR_ReadDir(prdir, PR_SKIP_BOTH)) != NULL) + { + PL_strncpyz(filepart, dirent->name, sizeof(fullname)-n); + nsresult ret = SyncComponentsInFile(fullname); + if (NS_FAILED(ret) && ret == NS_ERROR_IS_DIR) { + SyncComponentsInDir(fullname); + } + } // foreach file + PR_CloseDir(prdir); + return NS_OK; +} + +nsresult +nsComponentManagerImpl::SyncComponentsInFile(const char *fullname) +{ + const char *ValidDllExtensions[] = { + ".dll", /* Windows */ + ".dso", /* Unix */ + ".so", /* Unix */ + ".sl", /* Unix: HP */ + ".shlb", /* Mac ? */ + ".dlm", /* new for all platforms */ + NULL + }; + + + PRFileInfo statbuf; + if (PR_GetFileInfo(fullname,&statbuf) != PR_SUCCESS) + { + // Skip files that cannot be stat + return NS_ERROR_FAILURE; + } + + if (statbuf.type == PR_FILE_DIRECTORY) + { + // Cant register a directory + return NS_ERROR_IS_DIR; + } + else if (statbuf.type != PR_FILE_FILE) + { + // Skip non-files + return NS_ERROR_FAILURE; + } + + // deal with only files that have the right extension + PRBool validExtension = PR_FALSE; + int flen = PL_strlen(fullname); + for (int i=0; ValidDllExtensions[i] != NULL; i++) + { + int extlen = PL_strlen(ValidDllExtensions[i]); + + // Does fullname end with this extension + if (flen >= extlen && + !PL_strcasecmp(&(fullname[flen - extlen]), ValidDllExtensions[i]) + ) + { + validExtension = PR_TRUE; + break; + } + } + + if (validExtension == PR_FALSE) + { + // Skip invalid extensions + return NS_ERROR_FAILURE; + } + + // Check if dll is one that we have already seen + nsDll *dll = mDllStore->Get(fullname); + nsresult rv = NS_OK; + if (dll == NULL) + { + // XXX Create nsDll for this from registry and + // XXX add it to our dll cache mDllStore. +#ifdef USE_REGISTRY + rv = PlatformCreateDll(fullname, &dll); +#endif /* USE_REGISTRY */ + } + + if (NS_SUCCEEDED(rv)) + { + // Make sure the dll is OK + if (dll->GetStatus() != NS_OK) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: + nsDll not NS_OK \"%s\". Skipping...", + dll->GetFullPath())); + return NS_ERROR_FAILURE; + } + + // We already have seen this dll. Check if this dll changed + if (LL_EQ(dll->GetLastModifiedTime(), statbuf.modifyTime) && + (dll->GetSize() == statbuf.size)) + { + // Dll hasn't changed. Skip. + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: + nsDll not changed \"%s\". Skipping...", + dll->GetFullPath())); + return NS_OK; + } + + // Aagh! the dll has changed since the last time we saw it. + // re-register dll + if (dll->IsLoaded()) + { + // We are screwed. We loaded the old version of the dll + // and now we find that the on-disk copy if newer. + // The only thing to do would be to ask the dll if it can + // unload itself. It can do that if it hasn't created objects + // yet. + nsCanUnloadProc proc = (nsCanUnloadProc) + dll->FindSymbol("NSCanUnload"); + if (proc != NULL) + { + PRBool res = proc(this /*, PR_TRUE*/); + if (res) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: + Unloading \"%s\".", + dll->GetFullPath())); + dll->Unload(); + } + else + { + // THIS IS THE WORST SITUATION TO BE IN. + // Dll doesn't want to be unloaded. Cannot re-register + // this dll. + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: *** Dll already loaded. " + "Cannot unload either. Hence cannot re-register " + "\"%s\". Skipping...", dll->GetFullPath())); + return NS_ERROR_FAILURE; + } + } + else { + // dll doesn't have a CanUnload proc. Guess it is + // ok to unload it. + dll->Unload(); + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: + Unloading \"%s\". (no CanUnloadProc).", + dll->GetFullPath())); + + } + + } // dll isloaded + + // Sanity. + if (dll->IsLoaded()) + { + // We went through all the above to make sure the dll + // is unloaded. And here we are with the dll still + // loaded. Whoever taught dp programming... + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Dll still loaded. Cannot re-register " + "\"%s\". Skipping...", dll->GetFullPath())); + return NS_ERROR_FAILURE; + } + } // dll != NULL + else + { + // Create and add the dll to the mDllStore + // It is ok to do this even if the creation of nsDll + // didnt succeed. That way we wont do this again + // when we encounter the same dll. + dll = new nsDll(fullname); + if (dll == NULL) + return NS_ERROR_OUT_OF_MEMORY; + mDllStore->Put(fullname, dll); + } // dll == NULL + + // Either we are seeing the dll for the first time or the dll has + // changed since we last saw it and it is unloaded successfully. + // + // Now we can try register the dll for sure. + nsresult res = SelfRegisterDll(dll); + nsresult ret = NS_OK; + if (NS_FAILED(res)) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Autoregistration FAILED for " + "\"%s\". Skipping...", dll->GetFullPath())); + // Mark dll as not xpcom dll along with modified time and size in + // the registry so that we wont need to load the dll again every + // session until the dll changes. +#ifdef USE_REGISTRY + PlatformMarkNoComponents(dll); +#endif /* USE_REGISTRY */ + ret = NS_ERROR_FAILURE; + } + else + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Autoregistration Passed for " + "\"%s\". Skipping...", dll->GetFullPath())); + // Marking dll along with modified time and size in the + // registry happens at PlatformRegister(). No need to do it + // here again. + } + return ret; +} + +/* +* SelfRegisterDll +* +* Given a dll abstraction, this will load, selfregister the dll and +* unload the dll. +* +*/ +nsresult +nsComponentManagerImpl::SelfRegisterDll(nsDll *dll) +{ + // Precondition: dll is not loaded already + PR_ASSERT(dll->IsLoaded() == PR_FALSE); + + nsresult res = NS_ERROR_FAILURE; + + if (dll->Load() == PR_FALSE) + { + // Cannot load. Probably not a dll. + return(NS_ERROR_FAILURE); + } + + nsRegisterProc regproc = (nsRegisterProc)dll->FindSymbol("NSRegisterSelf"); + + if (regproc == NULL) + { + // Smart registration + QuickRegisterData* qr = + (QuickRegisterData*)dll->FindSymbol(NS_QUICKREGISTER_DATA_SYMBOL); + if (qr == NULL) + { + res = NS_ERROR_NO_INTERFACE; + } + else + { + // XXX register the quick registration data on behalf of the dll + // XXX for now return failure + res = NS_ERROR_FAILURE; + } + } + else + { + // Call the NSRegisterSelfProc to enable dll registration + nsIServiceManager* serviceMgr = NULL; + res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); + if (NS_SUCCEEDED(res)) { + res = regproc(serviceMgr, dll->GetFullPath()); + } + } + dll->Unload(); + return res; +} + +nsresult +nsComponentManagerImpl::SelfUnregisterDll(nsDll *dll) +{ + // Precondition: dll is not loaded + PR_ASSERT(dll->IsLoaded() == PR_FALSE); + + if (dll->Load() == PR_FALSE) + { + // Cannot load. Probably not a dll. + return(NS_ERROR_FAILURE); + } + + nsUnregisterProc unregproc = + (nsUnregisterProc) dll->FindSymbol("NSUnregisterSelf"); + nsresult res = NS_OK; + + if (unregproc == NULL) + { + // Smart unregistration + QuickRegisterData* qr = (QuickRegisterData*) + dll->FindSymbol(NS_QUICKREGISTER_DATA_SYMBOL); + if (qr == NULL) + { + return(NS_ERROR_NO_INTERFACE); + } + // XXX unregister the dll based on the quick registration data + } + else + { + // Call the NSUnregisterSelfProc to enable dll de-registration + nsIServiceManager* serviceMgr = NULL; + res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); + if (NS_SUCCEEDED(res)) { + res = unregproc(serviceMgr, dll->GetFullPath()); + } + } + dll->Unload(); + return res; +} + +//////////////////////////////////////////////////////////////////////////////// + +NS_COM nsresult +NS_GetGlobalComponentManager(nsIComponentManager* *result) +{ + if (nsComponentManagerImpl::gComponentManager == NULL) { + nsComponentManagerImpl::gComponentManager = + new nsComponentManagerImpl(); + if (nsComponentManagerImpl::gComponentManager == NULL) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(nsComponentManagerImpl::gComponentManager); + nsresult rv = nsComponentManagerImpl::gComponentManager->Init(); + if (NS_FAILED(rv)) { + NS_RELEASE(nsComponentManagerImpl::gComponentManager); + return rv; + } + } + *result = nsComponentManagerImpl::gComponentManager; + return NS_OK; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/xpcom/components/nsComponentManager.h b/mozilla/xpcom/components/nsComponentManager.h new file mode 100644 index 00000000000..a10b93c5b70 --- /dev/null +++ b/mozilla/xpcom/components/nsComponentManager.h @@ -0,0 +1,224 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsComponentManager_h__ +#define nsComponentManager_h__ + +#include "nsIComponentManager.h" +#include "NSReg.h" +#include "nsHashtable.h" +#include "prtime.h" + +class nsFactoryEntry; +class nsDllStore; +class nsDll; + +//////////////////////////////////////////////////////////////////////////////// +/* + *** Quick Registration NOT FOR PUBLIC CONSUMPTION *** + * + * Quick Registration + * + * For quick registration, dlls can define + * NSQuickRegisterClassData g_NSQuickRegisterData[]; + * and export the symbol "g_NSQuickRegisterData" + * + * Quick registration is tried only if the symbol "NSRegisterSelf" + * is not found. If it is found but fails registration, quick registration + * will not kick in. + * + * The array is terminated by having a NULL last element. Specifically, the + * array will be assumed to end when + * (g_NSQuickRegisterData[i].classIdStr == NULL) + * + */ +#define NS_QUICKREGISTER_DATA_SYMBOL "g_NSQuickRegisterData" + +//////////////////////////////////////////////////////////////////////////////// + +class nsComponentManagerImpl : public nsIComponentManager { +public: + NS_DECL_ISUPPORTS + + // nsIComponentManager methods: + NS_IMETHOD FindFactory(const nsCID &aClass, + nsIFactory **aFactory); + + // Finds a class ID for a specific Program ID + NS_IMETHOD ProgIDToCLSID(const char *aProgID, + nsCID *aClass); + + // Finds a Program ID for a specific class ID + // caller frees the result with delete[] + NS_IMETHOD CLSIDToProgID(nsCID *aClass, + char* *aClassName, + char* *aProgID); + + // Creates a class instance for a specific class ID + NS_IMETHOD CreateInstance(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult); + + // Convenience routine, creates a class instance for a specific ProgID + NS_IMETHOD CreateInstance(const char *aProgID, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult); + + // Creates a class instance for a specific class ID + /* + NS_IMETHOD CreateInstance2(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void *aSignature, + void **aResult); + */ + + // Manually registry a factory for a class + NS_IMETHOD RegisterFactory(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory *aFactory, + PRBool aReplace); + + // Manually register a dynamically loaded component. + NS_IMETHOD RegisterComponent(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + const char *aLibrary, + PRBool aReplace, + PRBool aPersist); + + // Manually unregister a factory for a class + NS_IMETHOD UnregisterFactory(const nsCID &aClass, + nsIFactory *aFactory); + + // Manually unregister a dynamically loaded factory for a class + NS_IMETHOD UnregisterFactory(const nsCID &aClass, + const char *aLibrary); + + // Manually unregister a dynamically loaded component + NS_IMETHOD UnregisterComponent(const nsCID &aClass, + const char *aLibrary); + + // Unload dynamically loaded factories that are not in use + NS_IMETHOD FreeLibraries(void); + + ////////////////////////////////////////////////////////////////////////////// + // DLL registration support + /* Autoregistration will try only files with these extensions. + * All extensions are case insensitive. + * ".dll", // Windows + * ".dso", // Unix + * ".so", // Unix + * ".sl", // Unix: HP + * "_dll", // Mac + * ".dlm", // new for all platforms + */ + NS_IMETHOD AutoRegister(RegistrationTime when, const char* pathlist); + // Pathlist is a semicolon separated list of pathnames + NS_IMETHOD AddToDefaultPathList(const char *pathlist); + NS_IMETHOD SyncComponentsInPathList(const char *pathlist); + NS_IMETHOD SyncComponentsInDir(const char *path); + NS_IMETHOD SyncComponentsInFile(const char *fullname); + + // nsComponentManagerImpl methods: + nsComponentManagerImpl(); + virtual ~nsComponentManagerImpl(); + + static nsComponentManagerImpl* gComponentManager; + nsresult Init(void); + +protected: + nsresult LoadFactory(nsFactoryEntry *aEntry, nsIFactory **aFactory); + nsresult SelfRegisterDll(nsDll *dll); + nsresult SelfUnregisterDll(nsDll *dll); + + nsresult PlatformDeleteKey(HREG hreg, RKEY rootkey, const char *hierarchy); + nsresult PlatformVersionCheck(); + nsresult PlatformCreateDll(const char *fullname, nsDll* *result); + nsresult PlatformMarkNoComponents(nsDll *dll); + struct QuickRegisterData { + const char *CIDString; // {98765-8776-8958758759-958785} + const char *className; // "Layout Engine" + const char *progID; // "Gecko.LayoutEngine.1" + }; + nsresult PlatformRegister(QuickRegisterData* regd, nsDll *dll); + nsresult PlatformUnregister(QuickRegisterData* regd, const char *aLibrary); + nsresult PlatformFind(const nsCID &aCID, nsFactoryEntry* *result); + nsresult PlatformProgIDToCLSID(const char *aProgID, nsCID *aClass); + nsresult PlatformCLSIDToProgID(nsCID *aClass, char* *aClassName, char* *aProgID); + +protected: + nsHashtable* mFactories; + nsHashtable* mProgIDs; + PRMonitor* mMonitor; + nsDllStore* mDllStore; +}; + +#define NS_MAX_FILENAME_LEN 1024 + +#define NS_ERROR_IS_DIR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, 24) + +/** + * When using the registry we put a version number in it. + * If the version number that is in the registry doesn't match + * the following, we ignore the registry. This lets news versions + * of the software deal with old formats of registry and not + * + * alpha0.20 : First time we did versioning + * alpha0.30 : Changing autoreg to begin registration from ./components on unix + */ +#define NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING "alpha0.31" + +//////////////////////////////////////////////////////////////////////////////// +/** + * Class: nsFactoryEntry() + * + * There are two types of FactoryEntries. + * + * 1. {CID, dll} mapping. + * Factory is a consequence of the dll. These can be either session + * specific or persistent based on whether we write this + * to the registry or not. + * + * 2. {CID, factory} mapping + * These are strictly session specific and in memory only. + */ + +class nsFactoryEntry { +public: + nsFactoryEntry(); + nsFactoryEntry(const nsCID &aClass, nsIFactory *aFactory); + ~nsFactoryEntry(); + + nsresult Init(nsDllStore* store, const nsCID &aClass, const char *aLibrary, + PRTime lastModTime, PRUint32 fileSize); + + nsCID cid; + nsIFactory *factory; + + // DO NOT DELETE THIS. Many nsFactoryEntry(s) could be sharing the same Dll. + // This gets deleted from the dllStore going away. + nsDll *dll; +}; + +//////////////////////////////////////////////////////////////////////////////// + +#endif // nsComponentManager_h__ diff --git a/mozilla/xpcom/components/nsIComponentManager.h b/mozilla/xpcom/components/nsIComponentManager.h new file mode 100644 index 00000000000..08aa15e0b50 --- /dev/null +++ b/mozilla/xpcom/components/nsIComponentManager.h @@ -0,0 +1,258 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIComponentManager_h__ +#define nsIComponentManager_h__ + +#include "prtypes.h" +#include "nsCom.h" +#include "nsID.h" +#include "nsError.h" +#include "nsISupports.h" +#include "nsIFactory.h" + +/* + * Prototypes for dynamic library export functions. Your DLL/DSO needs to export + * these methods to play in the component world. + */ + +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr); +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *fullpath); +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char *fullpath); + +typedef nsresult (*nsFactoryProc)(nsISupports* aServMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +typedef PRBool (*nsCanUnloadProc)(nsISupports* aServMgr); +typedef nsresult (*nsRegisterProc)(nsISupports* aServMgr, const char *path); +typedef nsresult (*nsUnregisterProc)(nsISupports* aServMgr, const char *path); + +#define NS_ICOMPONENTMANAGER_IID \ +{ /* 8458a740-d5dc-11d2-92fb-00e09805570f */ \ + 0x8458a740, \ + 0xd5dc, \ + 0x11d2, \ + {0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \ +} + +#define NS_COMPONENTMANAGER_CID \ +{ /* 91775d60-d5dc-11d2-92fb-00e09805570f */ \ + 0x91775d60, \ + 0xd5dc, \ + 0x11d2, \ + {0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \ +} + +/* + * nsIComponentManager interface + */ + +class nsIComponentManager : public nsISupports { +public: + + NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICOMPONENTMANAGER_IID) + + NS_IMETHOD FindFactory(const nsCID &aClass, + nsIFactory **aFactory) = 0; + + // Finds a class ID for a specific Program ID + NS_IMETHOD ProgIDToCLSID(const char *aProgID, + nsCID *aClass) = 0; + + // Finds a Program ID for a specific class ID + // caller frees the result with delete[] + NS_IMETHOD CLSIDToProgID(nsCID *aClass, + char* *aClassName, + char* *aProgID) = 0; + + // Creates a class instance for a specific class ID + NS_IMETHOD CreateInstance(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) = 0; + + // Convenience routine, creates a class instance for a specific ProgID + NS_IMETHOD CreateInstance(const char *aProgID, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) = 0; + + // Creates a class instance for a specific class ID + /* + NS_IMETHOD CreateInstance2(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void *aSignature, + void **aResult) = 0; + */ + + // Manually registry a factory for a class + NS_IMETHOD RegisterFactory(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory *aFactory, + PRBool aReplace) = 0; + + // Manually register a dynamically loaded component. + NS_IMETHOD RegisterComponent(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + const char *aLibrary, + PRBool aReplace, + PRBool aPersist) = 0; + + // Manually unregister a factory for a class + NS_IMETHOD UnregisterFactory(const nsCID &aClass, + nsIFactory *aFactory) = 0; + + // Manually unregister a dynamically loaded factory for a class + NS_IMETHOD UnregisterFactory(const nsCID &aClass, + const char *aLibrary) = 0; + + // Manually unregister a dynamically loaded component + NS_IMETHOD UnregisterComponent(const nsCID &aClass, + const char *aLibrary) = 0; + + // Unload dynamically loaded factories that are not in use + NS_IMETHOD FreeLibraries(void) = 0; + + ////////////////////////////////////////////////////////////////////////////// + // DLL registration support + /* Autoregistration will try only files with these extensions. + * All extensions are case insensitive. + * ".dll", // Windows + * ".dso", // Unix + * ".so", // Unix + * ".sl", // Unix: HP + * "_dll", // Mac + * ".dlm", // new for all platforms + */ + enum RegistrationTime { + NS_Startup = 0, + NS_Script = 1, + NS_Timer = 2 + }; + + NS_IMETHOD AutoRegister(RegistrationTime when, const char* pathlist) = 0; + // Pathlist is a semicolon separated list of pathnames + NS_IMETHOD AddToDefaultPathList(const char *pathlist) = 0; + NS_IMETHOD SyncComponentsInPathList(const char *pathlist) = 0; + NS_IMETHOD SyncComponentsInDir(const char *path) = 0; + NS_IMETHOD SyncComponentsInFile(const char *fullname) = 0; +}; + +//////////////////////////////////////////////////////////////////////////////// + +extern NS_COM nsresult +NS_GetGlobalComponentManager(nsIComponentManager* *result); + +//////////////////////////////////////////////////////////////////////////////// +// Global Static Component Manager Methods +// (for when you need to link with xpcom) + +class NS_COM nsComponentManager { +public: + static nsresult Initialize(void); + + // Finds a factory for a specific class ID + static nsresult FindFactory(const nsCID &aClass, + nsIFactory **aFactory); + + // Finds a class ID for a specific Program ID + static nsresult ProgIDToCLSID(const char *aProgID, + nsCID *aClass); + + // Finds a Program ID for a specific class ID + // caller frees the result with delete[] + static nsresult CLSIDToProgID(nsCID *aClass, + char* *aClassName, + char* *aProgID); + + // Creates a class instance for a specific class ID + static nsresult CreateInstance(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult); + + // Convenience routine, creates a class instance for a specific ProgID + static nsresult CreateInstance(const char *aProgID, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult); + + // Creates a class instance for a specific class ID + /* + static nsresult CreateInstance2(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void *aSignature, + void **aResult); + */ + + // Manually registry a factory for a class + static nsresult RegisterFactory(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory *aFactory, + PRBool aReplace); + + // Manually register a dynamically loaded component. + static nsresult RegisterComponent(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + const char *aLibrary, + PRBool aReplace, + PRBool aPersist); + + // Manually unregister a factory for a class + static nsresult UnregisterFactory(const nsCID &aClass, + nsIFactory *aFactory); + + // Manually unregister a dynamically loaded factory for a class + static nsresult UnregisterFactory(const nsCID &aClass, + const char *aLibrary); + + // Manually unregister a dynamically loaded component + static nsresult UnregisterComponent(const nsCID &aClass, + const char *aLibrary); + + // Unload dynamically loaded factories that are not in use + static nsresult FreeLibraries(void); + + ////////////////////////////////////////////////////////////////////////////// + // DLL registration support + static nsresult AutoRegister(nsIComponentManager::RegistrationTime when, + const char* pathlist); + // Pathlist is a semicolon separated list of pathnames + static nsresult AddToDefaultPathList(const char *pathlist); + static nsresult SyncComponentsInPathList(const char *pathlist); + static nsresult SyncComponentsInDir(const char *path); + static nsresult SyncComponentsInFile(const char *fullname); + +}; + +//////////////////////////////////////////////////////////////////////////////// + +#endif diff --git a/mozilla/xpcom/components/nsIFactory.h b/mozilla/xpcom/components/nsIFactory.h index a917b254119..5ed58f42a2c 100644 --- a/mozilla/xpcom/components/nsIFactory.h +++ b/mozilla/xpcom/components/nsIFactory.h @@ -22,18 +22,6 @@ #include "prtypes.h" #include "nsISupports.h" -/* - * Datatypes and helper macros - */ - -typedef nsID nsCID; - -// Define an CID -#define NS_DEFINE_CID(_name, _cidspec) \ - const nsCID _name = _cidspec - -#define REFNSCID const nsCID& - /* * nsIFactory interface */ diff --git a/mozilla/xpcom/components/nsIServiceManager.h b/mozilla/xpcom/components/nsIServiceManager.h index 09c23ca61f1..8d485659bef 100644 --- a/mozilla/xpcom/components/nsIServiceManager.h +++ b/mozilla/xpcom/components/nsIServiceManager.h @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -19,7 +19,8 @@ #ifndef nsIServiceManager_h___ #define nsIServiceManager_h___ -#include "nsRepository.h" +#include "nsISupports.h" +#include "nsID.h" class nsIShutdownListener; @@ -76,14 +77,15 @@ class nsIServiceManager : public nsISupports { public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISERVICEMANAGER_IID); - NS_IMETHOD - GetService(const nsCID& aClass, const nsIID& aIID, - nsISupports* *result, - nsIShutdownListener* shutdownListener = NULL) = 0; + /** + * RegisterService may be called explicitly to register a service + * with the service manager. If a service is not registered explicitly, + * the component manager will be used to create an instance according + * to the class ID specified. + */ NS_IMETHOD - ReleaseService(const nsCID& aClass, nsISupports* service, - nsIShutdownListener* shutdownListener = NULL) = 0; + RegisterService(const nsCID& aClass, nsISupports* aService) = 0; /** * Requests a service to be shut down, possibly unloading its DLL. @@ -96,24 +98,90 @@ public: * a shutdown listener. */ NS_IMETHOD - ShutdownService(const nsCID& aClass) = 0; + UnregisterService(const nsCID& aClass) = 0; + + NS_IMETHOD + GetService(const nsCID& aClass, const nsIID& aIID, + nsISupports* *result, + nsIShutdownListener* shutdownListener = NULL) = 0; + + NS_IMETHOD + ReleaseService(const nsCID& aClass, nsISupports* service, + nsIShutdownListener* shutdownListener = NULL) = 0; }; - #define NS_ERROR_SERVICE_NOT_FOUND NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM, 22) #define NS_ERROR_SERVICE_IN_USE NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM, 23) //////////////////////////////////////////////////////////////////////////////// +// nsService: Template to make using services easier. Now you can replace this: +// +// nsIMyService* service; +// rv = nsServiceManager::GetService(cid, iid, &service); +// if (NS_SUCCEEDED(rv)) { +// service->Doit(...); // use my service +// rv = nsServiceManager::ReleaseService(cid, service); +// } +// +// with this: +// +// nsService service(cid, &rv); +// if (NS_SUCCEEDED(rv)) { +// service->Doit(...); // use my service +// } +// +// and the automatic destructor will take care of releasing the service. + +template class nsService { +protected: + const nsCID mCID; + T* mService; -class nsIShutdownListener : public nsISupports { public: + nsService(nsISupports* aServMgr, const nsCID& aClass, nsresult *rv) + : mCID(aClass), mService(0) { + + nsIServiceManager* servMgr; + *rv = aServMgr->QueryInterface(nsIServiceManager::GetIID(), (void**)&servMgr); + if (NS_SUCCEEDED(*rv)) { + *rv = servMgr->GetService(aClass, T::GetIID(), (nsISupports**)&mService); + NS_RELEASE(servMgr); + } + NS_ASSERTION(NS_SUCCEEDED(*rv), "Couldn't get service."); + } - NS_IMETHOD - OnShutdown(const nsCID& aClass, nsISupports* service) = 0; + nsService(const nsCID& aClass, nsresult *rv) + : mCID(aClass), mService(0) { + *rv = nsServiceManager::GetService(aClass, T::GetIID(), + (nsISupports**)&mService); + NS_ASSERTION(NS_SUCCEEDED(*rv), "Couldn't get service."); + } + + ~nsService() { + if (mService) { // mService could be null if the constructor fails + nsresult rv = nsServiceManager::ReleaseService(mCID, mService); + NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't release service."); + } + } + + T* operator->() const { + NS_PRECONDITION(mService != 0, "Your code should test the error result from the constructor."); + return mService; + } + + PRBool operator==(const T* other) { + return mService == other; + } + + operator T*() const { + return mService; + } }; +//////////////////////////////////////////////////////////////////////////////// + #define NS_ISHUTDOWNLISTENER_IID \ { /* 56decae0-3406-11d2-8163-006008119d7a */ \ 0x56decae0, \ @@ -122,11 +190,26 @@ public: {0x81, 0x63, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \ } +class nsIShutdownListener : public nsISupports { +public: + + NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISHUTDOWNLISTENER_IID); + + NS_IMETHOD + OnShutdown(const nsCID& aClass, nsISupports* service) = 0; + +}; + //////////////////////////////////////////////////////////////////////////////// // Interface to Global Services class NS_COM nsServiceManager { public: + + static nsresult RegisterService(const nsCID& aClass, nsISupports* aService); + + static nsresult UnregisterService(const nsCID& aClass); + static nsresult GetService(const nsCID& aClass, const nsIID& aIID, nsISupports* *result, nsIShutdownListener* shutdownListener = NULL); @@ -134,17 +217,22 @@ public: static nsresult ReleaseService(const nsCID& aClass, nsISupports* service, nsIShutdownListener* shutdownListener = NULL); - static nsresult ShutdownService(const nsCID& aClass); - // Since the global Service Manager is truly global, there's no need to // release it. static nsresult GetGlobalServiceManager(nsIServiceManager* *result); protected: - static nsIServiceManager* globalServiceManager; + static nsIServiceManager* mGlobalServiceManager; }; +//////////////////////////////////////////////////////////////////////////////// +// NS_NewServiceManager: For when you want to create a service manager +// in a given context. + +extern NS_COM nsresult +NS_NewServiceManager(nsIServiceManager* *result); + //////////////////////////////////////////////////////////////////////////////// #endif /* nsIServiceManager_h___ */ diff --git a/mozilla/xpcom/components/nsRegistry.cpp b/mozilla/xpcom/components/nsRegistry.cpp index aed006362e9..ee6533ebcb2 100644 --- a/mozilla/xpcom/components/nsRegistry.cpp +++ b/mozilla/xpcom/components/nsRegistry.cpp @@ -1168,7 +1168,7 @@ nsRegistryFactory::LockFactory(PRBool aLock) } // This is a temporary hack; needs work to support dynamic binding -// via nsRepository and support for multiple factories per DLL. +// via nsComponentManager and support for multiple factories per DLL. extern "C" NS_EXPORT nsresult nsRegistry_GetFactory(const nsCID &cid, nsISupports* servMgr, nsIFactory** aFactory ) { nsresult rv = NS_OK; diff --git a/mozilla/xpcom/components/nsRepository.cpp b/mozilla/xpcom/components/nsRepository.cpp index 8c388156b76..6c8ba29f8a0 100644 --- a/mozilla/xpcom/components/nsRepository.cpp +++ b/mozilla/xpcom/components/nsRepository.cpp @@ -16,1962 +16,179 @@ * Reserved. */ -#include +#include "nsIComponentManager.h" -#ifndef XP_MAC -// including this on mac causes odd link errors in static initialization -// stuff that we (pinkerton & scc) don't yet understand. If you want to -// turn this on for mac, talk to one of us. -#include -#endif - -#ifdef XP_MAC -#include -#include -#include -#include -#endif - -#include "plstr.h" -#include "prlink.h" -#include "prsystem.h" -#include "prprf.h" -#include "nsRepository.h" - -/** - * When using the registry we put a version number in it. - * If the version number that is in the registry doesn't match - * the following, we ignore the registry. This lets news versions - * of the software deal with old formats of registry and not - * - * alpha0.20 : First time we did versioning - * alpha0.30 : Changing autoreg to begin registration from ./components on unix - */ -#define NS_XPCOM_REPOSITORY_VERSION_STRING "alpha0.33" - -#include "NSReg.h" - - -#if 0 -#ifdef XP_MAC -#ifdef MOZ_NGLAYOUT -#define IMPL_MAC_REPOSITORY -#include "nsMacRepository.h" -#endif -#endif -#endif - -#include "xcDllStore.h" -#include "nsIServiceManager.h" - -nsHashtable *nsRepository::factories = NULL; -nsHashtable *nsRepository::progIDs = NULL; -PRMonitor *nsRepository::monitor = NULL; - -/** - * dllStore - * - * The dllStore maintains a collection of dlls that are hashed by the dll - * name. The repository uses the DllStore only to store these dlls: - * - * 1. dlls that store components in them. - * The inmemory nsDll that is stored here always reflects the values of - * {lastModTime, fileSize} that are stored in the registry. - * It is the job of the autoregistration mechanism to do the right - * thing if the dll on disk is newer. - * 2. dlls that dont store components in them. - * This is for the purpose of the autoregistration mechanism only. - * These are marked in the registry too so that unless they change - * they wont have to loaded every session. - * - */ -nsDllStore *nsRepository::dllStore = NULL; - -static PRLogModuleInfo *logmodule = NULL; - -#if 0 -// Factory2 commented out until proven required -static NS_DEFINE_IID(kFactory2IID, NS_IFACTORY2_IID); -#endif /* 0 */ - -/***************************************************************************/ - -/** - * Class: FactoryEntry() - * - * There are two types of FactoryEntries. - * - * 1. {CID, dll} mapping. - * Factory is a consequence of the dll. These can be either session - * specific or persistent based on whether we write this - * to the registry or not. - * - * 2. {CID, factory} mapping - * These are strictly session specific and in memory only. - */ - -class FactoryEntry { -public: - nsCID cid; - nsIFactory *factory; - - FactoryEntry(const nsCID &aClass, const char *aLibrary, - PRTime lastModTime, PRUint32 fileSize); - FactoryEntry(const nsCID &aClass, nsIFactory *aFactory); - ~FactoryEntry(); - // DO NOT DELETE THIS. Many FactoryEntry(s) could be sharing the same Dll. - // This gets deleted from the dllStore going away. - nsDll *dll; - -}; - -FactoryEntry::FactoryEntry(const nsCID &aClass, const char *aLibrary, - PRTime lastModTime, PRUint32 fileSize) - : cid(aClass), factory(NULL), dll(NULL) +nsresult +nsComponentManager::Initialize(void) { - nsDllStore *dllCollection = nsRepository::dllStore; - - if (aLibrary == NULL) - { - return; - } - - // If dll not already in dllCollection, add it. - // PR_EnterMonitor(nsRepository::monitor); - dll = dllCollection->Get(aLibrary); - // PR_ExitMonitor(nsRepository::monitor); - - if (dll == NULL) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: New dll \"%s\".", aLibrary)); - - // Add a new Dll into the nsDllStore - dll = new nsDll(aLibrary, lastModTime, fileSize); - if (dll->GetStatus() != DLL_OK) - { - // Cant create a nsDll. Backoff. - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: New dll status error. \"%s\".", aLibrary)); - delete dll; - dll = NULL; - } - else - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: Adding New dll \"%s\" to dllStore.", - aLibrary)); - - // PR_EnterMonitor(nsRepository::monitor); - dllCollection->Put(aLibrary, dll); - // PR_ExitMonitor(nsRepository::monitor); - } - } - else - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: Found in dllStore \"%s\".", aLibrary)); - // XXX We found the dll in the dllCollection. - // XXX Consistency check: dll needs to have the same - // XXX lastModTime and fileSize. If not that would mean - // XXX that the dll wasn't registered properly. - } + return NS_OK; } - -FactoryEntry::FactoryEntry(const nsCID &aClass, nsIFactory *aFactory) - : cid(aClass), factory(aFactory), dll(NULL) +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); } - -FactoryEntry::~FactoryEntry(void) +nsresult +nsComponentManager::ProgIDToCLSID(const char *aProgID, + nsCID *aClass) { - if (factory != NULL) - { - factory->Release(); - } - // DO NOT DELETE nsDll *dll; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->ProgIDToCLSID(aProgID, aClass); } - -/***************************************************************************/ - -class ProgIDKey : public nsHashKey { -private: - char mProgIDBuf[64]; - char* mProgID; - -public: - ProgIDKey(const char* aProgID) : mProgID(mProgIDBuf) - { - PRInt32 len = PL_strlen(aProgID); - if (len >= sizeof(mProgIDBuf)) { - mProgID = new char[PL_strlen(aProgID) + 1]; - NS_ASSERTION(mProgID, "out of memory"); - if (! mProgID) - return; - } - - PL_strcpy(mProgID, aProgID); - } - - virtual ~ProgIDKey() { - if (mProgID != mProgIDBuf) - delete[] mProgID; - } - - virtual PRUint32 HashValue(void) const { - return (PRUint32) PL_HashString((const void*) mProgID); - } - - virtual PRBool Equals(const nsHashKey* aKey) const { - return PL_strcmp( ((ProgIDKey*)aKey)->mProgID, mProgID ) == 0; - } - - virtual nsHashKey* Clone() const { - return new ProgIDKey(mProgID); - } -}; - -/***************************************************************************/ - -#ifdef USE_NSREG -#define USE_REGISTRY - -/* - * platformDeleteKey() - * - * Deletes a key sub tree entirely. - */ -static nsresult platformDeleteKey(HREG hreg, RKEY rootkey, const char *keyname) + +nsresult +nsComponentManager::CLSIDToProgID(nsCID *aClass, + char* *aClassName, + char* *aProgID) { - RKEY key; - char subkeyname[MAXREGPATHLEN+1]; - int n = sizeof(subkeyname); - REGENUM state = 0; - - REGERR rerr = REGERR_OK; - - REGERR err = NR_RegGetKeyRaw(hreg, rootkey, (char *)keyname, &key); - if (err != REGERR_OK) - return (err); - - // Now recurse through and delete all keys under hierarchy - - subkeyname[0] = '\0'; - while (NR_RegEnumSubkeys(hreg, key, &state, subkeyname, n, REGENUM_NORMAL) == REGERR_OK) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: ...deleting %s", subkeyname)); - - rerr = platformDeleteKey(hreg, key, subkeyname); - - if (rerr != REGERR_OK) - { - break; - } - } - - // If success in deleting all subkeys, delete this key too - if (rerr == REGERR_OK) - { - err = NR_RegDeleteKeyRaw(hreg, rootkey, (char *)keyname); - } - else - { - err = rerr; - } - - return (err); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->CLSIDToProgID(aClass, aClassName, aProgID); } - - - -/** - * platformVersionCheck() - * - * Checks to see if the XPCOM hierarchy in the registry is the same as that of - * the software as defined by NS_XPCOM_REPOSITORY_VERSION_STRING - */ -static nsresult platformVersionCheck() + +nsresult +nsComponentManager::CreateInstance(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) { - HREG hreg; - REGERR err = NR_RegOpen(NULL, &hreg); - - if (err != REGERR_OK) - { - return (NS_ERROR_FAILURE); - } - - RKEY xpcomKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - char buf[MAXREGNAMELEN]; - uint32 len = sizeof(buf); - buf[0] = '\0'; - - err = NR_RegGetEntryString(hreg, xpcomKey, "VersionString", buf, len); - - // If there is a version mismatch or no version string, we got an old registry. - // Delete the old repository hierarchies and recreate version string - if (err != REGERR_OK || PL_strcmp(buf, NS_XPCOM_REPOSITORY_VERSION_STRING)) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: platformVersionCheck() failed. " - "Mismatch (%s vs %s). " - "Nuking xpcom registry hierarchy.", buf, NS_XPCOM_REPOSITORY_VERSION_STRING)); - - // Delete the XPCOM and CLSID hierarchy - RKEY akey; - NR_RegGetKey(hreg, ROOTKEY_COMMON, "Software/Netscape", &akey); - platformDeleteKey(hreg, akey, "XPCOM"); - NR_RegGetKey(hreg, ROOTKEY_COMMON, "Classes", &akey); - platformDeleteKey(hreg, akey, "Classes/CLSID"); - - // Recreate XPCOM and CLSID keys - NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey); - NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes/CLSID", NULL); - - NR_RegSetEntryString(hreg, xpcomKey, "VersionString", NS_XPCOM_REPOSITORY_VERSION_STRING); - } - else - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: platformVersionCheck() passed.")); - } - - NR_RegClose(hreg); - return (NS_OK); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->CreateInstance(aClass, aDelegate, aIID, aResult); } - -/** - * platformCreateDll(const char *fullname) - * - * Creates a nsDll from the registry representation of dll 'fullname'. - * Looks under - * ROOTKEY_COMMON/Software/Netscape/XPCOM/fullname - */ -static nsDll *platformCreateDll(const char *fullname) +nsresult +nsComponentManager::CreateInstance(const char *aProgID, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) { - HREG hreg; - REGERR err = NR_RegOpen(NULL, &hreg); - - if (err != REGERR_OK) - { - return (NULL); - } - - RKEY xpcomKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NULL); - } - - RKEY key; - err = NR_RegGetKeyRaw(hreg, xpcomKey, (char *)fullname, &key); - if (err != REGERR_OK) - { - return (NULL); - } - - PRTime lastModTime = LL_ZERO; - PRUint32 fileSize = 0; - uint32 n = sizeof(lastModTime); - NR_RegGetEntry(hreg, key, "LastModTimeStamp", &lastModTime, &n); - n = sizeof(fileSize); - NR_RegGetEntry(hreg, key, "FileSize", &fileSize, &n); - - nsDll *dll = new nsDll(fullname, lastModTime, fileSize); - - return (dll); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->CreateInstance(aProgID, aDelegate, aIID, aResult); } -/** - * platformMarkNoComponents(nsDll *dll) - * - * Stores the dll name, last modified time, size and 0 for number of - * components in dll in the registry at location - * ROOTKEY_COMMON/Software/Netscape/XPCOM/dllname - */ -static nsresult platformMarkNoComponents(nsDll *dll) +nsresult +nsComponentManager::RegisterFactory(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory *aFactory, + PRBool aReplace) { - HREG hreg; - REGERR err = NR_RegOpen(NULL, &hreg); - - if (err != REGERR_OK) - { - return (NS_ERROR_FAILURE); - } - - // XXX Gross. LongLongs dont have a serialization format. This makes - // XXX the registry non-xp. Someone beat on the nspr people to get - // XXX a longlong serialization function please! - RKEY xpcomKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - RKEY key; - err = NR_RegAddKeyRaw(hreg, xpcomKey, (char *)dll->GetFullPath(), &key); - - if (err != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - PRTime lastModTime = dll->GetLastModifiedTime(); - PRUint32 fileSize = dll->GetSize(); - - NR_RegSetEntry(hreg, key, "LastModTimeStamp", REGTYPE_ENTRY_BYTES, - &lastModTime, sizeof(lastModTime)); - NR_RegSetEntry(hreg, key, "FileSize", REGTYPE_ENTRY_BYTES, - &fileSize, sizeof(fileSize)); - - char *ncomponentsString = "0"; - - NR_RegSetEntryString(hreg, key, "ComponentsCount", - ncomponentsString); - - NR_RegClose(hreg); - return (NS_OK); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->RegisterFactory(aClass, aClassName, aProgID, + aFactory, aReplace); } -static nsresult platformRegister(NSQuickRegisterData regd, nsDll *dll) +nsresult +nsComponentManager::RegisterComponent(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + const char *aLibrary, + PRBool aReplace, + PRBool aPersist) { - HREG hreg; - // Preconditions - PR_ASSERT(regd != NULL); - PR_ASSERT(regd->CIDString != NULL); - PR_ASSERT(dll != NULL); - - REGERR err = NR_RegOpen(NULL, &hreg); - - if (err != REGERR_OK) - { - return (NS_ERROR_FAILURE); - } - - RKEY classesKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - RKEY key; - NR_RegAddKey(hreg, classesKey, "CLSID", &key); - NR_RegAddKeyRaw(hreg, key, (char *)regd->CIDString, &key); - - NR_RegSetEntryString(hreg, key, "ClassName", (char *)regd->className); - if (regd->progID) - NR_RegSetEntryString(hreg, key, "ProgID", (char *)(regd->progID)); - char *libName = (char *)dll->GetFullPath(); - NR_RegSetEntryString(hreg, key, "InprocServer", libName); - - if (regd->progID) - { - NR_RegAddKeyRaw(hreg, classesKey, (char *)regd->progID, &key); - NR_RegSetEntryString(hreg, key, "CLSID", (char *)regd->CIDString); - } - - // XXX Gross. LongLongs dont have a serialization format. This makes - // XXX the registry non-xp. Someone beat on the nspr people to get - // XXX a longlong serialization function please! - RKEY xpcomKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) - { - NR_RegClose(hreg); - // This aint a fatal error. It causes autoregistration to fail - // and hence the dll would be registered again the next time - // we startup. Let us run with it. - return (NS_OK); - } - - NR_RegAddKeyRaw(hreg, xpcomKey, (char *)dll->GetFullPath(), &key); - - PRTime lastModTime = dll->GetLastModifiedTime(); - PRUint32 fileSize = dll->GetSize(); - - NR_RegSetEntry(hreg, key, "LastModTimeStamp", REGTYPE_ENTRY_BYTES, - &lastModTime, sizeof(lastModTime)); - NR_RegSetEntry(hreg, key, "FileSize", REGTYPE_ENTRY_BYTES, - &fileSize, sizeof(fileSize)); - - unsigned int nComponents = 0; - char buf[MAXREGNAMELEN]; - uint32 len = sizeof(buf); - - if (NR_RegGetEntryString(hreg, key, "ComponentsCount", buf, len) == REGERR_OK) - { - nComponents = atoi(buf); - } - nComponents++; - PR_snprintf(buf, sizeof(buf), "%d", nComponents); - NR_RegSetEntryString(hreg, key, "ComponentsCount", buf); - - NR_RegClose(hreg); - return err; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->RegisterComponent(aClass, aClassName, aProgID, + aLibrary, aReplace, aPersist); } -static nsresult platformUnregister(NSQuickRegisterData regd, const char *aLibrary) -{ - HREG hreg; - REGERR err = NR_RegOpen(NULL, &hreg); - - if (err != REGERR_OK) - { - return (NS_ERROR_FAILURE); - } - - RKEY classesKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - RKEY key; - NR_RegAddKey(hreg, classesKey, "CLSID", &key); - RKEY cidKey; - NR_RegAddKeyRaw(hreg, key, (char *)regd->CIDString, &cidKey); - char progID[MAXREGNAMELEN]; - uint32 plen = sizeof(progID); - if (NR_RegGetEntryString(hreg, cidKey, "ProgID", progID, plen) == REGERR_OK) - { - NR_RegDeleteKey(hreg, classesKey, progID); - } - - NR_RegDeleteKey(hreg, key, (char *)regd->CIDString); - - RKEY xpcomKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) - { - NR_RegClose(hreg); - // This aint a fatal error. It causes autoregistration to fail - // and hence the dll would be registered again the next time - // we startup. Let us run with it. - return (NS_OK); - } - - NR_RegGetKeyRaw(hreg, xpcomKey, (char *)aLibrary, &key); - - // We need to reduce the ComponentCount by 1. - // If the ComponentCount hits 0, delete the entire key. - int nComponents = 0; - char buf[MAXREGNAMELEN]; - uint32 len = sizeof(buf); - - if (NR_RegGetEntryString(hreg, key, "ComponentsCount", buf, len) == REGERR_OK) - { - nComponents = atoi(buf); - nComponents--; - } - if (nComponents <= 0) - { - NR_RegDeleteKey(hreg, key, (char *)aLibrary); - } - else - { - PR_snprintf(buf, sizeof(buf), "%d", nComponents); - NR_RegSetEntryString(hreg, key, "ComponentsCount", buf); - } - - NR_RegClose(hreg); - return (NS_OK); -} - -static FactoryEntry *platformFind(const nsCID &aCID) +nsresult +nsComponentManager::UnregisterFactory(const nsCID &aClass, + nsIFactory *aFactory) { - HREG hreg; - REGERR err = NR_RegOpen(NULL, &hreg); - - if (err != REGERR_OK) - { - return (NULL); - } - - RKEY classesKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NULL); - } - - RKEY key; - NR_RegAddKey(hreg, classesKey, "CLSID", &key); - - FactoryEntry *res = NULL; - - RKEY cidKey; - char *cidString = aCID.ToString(); - err = NR_RegGetKeyRaw(hreg, key, cidString, &cidKey); - delete [] cidString; - - if (err != REGERR_OK) - { - NR_RegClose(hreg); - return (NULL); - } - - // Get the library name, modifiedtime and size - PRTime lastModTime = LL_ZERO; - PRUint32 fileSize = 0; - - char buf[MAXREGNAMELEN]; - uint32 len = sizeof(buf); - err = NR_RegGetEntryString(hreg, cidKey, "InprocServer", buf, len); - if (err != REGERR_OK) - { - // Registry inconsistent. No File name for CLSID. - NR_RegClose(hreg); - return (NULL); - } - - char *library = buf; - - // XXX Gross. LongLongs dont have a serialization format. This makes - // XXX the registry non-xp. Someone beat on the nspr people to get - // XXX a longlong serialization function please! - RKEY xpcomKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) == REGERR_OK) - { - if (NR_RegGetKeyRaw(hreg, xpcomKey, library, &key) == REGERR_OK) - { - uint32 n = sizeof(lastModTime); - NR_RegGetEntry(hreg, key, "LastModTimeStamp", &lastModTime, &n); - PR_ASSERT(n == sizeof(lastModTime)); - n = sizeof(fileSize); - NR_RegGetEntry(hreg, key, "FileSize", &fileSize, &n); - PR_ASSERT(n == sizeof(fileSize)); - } - } - - res = new FactoryEntry(aCID, library, lastModTime, fileSize); - - NR_RegClose(hreg); - - return (res); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->UnregisterFactory(aClass, aFactory); } - -static nsresult platformProgIDToCLSID(const char *aProgID, nsCID *aClass) +nsresult +nsComponentManager::UnregisterFactory(const nsCID &aClass, + const char *aLibrary) { - HREG hreg; - nsresult res = NS_ERROR_FAILURE; - - PR_ASSERT(aClass != NULL); - - REGERR err = NR_RegOpen(NULL, &hreg); - if (err != REGERR_OK) - { - return (NS_ERROR_FAILURE); - } - - RKEY classesKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - RKEY key; - err = NR_RegGetKeyRaw(hreg, classesKey, (char *)aProgID, &key); - if (err != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - char cidString[MAXREGNAMELEN]; - err = NR_RegGetEntryString(hreg, key, "CLSID", cidString, MAXREGNAMELEN); - if (err != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - NR_RegClose(hreg); - - if (!(aClass->Parse(cidString))) - { - return (NS_ERROR_FAILURE); - } - res = NS_OK; - return (res); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->UnregisterFactory(aClass, aLibrary); } -static nsresult platformCLSIDToProgID(nsCID *aClass, - char* *aClassName, char* *aProgID) +nsresult +nsComponentManager::UnregisterComponent(const nsCID &aClass, + const char *aLibrary) { - HREG hreg; - char* classnameString; - char* progidString; - nsresult res = NS_ERROR_FAILURE; - - char* cidStr = aClass->ToString(); - - PR_ASSERT(aClass != NULL); - - REGERR err = NR_RegOpen(NULL, &hreg); - if (err != REGERR_OK) - { - res = NS_ERROR_FAILURE; - goto done1; - } - - RKEY classesKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) - { - res = NS_ERROR_FAILURE; - goto done2; - } - - RKEY key; - err = NR_RegGetKeyRaw(hreg, classesKey, cidStr, &key); - if (err != REGERR_OK) - { - res = NS_ERROR_FAILURE; - goto done2; - } - - classnameString = new char[MAXREGNAMELEN]; - if (classnameString == NULL) { - res = NS_ERROR_OUT_OF_MEMORY; - goto done2; - } - err = NR_RegGetEntryString(hreg, key, "ClassName", classnameString, MAXREGNAMELEN); - if (err != REGERR_OK) - { - delete[] classnameString; - res = NS_ERROR_FAILURE; - goto done2; - } - *aClassName = classnameString; - - progidString = new char[MAXREGNAMELEN]; - if (progidString == NULL) { - delete[] classnameString; - res = NS_ERROR_OUT_OF_MEMORY; - goto done2; - } - err = NR_RegGetEntryString(hreg, key, "ProgID", progidString, MAXREGNAMELEN); - if (err != REGERR_OK) - { - delete[] progidString; - delete[] classnameString; - res = NS_ERROR_FAILURE; - goto done2; - } - - *aProgID = progidString; - res = NS_OK; - - done2: - NR_RegClose(hreg); - done1: - delete[] cidStr; - - return (res); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->UnregisterComponent(aClass, aLibrary); } -#endif // USE_NSREG - -/***************************************************************************/ - -/** - * LoadFactory() - * - * Given a FactoryEntry, this loads the dll if it has to, find the NSGetFactory - * symbol, calls the routine to create a new factory and returns it to the - * caller. - * - * No attempt is made to store the factory in any form anywhere. - */ -nsresult nsRepository::loadFactory(FactoryEntry *aEntry, - nsIFactory **aFactory) +nsresult +nsComponentManager::FreeLibraries(void) { - if (aFactory == NULL) - { - return NS_ERROR_NULL_POINTER; - } - *aFactory = NULL; - - // loadFactory() cannot be called for entries that are CID<->factory - // mapping entries for the session. - PR_ASSERT(aEntry->dll != NULL); - - if (aEntry->dll->IsLoaded() == PR_FALSE) - { - // Load the dll - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + Loading \"%s\".", aEntry->dll->GetFullPath())); - if (aEntry->dll->Load() == PR_FALSE) - { - PR_LOG(logmodule, PR_LOG_ERROR, - ("nsRepository: Library load unsuccessful.")); - return (NS_ERROR_FAILURE); - } - } - -#ifdef MOZ_TRACE_XPCOM_REFCNT - // Inform refcnt tracer of new library so that calls through the - // new library can be traced. - nsTraceRefcnt::LoadLibrarySymbols(aEntry->dll->GetFullPath(), aEntry->dll->GetInstance()); -#endif - nsFactoryProc proc = (nsFactoryProc) aEntry->dll->FindSymbol("NSGetFactory"); - if (proc != NULL) - { - char* className = NULL; - char* progID = NULL; - - // XXX dp, warren: deal with this! - //(void)CLSIDToProgID(&aEntry->cid, &className, &progID); - - nsIServiceManager* serviceMgr = NULL; - nsresult res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - NS_ASSERTION(NS_SUCCEEDED(res), "no service manager"); - - res = proc(serviceMgr, aEntry->cid, className, progID, aFactory); - - if (className) - delete[] className; - if (progID) - delete[] progID; - return res; - } - PR_LOG(logmodule, PR_LOG_ERROR, - ("nsRepository: NSGetFactory entrypoint not found.")); - return NS_ERROR_FACTORY_NOT_LOADED; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->FreeLibraries(); } - -/** - * FindFactory() - * - * Given a classID, this finds the factory for this CID by first searching the - * local CID<->factory mapping. Next it searches for a Dll that implements - * this classID and calls LoadFactory() to create the factory. - * - * Again, no attempt is made at storing the factory. - */ -nsresult nsRepository::FindFactory(const nsCID &aClass, - nsIFactory **aFactory) +nsresult +nsComponentManager::AutoRegister(nsIComponentManager::RegistrationTime when, + const char* pathlist) { - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: FindFactory(%s)", buf); - delete [] buf; - } - - PR_ASSERT(aFactory != NULL); - - PR_EnterMonitor(monitor); - - nsIDKey key(aClass); - FactoryEntry *entry = (FactoryEntry*) factories->Get(&key); - - nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; - -#ifdef USE_REGISTRY - if (entry == NULL) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, ("\t\tnot found in factory cache. Looking in registry")); - entry = platformFind(aClass); - - // XXX This should go into platformFind(), and platformFind() - // should just become a static method on nsRepository. - - // If we got one, cache it in our hashtable - if (entry != NULL) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, ("\t\tfound in registry.")); - factories->Put(&key, entry); - } - - // XXX update ProgID cache, if necessary - } - else - { - PR_LOG(logmodule, PR_LOG_ALWAYS, ("\t\tfound in factory cache.")); - } -#endif - - PR_ExitMonitor(monitor); - - if (entry != NULL) - { - if ((entry)->factory == NULL) - { - res = loadFactory(entry, aFactory); - } - else - { - *aFactory = entry->factory; - (*aFactory)->AddRef(); - res = NS_OK; - } - } - - PR_LOG(logmodule, PR_LOG_WARNING, - ("\t\tFindFactory() %s", - NS_SUCCEEDED(res) ? "succeeded" : "FAILED")); - - return res; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->AutoRegister(when, pathlist); } - -/** - * ProgIDToCLSID() - * - * Mapping function from a ProgID to a classID. Directly talks to the registry. - * - * XXX We need to add a cache this translation as this is done a lot. - */ -nsresult nsRepository::ProgIDToCLSID(const char *aProgID, - nsCID *aClass) +nsresult +nsComponentManager::AddToDefaultPathList(const char *pathlist) { - NS_PRECONDITION(aProgID != NULL, "null ptr"); - if (! aProgID) - return NS_ERROR_NULL_POINTER; - - NS_PRECONDITION(aClass != NULL, "null ptr"); - if (! aClass) - return NS_ERROR_NULL_POINTER; - - nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; - - checkInitialized(); - -#ifdef USE_REGISTRY - // XXX This isn't quite the best way to do this: we should - // probably move an nsArray into the FactoryEntry class, - // and then have the construct/destructor of the factory entry - // keep the ProgID to CID cache up-to-date. However, doing this - // significantly improves performance, so it'll do for now. - -#define NS_NO_CID { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } } -static NS_DEFINE_CID(kNoCID, NS_NO_CID); - - ProgIDKey key(aProgID); - nsCID* cid = (nsCID*) progIDs->Get(&key); - if (cid) { - if (cid == &kNoCID) { - // we've already tried to map this ProgID to a CLSID, and found - // that there _was_ no such mapping in the registry. - } - else { - *aClass = *cid; - res = NS_OK; - } - } - else { - // This is the first time someone has asked for this - // ProgID. Go to the registry to find the CID. - res = platformProgIDToCLSID(aProgID, aClass); - - if (NS_SUCCEEDED(res)) { - // Found it. So put it into the cache. - if (! (cid = new nsCID(*aClass))) - return NS_ERROR_OUT_OF_MEMORY; - - progIDs->Put(&key, cid); - } - else { - // Didn't find it. Put a special CID in the cache so we - // don't need to hit the registry on subsequent requests - // for the same ProgID. - progIDs->Put(&key, (void*) &kNoCID); - } - } -#endif /* USE_REGISTRY */ - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf; - if (NS_SUCCEEDED(res)) - buf = aClass->ToString(); - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: ProgIDToCLSID(%s)->%s", aProgID, - NS_SUCCEEDED(res) ? buf : "[FAILED]")); - if (NS_SUCCEEDED(res)) - delete [] buf; - } - - return res; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->AddToDefaultPathList(pathlist); } - -/** - * CLSIDToProgID() - * - * Translates a classID to a {ProgID, Class Name}. Does direct registry - * access to do the translation. - * - * XXX Would be nice to hook in a cache here too. - */ -nsresult nsRepository::CLSIDToProgID(nsCID *aClass, - char* *aClassName, - char* *aProgID) +nsresult +nsComponentManager::SyncComponentsInPathList(const char *pathlist) { - nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; - - checkInitialized(); - -#ifdef USE_REGISTRY - res = platformCLSIDToProgID(aClass, aClassName, aProgID); -#endif /* USE_REGISTRY */ - - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass->ToString(); - PR_LOG(logmodule, PR_LOG_WARNING, - ("nsRepository: CLSIDToProgID(%s)->%s", buf, - NS_SUCCEEDED(res) ? *aProgID : "[FAILED]")); - delete [] buf; - } - - return res; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->SyncComponentsInPathList(pathlist); } - -/** - * checkInitialized() - * - * Local function to make sure the repository is initialized. The repository - * is mostly full of static functions. We dont want to initialize ourselves - * with a static constructor as that wont make the code portable. Hence, - * in all our public entry points, we check if we are initialized and - * initialize ourselves if we aren't already. - */ -nsresult nsRepository::checkInitialized(void) +nsresult +nsComponentManager::SyncComponentsInDir(const char *path) { - nsresult res = NS_OK; - if (factories == NULL) - { - res = Initialize(); - } - return res; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->SyncComponentsInDir(path); } - -/** - * Initialize() - * - * Initialization of our global pointers. Also, the libreg/ is started here and - * if the xpcom hierarchy in the registry isn't the same as the version that we - * expect, it is nuked. - * - * XXX Plus for now autoregistration() begins here. We will remove it once the - * XXX application takes control of it. - */ -nsresult nsRepository::Initialize(void) +nsresult +nsComponentManager::SyncComponentsInFile(const char *fullname) { - if (factories == NULL) - { - factories = new nsHashtable(); - } - if (progIDs == NULL) - { - progIDs = new nsHashtable(); - } - if (monitor == NULL) - { - monitor = PR_NewMonitor(); - } - if (logmodule == NULL) - { - logmodule = PR_NewLogModule("nsRepository"); - } - if (dllStore == NULL) - { - dllStore = new nsDllStore(); - } - - PR_LOG(logmodule, PR_LOG_ALWAYS, ("nsRepository: Initialized.")); -#ifdef USE_NSREG - NR_StartupRegistry(); - - // Check the version of registry. Nuke old versions. - platformVersionCheck(); -#endif - - // Initiate autoreg - AutoRegister(NS_Startup, NULL); - - return NS_OK; -} - - -/** - * CreateInstance() - * - * Create an instance of an object that implements an interface and belongs - * to the implementation aClass using the factory. The factory is immediately - * released and not held onto for any longer. - */ -nsresult nsRepository::CreateInstance(const nsCID &aClass, - nsISupports *aDelegate, - const nsIID &aIID, - void **aResult) -{ - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: CreateInstance(%s)", buf); - delete [] buf; - } - if (aResult == NULL) - { - return NS_ERROR_NULL_POINTER; - } - *aResult = NULL; - - nsIFactory *factory = NULL; - nsresult res = FindFactory(aClass, &factory); - if (NS_SUCCEEDED(res)) - { - res = factory->CreateInstance(aDelegate, aIID, aResult); - factory->Release(); - PR_LOG(logmodule, PR_LOG_ALWAYS, ("\t\tCreateInstance() succeeded.")); - return res; - } - - PR_LOG(logmodule, PR_LOG_ALWAYS, ("\t\tCreateInstance() FAILED.")); - return NS_ERROR_FACTORY_NOT_REGISTERED; -} - - -/** - * CreateInstance() - * - * An overload of CreateInstance() that creates an instance of the object that - * implements the interface aIID and whose implementation has a progID aProgID. - * - * This is only a convenience routine that turns around can calls the - * CreateInstance() with classid and iid. - * - * XXX This is a function overload. We need to remove it. - */ -nsresult nsRepository::CreateInstance(const char *aProgID, - nsISupports *aDelegate, - const nsIID &aIID, - void **aResult) -{ - nsCID clsid; - nsresult rv = ProgIDToCLSID(aProgID, &clsid); - if (NS_FAILED(rv)) return rv; - return CreateInstance(clsid, aDelegate, aIID, aResult); -} - - -#if 0 -/* -nsresult nsRepository::CreateInstance2(const nsCID &aClass, - nsISupports *aDelegate, - const nsIID &aIID, - void *aSignature, - void **aResult) -{ - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: Creating Instance."); - PR_LogPrint("nsRepository: + %s.", - buf); - PR_LogPrint("nsRepository: + Signature = %p.", - aSignature); - delete [] buf; - } - if (aResult == NULL) - { - return NS_ERROR_NULL_POINTER; - } - *aResult = NULL; - - nsIFactory *factory = NULL; - - nsresult res = FindFactory(aClass, &factory); - - if (NS_SUCCEEDED(res)) - { - nsIFactory2 *factory2 = NULL; - res = NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT; - - factory->QueryInterface(kFactory2IID, (void **) &factory2); - - if (factory2 != NULL) - { - res = factory2->CreateInstance2(aDelegate, aIID, aSignature, aResult); - factory2->Release(); - } - - factory->Release(); - return res; - } - - return NS_ERROR_FACTORY_NOT_REGISTERED; -} -*/ -#endif /* 0 */ - - -/** - * RegisterFactory() - * - * Register a factory to be responsible for creation of implementation of - * classID aClass. Plus creates as association of aClassName and aProgID - * to the classID. If replace is PR_TRUE, we replace any existing registrations - * with this one. - * - * Once registration is complete, we add the class to the factories cache - * that we maintain. The factories cache is the ONLY place where these - * registrations are ever kept. - * - * XXX This uses FindFactory() to test if a factory already exists. This - * XXX has the bad side effect of loading the factory if the previous - * XXX registration was a dll for this class. We might be able to do away - * XXX with such a load. - */ -nsresult nsRepository::RegisterFactory(const nsCID &aClass, - const char *aClassName, - const char *aProgID, - nsIFactory *aFactory, - PRBool aReplace) -{ - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: RegisterFactory(%s, factory), replace = %d.", buf, (int)aReplace); - delete [] buf; - } - - nsIFactory *old = NULL; - FindFactory(aClass, &old); - - if (old != NULL) - { - old->Release(); - if (!aReplace) - { - PR_LOG(logmodule, PR_LOG_WARNING, ("\t\tFactory already registered.")); - return NS_ERROR_FACTORY_EXISTS; - } - else - { - PR_LOG(logmodule, PR_LOG_WARNING, ("\t\tdeleting old Factory Entry.")); - } - } - - PR_EnterMonitor(monitor); - - nsIDKey key(aClass); - factories->Put(&key, new FactoryEntry(aClass, aFactory)); - - // XXX update ProgID to CID cache as well, if necessary - - PR_ExitMonitor(monitor); - - PR_LOG(logmodule, PR_LOG_WARNING, - ("\t\tFactory register succeeded.")); - - return NS_OK; -} - - -nsresult nsRepository::RegisterComponent(const nsCID &aClass, - const char *aClassName, - const char *aProgID, - const char *aLibrary, - PRBool aReplace, - PRBool aPersist) -{ - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: RegisterComponent(%s, %s, %s, %s), replace = %d, persist = %d.", buf, aClassName, aProgID, aLibrary, (int)aReplace, (int)aPersist); - delete [] buf; - } - - nsIFactory *old = NULL; - FindFactory(aClass, &old); - - if (old != NULL) - { - old->Release(); - if (!aReplace) - { - PR_LOG(logmodule, PR_LOG_WARNING,("\t\tFactory already registered.")); - return NS_ERROR_FACTORY_EXISTS; - } - else - { - PR_LOG(logmodule, PR_LOG_WARNING,("\t\tdeleting registered Factory.")); - } - } - - PR_EnterMonitor(monitor); - -#ifdef USE_REGISTRY - if (aPersist == PR_TRUE) - { - // Add it to the registry - nsDll *dll = new nsDll(aLibrary); - // XXX temp hack until we get the dll to give us the entire - // XXX NSQuickRegisterClassData - NSQuickRegisterClassData cregd = {0}; - cregd.CIDString = aClass.ToString(); - cregd.className = aClassName; - cregd.progID = aProgID; - platformRegister(&cregd, dll); - delete [] (char *)cregd.CIDString; - delete dll; - } - else -#endif - { - nsDll *dll = new nsDll(aLibrary); - nsIDKey key(aClass); - factories->Put(&key, new FactoryEntry(aClass, aLibrary, - dll->GetLastModifiedTime(), dll->GetSize())); - - // XXX Update ProgID to CID cache as well, if necessary. - - delete dll; - } - - PR_ExitMonitor(monitor); - - PR_LOG(logmodule, PR_LOG_WARNING, - ("\t\tFactory register succeeded.")); - - return NS_OK; -} - - -nsresult nsRepository::UnregisterFactory(const nsCID &aClass, - nsIFactory *aFactory) -{ - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: Unregistering Factory."); - PR_LogPrint("nsRepository: + %s.", buf); - delete [] buf; - } - - - nsIDKey key(aClass); - nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; - FactoryEntry *old = (FactoryEntry *) factories->Get(&key); - if (old != NULL) - { - if (old->factory == aFactory) - { - PR_EnterMonitor(monitor); - old = (FactoryEntry *) factories->Remove(&key); - PR_ExitMonitor(monitor); - delete old; - res = NS_OK; - } - - } - - PR_LOG(logmodule, PR_LOG_WARNING, - ("nsRepository: ! Factory unregister %s.", - res == NS_OK ? "succeeded" : "failed")); - - return res; -} - - -nsresult nsRepository::UnregisterComponent(const nsCID &aClass, - const char *aLibrary) -{ - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: Unregistering Factory."); - PR_LogPrint("nsRepository: + %s in \"%s\".", buf, aLibrary); - delete [] buf; - } - - nsIDKey key(aClass); - FactoryEntry *old = (FactoryEntry *) factories->Get(&key); - - nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; - - PR_EnterMonitor(monitor); - - if (old != NULL && old->dll != NULL) - { - if (old->dll->GetFullPath() != NULL && -#ifdef XP_UNIX - PL_strcasecmp(old->dll->GetFullPath(), aLibrary) -#else - PL_strcmp(old->dll->GetFullPath(), aLibrary) -#endif - ) - { - FactoryEntry *entry = (FactoryEntry *) factories->Remove(&key); - delete entry; - res = NS_OK; - } -#ifdef USE_REGISTRY - // XXX temp hack until we get the dll to give us the entire - // XXX NSQuickRegisterClassData - NSQuickRegisterClassData cregd = {0}; - cregd.CIDString = aClass.ToString(); - res = platformUnregister(&cregd, aLibrary); - delete [] (char *)cregd.CIDString; -#endif - } - - PR_ExitMonitor(monitor); - - PR_LOG(logmodule, PR_LOG_WARNING, - ("nsRepository: ! Factory unregister %s.", - res == NS_OK ? "succeeded" : "failed")); - - return res; -} - - -nsresult nsRepository::UnregisterFactory(const nsCID &aClass, - const char *aLibrary) -{ - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: Unregistering Factory."); - PR_LogPrint("nsRepository: + %s in \"%s\".", buf, aLibrary); - delete [] buf; - } - - nsIDKey key(aClass); - FactoryEntry *old = (FactoryEntry *) factories->Get(&key); - - nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; - - PR_EnterMonitor(monitor); - - if (old != NULL && old->dll != NULL) - { - if (old->dll->GetFullPath() != NULL && -#ifdef XP_UNIX - PL_strcasecmp(old->dll->GetFullPath(), aLibrary) -#else - PL_strcmp(old->dll->GetFullPath(), aLibrary) -#endif - ) - { - FactoryEntry *entry = (FactoryEntry *) factories->Remove(&key); - delete entry; - res = NS_OK; - } -#ifdef USE_REGISTRY - // XXX temp hack until we get the dll to give us the entire - // XXX NSQuickRegisterClassData - NSQuickRegisterClassData cregd = {0}; - cregd.CIDString = aClass.ToString(); - res = platformUnregister(&cregd, aLibrary); - delete [] (char *)cregd.CIDString; -#endif - } - - PR_ExitMonitor(monitor); - - PR_LOG(logmodule, PR_LOG_WARNING, - ("nsRepository: ! Factory unregister %s.", - res == NS_OK ? "succeeded" : "failed")); - - return res; -} - - -static PRBool freeLibraryEnum(nsHashKey *aKey, void *aData, void* closure) -{ - FactoryEntry *entry = (FactoryEntry *) aData; - - if (entry->dll->IsLoaded() == PR_TRUE) - { - nsCanUnloadProc proc = (nsCanUnloadProc) entry->dll->FindSymbol("NSCanUnload"); - if (proc != NULL) - { - nsIServiceManager* serviceMgr = NULL; - nsresult res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - NS_ASSERTION(res == NS_OK, "no service manager"); - - res = proc(serviceMgr); - if (res) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + Unloading \"%s\".", entry->dll->GetFullPath())); - entry->dll->Unload(); - } - } - } - - return PR_TRUE; -} - -nsresult nsRepository::FreeLibraries(void) -{ - PR_EnterMonitor(monitor); - - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: Freeing Libraries.")); - factories->Enumerate(freeLibraryEnum); - - PR_ExitMonitor(monitor); - - return NS_OK; -} - - -/** - * AutoRegister(RegistrationInstant, const char *pathlist) - * - * Given a ; separated list of paths, this will ensure proper registration - * of all components. A default pathlist is maintained in the registry at - * \\HKEYROOT_COMMON\\Classes\\PathList - * In addition to looking at the pathlist, the default pathlist is looked at. - * - * This will take care not loading already registered dlls, finding and - * registering new dlls, re-registration of modified dlls - * - */ - -nsresult nsRepository::AutoRegister(NSRegistrationInstant when, - const char* pathlist) -{ -#ifdef XP_MAC - CInfoPBRec catInfo; - Handle pathH; - OSErr err; - ProcessSerialNumber psn; - ProcessInfoRec pInfo; - FSSpec appFSSpec; - FSSpec tempSpec; - long theDirID; - Str255 name; -#endif - - if (pathlist != NULL) - { - SyncComponentsInPathList(pathlist); - } - -#ifdef XP_MAC - // get info for the the current process to determine the directory its located in - if (!(err = GetCurrentProcess(&psn))) - { - // initialize ProcessInfoRec before calling GetProcessInformation() or die horribly. - pInfo.processName = nil; - pInfo.processAppSpec = &tempSpec; - pInfo.processInfoLength = sizeof(ProcessInfoRec); - if (!(err = GetProcessInformation(&psn, &pInfo))) - { - appFSSpec = *(pInfo.processAppSpec); - if ((pathH = NewHandle(1)) != NULL) - { - **pathH = '\0'; // initially null terminate the string - HNoPurge(pathH); - HUnlock(pathH); - theDirID = appFSSpec.parID; - do - { - catInfo.dirInfo.ioCompletion = NULL; - catInfo.dirInfo.ioNamePtr = (StringPtr)&name; - catInfo.dirInfo.ioVRefNum = appFSSpec.vRefNum; - catInfo.dirInfo.ioDrDirID = theDirID; - catInfo.dirInfo.ioFDirIndex = -1; // -1 = query dir in ioDrDirID - if (!(err = PBGetCatInfoSync(&catInfo))) - { - // build up a Unix style pathname due to NSPR - // XXX Note: this breaks if any of the parent - // directories contain a "slash" (blame NSPR) - - Munger(pathH, 0L, NULL, 0L, (const void *)&name[1], (long)name[0]); // prepend dir name - Munger(pathH, 0L, NULL, 0L, "/", 1); // prepend slash - - // move up to parent directory - theDirID = catInfo.dirInfo.ioDrParID; - } - } while ((!err) && (catInfo.dirInfo.ioDrDirID != 2)); // 2 = root - if (!err) - { - Munger(pathH, GetHandleSize(pathH)-1, NULL, 0L, "/components", 11); // append "/components" - HLock(pathH); - SyncComponentsInPathList((const char *)(*pathH)); - HUnlock(pathH); - } - DisposeHandle(pathH); - } - } - } -#else - //XXX get default pathlist from registry - //XXX Temporary hack. Registering components from components directory - const char *defaultPathList = "./components"; - SyncComponentsInPathList(defaultPathList); -#endif - return (NS_OK); -} - - -nsresult nsRepository::AddToDefaultPathList(const char *pathlist) -{ - //XXX add pathlist to the defaultpathlist in the registry - return (NS_ERROR_FAILURE); -} - -nsresult nsRepository::SyncComponentsInPathList(const char *pathlist) -{ - char *paths = PL_strdup(pathlist); - - if (paths == NULL || *paths == '\0') - return(NS_ERROR_FAILURE); - - char *pathsMem = paths; - while (paths != NULL) - { - char *nextpath = PL_strchr(paths, NS_PATH_SEPARATOR); - if (nextpath != NULL) *nextpath = '\0'; - SyncComponentsInDir(paths); - paths = nextpath; - } - PL_strfree(pathsMem); - return (NS_OK); -} - -nsresult nsRepository::SyncComponentsInDir(const char *dir) -{ - PRDir *prdir = PR_OpenDir(dir); - if (prdir == NULL) - return (NS_ERROR_FAILURE); - - // Create a buffer that has dir/ in it so we can append - // the filename each time in the loop - char fullname[NS_MAX_FILENAME_LEN]; - PL_strncpyz(fullname, dir, sizeof(fullname)); - unsigned int n = strlen(fullname); - if (n+1 < sizeof(fullname)) - { - fullname[n] = '/'; - n++; - } - char *filepart = fullname + n; - - PRDirEntry *dirent = NULL; - while ((dirent = PR_ReadDir(prdir, PR_SKIP_BOTH)) != NULL) - { - PL_strncpyz(filepart, dirent->name, sizeof(fullname)-n); - nsresult ret = SyncComponentsInFile(fullname); - if (NS_FAILED(ret) && - NS_ERROR_GET_CODE(ret) == NS_XPCOM_ERRORCODE_IS_DIR) - { - SyncComponentsInDir(fullname); - } - } // foreach file - PR_CloseDir(prdir); - return (NS_OK); -} - -nsresult nsRepository::SyncComponentsInFile(const char *fullname) -{ - const char *ValidDllExtensions[] = { - ".dll", /* Windows */ - ".dso", /* Unix */ - ".so", /* Unix */ - ".sl", /* Unix: HP */ - ".shlb", /* Mac ? */ - ".dlm", /* new for all platforms */ - NULL - }; - - - PRFileInfo statbuf; - if (PR_GetFileInfo(fullname,&statbuf) != PR_SUCCESS) - { - // Skip files that cannot be stat - return (NS_ERROR_FAILURE); - } - - if (statbuf.type == PR_FILE_DIRECTORY) - { - // Cant register a directory - return (NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, - NS_XPCOM_ERRORCODE_IS_DIR)); - } - else if (statbuf.type != PR_FILE_FILE) - { - // Skip non-files - return (NS_ERROR_FAILURE); - } - - // deal with only files that have the right extension - PRBool validExtension = PR_FALSE; - int flen = PL_strlen(fullname); - for (int i=0; ValidDllExtensions[i] != NULL; i++) - { - int extlen = PL_strlen(ValidDllExtensions[i]); - - // Does fullname end with this extension - if (flen >= extlen && - !PL_strcasecmp(&(fullname[flen - extlen]), ValidDllExtensions[i]) - ) - { - validExtension = PR_TRUE; - break; - } - } - - if (validExtension == PR_FALSE) - { - // Skip invalid extensions - return (NS_ERROR_FAILURE); - } - - // Check if dll is one that we have already seen - nsDll *dll = dllStore->Get(fullname); - if (dll == NULL) - { - // XXX Create nsDll for this from registry and - // XXX add it to our dll cache dllStore. -#ifdef USE_REGISTRY - dll = platformCreateDll(fullname); -#endif /* USE_REGISTRY */ - } - - if (dll != NULL) - { - // Make sure the dll is OK - if (dll->GetStatus() != NS_OK) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + nsDll not NS_OK \"%s\". Skipping...", - dll->GetFullPath())); - return (NS_ERROR_FAILURE); - } - - // We already have seen this dll. Check if this dll changed - if (LL_EQ(dll->GetLastModifiedTime(), statbuf.modifyTime) && - (dll->GetSize() == statbuf.size)) - { - // Dll hasn't changed. Skip. - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + nsDll not changed \"%s\". Skipping...", - dll->GetFullPath())); - return (NS_OK); - } - - // Aagh! the dll has changed since the last time we saw it. - // re-register dll - if (dll->IsLoaded()) - { - // We are screwed. We loaded the old version of the dll - // and now we find that the on-disk copy if newer. - // The only thing to do would be to ask the dll if it can - // unload itself. It can do that if it hasn't created objects - // yet. - nsCanUnloadProc proc = (nsCanUnloadProc) - dll->FindSymbol("NSCanUnload"); - if (proc != NULL) - { - nsIServiceManager* serviceMgr = NULL; - nsresult rv = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - NS_ASSERTION(rv == NS_OK, "no service manager"); - - PRBool res = proc(serviceMgr /*, PR_TRUE*/); - if (res) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + Unloading \"%s\".", - dll->GetFullPath())); - dll->Unload(); - } - else - { - // THIS IS THE WORST SITUATION TO BE IN. - // Dll doesn't want to be unloaded. Cannot re-register - // this dll. - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: *** Dll already loaded. " - "Cannot unload either. Hence cannot re-register " - "\"%s\". Skipping...", dll->GetFullPath())); - return (NS_ERROR_FAILURE); - } - } - else - { - // dll doesn't have a CanUnload proc. Guess it is - // ok to unload it. - dll->Unload(); - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + Unloading \"%s\". (no CanUnloadProc).", - dll->GetFullPath())); - - } - - } // dll isloaded - - // Sanity. - if (dll->IsLoaded()) - { - // We went through all the above to make sure the dll - // is unloaded. And here we are with the dll still - // loaded. Whoever taught dp programming... - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: Dll still loaded. Cannot re-register " - "\"%s\". Skipping...", dll->GetFullPath())); - return (NS_ERROR_FAILURE); - } - } // dll != NULL - else - { - // Create and add the dll to the dllStore - // It is ok to do this even if the creation of nsDll - // didnt succeed. That way we wont do this again - // when we encounter the same dll. - dll = new nsDll(fullname); - dllStore->Put(fullname, dll); - } // dll == NULL - - // Either we are seeing the dll for the first time or the dll has - // changed since we last saw it and it is unloaded successfully. - // - // Now we can try register the dll for sure. - nsresult res = SelfRegisterDll(dll); - nsresult ret = NS_OK; - if (NS_FAILED(res)) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: Autoregistration FAILED for " - "\"%s\". Skipping...", dll->GetFullPath())); - // Mark dll as not xpcom dll along with modified time and size in - // the registry so that we wont need to load the dll again every - // session until the dll changes. -#ifdef USE_REGISTRY - platformMarkNoComponents(dll); -#endif /* USE_REGISTRY */ - ret = NS_ERROR_FAILURE; - } - else - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: Autoregistration Passed for " - "\"%s\". Skipping...", dll->GetFullPath())); - // Marking dll along with modified time and size in the - // registry happens at platformregister(). No need to do it - // here again. - } - return (ret); -} - - -/* -* SelfRegisterDll -* -* Given a dll abstraction, this will load, selfregister the dll and -* unload the dll. -* -*/ -nsresult nsRepository::SelfRegisterDll(nsDll *dll) -{ - // Precondition: dll is not loaded already - PR_ASSERT(dll->IsLoaded() == PR_FALSE); - - nsresult res = NS_ERROR_FAILURE; - - if (dll->Load() == PR_FALSE) - { - // Cannot load. Probably not a dll. - return(NS_ERROR_FAILURE); - } - - nsRegisterProc regproc = (nsRegisterProc)dll->FindSymbol("NSRegisterSelf"); - - if (regproc == NULL) - { - // Smart registration - NSQuickRegisterData qr = (NSQuickRegisterData)dll->FindSymbol( - NS_QUICKREGISTER_DATA_SYMBOL); - if (qr == NULL) - { - res = NS_ERROR_NO_INTERFACE; - } - else - { - // XXX register the quick registration data on behalf of the dll - // XXX for now return failure - res = NS_ERROR_FAILURE; - } - } - else - { - // Call the NSRegisterSelfProc to enable dll registration - nsIServiceManager* serviceMgr = NULL; - res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - NS_ASSERTION(res == NS_OK, "no service manager"); - - res = regproc(serviceMgr, dll->GetFullPath()); - } - dll->Unload(); - return (res); -} - - -nsresult nsRepository::SelfUnregisterDll(nsDll *dll) -{ - // Precondition: dll is not loaded - PR_ASSERT(dll->IsLoaded() == PR_FALSE); - - if (dll->Load() == PR_FALSE) - { - // Cannot load. Probably not a dll. - return(NS_ERROR_FAILURE); - } - - nsUnregisterProc unregproc = - (nsUnregisterProc) dll->FindSymbol("NSUnregisterSelf"); - nsresult res = NS_OK; - - if (unregproc == NULL) - { - // Smart unregistration - NSQuickRegisterData qr = (NSQuickRegisterData) - dll->FindSymbol(NS_QUICKREGISTER_DATA_SYMBOL); - if (qr == NULL) - { - return(NS_ERROR_NO_INTERFACE); - } - // XXX unregister the dll based on the quick registration data - } - else - { - // Call the NSUnregisterSelfProc to enable dll de-registration - nsIServiceManager* serviceMgr = NULL; - res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - NS_ASSERTION(res == NS_OK, "no service manager"); - - res = unregproc(serviceMgr, dll->GetFullPath()); - } - dll->Unload(); - return (res); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->SyncComponentsInFile(fullname); } diff --git a/mozilla/xpcom/components/nsRepository.h b/mozilla/xpcom/components/nsRepository.h index 6da2215491c..3979c2c0c75 100644 --- a/mozilla/xpcom/components/nsRepository.h +++ b/mozilla/xpcom/components/nsRepository.h @@ -19,211 +19,10 @@ #ifndef __nsRespository_h #define __nsRespository_h -#include "prtypes.h" -#include "prlog.h" -#include "prmon.h" -#include "nsCom.h" -#include "nsID.h" -#include "nsError.h" -#include "nsISupports.h" -#include "nsIFactory.h" -#include "nsHashtable.h" +#include "nsIComponentManager.h" -/* - * Prototypes for dynamic library export functions - */ +// XXX nsRepository is obsolete! Use nsComponentManager now! -class nsIServiceManager; - - -//*********************************************************** -// -// NSGetFactory should take nsISupports instead of nsIServiceManager -// as the second param. This is done on purpose!! Please don't change -// it. -// sudu / stanley -// -//*********************************************************** -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, - const nsCID &aClass, - const char *aClassName, - const char *aProgID, - nsIFactory **aFactory); -extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr); -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *fullpath); -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *fullpath); - -/* - *** Quick Registration NOT FOR PUBLIC CONSUMPTION YET *** - * - * Quick Registration - * - * For quick registration, dlls can define - * NSQuickRegisterClassData g_NSQuickRegisterData[]; - * and export the symbol "g_NSQuickRegisterData" - * - * Quick registration is tried only if the symbol "NSRegisterSelf" - * is not found. If it is found but fails registration, quick registration - * will not kick in. - * - * The array is terminated by having a NULL last element. Specifically, the - * array will be assumed to end when - * (g_NSQuickRegisterData[i].classIdStr == NULL) - * - */ -#define NS_QUICKREGISTER_DATA_SYMBOL "g_NSQuickRegisterData" - -typedef struct NSQuickRegisterClassData { - const char *CIDString; // {98765-8776-8958758759-958785} - const char *className; // "Layout Engine" - const char *progID; // "Gecko.LayoutEngine.1" -} NSQuickRegisterClassData; - -typedef NSQuickRegisterClassData* NSQuickRegisterData; - -/* Autoregistration will try only files with these extensions. - * All extensions are case insensitive. - ".dll", // Windows - ".dso", // Unix - ".so", // Unix - ".sl", // Unix: HP - "_dll", // Mac - ".dlm", // new for all platforms -*/ - -/* - * Dynamic library export function types - */ - -typedef nsresult (*nsFactoryProc)(nsISupports* serviceMgr, - const nsCID &aClass, - const char *aClassName, - const char *aProgID, - nsIFactory **aFactory); -typedef PRBool (*nsCanUnloadProc)(nsISupports* serviceMgr); -typedef nsresult (*nsRegisterProc)(nsISupports* serviceMgr, const char *path); -typedef nsresult (*nsUnregisterProc)(nsISupports* serviceMgr, const char *path); - -/* - * Support types - */ - -class FactoryEntry; -class nsDllStore; -class nsDll; - -enum NSRegistrationInstant -{ - NS_Startup = 0, - NS_Script = 1, - NS_Timer = 2 -}; - -/* Error codes generated by the repository methods */ - -#define NS_XPCOM_ERRORCODE_IS_DIR 1 - -/* The separator for each path part in the pathlist for autoregistration */ - -#define NS_PATH_SEPARATOR ';' - - -/* - * nsRepository class - */ - -class NS_COM nsRepository { -private: - -#define NS_MAX_FILENAME_LEN 1024 - - static nsHashtable *factories; - static nsHashtable *progIDs; - static PRMonitor *monitor; - - static nsresult checkInitialized(void); - static nsresult loadFactory(FactoryEntry *aEntry, nsIFactory **aFactory); - static nsresult SelfRegisterDll(nsDll *dll); - static nsresult SelfUnregisterDll(nsDll *dll); - -public: - static nsDllStore *dllStore; - - static nsresult Initialize(void); - // Finds a factory for a specific class ID - static nsresult FindFactory(const nsCID &aClass, - nsIFactory **aFactory); - - // Finds a class ID for a specific Program ID - static nsresult ProgIDToCLSID(const char *aProgID, - nsCID *aClass); - - // Finds a Program ID for a specific class ID - // caller frees the result with delete[] - static nsresult CLSIDToProgID(nsCID *aClass, - char* *aClassName, - char* *aProgID); - - // Creates a class instance for a specific class ID - static nsresult CreateInstance(const nsCID &aClass, - nsISupports *aDelegate, - const nsIID &aIID, - void **aResult); - - // Convenience routine, creates a class instance for a specific ProgID - static nsresult CreateInstance(const char *aProgID, - nsISupports *aDelegate, - const nsIID &aIID, - void **aResult); - - // Creates a class instance for a specific class ID - /* - static nsresult CreateInstance2(const nsCID &aClass, - nsISupports *aDelegate, - const nsIID &aIID, - void *aSignature, - void **aResult); - */ - - // Manually registry a factory for a class - static nsresult RegisterFactory(const nsCID &aClass, - const char *aClassName, - const char *aProgID, - nsIFactory *aFactory, - PRBool aReplace); - - // Manually register a dynamically loaded component. - static nsresult RegisterComponent(const nsCID &aClass, - const char *aClassName, - const char *aProgID, - const char *aLibrary, - PRBool aReplace, - PRBool aPersist); - - // Manually unregister a factory for a class - static nsresult UnregisterFactory(const nsCID &aClass, - nsIFactory *aFactory); - - // Manually unregister a dynamically loaded factory for a class - static nsresult UnregisterFactory(const nsCID &aClass, - const char *aLibrary); - - // Manually unregister a dynamically loaded component - static nsresult UnregisterComponent(const nsCID &aClass, - const char *aLibrary); - - // Unload dynamically loaded factories that are not in use - static nsresult FreeLibraries(void); - - // DLL registration support - static nsresult AutoRegister(NSRegistrationInstant when, - const char* pathlist); - // Pathlist is a semicolon separated list of pathnames - static nsresult AddToDefaultPathList(const char *pathlist); - static nsresult SyncComponentsInPathList(const char *pathlist); - static nsresult SyncComponentsInDir(const char *path); - static nsresult SyncComponentsInFile(const char *fullname); - -}; +#define nsRepository nsComponentManager #endif diff --git a/mozilla/xpcom/components/nsServiceManager.cpp b/mozilla/xpcom/components/nsServiceManager.cpp index 26d3fdaa264..fec1cf67aa9 100644 --- a/mozilla/xpcom/components/nsServiceManager.cpp +++ b/mozilla/xpcom/components/nsServiceManager.cpp @@ -17,10 +17,14 @@ */ #include "nsIServiceManager.h" +#include "nsIComponentManager.h" #include "nsVector.h" +#include "nsHashtable.h" #include "prcmon.h" #include "prthread.h" /* XXX: only used for the NSPR initialization hack (rick) */ +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); + class nsServiceEntry { public: @@ -51,7 +55,7 @@ nsServiceEntry::~nsServiceEntry() PRUint32 size = mListeners->GetSize(); for (PRUint32 i = 0; i < size; i++) { nsIShutdownListener* listener = (nsIShutdownListener*)(*mListeners)[i]; - listener->Release(); + NS_RELEASE(listener); } #endif delete mListeners; @@ -68,9 +72,9 @@ nsServiceEntry::AddListener(nsIShutdownListener* listener) if (mListeners == NULL) return NS_ERROR_OUT_OF_MEMORY; } - PRInt32 err = mListeners->Add(listener); - listener->AddRef(); - return err == -1 ? NS_ERROR_FAILURE : NS_OK; + PRInt32 rv = mListeners->Add(listener); + NS_ADDREF(listener); + return rv == -1 ? NS_ERROR_FAILURE : NS_OK; } nsresult @@ -83,7 +87,7 @@ nsServiceEntry::RemoveListener(nsIShutdownListener* listener) for (PRUint32 i = 0; i < size; i++) { if ((*mListeners)[i] == listener) { mListeners->Remove(i); - listener->Release(); + NS_RELEASE(listener); return NS_OK; } } @@ -98,9 +102,9 @@ nsServiceEntry::NotifyListeners(void) PRUint32 size = mListeners->GetSize(); for (PRUint32 i = 0; i < size; i++) { nsIShutdownListener* listener = (nsIShutdownListener*)(*mListeners)[0]; - nsresult err = listener->OnShutdown(mClassID, mService); - if (err) return err; - listener->Release(); + nsresult rv = listener->OnShutdown(mClassID, mService); + if (NS_FAILED(rv)) return rv; + NS_RELEASE(listener); mListeners->Remove(0); } NS_ASSERTION(mListeners->GetSize() == 0, "failed to notify all listeners"); @@ -115,6 +119,12 @@ nsServiceEntry::NotifyListeners(void) class nsServiceManagerImpl : public nsIServiceManager { public: + NS_IMETHOD + RegisterService(const nsCID& aClass, nsISupports* aService); + + NS_IMETHOD + UnregisterService(const nsCID& aClass); + NS_IMETHOD GetService(const nsCID& aClass, const nsIID& aIID, nsISupports* *result, @@ -124,18 +134,15 @@ public: ReleaseService(const nsCID& aClass, nsISupports* service, nsIShutdownListener* shutdownListener = NULL); - NS_IMETHOD - ShutdownService(const nsCID& aClass); - nsServiceManagerImpl(void); - + NS_DECL_ISUPPORTS protected: virtual ~nsServiceManagerImpl(void); - nsHashtable* mServices; // nsHashtable + nsHashtable/**/* mServices; }; nsServiceManagerImpl::nsServiceManagerImpl(void) @@ -149,15 +156,17 @@ static PRBool DeleteEntry(nsHashKey *aKey, void *aData, void* closure) { nsServiceEntry* entry = (nsServiceEntry*)aData; - entry->mService->Release(); + NS_RELEASE(entry->mService); delete entry; return PR_TRUE; } nsServiceManagerImpl::~nsServiceManagerImpl(void) { - mServices->Enumerate(DeleteEntry); - delete mServices; + if (mServices) { + mServices->Enumerate(DeleteEntry); + delete mServices; + } } static NS_DEFINE_IID(kIServiceManagerIID, NS_ISERVICEMANAGER_IID); @@ -166,7 +175,7 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); NS_IMPL_ADDREF(nsServiceManagerImpl); NS_IMPL_RELEASE(nsServiceManagerImpl); -nsresult +NS_IMETHODIMP nsServiceManagerImpl::QueryInterface(const nsIID& aIID, void* *aInstancePtr) { if (NULL == aInstancePtr) { @@ -182,12 +191,12 @@ nsServiceManagerImpl::QueryInterface(const nsIID& aIID, void* *aInstancePtr) return NS_NOINTERFACE; } -nsresult +NS_IMETHODIMP nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, nsISupports* *result, nsIShutdownListener* shutdownListener) { - nsresult err = NS_OK; + nsresult rv = NS_OK; /* XXX: This is a hack to force NSPR initialization.. This should be * removed once PR_CEnterMonitor(...) initializes NSPR... (rick) */ @@ -199,10 +208,10 @@ nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, if (entry) { nsISupports* service; - err = entry->mService->QueryInterface(aIID, (void**)&service); - if (err == NS_OK) { - err = entry->AddListener(shutdownListener); - if (err == NS_OK) { + rv = entry->mService->QueryInterface(aIID, (void**)&service); + if (NS_SUCCEEDED(rv)) { + rv = entry->AddListener(shutdownListener); + if (NS_SUCCEEDED(rv)) { *result = service; // If someone else requested the service to be shut down, @@ -210,29 +219,29 @@ nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, // released, then cancel their shutdown request: if (entry->mShuttingDown) { entry->mShuttingDown = PR_FALSE; - service->AddRef(); // Released in ShutdownService + NS_ADDREF(service); // Released in UnregisterService } } } } else { nsISupports* service; - err = nsRepository::CreateInstance(aClass, NULL, aIID, (void**)&service); - if (err == NS_OK) { + rv = nsComponentManager::CreateInstance(aClass, NULL, aIID, (void**)&service); + if (NS_SUCCEEDED(rv)) { entry = new nsServiceEntry(aClass, service); if (entry == NULL) { - service->Release(); - err = NS_ERROR_OUT_OF_MEMORY; + NS_RELEASE(service); + rv = NS_ERROR_OUT_OF_MEMORY; } else { - err = entry->AddListener(shutdownListener); - if (err == NS_OK) { + rv = entry->AddListener(shutdownListener); + if (NS_SUCCEEDED(rv)) { mServices->Put(&key, entry); *result = service; - service->AddRef(); // Released in ShutdownService + NS_ADDREF(service); // Released in UnregisterService } else { - service->Release(); + NS_RELEASE(service); delete entry; } } @@ -240,14 +249,14 @@ nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, } PR_CExitMonitor(this); - return err; + return rv; } -nsresult +NS_IMETHODIMP nsServiceManagerImpl::ReleaseService(const nsCID& aClass, nsISupports* service, nsIShutdownListener* shutdownListener) { - nsresult err = NS_OK; + nsresult rv = NS_OK; PR_CEnterMonitor(this); nsIDKey key(aClass); @@ -257,63 +266,117 @@ nsServiceManagerImpl::ReleaseService(const nsCID& aClass, nsISupports* service, NS_ASSERTION(entry->mService == service, "service looked failed"); if (entry) { - err = entry->RemoveListener(shutdownListener); - nsrefcnt cnt = service->Release(); - if (err == NS_OK && cnt == 0) { + rv = entry->RemoveListener(shutdownListener); + nsrefcnt cnt; + NS_RELEASE2(service, cnt); + if (NS_SUCCEEDED(rv) && cnt == 0) { mServices->Remove(&key); delete entry; - err = nsRepository::FreeLibraries(); + rv = nsComponentManager::FreeLibraries(); } } PR_CExitMonitor(this); - return err; + return rv; } -nsresult -nsServiceManagerImpl::ShutdownService(const nsCID& aClass) +NS_IMETHODIMP +nsServiceManagerImpl::RegisterService(const nsCID& aClass, nsISupports* aService) { - nsresult err = NS_OK; + nsresult rv = NS_OK; + PR_CEnterMonitor(this); + + nsIDKey key(aClass); + nsServiceEntry* entry = (nsServiceEntry*)mServices->Get(&key); + if (entry) { + rv = NS_ERROR_FAILURE; + } + else { + nsServiceEntry* entry = new nsServiceEntry(aClass, aService); + if (entry == NULL) + rv = NS_ERROR_OUT_OF_MEMORY; + else { + mServices->Put(&key, entry); + NS_ADDREF(aService); // Released in UnregisterService + } + } + PR_CExitMonitor(this); + return rv; +} + +NS_IMETHODIMP +nsServiceManagerImpl::UnregisterService(const nsCID& aClass) +{ + nsresult rv = NS_OK; PR_CEnterMonitor(this); nsIDKey key(aClass); nsServiceEntry* entry = (nsServiceEntry*)mServices->Get(&key); if (entry == NULL) { - err = NS_ERROR_SERVICE_NOT_FOUND; + rv = NS_ERROR_SERVICE_NOT_FOUND; } else { - err = entry->NotifyListeners(); // break the cycles + rv = entry->NotifyListeners(); // break the cycles entry->mShuttingDown = PR_TRUE; - nsrefcnt cnt = entry->mService->Release(); // AddRef in GetService - if (err == NS_OK && cnt == 0) { + nsrefcnt cnt; + NS_RELEASE2(entry->mService, cnt); // AddRef in GetService + if (NS_SUCCEEDED(rv) && cnt == 0) { mServices->Remove(&key); delete entry; - err = nsRepository::FreeLibraries(); + rv = nsComponentManager::FreeLibraries(); } else - err = NS_ERROR_SERVICE_IN_USE; + rv = NS_ERROR_SERVICE_IN_USE; } PR_CExitMonitor(this); - return err; + return rv; +} + +//////////////////////////////////////////////////////////////////////////////// + +nsresult +NS_NewServiceManager(nsIServiceManager* *result) +{ + nsServiceManagerImpl* servMgr = new nsServiceManagerImpl(); + if (servMgr == NULL) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(servMgr); + *result = servMgr; + return NS_OK; } //////////////////////////////////////////////////////////////////////////////// // Global service manager interface (see nsIServiceManager.h) -nsIServiceManager* nsServiceManager::globalServiceManager = NULL; +nsIServiceManager* nsServiceManager::mGlobalServiceManager = NULL; nsresult nsServiceManager::GetGlobalServiceManager(nsIServiceManager* *result) { - if (globalServiceManager == NULL) { - globalServiceManager = new nsServiceManagerImpl(); - if (globalServiceManager == NULL) - return NS_ERROR_OUT_OF_MEMORY; - globalServiceManager->AddRef(); + if (mGlobalServiceManager == NULL) { + nsIServiceManager* servMgr; + nsresult rv = NS_NewServiceManager(&servMgr); + if (NS_FAILED(rv)) return rv; + + // The global service manager always has a global component manager service: + nsIComponentManager* compMgr; + rv = NS_GetGlobalComponentManager(&compMgr); + if (NS_FAILED(rv)) { + NS_RELEASE(servMgr); + return rv; + } + rv = servMgr->RegisterService(kComponentManagerCID, compMgr); + if (NS_FAILED(rv)) { + NS_RELEASE(servMgr); + return rv; + } + + mGlobalServiceManager = servMgr; } - *result = globalServiceManager; + + *result = mGlobalServiceManager; return NS_OK; } @@ -323,8 +386,8 @@ nsServiceManager::GetService(const nsCID& aClass, const nsIID& aIID, nsIShutdownListener* shutdownListener) { nsIServiceManager* mgr; - nsresult rslt = GetGlobalServiceManager(&mgr); - if (rslt != NS_OK) return rslt; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; return mgr->GetService(aClass, aIID, result, shutdownListener); } @@ -333,18 +396,27 @@ nsServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service, nsIShutdownListener* shutdownListener) { nsIServiceManager* mgr; - nsresult rslt = GetGlobalServiceManager(&mgr); - if (rslt != NS_OK) return rslt; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; return mgr->ReleaseService(aClass, service, shutdownListener); } nsresult -nsServiceManager::ShutdownService(const nsCID& aClass) +nsServiceManager::RegisterService(const nsCID& aClass, nsISupports* aService) { nsIServiceManager* mgr; - nsresult rslt = GetGlobalServiceManager(&mgr); - if (rslt != NS_OK) return rslt; - return mgr->ShutdownService(aClass); + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; + return mgr->RegisterService(aClass, aService); +} + +nsresult +nsServiceManager::UnregisterService(const nsCID& aClass) +{ + nsIServiceManager* mgr; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; + return mgr->UnregisterService(aClass); } //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/xpcom/ds/nsHashtable.h b/mozilla/xpcom/ds/nsHashtable.h index 17c2821a655..11509df3231 100644 --- a/mozilla/xpcom/ds/nsHashtable.h +++ b/mozilla/xpcom/ds/nsHashtable.h @@ -61,29 +61,29 @@ public: class nsISupportsKey : public nsHashKey { private: - nsISupports* mKey; + nsISupports* mKey; public: - nsISupportsKey(nsISupports* key) { - mKey = key; - NS_IF_ADDREF(mKey); - } + nsISupportsKey(nsISupports* key) { + mKey = key; + NS_IF_ADDREF(mKey); + } - ~nsISupportsKey(void) { - NS_IF_RELEASE(mKey); - } + ~nsISupportsKey(void) { + NS_IF_RELEASE(mKey); + } - PRUint32 HashValue(void) const { - return (PRUint32)mKey; - } + PRUint32 HashValue(void) const { + return (PRUint32)mKey; + } - PRBool Equals(const nsHashKey *aKey) const { - return (mKey == ((nsISupportsKey *) aKey)->mKey); - } + PRBool Equals(const nsHashKey *aKey) const { + return (mKey == ((nsISupportsKey *) aKey)->mKey); + } - nsHashKey *Clone(void) const { - return new nsISupportsKey(mKey); - } + nsHashKey *Clone(void) const { + return new nsISupportsKey(mKey); + } }; //////////////////////////////////////////////////////////////////////////////// @@ -91,24 +91,24 @@ public: class nsVoidKey : public nsHashKey { private: - const void* mKey; + const void* mKey; public: - nsVoidKey(const void* key) { - mKey = key; - } + nsVoidKey(const void* key) { + mKey = key; + } - PRUint32 HashValue(void) const { - return (PRUint32)mKey; - } + PRUint32 HashValue(void) const { + return (PRUint32)mKey; + } - PRBool Equals(const nsHashKey *aKey) const { - return (mKey == ((const nsVoidKey *) aKey)->mKey); - } + PRBool Equals(const nsHashKey *aKey) const { + return (mKey == ((const nsVoidKey *) aKey)->mKey); + } - nsHashKey *Clone(void) const { - return new nsVoidKey(mKey); - } + nsHashKey *Clone(void) const { + return new nsVoidKey(mKey); + } }; //////////////////////////////////////////////////////////////////////////////// @@ -118,24 +118,65 @@ public: class nsIDKey : public nsHashKey { private: - nsID mID; + nsID mID; public: - nsIDKey(const nsID &aID) { - mID = aID; - } + nsIDKey(const nsID &aID) { + mID = aID; + } - PRUint32 HashValue(void) const { - return mID.m0; + PRUint32 HashValue(void) const { + return mID.m0; + } + + PRBool Equals(const nsHashKey *aKey) const { + return (mID.Equals(((const nsIDKey *) aKey)->mID)); + } + + nsHashKey *Clone(void) const { + return new nsIDKey(mID); + } +}; + +//////////////////////////////////////////////////////////////////////////////// +// nsProgIDKey: Where keys are ProgIDs (char[64]) + +#include "plstr.h" + +class nsProgIDKey : public nsHashKey { +private: + char mProgIDBuf[64]; + char* mProgID; + +public: + nsProgIDKey(const char* aProgID) : mProgID(mProgIDBuf) { + PRInt32 len = PL_strlen(aProgID); + if (len >= sizeof(mProgIDBuf)) { + mProgID = new char[PL_strlen(aProgID) + 1]; + NS_ASSERTION(mProgID, "out of memory"); + if (! mProgID) + return; } - PRBool Equals(const nsHashKey *aKey) const { - return (mID.Equals(((const nsIDKey *) aKey)->mID)); - } + PL_strcpy(mProgID, aProgID); + } - nsHashKey *Clone(void) const { - return new nsIDKey(mID); - } + virtual ~nsProgIDKey(void) { + if (mProgID != mProgIDBuf) + delete[] mProgID; + } + + virtual PRUint32 HashValue(void) const { + return (PRUint32) PL_HashString((const void*) mProgID); + } + + virtual PRBool Equals(const nsHashKey* aKey) const { + return PL_strcmp( ((nsProgIDKey*)aKey)->mProgID, mProgID ) == 0; + } + + virtual nsHashKey* Clone() const { + return new nsProgIDKey(mProgID); + } }; #endif diff --git a/mozilla/xpcom/glue/nsID.h b/mozilla/xpcom/glue/nsID.h index 83238da6747..bb19b5fea28 100644 --- a/mozilla/xpcom/glue/nsID.h +++ b/mozilla/xpcom/glue/nsID.h @@ -85,5 +85,17 @@ struct nsID { extern "C" const nsID _name #endif +/* + * Class IDs + */ + +typedef nsID nsCID; + +// Define an CID +#define NS_DEFINE_CID(_name, _cidspec) \ + const nsCID _name = _cidspec + +#define REFNSCID const nsCID& + #endif diff --git a/mozilla/xpcom/io/nsFileSpec.h b/mozilla/xpcom/io/nsFileSpec.h index 41f1bbff0ec..1f5a33eee18 100644 --- a/mozilla/xpcom/io/nsFileSpec.h +++ b/mozilla/xpcom/io/nsFileSpec.h @@ -303,7 +303,7 @@ class NS_BASE nsFileSpec relativePath(inRelativePath); return *this + relativePath; } - void operator += (const char* inRelativePath); + void operator += (const char* inRelativePath); // Concatenate the relative path to this directory. // Used for constructing the filespec of a descendant. // This must be a directory for this to work. This differs @@ -312,7 +312,7 @@ class NS_BASE nsFileSpec // away its leaf information, whereas this one assumes // this is a directory, and the relative path starts // "below" this. - void operator += (const nsString& inRelativePath) + void operator += (const nsString& inRelativePath) { const nsAutoCString relativePath(inRelativePath); *this += relativePath; diff --git a/mozilla/xpcom/public/MANIFEST b/mozilla/xpcom/public/MANIFEST index 2ba24046343..eeec15a5162 100644 --- a/mozilla/xpcom/public/MANIFEST +++ b/mozilla/xpcom/public/MANIFEST @@ -16,6 +16,7 @@ nsISupportsUtils.h nsIPtr.h nsIRegistry.h nsIServiceManager.h +nsIComponentManager.h nsISupportsArray.h nsRepository.h nsIEnumerator.h diff --git a/mozilla/xpcom/public/Makefile.in b/mozilla/xpcom/public/Makefile.in index 3bf59c2532e..9947f0c300e 100644 --- a/mozilla/xpcom/public/Makefile.in +++ b/mozilla/xpcom/public/Makefile.in @@ -38,10 +38,11 @@ EXPORTS = \ nsISupports.h \ nsISupportsUtils.h \ nsIPtr.h \ + nsIComponentManager.h \ + nsRepository.h \ nsIServiceManager.h \ nsISupportsArray.h \ nsProxyEvent.h \ - nsRepository.h \ nsIEnumerator.h \ nsTraceRefcnt.h \ nsVector.h \ diff --git a/mozilla/xpcom/public/makefile.win b/mozilla/xpcom/public/makefile.win index 4a13cfcd1e1..c609f42304e 100644 --- a/mozilla/xpcom/public/makefile.win +++ b/mozilla/xpcom/public/makefile.win @@ -19,35 +19,36 @@ IGNORE_MANIFEST=1 DEPTH=..\.. -EXPORTS = \ - nsCOMPtr.h \ - nsAgg.h \ - nsCom.h \ - nsDebug.h \ - nsError.h \ - nsHashtable.h \ - nsICollection.h \ - nsID.h \ - nsIFactory.h \ - nsIID.h \ - nsISupports.h \ - nsISupportsUtils.h \ - nsIPtr.h \ - nsIServiceManager.h \ - nsISupportsArray.h \ - nsProxyEvent.h \ - nsRepository.h \ - nsIEnumerator.h \ - nsTraceRefcnt.h \ - nsVector.h \ - plvector.h \ - nsXPComFactory.h \ - nsXPComCIID.h \ - nsIEventQueueService.h \ - nsIAllocator.h \ - nsIRegistry.h \ - nsIGenericFactory.h \ - $(NULL) +EXPORTS = \ + nsCOMPtr.h \ + nsAgg.h \ + nsCom.h \ + nsDebug.h \ + nsError.h \ + nsHashtable.h \ + nsICollection.h \ + nsID.h \ + nsIFactory.h \ + nsIID.h \ + nsISupports.h \ + nsISupportsUtils.h \ + nsIPtr.h \ + nsIServiceManager.h \ + nsISupportsArray.h \ + nsIComponentManager.h \ + nsRepository.h \ + nsProxyEvent.h \ + nsIEnumerator.h \ + nsTraceRefcnt.h \ + nsVector.h \ + plvector.h \ + nsXPComFactory.h \ + nsXPComCIID.h \ + nsIEventQueueService.h \ + nsIAllocator.h \ + nsIRegistry.h \ + nsIGenericFactory.h \ + $(NULL) MODULE = xpcom diff --git a/mozilla/xpcom/public/mozIClassRegistry.h b/mozilla/xpcom/public/mozIClassRegistry.h index 86dc75f46c5..122932ca935 100644 --- a/mozilla/xpcom/public/mozIClassRegistry.h +++ b/mozilla/xpcom/public/mozIClassRegistry.h @@ -18,7 +18,7 @@ #ifndef __mozIClassRegistry_h #define __mozIClassRegistry_h -#include "nsRepository.h" +#include "nsIComponentManager.h" /*---------------------------- mozIClassRegistry ------------------------------- | This interface provides access to a mapping from mnemonic interface names | @@ -40,7 +40,7 @@ | name of the shared library that contains the implementation. | | | | The class registry object will register those classes with the "repository" | -| (see nsRepository.h) the first time a request is made to create an | +| (see nsComponentManager.h) the first time a request is made to create an | | instance. Subsequent requests will simply be forwarded to the repository | | after the appropriate interface and class IDs are determined. | | | diff --git a/mozilla/xpcom/public/nsHashtable.h b/mozilla/xpcom/public/nsHashtable.h index 17c2821a655..11509df3231 100644 --- a/mozilla/xpcom/public/nsHashtable.h +++ b/mozilla/xpcom/public/nsHashtable.h @@ -61,29 +61,29 @@ public: class nsISupportsKey : public nsHashKey { private: - nsISupports* mKey; + nsISupports* mKey; public: - nsISupportsKey(nsISupports* key) { - mKey = key; - NS_IF_ADDREF(mKey); - } + nsISupportsKey(nsISupports* key) { + mKey = key; + NS_IF_ADDREF(mKey); + } - ~nsISupportsKey(void) { - NS_IF_RELEASE(mKey); - } + ~nsISupportsKey(void) { + NS_IF_RELEASE(mKey); + } - PRUint32 HashValue(void) const { - return (PRUint32)mKey; - } + PRUint32 HashValue(void) const { + return (PRUint32)mKey; + } - PRBool Equals(const nsHashKey *aKey) const { - return (mKey == ((nsISupportsKey *) aKey)->mKey); - } + PRBool Equals(const nsHashKey *aKey) const { + return (mKey == ((nsISupportsKey *) aKey)->mKey); + } - nsHashKey *Clone(void) const { - return new nsISupportsKey(mKey); - } + nsHashKey *Clone(void) const { + return new nsISupportsKey(mKey); + } }; //////////////////////////////////////////////////////////////////////////////// @@ -91,24 +91,24 @@ public: class nsVoidKey : public nsHashKey { private: - const void* mKey; + const void* mKey; public: - nsVoidKey(const void* key) { - mKey = key; - } + nsVoidKey(const void* key) { + mKey = key; + } - PRUint32 HashValue(void) const { - return (PRUint32)mKey; - } + PRUint32 HashValue(void) const { + return (PRUint32)mKey; + } - PRBool Equals(const nsHashKey *aKey) const { - return (mKey == ((const nsVoidKey *) aKey)->mKey); - } + PRBool Equals(const nsHashKey *aKey) const { + return (mKey == ((const nsVoidKey *) aKey)->mKey); + } - nsHashKey *Clone(void) const { - return new nsVoidKey(mKey); - } + nsHashKey *Clone(void) const { + return new nsVoidKey(mKey); + } }; //////////////////////////////////////////////////////////////////////////////// @@ -118,24 +118,65 @@ public: class nsIDKey : public nsHashKey { private: - nsID mID; + nsID mID; public: - nsIDKey(const nsID &aID) { - mID = aID; - } + nsIDKey(const nsID &aID) { + mID = aID; + } - PRUint32 HashValue(void) const { - return mID.m0; + PRUint32 HashValue(void) const { + return mID.m0; + } + + PRBool Equals(const nsHashKey *aKey) const { + return (mID.Equals(((const nsIDKey *) aKey)->mID)); + } + + nsHashKey *Clone(void) const { + return new nsIDKey(mID); + } +}; + +//////////////////////////////////////////////////////////////////////////////// +// nsProgIDKey: Where keys are ProgIDs (char[64]) + +#include "plstr.h" + +class nsProgIDKey : public nsHashKey { +private: + char mProgIDBuf[64]; + char* mProgID; + +public: + nsProgIDKey(const char* aProgID) : mProgID(mProgIDBuf) { + PRInt32 len = PL_strlen(aProgID); + if (len >= sizeof(mProgIDBuf)) { + mProgID = new char[PL_strlen(aProgID) + 1]; + NS_ASSERTION(mProgID, "out of memory"); + if (! mProgID) + return; } - PRBool Equals(const nsHashKey *aKey) const { - return (mID.Equals(((const nsIDKey *) aKey)->mID)); - } + PL_strcpy(mProgID, aProgID); + } - nsHashKey *Clone(void) const { - return new nsIDKey(mID); - } + virtual ~nsProgIDKey(void) { + if (mProgID != mProgIDBuf) + delete[] mProgID; + } + + virtual PRUint32 HashValue(void) const { + return (PRUint32) PL_HashString((const void*) mProgID); + } + + virtual PRBool Equals(const nsHashKey* aKey) const { + return PL_strcmp( ((nsProgIDKey*)aKey)->mProgID, mProgID ) == 0; + } + + virtual nsHashKey* Clone() const { + return new nsProgIDKey(mProgID); + } }; #endif diff --git a/mozilla/xpcom/public/nsIComponentManager.h b/mozilla/xpcom/public/nsIComponentManager.h new file mode 100644 index 00000000000..08aa15e0b50 --- /dev/null +++ b/mozilla/xpcom/public/nsIComponentManager.h @@ -0,0 +1,258 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIComponentManager_h__ +#define nsIComponentManager_h__ + +#include "prtypes.h" +#include "nsCom.h" +#include "nsID.h" +#include "nsError.h" +#include "nsISupports.h" +#include "nsIFactory.h" + +/* + * Prototypes for dynamic library export functions. Your DLL/DSO needs to export + * these methods to play in the component world. + */ + +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr); +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *fullpath); +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char *fullpath); + +typedef nsresult (*nsFactoryProc)(nsISupports* aServMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +typedef PRBool (*nsCanUnloadProc)(nsISupports* aServMgr); +typedef nsresult (*nsRegisterProc)(nsISupports* aServMgr, const char *path); +typedef nsresult (*nsUnregisterProc)(nsISupports* aServMgr, const char *path); + +#define NS_ICOMPONENTMANAGER_IID \ +{ /* 8458a740-d5dc-11d2-92fb-00e09805570f */ \ + 0x8458a740, \ + 0xd5dc, \ + 0x11d2, \ + {0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \ +} + +#define NS_COMPONENTMANAGER_CID \ +{ /* 91775d60-d5dc-11d2-92fb-00e09805570f */ \ + 0x91775d60, \ + 0xd5dc, \ + 0x11d2, \ + {0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \ +} + +/* + * nsIComponentManager interface + */ + +class nsIComponentManager : public nsISupports { +public: + + NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICOMPONENTMANAGER_IID) + + NS_IMETHOD FindFactory(const nsCID &aClass, + nsIFactory **aFactory) = 0; + + // Finds a class ID for a specific Program ID + NS_IMETHOD ProgIDToCLSID(const char *aProgID, + nsCID *aClass) = 0; + + // Finds a Program ID for a specific class ID + // caller frees the result with delete[] + NS_IMETHOD CLSIDToProgID(nsCID *aClass, + char* *aClassName, + char* *aProgID) = 0; + + // Creates a class instance for a specific class ID + NS_IMETHOD CreateInstance(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) = 0; + + // Convenience routine, creates a class instance for a specific ProgID + NS_IMETHOD CreateInstance(const char *aProgID, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) = 0; + + // Creates a class instance for a specific class ID + /* + NS_IMETHOD CreateInstance2(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void *aSignature, + void **aResult) = 0; + */ + + // Manually registry a factory for a class + NS_IMETHOD RegisterFactory(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory *aFactory, + PRBool aReplace) = 0; + + // Manually register a dynamically loaded component. + NS_IMETHOD RegisterComponent(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + const char *aLibrary, + PRBool aReplace, + PRBool aPersist) = 0; + + // Manually unregister a factory for a class + NS_IMETHOD UnregisterFactory(const nsCID &aClass, + nsIFactory *aFactory) = 0; + + // Manually unregister a dynamically loaded factory for a class + NS_IMETHOD UnregisterFactory(const nsCID &aClass, + const char *aLibrary) = 0; + + // Manually unregister a dynamically loaded component + NS_IMETHOD UnregisterComponent(const nsCID &aClass, + const char *aLibrary) = 0; + + // Unload dynamically loaded factories that are not in use + NS_IMETHOD FreeLibraries(void) = 0; + + ////////////////////////////////////////////////////////////////////////////// + // DLL registration support + /* Autoregistration will try only files with these extensions. + * All extensions are case insensitive. + * ".dll", // Windows + * ".dso", // Unix + * ".so", // Unix + * ".sl", // Unix: HP + * "_dll", // Mac + * ".dlm", // new for all platforms + */ + enum RegistrationTime { + NS_Startup = 0, + NS_Script = 1, + NS_Timer = 2 + }; + + NS_IMETHOD AutoRegister(RegistrationTime when, const char* pathlist) = 0; + // Pathlist is a semicolon separated list of pathnames + NS_IMETHOD AddToDefaultPathList(const char *pathlist) = 0; + NS_IMETHOD SyncComponentsInPathList(const char *pathlist) = 0; + NS_IMETHOD SyncComponentsInDir(const char *path) = 0; + NS_IMETHOD SyncComponentsInFile(const char *fullname) = 0; +}; + +//////////////////////////////////////////////////////////////////////////////// + +extern NS_COM nsresult +NS_GetGlobalComponentManager(nsIComponentManager* *result); + +//////////////////////////////////////////////////////////////////////////////// +// Global Static Component Manager Methods +// (for when you need to link with xpcom) + +class NS_COM nsComponentManager { +public: + static nsresult Initialize(void); + + // Finds a factory for a specific class ID + static nsresult FindFactory(const nsCID &aClass, + nsIFactory **aFactory); + + // Finds a class ID for a specific Program ID + static nsresult ProgIDToCLSID(const char *aProgID, + nsCID *aClass); + + // Finds a Program ID for a specific class ID + // caller frees the result with delete[] + static nsresult CLSIDToProgID(nsCID *aClass, + char* *aClassName, + char* *aProgID); + + // Creates a class instance for a specific class ID + static nsresult CreateInstance(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult); + + // Convenience routine, creates a class instance for a specific ProgID + static nsresult CreateInstance(const char *aProgID, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult); + + // Creates a class instance for a specific class ID + /* + static nsresult CreateInstance2(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void *aSignature, + void **aResult); + */ + + // Manually registry a factory for a class + static nsresult RegisterFactory(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory *aFactory, + PRBool aReplace); + + // Manually register a dynamically loaded component. + static nsresult RegisterComponent(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + const char *aLibrary, + PRBool aReplace, + PRBool aPersist); + + // Manually unregister a factory for a class + static nsresult UnregisterFactory(const nsCID &aClass, + nsIFactory *aFactory); + + // Manually unregister a dynamically loaded factory for a class + static nsresult UnregisterFactory(const nsCID &aClass, + const char *aLibrary); + + // Manually unregister a dynamically loaded component + static nsresult UnregisterComponent(const nsCID &aClass, + const char *aLibrary); + + // Unload dynamically loaded factories that are not in use + static nsresult FreeLibraries(void); + + ////////////////////////////////////////////////////////////////////////////// + // DLL registration support + static nsresult AutoRegister(nsIComponentManager::RegistrationTime when, + const char* pathlist); + // Pathlist is a semicolon separated list of pathnames + static nsresult AddToDefaultPathList(const char *pathlist); + static nsresult SyncComponentsInPathList(const char *pathlist); + static nsresult SyncComponentsInDir(const char *path); + static nsresult SyncComponentsInFile(const char *fullname); + +}; + +//////////////////////////////////////////////////////////////////////////////// + +#endif diff --git a/mozilla/xpcom/public/nsID.h b/mozilla/xpcom/public/nsID.h index 83238da6747..bb19b5fea28 100644 --- a/mozilla/xpcom/public/nsID.h +++ b/mozilla/xpcom/public/nsID.h @@ -85,5 +85,17 @@ struct nsID { extern "C" const nsID _name #endif +/* + * Class IDs + */ + +typedef nsID nsCID; + +// Define an CID +#define NS_DEFINE_CID(_name, _cidspec) \ + const nsCID _name = _cidspec + +#define REFNSCID const nsCID& + #endif diff --git a/mozilla/xpcom/public/nsIFactory.h b/mozilla/xpcom/public/nsIFactory.h index a917b254119..5ed58f42a2c 100644 --- a/mozilla/xpcom/public/nsIFactory.h +++ b/mozilla/xpcom/public/nsIFactory.h @@ -22,18 +22,6 @@ #include "prtypes.h" #include "nsISupports.h" -/* - * Datatypes and helper macros - */ - -typedef nsID nsCID; - -// Define an CID -#define NS_DEFINE_CID(_name, _cidspec) \ - const nsCID _name = _cidspec - -#define REFNSCID const nsCID& - /* * nsIFactory interface */ diff --git a/mozilla/xpcom/public/nsIServiceManager.h b/mozilla/xpcom/public/nsIServiceManager.h index 09c23ca61f1..8d485659bef 100644 --- a/mozilla/xpcom/public/nsIServiceManager.h +++ b/mozilla/xpcom/public/nsIServiceManager.h @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -19,7 +19,8 @@ #ifndef nsIServiceManager_h___ #define nsIServiceManager_h___ -#include "nsRepository.h" +#include "nsISupports.h" +#include "nsID.h" class nsIShutdownListener; @@ -76,14 +77,15 @@ class nsIServiceManager : public nsISupports { public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISERVICEMANAGER_IID); - NS_IMETHOD - GetService(const nsCID& aClass, const nsIID& aIID, - nsISupports* *result, - nsIShutdownListener* shutdownListener = NULL) = 0; + /** + * RegisterService may be called explicitly to register a service + * with the service manager. If a service is not registered explicitly, + * the component manager will be used to create an instance according + * to the class ID specified. + */ NS_IMETHOD - ReleaseService(const nsCID& aClass, nsISupports* service, - nsIShutdownListener* shutdownListener = NULL) = 0; + RegisterService(const nsCID& aClass, nsISupports* aService) = 0; /** * Requests a service to be shut down, possibly unloading its DLL. @@ -96,24 +98,90 @@ public: * a shutdown listener. */ NS_IMETHOD - ShutdownService(const nsCID& aClass) = 0; + UnregisterService(const nsCID& aClass) = 0; + + NS_IMETHOD + GetService(const nsCID& aClass, const nsIID& aIID, + nsISupports* *result, + nsIShutdownListener* shutdownListener = NULL) = 0; + + NS_IMETHOD + ReleaseService(const nsCID& aClass, nsISupports* service, + nsIShutdownListener* shutdownListener = NULL) = 0; }; - #define NS_ERROR_SERVICE_NOT_FOUND NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM, 22) #define NS_ERROR_SERVICE_IN_USE NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM, 23) //////////////////////////////////////////////////////////////////////////////// +// nsService: Template to make using services easier. Now you can replace this: +// +// nsIMyService* service; +// rv = nsServiceManager::GetService(cid, iid, &service); +// if (NS_SUCCEEDED(rv)) { +// service->Doit(...); // use my service +// rv = nsServiceManager::ReleaseService(cid, service); +// } +// +// with this: +// +// nsService service(cid, &rv); +// if (NS_SUCCEEDED(rv)) { +// service->Doit(...); // use my service +// } +// +// and the automatic destructor will take care of releasing the service. + +template class nsService { +protected: + const nsCID mCID; + T* mService; -class nsIShutdownListener : public nsISupports { public: + nsService(nsISupports* aServMgr, const nsCID& aClass, nsresult *rv) + : mCID(aClass), mService(0) { + + nsIServiceManager* servMgr; + *rv = aServMgr->QueryInterface(nsIServiceManager::GetIID(), (void**)&servMgr); + if (NS_SUCCEEDED(*rv)) { + *rv = servMgr->GetService(aClass, T::GetIID(), (nsISupports**)&mService); + NS_RELEASE(servMgr); + } + NS_ASSERTION(NS_SUCCEEDED(*rv), "Couldn't get service."); + } - NS_IMETHOD - OnShutdown(const nsCID& aClass, nsISupports* service) = 0; + nsService(const nsCID& aClass, nsresult *rv) + : mCID(aClass), mService(0) { + *rv = nsServiceManager::GetService(aClass, T::GetIID(), + (nsISupports**)&mService); + NS_ASSERTION(NS_SUCCEEDED(*rv), "Couldn't get service."); + } + + ~nsService() { + if (mService) { // mService could be null if the constructor fails + nsresult rv = nsServiceManager::ReleaseService(mCID, mService); + NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't release service."); + } + } + + T* operator->() const { + NS_PRECONDITION(mService != 0, "Your code should test the error result from the constructor."); + return mService; + } + + PRBool operator==(const T* other) { + return mService == other; + } + + operator T*() const { + return mService; + } }; +//////////////////////////////////////////////////////////////////////////////// + #define NS_ISHUTDOWNLISTENER_IID \ { /* 56decae0-3406-11d2-8163-006008119d7a */ \ 0x56decae0, \ @@ -122,11 +190,26 @@ public: {0x81, 0x63, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \ } +class nsIShutdownListener : public nsISupports { +public: + + NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISHUTDOWNLISTENER_IID); + + NS_IMETHOD + OnShutdown(const nsCID& aClass, nsISupports* service) = 0; + +}; + //////////////////////////////////////////////////////////////////////////////// // Interface to Global Services class NS_COM nsServiceManager { public: + + static nsresult RegisterService(const nsCID& aClass, nsISupports* aService); + + static nsresult UnregisterService(const nsCID& aClass); + static nsresult GetService(const nsCID& aClass, const nsIID& aIID, nsISupports* *result, nsIShutdownListener* shutdownListener = NULL); @@ -134,17 +217,22 @@ public: static nsresult ReleaseService(const nsCID& aClass, nsISupports* service, nsIShutdownListener* shutdownListener = NULL); - static nsresult ShutdownService(const nsCID& aClass); - // Since the global Service Manager is truly global, there's no need to // release it. static nsresult GetGlobalServiceManager(nsIServiceManager* *result); protected: - static nsIServiceManager* globalServiceManager; + static nsIServiceManager* mGlobalServiceManager; }; +//////////////////////////////////////////////////////////////////////////////// +// NS_NewServiceManager: For when you want to create a service manager +// in a given context. + +extern NS_COM nsresult +NS_NewServiceManager(nsIServiceManager* *result); + //////////////////////////////////////////////////////////////////////////////// #endif /* nsIServiceManager_h___ */ diff --git a/mozilla/xpcom/public/nsRepository.h b/mozilla/xpcom/public/nsRepository.h index 6da2215491c..3979c2c0c75 100644 --- a/mozilla/xpcom/public/nsRepository.h +++ b/mozilla/xpcom/public/nsRepository.h @@ -19,211 +19,10 @@ #ifndef __nsRespository_h #define __nsRespository_h -#include "prtypes.h" -#include "prlog.h" -#include "prmon.h" -#include "nsCom.h" -#include "nsID.h" -#include "nsError.h" -#include "nsISupports.h" -#include "nsIFactory.h" -#include "nsHashtable.h" +#include "nsIComponentManager.h" -/* - * Prototypes for dynamic library export functions - */ +// XXX nsRepository is obsolete! Use nsComponentManager now! -class nsIServiceManager; - - -//*********************************************************** -// -// NSGetFactory should take nsISupports instead of nsIServiceManager -// as the second param. This is done on purpose!! Please don't change -// it. -// sudu / stanley -// -//*********************************************************** -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, - const nsCID &aClass, - const char *aClassName, - const char *aProgID, - nsIFactory **aFactory); -extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr); -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *fullpath); -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *fullpath); - -/* - *** Quick Registration NOT FOR PUBLIC CONSUMPTION YET *** - * - * Quick Registration - * - * For quick registration, dlls can define - * NSQuickRegisterClassData g_NSQuickRegisterData[]; - * and export the symbol "g_NSQuickRegisterData" - * - * Quick registration is tried only if the symbol "NSRegisterSelf" - * is not found. If it is found but fails registration, quick registration - * will not kick in. - * - * The array is terminated by having a NULL last element. Specifically, the - * array will be assumed to end when - * (g_NSQuickRegisterData[i].classIdStr == NULL) - * - */ -#define NS_QUICKREGISTER_DATA_SYMBOL "g_NSQuickRegisterData" - -typedef struct NSQuickRegisterClassData { - const char *CIDString; // {98765-8776-8958758759-958785} - const char *className; // "Layout Engine" - const char *progID; // "Gecko.LayoutEngine.1" -} NSQuickRegisterClassData; - -typedef NSQuickRegisterClassData* NSQuickRegisterData; - -/* Autoregistration will try only files with these extensions. - * All extensions are case insensitive. - ".dll", // Windows - ".dso", // Unix - ".so", // Unix - ".sl", // Unix: HP - "_dll", // Mac - ".dlm", // new for all platforms -*/ - -/* - * Dynamic library export function types - */ - -typedef nsresult (*nsFactoryProc)(nsISupports* serviceMgr, - const nsCID &aClass, - const char *aClassName, - const char *aProgID, - nsIFactory **aFactory); -typedef PRBool (*nsCanUnloadProc)(nsISupports* serviceMgr); -typedef nsresult (*nsRegisterProc)(nsISupports* serviceMgr, const char *path); -typedef nsresult (*nsUnregisterProc)(nsISupports* serviceMgr, const char *path); - -/* - * Support types - */ - -class FactoryEntry; -class nsDllStore; -class nsDll; - -enum NSRegistrationInstant -{ - NS_Startup = 0, - NS_Script = 1, - NS_Timer = 2 -}; - -/* Error codes generated by the repository methods */ - -#define NS_XPCOM_ERRORCODE_IS_DIR 1 - -/* The separator for each path part in the pathlist for autoregistration */ - -#define NS_PATH_SEPARATOR ';' - - -/* - * nsRepository class - */ - -class NS_COM nsRepository { -private: - -#define NS_MAX_FILENAME_LEN 1024 - - static nsHashtable *factories; - static nsHashtable *progIDs; - static PRMonitor *monitor; - - static nsresult checkInitialized(void); - static nsresult loadFactory(FactoryEntry *aEntry, nsIFactory **aFactory); - static nsresult SelfRegisterDll(nsDll *dll); - static nsresult SelfUnregisterDll(nsDll *dll); - -public: - static nsDllStore *dllStore; - - static nsresult Initialize(void); - // Finds a factory for a specific class ID - static nsresult FindFactory(const nsCID &aClass, - nsIFactory **aFactory); - - // Finds a class ID for a specific Program ID - static nsresult ProgIDToCLSID(const char *aProgID, - nsCID *aClass); - - // Finds a Program ID for a specific class ID - // caller frees the result with delete[] - static nsresult CLSIDToProgID(nsCID *aClass, - char* *aClassName, - char* *aProgID); - - // Creates a class instance for a specific class ID - static nsresult CreateInstance(const nsCID &aClass, - nsISupports *aDelegate, - const nsIID &aIID, - void **aResult); - - // Convenience routine, creates a class instance for a specific ProgID - static nsresult CreateInstance(const char *aProgID, - nsISupports *aDelegate, - const nsIID &aIID, - void **aResult); - - // Creates a class instance for a specific class ID - /* - static nsresult CreateInstance2(const nsCID &aClass, - nsISupports *aDelegate, - const nsIID &aIID, - void *aSignature, - void **aResult); - */ - - // Manually registry a factory for a class - static nsresult RegisterFactory(const nsCID &aClass, - const char *aClassName, - const char *aProgID, - nsIFactory *aFactory, - PRBool aReplace); - - // Manually register a dynamically loaded component. - static nsresult RegisterComponent(const nsCID &aClass, - const char *aClassName, - const char *aProgID, - const char *aLibrary, - PRBool aReplace, - PRBool aPersist); - - // Manually unregister a factory for a class - static nsresult UnregisterFactory(const nsCID &aClass, - nsIFactory *aFactory); - - // Manually unregister a dynamically loaded factory for a class - static nsresult UnregisterFactory(const nsCID &aClass, - const char *aLibrary); - - // Manually unregister a dynamically loaded component - static nsresult UnregisterComponent(const nsCID &aClass, - const char *aLibrary); - - // Unload dynamically loaded factories that are not in use - static nsresult FreeLibraries(void); - - // DLL registration support - static nsresult AutoRegister(NSRegistrationInstant when, - const char* pathlist); - // Pathlist is a semicolon separated list of pathnames - static nsresult AddToDefaultPathList(const char *pathlist); - static nsresult SyncComponentsInPathList(const char *pathlist); - static nsresult SyncComponentsInDir(const char *path); - static nsresult SyncComponentsInFile(const char *fullname); - -}; +#define nsRepository nsComponentManager #endif diff --git a/mozilla/xpcom/src/Makefile.in b/mozilla/xpcom/src/Makefile.in index fbe1d47c70b..db6daa64dd5 100644 --- a/mozilla/xpcom/src/Makefile.in +++ b/mozilla/xpcom/src/Makefile.in @@ -32,11 +32,12 @@ CPPSRCS = \ nsDebug.cpp \ nsHashtable.cpp \ nsID.cpp \ + nsComponentManager.cpp \ + nsRepository.cpp \ nsServiceManager.cpp \ nsSupportsArray.cpp \ nsSupportsArrayEnumerator.cpp \ nsConjoiningEnumerator.cpp \ - nsRepository.cpp \ nsTraceRefcnt.cpp \ nsProxyEvent.cpp \ nsXPComFactory.cpp \ diff --git a/mozilla/xpcom/src/makefile.win b/mozilla/xpcom/src/makefile.win index 7f1034df45f..785591d23d5 100644 --- a/mozilla/xpcom/src/makefile.win +++ b/mozilla/xpcom/src/makefile.win @@ -47,51 +47,53 @@ CSRCS = \ plvector.c \ $(NULL) -C_OBJS = \ - .\$(OBJDIR)\plvector.obj \ +C_OBJS = \ + .\$(OBJDIR)\plvector.obj \ $(NULL) -CPPSRCS = \ - nsDebug.cpp \ - nsHashtable.cpp \ - nsID.cpp \ - nsCOMPtr.cpp \ - nsProxyEvent.cpp \ - nsRepository.cpp \ - nsServiceManager.cpp \ - nsSupportsArray.cpp \ - nsSupportsArrayEnumerator.cpp \ - nsConjoiningEnumerator.cpp \ - nsTraceRefcnt.cpp \ - nsRegistry.cpp \ - nsXPComFactory.cpp \ - nsEventQueueService.cpp \ - nsAllocator.cpp \ - xcDll.cpp \ - xcDllStore.cpp \ - nsGenericFactory.cpp \ - $(NULL) +CPPSRCS = \ + nsDebug.cpp \ + nsHashtable.cpp \ + nsID.cpp \ + nsCOMPtr.cpp \ + nsProxyEvent.cpp \ + nsComponentManager.cpp \ + nsRepository.cpp \ + nsServiceManager.cpp \ + nsSupportsArray.cpp \ + nsSupportsArrayEnumerator.cpp \ + nsConjoiningEnumerator.cpp \ + nsTraceRefcnt.cpp \ + nsRegistry.cpp \ + nsXPComFactory.cpp \ + nsEventQueueService.cpp \ + nsAllocator.cpp \ + xcDll.cpp \ + xcDllStore.cpp \ + nsGenericFactory.cpp \ + $(NULL) -CPP_OBJS = \ - .\$(OBJDIR)\nsDebug.obj \ - .\$(OBJDIR)\nsHashtable.obj \ - .\$(OBJDIR)\nsID.obj \ - .\$(OBJDIR)\nsCOMPtr.obj \ - .\$(OBJDIR)\nsProxyEvent.obj \ - .\$(OBJDIR)\nsRepository.obj \ - .\$(OBJDIR)\nsServiceManager.obj \ - .\$(OBJDIR)\nsSupportsArray.obj \ - .\$(OBJDIR)\nsSupportsArrayEnumerator.obj \ - .\$(OBJDIR)\nsConjoiningEnumerator.obj \ - .\$(OBJDIR)\nsTraceRefcnt.obj \ - .\$(OBJDIR)\nsRegistry.obj \ - .\$(OBJDIR)\nsXPComFactory.obj \ - .\$(OBJDIR)\nsEventQueueService.obj \ - .\$(OBJDIR)\nsAllocator.obj \ - .\$(OBJDIR)\xcDll.obj \ - .\$(OBJDIR)\xcDllStore.obj \ - .\$(OBJDIR)\nsGenericFactory.obj \ - $(NULL) +CPP_OBJS = \ + .\$(OBJDIR)\nsDebug.obj \ + .\$(OBJDIR)\nsHashtable.obj \ + .\$(OBJDIR)\nsID.obj \ + .\$(OBJDIR)\nsCOMPtr.obj \ + .\$(OBJDIR)\nsProxyEvent.obj \ + .\$(OBJDIR)\nsComponentManager.obj \ + .\$(OBJDIR)\nsRepository.obj \ + .\$(OBJDIR)\nsServiceManager.obj \ + .\$(OBJDIR)\nsSupportsArray.obj \ + .\$(OBJDIR)\nsSupportsArrayEnumerator.obj \ + .\$(OBJDIR)\nsConjoiningEnumerator.obj \ + .\$(OBJDIR)\nsTraceRefcnt.obj \ + .\$(OBJDIR)\nsRegistry.obj \ + .\$(OBJDIR)\nsXPComFactory.obj \ + .\$(OBJDIR)\nsEventQueueService.obj \ + .\$(OBJDIR)\nsAllocator.obj \ + .\$(OBJDIR)\xcDll.obj \ + .\$(OBJDIR)\xcDllStore.obj \ + .\$(OBJDIR)\nsGenericFactory.obj \ + $(NULL) MODULE = xpcom diff --git a/mozilla/xpcom/src/mozRegistry.cpp b/mozilla/xpcom/src/mozRegistry.cpp index e0d7a28c3c2..dae56e6c7d9 100644 --- a/mozilla/xpcom/src/mozRegistry.cpp +++ b/mozilla/xpcom/src/mozRegistry.cpp @@ -1168,7 +1168,7 @@ mozRegistryFactory::LockFactory(PRBool aLock) } // This is a temporary hack; needs work to support dynamic binding -// via nsRepository and support for multiple factories per DLL. +// via nsComponentManager and support for multiple factories per DLL. extern "C" NS_EXPORT nsresult mozRegistry_GetFactory(const nsCID &cid, nsISupports* servMgr, nsIFactory** aFactory ) { nsresult rv = NS_OK; diff --git a/mozilla/xpcom/src/nsComponentManager.cpp b/mozilla/xpcom/src/nsComponentManager.cpp new file mode 100644 index 00000000000..42bfccfa058 --- /dev/null +++ b/mozilla/xpcom/src/nsComponentManager.cpp @@ -0,0 +1,1948 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsComponentManager.h" +#include "nsIServiceManager.h" +#include + +#ifndef XP_MAC +// including this on mac causes odd link errors in static initialization +// stuff that we (pinkerton & scc) don't yet understand. If you want to +// turn this on for mac, talk to one of us. +#include +#endif + +#ifdef XP_MAC +#include +#include +#include +#include +#include "primpl.h" // XXX for PR_PATH_SEPARATOR +#else +#include "private/primpl.h" // XXX for PR_PATH_SEPARATOR +#endif + +#include "plstr.h" +#include "prlink.h" +#include "prsystem.h" +#include "prprf.h" +#include "xcDllStore.h" +#include "prlog.h" + +#include "nsVector.h" +#include "prcmon.h" +#include "prthread.h" /* XXX: only used for the NSPR initialization hack (rick) */ + +#ifdef NS_DEBUG +PRLogModuleInfo* nsComponentManagerLog = NULL; +#endif + +//////////////////////////////////////////////////////////////////////////////// +// nsFactoryEntry +//////////////////////////////////////////////////////////////////////////////// + +nsFactoryEntry::nsFactoryEntry() + : factory(NULL), dll(NULL) +{ +} + +nsFactoryEntry::nsFactoryEntry(const nsCID &aClass, nsIFactory *aFactory) + : cid(aClass), factory(aFactory), dll(NULL) + +{ +} + +nsFactoryEntry::~nsFactoryEntry(void) +{ + if (factory != NULL) { + NS_RELEASE(factory); + } + // DO NOT DELETE nsDll *dll; +} + +nsresult +nsFactoryEntry::Init(nsDllStore* dllCollection, + const nsCID &aClass, const char *aLibrary, + PRTime lastModTime, PRUint32 fileSize) +{ + if (aLibrary == NULL) { + return NS_OK; + } + cid = aClass; + + // If dll not already in dllCollection, add it. + // PR_EnterMonitor(mMonitor); + dll = dllCollection->Get(aLibrary); + // PR_ExitMonitor(mMonitor); + + if (dll == NULL) { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: New dll \"%s\".", aLibrary)); + + // Add a new Dll into the nsDllStore + dll = new nsDll(aLibrary, lastModTime, fileSize); + if (dll == NULL) + return NS_ERROR_OUT_OF_MEMORY; + if (dll->GetStatus() != DLL_OK) { + // Cant create a nsDll. Backoff. + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: New dll status error. \"%s\".", aLibrary)); + delete dll; + dll = NULL; + } + else { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Adding New dll \"%s\" to mDllStore.", + aLibrary)); + + // PR_EnterMonitor(mMonitor); + dllCollection->Put(aLibrary, dll); + // PR_ExitMonitor(mMonitor); + } + } + else { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Found in mDllStore \"%s\".", aLibrary)); + // XXX We found the dll in the dllCollection. + // XXX Consistency check: dll needs to have the same + // XXX lastModTime and fileSize. If not that would mean + // XXX that the dll wasn't registered properly. + } + return NS_OK; +} + +//////////////////////////////////////////////////////////////////////////////// +// nsComponentManagerImpl +//////////////////////////////////////////////////////////////////////////////// + +nsComponentManagerImpl::nsComponentManagerImpl() + : mFactories(NULL), mProgIDs(NULL), mMonitor(NULL), mDllStore(NULL) +{ + NS_INIT_REFCNT(); +} + +nsresult nsComponentManagerImpl::Init(void) +{ + nsresult rv; + if (mFactories == NULL) { + mFactories = new nsHashtable(); + if (mFactories == NULL) + return NS_ERROR_OUT_OF_MEMORY; + } + if (mProgIDs == NULL) { + mProgIDs = new nsHashtable(); + if (mProgIDs == NULL) + return NS_ERROR_OUT_OF_MEMORY; + } + if (mMonitor == NULL) { + mMonitor = PR_NewMonitor(); + if (mMonitor == NULL) + return NS_ERROR_OUT_OF_MEMORY; + } + if (mDllStore == NULL) { + mDllStore = new nsDllStore(); + if (mDllStore == NULL) + return NS_ERROR_OUT_OF_MEMORY; + } + +#ifdef NS_DEBUG + if (nsComponentManagerLog == NULL) { + nsComponentManagerLog = PR_NewLogModule("nsComponentManager"); + } + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Initialized.")); +#endif + +#ifdef USE_NSREG + NR_StartupRegistry(); // XXX check error? + + // Check the version of registry. Nuke old versions. + rv = PlatformVersionCheck(); + if (NS_FAILED(rv)) return rv; +#endif + + // Initiate autoreg + rv = AutoRegister(NS_Startup, NULL); + if (NS_FAILED(rv)) return rv; + + return NS_OK; +} + +nsComponentManagerImpl::~nsComponentManagerImpl() +{ + if (mFactories) + delete mFactories; + if (mProgIDs) + delete mProgIDs; + if (mMonitor) + PR_DestroyMonitor(mMonitor); + if (mDllStore) + delete mDllStore; +} + +NS_IMPL_ISUPPORTS(nsComponentManagerImpl, nsIComponentManager::GetIID()); + +//////////////////////////////////////////////////////////////////////////////// +// nsComponentManagerImpl: Platform methods +//////////////////////////////////////////////////////////////////////////////// + +#ifdef USE_NSREG +#define USE_REGISTRY + +/* + * PlatformDeleteKey() + * + * Deletes a key sub tree entirely. + */ +nsresult +nsComponentManagerImpl::PlatformDeleteKey(HREG hreg, RKEY rootkey, const char *hierarchy) +{ + REGENUM state = 0; + RKEY key; + char keyname[MAXREGPATHLEN+1]; + int n = sizeof(keyname); + + REGERR err = NR_RegGetKey(hreg, rootkey, (char *)hierarchy, &key); + + if (err != REGERR_OK) + return err; + + keyname[0] = '\0'; + while (NR_RegEnumSubkeys(hreg, key, &state, keyname, n, REGENUM_DEPTH_FIRST) == REGERR_OK) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: ...enum %s", keyname)); + err = NR_RegDeleteKey(hreg, key, keyname); + if (err != REGERR_OK) + { + // Couldn't delete a key. We wont be able to delete the entire + // hierarchy. ABORT. + break; + } + keyname[0] = '\0'; + + // buf in NR_RegEnumSubKeys() causes it to return ./libxpcom.so first then + // subsequently libraptor.so (NOTE without the initial ./ which was there in + // the key). Hence continuing thought the enum and delete will fail with + // not found. Hence, restarting the enum everytime. + state = 0; + } + + if (err == REGERR_OK) + err = NR_RegDeleteKey(hreg, rootkey, (char *)hierarchy); + return err; +} + +/** + * PlatformVersionCheck() + * + * Checks to see if the XPCOM hierarchy in the registry is the same as that of + * the software as defined by NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING + */ +nsresult +nsComponentManagerImpl::PlatformVersionCheck() +{ + HREG hreg; + REGERR err = NR_RegOpen(NULL, &hreg); + + if (err != REGERR_OK) + { + return NS_ERROR_FAILURE; + } + + RKEY xpcomKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + char buf[MAXREGNAMELEN]; + uint32 len = sizeof(buf); + buf[0] = '\0'; + + err = NR_RegGetEntryString(hreg, xpcomKey, "VersionString", buf, len); + + // If there is a version mismatch or no version string, we got an old registry. + // Delete the old repository hierarchies and recreate version string + if (err != REGERR_OK || PL_strcmp(buf, NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING)) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Registry version mismatch (%s vs %s). Nuking xpcom " + "registry hierarchy.", buf, NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING)); + + // Delete the XPCOM and CLSID hierarchy + PlatformDeleteKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM"); + PlatformDeleteKey(hreg, ROOTKEY_COMMON, "Classes/CLSID"); + + // Recreate XPCOM and CLSID keys + NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey); + NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes/CLSID", NULL); + + NR_RegSetEntryString(hreg, xpcomKey, "VersionString", NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING); + } + else { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: platformVersionCheck() passed.")); + } + + NR_RegClose(hreg); + return NS_OK; +} + +/** + * PlatformCreateDll(const char *fullname) + * + * Creates a nsDll from the registry representation of dll 'fullname'. + * Looks under + * ROOTKEY_COMMON/Software/Netscape/XPCOM/fullname + */ +nsresult +nsComponentManagerImpl::PlatformCreateDll(const char *fullname, nsDll* *result) +{ + HREG hreg; + REGERR err = NR_RegOpen(NULL, &hreg); + + if (err != REGERR_OK) { + return NS_ERROR_FAILURE; + } + + RKEY xpcomKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + RKEY key; + err = NR_RegGetKey(hreg, xpcomKey, (char *)fullname, &key); + if (err != REGERR_OK) + { + return NS_ERROR_FAILURE; + } + + PRTime lastModTime = LL_ZERO; + PRUint32 fileSize = 0; + uint32 n = sizeof(lastModTime); + NR_RegGetEntry(hreg, key, "LastModTimeStamp", &lastModTime, &n); + n = sizeof(fileSize); + NR_RegGetEntry(hreg, key, "FileSize", &fileSize, &n); + + nsDll *dll = new nsDll(fullname, lastModTime, fileSize); + if (dll == NULL) + return NS_ERROR_OUT_OF_MEMORY; + + *result = dll; + return NS_OK; +} + +/** + * PlatformMarkNoComponents(nsDll *dll) + * + * Stores the dll name, last modified time, size and 0 for number of + * components in dll in the registry at location + * ROOTKEY_COMMON/Software/Netscape/XPCOM/dllname + */ +nsresult +nsComponentManagerImpl::PlatformMarkNoComponents(nsDll *dll) +{ + HREG hreg; + REGERR err = NR_RegOpen(NULL, &hreg); + + if (err != REGERR_OK) + { + return NS_ERROR_FAILURE; + } + + // XXX Gross. LongLongs dont have a serialization format. This makes + // XXX the registry non-xp. Someone beat on the nspr people to get + // XXX a longlong serialization function please! + RKEY xpcomKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + RKEY key; + err = NR_RegAddKey(hreg, xpcomKey, (char *)dll->GetFullPath(), &key); + + if (err != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + PRTime lastModTime = dll->GetLastModifiedTime(); + PRUint32 fileSize = dll->GetSize(); + + NR_RegSetEntry(hreg, key, "LastModTimeStamp", REGTYPE_ENTRY_BYTES, + &lastModTime, sizeof(lastModTime)); + NR_RegSetEntry(hreg, key, "FileSize", REGTYPE_ENTRY_BYTES, + &fileSize, sizeof(fileSize)); + + char *ncomponentsString = "0"; + + NR_RegSetEntryString(hreg, key, "ComponentsCount", + ncomponentsString); + + NR_RegClose(hreg); + return NS_OK; +} + +nsresult +nsComponentManagerImpl::PlatformRegister(QuickRegisterData* regd, nsDll *dll) +{ + HREG hreg; + // Preconditions + PR_ASSERT(regd != NULL); + PR_ASSERT(regd->CIDString != NULL); + PR_ASSERT(dll != NULL); + + REGERR err = NR_RegOpen(NULL, &hreg); + + if (err != REGERR_OK) + { + return NS_ERROR_FAILURE; + } + + RKEY classesKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + RKEY key; + NR_RegAddKey(hreg, classesKey, "CLSID", &key); + NR_RegAddKey(hreg, key, (char *)regd->CIDString, &key); + + NR_RegSetEntryString(hreg, key, "ClassName", (char *)regd->className); + if (regd->progID) + NR_RegSetEntryString(hreg, key, "ProgID", (char *)(regd->progID)); + char *libName = (char *)dll->GetFullPath(); + NR_RegSetEntryString(hreg, key, "InprocServer", libName); + + if (regd->progID) + { + NR_RegAddKey(hreg, classesKey, (char *)regd->progID, &key); + NR_RegSetEntryString(hreg, key, "CLSID", (char *)regd->CIDString); + } + + // XXX Gross. LongLongs dont have a serialization format. This makes + // XXX the registry non-xp. Someone beat on the nspr people to get + // XXX a longlong serialization function please! + RKEY xpcomKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) + { + NR_RegClose(hreg); + // This aint a fatal error. It causes autoregistration to fail + // and hence the dll would be registered again the next time + // we startup. Let us run with it. + return NS_OK; + } + + NR_RegAddKey(hreg, xpcomKey, (char *)dll->GetFullPath(), &key); + + PRTime lastModTime = dll->GetLastModifiedTime(); + PRUint32 fileSize = dll->GetSize(); + + NR_RegSetEntry(hreg, key, "LastModTimeStamp", REGTYPE_ENTRY_BYTES, + &lastModTime, sizeof(lastModTime)); + NR_RegSetEntry(hreg, key, "FileSize", REGTYPE_ENTRY_BYTES, + &fileSize, sizeof(fileSize)); + + unsigned int nComponents = 0; + char buf[MAXREGNAMELEN]; + uint32 len = sizeof(buf); + + if (NR_RegGetEntryString(hreg, key, "ComponentsCount", buf, len) == REGERR_OK) + { + nComponents = atoi(buf); + } + nComponents++; + PR_snprintf(buf, sizeof(buf), "%d", nComponents); + NR_RegSetEntryString(hreg, key, "ComponentsCount", buf); + + NR_RegClose(hreg); + return err; +} + +nsresult +nsComponentManagerImpl::PlatformUnregister(QuickRegisterData* regd, const char *aLibrary) +{ + HREG hreg; + REGERR err = NR_RegOpen(NULL, &hreg); + + if (err != REGERR_OK) + { + return NS_ERROR_FAILURE; + } + + RKEY classesKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + RKEY key; + NR_RegAddKey(hreg, classesKey, "CLSID", &key); + RKEY cidKey; + NR_RegAddKey(hreg, key, (char *)regd->CIDString, &cidKey); + char progID[MAXREGNAMELEN]; + uint32 plen = sizeof(progID); + if (NR_RegGetEntryString(hreg, cidKey, "ProgID", progID, plen) == REGERR_OK) + { + NR_RegDeleteKey(hreg, classesKey, progID); + } + + NR_RegDeleteKey(hreg, key, (char *)regd->CIDString); + + RKEY xpcomKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) + { + NR_RegClose(hreg); + // This aint a fatal error. It causes autoregistration to fail + // and hence the dll would be registered again the next time + // we startup. Let us run with it. + return NS_OK; + } + + NR_RegGetKey(hreg, xpcomKey, (char *)aLibrary, &key); + + // We need to reduce the ComponentCount by 1. + // If the ComponentCount hits 0, delete the entire key. + int nComponents = 0; + char buf[MAXREGNAMELEN]; + uint32 len = sizeof(buf); + + if (NR_RegGetEntryString(hreg, key, "ComponentsCount", buf, len) == REGERR_OK) + { + nComponents = atoi(buf); + nComponents--; + } + if (nComponents <= 0) + { + NR_RegDeleteKey(hreg, key, (char *)aLibrary); + } + else + { + PR_snprintf(buf, sizeof(buf), "%d", nComponents); + NR_RegSetEntryString(hreg, key, "ComponentsCount", buf); + } + + NR_RegClose(hreg); + return NS_OK; +} + +nsresult +nsComponentManagerImpl::PlatformFind(const nsCID &aCID, nsFactoryEntry* *result) +{ + nsresult rv; + HREG hreg; + REGERR err = NR_RegOpen(NULL, &hreg); + + if (err != REGERR_OK) { + return NS_ERROR_FAILURE; + } + + RKEY classesKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + RKEY key; + NR_RegAddKey(hreg, classesKey, "CLSID", &key); + + nsFactoryEntry *res = NULL; + + RKEY cidKey; + char *cidString = aCID.ToString(); + err = NR_RegGetKey(hreg, key, cidString, &cidKey); + delete [] cidString; + + if (err != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + // Get the library name, modifiedtime and size + PRTime lastModTime = LL_ZERO; + PRUint32 fileSize = 0; + + char buf[MAXREGNAMELEN]; + uint32 len = sizeof(buf); + err = NR_RegGetEntryString(hreg, cidKey, "InprocServer", buf, len); + if (err != REGERR_OK) + { + // Registry inconsistent. No File name for CLSID. + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + char *library = buf; + + // XXX Gross. LongLongs dont have a serialization format. This makes + // XXX the registry non-xp. Someone beat on the nspr people to get + // XXX a longlong serialization function please! + RKEY xpcomKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) == REGERR_OK) + { + if (NR_RegGetKey(hreg, xpcomKey, library, &key) == REGERR_OK) + { + uint32 n = sizeof(lastModTime); + NR_RegGetEntry(hreg, key, "LastModTimeStamp", &lastModTime, &n); + PR_ASSERT(n == sizeof(lastModTime)); + n = sizeof(fileSize); + NR_RegGetEntry(hreg, key, "FileSize", &fileSize, &n); + PR_ASSERT(n == sizeof(fileSize)); + } + } + + res = new nsFactoryEntry; + if (res == NULL) + return NS_ERROR_OUT_OF_MEMORY; + rv = res->Init(mDllStore, aCID, library, lastModTime, fileSize); + if (NS_FAILED(rv)) return rv; + + NR_RegClose(hreg); + + *result = res; + return NS_OK; +} + +nsresult +nsComponentManagerImpl::PlatformProgIDToCLSID(const char *aProgID, nsCID *aClass) +{ + HREG hreg; + nsresult res = NS_ERROR_FAILURE; + + PR_ASSERT(aClass != NULL); + + REGERR err = NR_RegOpen(NULL, &hreg); + if (err != REGERR_OK) + { + return NS_ERROR_FAILURE; + } + + RKEY classesKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + RKEY key; + err = NR_RegGetKey(hreg, classesKey, (char *)aProgID, &key); + if (err != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + char cidString[MAXREGNAMELEN]; + err = NR_RegGetEntryString(hreg, key, "CLSID", cidString, MAXREGNAMELEN); + if (err != REGERR_OK) + { + NR_RegClose(hreg); + return NS_ERROR_FAILURE; + } + + NR_RegClose(hreg); + + if (!(aClass->Parse(cidString))) + { + return NS_ERROR_FAILURE; + } + res = NS_OK; + return res; +} + +nsresult +nsComponentManagerImpl::PlatformCLSIDToProgID(nsCID *aClass, + char* *aClassName, char* *aProgID) +{ + HREG hreg; + char* classnameString; + char* progidString; + nsresult res = NS_ERROR_FAILURE; + + char* cidStr = aClass->ToString(); + + PR_ASSERT(aClass != NULL); + + REGERR err = NR_RegOpen(NULL, &hreg); + if (err != REGERR_OK) + { + res = NS_ERROR_FAILURE; + goto done1; + } + + RKEY classesKey; + if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) + { + res = NS_ERROR_FAILURE; + goto done2; + } + + RKEY key; + err = NR_RegGetKey(hreg, classesKey, cidStr, &key); + if (err != REGERR_OK) + { + res = NS_ERROR_FAILURE; + goto done2; + } + + classnameString = new char[MAXREGNAMELEN]; + if (classnameString == NULL) { + res = NS_ERROR_OUT_OF_MEMORY; + goto done2; + } + err = NR_RegGetEntryString(hreg, key, "ClassName", classnameString, MAXREGNAMELEN); + if (err != REGERR_OK) + { + delete[] classnameString; + res = NS_ERROR_FAILURE; + goto done2; + } + *aClassName = classnameString; + + progidString = new char[MAXREGNAMELEN]; + if (progidString == NULL) { + delete[] classnameString; + res = NS_ERROR_OUT_OF_MEMORY; + goto done2; + } + err = NR_RegGetEntryString(hreg, key, "ProgID", progidString, MAXREGNAMELEN); + if (err != REGERR_OK) + { + delete[] progidString; + delete[] classnameString; + res = NS_ERROR_FAILURE; + goto done2; + } + + *aProgID = progidString; + res = NS_OK; + + done2: + NR_RegClose(hreg); + done1: + delete[] cidStr; + + return res; +} + +#endif // USE_NSREG + +//////////////////////////////////////////////////////////////////////////////// +// nsComponentManagerImpl: Public methods +//////////////////////////////////////////////////////////////////////////////// + +nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = NULL; + +/** + * LoadFactory() + * + * Given a FactoryEntry, this loads the dll if it has to, find the NSGetFactory + * symbol, calls the routine to create a new factory and returns it to the + * caller. + * + * No attempt is made to store the factory in any form anywhere. + */ +nsresult +nsComponentManagerImpl::LoadFactory(nsFactoryEntry *aEntry, + nsIFactory **aFactory) +{ + if (aFactory == NULL) + { + return NS_ERROR_NULL_POINTER; + } + *aFactory = NULL; + + // LoadFactory() cannot be called for entries that are CID<->factory + // mapping entries for the session. + PR_ASSERT(aEntry->dll != NULL); + + if (aEntry->dll->IsLoaded() == PR_FALSE) + { + // Load the dll + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: + Loading \"%s\".", aEntry->dll->GetFullPath())); + if (aEntry->dll->Load() == PR_FALSE) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, + ("nsComponentManager: Library load unsuccessful.")); + return NS_ERROR_FAILURE; + } + } + +#ifdef MOZ_TRACE_XPCOM_REFCNT + // Inform refcnt tracer of new library so that calls through the + // new library can be traced. + nsTraceRefcnt::LoadLibrarySymbols(aEntry->dll->GetFullPath(), aEntry->dll->GetInstance()); +#endif + nsFactoryProc proc = (nsFactoryProc) aEntry->dll->FindSymbol("NSGetFactory"); + if (proc != NULL) + { + char* className = NULL; + char* progID = NULL; + nsresult rv; + + // XXX dp, warren: deal with this! +#if 0 + rv = CLSIDToProgID(&aEntry->cid, &className, &progID); + // if CLSIDToProgID fails, just pass null to NSGetFactory +#endif + + nsIServiceManager* serviceMgr = NULL; + rv = nsServiceManager::GetGlobalServiceManager(&serviceMgr); + if (NS_FAILED(rv)) return rv; + + rv = proc(serviceMgr, aEntry->cid, className, progID, aFactory); + if (NS_FAILED(rv)) return rv; + + if (className) + delete[] className; + if (progID) + delete[] progID; + return rv; + } + PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, + ("nsComponentManager: NSGetFactory entrypoint not found.")); + return NS_ERROR_FACTORY_NOT_LOADED; +} + +/** + * FindFactory() + * + * Given a classID, this finds the factory for this CID by first searching the + * local CID<->factory mapping. Next it searches for a Dll that implements + * this classID and calls LoadFactory() to create the factory. + * + * Again, no attempt is made at storing the factory. + */ +nsresult +nsComponentManagerImpl::FindFactory(const nsCID &aClass, + nsIFactory **aFactory) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: FindFactory(%s)", buf); + delete [] buf; + } +#endif + + PR_ASSERT(aFactory != NULL); + + PR_EnterMonitor(mMonitor); + + nsIDKey key(aClass); + nsFactoryEntry *entry = (nsFactoryEntry*) mFactories->Get(&key); + + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + +#ifdef USE_REGISTRY + if (entry == NULL) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("\t\tnot found in factory cache. Looking in registry")); + nsresult rv = PlatformFind(aClass, &entry); + + // XXX This should go into PlatformFind(), and PlatformFind() + // should just become a static method on nsComponentManager. + + // If we got one, cache it in our hashtable + if (NS_SUCCEEDED(rv)) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("\t\tfound in registry.")); + mFactories->Put(&key, entry); + } + } + else + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("\t\tfound in factory cache.")); + } +#endif + + PR_ExitMonitor(mMonitor); + + if (entry != NULL) + { + if ((entry)->factory == NULL) + { + res = LoadFactory(entry, aFactory); + } + else + { + *aFactory = entry->factory; + NS_ADDREF(*aFactory); + res = NS_OK; + } + } + + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tFindFactory() %s", + NS_SUCCEEDED(res) ? "succeeded" : "FAILED")); + + return res; +} + +/** + * ProgIDToCLSID() + * + * Mapping function from a ProgID to a classID. Directly talks to the registry. + * + * XXX We need to add a cache this translation as this is done a lot. + */ +nsresult +nsComponentManagerImpl::ProgIDToCLSID(const char *aProgID, nsCID *aClass) +{ + NS_PRECONDITION(aProgID != NULL, "null ptr"); + if (! aProgID) + return NS_ERROR_NULL_POINTER; + + NS_PRECONDITION(aClass != NULL, "null ptr"); + if (! aClass) + return NS_ERROR_NULL_POINTER; + + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + +#ifdef USE_REGISTRY + // XXX This isn't quite the best way to do this: we should + // probably move an nsArray into the FactoryEntry class, + // and then have the construct/destructor of the factory entry + // keep the ProgID to CID cache up-to-date. However, doing this + // significantly improves performance, so it'll do for now. + +#define NS_NO_CID { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } } + static NS_DEFINE_CID(kNoCID, NS_NO_CID); + + nsProgIDKey key(aProgID); + nsCID* cid = (nsCID*) mProgIDs->Get(&key); + if (cid) { + if (cid == &kNoCID) { + // we've already tried to map this ProgID to a CLSID, and found + // that there _was_ no such mapping in the registry. + } + else { + *aClass = *cid; + res = NS_OK; + } + } + else { + // This is the first time someone has asked for this + // ProgID. Go to the registry to find the CID. + res = PlatformProgIDToCLSID(aProgID, aClass); + + if (NS_SUCCEEDED(res)) { + // Found it. So put it into the cache. + cid = new nsCID(*aClass); + if (!cid) + return NS_ERROR_OUT_OF_MEMORY; + + mProgIDs->Put(&key, cid); + } + else { + // Didn't find it. Put a special CID in the cache so we + // don't need to hit the registry on subsequent requests + // for the same ProgID. + mProgIDs->Put(&key, (void*) &kNoCID); + } + } +#endif /* USE_REGISTRY */ + +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) { + char *buf; + if (NS_SUCCEEDED(res)) + buf = aClass->ToString(); + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: ProgIDToCLSID(%s)->%s", aProgID, + NS_SUCCEEDED(res) ? buf : "[FAILED]")); + if (NS_SUCCEEDED(res)) + delete [] buf; + } +#endif + + return res; +} + +/** + * CLSIDToProgID() + * + * Translates a classID to a {ProgID, Class Name}. Does direct registry + * access to do the translation. + * + * XXX Would be nice to hook in a cache here too. + */ +nsresult +nsComponentManagerImpl::CLSIDToProgID(nsCID *aClass, + char* *aClassName, + char* *aProgID) +{ + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + +#ifdef USE_REGISTRY + res = PlatformCLSIDToProgID(aClass, aClassName, aProgID); +#endif /* USE_REGISTRY */ + +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass->ToString(); + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("nsComponentManager: CLSIDToProgID(%s)->%s", buf, + NS_SUCCEEDED(res) ? *aProgID : "[FAILED]")); + delete [] buf; + } +#endif + + return res; +} + +/** + * CreateInstance() + * + * Create an instance of an object that implements an interface and belongs + * to the implementation aClass using the factory. The factory is immediately + * released and not held onto for any longer. + */ +nsresult +nsComponentManagerImpl::CreateInstance(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: CreateInstance(%s)", buf); + delete [] buf; + } +#endif + if (aResult == NULL) + { + return NS_ERROR_NULL_POINTER; + } + *aResult = NULL; + + nsIFactory *factory = NULL; + nsresult res = FindFactory(aClass, &factory); + if (NS_SUCCEEDED(res)) + { + res = factory->CreateInstance(aDelegate, aIID, aResult); + NS_RELEASE(factory); + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("\t\tCreateInstance() succeeded.")); + return res; + } + + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("\t\tCreateInstance() FAILED.")); + return NS_ERROR_FACTORY_NOT_REGISTERED; +} + +/** + * CreateInstance() + * + * An overload of CreateInstance() that creates an instance of the object that + * implements the interface aIID and whose implementation has a progID aProgID. + * + * This is only a convenience routine that turns around can calls the + * CreateInstance() with classid and iid. + * + * XXX This is a function overload. We need to remove it. + */ +nsresult +nsComponentManagerImpl::CreateInstance(const char *aProgID, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) +{ + nsCID clsid; + nsresult rv = ProgIDToCLSID(aProgID, &clsid); + if (NS_FAILED(rv)) return rv; + return CreateInstance(clsid, aDelegate, aIID, aResult); +} + +#if 0 +nsresult +nsComponentManagerImpl::CreateInstance2(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void *aSignature, + void **aResult) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: Creating Instance."); + PR_LogPrint("nsComponentManager: + %s.", + buf); + PR_LogPrint("nsComponentManager: + Signature = %p.", + aSignature); + delete [] buf; + } +#endif + if (aResult == NULL) + { + return NS_ERROR_NULL_POINTER; + } + *aResult = NULL; + + nsIFactory *factory = NULL; + + nsresult res = FindFactory(aClass, &factory); + + if (NS_SUCCEEDED(res)) + { + nsIFactory2 *factory2 = NULL; + res = NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT; + + factory->QueryInterface(kFactory2IID, (void **) &factory2); + + if (factory2 != NULL) + { + res = factory2->CreateInstance2(aDelegate, aIID, aSignature, aResult); + NS_RELEASE(factory2); + } + + NS_RELEASE(factory); + return res; + } + + return NS_ERROR_FACTORY_NOT_REGISTERED; +} +#endif /* 0 */ + +/** + * RegisterFactory() + * + * Register a factory to be responsible for creation of implementation of + * classID aClass. Plus creates as association of aClassName and aProgID + * to the classID. If replace is PR_TRUE, we replace any existing registrations + * with this one. + * + * Once registration is complete, we add the class to the factories cache + * that we maintain. The factories cache is the ONLY place where these + * registrations are ever kept. + * + * XXX This uses FindFactory() to test if a factory already exists. This + * XXX has the bad side effect of loading the factory if the previous + * XXX registration was a dll for this class. We might be able to do away + * XXX with such a load. + */ +nsresult +nsComponentManagerImpl::RegisterFactory(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory *aFactory, + PRBool aReplace) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: RegisterFactory(%s, factory), replace = %d.", buf, (int)aReplace); + delete [] buf; + } +#endif + + nsIFactory *old = NULL; + FindFactory(aClass, &old); + + if (old != NULL) + { + NS_RELEASE(old); + if (!aReplace) + { + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tFactory already registered.")); + return NS_ERROR_FACTORY_EXISTS; + } + else + { + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tdeleting old Factory Entry.")); + } + } + + PR_EnterMonitor(mMonitor); + + nsIDKey key(aClass); + nsFactoryEntry* entry = new nsFactoryEntry(aClass, aFactory); + if (entry == NULL) + return NS_ERROR_OUT_OF_MEMORY; + mFactories->Put(&key, entry); + + PR_ExitMonitor(mMonitor); + + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tFactory register succeeded.")); + + return NS_OK; +} + +nsresult +nsComponentManagerImpl::RegisterComponent(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + const char *aLibrary, + PRBool aReplace, + PRBool aPersist) +{ + nsresult rv = NS_OK; +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: RegisterComponent(%s, %s, %s, %s), replace = %d, persist = %d.", + buf, aClassName, aProgID, aLibrary, (int)aReplace, (int)aPersist); + delete [] buf; + } +#endif + + nsIFactory *old = NULL; + FindFactory(aClass, &old); + + if (old != NULL) + { + NS_RELEASE(old); + if (!aReplace) + { + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tFactory already registered.")); + return NS_ERROR_FACTORY_EXISTS; + } + else + { + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tdeleting registered Factory.")); + } + } + + PR_EnterMonitor(mMonitor); + +#ifdef USE_REGISTRY + if (aPersist == PR_TRUE) + { + // Add it to the registry + nsDll *dll = new nsDll(aLibrary); + if (dll == NULL) { + rv = NS_ERROR_OUT_OF_MEMORY; + goto done; + } + // XXX temp hack until we get the dll to give us the entire + // XXX NSQuickRegisterClassData + QuickRegisterData cregd = {0}; + cregd.CIDString = aClass.ToString(); + cregd.className = aClassName; + cregd.progID = aProgID; + PlatformRegister(&cregd, dll); + delete [] (char *)cregd.CIDString; + delete dll; + } + else +#endif + { + nsDll *dll = new nsDll(aLibrary); + if (dll == NULL) { + rv = NS_ERROR_OUT_OF_MEMORY; + goto done; + } + nsIDKey key(aClass); + nsFactoryEntry* entry = new nsFactoryEntry; + delete dll; + if (entry == NULL) { + rv = NS_ERROR_OUT_OF_MEMORY; + goto done; + } + rv = entry->Init(mDllStore, aClass, aLibrary, + dll->GetLastModifiedTime(), dll->GetSize()); + if (NS_FAILED(rv)) + goto done; + mFactories->Put(&key, entry); + } + + done: + PR_ExitMonitor(mMonitor); + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("\t\tFactory register succeeded.")); + return rv; +} + +nsresult +nsComponentManagerImpl::UnregisterFactory(const nsCID &aClass, + nsIFactory *aFactory) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: Unregistering Factory."); + PR_LogPrint("nsComponentManager: + %s.", buf); + delete [] buf; + } +#endif + + nsIDKey key(aClass); + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + nsFactoryEntry *old = (nsFactoryEntry *) mFactories->Get(&key); + if (old != NULL) + { + if (old->factory == aFactory) + { + PR_EnterMonitor(mMonitor); + old = (nsFactoryEntry *) mFactories->Remove(&key); + PR_ExitMonitor(mMonitor); + delete old; + res = NS_OK; + } + + } + + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("nsComponentManager: ! Factory unregister %s.", + res == NS_OK ? "succeeded" : "failed")); + + return res; +} + +nsresult +nsComponentManagerImpl::UnregisterComponent(const nsCID &aClass, + const char *aLibrary) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: Unregistering Factory."); + PR_LogPrint("nsComponentManager: + %s in \"%s\".", buf, aLibrary); + delete [] buf; + } +#endif + + nsIDKey key(aClass); + nsFactoryEntry *old = (nsFactoryEntry *) mFactories->Get(&key); + + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + + PR_EnterMonitor(mMonitor); + + if (old != NULL && old->dll != NULL) + { + if (old->dll->GetFullPath() != NULL && +#ifdef XP_UNIX + PL_strcasecmp(old->dll->GetFullPath(), aLibrary) +#else + PL_strcmp(old->dll->GetFullPath(), aLibrary) +#endif + ) + { + nsFactoryEntry *entry = (nsFactoryEntry *) mFactories->Remove(&key); + delete entry; + res = NS_OK; + } +#ifdef USE_REGISTRY + // XXX temp hack until we get the dll to give us the entire + // XXX NSQuickRegisterClassData + QuickRegisterData cregd = {0}; + cregd.CIDString = aClass.ToString(); + res = PlatformUnregister(&cregd, aLibrary); + delete [] (char *)cregd.CIDString; +#endif + } + + PR_ExitMonitor(mMonitor); + + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("nsComponentManager: ! Factory unregister %s.", + res == NS_OK ? "succeeded" : "failed")); + + return res; +} + +nsresult +nsComponentManagerImpl::UnregisterFactory(const nsCID &aClass, + const char *aLibrary) +{ +#ifdef NS_DEBUG + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) + { + char *buf = aClass.ToString(); + PR_LogPrint("nsComponentManager: Unregistering Factory."); + PR_LogPrint("nsComponentManager: + %s in \"%s\".", buf, aLibrary); + delete [] buf; + } +#endif + + nsIDKey key(aClass); + nsFactoryEntry *old = (nsFactoryEntry *) mFactories->Get(&key); + + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + + PR_EnterMonitor(mMonitor); + + if (old != NULL && old->dll != NULL) + { + if (old->dll->GetFullPath() != NULL && +#ifdef XP_UNIX + PL_strcasecmp(old->dll->GetFullPath(), aLibrary) +#else + PL_strcmp(old->dll->GetFullPath(), aLibrary) +#endif + ) + { + nsFactoryEntry *entry = (nsFactoryEntry *) mFactories->Remove(&key); + delete entry; + res = NS_OK; + } +#ifdef USE_REGISTRY + // XXX temp hack until we get the dll to give us the entire + // XXX NSQuickRegisterClassData + QuickRegisterData cregd = {0}; + cregd.CIDString = aClass.ToString(); + res = PlatformUnregister(&cregd, aLibrary); + delete [] (char *)cregd.CIDString; +#endif + } + + PR_ExitMonitor(mMonitor); + + PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, + ("nsComponentManager: ! Factory unregister %s.", + res == NS_OK ? "succeeded" : "failed")); + + return res; +} + +static PRBool +nsFreeLibraryEnum(nsHashKey *aKey, void *aData, void* closure) +{ + nsFactoryEntry *entry = (nsFactoryEntry *) aData; + nsIServiceManager* serviceMgr = (nsIServiceManager*)closure; + + if (entry->dll && entry->dll->IsLoaded() == PR_TRUE) + { + nsCanUnloadProc proc = (nsCanUnloadProc) entry->dll->FindSymbol("NSCanUnload"); + if (proc != NULL) { + nsresult rv = proc(serviceMgr); + if (NS_FAILED(rv)) { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: + Unloading \"%s\".", entry->dll->GetFullPath())); + entry->dll->Unload(); + } + } + } + + return PR_TRUE; +} + +nsresult +nsComponentManagerImpl::FreeLibraries(void) +{ + PR_EnterMonitor(mMonitor); + + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Freeing Libraries.")); + + nsIServiceManager* serviceMgr = NULL; + nsresult rv = nsServiceManager::GetGlobalServiceManager(&serviceMgr); + if (NS_FAILED(rv)) return rv; + mFactories->Enumerate(nsFreeLibraryEnum, serviceMgr); + + PR_ExitMonitor(mMonitor); + + return NS_OK; +} + +//////////////////////////////////////////////////////////////////////////////// + +/** + * AutoRegister(RegistrationInstant, const char *pathlist) + * + * Given a ; separated list of paths, this will ensure proper registration + * of all components. A default pathlist is maintained in the registry at + * \\HKEYROOT_COMMON\\Classes\\PathList + * In addition to looking at the pathlist, the default pathlist is looked at. + * + * This will take care not loading already registered dlls, finding and + * registering new dlls, re-registration of modified dlls + * + */ + +nsresult +nsComponentManagerImpl::AutoRegister(RegistrationTime when, + const char* pathlist) +{ +#ifdef XP_MAC + CInfoPBRec catInfo; + Handle pathH; + OSErr err; + ProcessSerialNumber psn; + ProcessInfoRec pInfo; + FSSpec appFSSpec; + FSSpec tempSpec; + long theDirID; + Str255 name; +#endif + + if (pathlist != NULL) + { + SyncComponentsInPathList(pathlist); + } + +#ifdef XP_MAC + // get info for the the current process to determine the directory its located in + if (!(err = GetCurrentProcess(&psn))) + { + // initialize ProcessInfoRec before calling GetProcessInformation() or die horribly. + pInfo.processName = nil; + pInfo.processAppSpec = &tempSpec; + pInfo.processInfoLength = sizeof(ProcessInfoRec); + if (!(err = GetProcessInformation(&psn, &pInfo))) + { + appFSSpec = *(pInfo.processAppSpec); + if ((pathH = NewHandle(1)) != NULL) + { + **pathH = '\0'; // initially null terminate the string + HNoPurge(pathH); + HUnlock(pathH); + theDirID = appFSSpec.parID; + do + { + catInfo.dirInfo.ioCompletion = NULL; + catInfo.dirInfo.ioNamePtr = (StringPtr)&name; + catInfo.dirInfo.ioVRefNum = appFSSpec.vRefNum; + catInfo.dirInfo.ioDrDirID = theDirID; + catInfo.dirInfo.ioFDirIndex = -1; // -1 = query dir in ioDrDirID + if (!(err = PBGetCatInfoSync(&catInfo))) + { + // build up a Unix style pathname due to NSPR + // XXX Note: this breaks if any of the parent + // directories contain a "slash" (blame NSPR) + + Munger(pathH, 0L, NULL, 0L, (const void *)&name[1], (long)name[0]); // prepend dir name + Munger(pathH, 0L, NULL, 0L, "/", 1); // prepend slash + + // move up to parent directory + theDirID = catInfo.dirInfo.ioDrParID; + } + } while ((!err) && (catInfo.dirInfo.ioDrDirID != 2)); // 2 = root + if (!err) + { + Munger(pathH, GetHandleSize(pathH)-1, NULL, 0L, "/components", 11); // append "/components" + HLock(pathH); + SyncComponentsInPathList((const char *)(*pathH)); + HUnlock(pathH); + } + DisposeHandle(pathH); + } + } + } +#else + //XXX get default pathlist from registry + //XXX Temporary hack. Registering components from current directory +#ifdef XP_UNIX + const char *defaultPathList = "./components"; +#else + // XXX This will change to ./components very soon + const char *defaultPathList = "."; +#endif + SyncComponentsInPathList(defaultPathList); +#endif + return NS_OK; +} + +nsresult +nsComponentManagerImpl::AddToDefaultPathList(const char *pathlist) +{ + //XXX add pathlist to the defaultpathlist in the registry + return NS_ERROR_FAILURE; +} + +nsresult +nsComponentManagerImpl::SyncComponentsInPathList(const char *pathlist) +{ + char *paths = PL_strdup(pathlist); + + if (paths == NULL || *paths == '\0') + return(NS_ERROR_FAILURE); + + char *pathsMem = paths; + while (paths != NULL) + { + char *nextpath = PL_strchr(paths, PR_PATH_SEPARATOR); + if (nextpath != NULL) *nextpath = '\0'; + SyncComponentsInDir(paths); + paths = nextpath; + } + PL_strfree(pathsMem); + return NS_OK; +} + +nsresult +nsComponentManagerImpl::SyncComponentsInDir(const char *dir) +{ + PRDir *prdir = PR_OpenDir(dir); + if (prdir == NULL) + return NS_ERROR_FAILURE; + + // Create a buffer that has dir/ in it so we can append + // the filename each time in the loop + char fullname[NS_MAX_FILENAME_LEN]; + PL_strncpyz(fullname, dir, sizeof(fullname)); + unsigned int n = strlen(fullname); + if (n+1 < sizeof(fullname)) + { +#ifdef XP_WIN + fullname[n] = PR_GetDirectorySeparator(); +#else + fullname[n] = '/'; +#endif + n++; + } + char *filepart = fullname + n; + + PRDirEntry *dirent = NULL; + while ((dirent = PR_ReadDir(prdir, PR_SKIP_BOTH)) != NULL) + { + PL_strncpyz(filepart, dirent->name, sizeof(fullname)-n); + nsresult ret = SyncComponentsInFile(fullname); + if (NS_FAILED(ret) && ret == NS_ERROR_IS_DIR) { + SyncComponentsInDir(fullname); + } + } // foreach file + PR_CloseDir(prdir); + return NS_OK; +} + +nsresult +nsComponentManagerImpl::SyncComponentsInFile(const char *fullname) +{ + const char *ValidDllExtensions[] = { + ".dll", /* Windows */ + ".dso", /* Unix */ + ".so", /* Unix */ + ".sl", /* Unix: HP */ + ".shlb", /* Mac ? */ + ".dlm", /* new for all platforms */ + NULL + }; + + + PRFileInfo statbuf; + if (PR_GetFileInfo(fullname,&statbuf) != PR_SUCCESS) + { + // Skip files that cannot be stat + return NS_ERROR_FAILURE; + } + + if (statbuf.type == PR_FILE_DIRECTORY) + { + // Cant register a directory + return NS_ERROR_IS_DIR; + } + else if (statbuf.type != PR_FILE_FILE) + { + // Skip non-files + return NS_ERROR_FAILURE; + } + + // deal with only files that have the right extension + PRBool validExtension = PR_FALSE; + int flen = PL_strlen(fullname); + for (int i=0; ValidDllExtensions[i] != NULL; i++) + { + int extlen = PL_strlen(ValidDllExtensions[i]); + + // Does fullname end with this extension + if (flen >= extlen && + !PL_strcasecmp(&(fullname[flen - extlen]), ValidDllExtensions[i]) + ) + { + validExtension = PR_TRUE; + break; + } + } + + if (validExtension == PR_FALSE) + { + // Skip invalid extensions + return NS_ERROR_FAILURE; + } + + // Check if dll is one that we have already seen + nsDll *dll = mDllStore->Get(fullname); + nsresult rv = NS_OK; + if (dll == NULL) + { + // XXX Create nsDll for this from registry and + // XXX add it to our dll cache mDllStore. +#ifdef USE_REGISTRY + rv = PlatformCreateDll(fullname, &dll); +#endif /* USE_REGISTRY */ + } + + if (NS_SUCCEEDED(rv)) + { + // Make sure the dll is OK + if (dll->GetStatus() != NS_OK) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: + nsDll not NS_OK \"%s\". Skipping...", + dll->GetFullPath())); + return NS_ERROR_FAILURE; + } + + // We already have seen this dll. Check if this dll changed + if (LL_EQ(dll->GetLastModifiedTime(), statbuf.modifyTime) && + (dll->GetSize() == statbuf.size)) + { + // Dll hasn't changed. Skip. + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: + nsDll not changed \"%s\". Skipping...", + dll->GetFullPath())); + return NS_OK; + } + + // Aagh! the dll has changed since the last time we saw it. + // re-register dll + if (dll->IsLoaded()) + { + // We are screwed. We loaded the old version of the dll + // and now we find that the on-disk copy if newer. + // The only thing to do would be to ask the dll if it can + // unload itself. It can do that if it hasn't created objects + // yet. + nsCanUnloadProc proc = (nsCanUnloadProc) + dll->FindSymbol("NSCanUnload"); + if (proc != NULL) + { + PRBool res = proc(this /*, PR_TRUE*/); + if (res) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: + Unloading \"%s\".", + dll->GetFullPath())); + dll->Unload(); + } + else + { + // THIS IS THE WORST SITUATION TO BE IN. + // Dll doesn't want to be unloaded. Cannot re-register + // this dll. + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: *** Dll already loaded. " + "Cannot unload either. Hence cannot re-register " + "\"%s\". Skipping...", dll->GetFullPath())); + return NS_ERROR_FAILURE; + } + } + else { + // dll doesn't have a CanUnload proc. Guess it is + // ok to unload it. + dll->Unload(); + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: + Unloading \"%s\". (no CanUnloadProc).", + dll->GetFullPath())); + + } + + } // dll isloaded + + // Sanity. + if (dll->IsLoaded()) + { + // We went through all the above to make sure the dll + // is unloaded. And here we are with the dll still + // loaded. Whoever taught dp programming... + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Dll still loaded. Cannot re-register " + "\"%s\". Skipping...", dll->GetFullPath())); + return NS_ERROR_FAILURE; + } + } // dll != NULL + else + { + // Create and add the dll to the mDllStore + // It is ok to do this even if the creation of nsDll + // didnt succeed. That way we wont do this again + // when we encounter the same dll. + dll = new nsDll(fullname); + if (dll == NULL) + return NS_ERROR_OUT_OF_MEMORY; + mDllStore->Put(fullname, dll); + } // dll == NULL + + // Either we are seeing the dll for the first time or the dll has + // changed since we last saw it and it is unloaded successfully. + // + // Now we can try register the dll for sure. + nsresult res = SelfRegisterDll(dll); + nsresult ret = NS_OK; + if (NS_FAILED(res)) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Autoregistration FAILED for " + "\"%s\". Skipping...", dll->GetFullPath())); + // Mark dll as not xpcom dll along with modified time and size in + // the registry so that we wont need to load the dll again every + // session until the dll changes. +#ifdef USE_REGISTRY + PlatformMarkNoComponents(dll); +#endif /* USE_REGISTRY */ + ret = NS_ERROR_FAILURE; + } + else + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Autoregistration Passed for " + "\"%s\". Skipping...", dll->GetFullPath())); + // Marking dll along with modified time and size in the + // registry happens at PlatformRegister(). No need to do it + // here again. + } + return ret; +} + +/* +* SelfRegisterDll +* +* Given a dll abstraction, this will load, selfregister the dll and +* unload the dll. +* +*/ +nsresult +nsComponentManagerImpl::SelfRegisterDll(nsDll *dll) +{ + // Precondition: dll is not loaded already + PR_ASSERT(dll->IsLoaded() == PR_FALSE); + + nsresult res = NS_ERROR_FAILURE; + + if (dll->Load() == PR_FALSE) + { + // Cannot load. Probably not a dll. + return(NS_ERROR_FAILURE); + } + + nsRegisterProc regproc = (nsRegisterProc)dll->FindSymbol("NSRegisterSelf"); + + if (regproc == NULL) + { + // Smart registration + QuickRegisterData* qr = + (QuickRegisterData*)dll->FindSymbol(NS_QUICKREGISTER_DATA_SYMBOL); + if (qr == NULL) + { + res = NS_ERROR_NO_INTERFACE; + } + else + { + // XXX register the quick registration data on behalf of the dll + // XXX for now return failure + res = NS_ERROR_FAILURE; + } + } + else + { + // Call the NSRegisterSelfProc to enable dll registration + nsIServiceManager* serviceMgr = NULL; + res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); + if (NS_SUCCEEDED(res)) { + res = regproc(serviceMgr, dll->GetFullPath()); + } + } + dll->Unload(); + return res; +} + +nsresult +nsComponentManagerImpl::SelfUnregisterDll(nsDll *dll) +{ + // Precondition: dll is not loaded + PR_ASSERT(dll->IsLoaded() == PR_FALSE); + + if (dll->Load() == PR_FALSE) + { + // Cannot load. Probably not a dll. + return(NS_ERROR_FAILURE); + } + + nsUnregisterProc unregproc = + (nsUnregisterProc) dll->FindSymbol("NSUnregisterSelf"); + nsresult res = NS_OK; + + if (unregproc == NULL) + { + // Smart unregistration + QuickRegisterData* qr = (QuickRegisterData*) + dll->FindSymbol(NS_QUICKREGISTER_DATA_SYMBOL); + if (qr == NULL) + { + return(NS_ERROR_NO_INTERFACE); + } + // XXX unregister the dll based on the quick registration data + } + else + { + // Call the NSUnregisterSelfProc to enable dll de-registration + nsIServiceManager* serviceMgr = NULL; + res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); + if (NS_SUCCEEDED(res)) { + res = unregproc(serviceMgr, dll->GetFullPath()); + } + } + dll->Unload(); + return res; +} + +//////////////////////////////////////////////////////////////////////////////// + +NS_COM nsresult +NS_GetGlobalComponentManager(nsIComponentManager* *result) +{ + if (nsComponentManagerImpl::gComponentManager == NULL) { + nsComponentManagerImpl::gComponentManager = + new nsComponentManagerImpl(); + if (nsComponentManagerImpl::gComponentManager == NULL) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(nsComponentManagerImpl::gComponentManager); + nsresult rv = nsComponentManagerImpl::gComponentManager->Init(); + if (NS_FAILED(rv)) { + NS_RELEASE(nsComponentManagerImpl::gComponentManager); + return rv; + } + } + *result = nsComponentManagerImpl::gComponentManager; + return NS_OK; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/xpcom/src/nsComponentManager.h b/mozilla/xpcom/src/nsComponentManager.h new file mode 100644 index 00000000000..a10b93c5b70 --- /dev/null +++ b/mozilla/xpcom/src/nsComponentManager.h @@ -0,0 +1,224 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsComponentManager_h__ +#define nsComponentManager_h__ + +#include "nsIComponentManager.h" +#include "NSReg.h" +#include "nsHashtable.h" +#include "prtime.h" + +class nsFactoryEntry; +class nsDllStore; +class nsDll; + +//////////////////////////////////////////////////////////////////////////////// +/* + *** Quick Registration NOT FOR PUBLIC CONSUMPTION *** + * + * Quick Registration + * + * For quick registration, dlls can define + * NSQuickRegisterClassData g_NSQuickRegisterData[]; + * and export the symbol "g_NSQuickRegisterData" + * + * Quick registration is tried only if the symbol "NSRegisterSelf" + * is not found. If it is found but fails registration, quick registration + * will not kick in. + * + * The array is terminated by having a NULL last element. Specifically, the + * array will be assumed to end when + * (g_NSQuickRegisterData[i].classIdStr == NULL) + * + */ +#define NS_QUICKREGISTER_DATA_SYMBOL "g_NSQuickRegisterData" + +//////////////////////////////////////////////////////////////////////////////// + +class nsComponentManagerImpl : public nsIComponentManager { +public: + NS_DECL_ISUPPORTS + + // nsIComponentManager methods: + NS_IMETHOD FindFactory(const nsCID &aClass, + nsIFactory **aFactory); + + // Finds a class ID for a specific Program ID + NS_IMETHOD ProgIDToCLSID(const char *aProgID, + nsCID *aClass); + + // Finds a Program ID for a specific class ID + // caller frees the result with delete[] + NS_IMETHOD CLSIDToProgID(nsCID *aClass, + char* *aClassName, + char* *aProgID); + + // Creates a class instance for a specific class ID + NS_IMETHOD CreateInstance(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult); + + // Convenience routine, creates a class instance for a specific ProgID + NS_IMETHOD CreateInstance(const char *aProgID, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult); + + // Creates a class instance for a specific class ID + /* + NS_IMETHOD CreateInstance2(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void *aSignature, + void **aResult); + */ + + // Manually registry a factory for a class + NS_IMETHOD RegisterFactory(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory *aFactory, + PRBool aReplace); + + // Manually register a dynamically loaded component. + NS_IMETHOD RegisterComponent(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + const char *aLibrary, + PRBool aReplace, + PRBool aPersist); + + // Manually unregister a factory for a class + NS_IMETHOD UnregisterFactory(const nsCID &aClass, + nsIFactory *aFactory); + + // Manually unregister a dynamically loaded factory for a class + NS_IMETHOD UnregisterFactory(const nsCID &aClass, + const char *aLibrary); + + // Manually unregister a dynamically loaded component + NS_IMETHOD UnregisterComponent(const nsCID &aClass, + const char *aLibrary); + + // Unload dynamically loaded factories that are not in use + NS_IMETHOD FreeLibraries(void); + + ////////////////////////////////////////////////////////////////////////////// + // DLL registration support + /* Autoregistration will try only files with these extensions. + * All extensions are case insensitive. + * ".dll", // Windows + * ".dso", // Unix + * ".so", // Unix + * ".sl", // Unix: HP + * "_dll", // Mac + * ".dlm", // new for all platforms + */ + NS_IMETHOD AutoRegister(RegistrationTime when, const char* pathlist); + // Pathlist is a semicolon separated list of pathnames + NS_IMETHOD AddToDefaultPathList(const char *pathlist); + NS_IMETHOD SyncComponentsInPathList(const char *pathlist); + NS_IMETHOD SyncComponentsInDir(const char *path); + NS_IMETHOD SyncComponentsInFile(const char *fullname); + + // nsComponentManagerImpl methods: + nsComponentManagerImpl(); + virtual ~nsComponentManagerImpl(); + + static nsComponentManagerImpl* gComponentManager; + nsresult Init(void); + +protected: + nsresult LoadFactory(nsFactoryEntry *aEntry, nsIFactory **aFactory); + nsresult SelfRegisterDll(nsDll *dll); + nsresult SelfUnregisterDll(nsDll *dll); + + nsresult PlatformDeleteKey(HREG hreg, RKEY rootkey, const char *hierarchy); + nsresult PlatformVersionCheck(); + nsresult PlatformCreateDll(const char *fullname, nsDll* *result); + nsresult PlatformMarkNoComponents(nsDll *dll); + struct QuickRegisterData { + const char *CIDString; // {98765-8776-8958758759-958785} + const char *className; // "Layout Engine" + const char *progID; // "Gecko.LayoutEngine.1" + }; + nsresult PlatformRegister(QuickRegisterData* regd, nsDll *dll); + nsresult PlatformUnregister(QuickRegisterData* regd, const char *aLibrary); + nsresult PlatformFind(const nsCID &aCID, nsFactoryEntry* *result); + nsresult PlatformProgIDToCLSID(const char *aProgID, nsCID *aClass); + nsresult PlatformCLSIDToProgID(nsCID *aClass, char* *aClassName, char* *aProgID); + +protected: + nsHashtable* mFactories; + nsHashtable* mProgIDs; + PRMonitor* mMonitor; + nsDllStore* mDllStore; +}; + +#define NS_MAX_FILENAME_LEN 1024 + +#define NS_ERROR_IS_DIR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, 24) + +/** + * When using the registry we put a version number in it. + * If the version number that is in the registry doesn't match + * the following, we ignore the registry. This lets news versions + * of the software deal with old formats of registry and not + * + * alpha0.20 : First time we did versioning + * alpha0.30 : Changing autoreg to begin registration from ./components on unix + */ +#define NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING "alpha0.31" + +//////////////////////////////////////////////////////////////////////////////// +/** + * Class: nsFactoryEntry() + * + * There are two types of FactoryEntries. + * + * 1. {CID, dll} mapping. + * Factory is a consequence of the dll. These can be either session + * specific or persistent based on whether we write this + * to the registry or not. + * + * 2. {CID, factory} mapping + * These are strictly session specific and in memory only. + */ + +class nsFactoryEntry { +public: + nsFactoryEntry(); + nsFactoryEntry(const nsCID &aClass, nsIFactory *aFactory); + ~nsFactoryEntry(); + + nsresult Init(nsDllStore* store, const nsCID &aClass, const char *aLibrary, + PRTime lastModTime, PRUint32 fileSize); + + nsCID cid; + nsIFactory *factory; + + // DO NOT DELETE THIS. Many nsFactoryEntry(s) could be sharing the same Dll. + // This gets deleted from the dllStore going away. + nsDll *dll; +}; + +//////////////////////////////////////////////////////////////////////////////// + +#endif // nsComponentManager_h__ diff --git a/mozilla/xpcom/src/nsEventQueueService.cpp b/mozilla/xpcom/src/nsEventQueueService.cpp index 49e2bc4b505..0379daae626 100644 --- a/mozilla/xpcom/src/nsEventQueueService.cpp +++ b/mozilla/xpcom/src/nsEventQueueService.cpp @@ -26,7 +26,7 @@ static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID); -// XXX move to nsID.h or nsHashtable.h? (copied from nsRepository.cpp) +// XXX move to nsID.h or nsHashtable.h? (copied from nsComponentManager.cpp) class ThreadKey: public nsHashKey { private: const PRThread* id; diff --git a/mozilla/xpcom/src/nsRegistry.cpp b/mozilla/xpcom/src/nsRegistry.cpp index aed006362e9..ee6533ebcb2 100644 --- a/mozilla/xpcom/src/nsRegistry.cpp +++ b/mozilla/xpcom/src/nsRegistry.cpp @@ -1168,7 +1168,7 @@ nsRegistryFactory::LockFactory(PRBool aLock) } // This is a temporary hack; needs work to support dynamic binding -// via nsRepository and support for multiple factories per DLL. +// via nsComponentManager and support for multiple factories per DLL. extern "C" NS_EXPORT nsresult nsRegistry_GetFactory(const nsCID &cid, nsISupports* servMgr, nsIFactory** aFactory ) { nsresult rv = NS_OK; diff --git a/mozilla/xpcom/src/nsRepository.cpp b/mozilla/xpcom/src/nsRepository.cpp index 8c388156b76..6c8ba29f8a0 100644 --- a/mozilla/xpcom/src/nsRepository.cpp +++ b/mozilla/xpcom/src/nsRepository.cpp @@ -16,1962 +16,179 @@ * Reserved. */ -#include +#include "nsIComponentManager.h" -#ifndef XP_MAC -// including this on mac causes odd link errors in static initialization -// stuff that we (pinkerton & scc) don't yet understand. If you want to -// turn this on for mac, talk to one of us. -#include -#endif - -#ifdef XP_MAC -#include -#include -#include -#include -#endif - -#include "plstr.h" -#include "prlink.h" -#include "prsystem.h" -#include "prprf.h" -#include "nsRepository.h" - -/** - * When using the registry we put a version number in it. - * If the version number that is in the registry doesn't match - * the following, we ignore the registry. This lets news versions - * of the software deal with old formats of registry and not - * - * alpha0.20 : First time we did versioning - * alpha0.30 : Changing autoreg to begin registration from ./components on unix - */ -#define NS_XPCOM_REPOSITORY_VERSION_STRING "alpha0.33" - -#include "NSReg.h" - - -#if 0 -#ifdef XP_MAC -#ifdef MOZ_NGLAYOUT -#define IMPL_MAC_REPOSITORY -#include "nsMacRepository.h" -#endif -#endif -#endif - -#include "xcDllStore.h" -#include "nsIServiceManager.h" - -nsHashtable *nsRepository::factories = NULL; -nsHashtable *nsRepository::progIDs = NULL; -PRMonitor *nsRepository::monitor = NULL; - -/** - * dllStore - * - * The dllStore maintains a collection of dlls that are hashed by the dll - * name. The repository uses the DllStore only to store these dlls: - * - * 1. dlls that store components in them. - * The inmemory nsDll that is stored here always reflects the values of - * {lastModTime, fileSize} that are stored in the registry. - * It is the job of the autoregistration mechanism to do the right - * thing if the dll on disk is newer. - * 2. dlls that dont store components in them. - * This is for the purpose of the autoregistration mechanism only. - * These are marked in the registry too so that unless they change - * they wont have to loaded every session. - * - */ -nsDllStore *nsRepository::dllStore = NULL; - -static PRLogModuleInfo *logmodule = NULL; - -#if 0 -// Factory2 commented out until proven required -static NS_DEFINE_IID(kFactory2IID, NS_IFACTORY2_IID); -#endif /* 0 */ - -/***************************************************************************/ - -/** - * Class: FactoryEntry() - * - * There are two types of FactoryEntries. - * - * 1. {CID, dll} mapping. - * Factory is a consequence of the dll. These can be either session - * specific or persistent based on whether we write this - * to the registry or not. - * - * 2. {CID, factory} mapping - * These are strictly session specific and in memory only. - */ - -class FactoryEntry { -public: - nsCID cid; - nsIFactory *factory; - - FactoryEntry(const nsCID &aClass, const char *aLibrary, - PRTime lastModTime, PRUint32 fileSize); - FactoryEntry(const nsCID &aClass, nsIFactory *aFactory); - ~FactoryEntry(); - // DO NOT DELETE THIS. Many FactoryEntry(s) could be sharing the same Dll. - // This gets deleted from the dllStore going away. - nsDll *dll; - -}; - -FactoryEntry::FactoryEntry(const nsCID &aClass, const char *aLibrary, - PRTime lastModTime, PRUint32 fileSize) - : cid(aClass), factory(NULL), dll(NULL) +nsresult +nsComponentManager::Initialize(void) { - nsDllStore *dllCollection = nsRepository::dllStore; - - if (aLibrary == NULL) - { - return; - } - - // If dll not already in dllCollection, add it. - // PR_EnterMonitor(nsRepository::monitor); - dll = dllCollection->Get(aLibrary); - // PR_ExitMonitor(nsRepository::monitor); - - if (dll == NULL) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: New dll \"%s\".", aLibrary)); - - // Add a new Dll into the nsDllStore - dll = new nsDll(aLibrary, lastModTime, fileSize); - if (dll->GetStatus() != DLL_OK) - { - // Cant create a nsDll. Backoff. - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: New dll status error. \"%s\".", aLibrary)); - delete dll; - dll = NULL; - } - else - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: Adding New dll \"%s\" to dllStore.", - aLibrary)); - - // PR_EnterMonitor(nsRepository::monitor); - dllCollection->Put(aLibrary, dll); - // PR_ExitMonitor(nsRepository::monitor); - } - } - else - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: Found in dllStore \"%s\".", aLibrary)); - // XXX We found the dll in the dllCollection. - // XXX Consistency check: dll needs to have the same - // XXX lastModTime and fileSize. If not that would mean - // XXX that the dll wasn't registered properly. - } + return NS_OK; } - -FactoryEntry::FactoryEntry(const nsCID &aClass, nsIFactory *aFactory) - : cid(aClass), factory(aFactory), dll(NULL) +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); } - -FactoryEntry::~FactoryEntry(void) +nsresult +nsComponentManager::ProgIDToCLSID(const char *aProgID, + nsCID *aClass) { - if (factory != NULL) - { - factory->Release(); - } - // DO NOT DELETE nsDll *dll; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->ProgIDToCLSID(aProgID, aClass); } - -/***************************************************************************/ - -class ProgIDKey : public nsHashKey { -private: - char mProgIDBuf[64]; - char* mProgID; - -public: - ProgIDKey(const char* aProgID) : mProgID(mProgIDBuf) - { - PRInt32 len = PL_strlen(aProgID); - if (len >= sizeof(mProgIDBuf)) { - mProgID = new char[PL_strlen(aProgID) + 1]; - NS_ASSERTION(mProgID, "out of memory"); - if (! mProgID) - return; - } - - PL_strcpy(mProgID, aProgID); - } - - virtual ~ProgIDKey() { - if (mProgID != mProgIDBuf) - delete[] mProgID; - } - - virtual PRUint32 HashValue(void) const { - return (PRUint32) PL_HashString((const void*) mProgID); - } - - virtual PRBool Equals(const nsHashKey* aKey) const { - return PL_strcmp( ((ProgIDKey*)aKey)->mProgID, mProgID ) == 0; - } - - virtual nsHashKey* Clone() const { - return new ProgIDKey(mProgID); - } -}; - -/***************************************************************************/ - -#ifdef USE_NSREG -#define USE_REGISTRY - -/* - * platformDeleteKey() - * - * Deletes a key sub tree entirely. - */ -static nsresult platformDeleteKey(HREG hreg, RKEY rootkey, const char *keyname) + +nsresult +nsComponentManager::CLSIDToProgID(nsCID *aClass, + char* *aClassName, + char* *aProgID) { - RKEY key; - char subkeyname[MAXREGPATHLEN+1]; - int n = sizeof(subkeyname); - REGENUM state = 0; - - REGERR rerr = REGERR_OK; - - REGERR err = NR_RegGetKeyRaw(hreg, rootkey, (char *)keyname, &key); - if (err != REGERR_OK) - return (err); - - // Now recurse through and delete all keys under hierarchy - - subkeyname[0] = '\0'; - while (NR_RegEnumSubkeys(hreg, key, &state, subkeyname, n, REGENUM_NORMAL) == REGERR_OK) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: ...deleting %s", subkeyname)); - - rerr = platformDeleteKey(hreg, key, subkeyname); - - if (rerr != REGERR_OK) - { - break; - } - } - - // If success in deleting all subkeys, delete this key too - if (rerr == REGERR_OK) - { - err = NR_RegDeleteKeyRaw(hreg, rootkey, (char *)keyname); - } - else - { - err = rerr; - } - - return (err); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->CLSIDToProgID(aClass, aClassName, aProgID); } - - - -/** - * platformVersionCheck() - * - * Checks to see if the XPCOM hierarchy in the registry is the same as that of - * the software as defined by NS_XPCOM_REPOSITORY_VERSION_STRING - */ -static nsresult platformVersionCheck() + +nsresult +nsComponentManager::CreateInstance(const nsCID &aClass, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) { - HREG hreg; - REGERR err = NR_RegOpen(NULL, &hreg); - - if (err != REGERR_OK) - { - return (NS_ERROR_FAILURE); - } - - RKEY xpcomKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - char buf[MAXREGNAMELEN]; - uint32 len = sizeof(buf); - buf[0] = '\0'; - - err = NR_RegGetEntryString(hreg, xpcomKey, "VersionString", buf, len); - - // If there is a version mismatch or no version string, we got an old registry. - // Delete the old repository hierarchies and recreate version string - if (err != REGERR_OK || PL_strcmp(buf, NS_XPCOM_REPOSITORY_VERSION_STRING)) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: platformVersionCheck() failed. " - "Mismatch (%s vs %s). " - "Nuking xpcom registry hierarchy.", buf, NS_XPCOM_REPOSITORY_VERSION_STRING)); - - // Delete the XPCOM and CLSID hierarchy - RKEY akey; - NR_RegGetKey(hreg, ROOTKEY_COMMON, "Software/Netscape", &akey); - platformDeleteKey(hreg, akey, "XPCOM"); - NR_RegGetKey(hreg, ROOTKEY_COMMON, "Classes", &akey); - platformDeleteKey(hreg, akey, "Classes/CLSID"); - - // Recreate XPCOM and CLSID keys - NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey); - NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes/CLSID", NULL); - - NR_RegSetEntryString(hreg, xpcomKey, "VersionString", NS_XPCOM_REPOSITORY_VERSION_STRING); - } - else - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: platformVersionCheck() passed.")); - } - - NR_RegClose(hreg); - return (NS_OK); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->CreateInstance(aClass, aDelegate, aIID, aResult); } - -/** - * platformCreateDll(const char *fullname) - * - * Creates a nsDll from the registry representation of dll 'fullname'. - * Looks under - * ROOTKEY_COMMON/Software/Netscape/XPCOM/fullname - */ -static nsDll *platformCreateDll(const char *fullname) +nsresult +nsComponentManager::CreateInstance(const char *aProgID, + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) { - HREG hreg; - REGERR err = NR_RegOpen(NULL, &hreg); - - if (err != REGERR_OK) - { - return (NULL); - } - - RKEY xpcomKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NULL); - } - - RKEY key; - err = NR_RegGetKeyRaw(hreg, xpcomKey, (char *)fullname, &key); - if (err != REGERR_OK) - { - return (NULL); - } - - PRTime lastModTime = LL_ZERO; - PRUint32 fileSize = 0; - uint32 n = sizeof(lastModTime); - NR_RegGetEntry(hreg, key, "LastModTimeStamp", &lastModTime, &n); - n = sizeof(fileSize); - NR_RegGetEntry(hreg, key, "FileSize", &fileSize, &n); - - nsDll *dll = new nsDll(fullname, lastModTime, fileSize); - - return (dll); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->CreateInstance(aProgID, aDelegate, aIID, aResult); } -/** - * platformMarkNoComponents(nsDll *dll) - * - * Stores the dll name, last modified time, size and 0 for number of - * components in dll in the registry at location - * ROOTKEY_COMMON/Software/Netscape/XPCOM/dllname - */ -static nsresult platformMarkNoComponents(nsDll *dll) +nsresult +nsComponentManager::RegisterFactory(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory *aFactory, + PRBool aReplace) { - HREG hreg; - REGERR err = NR_RegOpen(NULL, &hreg); - - if (err != REGERR_OK) - { - return (NS_ERROR_FAILURE); - } - - // XXX Gross. LongLongs dont have a serialization format. This makes - // XXX the registry non-xp. Someone beat on the nspr people to get - // XXX a longlong serialization function please! - RKEY xpcomKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - RKEY key; - err = NR_RegAddKeyRaw(hreg, xpcomKey, (char *)dll->GetFullPath(), &key); - - if (err != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - PRTime lastModTime = dll->GetLastModifiedTime(); - PRUint32 fileSize = dll->GetSize(); - - NR_RegSetEntry(hreg, key, "LastModTimeStamp", REGTYPE_ENTRY_BYTES, - &lastModTime, sizeof(lastModTime)); - NR_RegSetEntry(hreg, key, "FileSize", REGTYPE_ENTRY_BYTES, - &fileSize, sizeof(fileSize)); - - char *ncomponentsString = "0"; - - NR_RegSetEntryString(hreg, key, "ComponentsCount", - ncomponentsString); - - NR_RegClose(hreg); - return (NS_OK); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->RegisterFactory(aClass, aClassName, aProgID, + aFactory, aReplace); } -static nsresult platformRegister(NSQuickRegisterData regd, nsDll *dll) +nsresult +nsComponentManager::RegisterComponent(const nsCID &aClass, + const char *aClassName, + const char *aProgID, + const char *aLibrary, + PRBool aReplace, + PRBool aPersist) { - HREG hreg; - // Preconditions - PR_ASSERT(regd != NULL); - PR_ASSERT(regd->CIDString != NULL); - PR_ASSERT(dll != NULL); - - REGERR err = NR_RegOpen(NULL, &hreg); - - if (err != REGERR_OK) - { - return (NS_ERROR_FAILURE); - } - - RKEY classesKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - RKEY key; - NR_RegAddKey(hreg, classesKey, "CLSID", &key); - NR_RegAddKeyRaw(hreg, key, (char *)regd->CIDString, &key); - - NR_RegSetEntryString(hreg, key, "ClassName", (char *)regd->className); - if (regd->progID) - NR_RegSetEntryString(hreg, key, "ProgID", (char *)(regd->progID)); - char *libName = (char *)dll->GetFullPath(); - NR_RegSetEntryString(hreg, key, "InprocServer", libName); - - if (regd->progID) - { - NR_RegAddKeyRaw(hreg, classesKey, (char *)regd->progID, &key); - NR_RegSetEntryString(hreg, key, "CLSID", (char *)regd->CIDString); - } - - // XXX Gross. LongLongs dont have a serialization format. This makes - // XXX the registry non-xp. Someone beat on the nspr people to get - // XXX a longlong serialization function please! - RKEY xpcomKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) - { - NR_RegClose(hreg); - // This aint a fatal error. It causes autoregistration to fail - // and hence the dll would be registered again the next time - // we startup. Let us run with it. - return (NS_OK); - } - - NR_RegAddKeyRaw(hreg, xpcomKey, (char *)dll->GetFullPath(), &key); - - PRTime lastModTime = dll->GetLastModifiedTime(); - PRUint32 fileSize = dll->GetSize(); - - NR_RegSetEntry(hreg, key, "LastModTimeStamp", REGTYPE_ENTRY_BYTES, - &lastModTime, sizeof(lastModTime)); - NR_RegSetEntry(hreg, key, "FileSize", REGTYPE_ENTRY_BYTES, - &fileSize, sizeof(fileSize)); - - unsigned int nComponents = 0; - char buf[MAXREGNAMELEN]; - uint32 len = sizeof(buf); - - if (NR_RegGetEntryString(hreg, key, "ComponentsCount", buf, len) == REGERR_OK) - { - nComponents = atoi(buf); - } - nComponents++; - PR_snprintf(buf, sizeof(buf), "%d", nComponents); - NR_RegSetEntryString(hreg, key, "ComponentsCount", buf); - - NR_RegClose(hreg); - return err; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->RegisterComponent(aClass, aClassName, aProgID, + aLibrary, aReplace, aPersist); } -static nsresult platformUnregister(NSQuickRegisterData regd, const char *aLibrary) -{ - HREG hreg; - REGERR err = NR_RegOpen(NULL, &hreg); - - if (err != REGERR_OK) - { - return (NS_ERROR_FAILURE); - } - - RKEY classesKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - RKEY key; - NR_RegAddKey(hreg, classesKey, "CLSID", &key); - RKEY cidKey; - NR_RegAddKeyRaw(hreg, key, (char *)regd->CIDString, &cidKey); - char progID[MAXREGNAMELEN]; - uint32 plen = sizeof(progID); - if (NR_RegGetEntryString(hreg, cidKey, "ProgID", progID, plen) == REGERR_OK) - { - NR_RegDeleteKey(hreg, classesKey, progID); - } - - NR_RegDeleteKey(hreg, key, (char *)regd->CIDString); - - RKEY xpcomKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) != REGERR_OK) - { - NR_RegClose(hreg); - // This aint a fatal error. It causes autoregistration to fail - // and hence the dll would be registered again the next time - // we startup. Let us run with it. - return (NS_OK); - } - - NR_RegGetKeyRaw(hreg, xpcomKey, (char *)aLibrary, &key); - - // We need to reduce the ComponentCount by 1. - // If the ComponentCount hits 0, delete the entire key. - int nComponents = 0; - char buf[MAXREGNAMELEN]; - uint32 len = sizeof(buf); - - if (NR_RegGetEntryString(hreg, key, "ComponentsCount", buf, len) == REGERR_OK) - { - nComponents = atoi(buf); - nComponents--; - } - if (nComponents <= 0) - { - NR_RegDeleteKey(hreg, key, (char *)aLibrary); - } - else - { - PR_snprintf(buf, sizeof(buf), "%d", nComponents); - NR_RegSetEntryString(hreg, key, "ComponentsCount", buf); - } - - NR_RegClose(hreg); - return (NS_OK); -} - -static FactoryEntry *platformFind(const nsCID &aCID) +nsresult +nsComponentManager::UnregisterFactory(const nsCID &aClass, + nsIFactory *aFactory) { - HREG hreg; - REGERR err = NR_RegOpen(NULL, &hreg); - - if (err != REGERR_OK) - { - return (NULL); - } - - RKEY classesKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NULL); - } - - RKEY key; - NR_RegAddKey(hreg, classesKey, "CLSID", &key); - - FactoryEntry *res = NULL; - - RKEY cidKey; - char *cidString = aCID.ToString(); - err = NR_RegGetKeyRaw(hreg, key, cidString, &cidKey); - delete [] cidString; - - if (err != REGERR_OK) - { - NR_RegClose(hreg); - return (NULL); - } - - // Get the library name, modifiedtime and size - PRTime lastModTime = LL_ZERO; - PRUint32 fileSize = 0; - - char buf[MAXREGNAMELEN]; - uint32 len = sizeof(buf); - err = NR_RegGetEntryString(hreg, cidKey, "InprocServer", buf, len); - if (err != REGERR_OK) - { - // Registry inconsistent. No File name for CLSID. - NR_RegClose(hreg); - return (NULL); - } - - char *library = buf; - - // XXX Gross. LongLongs dont have a serialization format. This makes - // XXX the registry non-xp. Someone beat on the nspr people to get - // XXX a longlong serialization function please! - RKEY xpcomKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Software/Netscape/XPCOM", &xpcomKey) == REGERR_OK) - { - if (NR_RegGetKeyRaw(hreg, xpcomKey, library, &key) == REGERR_OK) - { - uint32 n = sizeof(lastModTime); - NR_RegGetEntry(hreg, key, "LastModTimeStamp", &lastModTime, &n); - PR_ASSERT(n == sizeof(lastModTime)); - n = sizeof(fileSize); - NR_RegGetEntry(hreg, key, "FileSize", &fileSize, &n); - PR_ASSERT(n == sizeof(fileSize)); - } - } - - res = new FactoryEntry(aCID, library, lastModTime, fileSize); - - NR_RegClose(hreg); - - return (res); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->UnregisterFactory(aClass, aFactory); } - -static nsresult platformProgIDToCLSID(const char *aProgID, nsCID *aClass) +nsresult +nsComponentManager::UnregisterFactory(const nsCID &aClass, + const char *aLibrary) { - HREG hreg; - nsresult res = NS_ERROR_FAILURE; - - PR_ASSERT(aClass != NULL); - - REGERR err = NR_RegOpen(NULL, &hreg); - if (err != REGERR_OK) - { - return (NS_ERROR_FAILURE); - } - - RKEY classesKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - RKEY key; - err = NR_RegGetKeyRaw(hreg, classesKey, (char *)aProgID, &key); - if (err != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - char cidString[MAXREGNAMELEN]; - err = NR_RegGetEntryString(hreg, key, "CLSID", cidString, MAXREGNAMELEN); - if (err != REGERR_OK) - { - NR_RegClose(hreg); - return (NS_ERROR_FAILURE); - } - - NR_RegClose(hreg); - - if (!(aClass->Parse(cidString))) - { - return (NS_ERROR_FAILURE); - } - res = NS_OK; - return (res); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->UnregisterFactory(aClass, aLibrary); } -static nsresult platformCLSIDToProgID(nsCID *aClass, - char* *aClassName, char* *aProgID) +nsresult +nsComponentManager::UnregisterComponent(const nsCID &aClass, + const char *aLibrary) { - HREG hreg; - char* classnameString; - char* progidString; - nsresult res = NS_ERROR_FAILURE; - - char* cidStr = aClass->ToString(); - - PR_ASSERT(aClass != NULL); - - REGERR err = NR_RegOpen(NULL, &hreg); - if (err != REGERR_OK) - { - res = NS_ERROR_FAILURE; - goto done1; - } - - RKEY classesKey; - if (NR_RegAddKey(hreg, ROOTKEY_COMMON, "Classes", &classesKey) != REGERR_OK) - { - res = NS_ERROR_FAILURE; - goto done2; - } - - RKEY key; - err = NR_RegGetKeyRaw(hreg, classesKey, cidStr, &key); - if (err != REGERR_OK) - { - res = NS_ERROR_FAILURE; - goto done2; - } - - classnameString = new char[MAXREGNAMELEN]; - if (classnameString == NULL) { - res = NS_ERROR_OUT_OF_MEMORY; - goto done2; - } - err = NR_RegGetEntryString(hreg, key, "ClassName", classnameString, MAXREGNAMELEN); - if (err != REGERR_OK) - { - delete[] classnameString; - res = NS_ERROR_FAILURE; - goto done2; - } - *aClassName = classnameString; - - progidString = new char[MAXREGNAMELEN]; - if (progidString == NULL) { - delete[] classnameString; - res = NS_ERROR_OUT_OF_MEMORY; - goto done2; - } - err = NR_RegGetEntryString(hreg, key, "ProgID", progidString, MAXREGNAMELEN); - if (err != REGERR_OK) - { - delete[] progidString; - delete[] classnameString; - res = NS_ERROR_FAILURE; - goto done2; - } - - *aProgID = progidString; - res = NS_OK; - - done2: - NR_RegClose(hreg); - done1: - delete[] cidStr; - - return (res); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->UnregisterComponent(aClass, aLibrary); } -#endif // USE_NSREG - -/***************************************************************************/ - -/** - * LoadFactory() - * - * Given a FactoryEntry, this loads the dll if it has to, find the NSGetFactory - * symbol, calls the routine to create a new factory and returns it to the - * caller. - * - * No attempt is made to store the factory in any form anywhere. - */ -nsresult nsRepository::loadFactory(FactoryEntry *aEntry, - nsIFactory **aFactory) +nsresult +nsComponentManager::FreeLibraries(void) { - if (aFactory == NULL) - { - return NS_ERROR_NULL_POINTER; - } - *aFactory = NULL; - - // loadFactory() cannot be called for entries that are CID<->factory - // mapping entries for the session. - PR_ASSERT(aEntry->dll != NULL); - - if (aEntry->dll->IsLoaded() == PR_FALSE) - { - // Load the dll - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + Loading \"%s\".", aEntry->dll->GetFullPath())); - if (aEntry->dll->Load() == PR_FALSE) - { - PR_LOG(logmodule, PR_LOG_ERROR, - ("nsRepository: Library load unsuccessful.")); - return (NS_ERROR_FAILURE); - } - } - -#ifdef MOZ_TRACE_XPCOM_REFCNT - // Inform refcnt tracer of new library so that calls through the - // new library can be traced. - nsTraceRefcnt::LoadLibrarySymbols(aEntry->dll->GetFullPath(), aEntry->dll->GetInstance()); -#endif - nsFactoryProc proc = (nsFactoryProc) aEntry->dll->FindSymbol("NSGetFactory"); - if (proc != NULL) - { - char* className = NULL; - char* progID = NULL; - - // XXX dp, warren: deal with this! - //(void)CLSIDToProgID(&aEntry->cid, &className, &progID); - - nsIServiceManager* serviceMgr = NULL; - nsresult res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - NS_ASSERTION(NS_SUCCEEDED(res), "no service manager"); - - res = proc(serviceMgr, aEntry->cid, className, progID, aFactory); - - if (className) - delete[] className; - if (progID) - delete[] progID; - return res; - } - PR_LOG(logmodule, PR_LOG_ERROR, - ("nsRepository: NSGetFactory entrypoint not found.")); - return NS_ERROR_FACTORY_NOT_LOADED; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->FreeLibraries(); } - -/** - * FindFactory() - * - * Given a classID, this finds the factory for this CID by first searching the - * local CID<->factory mapping. Next it searches for a Dll that implements - * this classID and calls LoadFactory() to create the factory. - * - * Again, no attempt is made at storing the factory. - */ -nsresult nsRepository::FindFactory(const nsCID &aClass, - nsIFactory **aFactory) +nsresult +nsComponentManager::AutoRegister(nsIComponentManager::RegistrationTime when, + const char* pathlist) { - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: FindFactory(%s)", buf); - delete [] buf; - } - - PR_ASSERT(aFactory != NULL); - - PR_EnterMonitor(monitor); - - nsIDKey key(aClass); - FactoryEntry *entry = (FactoryEntry*) factories->Get(&key); - - nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; - -#ifdef USE_REGISTRY - if (entry == NULL) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, ("\t\tnot found in factory cache. Looking in registry")); - entry = platformFind(aClass); - - // XXX This should go into platformFind(), and platformFind() - // should just become a static method on nsRepository. - - // If we got one, cache it in our hashtable - if (entry != NULL) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, ("\t\tfound in registry.")); - factories->Put(&key, entry); - } - - // XXX update ProgID cache, if necessary - } - else - { - PR_LOG(logmodule, PR_LOG_ALWAYS, ("\t\tfound in factory cache.")); - } -#endif - - PR_ExitMonitor(monitor); - - if (entry != NULL) - { - if ((entry)->factory == NULL) - { - res = loadFactory(entry, aFactory); - } - else - { - *aFactory = entry->factory; - (*aFactory)->AddRef(); - res = NS_OK; - } - } - - PR_LOG(logmodule, PR_LOG_WARNING, - ("\t\tFindFactory() %s", - NS_SUCCEEDED(res) ? "succeeded" : "FAILED")); - - return res; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->AutoRegister(when, pathlist); } - -/** - * ProgIDToCLSID() - * - * Mapping function from a ProgID to a classID. Directly talks to the registry. - * - * XXX We need to add a cache this translation as this is done a lot. - */ -nsresult nsRepository::ProgIDToCLSID(const char *aProgID, - nsCID *aClass) +nsresult +nsComponentManager::AddToDefaultPathList(const char *pathlist) { - NS_PRECONDITION(aProgID != NULL, "null ptr"); - if (! aProgID) - return NS_ERROR_NULL_POINTER; - - NS_PRECONDITION(aClass != NULL, "null ptr"); - if (! aClass) - return NS_ERROR_NULL_POINTER; - - nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; - - checkInitialized(); - -#ifdef USE_REGISTRY - // XXX This isn't quite the best way to do this: we should - // probably move an nsArray into the FactoryEntry class, - // and then have the construct/destructor of the factory entry - // keep the ProgID to CID cache up-to-date. However, doing this - // significantly improves performance, so it'll do for now. - -#define NS_NO_CID { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } } -static NS_DEFINE_CID(kNoCID, NS_NO_CID); - - ProgIDKey key(aProgID); - nsCID* cid = (nsCID*) progIDs->Get(&key); - if (cid) { - if (cid == &kNoCID) { - // we've already tried to map this ProgID to a CLSID, and found - // that there _was_ no such mapping in the registry. - } - else { - *aClass = *cid; - res = NS_OK; - } - } - else { - // This is the first time someone has asked for this - // ProgID. Go to the registry to find the CID. - res = platformProgIDToCLSID(aProgID, aClass); - - if (NS_SUCCEEDED(res)) { - // Found it. So put it into the cache. - if (! (cid = new nsCID(*aClass))) - return NS_ERROR_OUT_OF_MEMORY; - - progIDs->Put(&key, cid); - } - else { - // Didn't find it. Put a special CID in the cache so we - // don't need to hit the registry on subsequent requests - // for the same ProgID. - progIDs->Put(&key, (void*) &kNoCID); - } - } -#endif /* USE_REGISTRY */ - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf; - if (NS_SUCCEEDED(res)) - buf = aClass->ToString(); - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: ProgIDToCLSID(%s)->%s", aProgID, - NS_SUCCEEDED(res) ? buf : "[FAILED]")); - if (NS_SUCCEEDED(res)) - delete [] buf; - } - - return res; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->AddToDefaultPathList(pathlist); } - -/** - * CLSIDToProgID() - * - * Translates a classID to a {ProgID, Class Name}. Does direct registry - * access to do the translation. - * - * XXX Would be nice to hook in a cache here too. - */ -nsresult nsRepository::CLSIDToProgID(nsCID *aClass, - char* *aClassName, - char* *aProgID) +nsresult +nsComponentManager::SyncComponentsInPathList(const char *pathlist) { - nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; - - checkInitialized(); - -#ifdef USE_REGISTRY - res = platformCLSIDToProgID(aClass, aClassName, aProgID); -#endif /* USE_REGISTRY */ - - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass->ToString(); - PR_LOG(logmodule, PR_LOG_WARNING, - ("nsRepository: CLSIDToProgID(%s)->%s", buf, - NS_SUCCEEDED(res) ? *aProgID : "[FAILED]")); - delete [] buf; - } - - return res; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->SyncComponentsInPathList(pathlist); } - -/** - * checkInitialized() - * - * Local function to make sure the repository is initialized. The repository - * is mostly full of static functions. We dont want to initialize ourselves - * with a static constructor as that wont make the code portable. Hence, - * in all our public entry points, we check if we are initialized and - * initialize ourselves if we aren't already. - */ -nsresult nsRepository::checkInitialized(void) +nsresult +nsComponentManager::SyncComponentsInDir(const char *path) { - nsresult res = NS_OK; - if (factories == NULL) - { - res = Initialize(); - } - return res; + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->SyncComponentsInDir(path); } - -/** - * Initialize() - * - * Initialization of our global pointers. Also, the libreg/ is started here and - * if the xpcom hierarchy in the registry isn't the same as the version that we - * expect, it is nuked. - * - * XXX Plus for now autoregistration() begins here. We will remove it once the - * XXX application takes control of it. - */ -nsresult nsRepository::Initialize(void) +nsresult +nsComponentManager::SyncComponentsInFile(const char *fullname) { - if (factories == NULL) - { - factories = new nsHashtable(); - } - if (progIDs == NULL) - { - progIDs = new nsHashtable(); - } - if (monitor == NULL) - { - monitor = PR_NewMonitor(); - } - if (logmodule == NULL) - { - logmodule = PR_NewLogModule("nsRepository"); - } - if (dllStore == NULL) - { - dllStore = new nsDllStore(); - } - - PR_LOG(logmodule, PR_LOG_ALWAYS, ("nsRepository: Initialized.")); -#ifdef USE_NSREG - NR_StartupRegistry(); - - // Check the version of registry. Nuke old versions. - platformVersionCheck(); -#endif - - // Initiate autoreg - AutoRegister(NS_Startup, NULL); - - return NS_OK; -} - - -/** - * CreateInstance() - * - * Create an instance of an object that implements an interface and belongs - * to the implementation aClass using the factory. The factory is immediately - * released and not held onto for any longer. - */ -nsresult nsRepository::CreateInstance(const nsCID &aClass, - nsISupports *aDelegate, - const nsIID &aIID, - void **aResult) -{ - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: CreateInstance(%s)", buf); - delete [] buf; - } - if (aResult == NULL) - { - return NS_ERROR_NULL_POINTER; - } - *aResult = NULL; - - nsIFactory *factory = NULL; - nsresult res = FindFactory(aClass, &factory); - if (NS_SUCCEEDED(res)) - { - res = factory->CreateInstance(aDelegate, aIID, aResult); - factory->Release(); - PR_LOG(logmodule, PR_LOG_ALWAYS, ("\t\tCreateInstance() succeeded.")); - return res; - } - - PR_LOG(logmodule, PR_LOG_ALWAYS, ("\t\tCreateInstance() FAILED.")); - return NS_ERROR_FACTORY_NOT_REGISTERED; -} - - -/** - * CreateInstance() - * - * An overload of CreateInstance() that creates an instance of the object that - * implements the interface aIID and whose implementation has a progID aProgID. - * - * This is only a convenience routine that turns around can calls the - * CreateInstance() with classid and iid. - * - * XXX This is a function overload. We need to remove it. - */ -nsresult nsRepository::CreateInstance(const char *aProgID, - nsISupports *aDelegate, - const nsIID &aIID, - void **aResult) -{ - nsCID clsid; - nsresult rv = ProgIDToCLSID(aProgID, &clsid); - if (NS_FAILED(rv)) return rv; - return CreateInstance(clsid, aDelegate, aIID, aResult); -} - - -#if 0 -/* -nsresult nsRepository::CreateInstance2(const nsCID &aClass, - nsISupports *aDelegate, - const nsIID &aIID, - void *aSignature, - void **aResult) -{ - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: Creating Instance."); - PR_LogPrint("nsRepository: + %s.", - buf); - PR_LogPrint("nsRepository: + Signature = %p.", - aSignature); - delete [] buf; - } - if (aResult == NULL) - { - return NS_ERROR_NULL_POINTER; - } - *aResult = NULL; - - nsIFactory *factory = NULL; - - nsresult res = FindFactory(aClass, &factory); - - if (NS_SUCCEEDED(res)) - { - nsIFactory2 *factory2 = NULL; - res = NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT; - - factory->QueryInterface(kFactory2IID, (void **) &factory2); - - if (factory2 != NULL) - { - res = factory2->CreateInstance2(aDelegate, aIID, aSignature, aResult); - factory2->Release(); - } - - factory->Release(); - return res; - } - - return NS_ERROR_FACTORY_NOT_REGISTERED; -} -*/ -#endif /* 0 */ - - -/** - * RegisterFactory() - * - * Register a factory to be responsible for creation of implementation of - * classID aClass. Plus creates as association of aClassName and aProgID - * to the classID. If replace is PR_TRUE, we replace any existing registrations - * with this one. - * - * Once registration is complete, we add the class to the factories cache - * that we maintain. The factories cache is the ONLY place where these - * registrations are ever kept. - * - * XXX This uses FindFactory() to test if a factory already exists. This - * XXX has the bad side effect of loading the factory if the previous - * XXX registration was a dll for this class. We might be able to do away - * XXX with such a load. - */ -nsresult nsRepository::RegisterFactory(const nsCID &aClass, - const char *aClassName, - const char *aProgID, - nsIFactory *aFactory, - PRBool aReplace) -{ - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: RegisterFactory(%s, factory), replace = %d.", buf, (int)aReplace); - delete [] buf; - } - - nsIFactory *old = NULL; - FindFactory(aClass, &old); - - if (old != NULL) - { - old->Release(); - if (!aReplace) - { - PR_LOG(logmodule, PR_LOG_WARNING, ("\t\tFactory already registered.")); - return NS_ERROR_FACTORY_EXISTS; - } - else - { - PR_LOG(logmodule, PR_LOG_WARNING, ("\t\tdeleting old Factory Entry.")); - } - } - - PR_EnterMonitor(monitor); - - nsIDKey key(aClass); - factories->Put(&key, new FactoryEntry(aClass, aFactory)); - - // XXX update ProgID to CID cache as well, if necessary - - PR_ExitMonitor(monitor); - - PR_LOG(logmodule, PR_LOG_WARNING, - ("\t\tFactory register succeeded.")); - - return NS_OK; -} - - -nsresult nsRepository::RegisterComponent(const nsCID &aClass, - const char *aClassName, - const char *aProgID, - const char *aLibrary, - PRBool aReplace, - PRBool aPersist) -{ - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: RegisterComponent(%s, %s, %s, %s), replace = %d, persist = %d.", buf, aClassName, aProgID, aLibrary, (int)aReplace, (int)aPersist); - delete [] buf; - } - - nsIFactory *old = NULL; - FindFactory(aClass, &old); - - if (old != NULL) - { - old->Release(); - if (!aReplace) - { - PR_LOG(logmodule, PR_LOG_WARNING,("\t\tFactory already registered.")); - return NS_ERROR_FACTORY_EXISTS; - } - else - { - PR_LOG(logmodule, PR_LOG_WARNING,("\t\tdeleting registered Factory.")); - } - } - - PR_EnterMonitor(monitor); - -#ifdef USE_REGISTRY - if (aPersist == PR_TRUE) - { - // Add it to the registry - nsDll *dll = new nsDll(aLibrary); - // XXX temp hack until we get the dll to give us the entire - // XXX NSQuickRegisterClassData - NSQuickRegisterClassData cregd = {0}; - cregd.CIDString = aClass.ToString(); - cregd.className = aClassName; - cregd.progID = aProgID; - platformRegister(&cregd, dll); - delete [] (char *)cregd.CIDString; - delete dll; - } - else -#endif - { - nsDll *dll = new nsDll(aLibrary); - nsIDKey key(aClass); - factories->Put(&key, new FactoryEntry(aClass, aLibrary, - dll->GetLastModifiedTime(), dll->GetSize())); - - // XXX Update ProgID to CID cache as well, if necessary. - - delete dll; - } - - PR_ExitMonitor(monitor); - - PR_LOG(logmodule, PR_LOG_WARNING, - ("\t\tFactory register succeeded.")); - - return NS_OK; -} - - -nsresult nsRepository::UnregisterFactory(const nsCID &aClass, - nsIFactory *aFactory) -{ - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: Unregistering Factory."); - PR_LogPrint("nsRepository: + %s.", buf); - delete [] buf; - } - - - nsIDKey key(aClass); - nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; - FactoryEntry *old = (FactoryEntry *) factories->Get(&key); - if (old != NULL) - { - if (old->factory == aFactory) - { - PR_EnterMonitor(monitor); - old = (FactoryEntry *) factories->Remove(&key); - PR_ExitMonitor(monitor); - delete old; - res = NS_OK; - } - - } - - PR_LOG(logmodule, PR_LOG_WARNING, - ("nsRepository: ! Factory unregister %s.", - res == NS_OK ? "succeeded" : "failed")); - - return res; -} - - -nsresult nsRepository::UnregisterComponent(const nsCID &aClass, - const char *aLibrary) -{ - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: Unregistering Factory."); - PR_LogPrint("nsRepository: + %s in \"%s\".", buf, aLibrary); - delete [] buf; - } - - nsIDKey key(aClass); - FactoryEntry *old = (FactoryEntry *) factories->Get(&key); - - nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; - - PR_EnterMonitor(monitor); - - if (old != NULL && old->dll != NULL) - { - if (old->dll->GetFullPath() != NULL && -#ifdef XP_UNIX - PL_strcasecmp(old->dll->GetFullPath(), aLibrary) -#else - PL_strcmp(old->dll->GetFullPath(), aLibrary) -#endif - ) - { - FactoryEntry *entry = (FactoryEntry *) factories->Remove(&key); - delete entry; - res = NS_OK; - } -#ifdef USE_REGISTRY - // XXX temp hack until we get the dll to give us the entire - // XXX NSQuickRegisterClassData - NSQuickRegisterClassData cregd = {0}; - cregd.CIDString = aClass.ToString(); - res = platformUnregister(&cregd, aLibrary); - delete [] (char *)cregd.CIDString; -#endif - } - - PR_ExitMonitor(monitor); - - PR_LOG(logmodule, PR_LOG_WARNING, - ("nsRepository: ! Factory unregister %s.", - res == NS_OK ? "succeeded" : "failed")); - - return res; -} - - -nsresult nsRepository::UnregisterFactory(const nsCID &aClass, - const char *aLibrary) -{ - checkInitialized(); - if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) - { - char *buf = aClass.ToString(); - PR_LogPrint("nsRepository: Unregistering Factory."); - PR_LogPrint("nsRepository: + %s in \"%s\".", buf, aLibrary); - delete [] buf; - } - - nsIDKey key(aClass); - FactoryEntry *old = (FactoryEntry *) factories->Get(&key); - - nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; - - PR_EnterMonitor(monitor); - - if (old != NULL && old->dll != NULL) - { - if (old->dll->GetFullPath() != NULL && -#ifdef XP_UNIX - PL_strcasecmp(old->dll->GetFullPath(), aLibrary) -#else - PL_strcmp(old->dll->GetFullPath(), aLibrary) -#endif - ) - { - FactoryEntry *entry = (FactoryEntry *) factories->Remove(&key); - delete entry; - res = NS_OK; - } -#ifdef USE_REGISTRY - // XXX temp hack until we get the dll to give us the entire - // XXX NSQuickRegisterClassData - NSQuickRegisterClassData cregd = {0}; - cregd.CIDString = aClass.ToString(); - res = platformUnregister(&cregd, aLibrary); - delete [] (char *)cregd.CIDString; -#endif - } - - PR_ExitMonitor(monitor); - - PR_LOG(logmodule, PR_LOG_WARNING, - ("nsRepository: ! Factory unregister %s.", - res == NS_OK ? "succeeded" : "failed")); - - return res; -} - - -static PRBool freeLibraryEnum(nsHashKey *aKey, void *aData, void* closure) -{ - FactoryEntry *entry = (FactoryEntry *) aData; - - if (entry->dll->IsLoaded() == PR_TRUE) - { - nsCanUnloadProc proc = (nsCanUnloadProc) entry->dll->FindSymbol("NSCanUnload"); - if (proc != NULL) - { - nsIServiceManager* serviceMgr = NULL; - nsresult res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - NS_ASSERTION(res == NS_OK, "no service manager"); - - res = proc(serviceMgr); - if (res) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + Unloading \"%s\".", entry->dll->GetFullPath())); - entry->dll->Unload(); - } - } - } - - return PR_TRUE; -} - -nsresult nsRepository::FreeLibraries(void) -{ - PR_EnterMonitor(monitor); - - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: Freeing Libraries.")); - factories->Enumerate(freeLibraryEnum); - - PR_ExitMonitor(monitor); - - return NS_OK; -} - - -/** - * AutoRegister(RegistrationInstant, const char *pathlist) - * - * Given a ; separated list of paths, this will ensure proper registration - * of all components. A default pathlist is maintained in the registry at - * \\HKEYROOT_COMMON\\Classes\\PathList - * In addition to looking at the pathlist, the default pathlist is looked at. - * - * This will take care not loading already registered dlls, finding and - * registering new dlls, re-registration of modified dlls - * - */ - -nsresult nsRepository::AutoRegister(NSRegistrationInstant when, - const char* pathlist) -{ -#ifdef XP_MAC - CInfoPBRec catInfo; - Handle pathH; - OSErr err; - ProcessSerialNumber psn; - ProcessInfoRec pInfo; - FSSpec appFSSpec; - FSSpec tempSpec; - long theDirID; - Str255 name; -#endif - - if (pathlist != NULL) - { - SyncComponentsInPathList(pathlist); - } - -#ifdef XP_MAC - // get info for the the current process to determine the directory its located in - if (!(err = GetCurrentProcess(&psn))) - { - // initialize ProcessInfoRec before calling GetProcessInformation() or die horribly. - pInfo.processName = nil; - pInfo.processAppSpec = &tempSpec; - pInfo.processInfoLength = sizeof(ProcessInfoRec); - if (!(err = GetProcessInformation(&psn, &pInfo))) - { - appFSSpec = *(pInfo.processAppSpec); - if ((pathH = NewHandle(1)) != NULL) - { - **pathH = '\0'; // initially null terminate the string - HNoPurge(pathH); - HUnlock(pathH); - theDirID = appFSSpec.parID; - do - { - catInfo.dirInfo.ioCompletion = NULL; - catInfo.dirInfo.ioNamePtr = (StringPtr)&name; - catInfo.dirInfo.ioVRefNum = appFSSpec.vRefNum; - catInfo.dirInfo.ioDrDirID = theDirID; - catInfo.dirInfo.ioFDirIndex = -1; // -1 = query dir in ioDrDirID - if (!(err = PBGetCatInfoSync(&catInfo))) - { - // build up a Unix style pathname due to NSPR - // XXX Note: this breaks if any of the parent - // directories contain a "slash" (blame NSPR) - - Munger(pathH, 0L, NULL, 0L, (const void *)&name[1], (long)name[0]); // prepend dir name - Munger(pathH, 0L, NULL, 0L, "/", 1); // prepend slash - - // move up to parent directory - theDirID = catInfo.dirInfo.ioDrParID; - } - } while ((!err) && (catInfo.dirInfo.ioDrDirID != 2)); // 2 = root - if (!err) - { - Munger(pathH, GetHandleSize(pathH)-1, NULL, 0L, "/components", 11); // append "/components" - HLock(pathH); - SyncComponentsInPathList((const char *)(*pathH)); - HUnlock(pathH); - } - DisposeHandle(pathH); - } - } - } -#else - //XXX get default pathlist from registry - //XXX Temporary hack. Registering components from components directory - const char *defaultPathList = "./components"; - SyncComponentsInPathList(defaultPathList); -#endif - return (NS_OK); -} - - -nsresult nsRepository::AddToDefaultPathList(const char *pathlist) -{ - //XXX add pathlist to the defaultpathlist in the registry - return (NS_ERROR_FAILURE); -} - -nsresult nsRepository::SyncComponentsInPathList(const char *pathlist) -{ - char *paths = PL_strdup(pathlist); - - if (paths == NULL || *paths == '\0') - return(NS_ERROR_FAILURE); - - char *pathsMem = paths; - while (paths != NULL) - { - char *nextpath = PL_strchr(paths, NS_PATH_SEPARATOR); - if (nextpath != NULL) *nextpath = '\0'; - SyncComponentsInDir(paths); - paths = nextpath; - } - PL_strfree(pathsMem); - return (NS_OK); -} - -nsresult nsRepository::SyncComponentsInDir(const char *dir) -{ - PRDir *prdir = PR_OpenDir(dir); - if (prdir == NULL) - return (NS_ERROR_FAILURE); - - // Create a buffer that has dir/ in it so we can append - // the filename each time in the loop - char fullname[NS_MAX_FILENAME_LEN]; - PL_strncpyz(fullname, dir, sizeof(fullname)); - unsigned int n = strlen(fullname); - if (n+1 < sizeof(fullname)) - { - fullname[n] = '/'; - n++; - } - char *filepart = fullname + n; - - PRDirEntry *dirent = NULL; - while ((dirent = PR_ReadDir(prdir, PR_SKIP_BOTH)) != NULL) - { - PL_strncpyz(filepart, dirent->name, sizeof(fullname)-n); - nsresult ret = SyncComponentsInFile(fullname); - if (NS_FAILED(ret) && - NS_ERROR_GET_CODE(ret) == NS_XPCOM_ERRORCODE_IS_DIR) - { - SyncComponentsInDir(fullname); - } - } // foreach file - PR_CloseDir(prdir); - return (NS_OK); -} - -nsresult nsRepository::SyncComponentsInFile(const char *fullname) -{ - const char *ValidDllExtensions[] = { - ".dll", /* Windows */ - ".dso", /* Unix */ - ".so", /* Unix */ - ".sl", /* Unix: HP */ - ".shlb", /* Mac ? */ - ".dlm", /* new for all platforms */ - NULL - }; - - - PRFileInfo statbuf; - if (PR_GetFileInfo(fullname,&statbuf) != PR_SUCCESS) - { - // Skip files that cannot be stat - return (NS_ERROR_FAILURE); - } - - if (statbuf.type == PR_FILE_DIRECTORY) - { - // Cant register a directory - return (NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, - NS_XPCOM_ERRORCODE_IS_DIR)); - } - else if (statbuf.type != PR_FILE_FILE) - { - // Skip non-files - return (NS_ERROR_FAILURE); - } - - // deal with only files that have the right extension - PRBool validExtension = PR_FALSE; - int flen = PL_strlen(fullname); - for (int i=0; ValidDllExtensions[i] != NULL; i++) - { - int extlen = PL_strlen(ValidDllExtensions[i]); - - // Does fullname end with this extension - if (flen >= extlen && - !PL_strcasecmp(&(fullname[flen - extlen]), ValidDllExtensions[i]) - ) - { - validExtension = PR_TRUE; - break; - } - } - - if (validExtension == PR_FALSE) - { - // Skip invalid extensions - return (NS_ERROR_FAILURE); - } - - // Check if dll is one that we have already seen - nsDll *dll = dllStore->Get(fullname); - if (dll == NULL) - { - // XXX Create nsDll for this from registry and - // XXX add it to our dll cache dllStore. -#ifdef USE_REGISTRY - dll = platformCreateDll(fullname); -#endif /* USE_REGISTRY */ - } - - if (dll != NULL) - { - // Make sure the dll is OK - if (dll->GetStatus() != NS_OK) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + nsDll not NS_OK \"%s\". Skipping...", - dll->GetFullPath())); - return (NS_ERROR_FAILURE); - } - - // We already have seen this dll. Check if this dll changed - if (LL_EQ(dll->GetLastModifiedTime(), statbuf.modifyTime) && - (dll->GetSize() == statbuf.size)) - { - // Dll hasn't changed. Skip. - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + nsDll not changed \"%s\". Skipping...", - dll->GetFullPath())); - return (NS_OK); - } - - // Aagh! the dll has changed since the last time we saw it. - // re-register dll - if (dll->IsLoaded()) - { - // We are screwed. We loaded the old version of the dll - // and now we find that the on-disk copy if newer. - // The only thing to do would be to ask the dll if it can - // unload itself. It can do that if it hasn't created objects - // yet. - nsCanUnloadProc proc = (nsCanUnloadProc) - dll->FindSymbol("NSCanUnload"); - if (proc != NULL) - { - nsIServiceManager* serviceMgr = NULL; - nsresult rv = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - NS_ASSERTION(rv == NS_OK, "no service manager"); - - PRBool res = proc(serviceMgr /*, PR_TRUE*/); - if (res) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + Unloading \"%s\".", - dll->GetFullPath())); - dll->Unload(); - } - else - { - // THIS IS THE WORST SITUATION TO BE IN. - // Dll doesn't want to be unloaded. Cannot re-register - // this dll. - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: *** Dll already loaded. " - "Cannot unload either. Hence cannot re-register " - "\"%s\". Skipping...", dll->GetFullPath())); - return (NS_ERROR_FAILURE); - } - } - else - { - // dll doesn't have a CanUnload proc. Guess it is - // ok to unload it. - dll->Unload(); - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + Unloading \"%s\". (no CanUnloadProc).", - dll->GetFullPath())); - - } - - } // dll isloaded - - // Sanity. - if (dll->IsLoaded()) - { - // We went through all the above to make sure the dll - // is unloaded. And here we are with the dll still - // loaded. Whoever taught dp programming... - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: Dll still loaded. Cannot re-register " - "\"%s\". Skipping...", dll->GetFullPath())); - return (NS_ERROR_FAILURE); - } - } // dll != NULL - else - { - // Create and add the dll to the dllStore - // It is ok to do this even if the creation of nsDll - // didnt succeed. That way we wont do this again - // when we encounter the same dll. - dll = new nsDll(fullname); - dllStore->Put(fullname, dll); - } // dll == NULL - - // Either we are seeing the dll for the first time or the dll has - // changed since we last saw it and it is unloaded successfully. - // - // Now we can try register the dll for sure. - nsresult res = SelfRegisterDll(dll); - nsresult ret = NS_OK; - if (NS_FAILED(res)) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: Autoregistration FAILED for " - "\"%s\". Skipping...", dll->GetFullPath())); - // Mark dll as not xpcom dll along with modified time and size in - // the registry so that we wont need to load the dll again every - // session until the dll changes. -#ifdef USE_REGISTRY - platformMarkNoComponents(dll); -#endif /* USE_REGISTRY */ - ret = NS_ERROR_FAILURE; - } - else - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: Autoregistration Passed for " - "\"%s\". Skipping...", dll->GetFullPath())); - // Marking dll along with modified time and size in the - // registry happens at platformregister(). No need to do it - // here again. - } - return (ret); -} - - -/* -* SelfRegisterDll -* -* Given a dll abstraction, this will load, selfregister the dll and -* unload the dll. -* -*/ -nsresult nsRepository::SelfRegisterDll(nsDll *dll) -{ - // Precondition: dll is not loaded already - PR_ASSERT(dll->IsLoaded() == PR_FALSE); - - nsresult res = NS_ERROR_FAILURE; - - if (dll->Load() == PR_FALSE) - { - // Cannot load. Probably not a dll. - return(NS_ERROR_FAILURE); - } - - nsRegisterProc regproc = (nsRegisterProc)dll->FindSymbol("NSRegisterSelf"); - - if (regproc == NULL) - { - // Smart registration - NSQuickRegisterData qr = (NSQuickRegisterData)dll->FindSymbol( - NS_QUICKREGISTER_DATA_SYMBOL); - if (qr == NULL) - { - res = NS_ERROR_NO_INTERFACE; - } - else - { - // XXX register the quick registration data on behalf of the dll - // XXX for now return failure - res = NS_ERROR_FAILURE; - } - } - else - { - // Call the NSRegisterSelfProc to enable dll registration - nsIServiceManager* serviceMgr = NULL; - res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - NS_ASSERTION(res == NS_OK, "no service manager"); - - res = regproc(serviceMgr, dll->GetFullPath()); - } - dll->Unload(); - return (res); -} - - -nsresult nsRepository::SelfUnregisterDll(nsDll *dll) -{ - // Precondition: dll is not loaded - PR_ASSERT(dll->IsLoaded() == PR_FALSE); - - if (dll->Load() == PR_FALSE) - { - // Cannot load. Probably not a dll. - return(NS_ERROR_FAILURE); - } - - nsUnregisterProc unregproc = - (nsUnregisterProc) dll->FindSymbol("NSUnregisterSelf"); - nsresult res = NS_OK; - - if (unregproc == NULL) - { - // Smart unregistration - NSQuickRegisterData qr = (NSQuickRegisterData) - dll->FindSymbol(NS_QUICKREGISTER_DATA_SYMBOL); - if (qr == NULL) - { - return(NS_ERROR_NO_INTERFACE); - } - // XXX unregister the dll based on the quick registration data - } - else - { - // Call the NSUnregisterSelfProc to enable dll de-registration - nsIServiceManager* serviceMgr = NULL; - res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - NS_ASSERTION(res == NS_OK, "no service manager"); - - res = unregproc(serviceMgr, dll->GetFullPath()); - } - dll->Unload(); - return (res); + nsIComponentManager* cm; + nsresult rv = NS_GetGlobalComponentManager(&cm); + if (NS_FAILED(rv)) return rv; + return cm->SyncComponentsInFile(fullname); } diff --git a/mozilla/xpcom/src/nsServiceManager.cpp b/mozilla/xpcom/src/nsServiceManager.cpp index 26d3fdaa264..fec1cf67aa9 100644 --- a/mozilla/xpcom/src/nsServiceManager.cpp +++ b/mozilla/xpcom/src/nsServiceManager.cpp @@ -17,10 +17,14 @@ */ #include "nsIServiceManager.h" +#include "nsIComponentManager.h" #include "nsVector.h" +#include "nsHashtable.h" #include "prcmon.h" #include "prthread.h" /* XXX: only used for the NSPR initialization hack (rick) */ +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); + class nsServiceEntry { public: @@ -51,7 +55,7 @@ nsServiceEntry::~nsServiceEntry() PRUint32 size = mListeners->GetSize(); for (PRUint32 i = 0; i < size; i++) { nsIShutdownListener* listener = (nsIShutdownListener*)(*mListeners)[i]; - listener->Release(); + NS_RELEASE(listener); } #endif delete mListeners; @@ -68,9 +72,9 @@ nsServiceEntry::AddListener(nsIShutdownListener* listener) if (mListeners == NULL) return NS_ERROR_OUT_OF_MEMORY; } - PRInt32 err = mListeners->Add(listener); - listener->AddRef(); - return err == -1 ? NS_ERROR_FAILURE : NS_OK; + PRInt32 rv = mListeners->Add(listener); + NS_ADDREF(listener); + return rv == -1 ? NS_ERROR_FAILURE : NS_OK; } nsresult @@ -83,7 +87,7 @@ nsServiceEntry::RemoveListener(nsIShutdownListener* listener) for (PRUint32 i = 0; i < size; i++) { if ((*mListeners)[i] == listener) { mListeners->Remove(i); - listener->Release(); + NS_RELEASE(listener); return NS_OK; } } @@ -98,9 +102,9 @@ nsServiceEntry::NotifyListeners(void) PRUint32 size = mListeners->GetSize(); for (PRUint32 i = 0; i < size; i++) { nsIShutdownListener* listener = (nsIShutdownListener*)(*mListeners)[0]; - nsresult err = listener->OnShutdown(mClassID, mService); - if (err) return err; - listener->Release(); + nsresult rv = listener->OnShutdown(mClassID, mService); + if (NS_FAILED(rv)) return rv; + NS_RELEASE(listener); mListeners->Remove(0); } NS_ASSERTION(mListeners->GetSize() == 0, "failed to notify all listeners"); @@ -115,6 +119,12 @@ nsServiceEntry::NotifyListeners(void) class nsServiceManagerImpl : public nsIServiceManager { public: + NS_IMETHOD + RegisterService(const nsCID& aClass, nsISupports* aService); + + NS_IMETHOD + UnregisterService(const nsCID& aClass); + NS_IMETHOD GetService(const nsCID& aClass, const nsIID& aIID, nsISupports* *result, @@ -124,18 +134,15 @@ public: ReleaseService(const nsCID& aClass, nsISupports* service, nsIShutdownListener* shutdownListener = NULL); - NS_IMETHOD - ShutdownService(const nsCID& aClass); - nsServiceManagerImpl(void); - + NS_DECL_ISUPPORTS protected: virtual ~nsServiceManagerImpl(void); - nsHashtable* mServices; // nsHashtable + nsHashtable/**/* mServices; }; nsServiceManagerImpl::nsServiceManagerImpl(void) @@ -149,15 +156,17 @@ static PRBool DeleteEntry(nsHashKey *aKey, void *aData, void* closure) { nsServiceEntry* entry = (nsServiceEntry*)aData; - entry->mService->Release(); + NS_RELEASE(entry->mService); delete entry; return PR_TRUE; } nsServiceManagerImpl::~nsServiceManagerImpl(void) { - mServices->Enumerate(DeleteEntry); - delete mServices; + if (mServices) { + mServices->Enumerate(DeleteEntry); + delete mServices; + } } static NS_DEFINE_IID(kIServiceManagerIID, NS_ISERVICEMANAGER_IID); @@ -166,7 +175,7 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); NS_IMPL_ADDREF(nsServiceManagerImpl); NS_IMPL_RELEASE(nsServiceManagerImpl); -nsresult +NS_IMETHODIMP nsServiceManagerImpl::QueryInterface(const nsIID& aIID, void* *aInstancePtr) { if (NULL == aInstancePtr) { @@ -182,12 +191,12 @@ nsServiceManagerImpl::QueryInterface(const nsIID& aIID, void* *aInstancePtr) return NS_NOINTERFACE; } -nsresult +NS_IMETHODIMP nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, nsISupports* *result, nsIShutdownListener* shutdownListener) { - nsresult err = NS_OK; + nsresult rv = NS_OK; /* XXX: This is a hack to force NSPR initialization.. This should be * removed once PR_CEnterMonitor(...) initializes NSPR... (rick) */ @@ -199,10 +208,10 @@ nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, if (entry) { nsISupports* service; - err = entry->mService->QueryInterface(aIID, (void**)&service); - if (err == NS_OK) { - err = entry->AddListener(shutdownListener); - if (err == NS_OK) { + rv = entry->mService->QueryInterface(aIID, (void**)&service); + if (NS_SUCCEEDED(rv)) { + rv = entry->AddListener(shutdownListener); + if (NS_SUCCEEDED(rv)) { *result = service; // If someone else requested the service to be shut down, @@ -210,29 +219,29 @@ nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, // released, then cancel their shutdown request: if (entry->mShuttingDown) { entry->mShuttingDown = PR_FALSE; - service->AddRef(); // Released in ShutdownService + NS_ADDREF(service); // Released in UnregisterService } } } } else { nsISupports* service; - err = nsRepository::CreateInstance(aClass, NULL, aIID, (void**)&service); - if (err == NS_OK) { + rv = nsComponentManager::CreateInstance(aClass, NULL, aIID, (void**)&service); + if (NS_SUCCEEDED(rv)) { entry = new nsServiceEntry(aClass, service); if (entry == NULL) { - service->Release(); - err = NS_ERROR_OUT_OF_MEMORY; + NS_RELEASE(service); + rv = NS_ERROR_OUT_OF_MEMORY; } else { - err = entry->AddListener(shutdownListener); - if (err == NS_OK) { + rv = entry->AddListener(shutdownListener); + if (NS_SUCCEEDED(rv)) { mServices->Put(&key, entry); *result = service; - service->AddRef(); // Released in ShutdownService + NS_ADDREF(service); // Released in UnregisterService } else { - service->Release(); + NS_RELEASE(service); delete entry; } } @@ -240,14 +249,14 @@ nsServiceManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, } PR_CExitMonitor(this); - return err; + return rv; } -nsresult +NS_IMETHODIMP nsServiceManagerImpl::ReleaseService(const nsCID& aClass, nsISupports* service, nsIShutdownListener* shutdownListener) { - nsresult err = NS_OK; + nsresult rv = NS_OK; PR_CEnterMonitor(this); nsIDKey key(aClass); @@ -257,63 +266,117 @@ nsServiceManagerImpl::ReleaseService(const nsCID& aClass, nsISupports* service, NS_ASSERTION(entry->mService == service, "service looked failed"); if (entry) { - err = entry->RemoveListener(shutdownListener); - nsrefcnt cnt = service->Release(); - if (err == NS_OK && cnt == 0) { + rv = entry->RemoveListener(shutdownListener); + nsrefcnt cnt; + NS_RELEASE2(service, cnt); + if (NS_SUCCEEDED(rv) && cnt == 0) { mServices->Remove(&key); delete entry; - err = nsRepository::FreeLibraries(); + rv = nsComponentManager::FreeLibraries(); } } PR_CExitMonitor(this); - return err; + return rv; } -nsresult -nsServiceManagerImpl::ShutdownService(const nsCID& aClass) +NS_IMETHODIMP +nsServiceManagerImpl::RegisterService(const nsCID& aClass, nsISupports* aService) { - nsresult err = NS_OK; + nsresult rv = NS_OK; + PR_CEnterMonitor(this); + + nsIDKey key(aClass); + nsServiceEntry* entry = (nsServiceEntry*)mServices->Get(&key); + if (entry) { + rv = NS_ERROR_FAILURE; + } + else { + nsServiceEntry* entry = new nsServiceEntry(aClass, aService); + if (entry == NULL) + rv = NS_ERROR_OUT_OF_MEMORY; + else { + mServices->Put(&key, entry); + NS_ADDREF(aService); // Released in UnregisterService + } + } + PR_CExitMonitor(this); + return rv; +} + +NS_IMETHODIMP +nsServiceManagerImpl::UnregisterService(const nsCID& aClass) +{ + nsresult rv = NS_OK; PR_CEnterMonitor(this); nsIDKey key(aClass); nsServiceEntry* entry = (nsServiceEntry*)mServices->Get(&key); if (entry == NULL) { - err = NS_ERROR_SERVICE_NOT_FOUND; + rv = NS_ERROR_SERVICE_NOT_FOUND; } else { - err = entry->NotifyListeners(); // break the cycles + rv = entry->NotifyListeners(); // break the cycles entry->mShuttingDown = PR_TRUE; - nsrefcnt cnt = entry->mService->Release(); // AddRef in GetService - if (err == NS_OK && cnt == 0) { + nsrefcnt cnt; + NS_RELEASE2(entry->mService, cnt); // AddRef in GetService + if (NS_SUCCEEDED(rv) && cnt == 0) { mServices->Remove(&key); delete entry; - err = nsRepository::FreeLibraries(); + rv = nsComponentManager::FreeLibraries(); } else - err = NS_ERROR_SERVICE_IN_USE; + rv = NS_ERROR_SERVICE_IN_USE; } PR_CExitMonitor(this); - return err; + return rv; +} + +//////////////////////////////////////////////////////////////////////////////// + +nsresult +NS_NewServiceManager(nsIServiceManager* *result) +{ + nsServiceManagerImpl* servMgr = new nsServiceManagerImpl(); + if (servMgr == NULL) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(servMgr); + *result = servMgr; + return NS_OK; } //////////////////////////////////////////////////////////////////////////////// // Global service manager interface (see nsIServiceManager.h) -nsIServiceManager* nsServiceManager::globalServiceManager = NULL; +nsIServiceManager* nsServiceManager::mGlobalServiceManager = NULL; nsresult nsServiceManager::GetGlobalServiceManager(nsIServiceManager* *result) { - if (globalServiceManager == NULL) { - globalServiceManager = new nsServiceManagerImpl(); - if (globalServiceManager == NULL) - return NS_ERROR_OUT_OF_MEMORY; - globalServiceManager->AddRef(); + if (mGlobalServiceManager == NULL) { + nsIServiceManager* servMgr; + nsresult rv = NS_NewServiceManager(&servMgr); + if (NS_FAILED(rv)) return rv; + + // The global service manager always has a global component manager service: + nsIComponentManager* compMgr; + rv = NS_GetGlobalComponentManager(&compMgr); + if (NS_FAILED(rv)) { + NS_RELEASE(servMgr); + return rv; + } + rv = servMgr->RegisterService(kComponentManagerCID, compMgr); + if (NS_FAILED(rv)) { + NS_RELEASE(servMgr); + return rv; + } + + mGlobalServiceManager = servMgr; } - *result = globalServiceManager; + + *result = mGlobalServiceManager; return NS_OK; } @@ -323,8 +386,8 @@ nsServiceManager::GetService(const nsCID& aClass, const nsIID& aIID, nsIShutdownListener* shutdownListener) { nsIServiceManager* mgr; - nsresult rslt = GetGlobalServiceManager(&mgr); - if (rslt != NS_OK) return rslt; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; return mgr->GetService(aClass, aIID, result, shutdownListener); } @@ -333,18 +396,27 @@ nsServiceManager::ReleaseService(const nsCID& aClass, nsISupports* service, nsIShutdownListener* shutdownListener) { nsIServiceManager* mgr; - nsresult rslt = GetGlobalServiceManager(&mgr); - if (rslt != NS_OK) return rslt; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; return mgr->ReleaseService(aClass, service, shutdownListener); } nsresult -nsServiceManager::ShutdownService(const nsCID& aClass) +nsServiceManager::RegisterService(const nsCID& aClass, nsISupports* aService) { nsIServiceManager* mgr; - nsresult rslt = GetGlobalServiceManager(&mgr); - if (rslt != NS_OK) return rslt; - return mgr->ShutdownService(aClass); + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; + return mgr->RegisterService(aClass, aService); +} + +nsresult +nsServiceManager::UnregisterService(const nsCID& aClass) +{ + nsIServiceManager* mgr; + nsresult rv = GetGlobalServiceManager(&mgr); + if (NS_FAILED(rv)) return rv; + return mgr->UnregisterService(aClass); } //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/xpcom/tests/PropertiesTest.cpp b/mozilla/xpcom/tests/PropertiesTest.cpp index a780f7a7a3a..484df199998 100644 --- a/mozilla/xpcom/tests/PropertiesTest.cpp +++ b/mozilla/xpcom/tests/PropertiesTest.cpp @@ -24,7 +24,7 @@ #include "nsIProperties.h" #include "nsIServiceManager.h" #include "nsIURL.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #ifdef XP_PC #include "plevent.h" #endif @@ -60,9 +60,9 @@ extern "C" void NS_SetupRegistry(); int main(int argc, char *argv[]) { - nsRepository::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, + nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, + nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE); #ifdef XP_MAC // have not build this on PC and UNIX yet so make it #ifdef XP_MAC NS_SetupRegistry(); @@ -102,7 +102,7 @@ main(int argc, char *argv[]) return 1; } nsIProperties *props = nsnull; - ret = nsRepository::CreateInstance(kPropertiesCID, NULL, + ret = nsComponentManager::CreateInstance(kPropertiesCID, NULL, kIPropertiesIID, (void**) &props); if (NS_FAILED(ret)) { printf("create nsIProperties failed\n"); diff --git a/mozilla/xpcom/tests/RegFactory.cpp b/mozilla/xpcom/tests/RegFactory.cpp index 8a31425415e..ef531a4d9a2 100644 --- a/mozilla/xpcom/tests/RegFactory.cpp +++ b/mozilla/xpcom/tests/RegFactory.cpp @@ -19,7 +19,7 @@ #include #include "plstr.h" #include "prlink.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" static PRBool gUnreg = PR_FALSE; @@ -55,11 +55,11 @@ nsresult Register(const char *path) nsRegisterProc proc = (nsRegisterProc) PR_FindSymbol(instance, "NSRegisterSelf"); if (proc != NULL) { - nsIServiceManager* serviceMgr = NULL; - res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); + nsIServiceManager* servMgr = NULL; + res = nsServiceManager::GetGlobalServiceManager(&servMgr); if (res == NS_OK) { - res = proc(serviceMgr, path); + res = proc(servMgr, path); } } PR_UnloadLibrary(instance); @@ -76,13 +76,13 @@ nsresult Unregister(const char *path) PRLibrary *instance = GetLib(path); if (instance != NULL) { nsUnregisterProc proc = (nsUnregisterProc) PR_FindSymbol(instance, - "NSUnregisterSelf"); + "NSUnregisterSelf"); if (proc != NULL) { - nsIServiceManager* serviceMgr = NULL; - res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); + nsIServiceManager* servMgr = NULL; + res = nsServiceManager::GetGlobalServiceManager(&servMgr); if (res == NS_OK) { - res = proc(serviceMgr, path); + res = proc(servMgr, path); } } PR_UnloadLibrary(instance); diff --git a/mozilla/xpcom/tests/TestFactory.cpp b/mozilla/xpcom/tests/TestFactory.cpp index e745d7fe1c5..c7d8a029592 100644 --- a/mozilla/xpcom/tests/TestFactory.cpp +++ b/mozilla/xpcom/tests/TestFactory.cpp @@ -19,7 +19,7 @@ #include #include "TestFactory.h" #include "nsISupports.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" NS_DEFINE_IID(kFactoryIID, NS_IFACTORY_IID); NS_DEFINE_CID(kTestFactoryCID, NS_TESTFACTORY_CID); @@ -30,7 +30,7 @@ int main(int argc, char **argv) { RegisterTestFactories(); ITestClass *t = NULL; - nsRepository::CreateInstance(kTestFactoryCID, + nsComponentManager::CreateInstance(kTestFactoryCID, NULL, kTestClassIID, (void **) &t); @@ -44,7 +44,7 @@ int main(int argc, char **argv) { t = NULL; - nsRepository::CreateInstance(kTestLoadedFactoryCID, + nsComponentManager::CreateInstance(kTestLoadedFactoryCID, NULL, kTestClassIID, (void **) &t); @@ -56,7 +56,7 @@ int main(int argc, char **argv) { cout << "Dynamic CreateInstance failed\n"; } - nsRepository::FreeLibraries(); + nsComponentManager::FreeLibraries(); return 0; } @@ -130,12 +130,12 @@ nsresult TestFactory::CreateInstance(nsISupports *aDelegate, */ extern "C" void RegisterTestFactories() { - nsRepository::RegisterFactory(kTestFactoryCID, 0, 0, + nsComponentManager::RegisterFactory(kTestFactoryCID, 0, 0, new TestFactory(), PR_FALSE); // Windows can use persistant registry #ifndef USE_NSREG - nsRepository::RegisterComponent(kTestLoadedFactoryCID, NULL, NULL, + nsComponentManager::RegisterComponent(kTestLoadedFactoryCID, NULL, NULL, "libtestdynamic.so", PR_FALSE, PR_TRUE); diff --git a/mozilla/xpcom/tests/TestServMgr.cpp b/mozilla/xpcom/tests/TestServMgr.cpp index 03972337ca9..6c446d0054f 100644 --- a/mozilla/xpcom/tests/TestServMgr.cpp +++ b/mozilla/xpcom/tests/TestServMgr.cpp @@ -18,6 +18,7 @@ #include "MyService.h" #include "nsIServiceManager.h" +#include "nsIComponentManager.h" #include static NS_DEFINE_IID(kIMyServiceCID, NS_IMYSERVICE_CID); @@ -103,7 +104,7 @@ AsyncShutdown(int testNumber) // thread, we'd have to protect all accesses to myServ throughout this // code with a monitor. - err = nsServiceManager::ShutdownService(kIMyServiceCID); + err = nsServiceManager::UnregisterService(kIMyServiceCID); if (err == NS_ERROR_SERVICE_IN_USE) { printf("async shutdown -- service still in use\n"); return NS_OK; @@ -182,8 +183,8 @@ SetupFactories(void) { nsresult err; // seed the repository (hack) - err = nsRepository::RegisterComponent(kIMyServiceCID, NULL, NULL, "MyService.dll", - PR_TRUE, PR_FALSE); + err = nsComponentManager::RegisterComponent(kIMyServiceCID, NULL, NULL, "MyService.dll", + PR_TRUE, PR_FALSE); NS_ASSERTION(err == NS_OK, "failed to register my factory"); } diff --git a/mozilla/xpcom/tests/dynamic/TestDynamic.cpp b/mozilla/xpcom/tests/dynamic/TestDynamic.cpp index 28ba7e17b44..a6e7e5849f2 100644 --- a/mozilla/xpcom/tests/dynamic/TestDynamic.cpp +++ b/mozilla/xpcom/tests/dynamic/TestDynamic.cpp @@ -21,7 +21,10 @@ #include "TestFactory.h" #include "nsCom.h" #include "nsISupports.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" +#include "nsIServiceManager.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); NS_DEFINE_IID(kFactoryIID, NS_IFACTORY_IID); NS_DEFINE_CID(kTestLoadedFactoryCID, NS_TESTLOADEDFACTORY_CID); @@ -105,7 +108,7 @@ nsresult TestDynamicFactory::CreateInstance(nsISupports *aDelegate, return res; } -extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr, const nsCID &aClass, const char *aClassName, const char *aProgID, @@ -126,17 +129,25 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, return NS_NOINTERFACE; } -extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) { +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr) { return PRBool(g_FactoryCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr , const char *path) { - return nsRepository::RegisterComponent(kTestLoadedFactoryCID, NULL, NULL, path, - PR_TRUE, PR_TRUE); + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + + return compMgr->RegisterComponent(kTestLoadedFactoryCID, NULL, NULL, path, + PR_TRUE, PR_TRUE); } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char *path) { - return nsRepository::UnregisterFactory(kTestLoadedFactoryCID, path); + nsresult rv; + nsService compMgr(aServMgr, kComponentManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + + return compMgr->UnregisterFactory(kTestLoadedFactoryCID, path); } diff --git a/mozilla/xpcom/threads/nsEventQueueService.cpp b/mozilla/xpcom/threads/nsEventQueueService.cpp index 49e2bc4b505..0379daae626 100644 --- a/mozilla/xpcom/threads/nsEventQueueService.cpp +++ b/mozilla/xpcom/threads/nsEventQueueService.cpp @@ -26,7 +26,7 @@ static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID); -// XXX move to nsID.h or nsHashtable.h? (copied from nsRepository.cpp) +// XXX move to nsID.h or nsHashtable.h? (copied from nsComponentManager.cpp) class ThreadKey: public nsHashKey { private: const PRThread* id; diff --git a/mozilla/xpfe/AppCores/src/nsAppCores.cpp b/mozilla/xpfe/AppCores/src/nsAppCores.cpp index d23f292f38b..ddfe9614cac 100644 --- a/mozilla/xpfe/AppCores/src/nsAppCores.cpp +++ b/mozilla/xpfe/AppCores/src/nsAppCores.cpp @@ -26,13 +26,15 @@ #include "nsEditorAppCoreFactory.h" #include "nsToolkitCoreFactory.h" #include "nsIFactory.h" -#include "nsRepository.h" - +#include "nsIComponentManager.h" #include "pratom.h" +#include +#include "nsIServiceManager.h" static PRInt32 gLockCnt = 0; static PRInt32 gInstanceCnt = 0; +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); static NS_DEFINE_IID(kMailCoreCID, NS_MAILCORE_CID); static NS_DEFINE_IID(kRDFCoreCID, NS_RDFCORE_CID); @@ -57,13 +59,13 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path) { printf("*** AppCores is being registered\n"); - nsRepository::RegisterComponent(kAppCoresManagerCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - nsRepository::RegisterComponent(kMailCoreCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - nsRepository::RegisterComponent(kRDFCoreCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - nsRepository::RegisterComponent(kToolbarCoreCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - nsRepository::RegisterComponent(kToolkitCoreCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - nsRepository::RegisterComponent(kBrowserAppCoreCID, NULL, NULL, path, PR_TRUE, PR_TRUE); - nsRepository::RegisterComponent(kEditorAppCoreCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + nsComponentManager::RegisterComponent(kAppCoresManagerCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + nsComponentManager::RegisterComponent(kMailCoreCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + nsComponentManager::RegisterComponent(kRDFCoreCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + nsComponentManager::RegisterComponent(kToolbarCoreCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + nsComponentManager::RegisterComponent(kToolkitCoreCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + nsComponentManager::RegisterComponent(kBrowserAppCoreCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + nsComponentManager::RegisterComponent(kEditorAppCoreCID, NULL, NULL, path, PR_TRUE, PR_TRUE); return NS_OK; } @@ -72,13 +74,13 @@ NSUnregisterSelf(nsISupports* serviceMgr, const char *path) { printf("*** AppCores is being unregistered\n"); - nsRepository::UnregisterFactory(kAppCoresManagerCID, path); - nsRepository::UnregisterFactory(kMailCoreCID, path); - nsRepository::UnregisterFactory(kRDFCoreCID, path); - nsRepository::UnregisterFactory(kToolbarCoreCID, path); - nsRepository::UnregisterFactory(kToolkitCoreCID, path); - nsRepository::UnregisterFactory(kBrowserAppCoreCID, path); - nsRepository::UnregisterFactory(kEditorAppCoreCID, path); + nsComponentManager::UnregisterFactory(kAppCoresManagerCID, path); + nsComponentManager::UnregisterFactory(kMailCoreCID, path); + nsComponentManager::UnregisterFactory(kRDFCoreCID, path); + nsComponentManager::UnregisterFactory(kToolbarCoreCID, path); + nsComponentManager::UnregisterFactory(kToolkitCoreCID, path); + nsComponentManager::UnregisterFactory(kBrowserAppCoreCID, path); + nsComponentManager::UnregisterFactory(kEditorAppCoreCID, path); return NS_OK; } diff --git a/mozilla/xpfe/AppCores/src/nsAppCoresManager.cpp b/mozilla/xpfe/AppCores/src/nsAppCoresManager.cpp index a81f71a251d..0da5903eff7 100644 --- a/mozilla/xpfe/AppCores/src/nsAppCoresManager.cpp +++ b/mozilla/xpfe/AppCores/src/nsAppCoresManager.cpp @@ -28,7 +28,7 @@ #include "nsIFactory.h" #include "nsISupports.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIScriptObjectOwner.h" #include "nsIScriptGlobalObject.h" diff --git a/mozilla/xpfe/AppCores/src/nsBrowserAppCore.cpp b/mozilla/xpfe/AppCores/src/nsBrowserAppCore.cpp index 96b58d51c2b..c230200e338 100644 --- a/mozilla/xpfe/AppCores/src/nsBrowserAppCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsBrowserAppCore.cpp @@ -22,7 +22,7 @@ #include "nsIBrowserWindow.h" #include "nsIWebShell.h" #include "pratom.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsAppCores.h" #include "nsAppCoresCIDs.h" #include "nsAppCoresManager.h" diff --git a/mozilla/xpfe/AppCores/src/nsEditorAppCore.cpp b/mozilla/xpfe/AppCores/src/nsEditorAppCore.cpp index 38d4b31930f..ae3321f5e31 100755 --- a/mozilla/xpfe/AppCores/src/nsEditorAppCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsEditorAppCore.cpp @@ -22,7 +22,7 @@ #include "nsIBrowserWindow.h" #include "nsIWebShell.h" #include "pratom.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsAppCores.h" #include "nsAppCoresCIDs.h" #include "nsAppCoresManager.h" @@ -71,7 +71,7 @@ #include "nsIHTMLEditor.h" #include "nsEditorCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" /////////////////////////////////////// diff --git a/mozilla/xpfe/AppCores/src/nsEditorMode.cpp b/mozilla/xpfe/AppCores/src/nsEditorMode.cpp index 2555d57b4c1..6a1b8c7ed4f 100755 --- a/mozilla/xpfe/AppCores/src/nsEditorMode.cpp +++ b/mozilla/xpfe/AppCores/src/nsEditorMode.cpp @@ -22,7 +22,7 @@ #include "nsIHTMLEditor.h" #include "nsEditorCID.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" static nsIHTMLEditor *gEditor; @@ -69,7 +69,7 @@ nsresult NS_InitEditorMode(nsIDOMDocument *aDOMDocument, nsIPresShell* aPresShel result = nsServiceManager::GetService(kHTMLEditorCID, kIHTMLEditorIID, &isup); */ - result = nsRepository::CreateInstance(kHTMLEditorCID, + result = nsComponentManager::CreateInstance(kHTMLEditorCID, nsnull, kIHTMLEditorIID, (void **)&gEditor); if (NS_FAILED(result)) diff --git a/mozilla/xpfe/AppCores/src/nsJSBaseAppCore.cpp b/mozilla/xpfe/AppCores/src/nsJSBaseAppCore.cpp index 403fd665eac..c3b5e9b36f2 100644 --- a/mozilla/xpfe/AppCores/src/nsJSBaseAppCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsJSBaseAppCore.cpp @@ -28,7 +28,7 @@ #include "nsString.h" #include "nsIDOMBaseAppCore.h" #include "nsIScriptNameSpaceManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsDOMCID.h" @@ -277,7 +277,7 @@ BaseAppCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) return JS_FALSE; } - result = nsRepository::CreateInstance(classID, + result = nsComponentManager::CreateInstance(classID, nsnull, kIDOMBaseAppCoreIID, (void **)&nativeThis); diff --git a/mozilla/xpfe/AppCores/src/nsJSBrowserAppCore.cpp b/mozilla/xpfe/AppCores/src/nsJSBrowserAppCore.cpp index 297e2b46554..d5a6f9675b5 100644 --- a/mozilla/xpfe/AppCores/src/nsJSBrowserAppCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsJSBrowserAppCore.cpp @@ -29,7 +29,7 @@ #include "nsIDOMBrowserAppCore.h" #include "nsIDOMWindow.h" #include "nsIScriptNameSpaceManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsDOMCID.h" @@ -636,7 +636,7 @@ BrowserAppCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva return JS_FALSE; } - result = nsRepository::CreateInstance(classID, + result = nsComponentManager::CreateInstance(classID, nsnull, kIDOMBrowserAppCoreIID, (void **)&nativeThis); diff --git a/mozilla/xpfe/AppCores/src/nsJSEditorAppCore.cpp b/mozilla/xpfe/AppCores/src/nsJSEditorAppCore.cpp index 70efe713ef9..f0845057100 100755 --- a/mozilla/xpfe/AppCores/src/nsJSEditorAppCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsJSEditorAppCore.cpp @@ -29,7 +29,7 @@ #include "nsIDOMEditorAppCore.h" #include "nsIDOMWindow.h" #include "nsIScriptNameSpaceManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsDOMCID.h" @@ -493,7 +493,7 @@ EditorAppCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval return JS_FALSE; } - result = nsRepository::CreateInstance(classID, + result = nsComponentManager::CreateInstance(classID, nsnull, kIDOMEditorAppCoreIID, (void **)&nativeThis); diff --git a/mozilla/xpfe/AppCores/src/nsJSMailCore.cpp b/mozilla/xpfe/AppCores/src/nsJSMailCore.cpp index 1e281eb850d..3db115e93af 100644 --- a/mozilla/xpfe/AppCores/src/nsJSMailCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsJSMailCore.cpp @@ -29,7 +29,7 @@ #include "nsIDOMMailCore.h" #include "nsIDOMWindow.h" #include "nsIScriptNameSpaceManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsDOMCID.h" @@ -315,7 +315,7 @@ MailCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) return JS_FALSE; } - result = nsRepository::CreateInstance(classID, + result = nsComponentManager::CreateInstance(classID, nsnull, kIDOMMailCoreIID, (void **)&nativeThis); diff --git a/mozilla/xpfe/AppCores/src/nsJSRDFCore.cpp b/mozilla/xpfe/AppCores/src/nsJSRDFCore.cpp index 3d55acb3dd6..4e95a3703a7 100644 --- a/mozilla/xpfe/AppCores/src/nsJSRDFCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsJSRDFCore.cpp @@ -29,7 +29,7 @@ #include "nsIDOMNode.h" #include "nsIDOMRDFCore.h" #include "nsIScriptNameSpaceManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsDOMCID.h" @@ -241,7 +241,7 @@ RDFCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) return JS_FALSE; } - result = nsRepository::CreateInstance(classID, + result = nsComponentManager::CreateInstance(classID, nsnull, kIDOMRDFCoreIID, (void **)&nativeThis); diff --git a/mozilla/xpfe/AppCores/src/nsJSToolbarCore.cpp b/mozilla/xpfe/AppCores/src/nsJSToolbarCore.cpp index a74058212d3..dbf2cbfed33 100644 --- a/mozilla/xpfe/AppCores/src/nsJSToolbarCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsJSToolbarCore.cpp @@ -29,7 +29,7 @@ #include "nsIDOMToolbarCore.h" #include "nsIDOMWindow.h" #include "nsIScriptNameSpaceManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsDOMCID.h" @@ -272,7 +272,7 @@ ToolbarCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) return JS_FALSE; } - result = nsRepository::CreateInstance(classID, + result = nsComponentManager::CreateInstance(classID, nsnull, kIDOMToolbarCoreIID, (void **)&nativeThis); diff --git a/mozilla/xpfe/AppCores/src/nsJSToolkitCore.cpp b/mozilla/xpfe/AppCores/src/nsJSToolkitCore.cpp index eed0338390e..78b7f0a565b 100644 --- a/mozilla/xpfe/AppCores/src/nsJSToolkitCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsJSToolkitCore.cpp @@ -29,7 +29,7 @@ #include "nsIDOMToolkitCore.h" #include "nsIDOMWindow.h" #include "nsIScriptNameSpaceManager.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsDOMCID.h" @@ -284,7 +284,7 @@ ToolkitCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) return JS_FALSE; } - result = nsRepository::CreateInstance(classID, + result = nsComponentManager::CreateInstance(classID, nsnull, kIDOMToolkitCoreIID, (void **)&nativeThis); diff --git a/mozilla/xpfe/AppCores/src/nsMailCore.cpp b/mozilla/xpfe/AppCores/src/nsMailCore.cpp index f2db9f66da7..edbe0a3f145 100644 --- a/mozilla/xpfe/AppCores/src/nsMailCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsMailCore.cpp @@ -22,7 +22,7 @@ #include "nsIBrowserWindow.h" #include "nsIWebShell.h" #include "pratom.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsAppCores.h" #include "nsAppCoresCIDs.h" #include "nsAppCoresManager.h" diff --git a/mozilla/xpfe/AppCores/src/nsRDFCore.cpp b/mozilla/xpfe/AppCores/src/nsRDFCore.cpp index c1e96ea8d1e..bdd6ff97aa5 100644 --- a/mozilla/xpfe/AppCores/src/nsRDFCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsRDFCore.cpp @@ -22,7 +22,7 @@ #include "nsIBrowserWindow.h" #include "nsIWebShell.h" #include "pratom.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsAppCores.h" #include "nsAppCoresCIDs.h" #include "nsAppCoresManager.h" diff --git a/mozilla/xpfe/AppCores/src/nsToolbarCore.cpp b/mozilla/xpfe/AppCores/src/nsToolbarCore.cpp index 724eb1aee99..cade72cdc97 100644 --- a/mozilla/xpfe/AppCores/src/nsToolbarCore.cpp +++ b/mozilla/xpfe/AppCores/src/nsToolbarCore.cpp @@ -20,7 +20,7 @@ #include "nsToolbarCore.h" #include "nsIBrowserWindow.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsAppCores.h" #include "nsAppCoresCIDs.h" #include "nsAppCoresManager.h" diff --git a/mozilla/xpfe/apprunner/src/nsAppRunner.cpp b/mozilla/xpfe/apprunner/src/nsAppRunner.cpp index 5d2df3745bb..5d5cae8d92e 100644 --- a/mozilla/xpfe/apprunner/src/nsAppRunner.cpp +++ b/mozilla/xpfe/apprunner/src/nsAppRunner.cpp @@ -22,7 +22,7 @@ #include "nsAppRunner.h" #include "nsIAppShellService.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "xp_core.h" #include "xp_mcom.h" @@ -298,7 +298,7 @@ nsAppRunner &nsAppRunner::SetAppShell( nsIAppShellService *newAppShell ) { #if 0 // nsAppRunnerFactory // -// Means by which instances are created via nsRepository. +// Means by which instances are created via nsComponentManager. // This code is somewhat temporary as the CreateInstance should really // go in platform-specific code in order to create an instance specific // to the platform on which we're running. diff --git a/mozilla/xpfe/appshell/src/nsAppShellFactory.cpp b/mozilla/xpfe/appshell/src/nsAppShellFactory.cpp index 4e75b9748da..16069c62ece 100644 --- a/mozilla/xpfe/appshell/src/nsAppShellFactory.cpp +++ b/mozilla/xpfe/appshell/src/nsAppShellFactory.cpp @@ -55,7 +55,7 @@ NSGetFactory(nsISupports* serviceMgr, rv = NS_NewAppShellServiceFactory(aFactory); } else if (aClass.Equals(kCmdLineServiceCID)) { - rv = NS_NewCmdLineServiceFactory(aFactory); + rv = NS_NewCmdLineServiceFactory(aFactory); } return rv; diff --git a/mozilla/xpfe/appshell/src/nsAppShellService.cpp b/mozilla/xpfe/appshell/src/nsAppShellService.cpp index 8ade96d306f..cf0184f3506 100644 --- a/mozilla/xpfe/appshell/src/nsAppShellService.cpp +++ b/mozilla/xpfe/appshell/src/nsAppShellService.cpp @@ -20,7 +20,7 @@ #include "nsIAppShellService.h" #include "nsISupportsArray.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIURL.h" #include "nsIServiceManager.h" #include "nsIEventQueueService.h" @@ -135,7 +135,7 @@ nsAppShellService::Initialize(void) } // Create widget application shell - rv = nsRepository::CreateInstance(kAppShellCID, nsnull, kIAppShellIID, + rv = nsComponentManager::CreateInstance(kAppShellCID, nsnull, kIAppShellIID, (void**)&mAppShell); if (NS_FAILED(rv)) { goto done; diff --git a/mozilla/xpfe/appshell/src/nsCommandLineService.cpp b/mozilla/xpfe/appshell/src/nsCommandLineService.cpp index da57ae77d2e..033ce1f8c77 100644 --- a/mozilla/xpfe/appshell/src/nsCommandLineService.cpp +++ b/mozilla/xpfe/appshell/src/nsCommandLineService.cpp @@ -20,7 +20,7 @@ #include "nsICmdLineService.h" #include "nsVoidArray.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsString.h" #include "plstr.h" diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index 476dce97906..e68eb795815 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -20,7 +20,7 @@ #include "nsWebShellWindow.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIURL.h" @@ -192,7 +192,7 @@ nsresult nsWebShellWindow::Initialize(nsIWidget* aParent, } // Create top level window - rv = nsRepository::CreateInstance(kWindowCID, nsnull, kIWidgetIID, + rv = nsComponentManager::CreateInstance(kWindowCID, nsnull, kIWidgetIID, (void**)&mWindow); if (NS_OK != rv) { return rv; @@ -212,7 +212,7 @@ nsresult nsWebShellWindow::Initialize(nsIWidget* aParent, mWindow->SetBackgroundColor(NS_RGB(192,192,192)); // Create web shell - rv = nsRepository::CreateInstance(kWebShellCID, nsnull, + rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&mWebShell); if (NS_OK != rv) { @@ -248,7 +248,7 @@ nsresult nsWebShellWindow::Initialize(nsIWidget* aParent, aControllerIID.ToCString(str, sizeof(str)); iid.Parse(str); - //rv = nsRepository::CreateInstance(iid, nsnull, + //rv = nsComponentManager::CreateInstance(iid, nsnull, // kIWidgetControllerIID, // (void**)&mController); return rv; @@ -374,7 +374,7 @@ NS_IMETHODIMP nsWebShellWindow::CreateMenu(nsIMenuBar * aMenuBar, { // Create nsMenu nsIMenu * pnsMenu = nsnull; - nsresult rv = nsRepository::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&pnsMenu); + nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&pnsMenu); if (NS_OK == rv) { // Call Create pnsMenu->Create(aMenuBar, aMenuName); @@ -424,7 +424,7 @@ NS_IMETHODIMP nsWebShellWindow::LoadMenuItem( menuitemElement->GetAttribute(nsAutoString("cmd"), menuitemCmd); // Create nsMenuItem nsIMenuItem * pnsMenuItem = nsnull; - nsresult rv = nsRepository::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&pnsMenuItem); + nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&pnsMenuItem); if (NS_OK == rv) { pnsMenuItem->Create(pParentMenu, menuitemName, 0); // Set nsMenuItem Name @@ -478,7 +478,7 @@ void nsWebShellWindow::LoadSubMenu( // Create nsMenu nsIMenu * pnsMenu = nsnull; - nsresult rv = nsRepository::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&pnsMenu); + nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&pnsMenu); if (NS_OK == rv) { // Call Create pnsMenu->Create(pParentMenu, menuName); @@ -529,7 +529,7 @@ void nsWebShellWindow::LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWi nsCOMPtr menubarNode(FindNamedDOMNode(nsAutoString("menubar"), window, endCount, 1)); if (menubarNode) { nsIMenuBar * pnsMenuBar = nsnull; - rv = nsRepository::CreateInstance(kMenuBarCID, nsnull, kIMenuBarIID, (void**)&pnsMenuBar); + rv = nsComponentManager::CreateInstance(kMenuBarCID, nsnull, kIMenuBarIID, (void**)&pnsMenuBar); if (NS_OK == rv) { if (nsnull != pnsMenuBar) { pnsMenuBar->Create(aParentWindow); diff --git a/mozilla/xpfe/appshell/src/nsXULCommand.cpp b/mozilla/xpfe/appshell/src/nsXULCommand.cpp index 38feb7595ef..713e74fdf05 100644 --- a/mozilla/xpfe/appshell/src/nsXULCommand.cpp +++ b/mozilla/xpfe/appshell/src/nsXULCommand.cpp @@ -22,7 +22,7 @@ // FOr JS Execution #include "nsIScriptContextOwner.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsXULCommand.h" diff --git a/mozilla/xpfe/bootstrap/nsAppRunner.cpp b/mozilla/xpfe/bootstrap/nsAppRunner.cpp index 39d932f2686..1280ae0fe3c 100644 --- a/mozilla/xpfe/bootstrap/nsAppRunner.cpp +++ b/mozilla/xpfe/bootstrap/nsAppRunner.cpp @@ -17,6 +17,7 @@ * Netscape Communications Corporation. All Rights Reserved. */ #include "nsIServiceManager.h" +#include "nsIComponentManager.h" #include "nsIURL.h" #include "nsIWidget.h" #include "plevent.h" @@ -241,10 +242,10 @@ int main(int argc, char* argv[]) NS_DEFINE_CID(kCMessengerBootstrapCID, NS_MESSENGERBOOTSTRAP_CID); - result = nsRepository::CreateInstance(kCMessengerBootstrapCID, - nsnull, - nsIAppShellService::GetIID(), - (void **)&messenger); + result = nsComponentManager::CreateInstance(kCMessengerBootstrapCID, + nsnull, + nsIAppShellService::GetIID(), + (void **)&messenger); if (NS_SUCCEEDED(result)) { printf("The Messenger component is available. Initializing...\n"); result = messenger->Initialize(); diff --git a/mozilla/xpfe/bootstrap/nsSetupRegistry.cpp b/mozilla/xpfe/bootstrap/nsSetupRegistry.cpp index b99a5a71a56..227c0f36b38 100644 --- a/mozilla/xpfe/bootstrap/nsSetupRegistry.cpp +++ b/mozilla/xpfe/bootstrap/nsSetupRegistry.cpp @@ -92,17 +92,17 @@ NS_SetupRegistry_1() */ NS_SetupRegistry(); - nsRepository::RegisterComponent(kCAppShellServiceCID, NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCCmdLineServiceCID, NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCAppShellServiceCID, NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCCmdLineServiceCID, NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE); //#if defined(XP_PC) || defined(XP_MAC) - nsRepository::RegisterComponent(kAppCoresManagerCID, NULL, NULL, APPCORES_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kToolkitCoreCID, NULL, NULL, APPCORES_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kMailCoreCID, NULL, NULL, APPCORES_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kToolbarCoreCID, NULL, NULL, APPCORES_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kBrowserAppCoreCID, NULL, NULL, APPCORES_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kEditorAppCoreCID, NULL, NULL, APPCORES_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kAppCoresManagerCID, NULL, NULL, APPCORES_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kToolkitCoreCID, NULL, NULL, APPCORES_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kMailCoreCID, NULL, NULL, APPCORES_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kToolbarCoreCID, NULL, NULL, APPCORES_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kBrowserAppCoreCID, NULL, NULL, APPCORES_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kEditorAppCoreCID, NULL, NULL, APPCORES_DLL, PR_FALSE, PR_FALSE); //All Editor registration is done in webshell/tests/viewer/nsSetupregistry.cpp //#endif -/// nsRepository::RegisterComponent(kCBrowserControllerCID, NULL, NULL, BROWSER_DLL, PR_FALSE, PR_FALSE); +/// nsComponentManager::RegisterComponent(kCBrowserControllerCID, NULL, NULL, BROWSER_DLL, PR_FALSE, PR_FALSE); } diff --git a/mozilla/xpfe/components/startup/src/nsCommandLineService.cpp b/mozilla/xpfe/components/startup/src/nsCommandLineService.cpp index da57ae77d2e..033ce1f8c77 100644 --- a/mozilla/xpfe/components/startup/src/nsCommandLineService.cpp +++ b/mozilla/xpfe/components/startup/src/nsCommandLineService.cpp @@ -20,7 +20,7 @@ #include "nsICmdLineService.h" #include "nsVoidArray.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsString.h" #include "plstr.h" diff --git a/mozilla/xpfe/main/main.cpp b/mozilla/xpfe/main/main.cpp index ab9af1c2700..6f62f5b3198 100644 --- a/mozilla/xpfe/main/main.cpp +++ b/mozilla/xpfe/main/main.cpp @@ -19,7 +19,7 @@ #include // For printf, etc. -#include "nsRepository.h" // For nsRepository. +#include "nsIComponentManager.h" // For nsComponentManager. #include "nsIAppRunner.h" // For nsIAppRunner. // Define Class IDs. @@ -37,12 +37,12 @@ int main(int argc, char* argv[]) { nsresult rv; // Initialize XPCOM. - rv = nsRepository::Initialize( registryFile ); + rv = nsComponentManager::Initialize( registryFile ); if ( rv == NS_OK ) { // Attempt to create appRunner. nsIAppRunner *appRunner = 0; - rv = nsRepository::CreateInstance( kIAppRunnerIID, + rv = nsComponentManager::CreateInstance( kIAppRunnerIID, 0, kAppRunnerCID, (void**)&appRunner ); @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) { fprintf( stderr, "Error creating appRunner object, rv=%lX\n", (unsigned long)rv ); } } else { - fprintf( stderr, "Error initilizing nsRepository, rv=%lX\n", (unsigned long)rv ); + fprintf( stderr, "Error initilizing nsComponentManager, rv=%lX\n", (unsigned long)rv ); } return rv; diff --git a/mozilla/xpfe/tools/registerFactories.cpp b/mozilla/xpfe/tools/registerFactories.cpp index 1080c49dbb5..4de8878d8fe 100644 --- a/mozilla/xpfe/tools/registerFactories.cpp +++ b/mozilla/xpfe/tools/registerFactories.cpp @@ -19,12 +19,12 @@ #include -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIAppRunner.h" static nsresult registerLib( const nsCID &cid, const char *libName ) { printf( "Registering library %s...", libName ); - nsresult rv = nsRepository::RegisterComponent( cid, // Class ID. + nsresult rv = nsComponentManager::RegisterComponent( cid, // Class ID. NULL, // Class name. NULL, // Program ID. libName, // Library name. @@ -42,7 +42,7 @@ static nsresult registerLib( const nsCID &cid, const char *libName ) { int main(int argc, char* argv[]) { // Fire up the XPCOM repository with our NS Registry file. - nsresult rv = nsRepository::Initialize("mozilla.reg"); + nsresult rv = nsComponentManager::Initialize("mozilla.reg"); // Register required libraries. if ( rv == NS_OK ) { diff --git a/mozilla/xpfe/xpviewer/src/nsBrowserWindow.cpp b/mozilla/xpfe/xpviewer/src/nsBrowserWindow.cpp index efde3462704..7d54fef1e6e 100644 --- a/mozilla/xpfe/xpviewer/src/nsBrowserWindow.cpp +++ b/mozilla/xpfe/xpviewer/src/nsBrowserWindow.cpp @@ -38,13 +38,13 @@ #include "nsIURL.h" #include "nsIFileWidget.h" #include "nsILookAndFeel.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIFactory.h" #include "nsCRT.h" #include "nsWidgetsCID.h" #include "nsViewerApp.h" #include "prprf.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsParserCIID.h" #include "nsIXPBaseWindow.h" @@ -457,7 +457,7 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell, mAllowPlugins = aAllowPlugins; // Create top level window - nsresult rv = nsRepository::CreateInstance(kWindowCID, nsnull, kIWidgetIID, + nsresult rv = nsComponentManager::CreateInstance(kWindowCID, nsnull, kIWidgetIID, (void**)&mWindow); if (NS_OK != rv) { return rv; @@ -472,7 +472,7 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell, mWindow->SetBackgroundColor(NS_RGB(192,192,192)); // Create web shell - rv = nsRepository::CreateInstance(kWebShellCID, nsnull, + rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&mWebShell); if (NS_OK != rv) { @@ -765,7 +765,7 @@ static PRBool GetFileNameFromFileSelector(nsIWidget* aParentWindow, PRBool selectedFileName = PR_FALSE; nsIFileWidget *fileWidget; nsString title("Open HTML"); - nsresult rv = nsRepository::CreateInstance(kFileWidgetCID, + nsresult rv = nsComponentManager::CreateInstance(kFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget); @@ -1060,7 +1060,7 @@ void nsBrowserWindow::DoFind() nsString title("Find"); nsXPBaseWindow * dialog = nsnull; - nsresult rv = nsRepository::CreateInstance(kXPBaseWindowCID, nsnull, + nsresult rv = nsComponentManager::CreateInstance(kXPBaseWindowCID, nsnull, kIXPBaseWindowIID, (void**) &dialog); if (rv == NS_OK) { @@ -1130,7 +1130,7 @@ NS_CreateImageButton(nsISupports *aParent, } // Create MenuButton - nsresult rv = nsRepository::CreateInstance(kImageButtonCID, nsnull, kIImageButtonIID, + nsresult rv = nsComponentManager::CreateInstance(kImageButtonCID, nsnull, kIImageButtonIID, (void**)&aButton); if (NS_OK != rv) { return rv; @@ -1196,7 +1196,7 @@ NS_CreateMenuButton(nsISupports *aParent, } // Create MenuButton - nsresult rv = nsRepository::CreateInstance(kMenuButtonCID, nsnull, kIMenuButtonIID, + nsresult rv = nsComponentManager::CreateInstance(kMenuButtonCID, nsnull, kIMenuButtonIID, (void**)&aButton); if (NS_OK != rv) { return rv; @@ -1248,7 +1248,7 @@ nsBrowserWindow::AddToolbarItem(nsIToolbar *aToolbar, // Create the generic toolbar holder for widget nsIToolbarItemHolder * toolbarItemHolder; - nsresult rv = nsRepository::CreateInstance(kToolbarItemHolderCID, nsnull, kIToolbarItemHolderIID, + nsresult rv = nsComponentManager::CreateInstance(kToolbarItemHolderCID, nsnull, kIToolbarItemHolderIID, (void**)&toolbarItemHolder); if (NS_OK != rv) { return rv; @@ -1290,7 +1290,7 @@ nsBrowserWindow::DoAppsDialog() nscolor textFGColor = NS_RGB(255, 255, 255); nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); lookAndFeel->GetColor(nsILookAndFeel::eColor_TextBackground, textBGColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_TextForeground, textFGColor); @@ -1309,7 +1309,7 @@ nsBrowserWindow::DoAppsDialog() // nsRect rect(0, 0, (40*4)+8, 23+31); - nsRepository::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mAppsDialog); + nsComponentManager::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mAppsDialog); nsIWidget* widget = nsnull; NS_CreateDialog(mWindow, mAppsDialog, rect, HandleGUIEvent, &font); if (NS_OK == mAppsDialog->QueryInterface(kIWidgetIID,(void**)&widget)) { @@ -1374,7 +1374,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) nscolor widgetBGColor = NS_RGB(192, 192, 192); nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); lookAndFeel->GetColor(nsILookAndFeel::eColor_TextBackground, textBGColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, widgetBGColor); @@ -1396,7 +1396,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) //---------------------------------------------------- // Create Toolbar Manager //---------------------------------------------------- - rv = nsRepository::CreateInstance(kToolbarManagerCID, nsnull, kIToolbarManagerIID, + rv = nsComponentManager::CreateInstance(kToolbarManagerCID, nsnull, kIToolbarManagerIID, (void**)&mToolbarMgr); if (NS_OK != rv) { return rv; @@ -1417,7 +1417,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) //---------------------------------------------------- // Create Button Toolbar //---------------------------------------------------- - rv = nsRepository::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, + rv = nsComponentManager::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, (void**)&mBtnToolbar); if (NS_OK != rv) { return rv; @@ -1495,7 +1495,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) // Create and place throbber r.SetRect(aWidth - THROBBER_WIDTH, 0, THROBBER_WIDTH, THROBBER_HEIGHT); - rv = nsRepository::CreateInstance(kThrobberCID, nsnull, kIThrobberIID, + rv = nsComponentManager::CreateInstance(kThrobberCID, nsnull, kIThrobberIID, (void**)&mThrobber); if (NS_OK != rv) { return rv; @@ -1520,7 +1520,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) //---------------------------------------------------- // Create URL Toolbar //---------------------------------------------------- - rv = nsRepository::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, + rv = nsComponentManager::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, (void**)&mURLToolbar); if (NS_OK != rv) { return rv; @@ -1545,7 +1545,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) //------ // Create and place Bookmark button //------ - rv = nsRepository::CreateInstance(kImageButtonCID, nsnull, kIImageButtonIID, + rv = nsComponentManager::CreateInstance(kImageButtonCID, nsnull, kIImageButtonIID, (void**)&mBookmarks); if (NS_OK != rv) { return rv; @@ -1608,7 +1608,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) // Create and place URL Text Field r.SetRect(0, 0, 200, 24); - rv = nsRepository::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, + rv = nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mLocation); if (NS_OK != rv) { return rv; @@ -1659,7 +1659,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) // Load Personal Toolbar //---------------------------------------------- nsIToolbar * personalToolbar; - rv = nsRepository::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, + rv = nsComponentManager::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, (void**)&personalToolbar); if (NS_OK != rv) { return rv; @@ -1744,7 +1744,7 @@ nsBrowserWindow::CreateStatusBar(PRInt32 aWidth) nscolor widgetBGColor = NS_RGB(192, 192, 192); nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, widgetBGColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, windowBGColor); NS_RELEASE(lookAndFeel); @@ -1761,7 +1761,7 @@ nsBrowserWindow::CreateStatusBar(PRInt32 aWidth) //---------------------------------------------------- // Create StatusBar as a Toolbar //---------------------------------------------------- - rv = nsRepository::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, + rv = nsComponentManager::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, (void**)&mStatusBar); if (NS_OK != rv) { return rv; @@ -1846,7 +1846,7 @@ nsBrowserWindow::CreateStatusBar(PRInt32 aWidth) // Create Mini Tools Toolbar //---------------------------------------------------- rrr.SetRect(0, 0, 150, 18); - rv = nsRepository::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, + rv = nsComponentManager::CreateInstance(kToolbarCID, nsnull, kIToolbarIID, (void**)&mStatusAppBar); if (NS_OK != rv) { return rv; @@ -2023,7 +2023,7 @@ nsBrowserWindow::Layout(PRInt32 aWidth, PRInt32 aHeight) { nscoord txtHeight; nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); NS_RELEASE(lookAndFeel); } else { @@ -2727,7 +2727,7 @@ nsBrowserWindow::DoCopy() static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - nsresult rv = nsRepository::CreateInstance(kCParserCID, + nsresult rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); @@ -2813,7 +2813,7 @@ nsBrowserWindow::DoEditorMode(nsIWebShell *aWebShell) if (NS_SUCCEEDED(doc->QueryInterface(kIDOMDocumentIID, (void **)&domDoc))) { //returns an addreffed domdocument nsIEditor *editor; - if (NS_SUCCEEDED(nsRepository::CreateInstance(kEditorCID, nsnull, kIEditorIID, (void **)&editor))) + if (NS_SUCCEEDED(nsComponentManager::CreateInstance(kEditorCID, nsnull, kIEditorIID, (void **)&editor))) { editor->Init(domDoc); AddEditor(editor); //new call to set the editor interface this will addref @@ -3109,7 +3109,7 @@ static PRBool GetSaveFileNameFromFileSelector(nsIWidget* aParentWindow, PRBool selectedFileName = PR_FALSE; nsIFileWidget *fileWidget; nsString title("Save HTML"); - nsresult rv = nsRepository::CreateInstance(kFileWidgetCID, + nsresult rv = nsComponentManager::CreateInstance(kFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget); @@ -3177,7 +3177,7 @@ nsBrowserWindow::DoDebugSave() static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); - nsresult rv = nsRepository::CreateInstance(kCParserCID, + nsresult rv = nsComponentManager::CreateInstance(kCParserCID, nsnull, kCParserIID, (void **)&parser); @@ -3268,7 +3268,7 @@ typedef struct _menuBtns { nsIMenu * CreateMenu(nsIMenu * aMenu, const nsString & aName, char aMneu) { nsIMenu * menu; - nsresult rv = nsRepository::CreateInstance(kMenuCID, + nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&menu); @@ -3284,7 +3284,7 @@ nsIMenu * CreateMenu(nsIMenu * aMenu, const nsString & aName, char aMneu) nsIMenu * CreateMenu(nsIMenuBar * aMenuBar, const nsString & aName, char aMneu) { nsIMenu * menu; - nsresult rv = nsRepository::CreateInstance(kMenuCID, + nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&menu); @@ -3302,7 +3302,7 @@ nsIMenuItem * CreateMenuItem(nsIMenu * aMenu, const nsString & aName, PRUint32 a nsIMenuItem * menuItem = nsnull; if (!aName.Equals("-")) { - nsresult rv = nsRepository::CreateInstance(kMenuItemCID, + nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&menuItem); @@ -3428,7 +3428,7 @@ nsresult nsBrowserWindow::CreateMenuBar(PRInt32 aWidth) { nsIMenuBar * menuBar; - nsresult rv = nsRepository::CreateInstance(kMenuBarCID, + nsresult rv = nsComponentManager::CreateInstance(kMenuBarCID, nsnull, kIMenuBarIID, (void**)&menuBar); diff --git a/mozilla/xpfe/xpviewer/src/nsSetupRegistry.cpp b/mozilla/xpfe/xpviewer/src/nsSetupRegistry.cpp index d2856d2af48..2b98fa769b3 100644 --- a/mozilla/xpfe/xpviewer/src/nsSetupRegistry.cpp +++ b/mozilla/xpfe/xpviewer/src/nsSetupRegistry.cpp @@ -18,7 +18,7 @@ */ #define NS_IMPL_IDS #include "nsIPref.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsWidgetsCID.h" #include "nsGfxCIID.h" #include "nsViewsCID.h" @@ -148,62 +148,62 @@ static NS_DEFINE_IID(kCXULCommandCID, NS_XULCOMMAND_CID); extern "C" void NS_SetupRegistry() { - nsRepository::RegisterComponent(kLookAndFeelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCHScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDialogCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCLabelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCComboBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCFileWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCListBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCRadioButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCTextAreaCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCTextFieldCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCCheckButtonIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCChildIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCAppShellCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCToolkitCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCImageIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCRegionIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCBlenderIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDeviceContextSpecCID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDeviceContextSpecFactoryCID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCViewManagerCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCScrollingViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kWebShellCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDocumentLoaderCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kThrobberCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kPrefCID, NULL, NULL, PREF_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCPluginHostCID, NULL, NULL, PLUGIN_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDOMScriptObjectFactory, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCDOMNativeObjectRegistry, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCHTMLDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCXMLDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCImageDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCRangeListCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCRangeCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCHTMLImageElement, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kLookAndFeelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCWindowIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCHScrollbarIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDialogCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCLabelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCComboBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCFileWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCListBoxCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRadioButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCTextAreaCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCTextFieldCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCCheckButtonIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCChildIID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCAppShellCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCToolkitCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRenderingContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDeviceContextIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCFontMetricsIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCImageIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRegionIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCBlenderIID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDeviceContextSpecCID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDeviceContextSpecFactoryCID, NULL, NULL, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCViewManagerCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCScrollingViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kWebShellCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDocumentLoaderCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kThrobberCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kPrefCID, NULL, NULL, PREF_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCPluginHostCID, NULL, NULL, PLUGIN_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCParserCID, NULL, NULL, PARSER_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDOMScriptObjectFactory, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCDOMNativeObjectRegistry, NULL, NULL, DOM_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCHTMLDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCXMLDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCImageDocument, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRangeListCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCRangeCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCHTMLImageElement, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCImageButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCToolbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCToolbarManagerCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCToolbarItemHolderCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCPopUpMenuCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCMenuButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCMenuBarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCMenuCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCMenuItemCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsRepository::RegisterComponent(kCXULCommandCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCImageButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCToolbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCToolbarManagerCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCToolbarItemHolderCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCPopUpMenuCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCMenuButtonCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCMenuBarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCMenuCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCMenuItemCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCXULCommandCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); #ifndef XP_MAC // temporary - nsRepository::RegisterComponent(kCEditorCID, NULL, NULL, EDITOR_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponent(kCEditorCID, NULL, NULL, EDITOR_DLL, PR_FALSE, PR_FALSE); #endif // XP_MAC } diff --git a/mozilla/xpfe/xpviewer/src/nsViewerApp.cpp b/mozilla/xpfe/xpviewer/src/nsViewerApp.cpp index 9b04ae20e87..b05bab2db75 100644 --- a/mozilla/xpfe/xpviewer/src/nsViewerApp.cpp +++ b/mozilla/xpfe/xpviewer/src/nsViewerApp.cpp @@ -27,7 +27,7 @@ #include "nsIAppShell.h" #include "nsIPref.h" #include "nsINetService.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" //#include "nsWebCrawler.h" #include "prprf.h" #include "plstr.h" @@ -173,10 +173,10 @@ nsViewerApp::SetupRegistry() // Register our browser window factory nsIFactory* bwf; NS_NewBrowserWindowFactory(&bwf); - nsRepository::RegisterFactory(kBrowserWindowCID, NULL, NULL, bwf, PR_FALSE); + nsComponentManager::RegisterFactory(kBrowserWindowCID, NULL, NULL, bwf, PR_FALSE); NS_NewXPBaseWindowFactory(&bwf); - nsRepository::RegisterFactory(kXPBaseWindowCID, NULL, NULL, bwf, PR_FALSE); + nsComponentManager::RegisterFactory(kXPBaseWindowCID, NULL, NULL, bwf, PR_FALSE); return NS_OK; } @@ -192,7 +192,7 @@ nsViewerApp::Initialize(int argc, char** argv) } // Create widget application shell - rv = nsRepository::CreateInstance(kAppShellCID, nsnull, kIAppShellIID, + rv = nsComponentManager::CreateInstance(kAppShellCID, nsnull, kIAppShellIID, (void**)&mAppShell); if (NS_OK != rv) { return rv; @@ -200,7 +200,7 @@ nsViewerApp::Initialize(int argc, char** argv) mAppShell->Create(&argc, argv); // Load preferences - rv = nsRepository::CreateInstance(kPrefCID, NULL, kIPrefIID, + rv = nsComponentManager::CreateInstance(kPrefCID, NULL, kIPrefIID, (void **) &mPrefs); if (NS_OK != rv) { return rv; @@ -531,7 +531,7 @@ nsViewerApp::OpenWindow() // browser window. For the time being the reference is released by the // browser event handling code during processing of the NS_DESTROY event... nsBrowserWindow* bw = nsnull; - nsresult rv = nsRepository::CreateInstance(kBrowserWindowCID, nsnull, + nsresult rv = nsComponentManager::CreateInstance(kBrowserWindowCID, nsnull, kIBrowserWindowIID, (void**) &bw); bw->SetApp(this); @@ -543,7 +543,7 @@ nsViewerApp::OpenWindow() // browser window. For the time being the reference is released by the // browser event handling code during processing of the NS_DESTROY event... /*nsXPDialogWindow* dialog = nsnull; - rv = nsRepository::CreateInstance(kXPDialogWindowCID, nsnull, + rv = nsComponentManager::CreateInstance(kXPDialogWindowCID, nsnull, kIXPDialogWindowIID, (void**) &dialog); dialog->SetApp(this); @@ -587,7 +587,7 @@ nsViewerApp::OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow) { // Create browser window nsBrowserWindow* bw = nsnull; - nsresult rv = nsRepository::CreateInstance(kBrowserWindowCID, nsnull, + nsresult rv = nsComponentManager::CreateInstance(kBrowserWindowCID, nsnull, kIBrowserWindowIID, (void**) &bw); bw->SetApp(this); @@ -807,7 +807,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) nsRect rect; rect.SetRect(0, 0, dialogWidth, 162); - nsRepository::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mRobotDialog); + nsComponentManager::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mRobotDialog); NS_CreateDialog(aParent, mRobotDialog,rect,HandleRobotEvent,&font); mRobotDialog->SetLabel("Debug Robot Options"); @@ -816,7 +816,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) nscolor textFGColor = NS_RGB(255,255,255); nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); lookAndFeel->GetColor(nsILookAndFeel::eColor_TextBackground, textBGColor); lookAndFeel->GetColor(nsILookAndFeel::eColor_TextForeground, textFGColor); @@ -829,7 +829,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) // Create Update CheckButton rect.SetRect(x, y, 150, 24); - nsRepository::CreateInstance(kCheckButtonCID, nsnull, kICheckButtonIID, (void**)&mUpdateChkBtn); + nsComponentManager::CreateInstance(kCheckButtonCID, nsnull, kICheckButtonIID, (void**)&mUpdateChkBtn); NS_CreateCheckButton(mRobotDialog, mUpdateChkBtn,rect,HandleRobotEvent,&font); mUpdateChkBtn->SetLabel("Update Display (Visual)"); mUpdateChkBtn->SetState(PR_TRUE); @@ -838,7 +838,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) // Create Label w = 115; rect.SetRect(x, y+3, w, 24); - nsRepository::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); + nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); NS_CreateLabel(mRobotDialog,label,rect,HandleRobotEvent,&font); label->SetAlignment(eAlign_Right); label->SetLabel("Verfication Directory:"); @@ -847,7 +847,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) // Create TextField nsIWidget* widget = nsnull; rect.SetRect(x, y, 225, txtHeight); - nsRepository::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mVerDirTxt); + nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mVerDirTxt); NS_CreateTextWidget(mRobotDialog,mVerDirTxt,rect,HandleRobotEvent,&font); if (mVerDirTxt && NS_OK == mVerDirTxt->QueryInterface(kIWidgetIID,(void**)&widget)) { @@ -863,7 +863,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) x = 5; w = 55; rect.SetRect(x, y+4, w, 24); - nsRepository::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); + nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); NS_CreateLabel(mRobotDialog,label,rect,HandleRobotEvent,&font); label->SetAlignment(eAlign_Right); label->SetLabel("Stop after:"); @@ -871,7 +871,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) // Create TextField rect.SetRect(x, y, 75, txtHeight); - nsRepository::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mStopAfterTxt); + nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID, (void**)&mStopAfterTxt); NS_CreateTextWidget(mRobotDialog,mStopAfterTxt,rect,HandleRobotEvent,&font); if (mStopAfterTxt && NS_OK == mStopAfterTxt->QueryInterface(kIWidgetIID,(void**)&widget)) { @@ -883,7 +883,7 @@ PRBool CreateRobotDialog(nsIWidget * aParent) w = 75; rect.SetRect(x, y+4, w, 24); - nsRepository::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); + nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); NS_CreateLabel(mRobotDialog,label,rect,HandleRobotEvent,&font); label->SetAlignment(eAlign_Left); label->SetLabel("(page loads)"); @@ -895,14 +895,14 @@ PRBool CreateRobotDialog(nsIWidget * aParent) nscoord xx = (dialogWidth - (2*w)) / 3; // Create Find Start Button rect.SetRect(xx, y, w, 24); - nsRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mStartBtn); + nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mStartBtn); NS_CreateButton(mRobotDialog,mStartBtn,rect,HandleRobotEvent,&font); mStartBtn->SetLabel("Start"); xx += w + xx; // Create Cancel Button rect.SetRect(xx, y, w, 24); - nsRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mCancelBtn); + nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mCancelBtn); NS_CreateButton(mRobotDialog,mCancelBtn,rect,HandleRobotEvent,&font); mCancelBtn->SetLabel("Cancel"); @@ -1158,7 +1158,7 @@ PRBool CreateSiteDialog(nsIWidget * aParent) nscolor textFGColor = NS_RGB(255,255,255); nsILookAndFeel * lookAndFeel; - if (NS_OK == nsRepository::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { //lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight); //lookAndFeel->GetColor(nsILookAndFeel::eColor_TextBackground, textBGColor); //lookAndFeel->GetColor(nsILookAndFeel::eColor_TextForeground, textFGColor); @@ -1181,7 +1181,7 @@ PRBool CreateSiteDialog(nsIWidget * aParent) rect.SetRect(0, 0, dialogWidth, 125); nsIWidget* widget = nsnull; - nsRepository::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mSiteDialog); + nsComponentManager::CreateInstance(kDialogCID, nsnull, kIDialogIID, (void**)&mSiteDialog); if (mSiteDialog && NS_OK == mSiteDialog->QueryInterface(kIWidgetIID,(void**)&widget)) { widget->Create(aParent, rect, HandleSiteEvent, NULL); @@ -1197,7 +1197,7 @@ PRBool CreateSiteDialog(nsIWidget * aParent) // Create Label w = 50; rect.SetRect(x, y+3, w, 24); - nsRepository::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); + nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&label); NS_CreateLabel(mSiteDialog,label,rect,HandleSiteEvent,&font); label->SetAlignment(eAlign_Right); label->SetLabel("Site:"); @@ -1205,7 +1205,7 @@ PRBool CreateSiteDialog(nsIWidget * aParent) w = 250; rect.SetRect(x, y+3, w, 24); - nsRepository::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&mSiteLabel); + nsComponentManager::CreateInstance(kLabelCID, nsnull, kILabelIID, (void**)&mSiteLabel); NS_CreateLabel(mSiteDialog,mSiteLabel,rect,HandleSiteEvent,&font); mSiteLabel->SetAlignment(eAlign_Left); mSiteLabel->SetLabel(""); @@ -1216,21 +1216,21 @@ PRBool CreateSiteDialog(nsIWidget * aParent) x = spacing; // Create Previous Button rect.SetRect(x, y, w, 24); - nsRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSitePrevBtn); + nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSitePrevBtn); NS_CreateButton(mSiteDialog,mSitePrevBtn,rect,HandleSiteEvent,&font); mSitePrevBtn->SetLabel("<< Previous"); x += spacing + w; // Create Next Button rect.SetRect(x, y, w, 24); - nsRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteNextBtn); + nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteNextBtn); NS_CreateButton(mSiteDialog,mSiteNextBtn,rect,HandleSiteEvent,&font); mSiteNextBtn->SetLabel("Next >>"); x += spacing + w; // Create Cancel Button rect.SetRect(x, y, w, 24); - nsRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteCancelBtn); + nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID, (void**)&mSiteCancelBtn); NS_CreateButton(mSiteDialog,mSiteCancelBtn,rect,HandleSiteEvent,&font); mSiteCancelBtn->SetLabel("Cancel"); } diff --git a/mozilla/xpfe/xpviewer/src/nsXPBaseWindow.cpp b/mozilla/xpfe/xpviewer/src/nsXPBaseWindow.cpp index 8aee8787dec..f7e00eba666 100644 --- a/mozilla/xpfe/xpviewer/src/nsXPBaseWindow.cpp +++ b/mozilla/xpfe/xpviewer/src/nsXPBaseWindow.cpp @@ -32,7 +32,7 @@ #include "nsIWidget.h" #include "nsIDOMDocument.h" #include "nsIURL.h" -#include "nsRepository.h" +#include "nsIComponentManager.h" #include "nsIFactory.h" #include "nsCRT.h" #include "nsWidgetsCID.h" @@ -211,10 +211,10 @@ nsresult nsXPBaseWindow::Init(nsXPBaseWindowType aType, // Create top level window nsresult rv; if (aType == eXPBaseWindowType_window) { - rv = nsRepository::CreateInstance(kWindowCID, nsnull, kIWidgetIID, + rv = nsComponentManager::CreateInstance(kWindowCID, nsnull, kIWidgetIID, (void**)&mWindow); } else { - rv= nsRepository::CreateInstance(kDialogCID, nsnull, kIWidgetIID, + rv= nsComponentManager::CreateInstance(kDialogCID, nsnull, kIWidgetIID, (void**)&mWindow); } @@ -233,7 +233,7 @@ nsresult nsXPBaseWindow::Init(nsXPBaseWindowType aType, mWindow->GetBounds(r); // Create web shell - rv = nsRepository::CreateInstance(kWebShellCID, nsnull, + rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&mWebShell); if (NS_OK != rv) {