Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_FTP Class Reference

A CP_NetProtoBase class that implements the FTP internet protocol over a CP_Socket object.

Inheritance diagram for CP_FTP:

CP_NetProtoBase CP_Object CP_NoCopy List of all members.

Public Types

enum  { kCP_FTPPortNumber = 21 }
enum  CP_E_FTPConnectionState { CP_E_FTPClosed, CP_E_FTPConnected }
enum  CP_E_FTPTransferType { CP_FTP_UndefinedType = 0, CP_FTP_ASCIIType = 'A', CP_FTP_ImageType = 'I' }

Public Member Functions

CP_E_FTPConnectionState GetConnectionState () const
void SetID (FourCharCode inIdentifier)
FourCharCode GetID ()
void RegisterSignal (const CP_SignalHolder &inSignal)
CP_DataValueSignalFindSignal (const CP_String &inSignalName)
UInt32 GetNumberSignals ()
CP_String GetNthSignalName (UInt32 inSignalIndex)
void RegisterSlot (const CP_SlotHolder &inSlot)
CP_DataValueSlot FindSlot (const CP_String &inSlotName)
UInt32 GetNumberSlots ()
CP_String GetNthSlotName (UInt32 inSlotIndex)
template<class R, class P1, class P2>
CP_CommandHandlerSignalConnect (CPLAT::CP_CommandNo cmd, void(R::*handler)(P1, P2), SInt32 mode)
template<class R, class P1, class P2>
void Connect (CP_Object *control, const CPLAT::CP_String &signalName, void(R::*handler)(P1, P2))
Constructor / Destructor
 CP_FTP (CP_Socket *inSocketConnection)
 Constructor.
virtual ~CP_FTP () throw ()
 Destructor.
Connection
void Connect (const CP_String &inAddress, SInt16 inPortNumber=CP_FTP::kCP_FTPPortNumber)
Commands - Connection
void Disconnect ()
void GetList (CP_String &inOutList, const CP_String &inWildcard="")
Commands - Directory
void ChangeDirectory (const CP_String &inDirectory)
void ChangeDirectoryUp ()
CP_String GetWorkingDirectory ()
void MakeDirectory (const CP_String &inDirectory)
void RemoveDirectory (const CP_String &inDirectory)
Commands - File
void DeleteFile (const CP_String &inFileName)
void GetFile (CP_File *inDestinationFile, const CP_String &inFileName, CP_E_FTPTransferType inTransferType)
void PutFile (CP_File *inSourceFile, const CP_String &inDestFileName, CP_E_FTPTransferType inTransferType, bool inCreateUnique)
void RenameFile (const CP_String &inOriginalName, const CP_String &inNewName)
void RenameFileFrom (const CP_String &inOriginalName)
void RenameFileTo (const CP_String &inNewName)
SInt32 SendRETR (const CP_String &inFileName)
void SendSTOR (const CP_String &inFileName, bool inCreateUnique)
void SendTYPE (CP_E_FTPTransferType inTransferType)
Commands - Misc
void SendPORT (UInt32 inHostNum, SInt16 inPort)
void SendQUIT ()
void SendSYST ()
Getters
UInt32 GetReceiveBufferSize ()
UInt32 GetSendBufferSize ()
Login
void LogIn (const CP_String &inUser, const CP_String &inPassword)
Misc
CP_SocketGetDataPort ()
Setters
void SetReceiveBufferSize (UInt32 inBufferSize)
void SetSendBufferSize (UInt32 inBufferSize)

Static Public Member Functions

static void Connect (CP_Object *sender, const CP_String &signalName, CP_Object *receiver, const CP_String &slotName, const bool reciprocal=false)
static void Connect (CP_Object *sender, CP_Object *receiver, const bool reciprocal=false, const CP_String &signalName=kCP_Signal_ValueChanged, const CP_String &slotName=kCP_Slot_SetValue)

Protected Member Functions

