Browse Source

2010-06-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Made public member variables of DownloadEngine private. Added
	accessor funcs.
Tatsuhiro Tsujikawa 15 năm trước cách đây
mục cha
commit
7cd9b21937
72 tập tin đã thay đổi với 570 bổ sung273 xóa
  1. 5 0
      ChangeLog
  2. 14 12
      src/AbstractCommand.cc
  3. 6 2
      src/AbstractProxyRequestCommand.cc
  4. 6 2
      src/AbstractProxyResponseCommand.cc
  5. 6 2
      src/ActivePeerConnectionCommand.cc
  6. 5 2
      src/AutoSaveCommand.cc
  7. 2 0
      src/BtCheckIntegrityEntry.cc
  8. 3 0
      src/BtFileAllocationEntry.cc
  9. 10 5
      src/BtSetup.cc
  10. 7 4
      src/CheckIntegrityCommand.cc
  11. 2 0
      src/CheckIntegrityDispatcherCommand.cc
  12. 3 1
      src/CheckIntegrityEntry.cc
  13. 3 0
      src/ChecksumCheckIntegrityEntry.cc
  14. 16 14
      src/ConsoleStatCalc.cc
  15. 6 2
      src/CreateRequestCommand.cc
  16. 5 2
      src/DHTAutoSaveCommand.cc
  17. 4 1
      src/DHTBucketRefreshCommand.cc
  18. 6 3
      src/DHTEntryPointNameResolveCommand.cc
  19. 5 1
      src/DHTGetPeersCommand.cc
  20. 5 2
      src/DHTInteractionCommand.cc
  21. 4 1
      src/DHTPeerAnnounceCommand.cc
  22. 11 6
      src/DHTSetup.cc
  23. 4 1
      src/DHTTokenUpdateCommand.cc
  24. 7 5
      src/DownloadCommand.cc
  25. 6 11
      src/DownloadEngine.cc
  26. 54 6
      src/DownloadEngine.h
  27. 8 6
      src/DownloadEngineFactory.cc
  28. 7 4
      src/FileAllocationCommand.cc
  29. 2 0
      src/FileAllocationDispatcherCommand.cc
  30. 3 0
      src/FileAllocationEntry.cc
  31. 3 1
      src/FillRequestGroupCommand.cc
  32. 5 1
      src/FtpDownloadCommand.cc
  33. 5 1
      src/FtpFinishDownloadCommand.cc
  34. 4 0
      src/FtpInitiateConnectionCommand.cc
  35. 6 3
      src/FtpNegotiationCommand.cc
  36. 7 3
      src/HaveEraseCommand.cc
  37. 5 1
      src/HttpDownloadCommand.cc
  38. 4 1
      src/HttpInitiateConnectionCommand.cc
  39. 7 4
      src/HttpListenCommand.cc
  40. 7 3
      src/HttpRequestCommand.cc
  41. 9 6
      src/HttpResponseCommand.cc
  42. 7 4
      src/HttpServerBodyCommand.cc
  43. 11 8
      src/HttpServerCommand.cc
  44. 6 4
      src/HttpServerResponseCommand.cc
  45. 5 1
      src/HttpSkipResponseCommand.cc
  46. 7 3
      src/InitiateConnectionCommand.cc
  47. 4 0
      src/InitiateConnectionCommandFactory.cc
  48. 8 4
      src/InitiatorMSEHandshakeCommand.cc
  49. 6 1
      src/LpdDispatchMessageCommand.cc
  50. 5 2
      src/LpdReceiveMessageCommand.cc
  51. 9 6
      src/MultiUrlRequestInfo.cc
  52. 6 1
      src/PeerAbstractCommand.cc
  53. 6 1
      src/PeerChokeCommand.cc
  54. 7 3
      src/PeerInitiateConnectionCommand.cc
  55. 8 5
      src/PeerInteractionCommand.cc
  56. 6 3
      src/PeerListenCommand.cc
  57. 6 3
      src/PeerReceiveHandshakeCommand.cc
  58. 4 0
      src/RealtimeCommand.cc
  59. 10 7
      src/ReceiverMSEHandshakeCommand.cc
  60. 6 5
      src/RequestGroup.cc
  61. 6 4
      src/RequestGroupMan.cc
  62. 5 1
      src/SeedCheckCommand.cc
  63. 2 2
      src/SequentialDispatcherCommand.h
  64. 6 2
      src/SleepCommand.cc
  65. 2 0
      src/StreamCheckIntegrityEntry.cc
  66. 3 0
      src/StreamFileAllocationEntry.cc
  67. 6 1
      src/TimeBasedCommand.cc
  68. 4 1
      src/TimedHaltCommand.cc
  69. 7 3
      src/TrackerWatcherCommand.cc
  70. 5 0
      src/XmlRpcMethod.cc
  71. 55 41
      src/XmlRpcMethodImpl.cc
  72. 55 38
      test/XmlRpcMethodTest.cc

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2010-06-08  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Made public member variables of DownloadEngine private. Added
+	accessor funcs.
+
 2010-06-04  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Release 1.9.4

+ 14 - 12
src/AbstractCommand.cc

@@ -66,6 +66,8 @@
 #include "DownloadContext.h"
 #include "wallclock.h"
 #include "NameResolver.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
 
 namespace aria2 {
 
@@ -134,7 +136,7 @@ bool AbstractCommand::execute() {
           InitiateConnectionCommandFactory::createInitiateConnectionCommand
           (cuid, fasterRequest, _fileEntry, _requestGroup, e);
         e->setNoWait(true);
-        e->commands.push_back(command);
+        e->addCommand(command);
         return true;
       }
     }
@@ -204,13 +206,13 @@ bool AbstractCommand::execute() {
         // timeout triggers ServerStat error state.
 
         SharedHandle<ServerStat> ss =
-          e->_requestGroupMan->getOrCreateServerStat(req->getHost(),
-                                                     req->getProtocol());
+          e->getRequestGroupMan()->getOrCreateServerStat(req->getHost(),
+                                                         req->getProtocol());
         ss->setError();
 
         throw DL_RETRY_EX2(EX_TIME_OUT, downloadresultcode::TIME_OUT);
       }
-      e->commands.push_back(this);
+      e->addCommand(this);
       return false;
     }
   } catch(DlAbortEx& err) {
@@ -318,11 +320,11 @@ bool AbstractCommand::prepareForRetry(time_t wait) {
   Command* command = new CreateRequestCommand(cuid, _requestGroup, e);
   if(wait == 0) {
     e->setNoWait(true);
-    e->commands.push_back(command);
+    e->addCommand(command);
   } else {
     SleepCommand* scom = new SleepCommand(cuid, e, _requestGroup,
                                           command, wait);
-    e->commands.push_back(scom);
+    e->addCommand(scom);
   }
   return true;
 }
@@ -330,8 +332,8 @@ bool AbstractCommand::prepareForRetry(time_t wait) {
 void AbstractCommand::onAbort() {
   if(!req.isNull()) {
     // TODO This might be a problem if the failure is caused by proxy.
-    e->_requestGroupMan->getOrCreateServerStat(req->getHost(),
-                                               req->getProtocol())->setError();
+    e->getRequestGroupMan()->getOrCreateServerStat(req->getHost(),
+                                                   req->getProtocol())->setError();
     _fileEntry->removeIdenticalURI(req->getUri());
     _fileEntry->removeRequest(req);
   }
@@ -610,7 +612,7 @@ bool AbstractCommand::asyncResolveHostname()
   case AsyncNameResolver::STATUS_ERROR:
     disableNameResolverCheck(_asyncNameResolver);
     if(!isProxyRequest(req->getProtocol(), getOption())) {
-      e->_requestGroupMan->getOrCreateServerStat
+      e->getRequestGroupMan()->getOrCreateServerStat
         (req->getHost(), req->getProtocol())->setError();
     }
     throw DL_ABORT_EX(StringFormat(MSG_NAME_RESOLUTION_FAILED,
@@ -671,7 +673,7 @@ std::string AbstractCommand::resolveHostname
       {
         NameResolver res;
         res.setSocktype(SOCK_STREAM);
-        if(e->option->getAsBool(PREF_DISABLE_IPV6)) {
+        if(e->getOption()->getAsBool(PREF_DISABLE_IPV6)) {
           res.setFamily(AF_INET);
         }
         res.resolve(addrs, hostname);
@@ -737,14 +739,14 @@ bool AbstractCommand::checkIfConnectionEstablished
           InitiateConnectionCommandFactory::createInitiateConnectionCommand
           (cuid, req, _fileEntry, _requestGroup, e);
         e->setNoWait(true);
-        e->commands.push_back(command);
+        e->addCommand(command);
         return false;
       }
       e->removeCachedIPAddress(connectedHostname, connectedPort);
       // Don't set error if proxy server is used and its method is GET.
       if(resolveProxyMethod(req->getProtocol()) != V_GET ||
          !isProxyRequest(req->getProtocol(), getOption())) {
-        e->_requestGroupMan->getOrCreateServerStat
+        e->getRequestGroupMan()->getOrCreateServerStat
           (req->getHost(), req->getProtocol())->setError();
       }
       throw DL_RETRY_EX

+ 6 - 2
src/AbstractProxyRequestCommand.cc

@@ -46,6 +46,10 @@
 #include "AuthConfigFactory.h"
 #include "AuthConfig.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -86,11 +90,11 @@ bool AbstractProxyRequestCommand::executeInternal() {
     httpConnection->sendPendingData();
   }
   if(httpConnection->sendBufferIsEmpty()) {
-    e->commands.push_back(getNextCommand());
+    e->addCommand(getNextCommand());
     return true;
   } else {
     setWriteCheckSocket(socket);
-    e->commands.push_back(this);
+    e->addCommand(this);
     return false;
   }
 }

+ 6 - 2
src/AbstractProxyResponseCommand.cc

@@ -46,6 +46,10 @@
 #include "message.h"
 #include "HttpHeader.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -66,13 +70,13 @@ bool AbstractProxyResponseCommand::executeInternal() {
   SharedHandle<HttpResponse> httpResponse = httpConnection->receiveResponse();
   if(httpResponse.isNull()) {
     // the server has not responded our request yet.
-    e->commands.push_back(this);
+    e->addCommand(this);
     return false;
   }
   if(httpResponse->getResponseStatus() != HttpHeader::S200) {
     throw DL_RETRY_EX(EX_PROXY_CONNECTION_FAILED);
   }
-  e->commands.push_back(getNextCommand());
+  e->addCommand(getNextCommand());
   return true;
 }
 

+ 6 - 2
src/ActivePeerConnectionCommand.cc

@@ -51,6 +51,10 @@
 #include "bittorrent_helper.h"
 #include "wallclock.h"
 #include "util.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -125,7 +129,7 @@ bool ActivePeerConnectionCommand::execute() {
       }
     }
   }
-  e->commands.push_back(this);
+  e->addCommand(this);
   return false;
 }
 
@@ -140,7 +144,7 @@ void ActivePeerConnectionCommand::connectToPeer(const SharedHandle<Peer>& peer)
                                       _btRuntime);
   command->setPeerStorage(_peerStorage);
   command->setPieceStorage(_pieceStorage);
-  e->commands.push_back(command);
+  e->addCommand(command);
   if(logger->info()) {
     logger->info(MSG_CONNECTING_TO_PEER,
                  util::itos(cuid).c_str(), peer->ipaddr.c_str());

+ 5 - 2
src/AutoSaveCommand.cc

@@ -36,6 +36,9 @@
 #include "DownloadEngine.h"
 #include "RequestGroupMan.h"
 #include "FileEntry.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -46,14 +49,14 @@ AutoSaveCommand::~AutoSaveCommand() {}
 
 void AutoSaveCommand::preProcess()
 {
-  if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+  if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
     _exit = true;
   }
 }
 
 void AutoSaveCommand::process()
 {
-  _e->_requestGroupMan->save();
+  _e->getRequestGroupMan()->save();
 }
 
 } // namespace aria2

+ 2 - 0
src/BtCheckIntegrityEntry.cc

@@ -41,6 +41,8 @@
 #include "prefs.h"
 #include "Option.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 

+ 3 - 0
src/BtFileAllocationEntry.cc

@@ -41,6 +41,9 @@
 #include "Command.h"
 #include "DownloadEngine.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 

+ 10 - 5
src/BtSetup.cc

