mirror of https://github.com/aria2/aria2
2009-05-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
getFiles command now returns file data for finished/stopped downloads. * src/XmlRpcMethodImpl.ccpull/1/head
parent
8bbbc9c33b
commit
d3ae337ace
|
@ -1,3 +1,9 @@
|
||||||
|
2009-05-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
getFiles command now returns file data for finished/stopped
|
||||||
|
downloads.
|
||||||
|
* src/XmlRpcMethodImpl.cc
|
||||||
|
|
||||||
2009-05-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-05-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
DownloadResult now has the list of FileEntry. The download
|
DownloadResult now has the list of FileEntry. The download
|
||||||
|
|
|
@ -247,6 +247,19 @@ 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["index"] = Util::uitos(index);
|
||||||
|
entry["path"] = (*first)->getPath();
|
||||||
|
entry["selected"] = (*first)->isRequested()?BDE("true"):BDE("false");
|
||||||
|
files << entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BDE GetFilesXmlRpcMethod::process
|
BDE GetFilesXmlRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
|
@ -259,22 +272,21 @@ BDE GetFilesXmlRpcMethod::process
|
||||||
|
|
||||||
int32_t gid = Util::parseInt(params[0].s());
|
int32_t gid = Util::parseInt(params[0].s());
|
||||||
|
|
||||||
|
BDE files = BDE::list();
|
||||||
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
|
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
throw DlAbortEx
|
SharedHandle<DownloadResult> dr =
|
||||||
(StringFormat("No file data is available for GID#%d", gid).str());
|
e->_requestGroupMan->findDownloadResult(gid);
|
||||||
}
|
if(dr.isNull()) {
|
||||||
BDE files = BDE::list();
|
throw DlAbortEx
|
||||||
std::deque<SharedHandle<FileEntry> > fileEntries =
|
(StringFormat("No file data is available for GID#%d", gid).str());
|
||||||
group->getDownloadContext()->getFileEntries();
|
} else {
|
||||||
size_t index = 1;
|
createFileEntry(files, dr->fileEntries.begin(), dr->fileEntries.end());
|
||||||
for(std::deque<SharedHandle<FileEntry> >::const_iterator i =
|
}
|
||||||
fileEntries.begin(); i != fileEntries.end(); ++i, ++index) {
|
} else {
|
||||||
BDE entry = BDE::dict();
|
std::deque<SharedHandle<FileEntry> > fileEntries =
|
||||||
entry["index"] = Util::uitos(index);
|
group->getDownloadContext()->getFileEntries();
|
||||||
entry["path"] = (*i)->getPath();
|
createFileEntry(files, fileEntries.begin(), fileEntries.end());
|
||||||
entry["selected"] = (*i)->isRequested()?BDE("true"):BDE("false");
|
|
||||||
files << entry;
|
|
||||||
}
|
}
|
||||||
BDE resParams = BDE::list();
|
BDE resParams = BDE::list();
|
||||||
resParams << files;
|
resParams << files;
|
||||||
|
|
Loading…
Reference in New Issue