зеркало из https://github.com/mozilla/pjs.git
netwerk/makefile.win - adding the ftp dir to the build
netwerk/ftp/* - adding the ftp module
This commit is contained in:
Родитель
f2478e6ac7
Коммит
9d8296fc3b
|
@ -0,0 +1,27 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ..\..\..
|
||||
|
||||
MODULE = netwerk
|
||||
|
||||
DIRS= \
|
||||
public \
|
||||
src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
|
@ -0,0 +1,28 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
MODULE = netwerk
|
||||
|
||||
DEPTH = ..\..\..\..
|
||||
|
||||
EXPORTS = \
|
||||
nsIFtpEventSink.h \
|
||||
nsIFtpProtocolConnection.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIFtpProtocolConnection_h___
|
||||
#define nsIFtpProtocolConnection_h___
|
||||
|
||||
#include "nsIProtocolConnection.h"
|
||||
|
||||
// {25029495-F132-11d2-9588-00805F369F95}
|
||||
#define NS_IFTPPROTOCOLCONNECTION_IID \
|
||||
{ 0x25029495, 0xf132, 0x11d2, { 0x95, 0x88, 0x0, 0x80, 0x5f, 0x36, 0x9f, 0x95 } }
|
||||
|
||||
|
||||
class nsIFtpProtocolConnection : public nsIProtocolConnection
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFTPPROTOCOLCONNECTION_IID);
|
||||
|
||||
// PRE connect
|
||||
NS_IMETHOD UsePASV(PRBool aComm) = 0;
|
||||
|
||||
// POST connect
|
||||
|
||||
// Initiate connect
|
||||
NS_IMETHOD Get(void) = 0;
|
||||
|
||||
NS_IMETHOD Put(void) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIIFtpProtocolConnection_h___ */
|
|
@ -0,0 +1,36 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIFtpProtocolHandler_h___
|
||||
#define nsIFtpProtocolHandler_h___
|
||||
|
||||
#include "nsIProtocolHandler.h"
|
||||
|
||||
// {AEF15D51-F132-11d2-9588-00805F369F95}
|
||||
#define NS_IFTPPROTOCOLHANDLER_IID \
|
||||
{ 0xaef15d51, 0xf132, 0x11d2, { 0x95, 0x88, 0x0, 0x80, 0x5f, 0x36, 0x9f, 0x95 } }
|
||||
|
||||
|
||||
class nsIFtpProtocolHandler : public nsIProtocolHandler
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFTPPROTOCOLHANDLER_IID);
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsIIFtpProtocolHandler_h___ */
|
|
@ -0,0 +1,49 @@
|
|||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
MODULE = netwerk
|
||||
|
||||
DEPTH = ..\..\..\..
|
||||
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
DLLNAME=ftp
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
LCFLAGS = -DWIN32_LEAN_AND_MEAN -D_IMPL_NS_NET
|
||||
|
||||
CPP_OBJS = \
|
||||
.\$(OBJDIR)\nsFtpProtocolHandler.obj \
|
||||
.\$(OBJDIR)\nsFtpProtocolConnection.obj \
|
||||
.\$(OBJDIR)\nsFtpFactory.obj \
|
||||
$(NULL)
|
||||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\netwerk.lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
LINCS = \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\netwerk \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsFtpProtocolHandler.h"
|
||||
#include "nscore.h"
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kFtpProtocolHandlerCID, NS_FTPPROTOCOLHANDLER_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsNetFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
nsNetFactory(const nsCID &aClass);
|
||||
|
||||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIFactory methods
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
protected:
|
||||
virtual ~nsNetFactory();
|
||||
|
||||
protected:
|
||||
nsCID mClassID;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsNetFactory::nsNetFactory(const nsCID &aClass)
|
||||
: mClassID(aClass)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsNetFactory::~nsNetFactory()
|
||||
{
|
||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsNetFactory, nsIFactory::GetIID());
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNetFactory::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (aResult == nsnull)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsISupports *inst = nsnull;
|
||||
if (mClassID.Equals(kFtpProtocolHandlerCID)) {
|
||||
if (aOuter) return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsFtpProtocolHandler* net = new nsFtpProtocolHandler();
|
||||
if (net == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
inst = net;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
NS_ADDREF(inst);
|
||||
*aResult = inst;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsNetFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
// Not implemented in simplest case.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// return the proper factory to the caller
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSGetFactory(nsISupports* aServMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
if (aFactory == nsnull)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsNetFactory* factory = new nsNetFactory(aClass);
|
||||
if (factory == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(factory);
|
||||
*aFactory = factory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr, aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kFtpProtocolHandlerCID,
|
||||
"FTP Protocol Handler",
|
||||
NS_NETWORK_PROTOCOL_PROGID_PREFIX "ftp",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_WITH_SERVICE1(nsIComponentManager, compMgr, aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kFtpProtocolHandlerCID, aPath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,166 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsFtpProtocolConnection.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIUrl.h"
|
||||
#include "nsIFtpEventSink.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
nsFtpProtocolConnection::nsFtpProtocolConnection()
|
||||
: mUrl(nsnull), mEventSink(nsnull), mPasv(TRUE),
|
||||
mServerType(FTP_GENERIC_TYPE), mConnected(FALSE) {
|
||||
}
|
||||
|
||||
nsFtpProtocolConnection::~nsFtpProtocolConnection() {
|
||||
NS_IF_RELEASE(mUrl);
|
||||
NS_IF_RELEASE(mEventSink);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsFtpProtocolConnection);
|
||||
NS_IMPL_RELEASE(nsFtpProtocolConnection);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::QueryInterface(const nsIID& aIID, void** aInstancePtr) {
|
||||
NS_ASSERTION(aInstancePtr, "no instance pointer");
|
||||
if (aIID.Equals(nsIFtpProtocolConnection::GetIID()) ||
|
||||
aIID.Equals(nsIProtocolConnection::GetIID()) ||
|
||||
aIID.Equals(kISupportsIID) ) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIFtpProtocolConnection*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsIStreamListener::GetIID()) ||
|
||||
aIID.Equals(nsIStreamObserver::GetIID())) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIStreamListener*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFtpProtocolConnection::Init(nsIUrl* url, nsISupports* eventSink) {
|
||||
nsresult rv;
|
||||
|
||||
mUrl = url;
|
||||
NS_ADDREF(mUrl);
|
||||
|
||||
rv = eventSink->QueryInterface(nsIFtpEventSink::GetIID(), (void**)&mEventSink);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsICancelable methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::Cancel(void) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::Suspend(void) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::Resume(void) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIProtocolConnection methods:
|
||||
|
||||
|
||||
// establishes the connection and initiates the file transfer.
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::Open(nsIUrl* url, nsISupports* eventSink) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::GetContentType(char* *contentType) {
|
||||
|
||||
// XXX for ftp we need to do a file extension-to-type mapping lookup
|
||||
// XXX in some hash table/registry of mime-types
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::GetInputStream(nsIInputStream* *result) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::GetOutputStream(nsIOutputStream* *result) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIFtpProtocolConnection methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::Get(void) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::Put(void) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::UsePASV(PRBool aComm) {
|
||||
if (mConnected)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
mPasv = aComm;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIStreamObserver methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::OnStartBinding(nsISupports* context) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::OnStopBinding(nsISupports* context,
|
||||
nsresult aStatus,
|
||||
nsIString* aMsg) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIStreamListener methods:
|
||||
|
||||
// state machine
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolConnection::OnDataAvailable(nsISupports* context,
|
||||
nsIInputStream *aIStream,
|
||||
PRUint32 aLength) {
|
||||
// each hunk of data that comes in is evaluated, appropriate action
|
||||
// is taken and the state is incremented.
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,99 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsFtpProtocolConnection_h___
|
||||
#define nsFtpProtocolConnection_h___
|
||||
|
||||
#include "nsIFtpProtocolConnection.h"
|
||||
#include "nsIStreamListener.h"
|
||||
|
||||
class nsIConnectionGroup;
|
||||
class nsIFtpEventSink;
|
||||
|
||||
|
||||
// ftp server types
|
||||
#define FTP_GENERIC_TYPE 0
|
||||
#define FTP_UNIX_TYPE 1
|
||||
#define FTP_DCTS_TYPE 2
|
||||
#define FTP_NCSA_TYPE 3
|
||||
#define FTP_PETER_LEWIS_TYPE 4
|
||||
#define FTP_MACHTEN_TYPE 5
|
||||
#define FTP_CMS_TYPE 6
|
||||
#define FTP_TCPC_TYPE 7
|
||||
#define FTP_VMS_TYPE 8
|
||||
#define FTP_NT_TYPE 9
|
||||
#define FTP_WEBSTAR_TYPE 10
|
||||
|
||||
// ftp states
|
||||
typedef enum _FTP_STATE {
|
||||
FTP_CONNECT,
|
||||
FTP_S_PASV,
|
||||
FTP_R_PASV,
|
||||
FTP_S_PORT,
|
||||
FTP_R_PORT,
|
||||
FTP_COMPLETE
|
||||
} FTP_STATE;
|
||||
|
||||
class nsFtpProtocolConnection : public nsIFtpProtocolConnection,
|
||||
public nsIStreamListener {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsICancelable methods:
|
||||
NS_IMETHOD Cancel(void);
|
||||
NS_IMETHOD Suspend(void);
|
||||
NS_IMETHOD Resume(void);
|
||||
|
||||
// nsIProtocolConnection methods:
|
||||
NS_IMETHOD Open(nsIUrl* url, nsISupports* eventSink);
|
||||
NS_IMETHOD GetContentType(char* *contentType);
|
||||
NS_IMETHOD GetInputStream(nsIInputStream* *result);
|
||||
NS_IMETHOD GetOutputStream(nsIOutputStream* *result);
|
||||
|
||||
// nsIFtpProtocolConnection methods:
|
||||
NS_IMETHOD Get(void);
|
||||
NS_IMETHOD Put(void);
|
||||
NS_IMETHOD UsePASV(PRBool aComm);
|
||||
|
||||
// nsIStreamObserver methods:
|
||||
NS_IMETHOD OnStartBinding(nsISupports* context);
|
||||
NS_IMETHOD OnStopBinding(nsISupports* context,
|
||||
nsresult aStatus,
|
||||
nsIString* aMsg);
|
||||
|
||||
// nsIStreamListener methods:
|
||||
NS_IMETHOD OnDataAvailable(nsISupports* context,
|
||||
nsIInputStream *aIStream,
|
||||
PRUint32 aLength);
|
||||
|
||||
// nsFtpProtocolConnection methods:
|
||||
nsFtpProtocolConnection();
|
||||
virtual ~nsFtpProtocolConnection();
|
||||
|
||||
nsresult Init(nsIUrl* url, nsISupports* eventSink);
|
||||
|
||||
protected:
|
||||
nsIUrl* mUrl;
|
||||
nsIFtpEventSink* mEventSink;
|
||||
PRInt32 mServerType;
|
||||
PRBool mPasv;
|
||||
PRBool mConnected;
|
||||
FTP_STATE mState;
|
||||
};
|
||||
|
||||
#endif /* nsFtpProtocolConnection_h___ */
|
|
@ -0,0 +1,116 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsFtpProtocolHandler.h"
|
||||
#include "nsFtpProtocolConnection.h"
|
||||
#include "nsIUrl.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
static NS_DEFINE_CID(kTypicalUrlCID, NS_TYPICALURL_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsFtpProtocolHandler::nsFtpProtocolHandler()
|
||||
{
|
||||
}
|
||||
|
||||
nsFtpProtocolHandler::~nsFtpProtocolHandler()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsFtpProtocolHandler, nsIProtocolHandler::GetIID());
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIProtocolHandler methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolHandler::GetScheme(const char* *result)
|
||||
{
|
||||
*result = nsCRT::strdup("ftp");
|
||||
if (*result == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolHandler::GetDefaultPort(PRInt32 *result)
|
||||
{
|
||||
*result = 80;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolHandler::MakeAbsoluteUrl(const char* aSpec,
|
||||
nsIUrl* aBaseUrl,
|
||||
char* *result)
|
||||
{
|
||||
// XXX optimize this to not needlessly construct the URL
|
||||
|
||||
nsresult rv;
|
||||
nsIUrl* url;
|
||||
rv = NewUrl(aSpec, aBaseUrl, &url);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = url->ToNewCString(result);
|
||||
NS_RELEASE(url);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolHandler::NewUrl(const char* aSpec,
|
||||
nsIUrl* aBaseUrl,
|
||||
nsIUrl* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Ftp URLs (currently) have no additional structure beyond that provided by typical
|
||||
// URLs, so there is no "outer" given to CreateInstance
|
||||
|
||||
nsITypicalUrl* url;
|
||||
rv = nsComponentManager::CreateInstance(kTypicalUrlCID, nsnull,
|
||||
nsITypicalUrl::GetIID(),
|
||||
(void**)&url);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = url->Init(aSpec, aBaseUrl);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolHandler::NewConnection(nsIUrl* url,
|
||||
nsISupports* eventSink,
|
||||
nsIProtocolConnection* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsFtpProtocolConnection* connection = new nsFtpProtocolConnection();
|
||||
if (connection == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = connection->Init(url, eventSink);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete connection;
|
||||
return rv;
|
||||
}
|
||||
NS_ADDREF(connection);
|
||||
*result = connection;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,54 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsFtpProtocolHandler_h___
|
||||
#define nsFtpProtocolHandler_h___
|
||||
|
||||
#include "nsIProtocolHandler.h"
|
||||
|
||||
// {25029490-F132-11d2-9588-00805F369F95}
|
||||
#define NS_FTPPROTOCOLHANDLER_CID \
|
||||
{ 0x25029490, 0xf132, 0x11d2, { 0x95, 0x88, 0x0, 0x80, 0x5f, 0x36, 0x9f, 0x95 } }
|
||||
|
||||
class nsFtpProtocolHandler : public nsIProtocolHandler
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIProtocolHandler methods:
|
||||
NS_IMETHOD GetScheme(const char* *result);
|
||||
NS_IMETHOD GetDefaultPort(PRInt32 *result);
|
||||
NS_IMETHOD MakeAbsoluteUrl(const char* aSpec,
|
||||
nsIUrl* aBaseUrl,
|
||||
char* *result);
|
||||
NS_IMETHOD NewUrl(const char* aSpec,
|
||||
nsIUrl* aBaseUrl,
|
||||
nsIUrl* *result);
|
||||
NS_IMETHOD NewConnection(nsIUrl* url,
|
||||
nsISupports* eventSink,
|
||||
nsIProtocolConnection* *result);
|
||||
|
||||
// nsFtpProtocolHandler methods:
|
||||
nsFtpProtocolHandler();
|
||||
virtual ~nsFtpProtocolHandler();
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsFtpProtocolHandler_h___ */
|
|
@ -20,6 +20,7 @@ DEPTH = ..\..
|
|||
MODULE = netwerk
|
||||
|
||||
DIRS= \
|
||||
ftp \
|
||||
http \
|
||||
$(NULL)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче