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.org 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 : #ifndef _nsUdetXPCOMWrapper_h__
39 : #define _nsUdetXPCOMWrapper_h__
40 : #include "nsISupports.h"
41 : #include "nsICharsetDetector.h"
42 : #include "nsIStringCharsetDetector.h"
43 : #include "nsICharsetDetectionObserver.h"
44 : #include "nsCOMPtr.h"
45 :
46 : #include "nsIFactory.h"
47 :
48 : // {374E0CDE-F605-4259-8C92-E639C6C2EEEF}
49 : #define NS_UNIVERSAL_DETECTOR_CID \
50 : { 0x374e0cde, 0xf605, 0x4259, { 0x8c, 0x92, 0xe6, 0x39, 0xc6, 0xc2, 0xee, 0xef } }
51 :
52 : // {6EE5301A-3981-49bd-85F8-1A2CC228CF3E}
53 : #define NS_UNIVERSAL_STRING_DETECTOR_CID \
54 : { 0x6ee5301a, 0x3981, 0x49bd, { 0x85, 0xf8, 0x1a, 0x2c, 0xc2, 0x28, 0xcf, 0x3e } }
55 :
56 : // {12BB8F1B-2389-11d3-B3BF-00805F8A6670}
57 : #define NS_JA_PSMDETECTOR_CID \
58 : { 0x12bb8f1b, 0x2389, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
59 :
60 : // {12BB8F1C-2389-11d3-B3BF-00805F8A6670}
61 : #define NS_JA_STRING_PSMDETECTOR_CID \
62 : { 0x12bb8f1c, 0x2389, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
63 :
64 : // {EA06D4E1-2B3D-11d3-B3BF-00805F8A6670}
65 : #define NS_KO_PSMDETECTOR_CID \
66 : { 0xea06d4e1, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
67 :
68 : // {EA06D4E2-2B3D-11d3-B3BF-00805F8A6670}
69 : #define NS_ZHCN_PSMDETECTOR_CID \
70 : { 0xea06d4e2, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
71 :
72 : // {EA06D4E3-2B3D-11d3-B3BF-00805F8A6670}
73 : #define NS_ZHTW_PSMDETECTOR_CID \
74 : { 0xea06d4e3, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
75 :
76 :
77 : // {EA06D4E4-2B3D-11d3-B3BF-00805F8A6670}
78 : #define NS_KO_STRING_PSMDETECTOR_CID \
79 : { 0xea06d4e4, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
80 :
81 : // {EA06D4E5-2B3D-11d3-B3BF-00805F8A6670}
82 : #define NS_ZHCN_STRING_PSMDETECTOR_CID \
83 : { 0xea06d4e5, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
84 :
85 : // {EA06D4E6-2B3D-11d3-B3BF-00805F8A6670}
86 : #define NS_ZHTW_STRING_PSMDETECTOR_CID \
87 : { 0xea06d4e6, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
88 :
89 :
90 : // {FCACEF21-2B40-11d3-B3BF-00805F8A6670}
91 : #define NS_ZH_STRING_PSMDETECTOR_CID \
92 : { 0xfcacef21, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
93 :
94 : // {FCACEF22-2B40-11d3-B3BF-00805F8A6670}
95 : #define NS_CJK_STRING_PSMDETECTOR_CID \
96 : { 0xfcacef22, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
97 :
98 :
99 : // {FCACEF23-2B40-11d3-B3BF-00805F8A6670}
100 : #define NS_ZH_PSMDETECTOR_CID \
101 : { 0xfcacef23, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
102 :
103 : // {FCACEF24-2B40-11d3-B3BF-00805F8A6670}
104 : #define NS_CJK_PSMDETECTOR_CID \
105 : { 0xfcacef24, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
106 :
107 : //=====================================================================
108 : class nsXPCOMDetector :
109 : public nsUniversalDetector,
110 : public nsICharsetDetector
111 : {
112 : NS_DECL_ISUPPORTS
113 : public:
114 : nsXPCOMDetector(PRUint32 aLanguageFilter);
115 : virtual ~nsXPCOMDetector();
116 : NS_IMETHOD Init(nsICharsetDetectionObserver* aObserver);
117 : NS_IMETHOD DoIt(const char* aBuf, PRUint32 aLen, bool *oDontFeedMe);
118 : NS_IMETHOD Done();
119 : protected:
120 : virtual void Report(const char* aCharset);
121 : private:
122 : nsCOMPtr<nsICharsetDetectionObserver> mObserver;
123 : };
124 :
125 :
126 : //=====================================================================
127 : class nsXPCOMStringDetector :
128 : public nsUniversalDetector,
129 : public nsIStringCharsetDetector
130 : {
131 : NS_DECL_ISUPPORTS
132 : public:
133 : nsXPCOMStringDetector(PRUint32 aLanguageFilter);
134 : virtual ~nsXPCOMStringDetector();
135 : NS_IMETHOD DoIt(const char* aBuf, PRUint32 aLen,
136 : const char** oCharset, nsDetectionConfident &oConf);
137 : protected:
138 : virtual void Report(const char* aCharset);
139 : private:
140 : nsCOMPtr<nsICharsetDetectionObserver> mObserver;
141 : const char* mResult;
142 : };
143 :
144 : //=====================================================================
145 : class nsUniversalXPCOMDetector : public nsXPCOMDetector
146 0 : {
147 : public:
148 0 : nsUniversalXPCOMDetector()
149 0 : : nsXPCOMDetector(NS_FILTER_ALL) {}
150 : };
151 :
152 : class nsUniversalXPCOMStringDetector : public nsXPCOMStringDetector
153 0 : {
154 : public:
155 0 : nsUniversalXPCOMStringDetector()
156 0 : : nsXPCOMStringDetector(NS_FILTER_ALL) {}
157 : };
158 :
159 : class nsJAPSMDetector : public nsXPCOMDetector
160 0 : {
161 : public:
162 0 : nsJAPSMDetector()
163 0 : : nsXPCOMDetector(NS_FILTER_JAPANESE) {}
164 : };
165 :
166 : class nsJAStringPSMDetector : public nsXPCOMStringDetector
167 0 : {
168 : public:
169 0 : nsJAStringPSMDetector()
170 0 : : nsXPCOMStringDetector(NS_FILTER_JAPANESE) {}
171 : };
172 :
173 : class nsKOPSMDetector : public nsXPCOMDetector
174 0 : {
175 : public:
176 0 : nsKOPSMDetector()
177 0 : : nsXPCOMDetector(NS_FILTER_KOREAN) {}
178 : };
179 :
180 : class nsKOStringPSMDetector : public nsXPCOMStringDetector
181 0 : {
182 : public:
183 0 : nsKOStringPSMDetector()
184 0 : : nsXPCOMStringDetector(NS_FILTER_KOREAN) {}
185 : };
186 :
187 : class nsZHTWPSMDetector : public nsXPCOMDetector
188 0 : {
189 : public:
190 0 : nsZHTWPSMDetector()
191 0 : : nsXPCOMDetector(NS_FILTER_CHINESE_TRADITIONAL) {}
192 : };
193 :
194 : class nsZHTWStringPSMDetector : public nsXPCOMStringDetector
195 0 : {
196 : public:
197 0 : nsZHTWStringPSMDetector()
198 0 : : nsXPCOMStringDetector(NS_FILTER_CHINESE_TRADITIONAL) {}
199 : };
200 :
201 : class nsZHCNPSMDetector : public nsXPCOMDetector
202 0 : {
203 : public:
204 0 : nsZHCNPSMDetector()
205 0 : : nsXPCOMDetector(NS_FILTER_CHINESE_SIMPLIFIED) {}
206 : };
207 :
208 : class nsZHCNStringPSMDetector : public nsXPCOMStringDetector
209 0 : {
210 : public:
211 0 : nsZHCNStringPSMDetector()
212 0 : : nsXPCOMStringDetector(NS_FILTER_CHINESE_SIMPLIFIED) {}
213 : };
214 :
215 : class nsZHPSMDetector : public nsXPCOMDetector
216 0 : {
217 : public:
218 0 : nsZHPSMDetector()
219 0 : : nsXPCOMDetector(NS_FILTER_CHINESE) {}
220 : };
221 :
222 : class nsZHStringPSMDetector : public nsXPCOMStringDetector
223 0 : {
224 : public:
225 0 : nsZHStringPSMDetector()
226 0 : : nsXPCOMStringDetector(NS_FILTER_CHINESE) {}
227 : };
228 :
229 : class nsCJKPSMDetector : public nsXPCOMDetector
230 0 : {
231 : public:
232 0 : nsCJKPSMDetector()
233 0 : : nsXPCOMDetector(NS_FILTER_CJK) {}
234 : };
235 :
236 : class nsCJKStringPSMDetector : public nsXPCOMStringDetector
237 0 : {
238 : public:
239 0 : nsCJKStringPSMDetector()
240 0 : : nsXPCOMStringDetector(NS_FILTER_CJK) {}
241 : };
242 :
243 : #endif //_nsUdetXPCOMWrapper_h__
|