Переглянути джерело

2010-03-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Added aria2.forceRemove XML-RPC method.
	* doc/aria2c.1.txt
	* src/XmlRpcMethodFactory.cc
	* src/XmlRpcMethodImpl.cc
	* src/XmlRpcMethodImpl.h
Tatsuhiro Tsujikawa 15 роки тому
батько
коміт
41e203bf84
7 змінених файлів з 57 додано та 3 видалено
  1. 8 0
      ChangeLog
  2. 4 0
      doc/aria2c.1
  3. 6 1
      doc/aria2c.1.html
  4. 7 0
      doc/aria2c.1.txt
  5. 2 0
      src/XmlRpcMethodFactory.cc
  6. 19 2
      src/XmlRpcMethodImpl.cc
  7. 11 0
      src/XmlRpcMethodImpl.h

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2010-03-07  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Added aria2.forceRemove XML-RPC method.
+	* doc/aria2c.1.txt
+	* src/XmlRpcMethodFactory.cc
+	* src/XmlRpcMethodImpl.cc
+	* src/XmlRpcMethodImpl.h
+
 2010-03-07  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Added debug log.

+ 4 - 0
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\&.

+ 6 - 1
doc/aria2c.1.html

@@ -2752,6 +2752,11 @@ registered download.</p></div>
 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.</p></div>
+<div class="paragraph"><p><strong>aria2.forceRemove</strong> <em>gid</em></p></div>
+<div class="paragraph"><p>This method removes the download denoted by <em>gid</em>.  This method
+behaves just like <strong>aria2.remove</strong> except that this method removes
+download without any action which takes time such as contacting
+BitTorrent tracker.</p></div>
 <div class="paragraph"><p><strong>aria2.tellStatus</strong> <em>gid</em></p></div>
 <div class="paragraph"><p>This method returns download progress of the download denoted by
 <em>gid</em>. <em>gid</em> 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.</p></div>
 <div id="footnotes"><hr /></div>
 <div id="footer">
 <div id="footer-text">
-Last updated 2010-03-07 00:00:09 JST
+Last updated 2010-03-07 14:59:45 JST
 </div>
 </div>
 </body>

+ 7 - 0
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

+ 2 - 0
src/XmlRpcMethodFactory.cc

@@ -58,6 +58,8 @@ XmlRpcMethodFactory::create(const std::string& methodName)
   }
   else if(methodName == RemoveXmlRpcMethod::getMethodName()) {
     return SharedHandle<XmlRpcMethod>(new RemoveXmlRpcMethod());
+  } else if(methodName == ForceRemoveXmlRpcMethod::getMethodName()) {
+    return SharedHandle<XmlRpcMethod>(new ForceRemoveXmlRpcMethod());
   } else if(methodName == ChangePositionXmlRpcMethod::getMethodName()) {
     return SharedHandle<XmlRpcMethod>(new ChangePositionXmlRpcMethod());
   } else if(methodName == TellStatusXmlRpcMethod::getMethodName()) {

+ 19 - 2
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<FileEntry>& file)

+ 11 - 0
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: