mirror of https://github.com/aria2/aria2
2010-01-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added aria2.getSessionInfo XML-RPC method. This method returns a struct containing Session ID, which is generated each time when aria2 is invoked. * doc/aria2c.1.txt * doc/xmlrpc/aria2rpc * src/DownloadEngine.cc * src/DownloadEngine.h * src/XmlRpcMethodFactory.cc * src/XmlRpcMethodImpl.cc * src/XmlRpcMethodImpl.h * test/XmlRpcMethodTest.ccpull/1/head
parent
87b18019b4
commit
f2722cb870
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2010-01-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Added aria2.getSessionInfo XML-RPC method. This method returns a
|
||||
struct containing Session ID, which is generated each time when
|
||||
aria2 is invoked.
|
||||
* doc/aria2c.1.txt
|
||||
* doc/xmlrpc/aria2rpc
|
||||
* src/DownloadEngine.cc
|
||||
* src/DownloadEngine.h
|
||||
* src/XmlRpcMethodFactory.cc
|
||||
* src/XmlRpcMethodImpl.cc
|
||||
* src/XmlRpcMethodImpl.h
|
||||
* test/XmlRpcMethodTest.cc
|
||||
|
||||
2010-01-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Moved generateRandomKey() from bittorrent_helper to util.
|
||||
|
|
|
@ -2438,6 +2438,15 @@ enabledFeatures
|
|||
List of enabled features\&. Each feature name is of type string\&.
|
||||
.RE
|
||||
.sp
|
||||
\fBaria2\&.getSessionInfo\fR
|
||||
.sp
|
||||
This method returns session information\&. The response is of type struct and contains following key\&.
|
||||
.PP
|
||||
sessionId
|
||||
.RS 4
|
||||
Session ID, which is generated each time when aria2 is invoked\&.
|
||||
.RE
|
||||
.sp
|
||||
\fBsystem\&.multicall\fR \fImethods\fR
|
||||
.sp
|
||||
This methods encapsulates multiple method calls in a single request\&. \fImethods\fR is of type array and its element is struct\&. The struct contains two keys: "methodName" and "params"\&. "methodName" is the method name to call and "params" is array containing parameters to the method\&. This method returns array of responses\&. The element of array will either be a one\-item array containing the return value of each method call or struct of fault element if an encapsulated method call fails\&.
|
||||
|
|
|
@ -3120,6 +3120,19 @@ enabledFeatures
|
|||
</p>
|
||||
</dd>
|
||||
</dl></div>
|
||||
<div class="paragraph"><p><strong>aria2.getSessionInfo</strong></p></div>
|
||||
<div class="paragraph"><p>This method returns session information.
|
||||
The response is of type struct and contains following key.</p></div>
|
||||
<div class="dlist"><dl>
|
||||
<dt class="hdlist1">
|
||||
sessionId
|
||||
</dt>
|
||||
<dd>
|
||||
<p>
|
||||
Session ID, which is generated each time when aria2 is invoked.
|
||||
</p>
|
||||
</dd>
|
||||
</dl></div>
|
||||
<div class="paragraph"><p><strong>system.multicall</strong> <em>methods</em></p></div>
|
||||
<div class="paragraph"><p>This methods encapsulates multiple method calls in a single request.
|
||||
<em>methods</em> is of type array and its element is struct. The struct
|
||||
|
@ -3597,7 +3610,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-01-17 18:53:28 JST
|
||||
Last updated 2010-01-17 20:50:31 JST
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
@ -1457,6 +1457,15 @@ enabledFeatures::
|
|||
|
||||
List of enabled features. Each feature name is of type string.
|
||||
|
||||
*aria2.getSessionInfo*
|
||||
|
||||
This method returns session information.
|
||||
The response is of type struct and contains following key.
|
||||
|
||||
sessionId::
|
||||
|
||||
Session ID, which is generated each time when aria2 is invoked.
|
||||
|
||||
*system.multicall* 'methods'
|
||||
|
||||
This methods encapsulates multiple method calls in a single request.
|
||||
|
|
|
@ -191,6 +191,7 @@ Usage: #{program_name} addUri URI... [options]
|
|||
#{program_name} changeOption GID [options]
|
||||
#{program_name} changeGlobalOption [options]
|
||||
#{program_name} getVersion [options]
|
||||
#{program_name} getSessionInfo [options]
|
||||
Options:
|
||||
EOS
|
||||
|
||||
|
@ -270,6 +271,8 @@ elsif command == "changeGlobalOption" then
|
|||
result=client.call("aria2."+command, options)
|
||||
elsif command == "getVersion" then
|
||||
result=client.call("aria2."+command)
|
||||
elsif command == "getSessionInfo" then
|
||||
result=client.call("aria2."+command)
|
||||
else
|
||||
puts "Command not recognized"
|
||||
exit 1
|
||||
|
|
|
@ -94,7 +94,11 @@ DownloadEngine::DownloadEngine(const SharedHandle<EventPoll>& eventPoll):
|
|||
_btRegistry(new BtRegistry()),
|
||||
#endif // ENABLE_BITTORRENT
|
||||
_dnsCache(new DNSCache())
|
||||
{}
|
||||
{
|
||||
unsigned char sessionId[20];
|
||||
util::generateRandomKey(sessionId);
|
||||
_sessionId = std::string(&sessionId[0], & sessionId[sizeof(sessionId)]);
|
||||
}
|
||||
|
||||
DownloadEngine::~DownloadEngine() {
|
||||
cleanQueue();
|
||||
|
|
|
@ -73,6 +73,8 @@ class DownloadEngine {
|
|||
private:
|
||||
void waitData();
|
||||
|
||||
std::string _sessionId;
|
||||
|
||||
SharedHandle<EventPoll> _eventPoll;
|
||||
|
||||
Logger* logger;
|
||||
|
@ -274,6 +276,11 @@ public:
|
|||
}
|
||||
|
||||
void setRefreshInterval(time_t interval);
|
||||
|
||||
const std::string getSessionId() const
|
||||
{
|
||||
return _sessionId;
|
||||
}
|
||||
};
|
||||
|
||||
typedef SharedHandle<DownloadEngine> DownloadEngineHandle;
|
||||
|
|
|
@ -89,6 +89,8 @@ XmlRpcMethodFactory::create(const std::string& methodName)
|
|||
return SharedHandle<XmlRpcMethod>(new PurgeDownloadResultXmlRpcMethod());
|
||||
} else if(methodName == GetVersionXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new GetVersionXmlRpcMethod());
|
||||
} else if(methodName == GetSessionInfoXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new GetSessionInfoXmlRpcMethod());
|
||||
} else if(methodName == SystemMulticallXmlRpcMethod::getMethodName()) {
|
||||
return SharedHandle<XmlRpcMethod>(new SystemMulticallXmlRpcMethod());
|
||||
} else {
|
||||
|
|
|
@ -115,6 +115,7 @@ const std::string KEY_VERSION = "version";
|
|||
const std::string KEY_ENABLED_FEATURES = "enabledFeatures";
|
||||
const std::string KEY_METHOD_NAME = "methodName";
|
||||
const std::string KEY_PARAMS = "params";
|
||||
const std::string KEY_SESSION_ID = "sessionId";
|
||||
}
|
||||
|
||||
static BDE createGIDResponse(int32_t gid)
|
||||
|
@ -789,6 +790,14 @@ BDE ChangePositionXmlRpcMethod::process
|
|||
return result;
|
||||
}
|
||||
|
||||
BDE GetSessionInfoXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
{
|
||||
BDE result = BDE::dict();
|
||||
result[KEY_SESSION_ID] = util::toHex(e->getSessionId());
|
||||
return result;
|
||||
}
|
||||
|
||||
BDE SystemMulticallXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
{
|
||||
|
|
|
@ -332,6 +332,17 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class GetSessionInfoXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
public:
|
||||
static const std::string& getMethodName()
|
||||
{
|
||||
static std::string methodName = "aria2.getSessionInfo";
|
||||
return methodName;
|
||||
}
|
||||
};
|
||||
|
||||
class SystemMulticallXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
|
|
|
@ -69,6 +69,7 @@ class XmlRpcMethodTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testGatherProgressCommon);
|
||||
CPPUNIT_TEST(testChangePosition);
|
||||
CPPUNIT_TEST(testChangePosition_fail);
|
||||
CPPUNIT_TEST(testGetSessionInfo);
|
||||
CPPUNIT_TEST(testSystemMulticall);
|
||||
CPPUNIT_TEST(testSystemMulticall_fail);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
@ -125,6 +126,7 @@ public:
|
|||
void testGatherProgressCommon();
|
||||
void testChangePosition();
|
||||
void testChangePosition_fail();
|
||||
void testGetSessionInfo();
|
||||
void testSystemMulticall();
|
||||
void testSystemMulticall_fail();
|
||||
};
|
||||
|
@ -749,6 +751,16 @@ void XmlRpcMethodTest::testChangePosition_fail()
|
|||
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
||||
}
|
||||
|
||||
void XmlRpcMethodTest::testGetSessionInfo()
|
||||
{
|
||||
GetSessionInfoXmlRpcMethod m;
|
||||
XmlRpcRequest req(GetSessionInfoXmlRpcMethod::getMethodName(), BDE::list());
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
||||
CPPUNIT_ASSERT_EQUAL(util::toHex(_e->getSessionId()),
|
||||
res._param["sessionId"].s());
|
||||
}
|
||||
|
||||
void XmlRpcMethodTest::testSystemMulticall()
|
||||
{
|
||||
SystemMulticallXmlRpcMethod m;
|
||||
|
|
Loading…
Reference in New Issue