summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-11-28 16:52:02 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-11-28 16:52:02 +0900
commit947967fc631f885dae3726a80de3a85084fbca81 (patch)
treed2cab447a42fe1728b470a664bf652ab4e9a54a3 /src
parent13e3cf2573a6d3053674563c26cbbeac8ae42f36 (diff)
Renamed DownloadErrorCode.h as error_code.h. Renamed
downloaderrorcode::Value as error_code::Value.
Diffstat (limited to 'src')
-rw-r--r--src/AbstractCommand.cc8
-rw-r--r--src/AdaptiveURISelector.cc2
-rw-r--r--src/DlAbortEx.cc2
-rw-r--r--src/DlAbortEx.h2
-rw-r--r--src/DlRetryEx.cc2
-rw-r--r--src/DlRetryEx.h2
-rw-r--r--src/DownloadCommand.cc2
-rw-r--r--src/DownloadFailureException.cc2
-rw-r--r--src/DownloadFailureException.h2
-rw-r--r--src/DownloadResult.h4
-rw-r--r--src/FileEntry.cc8
-rw-r--r--src/FileEntry.h6
-rw-r--r--src/FtpNegotiationCommand.cc6
-rw-r--r--src/HttpResponse.cc2
-rw-r--r--src/HttpSkipResponseCommand.cc2
-rw-r--r--src/MultiUrlRequestInfo.cc12
-rw-r--r--src/MultiUrlRequestInfo.h2
-rw-r--r--src/RecoverableException.cc10
-rw-r--r--src/RecoverableException.h8
-rw-r--r--src/RequestGroup.cc12
-rw-r--r--src/RequestGroup.h10
-rw-r--r--src/RequestGroupMan.cc24
-rw-r--r--src/RequestGroupMan.h10
-rw-r--r--src/SessionSerializer.cc6
-rw-r--r--src/URIResult.cc2
-rw-r--r--src/URIResult.h8
-rw-r--r--src/XmlRpcMethodImpl.cc4
-rw-r--r--src/error_code.h (renamed from src/DownloadResultCode.h)13
-rw-r--r--src/main.cc8
-rw-r--r--src/option_processing.cc20
30 files changed, 101 insertions, 100 deletions
diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc
index 4e6cffa6..367e0313 100644
--- a/src/AbstractCommand.cc
+++ b/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();
diff --git a/src/AdaptiveURISelector.cc b/src/AdaptiveURISelector.cc
index 9a994549..efe28b80 100644
--- a/src/AdaptiveURISelector.cc
+++ b/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));
diff --git a/src/DlAbortEx.cc b/src/DlAbortEx.cc
index 9a8dbb74..886b4874 100644
--- a/src/DlAbortEx.cc
+++ b/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
diff --git a/src/DlAbortEx.h b/src/DlAbortEx.h
index a7a2b13c..83a7a001 100644
--- a/src/DlAbortEx.h
+++ b/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)
diff --git a/src/DlRetryEx.cc b/src/DlRetryEx.cc
index 11a8eab5..5f3ebfbe 100644
--- a/src/DlRetryEx.cc
+++ b/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
diff --git a/src/DlRetryEx.h b/src/DlRetryEx.h
index d49340f9..dc814990 100644
--- a/src/DlRetryEx.h
+++ b/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)
diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc
index 1a7752af..1854b9a0 100644
--- a/src/DownloadCommand.cc
+++ b/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);
}
}
}
diff --git a/src/DownloadFailureException.cc b/src/DownloadFailureException.cc
index 417fa285..d10513ad 100644
--- a/src/DownloadFailureException.cc
+++ b/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
diff --git a/src/DownloadFailureException.h b/src/DownloadFailureException.h
index 352ab79e..774e0bed 100644
--- a/src/DownloadFailureException.h
+++ b/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) \
diff --git a/src/DownloadResult.h b/src/DownloadResult.h
index ce3aece0..f2247509 100644
--- a/src/DownloadResult.h
+++ b/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.
diff --git a/src/FileEntry.cc b/src/FileEntry.cc
index 767d65da..9fe560e9 100644
--- a/src/FileEntry.cc
+++ b/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(),
diff --git a/src/FileEntry.h b/src/FileEntry.h
index 4c319e85..0a40ef49 100644
--- a/src/FileEntry.h
+++ b/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)
{
diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc
index 58b8b06e..04e90088 100644
--- a/src/FtpNegotiationCommand.cc
+++ b/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));
}
diff --git a/src/HttpResponse.cc b/src/HttpResponse.cc
index 880adf76..6ce8be89 100644
--- a/src/HttpResponse.cc
+++ b/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 {
diff --git a/src/HttpSkipResponseCommand.cc b/src/HttpSkipResponseCommand.cc
index 3e24bca2..f857aee3 100644
--- a/src/HttpSkipResponseCommand.cc
+++ b/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));
}
diff --git a/src/MultiUrlRequestInfo.cc b/src/MultiUrlRequestInfo.cc
index e7e01fdb..17c4b926 100644
--- a/src/MultiUrlRequestInfo.cc
+++ b/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);
}
diff --git a/src/MultiUrlRequestInfo.h b/src/MultiUrlRequestInfo.h
index 1ca4c4be..bb84ffc6 100644
--- a/src/MultiUrlRequestInfo.h
+++ b/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;
diff --git a/src/RecoverableException.cc b/src/RecoverableException.cc
index a0ba44a1..58b47049 100644
--- a/src/RecoverableException.cc
+++ b/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
diff --git a/src/RecoverableException.h b/src/RecoverableException.h
index ea90db68..d665a170 100644
--- a/src/RecoverableException.h
+++ b/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
diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc
index 9e014576..6823da62 100644
--- a/src/RequestGroup.cc
+++ b/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));
}
diff --git a/src/RequestGroup.h b/src/RequestGroup.h
index 8bc8dc22..2ce14ecd 100644
--- a/src/RequestGroup.h
+++ b/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;
diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc
index 1f71de2e..c1efa5a7 100644
--- a/src/RequestGroupMan.cc
+++ b/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_;
}
diff --git a/src/RequestGroupMan.h b/src/RequestGroupMan.h
index 80e90a7f..320382b9 100644
--- a/src/RequestGroupMan.h
+++ b/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_;
}
diff --git a/src/SessionSerializer.cc b/src/SessionSerializer.cc
index 94203974..9001dbe6 100644
--- a/src/SessionSerializer.cc
+++ b/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);
diff --git a/src/URIResult.cc b/src/URIResult.cc
index ae6ef8be..ff6d57f7 100644
--- a/src/URIResult.cc
+++ b/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)
{}
diff --git a/src/URIResult.h b/src/URIResult.h
index 9358e2d6..f23fd75e 100644
--- a/src/URIResult.h
+++ b/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_;
}
diff --git a/src/XmlRpcMethodImpl.cc b/src/XmlRpcMethodImpl.cc
index ea85c0e2..27b94438 100644
--- a/src/XmlRpcMethodImpl.cc
+++ b/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);
diff --git a/src/DownloadResultCode.h b/src/error_code.h
index a5712c75..0dc1a542 100644
--- a/src/DownloadResultCode.h
+++ b/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
diff --git a/src/main.cc b/src/main.cc
index dfc57b4d..5464867d 100644
--- a/src/main.cc
+++ b/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;
}
diff --git a/src/option_processing.cc b/src/option_processing.cc
index 820bf48f..bb5ef3be 100644
--- a/src/option_processing.cc
+++ b/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);
}
}
}