1. Converts callers of nsIComponentManagerObsolete to use

nsIComponentRegistrar.

2. Converts callers of nsComponentManager::AutoRegister to use
nsIComponentRegistrar's autoRegistrar method.

3. Add nsIComponentRegistrar implmentation to nsComponentManagerImpl.

4. Rearrange nsComponentManager.cpp so that related methods are in the same
place.

5. Added a C-style function NS_GetComponentRegistrar so that getting the
registrar is easier in some places.

6. Added a nsISimpleEnumerator interface on PLDHashTableEnumeratorImpl.  in
this way, the same base class can support both old style and new style
enumerations.

7. Fixed a nasty bug where unregistring factories will leave the contract id
hash with a dangling pointer.  Now, when unregister is called we search the
contract id hash for entries which have the given doomned cid and remove them.


Bug 115853.  r=dp@netscape.com, sr=rpotts@netscape.com
This commit is contained in:
dougt%netscape.com 2002-01-29 21:22:13 +00:00
Родитель 166128cd69
Коммит c50ca402ad
76 изменённых файлов: 1470 добавлений и 1201 удалений

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsGenericHTMLElement.h"
#include "nsHTMLAtoms.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsICategoryManager.h"
#include "nsIDocumentLoader.h"
#include "nsIDocumentLoaderFactory.h"
@ -580,16 +581,16 @@ RegisterTypes(nsIComponentManager* aCompMgr,
#ifdef NOISY_REGISTRY
printf("Register %s => %s\n", contractid, aPath);
#endif
// what I want to do here is QI for a Component Registration Manager. Since this
// has not been invented yet, QI to the obsolete manager. Kids, don't do this at home.
nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(aCompMgr, &rv);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(aCompMgr, &rv);
if (NS_FAILED(rv))
return rv;
rv = obsoleteManager->RegisterComponentWithType(kDocumentFactoryImplCID, "Layout",
contractid, aPath, aLocation,
PR_TRUE, PR_TRUE, aType);
rv = registrar->RegisterFactoryLocation(kDocumentFactoryImplCID,
"Layout",
contractid,
aPath,
aLocation,
aType);
if (NS_FAILED(rv)) break;
// add the MIME types layotu can handle to the handlers category.
@ -657,15 +658,12 @@ nsContentDLF::UnregisterDocumentFactories(nsIComponentManager* aCompMgr,
const nsModuleComponentInfo* aInfo)
{
// XXXwaterson seems like this leaves the registry pretty dirty.
// what I want to do here is QI for a Component Registration Manager. Since this
// has not been invented yet, QI to the obsolete manager. Kids, don't do this at home.
nsresult rv;
nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(aCompMgr, &rv);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(aCompMgr, &rv);
if (NS_FAILED(rv))
return rv;
return obsoleteManager->UnregisterComponentSpec(kDocumentFactoryImplCID, aPath);
return registrar->UnregisterFactoryLocation(kDocumentFactoryImplCID, aPath);
}
/* static */ nsresult

Просмотреть файл

@ -1358,41 +1358,41 @@ var nsLDAPDataSourceModule = {
debug("*** Registering LDAP datasource components" +
" (all right -- a JavaScript module!)\n");
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponenRegistrar);
compMgr.registerComponentWithType(
compMgr.registerFactoryLocation(
NS_LDAPDATASOURCE_CID,
'LDAP RDF DataSource',
NS_LDAPDATASOURCE_CONTRACTID,
fileSpec, location, true, true,
fileSpec, location,
type);
compMgr.registerComponentWithType(
compMgr.registerFactoryLocation(
NS_LDAPMESSAGERDFDELEGATEFACTORY_CID,
'LDAP Message RDF Delegate',
NS_LDAPMESSAGERDFDELEGATEFACTORY_CONTRACTID,
fileSpec, location, true, true,
fileSpec, location,
type);
compMgr.registerComponentWithType(
compMgr.registerFactoryLocation(
NS_LDAPMESSAGERDFDELEGATEFACTORY_CID,
'LDAP Flat MessageList RDF Delegate',
NS_LDAPFLATMESSAGELISTRDFDELEGATEFACTORY_CONTRACTID,
fileSpec, location, true, true,
fileSpec, location,
type);
compMgr.registerComponentWithType(
compMgr.registerFactoryLocation(
NS_LDAPMESSAGERDFDELEGATEFACTORY_CID,
'LDAP Recursive MessageList RDF Delegate',
NS_LDAPRECURSIVEMESSAGELISTRDFDELEGATEFACTORY_CONTRACTID,
fileSpec, location, true, true,
fileSpec, location,
type);
compMgr.registerComponentWithType(
compMgr.registerFactoryLocation(
NS_LDAPURLRDFDELEGATEFACTORY_CID,
'LDAP URL RDF Delegate',
NS_LDAPURLRDFDELEGATEFACTORY_CONTRACTID,
fileSpec, location, true, true,
fileSpec, location,
type);
},

Просмотреть файл

@ -23,6 +23,7 @@
*/
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIEventQueueService.h"
#include "nsIAppStartupNotifier.h"
#include "nsIStringBundle.h"
@ -106,8 +107,15 @@ nsresult NS_InitEmbedding(nsILocalFile *mozBinDirectory,
// Register components
if (!sRegistryInitializedFlag)
{
rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
NULL /* default */);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(sServiceManager, &rv);
if (NS_FAILED(rv))
{
NS_ASSERTION(PR_FALSE, "Could not QI to registrar");
return rv;
}
rv = registrar->AutoRegister(nsnull);
if (NS_FAILED(rv))
{
NS_ASSERTION(PR_FALSE, "Could not AutoRegister");

Просмотреть файл

@ -591,16 +591,14 @@ var module = {
this.firstTime = false;
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
}
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerComponentWithType( this.cid,
"Mozilla Helper App Launcher Dialog",
this.contractId,
fileSpec,
location,
true,
true,
type );
compMgr.registerFactoryLocation( this.cid,
"Mozilla Helper App Launcher Dialog",
this.contractId,
fileSpec,
location,
type );
},
// getClassObject: Return this component's factory object.

Просмотреть файл

@ -282,12 +282,14 @@ function (compMgr, fileSpec, location, type)
{
dump("*** Registering -chat handler.\n");
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerComponentWithType(CLINE_SERVICE_CID,
"Chatzilla CommandLine Service",
CLINE_SERVICE_CONTRACTID, fileSpec,
location, true, true, type);
compMgr.registerFactoryLocation(CLINE_SERVICE_CID,
"Chatzilla CommandLine Service",
CLINE_SERVICE_CONTRACTID,
fileSpec,
location,
type);
catman = Components.classes["@mozilla.org/categorymanager;1"]
.getService(nsICategoryManager);
@ -296,16 +298,20 @@ function (compMgr, fileSpec, location, type)
CLINE_SERVICE_CONTRACTID, true, true);
dump("*** Registering x-application-irc handler.\n");
compMgr.registerComponentWithType(IRCCNT_HANDLER_CID,
"IRC Content Handler",
IRCCNT_HANDLER_CONTRACTID, fileSpec,
location, true, true, type);
compMgr.registerFactoryLocation(IRCCNT_HANDLER_CID,
"IRC Content Handler",
IRCCNT_HANDLER_CONTRACTID,
fileSpec,
location,
type);
dump("*** Registering irc protocol handler.\n");
compMgr.registerComponentWithType(IRCPROT_HANDLER_CID,
"IRC protocol handler",
IRCPROT_HANDLER_CONTRACTID, fileSpec, location,
true, true, type);
compMgr.registerFactoryLocation(IRCPROT_HANDLER_CID,
"IRC protocol handler",
IRCPROT_HANDLER_CONTRACTID,
fileSpec,
location,
type);
}
@ -313,9 +319,10 @@ ChatzillaModule.unregisterSelf =
function(compMgr, fileSpec, location)
{
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.unregisterComponentSpec(CLINE_SERVICE_CID, fileSpec);
compMgr.unregisterFactoryLocation(CLINE_SERVICE_CID,
fileSpec);
catman = Components.classes["@mozilla.org/categorymanager;1"]
.getService(nsICategoryManager);
catman.deleteCategoryEntry("command-line-argument-handlers",

Просмотреть файл

@ -77,12 +77,14 @@ function (compMgr, fileSpec, location, type)
{
dump("*** Registering -venkman handler.\n");
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerComponentWithType(CLINE_SERVICE_CID,
"Venkman CommandLine Service",
CLINE_SERVICE_CTRID, fileSpec,
location, true, true, type);
compMgr.registerFactoryLocation(CLINE_SERVICE_CID,
"Venkman CommandLine Service",
CLINE_SERVICE_CTRID,
fileSpec,
location,
type);
catman = Components.classes[CATMAN_CTRID].getService(nsICategoryManager);
catman.addCategoryEntry("command-line-argument-handlers",
@ -94,9 +96,9 @@ function (compMgr, fileSpec, location, type)
Module.unregisterSelf =
function(compMgr, fileSpec, location)
{
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.unregisterComponentSpec(CLINE_SERVICE_CID, fileSpec);
compMgr.unregisterFactoryLocation(CLINE_SERVICE_CID, fileSpec);
catman = Components.classes[CATMAN_CTRID].getService(nsICategoryManager);
catman.deleteCategoryEntry("command-line-argument-handlers",
CLINE_SERVICE_CTRID, true);

Просмотреть файл

@ -18,9 +18,9 @@
/*
* nsDictionary XPCOM component
* Version: $Revision: 1.5 $
* Version: $Revision: 1.6 $
*
* $Id: nsDictionary.js,v 1.5 2001/12/19 00:11:33 dougt%netscape.com Exp $
* $Id: nsDictionary.js,v 1.6 2002/01/29 21:21:33 dougt%netscape.com Exp $
*/
/*
@ -83,10 +83,13 @@ nsDictionary.prototype= {
/* nsDictionary Module (for XPCOM registration) */
var nsDictionaryModule = {
registerSelf: function(compMgr, fileSpec, location, type) {
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr.registerComponentWithType(DICTIONARY_CID,
"nsDictionary JS component", DICTIONARY_CONTRACTID, fileSpec, location,
true, true, type);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation(DICTIONARY_CID,
"nsDictionary JS component",
DICTIONARY_CONTRACTID,
fileSpec,
location,
type);
},
getClassObject: function(compMgr, cid, iid) {

Просмотреть файл

@ -20,9 +20,9 @@
/*
* nsXmlRpcClient XPCOM component
* Version: $Revision: 1.20 $
* Version: $Revision: 1.21 $
*
* $Id: nsXmlRpcClient.js,v 1.20 2002/01/24 22:31:28 heikki%netscape.com Exp $
* $Id: nsXmlRpcClient.js,v 1.21 2002/01/29 21:21:33 dougt%netscape.com Exp $
*/
/*
@ -1174,14 +1174,20 @@ PushbackInputStream.prototype = {
/* nsXmlRpcClient Module (for XPCOM registration) */
var nsXmlRpcClientModule = {
registerSelf: function(compMgr, fileSpec, location, type) {
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerComponentWithType(XMLRPCCLIENT_CID,
'XML-RPC Client JS component', XMLRPCCLIENT_CONTRACTID, fileSpec,
location, true, true, type);
compMgr.registerComponentWithType(XMLRPCFAULT_CID,
'XML-RPC Fault JS component', XMLRPCFAULT_CONTRACTID, fileSpec,
location, true, true, type);
compMgr.registerFactoryLocation(XMLRPCCLIENT_CID,
'XML-RPC Client JS component',
XMLRPCCLIENT_CONTRACTID,
fileSpec,
location,
type);
compMgr.registerFactoryLocation(XMLRPCFAULT_CID,
'XML-RPC Fault JS component',
XMLRPCFAULT_CONTRACTID,
fileSpec,
location,
type);
},
getClassObject: function(compMgr, cid, iid) {

Просмотреть файл

@ -324,12 +324,14 @@ function (compMgr, fileSpec, location, type)
{
dump("*** Registering -terminal handler.\n");
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerComponentWithType(XMLTERMCLINE_SERVICE_CID,
"XMLterm CommandLine Service",
XMLTERMCLINE_SERVICE_CONTRACTID, fileSpec,
location, true, true, type);
compMgr.registerFactoryLocation(XMLTERMCLINE_SERVICE_CID,
"XMLterm CommandLine Service",
XMLTERMCLINE_SERVICE_CONTRACTID,
fileSpec,
location,
type);
catman = Components.classes["@mozilla.org/categorymanager;1"]
.getService(nsICategoryManager);
@ -338,24 +340,28 @@ function (compMgr, fileSpec, location, type)
XMLTERMCLINE_SERVICE_CONTRACTID, true, true);
dump("*** Registering x-application-terminal handler.\n");
compMgr.registerComponentWithType(XMLTERMCNT_HANDLER_CID,
"XMLTerm Content Handler",
XMLTERMCNT_HANDLER_CONTRACTID, fileSpec,
location, true, true, type);
compMgr.registerFactoryLocation(XMLTERMCNT_HANDLER_CID,
"XMLTerm Content Handler",
XMLTERMCNT_HANDLER_CONTRACTID,
fileSpec,
location,
type);
dump("*** Registering terminal protocol handler.\n");
compMgr.registerComponentWithType(XMLTERMPROT_HANDLER_CID,
"XMLTerm protocol handler",
XMLTERMPROT_HANDLER_CONTRACTID, fileSpec, location,
true, true, type);
compMgr.registerFactoryLocation(XMLTERMPROT_HANDLER_CID,
"XMLTerm protocol handler",
XMLTERMPROT_HANDLER_CONTRACTID,
fileSpec,
location,
type);
}
XMLtermModule.unregisterSelf =
function(compMgr, fileSpec, location)
{
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr.unregisterComponentSpec(XMLTERMCLINE_SERVICE_CID, fileSpec);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.unregisterFactoryLocation(XMLTERMCLINE_SERVICE_CID, fileSpec);
catman = Components.classes["@mozilla.org/categorymanager;1"]
.getService(nsICategoryManager);
catman.deleteCategoryEntry("command-line-argument-handlers",

Просмотреть файл

@ -30,6 +30,8 @@
#include "nsLayoutCID.h"
#include "nsIHTMLToTextSink.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsReadableUtils.h"
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
@ -288,8 +290,12 @@ Usage: %s [-i intype] [-o outtype] [-f flags] [-w wrapcol] [-c comparison_file]
}
else file = stdin;
NS_InitXPCOM2(nsnull, nsnull, nsnull);
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, 0);
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// Read in the string: very inefficient, but who cares?
nsString inString;

Просмотреть файл

@ -48,6 +48,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsNetCID.h"
#include "nsIServiceManager.h"
@ -135,51 +136,18 @@ getUILangCountry(PRUnichar** aUILang, PRUnichar** aCountry)
return result;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// end of locale stuff
//
////////////////////////////////////////////////////////////////////////////////////////////////////
nsresult NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
NULL /* default */);
// startup netlib:
nsComponentManager::RegisterComponent(kEventQueueServiceCID,
NULL, NULL,
XPCOM_DLL,
PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kIOServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
// Create the Event Queue for this thread...
nsIEventQueueService* pEventQService;
pEventQService = nsnull;
nsresult result = nsServiceManager::GetService(kEventQueueServiceCID,
kIEventQueueServiceIID,
(nsISupports **)&pEventQService);
if (NS_SUCCEEDED(result)) {
// XXX: What if this fails?
result = pEventQService->CreateThreadEventQueue();
}
nsComponentManager::RegisterComponent(kPersistentPropertiesCID,
NULL,
NULL,
RAPTORBASE_DLL,
PR_FALSE,
PR_FALSE);
return rv;
}
int
main(int argc, char *argv[])
{
nsresult ret;
NS_AutoregisterComponents();
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
nsIStringBundleService* service = nsnull;
ret = nsServiceManager::GetService(kStringBundleServiceCID,
kIStringBundleServiceIID, (nsISupports**) &service);

Просмотреть файл

@ -45,6 +45,7 @@
#include "nsIXPCScriptable.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "jsapi.h"
#include "jsprf.h"
#include "nscore.h"
@ -78,13 +79,6 @@
/***************************************************************************/
static void SetupRegistry()
{
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull);
}
/***************************************************************************/
#ifdef JS_THREADSAFE
#define DoBeginRequest(cx) JS_BeginRequest((cx))
#define DoEndRequest(cx) JS_EndRequest((cx))
@ -834,13 +828,16 @@ main(int argc, char **argv)
gErrFile = stderr;
gOutFile = stdout;
rv = NS_InitXPCOM2(NULL, NULL, NULL);
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
if (NS_FAILED(rv)) {
printf("NS_InitXPCOM failed!\n");
return 1;
}
SetupRegistry();
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
nsCOMPtr<nsIJSRuntimeService> rtsvc = do_GetService("@mozilla.org/js/xpc/RuntimeService;1");
// get the JSRuntime from the runtime svc

Просмотреть файл

@ -363,17 +363,15 @@ nsXPCComponents_Classes::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
PRUint32 enum_op, jsval * statep,
jsid * idp, PRBool *_retval)
{
nsIEnumerator* e;
nsISimpleEnumerator* e;
switch(enum_op)
{
case JSENUMERATE_INIT:
{
nsIComponentManagerObsolete* compMgr;
if(NS_FAILED(NS_GetGlobalComponentManager((nsIComponentManager**)&compMgr)) ||
!compMgr || NS_FAILED(compMgr->EnumerateContractIDs(&e)) || !e ||
NS_FAILED(e->First()))
nsCOMPtr<nsIComponentRegistrar> compMgr;
if(NS_FAILED(NS_GetComponentRegistrar(getter_AddRefs(compMgr))) || !compMgr ||
NS_FAILED(compMgr->EnumerateContractIDs(&e)) || !e )
{
*statep = JSVAL_NULL;
return NS_ERROR_UNEXPECTED;
@ -387,12 +385,12 @@ nsXPCComponents_Classes::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
case JSENUMERATE_NEXT:
{
nsCOMPtr<nsISupports> isup;
e = (nsIEnumerator*) JSVAL_TO_PRIVATE(*statep);
if(NS_COMFALSE == e->IsDone() &&
NS_SUCCEEDED(e->CurrentItem(getter_AddRefs(isup))) && isup)
PRBool hasMore;
e = (nsISimpleEnumerator*) JSVAL_TO_PRIVATE(*statep);
if(NS_SUCCEEDED(e->HasMoreElements(&hasMore)) && hasMore &&
NS_SUCCEEDED(e->GetNext(getter_AddRefs(isup))) && isup)
{
e->Next();
nsCOMPtr<nsISupportsString> holder(do_QueryInterface(isup));
if(holder)
{
@ -414,7 +412,7 @@ nsXPCComponents_Classes::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
case JSENUMERATE_DESTROY:
default:
e = (nsIEnumerator*) JSVAL_TO_PRIVATE(*statep);
e = (nsISimpleEnumerator*) JSVAL_TO_PRIVATE(*statep);
NS_IF_RELEASE(e);
*statep = JSVAL_NULL;
return NS_OK;
@ -523,17 +521,15 @@ nsXPCComponents_ClassesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
PRUint32 enum_op, jsval * statep,
jsid * idp, PRBool *_retval)
{
nsIEnumerator* e;
nsISimpleEnumerator* e;
switch(enum_op)
{
case JSENUMERATE_INIT:
{
nsIComponentManagerObsolete* compMgr;
if(NS_FAILED(NS_GetGlobalComponentManager((nsIComponentManager**)&compMgr)) ||
!compMgr || NS_FAILED(compMgr->EnumerateCLSIDs(&e)) || !e ||
NS_FAILED(e->First()))
nsCOMPtr<nsIComponentRegistrar> compMgr;
if(NS_FAILED(NS_GetComponentRegistrar(getter_AddRefs(compMgr))) || !compMgr ||
NS_FAILED(compMgr->EnumerateCIDs(&e)) || !e )
{
*statep = JSVAL_NULL;
return NS_ERROR_UNEXPECTED;
@ -547,12 +543,12 @@ nsXPCComponents_ClassesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
case JSENUMERATE_NEXT:
{
nsCOMPtr<nsISupports> isup;
PRBool hasMore;
e = (nsISimpleEnumerator*) JSVAL_TO_PRIVATE(*statep);
e = (nsIEnumerator*) JSVAL_TO_PRIVATE(*statep);
if(NS_COMFALSE == e->IsDone() &&
NS_SUCCEEDED(e->CurrentItem(getter_AddRefs(isup))) && isup)
if(NS_SUCCEEDED(e->HasMoreElements(&hasMore)) && hasMore &&
NS_SUCCEEDED(e->GetNext(getter_AddRefs(isup))) && isup)
{
e->Next();
nsCOMPtr<nsISupportsID> holder(do_QueryInterface(isup));
if(holder)
{
@ -574,7 +570,7 @@ nsXPCComponents_ClassesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
case JSENUMERATE_DESTROY:
default:
e = (nsIEnumerator*) JSVAL_TO_PRIVATE(*statep);
e = (nsISimpleEnumerator*) JSVAL_TO_PRIVATE(*statep);
NS_IF_RELEASE(e);
*statep = JSVAL_NULL;
return NS_OK;
@ -590,9 +586,9 @@ IsRegisteredCLSID(const char* str)
if(!id.Parse(str))
return PR_FALSE;
nsIComponentManagerObsolete* compMgr;
if(NS_FAILED(NS_GetGlobalComponentManager((nsIComponentManager**)&compMgr)) ||
!compMgr || NS_FAILED(compMgr->IsRegistered(id, &registered)))
nsCOMPtr<nsIComponentRegistrar> compMgr;
if(NS_FAILED(NS_GetComponentRegistrar(getter_AddRefs(compMgr))) || !compMgr ||
NS_FAILED(compMgr->IsCIDRegistered(id, &registered)))
return PR_FALSE;
return registered;

Просмотреть файл

@ -45,10 +45,12 @@
#include <stdarg.h>
#include <math.h>
#include "nscore.h"
#include "nsXPCOM.h"
#include "nsISupports.h"
#include "nsIServiceManager.h"
#include "nsIClassInfo.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsISupportsPrimitives.h"
#include "nsIGenericFactory.h"
#include "nsMemory.h"

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsIScriptError.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIJSContextStack.h"
#include "nsIJSRuntimeService.h"
#include "nsMemory.h"
@ -54,14 +55,6 @@
#include "xpctest.h"
/***************************************************************************/
// initialization stuff for the xpcom runtime
static void SetupRegistry()
{
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull);
}
/***************************************************************************/
// host support for jsengine
@ -713,8 +706,12 @@ int main()
gErrFile = stderr;
gOutFile = stdout;
SetupRegistry();
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// get the JSRuntime from the runtime svc, if possible
nsCOMPtr<nsIJSRuntimeService> rtsvc =
do_GetService("@mozilla.org/js/xpc/RuntimeService;1", &rv);

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsGenericHTMLElement.h"
#include "nsHTMLAtoms.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsICategoryManager.h"
#include "nsIDocumentLoader.h"
#include "nsIDocumentLoaderFactory.h"
@ -580,16 +581,16 @@ RegisterTypes(nsIComponentManager* aCompMgr,
#ifdef NOISY_REGISTRY
printf("Register %s => %s\n", contractid, aPath);
#endif
// what I want to do here is QI for a Component Registration Manager. Since this
// has not been invented yet, QI to the obsolete manager. Kids, don't do this at home.
nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(aCompMgr, &rv);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(aCompMgr, &rv);
if (NS_FAILED(rv))
return rv;
rv = obsoleteManager->RegisterComponentWithType(kDocumentFactoryImplCID, "Layout",
contractid, aPath, aLocation,
PR_TRUE, PR_TRUE, aType);
rv = registrar->RegisterFactoryLocation(kDocumentFactoryImplCID,
"Layout",
contractid,
aPath,
aLocation,
aType);
if (NS_FAILED(rv)) break;
// add the MIME types layotu can handle to the handlers category.
@ -657,15 +658,12 @@ nsContentDLF::UnregisterDocumentFactories(nsIComponentManager* aCompMgr,
const nsModuleComponentInfo* aInfo)
{
// XXXwaterson seems like this leaves the registry pretty dirty.
// what I want to do here is QI for a Component Registration Manager. Since this
// has not been invented yet, QI to the obsolete manager. Kids, don't do this at home.
nsresult rv;
nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(aCompMgr, &rv);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(aCompMgr, &rv);
if (NS_FAILED(rv))
return rv;
return obsoleteManager->UnregisterComponentSpec(kDocumentFactoryImplCID, aPath);
return registrar->UnregisterFactoryLocation(kDocumentFactoryImplCID, aPath);
}
/* static */ nsresult

Просмотреть файл

@ -533,13 +533,16 @@ NS_IMETHODIMP nsAbView::PerformActionOnCell(const PRUnichar *action, PRInt32 row
NS_IMETHODIMP nsAbView::GetCardFromRow(PRInt32 row, nsIAbCard **aCard)
{
if ((mCards.Count() <= row) || (row < 0)) {
*aCard = nsnull;
*aCard = nsnull;
if ((mCards.Count() <= row) || (row < 0)) {
return NS_OK;
}
*aCard = ((AbCard *)(mCards.ElementAt(row)))->card;
NS_IF_ADDREF(*aCard);
AbCard *a = ((AbCard *)(mCards.ElementAt(row)));
if (!a)
return NS_OK;
NS_IF_ADDREF(*aCard = a->card);
return NS_OK;
}

Просмотреть файл

@ -278,19 +278,21 @@ var nsLDAPPrefsModule = new Object();
nsLDAPPrefsModule.registerSelf =
function (compMgr, fileSpec, location, type)
{
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerComponentWithType(NS_LDAPPREFSSERVICE_CID,
"nsLDAPPrefs Service",
NS_LDAPPREFSSERVICE_CONTRACTID, fileSpec,
location, true, true, type);
compMgr.registerFactoryLocation(NS_LDAPPREFSSERVICE_CID,
"nsLDAPPrefs Service",
NS_LDAPPREFSSERVICE_CONTRACTID,
fileSpec,
location,
type);
}
nsLDAPPrefsModule.unregisterSelf =
function(compMgr, fileSpec, location)
{
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr.unregisterComponentSpec(NS_LDAPPREFSSERVICE_CID, fileSpec);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.unregisterFactoryLocation(NS_LDAPPREFSSERVICE_CID, fileSpec);
}
nsLDAPPrefsModule.getClassObject =

Просмотреть файл

@ -66,11 +66,13 @@ SMIMEModule.registerSelf =
function (compMgr, fileSpec, location, type)
{
dump("*** Registering smime account manager extension.\n");
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr.registerComponentWithType(SMIME_EXTENSION_SERVICE_CID,
"SMIME Account Manager Extension Service",
SMIME_EXTENSION_SERVICE_CONTRACTID, fileSpec,
location, true, true, type);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation(SMIME_EXTENSION_SERVICE_CID,
"SMIME Account Manager Extension Service",
SMIME_EXTENSION_SERVICE_CONTRACTID,
fileSpec,
location,
type);
catman = Components.classes["@mozilla.org/categorymanager;1"].getService(nsICategoryManager);
catman.addCategoryEntry("mailnews-accountmanager-extensions",
"smime account manager extension",
@ -80,8 +82,8 @@ function (compMgr, fileSpec, location, type)
SMIMEModule.unregisterSelf =
function(compMgr, fileSpec, location)
{
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr.unregisterComponentSpec(SMIME_EXTENSION_SERVICE_CID, fileSpec);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.unregisterFactoryLocation(SMIME_EXTENSION_SERVICE_CID, fileSpec);
catman = Components.classes["@mozilla.org/categorymanager;1"].getService(nsICategoryManager);
catman.deleteCategoryEntry("mailnews-accountmanager-extensions",
SMIME_EXTENSION_SERVICE_CONTRACTID, true);

Просмотреть файл

@ -86,7 +86,7 @@
#include "nsHashtable.h"
#include "nsIProxyInfo.h"
#include "nsObsoleteModuleLoading.h"
#include "nsIComponentRegistrar.h"
#include "nsPluginLogging.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
@ -2639,10 +2639,18 @@ nsresult nsPluginHostImpl::ReloadPlugins(PRBool reloadPages)
mPluginsLoaded = PR_FALSE;
//refresh the component registry first
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull);
nsCOMPtr<nsIServiceManager> servManager;
NS_GetServiceManager(getter_AddRefs(servManager));
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servManager);
if (!registrar) {
NS_ASSERTION(0, "No nsIComponentRegistrar from get service");
return NS_ERROR_FAILURE;
}
NS_ASSERTION(registrar, "No nsIComponentRegistrar from get service");
nsresult rv = registrar->AutoRegister(nsnull);
// load them again
nsresult rv = LoadPlugins();
rv = LoadPlugins();
PLUGIN_LOG(PLUGIN_LOG_NORMAL,
("nsPluginHostImpl::ReloadPlugins End active_instance_count=%d\n",

Просмотреть файл

@ -67,12 +67,13 @@ var filterModule = new Object();
filterModule.registerSelf =
function (compMgr, fileSpec, location, type) {
dump("*** Registering Web Filters (a Javascript module!)\n");
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerComponentWithType(kFILTERS_CID,
"Javascript Web Filters",
kFILTERS_CONTRACTID,
fileSpec, location,
true, true, type);
"Javascript Web Filters",
kFILTERS_CONTRACTID,
fileSpec,
location,
type);
}
filterModule.getClassObject =

Просмотреть файл

@ -188,12 +188,13 @@ var pacModule = new Object();
pacModule.registerSelf =
function (compMgr, fileSpec, location, type) {
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr.registerComponentWithType(kPAC_CID,
"Proxy Auto Config",
kPAC_CONTRACTID,
fileSpec, location,
true, true, type);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation(kPAC_CID,
"Proxy Auto Config",
kPAC_CONTRACTID,
fileSpec,
location,
type);
}
pacModule.getClassObject =

Просмотреть файл

@ -50,7 +50,7 @@
#include "nsIEventQueue.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIStreamListener.h"
#include "nsIInputStream.h"
#include "nsINetService.h"
@ -252,8 +252,12 @@ int main(int argc, char **argv)
return 0;
}
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, "./components");
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
testURL(argv[1]);
return 0;
#if 0

Просмотреть файл

@ -37,6 +37,7 @@
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIStreamConverterService.h"
#include "nsIStreamConverter.h"
#include "nsICategoryManager.h"
@ -139,7 +140,12 @@ int
main(int argc, char* argv[])
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// Create the Event Queue for this thread...
nsCOMPtr<nsIEventQueueService> eventQService =
do_GetService(kEventQueueServiceCID, &rv);
@ -150,9 +156,6 @@ main(int argc, char* argv[])
eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsICategoryManager> catman =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -18,11 +18,12 @@
#include "nsDirectoryServiceDefs.h"
#include "nsError.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIFile.h"
#include "nsILocalFile.h"
#include "nsIFileStreams.h"
#include "nsMemory.h"
#include "nsIComponentRegistrar.h"
#include "nsANSIFileStreams.h"
#include "nsDiskCacheBlockFile.h"
@ -212,12 +213,11 @@ main(void)
nsresult rv = NS_OK;
// Start up XPCOM
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
// Register components
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull);
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// Get default directory
rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,

Просмотреть файл

@ -19,6 +19,7 @@
#include "nsIStreamListener.h"
#include "nsIRequestObserver.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsIEventQueue.h"
@ -542,13 +543,6 @@ FillCache(nsINetDataCacheManager *aCache, PRUint32 aFlags, PRUint32 aCacheCapaci
return NS_OK;
}
nsresult NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
NULL /* default */);
return rv;
}
nsresult
Test(nsINetDataCacheManager *aCache, PRUint32 aFlags, PRUint32 aCacheCapacity)
{
@ -583,8 +577,13 @@ main(int argc, char* argv[])
nsresult rv;
nsCOMPtr<nsINetDataCacheManager> cache;
rv = NS_AutoregisterComponents();
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't register XPCOM components");
// Start up XPCOM
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
rv = nsComponentManager::CreateInstance(NS_NETWORK_CACHE_MANAGER_CONTRACTID,
nsnull,

Просмотреть файл

@ -38,6 +38,7 @@
#include "nsIFileTransportService.h"
#include "nsIStreamListener.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIInputStream.h"
#include "nsIEventQueue.h"
#include "nsIEventQueueService.h"
@ -393,12 +394,6 @@ ParallelReadTest(char* dirName, nsIFileTransportService* fts)
NS_ASSERTION(status == PR_SUCCESS, "can't close dir");
}
nsresult NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */);
return rv;
}
int
main(int argc, char* argv[])
{
@ -410,8 +405,12 @@ main(int argc, char* argv[])
}
char* dirName = argv[1];
rv = NS_AutoregisterComponents();
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
nsCOMPtr<nsIFileTransportService> fts =
do_GetService(kFileTransportServiceCID, &rv);

Просмотреть файл

@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsIRunnable.h"
@ -443,12 +444,6 @@ Test(CreateFun create, PRUint32 count,
////////////////////////////////////////////////////////////////////////////////
nsresult NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */);
return rv;
}
int
main(int argc, char* argv[])
{
@ -461,8 +456,12 @@ main(int argc, char* argv[])
char* inDir = argv[1];
char* outDir = argv[2];
rv = NS_AutoregisterComponents();
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
nsCOMPtr<nsILocalFile> inDirFile;
rv = NS_NewLocalFile(inDir, PR_FALSE, getter_AddRefs(inDirFile));

Просмотреть файл

@ -35,6 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsIComponentRegistrar.h"
#include "nsIFileTransportService.h"
#include "nsITransport.h"
#include "nsIProgressEventSink.h"
@ -339,12 +340,6 @@ NS_IMPL_ISUPPORTS1(MyOpenObserver, nsIRequestObserver);
////////////////////////////////////////////////////////////////////////////////
nsresult
NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */);
return rv;
}
int
main(int argc, char* argv[])
@ -361,8 +356,11 @@ main(int argc, char* argv[])
}
char* fileName = argv[1];
rv = NS_AutoregisterComponents();
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
nsCOMPtr<nsIEventQueueService> eventQService =
do_GetService(kEventQueueServiceCID, &rv);

Просмотреть файл

@ -1,6 +1,7 @@
#include "nsNetUtil.h"
#include "nsIEventQueueService.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIProgressEventSink.h"
@ -124,11 +125,6 @@ MyNotifications::OnProgress(nsIRequest *req, nsISupports *ctx,
// main, etc..
//-----------------------------------------------------------------------------
nsresult NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */);
return rv;
}
int main(int argc, char **argv)
{
@ -139,8 +135,11 @@ int main(int argc, char **argv)
return -1;
}
rv = NS_AutoregisterComponents();
RETURN_IF_FAILED(rv, "NS_AutoregisterComponents");
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// Create the Event Queue for this thread...
nsCOMPtr<nsIEventQueueService> eqs =

Просмотреть файл

@ -40,16 +40,11 @@
#include "nsCOMPtr.h"
#include "nsIIOService.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIURI.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
nsresult NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */);
return rv;
}
nsresult ServiceMakeAbsolute(nsIURI *baseURI, char *relativeInfo, char **_retval) {
nsresult rv;
nsCOMPtr<nsIIOService> serv(do_GetService(kIOServiceCID, &rv));
@ -75,8 +70,11 @@ main(int argc, char* argv[])
char *base = argv[2];
char *rel = argv[3];
rv = NS_AutoregisterComponents();
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
nsCOMPtr<nsIIOService> serv(do_GetService(kIOServiceCID, &rv));
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -50,7 +50,7 @@
#include "nsSupportsArray.h"
#include <fstream.h>
#include "nsReadableUtils.h"
#include "nsIComponentRegistrar.h"
int getStrLine(const char *src, char *str, int ind, int max);
nsresult auxLoad(char *uriBuf);
//----------------------------------------------------------------------
@ -265,13 +265,6 @@ MyNotifications::OnProgress(nsIRequest *req, nsISupports *ctx,
// main, etc..
//-----------------------------------------------------------------------------
nsresult NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */);
return rv;
}
//---------getStrLine Helper function---------------
//Finds a newline in src starting at ind. Puts the
//line in str (must be big enough). Returns the index
@ -361,14 +354,17 @@ int main(int argc, char **argv)
return -1;
}
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
PRTime start, finish;
rv = NS_NewISupportsArray(getter_AddRefs(uriList));
RETURN_IF_FAILED(rv, "NS_NewISupportsArray");
rv = NS_AutoregisterComponents();
RETURN_IF_FAILED(rv, "NS_AutoregisterComponents");
// Create the Event Queue for this thread...
nsCOMPtr<nsIEventQueueService> eqs =
do_GetService(kEventQueueServiceCID, &rv);

Просмотреть файл

@ -2,6 +2,7 @@
#include "nsNetUtil.h"
#include "nsIEventQueueService.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsISupportsArray.h"
static nsIIOService *gIOService = nsnull;
@ -227,8 +228,11 @@ main(int argc, char **argv)
return -1;
}
rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL);
if (NS_FAILED(rv)) return -1;
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// cache the io service
{

Просмотреть файл

@ -18,6 +18,7 @@
#include "nsIStreamListener.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsIEventQueue.h"
@ -683,13 +684,6 @@ FillCache(nsINetDataCache *cache)
return NS_OK;
}
nsresult NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
NULL /* default */);
return rv;
}
PRBool initPref ()
{
nsresult rv;
@ -733,8 +727,12 @@ main(int argc, char* argv[])
nsCOMPtr<nsINetDataCache> cache;
rv = NS_AutoregisterComponents();
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't register XPCOM components");
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
if (PL_strcasecmp(argv[1], "-m") == 0) {
rv = nsComponentManager::CreateInstance(kMemCacheCID, nsnull,

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsIIOService.h"
#include "nsIInputStream.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIStreamListener.h"
#include "nsIEventQueueService.h"
#include "nsIURI.h"
@ -240,22 +241,17 @@ TestAsyncRead(const char* url)
return rv;
}
////////////////////////////////////////////////////////////////////////////////
nsresult
NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
NULL /* default */);
return rv;
}
int
main(int argc, char* argv[])
{
nsresult rv;
rv = NS_AutoregisterComponents();
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "AutoregisterComponents failed");
if (argc < 2) {

Просмотреть файл

@ -48,6 +48,7 @@
#include "nsISocketTransportService.h"
#include "nsIEventQueueService.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsITransport.h"
#include "nsIRequest.h"
#include "nsIStreamListener.h"
@ -134,12 +135,6 @@ InputTestConsumer::OnStopRequest(nsIRequest *request, nsISupports* context,
}
nsresult NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */);
return rv;
}
int
main(int argc, char* argv[])
{
@ -157,8 +152,11 @@ main(int argc, char* argv[])
//port = portString.ToInteger(&rv);
port = 13;
rv = NS_AutoregisterComponents();
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// Create the Event Queue for this thread...
nsCOMPtr<nsIEventQueueService> eventQService =

Просмотреть файл

@ -54,6 +54,7 @@
#include "nsISocketTransportService.h"
#include "nsIEventQueueService.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIRequestObserver.h"
#include "nsIStreamListener.h"
#include "nsIPipe.h"
@ -579,13 +580,6 @@ void TimerCallback(nsITimer* aTimer, void* aClosure)
#endif /* USE_TIMERS */
nsresult NS_AutoregisterComponents();
nsresult NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */);
return rv;
}
int
main(int argc, char* argv[])
{
@ -636,8 +630,11 @@ main(int argc, char* argv[])
//
// -----
rv = NS_AutoregisterComponents();
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// Create the Event Queue for this thread...
nsCOMPtr<nsIEventQueueService> eventQService =

Просмотреть файл

@ -39,6 +39,7 @@
#include <windows.h>
#endif
#include "nsIComponentRegistrar.h"
#include "nsIEventQueueService.h"
#include "nsIIOService.h"
#include "nsIServiceManager.h"
@ -53,12 +54,6 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static int gKeepRunning = 1;
static nsIEventQueue* gEventQ = nsnull;
nsresult NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */);
return rv;
}
//-----------------------------------------------------------------------------
// InputTestConsumer
//-----------------------------------------------------------------------------
@ -138,10 +133,12 @@ main(int argc, char* argv[])
char* uriSpec = argv[1];
char* fileName = argv[2];
rv = NS_AutoregisterComponents();
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// Create the Event Queue for this thread...
nsCOMPtr<nsIEventQueueService> eventQService =

Просмотреть файл

@ -49,7 +49,7 @@
#include "nsIEventQueue.h"
#include "nsILocalFile.h"
#include "plhash.h"
#include "nsIComponentRegistrar.h"
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
@ -193,14 +193,6 @@ TestSyncWrites(char* filenamePrefix, PRUint32 startPosition, PRInt32 length)
}
////////////////////////////////////////////////////////////////////////////////
nsresult
NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */);
return rv;
}
int
main(int argc, char* argv[])
{
@ -213,8 +205,11 @@ main(int argc, char* argv[])
char* fileName = argv[1];
int length = atoi(argv[2]);
rv = NS_AutoregisterComponents();
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
rv = TestSyncWrites(fileName, 0, length);
NS_ASSERTION(NS_SUCCEEDED(rv), "TestAsyncRead failed");

Просмотреть файл

@ -55,6 +55,7 @@
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsNetCID.h"
#include "nsIComponentRegistrar.h"
// Define CIDs...
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
@ -393,12 +394,6 @@ int doMakeAbsTest(const char* i_URL = 0, const char* i_relativePortion=0)
}
}
nsresult NS_AutoregisterComponents()
{
nsresult rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL /* default */);
return rv;
}
void printusage(void)
{
cout << "urltest [-std] [-file <filename>] <URL> " <<
@ -422,8 +417,11 @@ int main(int argc, char **argv)
return NS_OK;
}
result = NS_AutoregisterComponents();
if (NS_FAILED(result)) return result;
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// end of all messages from register components...
cout << "------------------" << endl << endl;

Просмотреть файл

@ -30,6 +30,8 @@
#include "nsLayoutCID.h"
#include "nsIHTMLToTextSink.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsReadableUtils.h"
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
@ -288,8 +290,12 @@ Usage: %s [-i intype] [-o outtype] [-f flags] [-w wrapcol] [-c comparison_file]
}
else file = stdin;
NS_InitXPCOM2(nsnull, nsnull, nsnull);
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, 0);
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// Read in the string: very inefficient, but who cares?
nsString inString;

Просмотреть файл

@ -56,6 +56,7 @@
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIServiceManager.h"
#include "nsIEventQueueService.h"
#include "nsIInterfaceRequestor.h"
@ -255,13 +256,17 @@ nsresult
nsViewerApp::SetupRegistry()
{
nsresult rv;
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
NULL /* default */);
nsCOMPtr<nsIServiceManager> servManager;
NS_GetServiceManager(getter_AddRefs(servManager));
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servManager);
NS_ASSERTION(registrar, "No nsIComponentRegistrar from get service. see dougt");
rv = registrar->AutoRegister(nsnull);
// Register our browser window factory
nsIFactory* bwf;
NS_NewXPBaseWindowFactory(&bwf);
nsComponentManager::RegisterFactory(kXPBaseWindowCID, 0, 0, bwf, PR_FALSE);
registrar->RegisterFactory(kXPBaseWindowCID, 0, 0, bwf);
NS_RELEASE(bwf);
// register the cookie manager

