2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
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
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * FTP Protocol header file
16 * Author: Philippe Gabriel
30 #if !defined(__FTPPROT_H__)
36 /** FTPPROT.DLL major version number.
38 #define FTPPROTDLL_VERSION_MAJOR 0x01 // The very first release
39 /** FTPPROT.DLL minor version number. */
40 #define FTPPROTDLL_VERSION_MINOR 0x03
41 /** FTPPROT.DLL version number. */
42 #define FTPPROTDLL_VERSION_NUMBER (FTPPROTDLL_VERSION_MAJOR<<8)|FTPPROTDLL_VERSION_MINOR
44 class MFtpProtocolNotifier
45 /** FTP engine callback interface.
47 * An FTP engine client implements this interface to receive status and results
48 * from asynchronous FTP commands.
49 * @internalComponent */
51 // Operation completion return codes.
54 /** FTP engine/session operation completeness codes. */
57 /** Operation completed normally. */
59 /** Operation cancelled. */
60 EOpCanceled, // User canceled last operation
61 /** Operation failed. */
63 /** Sockets level error. */
67 /** Connection error: Connection reset. */
69 /** Connection error: Connection failed. */
71 /** Connection error: Server not found. */
75 /** Transfer error: Transfer was reset. */
77 /** Transfer error: Transfer is not initialised. */
80 //Transfer notification
81 /** Transfer notification: Data packet was received. */
83 /** Transfer notification: Data packet was sent. */
88 virtual ~MFtpProtocolNotifier(){};
90 /** Positive reply received from server.
92 * @param aStatus Operation completion code */
93 virtual void ServerPositiveAnswerNotification(const TOpComp aStatus)=0;
96 /** Message sent by the FTP server.
98 * This returns the full server reply in plain text format.
100 * @param aMessage The message sent by the server */
101 virtual void ServerMessage(const TDesC8& aMessage)=0;
103 /** Data transfer notification received from the server.
105 * @param aStatus Operation completion code */
106 virtual void ServerXFerNotification(const TOpComp aStatus)=0;
108 /** Negative reply received from server.
110 * @param aStatus Operation completion code */
111 virtual void ServerNegativeAnswerNotification(const TOpComp aStatus)=0;
113 /** Error condition notification.
115 * @param aStatus Operation completion code */
116 virtual void ErrorNotification(const TOpComp aStatus)=0;
120 class CFtpProtocol : public CBase
121 /** Implements an FTP engine, and allows the client to access the individual FTP
122 * commands as defined in RFC959.
124 * Note that before commands that cause data to transit on the DTP channel (e.g. NLST,
125 * LIST, RETR, STOR) a data buffer must be provided using SendBuffer()/RecvBuffer().
126 * Also, when the client is notified of a MoreData() event, it must re-issue RecvBuffer()
127 * to get the rest of the data.
133 // Establish a connection:
134 /** Connect to an FTP server, specifying an IP address.
136 * @param aNetAddr FTP server's IP address */
137 virtual void Connect(TSockAddr& aNetAddr)=0; // IP address
139 /** Connect to an FTP server, specifying a DNS name.
141 * @param aServerName FTP server's DNS name */
142 virtual void Connect(const THostName& aServerName)=0; // URL name
144 /** Connect to an FTP server, specifying a DNS name and port number.
146 * @param aServerName FTP server's DNS name
147 * @param aPort FTP server's port */
148 virtual void Connect(const THostName& aServerName, const TUint aPort)=0; // URL name + port
150 // FTP commands, presented in the same order as RFC959:
151 /** Issues the USER command.
153 * @param aParam Telnet string identifying the user */
154 virtual void User(const TDesC8& aParam)=0;
156 /** Issues the PASS command.
158 * @param aParam Telnet string specifying the user's password */
159 virtual void Pass(const TDesC8& aParam)=0;
161 /** Issues the ACCT command.
163 * @param aParam Telnet string identifying the user's account */
164 virtual void Acct(const TDesC8& aParam)=0;
166 /** Issues the CWD command.
168 * @param aParam Directory or other system dependent file group designator */
169 virtual void Cwd(const TDesC8& aParam)=0;
171 /** Issues the CDUP command. */
172 virtual void Cdup(void)=0;
174 /** Issues the SMNT command.
176 * @param aParam Pathname specifying a directory or other system dependent file
177 * group designator */
178 virtual void Smnt(const TDesC8& aParam)=0;
180 /** Issues the QUIT command. */
181 virtual void Quit(void)=0;
183 /** Issues the REIN command. */
184 virtual void Rein(void)=0;
186 /** Issues the PORT command, setting the Data Transfer Process port to a value
187 * allocated by the Sockets Server. */
188 virtual void Port(void)=0; // Sets the DTP port to one allocated by ESOCK
190 /** Issues the PORT command, specifying a port number.
192 * @param aPort Port number */
193 virtual void Port(TUint aPort)=0; // Sets the DTP port to a specific one
195 /** Issues the PASV command. */
196 virtual void Pasv(void)=0;
198 /** Issues the TYPE command (single parameter).
200 * @param aParam First representation type parameter */
201 virtual void Type(const TDesC8& aParam)=0;
203 /** Issues the TYPE command (two parameters).
205 * @param aParam1 First representation type parameter
206 * @param aParam2 Second representation type parameter */
207 virtual void Type(const TDesC8& aParam1, const TDesC8& aParam2)=0;
209 /** Issues the STRU command.
211 * @param aParam Telnet character code specifying the file structure */
212 virtual void Stru(const TDesC8& aParam)=0;
214 /** Issues the MODE command.
216 * @param aParam Telnet character code specifying the data transfer mode */
217 virtual void Mode(const TDesC8& aParam)=0;
219 /** Issues the RETR command.
221 * @param aFileName File name */
222 virtual void Retr(const TDesC8& aFileName)=0;
224 /** Issues the STOR command.
226 * @param aFileName File name */
227 virtual void Stor(const TDesC8& aFileName)=0;
229 /** Issues the STOU command. */
230 virtual void Stou(void)=0;
232 /** Issues the APPE command.
234 * @param aFileName File name */
235 virtual void Appe(const TDesC8& aFileName)=0;
237 /** Issues the ALLO command (single parameter).
239 * @param aParam Number of bytes (using the logical byte size) of storage to
240 * be reserved for the file */
241 virtual void Allo(const TDesC8& aParam)=0;
243 /** Issues the ALLO command (two parameters).
245 * @param aParam1 Number of bytes (using the logical byte size) of storage to
246 * be reserved for the file
247 * @param aParam2 Maximum record or page size (in logical bytes) */
248 virtual void Allo(const TDesC8& aParam1, const TDesC8& aParam2)=0;
250 /** Issues the REST command.
252 * @param aParam The server marker at which file transfer is to be restarted */
253 virtual void Rest(const TDesC8& aParam)=0;
255 /** Issues the RNFR command.
257 * @param aFileName File name */
258 virtual void Rnfr(const TDesC8& aFileName)=0;
260 /** Issues the RNTO command.
262 * @param aFileName File name */
263 virtual void Rnto(const TDesC8& aFileName)=0;
265 /** Issues the ABOR command. */
266 virtual void Abor(void)=0;
268 /** Issues the DELE command.
270 * @param aFileName File name */
271 virtual void Dele(const TDesC8& aFileName)=0;
273 /** Issues the RMD command.
275 * @param aParam Directory name */
276 virtual void Rmd(const TDesC8& aParam)=0;
278 /** Issues the MKD command.
280 * @param aParam Directory name */
281 virtual void Mkd(const TDesC8& aParam)=0;
283 /** Issues the PWD command. */
284 virtual void Pwd(void)=0;
286 /** Issues the LIST command, giving a null argument. */
287 virtual void List(void)=0;
289 /** Issues the LIST command, specifying a file/directory name.
291 * @param aParam File/directory name */
292 virtual void List(const TDesC8& aParam)=0;
294 /** Issues the NLST command, giving a null argument. */
295 virtual void Nlst(void)=0;
297 /** Issues the NLST command, specifying a directory name.
299 * @param aParam Directory name */
300 virtual void Nlst(const TDesC8& aParam)=0;
302 /** Issues the SITE command.
304 * @param aParam SITE command argument */
305 virtual void Site(const TDesC8& aParam)=0;
307 /** Issues the SYST command. */
308 virtual void Syst(void)=0;
310 /** Issues the STAT command, specifying an argument.
312 * @param aParam STAT command argument */
313 virtual void Stat(const TDesC8& aParam)=0;
315 /** Issues the STAT command (no argument). */
316 virtual void Stat(void)=0;
318 /** Issues the HELP command.
320 * @param aParam HELP command argument */
321 virtual void Help(const TDesC8& aParam)=0;
323 /** Issues the HELP command (no argument). */
324 virtual void Help(void)=0;
326 /** Issues the NOOP command. */
327 virtual void Noop(void)=0;
329 // Buffer management for transfer
330 // Following functions pass a pointer to a buffer
331 // to transfer data to/from the Dtp channel
332 // Before an operation which cause data to transit on the
333 // DTP channel to occur (Nlst, List, Retr, Stor)
334 // a Buffer must be provided with the following api
335 // Also when the client is notified of a MoreData event
336 // It must reissue the following operation to get the rest of
338 /** Specifies a buffer to transfer data to the DTP channel.
340 * @param aBuffer Send receive */
341 virtual void SendBuffer(TDes8* aBuffer)=0;
343 /** Specifies a buffer to receive data from the DTP channel.
345 * @param aBuffer Receive buffer */
346 virtual void RecvBuffer(TDes8* aBuffer)=0;
348 /** Finishes the transfer initiated by a STOR command. */
349 virtual void SendEOF(void)=0; //Finishes the transfer initiated by a stor command
351 /** Cancels current operation. */
352 virtual void UserCancel(void)=0;
354 // Copies the 3 digits answer received from the FTP server
355 /** Gets the 3 digits answer received from the FTP server.
357 * @param aServerAnswer 3 digit answer */
358 virtual void FTPServerAnswer(TDes& aServerAnswer)=0;
361 Returns 32-bit, with MAJOR_VERSION in the highest byte
362 MINOR_VERSION in the next byte
363 i.e. MAJOR 2, MINOR 0x34, BUILD 0x278 would be "ver 2.52
365 IMPORT_C static TUint32 GetVersion(void);
367 /** Allocates and constructs a new FTP engine object.
369 * @return New FTP engine object
371 // @param aNotifier Client callback interface.
372 // The FTP engine calls this interface to pass
373 //server responses and status messages to the client.
374 IMPORT_C static CFtpProtocol *NewL(MFtpProtocolNotifier*);
377 virtual ~CFtpProtocol();
379 #endif //__FTPPROT_H__