]> git.saurik.com Git - apt.git/blame - apt-pkg/install-progress.h
move install-progress.{cc,h} to apt-pkg
[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
31f97d7b
MV
11 class PackageManager
12 {
13 private:
14 /** \brief dpointer placeholder */
15 void *d;
16
6c5ae8ed
MV
17 protected:
18 std::string progress_str;
19 float percentage;
20 int last_reported_progress;
21
31f97d7b 22 public:
e6ad8031 23 PackageManager()
65dbd5a1 24 : percentage(0.0), last_reported_progress(-1) {};
31f97d7b
MV
25 virtual ~PackageManager() {};
26
a22fdebf
MV
27 virtual void Start() {};
28 virtual void Stop() {};
e6ad8031
MV
29
30 virtual pid_t fork() {return fork(); };
ca5b2578
MV
31
32 virtual void Pulse() {};
33 virtual long GetPulseInterval() {
34 return 500000;
35 };
36
6c5ae8ed 37 virtual bool StatusChanged(std::string PackageName,
31f97d7b 38 unsigned int StepsDone,
e6ad8031
MV
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;
f9935b1c 57 void WriteToStatusFd(std::string msg);
e6ad8031
MV
58
59 public:
60 PackageManagerProgressFd(int progress_fd);
f9935b1c 61
a22fdebf
MV
62 virtual void Start();
63 virtual void Stop();
e6ad8031
MV
64
65 virtual bool StatusChanged(std::string PackageName,
66 unsigned int StepsDone,
67 unsigned int TotalSteps,
68 std::string HumanReadableAction);
69 virtual void Error(std::string PackageName,
70 unsigned int StepsDone,
71 unsigned int TotalSteps,
72 std::string ErrorMessage);
73 virtual void ConffilePrompt(std::string PackageName,
74 unsigned int StepsDone,
75 unsigned int TotalSteps,
76 std::string ConfMessage);
77
31f97d7b
MV
78 };
79
c7ea1eba
MV
80 class PackageManagerProgressDeb822Fd : public PackageManager
81 {
82 protected:
83 int OutStatusFd;
84 int StepsDone;
85 int StepsTotal;
86 void WriteToStatusFd(std::string msg);
87
88 public:
89 PackageManagerProgressDeb822Fd(int progress_fd);
90
91 virtual void Start();
92 virtual void Stop();
93
94 virtual bool StatusChanged(std::string PackageName,
95 unsigned int StepsDone,
96 unsigned int TotalSteps,
97 std::string HumanReadableAction);
98 virtual void Error(std::string PackageName,
99 unsigned int StepsDone,
100 unsigned int TotalSteps,
101 std::string ErrorMessage);
102 virtual void ConffilePrompt(std::string PackageName,
103 unsigned int StepsDone,
104 unsigned int TotalSteps,
105 std::string ConfMessage);
106 };
107
31f97d7b
MV
108 class PackageManagerFancy : public PackageManager
109 {
110 protected:
31f97d7b 111 int nr_terminal_rows;
db78c60c
MV
112 void SetupTerminalScrollArea(int nr_rows);
113
31f97d7b
MV
114 public:
115 PackageManagerFancy();
a22fdebf
MV
116 virtual void Start();
117 virtual void Stop();
6c5ae8ed 118 virtual bool StatusChanged(std::string PackageName,
31f97d7b 119 unsigned int StepsDone,
e6ad8031
MV
120 unsigned int TotalSteps,
121 std::string HumanReadableAction);
31f97d7b
MV
122 };
123
124 class PackageManagerText : public PackageManager
125 {
31f97d7b 126 public:
6c5ae8ed 127 virtual bool StatusChanged(std::string PackageName,
31f97d7b 128 unsigned int StepsDone,
e6ad8031
MV
129 unsigned int TotalSteps,
130 std::string HumanReadableAction);
31f97d7b
MV
131 };
132
133
134}; // namespace Progress
135}; // namespace APT
136
137#endif