]>
Commit | Line | Data |
---|---|---|
31f97d7b | 1 | #ifndef PKGLIB_IPROGRESS_H |
e6ad8031 | 2 | #define PKGLIB_IPROGRESS_H |
31f97d7b | 3 | |
e6ad8031 MV |
4 | #include <string> |
5 | #include <unistd.h> | |
31f97d7b | 6 | |
31f97d7b MV |
7 | |
8 | namespace APT { | |
9 | namespace Progress { | |
10 | ||
31f97d7b MV |
11 | class PackageManager |
12 | { | |
13 | private: | |
14 | /** \brief dpointer placeholder */ | |
15 | void *d; | |
16 | ||
6c5ae8ed MV |
17 | protected: |
18 | std::string progress_str; | |
19 | float percentage; | |
20 | int last_reported_progress; | |
21 | ||
31f97d7b | 22 | public: |
e6ad8031 MV |
23 | PackageManager() |
24 | : percentage(0.0), last_reported_progress(0) {}; | |
31f97d7b MV |
25 | virtual ~PackageManager() {}; |
26 | ||
27 | virtual void Started() {}; | |
28 | virtual void Finished() {}; | |
e6ad8031 MV |
29 | |
30 | virtual pid_t fork() {return fork(); }; | |
31f97d7b | 31 | |
6c5ae8ed | 32 | virtual bool StatusChanged(std::string PackageName, |
31f97d7b | 33 | unsigned int StepsDone, |
e6ad8031 MV |
34 | unsigned int TotalSteps, |
35 | std::string HumanReadableAction) ; | |
36 | virtual void Error(std::string PackageName, | |
37 | unsigned int StepsDone, | |
38 | unsigned int TotalSteps, | |
39 | std::string ErrorMessage) {}; | |
40 | virtual void ConffilePrompt(std::string PackageName, | |
41 | unsigned int StepsDone, | |
42 | unsigned int TotalSteps, | |
43 | std::string ConfMessage) {}; | |
44 | }; | |
45 | ||
46 | class PackageManagerProgressFd : public PackageManager | |
47 | { | |
48 | protected: | |
49 | int OutStatusFd; | |
50 | int StepsDone; | |
51 | int StepsTotal; | |
52 | ||
53 | public: | |
54 | PackageManagerProgressFd(int progress_fd); | |
55 | virtual void Started(); | |
56 | virtual void Finished(); | |
57 | ||
58 | virtual bool StatusChanged(std::string PackageName, | |
59 | unsigned int StepsDone, | |
60 | unsigned int TotalSteps, | |
61 | std::string HumanReadableAction); | |
62 | virtual void Error(std::string PackageName, | |
63 | unsigned int StepsDone, | |
64 | unsigned int TotalSteps, | |
65 | std::string ErrorMessage); | |
66 | virtual void ConffilePrompt(std::string PackageName, | |
67 | unsigned int StepsDone, | |
68 | unsigned int TotalSteps, | |
69 | std::string ConfMessage); | |
70 | ||
31f97d7b MV |
71 | }; |
72 | ||
73 | class PackageManagerFancy : public PackageManager | |
74 | { | |
75 | protected: | |
31f97d7b | 76 | int nr_terminal_rows; |
db78c60c MV |
77 | void SetupTerminalScrollArea(int nr_rows); |
78 | ||
31f97d7b MV |
79 | public: |
80 | PackageManagerFancy(); | |
81 | virtual void Started(); | |
82 | virtual void Finished(); | |
6c5ae8ed | 83 | virtual bool StatusChanged(std::string PackageName, |
31f97d7b | 84 | unsigned int StepsDone, |
e6ad8031 MV |
85 | unsigned int TotalSteps, |
86 | std::string HumanReadableAction); | |
31f97d7b MV |
87 | }; |
88 | ||
89 | class PackageManagerText : public PackageManager | |
90 | { | |
31f97d7b | 91 | public: |
6c5ae8ed | 92 | virtual bool StatusChanged(std::string PackageName, |
31f97d7b | 93 | unsigned int StepsDone, |
e6ad8031 MV |
94 | unsigned int TotalSteps, |
95 | std::string HumanReadableAction); | |
31f97d7b MV |
96 | }; |
97 | ||
98 | ||
99 | }; // namespace Progress | |
100 | }; // namespace APT | |
101 | ||
102 | #endif |