Bug 458256. Use LoadLibraryW instead of LoadLibrary (patch by DougT). r+sr=vlad
[wine-gecko.git] / netwerk / build / nsNetModule.cpp
blob6e894aea381f90945ac7e4ffde042cf2f6d133f3
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 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 #include "necko-config.h"
40 #include "nsCOMPtr.h"
41 #include "nsIModule.h"
42 #include "nsIClassInfoImpl.h"
43 #include "nsIGenericFactory.h"
44 #include "nsIComponentManager.h"
45 #include "nsIServiceManager.h"
46 #include "nsICategoryManager.h"
47 #include "nsSocketProviderService.h"
48 #include "nscore.h"
49 #include "nsSimpleURI.h"
50 #include "nsSimpleNestedURI.h"
51 #include "nsLoadGroup.h"
52 #include "nsStreamLoader.h"
53 #include "nsUnicharStreamLoader.h"
54 #include "nsFileStreams.h"
55 #include "nsBufferedStreams.h"
56 #include "nsMIMEInputStream.h"
57 #include "nsSOCKSSocketProvider.h"
58 #include "nsCacheService.h"
59 #include "nsDiskCacheDeviceSQL.h"
60 #include "nsMimeTypes.h"
61 #include "nsNetStrings.h"
63 #include "nsNetCID.h"
65 #if defined(XP_MACOSX)
66 #define BUILD_APPLEFILE_DECODER 1
67 #else
68 #define BUILD_BINHEX_DECODER 1
69 #endif
71 ///////////////////////////////////////////////////////////////////////////////
73 #include "nsIOService.h"
74 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIOService, nsIOService::GetInstance)
76 #include "nsDNSService2.h"
77 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDNSService, Init)
79 #include "nsProtocolProxyService.h"
80 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsProtocolProxyService, Init)
81 NS_DECL_CLASSINFO(nsProtocolProxyService)
83 #include "nsStreamTransportService.h"
84 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStreamTransportService, Init)
86 #include "nsSocketTransportService2.h"
87 #undef LOG
88 #undef LOG_ENABLED
89 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSocketTransportService, Init)
91 #include "nsServerSocket.h"
92 NS_GENERIC_FACTORY_CONSTRUCTOR(nsServerSocket)
94 #include "nsUDPSocketProvider.h"
95 NS_GENERIC_FACTORY_CONSTRUCTOR(nsUDPSocketProvider)
97 #include "nsAsyncStreamCopier.h"
98 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAsyncStreamCopier)
100 #include "nsInputStreamPump.h"
101 NS_GENERIC_FACTORY_CONSTRUCTOR(nsInputStreamPump)
103 #include "nsInputStreamChannel.h"
104 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsInputStreamChannel, Init)
106 #include "nsDownloader.h"
107 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloader)
109 #include "nsSyncStreamListener.h"
110 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSyncStreamListener, Init)
112 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSafeFileOutputStream)
114 NS_GENERIC_AGGREGATED_CONSTRUCTOR_INIT(nsLoadGroup, Init)
116 #include "nsEffectiveTLDService.h"
117 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsEffectiveTLDService, Init)
119 ///////////////////////////////////////////////////////////////////////////////
121 extern NS_METHOD
122 net_NewIncrementalDownload(nsISupports *, const nsIID &, void **);
124 #define NS_INCREMENTALDOWNLOAD_CLASSNAME \
125 "nsIncrementalDownload"
126 #define NS_INCREMENTALDOWNLOAD_CID \
127 { /* a62af1ba-79b3-4896-8aaf-b148bfce4280 */ \
128 0xa62af1ba, \
129 0x79b3, \
130 0x4896, \
131 {0x8a, 0xaf, 0xb1, 0x48, 0xbf, 0xce, 0x42, 0x80} \
134 ///////////////////////////////////////////////////////////////////////////////
136 #include "nsStreamConverterService.h"
138 #ifdef BUILD_APPLEFILE_DECODER
139 #include "nsAppleFileDecoder.h"
140 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppleFileDecoder)
141 #endif
143 ///////////////////////////////////////////////////////////////////////////////
145 #include "nsMIMEHeaderParamImpl.h"
147 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMIMEHeaderParamImpl)
148 ///////////////////////////////////////////////////////////////////////////////
150 #include "nsRequestObserverProxy.h"
151 #include "nsSimpleStreamListener.h"
152 #include "nsDirIndexParser.h"
153 #include "nsDirIndex.h"
155 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRequestObserverProxy)
156 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleStreamListener)
157 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDirIndexParser, Init)
158 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDirIndex)
160 ///////////////////////////////////////////////////////////////////////////////
162 #include "nsStreamListenerTee.h"
163 NS_GENERIC_FACTORY_CONSTRUCTOR(nsStreamListenerTee)
165 ///////////////////////////////////////////////////////////////////////////////
167 #ifdef NECKO_COOKIES
168 #include "nsCookieService.h"
169 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsCookieService, nsCookieService::GetSingleton)
170 #endif
172 ///////////////////////////////////////////////////////////////////////////////
173 // protocols
174 ///////////////////////////////////////////////////////////////////////////////
176 // about:blank is mandatory
177 #include "nsAboutProtocolHandler.h"
178 #include "nsAboutBlank.h"
179 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAboutProtocolHandler)
180 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSafeAboutProtocolHandler)
182 #ifdef NECKO_PROTOCOL_about
183 // about
184 #ifdef NS_BUILD_REFCNT_LOGGING
185 #include "nsAboutBloat.h"
186 #endif
187 #include "nsAboutCache.h"
188 #include "nsAboutCacheEntry.h"
189 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAboutCacheEntry)
190 #endif
192 #ifdef NECKO_OFFLINE_CACHE
193 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsOfflineCacheDevice, nsOfflineCacheDevice::GetInstance)
194 NS_GENERIC_FACTORY_CONSTRUCTOR(nsApplicationCacheNamespace)
195 #endif
197 #ifdef NECKO_PROTOCOL_file
198 // file
199 #include "nsFileProtocolHandler.h"
200 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsFileProtocolHandler, Init)
201 #endif
203 #ifdef NECKO_PROTOCOL_ftp
204 // ftp
205 #include "nsFtpProtocolHandler.h"
206 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsFtpProtocolHandler, Init)
207 #endif
209 #ifdef NECKO_PROTOCOL_http
210 // http/https
211 #include "nsHttpHandler.h"
212 #include "nsHttpAuthManager.h"
213 #include "nsHttpBasicAuth.h"
214 #include "nsHttpDigestAuth.h"
215 #include "nsHttpNTLMAuth.h"
216 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHttpNTLMAuth)
217 #undef LOG
218 #undef LOG_ENABLED
219 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHttpHandler, Init)
220 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHttpsHandler, Init)
221 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHttpAuthManager, Init)
222 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHttpBasicAuth)
223 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHttpDigestAuth)
224 #endif // !NECKO_PROTOCOL_http
226 #ifdef NECKO_PROTOCOL_res
227 // resource
228 #include "nsResProtocolHandler.h"
229 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsResProtocolHandler, Init)
230 NS_GENERIC_FACTORY_CONSTRUCTOR(nsResURL)
231 #endif
233 #ifdef NECKO_PROTOCOL_gopher
234 #include "nsGopherHandler.h"
235 NS_GENERIC_FACTORY_CONSTRUCTOR(nsGopherHandler)
236 #endif
238 #ifdef NECKO_PROTOCOL_viewsource
239 #include "nsViewSourceHandler.h"
240 NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewSourceHandler)
241 #endif
243 #ifdef NECKO_PROTOCOL_data
244 #include "nsDataHandler.h"
245 #endif
247 ///////////////////////////////////////////////////////////////////////////////
249 #include "nsURIChecker.h"
250 NS_GENERIC_FACTORY_CONSTRUCTOR(nsURIChecker)
252 ///////////////////////////////////////////////////////////////////////////////
254 #include "nsURLParsers.h"
255 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoAuthURLParser)
256 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAuthURLParser)
257 NS_GENERIC_FACTORY_CONSTRUCTOR(nsStdURLParser)
259 #include "nsStandardURL.h"
260 NS_GENERIC_FACTORY_CONSTRUCTOR(nsStandardURL)
262 NS_GENERIC_AGGREGATED_CONSTRUCTOR(nsSimpleURI)
264 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleNestedURI)
266 ///////////////////////////////////////////////////////////////////////////////
268 #include "nsIDNService.h"
269 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsIDNService, Init)
271 ///////////////////////////////////////////////////////////////////////////////
272 #if defined(XP_WIN) && !defined(WINCE)
273 #include "nsNotifyAddrListener.h"
274 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNotifyAddrListener, Init)
275 #elif defined(MOZ_WIDGET_COCOA)
276 #include "nsNetworkLinkService.h"
277 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNetworkLinkService, Init)
278 #endif
280 ///////////////////////////////////////////////////////////////////////////////
282 #ifdef NECKO_PROTOCOL_ftp
283 #include "nsFTPDirListingConv.h"
284 nsresult NS_NewFTPDirListingConv(nsFTPDirListingConv** result);
285 #endif
287 #ifdef NECKO_PROTOCOL_gopher
288 #include "nsGopherDirListingConv.h"
289 NS_GENERIC_FACTORY_CONSTRUCTOR(nsGopherDirListingConv)
290 #endif
292 #include "nsMultiMixedConv.h"
293 #include "nsHTTPCompressConv.h"
294 #include "mozTXTToHTMLConv.h"
295 #include "nsUnknownDecoder.h"
296 #include "nsTXTToHTMLConv.h"
297 #include "nsIndexedToHTML.h"
298 #ifdef BUILD_BINHEX_DECODER
299 #include "nsBinHexDecoder.h"
300 #endif
302 nsresult NS_NewMultiMixedConv (nsMultiMixedConv** result);
303 nsresult MOZ_NewTXTToHTMLConv (mozTXTToHTMLConv** result);
304 nsresult NS_NewHTTPCompressConv (nsHTTPCompressConv ** result);
305 nsresult NS_NewNSTXTToHTMLConv(nsTXTToHTMLConv** result);
306 nsresult NS_NewStreamConv(nsStreamConverterService **aStreamConv);
308 #define FTP_TO_INDEX "?from=text/ftp-dir&to=application/http-index-format"
309 #define GOPHER_TO_INDEX "?from=text/gopher-dir&to=application/http-index-format"
310 #define INDEX_TO_HTML "?from=application/http-index-format&to=text/html"
311 #define MULTI_MIXED_X "?from=multipart/x-mixed-replace&to=*/*"
312 #define MULTI_MIXED "?from=multipart/mixed&to=*/*"
313 #define MULTI_BYTERANGES "?from=multipart/byteranges&to=*/*"
314 #define UNKNOWN_CONTENT "?from=" UNKNOWN_CONTENT_TYPE "&to=*/*"
315 #define GZIP_TO_UNCOMPRESSED "?from=gzip&to=uncompressed"
316 #define XGZIP_TO_UNCOMPRESSED "?from=x-gzip&to=uncompressed"
317 #define COMPRESS_TO_UNCOMPRESSED "?from=compress&to=uncompressed"
318 #define XCOMPRESS_TO_UNCOMPRESSED "?from=x-compress&to=uncompressed"
319 #define DEFLATE_TO_UNCOMPRESSED "?from=deflate&to=uncompressed"
320 #define PLAIN_TO_HTML "?from=text/plain&to=text/html"
322 #ifdef BUILD_BINHEX_DECODER
323 #define BINHEX_TO_WILD "?from=application/mac-binhex40&to=*/*"
324 #endif
326 static const char *const sStreamConverterArray[] = {
327 FTP_TO_INDEX,
328 GOPHER_TO_INDEX,
329 INDEX_TO_HTML,
330 MULTI_MIXED_X,
331 MULTI_MIXED,
332 MULTI_BYTERANGES,
333 UNKNOWN_CONTENT,
334 GZIP_TO_UNCOMPRESSED,
335 XGZIP_TO_UNCOMPRESSED,
336 COMPRESS_TO_UNCOMPRESSED,
337 XCOMPRESS_TO_UNCOMPRESSED,
338 DEFLATE_TO_UNCOMPRESSED,
339 #ifdef BUILD_BINHEX_DECODER
340 BINHEX_TO_WILD,
341 #endif
342 PLAIN_TO_HTML
345 static const PRUint32 sStreamConverterCount =
346 NS_ARRAY_LENGTH(sStreamConverterArray);
348 // each stream converter must add its from/to key to the category manager
349 // in RegisterStreamConverters(). This provides a string representation
350 // of each registered converter, rooted in the NS_ISTREAMCONVERTER_KEY
351 // category. These keys are then (when the stream converter service
352 // needs to chain converters together) enumerated and parsed to build
353 // a graph of converters for potential chaining.
354 static NS_METHOD
355 RegisterStreamConverters(nsIComponentManager *aCompMgr, nsIFile *aPath,
356 const char *registryLocation,
357 const char *componentType,
358 const nsModuleComponentInfo *info) {
359 nsCOMPtr<nsICategoryManager> catmgr =
360 do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
361 NS_ENSURE_STATE(catmgr);
363 for (PRUint32 count = 0; count < sStreamConverterCount; ++count) {
364 catmgr->AddCategoryEntry(NS_ISTREAMCONVERTER_KEY,
365 sStreamConverterArray[count], "",
366 PR_TRUE, PR_TRUE, nsnull);
368 return NS_OK;
371 // same as RegisterStreamConverters except the reverse.
372 static NS_METHOD
373 UnregisterStreamConverters(nsIComponentManager *aCompMgr, nsIFile *aPath,
374 const char *registryLocation,
375 const nsModuleComponentInfo *info) {
376 nsCOMPtr<nsICategoryManager> catmgr =
377 do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
378 NS_ENSURE_STATE(catmgr);
380 for (PRUint32 count = 0; count < sStreamConverterCount; ++count) {
381 catmgr->DeleteCategoryEntry(NS_ISTREAMCONVERTER_KEY,
382 sStreamConverterArray[count],
383 PR_TRUE);
385 return NS_OK;
388 #ifdef BUILD_BINHEX_DECODER
389 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinHexDecoder)
390 #endif
392 static NS_IMETHODIMP
393 CreateNewStreamConvServiceFactory(nsISupports* aOuter, REFNSIID aIID, void **aResult)
395 if (!aResult) {
396 return NS_ERROR_INVALID_POINTER;
398 if (aOuter) {
399 *aResult = nsnull;
400 return NS_ERROR_NO_AGGREGATION;
402 nsStreamConverterService* inst = nsnull;
403 nsresult rv = NS_NewStreamConv(&inst);
404 if (NS_FAILED(rv)) {
405 *aResult = nsnull;
406 return rv;
408 rv = inst->QueryInterface(aIID, aResult);
409 if (NS_FAILED(rv)) {
410 *aResult = nsnull;
412 NS_RELEASE(inst); /* get rid of extra refcnt */
413 return rv;
416 #ifdef NECKO_PROTOCOL_ftp
417 static NS_IMETHODIMP
418 CreateNewFTPDirListingConv(nsISupports* aOuter, REFNSIID aIID, void **aResult)
420 if (!aResult) {
421 return NS_ERROR_INVALID_POINTER;
423 if (aOuter) {
424 *aResult = nsnull;
425 return NS_ERROR_NO_AGGREGATION;
427 nsFTPDirListingConv* inst = nsnull;
428 nsresult rv = NS_NewFTPDirListingConv(&inst);
429 if (NS_FAILED(rv)) {
430 *aResult = nsnull;
431 return rv;
433 rv = inst->QueryInterface(aIID, aResult);
434 if (NS_FAILED(rv)) {
435 *aResult = nsnull;
437 NS_RELEASE(inst); /* get rid of extra refcnt */
438 return rv;
440 #endif
442 static NS_IMETHODIMP
443 CreateNewMultiMixedConvFactory(nsISupports* aOuter, REFNSIID aIID, void **aResult)
445 if (!aResult) {
446 return NS_ERROR_INVALID_POINTER;
448 if (aOuter) {
449 *aResult = nsnull;
450 return NS_ERROR_NO_AGGREGATION;
452 nsMultiMixedConv* inst = nsnull;
453 nsresult rv = NS_NewMultiMixedConv(&inst);
454 if (NS_FAILED(rv)) {
455 *aResult = nsnull;
456 return rv;
458 rv = inst->QueryInterface(aIID, aResult);
459 if (NS_FAILED(rv)) {
460 *aResult = nsnull;
462 NS_RELEASE(inst); /* get rid of extra refcnt */
463 return rv;
466 static NS_IMETHODIMP
467 CreateNewTXTToHTMLConvFactory(nsISupports* aOuter, REFNSIID aIID, void **aResult)
469 if (!aResult) {
470 return NS_ERROR_INVALID_POINTER;
472 if (aOuter) {
473 *aResult = nsnull;
474 return NS_ERROR_NO_AGGREGATION;
476 mozTXTToHTMLConv* inst = nsnull;
477 nsresult rv = MOZ_NewTXTToHTMLConv(&inst);
478 if (NS_FAILED(rv)) {
479 *aResult = nsnull;
480 return rv;
482 rv = inst->QueryInterface(aIID, aResult);
483 if (NS_FAILED(rv)) {
484 *aResult = nsnull;
486 NS_RELEASE(inst); /* get rid of extra refcnt */
487 return rv;
490 static NS_IMETHODIMP
491 CreateNewHTTPCompressConvFactory (nsISupports* aOuter, REFNSIID aIID, void **aResult)
493 if (!aResult) {
494 return NS_ERROR_INVALID_POINTER;
496 if (aOuter) {
497 *aResult = nsnull;
498 return NS_ERROR_NO_AGGREGATION;
500 nsHTTPCompressConv* inst = nsnull;
501 nsresult rv = NS_NewHTTPCompressConv (&inst);
502 if (NS_FAILED(rv)) {
503 *aResult = nsnull;
504 return rv;
506 rv = inst->QueryInterface(aIID, aResult);
507 if (NS_FAILED(rv)) {
508 *aResult = nsnull;
510 NS_RELEASE(inst); /* get rid of extra refcnt */
511 return rv;
514 static NS_IMETHODIMP
515 CreateNewUnknownDecoderFactory(nsISupports *aOuter, REFNSIID aIID, void **aResult)
517 nsresult rv;
519 if (!aResult) {
520 return NS_ERROR_NULL_POINTER;
522 *aResult = nsnull;
524 if (aOuter) {
525 return NS_ERROR_NO_AGGREGATION;
528 nsUnknownDecoder *inst;
530 inst = new nsUnknownDecoder();
531 if (!inst) {
532 return NS_ERROR_OUT_OF_MEMORY;
534 NS_ADDREF(inst);
535 rv = inst->QueryInterface(aIID, aResult);
536 NS_RELEASE(inst);
538 return rv;
541 static NS_IMETHODIMP
542 CreateNewBinaryDetectorFactory(nsISupports *aOuter, REFNSIID aIID, void **aResult)
544 nsresult rv;
546 if (!aResult) {
547 return NS_ERROR_NULL_POINTER;
549 *aResult = nsnull;
551 if (aOuter) {
552 return NS_ERROR_NO_AGGREGATION;
555 nsBinaryDetector* inst = new nsBinaryDetector();
556 if (!inst) {
557 return NS_ERROR_OUT_OF_MEMORY;
559 NS_ADDREF(inst);
560 rv = inst->QueryInterface(aIID, aResult);
561 NS_RELEASE(inst);
563 return rv;
566 static NS_IMETHODIMP
567 CreateNewNSTXTToHTMLConvFactory(nsISupports *aOuter, REFNSIID aIID, void **aResult)
569 nsresult rv;
571 if (!aResult) {
572 return NS_ERROR_NULL_POINTER;
574 *aResult = nsnull;
576 if (aOuter) {
577 return NS_ERROR_NO_AGGREGATION;
580 nsTXTToHTMLConv *inst;
582 inst = new nsTXTToHTMLConv();
583 if (!inst) return NS_ERROR_OUT_OF_MEMORY;
585 NS_ADDREF(inst);
586 rv = inst->Init();
587 if (NS_FAILED(rv)) {
588 delete inst;
589 return rv;
591 rv = inst->QueryInterface(aIID, aResult);
592 NS_RELEASE(inst);
594 return rv;
597 ///////////////////////////////////////////////////////////////////////////////
598 // Module implementation for the net library
600 // Net module startup hook
601 static nsresult nsNetStartup(nsIModule *neckoModule)
603 gNetStrings = new nsNetStrings();
604 return gNetStrings ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
608 // Net module shutdown hook
609 static void nsNetShutdown(nsIModule *neckoModule)
611 // Release the url parser that the stdurl is holding.
612 nsStandardURL::ShutdownGlobalObjects();
614 // Release buffer cache
615 NS_IF_RELEASE(nsIOService::gBufferCache);
617 // Release global state used by the URL helper module.
618 net_ShutdownURLHelper();
619 #ifdef XP_MACOSX
620 net_ShutdownURLHelperOSX();
621 #endif
623 // Release necko strings
624 delete gNetStrings;
625 gNetStrings = nsnull;
628 static const nsModuleComponentInfo gNetModuleInfo[] = {
629 { NS_IOSERVICE_CLASSNAME,
630 NS_IOSERVICE_CID,
631 NS_IOSERVICE_CONTRACTID,
632 nsIOServiceConstructor },
633 { NS_IOSERVICE_CLASSNAME,
634 NS_IOSERVICE_CID,
635 NS_NETUTIL_CONTRACTID,
636 nsIOServiceConstructor },
637 { NS_STREAMTRANSPORTSERVICE_CLASSNAME,
638 NS_STREAMTRANSPORTSERVICE_CID,
639 NS_STREAMTRANSPORTSERVICE_CONTRACTID,
640 nsStreamTransportServiceConstructor },
641 { NS_SOCKETTRANSPORTSERVICE_CLASSNAME,
642 NS_SOCKETTRANSPORTSERVICE_CID,
643 NS_SOCKETTRANSPORTSERVICE_CONTRACTID,
644 nsSocketTransportServiceConstructor },
645 { NS_SERVERSOCKET_CLASSNAME,
646 NS_SERVERSOCKET_CID,
647 NS_SERVERSOCKET_CONTRACTID,
648 nsServerSocketConstructor },
649 { NS_SOCKETPROVIDERSERVICE_CLASSNAME,
650 NS_SOCKETPROVIDERSERVICE_CID,
651 NS_SOCKETPROVIDERSERVICE_CONTRACTID,
652 nsSocketProviderService::Create },
653 { NS_DNSSERVICE_CLASSNAME,
654 NS_DNSSERVICE_CID,
655 NS_DNSSERVICE_CONTRACTID,
656 nsDNSServiceConstructor },
657 { NS_IDNSERVICE_CLASSNAME,
658 NS_IDNSERVICE_CID,
659 NS_IDNSERVICE_CONTRACTID,
660 nsIDNServiceConstructor },
661 { NS_EFFECTIVETLDSERVICE_CLASSNAME,
662 NS_EFFECTIVETLDSERVICE_CID,
663 NS_EFFECTIVETLDSERVICE_CONTRACTID,
664 nsEffectiveTLDServiceConstructor },
665 { NS_SIMPLEURI_CLASSNAME,
666 NS_SIMPLEURI_CID,
667 NS_SIMPLEURI_CONTRACTID,
668 nsSimpleURIConstructor },
669 { "Simple Nested URI",
670 NS_SIMPLENESTEDURI_CID,
671 nsnull,
672 nsSimpleNestedURIConstructor },
673 { NS_ASYNCSTREAMCOPIER_CLASSNAME,
674 NS_ASYNCSTREAMCOPIER_CID,
675 NS_ASYNCSTREAMCOPIER_CONTRACTID,
676 nsAsyncStreamCopierConstructor },
677 { NS_INPUTSTREAMPUMP_CLASSNAME,
678 NS_INPUTSTREAMPUMP_CID,
679 NS_INPUTSTREAMPUMP_CONTRACTID,
680 nsInputStreamPumpConstructor },
681 { NS_INPUTSTREAMCHANNEL_CLASSNAME,
682 NS_INPUTSTREAMCHANNEL_CID,
683 NS_INPUTSTREAMCHANNEL_CONTRACTID,
684 nsInputStreamChannelConstructor },
685 { NS_STREAMLOADER_CLASSNAME,
686 NS_STREAMLOADER_CID,
687 NS_STREAMLOADER_CONTRACTID,
688 nsStreamLoader::Create },
689 { NS_UNICHARSTREAMLOADER_CLASSNAME,
690 NS_UNICHARSTREAMLOADER_CID,
691 NS_UNICHARSTREAMLOADER_CONTRACTID,
692 nsUnicharStreamLoader::Create },
693 { NS_DOWNLOADER_CLASSNAME,
694 NS_DOWNLOADER_CID,
695 NS_DOWNLOADER_CONTRACTID,
696 nsDownloaderConstructor },
697 { NS_SYNCSTREAMLISTENER_CLASSNAME,
698 NS_SYNCSTREAMLISTENER_CID,
699 NS_SYNCSTREAMLISTENER_CONTRACTID,
700 nsSyncStreamListenerConstructor },
701 { NS_REQUESTOBSERVERPROXY_CLASSNAME,
702 NS_REQUESTOBSERVERPROXY_CID,
703 NS_REQUESTOBSERVERPROXY_CONTRACTID,
704 nsRequestObserverProxyConstructor },
705 { NS_SIMPLESTREAMLISTENER_CLASSNAME,
706 NS_SIMPLESTREAMLISTENER_CID,
707 NS_SIMPLESTREAMLISTENER_CONTRACTID,
708 nsSimpleStreamListenerConstructor },
709 { NS_STREAMLISTENERTEE_CLASSNAME,
710 NS_STREAMLISTENERTEE_CID,
711 NS_STREAMLISTENERTEE_CONTRACTID,
712 nsStreamListenerTeeConstructor },
713 { NS_LOADGROUP_CLASSNAME,
714 NS_LOADGROUP_CID,
715 NS_LOADGROUP_CONTRACTID,
716 nsLoadGroupConstructor },
717 { NS_LOCALFILEINPUTSTREAM_CLASSNAME,
718 NS_LOCALFILEINPUTSTREAM_CID,
719 NS_LOCALFILEINPUTSTREAM_CONTRACTID,
720 nsFileInputStream::Create },
721 { NS_LOCALFILEOUTPUTSTREAM_CLASSNAME,
722 NS_LOCALFILEOUTPUTSTREAM_CID,
723 NS_LOCALFILEOUTPUTSTREAM_CONTRACTID,
724 nsFileOutputStream::Create },
725 { NS_SAFELOCALFILEOUTPUTSTREAM_CLASSNAME,
726 NS_SAFELOCALFILEOUTPUTSTREAM_CID,
727 NS_SAFELOCALFILEOUTPUTSTREAM_CONTRACTID,
728 nsSafeFileOutputStreamConstructor
731 { "URIChecker",
732 NS_URICHECKER_CID,
733 NS_URICHECKER_CONTRACT_ID,
734 nsURICheckerConstructor
737 { NS_INCREMENTALDOWNLOAD_CLASSNAME,
738 NS_INCREMENTALDOWNLOAD_CID,
739 NS_INCREMENTALDOWNLOAD_CONTRACTID,
740 net_NewIncrementalDownload
743 // The register functions for the built-in
744 // parsers just need to be called once.
745 { NS_STDURLPARSER_CLASSNAME,
746 NS_STDURLPARSER_CID,
747 NS_STDURLPARSER_CONTRACTID,
748 nsStdURLParserConstructor},
749 { NS_NOAUTHURLPARSER_CLASSNAME,
750 NS_NOAUTHURLPARSER_CID,
751 NS_NOAUTHURLPARSER_CONTRACTID,
752 nsNoAuthURLParserConstructor },
753 { NS_AUTHURLPARSER_CLASSNAME,
754 NS_AUTHURLPARSER_CID,
755 NS_AUTHURLPARSER_CONTRACTID,
756 nsAuthURLParserConstructor },
758 { NS_STANDARDURL_CLASSNAME,
759 NS_STANDARDURL_CID,
760 NS_STANDARDURL_CONTRACTID,
761 nsStandardURLConstructor },
763 { NS_BUFFEREDINPUTSTREAM_CLASSNAME,
764 NS_BUFFEREDINPUTSTREAM_CID,
765 NS_BUFFEREDINPUTSTREAM_CONTRACTID,
766 nsBufferedInputStream::Create },
767 { NS_BUFFEREDOUTPUTSTREAM_CLASSNAME,
768 NS_BUFFEREDOUTPUTSTREAM_CID,
769 NS_BUFFEREDOUTPUTSTREAM_CONTRACTID,
770 nsBufferedOutputStream::Create },
771 { NS_MIMEINPUTSTREAM_CLASSNAME,
772 NS_MIMEINPUTSTREAM_CID,
773 NS_MIMEINPUTSTREAM_CONTRACTID,
774 nsMIMEInputStreamConstructor },
775 { NS_PROTOCOLPROXYSERVICE_CLASSNAME,
776 NS_PROTOCOLPROXYSERVICE_CID,
777 NS_PROTOCOLPROXYSERVICE_CONTRACTID,
778 nsProtocolProxyServiceConstructor,
779 nsnull, nsnull, nsnull,
780 NS_CI_INTERFACE_GETTER_NAME(nsProtocolProxyService),
781 nsnull,
782 &NS_CLASSINFO_NAME(nsProtocolProxyService),
783 nsIClassInfo::SINGLETON },
785 // from netwerk/streamconv:
787 // this converter is "always" built.
788 // HACK-ALERT, register *all* converters
789 // in this converter's component manager
790 // registration. just piggy backing here until
791 // you can add registration functions to
792 // the generic module macro.
793 { "Stream Converter Service",
794 NS_STREAMCONVERTERSERVICE_CID,
795 NS_STREAMCONVERTERSERVICE_CONTRACTID,
796 CreateNewStreamConvServiceFactory,
797 RegisterStreamConverters, // registers *all* converters
798 UnregisterStreamConverters // unregisters *all* converters
801 #ifdef BUILD_APPLEFILE_DECODER
802 { NS_APPLEFILEDECODER_CLASSNAME,
803 NS_APPLEFILEDECODER_CID,
804 NS_IAPPLEFILEDECODER_CONTRACTID,
805 nsAppleFileDecoderConstructor
807 #endif
809 #ifdef NECKO_PROTOCOL_ftp
810 // from netwerk/streamconv/converters:
811 { "FTPDirListingConverter",
812 NS_FTPDIRLISTINGCONVERTER_CID,
813 NS_ISTREAMCONVERTER_KEY FTP_TO_INDEX,
814 CreateNewFTPDirListingConv
816 #endif
818 #ifdef NECKO_PROTOCOL_gopher
819 { "GopherDirListingConverter",
820 NS_GOPHERDIRLISTINGCONVERTER_CID,
821 NS_ISTREAMCONVERTER_KEY GOPHER_TO_INDEX,
822 nsGopherDirListingConvConstructor
824 #endif
826 { "Indexed to HTML Converter",
827 NS_NSINDEXEDTOHTMLCONVERTER_CID,
828 NS_ISTREAMCONVERTER_KEY INDEX_TO_HTML,
829 nsIndexedToHTML::Create
832 { "Directory Index Parser",
833 NS_DIRINDEXPARSER_CID,
834 NS_DIRINDEXPARSER_CONTRACTID,
835 nsDirIndexParserConstructor
838 { "MultiMixedConverter",
839 NS_MULTIMIXEDCONVERTER_CID,
840 NS_ISTREAMCONVERTER_KEY MULTI_MIXED_X,
841 CreateNewMultiMixedConvFactory
844 { "MultiMixedByteRange",
845 NS_MULTIMIXEDCONVERTER_CID,
846 NS_ISTREAMCONVERTER_KEY MULTI_BYTERANGES,
847 CreateNewMultiMixedConvFactory
850 { "MultiMixedConverter2",
851 NS_MULTIMIXEDCONVERTER_CID,
852 NS_ISTREAMCONVERTER_KEY MULTI_MIXED,
853 CreateNewMultiMixedConvFactory
856 { "Unknown Content-Type Decoder",
857 NS_UNKNOWNDECODER_CID,
858 NS_ISTREAMCONVERTER_KEY UNKNOWN_CONTENT,
859 CreateNewUnknownDecoderFactory
862 { "Unknown Content-Type Decoder",
863 NS_UNKNOWNDECODER_CID,
864 NS_GENERIC_CONTENT_SNIFFER,
865 CreateNewUnknownDecoderFactory
868 { "Binary Detector",
869 NS_BINARYDETECTOR_CID,
870 NS_BINARYDETECTOR_CONTRACTID,
871 CreateNewBinaryDetectorFactory,
872 nsBinaryDetector::Register
875 { "HttpCompressConverter",
876 NS_HTTPCOMPRESSCONVERTER_CID,
877 NS_ISTREAMCONVERTER_KEY GZIP_TO_UNCOMPRESSED,
878 CreateNewHTTPCompressConvFactory
881 { "HttpCompressConverter",
882 NS_HTTPCOMPRESSCONVERTER_CID,
883 NS_ISTREAMCONVERTER_KEY XGZIP_TO_UNCOMPRESSED,
884 CreateNewHTTPCompressConvFactory
886 { "HttpCompressConverter",
887 NS_HTTPCOMPRESSCONVERTER_CID,
888 NS_ISTREAMCONVERTER_KEY COMPRESS_TO_UNCOMPRESSED,
889 CreateNewHTTPCompressConvFactory
891 { "HttpCompressConverter",
892 NS_HTTPCOMPRESSCONVERTER_CID,
893 NS_ISTREAMCONVERTER_KEY XCOMPRESS_TO_UNCOMPRESSED,
894 CreateNewHTTPCompressConvFactory
896 { "HttpCompressConverter",
897 NS_HTTPCOMPRESSCONVERTER_CID,
898 NS_ISTREAMCONVERTER_KEY DEFLATE_TO_UNCOMPRESSED,
899 CreateNewHTTPCompressConvFactory
901 { "NSTXTToHTMLConverter",
902 NS_NSTXTTOHTMLCONVERTER_CID,
903 NS_ISTREAMCONVERTER_KEY PLAIN_TO_HTML,
904 CreateNewNSTXTToHTMLConvFactory
906 #ifdef BUILD_BINHEX_DECODER
907 { "nsBinHexConverter", NS_BINHEXDECODER_CID,
908 NS_ISTREAMCONVERTER_KEY BINHEX_TO_WILD,
909 nsBinHexDecoderConstructor
911 #endif
912 // This is not a real stream converter, it's just
913 // registering its cid factory here.
914 { "HACK-TXTToHTMLConverter",
915 MOZITXTTOHTMLCONV_CID,
916 MOZ_TXTTOHTMLCONV_CONTRACTID,
917 CreateNewTXTToHTMLConvFactory
920 { "Directory Index",
921 NS_DIRINDEX_CID,
922 "@mozilla.org/dirIndex;1",
923 nsDirIndexConstructor
926 // from netwerk/mime:
927 { "mime header param",
928 NS_MIMEHEADERPARAM_CID,
929 NS_MIMEHEADERPARAM_CONTRACTID,
930 nsMIMEHeaderParamImplConstructor
933 #ifdef NECKO_PROTOCOL_file
934 // from netwerk/protocol/file:
935 { NS_FILEPROTOCOLHANDLER_CLASSNAME,
936 NS_FILEPROTOCOLHANDLER_CID,
937 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "file",
938 nsFileProtocolHandlerConstructor
940 #endif
942 #ifdef NECKO_PROTOCOL_http
943 { "HTTP Handler",
944 NS_HTTPPROTOCOLHANDLER_CID,
945 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http",
946 nsHttpHandlerConstructor },
948 { "HTTPS Handler",
949 NS_HTTPSPROTOCOLHANDLER_CID,
950 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "https",
951 nsHttpsHandlerConstructor },
953 { "HTTP Basic Auth Encoder",
954 NS_HTTPBASICAUTH_CID,
955 NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX "basic",
956 nsHttpBasicAuthConstructor },
958 { "HTTP Digest Auth Encoder",
959 NS_HTTPDIGESTAUTH_CID,
960 NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX "digest",
961 nsHttpDigestAuthConstructor },
963 { "HTTP NTLM Auth Encoder",
964 NS_HTTPNTLMAUTH_CID,
965 NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX "ntlm",
966 nsHttpNTLMAuthConstructor },
968 { NS_HTTPAUTHMANAGER_CLASSNAME,
969 NS_HTTPAUTHMANAGER_CID,
970 NS_HTTPAUTHMANAGER_CONTRACTID,
971 nsHttpAuthManagerConstructor },
972 #endif // !NECKO_PROTOCOL_http
974 #ifdef NECKO_PROTOCOL_ftp
975 // from netwerk/protocol/ftp:
976 { NS_FTPPROTOCOLHANDLER_CLASSNAME,
977 NS_FTPPROTOCOLHANDLER_CID,
978 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "ftp",
979 nsFtpProtocolHandlerConstructor
981 #endif
983 #ifdef NECKO_PROTOCOL_res
984 // from netwerk/protocol/res:
985 { NS_RESPROTOCOLHANDLER_CLASSNAME,
986 NS_RESPROTOCOLHANDLER_CID,
987 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "resource",
988 nsResProtocolHandlerConstructor
990 { NS_RESURL_CLASSNAME, // needed only for fastload
991 NS_RESURL_CID,
992 nsnull,
993 nsResURLConstructor
995 #endif
997 // from netwerk/protocol/about (about:blank is mandatory):
998 { NS_ABOUTPROTOCOLHANDLER_CLASSNAME,
999 NS_ABOUTPROTOCOLHANDLER_CID,
1000 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "about",
1001 nsAboutProtocolHandlerConstructor
1003 { NS_SAFEABOUTPROTOCOLHANDLER_CLASSNAME,
1004 NS_SAFEABOUTPROTOCOLHANDLER_CID,
1005 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "moz-safe-about",
1006 nsSafeAboutProtocolHandlerConstructor
1008 { "about:blank",
1009 NS_ABOUT_BLANK_MODULE_CID,
1010 NS_ABOUT_MODULE_CONTRACTID_PREFIX "blank",
1011 nsAboutBlank::Create
1013 #ifdef NECKO_PROTOCOL_about
1014 #ifdef NS_BUILD_REFCNT_LOGGING
1015 { "about:bloat",
1016 NS_ABOUT_BLOAT_MODULE_CID,
1017 NS_ABOUT_MODULE_CONTRACTID_PREFIX "bloat",
1018 nsAboutBloat::Create
1020 #endif
1021 { "about:cache",
1022 NS_ABOUT_CACHE_MODULE_CID,
1023 NS_ABOUT_MODULE_CONTRACTID_PREFIX "cache",
1024 nsAboutCache::Create
1026 { "about:cache-entry",
1027 NS_ABOUT_CACHE_ENTRY_MODULE_CID,
1028 NS_ABOUT_MODULE_CONTRACTID_PREFIX "cache-entry",
1029 nsAboutCacheEntryConstructor
1031 #endif
1033 { "nsSOCKSSocketProvider",
1034 NS_SOCKSSOCKETPROVIDER_CID,
1035 NS_NETWORK_SOCKET_CONTRACTID_PREFIX "socks",
1036 nsSOCKSSocketProvider::CreateV5
1039 { "nsSOCKS4SocketProvider",
1040 NS_SOCKS4SOCKETPROVIDER_CID,
1041 NS_NETWORK_SOCKET_CONTRACTID_PREFIX "socks4",
1042 nsSOCKSSocketProvider::CreateV4
1045 { "nsUDPSocketProvider",
1046 NS_UDPSOCKETPROVIDER_CID,
1047 NS_NETWORK_SOCKET_CONTRACTID_PREFIX "udp",
1048 nsUDPSocketProviderConstructor
1051 { NS_CACHESERVICE_CLASSNAME,
1052 NS_CACHESERVICE_CID,
1053 NS_CACHESERVICE_CONTRACTID,
1054 nsCacheService::Create
1057 #ifdef NECKO_OFFLINE_CACHE
1058 { NS_APPLICATIONCACHESERVICE_CLASSNAME,
1059 NS_APPLICATIONCACHESERVICE_CID,
1060 NS_APPLICATIONCACHESERVICE_CONTRACTID,
1061 nsOfflineCacheDeviceConstructor
1063 { NS_APPLICATIONCACHENAMESPACE_CLASSNAME,
1064 NS_APPLICATIONCACHENAMESPACE_CID,
1065 NS_APPLICATIONCACHENAMESPACE_CONTRACTID,
1066 nsApplicationCacheNamespaceConstructor
1068 #endif
1070 #ifdef NECKO_COOKIES
1071 { NS_COOKIEMANAGER_CLASSNAME,
1072 NS_COOKIEMANAGER_CID,
1073 NS_COOKIEMANAGER_CONTRACTID,
1074 nsCookieServiceConstructor
1077 { NS_COOKIESERVICE_CLASSNAME,
1078 NS_COOKIESERVICE_CID,
1079 NS_COOKIESERVICE_CONTRACTID,
1080 nsCookieServiceConstructor
1082 #endif
1084 #ifdef NECKO_PROTOCOL_gopher
1085 //gopher:
1086 { "The Gopher Protocol Handler",
1087 NS_GOPHERHANDLER_CID,
1088 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "gopher",
1089 nsGopherHandlerConstructor
1091 #endif
1093 #ifdef NECKO_PROTOCOL_data
1094 // from netwerk/protocol/data:
1095 { "Data Protocol Handler",
1096 NS_DATAPROTOCOLHANDLER_CID,
1097 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "data",
1098 nsDataHandler::Create},
1099 #endif
1101 #ifdef NECKO_PROTOCOL_viewsource
1102 // from netwerk/protocol/viewsource:
1103 { "The ViewSource Protocol Handler",
1104 NS_VIEWSOURCEHANDLER_CID,
1105 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "view-source",
1106 nsViewSourceHandlerConstructor
1108 #endif
1110 #if defined(XP_WIN) && !defined(WINCE)
1111 { NS_NETWORK_LINK_SERVICE_CLASSNAME,
1112 NS_NETWORK_LINK_SERVICE_CID,
1113 NS_NETWORK_LINK_SERVICE_CONTRACTID,
1114 nsNotifyAddrListenerConstructor
1116 #elif defined(MOZ_WIDGET_COCOA)
1117 { NS_NETWORK_LINK_SERVICE_CLASSNAME,
1118 NS_NETWORK_LINK_SERVICE_CID,
1119 NS_NETWORK_LINK_SERVICE_CONTRACTID,
1120 nsNetworkLinkServiceConstructor
1122 #endif
1125 NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(necko, gNetModuleInfo,
1126 nsNetStartup, nsNetShutdown)