michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim:set et ts=4 sts=4 sw=4 cin: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsFtpControlConnection_h___ michael@0: #define nsFtpControlConnection_h___ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: michael@0: #include "nsISocketTransport.h" michael@0: #include "nsIAsyncInputStream.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsString.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: class nsIOutputStream; michael@0: class nsIProxyInfo; michael@0: class nsITransportEventSink; michael@0: michael@0: class nsFtpControlConnectionListener : public nsISupports { michael@0: public: michael@0: /** michael@0: * Called when a chunk of data arrives on the control connection. michael@0: * @param data michael@0: * The new data or null if an error occurred. michael@0: * @param dataLen michael@0: * The data length in bytes. michael@0: */ michael@0: virtual void OnControlDataAvailable(const char *data, uint32_t dataLen) = 0; michael@0: michael@0: /** michael@0: * Called when an error occurs on the control connection. michael@0: * @param status michael@0: * A failure code providing more info about the error. michael@0: */ michael@0: virtual void OnControlError(nsresult status) = 0; michael@0: }; michael@0: michael@0: class nsFtpControlConnection MOZ_FINAL : public nsIInputStreamCallback michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIINPUTSTREAMCALLBACK michael@0: michael@0: nsFtpControlConnection(const nsCSubstring& host, uint32_t port); michael@0: ~nsFtpControlConnection(); michael@0: michael@0: nsresult Connect(nsIProxyInfo* proxyInfo, nsITransportEventSink* eventSink); michael@0: nsresult Disconnect(nsresult status); michael@0: nsresult Write(const nsCSubstring& command); michael@0: michael@0: bool IsAlive(); michael@0: michael@0: nsITransport *Transport() { return mSocket; } michael@0: michael@0: /** michael@0: * Call this function to be notified asynchronously when there is data michael@0: * available for the socket. The listener passed to this method replaces michael@0: * any existing listener, and the listener can be null to disconnect the michael@0: * previous listener. michael@0: */ michael@0: nsresult WaitData(nsFtpControlConnectionListener *listener); michael@0: michael@0: uint32_t mServerType; // what kind of server is it. michael@0: nsString mPassword; michael@0: int32_t mSuspendedWrite; michael@0: nsCString mPwd; michael@0: uint32_t mSessionId; michael@0: bool mUseUTF8; michael@0: michael@0: private: michael@0: nsCString mHost; michael@0: uint32_t mPort; michael@0: michael@0: nsCOMPtr mSocket; michael@0: nsCOMPtr mSocketOutput; michael@0: nsCOMPtr mSocketInput; michael@0: michael@0: nsRefPtr mListener; michael@0: }; michael@0: michael@0: #endif