mirror of
https://github.com/aria2/aria2.git
synced 2025-01-08 19:11:47 +00:00
Add gidToString and getActiveDownload API functions
This commit is contained in:
parent
9734fa5447
commit
28849e3ddf
@ -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)
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user