ソースを参照

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

	Made 'fileIndex' parameter in aria2.changeUri XML-RPC method
	1-based.
	* doc/aria2c.1.txt
	* src/XmlRpcMethodImpl.cc
	* test/XmlRpcMethodTest.cc
Tatsuhiro Tsujikawa 15 年 前
コミット
2cb0c8e69d
6 ファイル変更33 行追加25 行削除
  1. 8 0
      ChangeLog
  2. 1 1
      doc/aria2c.1
  3. 9 9
      doc/aria2c.1.html
  4. 8 8
      doc/aria2c.1.txt
  5. 2 2
      src/XmlRpcMethodImpl.cc
  6. 5 5
      test/XmlRpcMethodTest.cc

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2010-03-07  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Made 'fileIndex' parameter in aria2.changeUri XML-RPC method
+	1-based.
+	* doc/aria2c.1.txt
+	* src/XmlRpcMethodImpl.cc
+	* test/XmlRpcMethodTest.cc
+
 2010-03-07  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Call RequestGroupMan::requestQueueCheck() when

+ 1 - 1
doc/aria2c.1

@@ -2482,7 +2482,7 @@ For example, if GID#1 is placed in position 3, aria2\&.changePosition(1, \-1, PO
 .sp
 \fBaria2\&.changeUri\fR \fIgid, fileIndex, delUris, addUris[, position]\fR
 .sp
-This method removes URIs in \fIdelUris\fR from and appends URIs in \fIaddUris\fR to download denoted by \fIgid\fR\&. \fIdelUris\fR and \fIaddUris\fR are list of string\&. A download can contain multiple files and URIs are attached to each file\&. \fIfileIndex\fR is used to select which file to remove/attach given URIs\&. \fIposition\fR is used to specify where URIs are inserted in the existing waiting URI list\&. \fIposition\fR is 0\-based\&. When \fIposition\fR is omitted, URIs are appended to the back of the list\&. This method first execute removal and then addition\&. \fIposition\fR is the position after URIs are removed, not the position when this method is called\&. When removing URI, if same URIs exist in download, only one of them is removed for each URI in \fIdelUris\fR\&. In other words, there are three URIs "http://example\&.org/aria2" and you want remove them all, you have to specify (at least) 3 "http://example\&.org/aria2" in \fIdelUris\fR\&. This method returns a list which contains 2 integers\&. The first integer is the number of URIs deleted\&. The second integer is the number of URIs added\&.
+This method removes URIs in \fIdelUris\fR from and appends URIs in \fIaddUris\fR to download denoted by \fIgid\fR\&. \fIdelUris\fR and \fIaddUris\fR are list of string\&. A download can contain multiple files and URIs are attached to each file\&. \fIfileIndex\fR is used to select which file to remove/attach given URIs\&. \fIfileIndex\fR is 1\-based\&. \fIposition\fR is used to specify where URIs are inserted in the existing waiting URI list\&. \fIposition\fR is 0\-based\&. When \fIposition\fR is omitted, URIs are appended to the back of the list\&. This method first execute removal and then addition\&. \fIposition\fR is the position after URIs are removed, not the position when this method is called\&. When removing URI, if same URIs exist in download, only one of them is removed for each URI in \fIdelUris\fR\&. In other words, there are three URIs "http://example\&.org/aria2" and you want remove them all, you have to specify (at least) 3 "http://example\&.org/aria2" in \fIdelUris\fR\&. This method returns a list which contains 2 integers\&. The first integer is the number of URIs deleted\&. The second integer is the number of URIs added\&.
 .sp
 \fBaria2\&.getOption\fR \fIgid\fR
 .sp

+ 9 - 9
doc/aria2c.1.html

@@ -3195,14 +3195,14 @@ beginning of the queue).</p></div>
 <em>addUris</em> to download denoted by <em>gid</em>. <em>delUris</em> and <em>addUris</em> are
 list of string. A download can contain multiple files and URIs are
 attached to each file.  <em>fileIndex</em> is used to select which file to
-remove/attach given URIs.  <em>position</em> is used to specify where URIs
-are inserted in the existing waiting URI list. <em>position</em> is
-0-based. When <em>position</em> is omitted, URIs are appended to the back of
-the list.  This method first execute removal and then
-addition. <em>position</em> is the position after URIs are removed, not the
-position when this method is called.  When removing URI, if same URIs
-exist in download, only one of them is removed for each URI in
-<em>delUris</em>. In other words, there are three URIs
+remove/attach given URIs. <em>fileIndex</em> is 1-based. <em>position</em> is used
+to specify where URIs are inserted in the existing waiting URI
+list. <em>position</em> is 0-based. When <em>position</em> is omitted, URIs are
+appended to the back of the list.  This method first execute removal
+and then addition. <em>position</em> is the position after URIs are removed,
+not the position when this method is called.  When removing URI, if
+same URIs exist in download, only one of them is removed for each URI
+in <em>delUris</em>. In other words, there are three URIs
 "http://example.org/aria2" and you want remove them all, you have to
 specify (at least) 3 "http://example.org/aria2" in <em>delUris</em>.  This
 method returns a list which contains 2 integers. The first integer is
@@ -3754,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 14:59:45 JST
+Last updated 2010-03-07 16:16:27 JST
 </div>
 </div>
 </body>

+ 8 - 8
doc/aria2c.1.txt

@@ -1483,14 +1483,14 @@ This method removes URIs in 'delUris' from and appends URIs in
 'addUris' to download denoted by 'gid'. 'delUris' and 'addUris' are
 list of string. A download can contain multiple files and URIs are
 attached to each file.  'fileIndex' is used to select which file to
-remove/attach given URIs.  'position' is used to specify where URIs
-are inserted in the existing waiting URI list. 'position' is
-0-based. When 'position' is omitted, URIs are appended to the back of
-the list.  This method first execute removal and then
-addition. 'position' is the position after URIs are removed, not the
-position when this method is called.  When removing URI, if same URIs
-exist in download, only one of them is removed for each URI in
-'delUris'. In other words, there are three URIs
+remove/attach given URIs. 'fileIndex' is 1-based. 'position' is used
+to specify where URIs are inserted in the existing waiting URI
+list. 'position' is 0-based. When 'position' is omitted, URIs are
+appended to the back of the list.  This method first execute removal
+and then addition. 'position' is the position after URIs are removed,
+not the position when this method is called.  When removing URI, if
+same URIs exist in download, only one of them is removed for each URI
+in 'delUris'. In other words, there are three URIs
 "http://example.org/aria2" and you want remove them all, you have to
 specify (at least) 3 "http://example.org/aria2" in 'delUris'.  This
 method returns a list which contains 2 integers. The first integer is

+ 2 - 2
src/XmlRpcMethodImpl.cc

@@ -889,7 +889,7 @@ BDE ChangeUriXmlRpcMethod::process
   if(params.size() < 4 ||
      !params[0].isString() || !params[1].isInteger() ||
      !params[2].isList() || !params[3].isList() ||
-     params[1].i() < 0) {
+     params[1].i() <= 0) {
     throw DL_ABORT_EX("Bad request");
   }
   size_t pos = 0;
@@ -897,7 +897,7 @@ BDE ChangeUriXmlRpcMethod::process
   getPosParam(params, 4, posGiven, pos);
 
   int32_t gid = util::parseInt(params[0].s());
-  size_t index = params[1].i();
+  size_t index = params[1].i()-1;
   const BDE& deluris = params[2];
   const BDE& adduris = params[3];
   SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);

+ 5 - 5
test/XmlRpcMethodTest.cc

@@ -801,7 +801,7 @@ void XmlRpcMethodTest::testChangeUri()
   ChangeUriXmlRpcMethod m;
   XmlRpcRequest req(ChangeUriXmlRpcMethod::getMethodName(), BDE::list());
   req._params << std::string("1"); // GID
-  req._params << 1; // index of FileEntry
+  req._params << 2; // index of FileEntry
   BDE removeuris = BDE::list();
   removeuris << std::string("http://example.org/mustremove1");
   removeuris << std::string("http://example.org/mustremove2");
@@ -843,7 +843,7 @@ void XmlRpcMethodTest::testChangeUri()
   CPPUNIT_ASSERT_EQUAL(std::string("http://example.org/added1-2"), uris[3]);
 
   // Change index of FileEntry
-  req._params[1] = 0;
+  req._params[1] = 1;
   // Set position far beyond the size of uris in FileEntry.
   req._params[4] = 1000;
   res = m.execute(req, _e.get());
@@ -871,7 +871,7 @@ void XmlRpcMethodTest::testChangeUri_fail()
   ChangeUriXmlRpcMethod m;
   XmlRpcRequest req(ChangeUriXmlRpcMethod::getMethodName(), BDE::list());
   req._params << std::string("1"); // GID
-  req._params << 0; // index of FileEntry
+  req._params << 1; // index of FileEntry
   BDE removeuris = BDE::list();
   req._params << removeuris;
   BDE adduris = BDE::list();
@@ -885,7 +885,7 @@ void XmlRpcMethodTest::testChangeUri_fail()
   CPPUNIT_ASSERT_EQUAL(1, res._code);
 
   req._params[0] = std::string("1");
-  req._params[1] = 3;
+  req._params[1] = 4;
   res = m.execute(req, _e.get());  
   // RPC request fails because FileEntry#3 does not exist.
   CPPUNIT_ASSERT_EQUAL(1, res._code);
@@ -895,7 +895,7 @@ void XmlRpcMethodTest::testChangeUri_fail()
   // RPC request fails because index of FileEntry is string.
   CPPUNIT_ASSERT_EQUAL(1, res._code);
 
-  req._params[1] = 0;
+  req._params[1] = 1;
   req._params[2] = std::string("http://url");
   res = m.execute(req, _e.get());  
   // RPC request fails because 3rd param is not list.