use StartDpkg() in PackageManagerProgressDeb822Fd as well
[ntk/apt.git] / apt-pkg / install-progress.h
1 #ifndef PKGLIB_IPROGRESS_H
2 #define PKGLIB_IPROGRESS_H
3
4 #include <string>
5 #include <unistd.h>
6
7
8 namespace APT {
9 namespace Progress {
10
11 class PackageManager;
12 PackageManager* PackageManagerProgressFactory();
13
14 class PackageManager
15 {
16 private:
17 /** \brief dpointer placeholder */
18 void *d;
19
20 protected:
21 std::string progress_str;
22 float percentage;
23 int last_reported_progress;
24
25 public:
26 PackageManager()
27 : percentage(0.0), last_reported_progress(-1) {};
28 virtual ~PackageManager() {};
29
30 /* Global Start/Stop */
31 virtual void Start() {};
32 virtual void Stop() {};
33
34 /* When dpkg is invoked (may happen multiple times for each
35 * install/remove block
36 */
37 virtual void StartDpkg() {};
38
39 virtual pid_t fork() {return fork(); };
40
41 virtual void Pulse() {};
42 virtual long GetPulseInterval() {
43 return 500000;
44 };
45
46 virtual bool StatusChanged(std::string PackageName,
47 unsigned int StepsDone,
48 unsigned int TotalSteps,
49 std::string HumanReadableAction) ;
50 virtual void Error(std::string PackageName,
51 unsigned int StepsDone,
52 unsigned int TotalSteps,
53 std::string ErrorMessage) {};
54 virtual void ConffilePrompt(std::string PackageName,
55 unsigned int StepsDone,
56 unsigned int TotalSteps,
57 std::string ConfMessage) {};
58 };
59
60 class PackageManagerProgressFd : public PackageManager
61 {
62 protected:
63 int OutStatusFd;
64 int StepsDone;
65 int StepsTotal;
66 void WriteToStatusFd(std::string msg);
67
68 public:
69 PackageManagerProgressFd(int progress_fd);
70
71 virtual void StartDpkg();
72 virtual void Stop();
73
74 virtual bool StatusChanged(std::string PackageName,
75 unsigned int StepsDone,
76 unsigned int TotalSteps,
77 std::string HumanReadableAction);
78 virtual void Error(std::string PackageName,
79 unsigned int StepsDone,
80 unsigned int TotalSteps,
81 std::string ErrorMessage);
82 virtual void ConffilePrompt(std::string PackageName,
83 unsigned int StepsDone,
84 unsigned int TotalSteps,
85 std::string ConfMessage);
86
87 };
88
89 class PackageManagerProgressDeb822Fd : public PackageManager
90 {
91 protected:
92 int OutStatusFd;
93 int StepsDone;
94 int StepsTotal;
95 void WriteToStatusFd(std::string msg);
96
97 public:
98 PackageManagerProgressDeb822Fd(int progress_fd);
99
100 virtual void StartDpkg();
101 virtual void Stop();
102
103 virtual bool StatusChanged(std::string PackageName,
104 unsigned int StepsDone,
105 unsigned int TotalSteps,
106 std::string HumanReadableAction);
107 virtual void Error(std::string PackageName,
108 unsigned int StepsDone,
109 unsigned int TotalSteps,
110 std::string ErrorMessage);
111 virtual void ConffilePrompt(std::string PackageName,
112 unsigned int StepsDone,
113 unsigned int TotalSteps,
114 std::string ConfMessage);
115 };
116
117 class PackageManagerFancy : public PackageManager
118 {
119 protected:
120 int nr_terminal_rows;
121 void SetupTerminalScrollArea(int nr_rows);
122
123 public:
124 PackageManagerFancy();
125 virtual void Start();
126 virtual void Stop();
127 virtual bool StatusChanged(std::string PackageName,
128 unsigned int StepsDone,
129 unsigned int TotalSteps,
130 std::string HumanReadableAction);
131 };
132
133 class PackageManagerText : public PackageManager
134 {
135 public:
136 virtual bool StatusChanged(std::string PackageName,
137 unsigned int StepsDone,
138 unsigned int TotalSteps,
139 std::string HumanReadableAction);
140 };
141
142
143 }; // namespace Progress
144 }; // namespace APT
145
146 #endif