diff --git a/ChangeLog b/ChangeLog index a2b7f829..6783eb17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-11-27 Tatsuhiro Tsujikawa + + Added --bt-max-peers option to changeOption XML-RPC method. + * src/XmlRpcMethod.cc + * src/XmlRpcMethodImpl.cc + * test/XmlRpcMethodTest.cc + 2009-11-27 Tatsuhiro Tsujikawa Added test case for PREF_BT_REQUEST_PEER_SPEED_LIMIT diff --git a/src/XmlRpcMethod.cc b/src/XmlRpcMethod.cc index 17506e92..68ac442c 100644 --- a/src/XmlRpcMethod.cc +++ b/src/XmlRpcMethod.cc @@ -140,6 +140,7 @@ static void applyOption(InputIterator optNameFirst, const std::set& listChangeableOptions() { static const std::string OPTIONS[] = { + PREF_BT_MAX_PEERS, PREF_BT_REQUEST_PEER_SPEED_LIMIT, PREF_MAX_DOWNLOAD_LIMIT, PREF_MAX_UPLOAD_LIMIT diff --git a/src/XmlRpcMethodImpl.cc b/src/XmlRpcMethodImpl.cc index 766a36fb..738409e5 100644 --- a/src/XmlRpcMethodImpl.cc +++ b/src/XmlRpcMethodImpl.cc @@ -600,6 +600,14 @@ BDE ChangeOptionXmlRpcMethod::process if(option->defined(PREF_MAX_UPLOAD_LIMIT)) { group->setMaxUploadSpeedLimit(option->getAsInt(PREF_MAX_UPLOAD_LIMIT)); } +#ifdef ENABLE_BITTORRENT + BtObject btObject = e->getBtRegistry()->get(group->getGID()); + if(!btObject.isNull()) { + if(option->defined(PREF_BT_MAX_PEERS)) { + btObject._btRuntime->setMaxPeers(option->getAsInt(PREF_BT_MAX_PEERS)); + } + } +#endif // ENABLE_BITTORRENT } return BDE_OK; } diff --git a/test/XmlRpcMethodTest.cc b/test/XmlRpcMethodTest.cc index 27800ba7..afc671b2 100644 --- a/test/XmlRpcMethodTest.cc +++ b/test/XmlRpcMethodTest.cc @@ -18,6 +18,14 @@ #include "TestUtil.h" #include "DownloadContext.h" #include "FeatureConfig.h" +#ifdef ENABLE_BITTORRENT +# include "BtRegistry.h" +# include "BtRuntime.h" +# include "PieceStorage.h" +# include "PeerStorage.h" +# include "BtProgressInfoFile.h" +# include "BtAnnounce.h" +#endif // ENABLE_BITTORRENT namespace aria2 { @@ -365,24 +373,35 @@ void XmlRpcMethodTest::testChangeOption() BDE opt = BDE::dict(); opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K"); #ifdef ENABLE_BITTORRENT + opt[PREF_BT_MAX_PEERS] = BDE("100"); opt[PREF_BT_REQUEST_PEER_SPEED_LIMIT] = BDE("300K"); opt[PREF_MAX_UPLOAD_LIMIT] = BDE("50K"); + + BtObject btObject; + btObject._btRuntime = SharedHandle(new BtRuntime()); + _e->getBtRegistry()->put(group->getGID(), btObject); #endif // ENABLE_BITTORRENT req._params << opt; XmlRpcResponse res = m.execute(req, _e.get()); + SharedHandle