Преглед на файлове

2008-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Use Option::getAsBool(...) instead of Option::get(...) and 
compare
	it with V_TRUE.
	* src/DefaultPieceStorage.cc
	* src/DownloadCommand.cc
	* src/FtpNegotiationCommand.cc
	* src/HttpRequest.cc
	* src/InitiateConnectionCommand.cc
	* src/RequestGroup.cc
Tatsuhiro Tsujikawa преди 17 години
родител
ревизия
a0f8685de3
променени са 7 файла, в които са добавени 30 реда и са изтрити 19 реда
  1. 11 0
      ChangeLog
  2. 1 1
      src/DefaultPieceStorage.cc
  3. 1 1
      src/DownloadCommand.cc
  4. 2 2
      src/FtpNegotiationCommand.cc
  5. 3 3
      src/HttpRequest.cc
  6. 1 1
      src/InitiateConnectionCommand.cc
  7. 11 11
      src/RequestGroup.cc

+ 11 - 0
ChangeLog

@@ -1,3 +1,14 @@
+2008-05-18  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Use Option::getAsBool(...) instead of Option::get(...) and compare
+	it with V_TRUE.
+	* src/DefaultPieceStorage.cc
+	* src/DownloadCommand.cc
+	* src/FtpNegotiationCommand.cc
+	* src/HttpRequest.cc
+	* src/InitiateConnectionCommand.cc
+	* src/RequestGroup.cc
+	
 2008-05-18  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Made Option::get(...) return const reference of std::string.

+ 1 - 1
src/DefaultPieceStorage.cc