Просмотреть файл

@ -41,6 +41,7 @@
#include "nscore.h"
class nsIComponentManager;
class nsIComponentRegistrar;
class nsIServiceManager;
class nsIFile;
class nsIDirectoryServiceProvider;
@ -124,6 +125,19 @@ NS_GetServiceManager(nsIServiceManager* *result);
extern "C" NS_COM nsresult
NS_GetComponentManager(nsIComponentManager* *result);
/**
* Public Method to access to the component registration manager.
*
* @status FROZEN
* @param result Interface pointer to the service
*
* @return NS_OK for success;
* other error codes indicate a failure during initialisation.
*
*/
extern "C" NS_COM nsresult
NS_GetComponentRegistrar(nsIComponentRegistrar* *result);
/**
* Public Method to access to the memory manager. See nsIMemory
*

Просмотреть файл

@ -185,10 +185,12 @@ RegisterGenericFactory(nsIComponentManager* compMgr,
// what I want to do here is QI for a Component Registration Manager. Since this
// has not been invented yet, QI to the obsolete manager. Kids, don't do this at home.
nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(compMgr, &rv);
if (obsoleteManager)
rv = obsoleteManager->RegisterFactory(info->mCID, info->mDescription,
info->mContractID, fact, PR_TRUE);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(compMgr, &rv);
if (registrar)
rv = registrar->RegisterFactory(info->mCID,
info->mDescription,
info->mContractID,
fact);
NS_RELEASE(fact);
return rv;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -43,6 +43,7 @@
#include "nsIComponentLoader.h"
#include "nsNativeComponentLoader.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIComponentManagerObsolete.h"
#include "nsIServiceManager.h"
#include "nsIFactory.h"
@ -84,6 +85,7 @@ extern const char XPCOM_LIB_PREFIX[];
class nsComponentManagerImpl
: public nsIComponentManager,
public nsIServiceManager,
public nsIComponentRegistrar,
public nsSupportsWeakReference,
public nsIInterfaceRequestor,
public nsIServiceManagerObsolete,
@ -94,7 +96,7 @@ public:
NS_DECL_NSIINTERFACEREQUESTOR
// Since the nsIComponentManagerObsolete and nsIComponentManager share some of the
// same interface function name, we have to manually define the functions here.
// same interface function names, we have to manually define the functions here.
// The only function that is in nsIComponentManagerObsolete and is in nsIComponentManager
// is GetClassObjectContractID.
//
@ -103,39 +105,27 @@ public:
const nsIID &aIID,
void **_retval);
NS_DECL_NSICOMPONENTMANAGEROBSOLETE
NS_DECL_NSISERVICEMANAGER
// Since the nsIComponentManagerObsolete and nsIComponentRegistrar share some of the
// same interface function names, we have to manually define the functions here.
// the only fuction that is shared is UnregisterFactory
NS_IMETHOD AutoRegister(nsIFile *aSpec);
NS_IMETHOD AutoUnregister(nsIFile *aSpec);
NS_IMETHOD RegisterFactory(const nsCID & aClass, const char *aClassName, const char *aContractID, nsIFactory *aFactory);
// NS_IMETHOD UnregisterFactory(const nsCID & aClass, nsIFactory *aFactory);
NS_IMETHOD RegisterFactoryLocation(const nsCID & aClass, const char *aClassName, const char *aContractID, nsIFile *aFile, const char *loaderStr, const char *aType);
NS_IMETHOD UnregisterFactoryLocation(const nsCID & aClass, nsIFile *aFile);
NS_IMETHOD IsCIDRegistered(const nsCID & aClass, PRBool *_retval);
NS_IMETHOD IsContractIDRegistered(const char *aClass, PRBool *_retval);
NS_IMETHOD EnumerateCIDs(nsISimpleEnumerator **_retval);
NS_IMETHOD EnumerateContractIDs(nsISimpleEnumerator **_retval);
NS_IMETHOD CIDToContractID(const nsCID & aClass, char **_retval);
NS_IMETHOD ContractIDToCID(const char *aContractID, nsCID * *_retval);
// nsIServiceManagerObsolete
NS_IMETHOD
RegisterService(const nsCID& aClass, nsISupports* aService);
NS_IMETHOD
UnregisterService(const nsCID& aClass);
NS_IMETHOD
GetService(const nsCID& aClass, const nsIID& aIID,
nsISupports* *result,
nsIShutdownListener* shutdownListener);
NS_IMETHOD
ReleaseService(const nsCID& aClass, nsISupports* service,
nsIShutdownListener* shutdownListener);
NS_IMETHOD
RegisterService(const char* aContractID, nsISupports* aService);
NS_IMETHOD
UnregisterService(const char* aContractID);
NS_IMETHOD
GetService(const char* aContractID, const nsIID& aIID,
nsISupports* *result,
nsIShutdownListener* shutdownListener);
NS_IMETHOD
ReleaseService(const char* aContractID, nsISupports* service,
nsIShutdownListener* shutdownListener);
NS_DECL_NSISERVICEMANAGER
NS_DECL_NSISERVICEMANAGEROBSOLETE
// nsComponentManagerImpl methods:
nsComponentManagerImpl();
@ -181,6 +171,10 @@ protected:
nsresult HashContractID(const char *acontractID, nsFactoryEntry *fe_ptr);
nsresult HashContractID(const char *acontractID, const nsCID &aClass, nsFactoryEntry **fe_ptr = NULL);
nsresult HashContractID(const char *acontractID, const nsCID &aClass, nsIDKey &cidKey, nsFactoryEntry **fe_ptr = NULL);
void DeleteContractIDEntriesByCID(const nsCID* aClass, const char*registryName);
void DeleteContractIDEntriesByCID(const nsCID* aClass, nsIFactory* factory);
nsresult UnloadLibraries(nsIServiceManager *servmgr, PRInt32 when);
// The following functions are the only ones that operate on the persistent
@ -204,7 +198,7 @@ protected:
int AddLoaderType(const char *typeStr);
private:
nsresult AutoRegisterImpl(PRInt32 when, nsIFile *inDirSpec);
nsresult AutoRegisterImpl(PRInt32 when, nsIFile *inDirSpec, PRBool fileIsCompDir=PR_TRUE);
protected:
PLDHashTable mFactories;

Просмотреть файл

@ -43,7 +43,7 @@
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsIComponentManager.h"
#include "nsIComponentManagerObsolete.h"
#include "nsIComponentRegistrar.h"
nsGenericFactory::nsGenericFactory(nsModuleComponentInfo *info)
: mInfo(info)
{
@ -358,15 +358,14 @@ nsGenericModule::RegisterSelf(nsIComponentManager *aCompMgr,
for (PRUint32 i = 0; i < mComponentCount; i++) {
// Register the component only if it has a constructor
if (cp->mConstructor) {
// what I want to do here is QI for a Component Registration Manager. Since this
// has not been invented yet, QI to the obsolete manager. Kids, don't do this at home.
nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(aCompMgr, &rv);
if (obsoleteManager)
rv = obsoleteManager->RegisterComponentWithType(cp->mCID,
cp->mDescription,
cp->mContractID, aPath,
registryLocation, PR_TRUE,
PR_TRUE, componentType);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(aCompMgr, &rv);
if (registrar)
rv = registrar->RegisterFactoryLocation(cp->mCID,
cp->mDescription,
cp->mContractID,
aPath,
registryLocation,
componentType);
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("nsGenericModule %s: unable to register %s component => %x\n",
@ -411,13 +410,10 @@ nsGenericModule::UnregisterSelf(nsIComponentManager* aCompMgr,
}
// Unregister the component
// what I want to do here is QI for a Component Registration Manager. Since this
// has not been invented yet, QI to the obsolete manager. Kids, don't do this at home.
nsresult rv;
nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(aCompMgr, &rv);
if (obsoleteManager)
rv = obsoleteManager->UnregisterComponentSpec(cp->mCID, aPath);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(aCompMgr, &rv);
if (registrar)
rv = registrar->UnregisterFactoryLocation(cp->mCID, aPath);
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("nsGenericModule %s: unable to unregister %s component => %x\n",

Просмотреть файл

@ -42,7 +42,7 @@ interface nsIComponentManager;
/**
* The nsIModule interface.
* @status UNDER_REVIEW
* @status FROZEN
*/
[scriptable, uuid(7392D032-5371-11d3-994E-00805FD26FEE)]

