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>
|
||||
|
||||
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());
|
||||
} else if(methodName == "aria2.tellWaiting") {
|
||||
return SharedHandle<XmlRpcMethod>(new TellWaitingXmlRpcMethod());
|
||||
} else if(methodName == "aria2.tellStopped") {
|
||||
return SharedHandle<XmlRpcMethod>(new TellStoppedXmlRpcMethod());
|
||||
} else if(methodName == "aria2.getOption") {
|
||||
return SharedHandle<XmlRpcMethod>(new GetOptionXmlRpcMethod());
|
||||
} else if(methodName == "aria2.changeOption") {
|
||||
|
|
|
@ -582,8 +582,10 @@ BDE TellActiveXmlRpcMethod::process
|
|||
return list;
|
||||
}
|
||||
|
||||
BDE TellWaitingXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
template<typename InputIterator>
|
||||
static std::pair<InputIterator, InputIterator>
|
||||
getPaginationRange
|
||||
(const XmlRpcRequest& req, InputIterator first, InputIterator last)
|
||||
{
|
||||
const BDE& params = req._params;
|
||||
assert(params.isList());
|
||||
|
@ -598,27 +600,52 @@ BDE TellWaitingXmlRpcMethod::process
|
|||
size_t num = params[1].i();
|
||||
|
||||
BDE list = BDE::list();
|
||||
const std::deque<SharedHandle<RequestGroup> >& waitings =
|
||||
e->_requestGroupMan->getReservedGroups();
|
||||
if(waitings.size() <= offset) {
|
||||
return list;
|
||||
size_t size = std::distance(first, last);
|
||||
if(size <= offset) {
|
||||
return std::make_pair(last, last);
|
||||
}
|
||||
size_t lastDistance;
|
||||
if(waitings.size() < offset+num) {
|
||||
lastDistance = waitings.size();
|
||||
if(size < offset+num) {
|
||||
lastDistance = size;
|
||||
} else {
|
||||
lastDistance = offset+num;
|
||||
}
|
||||
std::deque<SharedHandle<RequestGroup> >::const_iterator first =
|
||||
waitings.begin();
|
||||
last = first;
|
||||
std::advance(first, offset);
|
||||
std::deque<SharedHandle<RequestGroup> >::const_iterator last =
|
||||
waitings.begin();
|
||||
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();
|
||||
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;
|
||||
}
|
||||
return list;
|
||||
|
|
|
@ -105,6 +105,11 @@ protected:
|
|||
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 {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
|
|
Loading…
Reference in New Issue