#include <server.h>
Inheritance diagram for Server:
Public Member Functions | |
Server (const String &zURL, Handler *pcTarget, int nParallelConnections=2) | |
Default constructor for the Server. This initializes all the details about the server. | |
virtual | ~Server () |
Server Deconstructor. This removes the server lock and quits. The m_pcThread is cleaned up on its own when it receives the M_TT_CLOSE message. | |
int | Close () |
Close all connections. Stop all transfers, close the server connection, free curl handles, stop transfer thread, delete self. | |
int | Lock () |
Lock the Server. This acts as a mutex lock for the Server so that the internal data structures aren't corrupted due to concurrency issues. | |
int | Unlock () |
Unlock the Server. This unlocks the Server so that other items can operate on the server. | |
String | GetServerAddress () |
Returns the server address. Returns the address part of the url, eg ftp://my.ftp.com. | |
int | GetDirListing (const String &zPath, Handler *pcTarger) |
Get Directory Listing. Creates and sends a message to the m_pcThread that will cause it to download a directory listing for the given path and generate the corresponding RemoteNodes for each listing. The resulting nodes should be sent to pcTarget. | |
int | GetRemote (const String &zRemoteSource, const String &zLocalDest) |
Get Remote file. Queue a download from the remote file to the local file. | |
int | SendLocal (const String &zLocalSource, const String &zRemoteDest) |
Send a local file. Queue an upload of the given local file to the given remote file. | |
int | PauseTransfer (int nNodeID) |
Pause Transfer of a given transfer thread. This pauses the transfer with the given node id. | |
int | ResumeTransfer (int nNodeID) |
Resume Transfer of a given transfer thread. This resumes the transfer of the item with the given node id. | |
int | CancelTransfer (int nNodeID) |
Cancel Transfer of a given transfer thread. This cancels the transfer of the item with the given node id. | |
Private Member Functions | |
virtual CURLcode | _SetupCurlHandle (CURL *pHandle) |
Setup Curl Handle. This initializes the curl handler for the FTP connection. | |
Private Attributes | |
String | m_zURL |
Handler * | m_pcTarget |
TransferThread * | m_pcThread |
int | m_nParallelConnections |
std::map< int, QueueNode * > | m_apcQueue |
List of all queued and running transfers stored as a map from id numbers to QueueNode objects. The reason for using a std::map and giving each node an id number is so that the gui can refer to queue nodes by their id rather than using a pointer. Since we can't be sure that the transfer thread hasn't deleted a node while the gui is still using the pointer. | |
int | m_nNextID |
Locker * | m_pcLock |
Friends | |
class | TransferThread |
Server::~Server | ( | ) | [virtual] |
Server Deconstructor. This removes the server lock and quits. The m_pcThread is cleaned up on its own when it receives the M_TT_CLOSE message.
int Server::Lock | ( | ) |
int Server::Unlock | ( | ) |
int Server::GetDirListing | ( | const String & | zPath, | |
Handler * | pcTarget | |||
) |
Get Directory Listing. Creates and sends a message to the m_pcThread that will cause it to download a directory listing for the given path and generate the corresponding RemoteNodes for each listing. The resulting nodes should be sent to pcTarget.
zPath | The path to get a directory listing of. | |
pcTarget | The handler for the resulting nodes. |
int Server::GetRemote | ( | const String & | zRemoteSource, | |
const String & | zLocalDest | |||
) |
Get Remote file. Queue a download from the remote file to the local file.
zRemoteSource | Remote source relative to the ftp server, eg /remotedir/file | |
zLocalDest | Local destination for the file. |
int Server::SendLocal | ( | const String & | zLocalSource, | |
const String & | zRemoteDest | |||
) |
Send a local file. Queue an upload of the given local file to the given remote file.
zRemoteDest | Remote destination relative to the ftp server, eg /remotedir/file | |
zLocalSource | Local source where the local file is coming from. |
int Server::PauseTransfer | ( | int | nNodeID | ) |
Pause Transfer of a given transfer thread. This pauses the transfer with the given node id.
nNodeID | The node ID of the node to pause the transfer. |
int Server::ResumeTransfer | ( | int | nNodeID | ) |
Resume Transfer of a given transfer thread. This resumes the transfer of the item with the given node id.
nNodeID | The node ID of the thread to resume transfering. |
int Server::CancelTransfer | ( | int | nNodeID | ) |
Cancel Transfer of a given transfer thread. This cancels the transfer of the item with the given node id.
nNodeID | The node ID of the thread to cancel transfering. |
CURLcode Server::_SetupCurlHandle | ( | CURL * | pHandle | ) | [private, virtual] |
Setup Curl Handle. This initializes the curl handler for the FTP connection.
pHandle | The pointer to the CURL handle. |
String Server::m_zURL [private] |
Address of the server.
Handler* Server::m_pcTarget [private] |
The window that created us.
TransferThread* Server::m_pcThread [private] |
Our transfer thread, that does all the work.
int Server::m_nParallelConnections [private] |
Number of concurrent connections (ie curl handles) to use.
int Server::m_nNextID [private] |
Next available ID number.
Locker* Server::m_pcLock [private] |
Lock used for concurrency.