File helper
void GetFile_internal (CP_Socket *inSocket, CP_File *inDestinationFile)
void PutFile_internal (CP_Socket *inSocket, CP_File *inSourceFile)

Protected Attributes

UInt32 fReceiveBufferSize
UInt32 fSendBufferSize
CP_E_FTPConnectionState fConnectionState
CP_E_FTPTransferType fTransferType
CP_SocketfSocketConnection
CP_InternetResponsefLastServerResponse
CP_DataValueSignal fProgressSignal
CP_Signals_ArrayfSignals
CP_Slots_ArrayfSlots
FourCharCode fObjectID

Static Protected Attributes

static FourCharCode fObjectIDCount = 0

Member Enumeration Documentation

anonymous enum
 

The port number used for this class.

Enumeration values:
kCP_FTPPortNumber 

enum CP_FTP::CP_E_FTPConnectionState
 

Current state of the FTP connection with the server.

Enumeration values:
CP_E_FTPClosed 
CP_E_FTPConnected 

enum CP_FTP::CP_E_FTPTransferType
 

Type of information being transfered.

Enumeration values:
CP_FTP_UndefinedType 
CP_FTP_ASCIIType 
CP_FTP_ImageType 


Constructor & Destructor Documentation

CPLAT_Begin_Namespace_CPLAT CP_FTP::CP_FTP CP_Socket inSocketConnection  ) 
 

Constructor.

Parameters:
inSocketConnection The socket connection to the FTP server.
Exceptions:
none 

CP_FTP::~CP_FTP  )  throw () [virtual]
 

Destructor.

Exceptions:
none 


Member Function Documentation

void CP_FTP::Connect const CP_String inAddress,
SInt16  inPortNumber = CP_FTP::kCP_FTPPortNumber
 

Connect to the FTP server.

Parameters:
inAddress The address of the server.
inPortNumber Port number to connect on.
Exceptions:
OSError / NULL exceptions.
Returns:
void

CP_E_FTPConnectionState CP_FTP::GetConnectionState  )  const
 

void CP_FTP::Disconnect  ) 
 

Disconnect from the FTP server.

Exceptions:
none 
Returns:
void

void CP_FTP::GetList CP_String inOutList,
const CP_String inWildcard = ""
 

Return a list of the files/directories on the FTP server. NOTE: The passed in inOutList will contain a list of the files from the server appended to the inOutList, so it should be of 0 length on entry.

Parameters:
inOutList Location to return the result in.
inWildcard Filter to control list of files.
Exceptions:
OSError / NULL exceptions.
Returns:
void

void CP_FTP::ChangeDirectory const CP_String inDirectory  ) 
 

Change to the passed in directory.

Parameters:
inDirectory The directory to change to.
Exceptions:
OSError/Server response exceptions.
Returns:
void

void CP_FTP::ChangeDirectoryUp  ) 
 

Change directory up one level.

Exceptions:
OSError/Server response exceptions.
Returns:
void

CP_String CP_FTP::GetWorkingDirectory  ) 
 

Returns a string that contains the current working directory.

Exceptions:
OSError/Server response exceptions.
Returns:
CP_String The current working directory.

void CP_FTP::MakeDirectory const CP_String inDirectory  ) 
 

Make a new directory on the FTP server with the name specified in inDirectory.

Parameters:
inDirectory The name of the new directory.
Exceptions:
OSError/Server response exceptions.
Returns:
void

void CP_FTP::RemoveDirectory const CP_String inDirectory  ) 
 

Removes the passed in directory on the FTP server.

Parameters:
inDirectory The directory to remove.
Exceptions:
OSError/Server response exceptions.
Returns:
void

void CP_FTP::DeleteFile const CP_String inFileName  ) 
 

Deletes a file on the FTP server with the passed in file name.

Parameters:
inFileName Name of the file to be deleted.
Exceptions:
OSError/Server response exceptions.
Returns:
void

void CP_FTP::GetFile CP_File inDestinationFile,
const CP_String inFileName,
CP_E_FTPTransferType  inTransferType
 

