1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
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
13 : * License.
14 : *
15 : * The Original Code is Mozilla Communicator client code.
16 : *
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.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either the GNU General Public License Version 2 or later (the "GPL"), or
26 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #include "mozilla/ModuleUtils.h"
39 :
40 : #include "nsCOMPtr.h"
41 :
42 : #include "nspr.h"
43 : #include "nsString.h"
44 : #include "pratom.h"
45 : #include "nsUniversalCharDetDll.h"
46 : #include "nsISupports.h"
47 : #include "nsICategoryManager.h"
48 : #include "nsIComponentManager.h"
49 : #include "nsIServiceManager.h"
50 : #include "nsICharsetDetector.h"
51 : #include "nsIStringCharsetDetector.h"
52 :
53 : #include "nsUniversalDetector.h"
54 : #include "nsUdetXPCOMWrapper.h"
55 :
56 :
57 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsUniversalXPCOMDetector)
58 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsUniversalXPCOMStringDetector)
59 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAPSMDetector)
60 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAStringPSMDetector)
61 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsKOPSMDetector)
62 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsKOStringPSMDetector)
63 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsZHTWPSMDetector)
64 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsZHTWStringPSMDetector)
65 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsZHCNPSMDetector)
66 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsZHCNStringPSMDetector)
67 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsZHPSMDetector)
68 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsZHStringPSMDetector)
69 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsCJKPSMDetector)
70 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsCJKStringPSMDetector)
71 : NS_DEFINE_NAMED_CID(NS_UNIVERSAL_DETECTOR_CID);
72 : NS_DEFINE_NAMED_CID(NS_UNIVERSAL_STRING_DETECTOR_CID);
73 : NS_DEFINE_NAMED_CID(NS_JA_PSMDETECTOR_CID);
74 : NS_DEFINE_NAMED_CID(NS_JA_STRING_PSMDETECTOR_CID);
75 : NS_DEFINE_NAMED_CID(NS_KO_PSMDETECTOR_CID);
76 : NS_DEFINE_NAMED_CID(NS_KO_STRING_PSMDETECTOR_CID);
77 : NS_DEFINE_NAMED_CID(NS_ZHTW_PSMDETECTOR_CID);
78 : NS_DEFINE_NAMED_CID(NS_ZHTW_STRING_PSMDETECTOR_CID);
79 : NS_DEFINE_NAMED_CID(NS_ZHCN_PSMDETECTOR_CID);
80 : NS_DEFINE_NAMED_CID(NS_ZHCN_STRING_PSMDETECTOR_CID);
81 : NS_DEFINE_NAMED_CID(NS_ZH_PSMDETECTOR_CID);
82 : NS_DEFINE_NAMED_CID(NS_ZH_STRING_PSMDETECTOR_CID);
83 : NS_DEFINE_NAMED_CID(NS_CJK_PSMDETECTOR_CID);
84 : NS_DEFINE_NAMED_CID(NS_CJK_STRING_PSMDETECTOR_CID);
85 :
86 : static const mozilla::Module::CIDEntry kChardetCIDs[] = {
87 : { &kNS_UNIVERSAL_DETECTOR_CID, false, NULL, nsUniversalXPCOMDetectorConstructor },
88 : { &kNS_UNIVERSAL_STRING_DETECTOR_CID, false, NULL, nsUniversalXPCOMStringDetectorConstructor },
89 : { &kNS_JA_PSMDETECTOR_CID, false, NULL, nsJAPSMDetectorConstructor },
90 : { &kNS_JA_STRING_PSMDETECTOR_CID, false, NULL, nsJAStringPSMDetectorConstructor },
91 : { &kNS_KO_PSMDETECTOR_CID, false, NULL, nsKOPSMDetectorConstructor },
92 : { &kNS_KO_STRING_PSMDETECTOR_CID, false, NULL, nsKOStringPSMDetectorConstructor },
93 : { &kNS_ZHTW_PSMDETECTOR_CID, false, NULL, nsZHTWPSMDetectorConstructor },
94 : { &kNS_ZHTW_STRING_PSMDETECTOR_CID, false, NULL, nsZHTWStringPSMDetectorConstructor },
95 : { &kNS_ZHCN_PSMDETECTOR_CID, false, NULL, nsZHCNPSMDetectorConstructor },
96 : { &kNS_ZHCN_STRING_PSMDETECTOR_CID, false, NULL, nsZHCNStringPSMDetectorConstructor },
97 : { &kNS_ZH_PSMDETECTOR_CID, false, NULL, nsZHPSMDetectorConstructor },
98 : { &kNS_ZH_STRING_PSMDETECTOR_CID, false, NULL, nsZHStringPSMDetectorConstructor },
99 : { &kNS_CJK_PSMDETECTOR_CID, false, NULL, nsCJKPSMDetectorConstructor },
100 : { &kNS_CJK_STRING_PSMDETECTOR_CID, false, NULL, nsCJKStringPSMDetectorConstructor },
101 : { NULL }
102 : };
103 :
104 : static const mozilla::Module::ContractIDEntry kChardetContracts[] = {
105 : { NS_CHARSET_DETECTOR_CONTRACTID_BASE "universal_charset_detector", &kNS_UNIVERSAL_DETECTOR_CID },
106 : { NS_STRCDETECTOR_CONTRACTID_BASE "universal_charset_detector", &kNS_UNIVERSAL_STRING_DETECTOR_CID },
107 : { NS_CHARSET_DETECTOR_CONTRACTID_BASE "ja_parallel_state_machine", &kNS_JA_PSMDETECTOR_CID },
108 : { NS_STRCDETECTOR_CONTRACTID_BASE "ja_parallel_state_machine", &kNS_JA_STRING_PSMDETECTOR_CID },
109 : { NS_CHARSET_DETECTOR_CONTRACTID_BASE "ko_parallel_state_machine", &kNS_KO_PSMDETECTOR_CID },
110 : { NS_STRCDETECTOR_CONTRACTID_BASE "ko_parallel_state_machine", &kNS_KO_STRING_PSMDETECTOR_CID },
111 : { NS_CHARSET_DETECTOR_CONTRACTID_BASE "zhtw_parallel_state_machine", &kNS_ZHTW_PSMDETECTOR_CID },
112 : { NS_STRCDETECTOR_CONTRACTID_BASE "zhtw_parallel_state_machine", &kNS_ZHTW_STRING_PSMDETECTOR_CID },
113 : { NS_CHARSET_DETECTOR_CONTRACTID_BASE "zhcn_parallel_state_machine", &kNS_ZHCN_PSMDETECTOR_CID },
114 : { NS_STRCDETECTOR_CONTRACTID_BASE "zhcn_parallel_state_machine", &kNS_ZHCN_STRING_PSMDETECTOR_CID },
115 : { NS_CHARSET_DETECTOR_CONTRACTID_BASE "zh_parallel_state_machine", &kNS_ZH_PSMDETECTOR_CID },
116 : { NS_STRCDETECTOR_CONTRACTID_BASE "zh_parallel_state_machine", &kNS_ZH_STRING_PSMDETECTOR_CID },
117 : { NS_CHARSET_DETECTOR_CONTRACTID_BASE "cjk_parallel_state_machine", &kNS_CJK_PSMDETECTOR_CID },
118 : { NS_STRCDETECTOR_CONTRACTID_BASE "cjk_parallel_state_machine", &kNS_CJK_STRING_PSMDETECTOR_CID },
119 : { NULL }
120 : };
121 :
122 : static const mozilla::Module::CategoryEntry kChardetCategories[] = {
123 : { NS_CHARSET_DETECTOR_CATEGORY, "universal_charset_detector", NS_CHARSET_DETECTOR_CONTRACTID_BASE "universal_charset_detector" },
124 : { NS_CHARSET_DETECTOR_CATEGORY, "ja_parallel_state_machine", NS_CHARSET_DETECTOR_CONTRACTID_BASE "ja_parallel_state_machine" },
125 : { NS_CHARSET_DETECTOR_CATEGORY, "ko_parallel_state_machine", NS_CHARSET_DETECTOR_CONTRACTID_BASE "ko_parallel_state_machine" },
126 : { NS_CHARSET_DETECTOR_CATEGORY, "zhtw_parallel_state_machine", NS_CHARSET_DETECTOR_CONTRACTID_BASE "zhtw_parallel_state_machine" },
127 : { NS_CHARSET_DETECTOR_CATEGORY, "zhcn_parallel_state_machine", NS_CHARSET_DETECTOR_CONTRACTID_BASE "zhcn_parallel_state_machine" },
128 : { NS_CHARSET_DETECTOR_CATEGORY, "zh_parallel_state_machine", NS_CHARSET_DETECTOR_CONTRACTID_BASE "zh_parallel_state_machine" },
129 : { NS_CHARSET_DETECTOR_CATEGORY, "cjk_parallel_state_machine", NS_CHARSET_DETECTOR_CONTRACTID_BASE "cjk_parallel_state_machine" },
130 : { NULL }
131 : };
132 :
133 : static const mozilla::Module kChardetModule = {
134 : mozilla::Module::kVersion,
135 : kChardetCIDs,
136 : kChardetContracts,
137 : kChardetCategories
138 : };
139 :
140 : NSMODULE_DEFN(nsUniversalCharDetModule) = &kChardetModule;
|