Follow-on fix for bug 457825. Use sheet principal for agent and user sheets. r=dbaron...
[wine-gecko.git] / intl / chardet / src / nsChardetModule.cpp
bloba91d5248ec947178dd1c0b849d3450feeadba8ce
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
13 * License.
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.
22 * Contributor(s):
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"
39 #include "nsCOMPtr.h"
40 #include "nsICategoryManager.h"
41 #include "nsIServiceManager.h"
43 #include "nsCharDetConstructors.h"
46 static NS_METHOD
47 AddCategoryEntry(const char* category,
48 const char* key,
49 const char* value)
51 nsresult rv;
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,
57 PR_TRUE, PR_TRUE,
58 nsnull);
61 static NS_METHOD
62 DeleteCategoryEntry(const char* category,
63 const char* key)
65 nsresult rv;
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);
73 static NS_METHOD
74 nsMetaCharsetObserverRegistrationProc(nsIComponentManager *aCompMgr,
75 nsIFile *aPath,
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);
85 static NS_METHOD
86 nsMetaCharsetObserverUnegistrationProc(nsIComponentManager *aCompMgr,
87 nsIFile *aPath,
88 const char *registryLocation,
89 const nsModuleComponentInfo *info)
91 return DeleteCategoryEntry("parser-service-category",
92 "Meta Charset Service");
95 static NS_METHOD
96 nsDetectionAdaptorRegistrationProc(nsIComponentManager *aCompMgr,
97 nsIFile *aPath,
98 const char *registryLocation,
99 const char *componentType,
100 const nsModuleComponentInfo *info)
102 return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY, "off", "off");
105 static NS_METHOD
106 nsRUProbDetectorRegistrationProc(nsIComponentManager *aCompMgr,
107 nsIFile *aPath,
108 const char *registryLocation,
109 const char *componentType,
110 const nsModuleComponentInfo *info)
112 return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
113 "ruprob",
114 info->mContractID);
117 static NS_METHOD
118 nsUKProbDetectorRegistrationProc(nsIComponentManager *aCompMgr,
119 nsIFile *aPath,
120 const char *registryLocation,
121 const char *componentType,
122 const nsModuleComponentInfo *info)
124 return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
125 "ukprob",
126 info->mContractID);
130 static nsModuleComponentInfo components[] =
132 { "Meta Charset", NS_META_CHARSET_CID,
133 NS_META_CHARSET_CONTRACTID, nsMetaCharsetObserverConstructor,
134 nsMetaCharsetObserverRegistrationProc, nsMetaCharsetObserverUnegistrationProc,
135 NULL},
136 { "Document Charset Info", NS_DOCUMENTCHARSETINFO_CID,
137 NS_DOCUMENTCHARSETINFO_CONTRACTID, nsDocumentCharsetInfoConstructor,
138 NULL, NULL},
139 { "XML Encoding", NS_XML_ENCODING_CID,
140 NS_XML_ENCODING_CONTRACTID, nsXMLEncodingObserverConstructor,
141 NULL, NULL},
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,
153 NULL, NULL},
154 { "Probability based Ukrainian String Charset Detector", NS_UK_STRING_PROBDETECTOR_CID,
155 NS_STRCDETECTOR_CONTRACTID_BASE "ukprob", nsUKStringProbDetectorConstructor,
156 NULL, NULL},
157 #ifdef INCLUDE_DBGDETECTOR
158 { "Debugging Detector 1st block", NS_1STBLKDBG_DETECTOR_CID,
159 NS_CHARSET_DETECTOR_CONTRACTID_BASE "1stblkdbg", ns1stBlkDbgDetectorConstructor,
160 NULL, NULL},
161 { "Debugging Detector 2nd block", NS_2NDBLKDBG_DETECTOR_CID,
162 NS_CHARSET_DETECTOR_CONTRACTID_BASE "2ndblkdbg", ns2ndBlkDbgDetectorConstructor,
163 NULL, NULL},
164 { "Debugging Detector Last block", NS_LASTBLKDBG_DETECTOR_CID,
165 NS_CHARSET_DETECTOR_CONTRACTID_BASE "lastblkdbg", nsLastBlkDbgDetectorConstructor,
166 NULL, NULL},
167 #endif /* INCLUDE_DBGDETECTOR */
171 NS_IMPL_NSGETMODULE(nsChardetModule, components)