Retrieve a file from our FTP server. This routine will open a data connection to the FTP server and return the data in the passed in inDestinationFile.

Parameters:
inDestinationFile The file we are going to write the contents to.
inFileName The name of the file on the FTP server.
inTransferType Determine the type of transfer to use, as follows:
  • CP_FTP_UndefinedType
  • CP_FTP_ASCIIType
  • CP_FTP_ImageType
Exceptions:
none 
Returns:
void

void CP_FTP::PutFile CP_File inSourceFile,
const CP_String inDestFileName,
CP_E_FTPTransferType  inTransferType,
bool  inCreateUnique
 

Put a file on the destination FTP server. This method assumes the file is already open for reading from.

Parameters:
inSourceFile The file we are reading from.
inDestFileName The name of the file on the FTP server.
inTransferType Determine the type of transfer to use, as follows:
  • CP_FTP_UndefinedType
  • CP_FTP_ASCIIType
  • CP_FTP_ImageType
inCreateUnique Flag to indicate if the file is to be created as a unique file on the FTP server.
Exceptions:
OSError/Server response exceptions.
Returns:
void

void CP_FTP::RenameFile const CP_String inOriginalName,
const CP_String inNewName
 

Renames a file on the FTP server.

Parameters:
inOriginalName Original name of the file we are renaming.
inNewName New name of the file.
Exceptions:
none 
Returns:
void

void CP_FTP::RenameFileFrom const CP_String inOriginalName  ) 
 

Sends the rename file from command to the FTP server. Called from the above RenameFile.

Parameters:
inOriginalName The name on the server to be renamed.
Exceptions:
OSError/Server response exceptions.
Returns:
void

void CP_FTP::RenameFileTo const CP_String inNewName  ) 
 

Sends the rename file from command to the FTP server. Called from the above RenameFile.

Parameters:
inNewName The new name of the file.
Exceptions:
OSError/Server response exceptions.
Returns:
void

SInt32 CP_FTP::SendRETR const CP_String inFileName  ) 
 

Sends the RETR command.

Exceptions:
OSError/Server response exceptions.
Returns:
void

void CP_FTP::SendSTOR const CP_String inFileName,
bool  inCreateUnique
 

Sends the STOR command.

Exceptions:
OSError/Server response exceptions.
Returns:
void

void CP_FTP::SendTYPE CP_E_FTPTransferType  inTransferType  ) 
 

Sends the TYPE command.

Exceptions:
OSError/Server response exceptions.
Returns:
void

void CP_FTP::SendPORT UInt32  inHostNum,
SInt16  inPort
 

Sends the PORT command.

Parameters:
inHostNum Host number of the port.
inPort Port number of the port.
Exceptions:
OSError/Server response exceptions.
Returns:
void

void CP_FTP::SendQUIT  ) 
 

Sends the QUIT command.

Exceptions:
OSError/Server response exceptions.
Returns:
void

void CP_FTP::SendSYST  ) 
 

Sends the SYST command.

Exceptions:
OSError/Server response exceptions.
Returns:
void

UInt32 CP_FTP::GetReceiveBufferSize  ) 
 

UInt32 CP_FTP::GetSendBufferSize  ) 
 

void CP_FTP::LogIn const CP_String inUser,
const CP_String inPassword
 

Log in to the FTP server using the passed in inUser and inPassword.

Parameters:
inUser Name of the user logging in.
inPassword Password of the user logging in.
Exceptions:
OSError/Server response exceptions.
Returns:
void

CP_Socket * CP_FTP::GetDataPort  ) 
 

Return a CP_Socket object to be used to communicate with the FTP server over a data port. This is used when we need to establish a new data port connection with the FTP server to send or receive information.

Exceptions:
OSError/Server response exceptions.
Returns:
CP_Socket * The socket we communicate with the port over.

void CP_FTP::SetReceiveBufferSize UInt32  inBufferSize  ) 
 

void CP_FTP::SetSendBufferSize UInt32  inBufferSize  ) 
 

