]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/install-progress.h
Merge remote-tracking branch 'mvo/bugfix/apt-list-rc-pkgs' into debian/sid
[apt.git] / apt-pkg / install-progress.h
index 513de1c08463aa1f4d76fe3d8e5150a520caac4d..112b034fbbf8d7f0fdb71796fddb7e5d38aec5f3 100644 (file)
@@ -4,6 +4,7 @@
 #include <string>
 #include <unistd.h>
 #include <signal.h>
+#include <vector>
 
 namespace APT {
 namespace Progress {
@@ -23,16 +24,16 @@ namespace Progress {
     int last_reported_progress;
 
  public:
-    PackageManager() 
+    PackageManager()
        : percentage(0.0), last_reported_progress(-1) {};
     virtual ~PackageManager() {};
 
     /* Global Start/Stop */
-    virtual void Start(int child_pty=-1) {};
+    virtual void Start(int /*child_pty*/=-1) {};
     virtual void Stop() {};
 
-    /* When dpkg is invoked (may happen multiple times for each 
-     * install/remove block 
+    /* When dpkg is invoked (may happen multiple times for each
+     * install/remove block
     */
     virtual void StartDpkg() {};
 
@@ -43,18 +44,18 @@ namespace Progress {
          return 500000;
     };
 
-    virtual bool StatusChanged(std::string PackageName, 
+    virtual bool StatusChanged(std::string PackageName,
                                unsigned int StepsDone,
                                unsigned int TotalSteps,
-                               std::string HumanReadableAction) ;
-    virtual void Error(std::string PackageName,                                
-                       unsigned int StepsDone,
-                       unsigned int TotalSteps,
-                       std::string ErrorMessage) {};
-    virtual void ConffilePrompt(std::string PackageName,
-                                unsigned int StepsDone,
-                                unsigned int TotalSteps,
-                                std::string ConfMessage) {};
+                               std::string HumanReadableAction);
+    virtual void Error(std::string /*PackageName*/,
+                       unsigned int /*StepsDone*/,
+                       unsigned int /*TotalSteps*/,
+                       std::string /*ErrorMessage*/) {}
+    virtual void ConffilePrompt(std::string /*PackageName*/,
+                                unsigned int /*StepsDone*/,
+                                unsigned int /*TotalSteps*/,
+                                std::string /*ConfMessage*/) {}
  };
 
  class PackageManagerProgressFd : public PackageManager
@@ -71,11 +72,11 @@ namespace Progress {
     virtual void StartDpkg();
     virtual void Stop();
 
-    virtual bool StatusChanged(std::string PackageName, 
+    virtual bool StatusChanged(std::string PackageName,
                                unsigned int StepsDone,
                                unsigned int TotalSteps,
                                std::string HumanReadableAction);
-    virtual void Error(std::string PackageName,                                
+    virtual void Error(std::string PackageName,
                        unsigned int StepsDone,
                        unsigned int TotalSteps,
                           std::string ErrorMessage);
@@ -100,11 +101,11 @@ namespace Progress {
     virtual void StartDpkg();
     virtual void Stop();
 
-    virtual bool StatusChanged(std::string PackageName, 
+    virtual bool StatusChanged(std::string PackageName,
                                unsigned int StepsDone,
                                unsigned int TotalSteps,
                                std::string HumanReadableAction);
-    virtual void Error(std::string PackageName,                                
+    virtual void Error(std::string PackageName,
                        unsigned int StepsDone,
                        unsigned int TotalSteps,
                           std::string ErrorMessage);
@@ -124,7 +125,12 @@ namespace Progress {
     void SetupTerminalScrollArea(int nr_rows);
     void HandleSIGWINCH(int);
 
-    int GetNumberTerminalRows();
+    typedef struct {
+       int rows;
+       int columns;
+    } TermSize;
+    TermSize GetTerminalSize();
+
     sighandler_t old_SIGWINCH;
     int child_pty;
 
@@ -133,23 +139,27 @@ namespace Progress {
     ~PackageManagerFancy();
     virtual void Start(int child_pty=-1);
     virtual void Stop();
-    virtual bool StatusChanged(std::string PackageName, 
+    virtual bool StatusChanged(std::string PackageName,
                                unsigned int StepsDone,
                                unsigned int TotalSteps,
                                std::string HumanReadableAction);
+
+    // return a progress bar of the given size for the given progress 
+    // percent between 0.0 and 1.0 in the form "[####...]"
+    static std::string GetTextProgressStr(float percent, int OutputSize);
  };
 
  class PackageManagerText : public PackageManager
  {
  public:
-    virtual bool StatusChanged(std::string PackageName, 
+    virtual bool StatusChanged(std::string PackageName,
                                unsigned int StepsDone,
                                unsigned int TotalSteps,
                                std::string HumanReadableAction);
  };
 
 
-}; // namespace Progress
-}; // namespace APT
+} // namespace Progress
+} // namespace APT
 
 #endif