]>
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(); }; | |
ca5b2578 MV |
31 | |
32 | virtual void Pulse() {}; | |
33 | virtual long GetPulseInterval() { | |
34 | return 500000; | |
35 | }; | |
36 | ||
6c5ae8ed | 37 | virtual bool StatusChanged(std::string PackageName, |
31f97d7b | 38 | unsigned int StepsDone, |
e6ad8031 MV |
39 | unsigned int TotalSteps, |
40 | std::string HumanReadableAction) ; | |
41 | virtual void Error(std::string PackageName, | |
42 | unsigned int StepsDone, | |
43 | unsigned int TotalSteps, | |
44 | std::string ErrorMessage) {}; | |
45 | virtual void ConffilePrompt(std::string PackageName, | |
46 | unsigned int StepsDone, | |
47 | unsigned int TotalSteps, | |
48 | std::string ConfMessage) {}; | |
49 | }; | |
50 | ||
51 | class PackageManagerProgressFd : public PackageManager | |
52 | { | |
53 | protected: | |
54 | int OutStatusFd; | |
55 | int StepsDone; | |
56 | int StepsTotal; | |
57 | ||
58 | public: | |
59 | PackageManagerProgressFd(int progress_fd); | |
60 | virtual void Started(); | |
61 | virtual void Finished(); | |
62 | ||
63 | virtual bool StatusChanged(std::string PackageName, | |
64 | unsigned int StepsDone, | |
65 | unsigned int TotalSteps, | |
66 | std::string HumanReadableAction); | |
67 | virtual void Error(std::string PackageName, | |
68 | unsigned int StepsDone, | |
69 | unsigned int TotalSteps, | |
70 | std::string ErrorMessage); | |
71 | virtual void ConffilePrompt(std::string PackageName, | |
72 | unsigned int StepsDone, | |
73 | unsigned int TotalSteps, | |
74 | std::string ConfMessage); | |
75 | ||
31f97d7b MV |
76 | }; |
77 | ||
78 | class PackageManagerFancy : public PackageManager | |
79 | { | |
80 | protected: | |
31f97d7b | 81 | int nr_terminal_rows; |
db78c60c MV |
82 | void SetupTerminalScrollArea(int nr_rows); |
83 | ||
31f97d7b MV |
84 | public: |
85 | PackageManagerFancy(); | |
86 | virtual void Started(); | |
87 | virtual void Finished(); | |
6c5ae8ed | 88 | virtual bool StatusChanged(std::string PackageName, |
31f97d7b | 89 | unsigned int StepsDone, |
e6ad8031 MV |
90 | unsigned int TotalSteps, |
91 | std::string HumanReadableAction); | |
31f97d7b MV |
92 | }; |
93 | ||
94 | class PackageManagerText : public PackageManager | |
95 | { | |
31f97d7b | 96 | public: |
6c5ae8ed | 97 | virtual bool StatusChanged(std::string PackageName, |
31f97d7b | 98 | unsigned int StepsDone, |
e6ad8031 MV |
99 | unsigned int TotalSteps, |
100 | std::string HumanReadableAction); | |
31f97d7b MV |
101 | }; |
102 | ||
103 | ||
104 | }; // namespace Progress | |
105 | }; // namespace APT | |
106 | ||
107 | #endif |