Просмотреть файл

@ -179,6 +179,17 @@ public:
static nsresult ShutdownGlobalServiceManager(nsIServiceManager* *result);
};
#define NS_DECL_NSISERVICEMANAGEROBSOLETE \
NS_IMETHOD RegisterService(const nsCID& aClass, nsISupports* aService); \
NS_IMETHOD UnregisterService(const nsCID& aClass);\
NS_IMETHOD GetService(const nsCID& aClass, const nsIID& aIID, nsISupports* *result, nsIShutdownListener* shutdownListener);\
NS_IMETHOD ReleaseService(const nsCID& aClass, nsISupports* service, nsIShutdownListener* shutdownListener);\
NS_IMETHOD RegisterService(const char* aContractID, nsISupports* aService);\
NS_IMETHOD UnregisterService(const char* aContractID);\
NS_IMETHOD GetService(const char* aContractID, const nsIID& aIID, nsISupports* *result, nsIShutdownListener* shutdownListener);\
NS_IMETHOD ReleaseService(const char* aContractID, nsISupports* service, nsIShutdownListener* shutdownListener);
////////////////////////////////////////////////////////////////////////////////
#define NS_ISHUTDOWNLISTENER_IID \

Просмотреть файл

@ -373,7 +373,6 @@ nsFreeLibrary(nsDll *dll, nsIServiceManager *serviceMgr, PRInt32 when)
#endif /* OBSOLETE_MODULE_LOADING */
mobj = nsnull; // Release our reference to the module object
// When shutting down, whether we can unload the dll or not,
// we will shutdown the dll to release any memory it has got
if (when == nsIComponentManagerObsolete::NS_Shutdown)