@@ -69,6 +69,10 @@
 #include "LpdMessageDispatcher.h"
 #include "message.h"
 #include "SocketCore.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -160,12 +164,12 @@ void BtSetup::setup(std::vector<Command*>& commands,
   }
   if(PeerListenCommand::getNumInstance() == 0) {
     PeerListenCommand* listenCommand = PeerListenCommand::getInstance(e);
-    IntSequence seq = util::parseIntRange(e->option->get(PREF_LISTEN_PORT));
+    IntSequence seq =util::parseIntRange(e->getOption()->get(PREF_LISTEN_PORT));
     uint16_t port;
     if(listenCommand->bindPort(port, seq)) {
       btRuntime->setListenPort(port);
       // Add command to DownloadEngine directly.
-      e->commands.push_back(listenCommand);
+      e->addCommand(listenCommand);
     } else {
       delete listenCommand;
       throw DL_ABORT_EX(_("Errors occurred while binding port.\n"));
@@ -181,7 +185,8 @@ void BtSetup::setup(std::vector<Command*>& commands,
       SharedHandle<LpdMessageReceiver> receiver
         (new LpdMessageReceiver(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT));
       bool initialized = false;
-      const std::string& lpdInterface = e->option->get(PREF_BT_LPD_INTERFACE);
+      const std::string& lpdInterface =
+        e->getOption()->get(PREF_BT_LPD_INTERFACE);
       if(lpdInterface.empty()) {
         if(receiver->init("")) {
           initialized = true;
@@ -206,7 +211,7 @@ void BtSetup::setup(std::vector<Command*>& commands,
                       receiver->getLocalAddress().c_str());
         LpdReceiveMessageCommand* cmd =
           LpdReceiveMessageCommand::getInstance(e, receiver);
-        e->commands.push_back(cmd);
+        e->addCommand(cmd);
       } else {
         _logger->info("LpdMessageReceiver not initialized.");
       }
@@ -227,7 +232,7 @@ void BtSetup::setup(std::vector<Command*>& commands,
         LpdDispatchMessageCommand* cmd =
           new LpdDispatchMessageCommand(e->newCUID(), dispatcher, e);
         cmd->setBtRuntime(btRuntime);
-        e->commands.push_back(cmd);
+        e->addCommand(cmd);
       } else {
         _logger->info("LpdMessageDispatcher not initialized.");
       }

+ 7 - 4
src/CheckIntegrityCommand.cc

@@ -43,6 +43,9 @@
 #include "a2functional.h"
 #include "RecoverableException.h"
 #include "util.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -58,12 +61,12 @@ CheckIntegrityCommand::~CheckIntegrityCommand() {}
 bool CheckIntegrityCommand::executeInternal()
 {
   if(_requestGroup->isHaltRequested()) {
-    _e->_checkIntegrityMan->dropPickedEntry();
+    _e->getCheckIntegrityMan()->dropPickedEntry();
     return true;
   }
   _entry->validateChunk();
   if(_entry->finished()) {
-    _e->_checkIntegrityMan->dropPickedEntry();
+    _e->getCheckIntegrityMan()->dropPickedEntry();
     // Enable control file saving here. See also
     // RequestGroup::processCheckIntegrityEntry() to know why this is
     // needed.
@@ -94,14 +97,14 @@ bool CheckIntegrityCommand::executeInternal()
     _e->setNoWait(true);
     return true;
   } else {
-    _e->commands.push_back(this);
+    _e->addCommand(this);
     return false;
   }
 }
 
 bool CheckIntegrityCommand::handleException(Exception& e)
 {
-  _e->_checkIntegrityMan->dropPickedEntry();
+  _e->getCheckIntegrityMan()->dropPickedEntry();
   logger->error(MSG_FILE_VALIDATION_FAILURE, e, util::itos(cuid).c_str());
   logger->error(MSG_DOWNLOAD_NOT_COMPLETE,
                 util::itos(cuid).c_str(),

+ 2 - 0
src/CheckIntegrityDispatcherCommand.cc

@@ -39,6 +39,8 @@
 #include "Logger.h"
 #include "FileEntry.h"
 #include "util.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
 
 namespace aria2 {
 

+ 3 - 1
src/CheckIntegrityEntry.cc

@@ -42,6 +42,8 @@
 #include "DownloadEngine.h"
 #include "Option.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -91,7 +93,7 @@ void CheckIntegrityEntry::proceedFileAllocation
  DownloadEngine* e)
 {
   if(_requestGroup->needsFileAllocation()) {
-    e->_fileAllocationMan->pushEntry(entry);
+    e->getFileAllocationMan()->pushEntry(entry);
   } else {
     entry->prepareForNextAction(commands, e);
   }

+ 3 - 0
src/ChecksumCheckIntegrityEntry.cc

@@ -39,6 +39,9 @@
 #include "IteratableChecksumValidator.h"
 #include "DownloadEngine.h"
 #include "PieceStorage.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 

+ 16 - 14
src/ConsoleStatCalc.cc

@@ -60,6 +60,7 @@
 #include "util.h"
 #include "DownloadContext.h"
 #include "wallclock.h"
+#include "ServerStatMan.h"
 #ifdef ENABLE_BITTORRENT
 # include "bittorrent_helper.h"
 # include "Peer.h"
@@ -242,37 +243,38 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
     std::cout << '\r' << std::setfill(' ') << std::setw(cols) << ' ' << '\r';
   }
   std::ostringstream o;
-  if(e->_requestGroupMan->countRequestGroup() > 0) {
+  if(e->getRequestGroupMan()->countRequestGroup() > 0) {
     if((_summaryInterval > 0) &&
        _lastSummaryNotified.difference(global::wallclock) >= _summaryInterval) {
       _lastSummaryNotified = global::wallclock;
-      printProgressSummary(e->_requestGroupMan->getRequestGroups(), cols, e,
+      printProgressSummary(e->getRequestGroupMan()->getRequestGroups(), cols, e,
                            sizeFormatter);
       std::cout << "\n";
     }
 
     SharedHandle<RequestGroup> firstRequestGroup =
-      e->_requestGroupMan->getRequestGroup(0);
+      e->getRequestGroupMan()->getRequestGroup(0);
 
     printProgress(o, firstRequestGroup, e, sizeFormatter);
 
-    if(e->_requestGroupMan->countRequestGroup() > 1) {
+    if(e->getRequestGroupMan()->countRequestGroup() > 1) {
       o << "("
-        << e->_requestGroupMan->countRequestGroup()-1
+        << e->getRequestGroupMan()->countRequestGroup()-1
         << "more...)";
     }
   }
 
-  if(e->_requestGroupMan->countRequestGroup() > 1 &&
-     !e->_requestGroupMan->downloadFinished()) {
-    TransferStat stat = e->_requestGroupMan->calculateStat();
+  if(e->getRequestGroupMan()->countRequestGroup() > 1 &&
+     !e->getRequestGroupMan()->downloadFinished()) {
+    TransferStat stat = e->getRequestGroupMan()->calculateStat();
     o << " "
       << "[TOTAL SPD:"
       << sizeFormatter(stat.getDownloadSpeed()) << "Bs" << "]";
   }
 
   {
-    SharedHandle<FileAllocationEntry> entry=e->_fileAllocationMan->getPickedEntry();
+    SharedHandle<FileAllocationEntry> entry =
+      e->getFileAllocationMan()->getPickedEntry();
     if(!entry.isNull()) {
       o << " "
         << "[FileAlloc:"
@@ -290,9 +292,9 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
       }
       o << "%)"
         << "]";
-      if(e->_fileAllocationMan->hasNext()) {
+      if(e->getFileAllocationMan()->hasNext()) {
         o << "("
-          << e->_fileAllocationMan->countEntryInQueue()
+          << e->getFileAllocationMan()->countEntryInQueue()
           << "waiting...)";
       }
     }
@@ -300,7 +302,7 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
 #ifdef ENABLE_MESSAGE_DIGEST
   {
     SharedHandle<CheckIntegrityEntry> entry =
-      e->_checkIntegrityMan->getPickedEntry();
+      e->getCheckIntegrityMan()->getPickedEntry();
     if(!entry.isNull()) {
       o << " "
         << "[Checksum:"
@@ -314,9 +316,9 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
         << 100*entry->getCurrentLength()/entry->getTotalLength()
         << "%)"
         << "]";
-      if(e->_checkIntegrityMan->hasNext()) {
+      if(e->getCheckIntegrityMan()->hasNext()) {
         o << "("
-          << e->_checkIntegrityMan->countEntryInQueue()
+          << e->getCheckIntegrityMan()->countEntryInQueue()
           << "waiting...)";
       }
     }

+ 6 - 2
src/CreateRequestCommand.cc

@@ -47,6 +47,10 @@
 #include "SleepCommand.h"
 #include "Logger.h"
 #include "util.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -95,7 +99,7 @@ bool CreateRequestCommand::executeInternal()
     InitiateConnectionCommandFactory::createInitiateConnectionCommand
     (cuid, req, _fileEntry, _requestGroup, e);
   e->setNoWait(true);
-  e->commands.push_back(command);
+  e->addCommand(command);
   return true;
 }
 
@@ -117,7 +121,7 @@ bool CreateRequestCommand::prepareForRetry(time_t wait)
                   util::itos(cuid).c_str());
   }
   SleepCommand* scom = new SleepCommand(cuid, e, _requestGroup, this, wait);
-  e->commands.push_back(scom);
+  e->addCommand(scom);
   return false;
 }
 

+ 5 - 2
src/DHTAutoSaveCommand.cc

@@ -55,6 +55,9 @@
 #include "FileEntry.h"
 #include "DlAbortEx.h"
 #include "StringFormat.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -65,7 +68,7 @@ DHTAutoSaveCommand::~DHTAutoSaveCommand() {}
 
 void DHTAutoSaveCommand::preProcess()
 {
-  if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+  if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
     save();
     _exit = true;
   }
@@ -78,7 +81,7 @@ void DHTAutoSaveCommand::process()
 
 void DHTAutoSaveCommand::save()
 {
-  std::string dhtFile = _e->option->get(PREF_DHT_FILE_PATH);
+  std::string dhtFile = _e->getOption()->get(PREF_DHT_FILE_PATH);
   logger->info("Saving DHT routing table to %s.", dhtFile.c_str());
 
   std::string tempFile = dhtFile;

+ 4 - 1
src/DHTBucketRefreshCommand.cc

@@ -40,6 +40,9 @@
 #include "DownloadEngine.h"
 #include "RequestGroupMan.h"
 #include "FileEntry.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -51,7 +54,7 @@ DHTBucketRefreshCommand::~DHTBucketRefreshCommand() {}
 
 void DHTBucketRefreshCommand::preProcess()
 {
-  _exit = _e->_requestGroupMan->downloadFinished() || _e->isHaltRequested();
+  _exit = _e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested();
 }
 
 void DHTBucketRefreshCommand::process()

+ 6 - 3
src/DHTEntryPointNameResolveCommand.cc

@@ -52,6 +52,9 @@
 #include "Logger.h"
 #include "StringFormat.h"
 #include "FileEntry.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -73,7 +76,7 @@ DHTEntryPointNameResolveCommand::~DHTEntryPointNameResolveCommand()
 
 bool DHTEntryPointNameResolveCommand::execute()
 {
-  if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+  if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
     return true;
   }
 #ifdef ENABLE_ASYNC_DNS
@@ -83,7 +86,7 @@ bool DHTEntryPointNameResolveCommand::execute()
 #endif // ENABLE_ASYNC_DNS
   try {
 #ifdef ENABLE_ASYNC_DNS
-    if(_e->option->getAsBool(PREF_ASYNC_DNS)) {
+    if(_e->getOption()->getAsBool(PREF_ASYNC_DNS)) {
       while(!_entryPoints.empty()) {
         std::string hostname = _entryPoints.front().first;
         try {
@@ -94,7 +97,7 @@ bool DHTEntryPointNameResolveCommand::execute()
             _resolvedEntryPoints.push_back(p);
             addPingTask(p);
           } else {
-            _e->commands.push_back(this);
+            _e->addCommand(this);
             return false;
           }
         } catch(RecoverableException& e) {

+ 5 - 1
src/DHTGetPeersCommand.cc

@@ -47,6 +47,10 @@
 #include "bittorrent_helper.h"
 #include "DownloadContext.h"
 #include "wallclock.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -94,7 +98,7 @@ bool DHTGetPeersCommand::execute()
     _task.reset();
   }
 
-  _e->commands.push_back(this);
+  _e->addCommand(this);
   return false;
 }
 

+ 5 - 2
src/DHTInteractionCommand.cc

@@ -46,6 +46,9 @@
 #include "DHTMessageCallback.h"
 #include "DHTNode.h"
 #include "FileEntry.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -71,7 +74,7 @@ void DHTInteractionCommand::disableReadCheckSocket(const SocketHandle& socket)
 
 bool DHTInteractionCommand::execute()
 {
-  if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+  if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
     return true;
   }
 
@@ -89,7 +92,7 @@ bool DHTInteractionCommand::execute()
   } catch(RecoverableException& e) {
     logger->error(EX_EXCEPTION_CAUGHT, e);
   }
-  _e->commands.push_back(this);
+  _e->addCommand(this);
   return false;
 }
 

+ 4 - 1
src/DHTPeerAnnounceCommand.cc

@@ -40,6 +40,9 @@
 #include "message.h"
 #include "Logger.h"
 #include "FileEntry.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -51,7 +54,7 @@ DHTPeerAnnounceCommand::~DHTPeerAnnounceCommand() {}
 
 void DHTPeerAnnounceCommand::preProcess()
 {
-  _exit = _e->_requestGroupMan->downloadFinished() || _e->isHaltRequested();
+  _exit = _e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested();
 }
 
 void DHTPeerAnnounceCommand::process()

+ 11 - 6
src/DHTSetup.cc

@@ -71,6 +71,11 @@
 #include "a2functional.h"
 #include "DownloadEngine.h"
 #include "wallclock.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
+#include "FileEntry.h"
 
 namespace aria2 {
 
@@ -93,7 +98,7 @@ void DHTSetup::setup(std::vector<Command*>& commands, DownloadEngine* e)
     SharedHandle<DHTNode> localNode;
 
     DHTRoutingTableDeserializer deserializer;
-    std::string dhtFile = e->option->get(PREF_DHT_FILE_PATH);
+    std::string dhtFile = e->getOption()->get(PREF_DHT_FILE_PATH);
     try {
       std::ifstream in(dhtFile.c_str(), std::ios::binary);
       if(!in) {
@@ -112,7 +117,7 @@ void DHTSetup::setup(std::vector<Command*>& commands, DownloadEngine* e)
     SharedHandle<DHTConnectionImpl> connection(new DHTConnectionImpl());
     {
       IntSequence seq =
-        util::parseIntRange(e->option->get(PREF_DHT_LISTEN_PORT));
+        util::parseIntRange(e->getOption()->get(PREF_DHT_LISTEN_PORT));
       uint16_t port;
       if(!connection->bind(port, seq)) {
         throw DL_ABORT_EX("Error occurred while binding port for DHT");
@@ -141,7 +146,7 @@ void DHTSetup::setup(std::vector<Command*>& commands, DownloadEngine* e)
 
     SharedHandle<DHTTokenTracker> tokenTracker(new DHTTokenTracker());
 
-    const time_t messageTimeout = e->option->getAsInt(PREF_DHT_MESSAGE_TIMEOUT);
+    const time_t messageTimeout = e->getOption()->getAsInt(PREF_DHT_MESSAGE_TIMEOUT);
     // wiring up
     tracker->setRoutingTable(routingTable);
     tracker->setMessageFactory(factory);
@@ -199,11 +204,11 @@ void DHTSetup::setup(std::vector<Command*>& commands, DownloadEngine* e)
       taskQueue->addPeriodicTask1(task);
     }
 
-    if(!e->option->get(PREF_DHT_ENTRY_POINT_HOST).empty()) {
+    if(!e->getOption()->get(PREF_DHT_ENTRY_POINT_HOST).empty()) {
       {
         std::pair<std::string, uint16_t> addr
-          (e->option->get(PREF_DHT_ENTRY_POINT_HOST),
-           e->option->getAsInt(PREF_DHT_ENTRY_POINT_PORT));
+          (e->getOption()->get(PREF_DHT_ENTRY_POINT_HOST),
+           e->getOption()->getAsInt(PREF_DHT_ENTRY_POINT_PORT));
         std::vector<std::pair<std::string, uint16_t> > entryPoints;
         entryPoints.push_back(addr);
         DHTEntryPointNameResolveCommand* command =

+ 4 - 1
src/DHTTokenUpdateCommand.cc

@@ -40,6 +40,9 @@
 #include "message.h"
 #include "Logger.h"
 #include "FileEntry.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -52,7 +55,7 @@ DHTTokenUpdateCommand::~DHTTokenUpdateCommand() {}
 
 void DHTTokenUpdateCommand::preProcess()
 {
-  _exit = _e->_requestGroupMan->downloadFinished() || _e->isHaltRequested();
+  _exit = _e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested();
 }
 
 void DHTTokenUpdateCommand::process()

+ 7 - 5
src/DownloadCommand.cc

@@ -59,6 +59,8 @@
 #include "Decoder.h"
 #include "RequestGroupMan.h"
 #include "wallclock.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
 #ifdef ENABLE_MESSAGE_DIGEST
 # include "MessageDigestHelper.h"
 #endif // ENABLE_MESSAGE_DIGEST
@@ -106,9 +108,9 @@ DownloadCommand::~DownloadCommand() {
 }
 
 bool DownloadCommand::executeInternal() {
-  if(e->_requestGroupMan->doesOverallDownloadSpeedExceed() ||
+  if(e->getRequestGroupMan()->doesOverallDownloadSpeedExceed() ||
      _requestGroup->doesDownloadSpeedExceed()) {
-    e->commands.push_back(this);
+    e->addCommand(this);
     disableReadCheckSocket();
     return false;
   }
@@ -248,7 +250,7 @@ bool DownloadCommand::executeInternal() {
   } else {
     checkLowestDownloadSpeed();
     setWriteCheckSocketIf(socket, socket->wantWrite());
-    e->commands.push_back(this);
+    e->addCommand(this);
     return false;
   }
 }
@@ -292,7 +294,7 @@ bool DownloadCommand::prepareForNextSegment() {
       if(entry->isValidationReady()) {
         entry->initValidator();
         // TODO do we need cuttrailinggarbage here?
-        e->_checkIntegrityMan->pushEntry(entry);
+        e->getCheckIntegrityMan()->pushEntry(entry);
       }
     }
     // Following 2lines are needed for DownloadEngine to detect
@@ -316,7 +318,7 @@ bool DownloadCommand::prepareForNextSegment() {
       if(nextSegment.isNull()) {
         return prepareForRetry(0);
       } else {
-        e->commands.push_back(this);
+        e->addCommand(this);
         return false;
       }
     } else {

+ 6 - 11
src/DownloadEngine.cc

@@ -111,8 +111,8 @@ DownloadEngine::~DownloadEngine() {
 }
 
 void DownloadEngine::cleanQueue() {
-  std::for_each(commands.begin(), commands.end(), Deleter());
-  commands.clear();
+  std::for_each(_commands.begin(), _commands.end(), Deleter());
+  _commands.clear();
 }
 
 static void executeCommand(std::deque<Command*>& commands,
@@ -141,18 +141,18 @@ void DownloadEngine::run()
 {
   Timer cp;
   cp.reset(0);
-  while(!commands.empty() || !_routineCommands.empty()) {
+  while(!_commands.empty() || !_routineCommands.empty()) {
     global::wallclock.reset();
     if(cp.difference(global::wallclock) >= _refreshInterval) {
       _refreshInterval = DEFAULT_REFRESH_INTERVAL;
       cp = global::wallclock;
-      executeCommand(commands, Command::STATUS_ALL);
+      executeCommand(_commands, Command::STATUS_ALL);
     } else {
-      executeCommand(commands, Command::STATUS_ACTIVE);
+      executeCommand(_commands, Command::STATUS_ACTIVE);
     }
     executeCommand(_routineCommands, Command::STATUS_ALL);
     afterEachIteration();
-    if(!commands.empty()) {
+    if(!_commands.empty()) {
       waitData();
     }
     _noWait = false;
@@ -250,11 +250,6 @@ void DownloadEngine::setStatCalc(const StatCalcHandle& statCalc)
   _statCalc = statCalc;
 }
 
-void DownloadEngine::addCommand(const std::vector<Command*>& commands)
-{
-  this->commands.insert(this->commands.end(), commands.begin(), commands.end());
-}
-
 #ifdef ENABLE_ASYNC_DNS
 bool DownloadEngine::addNameResolverCheck
 (const SharedHandle<AsyncNameResolver>& resolver, Command* command)

+ 54 - 6
src/DownloadEngine.h

@@ -154,16 +154,16 @@ private:
 
   std::multimap<std::string, SocketPoolEntry>::iterator
   findSocketPoolEntry(const std::string& key);
-public:
-  std::deque<Command*> commands;
+
+  std::deque<Command*> _commands;
   SharedHandle<RequestGroupMan> _requestGroupMan;
   SharedHandle<FileAllocationMan> _fileAllocationMan;
   SharedHandle<CheckIntegrityMan> _checkIntegrityMan;
-  Option* option;
-  
+  Option* _option;
+public:  
   DownloadEngine(const SharedHandle<EventPoll>& eventPoll);
 
-  virtual ~DownloadEngine();
+  ~DownloadEngine();
 
   void run();
 
@@ -186,7 +186,55 @@ public:
                                Command* command);
 #endif // ENABLE_ASYNC_DNS
 
-  void addCommand(const std::vector<Command*>& commands);
+  void addCommand(const std::vector<Command*>& commands)
+  {
+    _commands.insert(_commands.end(), commands.begin(), commands.end());
+  }
+
+  void addCommand(Command* command)
+  {
+    _commands.push_back(command);
+  }
+
+  const SharedHandle<RequestGroupMan>& getRequestGroupMan() const
+  {
+    return _requestGroupMan;
+  }
+
+  void setRequestGroupMan(const SharedHandle<RequestGroupMan>& rgman)
+  {
+    _requestGroupMan = rgman;
+  }
+
+  const SharedHandle<FileAllocationMan>& getFileAllocationMan() const
+  {
+    return _fileAllocationMan;
+  }
+
+  void setFileAllocationMan(const SharedHandle<FileAllocationMan>& faman)
+  {
+    _fileAllocationMan = faman;
+  }
+
+  const SharedHandle<CheckIntegrityMan>& getCheckIntegrityMan() const
+  {
+    return _checkIntegrityMan;
+  }
+
+  void setCheckIntegrityMan(const SharedHandle<CheckIntegrityMan>& ciman)
+  {
+    _checkIntegrityMan = ciman;
+  }
+
+  Option* getOption() const
+  {
+    return _option;
+  }
+
+  void setOption(Option* op)
+  {
+    _option = op;
+  }
 
   void setStatCalc(const SharedHandle<StatCalc>& statCalc);
 

+ 8 - 6
src/DownloadEngineFactory.cc

@@ -134,22 +134,24 @@ DownloadEngineFactory::newDownloadEngine
             abort();
           }
   DownloadEngineHandle e(new DownloadEngine(eventPoll));
-  e->option = op;
+  e->setOption(op);
 
   RequestGroupManHandle
     requestGroupMan(new RequestGroupMan(requestGroups, MAX_CONCURRENT_DOWNLOADS,
                                         op));
-  e->_requestGroupMan = requestGroupMan;
-  e->_fileAllocationMan.reset(new FileAllocationMan());
+  e->setRequestGroupMan(requestGroupMan);
+  e->setFileAllocationMan
+    (SharedHandle<FileAllocationMan>(new FileAllocationMan()));
 #ifdef ENABLE_MESSAGE_DIGEST
-  e->_checkIntegrityMan.reset(new CheckIntegrityMan());
+  e->setCheckIntegrityMan
+    (SharedHandle<CheckIntegrityMan>(new CheckIntegrityMan()));
 #endif // ENABLE_MESSAGE_DIGEST
   e->addRoutineCommand(new FillRequestGroupCommand(e->newCUID(), e.get()));
   e->addRoutineCommand(new FileAllocationDispatcherCommand
-                       (e->newCUID(), e->_fileAllocationMan, e.get()));
+                       (e->newCUID(), e->getFileAllocationMan(), e.get()));
 #ifdef ENABLE_MESSAGE_DIGEST
   e->addRoutineCommand(new CheckIntegrityDispatcherCommand
-                       (e->newCUID(), e->_checkIntegrityMan, e.get()));
+                       (e->newCUID(), e->getCheckIntegrityMan(), e.get()));
 #endif // ENABLE_MESSAGE_DIGEST
 
   if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {

+ 7 - 4
src/FileAllocationCommand.cc

@@ -46,6 +46,9 @@
 #include "a2functional.h"
 #include "RecoverableException.h"
 #include "wallclock.h"
+#include "RequestGroupMan.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -60,7 +63,7 @@ FileAllocationCommand::~FileAllocationCommand() {}
 bool FileAllocationCommand::executeInternal()
 {
   if(_requestGroup->isHaltRequested()) {
-    _e->_fileAllocationMan->dropPickedEntry();
+    _e->getFileAllocationMan()->dropPickedEntry();
     return true;
   }
   _fileAllocationEntry->allocateChunk();
@@ -70,7 +73,7 @@ bool FileAllocationCommand::executeInternal()
                     _timer.difference(global::wallclock),
                     util::itos(_requestGroup->getTotalLength(), true).c_str());
     }
-    _e->_fileAllocationMan->dropPickedEntry();
+    _e->getFileAllocationMan()->dropPickedEntry();
     
     std::vector<Command*> commands;
     try {
@@ -83,14 +86,14 @@ bool FileAllocationCommand::executeInternal()
     _e->setNoWait(true);
     return true;
   } else {
-    _e->commands.push_back(this);
+    _e->addCommand(this);
     return false;
   }
 }
 
 bool FileAllocationCommand::handleException(Exception& e)
 {
-  _e->_fileAllocationMan->dropPickedEntry();
+  _e->getFileAllocationMan()->dropPickedEntry();
   logger->error(MSG_FILE_ALLOCATION_FAILURE, e, util::itos(cuid).c_str());
   logger->error(MSG_DOWNLOAD_NOT_COMPLETE, util::itos(cuid).c_str(),
                 _requestGroup->getDownloadContext()->getBasePath().c_str());

+ 2 - 0
src/FileAllocationDispatcherCommand.cc

@@ -39,6 +39,8 @@
 #include "Logger.h"
 #include "DownloadContext.h"
 #include "util.h"
+#include "ServerStatMan.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 

+ 3 - 0
src/FileAllocationEntry.cc

@@ -39,6 +39,9 @@
 #include "PieceStorage.h"
 #include "DiskAdaptor.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 

+ 3 - 1
src/FillRequestGroupCommand.cc

@@ -41,6 +41,8 @@
 #include "Logger.h"
 #include "DownloadContext.h"
 #include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -59,7 +61,7 @@ bool FillRequestGroupCommand::execute()
   if(_e->isHaltRequested()) {
     return true;
   }
-  SharedHandle<RequestGroupMan> rgman = _e->_requestGroupMan;
+  SharedHandle<RequestGroupMan> rgman = _e->getRequestGroupMan();
   if(rgman->queueCheckRequested()) {
     try {
       // During adding RequestGroup,

+ 5 - 1
src/FtpDownloadCommand.cc

@@ -44,6 +44,10 @@
 #include "FtpConnection.h"
 #include "Logger.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -69,7 +73,7 @@ bool FtpDownloadCommand::prepareForNextSegment()
      static_cast<uint64_t>(_fileEntry->gtoloff(_segments.front()->getPositionToWrite())) == _fileEntry->getLength()) {
     Command* command = new FtpFinishDownloadCommand
       (cuid, req, _fileEntry, _requestGroup, _ftpConnection, e, ctrlSocket);
-    e->commands.push_back(command);
+    e->addCommand(command);
 
     if(_requestGroup->downloadFinished()) {
       // To run checksum checking, we had to call following function here.

+ 5 - 1
src/FtpFinishDownloadCommand.cc

@@ -48,6 +48,10 @@
 #include "RequestGroup.h"
 #include "Logger.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -73,7 +77,7 @@ bool FtpFinishDownloadCommand::execute()
   try {
     unsigned int status = _ftpConnection->receiveResponse();
     if(status == 0) {
-      e->commands.push_back(this);
+      e->addCommand(this);
       return false;
     }
     if(status != 226) {

+ 4 - 0
src/FtpInitiateConnectionCommand.cc

@@ -54,6 +54,10 @@
 #include "util.h"
 #include "AuthConfigFactory.h"
 #include "AuthConfig.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 

+ 6 - 3
src/FtpNegotiationCommand.cc

@@ -71,6 +71,9 @@
 #include "HttpResponse.h"
 #include "DlRetryEx.h"
 #include "CookieStorage.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -114,7 +117,7 @@ bool FtpNegotiationCommand::executeInternal() {
     }
     _requestGroup->getURISelector()->tuneDownloadCommand
       (_fileEntry->getRemainingUris(), command);
-    e->commands.push_back(command);
+    e->addCommand(command);
     return true;
   } else if(sequence == SEQ_HEAD_OK || sequence == SEQ_DOWNLOAD_ALREADY_COMPLETED) {
     return true;
@@ -128,7 +131,7 @@ bool FtpNegotiationCommand::executeInternal() {
   } else if(sequence == SEQ_EXIT) {
     return true;
   } else {
-    e->commands.push_back(this);
+    e->addCommand(this);
     return false;
   }
 }
@@ -358,7 +361,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
         util::fixTaintedBasename(util::percentDecode(req->getFile()))));
   }
   _requestGroup->preDownloadProcessing();
-  if(e->_requestGroupMan->isSameFileBeingDownloaded(_requestGroup)) {
+  if(e->getRequestGroupMan()->isSameFileBeingDownloaded(_requestGroup)) {
     throw DOWNLOAD_FAILURE_EXCEPTION
       (StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
                     _requestGroup->getFirstFilePath().c_str()).str());

+ 7 - 3
src/HaveEraseCommand.cc

@@ -38,6 +38,9 @@
 #include "PieceStorage.h"
 #include "RequestGroup.h"
 #include "DownloadContext.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -48,16 +51,17 @@ HaveEraseCommand::~HaveEraseCommand() {}
 
 void HaveEraseCommand::preProcess()
 {
-  if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+  if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
     _exit = true;
   }
 }
 
 void HaveEraseCommand::process()
 {
-  size_t numLoop = _e->_requestGroupMan->countRequestGroup();
+  size_t numLoop = _e->getRequestGroupMan()->countRequestGroup();
   for(size_t i = 0; i < numLoop; ++i) {
-    PieceStorageHandle ps = _e->_requestGroupMan->getRequestGroup(i)->getPieceStorage();
+    PieceStorageHandle ps =
+      _e->getRequestGroupMan()->getRequestGroup(i)->getPieceStorage();
     if(!ps.isNull()) {
       ps->removeAdvertisedPiece(5);
     }

+ 5 - 1
src/HttpDownloadCommand.cc

@@ -48,6 +48,10 @@
 #include "Range.h"
 #include "DownloadContext.h"
 #include "Decoder.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -78,7 +82,7 @@ bool HttpDownloadCommand::prepareForNextSegment() {
     if(resolveProxyMethod(req->getProtocol()) == V_GET) {
       command->setProxyRequest(createProxyRequest());
     }
-    e->commands.push_back(command);
+    e->addCommand(command);
     return true;
   } else {
     if(req->isPipeliningEnabled() ||

+ 4 - 1
src/HttpInitiateConnectionCommand.cc

@@ -49,7 +49,10 @@
 #include "A2STR.h"
 #include "DownloadContext.h"
 #include "util.h"
-
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 namespace aria2 {
 
 HttpInitiateConnectionCommand::HttpInitiateConnectionCommand

+ 7 - 4
src/HttpListenCommand.cc

@@ -45,6 +45,9 @@
 #include "prefs.h"
 #include "Option.h"
 #include "util.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -60,7 +63,7 @@ HttpListenCommand::~HttpListenCommand()
 
 bool HttpListenCommand::execute()
 {
-  if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+  if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
     return true;
   }
   try {
@@ -77,14 +80,14 @@ bool HttpListenCommand::execute()
       HttpServerCommand* c =
         new HttpServerCommand(_e->newCUID(), _e, socket);
       _e->setNoWait(true);
-      _e->commands.push_back(c);
+      _e->addCommand(c);
     }
   } catch(RecoverableException& e) {
     if(logger->debug()) {
       logger->debug(MSG_ACCEPT_FAILURE, e, util::itos(cuid).c_str());
     }
   }
-  _e->commands.push_back(this);
+  _e->addCommand(this);
   return false;
 }
 
@@ -100,7 +103,7 @@ bool HttpListenCommand::bindPort(uint16_t port)
   }
   try {
     int flags = 0;
-    if(_e->option->getAsBool(PREF_XML_RPC_LISTEN_ALL)) {
+    if(_e->getOption()->getAsBool(PREF_XML_RPC_LISTEN_ALL)) {
       flags = AI_PASSIVE;
     }
     _serverSocket->bind(port, flags);

+ 7 - 3
src/HttpRequestCommand.cc

@@ -53,6 +53,10 @@
 #include "AuthConfigFactory.h"
 #include "AuthConfig.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -116,7 +120,7 @@ bool HttpRequestCommand::executeInternal() {
     if(!socket->initiateSecureConnection(req->getHost())) {
       setReadCheckSocketIf(socket, socket->wantRead());
       setWriteCheckSocketIf(socket, socket->wantWrite());
-      e->commands.push_back(this);
+      e->addCommand(this);
       return false;
     }
   }
@@ -164,12 +168,12 @@ bool HttpRequestCommand::executeInternal() {
     Command* command = new HttpResponseCommand(cuid, req, _fileEntry,
                                                _requestGroup,
                                                _httpConnection, e, socket);
-    e->commands.push_back(command);
+    e->addCommand(command);
     return true;
   } else {
     setReadCheckSocketIf(socket, socket->wantRead());
     setWriteCheckSocketIf(socket, socket->wantWrite());
-    e->commands.push_back(this);
+    e->addCommand(this);
     return false;
   }
 }

+ 9 - 6
src/HttpResponseCommand.cc

@@ -66,6 +66,9 @@
 #include "AuthConfig.h"
 #include "a2functional.h"
 #include "URISelector.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -98,7 +101,7 @@ bool HttpResponseCommand::executeInternal()
     // For socket->wantRead() == true, setReadCheckSocket(socket) is already
     // done in the constructor.
     setWriteCheckSocketIf(socket, socket->wantWrite());
-    e->commands.push_back(this);
+    e->addCommand(this);
     return false;
   }
   // check HTTP status number
@@ -137,7 +140,7 @@ bool HttpResponseCommand::executeInternal()
     }
     _fileEntry->setContentType(httpResponse->getContentType());
     _requestGroup->preDownloadProcessing();
-    if(e->_requestGroupMan->isSameFileBeingDownloaded(_requestGroup)) {
+    if(e->getRequestGroupMan()->isSameFileBeingDownloaded(_requestGroup)) {
       throw DOWNLOAD_FAILURE_EXCEPTION
         (StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
                       _requestGroup->getFirstFilePath().c_str()).str());
@@ -173,12 +176,12 @@ bool HttpResponseCommand::executeInternal()
       // Also we can't resume in this case too.  So truncate the file
       // anyway.
       _requestGroup->getPieceStorage()->getDiskAdaptor()->truncate(0);
-      e->commands.push_back
+      e->addCommand
         (createHttpDownloadCommand(httpResponse,
                                    getTransferEncodingDecoder(httpResponse),
                                    getContentEncodingDecoder(httpResponse)));
     } else {
-      e->commands.push_back(createHttpDownloadCommand(httpResponse,
+      e->addCommand(createHttpDownloadCommand(httpResponse,
                                                       getTransferEncodingDecoder(httpResponse)));
     }
     return true;
@@ -347,7 +350,7 @@ bool HttpResponseCommand::handleOtherEncoding
   // AbstractCommand::execute()
   _requestGroup->getSegmentMan()->getSegment(cuid, 0);
 
-  e->commands.push_back
+  e->addCommand
     (createHttpDownloadCommand(httpResponse,
                                getTransferEncodingDecoder(httpResponse),
                                getContentEncodingDecoder(httpResponse)));
@@ -376,7 +379,7 @@ bool HttpResponseCommand::skipResponseBody
     e->setNoWait(true);
   }
 
-  e->commands.push_back(command);
+  e->addCommand(command);
   return true;
 }
 

+ 7 - 4
src/HttpServerBodyCommand.cc

@@ -52,6 +52,9 @@
 #include "DownloadContext.h"
 #include "wallclock.h"
 #include "util.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -76,7 +79,7 @@ HttpServerBodyCommand::~HttpServerBodyCommand()
 
 bool HttpServerBodyCommand::execute()
 {
-  if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+  if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
     return true;
   }
   try {
@@ -97,14 +100,14 @@ bool HttpServerBodyCommand::execute()
           _httpServer->feedResponse(responseData, "text/xml");
           Command* command =
             new HttpServerResponseCommand(cuid, _httpServer, _e, _socket);
-          _e->commands.push_back(command);
+          _e->addCommand(command);
           _e->setNoWait(true);
           return true;
         } else {
           return true;
         }
       } else {
-        _e->commands.push_back(this);
+        _e->addCommand(this);
         return false;
       } 
     } else {
@@ -112,7 +115,7 @@ bool HttpServerBodyCommand::execute()
         logger->info("HTTP request body timeout.");
         return true;
       } else {
-        _e->commands.push_back(this);
+        _e->addCommand(this);
         return false;
       }
     }

+ 11 - 8
src/HttpServerCommand.cc

@@ -48,6 +48,9 @@
 #include "util.h"
 #include "DownloadContext.h"
 #include "wallclock.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -60,8 +63,8 @@ HttpServerCommand::HttpServerCommand(cuid_t cuid, DownloadEngine* e,
 {
   setStatus(Command::STATUS_ONESHOT_REALTIME);
   _e->addSocketForReadCheck(_socket, this);
-  _httpServer->setUsernamePassword(_e->option->get(PREF_XML_RPC_USER),
-                                   _e->option->get(PREF_XML_RPC_PASSWD));
+  _httpServer->setUsernamePassword(_e->getOption()->get(PREF_XML_RPC_USER),
+                                   _e->getOption()->get(PREF_XML_RPC_PASSWD));
 #ifdef HAVE_LIBZ
   _httpServer->enableGZip();
 #else // !HAVE_LIBZ
@@ -88,7 +91,7 @@ HttpServerCommand::~HttpServerCommand()
 
 bool HttpServerCommand::execute()
 {
-  if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+  if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
     return true;
   }
   try {
@@ -99,7 +102,7 @@ bool HttpServerCommand::execute()
       header = _httpServer->receiveRequest();
 
       if(header.isNull()) {
-        _e->commands.push_back(this);
+        _e->addCommand(this);
         return false;
       }
       if(!_httpServer->authenticate()) {
@@ -109,12 +112,12 @@ bool HttpServerCommand::execute()
                                   "","text/html");
         Command* command =
           new HttpServerResponseCommand(cuid, _httpServer, _e, _socket);
-        _e->commands.push_back(command);
+        _e->addCommand(command);
         _e->setNoWait(true);
         return true;
       }
       if(static_cast<uint64_t>
-         (_e->option->getAsInt(PREF_XML_RPC_MAX_REQUEST_SIZE)) <
+         (_e->getOption()->getAsInt(PREF_XML_RPC_MAX_REQUEST_SIZE)) <
          _httpServer->getContentLength()) {
         logger->info("Request too long. ContentLength=%s."
                      " See --xml-rpc-max-request-size option to loose"
@@ -124,7 +127,7 @@ bool HttpServerCommand::execute()
       }
       Command* command = new HttpServerBodyCommand(cuid, _httpServer, _e,
                                                    _socket);
-      _e->commands.push_back(command);
+      _e->addCommand(command);
       _e->setNoWait(true);
       return true;
     } else {
@@ -132,7 +135,7 @@ bool HttpServerCommand::execute()
         logger->info("HTTP request timeout.");
         return true;
       } else {
-        _e->commands.push_back(this);
+        _e->addCommand(this);
         return false;
       }
     }

+ 6 - 4
src/HttpServerResponseCommand.cc

@@ -43,6 +43,9 @@
 #include "FileEntry.h"
 #include "wallclock.h"
 #include "util.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -67,7 +70,7 @@ HttpServerResponseCommand::~HttpServerResponseCommand()
 
 bool HttpServerResponseCommand::execute()
 {
-  if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+  if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
     return true;
   }
   try {
@@ -88,8 +91,7 @@ bool HttpServerResponseCommand::execute()
       if(logger->info()) {
         logger->info("CUID#%s - Persist connection.", util::itos(cuid).c_str());
       }
-      _e->commands.push_back
-        (new HttpServerCommand(cuid, _httpServer, _e, _socket));
+      _e->addCommand(new HttpServerCommand(cuid, _httpServer, _e, _socket));
     }
     return true;
   } else {
@@ -100,7 +102,7 @@ bool HttpServerResponseCommand::execute()
       }
       return true;
     } else {
-      _e->commands.push_back(this);
+      _e->addCommand(this);
       return false;
     }
   }

+ 5 - 1
src/HttpSkipResponseCommand.cc

@@ -54,6 +54,10 @@
 #include "AuthConfigFactory.h"
 #include "AuthConfig.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -137,7 +141,7 @@ bool HttpSkipResponseCommand::executeInternal()
     return processResponse();
   } else {
     setWriteCheckSocketIf(socket, socket->wantWrite());
-    e->commands.push_back(this);
+    e->addCommand(this);
     return false;
   }
 }

+ 7 - 3
src/InitiateConnectionCommand.cc

@@ -48,6 +48,10 @@
 #include "a2functional.h"
 #include "InitiateConnectionCommandFactory.h"
 #include "util.h"
+#include "RequestGroupMan.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -82,13 +86,13 @@ bool InitiateConnectionCommand::executeInternal() {
   std::vector<std::string> addrs;
   std::string ipaddr = resolveHostname(addrs, hostname, port);
   if(ipaddr.empty()) {
-    e->commands.push_back(this);
+    e->addCommand(this);
     return false;
   }
   try {
     Command* command = createNextCommand(hostname, ipaddr, port,
                                          addrs, proxyRequest);
-    e->commands.push_back(command);
+    e->addCommand(command);
     return true;
   } catch(RecoverableException& ex) {
     // Catch exception and retry another address.
@@ -106,7 +110,7 @@ bool InitiateConnectionCommand::executeInternal() {
         InitiateConnectionCommandFactory::createInitiateConnectionCommand
         (cuid, req, _fileEntry, _requestGroup, e);
       e->setNoWait(true);
-      e->commands.push_back(command);
+      e->addCommand(command);
       return true;
     }
     e->removeCachedIPAddress(hostname, port);

+ 4 - 0
src/InitiateConnectionCommandFactory.cc

@@ -44,6 +44,10 @@
 #include "prefs.h"
 #include "SocketCore.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 

+ 8 - 4
src/InitiatorMSEHandshakeCommand.cc

@@ -54,6 +54,10 @@
 #include "DownloadContext.h"
 #include "bittorrent_helper.h"
 #include "util.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -157,13 +161,13 @@ bool InitiatorMSEHandshakeCommand::executeInternal() {
          socket,
          PeerInteractionCommand::INITIATOR_SEND_HANDSHAKE,
          peerConnection);
-      e->commands.push_back(c);
+      e->addCommand(c);
       return true;
     }
     break;
   }
   }
-  e->commands.push_back(this);
+  e->addCommand(this);
   return false;
 }
 
@@ -183,7 +187,7 @@ bool InitiatorMSEHandshakeCommand::prepareForNextPeer(time_t wait)
                                           e, _btRuntime);
       command->setPeerStorage(_peerStorage);
       command->setPieceStorage(_pieceStorage);
-      e->commands.push_back(command);
+      e->addCommand(command);
     }
     return true;
   } else {
@@ -197,7 +201,7 @@ bool InitiatorMSEHandshakeCommand::prepareForNextPeer(time_t wait)
                                         _btRuntime, false);
     command->setPeerStorage(_peerStorage);
     command->setPieceStorage(_pieceStorage);
-    e->commands.push_back(command);
+    e->addCommand(command);
     return true;
   }
 }

+ 6 - 1
src/LpdDispatchMessageCommand.cc

@@ -40,6 +40,11 @@
 #include "RecoverableException.h"
 #include "SocketCore.h"
 #include "util.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
+#include "FileEntry.h"
 
 namespace aria2 {
 
@@ -81,7 +86,7 @@ bool LpdDispatchMessageCommand::execute()
       _tryCount = 0;
     }
   }
