mirror of https://github.com/aria2/aria2
2009-05-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added remove xml-rpc command which removes specified download. There is a known issue: the removed unfinished downloads are reported ERR when aria2 exits. They should be reported as INPR. * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/XmlRpcMethodFactory.cc * src/XmlRpcMethodImpl.cc * src/XmlRpcMethodImpl.hpull/1/head
parent
7f7ea34a4a
commit
c659b07b86
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2009-05-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Added remove xml-rpc command which removes specified download.
|
||||
There is a known issue: the removed unfinished downloads are
|
||||
reported ERR when aria2 exits. They should be reported as INPR.
|
||||
* src/RequestGroupMan.cc
|
||||
* src/RequestGroupMan.h
|
||||
* src/XmlRpcMethodFactory.cc
|
||||
* src/XmlRpcMethodImpl.cc
|
||||
* src/XmlRpcMethodImpl.h
|
||||
|
||||
2009-05-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
If --enable-http-server is enabled, don't stop aria2 when all
|
||||
|
|
|
@ -133,6 +133,18 @@ RequestGroupMan::getRequestGroups() const
|
|||
return _requestGroups;
|
||||
}
|
||||
|
||||
SharedHandle<RequestGroup>
|
||||
RequestGroupMan::findRequestGroup(int32_t gid) const
|
||||
{
|
||||
for(std::deque<SharedHandle<RequestGroup> >::const_iterator i =
|
||||
_requestGroups.begin(); i != _requestGroups.end(); ++i) {
|
||||
if((*i)->getGID() == gid) {
|
||||
return *i;
|
||||
}
|
||||
}
|
||||
return SharedHandle<RequestGroup>();
|
||||
}
|
||||
|
||||
const std::deque<SharedHandle<RequestGroup> >&
|
||||
RequestGroupMan::getReservedGroups() const
|
||||
{
|
||||
|
|
|
@ -112,6 +112,8 @@ public:
|
|||
|
||||
const std::deque<SharedHandle<RequestGroup> >& getRequestGroups() const;
|
||||
|
||||
SharedHandle<RequestGroup> findRequestGroup(int32_t gid) const;
|
||||
|
||||
const std::deque<SharedHandle<RequestGroup> >& getReservedGroups() const;
|
||||
|
||||
void showDownloadResults(std::ostream& o) const;
|
||||
|
|
|
@ -46,6 +46,8 @@ XmlRpcMethodFactory::create(const std::string& methodName)
|
|||
{
|
||||
if(methodName == "aria2.addURI") {
|
||||
return SharedHandle<XmlRpcMethod>(new AddURIXmlRpcMethod());
|
||||
} else if(methodName == "aria2.remove") {
|
||||
return SharedHandle<XmlRpcMethod>(new RemoveXmlRpcMethod());
|
||||
} else {
|
||||
return SharedHandle<XmlRpcMethod>(new FailXmlRpcMethod());
|
||||
}
|
||||
|
|
|
@ -89,6 +89,32 @@ BDE AddURIXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
|||
}
|
||||
}
|
||||
|
||||
BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
{
|
||||
const BDE& params = req._params;
|
||||
assert(params.isList());
|
||||
|
||||
if(params.empty() || !params[0].isString()) {
|
||||
throw DlAbortEx("GID is not provided.");
|
||||
}
|
||||
|
||||
int32_t gid = Util::parseInt(params[0].s());
|
||||
|
||||
SharedHandle<RequestGroup> group = e->_requestGroupMan->findRequestGroup(gid);
|
||||
|
||||
if(group.isNull()) {
|
||||
throw DlAbortEx
|
||||
(StringFormat("Active Download not found for GID#%d", gid).str());
|
||||
}
|
||||
|
||||
group->setHaltRequested(true);
|
||||
|
||||
BDE resParams = BDE::list();
|
||||
resParams << BDE("OK");
|
||||
resParams << BDE(Util::itos(gid));
|
||||
return resParams;
|
||||
}
|
||||
|
||||
BDE FailXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
{
|
||||
throw DlAbortEx
|
||||
|
|
|
@ -46,6 +46,11 @@ protected:
|
|||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
};
|
||||
|
||||
class RemoveXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
};
|
||||
|
||||
class FailXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
|
|
Loading…
Reference in New Issue