mirror of https://github.com/aria2/aria2
Add addMetalink API function
parent
24a6896bf4
commit
e5cccd335c
|
@ -227,6 +227,43 @@ int addUri(Session* session,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int addMetalink(Session* session,
|
||||||
|
std::vector<A2Gid>& gids,
|
||||||
|
const std::string& metalinkFile,
|
||||||
|
const KeyVals& options,
|
||||||
|
int position)
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_METALINK
|
||||||
|
const SharedHandle<DownloadEngine>& e =
|
||||||
|
session->context->reqinfo->getDownloadEngine();
|
||||||
|
SharedHandle<Option> requestOption(new Option(*e->getOption()));
|
||||||
|
std::vector<SharedHandle<RequestGroup> > result;
|
||||||
|
try {
|
||||||
|
apiGatherRequestOption(requestOption.get(), options,
|
||||||
|
OptionParser::getInstance());
|
||||||
|
requestOption->put(PREF_METALINK_FILE, metalinkFile);
|
||||||
|
createRequestGroupForMetalink(result, requestOption);
|
||||||
|
} catch(RecoverableException& e) {
|
||||||
|
A2_LOG_INFO_EX(EX_EXCEPTION_CAUGHT, e);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!result.empty()) {
|
||||||
|
if(position >= 0) {
|
||||||
|
e->getRequestGroupMan()->insertReservedGroup(position, result);
|
||||||
|
} else {
|
||||||
|
e->getRequestGroupMan()->addReservedGroup(result);
|
||||||
|
}
|
||||||
|
for(std::vector<SharedHandle<RequestGroup> >::const_iterator i =
|
||||||
|
result.begin(), eoi = result.end(); i != eoi; ++i) {
|
||||||
|
gids.push_back((*i)->getGID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#else // !ENABLE_METALINK
|
||||||
|
return -1;
|
||||||
|
#endif // !ENABLE_METALINK
|
||||||
|
}
|
||||||
|
|
||||||
int removeDownload(Session* session, const A2Gid& gid, bool force)
|
int removeDownload(Session* session, const A2Gid& gid, bool force)
|
||||||
{
|
{
|
||||||
const SharedHandle<DownloadEngine>& e =
|
const SharedHandle<DownloadEngine>& e =
|
||||||
|
|
|
@ -138,6 +138,20 @@ int addUri(Session* session,
|
||||||
const KeyVals& options,
|
const KeyVals& options,
|
||||||
int position = -1);
|
int position = -1);
|
||||||
|
|
||||||
|
// Adds Metalink download. The path to Metalink file is specified by
|
||||||
|
// the |metalinkFile|. On successful return, the GID of added
|
||||||
|
// download is appended to the |gids|. The |options| is a pair of
|
||||||
|
// option name and value. If the |position| is not negative integer,
|
||||||
|
// the new download is inserted at position in the waiting queue. If
|
||||||
|
// the |position| is negative or the |position| is larger than the
|
||||||
|
// size of the queue, it is appended at the end of the queue. This
|
||||||
|
// function returns 0 if it succeeds, or -1.
|
||||||
|
int addMetalink(Session* session,
|
||||||
|
std::vector<A2Gid>& gids,
|
||||||
|
const std::string& metalinkFile,
|
||||||
|
const KeyVals& options,
|
||||||
|
int position = -1);
|
||||||
|
|
||||||
// Returns the array of active download GID.
|
// Returns the array of active download GID.
|
||||||
std::vector<A2Gid> getActiveDownload(Session* session);
|
std::vector<A2Gid> getActiveDownload(Session* session);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue