]> git.saurik.com Git - apt.git/blob - apt-pkg/iprogress.h
6519e9445f467c13b42a1616397154d41dcbf13b
[apt.git] / apt-pkg / iprogress.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 {
13 private:
14 /** \brief dpointer placeholder */
15 void *d;
16
17 protected:
18 std::string progress_str;
19 float percentage;
20 int last_reported_progress;
21
22 public:
23 PackageManager()
24 : percentage(0.0), last_reported_progress(0) {};
25 virtual ~PackageManager() {};
26
27 virtual void Started() {};
28 virtual void Finished() {};
29
30 virtual pid_t fork() {return fork(); };
31
32 virtual bool StatusChanged(std::string PackageName,
33 unsigned int StepsDone,
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
71 };
72
73 class PackageManagerFancy : public PackageManager
74 {
75 protected:
76 int nr_terminal_rows;
77 void SetupTerminalScrollArea(int nr_rows);
78
79 public:
80 PackageManagerFancy();
81 virtual void Started();
82 virtual void Finished();
83 virtual bool StatusChanged(std::string PackageName,
84 unsigned int StepsDone,
85 unsigned int TotalSteps,
86 std::string HumanReadableAction);
87 };
88
89 class PackageManagerText : public PackageManager
90 {
91 public:
92 virtual bool StatusChanged(std::string PackageName,
93 unsigned int StepsDone,
94 unsigned int TotalSteps,
95 std::string HumanReadableAction);
96 };
97
98
99 }; // namespace Progress
100 }; // namespace APT
101
102 #endif