mirror of https://github.com/kiwix/libkiwix.git
Add few helper methods to xmlrpc objects.
This commit is contained in:
parent
18fc5cb4df
commit
be6dc01b4f
|
@ -101,7 +101,7 @@ std::string Aria2::doRequest(const MethodCall& methodCall)
|
|||
std::string Aria2::addUri(const std::vector<std::string>& uris)
|
||||
{
|
||||
MethodCall methodCall("aria2.addUri", m_secret);
|
||||
auto uriParams = methodCall.getParams().addParam().getValue().getArray();
|
||||
auto uriParams = methodCall.newParamValue().getArray();
|
||||
for (auto& uri : uris) {
|
||||
uriParams.addValue().set(uri);
|
||||
}
|
||||
|
@ -118,9 +118,9 @@ std::string Aria2::addUri(const std::vector<std::string>& uris)
|
|||
std::string Aria2::tellStatus(const std::string& gid, const std::vector<std::string>& statusKey)
|
||||
{
|
||||
MethodCall methodCall("aria2.tellStatus", m_secret);
|
||||
methodCall.getParams().addParam().getValue().set(gid);
|
||||
methodCall.newParamValue().set(gid);
|
||||
if (!statusKey.empty()) {
|
||||
auto statusArray = methodCall.getParams().addParam().getValue().getArray();
|
||||
auto statusArray = methodCall.newParamValue().getArray();
|
||||
for (auto& key : statusKey) {
|
||||
statusArray.addValue().set(key);
|
||||
}
|
||||
|
|
14
src/xmlrpc.h
14
src/xmlrpc.h
|
@ -215,6 +215,10 @@ class MethodCall {
|
|||
return Params(m_doc.child("methodCall").child("params"));
|
||||
}
|
||||
|
||||
Value newParamValue() {
|
||||
return getParams().addParam().getValue();
|
||||
}
|
||||
|
||||
std::string toString() const {
|
||||
return nodeToString(m_doc);
|
||||
}
|
||||
|
@ -236,11 +240,19 @@ class MethodResponse {
|
|||
return Params(params);
|
||||
}
|
||||
|
||||
Value getParamValue(int index) const {
|
||||
return getParams().getParam(index).getValue();
|
||||
}
|
||||
|
||||
bool isFault() const {
|
||||
return (!!m_doc.child("methodResponse").child("fault"));
|
||||
}
|
||||
|
||||
Fault getFault() const {
|
||||
auto fault = m_doc.child("methodResponse").child("fault");
|
||||
if (!fault)
|
||||
throw InvalidRPCNode("No fault");
|
||||
return Fault(fault);
|
||||
return Fault(fault.child("value").child("struct"));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue