mirror of https://github.com/aria2/aria2
2010-01-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added dir and files key to the response struct of aria2.tellStatus XML-RPC method. The value associated with files key is the list of files. Its element is the same struct used in aria2.getFiles XML-RPC method. Added uris key to the response struct of aria2.getFiles XML-RPC method. The value associated with uris key is the list of URIs. Its element is the same struct used in aria2.getUris XML-RPC method. * doc/aria2c.1.txt * src/XmlRpcMethodImpl.cc * test/XmlRpcMethodTest.ccpull/1/head
parent
f2722cb870
commit
2d74b16583
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2010-01-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Added dir and files key to the response struct of aria2.tellStatus
|
||||||
|
XML-RPC method. The value associated with files key is the list
|
||||||
|
of files. Its element is the same struct used in aria2.getFiles
|
||||||
|
XML-RPC method. Added uris key to the response struct of
|
||||||
|
aria2.getFiles XML-RPC method. The value associated with uris key
|
||||||
|
is the list of URIs. Its element is the same struct used in
|
||||||
|
aria2.getUris XML-RPC method.
|
||||||
|
* doc/aria2c.1.txt
|
||||||
|
* src/XmlRpcMethodImpl.cc
|
||||||
|
* test/XmlRpcMethodTest.cc
|
||||||
|
|
||||||
2010-01-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-01-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Added aria2.getSessionInfo XML-RPC method. This method returns a
|
Added aria2.getSessionInfo XML-RPC method. This method returns a
|
||||||
|
|
19
doc/aria2c.1
19
doc/aria2c.1
|
@ -2287,6 +2287,18 @@ belongsTo
|
||||||
.RS 4
|
.RS 4
|
||||||
GID of a parent download\&. Some downloads are a part of another download\&. For example, if a file in Metalink has BitTorrent resource, the download of \&.torrent is a part of that file\&. If this download has no parent, this key will not be included in the response\&.
|
GID of a parent download\&. Some downloads are a part of another download\&. For example, if a file in Metalink has BitTorrent resource, the download of \&.torrent is a part of that file\&. If this download has no parent, this key will not be included in the response\&.
|
||||||
.RE
|
.RE
|
||||||
|
.PP
|
||||||
|
dir
|
||||||
|
.RS 4
|
||||||
|
Directory to save files\&. This key is not available for stopped downloads\&.
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
|
files
|
||||||
|
.RS 4
|
||||||
|
Returns the list of files\&. The element of list is the same struct used in
|
||||||
|
\fBaria2\&.getFiles\fR
|
||||||
|
method\&.
|
||||||
|
.RE
|
||||||
.sp
|
.sp
|
||||||
\fBaria2\&.getUris\fR \fIgid\fR
|
\fBaria2\&.getUris\fR \fIgid\fR
|
||||||
.sp
|
.sp
|
||||||
|
@ -2324,6 +2336,13 @@ option\&. If
|
||||||
\fB\-\-select\-file\fR
|
\fB\-\-select\-file\fR
|
||||||
is not specified or this is single torrent or no torrent download, this value is always "true"\&. Otherwise "false"\&.
|
is not specified or this is single torrent or no torrent download, this value is always "true"\&. Otherwise "false"\&.
|
||||||
.RE
|
.RE
|
||||||
|
.PP
|
||||||
|
uris
|
||||||
|
.RS 4
|
||||||
|
Returns the list of URI for this file\&. The element of list is the same struct used in
|
||||||
|
\fBaria2\&.getUris\fR
|
||||||
|
method\&.
|
||||||
|
.RE
|
||||||
.sp
|
.sp
|
||||||
\fBaria2\&.getPeers\fR \fIgid\fR
|
\fBaria2\&.getPeers\fR \fIgid\fR
|
||||||
.sp
|
.sp
|
||||||
|
|
|
@ -2893,6 +2893,24 @@ belongsTo
|
||||||
response.
|
response.
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
|
<dt class="hdlist1">
|
||||||
|
dir
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
Directory to save files. This key is not available for stopped
|
||||||
|
downloads.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt class="hdlist1">
|
||||||
|
files
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
Returns the list of files. The element of list is the same struct
|
||||||
|
used in <strong>aria2.getFiles</strong> method.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
<div class="paragraph"><p><strong>aria2.getUris</strong> <em>gid</em></p></div>
|
<div class="paragraph"><p><strong>aria2.getUris</strong> <em>gid</em></p></div>
|
||||||
<div class="paragraph"><p>This method returns URIs used in the download denoted by <em>gid</em>. <em>gid</em>
|
<div class="paragraph"><p>This method returns URIs used in the download denoted by <em>gid</em>. <em>gid</em>
|
||||||
|
@ -2948,6 +2966,15 @@ selected
|
||||||
torrent download, this value is always "true". Otherwise "false".
|
torrent download, this value is always "true". Otherwise "false".
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
|
<dt class="hdlist1">
|
||||||
|
uris
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
Returns the list of URI for this file. The element of list is the
|
||||||
|
same struct used in <strong>aria2.getUris</strong> method.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
<div class="paragraph"><p><strong>aria2.getPeers</strong> <em>gid</em></p></div>
|
<div class="paragraph"><p><strong>aria2.getPeers</strong> <em>gid</em></p></div>
|
||||||
<div class="paragraph"><p>This method returns peer list of the download denoted by <em>gid</em>. <em>gid</em>
|
<div class="paragraph"><p>This method returns peer list of the download denoted by <em>gid</em>. <em>gid</em>
|
||||||
|
@ -3610,7 +3637,7 @@ files in the program, then also delete it here.</p></div>
|
||||||
<div id="footnotes"><hr /></div>
|
<div id="footnotes"><hr /></div>
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
<div id="footer-text">
|
<div id="footer-text">
|
||||||
Last updated 2010-01-17 20:50:31 JST
|
Last updated 2010-01-17 22:45:25 JST
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -1269,6 +1269,16 @@ belongsTo::
|
||||||
download has no parent, this key will not be included in the
|
download has no parent, this key will not be included in the
|
||||||
response.
|
response.
|
||||||
|
|
||||||
|
dir::
|
||||||
|
|
||||||
|
Directory to save files. This key is not available for stopped
|
||||||
|
downloads.
|
||||||
|
|
||||||
|
files::
|
||||||
|
|
||||||
|
Returns the list of files. The element of list is the same struct
|
||||||
|
used in *aria2.getFiles* method.
|
||||||
|
|
||||||
*aria2.getUris* 'gid'
|
*aria2.getUris* 'gid'
|
||||||
|
|
||||||
This method returns URIs used in the download denoted by 'gid'. 'gid'
|
This method returns URIs used in the download denoted by 'gid'. 'gid'
|
||||||
|
@ -1304,6 +1314,10 @@ selected::
|
||||||
*--select-file* is not specified or this is single torrent or no
|
*--select-file* is not specified or this is single torrent or no
|
||||||
torrent download, this value is always "true". Otherwise "false".
|
torrent download, this value is always "true". Otherwise "false".
|
||||||
|
|
||||||
|
uris::
|
||||||
|
|
||||||
|
Returns the list of URI for this file. The element of list is the
|
||||||
|
same struct used in *aria2.getUris* method.
|
||||||
|
|
||||||
*aria2.getPeers* 'gid'
|
*aria2.getPeers* 'gid'
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,9 @@ const std::string KEY_ENABLED_FEATURES = "enabledFeatures";
|
||||||
const std::string KEY_METHOD_NAME = "methodName";
|
const std::string KEY_METHOD_NAME = "methodName";
|
||||||
const std::string KEY_PARAMS = "params";
|
const std::string KEY_PARAMS = "params";
|
||||||
const std::string KEY_SESSION_ID = "sessionId";
|
const std::string KEY_SESSION_ID = "sessionId";
|
||||||
|
const std::string KEY_FILES = "files";
|
||||||
|
const std::string KEY_DIR = "dir";
|
||||||
|
const std::string KEY_URIS = "uris";
|
||||||
}
|
}
|
||||||
|
|
||||||
static BDE createGIDResponse(int32_t gid)
|
static BDE createGIDResponse(int32_t gid)
|
||||||
|
@ -300,6 +303,31 @@ BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
return createGIDResponse(gid);
|
return createGIDResponse(gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename InputIterator>
|
||||||
|
static void createFileEntry(BDE& files, InputIterator first, InputIterator last)
|
||||||
|
{
|
||||||
|
size_t index = 1;
|
||||||
|
for(; first != last; ++first, ++index) {
|
||||||
|
BDE entry = BDE::dict();
|
||||||
|
entry[KEY_INDEX] = util::uitos(index);
|
||||||
|
entry[KEY_PATH] = (*first)->getPath();
|
||||||
|
entry[KEY_SELECTED] = (*first)->isRequested()?BDE_TRUE:BDE_FALSE;
|
||||||
|
entry[KEY_LENGTH] = util::uitos((*first)->getLength());
|
||||||
|
|
||||||
|
BDE uriList = BDE::list();
|
||||||
|
std::deque<std::string> uris;
|
||||||
|
(*first)->getUris(uris);
|
||||||
|
for(std::deque<std::string>::const_iterator i = uris.begin();
|
||||||
|
i != uris.end(); ++i) {
|
||||||
|
BDE uriEntry = BDE::dict();
|
||||||
|
uriEntry[KEY_URI] = *i;
|
||||||
|
uriList << uriEntry;
|
||||||
|
}
|
||||||
|
entry[KEY_URIS] = uriList;
|
||||||
|
files << entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void gatherProgressCommon
|
void gatherProgressCommon
|
||||||
(BDE& entryDict, const SharedHandle<RequestGroup>& group)
|
(BDE& entryDict, const SharedHandle<RequestGroup>& group)
|
||||||
{
|
{
|
||||||
|
@ -320,10 +348,9 @@ void gatherProgressCommon
|
||||||
ps->getBitfieldLength());
|
ps->getBitfieldLength());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entryDict[KEY_PIECE_LENGTH] =
|
const SharedHandle<DownloadContext>& dctx = group->getDownloadContext();
|
||||||
util::uitos(group->getDownloadContext()->getPieceLength());
|
entryDict[KEY_PIECE_LENGTH] = util::uitos(dctx->getPieceLength());
|
||||||
entryDict[KEY_NUM_PIECES] =
|
entryDict[KEY_NUM_PIECES] = util::uitos(dctx->getNumPieces());
|
||||||
util::uitos(group->getDownloadContext()->getNumPieces());
|
|
||||||
if(!group->followedBy().empty()) {
|
if(!group->followedBy().empty()) {
|
||||||
BDE list = BDE::list();
|
BDE list = BDE::list();
|
||||||
// The element is GID.
|
// The element is GID.
|
||||||
|
@ -336,6 +363,11 @@ void gatherProgressCommon
|
||||||
if(group->belongsTo()) {
|
if(group->belongsTo()) {
|
||||||
entryDict[KEY_BELONGS_TO] = util::itos(group->belongsTo());
|
entryDict[KEY_BELONGS_TO] = util::itos(group->belongsTo());
|
||||||
}
|
}
|
||||||
|
BDE files = BDE::list();
|
||||||
|
createFileEntry
|
||||||
|
(files, dctx->getFileEntries().begin(), dctx->getFileEntries().end());
|
||||||
|
entryDict[KEY_FILES] = files;
|
||||||
|
entryDict[KEY_DIR] = group->getOption()->get(PREF_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
|
@ -417,6 +449,9 @@ void gatherStoppedDownload
|
||||||
if(ds->belongsTo) {
|
if(ds->belongsTo) {
|
||||||
entryDict[KEY_BELONGS_TO] = util::itos(ds->belongsTo);
|
entryDict[KEY_BELONGS_TO] = util::itos(ds->belongsTo);
|
||||||
}
|
}
|
||||||
|
BDE files = BDE::list();
|
||||||
|
createFileEntry(files, ds->fileEntries.begin(), ds->fileEntries.end());
|
||||||
|
entryDict[KEY_FILES] = files;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -430,20 +465,6 @@ findRequestGroup(const SharedHandle<RequestGroupMan>& rgman, int32_t gid)
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename InputIterator>
|
|
||||||
static void createFileEntry(BDE& files, InputIterator first, InputIterator last)
|
|
||||||
{
|
|
||||||
size_t index = 1;
|
|
||||||
for(; first != last; ++first, ++index) {
|
|
||||||
BDE entry = BDE::dict();
|
|
||||||
entry[KEY_INDEX] = util::uitos(index);
|
|
||||||
entry[KEY_PATH] = (*first)->getPath();
|
|
||||||
entry[KEY_SELECTED] = (*first)->isRequested()?BDE_TRUE:BDE_FALSE;
|
|
||||||
entry[KEY_LENGTH] = util::uitos((*first)->getLength());
|
|
||||||
files << entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BDE GetFilesXmlRpcMethod::process
|
BDE GetFilesXmlRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
|
@ -493,9 +514,9 @@ BDE GetUrisXmlRpcMethod::process
|
||||||
(StringFormat("No URI data is available for GID#%d", gid).str());
|
(StringFormat("No URI data is available for GID#%d", gid).str());
|
||||||
}
|
}
|
||||||
BDE uriList = BDE::list();
|
BDE uriList = BDE::list();
|
||||||
std::deque<std::string> uris;
|
|
||||||
// TODO Current implementation just returns first FileEntry's URIs.
|
// TODO Current implementation just returns first FileEntry's URIs.
|
||||||
if(!group->getDownloadContext()->getFileEntries().empty()) {
|
if(!group->getDownloadContext()->getFileEntries().empty()) {
|
||||||
|
std::deque<std::string> uris;
|
||||||
group->getDownloadContext()->getFirstFileEntry()->getUris(uris);
|
group->getDownloadContext()->getFirstFileEntry()->getUris(uris);
|
||||||
for(std::deque<std::string>::const_iterator i = uris.begin();
|
for(std::deque<std::string>::const_iterator i = uris.begin();
|
||||||
i != uris.end(); ++i) {
|
i != uris.end(); ++i) {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "FeatureConfig.h"
|
#include "FeatureConfig.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "array_fun.h"
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "BtRegistry.h"
|
# include "BtRegistry.h"
|
||||||
# include "BtRuntime.h"
|
# include "BtRuntime.h"
|
||||||
|
@ -697,7 +698,9 @@ void XmlRpcMethodTest::testGatherStoppedDownload()
|
||||||
|
|
||||||
void XmlRpcMethodTest::testGatherProgressCommon()
|
void XmlRpcMethodTest::testGatherProgressCommon()
|
||||||
{
|
{
|
||||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
SharedHandle<DownloadContext> dctx(new DownloadContext(0, 0,"aria2.tar.bz2"));
|
||||||
|
std::string uris[] = { "http://localhost/aria2.tar.bz2" };
|
||||||
|
dctx->getFirstFileEntry()->addUris(&uris[0], &uris[arrayLength(uris)]);
|
||||||
|
|
||||||
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
||||||
group->setDownloadContext(dctx);
|
group->setDownloadContext(dctx);
|
||||||
|
@ -717,6 +720,11 @@ void XmlRpcMethodTest::testGatherProgressCommon()
|
||||||
CPPUNIT_ASSERT_EQUAL(util::itos(followedBy[1]->getGID()),
|
CPPUNIT_ASSERT_EQUAL(util::itos(followedBy[1]->getGID()),
|
||||||
entry["followedBy"][1].s());
|
entry["followedBy"][1].s());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("2"), entry["belongsTo"].s());
|
CPPUNIT_ASSERT_EQUAL(std::string("2"), entry["belongsTo"].s());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((size_t)1, entry["files"].size());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"),
|
||||||
|
entry["files"][0]["path"].s());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(uris[0], entry["files"][0]["uris"][0]["uri"].s());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), entry["dir"].s());
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangePosition()
|
void XmlRpcMethodTest::testChangePosition()
|
||||||
|
|
Loading…
Reference in New Issue