From 965f95d136620ec43d1da055aabfe28b10c2e648 Mon Sep 17 00:00:00 2001 From: "tague%netscape.com" Date: Tue, 9 Feb 1999 04:44:23 +0000 Subject: [PATCH] Added autoregistration to Windows locale DLL --- intl/locale/src/windows/nsLocaleDLL.cpp | 70 ++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/intl/locale/src/windows/nsLocaleDLL.cpp b/intl/locale/src/windows/nsLocaleDLL.cpp index 91f69f19644..9114abf42a1 100644 --- a/intl/locale/src/windows/nsLocaleDLL.cpp +++ b/intl/locale/src/windows/nsLocaleDLL.cpp @@ -28,7 +28,8 @@ #include "nsLocaleFactoryWin.h" #include "nsIWin32LocaleImpl.h" #include "nsIWin32LocaleFactory.h" - +#include "nsDateTimeFormatCID.h" +#include "nsCollationCID.h" // // kLocaleFactory for the nsILocaleFactory interface and friends // @@ -45,6 +46,9 @@ NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); NS_DEFINE_IID(kICollationFactoryIID, NS_ICOLLATIONFACTORY_IID); NS_DEFINE_IID(kICollationIID, NS_ICOLLATION_IID); NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID); +NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID); +NS_DEFINE_CID(kCollationCID, NS_COLLATION_CID); +NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID); extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* serviceMgr, nsIFactory **aFactory) @@ -105,3 +109,67 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* servi return res; } + +extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path) +{ + nsresult res; + + // + // register the generic factory + // + res = nsRepository::RegisterFactory(kLocaleFactoryCID,path,PR_TRUE,PR_TRUE); + NS_ASSERTION(res==NS_OK,"nsLocaleTest: RegisterFactory failed."); + if (res!=NS_OK) return res; + + // + // register the windows specific factory + // + res = nsRepository::RegisterFactory(kWin32LocaleFactoryCID,path,PR_TRUE,PR_TRUE); + NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register nsIWin32LocaleFactory failed."); + if (res!=NS_OK) return res; + + // + // register the collation factory + // + res = nsRepository::RegisterFactory(kCollationFactoryCID, path, PR_TRUE, PR_TRUE); + NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register CollationFactory failed."); + if (NS_FAILED(res)) return res; + + // + // register the collation interface + // + res = nsRepository::RegisterFactory(kCollationCID, path, PR_TRUE, PR_TRUE); + NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register Collation failed."); + if (NS_FAILED(res)) return res; + + // + // register the date time formatter + // + res = nsRepository::RegisterFactory(kDateTimeFormatCID, path, PR_TRUE, PR_TRUE); + NS_ASSERTION(res==NS_OK,"nsLocaleTest: Register DateTimeFormat failed."); + if (NS_FAILED(res)) return res; + + return NS_OK; +} + +extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char * path) +{ + nsresult res; + + res = nsRepository::UnregisterFactory(kLocaleFactoryCID, path); + if (res!=NS_OK) return res; + + res = nsRepository::UnregisterFactory(kWin32LocaleFactoryCID, path); + if (res!=NS_OK) return res; + + res = nsRepository::UnregisterFactory(kCollationFactoryCID, path); + if (res!=NS_OK) return res; + + res = nsRepository::UnregisterFactory(kCollationCID, path); + if (res!=NS_OK) return res; + + res = nsRepository::UnregisterFactory(kDateTimeFormatCID, path); + if (res!=NS_OK) return res; + + return NS_OK; +}