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
This commit is contained in:
dougt%netscape.com 2002-07-18 05:09:10 +00:00
parent 9101286f0d
commit c2ec17237f
29 changed files with 211 additions and 227 deletions

View File

@ -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"

View File

@ -56,6 +56,8 @@ endif
# static lib.
FORCE_STATIC_LIB = 1
DEFINES += -DXPCOM_GLUE
include $(topsrcdir)/config/rules.mk
CXXFLAGS += $(MOZ_TOOLKIT_REGISTRY_CFLAGS)

View File

@ -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;
}

View File

@ -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)

View File

@ -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)

View File

@ -55,10 +55,11 @@
#include "nsIWindowWatcher.h"
#include "plstr.h"
#include "Preferences.h"
#include "nsCRT.h"
#include <io.h>
#include <fcntl.h>
#include "nsIComponentRegistrar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
@ -168,6 +169,12 @@ nsresult CMfcEmbedApp::OverrideComponents()
{
nsresult rv = NS_OK;
nsCOMPtr<nsIComponentRegistrar> 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<nsIFactory> 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<nsIFactory> 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<nsIFactory> 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;

View File

@ -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.

View File

@ -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;
}

View File

@ -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 <windows.h>
@ -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);

View File

@ -35,7 +35,6 @@
#include "nsILocalFile.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsCRT.h"
#include <windows.h>
@ -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))

View File

@ -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)

View File

@ -23,6 +23,7 @@
#include "nsHTMLEntities.h"
#include "nsElementTable.h"
#include "nsICategoryManager.h"
#include "nsCategoryManagerUtils.h"
nsParserService::nsParserService() : mEntries(0)
{

View File

@ -56,6 +56,7 @@
#include "nsIWindowWatcher.h"
#include "nsIDOMWindow.h"
#include "nsICategoryManager.h"
#include "nsCategoryManagerUtils.h"
class nsAbQueryLDAPMessageListener : public nsILDAPMessageListener
{

View File

@ -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);

View File

@ -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"

View File

@ -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"

View File

@ -23,6 +23,7 @@
#include "nsHTMLEntities.h"
#include "nsElementTable.h"
#include "nsICategoryManager.h"
#include "nsCategoryManagerUtils.h"
nsParserService::nsParserService() : mEntries(0)
{

View File

@ -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<nsIFactory> 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);

View File

@ -1,4 +1,3 @@
nsICategoryHandler.idl
nsICategoryManager.idl
nsIClassInfo.idl
nsIComponentLoader.idl

View File

@ -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))

View File

@ -47,7 +47,6 @@ EXPORTS = \
$(NULL)
XPIDLSRCS = \
.\nsICategoryHandler.idl \
.\nsICategoryManager.idl \
.\nsIClassInfo.idl \
.\nsIComponentLoader.idl \

View File

@ -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)

View File

@ -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} }

View File

@ -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:

View File

@ -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<nsIComponentManager> compMgr;
nsCOMPtr<nsICategoryManager> 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<nsICategoryManager> 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<nsICategoryManager> 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<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIProperties> 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),

View File

@ -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);
%}

View File

@ -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<nsIFile> 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<nsIFile> file;
iterator->GetNext(getter_AddRefs(item));
file = do_QueryInterface(item);
file->Remove(recursive);
if (file)
file->Remove(recursive);
iterator->HasMoreElements(&more);
}

View File

@ -976,13 +976,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsICategoryHandler.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsICategoryManager.idl</PATH>
@ -1475,11 +1468,6 @@
<PATH>nsIScriptableTimer.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsICategoryHandler.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsICategoryManager.idl</PATH>
@ -2655,13 +2643,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsICategoryHandler.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsICategoryManager.idl</PATH>
@ -3154,11 +3135,6 @@
<PATH>nsIScriptableTimer.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsICategoryHandler.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsICategoryManager.idl</PATH>
@ -3449,12 +3425,6 @@
<PATH>nsIByteArrayInputStream.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsICategoryHandler.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>

View File

@ -46,6 +46,7 @@
#include "nsIObserverService.h"
#include "nsNetUtil.h"
#include "nsICategoryManager.h"
#include "nsCategoryManagerUtils.h"
#ifdef PR_LOGGING
static PRLogModuleInfo *sLDAPAutoCompleteLogModule = 0;