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 : percentage(0.0), last_reported_progress(-1) {};
31 virtual ~PackageManager() {};
33 /* Global Start/Stop */
34 virtual void Start(int /*child_pty*/=-1) {};
35 virtual void Stop() {};
37 /* When dpkg is invoked (may happen multiple times for each
38 * install/remove block
40 virtual void StartDpkg() {};
42 virtual pid_t
fork() {return fork(); };
44 virtual void Pulse() {};
45 virtual long GetPulseInterval() {
49 virtual bool StatusChanged(std::string PackageName
,
50 unsigned int StepsDone
,
51 unsigned int TotalSteps
,
52 std::string HumanReadableAction
);
53 virtual void Error(std::string
/*PackageName*/,
54 unsigned int /*StepsDone*/,
55 unsigned int /*TotalSteps*/,
56 std::string
/*ErrorMessage*/) {}
57 virtual void ConffilePrompt(std::string
/*PackageName*/,
58 unsigned int /*StepsDone*/,
59 unsigned int /*TotalSteps*/,
60 std::string
/*ConfMessage*/) {}
63 class PackageManagerProgressFd
: public PackageManager
69 void WriteToStatusFd(std::string msg
);
72 PackageManagerProgressFd(int progress_fd
);
74 virtual void StartDpkg();
77 virtual bool StatusChanged(std::string PackageName
,
78 unsigned int StepsDone
,
79 unsigned int TotalSteps
,
80 std::string HumanReadableAction
);
81 virtual void Error(std::string PackageName
,
82 unsigned int StepsDone
,
83 unsigned int TotalSteps
,
84 std::string ErrorMessage
);
85 virtual void ConffilePrompt(std::string PackageName
,
86 unsigned int StepsDone
,
87 unsigned int TotalSteps
,
88 std::string ConfMessage
);
92 class PackageManagerProgressDeb822Fd
: public PackageManager
98 void WriteToStatusFd(std::string msg
);
101 PackageManagerProgressDeb822Fd(int progress_fd
);
103 virtual void StartDpkg();
106 virtual bool StatusChanged(std::string PackageName
,
107 unsigned int StepsDone
,
108 unsigned int TotalSteps
,
109 std::string HumanReadableAction
);
110 virtual void Error(std::string PackageName
,
111 unsigned int StepsDone
,
112 unsigned int TotalSteps
,
113 std::string ErrorMessage
);
114 virtual void ConffilePrompt(std::string PackageName
,
115 unsigned int StepsDone
,
116 unsigned int TotalSteps
,
117 std::string ConfMessage
);
120 class PackageManagerFancy
: public PackageManager
123 static void staticSIGWINCH(int);
124 static std::vector
<PackageManagerFancy
*> instances
;
125 APT_HIDDEN
bool DrawStatusLine();
128 void SetupTerminalScrollArea(int nr_rows
);
129 void HandleSIGWINCH(int);
135 TermSize
GetTerminalSize();
137 sighandler_t old_SIGWINCH
;
141 PackageManagerFancy();
142 ~PackageManagerFancy();
143 virtual void Start(int child_pty
=-1);
145 virtual bool StatusChanged(std::string PackageName
,
146 unsigned int StepsDone
,
147 unsigned int TotalSteps
,
148 std::string HumanReadableAction
);
150 // return a progress bar of the given size for the given progress
151 // percent between 0.0 and 1.0 in the form "[####...]"
152 static std::string
GetTextProgressStr(float percent
, int OutputSize
);
155 class PackageManagerText
: public PackageManager
158 virtual bool StatusChanged(std::string PackageName
,
159 unsigned int StepsDone
,
160 unsigned int TotalSteps
,
161 std::string HumanReadableAction
);
165 } // namespace Progress