Class Download

Class Documentation

class Download

A representation of a current download.

Download is not thread safe. User must care to not call method on a same download from different threads. However, it is safe to use different Downloads from different threads.

Public Types

enum StatusResult

Values:

enumerator K_ACTIVE
enumerator K_WAITING
enumerator K_PAUSED
enumerator K_ERROR
enumerator K_COMPLETE
enumerator K_REMOVED
enumerator K_UNKNOWN

Public Functions

inline Download()
inline Download(std::shared_ptr<Aria2> p_aria, std::string did)
void updateStatus(bool follow)

Update the status of the download.

This call make an aria rpc call and is blocking. Some download (started with a metalink) are in fact several downloads.

  • A first one to download the metadlink.

  • A second one to download the real file.

If follow is true, updateStatus tries to detect that and tracks the second download when the first one is finished. By passing false to follow, Download will only track the first download.

getFoo methods are based on the last statusUpdate.

Parameters:

follow – Do we have to follow following downloads.

void pauseDownload()

Pause the download (and call updateStatus)

void resumeDownload()

Resume the download (and call updateStatus)

void cancelDownload()

Cancel the download.

A canceled downlod cannot be resume and updateStatus does nothing. However, you can still get information based on the last known information.

inline StatusResult getStatus() const
inline const std::string &getDid() const
inline const std::string &getFollowedBy() const
inline uint64_t getTotalLength() const
inline uint64_t getCompletedLength() const
inline uint64_t getDownloadSpeed() const
inline uint64_t getVerifiedLength() const
inline const std::string &getPath() const
inline const std::vector<std::string> &getUris() const

Protected Attributes

std::shared_ptr<Aria2> mp_aria
StatusResult m_status
std::string m_did = ""
std::string m_followedBy = ""
uint64_t m_totalLength
uint64_t m_completedLength
uint64_t m_downloadSpeed
uint64_t m_verifiedLength
std::vector<std::string> m_uris
std::string m_path