]> git.saurik.com Git - apt.git/blob - apt-pkg/iprogress.h
5584b39404bf8e7863827b3190a2f654c987072d
[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 void Pulse() {};
33 virtual long GetPulseInterval() {
34 return 500000;
35 };
36
37 virtual bool StatusChanged(std::string PackageName,
38 unsigned int StepsDone,
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 void WriteToStatusFd(std::string msg);
58
59 public:
60 PackageManagerProgressFd(int progress_fd);
61
62 // FIXME: rename to Start/Stop to match the pkgAcquireStatus
63 virtual void Started();
64 virtual void Finished();
65
66 virtual bool StatusChanged(std::string PackageName,
67 unsigned int StepsDone,
68 unsigned int TotalSteps,
69 std::string HumanReadableAction);
70 virtual void Error(std::string PackageName,
71 unsigned int StepsDone,
72 unsigned int TotalSteps,
73 std::string ErrorMessage);
74 virtual void ConffilePrompt(std::string PackageName,
75 unsigned int StepsDone,
76 unsigned int TotalSteps,
77 std::string ConfMessage);
78
79 };
80
81 class PackageManagerFancy : public PackageManager
82 {
83 protected:
84 int nr_terminal_rows;
85 void SetupTerminalScrollArea(int nr_rows);
86
87 public:
88 PackageManagerFancy();
89 virtual void Started();
90 virtual void Finished();
91 virtual bool StatusChanged(std::string PackageName,
92 unsigned int StepsDone,
93 unsigned int TotalSteps,
94 std::string HumanReadableAction);
95 };
96
97 class PackageManagerText : public PackageManager
98 {
99 public:
100 virtual bool StatusChanged(std::string PackageName,
101 unsigned int StepsDone,
102 unsigned int TotalSteps,
103 std::string HumanReadableAction);
104 };
105
106
107 }; // namespace Progress
108 }; // namespace APT
109
110 #endif