Просмотреть файл

@ -83,7 +83,7 @@ public:
{
return nsnull;
}
return mImpl->mArray[aIndex];
return mImpl ? mImpl->mArray[aIndex] : nsnull;
}
// bounds-checked version
@ -93,7 +93,7 @@ public:
{
return nsnull;
}
return mImpl->mArray[aIndex];
return mImpl ? mImpl->mArray[aIndex] : nsnull;
}
void* operator[](PRInt32 aIndex) const { return ElementAt(aIndex); }

Просмотреть файл

@ -43,7 +43,7 @@
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsIComponentManager.h"
#include "nsIComponentManagerObsolete.h"
#include "nsIComponentRegistrar.h"
nsGenericFactory::nsGenericFactory(nsModuleComponentInfo *info)
: mInfo(info)
{
@ -358,15 +358,14 @@ nsGenericModule::RegisterSelf(nsIComponentManager *aCompMgr,
for (PRUint32 i = 0; i < mComponentCount; i++) {
// Register the component only if it has a constructor
if (cp->mConstructor) {
// what I want to do here is QI for a Component Registration Manager. Since this
// has not been invented yet, QI to the obsolete manager. Kids, don't do this at home.
nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(aCompMgr, &rv);
if (obsoleteManager)
rv = obsoleteManager->RegisterComponentWithType(cp->mCID,
cp->mDescription,
cp->mContractID, aPath,
registryLocation, PR_TRUE,
PR_TRUE, componentType);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(aCompMgr, &rv);
if (registrar)
rv = registrar->RegisterFactoryLocation(cp->mCID,
cp->mDescription,
cp->mContractID,
aPath,
registryLocation,
componentType);
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("nsGenericModule %s: unable to register %s component => %x\n",
@ -411,13 +410,10 @@ nsGenericModule::UnregisterSelf(nsIComponentManager* aCompMgr,
}
// Unregister the component
// what I want to do here is QI for a Component Registration Manager. Since this
// has not been invented yet, QI to the obsolete manager. Kids, don't do this at home.
nsresult rv;
nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(aCompMgr, &rv);
if (obsoleteManager)
rv = obsoleteManager->UnregisterComponentSpec(cp->mCID, aPath);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(aCompMgr, &rv);
if (registrar)
rv = registrar->UnregisterFactoryLocation(cp->mCID, aPath);
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("nsGenericModule %s: unable to unregister %s component => %x\n",

Просмотреть файл

@ -4,6 +4,7 @@ nsFileSpec.h
nsFileSpecStreaming.h
nsFileStream.h
nsIFileStream.h
nsIFileUtils.h
nsIUnicharInputStream.h
nsSpecialSystemDirectory.h
nsStorageStream.h

Просмотреть файл

@ -85,6 +85,7 @@ EXPORTS = \
nsFileSpecStreaming.h \
nsFileStream.h \
nsIFileStream.h \
nsIFileUtils.h \
nsIUnicharInputStream.h \
nsLinebreakConverter.h \
nsLocalFile.h \

Просмотреть файл

@ -39,6 +39,7 @@ EXPORTS = \
nsFileSpecStreaming.h \
nsFileStream.h \
nsIFileStream.h \
nsIFileUtils.h \
nsIUnicharInputStream.h \
nsLinebreakConverter.h \
nsScriptableInputStream.h \

Просмотреть файл

@ -136,8 +136,8 @@ interface nsIDirectoryService: nsISupports
};
%{C++
#define NS_DIRECTORY_SERVICE_CONTRACTID "@mozilla.org/file/directory_service;1"
#define NS_DIRECTORY_SERVICE_CLASSNAME "nsIFile Directory Service"
#define NS_DIRECTORY_SERVICE_CONTRACTID "@mozilla.org/file/directory_service;1"
#define NS_DIRECTORY_SERVICE_CLASSNAME "nsIFile Directory Service"
%}

Просмотреть файл

@ -1,27 +1,42 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "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/
/* Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* The Original Code is Mozilla Communicator client code,
* released March 31, 1998.
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 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):
* Doug Turner <dougt@netscape.com>
* Christopher Blizzard <blizzard@mozilla.org>
*/
*
* 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 ***** */
/**
@ -29,7 +44,7 @@
* Strings are not such a way. If you grew up on windows or unix, you
* may think they are. Welcome to reality.
*
* @status UNDER_REVIEW
* @status FROZEN
*/
#include "nsISupports.idl"
@ -302,32 +317,7 @@ interface nsIFile : nsISupports
%{C++
#define NS_FILE_CONTRACTID "@mozilla.org/file;1"
#define NS_FILE_CLASSNAME "File Specification"
////////////////////////////////////////////////////////////////////////////////
// Special Directories
#include "nsIServiceManager.h"
#include "nsIProperties.h"
#include "nsCOMPtr.h"
#define NS_DIRECTORY_SERVICE_CID {0xf00152d0,0xb40b,0x11d3,{0x8c, 0x9c, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74}}
inline nsresult
NS_GetSpecialDirectory(const char* specialDirName, nsIFile* *result)
{
nsresult rv;
static NS_DEFINE_CID(kDirectoryServiceCID, NS_DIRECTORY_SERVICE_CID);
nsCOMPtr<nsIProperties> serv(do_GetService(kDirectoryServiceCID, &rv));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> dir;
rv = serv->Get(specialDirName, NS_GET_IID(nsIFile), getter_AddRefs(dir));
if (NS_FAILED(rv)) return rv;
*result = NS_STATIC_CAST(nsIFile*, NS_STATIC_CAST(nsISupports*, dir));
if (*result)
NS_ADDREF(*result);
return NS_OK;
}
#ifndef MOZILLA_STRICT_API
#include "nsIFileUtils.h"
#endif
%}

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsXPCOM.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsSpecialSystemDirectory.h" // For exe dir
@ -496,11 +497,12 @@ main(int argc, char **argv)
if (argc > 1)
numberOfThreads = atoi(argv[1]);
NS_InitXPCOM2(nsnull, nsnull, nsnull);
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
NULL /* default */);
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
static PRThread** threads = (PRThread**) calloc(sizeof(PRThread*), numberOfThreads);
static PRThread* aEventThread;

Просмотреть файл

@ -65,12 +65,13 @@ var myModule = {
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
}
dump("*** Registering sample JS components\n");
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr.registerComponentWithType(this.myCID,
"Sample JS Component",
this.myProgID, fileSpec,
location, true, true,
type);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation(this.myCID,
"Sample JS Component",
this.myProgID,
fileSpec,
location,
type);
},
/*
@ -130,3 +131,5 @@ var myModule = {
function NSGetModule(compMgr, fileSpec) {
return myModule;
}

Просмотреть файл

@ -42,9 +42,10 @@
* to be a sample application for using xpcom standalone.
*/
#include <nsISample.h>
#include <nsIServiceManager.h>
#include <nsXPIDLString.h>
#include "nsISample.h"
#include "nsIServiceManager.h"
#include "nsXPIDLString.h"
#include "nsIComponentRegistrar.h"
#define NS_SAMPLE_CONTRACTID "@mozilla.org/sample;1"
@ -54,25 +55,18 @@ main(void)
nsresult rv;
// Initialize XPCOM
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
if (NS_FAILED(rv))
{
printf("ERROR: XPCOM intialization error [%x].\n", rv);
return -1;
}
// Do Autoreg to make sure our component is registered. The real way of
// doing this is running the xpcom registraion tool, regxpcom, at install
// time to get components registered and not make this call everytime.
// Ignore return value.
//
// Here we use the global component manager. Note that this will cause
// linkage dependency to XPCOM library. We feel that linkage dependency
// to XPCOM is inevitable and this is simpler to code.
// To break free from such dependencies, we can GetService() the component
// manager from the service manager that is returned from NS_InitXPCOM().
// We feel that linkage dependency to XPCOM library is inevitable.
(void) nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull);
// register all components in our default component directory
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// Create an instance of our component
nsCOMPtr<nsISample> mysample = do_CreateInstance(NS_SAMPLE_CONTRACTID, &rv);

Просмотреть файл

@ -43,6 +43,7 @@
#include "nsIEventQueueService.h"
#include "nsIPersistentProperties2.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIURL.h"
#include "nsIIOService.h"
#include "nsNetCID.h"
@ -69,9 +70,12 @@ main(int argc, char* argv[])
#ifndef XPCOM_STANDALONE
nsresult ret;
NS_InitXPCOM2(nsnull, nsnull, nsnull);
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
NULL /* default */);
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// Create the Event Queue for this thread...
nsCOMPtr<nsIEventQueueService> pEventQService =

Просмотреть файл

@ -38,6 +38,7 @@
#include <iostream.h>
#include "plstr.h"
#include "prlink.h"
#include "nsIComponentRegistrar.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
@ -64,14 +65,14 @@ void print_err(nsresult err)
}
}
nsresult Register(const char *path)
nsresult Register(nsIComponentRegistrar* register, const char *path)
{
nsCOMPtr<nsIFileSpec> spec;
nsresult res = NS_NewFileSpec(getter_AddRefs(spec));
if (NS_FAILED(res)) return res;
res = spec->SetNativePath((char *)path);
if (NS_FAILED(res)) return res;
res = nsComponentManager::AutoRegisterComponent(nsIComponentManagerObsolete::NS_Startup, spec);
res = register->AutoRegister(spec);
return res;
}
@ -79,14 +80,14 @@ nsresult Unregister(const char *path)
{
/* NEEDS IMPLEMENTATION */
#if 0
nsresult res = nsComponentManager::AutoUnregisterComponent(path);
nsresult res = nsComponentManager::AutoUnregisterComponent(path);
return res;
#else
return NS_ERROR_FAILURE;
#endif
}
int ProcessArgs(int argc, char *argv[])
int ProcessArgs(nsIComponentRegistrar* register, int argc, char *argv[])
{
int i = 1;
nsresult res;
@ -115,7 +116,7 @@ int ProcessArgs(int argc, char *argv[])
cerr << "): " << argv[i] << "\n";
}
} else {
res = Register(argv[i]);
res = Register(register, argv[i]);
if (NS_SUCCEEDED(res)) {
cout << "Successfully registered: " << argv[i] << "\n";
} else {
@ -134,16 +135,20 @@ int main(int argc, char *argv[])
{
int ret = 0;
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
if (NS_FAILED(rv)) return -1;
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
/* With no arguments, RegFactory will autoregister */
if (argc <= 1)
{
nsresult rv = nsComponentManager::AutoRegister(
nsIComponentManagerObsolete::NS_Startup,
NULL /* default location */);
ret = (NS_FAILED(rv)) ? -1 : 0;
rv = registrar->AutoRegister(nsnull);
ret = (NS_FAILED(rv)) ? -1 : 0;
}
else
ret = ProcessArgs(argc, argv);
ret = ProcessArgs(registrar, argc, argv);
return ret;
}

Просмотреть файл

@ -40,51 +40,12 @@
#include "TestFactory.h"
#include "nsISupports.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIServiceManager.h"
NS_DEFINE_CID(kTestFactoryCID, NS_TESTFACTORY_CID);
NS_DEFINE_CID(kTestLoadedFactoryCID, NS_TESTLOADEDFACTORY_CID);
int main(int argc, char **argv) {
nsresult rv;
rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
NULL /* default */);
if (NS_FAILED(rv)) return rv;
RegisterTestFactories();
ITestClass *t = NULL;
nsComponentManager::CreateInstance(kTestFactoryCID,
NULL,
NS_GET_IID(ITestClass),
(void **) &t);
if (t != NULL) {
t->Test();
t->Release();
} else {
cout << "CreateInstance failed\n";
}
t = NULL;
nsComponentManager::CreateInstance(kTestLoadedFactoryCID,
NULL,
NS_GET_IID(ITestClass),
(void **) &t);
if (t != NULL) {
t->Test();
t->Release();
} else {
cout << "Dynamic CreateInstance failed\n";
}
nsComponentManager::FreeLibraries();
return 0;
}
/**
* ITestClass implementation
@ -150,19 +111,50 @@ nsresult TestFactory::CreateInstance(nsISupports *aDelegate,
return res;
}
/**
* TestFactory registration function
*/
extern "C" void RegisterTestFactories() {
nsComponentManager::RegisterFactory(kTestFactoryCID, 0, 0,
new TestFactory(), PR_FALSE);
int main(int argc, char **argv) {
nsresult rv;
// Windows can use persistant registry
#ifndef USE_NSREG
nsComponentManager::RegisterComponent(kTestLoadedFactoryCID, NULL, NULL,
"libtestdynamic"MOZ_DLL_SUFFIX,
PR_FALSE,
PR_TRUE);
#endif
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
if (NS_FAILED(rv)) return -1;
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->RegisterFactory(kTestFactoryCID,
nsnull,
nsnull,
new TestFactory());
ITestClass *t = NULL;
nsComponentManager::CreateInstance(kTestFactoryCID,
NULL,
NS_GET_IID(ITestClass),
(void **) &t);
if (t != NULL) {
t->Test();
t->Release();
} else {
cout << "CreateInstance failed\n";
}
t = NULL;
nsComponentManager::CreateInstance(kTestLoadedFactoryCID,
NULL,
NS_GET_IID(ITestClass),
(void **) &t);
if (t != NULL) {
t->Test();
t->Release();
} else {
cout << "Dynamic CreateInstance failed\n";
}
return 0;
}

Просмотреть файл

@ -1,6 +1,7 @@
#include "nsILocalFile.h"
#include <stdio.h>
#include "nsIComponentRegistrar.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsMemory.h"
@ -60,14 +61,16 @@ main(int argc, char* argv[])
nsresult rv;
nsCOMPtr<nsILocalFile> topDir;
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
if (NS_FAILED(rv)) return -1;
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
if (argc > 1 && argv[1] != nsnull)
{
char* pathStr = argv[1];
char* pathStr = argv[1];
NS_NewLocalFile(pathStr, PR_FALSE, getter_AddRefs(topDir));
}

Просмотреть файл

@ -3,6 +3,7 @@
#include <stdio.h>
#include "nsXPCOM.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIServiceManager.h"
#include "nsIMemory.h"
#include "nsXPIDLString.h"
@ -314,11 +315,12 @@ DeletionTest(const char* creationPath, const char* appendPath, PRBool recursive)
int main(void)
{
NS_InitXPCOM2(nsnull, nsnull, nsnull);
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
NULL);
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
#ifdef XP_PC
InitTest("c:\\temp\\", "sub1/sub2/");
InitTest("d:\\temp\\", "sub1\\sub2\\");

Просмотреть файл

@ -40,70 +40,75 @@ void InfoBox(LPSTR text)
MessageBox(NULL, text, "XP Event Loop", MB_OK | MB_ICONINFORMATION);
}
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prevInstance, LPSTR lpszCmdLine,
int nShowCmd)
int WINAPI WinMain(HINSTANCE inst,
HINSTANCE prevInstance,
LPSTR lpszCmdLine,
int nShowCmd)
{
char* lpszAppName = "HelloWorld";
HWND wnd;
WNDCLASSEX wndclass;
int retCode;
nsresult rv;
rv = NS_InitXPCOM2(NULL, NULL, NULL);
{ // Needed to scope all nsCOMPtr within XPCOM Init and Shutdown
if(NS_FAILED(rv))
{
ErrorBox("Failed to initalize xpcom.");
return -1;
}
{ // Needed to scope all nsCOMPtr within XPCOM Init and Shutdown
nsresult rv;
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
if(NS_FAILED(rv))
{
ErrorBox("Failed to initalize xpcom.");
return -1;
}
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
nsCOMPtr<nsINativeApp> nativeAppService(do_GetService(kNativeAppCID, &rv));
nsCOMPtr<nsINativeApp> nativeAppService(do_GetService(kNativeAppCID, &rv));
if(NS_FAILED(rv))
{
ErrorBox("Failed to get nativeAppService");
return -1;
}
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = inst;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = lpszAppName;
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(NS_FAILED(rv))
{
ErrorBox("Failed to get nativeAppService");
return -1;
}
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = inst;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = lpszAppName;
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wndclass) ;
wnd = CreateWindow(lpszAppName, "The Hello World",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, inst, NULL);
ShowWindow(wnd, nShowCmd);
UpdateWindow(wnd);
nsCOMPtr<nsIEventLoop> eventLoop;
if(NS_FAILED(nativeAppService->CreateEventLoop(L"_MainLoop",
nsEventLoopTypes::MainAppLoop, getter_AddRefs(eventLoop))))
{
ErrorBox("Failed to create event Loop");
return 0;
}
eventLoop->Run(nsnull, nsnull, nsnull, &retCode);
eventLoop = nsnull; // Clear out before Shutting down XPCOM
InfoBox("Hello World app is out of loop");
}
RegisterClassEx(&wndclass) ;
wnd = CreateWindow(lpszAppName, "The Hello World",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, inst, NULL);
ShowWindow(wnd, nShowCmd);
UpdateWindow(wnd);
nsCOMPtr<nsIEventLoop> eventLoop;
if(NS_FAILED(nativeAppService->CreateEventLoop(L"_MainLoop",
nsEventLoopTypes::MainAppLoop, getter_AddRefs(eventLoop))))
{
ErrorBox("Failed to create event Loop");
return 0;
}
eventLoop->Run(nsnull, nsnull, nsnull, &retCode);
eventLoop = nsnull; // Clear out before Shutting down XPCOM
InfoBox("Hello World app is out of loop");
}
NS_ShutdownXPCOM(nsnull);
InfoBox("Hello World app is exiting");
return retCode;

