1999-03-10 12:53:25 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
1998-03-28 05:44:41 +03:00
|
|
|
/*
|
1999-11-06 06:43:54 +03:00
|
|
|
* 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/
|
1999-03-10 12:53:25 +03:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* 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.
|
1999-03-10 12:53:25 +03:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-03-10 12:53:25 +03:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:43:54 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-03-10 12:53:25 +03:00
|
|
|
*/
|
1998-03-28 05:44:41 +03:00
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1998-09-29 21:16:06 +04:00
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::Initialize(void)
|
1999-02-27 11:58:11 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03:00
|
|
|
return NS_OK;
|
1999-02-27 11:58:11 +03:00
|
|
|
}
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::FindFactory(const nsCID &aClass,
|
1999-03-10 12:53:25 +03:00
|
|
|
nsIFactory **aFactory)
|
1999-02-27 11:58:11 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->FindFactory(aClass, aFactory);
|
1999-02-27 11:58:11 +03:00
|
|
|
}
|
|
|
|
|
1999-08-19 18:54:12 +04:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::GetClassObject(const nsCID &aClass, const nsIID &aIID,
|
|
|
|
void **aResult)
|
|
|
|
{
|
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->GetClassObject(aClass, aIID, aResult);
|
|
|
|
}
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
nsresult
|
1999-12-31 01:03:58 +03:00
|
|
|
nsComponentManager::ProgIDToClassID(const char *aProgID,
|
1999-03-10 12:53:25 +03:00
|
|
|
nsCID *aClass)
|
1998-03-28 05:44:41 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-12-31 01:03:58 +03:00
|
|
|
return cm->ProgIDToClassID(aProgID, aClass);
|
1998-03-28 05:44:41 +03:00
|
|
|
}
|
1999-03-09 12:44:27 +03:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsComponentManager::CLSIDToProgID(nsCID *aClass,
|
1999-03-10 12:53:25 +03:00
|
|
|
char* *aClassName,
|
|
|
|
char* *aProgID)
|
1998-03-28 05:44:41 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-05 10:27:42 +04:00
|
|
|
return cm->CLSIDToProgID(*aClass, aClassName, aProgID);
|
1998-03-28 05:44:41 +03:00
|
|
|
}
|
1999-03-09 12:44:27 +03:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsComponentManager::CreateInstance(const nsCID &aClass,
|
1999-03-10 12:53:25 +03:00
|
|
|
nsISupports *aDelegate,
|
|
|
|
const nsIID &aIID,
|
|
|
|
void **aResult)
|
1999-02-18 19:58:22 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->CreateInstance(aClass, aDelegate, aIID, aResult);
|
1999-02-18 19:58:22 +03:00
|
|
|
}
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::CreateInstance(const char *aProgID,
|
1999-03-10 12:53:25 +03:00
|
|
|
nsISupports *aDelegate,
|
|
|
|
const nsIID &aIID,
|
|
|
|
void **aResult)
|
1999-02-26 13:17:14 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-05 10:27:42 +04:00
|
|
|
return cm->CreateInstanceByProgID(aProgID, aDelegate, aIID, aResult);
|
1999-02-26 13:17:14 +03:00
|
|
|
}
|
1999-02-18 19:58:22 +03:00
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::RegisterFactory(const nsCID &aClass,
|
1999-03-10 12:53:25 +03:00
|
|
|
const char *aClassName,
|
|
|
|
const char *aProgID,
|
|
|
|
nsIFactory *aFactory,
|
|
|
|
PRBool aReplace)
|
1998-03-28 05:44:41 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03: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 05:44:41 +03:00
|
|
|
}
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::RegisterComponent(const nsCID &aClass,
|
1999-03-10 12:53:25 +03:00
|
|
|
const char *aClassName,
|
|
|
|
const char *aProgID,
|
1999-06-22 18:02:58 +04:00
|
|
|
const char *aLibraryPersistentDescriptor,
|
1999-03-10 12:53:25 +03:00
|
|
|
PRBool aReplace,
|
|
|
|
PRBool aPersist)
|
1998-03-28 05:44:41 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->RegisterComponent(aClass, aClassName, aProgID,
|
1999-06-22 18:02:58 +04:00
|
|
|
aLibraryPersistentDescriptor, aReplace, aPersist);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsComponentManager::RegisterComponentSpec(const nsCID &aClass,
|
|
|
|
const char *aClassName,
|
|
|
|
const char *aProgID,
|
2000-01-25 00:28:28 +03:00
|
|
|
nsIFile *aLibrary,
|
1999-06-22 18:02:58 +04:00
|
|
|
PRBool aReplace,
|
|
|
|
PRBool aPersist)
|
|
|
|
{
|
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->RegisterComponentSpec(aClass, aClassName, aProgID,
|
|
|
|
aLibrary, aReplace, aPersist);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsComponentManager::RegisterComponentLib(const nsCID &aClass,
|
|
|
|
const char *aClassName,
|
|
|
|
const char *aProgID,
|
|
|
|
const char *adllName,
|
|
|
|
PRBool aReplace,
|
|
|
|
PRBool aPersist)
|
|
|
|
{
|
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->RegisterComponentLib(aClass, aClassName, aProgID,
|
|
|
|
adllName, aReplace, aPersist);
|
1998-03-28 05:44:41 +03:00
|
|
|
}
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::UnregisterFactory(const nsCID &aClass,
|
1999-03-10 12:53:25 +03:00
|
|
|
nsIFactory *aFactory)
|
1998-03-28 05:44:41 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->UnregisterFactory(aClass, aFactory);
|
1998-03-28 05:44:41 +03:00
|
|
|
}
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::UnregisterComponent(const nsCID &aClass,
|
1999-03-10 12:53:25 +03:00
|
|
|
const char *aLibrary)
|
1998-03-28 05:44:41 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->UnregisterComponent(aClass, aLibrary);
|
1998-03-28 05:44:41 +03:00
|
|
|
}
|
1999-02-27 12:50:19 +03:00
|
|
|
|
1999-08-13 23:30:13 +04:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::UnregisterComponentSpec(const nsCID &aClass,
|
2000-01-25 00:28:28 +03:00
|
|
|
nsIFile *aLibrarySpec)
|
1999-08-13 23:30:13 +04:00
|
|
|
{
|
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->UnregisterComponentSpec(aClass, aLibrarySpec);
|
|
|
|
}
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::FreeLibraries(void)
|
1998-03-28 05:44:41 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->FreeLibraries();
|
1998-03-28 05:44:41 +03:00
|
|
|
}
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
nsresult
|
2000-01-25 00:28:28 +03:00
|
|
|
nsComponentManager::AutoRegister(PRInt32 when, nsIFile *directory)
|
1999-02-18 19:58:22 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-04-03 00:28:22 +04:00
|
|
|
return cm->AutoRegister(when, directory);
|
1999-02-18 19:58:22 +03:00
|
|
|
}
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
nsresult
|
1999-09-05 10:27:42 +04:00
|
|
|
nsComponentManager::AutoRegisterComponent(PRInt32 when,
|
2000-01-25 00:28:28 +03:00
|
|
|
nsIFile *fullname)
|
1998-03-28 05:44:41 +03:00
|
|
|
{
|
1999-03-09 12:44:27 +03:00
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-04-03 00:28:22 +04:00
|
|
|
return cm->AutoRegisterComponent(when, fullname);
|
1999-02-06 23:39:40 +03:00
|
|
|
}
|
1999-08-09 09:02:25 +04:00
|
|
|
|
2000-04-18 09:25:05 +04:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::AutoUnregisterComponent(PRInt32 when,
|
|
|
|
nsIFile *fullname)
|
|
|
|
{
|
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->AutoUnregisterComponent(when, fullname);
|
|
|
|
}
|
|
|
|
|
1999-08-09 09:02:25 +04:00
|
|
|
nsresult
|
|
|
|
nsComponentManager::IsRegistered(const nsCID &aClass,
|
|
|
|
PRBool *aRegistered)
|
|
|
|
{
|
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->IsRegistered(aClass, aRegistered);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsComponentManager::EnumerateCLSIDs(nsIEnumerator** aEmumerator)
|
|
|
|
{
|
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->EnumerateCLSIDs(aEmumerator);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsComponentManager::EnumerateProgIDs(nsIEnumerator** aEmumerator)
|
|
|
|
{
|
|
|
|
nsIComponentManager* cm;
|
|
|
|
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
return cm->EnumerateProgIDs(aEmumerator);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|