1 #ifndef PKGLIB_IPROGRESS_H
2 #define PKGLIB_IPROGRESS_H
13 PackageManager
* PackageManagerProgressFactory();
18 /** \brief dpointer placeholder */
22 std::string progress_str
;
24 int last_reported_progress
;
28 : percentage(0.0), last_reported_progress(-1) {};
29 virtual ~PackageManager() {};
31 /* Global Start/Stop */
32 virtual void Start(int /*child_pty*/=-1) {};
33 virtual void Stop() {};
35 /* When dpkg is invoked (may happen multiple times for each
36 * install/remove block
38 virtual void StartDpkg() {};
40 virtual pid_t
fork() {return fork(); };
42 virtual void Pulse() {};
43 virtual long GetPulseInterval() {
47 virtual bool StatusChanged(std::string PackageName
,
48 unsigned int StepsDone
,
49 unsigned int TotalSteps
,
50 std::string HumanReadableAction
);
51 virtual void Error(std::string
/*PackageName*/,
52 unsigned int /*StepsDone*/,
53 unsigned int /*TotalSteps*/,
54 std::string
/*ErrorMessage*/) {}
55 virtual void ConffilePrompt(std::string
/*PackageName*/,
56 unsigned int /*StepsDone*/,
57 unsigned int /*TotalSteps*/,
58 std::string
/*ConfMessage*/) {}
61 class PackageManagerProgressFd
: public PackageManager
67 void WriteToStatusFd(std::string msg
);
70 PackageManagerProgressFd(int progress_fd
);
72 virtual void StartDpkg();
75 virtual bool StatusChanged(std::string PackageName
,
76 unsigned int StepsDone
,
77 unsigned int TotalSteps
,
78 std::string HumanReadableAction
);
79 virtual void Error(std::string PackageName
,
80 unsigned int StepsDone
,
81 unsigned int TotalSteps
,
82 std::string ErrorMessage
);
83 virtual void ConffilePrompt(std::string PackageName
,
84 unsigned int StepsDone
,
85 unsigned int TotalSteps
,
86 std::string ConfMessage
);
90 class PackageManagerProgressDeb822Fd
: public PackageManager
96 void WriteToStatusFd(std::string msg
);
99 PackageManagerProgressDeb822Fd(int progress_fd
);
101 virtual void StartDpkg();
104 virtual bool StatusChanged(std::string PackageName
,
105 unsigned int StepsDone
,
106 unsigned int TotalSteps
,
107 std::string HumanReadableAction
);
108 virtual void Error(std::string PackageName
,
109 unsigned int StepsDone
,
110 unsigned int TotalSteps
,
111 std::string ErrorMessage
);
112 virtual void ConffilePrompt(std::string PackageName
,
113 unsigned int StepsDone
,
114 unsigned int TotalSteps
,
115 std::string ConfMessage
);
118 class PackageManagerFancy
: public PackageManager
121 static void staticSIGWINCH(int);
122 static std::vector
<PackageManagerFancy
*> instances
;
125 void SetupTerminalScrollArea(int nr_rows
);
126 void HandleSIGWINCH(int);
128 int GetNumberTerminalRows();
129 sighandler_t old_SIGWINCH
;
133 PackageManagerFancy();
134 ~PackageManagerFancy();
135 virtual void Start(int child_pty
=-1);
137 virtual bool StatusChanged(std::string PackageName
,
138 unsigned int StepsDone
,
139 unsigned int TotalSteps
,
140 std::string HumanReadableAction
);
143 class PackageManagerText
: public PackageManager
146 virtual bool StatusChanged(std::string PackageName
,
147 unsigned int StepsDone
,
148 unsigned int TotalSteps
,
149 std::string HumanReadableAction
);
153 } // namespace Progress