From ecdd8ab65f9fd5aff6c35d54ad6022cc8a85473f Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Thu, 18 Jul 2002 05:09:10 +0000 Subject: [PATCH] Fixes the following: 154047 This change cleans up the category manager in hopes to freeze it for 1.1 final. This change removes dead and unsupported methods from the interface as well as removes the C++ code from the interface. This should land for 1.1b since users of the current category manager will have to update their components. 157597 Make embedding base and examples use XPCOM Glue This change makes our embedding samples use the XPCOM glue. 157625 nsLocalFile::Remove's file pointer is sometimes null afte... This fixes a crash when we dereference null. It is a bandaide fix as the real problems involves retooling the directory enumerator. 157801 This fixes a terrible state which you can get into whereby XPCOM will fail to startup regardless of what you do. The fix is to cause autoreg to happen if the component registry (compreg.dat) is not found. r/sr=alecf@netscape.com, rpotts@netscape.com. a=scc@mozilla.org git-svn-id: svn://10.0.0.236/trunk@125444 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/content/src/nsHTMLFormElement.cpp | 1 + mozilla/embedding/base/Makefile.in | 2 + mozilla/embedding/base/nsEmbedAPI.cpp | 12 +++ .../browser/activex/src/control/Makefile.in | 5 +- mozilla/embedding/tests/mfcembed/Makefile.in | 8 +- mozilla/embedding/tests/mfcembed/MfcEmbed.cpp | 44 ++++---- mozilla/embedding/tests/mfcembed/MfcEmbed.h | 22 ++++ .../embedding/tests/mfcembed/ProfilesDlg.cpp | 3 +- .../mfcembed/components/nsPrintDialogUtil.cpp | 14 ++- .../mfcembed/winEmbedFileLocProvider.cpp | 27 +++-- mozilla/embedding/tests/winEmbed/Makefile.in | 6 +- mozilla/htmlparser/src/nsParserService.cpp | 1 + .../addrbook/src/nsAbLDAPDirectoryQuery.cpp | 1 + mozilla/mailnews/base/util/nsMsgUtils.cpp | 1 + mozilla/modules/libpref/src/nsPrefService.cpp | 1 + .../protocol/http/src/nsHttpHandler.cpp | 1 + .../parser/htmlparser/src/nsParserService.cpp | 1 + mozilla/xpcom/build/nsXPComInit.cpp | 9 ++ mozilla/xpcom/components/MANIFEST_IDL | 1 - mozilla/xpcom/components/Makefile.in | 3 +- mozilla/xpcom/components/makefile.win | 1 - .../xpcom/components/nsCategoryManager.cpp | 42 +------- ...ategoryHandler.idl => nsCategoryManager.h} | 25 ++--- .../xpcom/components/nsCategoryManagerUtils.h | 5 + .../xpcom/components/nsComponentManager.cpp | 23 ++-- .../xpcom/components/nsICategoryManager.idl | 100 +++++++----------- mozilla/xpcom/io/nsLocalFileWin.cpp | 48 +++++---- mozilla/xpcom/macbuild/XPCOMIDL.xml | 30 ------ .../src/nsLDAPAutoCompleteSession.cpp | 1 + 29 files changed, 211 insertions(+), 227 deletions(-) rename mozilla/xpcom/components/{nsICategoryHandler.idl => nsCategoryManager.h} (76%) diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp index 78de2662609..0471c95891e 100644 --- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp @@ -68,6 +68,7 @@ #include "nsIURI.h" #include "nsIObserverService.h" #include "nsICategoryManager.h" +#include "nsCategoryManagerUtils.h" #include "nsISimpleEnumerator.h" #include "nsIDOMWindowInternal.h" #include "nsRange.h" diff --git a/mozilla/embedding/base/Makefile.in b/mozilla/embedding/base/Makefile.in index c4eafacab4c..2e297cd3771 100644 --- a/mozilla/embedding/base/Makefile.in +++ b/mozilla/embedding/base/Makefile.in @@ -56,6 +56,8 @@ endif # static lib. FORCE_STATIC_LIB = 1 +DEFINES += -DXPCOM_GLUE + include $(topsrcdir)/config/rules.mk CXXFLAGS += $(MOZ_TOOLKIT_REGISTRY_CFLAGS) diff --git a/mozilla/embedding/base/nsEmbedAPI.cpp b/mozilla/embedding/base/nsEmbedAPI.cpp index 1631996776d..40f6e57d5dc 100644 --- a/mozilla/embedding/base/nsEmbedAPI.cpp +++ b/mozilla/embedding/base/nsEmbedAPI.cpp @@ -22,6 +22,10 @@ * Contributor(s): */ +#ifdef XPCOM_GLUE +#include "nsXPCOMGlue.h" +#endif + #include "nsIServiceManager.h" #include "nsIComponentRegistrar.h" #include "nsIAppStartupNotifier.h" @@ -83,6 +87,11 @@ nsresult NS_InitEmbedding(nsILocalFile *mozBinDirectory, if (!sXPCOMInitializedFlag) #endif { + +#ifdef XPCOM_GLUE + // TODO: Need to be smarter about where exactly the xpcom library is. + XPCOMGlueStartup(nsnull); +#endif // Initialise XPCOM NS_InitXPCOM2(&sServiceManager, mozBinDirectory, appFileLocProvider); @@ -176,5 +185,8 @@ nsresult NS_TermEmbedding() NS_ShutdownXPCOM(sServiceManager); #endif +#ifdef XPCOM_GLUE + XPCOMGlueShutdown(); +#endif return NS_OK; } diff --git a/mozilla/embedding/browser/activex/src/control/Makefile.in b/mozilla/embedding/browser/activex/src/control/Makefile.in index b520909a089..c70f5bc73ec 100644 --- a/mozilla/embedding/browser/activex/src/control/Makefile.in +++ b/mozilla/embedding/browser/activex/src/control/Makefile.in @@ -79,9 +79,12 @@ CPPSRCS = \ guids.cpp \ $(NULL) +DEFINES += -DXPCOM_GLUE + +# we still include xpcom directly since this control uses atoms and voidarray. EXTRA_DSO_LDOPTS = \ - $(DIST)/lib/$(LIB_PREFIX)gkgfx.$(LIB_SUFFIX) \ $(DIST)/lib/$(LIB_PREFIX)embed_base_s.$(LIB_SUFFIX) \ + $(XPCOM_GLUE_LIBS) \ $(XPCOM_LIBS) \ $(NSPR_LIBS) \ $(NULL) diff --git a/mozilla/embedding/tests/mfcembed/Makefile.in b/mozilla/embedding/tests/mfcembed/Makefile.in index 1d59177e434..5cfbe0c8c49 100644 --- a/mozilla/embedding/tests/mfcembed/Makefile.in +++ b/mozilla/embedding/tests/mfcembed/Makefile.in @@ -83,11 +83,13 @@ CPPSRCS = \ StdAfx.cpp \ $(NULL) -EXTRA_DSO_LIBS = embed_base_s gkgfx mfcEmbedComponents +EXTRA_DSO_LIBS = mfcEmbedComponents + +DEFINES += -DXPCOM_GLUE LIBS = \ - $(EXTRA_DSO_LIBS) \ - $(XPCOM_LIBS) \ + $(DIST)/lib/$(LIB_PREFIX)embed_base_s.$(LIB_SUFFIX) \ + $(XPCOM_GLUE_LIBS) \ $(NSPR_LIBS) \ $(NULL) diff --git a/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp b/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp index 24c43dfa637..a6707ff8ff4 100644 --- a/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp +++ b/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp @@ -55,10 +55,11 @@ #include "nsIWindowWatcher.h" #include "plstr.h" #include "Preferences.h" -#include "nsCRT.h" #include #include +#include "nsIComponentRegistrar.h" + #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE @@ -168,6 +169,12 @@ nsresult CMfcEmbedApp::OverrideComponents() { nsresult rv = NS_OK; + + nsCOMPtr registrar; + rv = NS_GetComponentRegistrar(getter_AddRefs(registrar)); + if (NS_FAILED(rv)) + return rv; + // replace Mozilla's default PromptService with our own, if the // expected override DLL is present HMODULE overlib = ::LoadLibrary(kComponentsLibname); @@ -183,11 +190,10 @@ nsresult CMfcEmbedApp::OverrideComponents() nsCOMPtr promptFactory; rv = MakeFactory(getter_AddRefs(promptFactory)); if (NS_SUCCEEDED(rv)) - nsComponentManager::RegisterFactory(kPromptServiceCID, - "Prompt Service", - "@mozilla.org/embedcomp/prompt-service;1", - promptFactory, - PR_TRUE); // replace existing + registrar->RegisterFactory(kPromptServiceCID, + "Prompt Service", + "@mozilla.org/embedcomp/prompt-service;1", + promptFactory); // replace existing } else ::FreeLibrary(overlib); } @@ -206,11 +212,10 @@ nsresult CMfcEmbedApp::OverrideComponents() nsCOMPtr helperAppDlgFactory; rv = MakeFactory(getter_AddRefs(helperAppDlgFactory)); if (NS_SUCCEEDED(rv)) - nsComponentManager::RegisterFactory(kHelperAppLauncherDialogCID, - "Helper App Launcher Dialog", - "@mozilla.org/helperapplauncherdialog;1", - helperAppDlgFactory, - PR_TRUE); // replace existing + registrar->RegisterFactory(kHelperAppLauncherDialogCID, + "Helper App Launcher Dialog", + "@mozilla.org/helperapplauncherdialog;1", + helperAppDlgFactory); } else ::FreeLibrary(overlib); } @@ -230,11 +235,10 @@ nsresult CMfcEmbedApp::OverrideComponents() nsCOMPtr printingPromptFactory; rv = MakeFactory(getter_AddRefs(printingPromptFactory)); if (NS_SUCCEEDED(rv)) - nsComponentManager::RegisterFactory(kPrintingPromptServiceCID, - "Printing Prompt Service", - "@mozilla.org/embedcomp/printingprompt-service;1", - printingPromptFactory, - PR_TRUE); // replace existing + registrar->RegisterFactory(kPrintingPromptServiceCID, + "Printing Prompt Service", + "@mozilla.org/embedcomp/printingprompt-service;1", + printingPromptFactory); } else ::FreeLibrary(overlib); } @@ -647,7 +651,7 @@ NS_IMETHODIMP CMfcEmbedApp::Observe(nsISupports *aSubject, const char *aTopic, c { nsresult rv = NS_OK; - if (nsCRT::strcmp(aTopic, "profile-approve-change") == 0) + if (strcmp(aTopic, "profile-approve-change") == 0) { // Ask the user if they want to int result = MessageBox(NULL, "Do you want to close all windows in order to switch the profile?", "Confirm", MB_YESNO | MB_ICONQUESTION); @@ -658,7 +662,7 @@ NS_IMETHODIMP CMfcEmbedApp::Observe(nsISupports *aSubject, const char *aTopic, c status->VetoChange(); } } - else if (nsCRT::strcmp(aTopic, "profile-change-teardown") == 0) + else if (strcmp(aTopic, "profile-change-teardown") == 0) { // Close all open windows. Alternatively, we could just call CBrowserWindow::Stop() // on each. Either way, we have to stop all network activity on this phase. @@ -679,13 +683,13 @@ NS_IMETHODIMP CMfcEmbedApp::Observe(nsISupports *aSubject, const char *aTopic, c } } } - else if (nsCRT::strcmp(aTopic, "profile-after-change") == 0) + else if (strcmp(aTopic, "profile-after-change") == 0) { InitializePrefs(); // In case we have just switched to a newly created profile. // Only make a new browser window on a switch. This also gets // called at start up and we already make a window then. - if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("switch").get())) + if (!strcmp(someData, NS_LITERAL_STRING("switch").get())) OnNewBrowser(); } return rv; diff --git a/mozilla/embedding/tests/mfcembed/MfcEmbed.h b/mozilla/embedding/tests/mfcembed/MfcEmbed.h index e8d6f3e34fd..114f838df65 100644 --- a/mozilla/embedding/tests/mfcembed/MfcEmbed.h +++ b/mozilla/embedding/tests/mfcembed/MfcEmbed.h @@ -126,6 +126,28 @@ private: ///////////////////////////////////////////////////////////////////////////// +static PRInt32 strcmp(const PRUnichar* s1, const PRUnichar* s2) { + if(s1 && s2) { + for (;;) { + PRUnichar c1 = *s1++; + PRUnichar c2 = *s2++; + if (c1 != c2) { + if (c1 < c2) return -1; + return 1; + } + if ((0==c1) || (0==c2)) break; + } + } + else { + if (s1) // s2 must have been null + return -1; + if (s2) // s1 must have been null + return 1; + } + return 0; +} + + //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp b/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp index 9ba7ca093fa..9dc9ae68b0d 100644 --- a/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp +++ b/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp @@ -38,7 +38,6 @@ // Mozilla #include "nsIProfile.h" #include "nsIServiceManager.h" -#include "nsCRT.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -228,7 +227,7 @@ BOOL CProfilesDlg::OnInitDialog() { CString tmpStr(W2T(profileList[index])); m_ProfileList.AddString(tmpStr); - if (nsCRT::strcmp(profileList[index], curProfileName.get()) == 0) + if (strcmp(profileList[index], curProfileName.get()) == 0) selectedRow = index; } diff --git a/mozilla/embedding/tests/mfcembed/components/nsPrintDialogUtil.cpp b/mozilla/embedding/tests/mfcembed/components/nsPrintDialogUtil.cpp index 41581291f6b..467803f0a8f 100644 --- a/mozilla/embedding/tests/mfcembed/components/nsPrintDialogUtil.cpp +++ b/mozilla/embedding/tests/mfcembed/components/nsPrintDialogUtil.cpp @@ -81,7 +81,6 @@ static NS_DEFINE_IID(kPrinterEnumeratorCID, NS_PRINTER_ENUMERATOR_CID); #include "nsRect.h" #include "nsIPref.h" -#include "nsCRT.h" #include "prenv.h" /* for PR_GetEnv */ #include @@ -837,6 +836,17 @@ static PRUnichar * GetDefaultPrinterNameFromGlobalPrinters() return printerName; } +static PRUint32 strlen(const PRUnichar* s) +{ + PRUint32 len = 0; + if(s) { + while (*s++ != 0) { + len++; + } + } + return len; +} + //------------------------------------------------------------------ // Displays the native Print Dialog @@ -866,7 +876,7 @@ ShowNativePrintDialog(HWND aHWnd, if (!printerName) return NS_ERROR_FAILURE; // Now create a DEVNAMES struct so the the dialog is initialized correctly. - PRUint32 len = nsCRT::strlen(printerName); + PRUint32 len = strlen(printerName); hDevNames = (HGLOBAL)::GlobalAlloc(GHND, len+sizeof(DEVNAMES)+1); DEVNAMES* pDevNames = (DEVNAMES*)::GlobalLock(hDevNames); pDevNames->wDriverOffset = sizeof(DEVNAMES); diff --git a/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp b/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp index 420bf53c75a..8f203186648 100644 --- a/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp +++ b/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp @@ -35,7 +35,6 @@ #include "nsILocalFile.h" #include "nsString.h" #include "nsXPIDLString.h" -#include "nsCRT.h" #include @@ -92,23 +91,23 @@ winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile * *_retval = nsnull; *persistant = PR_TRUE; - if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_DIR) == 0) + if (strcmp(prop, NS_APP_APPLICATION_REGISTRY_DIR) == 0) { rv = GetProductDirectory(getter_AddRefs(localFile)); } - else if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_FILE) == 0) + else if (strcmp(prop, NS_APP_APPLICATION_REGISTRY_FILE) == 0) { rv = GetProductDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) rv = localFile->AppendNative(APP_REGISTRY_NAME); } - else if (nsCRT::strcmp(prop, NS_APP_DEFAULTS_50_DIR) == 0) + else if (strcmp(prop, NS_APP_DEFAULTS_50_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME); } - else if (nsCRT::strcmp(prop, NS_APP_PREF_DEFAULTS_50_DIR) == 0) + else if (strcmp(prop, NS_APP_PREF_DEFAULTS_50_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { @@ -117,8 +116,8 @@ winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile * rv = localFile->AppendRelativeNativePath(DEFAULTS_PREF_DIR_NAME); } } - else if (nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR) == 0 || - nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_50_DIR) == 0) + else if (strcmp(prop, NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR) == 0 || + strcmp(prop, NS_APP_PROFILE_DEFAULTS_50_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { @@ -127,29 +126,29 @@ winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile * rv = localFile->AppendRelativeNativePath(DEFAULTS_PROFILE_DIR_NAME); } } - else if (nsCRT::strcmp(prop, NS_APP_USER_PROFILES_ROOT_DIR) == 0) + else if (strcmp(prop, NS_APP_USER_PROFILES_ROOT_DIR) == 0) { rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile)); } - else if (nsCRT::strcmp(prop, NS_APP_RES_DIR) == 0) + else if (strcmp(prop, NS_APP_RES_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativeNativePath(RES_DIR_NAME); } - else if (nsCRT::strcmp(prop, NS_APP_CHROME_DIR) == 0) + else if (strcmp(prop, NS_APP_CHROME_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativeNativePath(CHROME_DIR_NAME); } - else if (nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR) == 0) + else if (strcmp(prop, NS_APP_PLUGINS_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME); } - else if (nsCRT::strcmp(prop, NS_APP_SEARCH_DIR) == 0) + else if (strcmp(prop, NS_APP_SEARCH_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) @@ -164,11 +163,11 @@ winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile * // Please see http://www.mozilla.org/projects/embedding/MRE.html // for more info. on MRE //--------------------------------------------------------------- - else if (nsCRT::strcmp(prop, NS_MRE_DIR) == 0) + else if (strcmp(prop, NS_MRE_DIR) == 0) { rv = GetMreDirectory(getter_AddRefs(localFile)); } - else if (nsCRT::strcmp(prop, NS_MRE_COMPONENT_DIR) == 0) + else if (strcmp(prop, NS_MRE_COMPONENT_DIR) == 0) { rv = GetMreDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) diff --git a/mozilla/embedding/tests/winEmbed/Makefile.in b/mozilla/embedding/tests/winEmbed/Makefile.in index 1a374b213c2..828dd56f4d5 100644 --- a/mozilla/embedding/tests/winEmbed/Makefile.in +++ b/mozilla/embedding/tests/winEmbed/Makefile.in @@ -62,11 +62,11 @@ CPPSRCS = \ StdAfx.cpp \ $(NULL) -EXTRA_DSO_LIBS = embed_base_s gkgfx +DEFINES += -DXPCOM_GLUE LIBS = \ - $(EXTRA_DSO_LIBS) \ - $(XPCOM_LIBS) \ + $(DIST)/lib/$(LIB_PREFIX)embed_base_s.$(LIB_SUFFIX) \ + $(XPCOM_GLUE_LIBS) \ $(NSPR_LIBS) \ $(NULL) diff --git a/mozilla/htmlparser/src/nsParserService.cpp b/mozilla/htmlparser/src/nsParserService.cpp index 095fda2cb5c..49296ae8db1 100644 --- a/mozilla/htmlparser/src/nsParserService.cpp +++ b/mozilla/htmlparser/src/nsParserService.cpp @@ -23,6 +23,7 @@ #include "nsHTMLEntities.h" #include "nsElementTable.h" #include "nsICategoryManager.h" +#include "nsCategoryManagerUtils.h" nsParserService::nsParserService() : mEntries(0) { diff --git a/mozilla/mailnews/addrbook/src/nsAbLDAPDirectoryQuery.cpp b/mozilla/mailnews/addrbook/src/nsAbLDAPDirectoryQuery.cpp index 750a5791266..41635e9cafe 100644 --- a/mozilla/mailnews/addrbook/src/nsAbLDAPDirectoryQuery.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbLDAPDirectoryQuery.cpp @@ -56,6 +56,7 @@ #include "nsIWindowWatcher.h" #include "nsIDOMWindow.h" #include "nsICategoryManager.h" +#include "nsCategoryManagerUtils.h" class nsAbQueryLDAPMessageListener : public nsILDAPMessageListener { diff --git a/mozilla/mailnews/base/util/nsMsgUtils.cpp b/mozilla/mailnews/base/util/nsMsgUtils.cpp index 2f874c9e100..ffea2de2bc4 100644 --- a/mozilla/mailnews/base/util/nsMsgUtils.cpp +++ b/mozilla/mailnews/base/util/nsMsgUtils.cpp @@ -60,6 +60,7 @@ #include "nsIMimeConverter.h" #include "nsMsgMimeCID.h" #include "nsICategoryManager.h" +#include "nsCategoryManagerUtils.h" static NS_DEFINE_CID(kImapUrlCID, NS_IMAPURL_CID); static NS_DEFINE_CID(kCMailboxUrl, NS_MAILBOXURL_CID); diff --git a/mozilla/modules/libpref/src/nsPrefService.cpp b/mozilla/modules/libpref/src/nsPrefService.cpp index e8c21906bde..ce63ee08f1a 100644 --- a/mozilla/modules/libpref/src/nsPrefService.cpp +++ b/mozilla/modules/libpref/src/nsPrefService.cpp @@ -42,6 +42,7 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h" #include "nsICategoryManager.h" +#include "nsCategoryManagerUtils.h" #include "nsIFile.h" #include "nsIFileStreams.h" #include "nsILocalFile.h" diff --git a/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp index 33a1f16162e..0f19c6083b5 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp @@ -41,6 +41,7 @@ #include "nsIStandardURL.h" #include "nsICacheService.h" #include "nsICategoryManager.h" +#include "nsCategoryManagerUtils.h" #include "nsIObserverService.h" #include "nsISupportsPrimitives.h" #include "nsINetModRegEntry.h" diff --git a/mozilla/parser/htmlparser/src/nsParserService.cpp b/mozilla/parser/htmlparser/src/nsParserService.cpp index 095fda2cb5c..49296ae8db1 100644 --- a/mozilla/parser/htmlparser/src/nsParserService.cpp +++ b/mozilla/parser/htmlparser/src/nsParserService.cpp @@ -23,6 +23,7 @@ #include "nsHTMLEntities.h" #include "nsElementTable.h" #include "nsICategoryManager.h" +#include "nsCategoryManagerUtils.h" nsParserService::nsParserService() : mEntries(0) { diff --git a/mozilla/xpcom/build/nsXPComInit.cpp b/mozilla/xpcom/build/nsXPComInit.cpp index 890aee1f030..581c047a47d 100644 --- a/mozilla/xpcom/build/nsXPComInit.cpp +++ b/mozilla/xpcom/build/nsXPComInit.cpp @@ -89,6 +89,7 @@ #endif #include "nsDirectoryService.h" #include "nsDirectoryServiceDefs.h" +#include "nsCategoryManager.h" #include "nsICategoryManager.h" #include "nsStringStream.h" #include "nsMultiplexInputStream.h" @@ -453,6 +454,7 @@ nsresult NS_COM NS_InitXPCOM2(nsIServiceManager* *result, // Category Manager { + extern nsresult NS_CategoryManagerGetFactory( nsIFactory** ); nsCOMPtr categoryManagerFactory; if ( NS_FAILED(rv = NS_CategoryManagerGetFactory(getter_AddRefs(categoryManagerFactory))) ) return rv; @@ -476,6 +478,13 @@ nsresult NS_COM NS_InitXPCOM2(nsIServiceManager* *result, printf("No Persistent Registry Found.\n"); } #endif + + if ( NS_FAILED(rv) ) { + // if we find no persistent registry, we will try to autoregister + // the default components directory. + nsComponentManagerImpl::gComponentManager->AutoRegister(nsnull); + } + // Pay the cost at startup time of starting this singleton. nsIInterfaceInfoManager* iim = XPTI_GetInterfaceInfoManager(); NS_IF_RELEASE(iim); diff --git a/mozilla/xpcom/components/MANIFEST_IDL b/mozilla/xpcom/components/MANIFEST_IDL index 1be86b20531..4e4df83eb40 100644 --- a/mozilla/xpcom/components/MANIFEST_IDL +++ b/mozilla/xpcom/components/MANIFEST_IDL @@ -1,4 +1,3 @@ -nsICategoryHandler.idl nsICategoryManager.idl nsIClassInfo.idl nsIComponentLoader.idl diff --git a/mozilla/xpcom/components/Makefile.in b/mozilla/xpcom/components/Makefile.in index 79b647a5b6c..afc1b86491b 100644 --- a/mozilla/xpcom/components/Makefile.in +++ b/mozilla/xpcom/components/Makefile.in @@ -64,8 +64,6 @@ EXPORTS = \ $(NULL) XPIDLSRCS = \ - nsICategoryHandler.idl \ - nsICategoryManager.idl \ nsIComponentLoader.idl \ nsIComponentLoaderManager.idl \ nsIComponentManagerObsolete.idl \ @@ -79,6 +77,7 @@ SDK_XPIDLSRCS = \ nsIModule.idl \ nsIServiceManager.idl \ nsIComponentManager.idl \ + nsICategoryManager.idl \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/mozilla/xpcom/components/makefile.win b/mozilla/xpcom/components/makefile.win index 9701d70e7e1..5bdcbd938ad 100644 --- a/mozilla/xpcom/components/makefile.win +++ b/mozilla/xpcom/components/makefile.win @@ -47,7 +47,6 @@ EXPORTS = \ $(NULL) XPIDLSRCS = \ - .\nsICategoryHandler.idl \ .\nsICategoryManager.idl \ .\nsIClassInfo.idl \ .\nsIComponentLoader.idl \ diff --git a/mozilla/xpcom/components/nsCategoryManager.cpp b/mozilla/xpcom/components/nsCategoryManager.cpp index b1f2f8f587d..a5129f681e6 100644 --- a/mozilla/xpcom/components/nsCategoryManager.cpp +++ b/mozilla/xpcom/components/nsCategoryManager.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsICategoryManager.h" +#include "nsCategoryManager.h" #include "nsCOMPtr.h" #include "nsHashtable.h" @@ -183,17 +184,6 @@ NS_IMETHODIMP nsCategoryManager::GetCategoryEntry( const char *aCategoryName, const char *aEntryName, char **_retval ) - { - // BULLSHIT ALERT: Category `handler's currently not implemented, so just call through - return GetCategoryEntryRaw(aCategoryName, aEntryName, _retval); - } - - - -NS_IMETHODIMP -nsCategoryManager::GetCategoryEntryRaw( const char *aCategoryName, - const char *aEntryName, - char **_retval ) { NS_ASSERTION(aCategoryName, "aCategoryName is NULL!"); NS_ASSERTION(aEntryName, "aEntryName is NULL!"); @@ -212,8 +202,6 @@ nsCategoryManager::GetCategoryEntryRaw( const char *aCategoryName, return status; } - - NS_IMETHODIMP nsCategoryManager::AddCategoryEntry( const char *aCategoryName, const char *aEntryName, @@ -385,30 +373,6 @@ nsCategoryManager::EnumerateCategories(nsISimpleEnumerator **_retval) return status; } - -NS_IMETHODIMP -nsCategoryManager::RegisterCategoryHandler( const char* /* aCategoryName */, - nsICategoryHandler* /* aHandler */, - PRInt32 /* aMode */, - nsICategoryHandler** /* _retval */ ) - { - // BULLSHIT ALERT: Category `handler's currently not implemented - return NS_ERROR_NOT_IMPLEMENTED; - } - - - -NS_IMETHODIMP -nsCategoryManager::UnregisterCategoryHandler( const char *category, - nsICategoryHandler *handler, - nsICategoryHandler *previous ) - { - // BULLSHIT ALERT: Category `handler's currently not implemented. - // Wasn't implemented in the JS version either. - return NS_ERROR_NOT_IMPLEMENTED; - } - - class nsCategoryManagerFactory : public nsIFactory { public: @@ -455,8 +419,6 @@ nsCategoryManagerFactory::LockFactory( PRBool ) return NS_OK; } -extern "C" -NS_EXPORT nsresult NS_CategoryManagerGetFactory( nsIFactory** aFactory ) { @@ -489,7 +451,7 @@ NS_CategoryManagerGetFactory( nsIFactory** aFactory ) * this will attempt to notify the observer with the origin, observerTopic string * as parameter. */ -nsresult +NS_EXPORT nsresult NS_CreateServicesFromCategory(const char *category, nsISupports *origin, const char *observerTopic) diff --git a/mozilla/xpcom/components/nsICategoryHandler.idl b/mozilla/xpcom/components/nsCategoryManager.h similarity index 76% rename from mozilla/xpcom/components/nsICategoryHandler.idl rename to mozilla/xpcom/components/nsCategoryManager.h index 5bad1a324a4..a1a893817c6 100644 --- a/mozilla/xpcom/components/nsICategoryHandler.idl +++ b/mozilla/xpcom/components/nsCategoryManager.h @@ -1,4 +1,4 @@ -/* -*- Mode: idl; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: NPL 1.1/GPL 2.0/LGPL 2.1 * @@ -14,7 +14,7 @@ * * The Original Code is mozilla.org code. * - * The Initial Developer of the Original Code is + * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. @@ -22,7 +22,7 @@ * Contributor(s): * * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or + * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only @@ -35,15 +35,12 @@ * * ***** END LICENSE BLOCK ***** */ -#include "nsISupports.idl" -[scriptable, uuid(9c1af822-1dd1-11b2-b8ce-a1d231c7953f)] -interface nsICategoryHandler : nsISupports -{ - /** - * Get the entry for the given category's tag. - * @param category The name of the category ("protocol") - * @param entry The entry you're looking for ("http") - */ - string getCategoryEntry(in string category, in string entry); -}; +#define NS_CATEGORYMANAGER_CLASSNAME "Category Manager" + +/* 16d222a6-1dd2-11b2-b693-f38b02c021b2 */ +#define NS_CATEGORYMANAGER_CID \ +{ 0x16d222a6, 0x1dd2, 0x11b2, \ + {0xb6, 0x93, 0xf3, 0x8b, 0x02, 0xc0, 0x21, 0xb2} } + + diff --git a/mozilla/xpcom/components/nsCategoryManagerUtils.h b/mozilla/xpcom/components/nsCategoryManagerUtils.h index e90adba1d12..f3f963fb7ca 100644 --- a/mozilla/xpcom/components/nsCategoryManagerUtils.h +++ b/mozilla/xpcom/components/nsCategoryManagerUtils.h @@ -41,6 +41,11 @@ #include "nsICategoryManager.h" #include "nsCOMPtr.h" +NS_COM nsresult +NS_CreateServicesFromCategory(const char *category, + nsISupports *origin, + const char *observerTopic); + class NS_COM nsCreateInstanceFromCategory : public nsCOMPtr_helper { public: diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp index 10fa00c2faa..431d796a9a2 100644 --- a/mozilla/xpcom/components/nsComponentManager.cpp +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -48,6 +48,7 @@ #include "nsDirectoryService.h" #include "nsDirectoryServiceDefs.h" #include "nsICategoryManager.h" +#include "nsCategoryManager.h" #include "nsCategoryManagerUtils.h" #include "nsIComponentLoader.h" #include "nsIEnumerator.h" @@ -152,7 +153,7 @@ nsCreateInstanceFromCategory::operator()( const nsIID& aIID, void** aInstancePtr nsXPIDLCString value; nsCOMPtr compMgr; nsCOMPtr catman = - do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &status); + do_GetService(kCategoryManagerCID, &status); if (NS_FAILED(status)) goto error; @@ -193,7 +194,7 @@ nsGetServiceFromCategory::operator()( const nsIID& aIID, void** aInstancePtr) co nsresult status; nsXPIDLCString value; nsCOMPtr catman = - do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &status); + do_GetService(kCategoryManagerCID, &status); if (NS_FAILED(status)) goto error; if (!mCategory || !mEntry) { // when categories have defaults, use that for null mEntry @@ -988,9 +989,9 @@ nsComponentManagerImpl::ReadPersistentRegistry() // populate Category Manager. need to get this early so that we don't get // skipped by 'goto out' nsCOMPtr catman; - nsresult rv = GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID, - NS_GET_IID(nsICategoryManager), - getter_AddRefs(catman)); + nsresult rv = GetService(kCategoryManagerCID, + NS_GET_IID(nsICategoryManager), + getter_AddRefs(catman)); if (NS_FAILED(rv)) return rv; @@ -3005,10 +3006,14 @@ nsComponentManagerImpl::AutoRegisterImpl(PRInt32 when, else { // Do default components directory - nsCOMPtr directoryService = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; + + nsCOMPtr directoryService; + nsDirectoryService::Create(nsnull, + NS_GET_IID(nsIProperties), + getter_AddRefs(directoryService)); + + if (!directoryService) + return NS_ERROR_FAILURE; rv = directoryService->Get(NS_XPCOM_COMPONENT_DIR, NS_GET_IID(nsIFile), diff --git a/mozilla/xpcom/components/nsICategoryManager.idl b/mozilla/xpcom/components/nsICategoryManager.idl index 881da30b142..4a669794e66 100644 --- a/mozilla/xpcom/components/nsICategoryManager.idl +++ b/mozilla/xpcom/components/nsICategoryManager.idl @@ -1,28 +1,49 @@ -/* -*- Mode: idl; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/NPL/ * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the - * NPL. + * License. * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ #include "nsISupports.idl" #include "nsISimpleEnumerator.idl" -#include "nsICategoryHandler.idl" -#include "nsIFactory.idl" -// change IID if you change this interface! -[scriptable, uuid(5a1e1a2c-1dd2-11b2-a72f-967357e43a00)] +/* + * nsICategoryManager + * @status UNDER_REVIEW - subject to at least bug 157624 + */ + +[scriptable, uuid(3275b2cd-af6d-429a-80d7-f0c5120342ac)] interface nsICategoryManager : nsISupports { /** @@ -33,12 +54,6 @@ interface nsICategoryManager : nsISupports */ string getCategoryEntry(in string aCategory, in string aEntry); - /** - * As above, but do not permit overriding. This is useful to allow - * an override handler to get at the ``normal'' category contents. - */ - string getCategoryEntryRaw(in string aCategory, in string aEntry); - /** * Add an entry to a category. * @param aCategory The name of the category ("protocol") @@ -74,53 +89,14 @@ interface nsICategoryManager : nsISupports */ nsISimpleEnumerator enumerateCategory(in string aCategory); - /** * Enumerate the entries in a category. * @param aCategory The category to be enumerated. */ nsISimpleEnumerator enumerateCategories(); - - const long OVERRIDE = 0; - const long FALLBACK = 1; - - /* - * Register a category handler for override or fallback when - * searching a given category. - * @param aCategory The name of the category ("protocol") - * @param aHandler The handler to be installed - * @param aMode override or fallback? - * @return The previously-installed category handler, if any - */ - nsICategoryHandler registerCategoryHandler(in string aCategory, - in nsICategoryHandler aHandler, - in long aMode); - - /* - * Unregister a category handler for the given category. - * XXX will this cause shutdown problems? Who has owning refs on whom? - * @param category The name of the category ("protocol") - * @param handler The handler to be unregistered. - * @param previous The handler that this one replaced, typically the - * return from the registerCategoryHandler call. - */ - void unregisterCategoryHandler(in string category, - in nsICategoryHandler handler, - in nsICategoryHandler previous); }; + %{C++ #define NS_CATEGORYMANAGER_CONTRACTID "@mozilla.org/categorymanager;1" -#define NS_CATEGORYMANAGER_CLASSNAME "Category Manager" -/* 16d222a6-1dd2-11b2-b693-f38b02c021b2 */ -#define NS_CATEGORYMANAGER_CID \ -{ 0x16d222a6, 0x1dd2, 0x11b2, \ - {0xb6, 0x93, 0xf3, 0x8b, 0x02, 0xc0, 0x21, 0xb2} } - -extern "C" NS_EXPORT nsresult NS_CategoryManagerGetFactory( nsIFactory** ); - -NS_COM nsresult -NS_CreateServicesFromCategory(const char *category, - nsISupports *origin, - const char *observerTopic); %} diff --git a/mozilla/xpcom/io/nsLocalFileWin.cpp b/mozilla/xpcom/io/nsLocalFileWin.cpp index 6dbcc0a8d60..eb275f5dabe 100644 --- a/mozilla/xpcom/io/nsLocalFileWin.cpp +++ b/mozilla/xpcom/io/nsLocalFileWin.cpp @@ -339,7 +339,7 @@ class nsDirEnumerator : public nsISimpleEnumerator *result = mNext; // might return nsnull NS_IF_ADDREF(*result); - + mNext = nsnull; return NS_OK; } @@ -1128,28 +1128,30 @@ nsLocalFile::CopyMove(nsIFile *aParentDir, const nsACString &newName, PRBool fol nsCOMPtr file; iterator->GetNext(getter_AddRefs(item)); file = do_QueryInterface(item); - PRBool isDir, isLink; + if (file) + { + PRBool isDir, isLink; - file->IsDirectory(&isDir); - file->IsSymlink(&isLink); - - if (move) - { - if (followSymlinks) - return NS_ERROR_FAILURE; - - rv = file->MoveToNative(target, nsCString()); - NS_ENSURE_SUCCESS(rv,rv); - } - else - { - if (followSymlinks) - rv = file->CopyToFollowingLinksNative(target, nsCString()); - else - rv = file->CopyToNative(target, nsCString()); - NS_ENSURE_SUCCESS(rv,rv); - } + file->IsDirectory(&isDir); + file->IsSymlink(&isLink); + + if (move) + { + if (followSymlinks) + return NS_ERROR_FAILURE; + rv = file->MoveToNative(target, nsCString()); + NS_ENSURE_SUCCESS(rv,rv); + } + else + { + if (followSymlinks) + rv = file->CopyToFollowingLinksNative(target, nsCString()); + else + rv = file->CopyToNative(target, nsCString()); + NS_ENSURE_SUCCESS(rv,rv); + } + } iterator->HasMoreElements(&more); } // we've finished moving all the children of this directory @@ -1267,8 +1269,8 @@ nsLocalFile::Remove(PRBool recursive) nsCOMPtr file; iterator->GetNext(getter_AddRefs(item)); file = do_QueryInterface(item); - - file->Remove(recursive); + if (file) + file->Remove(recursive); iterator->HasMoreElements(&more); } diff --git a/mozilla/xpcom/macbuild/XPCOMIDL.xml b/mozilla/xpcom/macbuild/XPCOMIDL.xml index 0c027761bb8..fee9618b364 100644 --- a/mozilla/xpcom/macbuild/XPCOMIDL.xml +++ b/mozilla/xpcom/macbuild/XPCOMIDL.xml @@ -976,13 +976,6 @@ Text - - Name - nsICategoryHandler.idl - MacOS - Text - - Name nsICategoryManager.idl @@ -1475,11 +1468,6 @@ nsIScriptableTimer.idl MacOS - - Name - nsICategoryHandler.idl - MacOS - Name nsICategoryManager.idl @@ -2655,13 +2643,6 @@ Text - - Name - nsICategoryHandler.idl - MacOS - Text - - Name nsICategoryManager.idl @@ -3154,11 +3135,6 @@ nsIScriptableTimer.idl MacOS - - Name - nsICategoryHandler.idl - MacOS - Name nsICategoryManager.idl @@ -3449,12 +3425,6 @@ nsIByteArrayInputStream.idl MacOS - - headers - Name - nsICategoryHandler.idl - MacOS - headers Name diff --git a/mozilla/xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.cpp b/mozilla/xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.cpp index 5066a7a7901..b7f3c796ae5 100644 --- a/mozilla/xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.cpp +++ b/mozilla/xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.cpp @@ -46,6 +46,7 @@ #include "nsIObserverService.h" #include "nsNetUtil.h" #include "nsICategoryManager.h" +#include "nsCategoryManagerUtils.h" #ifdef PR_LOGGING static PRLogModuleInfo *sLDAPAutoCompleteLogModule = 0;