-  _e->commands.push_back(this);
+  _e->addCommand(this);
   return false;
 }
 

+ 5 - 2
src/LpdReceiveMessageCommand.cc

@@ -49,6 +49,9 @@
 #include "BtAnnounce.h"
 #include "LpdMessage.h"
 #include "bittorrent_helper.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -75,7 +78,7 @@ LpdReceiveMessageCommand::~LpdReceiveMessageCommand()
 
 bool LpdReceiveMessageCommand::execute()
 {
-  if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+  if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
     return true;
   }
   for(size_t i = 0; i < 20; ++i) {
@@ -127,7 +130,7 @@ bool LpdReceiveMessageCommand::execute()
       }
     }
   }
-  _e->commands.push_back(this);
+  _e->addCommand(this);
   return false;
 }
 

+ 9 - 6
src/MultiUrlRequestInfo.cc

@@ -57,6 +57,8 @@
 #include "DownloadContext.h"
 #include "SessionSerializer.h"
 #include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 #ifdef ENABLE_SSL
 # include "SocketCore.h"
 # include "TLSContext.h"
@@ -176,8 +178,8 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
 
     std::string serverStatIf = _option->get(PREF_SERVER_STAT_IF);
     if(!serverStatIf.empty()) {
-      e->_requestGroupMan->loadServerStat(serverStatIf);
-      e->_requestGroupMan->removeStaleServerStat
+      e->getRequestGroupMan()->loadServerStat(serverStatIf);
+      e->getRequestGroupMan()->removeStaleServerStat
         (_option->getAsInt(PREF_SERVER_STAT_TIMEOUT));
     }
     e->setStatCalc(_statCalc);
@@ -195,12 +197,13 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
 
     std::string serverStatOf = _option->get(PREF_SERVER_STAT_OF);
     if(!serverStatOf.empty()) {
-      e->_requestGroupMan->saveServerStat(serverStatOf);
+      e->getRequestGroupMan()->saveServerStat(serverStatOf);
     }
-    e->_requestGroupMan->showDownloadResults(_summaryOut);
+    e->getRequestGroupMan()->showDownloadResults(_summaryOut);
     _summaryOut << std::flush;
 
-    RequestGroupMan::DownloadStat s = e->_requestGroupMan->getDownloadStat();
+    RequestGroupMan::DownloadStat s =
+      e->getRequestGroupMan()->getDownloadStat();
     if(!s.allCompleted()) {
       printMessageForContinue();
       if(s.getLastErrorResult() == downloadresultcode::FINISHED &&
@@ -210,7 +213,7 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
         returnValue = s.getLastErrorResult();
       }
     }
-    SessionSerializer sessionSerializer(e->_requestGroupMan);
+    SessionSerializer sessionSerializer(e->getRequestGroupMan());
     // TODO Add option: --save-session-status=error,inprogress,waiting
     if(!_option->blank(PREF_SAVE_SESSION)) {
       const std::string& filename = _option->get(PREF_SAVE_SESSION);

+ 6 - 1
src/PeerAbstractCommand.cc

@@ -45,6 +45,11 @@
 #include "StringFormat.h"
 #include "wallclock.h"
 #include "util.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
+#include "FileEntry.h"
 
 namespace aria2 {
 
@@ -65,7 +70,7 @@ PeerAbstractCommand::PeerAbstractCommand(cuid_t cuid,
     setReadCheckSocket(socket);
   }
   // TODO referring global option
-  timeout = e->option->getAsInt(PREF_BT_TIMEOUT);
+  timeout = e->getOption()->getAsInt(PREF_BT_TIMEOUT);
 }
 
 PeerAbstractCommand::~PeerAbstractCommand()

+ 6 - 1
src/PeerChokeCommand.cc

@@ -36,6 +36,11 @@
 #include "DownloadEngine.h"
 #include "BtRuntime.h"
 #include "PeerStorage.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
+#include "FileEntry.h"
 
 namespace aria2 {
 
@@ -53,7 +58,7 @@ bool PeerChokeCommand::execute() {
   if(_peerStorage->chokeRoundIntervalElapsed()) {
     _peerStorage->executeChoke();
   }
-  e->commands.push_back(this);
+  e->addCommand(this);
   return false;
 }
 

+ 7 - 3
src/PeerInitiateConnectionCommand.cc

@@ -49,6 +49,10 @@
 #include "RequestGroup.h"
 #include "DownloadContext.h"
 #include "util.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "RequestGroupMan.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -89,13 +93,13 @@ bool PeerInitiateConnectionCommand::executeInternal() {
                                        _btRuntime, socket);
     c->setPeerStorage(_peerStorage);
     c->setPieceStorage(_pieceStorage);
-    e->commands.push_back(c);
+    e->addCommand(c);
   } else {
     PeerInteractionCommand* command =
       new PeerInteractionCommand
       (cuid, _requestGroup, peer, e, _btRuntime, _pieceStorage, _peerStorage,
        socket, PeerInteractionCommand::INITIATOR_SEND_HANDSHAKE);
-    e->commands.push_back(command);
+    e->addCommand(command);
   }
   return true;
 }
@@ -110,7 +114,7 @@ bool PeerInitiateConnectionCommand::prepareForNextPeer(time_t wait) {
                                         _btRuntime);
     command->setPeerStorage(_peerStorage);
     command->setPieceStorage(_pieceStorage);
-    e->commands.push_back(command);
+    e->addCommand(command);
   }
   return true;
 }

+ 8 - 5
src/PeerInteractionCommand.cc

@@ -72,6 +72,9 @@
 #include "bittorrent_helper.h"
 #include "UTMetadataRequestFactory.h"
 #include "UTMetadataRequestTracker.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -155,7 +158,7 @@ PeerInteractionCommand::PeerInteractionCommand
   dispatcher->setPeerStorage(peerStorage);
   dispatcher->setRequestTimeout(getOption()->getAsInt(PREF_BT_REQUEST_TIMEOUT));
   dispatcher->setBtMessageFactory(factory);
-  dispatcher->setRequestGroupMan(e->_requestGroupMan);
+  dispatcher->setRequestGroupMan(e->getRequestGroupMan());
 
   DefaultBtMessageReceiverHandle receiver(new DefaultBtMessageReceiver());
   receiver->setCuid(cuid);
@@ -187,7 +190,7 @@ PeerInteractionCommand::PeerInteractionCommand
   btInteractive->setExtensionMessageRegistry(exMsgRegistry);
   btInteractive->setKeepAliveInterval
     (getOption()->getAsInt(PREF_BT_KEEP_ALIVE_INTERVAL));
-  btInteractive->setRequestGroupMan(e->_requestGroupMan);
+  btInteractive->setRequestGroupMan(e->getRequestGroupMan());
   btInteractive->setBtMessageFactory(factory);
   if((metadataGetMode || torrentAttrs[bittorrent::PRIVATE].i() == 0) &&
      !peer->isLocalPeer()) {
@@ -301,7 +304,7 @@ bool PeerInteractionCommand::executeInternal() {
         setWriteCheckSocket(socket);
       }
 
-      if(e->_requestGroupMan->doesOverallDownloadSpeedExceed() ||
+      if(e->getRequestGroupMan()->doesOverallDownloadSpeedExceed() ||
          _requestGroup->doesDownloadSpeedExceed()) {
         disableReadCheckSocket();
         setNoCheck(true);
@@ -316,7 +319,7 @@ bool PeerInteractionCommand::executeInternal() {
   if(btInteractive->countPendingMessage() > 0) {
     setNoCheck(true);
   }
-  e->commands.push_back(this);
+  e->addCommand(this);
   return false;
 }
 
@@ -330,7 +333,7 @@ bool PeerInteractionCommand::prepareForNextPeer(time_t wait) {
       (peer->usedBy(), _requestGroup, peer, e, _btRuntime);
     command->setPeerStorage(_peerStorage);
     command->setPieceStorage(_pieceStorage);
-    e->commands.push_back(command);
+    e->addCommand(command);
   }
   return true;
 }

+ 6 - 3
src/PeerListenCommand.cc

@@ -48,6 +48,9 @@
 #include "SimpleRandomizer.h"
 #include "FileEntry.h"
 #include "util.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -108,7 +111,7 @@ uint16_t PeerListenCommand::getPort() const
 }
 
 bool PeerListenCommand::execute() {
-  if(e->isHaltRequested() || e->_requestGroupMan->downloadFinished()) {
+  if(e->isHaltRequested() || e->getRequestGroupMan()->downloadFinished()) {
     return true;
   }
   for(int i = 0; i < 3 && socket->isReadable(0); ++i) {
@@ -124,7 +127,7 @@ bool PeerListenCommand::execute() {
       cuid_t cuid = e->newCUID();
       Command* command =
         new ReceiverMSEHandshakeCommand(cuid, peer, e, peerSocket);
-      e->commands.push_back(command);
+      e->addCommand(command);
       if(logger->debug()) {
         logger->debug("Accepted the connection from %s:%u.",
                       peer->ipaddr.c_str(),
@@ -136,7 +139,7 @@ bool PeerListenCommand::execute() {
       logger->debug(MSG_ACCEPT_FAILURE, ex, util::itos(cuid).c_str());
     }               
   }
-  e->commands.push_back(this);
+  e->addCommand(this);
   return false;
 }
 

+ 6 - 3
src/PeerReceiveHandshakeCommand.cc

@@ -56,6 +56,9 @@
 #include "RequestGroupMan.h"
 #include "StringFormat.h"
 #include "RequestGroup.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -78,7 +81,7 @@ PeerReceiveHandshakeCommand::~PeerReceiveHandshakeCommand() {}
 
 bool PeerReceiveHandshakeCommand::exitBeforeExecute()
 {
-  return e->isHaltRequested() || e->_requestGroupMan->downloadFinished();
+  return e->isHaltRequested() || e->getRequestGroupMan()->downloadFinished();
 }
 
 bool PeerReceiveHandshakeCommand::executeInternal()
@@ -141,7 +144,7 @@ bool PeerReceiveHandshakeCommand::executeInternal()
            socket,
            PeerInteractionCommand::RECEIVER_WAIT_HANDSHAKE,
            _peerConnection);
-        e->commands.push_back(command);
+        e->addCommand(command);
         if(logger->debug()) {
           logger->debug(MSG_INCOMING_PEER_CONNECTION,
                         util::itos(cuid).c_str(),
@@ -151,7 +154,7 @@ bool PeerReceiveHandshakeCommand::executeInternal()
     }
     return true;
   } else {
-    e->commands.push_back(this);
+    e->addCommand(this);
     return false;
   }
 }

+ 4 - 0
src/RealtimeCommand.cc

@@ -37,6 +37,10 @@
 #include "Exception.h"
 #include "RequestGroup.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 

+ 10 - 7
src/ReceiverMSEHandshakeCommand.cc

@@ -55,6 +55,9 @@
 #include "BtAnnounce.h"
 #include "BtRuntime.h"
 #include "BtProgressInfoFile.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -66,9 +69,9 @@ ReceiverMSEHandshakeCommand::ReceiverMSEHandshakeCommand
 
   PeerAbstractCommand(cuid, peer, e, s),
   _sequence(RECEIVER_IDENTIFY_HANDSHAKE),
-  _mseHandshake(new MSEHandshake(cuid, s, e->option))
+  _mseHandshake(new MSEHandshake(cuid, s, e->getOption()))
 {
-  setTimeout(e->option->getAsInt(PREF_PEER_CONNECTION_TIMEOUT));
+  setTimeout(e->getOption()->getAsInt(PREF_PEER_CONNECTION_TIMEOUT));
 }
 
 ReceiverMSEHandshakeCommand::~ReceiverMSEHandshakeCommand()
@@ -78,7 +81,7 @@ ReceiverMSEHandshakeCommand::~ReceiverMSEHandshakeCommand()
 
 bool ReceiverMSEHandshakeCommand::exitBeforeExecute()
 {
-  return e->isHaltRequested() || e->_requestGroupMan->downloadFinished();
+  return e->isHaltRequested() || e->getRequestGroupMan()->downloadFinished();
 }
 
 bool ReceiverMSEHandshakeCommand::executeInternal()
@@ -94,7 +97,7 @@ bool ReceiverMSEHandshakeCommand::executeInternal()
       _sequence = RECEIVER_WAIT_KEY;
       break;
     case MSEHandshake::HANDSHAKE_LEGACY: {
-      if(e->option->getAsBool(PREF_BT_REQUIRE_CRYPTO)) {
+      if(e->getOption()->getAsBool(PREF_BT_REQUIRE_CRYPTO)) {
         throw DL_ABORT_EX("The legacy BitTorrent handshake is not acceptable by the preference.");
       }
       SharedHandle<PeerConnection> peerConnection
@@ -103,7 +106,7 @@ bool ReceiverMSEHandshakeCommand::executeInternal()
                                    _mseHandshake->getBufferLength());
       Command* c = new PeerReceiveHandshakeCommand(cuid, peer, e, socket,
                                                    peerConnection);
-      e->commands.push_back(c);
+      e->addCommand(c);
       return true;
     }
     default:
@@ -175,7 +178,7 @@ bool ReceiverMSEHandshakeCommand::executeInternal()
     }
     break;
   }
-  e->commands.push_back(this);
+  e->addCommand(this);
   return false;
 }
 
@@ -196,7 +199,7 @@ void ReceiverMSEHandshakeCommand::createCommand()
   // match, then drop connection.
   Command* c =
     new PeerReceiveHandshakeCommand(cuid, peer, e, socket, peerConnection);
-  e->commands.push_back(c);
+  e->addCommand(c);
 }
 
 } // namespace aria2

+ 6 - 5
src/RequestGroup.cc

@@ -76,6 +76,7 @@
 #include "a2functional.h"
 #include "SocketCore.h"
 #include "SimpleRandomizer.h"
+#include "ServerStatMan.h"
 #ifdef ENABLE_MESSAGE_DIGEST
 # include "CheckIntegrityCommand.h"
 #endif // ENABLE_MESSAGE_DIGEST
@@ -221,7 +222,7 @@ void RequestGroup::createInitialCommand
         // Use UnknownLengthPieceStorage.
         initPieceStorage();
       } else {
-        if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
+        if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
           throw DOWNLOAD_FAILURE_EXCEPTION
             (StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
                           _downloadContext->getBasePath().c_str()).str());
@@ -356,7 +357,7 @@ void RequestGroup::createInitialCommand
           command->setTaskFactory(DHTRegistry::_taskFactory);
           command->setRoutingTable(DHTRegistry::_routingTable);
           command->setLocalNode(DHTRegistry::_localNode);
-          e->commands.push_back(command);
+          e->addCommand(command);
         }
       }
       SharedHandle<CheckIntegrityEntry> entry(new BtCheckIntegrityEntry(this));
@@ -379,7 +380,7 @@ void RequestGroup::createInitialCommand
        _downloadContext->getTotalLength() == 0) {
       createNextCommand(commands, e, 1);
     }else {
-      if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
+      if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
         throw DOWNLOAD_FAILURE_EXCEPTION
           (StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
                         _downloadContext->getBasePath().c_str()).str());
@@ -408,7 +409,7 @@ void RequestGroup::createInitialCommand
   } else {
     // In this context, multiple FileEntry objects are in
     // DownloadContext.
-    if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
+    if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
       throw DOWNLOAD_FAILURE_EXCEPTION
         (StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
                       _downloadContext->getBasePath().c_str()).str());
@@ -467,7 +468,7 @@ void RequestGroup::processCheckIntegrityEntry
     // enableSaveControlFile() will be called after hash checking is
     // done. See CheckIntegrityCommand.
     disableSaveControlFile();
-    e->_checkIntegrityMan->pushEntry(entry);
+    e->getCheckIntegrityMan()->pushEntry(entry);
   } else
 #endif // ENABLE_MESSAGE_DIGEST
     {

+ 6 - 4
src/RequestGroupMan.cc

@@ -67,6 +67,8 @@
 #include "Command.h"
 #include "FileEntry.h"
 #include "StringFormat.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -379,7 +381,7 @@ public:
                 ("Adding %lu RequestGroups as a result of PostDownloadHandler.",
                  static_cast<unsigned long>(nextGroups.size()));
             }
-            _e->_requestGroupMan->insertReservedGroup(0, nextGroups);
+            _e->getRequestGroupMan()->insertReservedGroup(0, nextGroups);
           }
         } else {
           group->saveControlFile();
@@ -395,11 +397,11 @@ public:
       group->releaseRuntimeResource(_e);
       if(group->isPauseRequested()) {
         group->setForceHaltRequested(false);
-        executeHookByOptName(group, _e->option, PREF_ON_DOWNLOAD_PAUSE);
+        executeHookByOptName(group, _e->getOption(), PREF_ON_DOWNLOAD_PAUSE);
         // TODO Should we have to prepend spend uris to remaining uris
         // in case PREF_REUSE_URI is disabed?
       } else {
-        executeStopHook(_downloadResults.back(), _e->option);
+        executeStopHook(_downloadResults.back(), _e->getOption());
       }
     }
   }
@@ -541,7 +543,7 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
       ++count;
       e->addCommand(commands);
       commands.clear();
-      executeHookByOptName(groupToAdd, e->option, PREF_ON_DOWNLOAD_START);
+      executeHookByOptName(groupToAdd, e->getOption(), PREF_ON_DOWNLOAD_START);
     } catch(RecoverableException& ex) {
       _logger->error(EX_EXCEPTION_CAUGHT, ex);
       if(_logger->debug()) {

+ 5 - 1
src/SeedCheckCommand.cc

@@ -41,6 +41,10 @@
 #include "message.h"
 #include "RequestGroup.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -83,7 +87,7 @@ bool SeedCheckCommand::execute() {
       _btRuntime->setHalt(true);
     }
   }
-  e->commands.push_back(this);
+  e->addCommand(this);
   return false;
 }
 

+ 2 - 2
src/SequentialDispatcherCommand.h

@@ -62,11 +62,11 @@ public:
   
   virtual bool execute()
   {
-    if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+    if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
       return true;
     }
     if(_picker->hasNext() && !_picker->isPicked()) {
-      _e->commands.push_back(createCommand(_picker->pickNext()));
+      _e->addCommand(createCommand(_picker->pickNext()));
 
       _e->setNoWait(true);
     }

+ 6 - 2
src/SleepCommand.cc

@@ -37,6 +37,10 @@
 #include "DownloadEngine.h"
 #include "DownloadContext.h"
 #include "wallclock.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -54,11 +58,11 @@ bool SleepCommand::execute() {
   if(_requestGroup->downloadFinished() || _requestGroup->isHaltRequested()) {
     return true;
   } else if(checkPoint.difference(global::wallclock) >= wait) {
-    engine->commands.push_back(nextCommand);
+    engine->addCommand(nextCommand);
     nextCommand = 0;
     return true;
   } else {
-    engine->commands.push_back(this);
+    engine->addCommand(this);
     return false;
   }
 }

+ 2 - 0
src/StreamCheckIntegrityEntry.cc

@@ -37,6 +37,8 @@
 #include "DownloadEngine.h"
 #include "StreamFileAllocationEntry.h"
 #include "DownloadContext.h"
+#include "RequestGroupMan.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 

+ 3 - 0
src/StreamFileAllocationEntry.cc

@@ -42,6 +42,9 @@
 #include "RequestGroup.h"
 #include "DownloadContext.h"
 #include "Command.h"
+#include "RequestGroupMan.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 

+ 6 - 1
src/TimeBasedCommand.cc

@@ -35,6 +35,11 @@
 #include "TimeBasedCommand.h"
 #include "DownloadEngine.h"
 #include "wallclock.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
+#include "FileEntry.h"
 
 namespace aria2 {
 
@@ -66,7 +71,7 @@ bool TimeBasedCommand::execute()
   if(_routineCommand) {
     _e->addRoutineCommand(this);
   } else {
-    _e->commands.push_back(this);
+    _e->addCommand(this);
   }
   return false;
 }

+ 4 - 1
src/TimedHaltCommand.cc

@@ -38,6 +38,9 @@
 #include "Logger.h"
 #include "message.h"
 #include "FileEntry.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 
 namespace aria2 {
 
@@ -51,7 +54,7 @@ TimedHaltCommand::~TimedHaltCommand() {}
 
 void TimedHaltCommand::preProcess()
 {
-  if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+  if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
     _exit = true;
   }
 }

+ 7 - 3
src/TrackerWatcherCommand.cc

@@ -61,6 +61,10 @@
 #include "bittorrent_helper.h"
 #include "a2functional.h"
 #include "util.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
 
 namespace aria2 {
 
@@ -87,7 +91,7 @@ bool TrackerWatcherCommand::execute() {
       return true;
     } else {
       _trackerRequestGroup->setForceHaltRequested(true);
-      e->commands.push_back(this);
+      e->addCommand(this);
       return false;
     }
   }
@@ -136,7 +140,7 @@ bool TrackerWatcherCommand::execute() {
       _btAnnounce->resetAnnounce();
     }
   }
-  e->commands.push_back(this);
+  e->addCommand(this);
   return false;
 }
 
@@ -175,7 +179,7 @@ void TrackerWatcherCommand::processTrackerResponse
       (peer->usedBy(), _requestGroup, peer, e, _btRuntime);
     command->setPeerStorage(_peerStorage);
     command->setPieceStorage(_pieceStorage);
