diff --git a/mozilla/base/src/nsBaseDLL.cpp b/mozilla/base/src/nsBaseDLL.cpp index 1503ff89d12..1a332ed626c 100644 --- a/mozilla/base/src/nsBaseDLL.cpp +++ b/mozilla/base/src/nsBaseDLL.cpp @@ -27,7 +27,7 @@ PRInt32 gLockCount = 0; NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); extern "C" NS_EXPORT nsresult -NSRegisterSelf(const char* path) +NSRegisterSelf(nsISupports* aServMgr, const char* path) { nsresult ret; @@ -41,7 +41,7 @@ NSRegisterSelf(const char* path) } extern "C" NS_EXPORT nsresult -NSUnregisterSelf(const char* path) +NSUnregisterSelf(nsISupports* aServMgr, const char* path) { nsresult ret; @@ -54,7 +54,11 @@ NSUnregisterSelf(const char* path) } extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID& aClass, nsISupports* aServMgr, nsIFactory** aFactory) +NSGetFactory(nsISupports* aServMgr, + const nsCID& aClass, + const char *aClassName, + const char *aProgID, + nsIFactory** aFactory) { nsresult res; @@ -78,3 +82,9 @@ NSGetFactory(const nsCID& aClass, nsISupports* aServMgr, nsIFactory** aFactory) return NS_NOINTERFACE; } + +extern "C" NS_EXPORT PRBool +NSCanUnload(nsISupports* serviceMgr) +{ + return PR_FALSE; // XXX can we unload this? +} diff --git a/mozilla/caps/src/nsCCapsManagerFactory.cpp b/mozilla/caps/src/nsCCapsManagerFactory.cpp index 964e90bd96a..40712762700 100644 --- a/mozilla/caps/src/nsCCapsManagerFactory.cpp +++ b/mozilla/caps/src/nsCCapsManagerFactory.cpp @@ -40,7 +40,11 @@ nsIFactory *nsCCapsManagerFactory::m_pNSIFactory = NULL; +++++++++++++++++++++++++++++++++++++++++++++++++*/ extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +NSGetFactory(nsISupports* servMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (!aClass.Equals(kCCapsManagerCID)) { @@ -55,7 +59,7 @@ NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) } extern "C" NS_EXPORT PRBool -NSCanUnload(void) +NSCanUnload(nsISupports* serviceMgr) { return PR_FALSE; } @@ -134,8 +138,8 @@ nsCCapsManagerFactory::nsCCapsManagerFactory(void) if ( (err == NS_OK) && (m_pNSIFactory != NULL) ) { NS_DEFINE_CID(kCCapsManagerCID, NS_CCAPSMANAGER_CID); - nsRepository::RegisterFactory(kCCapsManagerCID, m_pNSIFactory, - PR_FALSE); + nsRepository::RegisterFactory(kCCapsManagerCID, 0, 0, + m_pNSIFactory, PR_FALSE); } } diff --git a/mozilla/dom/src/build/nsDOMFactory.cpp b/mozilla/dom/src/build/nsDOMFactory.cpp index 5bbda6a98ca..11f5a2810dd 100644 --- a/mozilla/dom/src/build/nsDOMFactory.cpp +++ b/mozilla/dom/src/build/nsDOMFactory.cpp @@ -666,9 +666,19 @@ nsresult nsDOMFactory::LockFactory(PRBool aLock) // return the proper factory to the caller #if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_DOM nsresult NSGetFactory_DOM_DLL(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_DOM nsresult +NSGetFactory_DOM_DLL(nsISupports* servMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #else -extern "C" NS_DOM nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory ) +extern "C" NS_DOM nsresult +NSGetFactory(nsISupports* servMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #endif { if (nsnull == aFactory) { diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index 76371c34f0c..f99d8bd0f37 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -131,8 +131,10 @@ PRMonitor *getEditorMonitor() //if more than one person asks for the monitor at we must be good providers of factories ect. this is where to put ALL editor exports */ //BEGIN EXPORTS -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID & aClass, - nsISupports * aServiceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServiceMgr, + const nsCID & aClass, + const char *aClassName, + const char *aProgID, nsIFactory ** aFactory) { if (nsnull == aFactory) { @@ -153,7 +155,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID & aClass, extern "C" NS_EXPORT PRBool -NSCanUnload(void) +NSCanUnload(nsISupports* serviceMgr) { return nsEditor::gInstanceCount; //I have no idea. I am copying code here } @@ -161,14 +163,14 @@ NSCanUnload(void) extern "C" NS_EXPORT nsresult -NSRegisterSelf(const char *path) +NSRegisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::RegisterFactory(kIEditFactoryIID, path, PR_TRUE, PR_TRUE); //this will register the factory with the xpcom dll. } extern "C" NS_EXPORT nsresult -NSUnregisterSelf(const char *path) +NSUnregisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::UnregisterFactory(kIEditFactoryIID, path);//this will unregister the factory with the xpcom dll. } diff --git a/mozilla/editor/base/nsEditor.h b/mozilla/editor/base/nsEditor.h index 7eb0b7ca470..e98a6dbd309 100644 --- a/mozilla/editor/base/nsEditor.h +++ b/mozilla/editor/base/nsEditor.h @@ -64,7 +64,7 @@ private: nsCOMPtr mTxnMgr; - friend PRBool NSCanUnload(void); + friend PRBool NSCanUnload(nsISupports* serviceMgr); static PRInt32 gInstanceCount; public: diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index 76371c34f0c..f99d8bd0f37 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -131,8 +131,10 @@ PRMonitor *getEditorMonitor() //if more than one person asks for the monitor at we must be good providers of factories ect. this is where to put ALL editor exports */ //BEGIN EXPORTS -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID & aClass, - nsISupports * aServiceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServiceMgr, + const nsCID & aClass, + const char *aClassName, + const char *aProgID, nsIFactory ** aFactory) { if (nsnull == aFactory) { @@ -153,7 +155,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID & aClass, extern "C" NS_EXPORT PRBool -NSCanUnload(void) +NSCanUnload(nsISupports* serviceMgr) { return nsEditor::gInstanceCount; //I have no idea. I am copying code here } @@ -161,14 +163,14 @@ NSCanUnload(void) extern "C" NS_EXPORT nsresult -NSRegisterSelf(const char *path) +NSRegisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::RegisterFactory(kIEditFactoryIID, path, PR_TRUE, PR_TRUE); //this will register the factory with the xpcom dll. } extern "C" NS_EXPORT nsresult -NSUnregisterSelf(const char *path) +NSUnregisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::UnregisterFactory(kIEditFactoryIID, path);//this will unregister the factory with the xpcom dll. } diff --git a/mozilla/editor/libeditor/base/nsEditor.h b/mozilla/editor/libeditor/base/nsEditor.h index 7eb0b7ca470..e98a6dbd309 100644 --- a/mozilla/editor/libeditor/base/nsEditor.h +++ b/mozilla/editor/libeditor/base/nsEditor.h @@ -64,7 +64,7 @@ private: nsCOMPtr mTxnMgr; - friend PRBool NSCanUnload(void); + friend PRBool NSCanUnload(nsISupports* serviceMgr); static PRInt32 gInstanceCount; public: diff --git a/mozilla/editor/txmgr/src/nsTransactionManagerFactory.cpp b/mozilla/editor/txmgr/src/nsTransactionManagerFactory.cpp index 053ef06156d..8076ee7cc67 100644 --- a/mozilla/editor/txmgr/src/nsTransactionManagerFactory.cpp +++ b/mozilla/editor/txmgr/src/nsTransactionManagerFactory.cpp @@ -113,8 +113,11 @@ nsresult nsTransactionManagerFactory::LockFactory(PRBool aLock) } // return the proper factory to the caller -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory -**aFactory) +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (!aFactory) return NS_ERROR_NULL_POINTER; @@ -129,13 +132,13 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsISupports* ser return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); } -extern "C" NS_EXPORT nsresult NSRegisterSelf(const char *path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::RegisterFactory(kCTransactionManagerFactoryCID, path, PR_TRUE, PR_TRUE); } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char *path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::UnregisterFactory(kCTransactionManagerFactoryCID, path); } diff --git a/mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp b/mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp index ee9eaa9e3ab..2d01117394b 100644 --- a/mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp +++ b/mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp @@ -178,7 +178,11 @@ nsresult nsGfxFactoryGTK::LockFactory(PRBool aLock) } // return the proper factory to the caller -extern "C" NS_GFXNONXP nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_GFXNONXP nsresult NSGetFactory(nsISupports* servMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (nsnull == aFactory) { return NS_ERROR_NULL_POINTER; diff --git a/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp b/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp index 8901d6367ba..5148dd4ff7f 100644 --- a/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp +++ b/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp @@ -175,9 +175,17 @@ nsresult nsGfxFactoryMac::LockFactory(PRBool aLock) // return the proper factory to the caller #if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_GFX nsresult NSGetFactory_GFXWIN_DLL(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_GFX nsresult NSGetFactory_GFXWIN_DLL(nsISupports* servMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #else -extern "C" NS_GFX nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_GFX nsresult NSGetFactory(nsISupports* servMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #endif { if (nsnull == aFactory) { diff --git a/mozilla/gfx/src/motif/nsGfxFactoryMotif.cpp b/mozilla/gfx/src/motif/nsGfxFactoryMotif.cpp index 3c2b59b5b87..6a55d6efd31 100644 --- a/mozilla/gfx/src/motif/nsGfxFactoryMotif.cpp +++ b/mozilla/gfx/src/motif/nsGfxFactoryMotif.cpp @@ -161,7 +161,11 @@ nsresult nsGfxFactoryMotif::LockFactory(PRBool aLock) } // return the proper factory to the caller -extern "C" NS_GFXNONXP nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_GFXNONXP nsresult NSGetFactory(nsISupports* servMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (nsnull == aFactory) { return NS_ERROR_NULL_POINTER; diff --git a/mozilla/gfx/src/windows/nsGfxFactoryWin.cpp b/mozilla/gfx/src/windows/nsGfxFactoryWin.cpp index fba31518346..7ede00aad85 100644 --- a/mozilla/gfx/src/windows/nsGfxFactoryWin.cpp +++ b/mozilla/gfx/src/windows/nsGfxFactoryWin.cpp @@ -197,7 +197,11 @@ nsresult nsGfxFactoryWin::LockFactory(PRBool aLock) } // return the proper factory to the caller -extern "C" NS_GFXNONXP nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_GFXNONXP nsresult NSGetFactory(nsISupports* servMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (nsnull == aFactory) { return NS_ERROR_NULL_POINTER; diff --git a/mozilla/htmlparser/src/nsParserFactory.cpp b/mozilla/htmlparser/src/nsParserFactory.cpp index 09ed01b0090..aa6ee799223 100644 --- a/mozilla/htmlparser/src/nsParserFactory.cpp +++ b/mozilla/htmlparser/src/nsParserFactory.cpp @@ -167,9 +167,19 @@ nsresult nsParserFactory::LockFactory(PRBool aLock) // return the proper factory to the caller #if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_EXPORT nsresult NSGetFactory_PARSER_DLL(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_EXPORT nsresult +NSGetFactory_PARSER_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #else -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_EXPORT nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #endif { if (nsnull == aFactory) { diff --git a/mozilla/intl/locale/src/mac/nsLocaleSHLIB.cpp b/mozilla/intl/locale/src/mac/nsLocaleSHLIB.cpp index 2045e72bec9..77e83dd2ddf 100644 --- a/mozilla/intl/locale/src/mac/nsLocaleSHLIB.cpp +++ b/mozilla/intl/locale/src/mac/nsLocaleSHLIB.cpp @@ -47,9 +47,15 @@ NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID); NS_DEFINE_CID(kCollationCID, NS_COLLATION_CID); NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID); -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* serviceMgr, - nsIFactory **aFactory); -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, nsIFactory **aFactory) { nsIFactory* factoryInstance; diff --git a/mozilla/intl/locale/src/unix/nsLocaleSO.cpp b/mozilla/intl/locale/src/unix/nsLocaleSO.cpp index e2617c534a4..61e81f2c06a 100644 --- a/mozilla/intl/locale/src/unix/nsLocaleSO.cpp +++ b/mozilla/intl/locale/src/unix/nsLocaleSO.cpp @@ -49,7 +49,10 @@ NS_DEFINE_CID(kCollationCID, NS_COLLATION_CID); NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID); -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, nsIFactory **aFactory) { nsIFactory* factoryInstance; diff --git a/mozilla/intl/locale/src/windows/nsLocaleDLL.cpp b/mozilla/intl/locale/src/windows/nsLocaleDLL.cpp index 9114abf42a1..95cbae1c48a 100644 --- a/mozilla/intl/locale/src/windows/nsLocaleDLL.cpp +++ b/mozilla/intl/locale/src/windows/nsLocaleDLL.cpp @@ -50,7 +50,10 @@ NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID); NS_DEFINE_CID(kCollationCID, NS_COLLATION_CID); NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID); -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, nsIFactory **aFactory) { nsIFactory* factoryInstance; @@ -61,7 +64,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* servi // // first check for the nsILocaleFactory interfaces // - if (aCID.Equals(kLocaleFactoryCID)) + if (aClass.Equals(kLocaleFactoryCID)) { factoryInstance = new nsLocaleFactory(); res = factoryInstance->QueryInterface(kILocaleFactoryIID, (void **) aFactory); @@ -78,7 +81,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* servi // // okay about bout nsIWin32LocaleManager // - if (aCID.Equals(kWin32LocaleFactoryCID)) + if (aClass.Equals(kWin32LocaleFactoryCID)) { factoryInstance = new nsIWin32LocaleFactory(); res = factoryInstance->QueryInterface(kIFactoryIID,(void**)aFactory); @@ -93,7 +96,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* servi // // let the nsLocaleFactoryWin logic take over from here // - factoryInstance = new nsLocaleWinFactory(aCID); + factoryInstance = new nsLocaleWinFactory(aClass); if(NULL == factoryInstance) { @@ -110,7 +113,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* servi return res; } -extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char * path) { nsresult res; @@ -152,7 +155,7 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path) return NS_OK; } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char * path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char * path) { nsresult res; diff --git a/mozilla/intl/lwbrk/src/nsLWBrk.cpp b/mozilla/intl/lwbrk/src/nsLWBrk.cpp index 6777d1b56fa..6a37459124c 100644 --- a/mozilla/intl/lwbrk/src/nsLWBrk.cpp +++ b/mozilla/intl/lwbrk/src/nsLWBrk.cpp @@ -79,13 +79,16 @@ nsresult nsLWBrkFactory::CreateInstance(nsISupports *aDelegate, return res; } -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, nsIFactory **aFactory) { if (aFactory == NULL) { return NS_ERROR_NULL_POINTER; } - if (aCID.Equals(kLWBrkCID)) { + if (aClass.Equals(kLWBrkCID)) { nsLWBrkFactory *factory = new nsLWBrkFactory(); nsresult res = factory->QueryInterface(kFactoryIID, (void **) aFactory); if (NS_FAILED(res)) { @@ -97,17 +100,17 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* servi return NS_NOINTERFACE; } -extern "C" NS_EXPORT PRBool NSCanUnload() { +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSRegisterSelf(const char *path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::RegisterFactory(kLWBrkCID, path, PR_TRUE, PR_TRUE); } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char *path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::UnregisterFactory(kLWBrkCID, path); } diff --git a/mozilla/intl/strres/src/nsStringBundle.cpp b/mozilla/intl/strres/src/nsStringBundle.cpp index 44c20ff502b..6cae973d45b 100644 --- a/mozilla/intl/strres/src/nsStringBundle.cpp +++ b/mozilla/intl/strres/src/nsStringBundle.cpp @@ -208,7 +208,7 @@ nsStringBundleServiceFactory::LockFactory(PRBool aLock) } extern "C" NS_EXPORT nsresult -NSRegisterSelf(const char* path) +NSRegisterSelf(nsISupports* serviceMgr, const char* path) { nsresult ret; @@ -222,7 +222,7 @@ NSRegisterSelf(const char* path) } extern "C" NS_EXPORT nsresult -NSUnregisterSelf(const char* path) +NSUnregisterSelf(nsISupports* serviceMgr, const char* path) { nsresult ret; @@ -235,7 +235,11 @@ NSUnregisterSelf(const char* path) } extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID& aClass, nsISupports* aServMgr, nsIFactory** aFactory) +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { nsresult res; diff --git a/mozilla/intl/uconv/src/nsUConvDll.cpp b/mozilla/intl/uconv/src/nsUConvDll.cpp index a833a15dfd1..a8a52b20e49 100644 --- a/mozilla/intl/uconv/src/nsUConvDll.cpp +++ b/mozilla/intl/uconv/src/nsUConvDll.cpp @@ -36,18 +36,21 @@ extern "C" PRInt32 g_LockCount = 0; NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -extern "C" NS_EXPORT PRBool NSCanUnload() +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, nsIFactory **aFactory) { if (aFactory == NULL) return NS_ERROR_NULL_POINTER; // the converter manager - if (aCID.Equals(kCharsetConverterManagerCID)) { + if (aClass.Equals(kCharsetConverterManagerCID)) { nsManagerFactory *factory = new nsManagerFactory(); nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory); @@ -60,7 +63,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* servi } // the Unicode Encode helper - if (aCID.Equals(kUnicodeEncodeHelperCID)) { + if (aClass.Equals(kUnicodeEncodeHelperCID)) { nsEncodeHelperFactory *factory = new nsEncodeHelperFactory(); nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory); @@ -72,7 +75,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* servi return res; } - if (aCID.Equals(kPlatformCharsetCID)) { + if (aClass.Equals(kPlatformCharsetCID)) { nsIFactory *factory = NEW_PLATFORMCHARSETFACTORY(); nsresult res = factory->QueryInterface(kIFactoryIID, (void**) aFactory); if (NS_FAILED(res)) { @@ -86,7 +89,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* servi return NS_NOINTERFACE; } -extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char * path) { nsresult res; @@ -103,7 +106,7 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path) return res; } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char * path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char * path) { nsresult res; diff --git a/mozilla/intl/uconv/ucvja/nsUCVJADll.cpp b/mozilla/intl/uconv/ucvja/nsUCVJADll.cpp index 6e64f56c09b..c17c25d6459 100644 --- a/mozilla/intl/uconv/ucvja/nsUCVJADll.cpp +++ b/mozilla/intl/uconv/ucvja/nsUCVJADll.cpp @@ -110,13 +110,15 @@ public: NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -extern "C" NS_EXPORT PRBool NSCanUnload() +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, - nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, nsIFactory **aFactory) { if (aFactory == NULL) return NS_ERROR_NULL_POINTER; @@ -127,7 +129,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, for (PRInt32 i=0; imCID))) { + if (aClass.Equals(*(data->mCID))) { fac = new nsConverterFactory(data); res = fac->QueryInterface(kIFactoryIID, (void **) aFactory); if (NS_FAILED(res)) { @@ -142,7 +144,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, return NS_NOINTERFACE; } -extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char * path) { nsresult res; @@ -155,7 +157,7 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path) return res; } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char * path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char * path) { nsresult res; diff --git a/mozilla/intl/uconv/ucvja2/nsUCVJA2Dll.cpp b/mozilla/intl/uconv/ucvja2/nsUCVJA2Dll.cpp index 0d7291e1dcb..409b19848cc 100644 --- a/mozilla/intl/uconv/ucvja2/nsUCVJA2Dll.cpp +++ b/mozilla/intl/uconv/ucvja2/nsUCVJA2Dll.cpp @@ -129,13 +129,15 @@ public: NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -extern "C" NS_EXPORT PRBool NSCanUnload() +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, - nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, nsIFactory **aFactory) { if (aFactory == NULL) return NS_ERROR_NULL_POINTER; @@ -146,7 +148,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, for (PRInt32 i=0; imCID))) { + if (aClass.Equals(*(data->mCID))) { fac = new nsConverterFactory(data); res = fac->QueryInterface(kIFactoryIID, (void **) aFactory); if (NS_FAILED(res)) { @@ -161,7 +163,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, return NS_NOINTERFACE; } -extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char * path) { nsresult res; @@ -174,7 +176,7 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path) return res; } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char * path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char * path) { nsresult res; diff --git a/mozilla/intl/uconv/ucvlatin/nsUCvLatinDll.cpp b/mozilla/intl/uconv/ucvlatin/nsUCvLatinDll.cpp index 2bedc87ff77..d5a8a45f497 100644 --- a/mozilla/intl/uconv/ucvlatin/nsUCvLatinDll.cpp +++ b/mozilla/intl/uconv/ucvlatin/nsUCvLatinDll.cpp @@ -133,13 +133,15 @@ public: NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -extern "C" NS_EXPORT PRBool NSCanUnload() +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, - nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, nsIFactory **aFactory) { if (aFactory == NULL) return NS_ERROR_NULL_POINTER; @@ -150,7 +152,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, for (PRInt32 i=0; imCID))) { + if (aClass.Equals(*(data->mCID))) { fac = new nsConverterFactory(data); res = fac->QueryInterface(kIFactoryIID, (void **) aFactory); if (NS_FAILED(res)) { @@ -165,7 +167,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, return NS_NOINTERFACE; } -extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char * path) { nsresult res; @@ -178,7 +180,7 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path) return res; } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char * path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char * path) { nsresult res; diff --git a/mozilla/intl/unicharutil/src/nsUnicharUtilFactory.cpp b/mozilla/intl/unicharutil/src/nsUnicharUtilFactory.cpp index 668988317bc..2eaeab2c0ed 100644 --- a/mozilla/intl/unicharutil/src/nsUnicharUtilFactory.cpp +++ b/mozilla/intl/unicharutil/src/nsUnicharUtilFactory.cpp @@ -82,13 +82,16 @@ nsresult nsUnicharUtilFactory::CreateInstance(nsISupports *aDelegate, return res; } -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* serviceMgr, +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, nsIFactory **aFactory) { if (aFactory == NULL) { return NS_ERROR_NULL_POINTER; } - if (aCID.Equals(kUnicharUtilCID)) { + if (aClass.Equals(kUnicharUtilCID)) { nsUnicharUtilFactory *factory = new nsUnicharUtilFactory(); nsresult res = factory->QueryInterface(kFactoryIID, (void **) aFactory); if (NS_FAILED(res)) { @@ -100,16 +103,16 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* servi return NS_NOINTERFACE; } -extern "C" NS_EXPORT PRBool NSCanUnload() { +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSRegisterSelf(const char *path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::RegisterFactory(kUnicharUtilCID, path, PR_TRUE, PR_TRUE); } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char *path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::UnregisterFactory(kUnicharUtilCID, path); } diff --git a/mozilla/js/src/liveconnect/nsCLiveconnectFactory.cpp b/mozilla/js/src/liveconnect/nsCLiveconnectFactory.cpp index cc582ebda5b..a68ab0eb517 100644 --- a/mozilla/js/src/liveconnect/nsCLiveconnectFactory.cpp +++ b/mozilla/js/src/liveconnect/nsCLiveconnectFactory.cpp @@ -47,7 +47,11 @@ nsCLiveconnect *nsCLiveconnectFactory::m_pNSCLiveconnect = NULL; +++++++++++++++++++++++++++++++++++++++++++++++++*/ extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (!aClass.Equals(kCLiveconnectCID)) { @@ -62,7 +66,7 @@ NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) } extern "C" NS_EXPORT PRBool -NSCanUnload(void) +NSCanUnload(nsISupports* serviceMgr) { return PR_FALSE; } @@ -149,8 +153,8 @@ nsCLiveconnectFactory::nsCLiveconnectFactory(void) if ( (err == NS_OK) && (m_pNSIFactory != NULL) ) { NS_DEFINE_CID(kCLiveconnectCID, NS_CLIVECONNECT_CID); - nsRepository::RegisterFactory(kCLiveconnectCID, m_pNSIFactory, - PR_FALSE); + nsRepository::RegisterFactory(kCLiveconnectCID, NULL, NULL, + m_pNSIFactory, PR_FALSE); } } diff --git a/mozilla/layout/build/nsLayoutFactory.cpp b/mozilla/layout/build/nsLayoutFactory.cpp index 2796db9df4b..daa6d1a117b 100644 --- a/mozilla/layout/build/nsLayoutFactory.cpp +++ b/mozilla/layout/build/nsLayoutFactory.cpp @@ -373,9 +373,19 @@ static ScriptNameSetRegistryHolder gManager; // return the proper factory to the caller #if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_LAYOUT nsresult NSGetFactory_LAYOUT_DLL(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory ) +extern "C" NS_LAYOUT nsresult +NSGetFactory_LAYOUT_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #else -extern "C" NS_LAYOUT nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_LAYOUT nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #endif { if (nsnull == ScriptNameSetRegistryHolder::gRegistry) { diff --git a/mozilla/modules/libpref/src/nsPref.cpp b/mozilla/modules/libpref/src/nsPref.cpp index 5ee59f42559..61875fefe13 100644 --- a/mozilla/modules/libpref/src/nsPref.cpp +++ b/mozilla/modules/libpref/src/nsPref.cpp @@ -583,12 +583,17 @@ nsresult nsPrefFactory::CreateInstance(nsISupports *aDelegate, return res; } -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* serviceMgr, nsIFactory **aFactory) +extern "C" NS_EXPORT nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (aFactory == NULL) { return NS_ERROR_NULL_POINTER; } - if (aCID.Equals(kPrefCID)) { + if (aClass.Equals(kPrefCID)) { nsPrefFactory *factory = new nsPrefFactory(); nsresult res = factory->QueryInterface(kFactoryIID, (void **) aFactory); if (NS_FAILED(res)) { @@ -600,18 +605,18 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* servi return NS_NOINTERFACE; } -extern "C" NS_EXPORT PRBool NSCanUnload() +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) { return PRBool(g_InstanceCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSRegisterSelf(const char *path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::RegisterComponent(kPrefCID, NULL, NULL, path, PR_TRUE, PR_TRUE); } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char *path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::UnregisterFactory(kPrefCID, path); } diff --git a/mozilla/modules/oji/src/nsCJVMManagerFactory.cpp b/mozilla/modules/oji/src/nsCJVMManagerFactory.cpp index 13c593c0c58..1a65e196f2e 100644 --- a/mozilla/modules/oji/src/nsCJVMManagerFactory.cpp +++ b/mozilla/modules/oji/src/nsCJVMManagerFactory.cpp @@ -41,7 +41,11 @@ nsIServiceManager *g_pNSIServiceManager = NULL; +++++++++++++++++++++++++++++++++++++++++++++++++*/ extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { nsresult res = NS_OK; if (!aClass.Equals(kCJVMManagerCID)) { @@ -50,9 +54,9 @@ NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) nsCJVMManagerFactory* factory = new nsCJVMManagerFactory(); if (factory == NULL) return NS_ERROR_OUT_OF_MEMORY; - factory->AddRef(); + NS_ADDREF(factory); *aFactory = factory; - res = servMgr->QueryInterface(kIServiceManagerIID, (void**)&g_pNSIServiceManager); + res = serviceMgr->QueryInterface(kIServiceManagerIID, (void**)&g_pNSIServiceManager); if ((NS_OK == res) && (nsnull != g_pNSIServiceManager)) { return NS_OK; @@ -61,7 +65,7 @@ NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) } extern "C" NS_EXPORT PRBool -NSCanUnload(void) +NSCanUnload(nsISupports* serviceMgr) { return PR_FALSE; } diff --git a/mozilla/modules/plugin/base/public/nsplugin.h b/mozilla/modules/plugin/base/public/nsplugin.h index 6b7f0fdf857..e7e2cc4bcdb 100644 --- a/mozilla/modules/plugin/base/public/nsplugin.h +++ b/mozilla/modules/plugin/base/public/nsplugin.h @@ -97,8 +97,10 @@ * by calling nsIPlugin::CreateInstance. */ // (Declared in nsRepository.h) -//extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, -// nsISupports* serviceMgr, +//extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, +// const nsCID &aClass, +// const char *aClassName, +// const char *aProgID, // nsIFactory **aFactory); /** diff --git a/mozilla/modules/plugin/base/src/nsPluginFactory.cpp b/mozilla/modules/plugin/base/src/nsPluginFactory.cpp index 959f72a05dd..b95a9b66d12 100644 --- a/mozilla/modules/plugin/base/src/nsPluginFactory.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginFactory.cpp @@ -147,7 +147,12 @@ nsresult nsPluginFactory :: LockFactory(PRBool aLock) } // return the proper factory to the caller -extern "C" NS_PLUGIN nsresult NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory ) +extern "C" NS_PLUGIN nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (nsnull == aFactory) { return NS_ERROR_NULL_POINTER; diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 8a8720e4ce9..5272f2ff10f 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -1770,7 +1770,7 @@ NS_IMETHODIMP nsPluginHostImpl :: SetUpPluginInstance(const char *aMimeType, nsFactoryProc fact = (nsFactoryProc)PR_FindSymbol(plugins->mLibrary, "NSGetFactory"); if (nsnull != fact) - (fact)(kIPluginIID, mServiceMgr, (nsIFactory**)&plugins->mEntryPoint); + (fact)(mServiceMgr, kIPluginIID, 0, 0, (nsIFactory**)&plugins->mEntryPoint); // we only need to call this for 5x style plugins - CreatePlugin() handles this for // 4x style plugins @@ -1837,7 +1837,8 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi // need to get the plugin factory from this plugin. nsFactoryProc nsGetFactory = (nsFactoryProc) PR_FindSymbol(pluginTag->mLibrary, "NSGetFactory"); if (nsGetFactory != NULL) { - res = nsGetFactory(kIPluginIID, mServiceMgr, (nsIFactory**)&pluginTag->mEntryPoint); + res = nsGetFactory(mServiceMgr, kIPluginIID, nsnull, nsnull, // XXX fix ClassName/ProgID + (nsIFactory**)&pluginTag->mEntryPoint); plugin = pluginTag->mEntryPoint; if (plugin != NULL) plugin->Initialize(); diff --git a/mozilla/modules/plugin/nglsrc/nsPluginFactory.cpp b/mozilla/modules/plugin/nglsrc/nsPluginFactory.cpp index 959f72a05dd..b95a9b66d12 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginFactory.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginFactory.cpp @@ -147,7 +147,12 @@ nsresult nsPluginFactory :: LockFactory(PRBool aLock) } // return the proper factory to the caller -extern "C" NS_PLUGIN nsresult NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory ) +extern "C" NS_PLUGIN nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (nsnull == aFactory) { return NS_ERROR_NULL_POINTER; diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp index 8a8720e4ce9..5272f2ff10f 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -1770,7 +1770,7 @@ NS_IMETHODIMP nsPluginHostImpl :: SetUpPluginInstance(const char *aMimeType, nsFactoryProc fact = (nsFactoryProc)PR_FindSymbol(plugins->mLibrary, "NSGetFactory"); if (nsnull != fact) - (fact)(kIPluginIID, mServiceMgr, (nsIFactory**)&plugins->mEntryPoint); + (fact)(mServiceMgr, kIPluginIID, 0, 0, (nsIFactory**)&plugins->mEntryPoint); // we only need to call this for 5x style plugins - CreatePlugin() handles this for // 4x style plugins @@ -1837,7 +1837,8 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi // need to get the plugin factory from this plugin. nsFactoryProc nsGetFactory = (nsFactoryProc) PR_FindSymbol(pluginTag->mLibrary, "NSGetFactory"); if (nsGetFactory != NULL) { - res = nsGetFactory(kIPluginIID, mServiceMgr, (nsIFactory**)&pluginTag->mEntryPoint); + res = nsGetFactory(mServiceMgr, kIPluginIID, nsnull, nsnull, // XXX fix ClassName/ProgID + (nsIFactory**)&pluginTag->mEntryPoint); plugin = pluginTag->mEntryPoint; if (plugin != NULL) plugin->Initialize(); diff --git a/mozilla/modules/plugin/public/nsplugin.h b/mozilla/modules/plugin/public/nsplugin.h index 6b7f0fdf857..e7e2cc4bcdb 100644 --- a/mozilla/modules/plugin/public/nsplugin.h +++ b/mozilla/modules/plugin/public/nsplugin.h @@ -97,8 +97,10 @@ * by calling nsIPlugin::CreateInstance. */ // (Declared in nsRepository.h) -//extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, -// nsISupports* serviceMgr, +//extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, +// const nsCID &aClass, +// const char *aClassName, +// const char *aProgID, // nsIFactory **aFactory); /** diff --git a/mozilla/modules/plugin/samples/simple/npsimple.cpp b/mozilla/modules/plugin/samples/simple/npsimple.cpp index 7267fd9a450..f70ba722e1d 100644 --- a/mozilla/modules/plugin/samples/simple/npsimple.cpp +++ b/mozilla/modules/plugin/samples/simple/npsimple.cpp @@ -508,7 +508,11 @@ NS_IMPL_RELEASE(SimplePlugin); SimplePlugin* gPlugin = NULL; extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory) +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (aClass.Equals(kIPluginIID)) { if (gPlugin) { @@ -528,7 +532,7 @@ NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory } extern "C" NS_EXPORT PRBool -NSCanUnload(void) +NSCanUnload(nsISupports* serviceMgr) { return gPluginObjectCount == 1 && !gPluginLocked; } diff --git a/mozilla/modules/plugin/test/npsimple.cpp b/mozilla/modules/plugin/test/npsimple.cpp index 7267fd9a450..f70ba722e1d 100644 --- a/mozilla/modules/plugin/test/npsimple.cpp +++ b/mozilla/modules/plugin/test/npsimple.cpp @@ -508,7 +508,11 @@ NS_IMPL_RELEASE(SimplePlugin); SimplePlugin* gPlugin = NULL; extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory) +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (aClass.Equals(kIPluginIID)) { if (gPlugin) { @@ -528,7 +532,7 @@ NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory } extern "C" NS_EXPORT PRBool -NSCanUnload(void) +NSCanUnload(nsISupports* serviceMgr) { return gPluginObjectCount == 1 && !gPluginLocked; } diff --git a/mozilla/network/module/nsNetFactory.cpp b/mozilla/network/module/nsNetFactory.cpp index 90b7bab0b15..bfb60137ab5 100644 --- a/mozilla/network/module/nsNetFactory.cpp +++ b/mozilla/network/module/nsNetFactory.cpp @@ -147,9 +147,19 @@ nsresult nsNetFactory::LockFactory(PRBool aLock) // return the proper factory to the caller #if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_NET nsresult NSGetFactory_NETLIB_DLL(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_NET nsresult +NSGetFactory_NETLIB_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #else -extern "C" NS_NET nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_NET nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #endif { if (nsnull == aFactory) { diff --git a/mozilla/parser/htmlparser/src/nsParserFactory.cpp b/mozilla/parser/htmlparser/src/nsParserFactory.cpp index 09ed01b0090..aa6ee799223 100644 --- a/mozilla/parser/htmlparser/src/nsParserFactory.cpp +++ b/mozilla/parser/htmlparser/src/nsParserFactory.cpp @@ -167,9 +167,19 @@ nsresult nsParserFactory::LockFactory(PRBool aLock) // return the proper factory to the caller #if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_EXPORT nsresult NSGetFactory_PARSER_DLL(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_EXPORT nsresult +NSGetFactory_PARSER_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #else -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_EXPORT nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #endif { if (nsnull == aFactory) { diff --git a/mozilla/rdf/base/public/nsIRDFNode.h b/mozilla/rdf/base/public/nsIRDFNode.h index a4e9f97841a..4c4b440e470 100644 --- a/mozilla/rdf/base/public/nsIRDFNode.h +++ b/mozilla/rdf/base/public/nsIRDFNode.h @@ -57,6 +57,12 @@ class NS_RDF nsIRDFNode : public nsISupports { public: static const nsIID& IID() { static nsIID iid = NS_IRDFNODE_IID; return iid; } + /** + * Called by nsIRDFService after constructing a resource object to + * initialize it's URI. + */ + NS_IMETHOD Init(const char* uri) = 0; + /** * Determine if two nodes are identical */ diff --git a/mozilla/rdf/base/public/nsIRDFResourceFactory.h b/mozilla/rdf/base/public/nsIRDFResourceFactory.h index 9d02639d038..2cbc4d53cf8 100644 --- a/mozilla/rdf/base/public/nsIRDFResourceFactory.h +++ b/mozilla/rdf/base/public/nsIRDFResourceFactory.h @@ -27,6 +27,8 @@ #ifndef nsIRDFResourceFactory_h__ #define nsIRDFResourceFactory_h__ +#if 0 // obsolete + #include "nsISupports.h" class nsIRDFResource; @@ -69,6 +71,7 @@ public: NS_IMETHOD CreateResource(const char* aURI, nsIRDFResource** aResult) = 0; }; +#endif #endif // nsIRDFResourceFactory_h__ diff --git a/mozilla/rdf/base/public/nsIRDFService.h b/mozilla/rdf/base/public/nsIRDFService.h index 4fc6ec2814d..bfe2c384507 100644 --- a/mozilla/rdf/base/public/nsIRDFService.h +++ b/mozilla/rdf/base/public/nsIRDFService.h @@ -41,9 +41,6 @@ class nsIRDFDataBase; class nsIRDFDataSource; class nsIRDFLiteral; class nsIRDFResource; -class nsIRDFResourceFactory; - -typedef nsresult (*NSDataSourceConstructorCallback)(nsIRDFDataSource** aResult); // {BFD05261-834C-11d2-8EAC-00805F29F370} #define NS_IRDFSERVICE_IID \ @@ -76,6 +73,11 @@ public: */ NS_IMETHOD GetLiteral(const PRUnichar* value, nsIRDFLiteral** literal) = 0; + /** + * Registers a resource with the RDF system, making it unique w.r.t. GetResource. + */ + NS_IMETHOD RegisterResource(nsIRDFResource* aResource, PRBool replace = PR_FALSE) = 0; + /** * Called to notify the resource manager that a resource is no * longer in use. This method should only be called from the @@ -89,20 +91,7 @@ public: * reason, you must always un-cache the resource before * releasing the storage for the const char* URI. */ - NS_IMETHOD UnCacheResource(nsIRDFResource* resource) = 0; - - /** - * Registers the specified resource factory as the producer for resources that - * have the specified URI prefix. - */ - NS_IMETHOD RegisterResourceFactory(const char* aURIPrefix, nsIRDFResourceFactory* aFactory) = 0; - - /** - * Unregsters the specified resource factory from producing resources that have - * the specified URI prefix. - */ - NS_IMETHOD UnRegisterResourceFactory(const char* aURIPrefix) = 0; - + NS_IMETHOD UnregisterResource(nsIRDFResource* aResource) = 0; // Data source management routines @@ -117,7 +106,8 @@ public: * and unregisters when the last reference to the data source is * released. */ - NS_IMETHOD RegisterDataSource(nsIRDFDataSource* dataSource) = 0; + NS_IMETHOD RegisterDataSource(nsIRDFDataSource* dataSource, + PRBool replace = PR_FALSE) = 0; /** * Unregister a named data source. The RDF service will call @@ -126,18 +116,6 @@ public: */ NS_IMETHOD UnregisterDataSource(nsIRDFDataSource* dataSource) = 0; - /** - * Register a constructor function that will create a named data source. - * The RDF service will call this function to attempt to create a - * named data source. - */ - NS_IMETHOD RegisterDataSourceConstructor(const char* aURI, NSDataSourceConstructorCallback aFn) = 0; - - /** - * Unregister the constructor function for a named data source. - */ - NS_IMETHOD UnregisterDataSourceConstructor(const char* aURI) = 0; - /** * Get the named data source corresponding to the URI. If a data * source has been registered via RegisterDataSource(), that diff --git a/mozilla/rdf/base/public/rdf.h b/mozilla/rdf/base/public/rdf.h index a0960d7ffec..5d1ba9c3d4d 100644 --- a/mozilla/rdf/base/public/rdf.h +++ b/mozilla/rdf/base/public/rdf.h @@ -66,6 +66,13 @@ static const char* kTag##prefix##_##name = #name #define NS_ERROR_RDF_CURSOR_EMPTY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF, 1) #define NS_ERROR_RDF_NO_VALUE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF, 2) +/* ProgID prefixes for RDF DLL registration. */ +#define NS_RDF_PROGID "component:||netscape|rdf" +#define NS_RDF_DATASOURCE_PROGID NS_RDF_PROGID "|datasource" +#define NS_RDF_DATASOURCE_PROGID_PREFIX NS_RDF_DATASOURCE_PROGID "?name=" +#define NS_RDF_RESOURCE_FACTORY_PROGID "component:||netscape|rdf|resource-factory" +#define NS_RDF_RESOURCE_FACTORY_PROGID_PREFIX NS_RDF_RESOURCE_FACTORY_PROGID "?name=" + /*@}*/ #ifdef _IMPL_NS_RDF diff --git a/mozilla/rdf/base/src/nsDefaultResourceFactory.cpp b/mozilla/rdf/base/src/nsDefaultResourceFactory.cpp index c3b7c701464..2a40a289e4b 100644 --- a/mozilla/rdf/base/src/nsDefaultResourceFactory.cpp +++ b/mozilla/rdf/base/src/nsDefaultResourceFactory.cpp @@ -24,9 +24,12 @@ */ -#include "nsIRDFResourceFactory.h" #include "nsRDFResource.h" +#if 0 + +#include "nsIRDFResourceFactory.h" + //////////////////////////////////////////////////////////////////////// class DefaultResourceFactoryImpl : public nsIRDFResourceFactory @@ -88,3 +91,21 @@ NS_NewRDFDefaultResourceFactory(nsIRDFResourceFactory** result) *result = factory; return NS_OK; } + +#endif + +nsresult +NS_NewDefaultResource(nsIRDFResource** aResult) +{ + NS_PRECONDITION(aResult != nsnull, "null ptr"); + if (! aResult) + return NS_ERROR_NULL_POINTER; + + nsRDFResource* resource = new nsRDFResource(); + if (! resource) + return NS_ERROR_OUT_OF_MEMORY; + + NS_ADDREF(resource); + *aResult = resource; + return NS_OK; +} diff --git a/mozilla/rdf/base/src/nsRDFService.cpp b/mozilla/rdf/base/src/nsRDFService.cpp index 99ebc02a972..268ed6fe8e9 100644 --- a/mozilla/rdf/base/src/nsRDFService.cpp +++ b/mozilla/rdf/base/src/nsRDFService.cpp @@ -23,17 +23,7 @@ TO DO ----- - 1) Figure out a better way to do "pluggable resources." Currently, - we have two _major_ hacks: - - RegisterBuiltInNamedDataSources() - RegisterBuiltInResourceFactories() - - These introduce dependencies on the datasource directory. You'd - like to have this stuff discovered dynamically at startup or - something. Maybe from the registry. - - 2) Implement the CreateDataBase() methods. + 1) Implement the CreateDataBase() methods. */ @@ -43,8 +33,10 @@ #include "nsIRDFService.h" #include "nsIRDFResourceFactory.h" #include "nsString.h" +#include "nsRepository.h" #include "plhash.h" #include "plstr.h" +#include "prprf.h" #include "prlog.h" //////////////////////////////////////////////////////////////////////// @@ -221,6 +213,7 @@ public: NS_DECL_ISUPPORTS // nsIRDFNode + NS_IMETHOD Init(const char* uri); NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result) const; // nsIRDFLiteral @@ -262,6 +255,15 @@ LiteralImpl::QueryInterface(REFNSIID iid, void** result) return NS_NOINTERFACE; } +NS_IMETHODIMP +LiteralImpl::Init(const char* uri) +{ + // Literals should always be constructed by calling nsIRDFService::GetLiteral, + // so this method should never get called. + NS_NOTREACHED("RDF LiteralImpl::Init"); + return NS_ERROR_FAILURE; +} + NS_IMETHODIMP LiteralImpl::EqualsNode(nsIRDFNode* node, PRBool* result) const { @@ -318,7 +320,6 @@ class ServiceImpl : public nsIRDFService protected: PrefixMap mResourceFactories; PLHashTable* mNamedDataSources; - PLHashTable* mDataSourceConstructors; PLHashTable* mResources; ServiceImpl(void); @@ -326,9 +327,6 @@ protected: static nsIRDFService* gRDFService; // The one-and-only RDF service - static void RegisterBuiltInResourceFactories(); - static void RegisterBuiltInNamedDataSources(); - public: static nsresult GetRDFService(nsIRDFService** result); @@ -340,15 +338,10 @@ public: NS_IMETHOD GetResource(const char* uri, nsIRDFResource** resource); NS_IMETHOD GetUnicodeResource(const PRUnichar* uri, nsIRDFResource** resource); NS_IMETHOD GetLiteral(const PRUnichar* value, nsIRDFLiteral** literal); - NS_IMETHOD UnCacheResource(nsIRDFResource* resource); - - NS_IMETHOD RegisterResourceFactory(const char* aURIPrefix, nsIRDFResourceFactory* aFactory); - NS_IMETHOD UnRegisterResourceFactory(const char* aURIPrefix); - - NS_IMETHOD RegisterDataSource(nsIRDFDataSource* dataSource); + NS_IMETHOD RegisterResource(nsIRDFResource* aResource, PRBool replace = PR_FALSE); + NS_IMETHOD UnregisterResource(nsIRDFResource* aResource); + NS_IMETHOD RegisterDataSource(nsIRDFDataSource* dataSource, PRBool replace = PR_FALSE); NS_IMETHOD UnregisterDataSource(nsIRDFDataSource* dataSource); - NS_IMETHOD RegisterDataSourceConstructor(const char* uri, NSDataSourceConstructorCallback fn); - NS_IMETHOD UnregisterDataSourceConstructor(const char* uri); NS_IMETHOD GetDataSource(const char* uri, nsIRDFDataSource** dataSource); NS_IMETHOD CreateDatabase(const char** uris, nsIRDFDataBase** dataBase); NS_IMETHOD CreateBrowserDatabase(nsIRDFDataBase** dataBase); @@ -373,21 +366,11 @@ ServiceImpl::ServiceImpl(void) PL_CompareStrings, PL_CompareValues, nsnull, nsnull); - - mDataSourceConstructors = PL_NewHashTable(23, - PL_HashString, - PL_CompareStrings, - PL_CompareValues, - nsnull, nsnull); } ServiceImpl::~ServiceImpl(void) { - if (mDataSourceConstructors) { - PL_HashTableDestroy(mDataSourceConstructors); - mDataSourceConstructors = nsnull; - } if (mNamedDataSources) { PL_HashTableDestroy(mNamedDataSources); mNamedDataSources = nsnull; @@ -403,13 +386,12 @@ ServiceImpl::~ServiceImpl(void) nsresult ServiceImpl::GetRDFService(nsIRDFService** mgr) { + nsresult rv; if (! gRDFService) { - gRDFService = new ServiceImpl(); - if (! gRDFService) + ServiceImpl* serv = new ServiceImpl(); + if (! serv) return NS_ERROR_OUT_OF_MEMORY; - - RegisterBuiltInResourceFactories(); - RegisterBuiltInNamedDataSources(); + gRDFService = serv; } NS_ADDREF(gRDFService); @@ -440,41 +422,52 @@ ServiceImpl::GetResource(const char* uri, nsIRDFResource** resource) { nsIRDFResource* result = NS_STATIC_CAST(nsIRDFResource*, PL_HashTableLookup(mResources, uri)); - - if (! result) { - nsIRDFResourceFactory* factory = - NS_STATIC_CAST(nsIRDFResourceFactory*, - NS_CONST_CAST(void*, mResourceFactories.Find(uri))); - - PR_ASSERT(factory != nsnull); - if (! factory) - return NS_ERROR_FAILURE; // XXX - - nsresult rv; - - if (NS_FAILED(rv = factory->CreateResource(uri, &result))) - return rv; - - const char* uri; - result->GetValue(&uri); - - // This is a little trick to make storage more efficient. For - // the "key" in the table, we'll use the string value that's - // stored as a member variable of the nsIRDFResource object. - PL_HashTableAdd(mResources, uri, result); - - // *We* don't AddRef() the resource: that way, the resource - // can be garbage collected when the last refcount goes - // away. The single addref that the CreateResource() call made - // will be owned by the callee. - } - else { + + if (result) { // Addref for the callee. NS_ADDREF(result); + *resource = result; + return NS_OK; + } + + nsresult rv; + nsAutoString uriStr = uri; + PRInt32 pos = uriStr.Find(':'); + if (pos < 0) { + // no colon, so try the default resource factory + rv = nsRepository::CreateInstance(NS_RDF_RESOURCE_FACTORY_PROGID, + nsnull, nsIRDFResource::IID(), + (void**)&result); + if (NS_FAILED(rv)) return rv; } + else { + nsAutoString prefix; + uriStr.Left(prefix, pos); // truncate + char* prefixStr = prefix.ToNewCString(); + if (prefixStr == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + char* progID = PR_smprintf(NS_RDF_RESOURCE_FACTORY_PROGID_PREFIX "%s", + prefixStr); + delete[] prefixStr; + if (progID == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + rv = nsRepository::CreateInstance(progID, nsnull, + nsIRDFResource::IID(), + (void**)&result); + PR_smprintf_free(progID); + if (NS_FAILED(rv)) { + // if we failed, try the default resource factory + rv = nsRepository::CreateInstance(NS_RDF_RESOURCE_FACTORY_PROGID, + nsnull, nsIRDFResource::IID(), + (void**)&result); + if (NS_FAILED(rv)) return rv; + } + } + rv = result->Init(uri); + if (NS_FAILED(rv)) return rv; *resource = result; - return NS_OK; + return RegisterResource(result); } @@ -502,7 +495,41 @@ ServiceImpl::GetLiteral(const PRUnichar* uri, nsIRDFLiteral** literal) } NS_IMETHODIMP -ServiceImpl::UnCacheResource(nsIRDFResource* resource) +ServiceImpl::RegisterResource(nsIRDFResource* aResource, PRBool replace) +{ + NS_PRECONDITION(aResource != nsnull, "null ptr"); + if (! aResource) + return NS_ERROR_NULL_POINTER; + + nsresult rv; + + const char* uri; + rv = aResource->GetValue(&uri); + if (NS_FAILED(rv)) return rv; + + nsIRDFResource* prevRes = + NS_STATIC_CAST(nsIRDFResource*, PL_HashTableLookup(mResources, uri)); + if (prevRes != nsnull) { + if (replace) + NS_RELEASE(prevRes); + else + return NS_ERROR_FAILURE; // already registered + } + + // This is a little trick to make storage more efficient. For + // the "key" in the table, we'll use the string value that's + // stored as a member variable of the nsIRDFResource object. + PL_HashTableAdd(mResources, uri, aResource); + + // *We* don't AddRef() the resource: that way, the resource + // can be garbage collected when the last refcount goes + // away. The single addref that the CreateResource() call made + // will be owned by the callee. + return NS_OK; +} + +NS_IMETHODIMP +ServiceImpl::UnregisterResource(nsIRDFResource* resource) { nsresult rv; @@ -515,31 +542,7 @@ ServiceImpl::UnCacheResource(nsIRDFResource* resource) } NS_IMETHODIMP -ServiceImpl::RegisterResourceFactory(const char* aURIPrefix, nsIRDFResourceFactory* aFactory) -{ - if (! mResourceFactories.Add(aURIPrefix, aFactory)) - return NS_ERROR_ILLEGAL_VALUE; - - NS_ADDREF(aFactory); // XXX should we addref? - return NS_OK; -} - -NS_IMETHODIMP -ServiceImpl::UnRegisterResourceFactory(const char* aURIPrefix) -{ - nsIRDFResourceFactory* factory = - NS_STATIC_CAST(nsIRDFResourceFactory*, - NS_CONST_CAST(void*, mResourceFactories.Remove(aURIPrefix))); - - if (! factory) - return NS_ERROR_ILLEGAL_VALUE; - - NS_RELEASE(factory); // XXX should we addref? - return NS_OK; -} - -NS_IMETHODIMP -ServiceImpl::RegisterDataSource(nsIRDFDataSource* aDataSource) +ServiceImpl::RegisterDataSource(nsIRDFDataSource* aDataSource, PRBool replace) { NS_PRECONDITION(aDataSource != nsnull, "null ptr"); if (! aDataSource) @@ -551,7 +554,15 @@ ServiceImpl::RegisterDataSource(nsIRDFDataSource* aDataSource) if (NS_FAILED(rv = aDataSource->GetURI(&uri))) return rv; - // XXX check for dups, etc. + nsIRDFDataSource* ds = + NS_STATIC_CAST(nsIRDFDataSource*, PL_HashTableLookup(mNamedDataSources, uri)); + + if (ds) { + if (replace) + NS_RELEASE(ds); + else + return NS_ERROR_FAILURE; // already registered + } PL_HashTableAdd(mNamedDataSources, uri, aDataSource); return NS_OK; @@ -580,21 +591,6 @@ ServiceImpl::UnregisterDataSource(nsIRDFDataSource* aDataSource) return NS_OK; } -NS_IMETHODIMP -ServiceImpl::RegisterDataSourceConstructor(const char* uri, NSDataSourceConstructorCallback fn) -{ - // XXX check for dups, etc. - PL_HashTableAdd(mDataSourceConstructors, uri, fn); - return NS_OK; -} - -NS_IMETHODIMP -ServiceImpl::UnregisterDataSourceConstructor(const char* uri) -{ - PL_HashTableRemove(mDataSourceConstructors, uri); - return NS_OK; -} - NS_IMETHODIMP ServiceImpl::GetDataSource(const char* uri, nsIRDFDataSource** aDataSource) { @@ -606,41 +602,27 @@ ServiceImpl::GetDataSource(const char* uri, nsIRDFDataSource** aDataSource) *aDataSource = ds; return NS_OK; } - - // Otherwise, see if we have a lazy constructor - NSDataSourceConstructorCallback constructor = - (NSDataSourceConstructorCallback) - PL_HashTableLookup(mDataSourceConstructors, uri); - - if (constructor) { - // Yep, so try to construct it on the fly... - nsresult rv; - - if (NS_FAILED(rv = constructor(&ds))) { -#ifdef DEBUG - printf("error constructing built-in datasource %s\n", uri); -#endif - return rv; - } - - // If it wants to register itself, it should do so in the Init() method. - if (NS_FAILED(rv = ds->Init(uri))) { -#ifdef DEBUG - printf("error initializing named datasource %s\n", uri); -#endif - NS_RELEASE(ds); - return rv; - } - - // constructor did an implicit addref - *aDataSource = ds; - return NS_OK; - } - - // XXX at this point, we might want to try to construct a - // stream URI and load it that way... - return NS_ERROR_ILLEGAL_VALUE; - + nsresult rv; + nsAutoString dataSourceName = uri; + PRInt32 pos = dataSourceName.Find(':'); + if (pos < 0) return NS_ERROR_FAILURE; // bad URI + dataSourceName.Right(dataSourceName, pos + 1); + char* name = dataSourceName.ToNewCString(); + if (name == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + char* progID = PR_smprintf(NS_RDF_DATASOURCE_PROGID_PREFIX "%s", + name); + delete[] name; + if (progID == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + rv = nsRepository::CreateInstance(progID, nsnull, + nsIRDFDataSource::IID(), + (void**)aDataSource); + PR_smprintf_free(progID); + if (NS_FAILED(rv)) return rv; + rv = (*aDataSource)->Init(uri); + if (NS_FAILED(rv)) return rv; + return RegisterDataSource(*aDataSource); } NS_IMETHODIMP @@ -658,97 +640,6 @@ ServiceImpl::CreateBrowserDatabase(nsIRDFDataBase** dataBase) return NS_ERROR_NOT_IMPLEMENTED; } - -//////////////////////////////////////////////////////////////////////// -// -// This is Big Hack #1. Depedencies on all builtin resource -// factories are *here*, in the ResourceFactoryTable. -// - -struct ResourceFactoryTable { - const char* mPrefix; - nsresult (*mFactoryConstructor)(nsIRDFResourceFactory** result); -}; - -void -ServiceImpl::RegisterBuiltInResourceFactories(void) -{ - extern nsresult NS_NewRDFDefaultResourceFactory(nsIRDFResourceFactory** result); -// extern nsresult NS_NewRDFMailResourceFactory(nsIRDFResourceFactory** result); -// extern nsresult NS_NewRDFMailAccountResourceFactory(nsIRDFResourceFactory** result); - extern nsresult NS_NewRDFFileResourceFactory(nsIRDFResourceFactory** result); - - static ResourceFactoryTable gTable[] = { - "", NS_NewRDFDefaultResourceFactory, -// "mailaccount:", NS_NewRDFMailAccountResourceFactory, -// "mailbox:", NS_NewRDFMailResourceFactory, - nsnull, nsnull - }; - - nsresult rv; - for (ResourceFactoryTable* entry = gTable; entry->mPrefix != nsnull; ++entry) { - nsIRDFResourceFactory* factory; - - if (NS_FAILED(rv = (entry->mFactoryConstructor)(&factory))) - continue; - - rv = gRDFService->RegisterResourceFactory(entry->mPrefix, factory); - PR_ASSERT(NS_SUCCEEDED(rv)); - - NS_RELEASE(factory); - } -} - -//////////////////////////////////////////////////////////////////////// -// -// This is Big Hack #2. Dependencies on all builtin datasources are -// *here*, in the DataSourceTable. -// -// FWIW, I don't particularly like this interface *anyway*, because -// it requires each built-in data source to be constructed "up -// front". Not only does it cause the service manager to be -// re-entered (which may be a problem), but it's wasteful: I think -// these data sources should be created on demand, and released when -// you're done with them. -// - -struct DataSourceTable { - const char* mURI; - nsresult (*mDataSourceConstructor)(nsIRDFDataSource** result); -}; - -void -ServiceImpl::RegisterBuiltInNamedDataSources(void) -{ - extern nsresult NS_NewRDFBookmarkDataSource(nsIRDFDataSource** result); - extern nsresult NS_NewRDFHistoryDataSource(nsIRDFDataSource** result); - extern nsresult NS_NewRDFFileSystemDataSource(nsIRDFDataSource** result); -// extern nsresult NS_NewRDFMailDataSource(nsIRDFDataSource** result); - - static DataSourceTable gTable[] = { - "rdf:bookmarks", NS_NewRDFBookmarkDataSource, - "rdf:files", NS_NewRDFFileSystemDataSource, -// "rdf:mail", NS_NewRDFMailDataSource, -#if 0 - "rdf:history", NS_NewRDFHistoryDataSource, -#endif - nsnull, nsnull - }; - - nsresult rv; - for (DataSourceTable* entry = gTable; entry->mURI != nsnull; ++entry) { - if (NS_FAILED(rv = gRDFService->RegisterDataSourceConstructor(entry->mURI, entry->mDataSourceConstructor))) { -#ifdef DEBUG - printf("error registering built-in datasource constructor for %s\n", entry->mURI); -#endif - continue; - } - } -} - - -//////////////////////////////////////////////////////////////////////// - nsresult NS_NewRDFService(nsIRDFService** mgr) { diff --git a/mozilla/rdf/build/nsRDFCID.h b/mozilla/rdf/build/nsRDFCID.h index 884a027c0e4..568aa461a2c 100644 --- a/mozilla/rdf/build/nsRDFCID.h +++ b/mozilla/rdf/build/nsRDFCID.h @@ -27,7 +27,7 @@ #define nsRDFCID_h__ // {0F78DA56-8321-11d2-8EAC-00805F29F370} -#define NS_RDFNODE_CID \ +#define NS_RDFDEFAULTRESOURCE_CID \ { 0xf78da56, 0x8321, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } } // {BFD05264-834C-11d2-8EAC-00805F29F370} diff --git a/mozilla/rdf/build/nsRDFFactory.cpp b/mozilla/rdf/build/nsRDFFactory.cpp index b6edbce6403..9d601b929da 100644 --- a/mozilla/rdf/build/nsRDFFactory.cpp +++ b/mozilla/rdf/build/nsRDFFactory.cpp @@ -35,6 +35,7 @@ #include "nsRDFBuiltInDataSources.h" #include "nsRDFCID.h" #include "nsRepository.h" +#include "rdf.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); @@ -51,11 +52,12 @@ static NS_DEFINE_CID(kRDFXULBuilderCID, NS_RDFXULBUILDER_CID); static NS_DEFINE_CID(kXULContentSinkCID, NS_XULCONTENTSINK_CID); static NS_DEFINE_CID(kXULDataSourceCID, NS_XULDATASOURCE_CID); static NS_DEFINE_CID(kXULDocumentCID, NS_XULDOCUMENT_CID); +static NS_DEFINE_CID(kRDFDefaultResourceCID, NS_RDFDEFAULTRESOURCE_CID); class RDFFactoryImpl : public nsIFactory { public: - RDFFactoryImpl(const nsCID &aClass); + RDFFactoryImpl(const nsCID &aClass, const char* className, const char* progID); // nsISupports methods NS_DECL_ISUPPORTS @@ -70,16 +72,20 @@ public: protected: virtual ~RDFFactoryImpl(); -private: - nsCID mClassID; +protected: + nsCID mClassID; + const char* mClassName; + const char* mProgID; }; //////////////////////////////////////////////////////////////////////// -RDFFactoryImpl::RDFFactoryImpl(const nsCID &aClass) +RDFFactoryImpl::RDFFactoryImpl(const nsCID &aClass, + const char* className, + const char* progID) + : mClassID(aClass), mClassName(className), mProgID(progID) { NS_INIT_REFCNT(); - mClassID = aClass; } RDFFactoryImpl::~RDFFactoryImpl() @@ -88,8 +94,7 @@ RDFFactoryImpl::~RDFFactoryImpl() } NS_IMETHODIMP -RDFFactoryImpl::QueryInterface(const nsIID &aIID, - void **aResult) +RDFFactoryImpl::QueryInterface(const nsIID &aIID, void **aResult) { if (! aResult) return NS_ERROR_NULL_POINTER; @@ -112,11 +117,13 @@ RDFFactoryImpl::QueryInterface(const nsIID &aIID, NS_IMPL_ADDREF(RDFFactoryImpl); NS_IMPL_RELEASE(RDFFactoryImpl); +extern nsresult +NS_NewDefaultResource(nsIRDFResource** aResult); NS_IMETHODIMP RDFFactoryImpl::CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult) + const nsIID &aIID, + void **aResult) { if (! aResult) return NS_ERROR_NULL_POINTER; @@ -177,6 +184,10 @@ RDFFactoryImpl::CreateInstance(nsISupports *aOuter, else if (mClassID.Equals(kXULContentSinkCID)) { if (NS_FAILED(rv = NS_NewXULContentSink((nsIXULContentSink**) &inst))) return rv; + } + else if (mClassID.Equals(kRDFDefaultResourceCID)) { + if (NS_FAILED(rv = NS_NewDefaultResource((nsIRDFResource**) &inst))) + return rv; } else { return NS_ERROR_NO_INTERFACE; @@ -207,12 +218,16 @@ nsresult RDFFactoryImpl::LockFactory(PRBool aLock) // return the proper factory to the caller extern "C" PR_IMPLEMENT(nsresult) -NSGetFactory(const nsCID &aClass, nsISupports* aServiceManager, nsIFactory **aFactory) +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (! aFactory) return NS_ERROR_NULL_POINTER; - RDFFactoryImpl* factory = new RDFFactoryImpl(aClass); + RDFFactoryImpl* factory = new RDFFactoryImpl(aClass, aClassName, aProgID); if (factory == nsnull) return NS_ERROR_OUT_OF_MEMORY; @@ -225,39 +240,94 @@ NSGetFactory(const nsCID &aClass, nsISupports* aServiceManager, nsIFactory **aFa extern "C" PR_IMPLEMENT(nsresult) -NSRegisterSelf(const char* aPath) +NSRegisterSelf(nsISupports* serviceMgr, const char* aPath) { - nsRepository::RegisterFactory(kRDFBookmarkDataSourceCID, aPath, PR_TRUE, PR_TRUE); - nsRepository::RegisterFactory(kRDFCompositeDataSourceCID, aPath, PR_TRUE, PR_TRUE); - nsRepository::RegisterFactory(kRDFContentSinkCID, aPath, PR_TRUE, PR_TRUE); - nsRepository::RegisterFactory(kRDFHTMLBuilderCID, aPath, PR_TRUE, PR_TRUE); - nsRepository::RegisterFactory(kRDFInMemoryDataSourceCID, aPath, PR_TRUE, PR_TRUE); - nsRepository::RegisterFactory(kRDFServiceCID, aPath, PR_TRUE, PR_TRUE); - nsRepository::RegisterFactory(kRDFTreeBuilderCID, aPath, PR_TRUE, PR_TRUE); - nsRepository::RegisterFactory(kRDFXMLDataSourceCID, aPath, PR_TRUE, PR_TRUE); - nsRepository::RegisterFactory(kRDFXULBuilderCID, aPath, PR_TRUE, PR_TRUE); - nsRepository::RegisterFactory(kXULContentSinkCID, aPath, PR_TRUE, PR_TRUE); - nsRepository::RegisterFactory(kXULDataSourceCID, aPath, PR_TRUE, PR_TRUE); - nsRepository::RegisterFactory(kXULDocumentCID, aPath, PR_TRUE, PR_TRUE); + nsresult rv; + // XXX return error codes! + + // register our build-in datasources: + rv = nsRepository::RegisterComponent(kRDFBookmarkDataSourceCID, + "Bookmarks", + NS_RDF_DATASOURCE_PROGID_PREFIX "bookmarks", + aPath, PR_TRUE, PR_TRUE); + rv = nsRepository::RegisterComponent(kRDFCompositeDataSourceCID, + "RDF Composite Data Source", + NS_RDF_DATASOURCE_PROGID_PREFIX "composite-datasource", + aPath, PR_TRUE, PR_TRUE); + rv = nsRepository::RegisterComponent(kRDFInMemoryDataSourceCID, + "RDF In-Memory Data Source", + NS_RDF_DATASOURCE_PROGID_PREFIX "in-memory-datasource", + aPath, PR_TRUE, PR_TRUE); + rv = nsRepository::RegisterComponent(kRDFXMLDataSourceCID, + "RDF XML Data Source", + NS_RDF_DATASOURCE_PROGID_PREFIX "xml-datasource", + aPath, PR_TRUE, PR_TRUE); + rv = nsRepository::RegisterComponent(kXULDataSourceCID, + "XUL Data Source", + NS_RDF_DATASOURCE_PROGID_PREFIX "xul-datasource", + aPath, PR_TRUE, PR_TRUE); + + // register our built-in resource factories: + rv = nsRepository::RegisterComponent(kRDFDefaultResourceCID, + "RDF Default Resource Factory", + NS_RDF_RESOURCE_FACTORY_PROGID, // default resource factory has no name= part + aPath, PR_TRUE, PR_TRUE); + + // register all the other rdf components: + rv = nsRepository::RegisterComponent(kRDFContentSinkCID, + "RDF Content Sink", + NS_RDF_PROGID "|content-sink", + aPath, PR_TRUE, PR_TRUE); + rv = nsRepository::RegisterComponent(kRDFHTMLBuilderCID, + "RDF HTML Builder", + NS_RDF_PROGID "|html-builder", + aPath, PR_TRUE, PR_TRUE); + rv = nsRepository::RegisterComponent(kRDFServiceCID, + "RDF Service", + NS_RDF_PROGID "|rdf-service", + aPath, PR_TRUE, PR_TRUE); + rv = nsRepository::RegisterComponent(kRDFTreeBuilderCID, + "RDF Tree Builder", + NS_RDF_PROGID "|tree-builder", + aPath, PR_TRUE, PR_TRUE); + rv = nsRepository::RegisterComponent(kRDFXULBuilderCID, + "RDF XUL Builder", + NS_RDF_PROGID "|xul-builder", + aPath, PR_TRUE, PR_TRUE); + rv = nsRepository::RegisterComponent(kXULContentSinkCID, + "XUL Content Sink", + NS_RDF_PROGID "|xul-content-sink", + aPath, PR_TRUE, PR_TRUE); + rv = nsRepository::RegisterComponent(kXULDocumentCID, + "XUL Document", + NS_RDF_PROGID "|xul-document", + aPath, PR_TRUE, PR_TRUE); return NS_OK; } extern "C" PR_IMPLEMENT(nsresult) -NSUnregisterSelf(const char* aPath) +NSUnregisterSelf(nsISupports* serviceMgr, const char* aPath) { - nsRepository::UnregisterFactory(kRDFBookmarkDataSourceCID, aPath); - nsRepository::UnregisterFactory(kRDFCompositeDataSourceCID, aPath); - nsRepository::UnregisterFactory(kRDFContentSinkCID, aPath); - nsRepository::UnregisterFactory(kRDFHTMLBuilderCID, aPath); - nsRepository::UnregisterFactory(kRDFInMemoryDataSourceCID, aPath); - nsRepository::UnregisterFactory(kRDFServiceCID, aPath); - nsRepository::UnregisterFactory(kRDFTreeBuilderCID, aPath); - nsRepository::UnregisterFactory(kRDFXMLDataSourceCID, aPath); - nsRepository::UnregisterFactory(kRDFXULBuilderCID, aPath); - nsRepository::UnregisterFactory(kXULContentSinkCID, aPath); - nsRepository::UnregisterFactory(kXULDataSourceCID, aPath); - nsRepository::UnregisterFactory(kXULDocumentCID, aPath); + nsresult rv; + // XXX return error codes! + + rv = nsRepository::UnregisterComponent(kRDFBookmarkDataSourceCID, aPath); + rv = nsRepository::UnregisterComponent(kRDFCompositeDataSourceCID, aPath); + rv = nsRepository::UnregisterComponent(kRDFInMemoryDataSourceCID, aPath); + rv = nsRepository::UnregisterComponent(kRDFXMLDataSourceCID, aPath); + rv = nsRepository::UnregisterComponent(kXULDataSourceCID, aPath); + + rv = nsRepository::UnregisterComponent(kRDFDefaultResourceCID, aPath); + + 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; } diff --git a/mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp b/mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp index 4b49cba6b40..19654c4c534 100644 --- a/mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp +++ b/mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp @@ -711,9 +711,23 @@ HT_WriteOutAsBookmarks1 (RDF rdf, PRFileDesc *fp, RDF_Resource u, RDF_Resource t } #endif +//////////////////////////////////////////////////////////////////////////////// +#include "nsXPComFactory.h" -//////////////////////////////////////////////////////////////////////// +nsresult +NS_NewRDFBookmarkDataSourceFactory(nsIFactory** aResult) +{ + nsresult rv = NS_OK; + nsIFactory* inst = new nsFactory(); + if (NULL == inst) { + rv = NS_ERROR_OUT_OF_MEMORY; + } else { + NS_ADDREF(inst); + } + *aResult = inst; + return rv; +} nsresult NS_NewRDFBookmarkDataSource(nsIRDFDataSource** result) diff --git a/mozilla/rdf/datasource/src/nsFileSystemDataSource.cpp b/mozilla/rdf/datasource/src/nsFileSystemDataSource.cpp index 519c47b7590..37ad35bbb88 100644 --- a/mozilla/rdf/datasource/src/nsFileSystemDataSource.cpp +++ b/mozilla/rdf/datasource/src/nsFileSystemDataSource.cpp @@ -62,7 +62,6 @@ static NS_DEFINE_IID(kIRDFCursorIID, NS_IRDFCURSOR_IID); static NS_DEFINE_IID(kIRDFArcsOutCursorIID, NS_IRDFARCSOUTCURSOR_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID); -static NS_DEFINE_IID(kIRDFResourceFactoryIID, NS_IRDFRESOURCEFACTORY_IID); static NS_DEFINE_IID(kIRDFNodeIID, NS_IRDFNODE_IID); diff --git a/mozilla/rdf/util/public/nsRDFResource.h b/mozilla/rdf/util/public/nsRDFResource.h index 50aef996f90..e9062767082 100644 --- a/mozilla/rdf/util/public/nsRDFResource.h +++ b/mozilla/rdf/util/public/nsRDFResource.h @@ -32,6 +32,7 @@ public: NS_DECL_ISUPPORTS // nsIRDFNode methods: + NS_IMETHOD Init(const char* uri); NS_IMETHOD EqualsNode(nsIRDFNode* node, PRBool* result) const; // nsIRDFResource methods: @@ -40,7 +41,7 @@ public: NS_IMETHOD EqualsString(const char* uri, PRBool* result) const; // nsRDFResource methods: - nsRDFResource(const char* uri); + nsRDFResource(void); virtual ~nsRDFResource(void); protected: diff --git a/mozilla/rdf/util/src/nsRDFResource.cpp b/mozilla/rdf/util/src/nsRDFResource.cpp index 667392f5d13..03b98b53977 100644 --- a/mozilla/rdf/util/src/nsRDFResource.cpp +++ b/mozilla/rdf/util/src/nsRDFResource.cpp @@ -27,8 +27,8 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); //////////////////////////////////////////////////////////////////////////////// -nsRDFResource::nsRDFResource(const char* uri) - : mURI(nsCRT::strdup(uri)) +nsRDFResource::nsRDFResource(void) + : mURI(nsnull) { NS_INIT_REFCNT(); } @@ -44,7 +44,7 @@ nsRDFResource::~nsRDFResource(void) PR_ASSERT(NS_SUCCEEDED(rv)); if (NS_SUCCEEDED(rv)) { - mgr->UnCacheResource(this); + mgr->UnregisterResource(this); nsServiceManager::ReleaseService(kRDFServiceCID, mgr); } @@ -77,6 +77,15 @@ nsRDFResource::QueryInterface(REFNSIID iid, void** result) //////////////////////////////////////////////////////////////////////////////// // nsIRDFNode methods: +NS_IMETHODIMP +nsRDFResource::Init(const char* uri) +{ + mURI = nsCRT::strdup(uri); + if (mURI == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; +} + NS_IMETHODIMP nsRDFResource::EqualsNode(nsIRDFNode* node, PRBool* result) const { diff --git a/mozilla/silentdl/nsSilentDownload.cpp b/mozilla/silentdl/nsSilentDownload.cpp index ea24646380a..7ceb0170a53 100644 --- a/mozilla/silentdl/nsSilentDownload.cpp +++ b/mozilla/silentdl/nsSilentDownload.cpp @@ -1424,13 +1424,13 @@ nsSilentDownloadListener::SetSilentDownloadInfo(nsIDOMSilentDownloadTask* con) //////////////////////////////////////////////////////////////////////////////// extern "C" NS_EXPORT PRBool -NSCanUnload(void) +NSCanUnload(nsISupports* serviceMgr) { return PRBool (gInstanceCnt == 0 && gLockCnt == 0); } extern "C" NS_EXPORT nsresult -NSRegisterSelf(const char *path) +NSRegisterSelf(nsISupports* serviceMgr, const char *path) { printf("*** SilentDownload is being registered\n"); nsRepository::RegisterFactory(kSilentDownloadCID, path, PR_TRUE, PR_TRUE); @@ -1439,7 +1439,7 @@ NSRegisterSelf(const char *path) } extern "C" NS_EXPORT nsresult -NSUnregisterSelf(const char *path) +NSUnregisterSelf(nsISupports* serviceMgr, const char *path) { printf("*** SilentDownload is being unregistered\n"); @@ -1452,7 +1452,11 @@ NSUnregisterSelf(const char *path) extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory) +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (aFactory == NULL) diff --git a/mozilla/silentdl/nsSilentDownloadPrivate.h b/mozilla/silentdl/nsSilentDownloadPrivate.h index 01ea82e875e..e22d7771939 100644 --- a/mozilla/silentdl/nsSilentDownloadPrivate.h +++ b/mozilla/silentdl/nsSilentDownloadPrivate.h @@ -46,16 +46,20 @@ // DLL Entry Points: //////////////////////////////////////////////////////////////////////////////// extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory); +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); extern "C" NS_EXPORT PRBool -NSCanUnload(void); +NSCanUnload(nsISupports* serviceMgr); extern "C" NS_EXPORT nsresult -NSRegisterSelf(const char *path); +NSRegisterSelf(nsISupports* serviceMgr, const char *path); extern "C" NS_EXPORT nsresult -NSUnregisterSelf(const char *path); +NSUnregisterSelf(nsISupports* serviceMgr, const char *path); //////////////////////////////////////////////////////////////////////////////// // nsSilentDownloadListener: diff --git a/mozilla/view/src/nsViewFactory.cpp b/mozilla/view/src/nsViewFactory.cpp index 548efef7ba9..aa571d2c9b9 100644 --- a/mozilla/view/src/nsViewFactory.cpp +++ b/mozilla/view/src/nsViewFactory.cpp @@ -151,9 +151,19 @@ nsresult nsViewFactory::LockFactory(PRBool aLock) // return the proper factory to the caller #if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_VIEW nsresult NSGetFactory_VIEW_DLL(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_VIEW nsresult +NSGetFactory_VIEW_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #else -extern "C" NS_VIEW nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_VIEW nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #endif { if (nsnull == aFactory) { diff --git a/mozilla/webshell/embed/ActiveX/ActiveXPlugin.cpp b/mozilla/webshell/embed/ActiveX/ActiveXPlugin.cpp index 3851ec7a260..a9ece5d6223 100644 --- a/mozilla/webshell/embed/ActiveX/ActiveXPlugin.cpp +++ b/mozilla/webshell/embed/ActiveX/ActiveXPlugin.cpp @@ -23,7 +23,12 @@ static NS_DEFINE_IID(kIPluginIID, NS_IPLUGIN_IID); static CActiveXPlugin *gpFactory = NULL; -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory) +extern "C" NS_EXPORT nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (aClass.Equals(kIPluginIID)) { @@ -48,7 +53,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsISupports* ser return NS_ERROR_FAILURE; } -extern "C" NS_EXPORT PRBool NSCanUnload(void) +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) { return (_Module.GetLockCount() == 0); } diff --git a/mozilla/webshell/src/nsDLLFactory.cpp b/mozilla/webshell/src/nsDLLFactory.cpp index a003caaa221..496d6f3ab5e 100644 --- a/mozilla/webshell/src/nsDLLFactory.cpp +++ b/mozilla/webshell/src/nsDLLFactory.cpp @@ -32,9 +32,19 @@ nsresult NS_NewDocLoaderServiceFactory(nsIFactory** aResult); #if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_WEB nsresult NSGetFactory_WEB_DLL(const nsCID& aClass, nsISupports* servMgr, nsIFactory** aFactory) +extern "C" NS_WEB nsresult +NSGetFactory_WEB_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #else -extern "C" NS_WEB nsresult NSGetFactory(const nsCID& aClass, nsISupports* servMgr, nsIFactory** aFactory) +extern "C" NS_WEB nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #endif { nsresult rv = NS_OK; diff --git a/mozilla/webshell/tests/viewer/nsViewerApp.cpp b/mozilla/webshell/tests/viewer/nsViewerApp.cpp index 0cea01aa97f..5195fc970c3 100644 --- a/mozilla/webshell/tests/viewer/nsViewerApp.cpp +++ b/mozilla/webshell/tests/viewer/nsViewerApp.cpp @@ -178,10 +178,10 @@ nsViewerApp::SetupRegistry() // Register our browser window factory nsIFactory* bwf; NS_NewBrowserWindowFactory(&bwf); - nsRepository::RegisterFactory(kBrowserWindowCID, bwf, PR_FALSE); + nsRepository::RegisterFactory(kBrowserWindowCID, 0, 0, bwf, PR_FALSE); NS_NewXPBaseWindowFactory(&bwf); - nsRepository::RegisterFactory(kXPBaseWindowCID, bwf, PR_FALSE); + nsRepository::RegisterFactory(kXPBaseWindowCID, 0, 0, bwf, PR_FALSE); return NS_OK; } diff --git a/mozilla/widget/src/build/nsGTKWidgetFactory.cpp b/mozilla/widget/src/build/nsGTKWidgetFactory.cpp index 6bb174a6abd..f158dbe05b0 100644 --- a/mozilla/widget/src/build/nsGTKWidgetFactory.cpp +++ b/mozilla/widget/src/build/nsGTKWidgetFactory.cpp @@ -252,7 +252,12 @@ nsresult nsWidgetFactory::LockFactory(PRBool aLock) } // return the proper factory to the caller -extern "C" NS_WIDGET nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory ) +extern "C" NS_WIDGET nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (nsnull == aFactory) { return NS_ERROR_NULL_POINTER; diff --git a/mozilla/widget/src/build/nsMotifWidgetFactory.cpp b/mozilla/widget/src/build/nsMotifWidgetFactory.cpp index ef714c2cca5..37fd361b821 100644 --- a/mozilla/widget/src/build/nsMotifWidgetFactory.cpp +++ b/mozilla/widget/src/build/nsMotifWidgetFactory.cpp @@ -277,7 +277,12 @@ nsresult nsWidgetFactory::LockFactory(PRBool aLock) } // return the proper factory to the caller -extern "C" NS_WIDGET nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_WIDGET nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (nsnull == aFactory) { return NS_ERROR_NULL_POINTER; diff --git a/mozilla/widget/src/build/nsWinWidgetFactory.cpp b/mozilla/widget/src/build/nsWinWidgetFactory.cpp index b70fa019577..760529b99be 100644 --- a/mozilla/widget/src/build/nsWinWidgetFactory.cpp +++ b/mozilla/widget/src/build/nsWinWidgetFactory.cpp @@ -252,19 +252,24 @@ nsresult nsWidgetFactory::LockFactory(PRBool aLock) } // return the proper factory to the caller -extern "C" NS_WIDGET nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_WIDGET nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { - if (nsnull == aFactory) { - return NS_ERROR_NULL_POINTER; - } + if (nsnull == aFactory) { + return NS_ERROR_NULL_POINTER; + } - *aFactory = new nsWidgetFactory(aClass); + *aFactory = new nsWidgetFactory(aClass); - if (nsnull == aFactory) { - return NS_ERROR_OUT_OF_MEMORY; - } + if (nsnull == aFactory) { + return NS_ERROR_OUT_OF_MEMORY; + } - return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); + return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); } diff --git a/mozilla/widget/src/mac/nsWidgetFactory.cpp b/mozilla/widget/src/mac/nsWidgetFactory.cpp index 3cc1282f590..fe34045fdf4 100644 --- a/mozilla/widget/src/mac/nsWidgetFactory.cpp +++ b/mozilla/widget/src/mac/nsWidgetFactory.cpp @@ -279,9 +279,19 @@ nsresult nsWidgetFactory::LockFactory(PRBool aLock) //------------------------------------------------------------------------- // return the proper factory to the caller #if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_WIDGET nsresult NSGetFactory_WIDGET_DLL(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_WIDGET nsresult +NSGetFactory_WIDGET_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #else -extern "C" NS_WIDGET nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_WIDGET nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #endif { if (nsnull == aFactory) { diff --git a/mozilla/widget/src/windows/nsWidgetFactory.cpp b/mozilla/widget/src/windows/nsWidgetFactory.cpp index a1e27f1f450..fa74be28ea7 100644 --- a/mozilla/widget/src/windows/nsWidgetFactory.cpp +++ b/mozilla/widget/src/windows/nsWidgetFactory.cpp @@ -251,19 +251,24 @@ nsresult nsWidgetFactory::LockFactory(PRBool aLock) } // return the proper factory to the caller -extern "C" NS_WIDGET nsresult NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory) +extern "C" NS_WIDGET nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { - if (nsnull == aFactory) { - return NS_ERROR_NULL_POINTER; - } + if (nsnull == aFactory) { + return NS_ERROR_NULL_POINTER; + } - *aFactory = new nsWidgetFactory(aClass); + *aFactory = new nsWidgetFactory(aClass); - if (nsnull == aFactory) { - return NS_ERROR_OUT_OF_MEMORY; - } + if (nsnull == aFactory) { + return NS_ERROR_OUT_OF_MEMORY; + } - return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); + return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); } diff --git a/mozilla/xpcom/components/nsMacRepository.h b/mozilla/xpcom/components/nsMacRepository.h index 7c827ce9173..11fc652e56a 100644 --- a/mozilla/xpcom/components/nsMacRepository.h +++ b/mozilla/xpcom/components/nsMacRepository.h @@ -54,17 +54,63 @@ typedef struct MacLibrary #ifdef IMPL_MAC_REPOSITORY -extern "C" nsresult NSGetFactory_WIDGET_DLL(const nsCID &, nsISupports* , nsIFactory ** ); -extern "C" nsresult NSGetFactory_GFXWIN_DLL(const nsCID &, nsISupports*, nsIFactory ** ); -extern "C" nsresult NSGetFactory_VIEW_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_WEB_DLL(const nsCID &, nsISupports*, nsIFactory **); -//extern "C" nsresult NSGetFactory_PLUGIN_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_PREF_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_PARSER_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_DOM_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_LAYOUT_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_NETLIB_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_EDITOR_DLL(const nsCID &, nsISupports*, nsIFactory **); +extern "C" nsresult NSGetFactory_WIDGET_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_GFXWIN_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_VIEW_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_WEB_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +#if 0 +extern "C" nsresult NSGetFactory_PLUGIN_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +#endif +extern "C" nsresult NSGetFactory_PREF_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_PARSER_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_DOM_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_LAYOUT_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_NETLIB_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_EDITOR_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); extern "C" PRBool NSCanUnload_PREF_DLL(void); diff --git a/mozilla/xpcom/components/nsRepository.cpp b/mozilla/xpcom/components/nsRepository.cpp index 377f1d906ba..ebdd85064cb 100644 --- a/mozilla/xpcom/components/nsRepository.cpp +++ b/mozilla/xpcom/components/nsRepository.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -564,12 +564,20 @@ nsresult nsRepository::loadFactory(FactoryEntry *aEntry, nsFactoryProc proc = (nsFactoryProc) aEntry->dll->FindSymbol("NSGetFactory"); if (proc != NULL) { + char* className = NULL; + char* progID = NULL; + (void)CLSIDToProgID(&aEntry->cid, &className, &progID); + nsIServiceManager* serviceMgr = NULL; nsresult res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - if (res == NS_OK) - { - res = proc(aEntry->cid, serviceMgr, aFactory); - } + NS_ASSERTION(res == NS_OK, "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, @@ -639,7 +647,7 @@ nsresult nsRepository::FindFactory(const nsCID &aClass, nsresult nsRepository::ProgIDToCLSID(const char *aProgID, - nsCID *aClass) + nsCID *aClass) { nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; #ifdef USE_REGISTRY @@ -697,6 +705,88 @@ nsresult nsRepository::ProgIDToCLSID(const char *aProgID, return res; } +nsresult nsRepository::CLSIDToProgID(nsCID *aClass, + char* *aClassName, + char* *aProgID) +{ + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; +#ifdef USE_REGISTRY + HREG hreg; + char* classnameString; + char* progidString; + + checkInitialized(); + char* cidStr = aClass->ToString(); + if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) + { + PR_LogPrint("nsRepository: CLSIDToProgID(%s)", cidStr); + } + + 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; +#endif /* USE_REGISTRY */ + + done2: + NR_RegClose(hreg); + done1: + delete[] cidStr; + PR_LOG(logmodule, PR_LOG_WARNING, ("nsRepository: CLSIDToProgID() %s", + res == NS_OK ? "succeeded" : "FAILED")); + return res; +} nsresult nsRepository::checkInitialized(void) { @@ -770,6 +860,17 @@ nsresult nsRepository::CreateInstance(const nsCID &aClass, return NS_ERROR_FACTORY_NOT_REGISTERED; } +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 /* @@ -939,11 +1040,11 @@ nsresult nsRepository::RegisterFactory(const nsCID &aClass, nsresult nsRepository::RegisterComponent(const nsCID &aClass, - const char *aClassName, - const char *aProgID, - const char *aLibrary, - PRBool aReplace, - PRBool aPersist) + const char *aClassName, + const char *aProgID, + const char *aLibrary, + PRBool aReplace, + PRBool aPersist) { checkInitialized(); if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) @@ -1158,14 +1259,18 @@ static PRBool freeLibraryEnum(nsHashKey *aKey, void *aData, void* closure) nsCanUnloadProc proc = (nsCanUnloadProc) entry->dll->FindSymbol("NSCanUnload"); if (proc != NULL) { - PRBool res = proc(); - if (res) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + Unloading \"%s\".", entry->dll->GetFullPath())); - entry->dll->Unload(); - } - } + 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; @@ -1433,25 +1538,29 @@ nsresult nsRepository::SyncComponentsInFile(const char *fullname) dll->FindSymbol("NSCanUnload"); if (proc != NULL) { - PRBool res = proc(/*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); - } + 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 { @@ -1563,10 +1672,9 @@ nsresult nsRepository::SelfRegisterDll(nsDll *dll) // Call the NSRegisterSelfProc to enable dll registration nsIServiceManager* serviceMgr = NULL; res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - if (res == NS_OK) - { - res = regproc(/* serviceMgr, */ dll->GetFullPath()); - } + NS_ASSERTION(res == NS_OK, "no service manager"); + + res = regproc(serviceMgr, dll->GetFullPath()); } dll->Unload(); return (res); @@ -1604,10 +1712,9 @@ nsresult nsRepository::SelfUnregisterDll(nsDll *dll) // Call the NSUnregisterSelfProc to enable dll de-registration nsIServiceManager* serviceMgr = NULL; res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - if (res == NS_OK) - { - res = unregproc(/* serviceMgr, */dll->GetFullPath()); - } + NS_ASSERTION(res == NS_OK, "no service manager"); + + res = unregproc(serviceMgr, dll->GetFullPath()); } dll->Unload(); return (res); diff --git a/mozilla/xpcom/components/nsRepository.h b/mozilla/xpcom/components/nsRepository.h index 73294121b20..6e7df7c6791 100644 --- a/mozilla/xpcom/components/nsRepository.h +++ b/mozilla/xpcom/components/nsRepository.h @@ -44,12 +44,14 @@ class nsIServiceManager; // sudu / stanley // //*********************************************************** -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, - nsISupports* serviceMgr, +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(); -extern "C" NS_EXPORT nsresult NSRegisterSelf(const char *fullpath); -extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char *fullpath); +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 * @@ -90,12 +92,14 @@ typedef NSQuickRegisterClassData* NSQuickRegisterData; * Dynamic library export function types */ -typedef nsresult (*nsFactoryProc)(const nsCID &aCLass, - nsISupports* serviceMgr, +typedef nsresult (*nsFactoryProc)(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, nsIFactory **aFactory); -typedef PRBool (*nsCanUnloadProc)(void); -typedef nsresult (*nsRegisterProc)(const char *path); -typedef nsresult (*nsUnregisterProc)(const char *path); +typedef PRBool (*nsCanUnloadProc)(nsISupports* serviceMgr); +typedef nsresult (*nsRegisterProc)(nsISupports* serviceMgr, const char *path); +typedef nsresult (*nsUnregisterProc)(nsISupports* serviceMgr, const char *path); /* * Support types @@ -148,14 +152,26 @@ public: // Finds a class ID for a specific Program ID static nsresult ProgIDToCLSID(const char *aProgID, - nsCID *aClass); - + 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, @@ -185,11 +201,11 @@ public: // 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); + 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, @@ -201,14 +217,14 @@ public: // Manually unregister a dynamically loaded component static nsresult UnregisterComponent(const nsCID &aClass, - const char *aLibrary); + 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); + const char* pathlist); // Pathlist is a semicolon separated list of pathnames static nsresult AddToDefaultPathList(const char *pathlist); static nsresult SyncComponentsInPathList(const char *pathlist); diff --git a/mozilla/xpcom/public/nsMacRepository.h b/mozilla/xpcom/public/nsMacRepository.h index 7c827ce9173..11fc652e56a 100644 --- a/mozilla/xpcom/public/nsMacRepository.h +++ b/mozilla/xpcom/public/nsMacRepository.h @@ -54,17 +54,63 @@ typedef struct MacLibrary #ifdef IMPL_MAC_REPOSITORY -extern "C" nsresult NSGetFactory_WIDGET_DLL(const nsCID &, nsISupports* , nsIFactory ** ); -extern "C" nsresult NSGetFactory_GFXWIN_DLL(const nsCID &, nsISupports*, nsIFactory ** ); -extern "C" nsresult NSGetFactory_VIEW_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_WEB_DLL(const nsCID &, nsISupports*, nsIFactory **); -//extern "C" nsresult NSGetFactory_PLUGIN_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_PREF_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_PARSER_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_DOM_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_LAYOUT_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_NETLIB_DLL(const nsCID &, nsISupports*, nsIFactory **); -extern "C" nsresult NSGetFactory_EDITOR_DLL(const nsCID &, nsISupports*, nsIFactory **); +extern "C" nsresult NSGetFactory_WIDGET_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_GFXWIN_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_VIEW_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_WEB_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +#if 0 +extern "C" nsresult NSGetFactory_PLUGIN_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +#endif +extern "C" nsresult NSGetFactory_PREF_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_PARSER_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_DOM_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_LAYOUT_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_NETLIB_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); +extern "C" nsresult NSGetFactory_EDITOR_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory); extern "C" PRBool NSCanUnload_PREF_DLL(void); diff --git a/mozilla/xpcom/public/nsRepository.h b/mozilla/xpcom/public/nsRepository.h index 73294121b20..6e7df7c6791 100644 --- a/mozilla/xpcom/public/nsRepository.h +++ b/mozilla/xpcom/public/nsRepository.h @@ -44,12 +44,14 @@ class nsIServiceManager; // sudu / stanley // //*********************************************************** -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, - nsISupports* serviceMgr, +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(); -extern "C" NS_EXPORT nsresult NSRegisterSelf(const char *fullpath); -extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char *fullpath); +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 * @@ -90,12 +92,14 @@ typedef NSQuickRegisterClassData* NSQuickRegisterData; * Dynamic library export function types */ -typedef nsresult (*nsFactoryProc)(const nsCID &aCLass, - nsISupports* serviceMgr, +typedef nsresult (*nsFactoryProc)(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, nsIFactory **aFactory); -typedef PRBool (*nsCanUnloadProc)(void); -typedef nsresult (*nsRegisterProc)(const char *path); -typedef nsresult (*nsUnregisterProc)(const char *path); +typedef PRBool (*nsCanUnloadProc)(nsISupports* serviceMgr); +typedef nsresult (*nsRegisterProc)(nsISupports* serviceMgr, const char *path); +typedef nsresult (*nsUnregisterProc)(nsISupports* serviceMgr, const char *path); /* * Support types @@ -148,14 +152,26 @@ public: // Finds a class ID for a specific Program ID static nsresult ProgIDToCLSID(const char *aProgID, - nsCID *aClass); - + 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, @@ -185,11 +201,11 @@ public: // 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); + 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, @@ -201,14 +217,14 @@ public: // Manually unregister a dynamically loaded component static nsresult UnregisterComponent(const nsCID &aClass, - const char *aLibrary); + 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); + const char* pathlist); // Pathlist is a semicolon separated list of pathnames static nsresult AddToDefaultPathList(const char *pathlist); static nsresult SyncComponentsInPathList(const char *pathlist); diff --git a/mozilla/xpcom/src/nsRepository.cpp b/mozilla/xpcom/src/nsRepository.cpp index 377f1d906ba..ebdd85064cb 100644 --- a/mozilla/xpcom/src/nsRepository.cpp +++ b/mozilla/xpcom/src/nsRepository.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -564,12 +564,20 @@ nsresult nsRepository::loadFactory(FactoryEntry *aEntry, nsFactoryProc proc = (nsFactoryProc) aEntry->dll->FindSymbol("NSGetFactory"); if (proc != NULL) { + char* className = NULL; + char* progID = NULL; + (void)CLSIDToProgID(&aEntry->cid, &className, &progID); + nsIServiceManager* serviceMgr = NULL; nsresult res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - if (res == NS_OK) - { - res = proc(aEntry->cid, serviceMgr, aFactory); - } + NS_ASSERTION(res == NS_OK, "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, @@ -639,7 +647,7 @@ nsresult nsRepository::FindFactory(const nsCID &aClass, nsresult nsRepository::ProgIDToCLSID(const char *aProgID, - nsCID *aClass) + nsCID *aClass) { nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; #ifdef USE_REGISTRY @@ -697,6 +705,88 @@ nsresult nsRepository::ProgIDToCLSID(const char *aProgID, return res; } +nsresult nsRepository::CLSIDToProgID(nsCID *aClass, + char* *aClassName, + char* *aProgID) +{ + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; +#ifdef USE_REGISTRY + HREG hreg; + char* classnameString; + char* progidString; + + checkInitialized(); + char* cidStr = aClass->ToString(); + if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) + { + PR_LogPrint("nsRepository: CLSIDToProgID(%s)", cidStr); + } + + 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; +#endif /* USE_REGISTRY */ + + done2: + NR_RegClose(hreg); + done1: + delete[] cidStr; + PR_LOG(logmodule, PR_LOG_WARNING, ("nsRepository: CLSIDToProgID() %s", + res == NS_OK ? "succeeded" : "FAILED")); + return res; +} nsresult nsRepository::checkInitialized(void) { @@ -770,6 +860,17 @@ nsresult nsRepository::CreateInstance(const nsCID &aClass, return NS_ERROR_FACTORY_NOT_REGISTERED; } +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 /* @@ -939,11 +1040,11 @@ nsresult nsRepository::RegisterFactory(const nsCID &aClass, nsresult nsRepository::RegisterComponent(const nsCID &aClass, - const char *aClassName, - const char *aProgID, - const char *aLibrary, - PRBool aReplace, - PRBool aPersist) + const char *aClassName, + const char *aProgID, + const char *aLibrary, + PRBool aReplace, + PRBool aPersist) { checkInitialized(); if (PR_LOG_TEST(logmodule, PR_LOG_ALWAYS)) @@ -1158,14 +1259,18 @@ static PRBool freeLibraryEnum(nsHashKey *aKey, void *aData, void* closure) nsCanUnloadProc proc = (nsCanUnloadProc) entry->dll->FindSymbol("NSCanUnload"); if (proc != NULL) { - PRBool res = proc(); - if (res) - { - PR_LOG(logmodule, PR_LOG_ALWAYS, - ("nsRepository: + Unloading \"%s\".", entry->dll->GetFullPath())); - entry->dll->Unload(); - } - } + 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; @@ -1433,25 +1538,29 @@ nsresult nsRepository::SyncComponentsInFile(const char *fullname) dll->FindSymbol("NSCanUnload"); if (proc != NULL) { - PRBool res = proc(/*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); - } + 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 { @@ -1563,10 +1672,9 @@ nsresult nsRepository::SelfRegisterDll(nsDll *dll) // Call the NSRegisterSelfProc to enable dll registration nsIServiceManager* serviceMgr = NULL; res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - if (res == NS_OK) - { - res = regproc(/* serviceMgr, */ dll->GetFullPath()); - } + NS_ASSERTION(res == NS_OK, "no service manager"); + + res = regproc(serviceMgr, dll->GetFullPath()); } dll->Unload(); return (res); @@ -1604,10 +1712,9 @@ nsresult nsRepository::SelfUnregisterDll(nsDll *dll) // Call the NSUnregisterSelfProc to enable dll de-registration nsIServiceManager* serviceMgr = NULL; res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); - if (res == NS_OK) - { - res = unregproc(/* serviceMgr, */dll->GetFullPath()); - } + NS_ASSERTION(res == NS_OK, "no service manager"); + + res = unregproc(serviceMgr, dll->GetFullPath()); } dll->Unload(); return (res); diff --git a/mozilla/xpcom/src/nsXPComFactory.cpp b/mozilla/xpcom/src/nsXPComFactory.cpp index 25261a27b80..0fc15cc8224 100644 --- a/mozilla/xpcom/src/nsXPComFactory.cpp +++ b/mozilla/xpcom/src/nsXPComFactory.cpp @@ -29,9 +29,19 @@ nsresult NS_NewEventQueueServiceFactory(nsIFactory** aResult); * Define the global NSGetFactory(...) entry point for the xpcom DLL... */ #if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_EXPORT nsresult NSGetFactory_XPCOM_DLL(const nsCID& aClass, nsISupports* servMgr, nsIFactory** aFactory) +extern "C" NS_EXPORT nsresult +NSGetFactory_XPCOM_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #else -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID& aClass, nsISupports* servMgr, nsIFactory** aFactory) +extern "C" NS_EXPORT nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #endif { if (NULL == aFactory) { diff --git a/mozilla/xpcom/tests/RegFactory.cpp b/mozilla/xpcom/tests/RegFactory.cpp index b93e35961b8..8a31425415e 100644 --- a/mozilla/xpcom/tests/RegFactory.cpp +++ b/mozilla/xpcom/tests/RegFactory.cpp @@ -20,6 +20,7 @@ #include "plstr.h" #include "prlink.h" #include "nsRepository.h" +#include "nsIServiceManager.h" static PRBool gUnreg = PR_FALSE; @@ -54,7 +55,12 @@ nsresult Register(const char *path) nsRegisterProc proc = (nsRegisterProc) PR_FindSymbol(instance, "NSRegisterSelf"); if (proc != NULL) { - res = proc(path); + nsIServiceManager* serviceMgr = NULL; + res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); + if (res == NS_OK) + { + res = proc(serviceMgr, path); + } } PR_UnloadLibrary(instance); } else { @@ -72,7 +78,12 @@ nsresult Unregister(const char *path) nsUnregisterProc proc = (nsUnregisterProc) PR_FindSymbol(instance, "NSUnregisterSelf"); if (proc != NULL) { - res = proc(path); + nsIServiceManager* serviceMgr = NULL; + res = nsServiceManager::GetGlobalServiceManager(&serviceMgr); + if (res == NS_OK) + { + res = proc(serviceMgr, path); + } } PR_UnloadLibrary(instance); } else { diff --git a/mozilla/xpcom/tests/TestFactory.cpp b/mozilla/xpcom/tests/TestFactory.cpp index 00d540264d4..af916f28a40 100644 --- a/mozilla/xpcom/tests/TestFactory.cpp +++ b/mozilla/xpcom/tests/TestFactory.cpp @@ -130,8 +130,8 @@ nsresult TestFactory::CreateInstance(nsISupports *aDelegate, */ extern "C" void RegisterTestFactories() { - nsRepository::RegisterFactory(kTestFactoryCID, new TestFactory(), - PR_FALSE); + nsRepository::RegisterFactory(kTestFactoryCID, 0, 0, + new TestFactory(), PR_FALSE); // Windows can use persistant registry #ifndef USE_NSREG diff --git a/mozilla/xpcom/tests/dynamic/TestDynamic.cpp b/mozilla/xpcom/tests/dynamic/TestDynamic.cpp index 72a337294c7..6be26d3e18b 100644 --- a/mozilla/xpcom/tests/dynamic/TestDynamic.cpp +++ b/mozilla/xpcom/tests/dynamic/TestDynamic.cpp @@ -105,13 +105,16 @@ nsresult TestDynamicFactory::CreateInstance(nsISupports *aDelegate, return res; } -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, - nsISupports* serviceMgr, - nsIFactory **aFactory) { +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) +{ if (aFactory == NULL) { return NS_ERROR_NULL_POINTER; } - if (aCID.Equals(kTestLoadedFactoryCID)) { + if (aClass.Equals(kTestLoadedFactoryCID)) { TestDynamicFactory *factory = new TestDynamicFactory(); nsresult res = factory->QueryInterface(kFactoryIID, (void **) aFactory); if (NS_FAILED(res)) { @@ -123,17 +126,17 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, return NS_NOINTERFACE; } -extern "C" NS_EXPORT PRBool NSCanUnload() { +extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* serviceMgr) { return PRBool(g_FactoryCount == 0 && g_LockCount == 0); } -extern "C" NS_EXPORT nsresult NSRegisterSelf(const char *path) +extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::RegisterFactory(kTestLoadedFactoryCID, path, PR_TRUE, PR_TRUE); } -extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char *path) +extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, const char *path) { return nsRepository::UnregisterFactory(kTestLoadedFactoryCID, path); } diff --git a/mozilla/xpcom/tests/services/MyService.cpp b/mozilla/xpcom/tests/services/MyService.cpp index 2689d44e354..48aa2f13be2 100644 --- a/mozilla/xpcom/tests/services/MyService.cpp +++ b/mozilla/xpcom/tests/services/MyService.cpp @@ -136,7 +136,11 @@ MyServiceFactory::LockFactory(PRBool aLock) static NS_DEFINE_IID(kIMyServiceCID, NS_IMYSERVICE_CID); extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory) +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (!aClass.Equals(kIMyServiceCID)) return NS_ERROR_FACTORY_NOT_REGISTERED; @@ -153,7 +157,7 @@ NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory } extern "C" NS_EXPORT PRBool -NSCanUnload(void) +NSCanUnload(nsISupports* serviceMgr) { if (gFact && gFact->CanUnload()) { nsrefcnt cnt = gFact->Release(); diff --git a/mozilla/xpfe/AppCores/src/nsAppCores.cpp b/mozilla/xpfe/AppCores/src/nsAppCores.cpp index b0c9c851b2b..39ae445828d 100644 --- a/mozilla/xpfe/AppCores/src/nsAppCores.cpp +++ b/mozilla/xpfe/AppCores/src/nsAppCores.cpp @@ -48,13 +48,13 @@ static NS_DEFINE_IID(kAppCoresManagerCID, NS_APPCORESMANAGER_CID); //////////////////////////////////////////////////////////////////////////////// extern "C" NS_EXPORT PRBool -NSCanUnload(void) +NSCanUnload(nsISupports* serviceMgr) { return PRBool (gInstanceCnt == 0 && gLockCnt == 0); } extern "C" NS_EXPORT nsresult -NSRegisterSelf(const char *path) +NSRegisterSelf(nsISupports* serviceMgr, const char *path) { printf("*** AppCores is being registered\n"); nsRepository::RegisterFactory(kAppCoresManagerCID, path, PR_TRUE, PR_TRUE); @@ -68,7 +68,7 @@ NSRegisterSelf(const char *path) } extern "C" NS_EXPORT nsresult -NSUnregisterSelf(const char *path) +NSUnregisterSelf(nsISupports* serviceMgr, const char *path) { printf("*** AppCores is being unregistered\n"); @@ -86,7 +86,11 @@ NSUnregisterSelf(const char *path) extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory) +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) { if (aFactory == NULL) @@ -144,7 +148,7 @@ NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory delete inst; } - return res; + return res; } diff --git a/mozilla/xpfe/AppCores/src/nsAppCores.h b/mozilla/xpfe/AppCores/src/nsAppCores.h index a9ff85c65e5..c98dd1926a0 100644 --- a/mozilla/xpfe/AppCores/src/nsAppCores.h +++ b/mozilla/xpfe/AppCores/src/nsAppCores.h @@ -26,17 +26,6 @@ //////////////////////////////////////////////////////////////////////////////// // DLL Entry Points: //////////////////////////////////////////////////////////////////////////////// -extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory); - -extern "C" NS_EXPORT PRBool -NSCanUnload(void); - -extern "C" NS_EXPORT nsresult -NSRegisterSelf(const char *path); - -extern "C" NS_EXPORT nsresult -NSUnregisterSelf(const char *path); extern "C" void IncInstanceCount(); diff --git a/mozilla/xpfe/apprunner/src/nsAppRunner.cpp b/mozilla/xpfe/apprunner/src/nsAppRunner.cpp index c1d6ba69c57..5d2df3745bb 100644 --- a/mozilla/xpfe/apprunner/src/nsAppRunner.cpp +++ b/mozilla/xpfe/apprunner/src/nsAppRunner.cpp @@ -368,7 +368,12 @@ nsAppRunnerFactory::LockFactory(PRBool aLock) } extern "C" NS_EXPORT nsresult -NSGetFactory(const nsCID &cid, nsISupports* servMgr, nsIFactory** aFactory ) { +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) +{ nsresult rv = NS_OK; if ( aFactory == 0 ) { diff --git a/mozilla/xpfe/appshell/src/nsAppShellFactory.cpp b/mozilla/xpfe/appshell/src/nsAppShellFactory.cpp index 79efe0d99ac..4e75b9748da 100644 --- a/mozilla/xpfe/appshell/src/nsAppShellFactory.cpp +++ b/mozilla/xpfe/appshell/src/nsAppShellFactory.cpp @@ -30,9 +30,19 @@ static NS_DEFINE_IID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID); #if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_APPSHELL nsresult NSGetFactory_APPSHELL_DLL(const nsCID& aClass, nsISupports* servMgr, nsIFactory** aFactory) +extern "C" NS_APPSHELL nsresult +NSGetFactory_APPSHELL_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #else -extern "C" NS_APPSHELL nsresult NSGetFactory(const nsCID& aClass, nsISupports* servMgr, nsIFactory** aFactory) +extern "C" NS_APPSHELL nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #endif { nsresult rv = NS_OK; diff --git a/mozilla/xpfe/browser/src/nsBrowserFactory.cpp b/mozilla/xpfe/browser/src/nsBrowserFactory.cpp index d31488e32ed..170f9762266 100644 --- a/mozilla/xpfe/browser/src/nsBrowserFactory.cpp +++ b/mozilla/xpfe/browser/src/nsBrowserFactory.cpp @@ -30,9 +30,19 @@ #if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_EXPORT nsresult NSGetFactory_WEB_DLL(const nsCID& aClass, nsISupports* servMgr, nsIFactory** aFactory) +extern "C" NS_EXPORT nsresult +NSGetFactory_WEB_DLL(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #else -extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID& aClass, nsISupports* servMgr, nsIFactory** aFactory) +extern "C" NS_EXPORT nsresult +NSGetFactory(nsISupports* serviceMgr, + const nsCID &aClass, + const char *aClassName, + const char *aProgID, + nsIFactory **aFactory) #endif { nsresult rv = NS_OK;