1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the NPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the NPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
39
#include "nsIGenericFactory.h"
41
#include "nsICategoryManager.h"
42
#include "nsIServiceManager.h"
45
#include "nsCharDetConstructors.h"
48
#include "nsLWBrkConstructors.h"
49
#include "nsSemanticUnitScanner.h"
52
#include "nsUcharUtilConstructors.h"
54
// string bundles (intl)
55
#include "nsStrBundleConstructors.h"
58
#include "nsLocaleConstructors.h"
61
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSemanticUnitScanner)
64
AddCategoryEntry(const char* category,
69
nsCOMPtr<nsICategoryManager>
70
categoryManager(do_GetService("@mozilla.org/categorymanager;1", &rv));
71
if (NS_FAILED(rv)) return rv;
73
return categoryManager->AddCategoryEntry(category, key, value,
79
DeleteCategoryEntry(const char* category,
83
nsCOMPtr<nsICategoryManager>
84
categoryManager(do_GetService("@mozilla.org/categorymanager;1", &rv));
85
if (NS_FAILED(rv)) return rv;
87
return categoryManager->DeleteCategoryEntry(category, key, PR_TRUE);
91
nsMetaCharsetObserverRegistrationProc(nsIComponentManager *aCompMgr,
93
const char *registryLocation,
94
const char *componentType,
95
const nsModuleComponentInfo *info)
97
return AddCategoryEntry("parser-service-category",
98
"Meta Charset Service",
99
NS_META_CHARSET_CONTRACTID);
103
nsMetaCharsetObserverUnegistrationProc(nsIComponentManager *aCompMgr,
105
const char *registryLocation,
106
const nsModuleComponentInfo *info)
108
return DeleteCategoryEntry("parser-service-category",
109
"Meta Charset Service");
113
nsDetectionAdaptorRegistrationProc(nsIComponentManager *aCompMgr,
115
const char *registryLocation,
116
const char *componentType,
117
const nsModuleComponentInfo *info)
119
return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY, "off", "off");
123
nsJAPSMDetectorRegistrationProc(nsIComponentManager *aCompMgr,
125
const char *registryLocation,
126
const char *componentType,
127
const nsModuleComponentInfo *info)
129
return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
130
"ja_parallel_state_machine",
135
nsKOPSMDetectorRegistrationProc(nsIComponentManager *aCompMgr,
137
const char *registryLocation,
138
const char *componentType,
139
const nsModuleComponentInfo *info)
141
return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
142
"ko_parallel_state_machine",
147
nsZHTWPSMDetectorRegistrationProc(nsIComponentManager *aCompMgr,
149
const char *registryLocation,
150
const char *componentType,
151
const nsModuleComponentInfo *info)
153
return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
154
"zhtw_parallel_state_machine",
159
nsZHCNPSMDetectorRegistrationProc(nsIComponentManager *aCompMgr,
161
const char *registryLocation,
162
const char *componentType,
163
const nsModuleComponentInfo *info)
165
return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
166
"zhcn_parallel_state_machine",
171
nsZHPSMDetectorRegistrationProc(nsIComponentManager *aCompMgr,
173
const char *registryLocation,
174
const char *componentType,
175
const nsModuleComponentInfo *info)
177
return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
178
"zh_parallel_state_machine",
183
nsCJKPSMDetectorRegistrationProc(nsIComponentManager *aCompMgr,
185
const char *registryLocation,
186
const char *componentType,
187
const nsModuleComponentInfo *info)
189
return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
190
"cjk_parallel_state_machine",
195
nsRUProbDetectorRegistrationProc(nsIComponentManager *aCompMgr,
197
const char *registryLocation,
198
const char *componentType,
199
const nsModuleComponentInfo *info)
201
return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
207
nsUKProbDetectorRegistrationProc(nsIComponentManager *aCompMgr,
209
const char *registryLocation,
210
const char *componentType,
211
const nsModuleComponentInfo *info)
213
return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
219
static nsModuleComponentInfo components[] =
222
{ "Meta Charset", NS_META_CHARSET_CID,
223
NS_META_CHARSET_CONTRACTID, nsMetaCharsetObserverConstructor,
224
nsMetaCharsetObserverRegistrationProc, nsMetaCharsetObserverUnegistrationProc,
226
{ "Document Charset Info", NS_DOCUMENTCHARSETINFO_CID,
227
NS_DOCUMENTCHARSETINFO_CONTRACTID, nsDocumentCharsetInfoConstructor,
229
{ "XML Encoding", NS_XML_ENCODING_CID,
230
NS_XML_ENCODING_CONTRACTID, nsXMLEncodingObserverConstructor,
232
{ "Charset Detection Adaptor", NS_CHARSET_DETECTION_ADAPTOR_CID,
233
NS_CHARSET_DETECTION_ADAPTOR_CONTRACTID, nsDetectionAdaptorConstructor,
234
nsDetectionAdaptorRegistrationProc, NULL},
235
{ "PSM based Japanese Charset Detector", NS_JA_PSMDETECTOR_CID,
236
NS_CHARSET_DETECTOR_CONTRACTID_BASE "ja_parallel_state_machine", nsJAPSMDetectorConstructor,
237
nsJAPSMDetectorRegistrationProc, NULL},
238
{ "PSM based Japanese String Charset Detector", NS_JA_STRING_PSMDETECTOR_CID,
239
NS_STRCDETECTOR_CONTRACTID_BASE "ja_parallel_state_machine", nsJAStringPSMDetectorConstructor,
241
{ "PSM based Korean Charset Detector", NS_KO_PSMDETECTOR_CID,
242
NS_CHARSET_DETECTOR_CONTRACTID_BASE "ko_parallel_state_machine", nsKOPSMDetectorConstructor,
243
nsKOPSMDetectorRegistrationProc, NULL},
244
{ "PSM based Korean String Charset Detector", NS_KO_STRING_PSMDETECTOR_CID,
245
NS_STRCDETECTOR_CONTRACTID_BASE "ko_parallel_state_machine", nsKOStringPSMDetectorConstructor,
247
{ "PSM based Traditional Chinese Charset Detector", NS_ZHTW_PSMDETECTOR_CID,
248
NS_CHARSET_DETECTOR_CONTRACTID_BASE "zhtw_parallel_state_machine", nsZHTWPSMDetectorConstructor,
249
nsZHTWPSMDetectorRegistrationProc, NULL},
250
{ "PSM based Traditional Chinese String Charset Detector", NS_ZHTW_STRING_PSMDETECTOR_CID,
251
NS_STRCDETECTOR_CONTRACTID_BASE "zhtw_parallel_state_machine", nsZHTWStringPSMDetectorConstructor,
253
{ "PSM based Simplified Chinese Charset Detector", NS_ZHCN_PSMDETECTOR_CID,
254
NS_CHARSET_DETECTOR_CONTRACTID_BASE "zhcn_parallel_state_machine", nsZHCNPSMDetectorConstructor,
255
nsZHCNPSMDetectorRegistrationProc, NULL},
256
{ "PSM based Simplified Chinese String Charset Detector", NS_ZHCN_STRING_PSMDETECTOR_CID,
257
NS_STRCDETECTOR_CONTRACTID_BASE "zhcn_parallel_state_machine", nsZHCNStringPSMDetectorConstructor,
259
{ "PSM based Chinese Charset Detector", NS_ZH_PSMDETECTOR_CID,
260
NS_CHARSET_DETECTOR_CONTRACTID_BASE "zh_parallel_state_machine", nsZHPSMDetectorConstructor,
261
nsZHPSMDetectorRegistrationProc, NULL},
262
{ "PSM based Chinese String Charset Detector", NS_ZH_STRING_PSMDETECTOR_CID,
263
NS_STRCDETECTOR_CONTRACTID_BASE "zh_parallel_state_machine", nsZHStringPSMDetectorConstructor,
265
{ "PSM based CJK Charset Detector", NS_CJK_PSMDETECTOR_CID,
266
NS_CHARSET_DETECTOR_CONTRACTID_BASE "cjk_parallel_state_machine", nsCJKPSMDetectorConstructor,
267
nsCJKPSMDetectorRegistrationProc, NULL},
268
{ "PSM based CJK String Charset Detector", NS_CJK_STRING_PSMDETECTOR_CID,
269
NS_STRCDETECTOR_CONTRACTID_BASE "cjk_parallel_state_machine", nsCJKStringPSMDetectorConstructor,
271
{ "Probability based Russian Charset Detector", NS_RU_PROBDETECTOR_CID,
272
NS_CHARSET_DETECTOR_CONTRACTID_BASE "ruprob", nsRUProbDetectorConstructor,
273
nsRUProbDetectorRegistrationProc, NULL},
274
{ "Probability based Ukrainian Charset Detector", NS_UK_PROBDETECTOR_CID,
275
NS_CHARSET_DETECTOR_CONTRACTID_BASE "ukprob", nsUKProbDetectorConstructor,
276
nsUKProbDetectorRegistrationProc, NULL},
277
{ "Probability based Russian String Charset Detector", NS_RU_STRING_PROBDETECTOR_CID,
278
NS_STRCDETECTOR_CONTRACTID_BASE "ruprob", nsRUStringProbDetectorConstructor,
280
{ "Probability based Ukrainian String Charset Detector", NS_UK_STRING_PROBDETECTOR_CID,
281
NS_STRCDETECTOR_CONTRACTID_BASE "ukprob", nsUKStringProbDetectorConstructor,
283
#ifdef INCLUDE_DBGDETECTOR
284
{ "Debugging Detector 1st block", NS_1STBLKDBG_DETECTOR_CID,
285
NS_CHARSET_DETECTOR_CONTRACTID_BASE "1stblkdbg", ns1stBlkDbgDetectorConstructor,
287
{ "Debugging Detector 2nd block", NS_2NDBLKDBG_DETECTOR_CID,
288
NS_CHARSET_DETECTOR_CONTRACTID_BASE "2ndblkdbg", ns2ndBlkDbgDetectorConstructor,
290
{ "Debugging Detector Last block", NS_LASTBLKDBG_DETECTOR_CID,
291
NS_CHARSET_DETECTOR_CONTRACTID_BASE "lastblkdbg", nsLastBlkDbgDetectorConstructor,
293
#endif /* INCLUDE_DBGDETECTOR */
295
{ "Line and Word Breaker", NS_LWBRK_CID,
296
NS_LWBRK_CONTRACTID, nsLWBreakerFImpConstructor},
297
{ "Semantic Unit Scanner", NS_SEMANTICUNITSCANNER_CID,
298
NS_SEMANTICUNITSCANNER_CONTRACTID, nsSemanticUnitScannerConstructor},
301
{ "Unichar Utility", NS_UNICHARUTIL_CID,
302
NS_UNICHARUTIL_CONTRACTID, nsCaseConversionImp2Constructor},
303
{ "Unicode To Entity Converter", NS_ENTITYCONVERTER_CID,
304
NS_ENTITYCONVERTER_CONTRACTID, nsEntityConverterConstructor },
305
{ "Unicode To Charset Converter", NS_SAVEASCHARSET_CID,
306
NS_SAVEASCHARSET_CONTRACTID, nsSaveAsCharsetConstructor},
307
{ "Japanese Hankaku To Zenkaku", NS_HANKAKUTOZENKAKU_CID,
308
NS_HANKAKUTOZENKAKU_CONTRACTID, CreateNewHankakuToZenkaku},
309
{ "Unicode Normlization", NS_UNICODE_NORMALIZER_CID,
310
NS_UNICODE_NORMALIZER_CONTRACTID, nsUnicodeNormalizerConstructor},
314
{ "String Bundle", NS_STRINGBUNDLESERVICE_CID, NS_STRINGBUNDLE_CONTRACTID,
315
nsStringBundleServiceConstructor},
316
{ "String Textfile Overrides", NS_STRINGBUNDLETEXTOVERRIDE_CID,
317
NS_STRINGBUNDLETEXTOVERRIDE_CONTRACTID,
318
nsStringBundleTextOverrideConstructor },
321
{ "nsLocaleService component",
322
NS_LOCALESERVICE_CID,
323
NS_LOCALESERVICE_CONTRACTID,
324
CreateLocaleService },
325
{ "Collation factory",
326
NS_COLLATIONFACTORY_CID,
327
NS_COLLATIONFACTORY_CONTRACTID,
328
nsCollationFactoryConstructor },
329
{ "Scriptable Date Format",
330
NS_SCRIPTABLEDATEFORMAT_CID,
331
NS_SCRIPTABLEDATEFORMAT_CONTRACTID,
332
NS_NewScriptableDateFormat },
333
{ "Language Atom Service",
334
NS_LANGUAGEATOMSERVICE_CID,
335
NS_LANGUAGEATOMSERVICE_CONTRACTID,
336
nsLanguageAtomServiceConstructor },
337
{ "Font Package Service",
338
NS_FONTPACKAGESERVICE_CID,
339
NS_FONTPACKAGESERVICE_CONTRACTID,
340
nsFontPackageServiceConstructor },
345
NS_WIN32LOCALE_CONTRACTID,
346
nsIWin32LocaleImplConstructor },
349
NS_COLLATION_CONTRACTID,
350
nsCollationWinConstructor },
351
{ "Date/Time formatter",
352
NS_DATETIMEFORMAT_CID,
354
nsDateTimeFormatWinConstructor },
357
#ifdef USE_UNIX_LOCALE
360
NS_POSIXLOCALE_CONTRACTID,
361
nsPosixLocaleConstructor },
365
NS_COLLATION_CONTRACTID,
366
nsCollationUnixConstructor },
368
{ "Date/Time formatter",
369
NS_DATETIMEFORMAT_CID,
371
nsDateTimeFormatUnixConstructor },
374
#ifdef USE_MAC_LOCALE
377
NS_MACLOCALE_CONTRACTID,
378
nsMacLocaleConstructor },
381
NS_COLLATION_CONTRACTID,
382
#ifdef USE_UCCOLLATIONKEY
383
nsCollationMacUCConstructor },
385
nsCollationMacConstructor },
387
{ "Date/Time formatter",
388
NS_DATETIMEFORMAT_CID,
390
nsDateTimeFormatMacConstructor },
396
NS_OS2LOCALE_CONTRACTID,
397
nsOS2LocaleConstructor },
400
NS_COLLATION_CONTRACTID,
401
nsCollationOS2Constructor },
402
{ "Date/Time formatter",
403
NS_DATETIMEFORMAT_CID,
405
nsDateTimeFormatOS2Constructor },
411
NS_IMPL_NSGETMODULE(nsI18nModule, components)