mirror of https://github.com/aria2/aria2
2009-07-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Implemented getVersion xml-rpc method. This method returns struct which has 2 key-value pairs: "version" key is associated to the version of aria2, such as "1.5.0". "enabledFeatures" key is associated to the list of enabled features, such as "Async DNS", "BitTorrent". * src/FeatureConfig.h * src/XmlRpcMethodFactory.cc * src/XmlRpcMethodImpl.cc * src/XmlRpcMethodImpl.h * test/XmlRpcMethodTest.ccpull/1/head
parent
53d2a64cc5
commit
d6a8fa5b10
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2009-07-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Implemented getVersion xml-rpc method. This method returns struct
|
||||
which has 2 key-value pairs: "version" key is associated to the
|
||||
version of aria2, such as "1.5.0". "enabledFeatures" key is
|
||||
associated to the list of enabled features, such as "Async DNS",
|
||||
"BitTorrent".
|
||||
* src/FeatureConfig.h
|
||||
* src/XmlRpcMethodFactory.cc
|
||||
* src/XmlRpcMethodImpl.cc
|
||||
* src/XmlRpcMethodImpl.h
|
||||
* test/XmlRpcMethodTest.cc
|
||||
|
||||
2009-07-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Removed TLS1.1 protocol support when aria2 is built with gnutls
|
||||
|
|
|
@ -62,6 +62,11 @@ public:
|
|||
|
||||
std::string featureSummary() const;
|
||||
|
||||
const FeatureMap& getFeatures() const
|
||||
{
|
||||
return _features;
|
||||
}
|
||||
|
||||
static const std::string FEATURE_HTTPS;
|
||||
static const std::string FEATURE_BITTORRENT;
|
||||
static const std::string FEATURE_METALINK;
|
||||
|
|
|
@ -79,6 +79,8 @@ XmlRpcMethodFactory::create(const std::string& methodName)
|
|||
return SharedHandle<XmlRpcMethod>(new ChangeGlobalOptionXmlRpcMethod());
|
||||
} else if(methodName == "aria2.purgeDownloadResult") {
|
||||
return SharedHandle<XmlRpcMethod>(new PurgeDownloadResultXmlRpcMethod());
|
||||
} else if(methodName == "aria2.getVersion") {
|
||||
return SharedHandle<XmlRpcMethod>(new GetVersionXmlRpcMethod());
|
||||
} else {
|
||||
return SharedHandle<XmlRpcMethod>(new NoSuchMethodXmlRpcMethod());
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include "BtProgressInfoFile.h"
|
||||
#include "prefs.h"
|
||||
#include "message.h"
|
||||
#include "FeatureConfig.h"
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
# include "bittorrent_helper.h"
|
||||
# include "BtRegistry.h"
|
||||
|
@ -627,6 +628,22 @@ BDE ChangeGlobalOptionXmlRpcMethod::process
|
|||
return BDE_OK;
|
||||
}
|
||||
|
||||
BDE GetVersionXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
{
|
||||
BDE result = BDE::dict();
|
||||
result["version"] = std::string(PACKAGE_VERSION);
|
||||
BDE featureList = BDE::list();
|
||||
const FeatureMap& features = FeatureConfig::getInstance()->getFeatures();
|
||||
for(FeatureMap::const_iterator i = features.begin(); i != features.end();++i){
|
||||
if((*i).second) {
|
||||
featureList << (*i).first;
|
||||
}
|
||||
}
|
||||
result["enabledFeatures"] = featureList;
|
||||
return result;
|
||||
}
|
||||
|
||||
BDE NoSuchMethodXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
{
|
||||
|
|
|
@ -112,6 +112,11 @@ protected:
|
|||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
};
|
||||
|
||||
class GetVersionXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
};
|
||||
|
||||
class NoSuchMethodXmlRpcMethod:public XmlRpcMethod {
|
||||
protected:
|
||||
virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "prefs.h"
|
||||
#include "TestUtil.h"
|
||||
#include "DownloadContext.h"
|
||||
#include "FeatureConfig.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -51,6 +52,7 @@ class XmlRpcMethodTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testTellStatus_withoutGid);
|
||||
CPPUNIT_TEST(testTellWaiting);
|
||||
CPPUNIT_TEST(testTellWaiting_fail);
|
||||
CPPUNIT_TEST(testGetVersion);
|
||||
CPPUNIT_TEST(testNoSuchMethod);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
|
@ -98,6 +100,7 @@ public:
|
|||
void testTellStatus_withoutGid();
|
||||
void testTellWaiting();
|
||||
void testTellWaiting_fail();
|
||||
void testGetVersion();
|
||||
void testNoSuchMethod();
|
||||
};
|
||||
|
||||
|
@ -514,6 +517,25 @@ void XmlRpcMethodTest::testTellWaiting_fail()
|
|||
CPPUNIT_ASSERT_EQUAL(1, res._code);
|
||||
}
|
||||
|
||||
void XmlRpcMethodTest::testGetVersion()
|
||||
{
|
||||
GetVersionXmlRpcMethod m;
|
||||
XmlRpcRequest req("aria2.getVersion", BDE::none);
|
||||
XmlRpcResponse res = m.execute(req, _e.get());
|
||||
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(PACKAGE_VERSION), res._param["version"].s());
|
||||
const BDE& featureList = res._param["enabledFeatures"];
|
||||
std::string features;
|
||||
for(BDE::List::const_iterator i = featureList.listBegin();
|
||||
i != featureList.listEnd(); ++i) {
|
||||
features += (*i).s();
|
||||
features += ", ";
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(FeatureConfig::getInstance()->featureSummary()+", ",
|
||||
features);
|
||||
}
|
||||
|
||||
} // namespace xmlrpc
|
||||
|
||||
} // namespace aria2
|
||||
|
|
Loading…
Reference in New Issue