From 79231253824ffbb41cefb685cca98ace8b227182 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 6 Mar 2010 15:09:11 +0000 Subject: [PATCH] 2010-03-07 Tatsuhiro Tsujikawa Added 'status' key to the response of getUri XML-RPC method. * doc/aria2c.1.txt * src/XmlRpcMethodImpl.cc --- ChangeLog | 6 ++++++ doc/aria2c.1 | 13 +++++++++++-- doc/aria2c.1.html | 11 ++++++++++- doc/aria2c.1.txt | 5 +++++ src/XmlRpcMethodImpl.cc | 43 ++++++++++++++++++++++++++--------------- 5 files changed, 59 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d8a47b1..12deaa18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-03-07 Tatsuhiro Tsujikawa + + Added 'status' key to the response of getUri XML-RPC method. + * doc/aria2c.1.txt + * src/XmlRpcMethodImpl.cc + 2010-03-06 Tatsuhiro Tsujikawa Replaced Time::reset() call with assigning of global::wallclock. diff --git a/doc/aria2c.1 b/doc/aria2c.1 index d8e756d6..89b060cf 100644 --- a/doc/aria2c.1 +++ b/doc/aria2c.1 @@ -2,12 +2,12 @@ .\" Title: aria2c .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.75.2 -.\" Date: 03/06/2010 +.\" Date: 03/07/2010 .\" Manual: Aria2 Manual .\" Source: Aria2 1.9.0a .\" Language: English .\" -.TH "ARIA2C" "1" "03/06/2010" "Aria2 1\&.9\&.0a" "Aria2 Manual" +.TH "ARIA2C" "1" "03/07/2010" "Aria2 1\&.9\&.0a" "Aria2 Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -2352,6 +2352,15 @@ uri .RS 4 URI .RE +.PP +status +.RS 4 + +\fIused\fR +if the URI is already used\&. +\fIwaiting\fR +if the URI is waiting in the queue\&. +.RE .sp \fBaria2\&.getFiles\fR \fIgid\fR .sp diff --git a/doc/aria2c.1.html b/doc/aria2c.1.html index c47ddc13..4ab29dd6 100644 --- a/doc/aria2c.1.html +++ b/doc/aria2c.1.html @@ -2999,6 +2999,15 @@ uri URI

+
+status +
+
+

+ used if the URI is already used. waiting if the URI is waiting + in the queue. +

+

aria2.getFiles gid

This method returns file list of the download denoted by gid. gid @@ -3740,7 +3749,7 @@ files in the program, then also delete it here.


diff --git a/doc/aria2c.1.txt b/doc/aria2c.1.txt index 8da9a3ec..3d16e1a6 100644 --- a/doc/aria2c.1.txt +++ b/doc/aria2c.1.txt @@ -1330,6 +1330,11 @@ uri:: URI +status:: + + 'used' if the URI is already used. 'waiting' if the URI is waiting + in the queue. + *aria2.getFiles* 'gid' This method returns file list of the download denoted by 'gid'. 'gid' diff --git a/src/XmlRpcMethodImpl.cc b/src/XmlRpcMethodImpl.cc index 0213a761..285ce605 100644 --- a/src/XmlRpcMethodImpl.cc +++ b/src/XmlRpcMethodImpl.cc @@ -83,6 +83,7 @@ const BDE BDE_WAITING = BDE("waiting"); const BDE BDE_REMOVED = BDE("removed"); const BDE BDE_ERROR = BDE("error"); const BDE BDE_COMPLETE = BDE("complete"); +const BDE BDE_USED = BDE("used"); const std::string KEY_GID = "gid"; const std::string KEY_ERROR_CODE = "errorCode"; @@ -311,6 +312,30 @@ BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e) return createGIDResponse(gid); } +static void createUriEntry(BDE& uriList, const SharedHandle& file) +{ + { + const std::deque& uris = file->getSpentUris(); + for(std::deque::const_iterator i = uris.begin(), + eoi = uris.end(); i != eoi; ++i) { + BDE entry = BDE::dict(); + entry[KEY_URI] = *i; + entry[KEY_STATUS] = BDE_USED; + uriList << entry; + } + } + { + const std::deque& uris = file->getRemainingUris(); + for(std::deque::const_iterator i = uris.begin(), + eoi = uris.end(); i != eoi; ++i) { + BDE entry = BDE::dict(); + entry[KEY_URI] = *i; + entry[KEY_STATUS] = BDE_WAITING; + uriList << entry; + } + } +} + template static void createFileEntry(BDE& files, InputIterator first, InputIterator last) { @@ -323,14 +348,7 @@ static void createFileEntry(BDE& files, InputIterator first, InputIterator last) entry[KEY_LENGTH] = util::uitos((*first)->getLength()); BDE uriList = BDE::list(); - std::vector uris; - (*first)->getUris(uris); - for(std::vector::const_iterator i = uris.begin(), - eoi = uris.end(); i != eoi; ++i) { - BDE uriEntry = BDE::dict(); - uriEntry[KEY_URI] = *i; - uriList << uriEntry; - } + createUriEntry(uriList, *first); entry[KEY_URIS] = uriList; files << entry; } @@ -559,14 +577,7 @@ BDE GetUrisXmlRpcMethod::process BDE uriList = BDE::list(); // TODO Current implementation just returns first FileEntry's URIs. if(!group->getDownloadContext()->getFileEntries().empty()) { - std::vector uris; - group->getDownloadContext()->getFirstFileEntry()->getUris(uris); - for(std::vector::const_iterator i = uris.begin(), - eoi = uris.end(); i != eoi; ++i) { - BDE entry = BDE::dict(); - entry[KEY_URI] = *i; - uriList << entry; - } + createUriEntry(uriList, group->getDownloadContext()->getFirstFileEntry()); } return uriList; }