mirror of https://github.com/aria2/aria2
2009-05-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added addMetalink XML-RPC command. * src/XmlRpcMethodFactory.cc * src/XmlRpcMethodImpl.cc * src/XmlRpcMethodImpl.h * src/download_helper.cc * src/download_helper.hpull/1/head
parent
eb0cb42c72
commit
cbaf0619d9
|
@ -1,3 +1,12 @@
|
||||||
|
2009-05-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Added addMetalink XML-RPC command.
|
||||||
|
* src/XmlRpcMethodFactory.cc
|
||||||
|
* src/XmlRpcMethodImpl.cc
|
||||||
|
* src/XmlRpcMethodImpl.h
|
||||||
|
* src/download_helper.cc
|
||||||
|
* src/download_helper.h
|
||||||
|
|
||||||
2009-05-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-05-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Fixed the bug that POU peers are never choked in seeding.
|
Fixed the bug that POU peers are never choked in seeding.
|
||||||
|
|
|
@ -48,6 +48,8 @@ XmlRpcMethodFactory::create(const std::string& methodName)
|
||||||
return SharedHandle<XmlRpcMethod>(new AddUriXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new AddUriXmlRpcMethod());
|
||||||
} else if(methodName == "aria2.addTorrent") {
|
} else if(methodName == "aria2.addTorrent") {
|
||||||
return SharedHandle<XmlRpcMethod>(new AddTorrentXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new AddTorrentXmlRpcMethod());
|
||||||
|
} else if(methodName == "aria2.addMetalink") {
|
||||||
|
return SharedHandle<XmlRpcMethod>(new AddMetalinkXmlRpcMethod());
|
||||||
} else if(methodName == "aria2.remove") {
|
} else if(methodName == "aria2.remove") {
|
||||||
return SharedHandle<XmlRpcMethod>(new RemoveXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new RemoveXmlRpcMethod());
|
||||||
} else if(methodName == "aria2.tellStatus") {
|
} else if(methodName == "aria2.tellStatus") {
|
||||||
|
|
|
@ -140,6 +140,37 @@ BDE AddTorrentXmlRpcMethod::process
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BDE AddMetalinkXmlRpcMethod::process
|
||||||
|
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
|
{
|
||||||
|
const BDE& params = req._params;
|
||||||
|
assert(params.isList());
|
||||||
|
if(params.empty() || !params[0].isString()) {
|
||||||
|
throw DlAbortEx("Metalink data is not provided.");
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedHandle<Option> requestOption(new Option(*e->option));
|
||||||
|
if(params.size() > 1 && params[1].isDict()) {
|
||||||
|
gatherRequestOption(requestOption, params[1]);
|
||||||
|
}
|
||||||
|
std::deque<SharedHandle<RequestGroup> > result;
|
||||||
|
createRequestGroupForMetalink(result, requestOption, params[0].s());
|
||||||
|
if(!result.empty()) {
|
||||||
|
e->_requestGroupMan->addReservedGroup(result);
|
||||||
|
BDE resParams = BDE::list();
|
||||||
|
BDE gids = BDE::list();
|
||||||
|
for(std::deque<SharedHandle<RequestGroup> >::const_iterator i =
|
||||||
|
result.begin(); i != result.end(); ++i) {
|
||||||
|
gids << BDE(Util::itos((*i)->getGID()));
|
||||||
|
}
|
||||||
|
resParams << gids;
|
||||||
|
return resParams;
|
||||||
|
} else {
|
||||||
|
throw DlAbortEx("No files to download.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
const BDE& params = req._params;
|
const BDE& params = req._params;
|
||||||
|
|
|
@ -56,6 +56,11 @@ protected:
|
||||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AddMetalinkXmlRpcMethod:public XmlRpcMethod {
|
||||||
|
protected:
|
||||||
|
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||||
|
};
|
||||||
|
|
||||||
class GetUrisXmlRpcMethod:public XmlRpcMethod {
|
class GetUrisXmlRpcMethod:public XmlRpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "array_fun.h"
|
#include "array_fun.h"
|
||||||
#include "OptionHandler.h"
|
#include "OptionHandler.h"
|
||||||
|
#include "ByteArrayDiskWriter.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -252,11 +253,18 @@ void createRequestGroupForBitTorrent
|
||||||
#ifdef ENABLE_METALINK
|
#ifdef ENABLE_METALINK
|
||||||
void createRequestGroupForMetalink
|
void createRequestGroupForMetalink
|
||||||
(std::deque<SharedHandle<RequestGroup> >& result,
|
(std::deque<SharedHandle<RequestGroup> >& result,
|
||||||
const SharedHandle<Option>& option)
|
const SharedHandle<Option>& option,
|
||||||
|
const std::string& metalinkData)
|
||||||
{
|
{
|
||||||
Metalink2RequestGroup().generate(result,
|
if(metalinkData.empty()) {
|
||||||
option->get(PREF_METALINK_FILE),
|
Metalink2RequestGroup().generate(result,
|
||||||
option);
|
option->get(PREF_METALINK_FILE),
|
||||||
|
option);
|
||||||
|
} else {
|
||||||
|
SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter());
|
||||||
|
dw->setString(metalinkData);
|
||||||
|
Metalink2RequestGroup().generate(result, dw, option);
|
||||||
|
}
|
||||||
if(result.empty()) {
|
if(result.empty()) {
|
||||||
throw DlAbortEx(MSG_NO_FILES_TO_DOWNLOAD);
|
throw DlAbortEx(MSG_NO_FILES_TO_DOWNLOAD);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,8 @@ const std::vector<std::string>& listRequestOptions();
|
||||||
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
// Create RequestGroup object using torrent file specified by
|
// Create RequestGroup object using torrent file specified by
|
||||||
// torrent-file option. If torrentData is specified, then it is used
|
// torrent-file option. If non-empty torrentData is specified, then
|
||||||
// as a content of torrent file in stead. In this function,
|
// it is used as a content of torrent file instead. In this function,
|
||||||
// force-sequential is ignored.
|
// force-sequential is ignored.
|
||||||
void createRequestGroupForBitTorrent
|
void createRequestGroupForBitTorrent
|
||||||
(std::deque<SharedHandle<RequestGroup> >& result,
|
(std::deque<SharedHandle<RequestGroup> >& result,
|
||||||
|
@ -63,11 +63,13 @@ void createRequestGroupForBitTorrent
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
|
||||||
#ifdef ENABLE_METALINK
|
#ifdef ENABLE_METALINK
|
||||||
// Create RequestGroup objects using Metalink file specified by metalink-file
|
// Create RequestGroup objects using Metalink file specified by
|
||||||
// option.
|
// metalink-file option. If non-empty metalinkData is specified, it is
|
||||||
|
// used as a content of metalink file instead.
|
||||||
void createRequestGroupForMetalink
|
void createRequestGroupForMetalink
|
||||||
(std::deque<SharedHandle<RequestGroup> >& result,
|
(std::deque<SharedHandle<RequestGroup> >& result,
|
||||||
const SharedHandle<Option>& option);
|
const SharedHandle<Option>& option,
|
||||||
|
const std::string& metalinkData = "");
|
||||||
#endif // ENABLE_METALINK
|
#endif // ENABLE_METALINK
|
||||||
|
|
||||||
// Create RequestGroup objects from reading file specified by input-file option.
|
// Create RequestGroup objects from reading file specified by input-file option.
|
||||||
|
|
Loading…
Reference in New Issue