From 41e203bf84d56038a989d04ae18209241aa3e24b Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 7 Mar 2010 06:04:15 +0000 Subject: [PATCH] 2010-03-07 Tatsuhiro Tsujikawa Added aria2.forceRemove XML-RPC method. * doc/aria2c.1.txt * src/XmlRpcMethodFactory.cc * src/XmlRpcMethodImpl.cc * src/XmlRpcMethodImpl.h --- ChangeLog | 8 ++++++++ doc/aria2c.1 | 4 ++++ doc/aria2c.1.html | 7 ++++++- doc/aria2c.1.txt | 7 +++++++ src/XmlRpcMethodFactory.cc | 2 ++ src/XmlRpcMethodImpl.cc | 21 +++++++++++++++++++-- src/XmlRpcMethodImpl.h | 11 +++++++++++ 7 files changed, 57 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9aef0406..d7d1e40a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-03-07 Tatsuhiro Tsujikawa + + Added aria2.forceRemove XML-RPC method. + * doc/aria2c.1.txt + * src/XmlRpcMethodFactory.cc + * src/XmlRpcMethodImpl.cc + * src/XmlRpcMethodImpl.h + 2010-03-07 Tatsuhiro Tsujikawa Added debug log. diff --git a/doc/aria2c.1 b/doc/aria2c.1 index 89b060cf..6a564414 100644 --- a/doc/aria2c.1 +++ b/doc/aria2c.1 @@ -2208,6 +2208,10 @@ This method adds Metalink download by uploading \&.metalink file\&. \fImetalink\ .sp This method removes the download denoted by \fIgid\fR\&. \fIgid\fR is of type string\&. If specified download is in progress, it is stopped at first\&. The status of removed download becomes "removed"\&. This method returns GID of removed download\&. .sp +\fBaria2\&.forceRemove\fR \fIgid\fR +.sp +This method removes the download denoted by \fIgid\fR\&. This method behaves just like \fBaria2\&.remove\fR except that this method removes download without any action which takes time such as contacting BitTorrent tracker\&. +.sp \fBaria2\&.tellStatus\fR \fIgid\fR .sp This method returns download progress of the download denoted by \fIgid\fR\&. \fIgid\fR is of type string\&. The response is of type struct and it contains following keys\&. The value type is string\&. diff --git a/doc/aria2c.1.html b/doc/aria2c.1.html index 4ab29dd6..e2360682 100644 --- a/doc/aria2c.1.html +++ b/doc/aria2c.1.html @@ -2752,6 +2752,11 @@ registered download.

string. If specified download is in progress, it is stopped at first. The status of removed download becomes "removed". This method returns GID of removed download.

+

aria2.forceRemove gid

+

This method removes the download denoted by gid. This method +behaves just like aria2.remove except that this method removes +download without any action which takes time such as contacting +BitTorrent tracker.

aria2.tellStatus gid

This method returns download progress of the download denoted by gid. gid is of type string. The response is of type struct and it @@ -3749,7 +3754,7 @@ files in the program, then also delete it here.


diff --git a/doc/aria2c.1.txt b/doc/aria2c.1.txt index 3d16e1a6..c5aab3f5 100644 --- a/doc/aria2c.1.txt +++ b/doc/aria2c.1.txt @@ -1189,6 +1189,13 @@ string. If specified download is in progress, it is stopped at first. The status of removed download becomes "removed". This method returns GID of removed download. +*aria2.forceRemove* 'gid' + +This method removes the download denoted by 'gid'. This method +behaves just like *aria2.remove* except that this method removes +download without any action which takes time such as contacting +BitTorrent tracker. + *aria2.tellStatus* 'gid' This method returns download progress of the download denoted by diff --git a/src/XmlRpcMethodFactory.cc b/src/XmlRpcMethodFactory.cc index e99ea72c..0374f2da 100644 --- a/src/XmlRpcMethodFactory.cc +++ b/src/XmlRpcMethodFactory.cc @@ -58,6 +58,8 @@ XmlRpcMethodFactory::create(const std::string& methodName) } else if(methodName == RemoveXmlRpcMethod::getMethodName()) { return SharedHandle(new RemoveXmlRpcMethod()); + } else if(methodName == ForceRemoveXmlRpcMethod::getMethodName()) { + return SharedHandle(new ForceRemoveXmlRpcMethod()); } else if(methodName == ChangePositionXmlRpcMethod::getMethodName()) { return SharedHandle(new ChangePositionXmlRpcMethod()); } else if(methodName == TellStatusXmlRpcMethod::getMethodName()) { diff --git a/src/XmlRpcMethodImpl.cc b/src/XmlRpcMethodImpl.cc index 32344a6a..19b7ca5e 100644 --- a/src/XmlRpcMethodImpl.cc +++ b/src/XmlRpcMethodImpl.cc @@ -280,7 +280,8 @@ BDE AddMetalinkXmlRpcMethod::process } #endif // ENABLE_METALINK -BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e) +static BDE removeDownload +(const XmlRpcRequest& req, DownloadEngine* e, bool forceRemove) { const BDE& params = req._params; assert(params.isList()); @@ -306,10 +307,26 @@ BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e) (StringFormat("GID#%d cannot be removed now", gid).str()); } } else { - group->setHaltRequested(true, RequestGroup::USER_REQUEST); + if(forceRemove) { + group->setForceHaltRequested(true, RequestGroup::USER_REQUEST); + } else { + group->setHaltRequested(true, RequestGroup::USER_REQUEST); + } } return createGIDResponse(gid); + +} + +BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e) +{ + return removeDownload(req, e, false); +} + +BDE ForceRemoveXmlRpcMethod::process +(const XmlRpcRequest& req, DownloadEngine* e) +{ + return removeDownload(req, e, true); } static void createUriEntry(BDE& uriList, const SharedHandle& file) diff --git a/src/XmlRpcMethodImpl.h b/src/XmlRpcMethodImpl.h index f69f0527..fe10ea7f 100644 --- a/src/XmlRpcMethodImpl.h +++ b/src/XmlRpcMethodImpl.h @@ -73,6 +73,17 @@ public: } }; +class ForceRemoveXmlRpcMethod:public XmlRpcMethod { +protected: + virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); +public: + static const std::string& getMethodName() + { + static std::string methodName = "aria2.forceRemove"; + return methodName; + } +}; + #ifdef ENABLE_BITTORRENT class AddTorrentXmlRpcMethod:public XmlRpcMethod { protected: