summaryrefslogtreecommitdiff
path: root/python/progress.h
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-04-07 11:44:59 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-04-07 11:44:59 +0000
commit7e76103c2b13d27f4a9987b1f9fca50504177268 (patch)
tree5690b514e2c52155a231bae2e578b40a14f5470b /python/progress.h
parenta567392950a174ccb85c7f6c5c4ad8de7c37773d (diff)
downloadpython-apt-7e76103c2b13d27f4a9987b1f9fca50504177268.tar.gz
* code cleanups, simple MediaChanged implemented
Diffstat (limited to 'python/progress.h')
-rw-r--r--python/progress.h33
1 files changed, 20 insertions, 13 deletions
diff --git a/python/progress.h b/python/progress.h
index 6ea0b16b..a39ae41a 100644
--- a/python/progress.h
+++ b/python/progress.h
@@ -13,34 +13,39 @@
#include <apt-pkg/acquire.h>
#include <Python.h>
-struct PyOpProgress : public OpProgress
-{
+class PyCallbackObj {
+ protected:
PyObject *callbackInst;
+ public:
void setCallbackInst(PyObject *o) {
+ Py_INCREF(o);
callbackInst = o;
}
- virtual void Update();
- virtual void Done();
+ bool RunSimpleCallback(const char *method, PyObject *arglist=NULL);
- PyOpProgress() : OpProgress(), callbackInst(0) {};
+ PyCallbackObj() : callbackInst(0) {};
+ ~PyCallbackObj() {Py_DECREF(callbackInst); };
};
-
-struct PyFetchProgress : public pkgAcquireStatus
+struct PyOpProgress : public OpProgress, public PyCallbackObj
{
- PyObject *callbackInst;
- void setCallbackInst(PyObject *o) {
- callbackInst = o;
- }
+ virtual void Update();
+ virtual void Done();
+ PyOpProgress() : OpProgress(), PyCallbackObj() {};
+};
- void updateStatus(pkgAcquire::ItemDesc & Itm, int status);
- // apt interface
+struct PyFetchProgress : public pkgAcquireStatus, public PyCallbackObj
+{
+ 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);
@@ -49,6 +54,8 @@ struct PyFetchProgress : public pkgAcquireStatus
virtual void Stop();
bool Pulse(pkgAcquire * Owner);
+ PyFetchProgress() : PyCallbackObj() {};
+
};