netwerk/protocol/ftp/nsFtpControlConnection.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/ftp/nsFtpControlConnection.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,84 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim:set et ts=4 sts=4 sw=4 cin: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef nsFtpControlConnection_h___
    1.11 +#define nsFtpControlConnection_h___
    1.12 +
    1.13 +#include "nsCOMPtr.h"
    1.14 +
    1.15 +#include "nsISocketTransport.h"
    1.16 +#include "nsIAsyncInputStream.h"
    1.17 +#include "nsAutoPtr.h"
    1.18 +#include "nsString.h"
    1.19 +#include "mozilla/Attributes.h"
    1.20 +
    1.21 +class nsIOutputStream;
    1.22 +class nsIProxyInfo;
    1.23 +class nsITransportEventSink;
    1.24 +
    1.25 +class nsFtpControlConnectionListener : public nsISupports {
    1.26 +public:
    1.27 +    /**
    1.28 +     * Called when a chunk of data arrives on the control connection.
    1.29 +     * @param data
    1.30 +     *        The new data or null if an error occurred.
    1.31 +     * @param dataLen
    1.32 +     *        The data length in bytes.
    1.33 +     */
    1.34 +    virtual void OnControlDataAvailable(const char *data, uint32_t dataLen) = 0;
    1.35 +
    1.36 +    /**
    1.37 +     * Called when an error occurs on the control connection.
    1.38 +     * @param status
    1.39 +     *        A failure code providing more info about the error.
    1.40 +     */
    1.41 +    virtual void OnControlError(nsresult status) = 0;
    1.42 +};
    1.43 +
    1.44 +class nsFtpControlConnection MOZ_FINAL : public nsIInputStreamCallback
    1.45 +{
    1.46 +public:
    1.47 +    NS_DECL_ISUPPORTS
    1.48 +    NS_DECL_NSIINPUTSTREAMCALLBACK
    1.49 +
    1.50 +    nsFtpControlConnection(const nsCSubstring& host, uint32_t port);
    1.51 +    ~nsFtpControlConnection();
    1.52 +
    1.53 +    nsresult Connect(nsIProxyInfo* proxyInfo, nsITransportEventSink* eventSink);
    1.54 +    nsresult Disconnect(nsresult status);
    1.55 +    nsresult Write(const nsCSubstring& command);
    1.56 +
    1.57 +    bool IsAlive();
    1.58 +
    1.59 +    nsITransport *Transport()   { return mSocket; }
    1.60 +
    1.61 +    /**
    1.62 +     * Call this function to be notified asynchronously when there is data
    1.63 +     * available for the socket.  The listener passed to this method replaces
    1.64 +     * any existing listener, and the listener can be null to disconnect the
    1.65 +     * previous listener.
    1.66 +     */
    1.67 +    nsresult WaitData(nsFtpControlConnectionListener *listener);
    1.68 +
    1.69 +    uint32_t         mServerType;           // what kind of server is it.
    1.70 +    nsString         mPassword;
    1.71 +    int32_t          mSuspendedWrite;
    1.72 +    nsCString        mPwd;
    1.73 +    uint32_t         mSessionId;
    1.74 +    bool             mUseUTF8;
    1.75 +
    1.76 +private:
    1.77 +    nsCString mHost;
    1.78 +    uint32_t  mPort;
    1.79 +
    1.80 +    nsCOMPtr<nsISocketTransport>     mSocket;
    1.81 +    nsCOMPtr<nsIOutputStream>        mSocketOutput;
    1.82 +    nsCOMPtr<nsIAsyncInputStream>    mSocketInput;
    1.83 +
    1.84 +    nsRefPtr<nsFtpControlConnectionListener> mListener;
    1.85 +};
    1.86 +
    1.87 +#endif

mercurial