Pārlūkot izejas kodu

Renamed DownloadErrorCode.h as error_code.h. Renamed
downloaderrorcode::Value as error_code::Value.

Tatsuhiro Tsujikawa 15 gadi atpakaļ
vecāks
revīzija
947967fc63

+ 4 - 4
src/AbstractCommand.cc

@@ -248,7 +248,7 @@ bool AbstractCommand::execute() {
           e_->removeCachedIPAddress
             (req_->getConnectedHostname(), req_->getConnectedPort());
         }
-        throw DL_RETRY_EX2(EX_TIME_OUT, downloadresultcode::TIME_OUT);
+        throw DL_RETRY_EX2(EX_TIME_OUT, error_code::TIME_OUT);
       }
       e_->addCommand(this);
       return false;
@@ -264,7 +264,7 @@ bool AbstractCommand::execute() {
                                    err));
       fileEntry_->addURIResult(req_->getUri(), err.getCode());
       requestGroup_->setLastUriResult(req_->getUri(), err.getCode());
-      if(err.getCode() == downloadresultcode::CANNOT_RESUME) {
+      if(err.getCode() == error_code::CANNOT_RESUME) {
         requestGroup_->increaseResumeFailureCount();
       }
     }
@@ -292,7 +292,7 @@ bool AbstractCommand::execute() {
                       err);
       fileEntry_->addURIResult(req_->getUri(), err.getCode());
       requestGroup_->setLastUriResult(req_->getUri(), err.getCode());
-      if(err.getCode() == downloadresultcode::CANNOT_RESUME) {
+      if(err.getCode() == error_code::CANNOT_RESUME) {
         requestGroup_->increaseResumeFailureCount();
       }
       onAbort();
@@ -393,7 +393,7 @@ void AbstractCommand::onAbort() {
         // process.
         getOption()->put(PREF_ALWAYS_RESUME, A2_V_TRUE);
         std::deque<URIResult> res;
-        fileEntry_->extractURIResult(res, downloadresultcode::CANNOT_RESUME);
+        fileEntry_->extractURIResult(res, error_code::CANNOT_RESUME);
         if(!res.empty()) {
           getSegmentMan()->cancelAllSegments();
           getSegmentMan()->eraseSegmentWrittenLengthMemo();

+ 1 - 1
src/AdaptiveURISelector.cc

@@ -103,7 +103,7 @@ void AdaptiveURISelector::mayRetryWithIncreasedTimeout(FileEntry* fileEntry)
   std::deque<std::string>& uris = fileEntry->getRemainingUris();
   // looking for retries
   std::deque<URIResult> timeouts;
-  fileEntry->extractURIResult(timeouts, downloadresultcode::TIME_OUT);
+  fileEntry->extractURIResult(timeouts, error_code::TIME_OUT);
   std::transform(timeouts.begin(), timeouts.end(), std::back_inserter(uris),
                  std::mem_fun_ref(&URIResult::getURI));
 

+ 1 - 1
src/DlAbortEx.cc

@@ -57,7 +57,7 @@ DlAbortEx::DlAbortEx
   RecoverableException(file, line, errnoArg, msg) {}
 
 DlAbortEx::DlAbortEx(const char* file, int line, const std::string& msg,
-                     downloadresultcode::RESULT code):
+                     error_code::Value code):
   RecoverableException(file, line, msg, code) {}
 
 } // namespace aria2

+ 1 - 1
src/DlAbortEx.h

@@ -52,7 +52,7 @@ public:
   DlAbortEx(const char* file, int line, int errnoArg, const std::string& msg);
 
   DlAbortEx(const char* file, int line, const std::string& msg,
-            downloadresultcode::RESULT code);
+            error_code::Value code);
 };
 
 #define DL_ABORT_EX(arg) DlAbortEx(__FILE__, __LINE__, arg)

+ 1 - 1
src/DlRetryEx.cc

@@ -51,7 +51,7 @@ DlRetryEx::DlRetryEx(const char* file, int line, const std::string& msg,
 DlRetryEx::DlRetryEx(const char* file, int line, const DlRetryEx& e):
   RecoverableException(file, line, e) {}
 DlRetryEx::DlRetryEx(const char* file, int line, const std::string& msg,
-                     downloadresultcode::RESULT code):
+                     error_code::Value code):
   RecoverableException(file, line, msg, code) {}
 
 } // namespace aria2

+ 1 - 1
src/DlRetryEx.h

@@ -50,7 +50,7 @@ public:
   DlRetryEx(const char* file, int line, const DlRetryEx& e);
 
   DlRetryEx(const char* file, int line, const std::string& msg,
-            downloadresultcode::RESULT code);
+            error_code::Value code);
 };
 
 #define DL_RETRY_EX(arg) DlRetryEx(__FILE__, __LINE__, arg)

+ 1 - 1
src/DownloadCommand.cc

