1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* vim:set ts=4 sw=4 sts=4 et cindent: */
3 : /* ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is mozilla.org code.
17 : *
18 : * The Initial Developer of the Original Code is
19 : * Netscape Communications Corporation.
20 : * Portions created by the Initial Developer are Copyright (C) 1998
21 : * the Initial Developer. All Rights Reserved.
22 : *
23 : * Contributor(s):
24 : * Doug Turner <dougt@meer.net> (original author)
25 : * Darin Fisher <darin@meer.net>
26 : *
27 : * Alternatively, the contents of this file may be used under the terms of
28 : * either the GNU General Public License Version 2 or later (the "GPL"), or
29 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 : * in which case the provisions of the GPL or the LGPL are applicable instead
31 : * of those above. If you wish to allow use of your version of this file only
32 : * under the terms of either the GPL or the LGPL, and not to allow others to
33 : * use your version of this file under the terms of the MPL, indicate your
34 : * decision by deleting the provisions above and replace them with the notice
35 : * and other provisions required by the GPL or the LGPL. If you do not delete
36 : * the provisions above, a recipient may use your version of this file under
37 : * the terms of any one of the MPL, the GPL or the LGPL.
38 : *
39 : * ***** END LICENSE BLOCK ***** */
40 :
41 : #ifndef nsFTPChannel_h___
42 : #define nsFTPChannel_h___
43 :
44 : #include "nsBaseChannel.h"
45 :
46 : #include "nsIIOService.h"
47 : #include "nsIURI.h"
48 : #include "nsString.h"
49 : #include "nsILoadGroup.h"
50 : #include "nsCOMPtr.h"
51 : #include "nsIProtocolHandler.h"
52 : #include "nsIProgressEventSink.h"
53 : #include "nsIInterfaceRequestor.h"
54 : #include "nsIInterfaceRequestorUtils.h"
55 : #include "nsFtpConnectionThread.h"
56 : #include "netCore.h"
57 : #include "nsIStreamListener.h"
58 : #include "nsIFTPChannel.h"
59 : #include "nsIUploadChannel.h"
60 : #include "nsIProxyInfo.h"
61 : #include "nsIProxiedChannel.h"
62 : #include "nsIResumableChannel.h"
63 : #include "nsHashPropertyBag.h"
64 : #include "nsFtpProtocolHandler.h"
65 :
66 : class nsFtpChannel : public nsBaseChannel,
67 : public nsIFTPChannel,
68 : public nsIUploadChannel,
69 : public nsIResumableChannel,
70 : public nsIProxiedChannel
71 : {
72 : public:
73 : NS_DECL_ISUPPORTS_INHERITED
74 : NS_DECL_NSIUPLOADCHANNEL
75 : NS_DECL_NSIRESUMABLECHANNEL
76 : NS_DECL_NSIPROXIEDCHANNEL
77 :
78 19 : nsFtpChannel(nsIURI *uri, nsIProxyInfo *pi)
79 : : mProxyInfo(pi)
80 : , mStartPos(0)
81 : , mResumeRequested(false)
82 19 : , mLastModifiedTime(0)
83 : {
84 19 : SetURI(uri);
85 19 : }
86 :
87 0 : nsIProxyInfo *ProxyInfo() {
88 0 : return mProxyInfo;
89 : }
90 :
91 : // Were we asked to resume a download?
92 17 : bool ResumeRequested() { return mResumeRequested; }
93 :
94 : // Download from this byte offset
95 19 : PRUint64 StartPos() { return mStartPos; }
96 :
97 : // ID of the entity to resume downloading
98 17 : const nsCString &EntityID() {
99 17 : return mEntityID;
100 : }
101 17 : void SetEntityID(const nsCSubstring &entityID) {
102 17 : mEntityID = entityID;
103 17 : }
104 :
105 0 : NS_IMETHODIMP GetLastModifiedTime(PRTime* lastModifiedTime) {
106 0 : *lastModifiedTime = mLastModifiedTime;
107 0 : return NS_OK;
108 : }
109 :
110 0 : NS_IMETHODIMP SetLastModifiedTime(PRTime lastModifiedTime) {
111 0 : mLastModifiedTime = lastModifiedTime;
112 0 : return NS_OK;
113 : }
114 :
115 : // Data stream to upload
116 34 : nsIInputStream *UploadStream() {
117 34 : return mUploadStream;
118 : }
119 :
120 : // Helper function for getting the nsIFTPEventSink.
121 : void GetFTPEventSink(nsCOMPtr<nsIFTPEventSink> &aResult);
122 :
123 : protected:
124 76 : virtual ~nsFtpChannel() {}
125 : virtual nsresult OpenContentStream(bool async, nsIInputStream **result,
126 : nsIChannel** channel);
127 : virtual bool GetStatusArg(nsresult status, nsString &statusArg);
128 : virtual void OnCallbacksChanged();
129 :
130 : private:
131 : nsCOMPtr<nsIProxyInfo> mProxyInfo;
132 : nsCOMPtr<nsIFTPEventSink> mFTPEventSink;
133 : nsCOMPtr<nsIInputStream> mUploadStream;
134 : PRUint64 mStartPos;
135 : nsCString mEntityID;
136 : bool mResumeRequested;
137 : PRTime mLastModifiedTime;
138 : };
139 :
140 : #endif /* nsFTPChannel_h___ */
|