diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-07-10 15:55:42 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-07-10 15:55:42 +0000 |
| commit | d6a8fa5b100d87e9c939e4204109da8eaae2018a (patch) | |
| tree | 1c0d5b1a2b60ace9330ea6529bc7380d32884b6a /src | |
| parent | 53d2a64cc5fdbb515fafae6a6024c8c834fdafd6 (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/FeatureConfig.h | 5 | ||||
| -rw-r--r-- | src/XmlRpcMethodFactory.cc | 2 | ||||
| -rw-r--r-- | src/XmlRpcMethodImpl.cc | 17 | ||||
| -rw-r--r-- | src/XmlRpcMethodImpl.h | 5 |
4 files changed, 29 insertions, 0 deletions
diff --git a/src/FeatureConfig.h b/src/FeatureConfig.h index 29ac7a74..97ee1a15 100644 --- a/src/FeatureConfig.h +++ b/src/FeatureConfig.h @@ -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; diff --git a/src/XmlRpcMethodFactory.cc b/src/XmlRpcMethodFactory.cc index f6495fc8..6b93721c 100644 --- a/src/XmlRpcMethodFactory.cc +++ b/src/XmlRpcMethodFactory.cc @@ -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()); } diff --git a/src/XmlRpcMethodImpl.cc b/src/XmlRpcMethodImpl.cc index d3f0d78e..07ee25fa 100644 --- a/src/XmlRpcMethodImpl.cc +++ b/src/XmlRpcMethodImpl.cc @@ -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) { diff --git a/src/XmlRpcMethodImpl.h b/src/XmlRpcMethodImpl.h index 765f7748..c0bf38df 100644 --- a/src/XmlRpcMethodImpl.h +++ b/src/XmlRpcMethodImpl.h @@ -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); |
