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