зеркало из https://github.com/mozilla/pjs.git
170 строки
6.1 KiB
C++
170 строки
6.1 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
*
|
|
* The contents of this file are subject to the Netscape Public
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.mozilla.org/NPL/
|
|
*
|
|
* Software distributed under the License is distributed on an "AS
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
* implied. See the License for the specific language governing
|
|
* rights and limitations under the License.
|
|
*
|
|
* The Original Code is mozilla.org code.
|
|
*
|
|
* The Initial Developer of the Original Code is Netscape
|
|
* Communications Corporation. Portions created by Netscape are
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
* Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
*/
|
|
|
|
#include "nsCOMPtr.h"
|
|
#include "nsIModule.h"
|
|
#include "nsIGenericFactory.h"
|
|
|
|
#include "nsFTPDirListingConv.h"
|
|
#include "nsMultiMixedConv.h"
|
|
#include "mozTXTToHTMLConv.h"
|
|
#include "nsUnknownDecoder.h"
|
|
|
|
nsresult NS_NewFTPDirListingConv(nsFTPDirListingConv** result);
|
|
nsresult NS_NewMultiMixedConv(nsMultiMixedConv** result);
|
|
nsresult MOZ_NewTXTToHTMLConv(mozTXTToHTMLConv** result);
|
|
|
|
|
|
static NS_IMETHODIMP
|
|
CreateNewFTPDirListingConv(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
|
{
|
|
if (!aResult) {
|
|
return NS_ERROR_INVALID_POINTER;
|
|
}
|
|
if (aOuter) {
|
|
*aResult = nsnull;
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
}
|
|
nsFTPDirListingConv* inst = nsnull;
|
|
nsresult rv = NS_NewFTPDirListingConv(&inst);
|
|
if (NS_FAILED(rv)) {
|
|
*aResult = nsnull;
|
|
return rv;
|
|
}
|
|
rv = inst->QueryInterface(aIID, aResult);
|
|
if (NS_FAILED(rv)) {
|
|
*aResult = nsnull;
|
|
}
|
|
NS_RELEASE(inst); /* get rid of extra refcnt */
|
|
return rv;
|
|
}
|
|
|
|
static NS_IMETHODIMP
|
|
CreateNewMultiMixedConvFactory(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
|
{
|
|
if (!aResult) {
|
|
return NS_ERROR_INVALID_POINTER;
|
|
}
|
|
if (aOuter) {
|
|
*aResult = nsnull;
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
}
|
|
nsMultiMixedConv* inst = nsnull;
|
|
nsresult rv = NS_NewMultiMixedConv(&inst);
|
|
if (NS_FAILED(rv)) {
|
|
*aResult = nsnull;
|
|
return rv;
|
|
}
|
|
rv = inst->QueryInterface(aIID, aResult);
|
|
if (NS_FAILED(rv)) {
|
|
*aResult = nsnull;
|
|
}
|
|
NS_RELEASE(inst); /* get rid of extra refcnt */
|
|
return rv;
|
|
}
|
|
|
|
static NS_IMETHODIMP
|
|
CreateNewTXTToHTMLConvFactory(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
|
{
|
|
if (!aResult) {
|
|
return NS_ERROR_INVALID_POINTER;
|
|
}
|
|
if (aOuter) {
|
|
*aResult = nsnull;
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
}
|
|
mozTXTToHTMLConv* inst = nsnull;
|
|
nsresult rv = MOZ_NewTXTToHTMLConv(&inst);
|
|
if (NS_FAILED(rv)) {
|
|
*aResult = nsnull;
|
|
return rv;
|
|
}
|
|
rv = inst->QueryInterface(aIID, aResult);
|
|
if (NS_FAILED(rv)) {
|
|
*aResult = nsnull;
|
|
}
|
|
NS_RELEASE(inst); /* get rid of extra refcnt */
|
|
return rv;
|
|
}
|
|
|
|
static NS_IMETHODIMP
|
|
CreateNewUnknownDecoderFactory(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
|
{
|
|
nsresult rv;
|
|
|
|
if (!aResult) {
|
|
return NS_ERROR_NULL_POINTER;
|
|
}
|
|
*aResult = nsnull;
|
|
|
|
if (aOuter) {
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
}
|
|
|
|
nsUnknownDecoder *inst;
|
|
|
|
inst = new nsUnknownDecoder();
|
|
if (!inst) {
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
}
|
|
NS_ADDREF(inst);
|
|
rv = inst->QueryInterface(aIID, aResult);
|
|
NS_RELEASE(inst);
|
|
|
|
return rv;
|
|
}
|
|
|
|
// The list of components we register
|
|
static nsModuleComponentInfo components[] =
|
|
{
|
|
{ "FTPDirListingConverter",
|
|
NS_FTPDIRLISTINGCONVERTER_CID,
|
|
NS_ISTREAMCONVERTER_KEY "?from=text/ftp-dir-unix?to=application/http-index-format",
|
|
CreateNewFTPDirListingConv
|
|
},
|
|
|
|
{ "FTPDirListingConverter",
|
|
NS_FTPDIRLISTINGCONVERTER_CID,
|
|
NS_ISTREAMCONVERTER_KEY "?from=text/ftp-dir-nt?to=application/http-index-format",
|
|
CreateNewFTPDirListingConv
|
|
},
|
|
|
|
{ "MultiMixedConverter",
|
|
NS_MULTIMIXEDCONVERTER_CID,
|
|
NS_ISTREAMCONVERTER_KEY "?from=multipart/x-mixed-replace?to=*/*",
|
|
CreateNewMultiMixedConvFactory
|
|
},
|
|
|
|
{ "TXTToHTMLConverter",
|
|
MOZITXTTOHTMLCONV_CID,
|
|
NS_ISTREAMCONVERTER_KEY "?from=text/plain?to=text/html",
|
|
CreateNewTXTToHTMLConvFactory
|
|
},
|
|
{ "Unknown Content-Type Decoder",
|
|
NS_UNKNOWNDECODER_CID,
|
|
NS_ISTREAMCONVERTER_KEY "?from=application/x-unknown-content-type?to=*/*",
|
|
CreateNewUnknownDecoderFactory
|
|
},
|
|
};
|
|
|
|
NS_IMPL_NSGETMODULE("nsConvModule", components);
|