1999-03-10 09:53:25 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
1998-03-28 02:44:41 +00:00
|
|
|
/*
|
1999-03-10 09:53:25 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
1998-03-28 02:44:41 +00:00
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
#include "nsIComponentManager.h"
|
1998-09-29 17:16:06 +00:00
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::Initialize(void)
|
1999-02-27 08:58:11 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
return NS_OK;
|
1999-02-27 08:58:11 +00:00
|
|
|
}
|
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::FindFactory(const nsCID &aClass,
|
1999-03-10 09:53:25 +00:00
|
|
|
nsIFactory **aFactory)
|
1999-02-27 08:58:11 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->FindFactory(aClass, aFactory);
|
1999-02-27 08:58:11 +00:00
|
|
|
}
|
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::ProgIDToCLSID(const char *aProgID,
|
1999-03-10 09:53:25 +00:00
|
|
|
nsCID *aClass)
|
1998-03-28 02:44:41 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->ProgIDToCLSID(aProgID, aClass);
|
1998-03-28 02:44:41 +00:00
|
|
|
}
|
1999-03-09 09:44:27 +00:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsComponentManager::CLSIDToProgID(nsCID *aClass,
|
1999-03-10 09:53:25 +00:00
|
|
|
char* *aClassName,
|
|
|
|
char* *aProgID)
|
1998-03-28 02:44:41 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->CLSIDToProgID(aClass, aClassName, aProgID);
|
1998-03-28 02:44:41 +00:00
|
|
|
}
|
1999-03-09 09:44:27 +00:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsComponentManager::CreateInstance(const nsCID &aClass,
|
1999-03-10 09:53:25 +00:00
|
|
|
nsISupports *aDelegate,
|
|
|
|
const nsIID &aIID,
|
|
|
|
void **aResult)
|
1999-02-18 16:58:22 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->CreateInstance(aClass, aDelegate, aIID, aResult);
|
1999-02-18 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::CreateInstance(const char *aProgID,
|
1999-03-10 09:53:25 +00:00
|
|
|
nsISupports *aDelegate,
|
|
|
|
const nsIID &aIID,
|
|
|
|
void **aResult)
|
1999-02-26 10:17:14 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->CreateInstance(aProgID, aDelegate, aIID, aResult);
|
1999-02-26 10:17:14 +00:00
|
|
|
}
|
1999-02-18 16:58:22 +00:00
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::RegisterFactory(const nsCID &aClass,
|
1999-03-10 09:53:25 +00:00
|
|
|
const char *aClassName,
|
|
|
|
const char *aProgID,
|
|
|
|
nsIFactory *aFactory,
|
|
|
|
PRBool aReplace)
|
1998-03-28 02:44:41 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->RegisterFactory(aClass, aClassName, aProgID,
|
|
|
|
aFactory, aReplace);
|
1998-03-28 02:44:41 +00:00
|
|
|
}
|
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::RegisterComponent(const nsCID &aClass,
|
1999-03-10 09:53:25 +00:00
|
|
|
const char *aClassName,
|
|
|
|
const char *aProgID,
|
|
|
|
const char *aLibrary,
|
|
|
|
PRBool aReplace,
|
|
|
|
PRBool aPersist)
|
1998-03-28 02:44:41 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->RegisterComponent(aClass, aClassName, aProgID,
|
|
|
|
aLibrary, aReplace, aPersist);
|
1998-03-28 02:44:41 +00:00
|
|
|
}
|
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::UnregisterFactory(const nsCID &aClass,
|
1999-03-10 09:53:25 +00:00
|
|
|
nsIFactory *aFactory)
|
1998-03-28 02:44:41 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->UnregisterFactory(aClass, aFactory);
|
1998-03-28 02:44:41 +00:00
|
|
|
}
|
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::UnregisterComponent(const nsCID &aClass,
|
1999-03-10 09:53:25 +00:00
|
|
|
const char *aLibrary)
|
1998-03-28 02:44:41 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->UnregisterComponent(aClass, aLibrary);
|
1998-03-28 02:44:41 +00:00
|
|
|
}
|
1999-02-27 09:50:19 +00:00
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::FreeLibraries(void)
|
1998-03-28 02:44:41 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->FreeLibraries();
|
1998-03-28 02:44:41 +00:00
|
|
|
}
|
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::AutoRegister(nsIComponentManager::RegistrationTime when,
|
1999-04-02 20:28:22 +00:00
|
|
|
const char* directory)
|
1999-02-18 16:58:22 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-04-02 20:28:22 +00:00
|
|
|
return cm->AutoRegister(when, directory);
|
1999-02-18 16:58:22 +00:00
|
|
|
}
|
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult
|
1999-04-02 20:28:22 +00:00
|
|
|
nsComponentManager::AutoRegisterComponent(nsIComponentManager::RegistrationTime when,
|
|
|
|
const char *fullname)
|
1998-03-28 02:44:41 +00:00
|
|
|
{
|
1999-03-09 09:44:27 +00:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-04-02 20:28:22 +00:00
|
|
|
return cm->AutoRegisterComponent(when, fullname);
|
1999-02-06 20:39:40 +00:00
|
|
|
}
|