williamr@2: /**
williamr@2: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2: * All rights reserved.
williamr@2: * This component and the accompanying materials are made available
williamr@2: * 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: * which accompanies this distribution, and is available
williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2: *
williamr@2: * Initial Contributors:
williamr@2: * Nokia Corporation - initial contribution.
williamr@2: *
williamr@2: * Contributors:
williamr@2: *
williamr@2: * Description:
williamr@2: * FTP Protocol header file
williamr@2: * Author:	Philippe Gabriel
williamr@2: * 
williamr@2: *
williamr@2: */
williamr@2: 
williamr@2: 
williamr@2: 
williamr@2: 
williamr@2: 
williamr@2: /**
williamr@2:  @file ftprot.h
williamr@2:  @internalComponent
williamr@2: */
williamr@2: 
williamr@2: #if !defined(__FTPPROT_H__)
williamr@2: #define __FTPPROT_H__
williamr@2: 
williamr@2: #include <e32base.h>
williamr@2: #include <es_sock.h>
williamr@2: 
williamr@2: /** FTPPROT.DLL major version number.
williamr@2: @internalComponent */
williamr@2: #define FTPPROTDLL_VERSION_MAJOR 0x01 // The very first release
williamr@2: /** FTPPROT.DLL minor version number. */
williamr@2: #define FTPPROTDLL_VERSION_MINOR 0x03
williamr@2: /** FTPPROT.DLL version number. */
williamr@2: #define FTPPROTDLL_VERSION_NUMBER (FTPPROTDLL_VERSION_MAJOR<<8)|FTPPROTDLL_VERSION_MINOR
williamr@2: 
williamr@2: class MFtpProtocolNotifier
williamr@2: /** FTP engine callback interface.
williamr@2: *
williamr@2: * An FTP engine client implements this interface to receive status and results 
williamr@2: * from asynchronous FTP commands.
williamr@2: * @internalComponent */
williamr@2: 	{
williamr@2: // Operation completion return codes.
williamr@2: 	
williamr@2: public:
williamr@2: /** FTP engine/session operation completeness codes. */
williamr@2: 	enum TOpComp 
williamr@2: 	{
williamr@2: 	/** Operation completed normally. */
williamr@2: 	EOpComplete=0,
williamr@2: 	/** Operation cancelled. */
williamr@2: 	EOpCanceled,	// User canceled last operation
williamr@2: 	/** Operation failed. */
williamr@2: 	EOpFailed, 
williamr@2: 	/** Sockets level error. */
williamr@2: 	ESocketError, 
williamr@2: 
williamr@2: 	// Connection errors
williamr@2: 	/** Connection error: Connection reset. */
williamr@2: 	EOpConnectionReset,
williamr@2: 	/** Connection error: Connection failed. */
williamr@2: 	EOpConnectionFailed,	
williamr@2: 	/** Connection error: Server not found. */
williamr@2: 	EHostNotFound,
williamr@2: 
williamr@2: 	// Transfer error 
williamr@2: 	/** Transfer error: Transfer was reset. */
williamr@2: 	EXferReset,
williamr@2: 	/** Transfer error: Transfer is not initialised. */	
williamr@2: 	EXferNotInitialised,
williamr@2: 
williamr@2: 	//Transfer notification
williamr@2: 	/** Transfer notification: Data packet was received. */
williamr@2: 	EPacketReceived,
williamr@2: 	/** Transfer notification: Data packet was sent. */	
williamr@2: 	EPacketSent
williamr@2: 	};
williamr@2: public:
williamr@2: 	/** Destructor. */
williamr@2: 	virtual ~MFtpProtocolNotifier(){};
williamr@2: 
williamr@2: 	/** Positive reply received from server.
williamr@2: 	*
williamr@2: 	* @param aStatus	Operation completion code */
williamr@2: 	virtual void ServerPositiveAnswerNotification(const TOpComp aStatus)=0;
williamr@2: 
williamr@2: 
williamr@2: 	/** Message sent by the FTP server.
williamr@2: 	*
williamr@2: 	* This returns the full server reply in plain text format.
williamr@2: 	* 
williamr@2: 	* @param aMessage	The message sent by the server */
williamr@2: 	virtual void ServerMessage(const TDesC8& aMessage)=0;
williamr@2: 
williamr@2: 	/** Data transfer notification received from the server.
williamr@2: 	*
williamr@2: 	* @param aStatus	Operation completion code */
williamr@2: 	virtual void ServerXFerNotification(const TOpComp aStatus)=0;
williamr@2: 
williamr@2: 	/** Negative reply received from server.
williamr@2: 	* 
williamr@2: 	* @param aStatus	Operation completion code */
williamr@2: 	virtual void ServerNegativeAnswerNotification(const TOpComp aStatus)=0;
williamr@2: 
williamr@2: 	/** Error condition notification.
williamr@2: 	* 
williamr@2: 	* @param aStatus	Operation completion code */
williamr@2: 	virtual void ErrorNotification(const TOpComp aStatus)=0;
williamr@2: 	};
williamr@2: 
williamr@2: 
williamr@2: class CFtpProtocol : public CBase
williamr@2: /** Implements an FTP engine, and allows the client to access the individual FTP 
williamr@2: * commands as defined in RFC959.
williamr@2: * 
williamr@2: * Note that before commands that cause data to transit on the DTP channel (e.g. NLST, 
williamr@2: * LIST, RETR, STOR) a data buffer must be provided using SendBuffer()/RecvBuffer(). 
williamr@2: * Also, when the client is notified of a MoreData() event, it must re-issue RecvBuffer() 
williamr@2: * to get the rest of the data.
williamr@2: * @internalComponent
williamr@2: */
williamr@2: 	{
williamr@2: public:
williamr@2: 
williamr@2: // Establish a connection:
williamr@2: 	/** Connect to an FTP server, specifying an IP address.	
williamr@2: 	* 
williamr@2: 	* @param aNetAddr	FTP server's IP address */
williamr@2: 	virtual void Connect(TSockAddr& aNetAddr)=0;	// IP address
williamr@2: 
williamr@2: 	/** Connect to an FTP server, specifying a DNS name.
williamr@2: 	* 
williamr@2: 	* @param aServerName	FTP server's DNS name */
williamr@2: 	virtual void Connect(const THostName& aServerName)=0;  // URL name
williamr@2: 
williamr@2: 	/** Connect to an FTP server, specifying a DNS name and port number.
williamr@2: 	* 
williamr@2: 	* @param aServerName	FTP server's DNS name
williamr@2: 	* @param aPort			FTP server's port */
williamr@2: 	virtual void Connect(const THostName& aServerName, const TUint aPort)=0; // URL name + port
williamr@2: 
williamr@2: // FTP commands, presented in the same order as RFC959:
williamr@2: 	/** Issues the USER command.
williamr@2: 	* 
williamr@2: 	* @param aParam	Telnet string identifying the user */
williamr@2: 	virtual void User(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the PASS command.
williamr@2: 	* 
williamr@2: 	* @param aParam	Telnet string specifying the user's password */
williamr@2: 	virtual void Pass(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the ACCT command.
williamr@2: 	* 
williamr@2: 	* @param aParam	Telnet string identifying the user's account */
williamr@2: 	virtual void Acct(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the CWD command.
williamr@2: 	* 
williamr@2: 	* @param aParam	Directory or other system dependent file group designator */
williamr@2: 	virtual void Cwd(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the CDUP command. */
williamr@2: 	virtual void Cdup(void)=0;
williamr@2: 
williamr@2: 	/** Issues the SMNT command.
williamr@2: 	* 
williamr@2: 	* @param aParam	Pathname specifying a directory or other system dependent file 
williamr@2: 	* 				group designator */
williamr@2: 	virtual void Smnt(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the QUIT command. */
williamr@2: 	virtual void Quit(void)=0;
williamr@2: 
williamr@2: 	/** Issues the REIN command. */
williamr@2: 	virtual void Rein(void)=0;
williamr@2: 
williamr@2: 	/** Issues the PORT command, setting the Data Transfer Process port to a value 
williamr@2: 	* allocated by the Sockets Server. */
williamr@2: 	virtual void Port(void)=0;			// Sets the DTP port to one allocated by ESOCK
williamr@2: 
williamr@2: 	/** Issues the PORT command, specifying a port number.
williamr@2: 	* 
williamr@2: 	* @param aPort	Port number */
williamr@2: 	virtual void Port(TUint aPort)=0;	// Sets the DTP port to a specific one
williamr@2: 
williamr@2: 	/** Issues the PASV command. */
williamr@2: 	virtual void Pasv(void)=0;
williamr@2: 
williamr@2: 	/** Issues the TYPE command (single parameter).
williamr@2: 	* 
williamr@2: 	* @param aParam	First representation type parameter */
williamr@2: 	virtual void Type(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the TYPE command (two parameters).
williamr@2: 	* 
williamr@2: 	* @param aParam1	First representation type parameter
williamr@2: 	* @param aParam2	Second representation type parameter */
williamr@2: 	virtual void Type(const TDesC8& aParam1, const TDesC8& aParam2)=0;
williamr@2: 
williamr@2: 	/** Issues the STRU command.
williamr@2: 	* 
williamr@2: 	* @param aParam	Telnet character code specifying the file structure */
williamr@2: 	virtual void Stru(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the MODE command.
williamr@2: 	* 
williamr@2: 	* @param aParam	Telnet character code specifying the data transfer mode */
williamr@2: 	virtual void Mode(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the RETR command.
williamr@2: 	* 
williamr@2: 	* @param aFileName	File name */
williamr@2: 	virtual void Retr(const TDesC8& aFileName)=0;
williamr@2: 
williamr@2: 	/** Issues the STOR command.
williamr@2: 	* 
williamr@2: 	* @param aFileName	File name */
williamr@2: 	virtual void Stor(const TDesC8& aFileName)=0;
williamr@2: 
williamr@2: 	/** Issues the STOU command. */
williamr@2: 	virtual void Stou(void)=0;
williamr@2: 
williamr@2: 	/** Issues the APPE command.
williamr@2: 	* 
williamr@2: 	* @param aFileName	File name */
williamr@2: 	virtual void Appe(const TDesC8& aFileName)=0;
williamr@2: 
williamr@2: 	/** Issues the ALLO command (single parameter).
williamr@2: 	* 
williamr@2: 	* @param aParam	Number of bytes (using the logical byte size) of storage to 
williamr@2: 	* 				be reserved for the file */
williamr@2: 	virtual void Allo(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the ALLO command (two parameters).
williamr@2: 	* 
williamr@2: 	* @param aParam1	Number of bytes (using the logical byte size) of storage to 
williamr@2: 	* 					be reserved for the file
williamr@2: 	* @param aParam2	Maximum record or page size (in logical bytes) */
williamr@2: 	virtual void Allo(const TDesC8& aParam1, const TDesC8& aParam2)=0;
williamr@2: 
williamr@2: 	/** Issues the REST command.
williamr@2: 	* 
williamr@2: 	* @param aParam	The server marker at which file transfer is to be restarted */
williamr@2: 	virtual void Rest(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the RNFR command.
williamr@2: 	* 
williamr@2: 	* @param aFileName	File name */
williamr@2: 	virtual void Rnfr(const TDesC8& aFileName)=0;
williamr@2: 
williamr@2: 	/** Issues the RNTO command.
williamr@2: 	* 
williamr@2: 	* @param aFileName	File name */
williamr@2: 	virtual void Rnto(const TDesC8& aFileName)=0;
williamr@2: 
williamr@2: 	/** Issues the ABOR command. */
williamr@2: 	virtual void Abor(void)=0;
williamr@2: 
williamr@2: 	/** Issues the DELE command.
williamr@2: 	* 
williamr@2: 	* @param aFileName	File name */
williamr@2: 	virtual void Dele(const TDesC8& aFileName)=0;
williamr@2: 
williamr@2: 	/** Issues the RMD command.
williamr@2: 	* 
williamr@2: 	* @param aParam	Directory name */
williamr@2: 	virtual void Rmd(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the MKD command.
williamr@2: 	* 
williamr@2: 	* @param aParam	Directory name */
williamr@2: 	virtual void Mkd(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the PWD command. */
williamr@2: 	virtual void Pwd(void)=0;
williamr@2: 
williamr@2: 	/** Issues the LIST command, giving a null argument. */
williamr@2: 	virtual void List(void)=0;
williamr@2: 
williamr@2: 	/** Issues the LIST command, specifying a file/directory name.
williamr@2: 	* 
williamr@2: 	* @param aParam	File/directory name */
williamr@2: 	virtual void List(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the NLST command, giving a null argument. */
williamr@2: 	virtual void Nlst(void)=0;
williamr@2: 
williamr@2: 	/** Issues the NLST command, specifying a directory name.
williamr@2: 	* 
williamr@2: 	* @param aParam	Directory name */
williamr@2: 	virtual void Nlst(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the SITE command.
williamr@2: 	* 
williamr@2: 	* @param aParam	SITE command argument */
williamr@2: 	virtual void Site(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the SYST command. */
williamr@2: 	virtual void Syst(void)=0;
williamr@2: 
williamr@2: 	/** Issues the STAT command, specifying an argument.
williamr@2: 	* 
williamr@2: 	* @param aParam	STAT command argument */
williamr@2: 	virtual void Stat(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the STAT command (no argument). */
williamr@2: 	virtual void Stat(void)=0;
williamr@2: 
williamr@2: 	/** Issues the HELP command.
williamr@2: 	* 
williamr@2: 	* @param aParam	HELP command argument */
williamr@2: 	virtual void Help(const TDesC8& aParam)=0;
williamr@2: 
williamr@2: 	/** Issues the HELP command (no argument). */
williamr@2: 	virtual void Help(void)=0;
williamr@2: 
williamr@2: 	/** Issues the NOOP command. */
williamr@2: 	virtual void Noop(void)=0;
williamr@2: 
williamr@2: // Buffer management for transfer
williamr@2: 	// Following functions pass a pointer to a buffer
williamr@2: 	// to transfer data to/from the Dtp channel
williamr@2: 	// Before an operation which cause data to transit on the 
williamr@2: 	// DTP channel to occur (Nlst, List, Retr, Stor)
williamr@2: 	// a Buffer must be provided with the following api
williamr@2: 	// Also when the client is notified of a MoreData event
williamr@2: 	// It must reissue the following operation to get the rest of
williamr@2: 	// the data
williamr@2: 	/** Specifies a buffer to transfer data to the DTP channel.	
williamr@2: 	* 
williamr@2: 	* @param aBuffer	Send receive */
williamr@2: 	virtual void SendBuffer(TDes8* aBuffer)=0;
williamr@2: 
williamr@2: 	/** Specifies a buffer to receive data from the DTP channel.
williamr@2: 	* 
williamr@2: 	* @param aBuffer	Receive buffer */
williamr@2: 	virtual void RecvBuffer(TDes8* aBuffer)=0;
williamr@2: 
williamr@2: 	/** Finishes the transfer initiated by a STOR command. */
williamr@2: 	virtual void SendEOF(void)=0; //Finishes the transfer initiated by a stor command
williamr@2: 
williamr@2: 	/** Cancels current operation. */
williamr@2: 	virtual void UserCancel(void)=0;
williamr@2: 
williamr@2: // Copies the 3 digits answer received from the FTP server
williamr@2: 	/** Gets the 3 digits answer received from the FTP server.
williamr@2: 	* 
williamr@2: 	* @param aServerAnswer	3 digit answer */
williamr@2: 	virtual void FTPServerAnswer(TDes& aServerAnswer)=0;
williamr@2: 
williamr@2: 	/**
williamr@2: 	Returns 32-bit, with MAJOR_VERSION in the highest byte
williamr@2: 	MINOR_VERSION in the next byte
williamr@2: 	i.e. MAJOR 2, MINOR 0x34, BUILD 0x278 would be "ver 2.52
williamr@2: 	*/
williamr@2: 	IMPORT_C static TUint32 GetVersion(void);
williamr@2: 
williamr@2: 	/** Allocates and constructs a new FTP engine object.
williamr@2: 	* 
williamr@2: 	* @return	New FTP engine object
williamr@2: 	*/
williamr@2: 	// @param aNotifier Client callback interface. 
williamr@2: 	// The FTP engine calls this interface to pass 
williamr@2: 	//server responses and status messages to the client.
williamr@2: 	IMPORT_C static CFtpProtocol *NewL(MFtpProtocolNotifier*);
williamr@2: 
williamr@2: 	/**Destructor.*/
williamr@2: 	virtual ~CFtpProtocol();
williamr@2: 	};
williamr@2: #endif //__FTPPROT_H__