restore ABI and prepare next ABI via #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
[ntk/apt.git] / apt-pkg / install-progress.h
CommitLineData
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
8namespace APT {
9namespace Progress {
10
bd5f39b3
MV
11 class PackageManager;
12 PackageManager* PackageManagerProgressFactory();
13
31f97d7b
MV
14 class PackageManager
15 {
16 private:
17 /** \brief dpointer placeholder */
18 void *d;
19
6c5ae8ed
MV
20 protected:
21 std::string progress_str;
22 float percentage;
23 int last_reported_progress;
24
31f97d7b 25 public:
e6ad8031 26 PackageManager()
65dbd5a1 27 : percentage(0.0), last_reported_progress(-1) {};
31f97d7b
MV
28 virtual ~PackageManager() {};
29
a22fdebf
MV
30 virtual void Start() {};
31 virtual void Stop() {};
e6ad8031
MV
32
33 virtual pid_t fork() {return fork(); };
ca5b2578
MV
34
35 virtual void Pulse() {};
36 virtual long GetPulseInterval() {
37 return 500000;
38 };
39
6c5ae8ed 40 virtual bool StatusChanged(std::string PackageName,
31f97d7b 41 unsigned int StepsDone,
e6ad8031
MV
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;
f9935b1c 60 void WriteToStatusFd(std::string msg);
e6ad8031
MV
61
62 public:
63 PackageManagerProgressFd(int progress_fd);
f9935b1c 64
a22fdebf
MV
65 virtual void Start();
66 virtual void Stop();
e6ad8031
MV
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
31f97d7b
MV
81 };
82
c7ea1eba
MV
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
31f97d7b
MV
111 class PackageManagerFancy : public PackageManager
112 {
113 protected:
31f97d7b 114 int nr_terminal_rows;
db78c60c
MV
115 void SetupTerminalScrollArea(int nr_rows);
116
31f97d7b
MV
117 public:
118 PackageManagerFancy();
a22fdebf
MV
119 virtual void Start();
120 virtual void Stop();
6c5ae8ed 121 virtual bool StatusChanged(std::string PackageName,
31f97d7b 122 unsigned int StepsDone,
e6ad8031
MV
123 unsigned int TotalSteps,
124 std::string HumanReadableAction);
31f97d7b
MV
125 };
126
127 class PackageManagerText : public PackageManager
128 {
31f97d7b 129 public:
6c5ae8ed 130 virtual bool StatusChanged(std::string PackageName,
31f97d7b 131 unsigned int StepsDone,
e6ad8031
MV
132 unsigned int TotalSteps,
133 std::string HumanReadableAction);
31f97d7b
MV
134 };
135
136
137}; // namespace Progress
138}; // namespace APT
139
140#endif