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
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/
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.
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.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef _nsUdetXPCOMWrapper_h__
39 #define _nsUdetXPCOMWrapper_h__
40 #include "nsISupports.h"
41 #include "nsICharsetDetector.h"
42 #include "nsIStringCharsetDetector.h"
43 #include "nsICharsetDetectionObserver.h"
46 #include "nsIFactory.h"
48 // {374E0CDE-F605-4259-8C92-E639C6C2EEEF}
49 #define NS_UNIVERSAL_DETECTOR_CID \
50 { 0x374e0cde, 0xf605, 0x4259, { 0x8c, 0x92, 0xe6, 0x39, 0xc6, 0xc2, 0xee, 0xef } }
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 } }
56 // {12BB8F1B-2389-11d3-B3BF-00805F8A6670}
57 #define NS_JA_PSMDETECTOR_CID \
58 { 0x12bb8f1b, 0x2389, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
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 } }
64 // {EA06D4E1-2B3D-11d3-B3BF-00805F8A6670}
65 #define NS_KO_PSMDETECTOR_CID \
66 { 0xea06d4e1, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
68 // {EA06D4E2-2B3D-11d3-B3BF-00805F8A6670}
69 #define NS_ZHCN_PSMDETECTOR_CID \
70 { 0xea06d4e2, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
72 // {EA06D4E3-2B3D-11d3-B3BF-00805F8A6670}
73 #define NS_ZHTW_PSMDETECTOR_CID \
74 { 0xea06d4e3, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
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 } }
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 } }
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 } }
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 } }
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 } }
99 // {FCACEF23-2B40-11d3-B3BF-00805F8A6670}
100 #define NS_ZH_PSMDETECTOR_CID \
101 { 0xfcacef23, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
103 // {FCACEF24-2B40-11d3-B3BF-00805F8A6670}
104 #define NS_CJK_PSMDETECTOR_CID \
105 { 0xfcacef24, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
107 //=====================================================================
108 class nsXPCOMDetector
:
109 public nsUniversalDetector
,
110 public nsICharsetDetector
114 nsXPCOMDetector(PRUint32 aLanguageFilter
);
115 virtual ~nsXPCOMDetector();
116 NS_IMETHOD
Init(nsICharsetDetectionObserver
* aObserver
);
117 NS_IMETHOD
DoIt(const char* aBuf
, PRUint32 aLen
, PRBool
*oDontFeedMe
);
120 virtual void Report(const char* aCharset
);
122 nsCOMPtr
<nsICharsetDetectionObserver
> mObserver
;
126 //=====================================================================
127 class nsXPCOMStringDetector
:
128 public nsUniversalDetector
,
129 public nsIStringCharsetDetector
133 nsXPCOMStringDetector(PRUint32 aLanguageFilter
);
134 virtual ~nsXPCOMStringDetector();
135 NS_IMETHOD
DoIt(const char* aBuf
, PRUint32 aLen
,
136 const char** oCharset
, nsDetectionConfident
&oConf
);
138 virtual void Report(const char* aCharset
);
140 nsCOMPtr
<nsICharsetDetectionObserver
> mObserver
;
144 //=====================================================================
145 class nsUniversalXPCOMDetector
: public nsXPCOMDetector
148 nsUniversalXPCOMDetector()
149 : nsXPCOMDetector(NS_FILTER_ALL
) {}
152 class nsUniversalXPCOMStringDetector
: public nsXPCOMStringDetector
155 nsUniversalXPCOMStringDetector()
156 : nsXPCOMStringDetector(NS_FILTER_ALL
) {}
159 class nsJAPSMDetector
: public nsXPCOMDetector
163 : nsXPCOMDetector(NS_FILTER_JAPANESE
) {}
166 class nsJAStringPSMDetector
: public nsXPCOMStringDetector
169 nsJAStringPSMDetector()
170 : nsXPCOMStringDetector(NS_FILTER_JAPANESE
) {}
173 class nsKOPSMDetector
: public nsXPCOMDetector
177 : nsXPCOMDetector(NS_FILTER_KOREAN
) {}
180 class nsKOStringPSMDetector
: public nsXPCOMStringDetector
183 nsKOStringPSMDetector()
184 : nsXPCOMStringDetector(NS_FILTER_KOREAN
) {}
187 class nsZHTWPSMDetector
: public nsXPCOMDetector
191 : nsXPCOMDetector(NS_FILTER_CHINESE_TRADITIONAL
) {}
194 class nsZHTWStringPSMDetector
: public nsXPCOMStringDetector
197 nsZHTWStringPSMDetector()
198 : nsXPCOMStringDetector(NS_FILTER_CHINESE_TRADITIONAL
) {}
201 class nsZHCNPSMDetector
: public nsXPCOMDetector
205 : nsXPCOMDetector(NS_FILTER_CHINESE_SIMPLIFIED
) {}
208 class nsZHCNStringPSMDetector
: public nsXPCOMStringDetector
211 nsZHCNStringPSMDetector()
212 : nsXPCOMStringDetector(NS_FILTER_CHINESE_SIMPLIFIED
) {}
215 class nsZHPSMDetector
: public nsXPCOMDetector
219 : nsXPCOMDetector(NS_FILTER_CHINESE
) {}
222 class nsZHStringPSMDetector
: public nsXPCOMStringDetector
225 nsZHStringPSMDetector()
226 : nsXPCOMStringDetector(NS_FILTER_CHINESE
) {}
229 class nsCJKPSMDetector
: public nsXPCOMDetector
233 : nsXPCOMDetector(NS_FILTER_CJK
) {}
236 class nsCJKStringPSMDetector
: public nsXPCOMStringDetector
239 nsCJKStringPSMDetector()
240 : nsXPCOMStringDetector(NS_FILTER_CJK
) {}
243 #endif //_nsUdetXPCOMWrapper_h__