void CP_FTP::GetFile_internal CP_Socket inSocket,
CP_File inDestinationFile
[protected]
 

Internal routine used by the GetFile method above to do the actual work of retrieving the file.

Parameters:
inSocket The socket we communicate with the FTP server over.
inDestinationFile The file we are going to write the contents to.
Exceptions:
OSError/Server response exceptions.
Returns:
void

void CP_FTP::PutFile_internal CP_Socket inSocket,
CP_File inSourceFile
[protected]
 

Internal routine to handle putting the file on the FTP server.

Parameters:
inSocket The socket we communicate over.
inSourceFile The file we are reading from.
Exceptions:
OSError/Server response exceptions.
Returns:
void

virtual CP_InternetResponse* CP_NetProtoBase::GetServerResponse  )  [virtual, inherited]
 

Returns the last server response.

Exceptions:
none 
Returns:
CP_InternetResponse * The internet response for this protocol.

void CP_NetProtoBase::BroadcastProgress CP_InternetProtocolProgress inProtocolProgress  )  [inherited]
 

Broadcast our progress information to any objects that have added themselves as listeners to this object. This will send the signal kCP_Signal_InternetProgress which listeners should connect a slot to.

Parameters:
inProtocolProgress The internnet protocol progress object that contains the progress information. This is also the value of the data value holder for the signal being sent.
Exceptions:
none 
Returns:
void

SInt32 CP_NetProtoBase::ReadLine CP_Socket inSocket,
CP_String inOutResult
[protected, inherited]
 

Receive the next line from our server. We keep receiving until the end of line is reached.

Parameters:
inSocket The socket connection to the server. inOutResult Loction to return the result in.
Exceptions:
none 
Returns:
SInt32 A result code, either CP_noErr or CP_Err_ReceivingFromSocket.

bool CP_NetProtoBase::IsCommaDelimitedListOfSixOctets char *  p  )  [protected, inherited]
 

Return true if our passed in string is in the form of a 6 part address. (h1,h2,h3,h4,p1,p2)

Parameters:
p The string we are checking.
Exceptions:
none 
Returns:
bool True if the passed in string is in the form of a 6 part address.

void CP_NetProtoBase::SendCommand CP_String inCommand  )  [protected, inherited]
 

Sends a command to the server, but does not wait for a response.

Parameters:
inCommand The command to send.
Exceptions:
none 
Returns:
void

void CP_NetProtoBase::SendCommandWithReply CP_String inCommand  )  [protected, inherited]
 

Send the command, and wait for a response. The response will be placed in the CP_InternetResponse object associated with this object.

Parameters:
inCommand The command to send.
Exceptions:
none 
Returns:
void

void CP_NetProtoBase::SendData CP_String inData  )  [protected, inherited]
 

Send data to our socket connection. inData needs to be formatted correctly since we just send the bytes.

Parameters:
inData The data we are sending.
Exceptions:
none 
Returns:
void

void CP_NetProtoBase::SendData char *  inData,
UInt32  inDataLength
[protected, inherited]
 

Send data to our socket connection. inData needs to be formatted correctly since we just send the bytes.

Parameters:
inData The data we are sending.
inDataLength The length of the data being sent.
Exceptions:
none 
Returns:
void

void CP_Object::SetID FourCharCode  inIdentifier  )  [inherited]
 

Sets the identifier for this object. If a specific identifier is not set with this function, then a default id is used, which is simply a running count of the number of objects created.

Parameters:
inIdentifier The objects identifier.
Returns:
void

FourCharCode CP_Object::GetID  )  [inherited]
 

Returns the objects identifier.

Returns:
FourCharCode The identifier of this object.

void CP_Object::RegisterSignal const CP_SignalHolder inSignal  )  [inherited]
 

Registers the signal / signal name contained in the passed in inSignal object.

Parameters:
inSignal CP_SignalHolder that holds a signal and string identifier.
Returns:
void

CP_DataValueSignal * CP_Object::FindSignal const CP_String inSignalName  )  [inherited]
 