@@ -262,7 +262,7 @@ void DownloadCommand::checkLowestDownloadSpeed() const
                              nowSpeed,
                              lowestDownloadSpeedLimit_,
                              getRequest()->getHost().c_str()),
-                         downloadresultcode::TOO_SLOW_DOWNLOAD_SPEED);
+                         error_code::TOO_SLOW_DOWNLOAD_SPEED);
     }
   }
 }

+ 1 - 1
src/DownloadFailureException.cc

@@ -59,7 +59,7 @@ DownloadFailureException::DownloadFailureException
 DownloadFailureException::DownloadFailureException
 (const char* file, int line,
  const std::string& msg,
- downloadresultcode::RESULT code):
+ error_code::Value code):
   RecoverableException(file, line, msg, code) {}
 
 } // namespace aria2

+ 1 - 1
src/DownloadFailureException.h

@@ -56,7 +56,7 @@ public:
 
   DownloadFailureException(const char* file, int line,
                            const std::string& msg,
-                           downloadresultcode::RESULT code);
+                           error_code::Value code);
 };
 
 #define DOWNLOAD_FAILURE_EXCEPTION(arg)                 \

+ 2 - 2
src/DownloadResult.h

@@ -43,7 +43,7 @@
 #include <vector>
 
 #include "SharedHandle.h"
-#include "DownloadResultCode.h"
+#include "error_code.h"
 #include "RequestGroup.h"
 
 namespace aria2 {
@@ -65,7 +65,7 @@ struct DownloadResult
   // milliseconds
   int64_t sessionTime;
 
-  downloadresultcode::RESULT result;
+  error_code::Value result;
 
   // This field contains GIDs. See comment in
   // RequestGroup.cc::_followedByGIDs.

+ 4 - 4
src/FileEntry.cc

@@ -284,7 +284,7 @@ void FileEntry::removeIdenticalURI(const std::string& uri)
   uris_.erase(std::remove(uris_.begin(), uris_.end(), uri), uris_.end());
 }
 
-void FileEntry::addURIResult(std::string uri, downloadresultcode::RESULT result)
+void FileEntry::addURIResult(std::string uri, error_code::Value result)
 {
   uriResults_.push_back(URIResult(uri, result));
 }
@@ -292,9 +292,9 @@ void FileEntry::addURIResult(std::string uri, downloadresultcode::RESULT result)
 namespace {
 class FindURIResultByResult {
 private:
-  downloadresultcode::RESULT r_;
+  error_code::Value r_;
 public:
-  FindURIResultByResult(downloadresultcode::RESULT r):r_(r) {}
+  FindURIResultByResult(error_code::Value r):r_(r) {}
 
   bool operator()(const URIResult& uriResult) const
   {
@@ -304,7 +304,7 @@ public:
 } // namespace
 
 void FileEntry::extractURIResult
-(std::deque<URIResult>& res, downloadresultcode::RESULT r)
+(std::deque<URIResult>& res, error_code::Value r)
 {
   std::deque<URIResult>::iterator i =
     std::stable_partition(uriResults_.begin(), uriResults_.end(),

+ 3 - 3
src/FileEntry.h

@@ -46,7 +46,7 @@
 #include "File.h"
 #include "Request.h"
 #include "URIResult.h"
-#include "DownloadResultCode.h"
+#include "error_code.h"
 #include "A2STR.h"
 #include "TimerA2.h"
 
@@ -193,7 +193,7 @@ public:
 
   void removeIdenticalURI(const std::string& uri);
 
-  void addURIResult(std::string uri, downloadresultcode::RESULT result);
+  void addURIResult(std::string uri, error_code::Value result);
 
   const std::deque<URIResult>& getURIResults() const
   {
@@ -203,7 +203,7 @@ public:
   // Extracts URIResult whose _result is r and stores them into res.
   // The extracted URIResults are removed from uriResults_.
   void extractURIResult
-  (std::deque<URIResult>& res, downloadresultcode::RESULT r);
+  (std::deque<URIResult>& res, error_code::Value r);
 
   void setMaxConnectionPerServer(size_t n)
   {

+ 3 - 3
src/FtpNegotiationCommand.cc

@@ -293,7 +293,7 @@ bool FtpNegotiationCommand::recvCwd()
     getRequestGroup()->increaseAndValidateFileNotFoundCount();
     if (status == 550)
       throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND,
-                         downloadresultcode::RESOURCE_NOT_FOUND);
+                         error_code::RESOURCE_NOT_FOUND);
     else
       throw DL_ABORT_EX(fmt(EX_BAD_STATUS, status));
   }
@@ -771,7 +771,7 @@ bool FtpNegotiationCommand::recvRest(const SharedHandle<Segment>& segment) {
   if(status != 350) {
     if(segment && segment->getPositionToWrite() != 0) {
       throw DL_ABORT_EX2("FTP server doesn't support resuming.",
-                         downloadresultcode::CANNOT_RESUME);
+                         error_code::CANNOT_RESUME);
     }
   }
   sequence_ = SEQ_SEND_RETR;
@@ -797,7 +797,7 @@ bool FtpNegotiationCommand::recvRetr() {
     getRequestGroup()->increaseAndValidateFileNotFoundCount();
     if (status == 550)
       throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND,
-                         downloadresultcode::RESOURCE_NOT_FOUND);
+                         error_code::RESOURCE_NOT_FOUND);
     else
       throw DL_ABORT_EX(fmt(EX_BAD_STATUS, status));
   }

+ 1 - 1
src/HttpResponse.cc

@@ -93,7 +93,7 @@ void HttpResponse::validateResponse() const
                util::itos(responseRange->getStartByte(), true).c_str(),
                util::itos(responseRange->getEndByte(), true).c_str(),
                util::uitos(responseRange->getEntityLength(), true).c_str()),
