#include <mmsfiletransfer.h>
Public Member Functions | |
virtual size_t | mem_write_callback (char *buffer, size_t size, size_t nitems, void *outstream) |
Virtual function for the curl write callback. | |
MMSFiletransfer (const string url, const unsigned int ftpPort) | |
Constructor of class MMSFiletransfer. | |
virtual | ~MMSFiletransfer () |
Destructor of class MMSFiletransfer. | |
bool | performUpload (const string localfile, const string remoteName, bool resume=false) |
Performs a ftp upload for the specified local file. | |
bool | performDownload (const string localfile, const string remoteName, bool resume=false) |
Performs a ftp download for the specified remote file. | |
bool | deleteRemoteFile (const string remoteFile) |
Deletes the specified remote file. | |
bool | getListing (char **buffer, string directory, bool namesOnly=false) |
Retrieves a directory listing and writes it into the memory. | |
void | setVerboseInformation (bool enable) |
Enables verbose output of from the curl lib. | |
void | setAuthData (const string user, const string password) |
Use this to set user and password for the ftp server connection, if necessary. | |
void | setRemoteUrl (const string url) |
Changes the remote url. | |
const string | getRemoteUrl () |
Returns the current remote url. | |
void | setFtpPort (const unsigned int ftpPort) |
Sets the port for the ftp connection. | |
const unsigned int | getFtpPort () |
Returns the current ftp port. | |
void | setTimeout (const long timemout) |
Sets the timeout. | |
const long | getTimeout () |
Returns the current timeout in seconds. | |
void | setLowSpeedLimit (const long limit) |
Sets the low speed limit to be considered as timeout (default: 100 kb/s). | |
const long | getLowSpeedLimit () |
Returns the current speed limit (bytes per second) to be considered as timeout. | |
int | getLastError (string *errormsg) |
Returns the error number of the last operation, or 0 if no error has occured. | |
Public Attributes | |
sigc::signal< void, const unsigned int > | progress |
A signal that emits the progress (in percentage) of the current up- or download. | |
Private Attributes | |
CURL * | ehandle |
string | remoteUrl |
string | logindata |
CURLcode | lasterror |
long | timeout |
long | lowSpeedLimit |
unsigned int | port |
char * | buffer |
buffer to cached data from url | |
unsigned | buf_len |
buffer length | |
unsigned | buf_pos |
fill pointer within buffer |
This is a class that provides the functions to down- and upload files from/to a ftp server. As far as it is supported by the ftp server, resuming is also possible.
Definition at line 64 of file mmsfiletransfer.h.
MMSFiletransfer::MMSFiletransfer | ( | const string | url, | |
const unsigned int | ftpPort = 0 | |||
) |
Constructor of class MMSFiletransfer.
url | [in] the remote host and desired directory ("localhost/dir") |
Definition at line 99 of file mmsfiletransfer.cpp.
MMSFiletransfer::~MMSFiletransfer | ( | ) | [virtual] |
size_t MMSFiletransfer::mem_write_callback | ( | char * | buffer, | |
size_t | size, | |||
size_t | nitems, | |||
void * | outstream | |||
) | [virtual] |
bool MMSFiletransfer::performUpload | ( | const string | localfile, | |
const string | remoteName, | |||
bool | resume = false | |||
) |
Performs a ftp upload for the specified local file.
localfile | [in] the local file to be uploaded | |
remoteName | [in] name and path of the remote file | |
resume | [in] resume a prior upload |
Definition at line 143 of file mmsfiletransfer.cpp.
bool MMSFiletransfer::performDownload | ( | const string | localfile, | |
const string | remoteName, | |||
bool | resume = false | |||
) |
Performs a ftp download for the specified remote file.
localfile | [in] the local file to be saved | |
remoteName | [in] name and path of the remote file | |
resume | [in] resume a prior download |
Definition at line 197 of file mmsfiletransfer.cpp.
bool MMSFiletransfer::deleteRemoteFile | ( | const string | remoteFile | ) |
Deletes the specified remote file.
remoteFile | [in] name and path of the remote file |
Definition at line 241 of file mmsfiletransfer.cpp.
bool MMSFiletransfer::getListing | ( | char ** | buffer, | |
string | directory, | |||
bool | namesOnly = false | |||
) |
Retrieves a directory listing and writes it into the memory.
buffer | [out] pointer to a char buffer | |
directory | [in] the remote directory (path from root) | |
namesOnly | [in] flag to retrieve only the names |
Definition at line 271 of file mmsfiletransfer.cpp.
void MMSFiletransfer::setVerboseInformation | ( | bool | enable | ) |
void MMSFiletransfer::setAuthData | ( | const string | user, | |
const string | password | |||
) |
Use this to set user and password for the ftp server connection, if necessary.
user | [in] the ftp user | |
password | [in] the password |
Definition at line 134 of file mmsfiletransfer.cpp.
void MMSFiletransfer::setRemoteUrl | ( | const string | url | ) |
Changes the remote url.
The change will be performed on the following ftp operation (upload / download).
url | [in] the remote host (e.g. "127.0.0.1") |
Definition at line 301 of file mmsfiletransfer.cpp.
const string MMSFiletransfer::getRemoteUrl | ( | ) |
void MMSFiletransfer::setFtpPort | ( | const unsigned int | ftpPort | ) |
Sets the port for the ftp connection.
ftpPort | [in] The port for the ftp connection to the remote server. |
Definition at line 327 of file mmsfiletransfer.cpp.
const unsigned int MMSFiletransfer::getFtpPort | ( | ) |
void MMSFiletransfer::setTimeout | ( | const long | timemout | ) |
Sets the timeout.
timeouts | [in] The timeout in seconds. |
Definition at line 316 of file mmsfiletransfer.cpp.
const long MMSFiletransfer::getTimeout | ( | ) |
void MMSFiletransfer::setLowSpeedLimit | ( | const long | limit | ) |
Sets the low speed limit to be considered as timeout (default: 100 kb/s).
limit | [in] The low speed limit in byte per second |
Definition at line 340 of file mmsfiletransfer.cpp.
const long MMSFiletransfer::getLowSpeedLimit | ( | ) |
Returns the current speed limit (bytes per second) to be considered as timeout.
Definition at line 346 of file mmsfiletransfer.cpp.
int MMSFiletransfer::getLastError | ( | string * | errormsg = NULL |
) |
Returns the error number of the last operation, or 0 if no error has occured.
If the errormsg parameter is supplied it will be filled with a human readable errormessage.
errormsg | [out] If supplied it will be filled with an error message. |
Definition at line 351 of file mmsfiletransfer.cpp.
CURL* MMSFiletransfer::ehandle [private] |
Definition at line 67 of file mmsfiletransfer.h.
string MMSFiletransfer::remoteUrl [private] |
Definition at line 68 of file mmsfiletransfer.h.
string MMSFiletransfer::logindata [private] |
Definition at line 69 of file mmsfiletransfer.h.
CURLcode MMSFiletransfer::lasterror [private] |
Definition at line 70 of file mmsfiletransfer.h.
long MMSFiletransfer::timeout [private] |
Definition at line 71 of file mmsfiletransfer.h.
long MMSFiletransfer::lowSpeedLimit [private] |
Definition at line 72 of file mmsfiletransfer.h.
unsigned int MMSFiletransfer::port [private] |
Definition at line 73 of file mmsfiletransfer.h.
char* MMSFiletransfer::buffer [private] |
unsigned MMSFiletransfer::buf_len [private] |
unsigned MMSFiletransfer::buf_pos [private] |
sigc::signal<void, const unsigned int> MMSFiletransfer::progress |
A signal that emits the progress (in percentage) of the current up- or download.
Definition at line 87 of file mmsfiletransfer.h.