1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
// Description /*{{{*/
// $Id: progress.h,v 1.5 2003/06/03 03:03:23 mdz Exp $
/* ######################################################################
Progress - Wrapper for the progress related functions
##################################################################### */
#ifndef PROGRESS_H
#define PROGRESS_H
#include <apt-pkg/progress.h>
#include <apt-pkg/acquire.h>
#include <apt-pkg/packagemanager.h>
#include <apt-pkg/cdrom.h>
#include <Python.h>
typedef struct {
PyObject_HEAD
PyObject *op;
PyObject *subop;
#ifdef T_BOOL
char major_change;
#else
int major_change;
#endif
float percent;
} PyOpProgressObject;
typedef struct {
PyObject_HEAD
int total_steps;
} PyCdromProgressObject;
typedef struct {
PyObject_HEAD
double last_bytes;
double current_cps;
double current_bytes;
double total_bytes;
double fetched_bytes;
unsigned long elapsed_time;
unsigned long total_items;
unsigned long current_items;
} PyAcquireProgressObject;
class PyCallbackObj {
protected:
PyObject *callbackInst;
public:
void setCallbackInst(PyObject *o) {
Py_INCREF(o);
callbackInst = o;
}
bool RunSimpleCallback(const char *method, PyObject *arglist=NULL,
PyObject **result=NULL);
PyCallbackObj() : callbackInst(0) {};
~PyCallbackObj() {Py_DECREF(callbackInst); };
};
struct PyOpProgress : public OpProgress, public PyCallbackObj
{
virtual void Update();
virtual void Done();
PyOpProgress() : OpProgress(), PyCallbackObj() {};
};
struct PyFetchProgress : public pkgAcquireStatus, public PyCallbackObj
{
enum {
DLDone, DLQueued, DLFailed, DLHit, DLIgnored
};
void UpdateStatus(pkgAcquire::ItemDesc & Itm, int status);
virtual bool MediaChange(string Media, string Drive);
/* apt stuff */
virtual void IMSHit(pkgAcquire::ItemDesc &Itm);
virtual void Fetch(pkgAcquire::ItemDesc &Itm);
virtual void Done(pkgAcquire::ItemDesc &Itm);
virtual void Fail(pkgAcquire::ItemDesc &Itm);
virtual void Start();
virtual void Stop();
bool Pulse(pkgAcquire * Owner);
PyFetchProgress() : PyCallbackObj() {};
};
struct PyInstallProgress : public PyCallbackObj
{
void StartUpdate();
void UpdateInterface();
void FinishUpdate();
pkgPackageManager::OrderResult Run(pkgPackageManager *pm);
PyInstallProgress() : PyCallbackObj() {};
};
struct PyCdromProgress : public pkgCdromStatus, public PyCallbackObj
{
// update steps, will be called regularly as a "pulse"
virtual void Update(string text="", int current=0);
// ask for cdrom insert
virtual bool ChangeCdrom();
// ask for cdrom name
virtual bool AskCdromName(string &Name);
PyCdromProgress() : PyCallbackObj() {};
};
#endif
|