-           downloadresultcode::CANNOT_RESUME);
+           error_code::CANNOT_RESUME);
       }
     }
   } else {

+ 1 - 1
src/HttpSkipResponseCommand.cc

@@ -191,7 +191,7 @@ bool HttpSkipResponseCommand::processResponse()
       }
     } else if(statusCode == 404) {
       throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND,
-                         downloadresultcode::RESOURCE_NOT_FOUND);
+                         error_code::RESOURCE_NOT_FOUND);
     } else {
       throw DL_ABORT_EX(fmt(EX_BAD_STATUS, statusCode));
     }

+ 6 - 6
src/MultiUrlRequestInfo.cc

@@ -112,9 +112,9 @@ void MultiUrlRequestInfo::printMessageForContinue()
               << "\n";
 }
 
-downloadresultcode::RESULT MultiUrlRequestInfo::execute()
+error_code::Value MultiUrlRequestInfo::execute()
 {
-  downloadresultcode::RESULT returnValue = downloadresultcode::FINISHED;
+  error_code::Value returnValue = error_code::FINISHED;
   try {
     DownloadEngineHandle e =
       DownloadEngineFactory().newDownloadEngine(option_.get(), requestGroups_);
@@ -200,9 +200,9 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
       e->getRequestGroupMan()->getDownloadStat();
     if(!s.allCompleted()) {
       printMessageForContinue();
-      if(s.getLastErrorResult() == downloadresultcode::FINISHED &&
+      if(s.getLastErrorResult() == error_code::FINISHED &&
          s.getInProgress() > 0) {
-        returnValue = downloadresultcode::IN_PROGRESS;
+        returnValue = error_code::IN_PROGRESS;
       } else {
         returnValue = s.getLastErrorResult();
       }
@@ -220,8 +220,8 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
       }
     }
   } catch(RecoverableException& e) {
-    if(returnValue == downloadresultcode::FINISHED) {
-      returnValue = downloadresultcode::UNKNOWN_ERROR;
+    if(returnValue == error_code::FINISHED) {
+      returnValue = error_code::UNKNOWN_ERROR;
     }
     A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, e);
   }

+ 1 - 1
src/MultiUrlRequestInfo.h

@@ -73,7 +73,7 @@ public:
    * Returns FINISHED if all downloads have completed, otherwise returns the
    * last download result.
    */
-  downloadresultcode::RESULT execute();
+  error_code::Value execute();
 };
 
 typedef SharedHandle<MultiUrlRequestInfo> MultiUrlRequestInfoHandle;

+ 5 - 5
src/RecoverableException.cc

@@ -45,28 +45,28 @@ SharedHandle<Exception> RecoverableException::copy() const
 RecoverableException::RecoverableException
 (const char* file, int line, const std::string& msg):
   Exception(file, line, msg),
-  code_(downloadresultcode::UNKNOWN_ERROR) {}
+  code_(error_code::UNKNOWN_ERROR) {}
 
 RecoverableException::RecoverableException
 (const char* file, int line, const std::string& msg,
  const Exception& cause):
   Exception(file, line, msg, cause),
-  code_(downloadresultcode::UNKNOWN_ERROR) {}
+  code_(error_code::UNKNOWN_ERROR) {}
 
 RecoverableException::RecoverableException
 (const char* file, int line,
  const RecoverableException& e):
   Exception(file, line, e),
-  code_(downloadresultcode::UNKNOWN_ERROR) {}
+  code_(error_code::UNKNOWN_ERROR) {}
   
 RecoverableException::RecoverableException
 (const char* file, int line, int errnoArg, const std::string& msg):
   Exception(file, line, errnoArg, msg),
