mirror of https://github.com/aria2/aria2
2009-12-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added tellStopped XML-RPC method. This method returns stopped download in the specified range. It takes same parameters with tellWaiting XML-RPC method. offset = 0 means the oldest download. * src/XmlRpcMethodFactory.cc * src/XmlRpcMethodImpl.cc * src/XmlRpcMethodImpl.hpull/1/head
parent
88bcc6e681
commit
4e294c7129
|
@ -1,3 +1,12 @@
|
||||||
|
2009-12-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Added tellStopped XML-RPC method. This method returns stopped
|
||||||
|
download in the specified range. It takes same parameters with
|
||||||
|
tellWaiting XML-RPC method. offset = 0 means the oldest download.
|
||||||
|
* src/XmlRpcMethodFactory.cc
|
||||||
|
* src/XmlRpcMethodImpl.cc
|
||||||
|
* src/XmlRpcMethodImpl.h
|
||||||
|
|
||||||
2009-12-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-12-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Use AI_ADDRCONFIG flag if it is available. Refactored so that
|
Use AI_ADDRCONFIG flag if it is available. Refactored so that
|
||||||
|
|
|
@ -75,6 +75,8 @@ XmlRpcMethodFactory::create(const std::string& methodName)
|
||||||
return SharedHandle<XmlRpcMethod>(new TellActiveXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new TellActiveXmlRpcMethod());
|
||||||
} else if(methodName == "aria2.tellWaiting") {
|
} else if(methodName == "aria2.tellWaiting") {
|
||||||
return SharedHandle<XmlRpcMethod>(new TellWaitingXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new TellWaitingXmlRpcMethod());
|
||||||
|
} else if(methodName == "aria2.tellStopped") {
|
||||||
|
return SharedHandle<XmlRpcMethod>(new TellStoppedXmlRpcMethod());
|
||||||
} else if(methodName == "aria2.getOption") {
|
} else if(methodName == "aria2.getOption") {
|
||||||
return SharedHandle<XmlRpcMethod>(new GetOptionXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new GetOptionXmlRpcMethod());
|
||||||
} else if(methodName == "aria2.changeOption") {
|
} else if(methodName == "aria2.changeOption") {
|
||||||
|
|
|
@ -582,8 +582,10 @@ BDE TellActiveXmlRpcMethod::process
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
BDE TellWaitingXmlRpcMethod::process
|
template<typename InputIterator>
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
static std::pair<InputIterator, InputIterator>
|
||||||
|
getPaginationRange
|
||||||
|
(const XmlRpcRequest& req, InputIterator first, InputIterator last)
|
||||||
{
|
{
|
||||||
const BDE& params = req._params;
|
const BDE& params = req._params;
|
||||||
assert(params.isList());
|
assert(params.isList());
|
||||||
|
@ -598,27 +600,52 @@ BDE TellWaitingXmlRpcMethod::process
|
||||||
size_t num = params[1].i();
|
size_t num = params[1].i();
|
||||||
|
|
||||||
BDE list = BDE::list();
|
BDE list = BDE::list();
|
||||||
const std::deque<SharedHandle<RequestGroup> >& waitings =
|
size_t size = std::distance(first, last);
|
||||||
e->_requestGroupMan->getReservedGroups();
|
if(size <= offset) {
|
||||||
if(waitings.size() <= offset) {
|
return std::make_pair(last, last);
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
size_t lastDistance;
|
size_t lastDistance;
|
||||||
if(waitings.size() < offset+num) {
|
if(size < offset+num) {
|
||||||
lastDistance = waitings.size();
|
lastDistance = size;
|
||||||
} else {
|
} else {
|
||||||
lastDistance = offset+num;
|
lastDistance = offset+num;
|
||||||
}
|
}
|
||||||
std::deque<SharedHandle<RequestGroup> >::const_iterator first =
|
last = first;
|
||||||
waitings.begin();
|
|
||||||
std::advance(first, offset);
|
std::advance(first, offset);
|
||||||
std::deque<SharedHandle<RequestGroup> >::const_iterator last =
|
|
||||||
waitings.begin();
|
|
||||||
std::advance(last, lastDistance);
|
std::advance(last, lastDistance);
|
||||||
for(; first != last; ++first) {
|
return std::make_pair(first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
BDE TellWaitingXmlRpcMethod::process
|
||||||
|
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
|
{
|
||||||
|
const std::deque<SharedHandle<RequestGroup> >& waitings =
|
||||||
|
e->_requestGroupMan->getReservedGroups();
|
||||||
|
std::pair<std::deque<SharedHandle<RequestGroup> >::const_iterator,
|
||||||
|
std::deque<SharedHandle<RequestGroup> >::const_iterator> range =
|
||||||
|
getPaginationRange(req, waitings.begin(), waitings.end());
|
||||||
|
BDE list = BDE::list();
|
||||||
|
for(; range.first != range.second; ++range.first) {
|
||||||
BDE entryDict = BDE::dict();
|
BDE entryDict = BDE::dict();
|
||||||
entryDict[KEY_STATUS] = BDE_WAITING;
|
entryDict[KEY_STATUS] = BDE_WAITING;
|
||||||
gatherProgress(entryDict, *first, e);
|
gatherProgress(entryDict, *range.first, e);
|
||||||
|
list << entryDict;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
BDE TellStoppedXmlRpcMethod::process
|
||||||
|
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
|
{
|
||||||
|
const std::deque<SharedHandle<DownloadResult> >& stopped =
|
||||||
|
e->_requestGroupMan->getDownloadResults();
|
||||||
|
std::pair<std::deque<SharedHandle<DownloadResult> >::const_iterator,
|
||||||
|
std::deque<SharedHandle<DownloadResult> >::const_iterator> range =
|
||||||
|
getPaginationRange(req, stopped.begin(), stopped.end());
|
||||||
|
BDE list = BDE::list();
|
||||||
|
for(; range.first != range.second; ++range.first) {
|
||||||
|
BDE entryDict = BDE::dict();
|
||||||
|
gatherStoppedDownload(entryDict, *range.first);
|
||||||
list << entryDict;
|
list << entryDict;
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|
|
@ -105,6 +105,11 @@ protected:
|
||||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TellStoppedXmlRpcMethod:public XmlRpcMethod {
|
||||||
|
protected:
|
||||||
|
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||||
|
};
|
||||||
|
|
||||||
class ChangeOptionXmlRpcMethod:public XmlRpcMethod {
|
class ChangeOptionXmlRpcMethod:public XmlRpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||||
|
|
Loading…
Reference in New Issue