1 #ifndef PKGLIB_IPROGRESS_H
2 #define PKGLIB_IPROGRESS_H
4 #include <apt-pkg/macros.h>
15 PackageManager
* PackageManagerProgressFactory();
20 /** \brief dpointer placeholder */
24 std::string progress_str
;
26 int last_reported_progress
;
30 virtual ~PackageManager();
32 /* Global Start/Stop */
33 virtual void Start(int /*child_pty*/=-1) {};
34 virtual void Stop() {};
36 /* When dpkg is invoked (may happen multiple times for each
37 * install/remove block
39 virtual void StartDpkg() {};
41 virtual pid_t
fork() {return fork(); };
43 virtual void Pulse() {};
44 virtual long GetPulseInterval() {
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*/) {}
62 class PackageManagerProgressFd
: public PackageManager
69 void WriteToStatusFd(std::string msg
);
72 explicit PackageManagerProgressFd(int progress_fd
);
73 virtual ~PackageManagerProgressFd();
75 virtual void StartDpkg() APT_OVERRIDE
;
76 virtual void Stop() APT_OVERRIDE
;
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
;
93 class PackageManagerProgressDeb822Fd
: public PackageManager
100 void WriteToStatusFd(std::string msg
);
103 explicit PackageManagerProgressDeb822Fd(int progress_fd
);
104 virtual ~PackageManagerProgressDeb822Fd();
106 virtual void StartDpkg() APT_OVERRIDE
;
107 virtual void Stop() APT_OVERRIDE
;
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
;
123 class PackageManagerFancy
: public PackageManager
127 APT_HIDDEN
static void staticSIGWINCH(int);
128 static std::vector
<PackageManagerFancy
*> instances
;
129 APT_HIDDEN
bool DrawStatusLine();
132 void SetupTerminalScrollArea(int nr_rows
);
133 void HandleSIGWINCH(int);
139 TermSize
GetTerminalSize();
141 sighandler_t old_SIGWINCH
;
145 PackageManagerFancy();
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
;
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
);
159 class PackageManagerText
: public PackageManager
163 virtual bool StatusChanged(std::string PackageName
,
164 unsigned int StepsDone
,
165 unsigned int TotalSteps
,
166 std::string HumanReadableAction
) APT_OVERRIDE
;
168 PackageManagerText();
169 virtual ~PackageManagerText();
173 } // namespace Progress