MMSFiletransfer Class Reference

A ftp operations class. More...

#include <mmsfiletransfer.h>

List of all members.


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

Detailed Description

A ftp operations class.

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.

Author:
Patrick Helterhoff

Definition at line 64 of file mmsfiletransfer.h.


Constructor & Destructor Documentation

MMSFiletransfer::MMSFiletransfer ( const string  url,
const unsigned int  ftpPort = 0 
)

Constructor of class MMSFiletransfer.

Parameters:
url [in] the remote host and desired directory ("localhost/dir")

Definition at line 99 of file mmsfiletransfer.cpp.

MMSFiletransfer::~MMSFiletransfer (  )  [virtual]

Destructor of class MMSFiletransfer.

Definition at line 123 of file mmsfiletransfer.cpp.


Member Function Documentation

size_t MMSFiletransfer::mem_write_callback ( char *  buffer,
size_t  size,
size_t  nitems,
void *  outstream 
) [virtual]

Virtual function for the curl write callback.

Definition at line 64 of file mmsfiletransfer.cpp.

bool MMSFiletransfer::performUpload ( const string  localfile,
const string  remoteName,
bool  resume = false 
)

Performs a ftp upload for the specified local file.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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  ) 

Enables verbose output of from the curl lib.

Definition at line 129 of file mmsfiletransfer.cpp.

void MMSFiletransfer::setAuthData ( const string  user,
const string  password 
)

Use this to set user and password for the ftp server connection, if necessary.

Parameters:
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).

Parameters:
url [in] the remote host (e.g. "127.0.0.1")

Definition at line 301 of file mmsfiletransfer.cpp.

const string MMSFiletransfer::getRemoteUrl (  ) 

Returns the current remote url.

Definition at line 311 of file mmsfiletransfer.cpp.

void MMSFiletransfer::setFtpPort ( const unsigned int  ftpPort  ) 

Sets the port for the ftp connection.

Parameters:
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 (  ) 

Returns the current ftp port.

Definition at line 335 of file mmsfiletransfer.cpp.

void MMSFiletransfer::setTimeout ( const long  timemout  ) 

Sets the timeout.

Parameters:
timeouts [in] The timeout in seconds.

Definition at line 316 of file mmsfiletransfer.cpp.

const long MMSFiletransfer::getTimeout (  ) 

Returns the current timeout in seconds.

Definition at line 322 of file mmsfiletransfer.cpp.

void MMSFiletransfer::setLowSpeedLimit ( const long  limit  ) 

Sets the low speed limit to be considered as timeout (default: 100 kb/s).

Parameters:
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.

Parameters:
errormsg [out] If supplied it will be filled with an error message.
Returns:
the errornumber or 0

Definition at line 351 of file mmsfiletransfer.cpp.


Member Data Documentation

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.

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]

buffer to cached data from url

Definition at line 76 of file mmsfiletransfer.h.

unsigned MMSFiletransfer::buf_len [private]

buffer length

Definition at line 79 of file mmsfiletransfer.h.

unsigned MMSFiletransfer::buf_pos [private]

fill pointer within buffer

Definition at line 82 of file mmsfiletransfer.h.

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.


The documentation for this class was generated from the following files: