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
68 void WriteToStatusFd(std::string msg
);
71 PackageManagerProgressFd(int progress_fd
);
73 virtual void StartDpkg();
76 virtual bool StatusChanged(std::string PackageName
,
77 unsigned int StepsDone
,
78 unsigned int TotalSteps
,
79 std::string HumanReadableAction
);
80 virtual void Error(std::string PackageName
,
81 unsigned int StepsDone
,
82 unsigned int TotalSteps
,
83 std::string ErrorMessage
);
84 virtual void ConffilePrompt(std::string PackageName
,
85 unsigned int StepsDone
,
86 unsigned int TotalSteps
,
87 std::string ConfMessage
);
91 class PackageManagerProgressDeb822Fd
: public PackageManager
97 void WriteToStatusFd(std::string msg
);
100 PackageManagerProgressDeb822Fd(int progress_fd
);
102 virtual void StartDpkg();
105 virtual bool StatusChanged(std::string PackageName
,
106 unsigned int StepsDone
,
107 unsigned int TotalSteps
,
108 std::string HumanReadableAction
);
109 virtual void Error(std::string PackageName
,
110 unsigned int StepsDone
,
111 unsigned int TotalSteps
,
112 std::string ErrorMessage
);
113 virtual void ConffilePrompt(std::string PackageName
,
114 unsigned int StepsDone
,
115 unsigned int TotalSteps
,
116 std::string ConfMessage
);
119 class PackageManagerFancy
: public PackageManager
122 APT_HIDDEN
static void staticSIGWINCH(int);
123 static std::vector
<PackageManagerFancy
*> instances
;
124 APT_HIDDEN
bool DrawStatusLine();
127 void SetupTerminalScrollArea(int nr_rows
);
128 void HandleSIGWINCH(int);
134 TermSize
GetTerminalSize();
136 sighandler_t old_SIGWINCH
;
140 PackageManagerFancy();
141 ~PackageManagerFancy();
142 virtual void Start(int child_pty
=-1);
144 virtual bool StatusChanged(std::string PackageName
,
145 unsigned int StepsDone
,
146 unsigned int TotalSteps
,
147 std::string HumanReadableAction
);
149 // return a progress bar of the given size for the given progress
150 // percent between 0.0 and 1.0 in the form "[####...]"
151 static std::string
GetTextProgressStr(float percent
, int OutputSize
);
154 class PackageManagerText
: public PackageManager
157 virtual bool StatusChanged(std::string PackageName
,
158 unsigned int StepsDone
,
159 unsigned int TotalSteps
,
160 std::string HumanReadableAction
);
164 } // namespace Progress