Finds the CP_DataValueSignal object that matches the passed in inSignalName.

Parameters:
inSignalName CP_String containing the identifier of the signal to return.
Returns:
CP_DataValueSignal * Returns a pointer to a CP_DataValueSignal object.

UInt32 CP_Object::GetNumberSignals  )  [inherited]
 

Returns the number of signals for this object.

Returns:
UInt32 The number of signals.

CP_String CP_Object::GetNthSignalName UInt32  inSignalIndex  )  [inherited]
 

Returns the signal name of the passed in signal index.

Parameters:
inSignalIndex Index of the name of the signal to return.
Returns:
CP_String The name of the nth signal being returned.

void CP_Object::RegisterSlot const CP_SlotHolder inSlot  )  [inherited]
 

Registers the slot / slot name contained in the passed in inSlot object.

Parameters:
inSlot CP_SignalHolder that holds a slot and string identifier.
Returns:
void

CP_DataValueSlot CP_Object::FindSlot const CP_String inSlotName  )  [inherited]
 

Finds the CP_Slot1 object that matches the passed in inSlotName.

Parameters:
inSlotName CP_String containing the identifier of the slot to return.
Returns:
CP_DataValueSlot Returns a pointer to a CP_DataValueSlot object.

UInt32 CP_Object::GetNumberSlots  )  [inherited]
 

Returns the number of slots for this object.

Returns:
UInt32 The number of slots.

CP_String CP_Object::GetNthSlotName UInt32  inSlotIndex  )  [inherited]
 

Returns the slot name of the passed in signal index.

Parameters:
inSlotIndex Index of the name of the slot to return.
Returns:
CP_String The name of the nth slot being returned.

template<class R, class P1, class P2>
CP_CommandHandlerSignal* CP_Object::Connect CPLAT::CP_CommandNo  cmd,
void(R::*)(P1, P2)  handler,
SInt32  mode
[inherited]
 

template<class R, class P1, class P2>
void CP_Object::Connect CP_Object control,
const CPLAT::CP_String &  signalName,
void(R::*)(P1, P2)  handler
[inherited]
 

void CP_Object::Connect CP_Object sender,
const CP_String signalName,
CP_Object receiver,
const CP_String slotName,
const bool  reciprocal = false
[static, inherited]
 

void CP_Object::Connect CP_Object sender,
CP_Object receiver,
const bool  reciprocal = false,
const CP_String signalName = kCP_Signal_ValueChanged,
const CP_String slotName = kCP_Slot_SetValue
[static, inherited]
 


Member Data Documentation

UInt32 CP_FTP::fReceiveBufferSize [protected]
 

UInt32 CP_FTP::fSendBufferSize [protected]
 

Size of the buffer to hold received information.

CP_E_FTPConnectionState CP_FTP::fConnectionState [protected]
 

Size of the buffer to hold sent information.

CP_E_FTPTransferType CP_FTP::fTransferType [protected]
 

Current state of the connection.

CP_Socket* CP_NetProtoBase::fSocketConnection [protected, inherited]
 

CP_InternetResponse* CP_NetProtoBase::fLastServerResponse [protected, inherited]
 

The CP_Socket object that communicates between CPLAT and the server.

CP_DataValueSignal CP_NetProtoBase::fProgressSignal [protected, inherited]
 

This object contains the last response for the server, each different protocol class will implement its own response class to handle server responses.

CP_Signals_Array* CP_Object::fSignals [protected, inherited]
 

CP_Slots_Array* CP_Object::fSlots [protected, inherited]
 

List of registered signals for this object.

FourCharCode CP_Object::fObjectID [protected, inherited]
 

List of registered slots for this object.

CPLAT_Begin_Namespace_CPLAT FourCharCode CP_Object::fObjectIDCount = 0 [static, protected, inherited]
 

Object identifier.


The documentation for this class was generated from the following files:
Generated on Sat Sep 17 20:01:42 2005 for CPLAT by  doxygen 1.4.0