libwfut  0.2.3
Public Member Functions | Public Attributes | List of all members
WFUT::WFUTClient Class Reference

#include <WFUT.h>

Public Member Functions

WFUTError init ()
 
WFUTError shutdown ()
 
void updateChannel (const ChannelFileList &updates, const std::string &urlPrefix, const std::string &pathPrefix)
 
void updateFile (const FileObject &file, const std::string &urlPrefix, const std::string &pathPrefix)
 
WFUTError getMirrorList (const std::string &url, MirrorList &mirrors)
 
WFUTError getChannelList (const std::string &url, ChannelList &channels)
 
WFUTError getFileList (const std::string &url, ChannelFileList &files)
 
WFUTError getLocalList (const std::string &filename, ChannelFileList &files)
 
WFUTError saveLocalList (const ChannelFileList &files, const std::string &filename)
 
WFUTError calculateUpdates (const ChannelFileList &server, const ChannelFileList &system, const ChannelFileList &local, ChannelFileList &updates, const std::string &prefix)
 
int poll ()
 
void abortAll ()
 
void abortDownload (const std::string &filename)
 

Public Attributes

sigc::signal< void, const std::string &, const std::string & > DownloadComplete
 
sigc::signal< void, const std::string &, const std::string &, const std::string & > DownloadFailed
 
sigc::signal< void, const std::string &, const WFUTUpdateReason > UpdateReason
 

Detailed Description

The WFUTClient class should be the main class that client applications use. It wraps up the underlying function calls. The IO class may be of more interest to those looking for more direct control of downloads. The channel listings and channel file lists arae downloaded as a blocking function. It is expected that such files are quick to download. The main files to download are processed in chunks and progress through repeated calls to the poll function. It is intended that for a given channel, there will be a system version. These will be in a read-only location and may have been installed as part of a system packge. There will be a user writable location, referred to as the local version. The server version is the file stored on the remote web server.

Member Function Documentation

void WFUT::WFUTClient::abortAll ( )

Abort all current and pending downloads. The DownloadFailed signal will be fired with an "Aborted" message.

References WFUT::IO::abortAll().

void WFUT::WFUTClient::abortDownload ( const std::string &  filename)

Abort specified current or pending downloa . The DownloadFailed signal will be fired with an "Aborted" message.

References WFUT::IO::abortDownload().

WFUTError WFUT::WFUTClient::calculateUpdates ( const ChannelFileList server,
const ChannelFileList system,
const ChannelFileList local,
ChannelFileList updates,
const std::string &  prefix 
)

This function takes three sets of channel file lists and calculates which files need updating. The server list is the server side file list. The system list is intended for data stored in a read only location. This may be empty i no such location exists. The local list is the list of files stored in a writable location. This may be empty if no files have yet been downloaded. The updates list is the list of FileObjects in the server list that require downloading. The prefix argument is the path prefix to the local files so that the CRC32 value maybe checked. This process also doubles up to check to see if local files have been deleted and need re-downloading.

References WFUT::ChannelFileList::addFile(), WFUT::ChannelFileList::getFiles(), and UpdateReason.

WFUTError WFUT::WFUTClient::getChannelList ( const std::string &  url,
ChannelList &  channels 
)

This function directly download and parses a channel listings file from the specified URL. This function will block until complete. This is the file that lists all the channels that are available at a that location.

References WFUT::IO::downloadFile().

WFUTError WFUT::WFUTClient::getFileList ( const std::string &  url,
ChannelFileList files 
)

This function will download a channel file from the specified URL. This function will block until complete. This is the wfut.xml file.

References WFUT::IO::downloadFile().

WFUTError WFUT::WFUTClient::getLocalList ( const std::string &  filename,
ChannelFileList files 
)

This function will parse a local channel file from the given filename * This can be used for both the local and system file lists.

WFUTError WFUT::WFUTClient::getMirrorList ( const std::string &  url,
MirrorList &  mirrors 
)

This function retrieves a list of mirrors from the given url. These mirrors will be the root url.

References WFUT::IO::downloadFile().

WFUTError WFUT::WFUTClient::init ( )

Initialise the WFUT object. This in turn will call IO::init which will initialise curl.

References WFUT::IO::DownloadComplete, WFUT::IO::DownloadFailed, and WFUT::IO::init().

int WFUT::WFUTClient::poll ( )

The poll function is used to perform a chunk of downloading. This means that it needs to be called frequently. It returns the number of files still being downloaded. It will return 0 when all files have finished downloading.

References WFUT::IO::poll().

WFUTError WFUT::WFUTClient::saveLocalList ( const ChannelFileList files,
const std::string &  filename 
)

This function will save a channel file list to the given filename. This should be called once all files have finished downloading to create the local file list.

WFUTError WFUT::WFUTClient::shutdown ( )

Clean up the WFUT object. This will in turn call IO::shutdown which will cleanup curl

References WFUT::IO::shutdown().

void WFUT::WFUTClient::updateChannel ( const ChannelFileList updates,
const std::string &  urlPrefix,
const std::string &  pathPrefix 
)

This function queues a list of files to download. The urlPrefix is prefixed to the FileObject filename to find the server side version. The pathPrefix is prefixed to the FileObject filename to determine the client side file location. The poll function must be called to perform the downloading and the DownloadComplete and DownloadFailed signals can be used to track the result of each file download. The updates channel name is appended to the urlPrefix.

References WFUT::ChannelFileList::getFiles(), WFUT::ChannelFileList::getName(), and WFUT::IO::queueFile().

void WFUT::WFUTClient::updateFile ( const FileObject file,
const std::string &  urlPrefix,
const std::string &  pathPrefix 
)

This function is similar to updateChannel, except it takes a single FileObject, rather than a whole list.

References WFUT::IO::queueFile().

Member Data Documentation

sigc::signal<void, const std::string&, const std::string&> WFUT::WFUTClient::DownloadComplete

The DownloadComplete signal is fired every time a file is successfully downloaded. The first argument is the source url and the second argument is the filename from the FileObject.

sigc::signal<void, const std::string&, const std::string&, const std::string&> WFUT::WFUTClient::DownloadFailed

The DownloadFailed signal is fired when there was a problem downloading a file. This could happen due to a broken url, or a problem saving the file in the temp location, or copying it from the tmp location to the destination. The first argument is the source url and the second argument is the filename from the FileObject. The third argument is a message indicating a general reason why the download failed.

sigc::signal<void, const std::string&, const WFUTUpdateReason> WFUT::WFUTClient::UpdateReason

The UpdateReason signal is fired every time a FileObject is processed in the calculateUpdates function. If WFUT_UPDATE_MODIFIED is passed as a reason code, then this file has not been added to the updates list because there are modifications to the local file. If an update is required, this file can be manually added to the updates list.

Referenced by calculateUpdates().


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