From e15d104d8853b305806939e684663d9241ecd317 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 21 Oct 2008 16:26:43 +0000 Subject: [PATCH] 2008-10-22 Tatsuhiro Tsujikawa Now each status legends is shown only when it appears in Download Result. If Download Result has no item, then status legend will not be printed. * src/RequestGroupMan.cc --- ChangeLog | 7 +++++++ src/RequestGroupMan.cc | 45 +++++++++++++++++++++++++++++++++++------- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4dc25ab0..84e84133 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-10-22 Tatsuhiro Tsujikawa + + Now each status legends is shown only when it appears in Download + Result. If Download Result has no item, then status legend will not + be printed. + * src/RequestGroupMan.cc + 2008-10-22 Tatsuhiro Tsujikawa Removed duplicate creation of OptionHandlers. diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index 027072c8..8081a37a 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -382,20 +382,51 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const <<_("Download Results:") << "\n" << "gid|stat|path/URI" << "\n" << "===+====+======================================================================" << "\n"; + + int ok = 0; + int err = 0; + int inpr = 0; + for(std::deque >::const_iterator itr = _downloadResults.begin(); itr != _downloadResults.end(); ++itr) { - o << formatDownloadResult((*itr)->result == DownloadResult::FINISHED ? - MARK_OK : MARK_ERR, *itr) << "\n"; + std::string status; + if((*itr)->result == DownloadResult::FINISHED) { + status = MARK_OK; + ++ok; + } else { + status = MARK_ERR; + ++err; + } + o << formatDownloadResult(status, *itr) << "\n"; } for(RequestGroups::const_iterator itr = _requestGroups.begin(); itr != _requestGroups.end(); ++itr) { DownloadResultHandle result = (*itr)->createDownloadResult(); - o << formatDownloadResult(result->result == DownloadResult::FINISHED ? - MARK_OK : MARK_INPR, result) << "\n"; + std::string status; + if(result->result == DownloadResult::FINISHED) { + status = MARK_OK; + ++ok; + } else { + status = MARK_INPR; + ++inpr; + } + o << formatDownloadResult(status, result) << "\n"; + } + if(ok > 0 || err > 0 || inpr > 0) { + o << "\n" + << _("Status Legend:") << "\n"; + + if(ok > 0) { + o << " (OK):download completed."; + } + if(err > 0) { + o << "(ERR):error occurred."; + } + if(inpr > 0) { + o << "(INPR):download in-progress."; + } + o << "\n"; } - o << "\n" - << _("Status Legend:") << "\n" - << " (OK):download completed.(ERR):error occurred.(INPR):download in-progress." << "\n"; } std::string RequestGroupMan::formatDownloadResult(const std::string& status, const DownloadResultHandle& downloadResult) const