]> git.saurik.com Git - apt.git/blame - apt-pkg/install-progress.h
abstract version hash comparison a bit
[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>
e96e4e9c 6#include <signal.h>
23bd0977 7#include <vector>
31f97d7b
MV
8
9namespace APT {
10namespace Progress {
11
bd5f39b3
MV
12 class PackageManager;
13 PackageManager* PackageManagerProgressFactory();
14
31f97d7b
MV
15 class PackageManager
16 {
17 private:
18 /** \brief dpointer placeholder */
19 void *d;
20
6c5ae8ed
MV
21 protected:
22 std::string progress_str;
23 float percentage;
24 int last_reported_progress;
25
31f97d7b 26 public:
d3e8fbb3 27 PackageManager()
65dbd5a1 28 : percentage(0.0), last_reported_progress(-1) {};
31f97d7b
MV
29 virtual ~PackageManager() {};
30
e45c4617 31 /* Global Start/Stop */
65512241 32 virtual void Start(int /*child_pty*/=-1) {};
a22fdebf 33 virtual void Stop() {};
e6ad8031 34
d3e8fbb3
DK
35 /* When dpkg is invoked (may happen multiple times for each
36 * install/remove block
e45c4617
MV
37 */
38 virtual void StartDpkg() {};
39
e6ad8031 40 virtual pid_t fork() {return fork(); };
ca5b2578
MV
41
42 virtual void Pulse() {};
43 virtual long GetPulseInterval() {
44 return 500000;
45 };
46
d3e8fbb3 47 virtual bool StatusChanged(std::string PackageName,
31f97d7b 48 unsigned int StepsDone,
e6ad8031 49 unsigned int TotalSteps,
d3e8fbb3 50 std::string HumanReadableAction);
65512241
DK
51 virtual void Error(std::string /*PackageName*/,
52 unsigned int /*StepsDone*/,
53 unsigned int /*TotalSteps*/,
54 std::string /*ErrorMessage*/) {}
55 virtual void ConffilePrompt(std::string /*PackageName*/,
56 unsigned int /*StepsDone*/,
57 unsigned int /*TotalSteps*/,
58 std::string /*ConfMessage*/) {}
e6ad8031
MV
59 };
60
61 class PackageManagerProgressFd : public PackageManager
62 {
63 protected:
64 int OutStatusFd;
65 int StepsDone;
66 int StepsTotal;
f9935b1c 67 void WriteToStatusFd(std::string msg);
e6ad8031
MV
68
69 public:
70 PackageManagerProgressFd(int progress_fd);
f9935b1c 71
e45c4617 72 virtual void StartDpkg();
a22fdebf 73 virtual void Stop();
e6ad8031 74
d3e8fbb3 75 virtual bool StatusChanged(std::string PackageName,
e6ad8031
MV
76 unsigned int StepsDone,
77 unsigned int TotalSteps,
78 std::string HumanReadableAction);
d3e8fbb3 79 virtual void Error(std::string PackageName,
e6ad8031
MV
80 unsigned int StepsDone,
81 unsigned int TotalSteps,
82 std::string ErrorMessage);
83 virtual void ConffilePrompt(std::string PackageName,
84 unsigned int StepsDone,
85 unsigned int TotalSteps,
86 std::string ConfMessage);
87
31f97d7b
MV
88 };
89
c7ea1eba
MV
90 class PackageManagerProgressDeb822Fd : public PackageManager
91 {
92 protected:
93 int OutStatusFd;
94 int StepsDone;
95 int StepsTotal;
96 void WriteToStatusFd(std::string msg);
97
98 public:
99 PackageManagerProgressDeb822Fd(int progress_fd);
100
790d41f6 101 virtual void StartDpkg();
c7ea1eba
MV
102 virtual void Stop();
103
d3e8fbb3 104 virtual bool StatusChanged(std::string PackageName,
c7ea1eba
MV
105 unsigned int StepsDone,
106 unsigned int TotalSteps,
107 std::string HumanReadableAction);
d3e8fbb3 108 virtual void Error(std::string PackageName,
c7ea1eba
MV
109 unsigned int StepsDone,
110 unsigned int TotalSteps,
111 std::string ErrorMessage);
112 virtual void ConffilePrompt(std::string PackageName,
113 unsigned int StepsDone,
114 unsigned int TotalSteps,
115 std::string ConfMessage);
116 };
117
31f97d7b
MV
118 class PackageManagerFancy : public PackageManager
119 {
5ed88785
MV
120 private:
121 static void staticSIGWINCH(int);
122 static std::vector<PackageManagerFancy*> instances;
123
31f97d7b 124 protected:
5ed88785
MV
125 void SetupTerminalScrollArea(int nr_rows);
126 void HandleSIGWINCH(int);
127
128 int GetNumberTerminalRows();
e96e4e9c 129 sighandler_t old_SIGWINCH;
5ed88785 130 int child_pty;
db78c60c 131
31f97d7b
MV
132 public:
133 PackageManagerFancy();
e96e4e9c 134 ~PackageManagerFancy();
4754718a 135 virtual void Start(int child_pty=-1);
a22fdebf 136 virtual void Stop();
d3e8fbb3 137 virtual bool StatusChanged(std::string PackageName,
31f97d7b 138 unsigned int StepsDone,
e6ad8031
MV
139 unsigned int TotalSteps,
140 std::string HumanReadableAction);
31f97d7b
MV
141 };
142
143 class PackageManagerText : public PackageManager
144 {
31f97d7b 145 public:
d3e8fbb3 146 virtual bool StatusChanged(std::string PackageName,
31f97d7b 147 unsigned int StepsDone,
e6ad8031
MV
148 unsigned int TotalSteps,
149 std::string HumanReadableAction);
31f97d7b
MV
150 };
151
152
d3e8fbb3
DK
153} // namespace Progress
154} // namespace APT
31f97d7b
MV
155
156#endif