michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim:set ts=4 sw=4 sts=4 et cindent: */ 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 nsFTPChannel_h___ michael@0: #define nsFTPChannel_h___ michael@0: michael@0: #include "nsBaseChannel.h" michael@0: michael@0: #include "nsString.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIFTPChannel.h" michael@0: #include "nsIUploadChannel.h" michael@0: #include "nsIProxyInfo.h" michael@0: #include "nsIProxiedChannel.h" michael@0: #include "nsIResumableChannel.h" michael@0: michael@0: class nsIURI; michael@0: michael@0: class nsFtpChannel : public nsBaseChannel, michael@0: public nsIFTPChannel, michael@0: public nsIUploadChannel, michael@0: public nsIResumableChannel, michael@0: public nsIProxiedChannel michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_NSIUPLOADCHANNEL michael@0: NS_DECL_NSIRESUMABLECHANNEL michael@0: NS_DECL_NSIPROXIEDCHANNEL michael@0: michael@0: nsFtpChannel(nsIURI *uri, nsIProxyInfo *pi) michael@0: : mProxyInfo(pi) michael@0: , mStartPos(0) michael@0: , mResumeRequested(false) michael@0: , mLastModifiedTime(0) michael@0: , mForcePending(false) michael@0: { michael@0: SetURI(uri); michael@0: } michael@0: michael@0: nsIProxyInfo *ProxyInfo() { michael@0: return mProxyInfo; michael@0: } michael@0: michael@0: void SetProxyInfo(nsIProxyInfo *pi) michael@0: { michael@0: mProxyInfo = pi; michael@0: } michael@0: michael@0: NS_IMETHOD IsPending(bool *result) MOZ_OVERRIDE; michael@0: michael@0: // This is a short-cut to calling nsIRequest::IsPending(). michael@0: // Overrides Pending in nsBaseChannel. michael@0: bool Pending() const MOZ_OVERRIDE; michael@0: michael@0: // Were we asked to resume a download? michael@0: bool ResumeRequested() { return mResumeRequested; } michael@0: michael@0: // Download from this byte offset michael@0: uint64_t StartPos() { return mStartPos; } michael@0: michael@0: // ID of the entity to resume downloading michael@0: const nsCString &EntityID() { michael@0: return mEntityID; michael@0: } michael@0: void SetEntityID(const nsCSubstring &entityID) { michael@0: mEntityID = entityID; michael@0: } michael@0: michael@0: NS_IMETHODIMP GetLastModifiedTime(PRTime* lastModifiedTime) { michael@0: *lastModifiedTime = mLastModifiedTime; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP SetLastModifiedTime(PRTime lastModifiedTime) { michael@0: mLastModifiedTime = lastModifiedTime; michael@0: return NS_OK; michael@0: } michael@0: michael@0: // Data stream to upload michael@0: nsIInputStream *UploadStream() { michael@0: return mUploadStream; michael@0: } michael@0: michael@0: // Helper function for getting the nsIFTPEventSink. michael@0: void GetFTPEventSink(nsCOMPtr &aResult); michael@0: michael@0: public: /* Internal Necko use only. */ michael@0: void ForcePending(bool aForcePending); michael@0: michael@0: protected: michael@0: virtual ~nsFtpChannel() {} michael@0: virtual nsresult OpenContentStream(bool async, nsIInputStream **result, michael@0: nsIChannel** channel); michael@0: virtual bool GetStatusArg(nsresult status, nsString &statusArg); michael@0: virtual void OnCallbacksChanged(); michael@0: michael@0: private: michael@0: nsCOMPtr mProxyInfo; michael@0: nsCOMPtr mFTPEventSink; michael@0: nsCOMPtr mUploadStream; michael@0: uint64_t mStartPos; michael@0: nsCString mEntityID; michael@0: bool mResumeRequested; michael@0: PRTime mLastModifiedTime; michael@0: bool mForcePending; michael@0: }; michael@0: michael@0: #endif /* nsFTPChannel_h___ */