apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

install-progress.h
Go to the documentation of this file.
1 #ifndef PKGLIB_IPROGRESS_H
2 #define PKGLIB_IPROGRESS_H
3 
4 #include <apt-pkg/macros.h>
5 
6 #include <string>
7 #include <vector>
8 #include <signal.h>
9 #include <unistd.h>
10 
11 namespace APT {
12 namespace Progress {
13 
14  class PackageManager;
15  APT_PUBLIC PackageManager* PackageManagerProgressFactory();
16 
18  {
19  private:
20  /** \brief dpointer placeholder */
21  void * const d;
22 
23  protected:
24  std::string progress_str;
25  float percentage;
27 
28  public:
30  virtual ~~PackageManager();
31 
32  /* Global Start/Stop */
33  virtual void Start(int /*child_pty*/=-1) {};
34  virtual void Stop() {};
35 
36  /* When dpkg is invoked (may happen multiple times for each
37  * install/remove block
38  */
39  virtual void StartDpkg() {};
40 
41  virtual pid_t fork() {return ::fork(); };
42 
43  virtual void Pulse() {};
44  virtual long GetPulseInterval() {
45  return 50000000;
46  };
47 
48  virtual bool StatusChanged(std::string PackageName,
49  unsigned int StepsDone,
50  unsigned int TotalSteps,
51  std::string HumanReadableAction);
52  virtual void Error(std::string /*PackageName*/,
53  unsigned int /*StepsDone*/,
54  unsigned int /*TotalSteps*/,
55  std::string /*ErrorMessage*/) {}
56  virtual void ConffilePrompt(std::string /*PackageName*/,
57  unsigned int /*StepsDone*/,
58  unsigned int /*TotalSteps*/,
59  std::string /*ConfMessage*/) {}
60  };
61 
63  {
64  void * const d;
65  protected:
67  int StepsDone;
69  void WriteToStatusFd(std::string msg);
70 
71  public:
72  explicit PackageManagerProgressFd(int progress_fd);
73  virtual ~~PackageManagerProgressFd();
74 
75  virtual void StartDpkg() APT_OVERRIDE;
76  virtual void Stop() APT_OVERRIDE;
77 
78  virtual bool StatusChanged(std::string PackageName,
79  unsigned int StepsDone,
80  unsigned int TotalSteps,
81  std::string HumanReadableAction) APT_OVERRIDE;
82  virtual void Error(std::string PackageName,
83  unsigned int StepsDone,
84  unsigned int TotalSteps,
85  std::string ErrorMessage) APT_OVERRIDE;
86  virtual void ConffilePrompt(std::string PackageName,
87  unsigned int StepsDone,
88  unsigned int TotalSteps,
89  std::string ConfMessage) APT_OVERRIDE;
90 
91  };
92 
94  {
95  void * const d;
96  protected:
98  int StepsDone;
100  void WriteToStatusFd(std::string msg);
101 
102  public:
103  explicit PackageManagerProgressDeb822Fd(int progress_fd);
105 
106  virtual void StartDpkg() APT_OVERRIDE;
107  virtual void Stop() APT_OVERRIDE;
108 
109  virtual bool StatusChanged(std::string PackageName,
110  unsigned int StepsDone,
111  unsigned int TotalSteps,
112  std::string HumanReadableAction) APT_OVERRIDE;
113  virtual void Error(std::string PackageName,
114  unsigned int StepsDone,
115  unsigned int TotalSteps,
116  std::string ErrorMessage) APT_OVERRIDE;
117  virtual void ConffilePrompt(std::string PackageName,
118  unsigned int StepsDone,
119  unsigned int TotalSteps,
120  std::string ConfMessage) APT_OVERRIDE;
121  };
122 
124  {
125  void * const d;
126  private:
127  APT_HIDDEN static void staticSIGWINCH(int);
128  static std::vector<PackageManagerFancy*> instances;
129  APT_HIDDEN bool DrawStatusLine();
130 
131  protected:
132  void SetupTerminalScrollArea(int nr_rows);
133  void HandleSIGWINCH(int);
134 
135  typedef struct {
136  int rows;
137  int columns;
138  } TermSize;
139  TermSize GetTerminalSize();
140 
141  sighandler_t old_SIGWINCH;
143 
144  public:
146  virtual ~~PackageManagerFancy();
147  virtual void Start(int child_pty=-1) APT_OVERRIDE;
148  virtual void Stop() APT_OVERRIDE;
149  virtual bool StatusChanged(std::string PackageName,
150  unsigned int StepsDone,
151  unsigned int TotalSteps,
152  std::string HumanReadableAction) APT_OVERRIDE;
153 
154  // return a progress bar of the given size for the given progress
155  // percent between 0.0 and 1.0 in the form "[####...]"
156  static std::string GetTextProgressStr(float percent, int OutputSize);
157  };
158 
160  {
161  void * const d;
162  public:
163  virtual bool StatusChanged(std::string PackageName,
164  unsigned int StepsDone,
165  unsigned int TotalSteps,
166  std::string HumanReadableAction) APT_OVERRIDE;
167 
169  virtual ~~PackageManagerText();
170  };
171 
172 
173 } // namespace Progress
174 } // namespace APT
175 
176 #endif
static char const *const msg
static std::vector< PackageManagerFancy * > instances
virtual void Start(int=-1)
virtual void Error(std::string, unsigned int, unsigned int, std::string)
virtual void ConffilePrompt(std::string, unsigned int, unsigned int, std::string)
void *const d
dpointer placeholder
#define APT_OVERRIDE
Definition: macros.h:111
#define APT_PUBLIC
Definition: macros.h:77
#define APT_HIDDEN
Definition: macros.h:78
PackageManager * PackageManagerProgressFactory()