-  code_(downloadresultcode::UNKNOWN_ERROR) {}
+  code_(error_code::UNKNOWN_ERROR) {}
 
 RecoverableException::RecoverableException
 (const char* file, int line, const std::string& msg,
- downloadresultcode::RESULT result):
+ error_code::Value result):
   Exception(file, line, msg), code_(result) {}
 
 } // namespace aria2

+ 4 - 4
src/RecoverableException.h

@@ -35,13 +35,13 @@
 #ifndef D_RECOVERABLE_EXCEPTION_H
 #define D_RECOVERABLE_EXCEPTION_H
 #include "Exception.h"
-#include "DownloadResultCode.h"
+#include "error_code.h"
 
 namespace aria2 {
 
 class RecoverableException:public Exception {
 private:
-  downloadresultcode::RESULT code_;
+  error_code::Value code_;
 
 protected:
   virtual SharedHandle<Exception> copy() const;
@@ -58,9 +58,9 @@ public:
   (const char* file, int line, int errnoArg, const std::string& msg);
   
   RecoverableException(const char* file, int line, const std::string& msg,
-                       downloadresultcode::RESULT result);
+                       error_code::Value result);
 
-  downloadresultcode::RESULT getCode() const { return code_; }
+  error_code::Value getCode() const { return code_; }
 };
 
 } // namespace aria2

+ 6 - 6
src/RequestGroup.cc

@@ -190,17 +190,17 @@ bool RequestGroup::allDownloadFinished() const
   }
 }
 
-downloadresultcode::RESULT RequestGroup::downloadResult() const
+error_code::Value RequestGroup::downloadResult() const
 {
   if(downloadFinished() && !downloadContext_->isChecksumVerificationNeeded())
-    return downloadresultcode::FINISHED;
+    return error_code::FINISHED;
   else {
     if(!lastUriResult_) {
       if(haltReason_ == RequestGroup::USER_REQUEST ||
          haltReason_ == RequestGroup::SHUTDOWN_SIGNAL) {
-        return downloadresultcode::IN_PROGRESS;
+        return error_code::IN_PROGRESS;
       } else {
-        return downloadresultcode::UNKNOWN_ERROR;
+        return error_code::UNKNOWN_ERROR;
       }
     } else {
       return lastUriResult_->getResult();
@@ -1252,7 +1252,7 @@ void RequestGroup::increaseAndValidateFileNotFoundCount()
       segmentMan_->calculateSessionDownloadLength() == 0)) {
     throw DOWNLOAD_FAILURE_EXCEPTION2
       (fmt("Reached max-file-not-found count=%u", maxCount),
-       downloadresultcode::MAX_FILE_NOT_FOUND);
+       error_code::MAX_FILE_NOT_FOUND);
   }
 }
 
@@ -1279,7 +1279,7 @@ bool RequestGroup::doesUploadSpeedExceed()
 }
 
 void RequestGroup::setLastUriResult
-(const std::string uri, downloadresultcode::RESULT result)
+(const std::string uri, error_code::Value result)
 {
   lastUriResult_.reset(new URIResult(uri, result));
 }

+ 5 - 5
src/RequestGroup.h

@@ -45,7 +45,7 @@
 #include "TransferStat.h"
 #include "TimeA2.h"
 #include "Request.h"
-#include "DownloadResultCode.h"
+#include "error_code.h"
 #include "MetadataInfo.h"
 
 namespace aria2 {
@@ -185,11 +185,11 @@ private:
   bool tryAutoFileRenaming();
 
   // Returns the result code of this RequestGroup.  If the download
-  // finished, then returns downloadresultcode::FINISHED.  If the
+  // finished, then returns error_code::FINISHED.  If the
   // download didn't finish and error result is available in
   // _uriResults, then last result code is returned.  Otherwise
-  // returns downloadresultcode::UNKNOWN_ERROR.
-  downloadresultcode::RESULT downloadResult() const;
+  // returns error_code::UNKNOWN_ERROR.
+  error_code::Value downloadResult() const;
 
   void removeDefunctControlFile
   (const SharedHandle<BtProgressInfoFile>& progressInfoFile);
@@ -481,7 +481,7 @@ public:
     maxUploadSpeedLimit_ = speed;
   }
 
-  void setLastUriResult(std::string uri, downloadresultcode::RESULT result);
+  void setLastUriResult(std::string uri, error_code::Value result);
 
   void saveControlFile() const;
 

+ 12 - 12
src/RequestGroupMan.cc

@@ -92,7 +92,7 @@ RequestGroupMan::RequestGroupMan
     xmlRpc_(option->getAsBool(PREF_ENABLE_XML_RPC)),
     queueCheck_(true),
     removedErrorResult_(0),
-    removedLastErrorResult_(downloadresultcode::FINISHED),
+    removedLastErrorResult_(error_code::FINISHED),
     maxDownloadResult_(option->getAsInt(PREF_MAX_DOWNLOAD_RESULT))
 {}
 
