diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-04-27 01:26:59 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-04-27 01:26:59 +0900 |
| commit | 28849e3ddf66711df375ee1c56fb5fff44b3009b (patch) | |
| tree | d567c6f72ae65720359221b006f054e34e25c4d0 | |
| parent | 9734fa5447f2e45198b347959a12b10e3d49f2ea (diff) | |
Add gidToString and getActiveDownload API functions
| -rw-r--r-- | src/aria2api.cc | 18 | ||||
| -rw-r--r-- | src/includes/aria2/aria2.h | 7 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/aria2api.cc b/src/aria2api.cc index 2943b591..e1d70e13 100644 --- a/src/aria2api.cc +++ b/src/aria2api.cc @@ -107,6 +107,11 @@ int run(Session* session, RUN_MODE mode) return e->run(mode == RUN_ONCE); } +std::string gidToString(const A2Gid& gid) +{ + return GroupId::toHex(gid); +} + namespace { template<typename InputIterator, typename Pred> void apiGatherOption @@ -182,6 +187,19 @@ int addUri(Session* session, return 0; } +std::vector<A2Gid> getActiveDownload(Session* session) +{ + const SharedHandle<DownloadEngine>& e = + session->context->reqinfo->getDownloadEngine(); + const RequestGroupList& groups = e->getRequestGroupMan()->getRequestGroups(); + std::vector<A2Gid> res; + for(RequestGroupList::const_iterator i = groups.begin(), + eoi = groups.end(); i != eoi; ++i) { + res.push_back((*i)->getGID()); + } + return res; +} + namespace { struct RequestGroupDH : public DownloadHandle { RequestGroupDH(const SharedHandle<RequestGroup>& group) diff --git a/src/includes/aria2/aria2.h b/src/includes/aria2/aria2.h index fb4a2c14..881b3974 100644 --- a/src/includes/aria2/aria2.h +++ b/src/includes/aria2/aria2.h @@ -106,6 +106,9 @@ enum RUN_MODE { // function one or more time to complete downloads. int run(Session* session, RUN_MODE mode); +// Returns textual representation of the |gid|. +std::string gidToString(const A2Gid& gid); + // This method adds new HTTP(S)/FTP/BitTorrent Magnet URI. On // successful return, the |gid| includes the GID of newly added // download. The |uris| includes URI to be downloaded. For @@ -124,7 +127,9 @@ int addUri(Session* session, const KeyVals& options, int position = -1); -// Query download +// Returns the array of active download GID. +std::vector<A2Gid> getActiveDownload(Session* session); + enum DOWNLOAD_STATUS { DOWNLOAD_ACTIVE, DOWNLOAD_WAITING, |
