2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2004-08-08 20:17:54 +00:00
|
|
|
/* vim:set et ts=4 sts=4 sw=4 cin: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-01-10 23:45:04 +00:00
|
|
|
|
|
|
|
#ifndef nsFtpControlConnection_h___
|
|
|
|
#define nsFtpControlConnection_h___
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
#include "nsISocketTransport.h"
|
2006-03-03 16:27:35 +00:00
|
|
|
#include "nsIAsyncInputStream.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2003-01-18 02:15:14 +00:00
|
|
|
#include "nsString.h"
|
2012-06-06 03:18:25 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2001-01-10 23:45:04 +00:00
|
|
|
|
2013-09-23 03:35:52 +00:00
|
|
|
class nsIOutputStream;
|
2001-09-13 02:21:05 +00:00
|
|
|
class nsIProxyInfo;
|
2004-08-08 20:17:54 +00:00
|
|
|
class nsITransportEventSink;
|
2001-09-13 02:21:05 +00:00
|
|
|
|
2006-03-03 16:27:35 +00:00
|
|
|
class nsFtpControlConnectionListener : public nsISupports {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Called when a chunk of data arrives on the control connection.
|
|
|
|
* @param data
|
2010-05-13 12:19:50 +00:00
|
|
|
* The new data or null if an error occurred.
|
2006-03-03 16:27:35 +00:00
|
|
|
* @param dataLen
|
|
|
|
* The data length in bytes.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual void OnControlDataAvailable(const char *data, uint32_t dataLen) = 0;
|
2006-03-03 16:27:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when an error occurs on the control connection.
|
|
|
|
* @param status
|
|
|
|
* A failure code providing more info about the error.
|
|
|
|
*/
|
|
|
|
virtual void OnControlError(nsresult status) = 0;
|
|
|
|
};
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class nsFtpControlConnection final : public nsIInputStreamCallback
|
2001-01-10 23:45:04 +00:00
|
|
|
{
|
2014-06-24 16:36:44 +00:00
|
|
|
~nsFtpControlConnection();
|
|
|
|
|
2001-01-10 23:45:04 +00:00
|
|
|
public:
|
2004-08-08 20:17:54 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
2006-03-03 16:27:35 +00:00
|
|
|
NS_DECL_NSIINPUTSTREAMCALLBACK
|
2001-01-10 23:45:04 +00:00
|
|
|
|
2017-06-20 09:19:52 +00:00
|
|
|
nsFtpControlConnection(const nsACString& host, uint32_t port);
|
2004-08-08 20:17:54 +00:00
|
|
|
|
|
|
|
nsresult Connect(nsIProxyInfo* proxyInfo, nsITransportEventSink* eventSink);
|
2001-08-14 05:07:49 +00:00
|
|
|
nsresult Disconnect(nsresult status);
|
2017-06-20 09:19:52 +00:00
|
|
|
nsresult Write(const nsACString& command);
|
2001-03-21 19:04:32 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsAlive();
|
2004-11-15 20:16:52 +00:00
|
|
|
|
2006-03-03 16:27:35 +00:00
|
|
|
nsITransport *Transport() { return mSocket; }
|
2004-11-15 20:16:52 +00:00
|
|
|
|
2006-03-03 16:27:35 +00:00
|
|
|
/**
|
|
|
|
* Call this function to be notified asynchronously when there is data
|
|
|
|
* available for the socket. The listener passed to this method replaces
|
|
|
|
* any existing listener, and the listener can be null to disconnect the
|
|
|
|
* previous listener.
|
|
|
|
*/
|
|
|
|
nsresult WaitData(nsFtpControlConnectionListener *listener);
|
2001-01-10 23:45:04 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mServerType; // what kind of server is it.
|
2001-08-14 05:07:49 +00:00
|
|
|
nsString mPassword;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mSuspendedWrite;
|
2001-10-28 08:58:18 +00:00
|
|
|
nsCString mPwd;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mSessionId;
|
2014-04-22 16:12:58 +00:00
|
|
|
bool mUseUTF8;
|
2001-01-10 23:45:04 +00:00
|
|
|
|
|
|
|
private:
|
2004-11-15 20:16:52 +00:00
|
|
|
nsCString mHost;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mPort;
|
2003-01-18 02:15:14 +00:00
|
|
|
|
2006-03-03 16:27:35 +00:00
|
|
|
nsCOMPtr<nsISocketTransport> mSocket;
|
|
|
|
nsCOMPtr<nsIOutputStream> mSocketOutput;
|
|
|
|
nsCOMPtr<nsIAsyncInputStream> mSocketInput;
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsFtpControlConnectionListener> mListener;
|
2001-01-10 23:45:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|