Просмотреть файл

@ -45,6 +45,7 @@
#include "plstr.h"
#include "prlink.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsILocalFile.h"
@ -52,7 +53,7 @@
static PRBool gUnreg = PR_FALSE, gSilent = PR_FALSE, gQuiet = PR_FALSE;
nsresult Register(const char *path)
nsresult Register(nsIComponentRegistrar* registrar, const char *path)
{
nsCOMPtr<nsILocalFile> spec;
nsresult rv = nsComponentManager::CreateInstance(NS_LOCAL_FILE_CONTRACTID,
@ -68,11 +69,10 @@ nsresult Register(const char *path)
rv = spec->InitWithPath(path);
if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::AutoRegisterComponent(nsIComponentManagerObsolete::NS_Startup, spec);
return rv;
return registrar->AutoRegister(spec);
}
nsresult Unregister(const char *path)
nsresult Unregister(nsIComponentRegistrar *registrar, const char *path)
{
nsCOMPtr<nsILocalFile> spec;
nsresult rv = nsComponentManager::CreateInstance(NS_LOCAL_FILE_CONTRACTID,
@ -88,8 +88,7 @@ nsresult Unregister(const char *path)
rv = spec->InitWithPath(path);
if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::AutoUnregisterComponent(nsIComponentManagerObsolete::NS_Startup, spec);
return rv;
return registrar->AutoUnregister(spec);
}
void ReportSuccess(const char *file)
@ -133,7 +132,7 @@ void ReportError(nsresult err, const char *file)
fprintf(stderr, ") %s\n", file);
}
int ProcessArgs(int argc, char *argv[])
int ProcessArgs(nsIComponentRegistrar *registrar, int argc, char *argv[])
{
int i = 1, result = 0;
nsresult res;
@ -158,9 +157,9 @@ int ProcessArgs(int argc, char *argv[])
}
} else {
if (gUnreg == PR_TRUE)
res = Unregister(argv[i]);
res = Unregister(registrar, argv[i]);
else
res = Register(argv[i]);
res = Register(registrar, argv[i]);
if (NS_FAILED(res)) {
ReportError(res, argv[i]);
result = -1;
@ -183,18 +182,27 @@ int main(int argc, char *argv[])
#endif
#endif
NS_InitXPCOM2(nsnull, nsnull, nsnull);
nsCOMPtr<nsIServiceManager> servMan;
nsresult rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
if (NS_FAILED(rv)) {
printf("Can not initialize XPCOM\n");
return -1;
}
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
/* With no arguments, RegFactory will autoregister */
if (argc <= 1)
{
nsresult rv = nsComponentManager::AutoRegister(
nsIComponentManagerObsolete::NS_Startup,
NULL /* default location */);
ret = (NS_FAILED(rv)) ? -1 : 0;
rv = registrar->AutoRegister(nsnull);
ret = (NS_FAILED(rv)) ? -1 : 0;
}
else
ret = ProcessArgs(argc, argv);
{
ret = ProcessArgs(registrar, argc, argv);
}
NS_ShutdownXPCOM(NULL);
return ret;

Просмотреть файл

@ -92,15 +92,13 @@ var module = {
this.firstTime = false;
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
}
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr.registerComponentWithType( this.cid,
"Close All Windows",
this.contractId,
fileSpec,
location,
true,
true,
type );
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation( this.cid,
"Close All Windows",
this.contractId,
fileSpec,
location,
type );
},
// getClassObject: Return this component's factory object.

Просмотреть файл

@ -58,12 +58,14 @@ jsConsoleHandler.prototype = {
/* jsConsoleHandler Module (for XPCOM registration) */
var jsConsoleHandlerModule = {
registerSelf: function(compMgr, fileSpec, location, type) {
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerComponentWithType(JSCONSOLEHANDLER_CID,
'JS Console Commandline Handler component',
JSCONSOLEHANDLER_CONTRACTID, fileSpec,
location, true, true, type);
compMgr.registerFactoryLocation(JSCONSOLEHANDLER_CID,
'JS Console Commandline Handler component',
JSCONSOLEHANDLER_CONTRACTID,
fileSpec,
location,
type);
var catman = Components.classes["@mozilla.org/categorymanager;1"]
.getService(Components.interfaces.nsICategoryManager);
catman.addCategoryEntry("command-line-argument-handlers", "jsconsole command line handler",
@ -72,8 +74,8 @@ var jsConsoleHandlerModule = {
},
unregisterSelf: function(compMgr, fileSpec, location) {
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr.unregisterComponentSpec(JSCONSOLEHANDLER_CID, fileSpec);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.unregisterFactoryLocation(JSCONSOLEHANDLER_CID, fileSpec);
var catman = Components.classes["@mozilla.org/categorymanager;1"]
.getService(Components.interfaces.nsICategoryManager);
catman.deleteCategoryEntry("command-line-argument-handlers",

Просмотреть файл

@ -207,11 +207,14 @@ filePickerModule.registerSelf =
function (compMgr, fileSpec, location, type)
{
debug("registering (all right -- a JavaScript module!)");
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerComponentWithType(FILEPICKER_CID, "FilePicker JS Component",
FILEPICKER_CONTRACTID, fileSpec, location,
true, true, type);
compMgr.registerFactoryLocation(FILEPICKER_CID,
"FilePicker JS Component",
FILEPICKER_CONTRACTID,
fileSpec,
location,
type);
}
filePickerModule.getClassObject =

Просмотреть файл

@ -207,11 +207,14 @@ filePickerModule.registerSelf =
function (compMgr, fileSpec, location, type)
{
debug("registering (all right -- a JavaScript module!)");
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerComponentWithType(FILEPICKER_CID, "FilePicker JS Component",
FILEPICKER_CONTRACTID, fileSpec, location,
true, true, type);
compMgr.registerFactoryLocation(FILEPICKER_CID,
"FilePicker JS Component",
FILEPICKER_CONTRACTID,
fileSpec,
location,
type);
}
filePickerModule.getClassObject =

Просмотреть файл

@ -352,11 +352,14 @@ sidebarModule.registerSelf =
function (compMgr, fileSpec, location, type)
{
debug("registering (all right -- a JavaScript module!)");
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerComponentWithType(SIDEBAR_CID, "Sidebar JS Component",
SIDEBAR_CONTRACTID, fileSpec, location,
true, true, type);
compMgr.registerFactoryLocation(SIDEBAR_CID,
"Sidebar JS Component",
SIDEBAR_CONTRACTID,
fileSpec,
location,
type);
}
sidebarModule.getClassObject =

Просмотреть файл

@ -92,15 +92,13 @@ var module = {
this.firstTime = false;
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
}
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
compMgr.registerComponentWithType( this.cid,
"Close All Windows",
this.contractId,
fileSpec,
location,
true,
true,
type );
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation( this.cid,
"Close All Windows",
this.contractId,
fileSpec,
location,
type );
},
// getClassObject: Return this component's factory object.

Просмотреть файл

@ -27,6 +27,7 @@
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIServiceManager.h"
#include "nsICategoryManager.h"
#include "nsCOMPtr.h"
@ -437,7 +438,11 @@ nsSoftwareUpdate::StartupTasks( PRBool *needAutoreg )
// is not the actual BuildID, or if we couldn't get the BuildID
if ( autoReg || NS_FAILED(rv) || buildID != NS_BUILD_ID )
{
rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,0);
nsCOMPtr<nsIServiceManager> servManager;
NS_GetServiceManager(getter_AddRefs(servManager));
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servManager);
NS_ASSERTION(registrar, "No nsIComponentRegistrar from get service. see dougt");
rv = registrar->AutoRegister(nsnull);
if (NS_SUCCEEDED(rv))
{

Просмотреть файл

@ -97,10 +97,16 @@ main(int argc, char **argv)
}
NS_InitXPCOM2(nsnull, nsnull, nsnull);
nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
nsnull /* default */);
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
if (!registrar) {
NS_ASSERTION(0, "Null nsIComponentRegistrar");
return rv;
}
registrar->AutoRegister(nsnull);
nsresult rv = nsComponentManager::CreateInstance(kSoftwareUpdateCID,
nsnull,

Просмотреть файл

@ -26,6 +26,7 @@
#include "xpistub.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsSpecialSystemDirectory.h"
@ -148,12 +149,13 @@ PR_PUBLIC_API(nsresult) XPI_Init(
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(gServiceMgr);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
#if defined(XP_UNIX) || defined(XP_MAC)
rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
compDir);
rv = registrar->AutoRegister(compDir);
#else
rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,
nsnull);
rv = registrar->AutoRegister(nsnull);
#endif
if (NS_FAILED(rv))
return rv;