netwerk/protocol/ftp/nsFtpControlConnection.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* vim:set et ts=4 sts=4 sw=4 cin: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef nsFtpControlConnection_h___
michael@0 8 #define nsFtpControlConnection_h___
michael@0 9
michael@0 10 #include "nsCOMPtr.h"
michael@0 11
michael@0 12 #include "nsISocketTransport.h"
michael@0 13 #include "nsIAsyncInputStream.h"
michael@0 14 #include "nsAutoPtr.h"
michael@0 15 #include "nsString.h"
michael@0 16 #include "mozilla/Attributes.h"
michael@0 17
michael@0 18 class nsIOutputStream;
michael@0 19 class nsIProxyInfo;
michael@0 20 class nsITransportEventSink;
michael@0 21
michael@0 22 class nsFtpControlConnectionListener : public nsISupports {
michael@0 23 public:
michael@0 24 /**
michael@0 25 * Called when a chunk of data arrives on the control connection.
michael@0 26 * @param data
michael@0 27 * The new data or null if an error occurred.
michael@0 28 * @param dataLen
michael@0 29 * The data length in bytes.
michael@0 30 */
michael@0 31 virtual void OnControlDataAvailable(const char *data, uint32_t dataLen) = 0;
michael@0 32
michael@0 33 /**
michael@0 34 * Called when an error occurs on the control connection.
michael@0 35 * @param status
michael@0 36 * A failure code providing more info about the error.
michael@0 37 */
michael@0 38 virtual void OnControlError(nsresult status) = 0;
michael@0 39 };
michael@0 40
michael@0 41 class nsFtpControlConnection MOZ_FINAL : public nsIInputStreamCallback
michael@0 42 {
michael@0 43 public:
michael@0 44 NS_DECL_ISUPPORTS
michael@0 45 NS_DECL_NSIINPUTSTREAMCALLBACK
michael@0 46
michael@0 47 nsFtpControlConnection(const nsCSubstring& host, uint32_t port);
michael@0 48 ~nsFtpControlConnection();
michael@0 49
michael@0 50 nsresult Connect(nsIProxyInfo* proxyInfo, nsITransportEventSink* eventSink);
michael@0 51 nsresult Disconnect(nsresult status);
michael@0 52 nsresult Write(const nsCSubstring& command);
michael@0 53
michael@0 54 bool IsAlive();
michael@0 55
michael@0 56 nsITransport *Transport() { return mSocket; }
michael@0 57
michael@0 58 /**
michael@0 59 * Call this function to be notified asynchronously when there is data
michael@0 60 * available for the socket. The listener passed to this method replaces
michael@0 61 * any existing listener, and the listener can be null to disconnect the
michael@0 62 * previous listener.
michael@0 63 */
michael@0 64 nsresult WaitData(nsFtpControlConnectionListener *listener);
michael@0 65
michael@0 66 uint32_t mServerType; // what kind of server is it.
michael@0 67 nsString mPassword;
michael@0 68 int32_t mSuspendedWrite;
michael@0 69 nsCString mPwd;
michael@0 70 uint32_t mSessionId;
michael@0 71 bool mUseUTF8;
michael@0 72
michael@0 73 private:
michael@0 74 nsCString mHost;
michael@0 75 uint32_t mPort;
michael@0 76
michael@0 77 nsCOMPtr<nsISocketTransport> mSocket;
michael@0 78 nsCOMPtr<nsIOutputStream> mSocketOutput;
michael@0 79 nsCOMPtr<nsIAsyncInputStream> mSocketInput;
michael@0 80
michael@0 81 nsRefPtr<nsFtpControlConnectionListener> mListener;
michael@0 82 };
michael@0 83
michael@0 84 #endif

mercurial