-    e->commands.push_back(command);
+    e->addCommand(command);
     if(logger->debug()) {
       logger->debug("CUID#%s - Adding new command CUID#%s",
                     util::itos(cuid).c_str(),

+ 5 - 0
src/XmlRpcMethod.cc

@@ -47,6 +47,11 @@
 #include "XmlRpcResponse.h"
 #include "prefs.h"
 #include "StringFormat.h"
+#include "RequestGroupMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
+#include "ServerStatMan.h"
+#include "FileEntry.h"
 
 namespace aria2 {
 

+ 55 - 41
src/XmlRpcMethodImpl.cc

@@ -64,6 +64,9 @@
 #include "XmlRpcResponse.h"
 #include "SegmentMan.h"
 #include "TimedHaltCommand.h"
+#include "ServerStatMan.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 #ifdef ENABLE_BITTORRENT
 # include "bittorrent_helper.h"
 # include "BtRegistry.h"
@@ -146,9 +149,9 @@ static BDE addRequestGroup(const SharedHandle<RequestGroup>& group,
                            bool posGiven, int pos)
 {
   if(posGiven) {
-    e->_requestGroupMan->insertReservedGroup(pos, group);
+    e->getRequestGroupMan()->insertReservedGroup(pos, group);
   } else {
-    e->_requestGroupMan->addReservedGroup(group);
+    e->getRequestGroupMan()->addReservedGroup(group);
   }
   return createGIDResponse(group->getGID());
 }
@@ -205,7 +208,7 @@ BDE AddUriXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
   std::vector<std::string> uris;
   extractUris(std::back_inserter(uris), params[0]);
 
-  SharedHandle<Option> requestOption(new Option(*e->option));
+  SharedHandle<Option> requestOption(new Option(*e->getOption()));
   if(hasDictParam(params, 1)) {
     gatherRequestOption(requestOption, params[1]);
   }
@@ -239,7 +242,7 @@ BDE AddTorrentXmlRpcMethod::process
   if(params.size() > 1 && params[1].isList()) {
     extractUris(std::back_inserter(uris), params[1]);
   }
-  SharedHandle<Option> requestOption(new Option(*e->option));
+  SharedHandle<Option> requestOption(new Option(*e->getOption()));
   if(hasDictParam(params, 2)) {
     gatherRequestOption(requestOption, params[2]);
   }
@@ -270,7 +273,7 @@ BDE AddMetalinkXmlRpcMethod::process
     throw DL_ABORT_EX("Metalink data is not provided.");
   }
   
-  SharedHandle<Option> requestOption(new Option(*e->option));
+  SharedHandle<Option> requestOption(new Option(*e->getOption()));
   if(hasDictParam(params, 1)) {
     gatherRequestOption(requestOption, params[1]);
   };
@@ -282,9 +285,9 @@ BDE AddMetalinkXmlRpcMethod::process
   createRequestGroupForMetalink(result, requestOption, params[0].s());
   if(!result.empty()) {
     if(posGiven) {
-      e->_requestGroupMan->insertReservedGroup(pos, result);
+      e->getRequestGroupMan()->insertReservedGroup(pos, result);
     } else {
-      e->_requestGroupMan->addReservedGroup(result);
+      e->getRequestGroupMan()->addReservedGroup(result);
     }
     BDE gids = BDE::list();
     for(std::vector<SharedHandle<RequestGroup> >::const_iterator i =
@@ -310,17 +313,18 @@ static BDE removeDownload
   
   gid_t gid = util::parseLLInt(params[0].s());
 
-  SharedHandle<RequestGroup> group = e->_requestGroupMan->findRequestGroup(gid);
+  SharedHandle<RequestGroup> group =
+    e->getRequestGroupMan()->findRequestGroup(gid);
 
   if(group.isNull()) {
-    group = e->_requestGroupMan->findReservedGroup(gid);
+    group = e->getRequestGroupMan()->findReservedGroup(gid);
     if(group.isNull()) {
       throw DL_ABORT_EX
         (StringFormat("Active Download not found for GID#%s",
                       util::itos(gid).c_str()).str());
     }
     if(group->isDependencyResolved()) {
-      e->_requestGroupMan->removeReservedGroup(gid);
+      e->getRequestGroupMan()->removeReservedGroup(gid);
     } else {
       throw DL_ABORT_EX
         (StringFormat("GID#%s cannot be removed now",
@@ -383,10 +387,11 @@ static BDE pauseDownload
   }
   gid_t gid = util::parseLLInt(params[0].s());
   bool reserved = false;
-  SharedHandle<RequestGroup> group = e->_requestGroupMan->findRequestGroup(gid);
+  SharedHandle<RequestGroup> group =
+    e->getRequestGroupMan()->findRequestGroup(gid);
   if(group.isNull()) {
     reserved = true;
-    group = e->_requestGroupMan->findReservedGroup(gid);
+    group = e->getRequestGroupMan()->findReservedGroup(gid);
   }
   if(!group.isNull() && pauseRequestGroup(group, reserved, forcePause)) {
     return createGIDResponse(gid);
@@ -420,10 +425,10 @@ static BDE pauseAllDownloads
 (const XmlRpcRequest& req, DownloadEngine* e, bool forcePause)
 {
   const std::deque<SharedHandle<RequestGroup> >& groups =
-    e->_requestGroupMan->getRequestGroups();
+    e->getRequestGroupMan()->getRequestGroups();
   pauseRequestGroups(groups.begin(), groups.end(), false, forcePause);
   const std::deque<SharedHandle<RequestGroup> >& reservedGroups =
-    e->_requestGroupMan->getReservedGroups();
+    e->getRequestGroupMan()->getReservedGroups();
   pauseRequestGroups(reservedGroups.begin(), reservedGroups.end(),
                      true, forcePause);
   return BDE_OK;
@@ -448,14 +453,15 @@ BDE UnpauseXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
     throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED);
   }
   gid_t gid = util::parseLLInt(params[0].s());
-  SharedHandle<RequestGroup> group =e->_requestGroupMan->findReservedGroup(gid);
+  SharedHandle<RequestGroup> group =
+    e->getRequestGroupMan()->findReservedGroup(gid);
   if(group.isNull() || !group->isPauseRequested()) {
     throw DL_ABORT_EX
       (StringFormat("GID#%s cannot be unpaused now",
                     util::itos(gid).c_str()).str());
   } else {
     group->setPauseRequested(false);
-    e->_requestGroupMan->requestQueueCheck();    
+    e->getRequestGroupMan()->requestQueueCheck();    
   }
   return createGIDResponse(gid);
 }
@@ -463,11 +469,11 @@ BDE UnpauseXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
 BDE UnpauseAllXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
 {
   const std::deque<SharedHandle<RequestGroup> >& groups =
-    e->_requestGroupMan->getReservedGroups();
+    e->getRequestGroupMan()->getReservedGroups();
   std::for_each(groups.begin(), groups.end(),
                 std::bind2nd(mem_fun_sh(&RequestGroup::setPauseRequested),
                              false));
-  e->_requestGroupMan->requestQueueCheck();    
+  e->getRequestGroupMan()->requestQueueCheck();    
   return BDE_OK;
 }
 
@@ -710,10 +716,11 @@ BDE GetFilesXmlRpcMethod::process
   gid_t gid = util::parseLLInt(params[0].s());
 
   BDE files = BDE::list();
-  SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
+  SharedHandle<RequestGroup> group =
+    findRequestGroup(e->getRequestGroupMan(), gid);
   if(group.isNull()) {
     SharedHandle<DownloadResult> dr =
-      e->_requestGroupMan->findDownloadResult(gid);
+      e->getRequestGroupMan()->findDownloadResult(gid);
     if(dr.isNull()) {
       throw DL_ABORT_EX
         (StringFormat("No file data is available for GID#%s",
@@ -741,7 +748,8 @@ BDE GetUrisXmlRpcMethod::process
   
   gid_t gid = util::parseLLInt(params[0].s());
 
-  SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
+  SharedHandle<RequestGroup> group =
+    findRequestGroup(e->getRequestGroupMan(), gid);
   if(group.isNull()) {
     throw DL_ABORT_EX
       (StringFormat("No URI data is available for GID#%s",
@@ -768,7 +776,8 @@ BDE GetPeersXmlRpcMethod::process
   
   gid_t gid = util::parseLLInt(params[0].s());
 
-  SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
+  SharedHandle<RequestGroup> group =
+    findRequestGroup(e->getRequestGroupMan(), gid);
   if(group.isNull()) {
     throw DL_ABORT_EX
       (StringFormat("No peer data is available for GID#%s",
@@ -796,14 +805,15 @@ BDE TellStatusXmlRpcMethod::process
   
   gid_t gid = util::parseLLInt(params[0].s());
 
-  SharedHandle<RequestGroup> group = e->_requestGroupMan->findRequestGroup(gid);
+  SharedHandle<RequestGroup> group =
+    e->getRequestGroupMan()->findRequestGroup(gid);
 
   BDE entryDict = BDE::dict();
   if(group.isNull()) {
-    group = e->_requestGroupMan->findReservedGroup(gid);
+    group = e->getRequestGroupMan()->findReservedGroup(gid);
     if(group.isNull()) {
       SharedHandle<DownloadResult> ds =
-        e->_requestGroupMan->findDownloadResult(gid);
+        e->getRequestGroupMan()->findDownloadResult(gid);
       if(ds.isNull()) {
         throw DL_ABORT_EX
           (StringFormat("No such download for GID#%s",
@@ -830,7 +840,7 @@ BDE TellActiveXmlRpcMethod::process
 {
   BDE list = BDE::list();
   const std::deque<SharedHandle<RequestGroup> >& groups =
-    e->_requestGroupMan->getRequestGroups();
+    e->getRequestGroupMan()->getRequestGroups();
   for(std::deque<SharedHandle<RequestGroup> >::const_iterator i =
         groups.begin(), eoi = groups.end(); i != eoi; ++i) {
     BDE entryDict = BDE::dict();
@@ -844,7 +854,7 @@ BDE TellActiveXmlRpcMethod::process
 const std::deque<SharedHandle<RequestGroup> >&
 TellWaitingXmlRpcMethod::getItems(DownloadEngine* e) const
 {
-  return e->_requestGroupMan->getReservedGroups();
+  return e->getRequestGroupMan()->getReservedGroups();
 }
 
 void TellWaitingXmlRpcMethod::createEntry
@@ -862,7 +872,7 @@ void TellWaitingXmlRpcMethod::createEntry
 const std::deque<SharedHandle<DownloadResult> >&
 TellStoppedXmlRpcMethod::getItems(DownloadEngine* e) const
 {
-  return e->_requestGroupMan->getDownloadResults();
+  return e->getRequestGroupMan()->getDownloadResults();
 }
 
 void TellStoppedXmlRpcMethod::createEntry
@@ -875,7 +885,7 @@ void TellStoppedXmlRpcMethod::createEntry
 BDE PurgeDownloadResultXmlRpcMethod::process
 (const XmlRpcRequest& req, DownloadEngine* e)
 {
-  e->_requestGroupMan->purgeDownloadResult();
+  e->getRequestGroupMan()->purgeDownloadResult();
   return BDE_OK;
 }
 
@@ -889,7 +899,8 @@ BDE ChangeOptionXmlRpcMethod::process
   }  
   gid_t gid = util::parseLLInt(params[0].s());
 
-  SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
+  SharedHandle<RequestGroup> group =
+    findRequestGroup(e->getRequestGroupMan(), gid);
   if(group.isNull()) {
     throw DL_ABORT_EX
       (StringFormat("Cannot change option for GID#%s",
@@ -928,20 +939,20 @@ BDE ChangeGlobalOptionXmlRpcMethod::process
   }
   SharedHandle<Option> option(new Option());
   gatherChangeableGlobalOption(option, params[0]);
-  applyChangeableGlobalOption(e->option, option.get());
+  applyChangeableGlobalOption(e->getOption(), option.get());
 
   if(option->defined(PREF_MAX_OVERALL_DOWNLOAD_LIMIT)) {
-    e->_requestGroupMan->setMaxOverallDownloadSpeedLimit
+    e->getRequestGroupMan()->setMaxOverallDownloadSpeedLimit
       (option->getAsInt(PREF_MAX_OVERALL_DOWNLOAD_LIMIT));
   }
   if(option->defined(PREF_MAX_OVERALL_UPLOAD_LIMIT)) {
-    e->_requestGroupMan->setMaxOverallUploadSpeedLimit
+    e->getRequestGroupMan()->setMaxOverallUploadSpeedLimit
       (option->getAsInt(PREF_MAX_OVERALL_UPLOAD_LIMIT));
   }
   if(option->defined(PREF_MAX_CONCURRENT_DOWNLOADS)) {
-    e->_requestGroupMan->setMaxSimultaneousDownloads
+    e->getRequestGroupMan()->setMaxSimultaneousDownloads
       (option->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS));
-    e->_requestGroupMan->requestQueueCheck();
+    e->getRequestGroupMan()->requestQueueCheck();
   }
   return BDE_OK;
 }
@@ -985,7 +996,8 @@ BDE GetOptionXmlRpcMethod::process
   }  
   gid_t gid = util::parseLLInt(params[0].s());
 
-  SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
+  SharedHandle<RequestGroup> group =
+    findRequestGroup(e->getRequestGroupMan(), gid);
   if(group.isNull()) {
     throw DL_ABORT_EX
       (StringFormat("Cannot get option for GID#%s",
@@ -1001,8 +1013,8 @@ BDE GetGlobalOptionXmlRpcMethod::process
 (const XmlRpcRequest& req, DownloadEngine* e)
 {
   BDE result = BDE::dict();
-  for(std::map<std::string, std::string>::const_iterator i = e->option->begin(),
-        eoi = e->option->end(); i != eoi; ++i) {
+  for(std::map<std::string, std::string>::const_iterator i =
+        e->getOption()->begin(), eoi = e->getOption()->end(); i != eoi; ++i) {
     SharedHandle<OptionHandler> h = _optionParser->findByName((*i).first);
     if(!h.isNull() && !h->isHidden()) {
       result[(*i).first] = (*i).second;
@@ -1035,7 +1047,7 @@ BDE ChangePositionXmlRpcMethod::process
     throw DL_ABORT_EX("Illegal argument.");
   }
   size_t destPos =
-    e->_requestGroupMan->changeReservedGroupPosition(gid, pos, how);
+    e->getRequestGroupMan()->changeReservedGroupPosition(gid, pos, how);
   BDE result(destPos);
   return result;
 }
@@ -1058,7 +1070,8 @@ BDE GetServersXmlRpcMethod::process
     throw DL_ABORT_EX("Bad request");
   }
   gid_t gid = util::parseLLInt(params[0].s());
-  SharedHandle<RequestGroup> group = e->_requestGroupMan->findRequestGroup(gid);
+  SharedHandle<RequestGroup> group =
+    e->getRequestGroupMan()->findRequestGroup(gid);
   if(group.isNull()) {
     throw DL_ABORT_EX(StringFormat("No active download for GID#%s",
                                    util::itos(gid).c_str()).str());
@@ -1112,7 +1125,8 @@ BDE ChangeUriXmlRpcMethod::process
   size_t index = params[1].i()-1;
   const BDE& deluris = params[2];
   const BDE& adduris = params[3];
-  SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
+  SharedHandle<RequestGroup> group =
+    findRequestGroup(e->getRequestGroupMan(), gid);
   if(group.isNull()) {
     throw DL_ABORT_EX
       (StringFormat("Cannot remove URIs from GID#%s",

+ 55 - 38
test/XmlRpcMethodTest.cc

@@ -21,6 +21,8 @@
 #include "util.h"
 #include "array_fun.h"
 #include "download_helper.h"
+#include "FileAllocationEntry.h"
+#include "CheckIntegrityEntry.h"
 #ifdef ENABLE_BITTORRENT
 # include "BtRegistry.h"
 # include "BtRuntime.h"
@@ -92,15 +94,15 @@ public:
     _option.reset(new Option());
     _option->put(PREF_DIR, "/tmp");
     _option->put(PREF_SEGMENT_SIZE, "1048576");
-    _e.reset(new DownloadEngine(SharedHandle<EventPoll>(new SelectEventPoll())));
-    _e->option = _option.get();
-    _e->_requestGroupMan.reset
-      (new RequestGroupMan(std::vector<SharedHandle<RequestGroup> >(),
-                           1, _option.get()));
+    _e.reset
+      (new DownloadEngine(SharedHandle<EventPoll>(new SelectEventPoll())));
+    _e->setOption(_option.get());
+    _e->setRequestGroupMan
+      (SharedHandle<RequestGroupMan>
+       (new RequestGroupMan(std::vector<SharedHandle<RequestGroup> >(),
+                            1, _option.get())));
   }
 
-  void tearDown() {}
-
   void testAddUri();
   void testAddUri_withoutUri();
   void testAddUri_notUri();
@@ -159,10 +161,11 @@ void XmlRpcMethodTest::testAddUri()
     XmlRpcResponse res = m.execute(req, _e.get());
     CPPUNIT_ASSERT_EQUAL(0, res._code);
     const std::deque<SharedHandle<RequestGroup> > rgs =
-      _e->_requestGroupMan->getReservedGroups();
+      _e->getRequestGroupMan()->getReservedGroups();
     CPPUNIT_ASSERT_EQUAL((size_t)1, rgs.size());
     CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/"),
-                         rgs.front()->getDownloadContext()->getFirstFileEntry()->getRemainingUris().front());
+                         rgs.front()->getDownloadContext()->
+                         getFirstFileEntry()->getRemainingUris().front());
   }
   // with options
   BDE opt = BDE::dict();
@@ -172,7 +175,7 @@ void XmlRpcMethodTest::testAddUri()
     XmlRpcResponse res = m.execute(req, _e.get());
     CPPUNIT_ASSERT_EQUAL(0, res._code);
     CPPUNIT_ASSERT_EQUAL(std::string("/sink"),
-                         _e->_requestGroupMan->findReservedGroup(2)->
+                         _e->getRequestGroupMan()->findReservedGroup(2)->
                          getDownloadContext()->getDir());
   }
 }
@@ -225,7 +228,8 @@ void XmlRpcMethodTest::testAddUri_withPosition()
   m.execute(req2, _e.get());
 
   std::string uri =
-    _e->_requestGroupMan->getReservedGroups()[0]->getDownloadContext()->getFirstFileEntry()->getRemainingUris()[0];
+    _e->getRequestGroupMan()->getReservedGroups()[0]->
+    getDownloadContext()->getFirstFileEntry()->getRemainingUris()[0];
 
   CPPUNIT_ASSERT_EQUAL(std::string("http://uri2"), uri);
 }
@@ -256,13 +260,17 @@ void XmlRpcMethodTest::testAddTorrent()
     CPPUNIT_ASSERT_EQUAL(0, res._code);
     CPPUNIT_ASSERT_EQUAL(std::string("1"), res._param.s());
 
-    SharedHandle<RequestGroup> group = _e->_requestGroupMan->findReservedGroup(1);
+    SharedHandle<RequestGroup> group =
+      _e->getRequestGroupMan()->findReservedGroup(1);
     CPPUNIT_ASSERT(!group.isNull());
     CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-0.8.2.tar.bz2"),
                          group->getFirstFilePath());
-    CPPUNIT_ASSERT_EQUAL((size_t)1, group->getDownloadContext()->getFirstFileEntry()->getRemainingUris().size());
+    CPPUNIT_ASSERT_EQUAL((size_t)1,
+                         group->getDownloadContext()->getFirstFileEntry()->
+                         getRemainingUris().size());
     CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/aria2-0.8.2.tar.bz2"),
-                         group->getDownloadContext()->getFirstFileEntry()->getRemainingUris()[0]);
+                         group->getDownloadContext()->getFirstFileEntry()->
+                         getRemainingUris()[0]);
   }
   // with options
   BDE opt = BDE::dict();
@@ -272,7 +280,8 @@ void XmlRpcMethodTest::testAddTorrent()
     XmlRpcResponse res = m.execute(req, _e.get());
     CPPUNIT_ASSERT_EQUAL(0, res._code);
     CPPUNIT_ASSERT_EQUAL(std::string("/sink/aria2-0.8.2.tar.bz2"),
-                         _e->_requestGroupMan->findReservedGroup(2)->getFirstFilePath());
+                         _e->getRequestGroupMan()->findReservedGroup(2)->
+                         getFirstFilePath());
   }
 }
 
@@ -311,7 +320,7 @@ void XmlRpcMethodTest::testAddTorrent_withPosition()
   m.execute(req2, _e.get());
 
   CPPUNIT_ASSERT_EQUAL((size_t)1,
-                       _e->_requestGroupMan->getReservedGroups()[0]->
+                       _e->getRequestGroupMan()->getReservedGroups()[0]->
                        getDownloadContext()->getFileEntries().size());
 }
 
@@ -330,11 +339,13 @@ void XmlRpcMethodTest::testAddMetalink()
     CPPUNIT_ASSERT_EQUAL(std::string("1"), res._param[0].s());
     CPPUNIT_ASSERT_EQUAL(std::string("2"), res._param[1].s());
 
-    SharedHandle<RequestGroup> tar = _e->_requestGroupMan->findReservedGroup(1);
+    SharedHandle<RequestGroup> tar =
+      _e->getRequestGroupMan()->findReservedGroup(1);
     CPPUNIT_ASSERT(!tar.isNull());
     CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.tar.bz2"),
                          tar->getFirstFilePath());
-    SharedHandle<RequestGroup> deb = _e->_requestGroupMan->findReservedGroup(2);
+    SharedHandle<RequestGroup> deb =
+      _e->getRequestGroupMan()->findReservedGroup(2);
     CPPUNIT_ASSERT(!deb.isNull());
     CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.deb"),
                          deb->getFirstFilePath());
@@ -347,7 +358,8 @@ void XmlRpcMethodTest::testAddMetalink()
     XmlRpcResponse res = m.execute(req, _e.get());
     CPPUNIT_ASSERT_EQUAL(0, res._code);
     CPPUNIT_ASSERT_EQUAL(std::string("/sink/aria2-5.0.0.tar.bz2"),
-                         _e->_requestGroupMan->findReservedGroup(3)->getFirstFilePath());
+                         _e->getRequestGroupMan()->findReservedGroup(3)->
+                         getFirstFilePath());
   }
 }
 
@@ -386,7 +398,7 @@ void XmlRpcMethodTest::testAddMetalink_withPosition()
   CPPUNIT_ASSERT_EQUAL(0, res2._code);
 
   CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.tar.bz2"),
-                       _e->_requestGroupMan->getReservedGroups()[0]->
+                       _e->getRequestGroupMan()->getReservedGroups()[0]->
                        getFirstFilePath());
 }
 
@@ -395,7 +407,7 @@ void XmlRpcMethodTest::testAddMetalink_withPosition()
 void XmlRpcMethodTest::testChangeOption()
 {
   SharedHandle<RequestGroup> group(new RequestGroup(_option));
-  _e->_requestGroupMan->addReservedGroup(group);
+  _e->getRequestGroupMan()->addReservedGroup(group);
 
   ChangeOptionXmlRpcMethod m;
   XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
@@ -438,7 +450,7 @@ void XmlRpcMethodTest::testChangeOption()
 void XmlRpcMethodTest::testChangeOption_withBadOption()
 {
   SharedHandle<RequestGroup> group(new RequestGroup(_option));
-  _e->_requestGroupMan->addReservedGroup(group);
+  _e->getRequestGroupMan()->addReservedGroup(group);
 
   ChangeOptionXmlRpcMethod m;
   XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
@@ -453,7 +465,7 @@ void XmlRpcMethodTest::testChangeOption_withBadOption()
 void XmlRpcMethodTest::testChangeOption_withNotAllowedOption()
 {
   SharedHandle<RequestGroup> group(new RequestGroup(_option));
-  _e->_requestGroupMan->addReservedGroup(group);
+  _e->getRequestGroupMan()->addReservedGroup(group);
 
   ChangeOptionXmlRpcMethod m;
   XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
@@ -476,7 +488,8 @@ void XmlRpcMethodTest::testChangeOption_withoutGid()
 void XmlRpcMethodTest::testChangeGlobalOption()
 {
   ChangeGlobalOptionXmlRpcMethod m;
-  XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
+  XmlRpcRequest req
+    (ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
   BDE opt = BDE::dict();
   opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("100K");
 #ifdef ENABLE_BITTORRENT
@@ -486,22 +499,25 @@ void XmlRpcMethodTest::testChangeGlobalOption()
   XmlRpcResponse res = m.execute(req, _e.get());
 
   CPPUNIT_ASSERT_EQUAL(0, res._code);
-  CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024,
-                       _e->_requestGroupMan->getMaxOverallDownloadSpeedLimit());
+  CPPUNIT_ASSERT_EQUAL
+    ((unsigned int)100*1024,
+     _e->getRequestGroupMan()->getMaxOverallDownloadSpeedLimit());
   CPPUNIT_ASSERT_EQUAL(std::string("102400"),
-                       _e->option->get(PREF_MAX_OVERALL_DOWNLOAD_LIMIT));
+                       _e->getOption()->get(PREF_MAX_OVERALL_DOWNLOAD_LIMIT));
 #ifdef ENABLE_BITTORRENT
-  CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024,
-                       _e->_requestGroupMan->getMaxOverallUploadSpeedLimit());
+  CPPUNIT_ASSERT_EQUAL
+    ((unsigned int)50*1024,
+     _e->getRequestGroupMan()->getMaxOverallUploadSpeedLimit());
   CPPUNIT_ASSERT_EQUAL(std::string("51200"),
-                       _e->option->get(PREF_MAX_OVERALL_UPLOAD_LIMIT));
+                       _e->getOption()->get(PREF_MAX_OVERALL_UPLOAD_LIMIT));
 #endif // ENABLE_BITTORRENT
 }
 
 void XmlRpcMethodTest::testChangeGlobalOption_withBadOption()
 {
   ChangeGlobalOptionXmlRpcMethod m;
-  XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
+  XmlRpcRequest req
+    (ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
   BDE opt = BDE::dict();
   opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("badvalue");
   req._params << opt;
@@ -512,7 +528,8 @@ void XmlRpcMethodTest::testChangeGlobalOption_withBadOption()
 void XmlRpcMethodTest::testChangeGlobalOption_withNotAllowedOption()
 {
   ChangeGlobalOptionXmlRpcMethod m;
-  XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
+  XmlRpcRequest req
+    (ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
   BDE opt = BDE::dict();
   opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K");
   req._params << opt;
@@ -756,9 +773,9 @@ void XmlRpcMethodTest::testGatherBitTorrentMetadata()
 
 void XmlRpcMethodTest::testChangePosition()
 {
-  _e->_requestGroupMan->addReservedGroup
+  _e->getRequestGroupMan()->addReservedGroup
     (SharedHandle<RequestGroup>(new RequestGroup(_option)));
-  _e->_requestGroupMan->addReservedGroup
+  _e->getRequestGroupMan()->addReservedGroup
     (SharedHandle<RequestGroup>(new RequestGroup(_option)));
 
   ChangePositionXmlRpcMethod m;
@@ -770,7 +787,7 @@ void XmlRpcMethodTest::testChangePosition()
   CPPUNIT_ASSERT_EQUAL(0, res._code);
   CPPUNIT_ASSERT_EQUAL((int64_t)1, res._param.i());
   CPPUNIT_ASSERT_EQUAL
-    ((gid_t)1, _e->_requestGroupMan->getReservedGroups()[1]->getGID());
+    ((gid_t)1, _e->getRequestGroupMan()->getReservedGroups()[1]->getGID());
 }
 
 void XmlRpcMethodTest::testChangePosition_fail()
@@ -799,7 +816,7 @@ void XmlRpcMethodTest::testChangeUri()
   dctx->setFileEntries(&files[0], &files[3]);
   SharedHandle<RequestGroup> group(new RequestGroup(_option));
   group->setDownloadContext(dctx);
-  _e->_requestGroupMan->addReservedGroup(group);
+  _e->getRequestGroupMan()->addReservedGroup(group);
 
   ChangeUriXmlRpcMethod m;
   XmlRpcRequest req(ChangeUriXmlRpcMethod::getMethodName(), BDE::list());
@@ -869,7 +886,7 @@ void XmlRpcMethodTest::testChangeUri_fail()
   dctx->setFileEntries(&files[0], &files[3]);
   SharedHandle<RequestGroup> group(new RequestGroup(_option));
   group->setDownloadContext(dctx);
-  _e->_requestGroupMan->addReservedGroup(group);
+  _e->getRequestGroupMan()->addReservedGroup(group);
 
   ChangeUriXmlRpcMethod m;
   XmlRpcRequest req(ChangeUriXmlRpcMethod::getMethodName(), BDE::list());
@@ -933,7 +950,7 @@ void XmlRpcMethodTest::testPause()
   std::vector<SharedHandle<RequestGroup> > groups;
   createRequestGroupForUri(groups, _option, uris);
   CPPUNIT_ASSERT_EQUAL((size_t)3, groups.size());  
-  _e->_requestGroupMan->addReservedGroup(groups);
+  _e->getRequestGroupMan()->addReservedGroup(groups);
   {
     PauseXmlRpcMethod m;
     XmlRpcRequest req(PauseXmlRpcMethod::getMethodName(), BDE::list());