1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 of the GNU General Public License Version 2 or later (the "GPL"),
26 * or 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 #include "nsIGenericFactory.h"
40 #include "nsICategoryManager.h"
41 #include "nsIServiceManager.h"
43 #include "nsCharDetConstructors.h"
47 AddCategoryEntry(const char* category
,
52 nsCOMPtr
<nsICategoryManager
>
53 categoryManager(do_GetService("@mozilla.org/categorymanager;1", &rv
));
54 if (NS_FAILED(rv
)) return rv
;
56 return categoryManager
->AddCategoryEntry(category
, key
, value
,
62 DeleteCategoryEntry(const char* category
,
66 nsCOMPtr
<nsICategoryManager
>
67 categoryManager(do_GetService("@mozilla.org/categorymanager;1", &rv
));
68 if (NS_FAILED(rv
)) return rv
;
70 return categoryManager
->DeleteCategoryEntry(category
, key
, PR_TRUE
);
74 nsMetaCharsetObserverRegistrationProc(nsIComponentManager
*aCompMgr
,
76 const char *registryLocation
,
77 const char *componentType
,
78 const nsModuleComponentInfo
*info
)
80 return AddCategoryEntry("parser-service-category",
81 "Meta Charset Service",
82 NS_META_CHARSET_CONTRACTID
);
86 nsMetaCharsetObserverUnegistrationProc(nsIComponentManager
*aCompMgr
,
88 const char *registryLocation
,
89 const nsModuleComponentInfo
*info
)
91 return DeleteCategoryEntry("parser-service-category",
92 "Meta Charset Service");
96 nsDetectionAdaptorRegistrationProc(nsIComponentManager
*aCompMgr
,
98 const char *registryLocation
,
99 const char *componentType
,
100 const nsModuleComponentInfo
*info
)
102 return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY
, "off", "off");
106 nsRUProbDetectorRegistrationProc(nsIComponentManager
*aCompMgr
,
108 const char *registryLocation
,
109 const char *componentType
,
110 const nsModuleComponentInfo
*info
)
112 return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY
,
118 nsUKProbDetectorRegistrationProc(nsIComponentManager
*aCompMgr
,
120 const char *registryLocation
,
121 const char *componentType
,
122 const nsModuleComponentInfo
*info
)
124 return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY
,
130 static nsModuleComponentInfo components
[] =
132 { "Meta Charset", NS_META_CHARSET_CID
,
133 NS_META_CHARSET_CONTRACTID
, nsMetaCharsetObserverConstructor
,
134 nsMetaCharsetObserverRegistrationProc
, nsMetaCharsetObserverUnegistrationProc
,
136 { "Document Charset Info", NS_DOCUMENTCHARSETINFO_CID
,
137 NS_DOCUMENTCHARSETINFO_CONTRACTID
, nsDocumentCharsetInfoConstructor
,
139 { "XML Encoding", NS_XML_ENCODING_CID
,
140 NS_XML_ENCODING_CONTRACTID
, nsXMLEncodingObserverConstructor
,
142 { "Charset Detection Adaptor", NS_CHARSET_DETECTION_ADAPTOR_CID
,
143 NS_CHARSET_DETECTION_ADAPTOR_CONTRACTID
, nsDetectionAdaptorConstructor
,
144 nsDetectionAdaptorRegistrationProc
, NULL
},
145 { "Probability based Russian Charset Detector", NS_RU_PROBDETECTOR_CID
,
146 NS_CHARSET_DETECTOR_CONTRACTID_BASE
"ruprob", nsRUProbDetectorConstructor
,
147 nsRUProbDetectorRegistrationProc
, NULL
},
148 { "Probability based Ukrainian Charset Detector", NS_UK_PROBDETECTOR_CID
,
149 NS_CHARSET_DETECTOR_CONTRACTID_BASE
"ukprob", nsUKProbDetectorConstructor
,
150 nsUKProbDetectorRegistrationProc
, NULL
},
151 { "Probability based Russian String Charset Detector", NS_RU_STRING_PROBDETECTOR_CID
,
152 NS_STRCDETECTOR_CONTRACTID_BASE
"ruprob", nsRUStringProbDetectorConstructor
,
154 { "Probability based Ukrainian String Charset Detector", NS_UK_STRING_PROBDETECTOR_CID
,
155 NS_STRCDETECTOR_CONTRACTID_BASE
"ukprob", nsUKStringProbDetectorConstructor
,
157 #ifdef INCLUDE_DBGDETECTOR
158 { "Debugging Detector 1st block", NS_1STBLKDBG_DETECTOR_CID
,
159 NS_CHARSET_DETECTOR_CONTRACTID_BASE
"1stblkdbg", ns1stBlkDbgDetectorConstructor
,
161 { "Debugging Detector 2nd block", NS_2NDBLKDBG_DETECTOR_CID
,
162 NS_CHARSET_DETECTOR_CONTRACTID_BASE
"2ndblkdbg", ns2ndBlkDbgDetectorConstructor
,
164 { "Debugging Detector Last block", NS_LASTBLKDBG_DETECTOR_CID
,
165 NS_CHARSET_DETECTOR_CONTRACTID_BASE
"lastblkdbg", nsLastBlkDbgDetectorConstructor
,
167 #endif /* INCLUDE_DBGDETECTOR */
171 NS_IMPL_NSGETMODULE(nsChardetModule
, components
)