mirror of https://github.com/aria2/aria2
2009-05-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added tellActiveStatus xml-rpc command which reports download status of active downloads. * src/XmlRpcMethodFactory.cc * src/XmlRpcMethodImpl.cc * src/XmlRpcMethodImpl.hpull/1/head
parent
c45ff588d1
commit
08856691b3
|
@ -1,3 +1,11 @@
|
||||||
|
2009-05-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Added tellActiveStatus xml-rpc command which reports download
|
||||||
|
status of active downloads.
|
||||||
|
* src/XmlRpcMethodFactory.cc
|
||||||
|
* src/XmlRpcMethodImpl.cc
|
||||||
|
* src/XmlRpcMethodImpl.h
|
||||||
|
|
||||||
2009-05-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-05-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Added addTorrentFile xml-rpc command which receives uploaded
|
Added addTorrentFile xml-rpc command which receives uploaded
|
||||||
|
|
|
@ -46,10 +46,12 @@ XmlRpcMethodFactory::create(const std::string& methodName)
|
||||||
{
|
{
|
||||||
if(methodName == "aria2.addURI") {
|
if(methodName == "aria2.addURI") {
|
||||||
return SharedHandle<XmlRpcMethod>(new AddURIXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new AddURIXmlRpcMethod());
|
||||||
} else if(methodName == "aria2.addTorrent") {
|
} else if(methodName == "aria2.addTorrentFile") {
|
||||||
return SharedHandle<XmlRpcMethod>(new AddTorrentFileXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new AddTorrentFileXmlRpcMethod());
|
||||||
} else if(methodName == "aria2.remove") {
|
} else if(methodName == "aria2.remove") {
|
||||||
return SharedHandle<XmlRpcMethod>(new RemoveXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new RemoveXmlRpcMethod());
|
||||||
|
} else if(methodName == "aria2.tellActiveStatus") {
|
||||||
|
return SharedHandle<XmlRpcMethod>(new TellActiveStatusXmlRpcMethod());
|
||||||
} else {
|
} else {
|
||||||
return SharedHandle<XmlRpcMethod>(new FailXmlRpcMethod());
|
return SharedHandle<XmlRpcMethod>(new FailXmlRpcMethod());
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,16 @@
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
#include "XmlRpcRequest.h"
|
#include "XmlRpcRequest.h"
|
||||||
|
#include "PieceStorage.h"
|
||||||
|
#include "PeerStorage.h"
|
||||||
|
#include "BtContext.h"
|
||||||
|
#include "BtRegistry.h"
|
||||||
|
#include "Peer.h"
|
||||||
|
#include "DiskAdaptor.h"
|
||||||
|
#include "FileEntry.h"
|
||||||
|
#include "BtProgressInfoFile.h"
|
||||||
|
#include "BtRuntime.h"
|
||||||
|
#include "BtAnnounce.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -143,6 +153,73 @@ BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
return resParams;
|
return resParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BDE TellActiveStatusXmlRpcMethod::process
|
||||||
|
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
|
{
|
||||||
|
BDE res = BDE::list();
|
||||||
|
const std::deque<SharedHandle<RequestGroup> >& groups =
|
||||||
|
e->_requestGroupMan->getRequestGroups();
|
||||||
|
for(std::deque<SharedHandle<RequestGroup> >::const_iterator i =
|
||||||
|
groups.begin(); i != groups.end(); ++i) {
|
||||||
|
BDE entryDict = BDE::dict();
|
||||||
|
entryDict["gid"] = BDE(Util::itos((*i)->getGID()));
|
||||||
|
entryDict["totalLength"] = BDE(Util::uitos((*i)->getTotalLength()));
|
||||||
|
entryDict["completedLength"] = BDE(Util::uitos((*i)->getCompletedLength()));
|
||||||
|
TransferStat stat = (*i)->calculateStat();
|
||||||
|
entryDict["downloadSpeed"] = BDE(Util::uitos(stat.getDownloadSpeed()));
|
||||||
|
entryDict["uploadSpeed"] = BDE(Util::uitos(stat.getUploadSpeed()));
|
||||||
|
|
||||||
|
SharedHandle<PieceStorage> ps = (*i)->getPieceStorage();
|
||||||
|
if(!ps.isNull()) {
|
||||||
|
if(ps->getBitfieldLength() > 0) {
|
||||||
|
entryDict["bitfield"] = BDE(Util::toHex(ps->getBitfield(),
|
||||||
|
ps->getBitfieldLength()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!ps->getDiskAdaptor().isNull()) {
|
||||||
|
BDE files = BDE::list();
|
||||||
|
const std::deque<SharedHandle<FileEntry> >& entries =
|
||||||
|
ps->getDiskAdaptor()->getFileEntries();
|
||||||
|
for(std::deque<SharedHandle<FileEntry> >::const_iterator i =
|
||||||
|
entries.begin(); i != entries.end(); ++i) {
|
||||||
|
files << BDE((*i)->getPath());
|
||||||
|
}
|
||||||
|
entryDict["files"] = files;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedHandle<BtContext> btctx =
|
||||||
|
dynamic_pointer_cast<BtContext>((*i)->getDownloadContext());
|
||||||
|
if(!btctx.isNull()) {
|
||||||
|
SharedHandle<BtRegistry> btreg = e->getBtRegistry();
|
||||||
|
|
||||||
|
BDE peers = BDE::list();
|
||||||
|
SharedHandle<PeerStorage> ps =
|
||||||
|
btreg->getPeerStorage(btctx->getInfoHashAsString());
|
||||||
|
|
||||||
|
assert(!ps.isNull());
|
||||||
|
|
||||||
|
std::deque<SharedHandle<Peer> > activePeers;
|
||||||
|
ps->getActivePeers(activePeers);
|
||||||
|
for(std::deque<SharedHandle<Peer> >::const_iterator i =
|
||||||
|
activePeers.begin(); i != activePeers.end(); ++i) {
|
||||||
|
BDE peerEntry = BDE::dict();
|
||||||
|
peerEntry["peerId"] = BDE(Util::torrentUrlencode((*i)->getPeerId(),
|
||||||
|
PEER_ID_LENGTH));
|
||||||
|
peerEntry["ip"] = BDE((*i)->ipaddr);
|
||||||
|
peerEntry["port"] = BDE(Util::uitos((*i)->port));
|
||||||
|
peerEntry["bitfield"] = BDE(Util::toHex((*i)->getBitfield(),
|
||||||
|
(*i)->getBitfieldLength()));
|
||||||
|
peers << peerEntry;
|
||||||
|
}
|
||||||
|
entryDict["peers"] = peers;
|
||||||
|
}
|
||||||
|
|
||||||
|
res << entryDict;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
BDE FailXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
BDE FailXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
throw DlAbortEx
|
throw DlAbortEx
|
||||||
|
|
|
@ -56,6 +56,11 @@ protected:
|
||||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TellActiveStatusXmlRpcMethod:public XmlRpcMethod {
|
||||||
|
protected:
|
||||||
|
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||||
|
};
|
||||||
|
|
||||||
class FailXmlRpcMethod:public XmlRpcMethod {
|
class FailXmlRpcMethod:public XmlRpcMethod {
|
||||||
protected:
|
protected:
|
||||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||||
|
|
Loading…
Reference in New Issue