mirror of https://github.com/aria2/aria2
Add gidToString and getActiveDownload API functions
parent
9734fa5447
commit
28849e3ddf
|
@ -107,6 +107,11 @@ int run(Session* session, RUN_MODE mode)
|
||||||
return e->run(mode == RUN_ONCE);
|
return e->run(mode == RUN_ONCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string gidToString(const A2Gid& gid)
|
||||||
|
{
|
||||||
|
return GroupId::toHex(gid);
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
template<typename InputIterator, typename Pred>
|
template<typename InputIterator, typename Pred>
|
||||||
void apiGatherOption
|
void apiGatherOption
|
||||||
|
@ -182,6 +187,19 @@ int addUri(Session* session,
|
||||||
return 0;
|
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 {
|
namespace {
|
||||||
struct RequestGroupDH : public DownloadHandle {
|
struct RequestGroupDH : public DownloadHandle {
|
||||||
RequestGroupDH(const SharedHandle<RequestGroup>& group)
|
RequestGroupDH(const SharedHandle<RequestGroup>& group)
|
||||||
|
|
|
@ -106,6 +106,9 @@ enum RUN_MODE {
|
||||||
// function one or more time to complete downloads.
|
// function one or more time to complete downloads.
|
||||||
int run(Session* session, RUN_MODE mode);
|
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
|
// This method adds new HTTP(S)/FTP/BitTorrent Magnet URI. On
|
||||||
// successful return, the |gid| includes the GID of newly added
|
// successful return, the |gid| includes the GID of newly added
|
||||||
// download. The |uris| includes URI to be downloaded. For
|
// download. The |uris| includes URI to be downloaded. For
|
||||||
|
@ -124,7 +127,9 @@ int addUri(Session* session,
|
||||||
const KeyVals& options,
|
const KeyVals& options,
|
||||||
int position = -1);
|
int position = -1);
|
||||||
|
|
||||||
// Query download
|
// Returns the array of active download GID.
|
||||||
|
std::vector<A2Gid> getActiveDownload(Session* session);
|
||||||
|
|
||||||
enum DOWNLOAD_STATUS {
|
enum DOWNLOAD_STATUS {
|
||||||
DOWNLOAD_ACTIVE,
|
DOWNLOAD_ACTIVE,
|
||||||
DOWNLOAD_WAITING,
|
DOWNLOAD_WAITING,
|
||||||
|
|
Loading…
Reference in New Issue