williamr@2
|
1 |
/**
|
williamr@2
|
2 |
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@2
|
5 |
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description:
|
williamr@2
|
15 |
* FTP Protocol header file
|
williamr@2
|
16 |
* Author: Philippe Gabriel
|
williamr@2
|
17 |
*
|
williamr@2
|
18 |
*
|
williamr@2
|
19 |
*/
|
williamr@2
|
20 |
|
williamr@2
|
21 |
|
williamr@2
|
22 |
|
williamr@2
|
23 |
|
williamr@2
|
24 |
|
williamr@2
|
25 |
/**
|
williamr@2
|
26 |
@file ftprot.h
|
williamr@2
|
27 |
@internalComponent
|
williamr@2
|
28 |
*/
|
williamr@2
|
29 |
|
williamr@2
|
30 |
#if !defined(__FTPPROT_H__)
|
williamr@2
|
31 |
#define __FTPPROT_H__
|
williamr@2
|
32 |
|
williamr@2
|
33 |
#include <e32base.h>
|
williamr@2
|
34 |
#include <es_sock.h>
|
williamr@2
|
35 |
|
williamr@2
|
36 |
/** FTPPROT.DLL major version number.
|
williamr@2
|
37 |
@internalComponent */
|
williamr@2
|
38 |
#define FTPPROTDLL_VERSION_MAJOR 0x01 // The very first release
|
williamr@2
|
39 |
/** FTPPROT.DLL minor version number. */
|
williamr@2
|
40 |
#define FTPPROTDLL_VERSION_MINOR 0x03
|
williamr@2
|
41 |
/** FTPPROT.DLL version number. */
|
williamr@2
|
42 |
#define FTPPROTDLL_VERSION_NUMBER (FTPPROTDLL_VERSION_MAJOR<<8)|FTPPROTDLL_VERSION_MINOR
|
williamr@2
|
43 |
|
williamr@2
|
44 |
class MFtpProtocolNotifier
|
williamr@2
|
45 |
/** FTP engine callback interface.
|
williamr@2
|
46 |
*
|
williamr@2
|
47 |
* An FTP engine client implements this interface to receive status and results
|
williamr@2
|
48 |
* from asynchronous FTP commands.
|
williamr@2
|
49 |
* @internalComponent */
|
williamr@2
|
50 |
{
|
williamr@2
|
51 |
// Operation completion return codes.
|
williamr@2
|
52 |
|
williamr@2
|
53 |
public:
|
williamr@2
|
54 |
/** FTP engine/session operation completeness codes. */
|
williamr@2
|
55 |
enum TOpComp
|
williamr@2
|
56 |
{
|
williamr@2
|
57 |
/** Operation completed normally. */
|
williamr@2
|
58 |
EOpComplete=0,
|
williamr@2
|
59 |
/** Operation cancelled. */
|
williamr@2
|
60 |
EOpCanceled, // User canceled last operation
|
williamr@2
|
61 |
/** Operation failed. */
|
williamr@2
|
62 |
EOpFailed,
|
williamr@2
|
63 |
/** Sockets level error. */
|
williamr@2
|
64 |
ESocketError,
|
williamr@2
|
65 |
|
williamr@2
|
66 |
// Connection errors
|
williamr@2
|
67 |
/** Connection error: Connection reset. */
|
williamr@2
|
68 |
EOpConnectionReset,
|
williamr@2
|
69 |
/** Connection error: Connection failed. */
|
williamr@2
|
70 |
EOpConnectionFailed,
|
williamr@2
|
71 |
/** Connection error: Server not found. */
|
williamr@2
|
72 |
EHostNotFound,
|
williamr@2
|
73 |
|
williamr@2
|
74 |
// Transfer error
|
williamr@2
|
75 |
/** Transfer error: Transfer was reset. */
|
williamr@2
|
76 |
EXferReset,
|
williamr@2
|
77 |
/** Transfer error: Transfer is not initialised. */
|
williamr@2
|
78 |
EXferNotInitialised,
|
williamr@2
|
79 |
|
williamr@2
|
80 |
//Transfer notification
|
williamr@2
|
81 |
/** Transfer notification: Data packet was received. */
|
williamr@2
|
82 |
EPacketReceived,
|
williamr@2
|
83 |
/** Transfer notification: Data packet was sent. */
|
williamr@2
|
84 |
EPacketSent
|
williamr@2
|
85 |
};
|
williamr@2
|
86 |
public:
|
williamr@2
|
87 |
/** Destructor. */
|
williamr@2
|
88 |
virtual ~MFtpProtocolNotifier(){};
|
williamr@2
|
89 |
|
williamr@2
|
90 |
/** Positive reply received from server.
|
williamr@2
|
91 |
*
|
williamr@2
|
92 |
* @param aStatus Operation completion code */
|
williamr@2
|
93 |
virtual void ServerPositiveAnswerNotification(const TOpComp aStatus)=0;
|
williamr@2
|
94 |
|
williamr@2
|
95 |
|
williamr@2
|
96 |
/** Message sent by the FTP server.
|
williamr@2
|
97 |
*
|
williamr@2
|
98 |
* This returns the full server reply in plain text format.
|
williamr@2
|
99 |
*
|
williamr@2
|
100 |
* @param aMessage The message sent by the server */
|
williamr@2
|
101 |
virtual void ServerMessage(const TDesC8& aMessage)=0;
|
williamr@2
|
102 |
|
williamr@2
|
103 |
/** Data transfer notification received from the server.
|
williamr@2
|
104 |
*
|
williamr@2
|
105 |
* @param aStatus Operation completion code */
|
williamr@2
|
106 |
virtual void ServerXFerNotification(const TOpComp aStatus)=0;
|
williamr@2
|
107 |
|
williamr@2
|
108 |
/** Negative reply received from server.
|
williamr@2
|
109 |
*
|
williamr@2
|
110 |
* @param aStatus Operation completion code */
|
williamr@2
|
111 |
virtual void ServerNegativeAnswerNotification(const TOpComp aStatus)=0;
|
williamr@2
|
112 |
|
williamr@2
|
113 |
/** Error condition notification.
|
williamr@2
|
114 |
*
|
williamr@2
|
115 |
* @param aStatus Operation completion code */
|
williamr@2
|
116 |
virtual void ErrorNotification(const TOpComp aStatus)=0;
|
williamr@2
|
117 |
};
|
williamr@2
|
118 |
|
williamr@2
|
119 |
|
williamr@2
|
120 |
class CFtpProtocol : public CBase
|
williamr@2
|
121 |
/** Implements an FTP engine, and allows the client to access the individual FTP
|
williamr@2
|
122 |
* commands as defined in RFC959.
|
williamr@2
|
123 |
*
|
williamr@2
|
124 |
* Note that before commands that cause data to transit on the DTP channel (e.g. NLST,
|
williamr@2
|
125 |
* LIST, RETR, STOR) a data buffer must be provided using SendBuffer()/RecvBuffer().
|
williamr@2
|
126 |
* Also, when the client is notified of a MoreData() event, it must re-issue RecvBuffer()
|
williamr@2
|
127 |
* to get the rest of the data.
|
williamr@2
|
128 |
* @internalComponent
|
williamr@2
|
129 |
*/
|
williamr@2
|
130 |
{
|
williamr@2
|
131 |
public:
|
williamr@2
|
132 |
|
williamr@2
|
133 |
// Establish a connection:
|
williamr@2
|
134 |
/** Connect to an FTP server, specifying an IP address.
|
williamr@2
|
135 |
*
|
williamr@2
|
136 |
* @param aNetAddr FTP server's IP address */
|
williamr@2
|
137 |
virtual void Connect(TSockAddr& aNetAddr)=0; // IP address
|
williamr@2
|
138 |
|
williamr@2
|
139 |
/** Connect to an FTP server, specifying a DNS name.
|
williamr@2
|
140 |
*
|
williamr@2
|
141 |
* @param aServerName FTP server's DNS name */
|
williamr@2
|
142 |
virtual void Connect(const THostName& aServerName)=0; // URL name
|
williamr@2
|
143 |
|
williamr@2
|
144 |
/** Connect to an FTP server, specifying a DNS name and port number.
|
williamr@2
|
145 |
*
|
williamr@2
|
146 |
* @param aServerName FTP server's DNS name
|
williamr@2
|
147 |
* @param aPort FTP server's port */
|
williamr@2
|
148 |
virtual void Connect(const THostName& aServerName, const TUint aPort)=0; // URL name + port
|
williamr@2
|
149 |
|
williamr@2
|
150 |
// FTP commands, presented in the same order as RFC959:
|
williamr@2
|
151 |
/** Issues the USER command.
|
williamr@2
|
152 |
*
|
williamr@2
|
153 |
* @param aParam Telnet string identifying the user */
|
williamr@2
|
154 |
virtual void User(const TDesC8& aParam)=0;
|
williamr@2
|
155 |
|
williamr@2
|
156 |
/** Issues the PASS command.
|
williamr@2
|
157 |
*
|
williamr@2
|
158 |
* @param aParam Telnet string specifying the user's password */
|
williamr@2
|
159 |
virtual void Pass(const TDesC8& aParam)=0;
|
williamr@2
|
160 |
|
williamr@2
|
161 |
/** Issues the ACCT command.
|
williamr@2
|
162 |
*
|
williamr@2
|
163 |
* @param aParam Telnet string identifying the user's account */
|
williamr@2
|
164 |
virtual void Acct(const TDesC8& aParam)=0;
|
williamr@2
|
165 |
|
williamr@2
|
166 |
/** Issues the CWD command.
|
williamr@2
|
167 |
*
|
williamr@2
|
168 |
* @param aParam Directory or other system dependent file group designator */
|
williamr@2
|
169 |
virtual void Cwd(const TDesC8& aParam)=0;
|
williamr@2
|
170 |
|
williamr@2
|
171 |
/** Issues the CDUP command. */
|
williamr@2
|
172 |
virtual void Cdup(void)=0;
|
williamr@2
|
173 |
|
williamr@2
|
174 |
/** Issues the SMNT command.
|
williamr@2
|
175 |
*
|
williamr@2
|
176 |
* @param aParam Pathname specifying a directory or other system dependent file
|
williamr@2
|
177 |
* group designator */
|
williamr@2
|
178 |
virtual void Smnt(const TDesC8& aParam)=0;
|
williamr@2
|
179 |
|
williamr@2
|
180 |
/** Issues the QUIT command. */
|
williamr@2
|
181 |
virtual void Quit(void)=0;
|
williamr@2
|
182 |
|
williamr@2
|
183 |
/** Issues the REIN command. */
|
williamr@2
|
184 |
virtual void Rein(void)=0;
|
williamr@2
|
185 |
|
williamr@2
|
186 |
/** Issues the PORT command, setting the Data Transfer Process port to a value
|
williamr@2
|
187 |
* allocated by the Sockets Server. */
|
williamr@2
|
188 |
virtual void Port(void)=0; // Sets the DTP port to one allocated by ESOCK
|
williamr@2
|
189 |
|
williamr@2
|
190 |
/** Issues the PORT command, specifying a port number.
|
williamr@2
|
191 |
*
|
williamr@2
|
192 |
* @param aPort Port number */
|
williamr@2
|
193 |
virtual void Port(TUint aPort)=0; // Sets the DTP port to a specific one
|
williamr@2
|
194 |
|
williamr@2
|
195 |
/** Issues the PASV command. */
|
williamr@2
|
196 |
virtual void Pasv(void)=0;
|
williamr@2
|
197 |
|
williamr@2
|
198 |
/** Issues the TYPE command (single parameter).
|
williamr@2
|
199 |
*
|
williamr@2
|
200 |
* @param aParam First representation type parameter */
|
williamr@2
|
201 |
virtual void Type(const TDesC8& aParam)=0;
|
williamr@2
|
202 |
|
williamr@2
|
203 |
/** Issues the TYPE command (two parameters).
|
williamr@2
|
204 |
*
|
williamr@2
|
205 |
* @param aParam1 First representation type parameter
|
williamr@2
|
206 |
* @param aParam2 Second representation type parameter */
|
williamr@2
|
207 |
virtual void Type(const TDesC8& aParam1, const TDesC8& aParam2)=0;
|
williamr@2
|
208 |
|
williamr@2
|
209 |
/** Issues the STRU command.
|
williamr@2
|
210 |
*
|
williamr@2
|
211 |
* @param aParam Telnet character code specifying the file structure */
|
williamr@2
|
212 |
virtual void Stru(const TDesC8& aParam)=0;
|
williamr@2
|
213 |
|
williamr@2
|
214 |
/** Issues the MODE command.
|
williamr@2
|
215 |
*
|
williamr@2
|
216 |
* @param aParam Telnet character code specifying the data transfer mode */
|
williamr@2
|
217 |
virtual void Mode(const TDesC8& aParam)=0;
|
williamr@2
|
218 |
|
williamr@2
|
219 |
/** Issues the RETR command.
|
williamr@2
|
220 |
*
|
williamr@2
|
221 |
* @param aFileName File name */
|
williamr@2
|
222 |
virtual void Retr(const TDesC8& aFileName)=0;
|
williamr@2
|
223 |
|
williamr@2
|
224 |
/** Issues the STOR command.
|
williamr@2
|
225 |
*
|
williamr@2
|
226 |
* @param aFileName File name */
|
williamr@2
|
227 |
virtual void Stor(const TDesC8& aFileName)=0;
|
williamr@2
|
228 |
|
williamr@2
|
229 |
/** Issues the STOU command. */
|
williamr@2
|
230 |
virtual void Stou(void)=0;
|
williamr@2
|
231 |
|
williamr@2
|
232 |
/** Issues the APPE command.
|
williamr@2
|
233 |
*
|
williamr@2
|
234 |
* @param aFileName File name */
|
williamr@2
|
235 |
virtual void Appe(const TDesC8& aFileName)=0;
|
williamr@2
|
236 |
|
williamr@2
|
237 |
/** Issues the ALLO command (single parameter).
|
williamr@2
|
238 |
*
|
williamr@2
|
239 |
* @param aParam Number of bytes (using the logical byte size) of storage to
|
williamr@2
|
240 |
* be reserved for the file */
|
williamr@2
|
241 |
virtual void Allo(const TDesC8& aParam)=0;
|
williamr@2
|
242 |
|
williamr@2
|
243 |
/** Issues the ALLO command (two parameters).
|
williamr@2
|
244 |
*
|
williamr@2
|
245 |
* @param aParam1 Number of bytes (using the logical byte size) of storage to
|
williamr@2
|
246 |
* be reserved for the file
|
williamr@2
|
247 |
* @param aParam2 Maximum record or page size (in logical bytes) */
|
williamr@2
|
248 |
virtual void Allo(const TDesC8& aParam1, const TDesC8& aParam2)=0;
|
williamr@2
|
249 |
|
williamr@2
|
250 |
/** Issues the REST command.
|
williamr@2
|
251 |
*
|
williamr@2
|
252 |
* @param aParam The server marker at which file transfer is to be restarted */
|
williamr@2
|
253 |
virtual void Rest(const TDesC8& aParam)=0;
|
williamr@2
|
254 |
|
williamr@2
|
255 |
/** Issues the RNFR command.
|
williamr@2
|
256 |
*
|
williamr@2
|
257 |
* @param aFileName File name */
|
williamr@2
|
258 |
virtual void Rnfr(const TDesC8& aFileName)=0;
|
williamr@2
|
259 |
|
williamr@2
|
260 |
/** Issues the RNTO command.
|
williamr@2
|
261 |
*
|
williamr@2
|
262 |
* @param aFileName File name */
|
williamr@2
|
263 |
virtual void Rnto(const TDesC8& aFileName)=0;
|
williamr@2
|
264 |
|
williamr@2
|
265 |
/** Issues the ABOR command. */
|
williamr@2
|
266 |
virtual void Abor(void)=0;
|
williamr@2
|
267 |
|
williamr@2
|
268 |
/** Issues the DELE command.
|
williamr@2
|
269 |
*
|
williamr@2
|
270 |
* @param aFileName File name */
|
williamr@2
|
271 |
virtual void Dele(const TDesC8& aFileName)=0;
|
williamr@2
|
272 |
|
williamr@2
|
273 |
/** Issues the RMD command.
|
williamr@2
|
274 |
*
|
williamr@2
|
275 |
* @param aParam Directory name */
|
williamr@2
|
276 |
virtual void Rmd(const TDesC8& aParam)=0;
|
williamr@2
|
277 |
|
williamr@2
|
278 |
/** Issues the MKD command.
|
williamr@2
|
279 |
*
|
williamr@2
|
280 |
* @param aParam Directory name */
|
williamr@2
|
281 |
virtual void Mkd(const TDesC8& aParam)=0;
|
williamr@2
|
282 |
|
williamr@2
|
283 |
/** Issues the PWD command. */
|
williamr@2
|
284 |
virtual void Pwd(void)=0;
|
williamr@2
|
285 |
|
williamr@2
|
286 |
/** Issues the LIST command, giving a null argument. */
|
williamr@2
|
287 |
virtual void List(void)=0;
|
williamr@2
|
288 |
|
williamr@2
|
289 |
/** Issues the LIST command, specifying a file/directory name.
|
williamr@2
|
290 |
*
|
williamr@2
|
291 |
* @param aParam File/directory name */
|
williamr@2
|
292 |
virtual void List(const TDesC8& aParam)=0;
|
williamr@2
|
293 |
|
williamr@2
|
294 |
/** Issues the NLST command, giving a null argument. */
|
williamr@2
|
295 |
virtual void Nlst(void)=0;
|
williamr@2
|
296 |
|
williamr@2
|
297 |
/** Issues the NLST command, specifying a directory name.
|
williamr@2
|
298 |
*
|
williamr@2
|
299 |
* @param aParam Directory name */
|
williamr@2
|
300 |
virtual void Nlst(const TDesC8& aParam)=0;
|
williamr@2
|
301 |
|
williamr@2
|
302 |
/** Issues the SITE command.
|
williamr@2
|
303 |
*
|
williamr@2
|
304 |
* @param aParam SITE command argument */
|
williamr@2
|
305 |
virtual void Site(const TDesC8& aParam)=0;
|
williamr@2
|
306 |
|
williamr@2
|
307 |
/** Issues the SYST command. */
|
williamr@2
|
308 |
virtual void Syst(void)=0;
|
williamr@2
|
309 |
|
williamr@2
|
310 |
/** Issues the STAT command, specifying an argument.
|
williamr@2
|
311 |
*
|
williamr@2
|
312 |
* @param aParam STAT command argument */
|
williamr@2
|
313 |
virtual void Stat(const TDesC8& aParam)=0;
|
williamr@2
|
314 |
|
williamr@2
|
315 |
/** Issues the STAT command (no argument). */
|
williamr@2
|
316 |
virtual void Stat(void)=0;
|
williamr@2
|
317 |
|
williamr@2
|
318 |
/** Issues the HELP command.
|
williamr@2
|
319 |
*
|
williamr@2
|
320 |
* @param aParam HELP command argument */
|
williamr@2
|
321 |
virtual void Help(const TDesC8& aParam)=0;
|
williamr@2
|
322 |
|
williamr@2
|
323 |
/** Issues the HELP command (no argument). */
|
williamr@2
|
324 |
virtual void Help(void)=0;
|
williamr@2
|
325 |
|
williamr@2
|
326 |
/** Issues the NOOP command. */
|
williamr@2
|
327 |
virtual void Noop(void)=0;
|
williamr@2
|
328 |
|
williamr@2
|
329 |
// Buffer management for transfer
|
williamr@2
|
330 |
// Following functions pass a pointer to a buffer
|
williamr@2
|
331 |
// to transfer data to/from the Dtp channel
|
williamr@2
|
332 |
// Before an operation which cause data to transit on the
|
williamr@2
|
333 |
// DTP channel to occur (Nlst, List, Retr, Stor)
|
williamr@2
|
334 |
// a Buffer must be provided with the following api
|
williamr@2
|
335 |
// Also when the client is notified of a MoreData event
|
williamr@2
|
336 |
// It must reissue the following operation to get the rest of
|
williamr@2
|
337 |
// the data
|
williamr@2
|
338 |
/** Specifies a buffer to transfer data to the DTP channel.
|
williamr@2
|
339 |
*
|
williamr@2
|
340 |
* @param aBuffer Send receive */
|
williamr@2
|
341 |
virtual void SendBuffer(TDes8* aBuffer)=0;
|
williamr@2
|
342 |
|
williamr@2
|
343 |
/** Specifies a buffer to receive data from the DTP channel.
|
williamr@2
|
344 |
*
|
williamr@2
|
345 |
* @param aBuffer Receive buffer */
|
williamr@2
|
346 |
virtual void RecvBuffer(TDes8* aBuffer)=0;
|
williamr@2
|
347 |
|
williamr@2
|
348 |
/** Finishes the transfer initiated by a STOR command. */
|
williamr@2
|
349 |
virtual void SendEOF(void)=0; //Finishes the transfer initiated by a stor command
|
williamr@2
|
350 |
|
williamr@2
|
351 |
/** Cancels current operation. */
|
williamr@2
|
352 |
virtual void UserCancel(void)=0;
|
williamr@2
|
353 |
|
williamr@2
|
354 |
// Copies the 3 digits answer received from the FTP server
|
williamr@2
|
355 |
/** Gets the 3 digits answer received from the FTP server.
|
williamr@2
|
356 |
*
|
williamr@2
|
357 |
* @param aServerAnswer 3 digit answer */
|
williamr@2
|
358 |
virtual void FTPServerAnswer(TDes& aServerAnswer)=0;
|
williamr@2
|
359 |
|
williamr@2
|
360 |
/**
|
williamr@2
|
361 |
Returns 32-bit, with MAJOR_VERSION in the highest byte
|
williamr@2
|
362 |
MINOR_VERSION in the next byte
|
williamr@2
|
363 |
i.e. MAJOR 2, MINOR 0x34, BUILD 0x278 would be "ver 2.52
|
williamr@2
|
364 |
*/
|
williamr@2
|
365 |
IMPORT_C static TUint32 GetVersion(void);
|
williamr@2
|
366 |
|
williamr@2
|
367 |
/** Allocates and constructs a new FTP engine object.
|
williamr@2
|
368 |
*
|
williamr@2
|
369 |
* @return New FTP engine object
|
williamr@2
|
370 |
*/
|
williamr@2
|
371 |
// @param aNotifier Client callback interface.
|
williamr@2
|
372 |
// The FTP engine calls this interface to pass
|
williamr@2
|
373 |
//server responses and status messages to the client.
|
williamr@2
|
374 |
IMPORT_C static CFtpProtocol *NewL(MFtpProtocolNotifier*);
|
williamr@2
|
375 |
|
williamr@2
|
376 |
/**Destructor.*/
|
williamr@2
|
377 |
virtual ~CFtpProtocol();
|
williamr@2
|
378 |
};
|
williamr@2
|
379 |
#endif //__FTPPROT_H__
|