Add gidToString and getActiveDownload API functions

This commit is contained in:
Tatsuhiro Tsujikawa 2013-04-27 01:26:59 +09:00
parent 9734fa5447
commit 28849e3ddf
2 changed files with 24 additions and 1 deletions

View File

@ -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)

View File

@ -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,