summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-05-02 11:51:44 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-05-02 11:51:44 +0200
commite876223c704d8cac6246b4aff4bf683fb8b053e3 (patch)
tree1761b7f9d4001bd35a98fd8c070d7b9e65a7429e /apt-pkg
parent7ca70a9af1bc6af753ee3012d1840d5ddfafe37c (diff)
implement optional Progress report in EDSP
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/edsp.cc21
-rw-r--r--apt-pkg/edsp.h1
2 files changed, 20 insertions, 2 deletions
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index aec43c7e8..6343b57cd 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -242,8 +242,16 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache) {
type = "Install";
else if (section.Exists("Remove") == true)
type = "Remove";
- //FIXME: handle progress
- else
+ else if (section.Exists("Progress") == true) {
+ ioprintf(std::clog, "[ %3d%% ] ", section.FindI("Percentage", 0));
+ std::clog << section.FindS("Progress") << " - ";
+ string const msg = section.FindS("Message");
+ if (msg.empty() == true)
+ std::clog << "Solver is still working on the solution" << std::endl;
+ else
+ std::clog << msg << std::endl;
+ continue;
+ } else
continue;
size_t const id = section.FindULL(type.c_str(), VersionCount);
@@ -422,4 +430,13 @@ bool EDSP::WriteSolution(pkgDepCache &Cache, FILE* output)
return true;
}
/*}}}*/
+// EDSP::WriteProgess - pulse to the given file descriptor /*{{{*/
+bool EDSP::WriteProgress(unsigned short const percent, const char* const message, FILE* output) {
+ fprintf(output, "Progress: %s\n", TimeRFC1123(time(NULL)).c_str());
+ fprintf(output, "Percentage: %d\n", percent);
+ fprintf(output, "Message: %s\n\n", message);
+ fflush(output);
+ return true;
+}
+ /*}}}*/
bool EDSP::WriteError(std::string const &message, FILE* output) { return false; }
diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h
index db4f06a7c..a05de9448 100644
--- a/apt-pkg/edsp.h
+++ b/apt-pkg/edsp.h
@@ -49,6 +49,7 @@ public:
std::list<std::string> const &remove,
pkgDepCache &Cache);
bool static WriteSolution(pkgDepCache &Cache, FILE* output);
+ bool static WriteProgress(unsigned short const percent, const char* const message, FILE* output);
bool static WriteError(std::string const &message, FILE* output);
};