@@ -438,7 +438,7 @@ void DefaultPieceStorage::initStorage()
     this->diskAdaptor = directDiskAdaptor;
   } else {
     // file mode == DownloadContext::MULTI
-    if(option->get(PREF_DIRECT_FILE_MAPPING) == V_TRUE) {
+    if(option->getAsBool(PREF_DIRECT_FILE_MAPPING)) {
       logger->debug("Instantiating MultiDiskAdaptor");
       MultiDiskAdaptorHandle multiDiskAdaptor(new MultiDiskAdaptor());
       multiDiskAdaptor->setDirectIOAllowed(option->getAsBool(PREF_ENABLE_DIRECT_IO));

+ 1 - 1
src/DownloadCommand.cc

@@ -201,7 +201,7 @@ void DownloadCommand::validatePieceHash(const SegmentHandle& segment)
   std::string expectedPieceHash =
     _requestGroup->getDownloadContext()->getPieceHash(segment->getIndex());
   if(!_messageDigestContext.isNull() &&
-     e->option->get(PREF_REALTIME_CHUNK_CHECKSUM) == V_TRUE &&
+     e->option->getAsBool(PREF_REALTIME_CHUNK_CHECKSUM) &&
      !expectedPieceHash.empty()) {
     _messageDigestContext->digestReset();
     std::string actualPieceHash =

+ 2 - 2
src/FtpNegotiationCommand.cc

@@ -93,7 +93,7 @@ bool FtpNegotiationCommand::executeInternal() {
   } else if(sequence == SEQ_HEAD_OK || sequence == SEQ_DOWNLOAD_ALREADY_COMPLETED) {
     return true;
   } else if(sequence == SEQ_FILE_PREPARATION) {
-    if(e->option->get(PREF_FTP_PASV) == V_TRUE) {
+    if(e->option->getAsBool(PREF_FTP_PASV)) {
       sequence = SEQ_SEND_PASV;
     } else {
       sequence = SEQ_SEND_PORT;
@@ -262,7 +262,7 @@ bool FtpNegotiationCommand::recvSize() {
   } else {
     _requestGroup->validateTotalLength(size);
   }
-  if(e->option->get(PREF_FTP_PASV) == V_TRUE) {
+  if(e->option->getAsBool(PREF_FTP_PASV)) {
     sequence = SEQ_SEND_PASV;
   } else {
     sequence = SEQ_SEND_PORT;

+ 3 - 3
src/HttpRequest.cc

@@ -249,11 +249,11 @@ void HttpRequest::addAcceptType(const std::string& type)
 
 void HttpRequest::configure(const Option* option)
 {
-  authEnabled = option->get(PREF_HTTP_AUTH_ENABLED) == V_TRUE;
+  authEnabled = option->getAsBool(PREF_HTTP_AUTH_ENABLED);
   proxyEnabled =
-    option->get(PREF_HTTP_PROXY_ENABLED) == V_TRUE &&
+    option->getAsBool(PREF_HTTP_PROXY_ENABLED) &&
     option->get(PREF_HTTP_PROXY_METHOD) == V_GET;
-  proxyAuthEnabled = option->get(PREF_HTTP_PROXY_AUTH_ENABLED) == V_TRUE;
+  proxyAuthEnabled = option->getAsBool(PREF_HTTP_PROXY_AUTH_ENABLED);
 }
 
 std::string HttpRequest::getPreviousURI() const

+ 1 - 1
src/InitiateConnectionCommand.cc

@@ -104,7 +104,7 @@ bool InitiateConnectionCommand::executeInternal() {
 
 bool InitiateConnectionCommand::useHTTPProxy() const
 {
-  return e->option->get(PREF_HTTP_PROXY_ENABLED) == V_TRUE;
+  return e->option->getAsBool(PREF_HTTP_PROXY_ENABLED);
 }
 
 } // namespace aria2

+ 11 - 11
src/RequestGroup.cc

@@ -238,8 +238,8 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
 	_pieceStorage->getDiskAdaptor()->openFile();
       } else {
 	if(_pieceStorage->getDiskAdaptor()->fileExists()) {
-	  if(_option->get(PREF_CHECK_INTEGRITY) != V_TRUE &&
-	     _option->get(PREF_ALLOW_OVERWRITE) != V_TRUE) {
+	  if(!_option->getAsBool(PREF_CHECK_INTEGRITY) &&
+	     !_option->getAsBool(PREF_ALLOW_OVERWRITE)) {
 	    // TODO we need this->haltRequested = true?
 	    throw DownloadFailureException
 	      (StringFormat(MSG_FILE_ALREADY_EXISTS,
@@ -302,7 +302,7 @@ void RequestGroup::processCheckIntegrityEntry(std::deque<Command*>& commands,
 					      DownloadEngine* e)
 {
 #ifdef ENABLE_MESSAGE_DIGEST
-  if(e->option->get(PREF_CHECK_INTEGRITY) == V_TRUE &&
+  if(e->option->getAsBool(PREF_CHECK_INTEGRITY) &&
      entry->isValidationReady()) {
     entry->initValidator();
     CheckIntegrityCommand* command =
@@ -338,8 +338,8 @@ bool RequestGroup::downloadFinishedByFileLength()
 {
   // assuming that a control file doesn't exist.
   if(!isPreLocalFileCheckEnabled() ||
-     (_option->get(PREF_ALLOW_OVERWRITE) == V_TRUE) ||
-     ((_option->get(PREF_CHECK_INTEGRITY) == V_TRUE) &&
+     _option->getAsBool(PREF_ALLOW_OVERWRITE) ||
+     (_option->getAsBool(PREF_CHECK_INTEGRITY) &&
       !_downloadContext->getPieceHashes().empty())) {
     return false;
   }
@@ -374,7 +374,7 @@ void RequestGroup::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoF
 	_pieceStorage->getDiskAdaptor()->openExistingFile();
       } else {
 	File outfile(getFilePath());    
-	if(outfile.exists() && _option->get(PREF_CONTINUE) == V_TRUE) {
+	if(outfile.exists() && _option->getAsBool(PREF_CONTINUE)) {
 	  if(getTotalLength() < outfile.size()) {
 	    throw DlAbortEx
 	      (StringFormat(EX_FILE_LENGTH_MISMATCH_BETWEEN_LOCAL_AND_REMOTE,
@@ -386,7 +386,7 @@ void RequestGroup::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoF
 	  _pieceStorage->markPiecesDone(outfile.size());
 	} else {
 #ifdef ENABLE_MESSAGE_DIGEST
-	  if(outfile.exists() && _option->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
+	  if(outfile.exists() && _option->getAsBool(PREF_CHECK_INTEGRITY)) {
 	    _pieceStorage->getDiskAdaptor()->openExistingFile();
 	  } else {
 #endif // ENABLE_MESSAGE_DIGEST
@@ -415,12 +415,12 @@ void RequestGroup::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoF
 // assuming that a control file does not exist
 void RequestGroup::shouldCancelDownloadForSafety()
 {
-  if(_option->get(PREF_ALLOW_OVERWRITE) == V_TRUE) {
+  if(_option->getAsBool(PREF_ALLOW_OVERWRITE)) {
     return;
   }
   File outfile(getFilePath());
   if(outfile.exists()) {
-    if(_option->get(PREF_AUTO_FILE_RENAMING) == V_TRUE) {
+    if(_option->getAsBool(PREF_AUTO_FILE_RENAMING)) {
       if(tryAutoFileRenaming()) {
 	_logger->notice(MSG_FILE_RENAMED, getFilePath().c_str());
       } else {
@@ -742,13 +742,13 @@ void RequestGroup::initializePreDownloadHandler()
 void RequestGroup::initializePostDownloadHandler()
 {
 #ifdef ENABLE_BITTORRENT
-  if(_option->get(PREF_FOLLOW_TORRENT) == V_TRUE ||
+  if(_option->getAsBool(PREF_FOLLOW_TORRENT) ||
      _option->get(PREF_FOLLOW_TORRENT) == V_MEM) {
     _postDownloadHandlers.push_back(DownloadHandlerFactory::getBtPostDownloadHandler());
   }
 #endif // ENABLE_BITTORRENT
 #ifdef ENABLE_METALINK
-  if(_option->get(PREF_FOLLOW_METALINK) == V_TRUE ||
+  if(_option->getAsBool(PREF_FOLLOW_METALINK) ||
      _option->get(PREF_FOLLOW_METALINK) == V_MEM) {
     _postDownloadHandlers.push_back(DownloadHandlerFactory::getMetalinkPostDownloadHandler());
   }