mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Using the registry for converter info. Should improve startup performance.
This commit is contained in:
parent
149f718e80
commit
f15ef21611
@ -22,6 +22,9 @@
|
||||
#include "pratom.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsICharsetConverterInfo.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
@ -206,10 +209,108 @@ nsresult nsCharsetConverterManager::CreateMapping()
|
||||
{
|
||||
mMappingDone = PR_TRUE;
|
||||
|
||||
nsresult res = NS_OK;
|
||||
nsIRegistry * registry = NULL;
|
||||
nsIEnumerator * components = NULL;
|
||||
nsIRegistry::Key key;
|
||||
char buff[1024];
|
||||
|
||||
// XXX hack; make these dynamic
|
||||
mEncArray = new ConverterInfo [100];
|
||||
mDecArray = new ConverterInfo [100];
|
||||
mEncSize = mDecSize = 0;
|
||||
|
||||
// get the registry
|
||||
res = nsServiceManager::GetService(NS_REGISTRY_PROGID,
|
||||
nsIRegistry::GetIID(),
|
||||
(nsISupports**)®istry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// open the registry
|
||||
res = registry->OpenWellKnownRegistry(
|
||||
nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// get subtree
|
||||
res = registry -> GetSubtree(nsIRegistry::Common,
|
||||
"software/netscape/intl/uconv",
|
||||
&key);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// enumerate subtrees
|
||||
res = registry -> EnumerateSubtrees(key, &components);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = components -> First();
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// XXX take these KONSTANTS out of here
|
||||
// XXX check return values, free stuff
|
||||
// XXX bit hacky, clean me up
|
||||
|
||||
while (!components -> IsDone()) {
|
||||
nsISupports * base;
|
||||
res = components -> CurrentItem(&base);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
nsIRegistryNode * node;
|
||||
nsIID nodeIID = NS_IREGISTRYNODE_IID;
|
||||
res = base->QueryInterface (nodeIID, (void**)&node);
|
||||
if (NS_FAILED(res)) continue;
|
||||
|
||||
char *name;
|
||||
res = node->GetName(&name);
|
||||
if (NS_FAILED(res)) continue;
|
||||
|
||||
nsCID * cid = new nsCID();
|
||||
char * src;
|
||||
char * dest;
|
||||
if (!cid->Parse(name)) continue;
|
||||
|
||||
sprintf(buff, "%s/%s", "software/netscape/intl/uconv", name);
|
||||
res = registry -> GetSubtree(nsIRegistry::Common, buff, &key);
|
||||
|
||||
res = registry->GetString(key, "source", &src);
|
||||
if (NS_FAILED(res)) continue;
|
||||
res = registry->GetString(key, "destination", &dest);
|
||||
if (NS_FAILED(res)) continue;
|
||||
|
||||
nsString * str;
|
||||
|
||||
if (!strcmp(src, "Unicode")) {
|
||||
str = new nsString(dest);
|
||||
GetCharsetName(str,&mEncArray[mEncSize].mCharset);
|
||||
mEncArray[mEncSize].mCID = cid;
|
||||
mEncSize++;
|
||||
} else if (!strcmp(dest, "Unicode")) {
|
||||
str = new nsString(src);
|
||||
GetCharsetName(str,&mDecArray[mDecSize].mCharset);
|
||||
mDecArray[mDecSize].mCID = cid;
|
||||
mDecSize++;
|
||||
}
|
||||
|
||||
nsCRT::free(name);
|
||||
NS_RELEASE(node);
|
||||
NS_RELEASE(base);
|
||||
}
|
||||
|
||||
res = components->Next();
|
||||
}
|
||||
|
||||
done:
|
||||
if (registry != NULL) {
|
||||
registry -> Close();
|
||||
nsServiceManager::ReleaseService(NS_REGISTRY_PROGID, registry);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
/* XXX old code
|
||||
mMappingDone = PR_TRUE;
|
||||
|
||||
nsresult res = CreateConvertersList();
|
||||
if NS_FAILED(res) return res;
|
||||
|
||||
return GatherConvertersInfo();
|
||||
*/
|
||||
}
|
||||
|
||||
// XXX Hack! These lists should be obtained from the Repository, in a Component
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICharsetConverterInfo.h"
|
||||
#include "nsUCvCnCID.h"
|
||||
@ -177,28 +178,63 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path)
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports * aServMgr,
|
||||
const char * path)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult res;
|
||||
PRUint32 i;
|
||||
nsIComponentManager * compMgr = NULL;
|
||||
nsIRegistry * registry = NULL;
|
||||
nsIRegistry::Key key;
|
||||
char buff[1024];
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// get the service manager
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &res));
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// get the component manager
|
||||
res = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
rv = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
// get the registry
|
||||
res = servMgr->GetService(NS_REGISTRY_PROGID,
|
||||
nsIRegistry::GetIID(),
|
||||
(nsISupports**)®istry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// open the registry
|
||||
res = registry->OpenWellKnownRegistry(
|
||||
nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
// register component
|
||||
res = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) goto done;
|
||||
|
||||
// register component info
|
||||
// XXX take these KONSTANTS out of here
|
||||
// XXX free the string from "ToString()"
|
||||
sprintf(buff, "%s/%s", "software/netscape/intl/uconv", (g_FactoryData[i].mCID -> ToString()));
|
||||
res = registry -> AddSubtree(nsIRegistry::Common, buff, &key);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "source", g_FactoryData[i].mCharsetSrc);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "destination", g_FactoryData[i].mCharsetDest);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
done:
|
||||
if (compMgr != NULL)
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
if (registry != NULL) {
|
||||
registry -> Close();
|
||||
(void)servMgr->ReleaseService(NS_REGISTRY_PROGID, registry);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICharsetConverterInfo.h"
|
||||
#include "nsUCVJACID.h"
|
||||
@ -158,28 +159,63 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path)
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports * aServMgr,
|
||||
const char * path)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult res;
|
||||
PRUint32 i;
|
||||
nsIComponentManager * compMgr = NULL;
|
||||
nsIRegistry * registry = NULL;
|
||||
nsIRegistry::Key key;
|
||||
char buff[1024];
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// get the service manager
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &res));
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// get the component manager
|
||||
res = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
rv = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
// get the registry
|
||||
res = servMgr->GetService(NS_REGISTRY_PROGID,
|
||||
nsIRegistry::GetIID(),
|
||||
(nsISupports**)®istry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// open the registry
|
||||
res = registry->OpenWellKnownRegistry(
|
||||
nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
// register component
|
||||
res = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) goto done;
|
||||
|
||||
// register component info
|
||||
// XXX take these KONSTANTS out of here
|
||||
// XXX free the string from "ToString()"
|
||||
sprintf(buff, "%s/%s", "software/netscape/intl/uconv", (g_FactoryData[i].mCID -> ToString()));
|
||||
res = registry -> AddSubtree(nsIRegistry::Common, buff, &key);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "source", g_FactoryData[i].mCharsetSrc);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "destination", g_FactoryData[i].mCharsetDest);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
done:
|
||||
if (compMgr != NULL)
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
if (registry != NULL) {
|
||||
registry -> Close();
|
||||
(void)servMgr->ReleaseService(NS_REGISTRY_PROGID, registry);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICharsetConverterInfo.h"
|
||||
#include "nsUCVJA2CID.h"
|
||||
@ -217,28 +218,63 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path)
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports * aServMgr,
|
||||
const char * path)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult res;
|
||||
PRUint32 i;
|
||||
nsIComponentManager * compMgr = NULL;
|
||||
nsIRegistry * registry = NULL;
|
||||
nsIRegistry::Key key;
|
||||
char buff[1024];
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// get the service manager
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &res));
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// get the component manager
|
||||
res = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
rv = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
// get the registry
|
||||
res = servMgr->GetService(NS_REGISTRY_PROGID,
|
||||
nsIRegistry::GetIID(),
|
||||
(nsISupports**)®istry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// open the registry
|
||||
res = registry->OpenWellKnownRegistry(
|
||||
nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
// register component
|
||||
res = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) goto done;
|
||||
|
||||
// register component info
|
||||
// XXX take these KONSTANTS out of here
|
||||
// XXX free the string from "ToString()"
|
||||
sprintf(buff, "%s/%s", "software/netscape/intl/uconv", (g_FactoryData[i].mCID -> ToString()));
|
||||
res = registry -> AddSubtree(nsIRegistry::Common, buff, &key);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "source", g_FactoryData[i].mCharsetSrc);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "destination", g_FactoryData[i].mCharsetDest);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
done:
|
||||
if (compMgr != NULL)
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
if (registry != NULL) {
|
||||
registry -> Close();
|
||||
(void)servMgr->ReleaseService(NS_REGISTRY_PROGID, registry);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICharsetConverterInfo.h"
|
||||
#include "nsUCvKOCID.h"
|
||||
@ -178,28 +179,63 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path)
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports * aServMgr,
|
||||
const char * path)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult res;
|
||||
PRUint32 i;
|
||||
nsIComponentManager * compMgr = NULL;
|
||||
nsIRegistry * registry = NULL;
|
||||
nsIRegistry::Key key;
|
||||
char buff[1024];
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// get the service manager
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &res));
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// get the component manager
|
||||
res = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
rv = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
// get the registry
|
||||
res = servMgr->GetService(NS_REGISTRY_PROGID,
|
||||
nsIRegistry::GetIID(),
|
||||
(nsISupports**)®istry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// open the registry
|
||||
res = registry->OpenWellKnownRegistry(
|
||||
nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
// register component
|
||||
res = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) goto done;
|
||||
|
||||
// register component info
|
||||
// XXX take these KONSTANTS out of here
|
||||
// XXX free the string from "ToString()"
|
||||
sprintf(buff, "%s/%s", "software/netscape/intl/uconv", (g_FactoryData[i].mCID -> ToString()));
|
||||
res = registry -> AddSubtree(nsIRegistry::Common, buff, &key);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "source", g_FactoryData[i].mCharsetSrc);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "destination", g_FactoryData[i].mCharsetDest);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
done:
|
||||
if (compMgr != NULL)
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
if (registry != NULL) {
|
||||
registry -> Close();
|
||||
(void)servMgr->ReleaseService(NS_REGISTRY_PROGID, registry);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path)
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "pratom.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICharsetConverterInfo.h"
|
||||
@ -845,7 +846,66 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path)
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports * aServMgr,
|
||||
const char * path)
|
||||
{
|
||||
nsresult res;
|
||||
PRUint32 i;
|
||||
nsIComponentManager * compMgr = NULL;
|
||||
nsIRegistry * registry = NULL;
|
||||
nsIRegistry::Key key;
|
||||
char buff[1024];
|
||||
|
||||
// get the service manager
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &res));
|
||||
|
||||
// get the component manager
|
||||
res = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// get the registry
|
||||
res = servMgr->GetService(NS_REGISTRY_PROGID,
|
||||
nsIRegistry::GetIID(),
|
||||
(nsISupports**)®istry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// open the registry
|
||||
res = registry->OpenWellKnownRegistry(
|
||||
nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
// register component
|
||||
res = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) goto done;
|
||||
|
||||
// register component info
|
||||
// XXX take these KONSTANTS out of here
|
||||
// XXX free the string from "ToString()"
|
||||
sprintf(buff, "%s/%s", "software/netscape/intl/uconv", (g_FactoryData[i].mCID -> ToString()));
|
||||
res = registry -> AddSubtree(nsIRegistry::Common, buff, &key);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "source", g_FactoryData[i].mCharsetSrc);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "destination", g_FactoryData[i].mCharsetDest);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
if (compMgr != NULL)
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
if (registry != NULL) {
|
||||
registry -> Close();
|
||||
(void)servMgr->ReleaseService(NS_REGISTRY_PROGID, registry);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf_0(nsISupports* aServMgr, const char * path)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICharsetConverterInfo.h"
|
||||
#include "nsUCvTWCID.h"
|
||||
@ -176,28 +177,63 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path)
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports * aServMgr,
|
||||
const char * path)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult res;
|
||||
PRUint32 i;
|
||||
nsIComponentManager * compMgr = NULL;
|
||||
nsIRegistry * registry = NULL;
|
||||
nsIRegistry::Key key;
|
||||
char buff[1024];
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// get the service manager
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &res));
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// get the component manager
|
||||
res = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
rv = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
// get the registry
|
||||
res = servMgr->GetService(NS_REGISTRY_PROGID,
|
||||
nsIRegistry::GetIID(),
|
||||
(nsISupports**)®istry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// open the registry
|
||||
res = registry->OpenWellKnownRegistry(
|
||||
nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
// register component
|
||||
res = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) goto done;
|
||||
|
||||
// register component info
|
||||
// XXX take these KONSTANTS out of here
|
||||
// XXX free the string from "ToString()"
|
||||
sprintf(buff, "%s/%s", "software/netscape/intl/uconv", (g_FactoryData[i].mCID -> ToString()));
|
||||
res = registry -> AddSubtree(nsIRegistry::Common, buff, &key);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "source", g_FactoryData[i].mCharsetSrc);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "destination", g_FactoryData[i].mCharsetDest);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
done:
|
||||
if (compMgr != NULL)
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
if (registry != NULL) {
|
||||
registry -> Close();
|
||||
(void)servMgr->ReleaseService(NS_REGISTRY_PROGID, registry);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICharsetConverterInfo.h"
|
||||
#include "nsUCvTW2CID.h"
|
||||
@ -255,28 +256,63 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char * path)
|
||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports * aServMgr,
|
||||
const char * path)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult res;
|
||||
PRUint32 i;
|
||||
nsIComponentManager * compMgr = NULL;
|
||||
nsIRegistry * registry = NULL;
|
||||
nsIRegistry::Key key;
|
||||
char buff[1024];
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// get the service manager
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &res));
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// get the component manager
|
||||
res = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
rv = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
// get the registry
|
||||
res = servMgr->GetService(NS_REGISTRY_PROGID,
|
||||
nsIRegistry::GetIID(),
|
||||
(nsISupports**)®istry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// open the registry
|
||||
res = registry->OpenWellKnownRegistry(
|
||||
nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
for (i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
// register component
|
||||
res = compMgr->RegisterComponent(*(g_FactoryData[i].mCID), NULL, NULL,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) goto done;
|
||||
|
||||
// register component info
|
||||
// XXX take these KONSTANTS out of here
|
||||
// XXX free the string from "ToString()"
|
||||
sprintf(buff, "%s/%s", "software/netscape/intl/uconv", (g_FactoryData[i].mCID -> ToString()));
|
||||
res = registry -> AddSubtree(nsIRegistry::Common, buff, &key);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "source", g_FactoryData[i].mCharsetSrc);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetString(key, "destination", g_FactoryData[i].mCharsetDest);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
done:
|
||||
if (compMgr != NULL)
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
if (registry != NULL) {
|
||||
registry -> Close();
|
||||
(void)servMgr->ReleaseService(NS_REGISTRY_PROGID, registry);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char * path)
|
||||
|
Loading…
Reference in New Issue
Block a user