@@ -264,11 +264,11 @@ namespace {
 void executeStopHook
 (const SharedHandle<DownloadResult>& result, const Option* option)
 {
-  if(result->result == downloadresultcode::FINISHED &&
+  if(result->result == error_code::FINISHED &&
      !option->blank(PREF_ON_DOWNLOAD_COMPLETE)) {
     util::executeHook(option->get(PREF_ON_DOWNLOAD_COMPLETE),
                       util::itos(result->gid));
-  } else if(result->result != downloadresultcode::IN_PROGRESS &&
+  } else if(result->result != error_code::IN_PROGRESS &&
             !option->blank(PREF_ON_DOWNLOAD_ERROR)) {
     util::executeHook(option->get(PREF_ON_DOWNLOAD_ERROR),
                       util::itos(result->gid));
@@ -567,11 +567,11 @@ RequestGroupMan::DownloadStat RequestGroupMan::getDownloadStat() const
   size_t finished = 0;
   size_t error = removedErrorResult_;
   size_t inprogress = 0;
-  downloadresultcode::RESULT lastError = removedLastErrorResult_;
+  error_code::Value lastError = removedLastErrorResult_;
   for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
         downloadResults_.begin(), eoi = downloadResults_.end();
       itr != eoi; ++itr) {
-    if((*itr)->result == downloadresultcode::FINISHED) {
+    if((*itr)->result == error_code::FINISHED) {
       ++finished;
     } else {
       ++error;
@@ -581,7 +581,7 @@ RequestGroupMan::DownloadStat RequestGroupMan::getDownloadStat() const
   for(std::deque<SharedHandle<RequestGroup> >::const_iterator itr =
         requestGroups_.begin(), eoi = requestGroups_.end(); itr != eoi; ++itr) {
     DownloadResultHandle result = (*itr)->createDownloadResult();
-    if(result->result == downloadresultcode::FINISHED) {
+    if(result->result == error_code::FINISHED) {
       ++finished;
     } else {
       ++inprogress;
@@ -618,10 +618,10 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
         downloadResults_.begin(), eoi = downloadResults_.end();
       itr != eoi; ++itr) {
     std::string status;
-    if((*itr)->result == downloadresultcode::FINISHED) {
+    if((*itr)->result == error_code::FINISHED) {
       status = MARK_OK;
       ++ok;
-    } else if((*itr)->result == downloadresultcode::IN_PROGRESS) {
+    } else if((*itr)->result == error_code::IN_PROGRESS) {
       status = MARK_INPR;
       ++inpr;
     } else {
@@ -634,7 +634,7 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
         requestGroups_.begin(), eoi = requestGroups_.end(); itr != eoi; ++itr) {
     DownloadResultHandle result = (*itr)->createDownloadResult();
     std::string status;
-    if(result->result == downloadresultcode::FINISHED) {
+    if(result->result == error_code::FINISHED) {
       status = MARK_OK;
       ++ok;
     } else {
@@ -783,14 +783,14 @@ void RequestGroupMan::addDownloadResult(const SharedHandle<DownloadResult>& dr)
       for(std::deque<SharedHandle<DownloadResult> >::iterator i =
             downloadResults_.begin(), eoi = downloadResults_.end(); i != eoi;
           ++i) {
-        if((*i)->result != downloadresultcode::FINISHED) {
+        if((*i)->result != error_code::FINISHED) {
           removedLastErrorResult_ = (*i)->result;
           ++removedErrorResult_;
         }
       }
       downloadResults_.clear();
     }
-    if(dr->result != downloadresultcode::FINISHED) {
+    if(dr->result != error_code::FINISHED) {
       removedLastErrorResult_ = dr->result;
       ++removedErrorResult_;
     }
@@ -801,7 +801,7 @@ void RequestGroupMan::addDownloadResult(const SharedHandle<DownloadResult>& dr)
         downloadResults_.begin()+curSize-maxDownloadResult_+1;
       for(std::deque<SharedHandle<DownloadResult> >::iterator i =
             downloadResults_.begin(); i != last; ++i) {
-        if((*i)->result != downloadresultcode::FINISHED) {
+        if((*i)->result != error_code::FINISHED) {
           removedLastErrorResult_ = (*i)->result;
           ++removedErrorResult_;
         }

+ 5 - 5
src/RequestGroupMan.h

@@ -81,7 +81,7 @@ private:
   size_t removedErrorResult_;
 
   // The last error of removed DownloadResult
-  downloadresultcode::RESULT removedLastErrorResult_;
+  error_code::Value removedLastErrorResult_;
 
   size_t maxDownloadResult_;
 
@@ -172,21 +172,21 @@ public:
     size_t error_;
     size_t inProgress_;
     size_t waiting_;
-    downloadresultcode::RESULT lastErrorResult_;
+    error_code::Value lastErrorResult_;
   public:
     DownloadStat(size_t completed,
                  size_t error,
                  size_t inProgress,
                  size_t waiting,
-                 downloadresultcode::RESULT lastErrorResult =
-                 downloadresultcode::FINISHED):
+                 error_code::Value lastErrorResult =
+                 error_code::FINISHED):
       completed_(completed),
       error_(error),
       inProgress_(inProgress),
       waiting_(waiting),
       lastErrorResult_(lastErrorResult) {}
 
-    downloadresultcode::RESULT getLastErrorResult() const
+    error_code::Value getLastErrorResult() const
     {
       return lastErrorResult_;
     }

+ 3 - 3
src/SessionSerializer.cc

@@ -171,9 +171,9 @@ void SessionSerializer::save(std::ostream& out) const
     rgman_->getDownloadResults();
   for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
         results.begin(), eoi = results.end(); itr != eoi; ++itr) {
-    if((*itr)->result == downloadresultcode::FINISHED) {
+    if((*itr)->result == error_code::FINISHED) {
       continue;
-    } else if((*itr)->result == downloadresultcode::IN_PROGRESS) {
+    } else if((*itr)->result == error_code::IN_PROGRESS) {
       if(saveInProgress_) {
         writeDownloadResult(out, metainfoCache, *itr);
       }
@@ -190,7 +190,7 @@ void SessionSerializer::save(std::ostream& out) const
     for(std::deque<SharedHandle<RequestGroup> >::const_iterator itr =
           groups.begin(), eoi = groups.end(); itr != eoi; ++itr) {
       SharedHandle<DownloadResult> result = (*itr)->createDownloadResult();
-      if(result->result == downloadresultcode::FINISHED) {
+      if(result->result == error_code::FINISHED) {
         continue;
       }
       writeDownloadResult(out, metainfoCache, result);

+ 1 - 1
src/URIResult.cc

@@ -36,7 +36,7 @@
 
 namespace aria2 {
 
-URIResult::URIResult(const std::string& uri, downloadresultcode::RESULT result)
+URIResult::URIResult(const std::string& uri, error_code::Value result)
   : uri_(uri), result_(result)
 {}
 

+ 4 - 4
src/URIResult.h

@@ -39,7 +39,7 @@
 
 #include <string>
 
-#include "DownloadResultCode.h"
+#include "error_code.h"
 
 namespace aria2 {
 
@@ -48,9 +48,9 @@ class URIResult {
 private:
   std::string uri_;
 
-  downloadresultcode::RESULT result_;
+  error_code::Value result_;
 public:
-  URIResult(const std::string& uri, downloadresultcode::RESULT result);
+  URIResult(const std::string& uri, error_code::Value result);
 
   ~URIResult();
 
@@ -59,7 +59,7 @@ public:
     return uri_;
   }
 
-  downloadresultcode::RESULT getResult() const
+  error_code::Value getResult() const
   {
     return result_;
   }

+ 2 - 2
src/XmlRpcMethodImpl.cc

@@ -739,9 +739,9 @@ void gatherStoppedDownload
     entryDict->put(KEY_ERROR_CODE, util::itos(static_cast<int>(ds->result)));
   }
   if(requested_key(keys, KEY_STATUS)) {
-    if(ds->result == downloadresultcode::IN_PROGRESS) {
+    if(ds->result == error_code::IN_PROGRESS) {
       entryDict->put(KEY_STATUS, VLB_REMOVED);
-    } else if(ds->result == downloadresultcode::FINISHED) {
+    } else if(ds->result == error_code::FINISHED) {
       entryDict->put(KEY_STATUS, VLB_COMPLETE);
     } else {
       entryDict->put(KEY_STATUS, VLB_ERROR);

+ 7 - 6
src/DownloadResultCode.h → src/error_code.h

@@ -32,16 +32,17 @@
  * files in the program, then also delete it here.
  */
 /* copyright --> */
-#ifndef D_DOWNLOAD_RESULT_CODE_H
-#define D_DOWNLOAD_RESULT_CODE_H
+#ifndef D_ERROR_CODE_H
+#define D_ERROR_CODE_H
 
 #include "common.h"
 
 namespace aria2 {
 
-namespace downloadresultcode {
+namespace error_code {
 
-enum RESULT {
+enum Value {
+  UNDEFINED = -1,
   FINISHED = 0,
   UNKNOWN_ERROR = 1,
   TIME_OUT = 2,
@@ -53,8 +54,8 @@ enum RESULT {
   CANNOT_RESUME = 8,
 };
 
-} // namespace downloadresultcode
+} // namespace error_code
 
 } // namespace aria2
 
-#endif // D_DOWNLOAD_RESULT_CODE_H
+#endif // D_ERROR_CODE_H

+ 4 - 4
src/main.cc

@@ -172,7 +172,7 @@ void showFiles
 extern void option_processing(Option& option, std::vector<std::string>& uris,
                               int argc, char* const argv[]);
 
-downloadresultcode::RESULT main(int argc, char* argv[])
+error_code::Value main(int argc, char* argv[])
 {
   std::vector<std::string> args;
   SharedHandle<Option> op(new Option());
@@ -187,7 +187,7 @@ downloadresultcode::RESULT main(int argc, char* argv[])
   if(op->getAsBool(PREF_QUIET)) {
     LogFactory::setConsoleOutput(false);
   }
-  downloadresultcode::RESULT exitStatus = downloadresultcode::FINISHED;
+  error_code::Value exitStatus = error_code::FINISHED;
   A2_LOG_INFO("<<--- --- --- ---");
   A2_LOG_INFO("  --- --- --- ---");
   A2_LOG_INFO("  --- --- --- --->>");
@@ -278,13 +278,13 @@ downloadresultcode::RESULT main(int argc, char* argv[])
 
 int main(int argc, char* argv[])
 {
-  aria2::downloadresultcode::RESULT r;
+  aria2::error_code::Value r;
   try {
     aria2::Platform platform;
     r = aria2::main(argc, argv);
   } catch(aria2::Exception& ex) {
     std::cerr << EX_EXCEPTION_CAUGHT << "\n" << ex.stackTrace() << std::endl;
-    r = aria2::downloadresultcode::UNKNOWN_ERROR;
+    r = aria2::error_code::UNKNOWN_ERROR;
   }
   return r;
 }

+ 10 - 10
src/option_processing.cc

@@ -53,7 +53,7 @@
 #include "File.h"
 #include "fmt.h"
 #include "OptionHandlerException.h"
-#include "DownloadResultCode.h"
+#include "error_code.h"
 #include "SimpleRandomizer.h"
 #include "bittorrent_helper.h"
 #ifndef HAVE_DAEMON
@@ -103,7 +103,7 @@ void option_processing(Option& op, std::vector<std::string>& uris,
 
       if(op.defined("version")) {
         showVersion();
-        exit(downloadresultcode::FINISHED);
+        exit(error_code::FINISHED);
       }
       if(op.defined("help")) {
         std::string keyword;
@@ -120,7 +120,7 @@ void option_processing(Option& op, std::vector<std::string>& uris,
           }
         }
         showUsage(keyword, oparser);
-        exit(downloadresultcode::FINISHED);
+        exit(error_code::FINISHED);
       }
     }
 
@@ -145,17 +145,17 @@ void option_processing(Option& op, std::vector<std::string>& uris,
                       << oparser.findByName(e.getOptionName())->getDescription()
                       << std::endl;
           }
-          exit(downloadresultcode::UNKNOWN_ERROR);
+          exit(error_code::UNKNOWN_ERROR);
         } catch(Exception& e) {
           std::cerr << "Parse error in " << cfname << "\n"
                     << e.stackTrace() << std::endl;
-          exit(downloadresultcode::UNKNOWN_ERROR);
+          exit(error_code::UNKNOWN_ERROR);
         }
       } else if(!ucfname.empty()) {
         std::cerr << fmt("Configuration file %s is not found.", cfname.c_str())
                   << "\n";
         showUsage(TAG_HELP, oparser);
-        exit(downloadresultcode::UNKNOWN_ERROR);
+        exit(error_code::UNKNOWN_ERROR);
       }
     }
     // Override configuration with environment variables.
@@ -175,11 +175,11 @@ void option_processing(Option& op, std::vector<std::string>& uris,
               << "Usage:" << "\n"
               << *oparser.findByName(e.getOptionName())
               << std::endl;
-    exit(downloadresultcode::UNKNOWN_ERROR);
+    exit(error_code::UNKNOWN_ERROR);
   } catch(Exception& e) {
     std::cerr << e.stackTrace() << std::endl;
     showUsage(TAG_HELP, oparser);
-    exit(downloadresultcode::UNKNOWN_ERROR);
+    exit(error_code::UNKNOWN_ERROR);
   }
   if(
 #ifdef ENABLE_XML_RPC
@@ -195,13 +195,13 @@ void option_processing(Option& op, std::vector<std::string>& uris,
     if(uris.empty()) {
       std::cerr << MSG_URI_REQUIRED << std::endl;
       showUsage(TAG_HELP, oparser);
-      exit(downloadresultcode::UNKNOWN_ERROR);
+      exit(error_code::UNKNOWN_ERROR);
     }
   }
   if(op.getAsBool(PREF_DAEMON)) {
     if(daemon(0, 0) < 0) {
       perror(MSG_DAEMON_FAILED);
-      exit(downloadresultcode::UNKNOWN_ERROR);
+      exit(error_code::UNKNOWN_ERROR);
     }
   }
 }

+ 7 - 7
test/FileEntryTest.cc

@@ -64,13 +64,13 @@ void FileEntryTest::testRemoveURIWhoseHostnameIs()
 void FileEntryTest::testExtractURIResult()
 {
   FileEntry fileEntry;
-  fileEntry.addURIResult("http://timeout/file", downloadresultcode::TIME_OUT);
-  fileEntry.addURIResult("http://finished/file", downloadresultcode::FINISHED);
-  fileEntry.addURIResult("http://timeout/file2", downloadresultcode::TIME_OUT);
-  fileEntry.addURIResult("http://unknownerror/file", downloadresultcode::UNKNOWN_ERROR);
+  fileEntry.addURIResult("http://timeout/file", error_code::TIME_OUT);
+  fileEntry.addURIResult("http://finished/file", error_code::FINISHED);
+  fileEntry.addURIResult("http://timeout/file2", error_code::TIME_OUT);
+  fileEntry.addURIResult("http://unknownerror/file", error_code::UNKNOWN_ERROR);
 
   std::deque<URIResult> res;
-  fileEntry.extractURIResult(res, downloadresultcode::TIME_OUT);
+  fileEntry.extractURIResult(res, error_code::TIME_OUT);
   CPPUNIT_ASSERT_EQUAL((size_t)2, res.size());
   CPPUNIT_ASSERT_EQUAL(std::string("http://timeout/file"), res[0].getURI());
   CPPUNIT_ASSERT_EQUAL(std::string("http://timeout/file2"), res[1].getURI());
@@ -83,7 +83,7 @@ void FileEntryTest::testExtractURIResult()
 
   res.clear();
 
-  fileEntry.extractURIResult(res, downloadresultcode::TIME_OUT);
+  fileEntry.extractURIResult(res, error_code::TIME_OUT);
   CPPUNIT_ASSERT(res.empty());
   CPPUNIT_ASSERT_EQUAL((size_t)2, fileEntry.getURIResults().size());
 }
@@ -194,7 +194,7 @@ void FileEntryTest::testReuseUri()
   }
   CPPUNIT_ASSERT_EQUAL((size_t)0, fileEntry->getRemainingUris().size());
   fileEntry->addURIResult("http://localhost/aria2.zip",
-                          downloadresultcode::UNKNOWN_ERROR);
+                          error_code::UNKNOWN_ERROR);
   std::vector<std::string> ignore;
   fileEntry->reuseUri(ignore);
   CPPUNIT_ASSERT_EQUAL((size_t)2, fileEntry->getRemainingUris().size());

+ 5 - 5
test/RequestGroupTest.cc

@@ -64,28 +64,28 @@ void RequestGroupTest::testCreateDownloadResult()
     CPPUNIT_ASSERT_EQUAL((int64_t)0, result->sessionTime);
     // result is UNKNOWN_ERROR if download has not completed and no specific
     // error has been reported
-    CPPUNIT_ASSERT_EQUAL(downloadresultcode::UNKNOWN_ERROR, result->result);
+    CPPUNIT_ASSERT_EQUAL(error_code::UNKNOWN_ERROR, result->result);
 
     // if haltReason is set to RequestGroup::USER_REQUEST, download
     // result becomes IN_PROGRESS
     group.setHaltRequested(true, RequestGroup::USER_REQUEST);
     result = group.createDownloadResult();
-    CPPUNIT_ASSERT_EQUAL(downloadresultcode::IN_PROGRESS, result->result);
+    CPPUNIT_ASSERT_EQUAL(error_code::IN_PROGRESS, result->result);
   }
   {
     group.setLastUriResult
-      ("http://second/file",downloadresultcode::RESOURCE_NOT_FOUND);
+      ("http://second/file",error_code::RESOURCE_NOT_FOUND);
   
     SharedHandle<DownloadResult> result = group.createDownloadResult();
 
-    CPPUNIT_ASSERT_EQUAL(downloadresultcode::RESOURCE_NOT_FOUND, result->result);
+    CPPUNIT_ASSERT_EQUAL(error_code::RESOURCE_NOT_FOUND, result->result);
   }
   {
     group.getPieceStorage()->markAllPiecesDone();
 
     SharedHandle<DownloadResult> result = group.createDownloadResult();
 
-    CPPUNIT_ASSERT_EQUAL(downloadresultcode::FINISHED, result->result);
+    CPPUNIT_ASSERT_EQUAL(error_code::FINISHED, result->result);
   }
 }
 

+ 1 - 1
test/XmlRpcMethodTest.cc

@@ -721,7 +721,7 @@ void XmlRpcMethodTest::testGatherStoppedDownload()
   d->inMemoryDownload = false;
   d->sessionDownloadLength = UINT64_MAX;
   d->sessionTime = 1000;
-  d->result = downloadresultcode::FINISHED;
+  d->result = error_code::FINISHED;
   d->followedBy = followedBy;
   d->belongsTo = 2;
   SharedHandle<Dict> entry = Dict::g();