mirror of https://github.com/aria2/aria2
Renamed classes in abstract layer of RPC service from XmlRpc* to Rpc*.
Now JSON-RPC is available by default regardless of XML library. XML-RPC becomes available when XML library is available.pull/1/head
parent
5a1fb3875f
commit
f0cfbb21c1
|
@ -72,9 +72,7 @@
|
||||||
#include "SelectEventPoll.h"
|
#include "SelectEventPoll.h"
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
#include "FileAllocationEntry.h"
|
#include "FileAllocationEntry.h"
|
||||||
#ifdef ENABLE_XML_RPC
|
|
||||||
#include "HttpListenCommand.h"
|
#include "HttpListenCommand.h"
|
||||||
#endif // ENABLE_XML_RPC
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -165,7 +163,6 @@ DownloadEngineFactory::newDownloadEngine
|
||||||
stopSec));
|
stopSec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_XML_RPC
|
|
||||||
if(op->getAsBool(PREF_ENABLE_XML_RPC)) {
|
if(op->getAsBool(PREF_ENABLE_XML_RPC)) {
|
||||||
static int families[] = { AF_INET, AF_INET6 };
|
static int families[] = { AF_INET, AF_INET6 };
|
||||||
size_t familiesLength = op->getAsBool(PREF_DISABLE_IPV6)?1:2;
|
size_t familiesLength = op->getAsBool(PREF_DISABLE_IPV6)?1:2;
|
||||||
|
@ -179,7 +176,6 @@ DownloadEngineFactory::newDownloadEngine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_XML_RPC
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct SessionData {
|
struct SessionData {
|
||||||
|
@ -104,7 +104,7 @@ void mlCharacters(void* userData, const char* ch, int len)
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
XmlRpcRequest
|
RpcRequest
|
||||||
XmlRpcRequestProcessor::parseMemory(const std::string& xml)
|
XmlRpcRequestProcessor::parseMemory(const std::string& xml)
|
||||||
{
|
{
|
||||||
stm_.reset(new XmlRpcRequestParserStateMachine());
|
stm_.reset(new XmlRpcRequestParserStateMachine());
|
||||||
|
@ -125,10 +125,10 @@ XmlRpcRequestProcessor::parseMemory(const std::string& xml)
|
||||||
if(!asList(stm_->getCurrentFrameValue())) {
|
if(!asList(stm_->getCurrentFrameValue())) {
|
||||||
throw DL_ABORT_EX("Bad XML-RPC parameter list");
|
throw DL_ABORT_EX("Bad XML-RPC parameter list");
|
||||||
}
|
}
|
||||||
return XmlRpcRequest(stm_->getMethodName(),
|
return RpcRequest(stm_->getMethodName(),
|
||||||
static_pointer_cast<List>(stm_->getCurrentFrameValue()));
|
static_pointer_cast<List>(stm_->getCurrentFrameValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -40,11 +40,11 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "XmlRpcRequest.h"
|
#include "RpcRequest.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
class XmlRpcRequestParserStateMachine;
|
class XmlRpcRequestParserStateMachine;
|
||||||
|
|
||||||
|
@ -52,10 +52,10 @@ class XmlRpcRequestProcessor {
|
||||||
private:
|
private:
|
||||||
SharedHandle<XmlRpcRequestParserStateMachine> stm_;
|
SharedHandle<XmlRpcRequestParserStateMachine> stm_;
|
||||||
public:
|
public:
|
||||||
XmlRpcRequest parseMemory(const std::string& xml);
|
RpcRequest parseMemory(const std::string& xml);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,6 @@
|
||||||
#include "HttpServerResponseCommand.h"
|
#include "HttpServerResponseCommand.h"
|
||||||
#include "OptionParser.h"
|
#include "OptionParser.h"
|
||||||
#include "OptionHandler.h"
|
#include "OptionHandler.h"
|
||||||
#include "XmlRpcRequestProcessor.h"
|
|
||||||
#include "XmlRpcRequestParserStateMachine.h"
|
|
||||||
#include "XmlRpcMethod.h"
|
|
||||||
#include "XmlRpcMethodFactory.h"
|
|
||||||
#include "XmlRpcResponse.h"
|
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
@ -57,6 +52,14 @@
|
||||||
#include "json.h"
|
#include "json.h"
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
#include "RpcMethod.h"
|
||||||
|
#include "RpcMethodFactory.h"
|
||||||
|
#include "RpcRequest.h"
|
||||||
|
#include "RpcResponse.h"
|
||||||
|
#ifdef ENABLE_XML_RPC
|
||||||
|
# include "XmlRpcRequestProcessor.h"
|
||||||
|
# include "XmlRpcRequestParserStateMachine.h"
|
||||||
|
#endif // ENABLE_XML_RPC
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -84,7 +87,7 @@ HttpServerBodyCommand::~HttpServerBodyCommand()
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
xmlrpc::XmlRpcResponse
|
rpc::RpcResponse
|
||||||
createJsonRpcErrorResponse
|
createJsonRpcErrorResponse
|
||||||
(int code,
|
(int code,
|
||||||
const std::string& msg,
|
const std::string& msg,
|
||||||
|
@ -93,13 +96,13 @@ createJsonRpcErrorResponse
|
||||||
SharedHandle<Dict> params = Dict::g();
|
SharedHandle<Dict> params = Dict::g();
|
||||||
params->put("code", Integer::g(code));
|
params->put("code", Integer::g(code));
|
||||||
params->put("message", msg);
|
params->put("message", msg);
|
||||||
xmlrpc::XmlRpcResponse res(code, params, id);
|
rpc::RpcResponse res(code, params, id);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void HttpServerBodyCommand::sendJsonRpcResponse
|
void HttpServerBodyCommand::sendJsonRpcResponse
|
||||||
(const xmlrpc::XmlRpcResponse& res,
|
(const rpc::RpcResponse& res,
|
||||||
const std::string& callback)
|
const std::string& callback)
|
||||||
{
|
{
|
||||||
bool gzip = httpServer_->supportsGZip();
|
bool gzip = httpServer_->supportsGZip();
|
||||||
|
@ -126,11 +129,11 @@ void HttpServerBodyCommand::sendJsonRpcResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpServerBodyCommand::sendJsonRpcBatchResponse
|
void HttpServerBodyCommand::sendJsonRpcBatchResponse
|
||||||
(const std::vector<xmlrpc::XmlRpcResponse>& results,
|
(const std::vector<rpc::RpcResponse>& results,
|
||||||
const std::string& callback)
|
const std::string& callback)
|
||||||
{
|
{
|
||||||
bool gzip = httpServer_->supportsGZip();
|
bool gzip = httpServer_->supportsGZip();
|
||||||
std::string responseData = xmlrpc::toJsonBatch(results, callback, gzip);
|
std::string responseData = rpc::toJsonBatch(results, callback, gzip);
|
||||||
httpServer_->feedResponse(responseData, "application/json-rpc");
|
httpServer_->feedResponse(responseData, "application/json-rpc");
|
||||||
addHttpServerResponseCommand();
|
addHttpServerResponseCommand();
|
||||||
}
|
}
|
||||||
|
@ -143,7 +146,7 @@ void HttpServerBodyCommand::addHttpServerResponseCommand()
|
||||||
e_->setNoWait(true);
|
e_->setNoWait(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlrpc::XmlRpcResponse
|
rpc::RpcResponse
|
||||||
HttpServerBodyCommand::processJsonRpcRequest(const Dict* jsondict)
|
HttpServerBodyCommand::processJsonRpcRequest(const Dict* jsondict)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -165,16 +168,16 @@ HttpServerBodyCommand::processJsonRpcRequest(const Dict* jsondict)
|
||||||
// TODO No support for Named params
|
// TODO No support for Named params
|
||||||
return createJsonRpcErrorResponse(-32602, "Invalid params.", id);
|
return createJsonRpcErrorResponse(-32602, "Invalid params.", id);
|
||||||
}
|
}
|
||||||
xmlrpc::XmlRpcRequest req(methodName->s(), params, id);
|
rpc::RpcRequest req(methodName->s(), params, id);
|
||||||
SharedHandle<xmlrpc::XmlRpcMethod> method;
|
SharedHandle<rpc::RpcMethod> method;
|
||||||
try {
|
try {
|
||||||
method = xmlrpc::XmlRpcMethodFactory::create(req.methodName);
|
method = rpc::RpcMethodFactory::create(req.methodName);
|
||||||
} catch(RecoverableException& e) {
|
} catch(RecoverableException& e) {
|
||||||
A2_LOG_INFO_EX(EX_EXCEPTION_CAUGHT, e);
|
A2_LOG_INFO_EX(EX_EXCEPTION_CAUGHT, e);
|
||||||
return createJsonRpcErrorResponse(-32601, "Method not found.", id);
|
return createJsonRpcErrorResponse(-32601, "Method not found.", id);
|
||||||
}
|
}
|
||||||
method->setJsonRpc(true);
|
method->setJsonRpc(true);
|
||||||
xmlrpc::XmlRpcResponse res = method->execute(req, e_);
|
rpc::RpcResponse res = method->execute(req, e_);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,16 +203,17 @@ bool HttpServerBodyCommand::execute()
|
||||||
reqPath.erase(reqPath.size()-query.size(), query.size());
|
reqPath.erase(reqPath.size()-query.size(), query.size());
|
||||||
// Do something for requestpath and body
|
// Do something for requestpath and body
|
||||||
if(reqPath == "/rpc") {
|
if(reqPath == "/rpc") {
|
||||||
xmlrpc::XmlRpcRequest req =
|
#ifdef ENABLE_XML_RPC
|
||||||
xmlrpc::XmlRpcRequestProcessor().parseMemory(httpServer_->getBody());
|
rpc::RpcRequest req =
|
||||||
|
rpc::XmlRpcRequestProcessor().parseMemory(httpServer_->getBody());
|
||||||
SharedHandle<xmlrpc::XmlRpcMethod> method =
|
SharedHandle<rpc::RpcMethod> method =
|
||||||
xmlrpc::XmlRpcMethodFactory::create(req.methodName);
|
rpc::RpcMethodFactory::create(req.methodName);
|
||||||
xmlrpc::XmlRpcResponse res = method->execute(req, e_);
|
rpc::RpcResponse res = method->execute(req, e_);
|
||||||
bool gzip = httpServer_->supportsGZip();
|
bool gzip = httpServer_->supportsGZip();
|
||||||
std::string responseData = res.toXml(gzip);
|
std::string responseData = res.toXml(gzip);
|
||||||
httpServer_->feedResponse(responseData, "text/xml");
|
httpServer_->feedResponse(responseData, "text/xml");
|
||||||
addHttpServerResponseCommand();
|
addHttpServerResponseCommand();
|
||||||
|
#endif // ENABLE_XML_RPC
|
||||||
return true;
|
return true;
|
||||||
} else if(reqPath == "/jsonrpc") {
|
} else if(reqPath == "/jsonrpc") {
|
||||||
std::string callback;
|
std::string callback;
|
||||||
|
@ -227,7 +231,7 @@ bool HttpServerBodyCommand::execute()
|
||||||
(fmt("CUID#%lld - Failed to parse JSON-RPC request",
|
(fmt("CUID#%lld - Failed to parse JSON-RPC request",
|
||||||
getCuid()),
|
getCuid()),
|
||||||
e);
|
e);
|
||||||
xmlrpc::XmlRpcResponse res
|
rpc::RpcResponse res
|
||||||
(createJsonRpcErrorResponse
|
(createJsonRpcErrorResponse
|
||||||
(-32700, "Parse error.", SharedHandle<ValueBase>()));
|
(-32700, "Parse error.", SharedHandle<ValueBase>()));
|
||||||
sendJsonRpcResponse(res, callback);
|
sendJsonRpcResponse(res, callback);
|
||||||
|
@ -235,24 +239,24 @@ bool HttpServerBodyCommand::execute()
|
||||||
}
|
}
|
||||||
const Dict* jsondict = asDict(json);
|
const Dict* jsondict = asDict(json);
|
||||||
if(jsondict) {
|
if(jsondict) {
|
||||||
xmlrpc::XmlRpcResponse res = processJsonRpcRequest(jsondict);
|
rpc::RpcResponse res = processJsonRpcRequest(jsondict);
|
||||||
sendJsonRpcResponse(res, callback);
|
sendJsonRpcResponse(res, callback);
|
||||||
} else {
|
} else {
|
||||||
const List* jsonlist = asList(json);
|
const List* jsonlist = asList(json);
|
||||||
if(jsonlist) {
|
if(jsonlist) {
|
||||||
// This is batch call
|
// This is batch call
|
||||||
std::vector<xmlrpc::XmlRpcResponse> results;
|
std::vector<rpc::RpcResponse> results;
|
||||||
for(List::ValueType::const_iterator i = jsonlist->begin(),
|
for(List::ValueType::const_iterator i = jsonlist->begin(),
|
||||||
eoi = jsonlist->end(); i != eoi; ++i) {
|
eoi = jsonlist->end(); i != eoi; ++i) {
|
||||||
const Dict* jsondict = asDict(*i);
|
const Dict* jsondict = asDict(*i);
|
||||||
if(jsondict) {
|
if(jsondict) {
|
||||||
xmlrpc::XmlRpcResponse r = processJsonRpcRequest(jsondict);
|
rpc::RpcResponse r = processJsonRpcRequest(jsondict);
|
||||||
results.push_back(r);
|
results.push_back(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendJsonRpcBatchResponse(results, callback);
|
sendJsonRpcBatchResponse(results, callback);
|
||||||
} else {
|
} else {
|
||||||
xmlrpc::XmlRpcResponse res
|
rpc::RpcResponse res
|
||||||
(createJsonRpcErrorResponse
|
(createJsonRpcErrorResponse
|
||||||
(-32600, "Invalid Request.", SharedHandle<ValueBase>()));
|
(-32600, "Invalid Request.", SharedHandle<ValueBase>()));
|
||||||
sendJsonRpcResponse(res, callback);
|
sendJsonRpcResponse(res, callback);
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "TimerA2.h"
|
#include "TimerA2.h"
|
||||||
#include "ValueBase.h"
|
#include "ValueBase.h"
|
||||||
#include "XmlRpcResponse.h"
|
#include "RpcResponse.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -60,12 +60,12 @@ private:
|
||||||
const SharedHandle<ValueBase>& id,
|
const SharedHandle<ValueBase>& id,
|
||||||
const std::string& callback);
|
const std::string& callback);
|
||||||
void sendJsonRpcResponse
|
void sendJsonRpcResponse
|
||||||
(const xmlrpc::XmlRpcResponse& res,
|
(const rpc::RpcResponse& res,
|
||||||
const std::string& callback);
|
const std::string& callback);
|
||||||
void sendJsonRpcBatchResponse
|
void sendJsonRpcBatchResponse
|
||||||
(const std::vector<xmlrpc::XmlRpcResponse>& results,
|
(const std::vector<rpc::RpcResponse>& results,
|
||||||
const std::string& callback);
|
const std::string& callback);
|
||||||
xmlrpc::XmlRpcResponse processJsonRpcRequest(const Dict* jsondict);
|
rpc::RpcResponse processJsonRpcRequest(const Dict* jsondict);
|
||||||
void addHttpServerResponseCommand();
|
void addHttpServerResponseCommand();
|
||||||
public:
|
public:
|
||||||
HttpServerBodyCommand(cuid_t cuid,
|
HttpServerBodyCommand(cuid_t cuid,
|
||||||
|
|
|
@ -211,7 +211,17 @@ SRCS = Socket.h\
|
||||||
uri.cc uri.h\
|
uri.cc uri.h\
|
||||||
Triplet.h\
|
Triplet.h\
|
||||||
cookie_helper.cc cookie_helper.h\
|
cookie_helper.cc cookie_helper.h\
|
||||||
json.cc json.h
|
json.cc json.h\
|
||||||
|
HttpServerBodyCommand.cc HttpServerBodyCommand.h\
|
||||||
|
RpcRequest.cc RpcRequest.h\
|
||||||
|
RpcMethod.cc RpcMethod.h\
|
||||||
|
RpcMethodImpl.cc RpcMethodImpl.h\
|
||||||
|
RpcMethodFactory.cc RpcMethodFactory.h\
|
||||||
|
RpcResponse.cc RpcResponse.h\
|
||||||
|
HttpListenCommand.cc HttpListenCommand.h\
|
||||||
|
HttpServerCommand.cc HttpServerCommand.h\
|
||||||
|
HttpServerResponseCommand.cc HttpServerResponseCommand.h\
|
||||||
|
HttpServer.cc HttpServer.h
|
||||||
|
|
||||||
if ENABLE_XML_RPC
|
if ENABLE_XML_RPC
|
||||||
SRCS += XmlRpcRequestParserController.cc XmlRpcRequestParserController.h\
|
SRCS += XmlRpcRequestParserController.cc XmlRpcRequestParserController.h\
|
||||||
|
@ -219,17 +229,7 @@ SRCS += XmlRpcRequestParserController.cc XmlRpcRequestParserController.h\
|
||||||
XmlRpcRequestParserState.h\
|
XmlRpcRequestParserState.h\
|
||||||
XmlRpcRequestParserStateImpl.cc XmlRpcRequestParserStateImpl.h\
|
XmlRpcRequestParserStateImpl.cc XmlRpcRequestParserStateImpl.h\
|
||||||
XmlRpcElements.cc XmlRpcElements.h\
|
XmlRpcElements.cc XmlRpcElements.h\
|
||||||
XmlRpcRequest.cc XmlRpcRequest.h\
|
XmlRpcRequestProcessor.h
|
||||||
XmlRpcRequestProcessor.h\
|
|
||||||
HttpServerBodyCommand.cc HttpServerBodyCommand.h\
|
|
||||||
XmlRpcMethod.cc XmlRpcMethod.h\
|
|
||||||
XmlRpcMethodImpl.cc XmlRpcMethodImpl.h\
|
|
||||||
XmlRpcMethodFactory.cc XmlRpcMethodFactory.h\
|
|
||||||
XmlRpcResponse.cc XmlRpcResponse.h\
|
|
||||||
HttpListenCommand.cc HttpListenCommand.h\
|
|
||||||
HttpServerCommand.cc HttpServerCommand.h\
|
|
||||||
HttpServerResponseCommand.cc HttpServerResponseCommand.h\
|
|
||||||
HttpServer.cc HttpServer.h
|
|
||||||
|
|
||||||
if HAVE_LIBXML2
|
if HAVE_LIBXML2
|
||||||
SRCS += Xml2XmlRpcRequestProcessor.cc Xml2XmlRpcRequestProcessor.h
|
SRCS += Xml2XmlRpcRequestProcessor.cc Xml2XmlRpcRequestProcessor.h
|
||||||
|
|
|
@ -228,7 +228,6 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_DIRECT_IO
|
#endif // ENABLE_DIRECT_IO
|
||||||
#ifdef ENABLE_XML_RPC
|
|
||||||
{
|
{
|
||||||
SharedHandle<OptionHandler> op(new BooleanOptionHandler
|
SharedHandle<OptionHandler> op(new BooleanOptionHandler
|
||||||
(PREF_ENABLE_XML_RPC,
|
(PREF_ENABLE_XML_RPC,
|
||||||
|
@ -238,7 +237,6 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
||||||
op->addTag(TAG_XML_RPC);
|
op->addTag(TAG_XML_RPC);
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_XML_RPC
|
|
||||||
{
|
{
|
||||||
std::string params[] = {
|
std::string params[] = {
|
||||||
#ifdef HAVE_EPOLL
|
#ifdef HAVE_EPOLL
|
||||||
|
@ -568,7 +566,6 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
||||||
op->addTag(TAG_ADVANCED);
|
op->addTag(TAG_ADVANCED);
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_XML_RPC
|
|
||||||
{
|
{
|
||||||
SharedHandle<OptionHandler> op(new BooleanOptionHandler
|
SharedHandle<OptionHandler> op(new BooleanOptionHandler
|
||||||
(PREF_XML_RPC_LISTEN_ALL,
|
(PREF_XML_RPC_LISTEN_ALL,
|
||||||
|
@ -610,7 +607,6 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
||||||
op->addTag(TAG_XML_RPC);
|
op->addTag(TAG_XML_RPC);
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_XML_RPC
|
|
||||||
// HTTP/FTP options
|
// HTTP/FTP options
|
||||||
{
|
{
|
||||||
SharedHandle<OptionHandler> op(new NumberOptionHandler
|
SharedHandle<OptionHandler> op(new NumberOptionHandler
|
||||||
|
|
|
@ -100,11 +100,9 @@ RequestGroupMan::~RequestGroupMan() {}
|
||||||
|
|
||||||
bool RequestGroupMan::downloadFinished()
|
bool RequestGroupMan::downloadFinished()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_XML_RPC
|
|
||||||
if(xmlRpc_) {
|
if(xmlRpc_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif // ENABLE_XML_RPC
|
|
||||||
return requestGroups_.empty() && reservedGroups_.empty();
|
return requestGroups_.empty() && reservedGroups_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
* files in the program, then also delete it here.
|
* files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "XmlRpcMethod.h"
|
#include "RpcMethod.h"
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
#include "RecoverableException.h"
|
#include "RecoverableException.h"
|
||||||
|
@ -42,24 +42,24 @@
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "array_fun.h"
|
#include "array_fun.h"
|
||||||
#include "download_helper.h"
|
#include "download_helper.h"
|
||||||
#include "XmlRpcRequest.h"
|
#include "RpcRequest.h"
|
||||||
#include "XmlRpcResponse.h"
|
#include "RpcResponse.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
XmlRpcMethod::XmlRpcMethod()
|
RpcMethod::RpcMethod()
|
||||||
: optionParser_(OptionParser::getInstance()),
|
: optionParser_(OptionParser::getInstance()),
|
||||||
jsonRpc_(false)
|
jsonRpc_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
XmlRpcMethod::~XmlRpcMethod() {}
|
RpcMethod::~RpcMethod() {}
|
||||||
|
|
||||||
SharedHandle<ValueBase> XmlRpcMethod::createErrorResponse
|
SharedHandle<ValueBase> RpcMethod::createErrorResponse
|
||||||
(const Exception& e)
|
(const Exception& e)
|
||||||
{
|
{
|
||||||
SharedHandle<Dict> params = Dict::g();
|
SharedHandle<Dict> params = Dict::g();
|
||||||
|
@ -68,14 +68,14 @@ SharedHandle<ValueBase> XmlRpcMethod::createErrorResponse
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlRpcResponse XmlRpcMethod::execute
|
RpcResponse RpcMethod::execute
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return XmlRpcResponse(0, process(req, e), req.id);
|
return RpcResponse(0, process(req, e), req.id);
|
||||||
} catch(RecoverableException& e) {
|
} catch(RecoverableException& e) {
|
||||||
A2_LOG_DEBUG_EX(EX_EXCEPTION_CAUGHT, e);
|
A2_LOG_DEBUG_EX(EX_EXCEPTION_CAUGHT, e);
|
||||||
return XmlRpcResponse(1, createErrorResponse(e), req.id);
|
return RpcResponse(1, createErrorResponse(e), req.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ void gatherOption
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void XmlRpcMethod::gatherRequestOption
|
void RpcMethod::gatherRequestOption
|
||||||
(const SharedHandle<Option>& option, const Dict* optionsDict)
|
(const SharedHandle<Option>& option, const Dict* optionsDict)
|
||||||
{
|
{
|
||||||
if(optionsDict) {
|
if(optionsDict) {
|
||||||
|
@ -162,7 +162,7 @@ const std::set<std::string>& listChangeableOptions()
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethod::gatherChangeableOption
|
void RpcMethod::gatherChangeableOption
|
||||||
(const SharedHandle<Option>& option, const Dict* optionsDict)
|
(const SharedHandle<Option>& option, const Dict* optionsDict)
|
||||||
{
|
{
|
||||||
if(optionsDict) {
|
if(optionsDict) {
|
||||||
|
@ -172,7 +172,7 @@ void XmlRpcMethod::gatherChangeableOption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethod::applyChangeableOption(Option* dest, Option* src) const
|
void RpcMethod::applyChangeableOption(Option* dest, Option* src) const
|
||||||
{
|
{
|
||||||
applyOption(listChangeableOptions().begin(), listChangeableOptions().end(),
|
applyOption(listChangeableOptions().begin(), listChangeableOptions().end(),
|
||||||
dest, src);
|
dest, src);
|
||||||
|
@ -191,7 +191,7 @@ const std::set<std::string>& listChangeableGlobalOptions()
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethod::gatherChangeableGlobalOption
|
void RpcMethod::gatherChangeableGlobalOption
|
||||||
(const SharedHandle<Option>& option, const Dict* optionsDict)
|
(const SharedHandle<Option>& option, const Dict* optionsDict)
|
||||||
{
|
{
|
||||||
if(optionsDict) {
|
if(optionsDict) {
|
||||||
|
@ -201,13 +201,13 @@ void XmlRpcMethod::gatherChangeableGlobalOption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethod::applyChangeableGlobalOption(Option* dest, Option* src) const
|
void RpcMethod::applyChangeableGlobalOption(Option* dest, Option* src) const
|
||||||
{
|
{
|
||||||
applyOption(listChangeableGlobalOptions().begin(),
|
applyOption(listChangeableGlobalOptions().begin(),
|
||||||
listChangeableGlobalOptions().end(),
|
listChangeableGlobalOptions().end(),
|
||||||
dest, src);
|
dest, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
|
@ -32,8 +32,8 @@
|
||||||
* files in the program, then also delete it here.
|
* files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#ifndef D_XML_RPC_METHOD_H
|
#ifndef D_RPC_METHOD_H
|
||||||
#define D_XML_RPC_METHOD_H
|
#define D_RPC_METHOD_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
@ -49,28 +49,28 @@ class OptionParser;
|
||||||
class Option;
|
class Option;
|
||||||
class Exception;
|
class Exception;
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
struct XmlRpcRequest;
|
struct RpcRequest;
|
||||||
struct XmlRpcResponse;
|
struct RpcResponse;
|
||||||
|
|
||||||
// This class offers abstract implementation of processing XML-RPC
|
// This class offers abstract implementation of processing RPC
|
||||||
// request. You have to inherit this class and implement process()
|
// request. You have to inherit this class and implement process()
|
||||||
// method to add new XML-RPC API.
|
// method to add new RPC API.
|
||||||
//
|
//
|
||||||
// There is XmlRpcMethodFactory class which instantiates XmlRpcMethod
|
// There is RpcMethodFactory class which instantiates RpcMethod
|
||||||
// subclass. If you add new XmlRpcMethod subclass, don't forget to add
|
// subclass. If you add new RpcMethod subclass, don't forget to add it
|
||||||
// it to XmlRpcMethodFactory.
|
// to RpcMethodFactory.
|
||||||
class XmlRpcMethod {
|
class RpcMethod {
|
||||||
private:
|
private:
|
||||||
SharedHandle<OptionParser> optionParser_;
|
SharedHandle<OptionParser> optionParser_;
|
||||||
bool jsonRpc_;
|
bool jsonRpc_;
|
||||||
protected:
|
protected:
|
||||||
// Subclass must implement this function to fulfil XmlRpcRequest
|
// Subclass must implement this function to fulfil RpcRequest req.
|
||||||
// req. The return value of this method is used as a return value
|
// The return value of this method is used as a return value of RPC
|
||||||
// of XML-RPC request.
|
// request.
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e) = 0;
|
(const RpcRequest& req, DownloadEngine* e) = 0;
|
||||||
|
|
||||||
void gatherRequestOption
|
void gatherRequestOption
|
||||||
(const SharedHandle<Option>& option, const Dict* optionsDict);
|
(const SharedHandle<Option>& option, const Dict* optionsDict);
|
||||||
|
@ -78,14 +78,14 @@ protected:
|
||||||
void gatherChangeableOption
|
void gatherChangeableOption
|
||||||
(const SharedHandle<Option>& option, const Dict* optionDict);
|
(const SharedHandle<Option>& option, const Dict* optionDict);
|
||||||
|
|
||||||
// Copy options which is changeable in XML-RPC changeOption command
|
// Copy options which is changeable in RPC changeOption command to
|
||||||
// to dest.
|
// dest.
|
||||||
void applyChangeableOption(Option* dest, Option* src) const;
|
void applyChangeableOption(Option* dest, Option* src) const;
|
||||||
|
|
||||||
void gatherChangeableGlobalOption(const SharedHandle<Option>& option,
|
void gatherChangeableGlobalOption(const SharedHandle<Option>& option,
|
||||||
const Dict* optionDict);
|
const Dict* optionDict);
|
||||||
|
|
||||||
// Copy options which is changeable in XML-RPC changeGlobalOption
|
// Copy options which is changeable in RPC changeGlobalOption
|
||||||
// command to dest.
|
// command to dest.
|
||||||
void applyChangeableGlobalOption(Option* dest, Option* src) const;
|
void applyChangeableGlobalOption(Option* dest, Option* src) const;
|
||||||
|
|
||||||
|
@ -96,13 +96,13 @@ protected:
|
||||||
return optionParser_;
|
return optionParser_;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
XmlRpcMethod();
|
RpcMethod();
|
||||||
|
|
||||||
virtual ~XmlRpcMethod();
|
virtual ~RpcMethod();
|
||||||
|
|
||||||
// Do work to fulfill XmlRpcRequest req and returns its result as
|
// Do work to fulfill RpcRequest req and returns its result as
|
||||||
// XmlRpcResponse. This method delegates to process() method.
|
// RpcResponse. This method delegates to process() method.
|
||||||
XmlRpcResponse execute(const XmlRpcRequest& req, DownloadEngine* e);
|
RpcResponse execute(const RpcRequest& req, DownloadEngine* e);
|
||||||
// Set whether JSON-RPC style parameter handling.
|
// Set whether JSON-RPC style parameter handling.
|
||||||
void setJsonRpc(bool f)
|
void setJsonRpc(bool f)
|
||||||
{
|
{
|
||||||
|
@ -114,8 +114,8 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
#endif // D_XML_RPC_METHOD_H
|
#endif // D_RPC_METHOD_H
|
|
@ -0,0 +1,127 @@
|
||||||
|
/* <!-- copyright */
|
||||||
|
/*
|
||||||
|
* aria2 - The high speed download utility
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Tatsuhiro Tsujikawa
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give
|
||||||
|
* permission to link the code of portions of this program with the
|
||||||
|
* OpenSSL library under certain conditions as described in each
|
||||||
|
* individual source file, and distribute linked combinations
|
||||||
|
* including the two.
|
||||||
|
* You must obey the GNU General Public License in all respects
|
||||||
|
* for all of the code used other than OpenSSL. If you modify
|
||||||
|
* file(s) with this exception, you may extend this exception to your
|
||||||
|
* version of the file(s), but you are not obligated to do so. If you
|
||||||
|
* do not wish to do so, delete this exception statement from your
|
||||||
|
* version. If you delete this exception statement from all source
|
||||||
|
* files in the program, then also delete it here.
|
||||||
|
*/
|
||||||
|
/* copyright --> */
|
||||||
|
#include "RpcMethodFactory.h"
|
||||||
|
#include "RpcMethodImpl.h"
|
||||||
|
#include "OptionParser.h"
|
||||||
|
#include "OptionHandler.h"
|
||||||
|
|
||||||
|
namespace aria2 {
|
||||||
|
|
||||||
|
namespace rpc {
|
||||||
|
|
||||||
|
SharedHandle<RpcMethod>
|
||||||
|
RpcMethodFactory::create(const std::string& methodName)
|
||||||
|
{
|
||||||
|
if(methodName == AddUriRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new AddUriRpcMethod());
|
||||||
|
#ifdef ENABLE_BITTORRENT
|
||||||
|
} else if(methodName == AddTorrentRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new AddTorrentRpcMethod());
|
||||||
|
#endif // ENABLE_BITTORRENT
|
||||||
|
#ifdef ENABLE_METALINK
|
||||||
|
}
|
||||||
|
else if(methodName == AddMetalinkRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new AddMetalinkRpcMethod());
|
||||||
|
#endif // ENABLE_METALINK
|
||||||
|
}
|
||||||
|
else if(methodName == RemoveRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new RemoveRpcMethod());
|
||||||
|
} else if(methodName == PauseRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new PauseRpcMethod());
|
||||||
|
} else if(methodName == ForcePauseRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new ForcePauseRpcMethod());
|
||||||
|
} else if(methodName == PauseAllRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new PauseAllRpcMethod());
|
||||||
|
} else if(methodName == ForcePauseAllRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new ForcePauseAllRpcMethod());
|
||||||
|
} else if(methodName == UnpauseRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new UnpauseRpcMethod());
|
||||||
|
} else if(methodName == UnpauseAllRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new UnpauseAllRpcMethod());
|
||||||
|
} else if(methodName == ForceRemoveRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new ForceRemoveRpcMethod());
|
||||||
|
} else if(methodName == ChangePositionRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new ChangePositionRpcMethod());
|
||||||
|
} else if(methodName == TellStatusRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new TellStatusRpcMethod());
|
||||||
|
} else if(methodName == GetUrisRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new GetUrisRpcMethod());
|
||||||
|
} else if(methodName == GetFilesRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new GetFilesRpcMethod());
|
||||||
|
#ifdef ENABLE_BITTORRENT
|
||||||
|
}
|
||||||
|
else if(methodName == GetPeersRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new GetPeersRpcMethod());
|
||||||
|
#endif // ENABLE_BITTORRENT
|
||||||
|
} else if(methodName == GetServersRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new GetServersRpcMethod());
|
||||||
|
} else if(methodName == TellActiveRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new TellActiveRpcMethod());
|
||||||
|
} else if(methodName == TellWaitingRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new TellWaitingRpcMethod());
|
||||||
|
} else if(methodName == TellStoppedRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new TellStoppedRpcMethod());
|
||||||
|
} else if(methodName == GetOptionRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new GetOptionRpcMethod());
|
||||||
|
} else if(methodName == ChangeUriRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new ChangeUriRpcMethod());
|
||||||
|
} else if(methodName == ChangeOptionRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new ChangeOptionRpcMethod());
|
||||||
|
} else if(methodName == GetGlobalOptionRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new GetGlobalOptionRpcMethod());
|
||||||
|
} else if(methodName == ChangeGlobalOptionRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new ChangeGlobalOptionRpcMethod());
|
||||||
|
} else if(methodName == PurgeDownloadResultRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new PurgeDownloadResultRpcMethod());
|
||||||
|
} else if(methodName == RemoveDownloadResultRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new RemoveDownloadResultRpcMethod());
|
||||||
|
} else if(methodName == GetVersionRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new GetVersionRpcMethod());
|
||||||
|
} else if(methodName == GetSessionInfoRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new GetSessionInfoRpcMethod());
|
||||||
|
} else if(methodName == ShutdownRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new ShutdownRpcMethod());
|
||||||
|
} else if(methodName == ForceShutdownRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new ForceShutdownRpcMethod());
|
||||||
|
} else if(methodName == SystemMulticallRpcMethod::getMethodName()) {
|
||||||
|
return SharedHandle<RpcMethod>(new SystemMulticallRpcMethod());
|
||||||
|
} else {
|
||||||
|
return SharedHandle<RpcMethod>(new NoSuchMethodRpcMethod());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace rpc
|
||||||
|
|
||||||
|
} // namespace aria2
|
|
@ -32,8 +32,8 @@
|
||||||
* files in the program, then also delete it here.
|
* files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#ifndef D_XML_RPC_METHOD_FACTORY_H
|
#ifndef D_RPC_METHOD_FACTORY_H
|
||||||
#define D_XML_RPC_METHOD_FACTORY_H
|
#define D_RPC_METHOD_FACTORY_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
@ -43,17 +43,17 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
class XmlRpcMethod;
|
class RpcMethod;
|
||||||
|
|
||||||
class XmlRpcMethodFactory {
|
class RpcMethodFactory {
|
||||||
public:
|
public:
|
||||||
static SharedHandle<XmlRpcMethod> create(const std::string& methodName);
|
static SharedHandle<RpcMethod> create(const std::string& methodName);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
#endif // D_XML_RPC_METHOD_FACTORY_H
|
#endif // D_RPC_METHOD_FACTORY_H
|
|
@ -32,7 +32,7 @@
|
||||||
* files in the program, then also delete it here.
|
* files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "XmlRpcMethodImpl.h"
|
#include "RpcMethodImpl.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
#include "XmlRpcRequest.h"
|
#include "RpcRequest.h"
|
||||||
#include "PieceStorage.h"
|
#include "PieceStorage.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "DiskAdaptor.h"
|
#include "DiskAdaptor.h"
|
||||||
|
@ -58,8 +58,8 @@
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "FeatureConfig.h"
|
#include "FeatureConfig.h"
|
||||||
#include "array_fun.h"
|
#include "array_fun.h"
|
||||||
#include "XmlRpcMethodFactory.h"
|
#include "RpcMethodFactory.h"
|
||||||
#include "XmlRpcResponse.h"
|
#include "RpcResponse.h"
|
||||||
#include "SegmentMan.h"
|
#include "SegmentMan.h"
|
||||||
#include "TimedHaltCommand.h"
|
#include "TimedHaltCommand.h"
|
||||||
#include "PeerStat.h"
|
#include "PeerStat.h"
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const SharedHandle<String> VLB_TRUE = String::g("true");
|
const SharedHandle<String> VLB_TRUE = String::g("true");
|
||||||
|
@ -173,7 +173,7 @@ findRequestGroup(const SharedHandle<RequestGroupMan>& rgman, gid_t gid)
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void getPosParam(const XmlRpcRequest& req, size_t posParamIndex,
|
void getPosParam(const RpcRequest& req, size_t posParamIndex,
|
||||||
bool& posGiven, size_t& pos)
|
bool& posGiven, size_t& pos)
|
||||||
{
|
{
|
||||||
const Integer* p = req.getIntegerParam(posParamIndex);
|
const Integer* p = req.getIntegerParam(posParamIndex);
|
||||||
|
@ -192,7 +192,7 @@ void getPosParam(const XmlRpcRequest& req, size_t posParamIndex,
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
gid_t getRequiredGidParam
|
gid_t getRequiredGidParam
|
||||||
(const XmlRpcRequest& req, size_t posParamIndex)
|
(const RpcRequest& req, size_t posParamIndex)
|
||||||
{
|
{
|
||||||
const String* gidParam = req.getStringParam(posParamIndex);
|
const String* gidParam = req.getStringParam(posParamIndex);
|
||||||
if(gidParam) {
|
if(gidParam) {
|
||||||
|
@ -219,8 +219,8 @@ void extractUris(OutputIterator out, const List* src)
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
SharedHandle<ValueBase> AddUriXmlRpcMethod::process
|
SharedHandle<ValueBase> AddUriRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
std::vector<std::string> uris;
|
std::vector<std::string> uris;
|
||||||
extractUris(std::back_inserter(uris), req.getListParam(0));
|
extractUris(std::back_inserter(uris), req.getListParam(0));
|
||||||
|
@ -260,8 +260,8 @@ std::string getHexSha1(const std::string& s)
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
SharedHandle<ValueBase> AddTorrentXmlRpcMethod::process
|
SharedHandle<ValueBase> AddTorrentRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
const String* torrentParam = req.getStringParam(0);
|
const String* torrentParam = req.getStringParam(0);
|
||||||
if(!torrentParam) {
|
if(!torrentParam) {
|
||||||
|
@ -307,8 +307,8 @@ SharedHandle<ValueBase> AddTorrentXmlRpcMethod::process
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
|
||||||
#ifdef ENABLE_METALINK
|
#ifdef ENABLE_METALINK
|
||||||
SharedHandle<ValueBase> AddMetalinkXmlRpcMethod::process
|
SharedHandle<ValueBase> AddMetalinkRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
const String* metalinkParam = req.getStringParam(0);
|
const String* metalinkParam = req.getStringParam(0);
|
||||||
if(!metalinkParam) {
|
if(!metalinkParam) {
|
||||||
|
@ -362,7 +362,7 @@ SharedHandle<ValueBase> AddMetalinkXmlRpcMethod::process
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
SharedHandle<ValueBase> removeDownload
|
SharedHandle<ValueBase> removeDownload
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e, bool forceRemove)
|
(const RpcRequest& req, DownloadEngine* e, bool forceRemove)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
|
|
||||||
|
@ -393,14 +393,14 @@ SharedHandle<ValueBase> removeDownload
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
SharedHandle<ValueBase> RemoveXmlRpcMethod::process
|
SharedHandle<ValueBase> RemoveRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
return removeDownload(req, e, false);
|
return removeDownload(req, e, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> ForceRemoveXmlRpcMethod::process
|
SharedHandle<ValueBase> ForceRemoveRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
return removeDownload(req, e, true);
|
return removeDownload(req, e, true);
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ bool pauseRequestGroup
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
SharedHandle<ValueBase> pauseDownload
|
SharedHandle<ValueBase> pauseDownload
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e, bool forcePause)
|
(const RpcRequest& req, DownloadEngine* e, bool forcePause)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
|
|
||||||
|
@ -454,14 +454,14 @@ SharedHandle<ValueBase> pauseDownload
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
SharedHandle<ValueBase> PauseXmlRpcMethod::process
|
SharedHandle<ValueBase> PauseRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
return pauseDownload(req, e, false);
|
return pauseDownload(req, e, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> ForcePauseXmlRpcMethod::process
|
SharedHandle<ValueBase> ForcePauseRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
return pauseDownload(req, e, true);
|
return pauseDownload(req, e, true);
|
||||||
}
|
}
|
||||||
|
@ -479,7 +479,7 @@ void pauseRequestGroups
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
SharedHandle<ValueBase> pauseAllDownloads
|
SharedHandle<ValueBase> pauseAllDownloads
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e, bool forcePause)
|
(const RpcRequest& req, DownloadEngine* e, bool forcePause)
|
||||||
{
|
{
|
||||||
const std::deque<SharedHandle<RequestGroup> >& groups =
|
const std::deque<SharedHandle<RequestGroup> >& groups =
|
||||||
e->getRequestGroupMan()->getRequestGroups();
|
e->getRequestGroupMan()->getRequestGroups();
|
||||||
|
@ -492,20 +492,20 @@ SharedHandle<ValueBase> pauseAllDownloads
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
SharedHandle<ValueBase> PauseAllXmlRpcMethod::process
|
SharedHandle<ValueBase> PauseAllRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
return pauseAllDownloads(req, e, false);
|
return pauseAllDownloads(req, e, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> ForcePauseAllXmlRpcMethod::process
|
SharedHandle<ValueBase> ForcePauseAllRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
return pauseAllDownloads(req, e, true);
|
return pauseAllDownloads(req, e, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> UnpauseXmlRpcMethod::process
|
SharedHandle<ValueBase> UnpauseRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
SharedHandle<RequestGroup> group =
|
SharedHandle<RequestGroup> group =
|
||||||
|
@ -521,8 +521,8 @@ SharedHandle<ValueBase> UnpauseXmlRpcMethod::process
|
||||||
return createGIDResponse(gid);
|
return createGIDResponse(gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> UnpauseAllXmlRpcMethod::process
|
SharedHandle<ValueBase> UnpauseAllRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
const std::deque<SharedHandle<RequestGroup> >& groups =
|
const std::deque<SharedHandle<RequestGroup> >& groups =
|
||||||
e->getRequestGroupMan()->getReservedGroups();
|
e->getRequestGroupMan()->getReservedGroups();
|
||||||
|
@ -862,8 +862,8 @@ void gatherStoppedDownload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> GetFilesXmlRpcMethod::process
|
SharedHandle<ValueBase> GetFilesRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
SharedHandle<List> files = List::g();
|
SharedHandle<List> files = List::g();
|
||||||
|
@ -887,8 +887,8 @@ SharedHandle<ValueBase> GetFilesXmlRpcMethod::process
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> GetUrisXmlRpcMethod::process
|
SharedHandle<ValueBase> GetUrisRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
SharedHandle<RequestGroup> group =
|
SharedHandle<RequestGroup> group =
|
||||||
|
@ -907,8 +907,8 @@ SharedHandle<ValueBase> GetUrisXmlRpcMethod::process
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
SharedHandle<ValueBase> GetPeersXmlRpcMethod::process
|
SharedHandle<ValueBase> GetPeersRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
|
|
||||||
|
@ -929,8 +929,8 @@ SharedHandle<ValueBase> GetPeersXmlRpcMethod::process
|
||||||
}
|
}
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
|
||||||
SharedHandle<ValueBase> TellStatusXmlRpcMethod::process
|
SharedHandle<ValueBase> TellStatusRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
|
|
||||||
|
@ -972,8 +972,8 @@ SharedHandle<ValueBase> TellStatusXmlRpcMethod::process
|
||||||
return entryDict;
|
return entryDict;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> TellActiveXmlRpcMethod::process
|
SharedHandle<ValueBase> TellActiveRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
const List* keysParam = req.getListParam(0);
|
const List* keysParam = req.getListParam(0);
|
||||||
std::vector<std::string> keys;
|
std::vector<std::string> keys;
|
||||||
|
@ -994,12 +994,12 @@ SharedHandle<ValueBase> TellActiveXmlRpcMethod::process
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::deque<SharedHandle<RequestGroup> >&
|
const std::deque<SharedHandle<RequestGroup> >&
|
||||||
TellWaitingXmlRpcMethod::getItems(DownloadEngine* e) const
|
TellWaitingRpcMethod::getItems(DownloadEngine* e) const
|
||||||
{
|
{
|
||||||
return e->getRequestGroupMan()->getReservedGroups();
|
return e->getRequestGroupMan()->getReservedGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TellWaitingXmlRpcMethod::createEntry
|
void TellWaitingRpcMethod::createEntry
|
||||||
(const SharedHandle<Dict>& entryDict,
|
(const SharedHandle<Dict>& entryDict,
|
||||||
const SharedHandle<RequestGroup>& item,
|
const SharedHandle<RequestGroup>& item,
|
||||||
DownloadEngine* e,
|
DownloadEngine* e,
|
||||||
|
@ -1016,12 +1016,12 @@ void TellWaitingXmlRpcMethod::createEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::deque<SharedHandle<DownloadResult> >&
|
const std::deque<SharedHandle<DownloadResult> >&
|
||||||
TellStoppedXmlRpcMethod::getItems(DownloadEngine* e) const
|
TellStoppedRpcMethod::getItems(DownloadEngine* e) const
|
||||||
{
|
{
|
||||||
return e->getRequestGroupMan()->getDownloadResults();
|
return e->getRequestGroupMan()->getDownloadResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TellStoppedXmlRpcMethod::createEntry
|
void TellStoppedRpcMethod::createEntry
|
||||||
(const SharedHandle<Dict>& entryDict,
|
(const SharedHandle<Dict>& entryDict,
|
||||||
const SharedHandle<DownloadResult>& item,
|
const SharedHandle<DownloadResult>& item,
|
||||||
DownloadEngine* e,
|
DownloadEngine* e,
|
||||||
|
@ -1030,15 +1030,15 @@ void TellStoppedXmlRpcMethod::createEntry
|
||||||
gatherStoppedDownload(entryDict, item, keys);
|
gatherStoppedDownload(entryDict, item, keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> PurgeDownloadResultXmlRpcMethod::process
|
SharedHandle<ValueBase> PurgeDownloadResultRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
e->getRequestGroupMan()->purgeDownloadResult();
|
e->getRequestGroupMan()->purgeDownloadResult();
|
||||||
return VLB_OK;
|
return VLB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> RemoveDownloadResultXmlRpcMethod::process
|
SharedHandle<ValueBase> RemoveDownloadResultRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
if(!e->getRequestGroupMan()->removeDownloadResult(gid)) {
|
if(!e->getRequestGroupMan()->removeDownloadResult(gid)) {
|
||||||
|
@ -1049,8 +1049,8 @@ SharedHandle<ValueBase> RemoveDownloadResultXmlRpcMethod::process
|
||||||
return VLB_OK;
|
return VLB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> ChangeOptionXmlRpcMethod::process
|
SharedHandle<ValueBase> ChangeOptionRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
|
|
||||||
|
@ -1085,8 +1085,8 @@ SharedHandle<ValueBase> ChangeOptionXmlRpcMethod::process
|
||||||
return VLB_OK;
|
return VLB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> ChangeGlobalOptionXmlRpcMethod::process
|
SharedHandle<ValueBase> ChangeGlobalOptionRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
const Dict* optionsParam = req.getDictParam(0);
|
const Dict* optionsParam = req.getDictParam(0);
|
||||||
if(!optionsParam) {
|
if(!optionsParam) {
|
||||||
|
@ -1124,8 +1124,8 @@ SharedHandle<ValueBase> ChangeGlobalOptionXmlRpcMethod::process
|
||||||
return VLB_OK;
|
return VLB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> GetVersionXmlRpcMethod::process
|
SharedHandle<ValueBase> GetVersionRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
SharedHandle<Dict> result = Dict::g();
|
SharedHandle<Dict> result = Dict::g();
|
||||||
result->put(KEY_VERSION, PACKAGE_VERSION);
|
result->put(KEY_VERSION, PACKAGE_VERSION);
|
||||||
|
@ -1156,8 +1156,8 @@ void pushRequestOption
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
SharedHandle<ValueBase> GetOptionXmlRpcMethod::process
|
SharedHandle<ValueBase> GetOptionRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
|
|
||||||
|
@ -1174,8 +1174,8 @@ SharedHandle<ValueBase> GetOptionXmlRpcMethod::process
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> GetGlobalOptionXmlRpcMethod::process
|
SharedHandle<ValueBase> GetGlobalOptionRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
SharedHandle<Dict> result = Dict::g();
|
SharedHandle<Dict> result = Dict::g();
|
||||||
for(std::map<std::string, std::string>::const_iterator i =
|
for(std::map<std::string, std::string>::const_iterator i =
|
||||||
|
@ -1188,8 +1188,8 @@ SharedHandle<ValueBase> GetGlobalOptionXmlRpcMethod::process
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> ChangePositionXmlRpcMethod::process
|
SharedHandle<ValueBase> ChangePositionRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
const Integer* posParam = req.getIntegerParam(1);
|
const Integer* posParam = req.getIntegerParam(1);
|
||||||
|
@ -1216,16 +1216,16 @@ SharedHandle<ValueBase> ChangePositionXmlRpcMethod::process
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> GetSessionInfoXmlRpcMethod::process
|
SharedHandle<ValueBase> GetSessionInfoRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
SharedHandle<Dict> result = Dict::g();
|
SharedHandle<Dict> result = Dict::g();
|
||||||
result->put(KEY_SESSION_ID, util::toHex(e->getSessionId()));
|
result->put(KEY_SESSION_ID, util::toHex(e->getSessionId()));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> GetServersXmlRpcMethod::process
|
SharedHandle<ValueBase> GetServersRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
SharedHandle<RequestGroup> group =
|
SharedHandle<RequestGroup> group =
|
||||||
|
@ -1263,8 +1263,8 @@ SharedHandle<ValueBase> GetServersXmlRpcMethod::process
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> ChangeUriXmlRpcMethod::process
|
SharedHandle<ValueBase> ChangeUriRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
gid_t gid = getRequiredGidParam(req, 0);
|
gid_t gid = getRequiredGidParam(req, 0);
|
||||||
const Integer* indexParam = req.getIntegerParam(1);
|
const Integer* indexParam = req.getIntegerParam(1);
|
||||||
|
@ -1332,30 +1332,30 @@ SharedHandle<ValueBase> ChangeUriXmlRpcMethod::process
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
SharedHandle<ValueBase> goingShutdown
|
SharedHandle<ValueBase> goingShutdown
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e, bool forceHalt)
|
(const RpcRequest& req, DownloadEngine* e, bool forceHalt)
|
||||||
{
|
{
|
||||||
// Schedule shutdown after 3seconds to give time to client to
|
// Schedule shutdown after 3seconds to give time to client to
|
||||||
// receive XML-RPC response.
|
// receive RPC response.
|
||||||
e->addRoutineCommand(new TimedHaltCommand(e->newCUID(), e, 3, forceHalt));
|
e->addRoutineCommand(new TimedHaltCommand(e->newCUID(), e, 3, forceHalt));
|
||||||
A2_LOG_INFO("Scheduled shutdown in 3 seconds.");
|
A2_LOG_INFO("Scheduled shutdown in 3 seconds.");
|
||||||
return VLB_OK;
|
return VLB_OK;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
SharedHandle<ValueBase> ShutdownXmlRpcMethod::process
|
SharedHandle<ValueBase> ShutdownRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
return goingShutdown(req, e, false);
|
return goingShutdown(req, e, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> ForceShutdownXmlRpcMethod::process
|
SharedHandle<ValueBase> ForceShutdownRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
return goingShutdown(req, e, true);
|
return goingShutdown(req, e, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> SystemMulticallXmlRpcMethod::process
|
SharedHandle<ValueBase> SystemMulticallRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
const List* methodSpecs = req.getListParam(0);
|
const List* methodSpecs = req.getListParam(0);
|
||||||
if(!methodSpecs) {
|
if(!methodSpecs) {
|
||||||
|
@ -1383,11 +1383,11 @@ SharedHandle<ValueBase> SystemMulticallXmlRpcMethod::process
|
||||||
(DL_ABORT_EX("Recursive system.multicall forbidden.")));
|
(DL_ABORT_EX("Recursive system.multicall forbidden.")));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SharedHandle<XmlRpcMethod> method =
|
SharedHandle<RpcMethod> method =
|
||||||
XmlRpcMethodFactory::create(methodName->s());
|
RpcMethodFactory::create(methodName->s());
|
||||||
XmlRpcRequest innerReq
|
RpcRequest innerReq
|
||||||
(methodName->s(), static_pointer_cast<List>(methodDict->get(KEY_PARAMS)));
|
(methodName->s(), static_pointer_cast<List>(methodDict->get(KEY_PARAMS)));
|
||||||
XmlRpcResponse res = method->execute(innerReq, e);
|
RpcResponse res = method->execute(innerReq, e);
|
||||||
if(res.code == 0) {
|
if(res.code == 0) {
|
||||||
SharedHandle<List> l = List::g();
|
SharedHandle<List> l = List::g();
|
||||||
l->append(res.param);
|
l->append(res.param);
|
||||||
|
@ -1399,12 +1399,12 @@ SharedHandle<ValueBase> SystemMulticallXmlRpcMethod::process
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<ValueBase> NoSuchMethodXmlRpcMethod::process
|
SharedHandle<ValueBase> NoSuchMethodRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
throw DL_ABORT_EX(fmt("No such method: %s", req.methodName.c_str()));
|
throw DL_ABORT_EX(fmt("No such method: %s", req.methodName.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
|
@ -32,16 +32,16 @@
|
||||||
* files in the program, then also delete it here.
|
* files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#ifndef D_XML_RPC_METHOD_IMPL_H
|
#ifndef D_RPC_METHOD_IMPL_H
|
||||||
#define D_XML_RPC_METHOD_IMPL_H
|
#define D_RPC_METHOD_IMPL_H
|
||||||
|
|
||||||
#include "XmlRpcMethod.h"
|
#include "RpcMethod.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "XmlRpcRequest.h"
|
#include "RpcRequest.h"
|
||||||
#include "ValueBase.h"
|
#include "ValueBase.h"
|
||||||
#include "TorrentAttribute.h"
|
#include "TorrentAttribute.h"
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
|
@ -51,7 +51,7 @@ namespace aria2 {
|
||||||
struct DownloadResult;
|
struct DownloadResult;
|
||||||
class RequestGroup;
|
class RequestGroup;
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
template<typename OutputIterator>
|
template<typename OutputIterator>
|
||||||
void toStringList(OutputIterator out, const List* src)
|
void toStringList(OutputIterator out, const List* src)
|
||||||
|
@ -68,10 +68,10 @@ void toStringList(OutputIterator out, const List* src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddUriXmlRpcMethod:public XmlRpcMethod {
|
class AddUriRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -80,10 +80,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class RemoveXmlRpcMethod:public XmlRpcMethod {
|
class RemoveRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -92,10 +92,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ForceRemoveXmlRpcMethod:public XmlRpcMethod {
|
class ForceRemoveRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -104,10 +104,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PauseXmlRpcMethod:public XmlRpcMethod {
|
class PauseRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -116,10 +116,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ForcePauseXmlRpcMethod:public XmlRpcMethod {
|
class ForcePauseRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -128,10 +128,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PauseAllXmlRpcMethod:public XmlRpcMethod {
|
class PauseAllRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -140,10 +140,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ForcePauseAllXmlRpcMethod:public XmlRpcMethod {
|
class ForcePauseAllRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -152,10 +152,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnpauseXmlRpcMethod:public XmlRpcMethod {
|
class UnpauseRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -164,10 +164,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnpauseAllXmlRpcMethod:public XmlRpcMethod {
|
class UnpauseAllRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -177,10 +177,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
class AddTorrentXmlRpcMethod:public XmlRpcMethod {
|
class AddTorrentRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -191,10 +191,10 @@ public:
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
|
||||||
#ifdef ENABLE_METALINK
|
#ifdef ENABLE_METALINK
|
||||||
class AddMetalinkXmlRpcMethod:public XmlRpcMethod {
|
class AddMetalinkRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -204,10 +204,10 @@ public:
|
||||||
};
|
};
|
||||||
#endif // ENABLE_METALINK
|
#endif // ENABLE_METALINK
|
||||||
|
|
||||||
class PurgeDownloadResultXmlRpcMethod:public XmlRpcMethod {
|
class PurgeDownloadResultRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -216,10 +216,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class RemoveDownloadResultXmlRpcMethod:public XmlRpcMethod {
|
class RemoveDownloadResultRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -228,10 +228,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GetUrisXmlRpcMethod:public XmlRpcMethod {
|
class GetUrisRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -240,10 +240,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GetFilesXmlRpcMethod:public XmlRpcMethod {
|
class GetFilesRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -253,10 +253,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
class GetPeersXmlRpcMethod:public XmlRpcMethod {
|
class GetPeersRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -266,10 +266,10 @@ public:
|
||||||
};
|
};
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
|
||||||
class GetServersXmlRpcMethod:public XmlRpcMethod {
|
class GetServersRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -278,10 +278,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TellStatusXmlRpcMethod:public XmlRpcMethod {
|
class TellStatusRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -290,10 +290,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TellActiveXmlRpcMethod:public XmlRpcMethod {
|
class TellActiveRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -303,7 +303,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class AbstractPaginationXmlRpcMethod:public XmlRpcMethod {
|
class AbstractPaginationRpcMethod:public RpcMethod {
|
||||||
private:
|
private:
|
||||||
template<typename InputIterator>
|
template<typename InputIterator>
|
||||||
std::pair<InputIterator, InputIterator>
|
std::pair<InputIterator, InputIterator>
|
||||||
|
@ -349,7 +349,7 @@ private:
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const RpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
const SharedHandle<List>& params = req.params;
|
const SharedHandle<List>& params = req.params;
|
||||||
checkPaginationParams(params);
|
checkPaginationParams(params);
|
||||||
|
@ -384,8 +384,8 @@ protected:
|
||||||
const std::vector<std::string>& keys) const = 0;
|
const std::vector<std::string>& keys) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TellWaitingXmlRpcMethod:
|
class TellWaitingRpcMethod:
|
||||||
public AbstractPaginationXmlRpcMethod<RequestGroup> {
|
public AbstractPaginationRpcMethod<RequestGroup> {
|
||||||
protected:
|
protected:
|
||||||
virtual const std::deque<SharedHandle<RequestGroup> >&
|
virtual const std::deque<SharedHandle<RequestGroup> >&
|
||||||
getItems(DownloadEngine* e) const;
|
getItems(DownloadEngine* e) const;
|
||||||
|
@ -403,8 +403,8 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TellStoppedXmlRpcMethod:
|
class TellStoppedRpcMethod:
|
||||||
public AbstractPaginationXmlRpcMethod<DownloadResult> {
|
public AbstractPaginationRpcMethod<DownloadResult> {
|
||||||
protected:
|
protected:
|
||||||
virtual const std::deque<SharedHandle<DownloadResult> >&
|
virtual const std::deque<SharedHandle<DownloadResult> >&
|
||||||
getItems(DownloadEngine* e) const;
|
getItems(DownloadEngine* e) const;
|
||||||
|
@ -422,10 +422,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChangeOptionXmlRpcMethod:public XmlRpcMethod {
|
class ChangeOptionRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -434,10 +434,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChangeGlobalOptionXmlRpcMethod:public XmlRpcMethod {
|
class ChangeGlobalOptionRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -446,10 +446,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GetVersionXmlRpcMethod:public XmlRpcMethod {
|
class GetVersionRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -458,10 +458,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GetOptionXmlRpcMethod:public XmlRpcMethod {
|
class GetOptionRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -470,10 +470,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GetGlobalOptionXmlRpcMethod:public XmlRpcMethod {
|
class GetGlobalOptionRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -482,10 +482,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChangePositionXmlRpcMethod:public XmlRpcMethod {
|
class ChangePositionRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -494,10 +494,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChangeUriXmlRpcMethod:public XmlRpcMethod {
|
class ChangeUriRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -506,10 +506,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GetSessionInfoXmlRpcMethod:public XmlRpcMethod {
|
class GetSessionInfoRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -518,10 +518,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShutdownXmlRpcMethod:public XmlRpcMethod {
|
class ShutdownRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -530,10 +530,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ForceShutdownXmlRpcMethod:public XmlRpcMethod {
|
class ForceShutdownRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -542,10 +542,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SystemMulticallXmlRpcMethod:public XmlRpcMethod {
|
class SystemMulticallRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
public:
|
public:
|
||||||
static const std::string& getMethodName()
|
static const std::string& getMethodName()
|
||||||
{
|
{
|
||||||
|
@ -554,10 +554,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class NoSuchMethodXmlRpcMethod:public XmlRpcMethod {
|
class NoSuchMethodRpcMethod:public RpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<ValueBase> process
|
virtual SharedHandle<ValueBase> process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e);
|
(const RpcRequest& req, DownloadEngine* e);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper function to store data to entryDict from ds. This function
|
// Helper function to store data to entryDict from ds. This function
|
||||||
|
@ -579,8 +579,8 @@ void gatherBitTorrentMetadata
|
||||||
const SharedHandle<TorrentAttribute>& torrentAttrs);
|
const SharedHandle<TorrentAttribute>& torrentAttrs);
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
#endif // D_XML_RPC_METHOD_IMPL_H
|
#endif // D_RPC_METHOD_IMPL_H
|
|
@ -32,30 +32,30 @@
|
||||||
* files in the program, then also delete it here.
|
* files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "XmlRpcRequest.h"
|
#include "RpcRequest.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
XmlRpcRequest::XmlRpcRequest(const std::string& methodName,
|
RpcRequest::RpcRequest(const std::string& methodName,
|
||||||
const SharedHandle<List>& params)
|
const SharedHandle<List>& params)
|
||||||
: methodName(methodName), params(params)
|
: methodName(methodName), params(params)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
XmlRpcRequest::XmlRpcRequest(const std::string& methodName,
|
RpcRequest::RpcRequest(const std::string& methodName,
|
||||||
const SharedHandle<List>& params,
|
const SharedHandle<List>& params,
|
||||||
const SharedHandle<ValueBase>& id)
|
const SharedHandle<ValueBase>& id)
|
||||||
: methodName(methodName), params(params), id(id)
|
: methodName(methodName), params(params), id(id)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
XmlRpcRequest::XmlRpcRequest(const XmlRpcRequest& c)
|
RpcRequest::RpcRequest(const RpcRequest& c)
|
||||||
: methodName(c.methodName), params(c.params), id(c.id)
|
: methodName(c.methodName), params(c.params), id(c.id)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
XmlRpcRequest::~XmlRpcRequest() {}
|
RpcRequest::~RpcRequest() {}
|
||||||
|
|
||||||
XmlRpcRequest& XmlRpcRequest::operator=(const XmlRpcRequest& c)
|
RpcRequest& RpcRequest::operator=(const RpcRequest& c)
|
||||||
{
|
{
|
||||||
if(this != &c) {
|
if(this != &c) {
|
||||||
methodName = c.methodName;
|
methodName = c.methodName;
|
||||||
|
@ -64,7 +64,7 @@ XmlRpcRequest& XmlRpcRequest::operator=(const XmlRpcRequest& c)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
const String* XmlRpcRequest::getStringParam(size_t index) const
|
const String* RpcRequest::getStringParam(size_t index) const
|
||||||
{
|
{
|
||||||
const String* stringParam = 0;
|
const String* stringParam = 0;
|
||||||
if(params->size() > index) {
|
if(params->size() > index) {
|
||||||
|
@ -73,7 +73,7 @@ const String* XmlRpcRequest::getStringParam(size_t index) const
|
||||||
return stringParam;
|
return stringParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Integer* XmlRpcRequest::getIntegerParam(size_t index) const
|
const Integer* RpcRequest::getIntegerParam(size_t index) const
|
||||||
{
|
{
|
||||||
const Integer* integerParam = 0;
|
const Integer* integerParam = 0;
|
||||||
if(params->size() > index) {
|
if(params->size() > index) {
|
||||||
|
@ -82,7 +82,7 @@ const Integer* XmlRpcRequest::getIntegerParam(size_t index) const
|
||||||
return integerParam;
|
return integerParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
const List* XmlRpcRequest::getListParam(size_t index) const
|
const List* RpcRequest::getListParam(size_t index) const
|
||||||
{
|
{
|
||||||
const List* listParam = 0;
|
const List* listParam = 0;
|
||||||
if(params->size() > index) {
|
if(params->size() > index) {
|
||||||
|
@ -91,7 +91,7 @@ const List* XmlRpcRequest::getListParam(size_t index) const
|
||||||
return listParam;
|
return listParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Dict* XmlRpcRequest::getDictParam(size_t index) const
|
const Dict* RpcRequest::getDictParam(size_t index) const
|
||||||
{
|
{
|
||||||
const Dict* dictParam = 0;
|
const Dict* dictParam = 0;
|
||||||
if(params->size() > index) {
|
if(params->size() > index) {
|
||||||
|
@ -100,6 +100,6 @@ const Dict* XmlRpcRequest::getDictParam(size_t index) const
|
||||||
return dictParam;
|
return dictParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
|
@ -32,8 +32,8 @@
|
||||||
* files in the program, then also delete it here.
|
* files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#ifndef D_XML_RPC_REQUEST_H
|
#ifndef D_RPC_REQUEST_H
|
||||||
#define D_XML_RPC_REQUEST_H
|
#define D_RPC_REQUEST_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
@ -43,25 +43,25 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
struct XmlRpcRequest {
|
struct RpcRequest {
|
||||||
std::string methodName;
|
std::string methodName;
|
||||||
SharedHandle<List> params;
|
SharedHandle<List> params;
|
||||||
SharedHandle<ValueBase> id;
|
SharedHandle<ValueBase> id;
|
||||||
|
|
||||||
XmlRpcRequest(const std::string& methodName,
|
RpcRequest(const std::string& methodName,
|
||||||
const SharedHandle<List>& params);
|
const SharedHandle<List>& params);
|
||||||
|
|
||||||
XmlRpcRequest(const std::string& methodName,
|
RpcRequest(const std::string& methodName,
|
||||||
const SharedHandle<List>& params,
|
const SharedHandle<List>& params,
|
||||||
const SharedHandle<ValueBase>& id);
|
const SharedHandle<ValueBase>& id);
|
||||||
|
|
||||||
~XmlRpcRequest();
|
~RpcRequest();
|
||||||
|
|
||||||
XmlRpcRequest(const XmlRpcRequest& c);
|
RpcRequest(const RpcRequest& c);
|
||||||
|
|
||||||
XmlRpcRequest& operator=(const XmlRpcRequest& c);
|
RpcRequest& operator=(const RpcRequest& c);
|
||||||
|
|
||||||
const String* getStringParam(size_t index) const;
|
const String* getStringParam(size_t index) const;
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ struct XmlRpcRequest {
|
||||||
const Dict* getDictParam(size_t index) const;
|
const Dict* getDictParam(size_t index) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
#endif // D_XML_RPC_REQUEST_H
|
#endif // D_RPC_REQUEST_H
|
|
@ -32,7 +32,7 @@
|
||||||
* files in the program, then also delete it here.
|
* files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "XmlRpcResponse.h"
|
#include "RpcResponse.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
template<typename OutputStream>
|
template<typename OutputStream>
|
||||||
|
@ -121,22 +121,22 @@ std::string encodeAll
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
XmlRpcResponse::XmlRpcResponse
|
RpcResponse::RpcResponse
|
||||||
(int code,
|
(int code,
|
||||||
const SharedHandle<ValueBase>& param,
|
const SharedHandle<ValueBase>& param,
|
||||||
const SharedHandle<ValueBase>& id)
|
const SharedHandle<ValueBase>& id)
|
||||||
: code(code), param(param), id(id)
|
: code(code), param(param), id(id)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
XmlRpcResponse::XmlRpcResponse(const XmlRpcResponse& c)
|
RpcResponse::RpcResponse(const RpcResponse& c)
|
||||||
: code(c.code),
|
: code(c.code),
|
||||||
param(c.param),
|
param(c.param),
|
||||||
id(c.id)
|
id(c.id)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
XmlRpcResponse::~XmlRpcResponse() {}
|
RpcResponse::~RpcResponse() {}
|
||||||
|
|
||||||
XmlRpcResponse& XmlRpcResponse::operator=(const XmlRpcResponse& c)
|
RpcResponse& RpcResponse::operator=(const RpcResponse& c)
|
||||||
{
|
{
|
||||||
if(this != &c) {
|
if(this != &c) {
|
||||||
code = c.code;
|
code = c.code;
|
||||||
|
@ -145,7 +145,7 @@ XmlRpcResponse& XmlRpcResponse::operator=(const XmlRpcResponse& c)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string XmlRpcResponse::toXml(bool gzip) const
|
std::string RpcResponse::toXml(bool gzip) const
|
||||||
{
|
{
|
||||||
if(gzip) {
|
if(gzip) {
|
||||||
#ifdef HAVE_ZLIB
|
#ifdef HAVE_ZLIB
|
||||||
|
@ -189,7 +189,7 @@ OutputStream& encodeJsonAll
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::string XmlRpcResponse::toJson(const std::string& callback, bool gzip) const
|
std::string RpcResponse::toJson(const std::string& callback, bool gzip) const
|
||||||
{
|
{
|
||||||
if(gzip) {
|
if(gzip) {
|
||||||
#ifdef HAVE_ZLIB
|
#ifdef HAVE_ZLIB
|
||||||
|
@ -209,14 +209,14 @@ namespace {
|
||||||
template<typename OutputStream>
|
template<typename OutputStream>
|
||||||
OutputStream& encodeJsonBatchAll
|
OutputStream& encodeJsonBatchAll
|
||||||
(OutputStream& o,
|
(OutputStream& o,
|
||||||
const std::vector<XmlRpcResponse>& results,
|
const std::vector<RpcResponse>& results,
|
||||||
const std::string& callback)
|
const std::string& callback)
|
||||||
{
|
{
|
||||||
o << "[";
|
o << "[";
|
||||||
if(!results.empty()) {
|
if(!results.empty()) {
|
||||||
encodeJsonAll(o, results[0].code, results[0].param, results[0].id,callback);
|
encodeJsonAll(o, results[0].code, results[0].param, results[0].id,callback);
|
||||||
}
|
}
|
||||||
for(std::vector<XmlRpcResponse>::const_iterator i = results.begin()+1,
|
for(std::vector<RpcResponse>::const_iterator i = results.begin()+1,
|
||||||
eoi = results.end(); i != eoi; ++i) {
|
eoi = results.end(); i != eoi; ++i) {
|
||||||
o << ",";
|
o << ",";
|
||||||
encodeJsonAll(o, (*i).code, (*i).param, (*i).id, callback);
|
encodeJsonAll(o, (*i).code, (*i).param, (*i).id, callback);
|
||||||
|
@ -227,7 +227,7 @@ OutputStream& encodeJsonBatchAll
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::string toJsonBatch
|
std::string toJsonBatch
|
||||||
(const std::vector<XmlRpcResponse>& results,
|
(const std::vector<RpcResponse>& results,
|
||||||
const std::string& callback,
|
const std::string& callback,
|
||||||
bool gzip)
|
bool gzip)
|
||||||
{
|
{
|
||||||
|
@ -245,6 +245,6 @@ std::string toJsonBatch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
|
@ -32,8 +32,8 @@
|
||||||
* files in the program, then also delete it here.
|
* files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#ifndef D_XML_RPC_RESPONSE_H
|
#ifndef D_RPC_RESPONSE_H
|
||||||
#define D_XML_RPC_RESPONSE_H
|
#define D_RPC_RESPONSE_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
@ -44,9 +44,9 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
struct XmlRpcResponse {
|
struct RpcResponse {
|
||||||
// 0 for success, non-zero for error
|
// 0 for success, non-zero for error
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
|
@ -54,16 +54,16 @@ struct XmlRpcResponse {
|
||||||
|
|
||||||
SharedHandle<ValueBase> id;
|
SharedHandle<ValueBase> id;
|
||||||
|
|
||||||
XmlRpcResponse
|
RpcResponse
|
||||||
(int code,
|
(int code,
|
||||||
const SharedHandle<ValueBase>& param,
|
const SharedHandle<ValueBase>& param,
|
||||||
const SharedHandle<ValueBase>& id);
|
const SharedHandle<ValueBase>& id);
|
||||||
|
|
||||||
XmlRpcResponse(const XmlRpcResponse& c);
|
RpcResponse(const RpcResponse& c);
|
||||||
|
|
||||||
~XmlRpcResponse();
|
~RpcResponse();
|
||||||
|
|
||||||
XmlRpcResponse& operator=(const XmlRpcResponse& c);
|
RpcResponse& operator=(const RpcResponse& c);
|
||||||
|
|
||||||
std::string toXml(bool gzip = false) const;
|
std::string toXml(bool gzip = false) const;
|
||||||
|
|
||||||
|
@ -73,12 +73,12 @@ struct XmlRpcResponse {
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string toJsonBatch
|
std::string toJsonBatch
|
||||||
(const std::vector<XmlRpcResponse>& results,
|
(const std::vector<RpcResponse>& results,
|
||||||
const std::string& callback,
|
const std::string& callback,
|
||||||
bool gzip = false);
|
bool gzip = false);
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
#endif // D_XML_RPC_RESPONSE_H
|
#endif // D_RPC_RESPONSE_H
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct SessionData {
|
struct SessionData {
|
||||||
|
@ -148,7 +148,7 @@ XmlRpcRequestProcessor::XmlRpcRequestProcessor() {}
|
||||||
|
|
||||||
XmlRpcRequestProcessor::~XmlRpcRequestProcessor() {}
|
XmlRpcRequestProcessor::~XmlRpcRequestProcessor() {}
|
||||||
|
|
||||||
XmlRpcRequest
|
RpcRequest
|
||||||
XmlRpcRequestProcessor::parseMemory(const std::string& xml)
|
XmlRpcRequestProcessor::parseMemory(const std::string& xml)
|
||||||
{
|
{
|
||||||
stm_.reset(new XmlRpcRequestParserStateMachine());
|
stm_.reset(new XmlRpcRequestParserStateMachine());
|
||||||
|
@ -162,10 +162,10 @@ XmlRpcRequestProcessor::parseMemory(const std::string& xml)
|
||||||
if(!asList(stm_->getCurrentFrameValue())) {
|
if(!asList(stm_->getCurrentFrameValue())) {
|
||||||
throw DL_ABORT_EX("Bad XML-RPC parameter list");
|
throw DL_ABORT_EX("Bad XML-RPC parameter list");
|
||||||
}
|
}
|
||||||
return XmlRpcRequest(stm_->getMethodName(),
|
return RpcRequest(stm_->getMethodName(),
|
||||||
static_pointer_cast<List>(stm_->getCurrentFrameValue()));
|
static_pointer_cast<List>(stm_->getCurrentFrameValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -40,11 +40,11 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "XmlRpcRequest.h"
|
#include "RpcRequest.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
class XmlRpcRequestParserStateMachine;
|
class XmlRpcRequestParserStateMachine;
|
||||||
|
|
||||||
|
@ -56,10 +56,10 @@ public:
|
||||||
|
|
||||||
~XmlRpcRequestProcessor();
|
~XmlRpcRequestProcessor();
|
||||||
|
|
||||||
XmlRpcRequest parseMemory(const std::string& xml);
|
RpcRequest parseMemory(const std::string& xml);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "XmlRpcElements.h"
|
#include "XmlRpcElements.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
namespace elements {
|
namespace elements {
|
||||||
|
|
||||||
const std::string METHOD_CALL("methodCall");
|
const std::string METHOD_CALL("methodCall");
|
||||||
|
@ -57,5 +57,5 @@ const std::string ARRAY("array");
|
||||||
const std::string DATA("data");
|
const std::string DATA("data");
|
||||||
|
|
||||||
} // namespace elements
|
} // namespace elements
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
namespace elements {
|
namespace elements {
|
||||||
|
|
||||||
extern const std::string METHOD_CALL;
|
extern const std::string METHOD_CALL;
|
||||||
|
@ -62,7 +62,7 @@ extern const std::string ARRAY;
|
||||||
extern const std::string DATA;
|
extern const std::string DATA;
|
||||||
|
|
||||||
} // namespace elements
|
} // namespace elements
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
#endif // D_XML_RPC_ELEMENTS_H
|
#endif // D_XML_RPC_ELEMENTS_H
|
||||||
|
|
|
@ -1,127 +0,0 @@
|
||||||
/* <!-- copyright */
|
|
||||||
/*
|
|
||||||
* aria2 - The high speed download utility
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 Tatsuhiro Tsujikawa
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* In addition, as a special exception, the copyright holders give
|
|
||||||
* permission to link the code of portions of this program with the
|
|
||||||
* OpenSSL library under certain conditions as described in each
|
|
||||||
* individual source file, and distribute linked combinations
|
|
||||||
* including the two.
|
|
||||||
* You must obey the GNU General Public License in all respects
|
|
||||||
* for all of the code used other than OpenSSL. If you modify
|
|
||||||
* file(s) with this exception, you may extend this exception to your
|
|
||||||
* version of the file(s), but you are not obligated to do so. If you
|
|
||||||
* do not wish to do so, delete this exception statement from your
|
|
||||||
* version. If you delete this exception statement from all source
|
|
||||||
* files in the program, then also delete it here.
|
|
||||||
*/
|
|
||||||
/* copyright --> */
|
|
||||||
#include "XmlRpcMethodFactory.h"
|
|
||||||
#include "XmlRpcMethodImpl.h"
|
|
||||||
#include "OptionParser.h"
|
|
||||||
#include "OptionHandler.h"
|
|
||||||
|
|
||||||
namespace aria2 {
|
|
||||||
|
|
||||||
namespace xmlrpc {
|
|
||||||
|
|
||||||
SharedHandle<XmlRpcMethod>
|
|
||||||
XmlRpcMethodFactory::create(const std::string& methodName)
|
|
||||||
{
|
|
||||||
if(methodName == AddUriXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new AddUriXmlRpcMethod());
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
|
||||||
} else if(methodName == AddTorrentXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new AddTorrentXmlRpcMethod());
|
|
||||||
#endif // ENABLE_BITTORRENT
|
|
||||||
#ifdef ENABLE_METALINK
|
|
||||||
}
|
|
||||||
else if(methodName == AddMetalinkXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new AddMetalinkXmlRpcMethod());
|
|
||||||
#endif // ENABLE_METALINK
|
|
||||||
}
|
|
||||||
else if(methodName == RemoveXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new RemoveXmlRpcMethod());
|
|
||||||
} else if(methodName == PauseXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new PauseXmlRpcMethod());
|
|
||||||
} else if(methodName == ForcePauseXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new ForcePauseXmlRpcMethod());
|
|
||||||
} else if(methodName == PauseAllXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new PauseAllXmlRpcMethod());
|
|
||||||
} else if(methodName == ForcePauseAllXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new ForcePauseAllXmlRpcMethod());
|
|
||||||
} else if(methodName == UnpauseXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new UnpauseXmlRpcMethod());
|
|
||||||
} else if(methodName == UnpauseAllXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new UnpauseAllXmlRpcMethod());
|
|
||||||
} else if(methodName == ForceRemoveXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new ForceRemoveXmlRpcMethod());
|
|
||||||
} else if(methodName == ChangePositionXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new ChangePositionXmlRpcMethod());
|
|
||||||
} else if(methodName == TellStatusXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new TellStatusXmlRpcMethod());
|
|
||||||
} else if(methodName == GetUrisXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new GetUrisXmlRpcMethod());
|
|
||||||
} else if(methodName == GetFilesXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new GetFilesXmlRpcMethod());
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
|
||||||
}
|
|
||||||
else if(methodName == GetPeersXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new GetPeersXmlRpcMethod());
|
|
||||||
#endif // ENABLE_BITTORRENT
|
|
||||||
} else if(methodName == GetServersXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new GetServersXmlRpcMethod());
|
|
||||||
} else if(methodName == TellActiveXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new TellActiveXmlRpcMethod());
|
|
||||||
} else if(methodName == TellWaitingXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new TellWaitingXmlRpcMethod());
|
|
||||||
} else if(methodName == TellStoppedXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new TellStoppedXmlRpcMethod());
|
|
||||||
} else if(methodName == GetOptionXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new GetOptionXmlRpcMethod());
|
|
||||||
} else if(methodName == ChangeUriXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new ChangeUriXmlRpcMethod());
|
|
||||||
} else if(methodName == ChangeOptionXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new ChangeOptionXmlRpcMethod());
|
|
||||||
} else if(methodName == GetGlobalOptionXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new GetGlobalOptionXmlRpcMethod());
|
|
||||||
} else if(methodName == ChangeGlobalOptionXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new ChangeGlobalOptionXmlRpcMethod());
|
|
||||||
} else if(methodName == PurgeDownloadResultXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new PurgeDownloadResultXmlRpcMethod());
|
|
||||||
} else if(methodName == RemoveDownloadResultXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new RemoveDownloadResultXmlRpcMethod());
|
|
||||||
} else if(methodName == GetVersionXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new GetVersionXmlRpcMethod());
|
|
||||||
} else if(methodName == GetSessionInfoXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new GetSessionInfoXmlRpcMethod());
|
|
||||||
} else if(methodName == ShutdownXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new ShutdownXmlRpcMethod());
|
|
||||||
} else if(methodName == ForceShutdownXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new ForceShutdownXmlRpcMethod());
|
|
||||||
} else if(methodName == SystemMulticallXmlRpcMethod::getMethodName()) {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new SystemMulticallXmlRpcMethod());
|
|
||||||
} else {
|
|
||||||
return SharedHandle<XmlRpcMethod>(new NoSuchMethodXmlRpcMethod());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace xmlrpc
|
|
||||||
|
|
||||||
} // namespace aria2
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
void XmlRpcRequestParserController::pushFrame()
|
void XmlRpcRequestParserController::pushFrame()
|
||||||
{
|
{
|
||||||
|
@ -92,6 +92,6 @@ XmlRpcRequestParserController::getCurrentFrameValue() const
|
||||||
return currentFrame_.value_;
|
return currentFrame_.value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
class XmlRpcRequestParserController {
|
class XmlRpcRequestParserController {
|
||||||
private:
|
private:
|
||||||
|
@ -89,7 +89,7 @@ public:
|
||||||
const std::string& getMethodName() const { return methodName_; }
|
const std::string& getMethodName() const { return methodName_; }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
class XmlRpcRequestParserStateMachine;
|
class XmlRpcRequestParserStateMachine;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public:
|
||||||
virtual bool needsCharactersBuffering() const = 0;
|
virtual bool needsCharactersBuffering() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
// InitialXmlRpcRequestParserState
|
// InitialXmlRpcRequestParserState
|
||||||
|
|
||||||
|
@ -324,6 +324,6 @@ void ArrayValueXmlRpcRequestParserState::endElement
|
||||||
stm->popArrayFrame();
|
stm->popArrayFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
class InitialXmlRpcRequestParserState:public XmlRpcRequestParserState {
|
class InitialXmlRpcRequestParserState:public XmlRpcRequestParserState {
|
||||||
public:
|
public:
|
||||||
|
@ -231,7 +231,7 @@ class ArrayValueXmlRpcRequestParserState:public ValueXmlRpcRequestParserState {
|
||||||
const std::string& characters);
|
const std::string& characters);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
InitialXmlRpcRequestParserState*
|
InitialXmlRpcRequestParserState*
|
||||||
XmlRpcRequestParserStateMachine::initialState_ =
|
XmlRpcRequestParserStateMachine::initialState_ =
|
||||||
|
@ -113,6 +113,6 @@ XmlRpcRequestParserStateMachine::~XmlRpcRequestParserStateMachine()
|
||||||
delete controller_;
|
delete controller_;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
class XmlRpcRequestParserStateMachine {
|
class XmlRpcRequestParserStateMachine {
|
||||||
private:
|
private:
|
||||||
|
@ -165,7 +165,7 @@ public:
|
||||||
void pushArrayValueState() { stateStack_.push(arrayValueState_); }
|
void pushArrayValueState() { stateStack_.push(arrayValueState_); }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
|
|
|
@ -262,11 +262,7 @@ error_code::Value main(int argc, char* argv[])
|
||||||
op->remove(PREF_INPUT_FILE);
|
op->remove(PREF_INPUT_FILE);
|
||||||
op->remove(PREF_INDEX_OUT);
|
op->remove(PREF_INDEX_OUT);
|
||||||
op->remove(PREF_SELECT_FILE);
|
op->remove(PREF_SELECT_FILE);
|
||||||
if(
|
if(!op->getAsBool(PREF_ENABLE_XML_RPC) && requestGroups.empty()) {
|
||||||
#ifdef ENABLE_XML_RPC
|
|
||||||
!op->getAsBool(PREF_ENABLE_XML_RPC) &&
|
|
||||||
#endif // ENABLE_XML_RPC
|
|
||||||
requestGroups.empty()) {
|
|
||||||
std::cout << MSG_NO_FILES_TO_DOWNLOAD << std::endl;
|
std::cout << MSG_NO_FILES_TO_DOWNLOAD << std::endl;
|
||||||
} else {
|
} else {
|
||||||
exitStatus = MultiUrlRequestInfo(requestGroups, op, getStatCalc(op),
|
exitStatus = MultiUrlRequestInfo(requestGroups, op, getStatCalc(op),
|
||||||
|
|
|
@ -184,10 +184,7 @@ void option_processing(Option& op, std::vector<std::string>& uris,
|
||||||
showUsage(TAG_HELP, oparser);
|
showUsage(TAG_HELP, oparser);
|
||||||
exit(e.getErrorCode());
|
exit(e.getErrorCode());
|
||||||
}
|
}
|
||||||
if(
|
if(!op.getAsBool(PREF_ENABLE_XML_RPC) &&
|
||||||
#ifdef ENABLE_XML_RPC
|
|
||||||
!op.getAsBool(PREF_ENABLE_XML_RPC) &&
|
|
||||||
#endif // ENABLE_XML_RPC
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
op.blank(PREF_TORRENT_FILE) &&
|
op.blank(PREF_TORRENT_FILE) &&
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
|
|
@ -78,12 +78,12 @@ aria2c_SOURCES = AllTest.cc\
|
||||||
TripletTest.cc\
|
TripletTest.cc\
|
||||||
CookieHelperTest.cc\
|
CookieHelperTest.cc\
|
||||||
JsonTest.cc\
|
JsonTest.cc\
|
||||||
XmlRpcResponseTest.cc
|
RpcResponseTest.cc\
|
||||||
|
RpcMethodTest.cc
|
||||||
|
|
||||||
if ENABLE_XML_RPC
|
if ENABLE_XML_RPC
|
||||||
aria2c_SOURCES += XmlRpcRequestParserControllerTest.cc\
|
aria2c_SOURCES += XmlRpcRequestParserControllerTest.cc\
|
||||||
XmlRpcRequestProcessorTest.cc\
|
XmlRpcRequestProcessorTest.cc
|
||||||
XmlRpcMethodTest.cc
|
|
||||||
endif # ENABLE_XML_RPC
|
endif # ENABLE_XML_RPC
|
||||||
|
|
||||||
if HAVE_SOME_FALLOCATE
|
if HAVE_SOME_FALLOCATE
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "XmlRpcMethod.h"
|
#include "RpcMethod.h"
|
||||||
|
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
#include "XmlRpcMethodImpl.h"
|
#include "RpcMethodImpl.h"
|
||||||
#include "OptionParser.h"
|
#include "OptionParser.h"
|
||||||
#include "OptionHandler.h"
|
#include "OptionHandler.h"
|
||||||
#include "XmlRpcRequest.h"
|
#include "RpcRequest.h"
|
||||||
#include "XmlRpcResponse.h"
|
#include "RpcResponse.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "TestUtil.h"
|
#include "TestUtil.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
@ -28,11 +28,11 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
class XmlRpcMethodTest:public CppUnit::TestFixture {
|
class RpcMethodTest:public CppUnit::TestFixture {
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE(XmlRpcMethodTest);
|
CPPUNIT_TEST_SUITE(RpcMethodTest);
|
||||||
CPPUNIT_TEST(testAddUri);
|
CPPUNIT_TEST(testAddUri);
|
||||||
CPPUNIT_TEST(testAddUri_withoutUri);
|
CPPUNIT_TEST(testAddUri_withoutUri);
|
||||||
CPPUNIT_TEST(testAddUri_notUri);
|
CPPUNIT_TEST(testAddUri_notUri);
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
{
|
{
|
||||||
RequestGroup::resetGIDCounter();
|
RequestGroup::resetGIDCounter();
|
||||||
option_.reset(new Option());
|
option_.reset(new Option());
|
||||||
option_->put(PREF_DIR, A2_TEST_OUT_DIR"/aria2_XmlRpcMethodTest");
|
option_->put(PREF_DIR, A2_TEST_OUT_DIR"/aria2_RpcMethodTest");
|
||||||
option_->put(PREF_SEGMENT_SIZE, "1048576");
|
option_->put(PREF_SEGMENT_SIZE, "1048576");
|
||||||
File(option_->get(PREF_DIR)).mkdirs();
|
File(option_->get(PREF_DIR)).mkdirs();
|
||||||
e_.reset
|
e_.reset
|
||||||
|
@ -143,7 +143,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION(XmlRpcMethodTest);
|
CPPUNIT_TEST_SUITE_REGISTRATION(RpcMethodTest);
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
std::string getString(const Dict* dict, const std::string& key)
|
std::string getString(const Dict* dict, const std::string& key)
|
||||||
|
@ -152,15 +152,15 @@ std::string getString(const Dict* dict, const std::string& key)
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void XmlRpcMethodTest::testAddUri()
|
void RpcMethodTest::testAddUri()
|
||||||
{
|
{
|
||||||
AddUriXmlRpcMethod m;
|
AddUriRpcMethod m;
|
||||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddUriRpcMethod::getMethodName(), List::g());
|
||||||
SharedHandle<List> urisParam = List::g();
|
SharedHandle<List> urisParam = List::g();
|
||||||
urisParam->append("http://localhost/");
|
urisParam->append("http://localhost/");
|
||||||
req.params->append(urisParam);
|
req.params->append(urisParam);
|
||||||
{
|
{
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
const std::deque<SharedHandle<RequestGroup> > rgs =
|
const std::deque<SharedHandle<RequestGroup> > rgs =
|
||||||
e_->getRequestGroupMan()->getReservedGroups();
|
e_->getRequestGroupMan()->getReservedGroups();
|
||||||
|
@ -174,7 +174,7 @@ void XmlRpcMethodTest::testAddUri()
|
||||||
opt->put(PREF_DIR, "/sink");
|
opt->put(PREF_DIR, "/sink");
|
||||||
req.params->append(opt);
|
req.params->append(opt);
|
||||||
{
|
{
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/sink"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/sink"),
|
||||||
e_->getRequestGroupMan()->findReservedGroup(2)->
|
e_->getRequestGroupMan()->findReservedGroup(2)->
|
||||||
|
@ -182,50 +182,50 @@ void XmlRpcMethodTest::testAddUri()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testAddUri_withoutUri()
|
void RpcMethodTest::testAddUri_withoutUri()
|
||||||
{
|
{
|
||||||
AddUriXmlRpcMethod m;
|
AddUriRpcMethod m;
|
||||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddUriRpcMethod::getMethodName(), List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testAddUri_notUri()
|
void RpcMethodTest::testAddUri_notUri()
|
||||||
{
|
{
|
||||||
AddUriXmlRpcMethod m;
|
AddUriRpcMethod m;
|
||||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddUriRpcMethod::getMethodName(), List::g());
|
||||||
SharedHandle<List> urisParam = List::g();
|
SharedHandle<List> urisParam = List::g();
|
||||||
urisParam->append("not uri");
|
urisParam->append("not uri");
|
||||||
req.params->append(urisParam);
|
req.params->append(urisParam);
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testAddUri_withBadOption()
|
void RpcMethodTest::testAddUri_withBadOption()
|
||||||
{
|
{
|
||||||
AddUriXmlRpcMethod m;
|
AddUriRpcMethod m;
|
||||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddUriRpcMethod::getMethodName(), List::g());
|
||||||
SharedHandle<List> urisParam = List::g();
|
SharedHandle<List> urisParam = List::g();
|
||||||
urisParam->append("http://localhost");
|
urisParam->append("http://localhost");
|
||||||
req.params->append(urisParam);
|
req.params->append(urisParam);
|
||||||
SharedHandle<Dict> opt = Dict::g();
|
SharedHandle<Dict> opt = Dict::g();
|
||||||
opt->put(PREF_FILE_ALLOCATION, "badvalue");
|
opt->put(PREF_FILE_ALLOCATION, "badvalue");
|
||||||
req.params->append(opt);
|
req.params->append(opt);
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testAddUri_withPosition()
|
void RpcMethodTest::testAddUri_withPosition()
|
||||||
{
|
{
|
||||||
AddUriXmlRpcMethod m;
|
AddUriRpcMethod m;
|
||||||
XmlRpcRequest req1(AddUriXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req1(AddUriRpcMethod::getMethodName(), List::g());
|
||||||
SharedHandle<List> urisParam1 = List::g();
|
SharedHandle<List> urisParam1 = List::g();
|
||||||
urisParam1->append("http://uri1");
|
urisParam1->append("http://uri1");
|
||||||
req1.params->append(urisParam1);
|
req1.params->append(urisParam1);
|
||||||
XmlRpcResponse res1 = m.execute(req1, e_.get());
|
RpcResponse res1 = m.execute(req1, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res1.code);
|
CPPUNIT_ASSERT_EQUAL(0, res1.code);
|
||||||
|
|
||||||
XmlRpcRequest req2(AddUriXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req2(AddUriRpcMethod::getMethodName(), List::g());
|
||||||
SharedHandle<List> urisParam2 = List::g();
|
SharedHandle<List> urisParam2 = List::g();
|
||||||
urisParam2->append("http://uri2");
|
urisParam2->append("http://uri2");
|
||||||
req2.params->append(urisParam2);
|
req2.params->append(urisParam2);
|
||||||
|
@ -240,32 +240,32 @@ void XmlRpcMethodTest::testAddUri_withPosition()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://uri2"), uri);
|
CPPUNIT_ASSERT_EQUAL(std::string("http://uri2"), uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testAddUri_withBadPosition()
|
void RpcMethodTest::testAddUri_withBadPosition()
|
||||||
{
|
{
|
||||||
AddUriXmlRpcMethod m;
|
AddUriRpcMethod m;
|
||||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddUriRpcMethod::getMethodName(), List::g());
|
||||||
SharedHandle<List> urisParam = List::g();
|
SharedHandle<List> urisParam = List::g();
|
||||||
urisParam->append("http://localhost/");
|
urisParam->append("http://localhost/");
|
||||||
req.params->append(urisParam);
|
req.params->append(urisParam);
|
||||||
req.params->append(Dict::g());
|
req.params->append(Dict::g());
|
||||||
req.params->append(Integer::g(-1));
|
req.params->append(Integer::g(-1));
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
void XmlRpcMethodTest::testAddTorrent()
|
void RpcMethodTest::testAddTorrent()
|
||||||
{
|
{
|
||||||
File(e_->getOption()->get(PREF_DIR)+
|
File(e_->getOption()->get(PREF_DIR)+
|
||||||
"/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").remove();
|
"/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").remove();
|
||||||
AddTorrentXmlRpcMethod m;
|
AddTorrentRpcMethod m;
|
||||||
XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddTorrentRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append(readFile(A2_TEST_DIR"/single.torrent"));
|
req.params->append(readFile(A2_TEST_DIR"/single.torrent"));
|
||||||
SharedHandle<List> uris = List::g();
|
SharedHandle<List> uris = List::g();
|
||||||
uris->append("http://localhost/aria2-0.8.2.tar.bz2");
|
uris->append("http://localhost/aria2-0.8.2.tar.bz2");
|
||||||
req.params->append(uris);
|
req.params->append(uris);
|
||||||
{
|
{
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT
|
CPPUNIT_ASSERT
|
||||||
(File(e_->getOption()->get(PREF_DIR)+
|
(File(e_->getOption()->get(PREF_DIR)+
|
||||||
"/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").exists());
|
"/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").exists());
|
||||||
|
@ -285,14 +285,14 @@ void XmlRpcMethodTest::testAddTorrent()
|
||||||
getRemainingUris()[0]);
|
getRemainingUris()[0]);
|
||||||
}
|
}
|
||||||
// with options
|
// with options
|
||||||
std::string dir = A2_TEST_OUT_DIR"/aria2_XmlRpcMethodTest_testAddTorrent";
|
std::string dir = A2_TEST_OUT_DIR"/aria2_RpcMethodTest_testAddTorrent";
|
||||||
File(dir).mkdirs();
|
File(dir).mkdirs();
|
||||||
SharedHandle<Dict> opt = Dict::g();
|
SharedHandle<Dict> opt = Dict::g();
|
||||||
opt->put(PREF_DIR, dir);
|
opt->put(PREF_DIR, dir);
|
||||||
File(dir+"/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").remove();
|
File(dir+"/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").remove();
|
||||||
req.params->append(opt);
|
req.params->append(opt);
|
||||||
{
|
{
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
(dir+"/aria2-0.8.2.tar.bz2",
|
(dir+"/aria2-0.8.2.tar.bz2",
|
||||||
|
@ -302,34 +302,34 @@ void XmlRpcMethodTest::testAddTorrent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testAddTorrent_withoutTorrent()
|
void RpcMethodTest::testAddTorrent_withoutTorrent()
|
||||||
{
|
{
|
||||||
AddTorrentXmlRpcMethod m;
|
AddTorrentRpcMethod m;
|
||||||
XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddTorrentRpcMethod::getMethodName(), List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testAddTorrent_notBase64Torrent()
|
void RpcMethodTest::testAddTorrent_notBase64Torrent()
|
||||||
{
|
{
|
||||||
AddTorrentXmlRpcMethod m;
|
AddTorrentRpcMethod m;
|
||||||
XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddTorrentRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append("not torrent");
|
req.params->append("not torrent");
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testAddTorrent_withPosition()
|
void RpcMethodTest::testAddTorrent_withPosition()
|
||||||
{
|
{
|
||||||
AddTorrentXmlRpcMethod m;
|
AddTorrentRpcMethod m;
|
||||||
XmlRpcRequest req1(AddTorrentXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req1(AddTorrentRpcMethod::getMethodName(), List::g());
|
||||||
req1.params->append(readFile(A2_TEST_DIR"/test.torrent"));
|
req1.params->append(readFile(A2_TEST_DIR"/test.torrent"));
|
||||||
req1.params->append(List::g());
|
req1.params->append(List::g());
|
||||||
req1.params->append(Dict::g());
|
req1.params->append(Dict::g());
|
||||||
XmlRpcResponse res1 = m.execute(req1, e_.get());
|
RpcResponse res1 = m.execute(req1, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res1.code);
|
CPPUNIT_ASSERT_EQUAL(0, res1.code);
|
||||||
|
|
||||||
XmlRpcRequest req2(AddTorrentXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req2(AddTorrentRpcMethod::getMethodName(), List::g());
|
||||||
req2.params->append(readFile(A2_TEST_DIR"/single.torrent"));
|
req2.params->append(readFile(A2_TEST_DIR"/single.torrent"));
|
||||||
req2.params->append(List::g());
|
req2.params->append(List::g());
|
||||||
req2.params->append(Dict::g());
|
req2.params->append(Dict::g());
|
||||||
|
@ -344,15 +344,15 @@ void XmlRpcMethodTest::testAddTorrent_withPosition()
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
|
||||||
#ifdef ENABLE_METALINK
|
#ifdef ENABLE_METALINK
|
||||||
void XmlRpcMethodTest::testAddMetalink()
|
void RpcMethodTest::testAddMetalink()
|
||||||
{
|
{
|
||||||
File(e_->getOption()->get(PREF_DIR)+
|
File(e_->getOption()->get(PREF_DIR)+
|
||||||
"/c908634fbc257fd56f0114912c2772aeeb4064f4.metalink").remove();
|
"/c908634fbc257fd56f0114912c2772aeeb4064f4.metalink").remove();
|
||||||
AddMetalinkXmlRpcMethod m;
|
AddMetalinkRpcMethod m;
|
||||||
XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddMetalinkRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append(readFile(A2_TEST_DIR"/2files.metalink"));
|
req.params->append(readFile(A2_TEST_DIR"/2files.metalink"));
|
||||||
{
|
{
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
const List* resParams = asList(res.param);
|
const List* resParams = asList(res.param);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, resParams->size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, resParams->size());
|
||||||
|
@ -374,14 +374,14 @@ void XmlRpcMethodTest::testAddMetalink()
|
||||||
deb->getFirstFilePath());
|
deb->getFirstFilePath());
|
||||||
}
|
}
|
||||||
// with options
|
// with options
|
||||||
std::string dir = A2_TEST_OUT_DIR"/aria2_XmlRpcMethodTest_testAddMetalink";
|
std::string dir = A2_TEST_OUT_DIR"/aria2_RpcMethodTest_testAddMetalink";
|
||||||
File(dir).mkdirs();
|
File(dir).mkdirs();
|
||||||
SharedHandle<Dict> opt = Dict::g();
|
SharedHandle<Dict> opt = Dict::g();
|
||||||
opt->put(PREF_DIR, dir);
|
opt->put(PREF_DIR, dir);
|
||||||
File(dir+"/c908634fbc257fd56f0114912c2772aeeb4064f4.metalink").remove();
|
File(dir+"/c908634fbc257fd56f0114912c2772aeeb4064f4.metalink").remove();
|
||||||
req.params->append(opt);
|
req.params->append(opt);
|
||||||
{
|
{
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
CPPUNIT_ASSERT_EQUAL(dir+"/aria2-5.0.0.tar.bz2",
|
CPPUNIT_ASSERT_EQUAL(dir+"/aria2-5.0.0.tar.bz2",
|
||||||
e_->getRequestGroupMan()->findReservedGroup(3)->
|
e_->getRequestGroupMan()->findReservedGroup(3)->
|
||||||
|
@ -391,39 +391,39 @@ void XmlRpcMethodTest::testAddMetalink()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testAddMetalink_withoutMetalink()
|
void RpcMethodTest::testAddMetalink_withoutMetalink()
|
||||||
{
|
{
|
||||||
AddMetalinkXmlRpcMethod m;
|
AddMetalinkRpcMethod m;
|
||||||
XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddMetalinkRpcMethod::getMethodName(), List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testAddMetalink_notBase64Metalink()
|
void RpcMethodTest::testAddMetalink_notBase64Metalink()
|
||||||
{
|
{
|
||||||
AddMetalinkXmlRpcMethod m;
|
AddMetalinkRpcMethod m;
|
||||||
XmlRpcRequest req(AddMetalinkXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddMetalinkRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append("not metalink");
|
req.params->append("not metalink");
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testAddMetalink_withPosition()
|
void RpcMethodTest::testAddMetalink_withPosition()
|
||||||
{
|
{
|
||||||
AddUriXmlRpcMethod m1;
|
AddUriRpcMethod m1;
|
||||||
XmlRpcRequest req1(AddUriXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req1(AddUriRpcMethod::getMethodName(), List::g());
|
||||||
SharedHandle<List> urisParam1 = List::g();
|
SharedHandle<List> urisParam1 = List::g();
|
||||||
urisParam1->append("http://uri");
|
urisParam1->append("http://uri");
|
||||||
req1.params->append(urisParam1);
|
req1.params->append(urisParam1);
|
||||||
XmlRpcResponse res1 = m1.execute(req1, e_.get());
|
RpcResponse res1 = m1.execute(req1, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res1.code);
|
CPPUNIT_ASSERT_EQUAL(0, res1.code);
|
||||||
|
|
||||||
AddMetalinkXmlRpcMethod m2;
|
AddMetalinkRpcMethod m2;
|
||||||
XmlRpcRequest req2("ari2.addMetalink", List::g());
|
RpcRequest req2("ari2.addMetalink", List::g());
|
||||||
req2.params->append(readFile(A2_TEST_DIR"/2files.metalink"));
|
req2.params->append(readFile(A2_TEST_DIR"/2files.metalink"));
|
||||||
req2.params->append(Dict::g());
|
req2.params->append(Dict::g());
|
||||||
req2.params->append(Integer::g(0));
|
req2.params->append(Integer::g(0));
|
||||||
XmlRpcResponse res2 = m2.execute(req2, e_.get());
|
RpcResponse res2 = m2.execute(req2, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res2.code);
|
CPPUNIT_ASSERT_EQUAL(0, res2.code);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR)+"/aria2-5.0.0.tar.bz2",
|
CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR)+"/aria2-5.0.0.tar.bz2",
|
||||||
|
@ -433,13 +433,13 @@ void XmlRpcMethodTest::testAddMetalink_withPosition()
|
||||||
|
|
||||||
#endif // ENABLE_METALINK
|
#endif // ENABLE_METALINK
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangeOption()
|
void RpcMethodTest::testChangeOption()
|
||||||
{
|
{
|
||||||
SharedHandle<RequestGroup> group(new RequestGroup(option_));
|
SharedHandle<RequestGroup> group(new RequestGroup(option_));
|
||||||
e_->getRequestGroupMan()->addReservedGroup(group);
|
e_->getRequestGroupMan()->addReservedGroup(group);
|
||||||
|
|
||||||
ChangeOptionXmlRpcMethod m;
|
ChangeOptionRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(ChangeOptionRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append("1");
|
req.params->append("1");
|
||||||
SharedHandle<Dict> opt = Dict::g();
|
SharedHandle<Dict> opt = Dict::g();
|
||||||
opt->put(PREF_MAX_DOWNLOAD_LIMIT, "100K");
|
opt->put(PREF_MAX_DOWNLOAD_LIMIT, "100K");
|
||||||
|
@ -453,7 +453,7 @@ void XmlRpcMethodTest::testChangeOption()
|
||||||
e_->getBtRegistry()->put(group->getGID(), btObject);
|
e_->getBtRegistry()->put(group->getGID(), btObject);
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
req.params->append(opt);
|
req.params->append(opt);
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
|
|
||||||
SharedHandle<Option> option = group->getOption();
|
SharedHandle<Option> option = group->getOption();
|
||||||
|
|
||||||
|
@ -476,56 +476,56 @@ void XmlRpcMethodTest::testChangeOption()
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangeOption_withBadOption()
|
void RpcMethodTest::testChangeOption_withBadOption()
|
||||||
{
|
{
|
||||||
SharedHandle<RequestGroup> group(new RequestGroup(option_));
|
SharedHandle<RequestGroup> group(new RequestGroup(option_));
|
||||||
e_->getRequestGroupMan()->addReservedGroup(group);
|
e_->getRequestGroupMan()->addReservedGroup(group);
|
||||||
|
|
||||||
ChangeOptionXmlRpcMethod m;
|
ChangeOptionRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(ChangeOptionRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append("1");
|
req.params->append("1");
|
||||||
SharedHandle<Dict> opt = Dict::g();
|
SharedHandle<Dict> opt = Dict::g();
|
||||||
opt->put(PREF_MAX_DOWNLOAD_LIMIT, "badvalue");
|
opt->put(PREF_MAX_DOWNLOAD_LIMIT, "badvalue");
|
||||||
req.params->append(opt);
|
req.params->append(opt);
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangeOption_withNotAllowedOption()
|
void RpcMethodTest::testChangeOption_withNotAllowedOption()
|
||||||
{
|
{
|
||||||
SharedHandle<RequestGroup> group(new RequestGroup(option_));
|
SharedHandle<RequestGroup> group(new RequestGroup(option_));
|
||||||
e_->getRequestGroupMan()->addReservedGroup(group);
|
e_->getRequestGroupMan()->addReservedGroup(group);
|
||||||
|
|
||||||
ChangeOptionXmlRpcMethod m;
|
ChangeOptionRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(ChangeOptionRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append("1");
|
req.params->append("1");
|
||||||
SharedHandle<Dict> opt = Dict::g();
|
SharedHandle<Dict> opt = Dict::g();
|
||||||
opt->put(PREF_MAX_OVERALL_DOWNLOAD_LIMIT, "100K");
|
opt->put(PREF_MAX_OVERALL_DOWNLOAD_LIMIT, "100K");
|
||||||
req.params->append(opt);
|
req.params->append(opt);
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangeOption_withoutGid()
|
void RpcMethodTest::testChangeOption_withoutGid()
|
||||||
{
|
{
|
||||||
ChangeOptionXmlRpcMethod m;
|
ChangeOptionRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(ChangeOptionRpcMethod::getMethodName(), List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangeGlobalOption()
|
void RpcMethodTest::testChangeGlobalOption()
|
||||||
{
|
{
|
||||||
ChangeGlobalOptionXmlRpcMethod m;
|
ChangeGlobalOptionRpcMethod m;
|
||||||
XmlRpcRequest req
|
RpcRequest req
|
||||||
(ChangeGlobalOptionXmlRpcMethod::getMethodName(), List::g());
|
(ChangeGlobalOptionRpcMethod::getMethodName(), List::g());
|
||||||
SharedHandle<Dict> opt = Dict::g();
|
SharedHandle<Dict> opt = Dict::g();
|
||||||
opt->put(PREF_MAX_OVERALL_DOWNLOAD_LIMIT, "100K");
|
opt->put(PREF_MAX_OVERALL_DOWNLOAD_LIMIT, "100K");
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
opt->put(PREF_MAX_OVERALL_UPLOAD_LIMIT, "50K");
|
opt->put(PREF_MAX_OVERALL_UPLOAD_LIMIT, "50K");
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
req.params->append(opt);
|
req.params->append(opt);
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
|
@ -542,73 +542,53 @@ void XmlRpcMethodTest::testChangeGlobalOption()
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangeGlobalOption_withBadOption()
|
void RpcMethodTest::testChangeGlobalOption_withBadOption()
|
||||||
{
|
{
|
||||||
ChangeGlobalOptionXmlRpcMethod m;
|
ChangeGlobalOptionRpcMethod m;
|
||||||
XmlRpcRequest req
|
RpcRequest req
|
||||||
(ChangeGlobalOptionXmlRpcMethod::getMethodName(), List::g());
|
(ChangeGlobalOptionRpcMethod::getMethodName(), List::g());
|
||||||
SharedHandle<Dict> opt = Dict::g();
|
SharedHandle<Dict> opt = Dict::g();
|
||||||
opt->put(PREF_MAX_OVERALL_DOWNLOAD_LIMIT, "badvalue");
|
opt->put(PREF_MAX_OVERALL_DOWNLOAD_LIMIT, "badvalue");
|
||||||
req.params->append(opt);
|
req.params->append(opt);
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangeGlobalOption_withNotAllowedOption()
|
void RpcMethodTest::testChangeGlobalOption_withNotAllowedOption()
|
||||||
{
|
{
|
||||||
ChangeGlobalOptionXmlRpcMethod m;
|
ChangeGlobalOptionRpcMethod m;
|
||||||
XmlRpcRequest req
|
RpcRequest req
|
||||||
(ChangeGlobalOptionXmlRpcMethod::getMethodName(), List::g());
|
(ChangeGlobalOptionRpcMethod::getMethodName(), List::g());
|
||||||
SharedHandle<Dict> opt = Dict::g();
|
SharedHandle<Dict> opt = Dict::g();
|
||||||
opt->put(PREF_MAX_DOWNLOAD_LIMIT, "100K");
|
opt->put(PREF_MAX_DOWNLOAD_LIMIT, "100K");
|
||||||
req.params->append(opt);
|
req.params->append(opt);
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testNoSuchMethod()
|
void RpcMethodTest::testNoSuchMethod()
|
||||||
{
|
{
|
||||||
NoSuchMethodXmlRpcMethod m;
|
NoSuchMethodRpcMethod m;
|
||||||
XmlRpcRequest req("make.hamburger", List::g());
|
RpcRequest req("make.hamburger", List::g());
|
||||||
XmlRpcResponse res = m.execute(req, 0);
|
RpcResponse res = m.execute(req, 0);
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("No such method: make.hamburger"),
|
CPPUNIT_ASSERT_EQUAL(std::string("No such method: make.hamburger"),
|
||||||
getString(asDict(res.param), "faultString"));
|
getString(asDict(res.param), "faultString"));
|
||||||
CPPUNIT_ASSERT_EQUAL
|
|
||||||
(std::string("<?xml version=\"1.0\"?>"
|
|
||||||
"<methodResponse>"
|
|
||||||
"<fault>"
|
|
||||||
"<value>"
|
|
||||||
"<struct>"
|
|
||||||
"<member>"
|
|
||||||
"<name>faultCode</name><value><int>1</int></value>"
|
|
||||||
"</member>"
|
|
||||||
"<member>"
|
|
||||||
"<name>faultString</name>"
|
|
||||||
"<value>"
|
|
||||||
"<string>No such method: make.hamburger</string>"
|
|
||||||
"</value>"
|
|
||||||
"</member>"
|
|
||||||
"</struct>"
|
|
||||||
"</value>"
|
|
||||||
"</fault>"
|
|
||||||
"</methodResponse>"),
|
|
||||||
res.toXml());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testTellStatus_withoutGid()
|
void RpcMethodTest::testTellStatus_withoutGid()
|
||||||
{
|
{
|
||||||
TellStatusXmlRpcMethod m;
|
TellStatusRpcMethod m;
|
||||||
XmlRpcRequest req(TellStatusXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(TellStatusRpcMethod::getMethodName(), List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void addUri(const std::string& uri, const SharedHandle<DownloadEngine>& e)
|
void addUri(const std::string& uri, const SharedHandle<DownloadEngine>& e)
|
||||||
{
|
{
|
||||||
AddUriXmlRpcMethod m;
|
AddUriRpcMethod m;
|
||||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddUriRpcMethod::getMethodName(), List::g());
|
||||||
SharedHandle<List> urisParam = List::g();
|
SharedHandle<List> urisParam = List::g();
|
||||||
urisParam->append(uri);
|
urisParam->append(uri);
|
||||||
req.params->append(urisParam);
|
req.params->append(urisParam);
|
||||||
|
@ -621,15 +601,15 @@ namespace {
|
||||||
void addTorrent
|
void addTorrent
|
||||||
(const std::string& torrentFile, const SharedHandle<DownloadEngine>& e)
|
(const std::string& torrentFile, const SharedHandle<DownloadEngine>& e)
|
||||||
{
|
{
|
||||||
AddTorrentXmlRpcMethod m;
|
AddTorrentRpcMethod m;
|
||||||
XmlRpcRequest req(AddTorrentXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(AddTorrentRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append(readFile(torrentFile));
|
req.params->append(readFile(torrentFile));
|
||||||
XmlRpcResponse res = m.execute(req, e.get());
|
RpcResponse res = m.execute(req, e.get());
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
|
||||||
void XmlRpcMethodTest::testTellWaiting()
|
void RpcMethodTest::testTellWaiting()
|
||||||
{
|
{
|
||||||
addUri("http://1/", e_);
|
addUri("http://1/", e_);
|
||||||
addUri("http://2/", e_);
|
addUri("http://2/", e_);
|
||||||
|
@ -640,11 +620,11 @@ void XmlRpcMethodTest::testTellWaiting()
|
||||||
addUri("http://4/", e_);
|
addUri("http://4/", e_);
|
||||||
#endif // !ENABLE_BITTORRENT
|
#endif // !ENABLE_BITTORRENT
|
||||||
|
|
||||||
TellWaitingXmlRpcMethod m;
|
TellWaitingRpcMethod m;
|
||||||
XmlRpcRequest req(TellWaitingXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(TellWaitingRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append(Integer::g(1));
|
req.params->append(Integer::g(1));
|
||||||
req.params->append(Integer::g(2));
|
req.params->append(Integer::g(2));
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
const List* resParams = asList(res.param);
|
const List* resParams = asList(res.param);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, resParams->size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, resParams->size());
|
||||||
|
@ -653,7 +633,7 @@ void XmlRpcMethodTest::testTellWaiting()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("3"),
|
CPPUNIT_ASSERT_EQUAL(std::string("3"),
|
||||||
getString(asDict(resParams->get(1)), "gid"));
|
getString(asDict(resParams->get(1)), "gid"));
|
||||||
// waiting.size() == offset+num
|
// waiting.size() == offset+num
|
||||||
req = XmlRpcRequest(TellWaitingXmlRpcMethod::getMethodName(), List::g());
|
req = RpcRequest(TellWaitingRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append(Integer::g(1));
|
req.params->append(Integer::g(1));
|
||||||
req.params->append(Integer::g(3));
|
req.params->append(Integer::g(3));
|
||||||
res = m.execute(req, e_.get());
|
res = m.execute(req, e_.get());
|
||||||
|
@ -661,7 +641,7 @@ void XmlRpcMethodTest::testTellWaiting()
|
||||||
resParams = asList(res.param);
|
resParams = asList(res.param);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)3, resParams->size());
|
CPPUNIT_ASSERT_EQUAL((size_t)3, resParams->size());
|
||||||
// waiting.size() < offset+num
|
// waiting.size() < offset+num
|
||||||
req = XmlRpcRequest(TellWaitingXmlRpcMethod::getMethodName(), List::g());
|
req = RpcRequest(TellWaitingRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append(Integer::g(1));
|
req.params->append(Integer::g(1));
|
||||||
req.params->append(Integer::g(4));
|
req.params->append(Integer::g(4));
|
||||||
res = m.execute(req, e_.get());
|
res = m.execute(req, e_.get());
|
||||||
|
@ -669,7 +649,7 @@ void XmlRpcMethodTest::testTellWaiting()
|
||||||
resParams = asList(res.param);
|
resParams = asList(res.param);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)3, resParams->size());
|
CPPUNIT_ASSERT_EQUAL((size_t)3, resParams->size());
|
||||||
// negative offset
|
// negative offset
|
||||||
req = XmlRpcRequest(TellWaitingXmlRpcMethod::getMethodName(), List::g());
|
req = RpcRequest(TellWaitingRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append(Integer::g(-1));
|
req.params->append(Integer::g(-1));
|
||||||
req.params->append(Integer::g(2));
|
req.params->append(Integer::g(2));
|
||||||
res = m.execute(req, e_.get());
|
res = m.execute(req, e_.get());
|
||||||
|
@ -700,19 +680,19 @@ void XmlRpcMethodTest::testTellWaiting()
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, resParams->size());
|
CPPUNIT_ASSERT_EQUAL((size_t)1, resParams->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testTellWaiting_fail()
|
void RpcMethodTest::testTellWaiting_fail()
|
||||||
{
|
{
|
||||||
TellWaitingXmlRpcMethod m;
|
TellWaitingRpcMethod m;
|
||||||
XmlRpcRequest req(TellWaitingXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(TellWaitingRpcMethod::getMethodName(), List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testGetVersion()
|
void RpcMethodTest::testGetVersion()
|
||||||
{
|
{
|
||||||
GetVersionXmlRpcMethod m;
|
GetVersionRpcMethod m;
|
||||||
XmlRpcRequest req(GetVersionXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(GetVersionRpcMethod::getMethodName(), List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
const Dict* resParams = asDict(res.param);
|
const Dict* resParams = asDict(res.param);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string(PACKAGE_VERSION),
|
CPPUNIT_ASSERT_EQUAL(std::string(PACKAGE_VERSION),
|
||||||
|
@ -730,7 +710,7 @@ void XmlRpcMethodTest::testGetVersion()
|
||||||
features);
|
features);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testGatherStoppedDownload()
|
void RpcMethodTest::testGatherStoppedDownload()
|
||||||
{
|
{
|
||||||
std::vector<SharedHandle<FileEntry> > fileEntries;
|
std::vector<SharedHandle<FileEntry> > fileEntries;
|
||||||
std::vector<gid_t> followedBy;
|
std::vector<gid_t> followedBy;
|
||||||
|
@ -763,7 +743,7 @@ void XmlRpcMethodTest::testGatherStoppedDownload()
|
||||||
CPPUNIT_ASSERT(entry->containsKey("gid"));
|
CPPUNIT_ASSERT(entry->containsKey("gid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testGatherProgressCommon()
|
void RpcMethodTest::testGatherProgressCommon()
|
||||||
{
|
{
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext(0, 0,"aria2.tar.bz2"));
|
SharedHandle<DownloadContext> dctx(new DownloadContext(0, 0,"aria2.tar.bz2"));
|
||||||
std::string uris[] = { "http://localhost/aria2.tar.bz2" };
|
std::string uris[] = { "http://localhost/aria2.tar.bz2" };
|
||||||
|
@ -813,7 +793,7 @@ void XmlRpcMethodTest::testGatherProgressCommon()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
void XmlRpcMethodTest::testGatherBitTorrentMetadata()
|
void RpcMethodTest::testGatherBitTorrentMetadata()
|
||||||
{
|
{
|
||||||
SharedHandle<Option> option(new Option());
|
SharedHandle<Option> option(new Option());
|
||||||
option->put(PREF_DIR, ".");
|
option->put(PREF_DIR, ".");
|
||||||
|
@ -857,30 +837,30 @@ void XmlRpcMethodTest::testGatherBitTorrentMetadata()
|
||||||
}
|
}
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangePosition()
|
void RpcMethodTest::testChangePosition()
|
||||||
{
|
{
|
||||||
e_->getRequestGroupMan()->addReservedGroup
|
e_->getRequestGroupMan()->addReservedGroup
|
||||||
(SharedHandle<RequestGroup>(new RequestGroup(option_)));
|
(SharedHandle<RequestGroup>(new RequestGroup(option_)));
|
||||||
e_->getRequestGroupMan()->addReservedGroup
|
e_->getRequestGroupMan()->addReservedGroup
|
||||||
(SharedHandle<RequestGroup>(new RequestGroup(option_)));
|
(SharedHandle<RequestGroup>(new RequestGroup(option_)));
|
||||||
|
|
||||||
ChangePositionXmlRpcMethod m;
|
ChangePositionRpcMethod m;
|
||||||
XmlRpcRequest req(ChangePositionXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(ChangePositionRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append("1");
|
req.params->append("1");
|
||||||
req.params->append(Integer::g(1));
|
req.params->append(Integer::g(1));
|
||||||
req.params->append("POS_SET");
|
req.params->append("POS_SET");
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
CPPUNIT_ASSERT_EQUAL((int64_t)1, asInteger(res.param)->i());
|
CPPUNIT_ASSERT_EQUAL((int64_t)1, asInteger(res.param)->i());
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
((gid_t)1, e_->getRequestGroupMan()->getReservedGroups()[1]->getGID());
|
((gid_t)1, e_->getRequestGroupMan()->getReservedGroups()[1]->getGID());
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangePosition_fail()
|
void RpcMethodTest::testChangePosition_fail()
|
||||||
{
|
{
|
||||||
ChangePositionXmlRpcMethod m;
|
ChangePositionRpcMethod m;
|
||||||
XmlRpcRequest req(ChangePositionXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(ChangePositionRpcMethod::getMethodName(), List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
|
|
||||||
req.params->append("1");
|
req.params->append("1");
|
||||||
|
@ -889,7 +869,7 @@ void XmlRpcMethodTest::testChangePosition_fail()
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangeUri()
|
void RpcMethodTest::testChangeUri()
|
||||||
{
|
{
|
||||||
SharedHandle<FileEntry> files[3];
|
SharedHandle<FileEntry> files[3];
|
||||||
for(int i = 0; i < 3; ++i) {
|
for(int i = 0; i < 3; ++i) {
|
||||||
|
@ -904,8 +884,8 @@ void XmlRpcMethodTest::testChangeUri()
|
||||||
group->setDownloadContext(dctx);
|
group->setDownloadContext(dctx);
|
||||||
e_->getRequestGroupMan()->addReservedGroup(group);
|
e_->getRequestGroupMan()->addReservedGroup(group);
|
||||||
|
|
||||||
ChangeUriXmlRpcMethod m;
|
ChangeUriRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeUriXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(ChangeUriRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append("1"); // GID
|
req.params->append("1"); // GID
|
||||||
req.params->append(Integer::g(2)); // index of FileEntry
|
req.params->append(Integer::g(2)); // index of FileEntry
|
||||||
SharedHandle<List> removeuris = List::g();
|
SharedHandle<List> removeuris = List::g();
|
||||||
|
@ -919,7 +899,7 @@ void XmlRpcMethodTest::testChangeUri()
|
||||||
adduris->append("baduri");
|
adduris->append("baduri");
|
||||||
adduris->append("http://example.org/added3");
|
adduris->append("http://example.org/added3");
|
||||||
req.params->append(adduris);
|
req.params->append(adduris);
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
CPPUNIT_ASSERT_EQUAL((int64_t)2, asInteger(asList(res.param)->get(0))->i());
|
CPPUNIT_ASSERT_EQUAL((int64_t)2, asInteger(asList(res.param)->get(0))->i());
|
||||||
CPPUNIT_ASSERT_EQUAL((int64_t)3, asInteger(asList(res.param)->get(1))->i());
|
CPPUNIT_ASSERT_EQUAL((int64_t)3, asInteger(asList(res.param)->get(1))->i());
|
||||||
|
@ -962,7 +942,7 @@ void XmlRpcMethodTest::testChangeUri()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/added1-2"), uris[1]);
|
CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/added1-2"), uris[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangeUri_fail()
|
void RpcMethodTest::testChangeUri_fail()
|
||||||
{
|
{
|
||||||
SharedHandle<FileEntry> files[3];
|
SharedHandle<FileEntry> files[3];
|
||||||
for(int i = 0; i < 3; ++i) {
|
for(int i = 0; i < 3; ++i) {
|
||||||
|
@ -974,15 +954,15 @@ void XmlRpcMethodTest::testChangeUri_fail()
|
||||||
group->setDownloadContext(dctx);
|
group->setDownloadContext(dctx);
|
||||||
e_->getRequestGroupMan()->addReservedGroup(group);
|
e_->getRequestGroupMan()->addReservedGroup(group);
|
||||||
|
|
||||||
ChangeUriXmlRpcMethod m;
|
ChangeUriRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeUriXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(ChangeUriRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append("1"); // GID
|
req.params->append("1"); // GID
|
||||||
req.params->append(Integer::g(1)); // index of FileEntry
|
req.params->append(Integer::g(1)); // index of FileEntry
|
||||||
SharedHandle<List> removeuris = List::g();
|
SharedHandle<List> removeuris = List::g();
|
||||||
req.params->append(removeuris);
|
req.params->append(removeuris);
|
||||||
SharedHandle<List> adduris = List::g();
|
SharedHandle<List> adduris = List::g();
|
||||||
req.params->append(adduris);
|
req.params->append(adduris);
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
|
|
||||||
req.params->set(0, String::g("2"));
|
req.params->set(0, String::g("2"));
|
||||||
|
@ -1014,17 +994,17 @@ void XmlRpcMethodTest::testChangeUri_fail()
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testGetSessionInfo()
|
void RpcMethodTest::testGetSessionInfo()
|
||||||
{
|
{
|
||||||
GetSessionInfoXmlRpcMethod m;
|
GetSessionInfoRpcMethod m;
|
||||||
XmlRpcRequest req(GetSessionInfoXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(GetSessionInfoRpcMethod::getMethodName(), List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
CPPUNIT_ASSERT_EQUAL(util::toHex(e_->getSessionId()),
|
CPPUNIT_ASSERT_EQUAL(util::toHex(e_->getSessionId()),
|
||||||
getString(asDict(res.param), "sessionId"));
|
getString(asDict(res.param), "sessionId"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testPause()
|
void RpcMethodTest::testPause()
|
||||||
{
|
{
|
||||||
const std::string URIS[] = {
|
const std::string URIS[] = {
|
||||||
"http://url1",
|
"http://url1",
|
||||||
|
@ -1038,43 +1018,43 @@ void XmlRpcMethodTest::testPause()
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)3, groups.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)3, groups.size());
|
||||||
e_->getRequestGroupMan()->addReservedGroup(groups);
|
e_->getRequestGroupMan()->addReservedGroup(groups);
|
||||||
{
|
{
|
||||||
PauseXmlRpcMethod m;
|
PauseRpcMethod m;
|
||||||
XmlRpcRequest req(PauseXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(PauseRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append("1");
|
req.params->append("1");
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT(groups[0]->isPauseRequested());
|
CPPUNIT_ASSERT(groups[0]->isPauseRequested());
|
||||||
{
|
{
|
||||||
UnpauseXmlRpcMethod m;
|
UnpauseRpcMethod m;
|
||||||
XmlRpcRequest req(UnpauseXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(UnpauseRpcMethod::getMethodName(), List::g());
|
||||||
req.params->append("1");
|
req.params->append("1");
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT(!groups[0]->isPauseRequested());
|
CPPUNIT_ASSERT(!groups[0]->isPauseRequested());
|
||||||
{
|
{
|
||||||
PauseAllXmlRpcMethod m;
|
PauseAllRpcMethod m;
|
||||||
XmlRpcRequest req(PauseAllXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(PauseAllRpcMethod::getMethodName(), List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
}
|
}
|
||||||
for(size_t i = 0; i < groups.size(); ++i) {
|
for(size_t i = 0; i < groups.size(); ++i) {
|
||||||
CPPUNIT_ASSERT(groups[i]->isPauseRequested());
|
CPPUNIT_ASSERT(groups[i]->isPauseRequested());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
UnpauseAllXmlRpcMethod m;
|
UnpauseAllRpcMethod m;
|
||||||
XmlRpcRequest req(UnpauseAllXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(UnpauseAllRpcMethod::getMethodName(), List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
}
|
}
|
||||||
for(size_t i = 0; i < groups.size(); ++i) {
|
for(size_t i = 0; i < groups.size(); ++i) {
|
||||||
CPPUNIT_ASSERT(!groups[i]->isPauseRequested());
|
CPPUNIT_ASSERT(!groups[i]->isPauseRequested());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ForcePauseAllXmlRpcMethod m;
|
ForcePauseAllRpcMethod m;
|
||||||
XmlRpcRequest req(ForcePauseAllXmlRpcMethod::getMethodName(), List::g());
|
RpcRequest req(ForcePauseAllRpcMethod::getMethodName(), List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
}
|
}
|
||||||
for(size_t i = 0; i < groups.size(); ++i) {
|
for(size_t i = 0; i < groups.size(); ++i) {
|
||||||
|
@ -1082,15 +1062,15 @@ void XmlRpcMethodTest::testPause()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testSystemMulticall()
|
void RpcMethodTest::testSystemMulticall()
|
||||||
{
|
{
|
||||||
SystemMulticallXmlRpcMethod m;
|
SystemMulticallRpcMethod m;
|
||||||
XmlRpcRequest req("system.multicall", List::g());
|
RpcRequest req("system.multicall", List::g());
|
||||||
SharedHandle<List> reqparams = List::g();
|
SharedHandle<List> reqparams = List::g();
|
||||||
req.params->append(reqparams);
|
req.params->append(reqparams);
|
||||||
for(int i = 0; i < 2; ++i) {
|
for(int i = 0; i < 2; ++i) {
|
||||||
SharedHandle<Dict> dict = Dict::g();
|
SharedHandle<Dict> dict = Dict::g();
|
||||||
dict->put("methodName", AddUriXmlRpcMethod::getMethodName());
|
dict->put("methodName", AddUriRpcMethod::getMethodName());
|
||||||
SharedHandle<List> params = List::g();
|
SharedHandle<List> params = List::g();
|
||||||
SharedHandle<List> urisParam = List::g();
|
SharedHandle<List> urisParam = List::g();
|
||||||
urisParam->append("http://localhost/"+util::itos(i));
|
urisParam->append("http://localhost/"+util::itos(i));
|
||||||
|
@ -1116,16 +1096,16 @@ void XmlRpcMethodTest::testSystemMulticall()
|
||||||
{
|
{
|
||||||
// missing params
|
// missing params
|
||||||
SharedHandle<Dict> dict = Dict::g();
|
SharedHandle<Dict> dict = Dict::g();
|
||||||
dict->put("methodName", GetVersionXmlRpcMethod::getMethodName());
|
dict->put("methodName", GetVersionRpcMethod::getMethodName());
|
||||||
reqparams->append(dict);
|
reqparams->append(dict);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
SharedHandle<Dict> dict = Dict::g();
|
SharedHandle<Dict> dict = Dict::g();
|
||||||
dict->put("methodName", GetVersionXmlRpcMethod::getMethodName());
|
dict->put("methodName", GetVersionRpcMethod::getMethodName());
|
||||||
dict->put("params", List::g());
|
dict->put("params", List::g());
|
||||||
reqparams->append(dict);
|
reqparams->append(dict);
|
||||||
}
|
}
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
const List* resParams = asList(res.param);
|
const List* resParams = asList(res.param);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)7, resParams->size());
|
CPPUNIT_ASSERT_EQUAL((size_t)7, resParams->size());
|
||||||
|
@ -1152,14 +1132,14 @@ void XmlRpcMethodTest::testSystemMulticall()
|
||||||
CPPUNIT_ASSERT(asList(resParams->get(6)));
|
CPPUNIT_ASSERT(asList(resParams->get(6)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testSystemMulticall_fail()
|
void RpcMethodTest::testSystemMulticall_fail()
|
||||||
{
|
{
|
||||||
SystemMulticallXmlRpcMethod m;
|
SystemMulticallRpcMethod m;
|
||||||
XmlRpcRequest req("system.multicall", List::g());
|
RpcRequest req("system.multicall", List::g());
|
||||||
XmlRpcResponse res = m.execute(req, e_.get());
|
RpcResponse res = m.execute(req, e_.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
|
@ -1,29 +1,35 @@
|
||||||
#include "XmlRpcResponse.h"
|
#include "RpcResponse.h"
|
||||||
|
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
class XmlRpcResponseTest:public CppUnit::TestFixture {
|
class RpcResponseTest:public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST_SUITE(XmlRpcResponseTest);
|
CPPUNIT_TEST_SUITE(RpcResponseTest);
|
||||||
CPPUNIT_TEST(testToJson);
|
CPPUNIT_TEST(testToJson);
|
||||||
|
#ifdef ENABLE_XML_RPC
|
||||||
|
CPPUNIT_TEST(testToXml);
|
||||||
|
#endif // ENABLE_XML_RPC
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
public:
|
public:
|
||||||
void testToJson();
|
void testToJson();
|
||||||
|
#ifdef ENABLE_XML_RPC
|
||||||
|
void testToXml();
|
||||||
|
#endif // ENABLE_XML_RPC
|
||||||
};
|
};
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION(XmlRpcResponseTest);
|
CPPUNIT_TEST_SUITE_REGISTRATION(RpcResponseTest);
|
||||||
|
|
||||||
void XmlRpcResponseTest::testToJson()
|
void RpcResponseTest::testToJson()
|
||||||
{
|
{
|
||||||
std::vector<XmlRpcResponse> results;
|
std::vector<RpcResponse> results;
|
||||||
{
|
{
|
||||||
SharedHandle<List> param = List::g();
|
SharedHandle<List> param = List::g();
|
||||||
param->append(Integer::g(1));
|
param->append(Integer::g(1));
|
||||||
SharedHandle<String> id = String::g("9");
|
SharedHandle<String> id = String::g("9");
|
||||||
XmlRpcResponse res(0, param, id);
|
RpcResponse res(0, param, id);
|
||||||
results.push_back(res);
|
results.push_back(res);
|
||||||
std::string s = res.toJson("", false);
|
std::string s = res.toJson("", false);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("{\"id\":\"9\","
|
CPPUNIT_ASSERT_EQUAL(std::string("{\"id\":\"9\","
|
||||||
|
@ -36,7 +42,7 @@ void XmlRpcResponseTest::testToJson()
|
||||||
SharedHandle<Dict> param = Dict::g();
|
SharedHandle<Dict> param = Dict::g();
|
||||||
param->put("code", Integer::g(1));
|
param->put("code", Integer::g(1));
|
||||||
param->put("message", "HELLO ERROR");
|
param->put("message", "HELLO ERROR");
|
||||||
XmlRpcResponse res(1, param, Null::g());
|
RpcResponse res(1, param, Null::g());
|
||||||
results.push_back(res);
|
results.push_back(res);
|
||||||
std::string s = res.toJson("", false);
|
std::string s = res.toJson("", false);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("{\"error\":{\"code\":1,"
|
CPPUNIT_ASSERT_EQUAL(std::string("{\"error\":{\"code\":1,"
|
||||||
|
@ -63,6 +69,37 @@ void XmlRpcResponseTest::testToJson()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
#ifdef ENABLE_XML_RPC
|
||||||
|
void RpcResponseTest::testToXml()
|
||||||
|
{
|
||||||
|
SharedHandle<Dict> param = Dict::g();
|
||||||
|
param->put("faultCode", Integer::g(1));
|
||||||
|
param->put("faultString", "No such method: make.hamburger");
|
||||||
|
RpcResponse res(1, param, Null::g());
|
||||||
|
std::string s = res.toXml(false);
|
||||||
|
CPPUNIT_ASSERT_EQUAL
|
||||||
|
(std::string("<?xml version=\"1.0\"?>"
|
||||||
|
"<methodResponse>"
|
||||||
|
"<fault>"
|
||||||
|
"<value>"
|
||||||
|
"<struct>"
|
||||||
|
"<member>"
|
||||||
|
"<name>faultCode</name><value><int>1</int></value>"
|
||||||
|
"</member>"
|
||||||
|
"<member>"
|
||||||
|
"<name>faultString</name>"
|
||||||
|
"<value>"
|
||||||
|
"<string>No such method: make.hamburger</string>"
|
||||||
|
"</value>"
|
||||||
|
"</member>"
|
||||||
|
"</struct>"
|
||||||
|
"</value>"
|
||||||
|
"</fault>"
|
||||||
|
"</methodResponse>"),
|
||||||
|
s);
|
||||||
|
}
|
||||||
|
#endif // ENABLE_XML_RPC
|
||||||
|
|
||||||
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
class XmlRpcRequestParserControllerTest:public CppUnit::TestFixture {
|
class XmlRpcRequestParserControllerTest:public CppUnit::TestFixture {
|
||||||
|
|
||||||
|
@ -157,6 +157,6 @@ void XmlRpcRequestParserControllerTest::testPopArrayFrame_compound()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("jp"), asString(countryList->get(0))->s());
|
CPPUNIT_ASSERT_EQUAL(std::string("jp"), asString(countryList->get(0))->s());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace rpc {
|
||||||
|
|
||||||
class XmlRpcRequestProcessorTest:public CppUnit::TestFixture {
|
class XmlRpcRequestProcessorTest:public CppUnit::TestFixture {
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(XmlRpcRequestProcessorTest);
|
||||||
void XmlRpcRequestProcessorTest::testParseMemory()
|
void XmlRpcRequestProcessorTest::testParseMemory()
|
||||||
{
|
{
|
||||||
XmlRpcRequestProcessor proc;
|
XmlRpcRequestProcessor proc;
|
||||||
XmlRpcRequest req =
|
RpcRequest req =
|
||||||
proc.parseMemory("<?xml version=\"1.0\"?>"
|
proc.parseMemory("<?xml version=\"1.0\"?>"
|
||||||
"<methodCall>"
|
"<methodCall>"
|
||||||
" <methodName>aria2.addURI</methodName>"
|
" <methodName>aria2.addURI</methodName>"
|
||||||
|
@ -95,7 +95,7 @@ void XmlRpcRequestProcessorTest::testParseMemory_shouldFail()
|
||||||
// success
|
// success
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
XmlRpcRequest req =
|
RpcRequest req =
|
||||||
proc.parseMemory("<methodCall>"
|
proc.parseMemory("<methodCall>"
|
||||||
" <methodName>aria2.addURI</methodName>"
|
" <methodName>aria2.addURI</methodName>"
|
||||||
" <params>"
|
" <params>"
|
||||||
|
@ -104,7 +104,7 @@ void XmlRpcRequestProcessorTest::testParseMemory_shouldFail()
|
||||||
CPPUNIT_ASSERT(req.params);
|
CPPUNIT_ASSERT(req.params);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
XmlRpcRequest req =
|
RpcRequest req =
|
||||||
proc.parseMemory("<methodCall>"
|
proc.parseMemory("<methodCall>"
|
||||||
" <methodName>aria2.addURI</methodName>"
|
" <methodName>aria2.addURI</methodName>"
|
||||||
"</methodCall>");
|
"</methodCall>");
|
||||||
|
@ -114,6 +114,6 @@ void XmlRpcRequestProcessorTest::testParseMemory_shouldFail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xmlrpc
|
} // namespace rpc
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
Loading…
Reference in New Issue