Move finger and datetime protocols to extensions/, not built by default (bug 98753). r=cls, sr=darin.

This commit is contained in:
bryner%netscape.com 2002-09-03 02:14:42 +00:00
Родитель 79d4542503
Коммит 85f230d791
24 изменённых файлов: 8 добавлений и 1822 удалений

Просмотреть файл

@ -392,13 +392,9 @@ netwerk/protocol/about/src/Makefile
netwerk/protocol/data/Makefile
netwerk/protocol/data/public/Makefile
netwerk/protocol/data/src/Makefile
netwerk/protocol/datetime/src/Makefile
netwerk/protocol/datetime/Makefile
netwerk/protocol/file/Makefile
netwerk/protocol/file/public/Makefile
netwerk/protocol/file/src/Makefile
netwerk/protocol/finger/Makefile
netwerk/protocol/finger/src/Makefile
netwerk/protocol/ftp/Makefile
netwerk/protocol/ftp/public/Makefile
netwerk/protocol/ftp/src/Makefile
@ -1064,6 +1060,12 @@ for extension in $MOZ_EXTENSIONS; do
extensions/cview/Makefile
extensions/cview/resources/Makefile
" ;;
datetime ) MAKEFILES_extensions="$MAKEFILES_extensions
extensions/datetime/Makefile
" ;;
finger ) MAKEFILES_extensions="$MAKEFILES_extensions
extensions/finger/Makefile
" ;;
help ) MAKEFILES_extensions="$MAKEFILES_extensions
extensions/help/Makefile
extensions/help/resources/Makefile

Просмотреть файл

@ -3258,7 +3258,7 @@ dnl ========================================================
MOZ_EXTENSIONS_DEFAULT=" cookie wallet content-packs xml-rpc xmlextras help pref transformiix venkman inspector irc universalchardet typeaheadfind"
MOZ_EXTENSIONS_ALL="$MOZ_EXTENSIONS_DEFAULT xmlterm access-builtin p3p interfaceinfo"
MOZ_EXTENSIONS_ALL="$MOZ_EXTENSIONS_DEFAULT xmlterm access-builtin p3p interfaceinfo datetime finger"
MOZ_ARG_ENABLE_STRING(extensions,
[ --enable-extensions Enable extensions],

Просмотреть файл

@ -42,8 +42,6 @@ CPPSRCS = nsNetModule2.cpp
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/$(LIB_PREFIX)nkgopher_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)nkftp_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)nkfinger_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)nkdatetm_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)nkviewsource_s.$(LIB_SUFFIX) \
$(NULL)

Просмотреть файл

