mirror of https://github.com/aria2/aria2
				
				
				
			2009-11-27 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --bt-max-peers option to changeOption XML-RPC method. * src/XmlRpcMethod.cc * src/XmlRpcMethodImpl.cc * test/XmlRpcMethodTest.ccpull/1/head
							parent
							
								
									58f4e715e0
								
							
						
					
					
						commit
						a8d4fbad51
					
				| 
						 | 
				
			
			@ -1,3 +1,10 @@
 | 
			
		|||
2009-11-27  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 | 
			
		||||
 | 
			
		||||
	Added --bt-max-peers option to changeOption XML-RPC method.
 | 
			
		||||
	* src/XmlRpcMethod.cc
 | 
			
		||||
	* src/XmlRpcMethodImpl.cc
 | 
			
		||||
	* test/XmlRpcMethodTest.cc
 | 
			
		||||
 | 
			
		||||
2009-11-27  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 | 
			
		||||
 | 
			
		||||
	Added test case for PREF_BT_REQUEST_PEER_SPEED_LIMIT
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -140,6 +140,7 @@ static void applyOption(InputIterator optNameFirst,
 | 
			
		|||
const std::set<std::string>& listChangeableOptions()
 | 
			
		||||
{
 | 
			
		||||
  static const std::string OPTIONS[] = {
 | 
			
		||||
    PREF_BT_MAX_PEERS,
 | 
			
		||||
    PREF_BT_REQUEST_PEER_SPEED_LIMIT,
 | 
			
		||||
    PREF_MAX_DOWNLOAD_LIMIT,
 | 
			
		||||
    PREF_MAX_UPLOAD_LIMIT
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<BtRuntime>(new BtRuntime());
 | 
			
		||||
  _e->getBtRegistry()->put(group->getGID(), btObject);
 | 
			
		||||
#endif // ENABLE_BITTORRENT
 | 
			
		||||
  req._params << opt;
 | 
			
		||||
  XmlRpcResponse res = m.execute(req, _e.get());
 | 
			
		||||
 | 
			
		||||
  SharedHandle<Option> option = group->getOption();
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(0, res._code);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024,
 | 
			
		||||
		       group->getMaxDownloadSpeedLimit());
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("102400"),
 | 
			
		||||
		       group->getOption()->get(PREF_MAX_DOWNLOAD_LIMIT));
 | 
			
		||||
		       option->get(PREF_MAX_DOWNLOAD_LIMIT));
 | 
			
		||||
#ifdef ENABLE_BITTORRENT
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL
 | 
			
		||||
    (std::string("307200"),
 | 
			
		||||
     group->getOption()->get(PREF_BT_REQUEST_PEER_SPEED_LIMIT));
 | 
			
		||||
   CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024, group->getMaxUploadSpeedLimit());
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("307200"),
 | 
			
		||||
		       option->get(PREF_BT_REQUEST_PEER_SPEED_LIMIT));
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("100"), option->get(PREF_BT_MAX_PEERS));
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((unsigned int)100, btObject._btRuntime->getMaxPeers());
 | 
			
		||||
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024,
 | 
			
		||||
		       group->getMaxUploadSpeedLimit());
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL(std::string("51200"),
 | 
			
		||||
			group->getOption()->get(PREF_MAX_UPLOAD_LIMIT));
 | 
			
		||||
		       option->get(PREF_MAX_UPLOAD_LIMIT));
 | 
			
		||||
#endif // ENABLE_BITTORRENT
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue