]> git.saurik.com Git - apt.git/blob - apt-pkg/install-progress.h
050954bb5c74dc82158c6daddf56b97e5d8af366
[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 virtual void Start() {};
31 virtual void Stop() {};
32
33 virtual pid_t fork() {return fork(); };
34
35 virtual void Pulse() {};
36 virtual long GetPulseInterval() {
37 return 500000;
38 };
39
40 virtual bool StatusChanged(std::string PackageName,
41 unsigned int StepsDone,
42 unsigned int TotalSteps,
43 std::string HumanReadableAction) ;
44 virtual void Error(std::string PackageName,
45 unsigned int StepsDone,
46 unsigned int TotalSteps,
47 std::string ErrorMessage) {};
48 virtual void ConffilePrompt(std::string PackageName,
49 unsigned int StepsDone,
50 unsigned int TotalSteps,
51 std::string ConfMessage) {};
52 };
53
54 class PackageManagerProgressFd : public PackageManager
55 {
56 protected:
57 int OutStatusFd;
58 int StepsDone;
59 int StepsTotal;
60 void WriteToStatusFd(std::string msg);
61
62 public:
63 PackageManagerProgressFd(int progress_fd);
64
65 virtual void Start();
66 virtual void Stop();
67
68 virtual bool StatusChanged(std::string PackageName,
69 unsigned int StepsDone,
70 unsigned int TotalSteps,
71 std::string HumanReadableAction);
72 virtual void Error(std::string PackageName,
73 unsigned int StepsDone,
74 unsigned int TotalSteps,
75 std::string ErrorMessage);
76 virtual void ConffilePrompt(std::string PackageName,
77 unsigned int StepsDone,
78 unsigned int TotalSteps,
79 std::string ConfMessage);
80
81 };
82
83 class PackageManagerProgressDeb822Fd : public PackageManager
84 {
85 protected:
86 int OutStatusFd;
87 int StepsDone;
88 int StepsTotal;
89 void WriteToStatusFd(std::string msg);
90
91 public:
92 PackageManagerProgressDeb822Fd(int progress_fd);
93
94 virtual void Start();
95 virtual void Stop();
96
97 virtual bool StatusChanged(std::string PackageName,
98 unsigned int StepsDone,
99 unsigned int TotalSteps,
100 std::string HumanReadableAction);
101 virtual void Error(std::string PackageName,
102 unsigned int StepsDone,
103 unsigned int TotalSteps,
104 std::string ErrorMessage);
105 virtual void ConffilePrompt(std::string PackageName,
106 unsigned int StepsDone,
107 unsigned int TotalSteps,
108 std::string ConfMessage);
109 };
110
111 class PackageManagerFancy : public PackageManager
112 {
113 protected:
114 int nr_terminal_rows;
115 void SetupTerminalScrollArea(int nr_rows);
116
117 public:
118 PackageManagerFancy();
119 virtual void Start();
120 virtual void Stop();
121 virtual bool StatusChanged(std::string PackageName,
122 unsigned int StepsDone,
123 unsigned int TotalSteps,
124 std::string HumanReadableAction);
125 };
126
127 class PackageManagerText : public PackageManager
128 {
129 public:
130 virtual bool StatusChanged(std::string PackageName,
131 unsigned int StepsDone,
132 unsigned int TotalSteps,
133 std::string HumanReadableAction);
134 };
135
136
137 }; // namespace Progress
138 }; // namespace APT
139
140 #endif