@ -39,8 +39,6 @@
#include "nsGopherHandler.h"
#include "nsFtpProtocolHandler.h"
#include "nsFingerHandler.h"
#include "nsDateTimeHandler.h"
#include "nsViewSourceHandler.h"
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsFtpProtocolHandler, Init);
@ -63,20 +61,6 @@ static const nsModuleComponentInfo gNetModuleInfo[] = {
nsFtpProtocolHandlerConstructor
},
// from netwerk/protocol/finger:
{ "The Finger Protocol Handler",
NS_FINGERHANDLER_CID,
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "finger",
nsFingerHandler::Create
},
// from netwerk/protocol/datetime:
{ "The DateTime Protocol Handler",
NS_DATETIMEHANDLER_CID,
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "datetime",
nsDateTimeHandler::Create
},
// from netwerk/protocol/viewsource:
{ "The ViewSource Protocol Handler",
NS_VIEWSOURCEHANDLER_CID,

Просмотреть файл

@ -1006,34 +1006,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDateTimeChannel.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDateTimeHandler.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFingerChannel.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFingerHandler.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFtpProtocolHandler.cpp</PATH>
@ -1127,26 +1099,6 @@
<PATH>nsNetModule2.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDateTimeChannel.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDateTimeHandler.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFingerChannel.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFingerHandler.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFtpProtocolHandler.cpp</PATH>
@ -2142,34 +2094,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDateTimeChannel.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDateTimeHandler.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFingerChannel.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFingerHandler.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFtpProtocolHandler.cpp</PATH>
@ -2263,26 +2187,6 @@
<PATH>nsNetModule2.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDateTimeChannel.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDateTimeHandler.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFingerChannel.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFingerHandler.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFtpProtocolHandler.cpp</PATH>
@ -2342,34 +2246,6 @@
</FILEREF>
</GROUP>
<GROUP><NAME>protocol</NAME>
<GROUP><NAME>datetime</NAME>
<FILEREF>
<TARGETNAME>Necko2.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDateTimeChannel.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>Necko2.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsDateTimeHandler.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</GROUP>
<GROUP><NAME>finger</NAME>
<FILEREF>
<TARGETNAME>Necko2.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFingerChannel.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>Necko2.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsFingerHandler.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</GROUP>
<GROUP><NAME>ftp</NAME>
<FILEREF>
<TARGETNAME>Necko2.shlb</TARGETNAME>

Просмотреть файл

@ -27,7 +27,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = about data file ftp http keyword jar res \
datetime finger gopher viewsource
gopher viewsource
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1 +0,0 @@
Makefile

Просмотреть файл

@ -1,31 +0,0 @@
#
# 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):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = src
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1 +0,0 @@
Makefile

Просмотреть файл

@ -1,49 +0,0 @@
#
# 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):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = necko2
LIBRARY_NAME = nkdatetm_s
REQUIRES = xpcom \
string \
necko \
$(NULL)
CPPSRCS = \
nsDateTimeHandler.cpp \
nsDateTimeChannel.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
ifeq ($(OS_ARCH),WINNT)
DEFINES += -DWIN32_LEAN_AND_MEAN
endif

Просмотреть файл

@ -1,372 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// datetime implementation
#include "nsDateTimeChannel.h"
#include "nsNetUtil.h"
#include "nsIServiceManager.h"
#include "nsILoadGroup.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsXPIDLString.h"
#include "nsISocketTransportService.h"
#include "nsITransport.h"
#include "nsIProgressEventSink.h"
// nsDateTimeChannel methods
nsDateTimeChannel::nsDateTimeChannel() {
NS_INIT_REFCNT();
mContentLength = -1;
mPort = -1;
}
nsDateTimeChannel::~nsDateTimeChannel() {
}
NS_IMPL_ISUPPORTS4(nsDateTimeChannel,
nsIChannel,
nsIRequest,
nsIStreamListener,
nsIRequestObserver)
nsresult
nsDateTimeChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo)
{
nsresult rv;
NS_ASSERTION(uri, "no uri");
mUrl = uri;
mProxyInfo = proxyInfo;
rv = mUrl->GetPort(&mPort);
if (NS_FAILED(rv) || mPort < 1)
mPort = DATETIME_PORT;
rv = mUrl->GetPath(mHost);
if (NS_FAILED(rv)) return rv;
if (!*(const char *)mHost) return NS_ERROR_NOT_INITIALIZED;
return NS_OK;
}
NS_METHOD
nsDateTimeChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)
{
nsDateTimeChannel* dc = new nsDateTimeChannel();
if (dc == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(dc);
nsresult rv = dc->QueryInterface(aIID, aResult);
NS_RELEASE(dc);
return rv;
}
////////////////////////////////////////////////////////////////////////////////
// nsIRequest methods:
NS_IMETHODIMP
nsDateTimeChannel::GetName(nsACString &result)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDateTimeChannel::IsPending(PRBool *result)
{
NS_NOTREACHED("nsDateTimeChannel::IsPending");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDateTimeChannel::GetStatus(nsresult *status)
{
*status = NS_OK;
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::Cancel(nsresult status)
{
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
NS_NOTREACHED("nsDateTimeChannel::Cancel");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDateTimeChannel::Suspend(void)
{
NS_NOTREACHED("nsDateTimeChannel::Suspend");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDateTimeChannel::Resume(void)
{
NS_NOTREACHED("nsDateTimeChannel::Resume");
return NS_ERROR_NOT_IMPLEMENTED;
}
////////////////////////////////////////////////////////////////////////////////
// nsIChannel methods:
NS_IMETHODIMP
nsDateTimeChannel::GetOriginalURI(nsIURI* *aURI)
{
*aURI = mOriginalURI ? mOriginalURI : mUrl;
NS_ADDREF(*aURI);
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::SetOriginalURI(nsIURI* aURI)
{
mOriginalURI = aURI;
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::GetURI(nsIURI* *aURI)
{
*aURI = mUrl;
NS_IF_ADDREF(*aURI);
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::Open(nsIInputStream **_retval)
{
nsresult rv = NS_OK;
rv = NS_CheckPortSafety(mPort, "datetime");
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISocketTransportService> sts =
do_GetService("@mozilla.org/network/socket-transport-service;1", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> transport;
rv = sts->CreateTransport(mHost,
mPort,
mProxyInfo,
32,
32,
getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
transport->SetNotificationCallbacks(mCallbacks,
(mLoadFlags & LOAD_BACKGROUND));
return transport->OpenInputStream(0, PRUint32(-1), 0, _retval);
}
NS_IMETHODIMP
nsDateTimeChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
{
nsresult rv = NS_OK;
rv = NS_CheckPortSafety(mPort, "datetime");
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISocketTransportService> sts =
do_GetService("@mozilla.org/network/socket-transport-service;1", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> transport;
rv = sts->CreateTransport(mHost,
mPort,
mProxyInfo,
32,
32,
getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
transport->SetNotificationCallbacks(mCallbacks,
(mLoadFlags & LOAD_BACKGROUND));
mListener = aListener;
nsCOMPtr<nsIRequest> request;
return transport->AsyncRead(this, ctxt, 0, PRUint32(-1), 0, getter_AddRefs(request));
}
NS_IMETHODIMP
nsDateTimeChannel::GetLoadFlags(PRUint32 *aLoadFlags)
{
*aLoadFlags = mLoadFlags;
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::SetLoadFlags(PRUint32 aLoadFlags)
{
mLoadFlags = aLoadFlags;
return NS_OK;
}
#define DATETIME_TYPE "text/plain"
NS_IMETHODIMP
nsDateTimeChannel::GetContentType(nsACString &aContentType)
{
aContentType = NS_LITERAL_CSTRING(DATETIME_TYPE);
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::SetContentType(const nsACString &aContentType)
{
// It doesn't make sense to set the content-type on this type
// of channel...
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsDateTimeChannel::GetContentCharset(nsACString &aContentCharset)
{
aContentCharset.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::SetContentCharset(const nsACString &aContentCharset)
{
NS_NOTREACHED("nsDateTimeChannel::SetContentCharset");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDateTimeChannel::GetContentLength(PRInt32 *aContentLength)
{
*aContentLength = mContentLength;
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::SetContentLength(PRInt32 aContentLength)
{
NS_NOTREACHED("nsDateTimeChannel::SetContentLength");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDateTimeChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
{
*aLoadGroup = mLoadGroup;
NS_IF_ADDREF(*aLoadGroup);
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
{
if (mLoadGroup) // if we already had a load group remove ourselves...
(void)mLoadGroup->RemoveRequest(this, nsnull, NS_OK);
mLoadGroup = aLoadGroup;
if (mLoadGroup) {
return mLoadGroup->AddRequest(this, nsnull);
}
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::GetOwner(nsISupports* *aOwner)
{
*aOwner = mOwner.get();
NS_IF_ADDREF(*aOwner);
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::SetOwner(nsISupports* aOwner)
{
mOwner = aOwner;
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
{
*aNotificationCallbacks = mCallbacks.get();
NS_IF_ADDREF(*aNotificationCallbacks);
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
{
mCallbacks = aNotificationCallbacks;
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeChannel::GetSecurityInfo(nsISupports **sec)
{
NS_ENSURE_ARG_POINTER(sec);
*sec = nsnull;
return NS_OK;
}
// nsIRequestObserver methods
NS_IMETHODIMP
nsDateTimeChannel::OnStartRequest(nsIRequest *request, nsISupports *aContext) {
return mListener->OnStartRequest(this, aContext);
}
NS_IMETHODIMP
nsDateTimeChannel::OnStopRequest(nsIRequest *request, nsISupports* aContext,
nsresult aStatus) {
if (mLoadGroup) {
nsresult rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus);
if (NS_FAILED(rv)) return rv;
}
return mListener->OnStopRequest(this, aContext, aStatus);
}
// nsIStreamListener method
NS_IMETHODIMP
nsDateTimeChannel::OnDataAvailable(nsIRequest *request, nsISupports* aContext,
nsIInputStream *aInputStream, PRUint32 aSourceOffset,
PRUint32 aLength) {
mContentLength = aLength;
return mListener->OnDataAvailable(this, aContext, aInputStream, aSourceOffset, aLength);
}

Просмотреть файл

@ -1,95 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// A datetime channel retrieves date time information from
// RFC 867 compliant datetime servers. The date/time returned
// to the caller is of MIME type "text/plain".
#ifndef nsDateTimeChannel_h___
#define nsDateTimeChannel_h___
#include "nsString.h"
#include "nsILoadGroup.h"
#include "nsIInputStream.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsIChannel.h"
#include "nsIURI.h"
#include "nsDateTimeHandler.h"
#include "nsIStreamListener.h"
#include "nsIProxyInfo.h"
class nsDateTimeChannel
: public nsIChannel,
public nsIStreamListener {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUEST
NS_DECL_NSICHANNEL
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIREQUESTOBSERVER
// nsDateTimeChannel methods:
nsDateTimeChannel();
virtual ~nsDateTimeChannel();
// Define a Create method to be used with a factory:
static NS_METHOD
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
nsresult Init(nsIURI* uri, nsIProxyInfo* proxyInfo);
protected:
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsIURI> mUrl;
nsCOMPtr<nsIStreamListener> mListener;
PRUint32 mLoadFlags;
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCString mContentType;
PRInt32 mContentLength;
nsCOMPtr<nsISupports> mOwner;
nsCOMPtr<nsIProxyInfo> mProxyInfo;
PRInt32 mPort;
nsXPIDLCString mHost;
};
#endif /* nsDateTimeChannel_h___ */

Просмотреть файл

@ -1,156 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nspr.h"
#include "nsDateTimeChannel.h"
#include "nsDateTimeHandler.h"
#include "nsIURL.h"
#include "nsCRT.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIProgressEventSink.h"
#include "nsNetCID.h"
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
////////////////////////////////////////////////////////////////////////////////
nsDateTimeHandler::nsDateTimeHandler() {
NS_INIT_REFCNT();
}
nsDateTimeHandler::~nsDateTimeHandler() {
}
NS_IMPL_ISUPPORTS2(nsDateTimeHandler,
nsIProtocolHandler,
nsIProxiedProtocolHandler)
NS_METHOD
nsDateTimeHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) {
nsDateTimeHandler* ph = new nsDateTimeHandler();
if (ph == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(ph);
nsresult rv = ph->QueryInterface(aIID, aResult);
NS_RELEASE(ph);
return rv;
}
////////////////////////////////////////////////////////////////////////////////
// nsIProtocolHandler methods:
NS_IMETHODIMP
nsDateTimeHandler::GetScheme(nsACString &result) {
result = "datetime";
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeHandler::GetDefaultPort(PRInt32 *result) {
*result = DATETIME_PORT;
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeHandler::GetProtocolFlags(PRUint32 *result) {
*result = URI_NORELATIVE | URI_NOAUTH | ALLOWS_PROXY;
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeHandler::NewURI(const nsACString &aSpec,
const char *aCharset, // ignore charset info
nsIURI *aBaseURI,
nsIURI **result) {
nsresult rv;
nsIURI* url;
rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv;
rv = url->SetSpec(aSpec);
if (NS_FAILED(rv)) {
NS_RELEASE(url);
return rv;
}
*result = url;
return rv;
}
NS_IMETHODIMP
nsDateTimeHandler::NewChannel(nsIURI* url, nsIChannel* *result)
{
return NewProxiedChannel(url, nsnull, result);
}
NS_IMETHODIMP
nsDateTimeHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo,
nsIChannel* *result)
{
nsresult rv;
nsDateTimeChannel* channel;
rv = nsDateTimeChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel);
if (NS_FAILED(rv)) return rv;
rv = channel->Init(url, proxyInfo);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;
}
*result = channel;
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
{
if (port == DATETIME_PORT)
*_retval = PR_TRUE;
else
*_retval = PR_FALSE;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -1,67 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// The datetime protocol handler creates "datetime" URIs of the form
// "datetime:RFC867Server".
#ifndef nsDateTimeHandler_h___
#define nsDateTimeHandler_h___
#include "nsIProxiedProtocolHandler.h"
#define DATETIME_PORT 13
// {AA27D2A0-B71B-11d3-A1A0-0050041CAF44}
#define NS_DATETIMEHANDLER_CID \
{ 0xaa27d2a0, 0xb71b, 0x11d3, { 0xa1, 0xa0, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44 } }
class nsDateTimeHandler : public nsIProxiedProtocolHandler
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPROTOCOLHANDLER
NS_DECL_NSIPROXIEDPROTOCOLHANDLER
// nsDateTimeHandler methods:
nsDateTimeHandler();
virtual ~nsDateTimeHandler();
// Define a Create method to be used with a factory:
static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
};
#endif /* nsDateTimeHandler_h___ */

Просмотреть файл

@ -1,49 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIGenericFactory.h"
#include "nsDateTimeHandler.h"
static const nsModuleComponentInfo gResComponents[] = {
{ "The DateTime Protocol Handler",
NS_DATETIMEHANDLER_CID,
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "datetime",
nsDateTimeHandler::Create
}
};
NS_IMPL_NSGETMODULE(datetime, gResComponents)

Просмотреть файл

@ -1 +0,0 @@
Makefile

Просмотреть файл

@ -1,30 +0,0 @@
#
# The contents of this file are subject to the Mozilla 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/MPL/
#
# 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 Brian Ryner.
# Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
# All Rights Reserved.
#
# Contributor(s):
# Brian Ryner <bryner@uiuc.edu>
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = src
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1 +0,0 @@
Makefile

Просмотреть файл

@ -1,49 +0,0 @@
#
# The contents of this file are subject to the Mozilla 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/MPL/
#
# 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 Brian Ryner.
# Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
# All Rights Reserved.
#
# Contributor(s):
# Brian Ryner <bryner@uiuc.edu>
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = necko2
LIBRARY_NAME = nkfinger_s
REQUIRES = xpcom \
string \
necko \
mimetype \
$(NULL)
CPPSRCS = \
nsFingerHandler.cpp \
nsFingerChannel.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
ifeq ($(OS_ARCH),WINNT)
DEFINES += -DWIN32_LEAN_AND_MEAN
endif

Просмотреть файл

@ -1,452 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Brian Ryner.
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
* All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@uiuc.edu>
*/
// finger implementation
#include "nsFingerChannel.h"
#include "nsIServiceManager.h"
#include "nsILoadGroup.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsXPIDLString.h"
#include "nsISocketTransportService.h"
#include "nsIStringStream.h"
#include "nsMimeTypes.h"
#include "nsIStreamConverterService.h"
#include "nsITXTToHTMLConv.h"
#include "nsIProgressEventSink.h"
#include "nsNetUtil.h"
#include "nsCRT.h"
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
#define BUFFER_SEG_SIZE (4*1024)
#define BUFFER_MAX_SIZE (64*1024)
// nsFingerChannel methods
nsFingerChannel::nsFingerChannel()
: mContentLength(-1),
mActAsObserver(PR_TRUE),
mPort(-1),
mStatus(NS_OK)
{
NS_INIT_REFCNT();
}
nsFingerChannel::~nsFingerChannel() {
}
NS_IMPL_THREADSAFE_ISUPPORTS4(nsFingerChannel,
nsIChannel,
nsIRequest,
nsIStreamListener,
nsIRequestObserver)
nsresult
nsFingerChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo)
{
nsresult rv;
nsCAutoString autoBuffer;
NS_ASSERTION(uri, "no uri");
mUrl = uri;
mProxyInfo = proxyInfo;
// For security reasons, we do not allow the user to specify a
// non-default port for finger: URL's.
mPort = FINGER_PORT;
rv = mUrl->GetPath(autoBuffer); // autoBuffer = user@host
if (NS_FAILED(rv)) return rv;
// Now parse out the user and host
const char* buf = autoBuffer.get();
const char* pos = strchr(buf, '@');
// Catch the case of just the host being given
if (!pos) {
mHost.Assign(buf);
} else {
mUser.Assign(buf,pos-buf);
mHost.Assign(pos+1); // ignore '@'
}
if (mHost.IsEmpty()) return NS_ERROR_NOT_INITIALIZED;
return NS_OK;
}
NS_METHOD
nsFingerChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)
{
nsFingerChannel* fc = new nsFingerChannel();
if (fc == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(fc);
nsresult rv = fc->QueryInterface(aIID, aResult);
NS_RELEASE(fc);
return rv;
}
////////////////////////////////////////////////////////////////////////////////
// nsIRequest methods:
NS_IMETHODIMP
nsFingerChannel::GetName(nsACString &result)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFingerChannel::IsPending(PRBool *result)
{
NS_NOTREACHED("nsFingerChannel::IsPending");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFingerChannel::GetStatus(nsresult *status)
{
*status = mStatus;
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::Cancel(nsresult status)
{
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
nsresult rv = NS_ERROR_FAILURE;
mStatus = status;
if (mTransportRequest) {
rv = mTransportRequest->Cancel(status);
}
return rv;
}
NS_IMETHODIMP
nsFingerChannel::Suspend(void)
{
NS_NOTREACHED("nsFingerChannel::Suspend");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFingerChannel::Resume(void)
{
NS_NOTREACHED("nsFingerChannel::Resume");
return NS_ERROR_NOT_IMPLEMENTED;
}
////////////////////////////////////////////////////////////////////////////////
// nsIChannel methods:
NS_IMETHODIMP
nsFingerChannel::GetOriginalURI(nsIURI* *aURI)
{
*aURI = mOriginalURI ? mOriginalURI : mUrl;
NS_ADDREF(*aURI);
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::SetOriginalURI(nsIURI* aURI)
{
mOriginalURI = aURI;
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::GetURI(nsIURI* *aURI)
{
*aURI = mUrl;
NS_IF_ADDREF(*aURI);
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::Open(nsIInputStream **_retval)
{
nsresult rv = NS_OK;
rv = NS_CheckPortSafety(mPort, "finger");
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISocketTransportService> socketService =
do_GetService(kSocketTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = socketService->CreateTransport(mHost.get(), mPort, mProxyInfo, BUFFER_SEG_SIZE,
BUFFER_MAX_SIZE, getter_AddRefs(mTransport));
if (NS_FAILED(rv)) return rv;
mTransport->SetNotificationCallbacks(mCallbacks,
(mLoadFlags & LOAD_BACKGROUND));
return mTransport->OpenInputStream(0, PRUint32(-1), 0, _retval);
}
NS_IMETHODIMP
nsFingerChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
{
nsresult rv = NS_OK;
rv = NS_CheckPortSafety(mPort, "finger");
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISocketTransportService> socketService =
do_GetService(kSocketTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = socketService->CreateTransport(mHost.get(), mPort, mProxyInfo, BUFFER_SEG_SIZE,
BUFFER_MAX_SIZE, getter_AddRefs(mTransport));
if (NS_FAILED(rv)) return rv;
mTransport->SetNotificationCallbacks(mCallbacks,
(mLoadFlags & LOAD_BACKGROUND));
mListener = aListener;
mResponseContext = ctxt;
return SendRequest(mTransport);
}
NS_IMETHODIMP
nsFingerChannel::GetLoadFlags(PRUint32 *aLoadFlags)
{
*aLoadFlags = mLoadFlags;
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::SetLoadFlags(PRUint32 aLoadFlags)
{
mLoadFlags = aLoadFlags;
return NS_OK;
}
#define FINGER_TYPE TEXT_HTML
NS_IMETHODIMP
nsFingerChannel::GetContentType(nsACString &aContentType)
{
aContentType = NS_LITERAL_CSTRING(FINGER_TYPE);
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::SetContentType(const nsACString &aContentType)
{
//It doesn't make sense to set the content-type on this type
// of channel...
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsFingerChannel::GetContentCharset(nsACString &aContentCharset)
{
aContentCharset.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::SetContentCharset(const nsACString &aContentCharset)
{
NS_NOTREACHED("nsFingerChannel::SetContentCharset");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFingerChannel::GetContentLength(PRInt32 *aContentLength)
{
*aContentLength = mContentLength;
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::SetContentLength(PRInt32 aContentLength)
{
NS_NOTREACHED("nsFingerChannel::SetContentLength");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFingerChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
{
*aLoadGroup = mLoadGroup;
NS_IF_ADDREF(*aLoadGroup);
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
{
mLoadGroup = aLoadGroup;
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::GetOwner(nsISupports* *aOwner)
{
*aOwner = mOwner.get();
NS_IF_ADDREF(*aOwner);
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::SetOwner(nsISupports* aOwner)
{
mOwner = aOwner;
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
{
*aNotificationCallbacks = mCallbacks.get();
NS_IF_ADDREF(*aNotificationCallbacks);
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
{
mCallbacks = aNotificationCallbacks;
return NS_OK;
}
NS_IMETHODIMP
nsFingerChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
{
*aSecurityInfo = nsnull;
return NS_OK;
}
// nsIRequestObserver methods
NS_IMETHODIMP
nsFingerChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) {
if (!mActAsObserver) {
// acting as a listener
return mListener->OnStartRequest(this, mResponseContext);
} else {
// we don't want to pass our AsyncWrite's OnStart through
// we just ignore this
return NS_OK;
}
}
NS_IMETHODIMP
nsFingerChannel::OnStopRequest(nsIRequest *aRequest, nsISupports* aContext,
nsresult aStatus)
{
nsresult rv = NS_OK;
if (NS_FAILED(aStatus) || !mActAsObserver) {
if (mLoadGroup) {
rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus);
if (NS_FAILED(rv)) return rv;
}
rv = mListener->OnStopRequest(this, mResponseContext, aStatus);
mTransport = 0;
return rv;
} else {
// at this point we know the request has been sent.
// we're no longer acting as an observer.
mActAsObserver = PR_FALSE;
nsCOMPtr<nsIStreamListener> converterListener;
nsCOMPtr<nsIStreamConverterService> StreamConvService =
do_GetService(kStreamConverterServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString fromStr(NS_LITERAL_STRING("text/plain"));
nsAutoString toStr(NS_LITERAL_STRING("text/html"));
rv = StreamConvService->AsyncConvertData(fromStr.get(),
toStr.get(), this, mResponseContext,
getter_AddRefs(converterListener));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITXTToHTMLConv> converter(do_QueryInterface(converterListener));
if (converter) {
nsAutoString title(NS_LITERAL_STRING("Finger information for "));
nsCAutoString userHost;
rv = mUrl->GetPath(userHost);
title.Append(NS_ConvertUTF8toUCS2(userHost));
converter->SetTitle(title.get());
converter->PreFormatHTML(PR_TRUE);
}
return mTransport->AsyncRead(converterListener, mResponseContext, 0, PRUint32(-1), 0,
getter_AddRefs(mTransportRequest));
}
}
// nsIStreamListener method
NS_IMETHODIMP
nsFingerChannel::OnDataAvailable(nsIRequest *aRequest, nsISupports* aContext,
nsIInputStream *aInputStream, PRUint32 aSourceOffset,
PRUint32 aLength) {
mContentLength = aLength;
return mListener->OnDataAvailable(this, mResponseContext, aInputStream, aSourceOffset, aLength);
}
nsresult
nsFingerChannel::SendRequest(nsITransport* aTransport) {
// The text to send should already be in mUser
nsresult rv = NS_OK;
nsCOMPtr<nsISupports> result;
nsCOMPtr<nsIInputStream> charstream;
nsCString requestBuffer(mUser);
if (mLoadGroup) {
mLoadGroup->AddRequest(this, nsnull);
}
requestBuffer.Append(CRLF);
mRequest.Assign(requestBuffer);
rv = NS_NewCharInputStream(getter_AddRefs(result), mRequest);
if (NS_FAILED(rv)) return rv;
charstream = do_QueryInterface(result, &rv);
if (NS_FAILED(rv)) return rv;
rv = NS_AsyncWriteFromStream(getter_AddRefs(mTransportRequest),
aTransport, charstream,
0, requestBuffer.Length(), 0,
this, nsnull);
return rv;
}

Просмотреть файл

@ -1,91 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Brian Ryner.
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
* All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@uiuc.edu>
*/
#ifndef nsFingerChannel_h___
#define nsFingerChannel_h___
#include "nsString.h"
#include "nsILoadGroup.h"
#include "nsIInputStream.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsIChannel.h"
#include "nsIURI.h"
#include "nsFingerHandler.h"
#include "nsIStreamListener.h"
#include "nsITransport.h"
#include "nsIProxyInfo.h"
class nsFingerChannel
: public nsIChannel,
public nsIStreamListener {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUEST
NS_DECL_NSICHANNEL
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIREQUESTOBSERVER
// nsFingerChannel methods:
nsFingerChannel();
virtual ~nsFingerChannel();
// Define a Create method to be used with a factory:
static NS_METHOD
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
nsresult Init(nsIURI* uri, nsIProxyInfo* proxyInfo);
protected:
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsIURI> mUrl;
nsCOMPtr<nsIStreamListener> mListener;
PRUint32 mLoadFlags;
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCString mContentType;
PRInt32 mContentLength;
nsCOMPtr<nsISupports> mOwner;
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
PRBool mActAsObserver;
PRInt32 mPort;
nsCString mHost;
nsCString mUser;
nsXPIDLCString mRequest;
nsCOMPtr<nsISupports> mResponseContext;
nsCOMPtr<nsITransport> mTransport;
nsCOMPtr<nsIRequest> mTransportRequest;
nsCOMPtr<nsIProxyInfo> mProxyInfo;
nsresult mStatus;
protected:
nsresult SendRequest(nsITransport* aTransport);
};
#endif /* nsFingerChannel_h___ */

Просмотреть файл

@ -1,140 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Brian Ryner.
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
* All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@uiuc.edu>
*/
#include "nspr.h"
#include "nsFingerChannel.h"
#include "nsFingerHandler.h"
#include "nsIURL.h"
#include "nsCRT.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIProgressEventSink.h"
#include "nsNetCID.h"
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
////////////////////////////////////////////////////////////////////////////////
nsFingerHandler::nsFingerHandler() {
NS_INIT_REFCNT();
}
nsFingerHandler::~nsFingerHandler() {
}
NS_IMPL_ISUPPORTS2(nsFingerHandler,
nsIProtocolHandler,
nsIProxiedProtocolHandler)
NS_METHOD
nsFingerHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) {
nsFingerHandler* ph = new nsFingerHandler();
if (ph == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(ph);
nsresult rv = ph->QueryInterface(aIID, aResult);
NS_RELEASE(ph);
return rv;
}
////////////////////////////////////////////////////////////////////////////////
// nsIProtocolHandler methods:
NS_IMETHODIMP
nsFingerHandler::GetScheme(nsACString &result) {
result = "finger";
return NS_OK;
}
NS_IMETHODIMP
nsFingerHandler::GetDefaultPort(PRInt32 *result) {
*result = FINGER_PORT;
return NS_OK;
}
NS_IMETHODIMP
nsFingerHandler::GetProtocolFlags(PRUint32 *result) {
*result = URI_NORELATIVE | URI_NOAUTH | ALLOWS_PROXY;
return NS_OK;
}
NS_IMETHODIMP
nsFingerHandler::NewURI(const nsACString &aSpec,
const char *aCharset, // ignore charset info
nsIURI *aBaseURI,
nsIURI **result) {
nsresult rv;
nsIURI* url;
rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv;
rv = url->SetSpec(aSpec);
if (NS_FAILED(rv)) {
NS_RELEASE(url);
return rv;
}
*result = url;
return rv;
}
NS_IMETHODIMP
nsFingerHandler::NewChannel(nsIURI* url, nsIChannel* *result)
{
return NewProxiedChannel(url, nsnull, result);
}
NS_IMETHODIMP
nsFingerHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo,
nsIChannel* *result)
{
nsresult rv;
nsFingerChannel* channel;
rv = nsFingerChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel);
if (NS_FAILED(rv)) return rv;
rv = channel->Init(url, proxyInfo);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;
}
*result = channel;
return NS_OK;
}
NS_IMETHODIMP
nsFingerHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
{
if (port == FINGER_PORT)
*_retval = PR_TRUE;
else
*_retval = PR_FALSE;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -1,55 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Brian Ryner.
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
* All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@uiuc.edu>
*/
// The finger protocol handler creates "finger" URIs of the form
// "finger:user@host" or "finger:host".
#ifndef nsFingerHandler_h___
#define nsFingerHandler_h___
#include "nsIProxiedProtocolHandler.h"
class nsIProxyInfo;
#define FINGER_PORT 79
// {0x76d6d5d8-1dd2-11b2-b361-850ddf15ef07}
#define NS_FINGERHANDLER_CID \
{ 0x76d6d5d8, 0x1dd2, 0x11b2, \
{0xb3, 0x61, 0x85, 0x0d, 0xdf, 0x15, 0xef, 0x07} }
class nsFingerHandler : public nsIProxiedProtocolHandler
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPROTOCOLHANDLER
NS_DECL_NSIPROXIEDPROTOCOLHANDLER
// nsFingerHandler methods:
nsFingerHandler();
virtual ~nsFingerHandler();
// Define a Create method to be used with a factory:
static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
};
#endif /* nsFingerHandler_h___ */

Просмотреть файл

@ -1,34 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Brian Ryner.
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
* All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@uiuc.edu>
*/
#include "nsIGenericFactory.h"
#include "nsFingerHandler.h"
static const nsModuleComponentInfo gResComponents[] = {
{ "The Finger Protocol Handler",
NS_FINGERHANDLER_CID,
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "finger",
nsFingerHandler::Create
}
};
NS_IMPL_NSGETMODULE(finger, gResComponents)