[280] | 1 | // helper code for the swig generated bindings |
---|
| 2 | |
---|
| 3 | #include<apt-pkg/configuration.h> |
---|
| 4 | #include<apt-pkg/init.h> |
---|
| 5 | #include<apt-pkg/progress.h> |
---|
| 6 | #include<apt-pkg/acquire.h> |
---|
| 7 | #include "rinstallprogress.h" |
---|
| 8 | |
---|
| 9 | bool RInitSystem(); |
---|
| 10 | |
---|
| 11 | class SwigOpProgress : public OpProgress { |
---|
| 12 | protected: |
---|
| 13 | virtual void Update() { UpdateStatus(Percent); }; |
---|
| 14 | public: |
---|
| 15 | virtual void UpdateStatus(float p) {}; |
---|
| 16 | virtual void Done() {}; |
---|
| 17 | }; |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | class SwigInstallProgress : public RInstallProgress { |
---|
| 21 | public: |
---|
| 22 | virtual void startUpdate() { |
---|
| 23 | }; |
---|
| 24 | virtual void updateInterface() { |
---|
| 25 | }; |
---|
| 26 | virtual void finishUpdate() { |
---|
| 27 | }; |
---|
| 28 | // get a str feed to the user with the result of the install run |
---|
| 29 | virtual const char* getResultStr(pkgPackageManager::OrderResult r) { |
---|
| 30 | RInstallProgress::getResultStr(r); |
---|
| 31 | }; |
---|
| 32 | virtual pkgPackageManager::OrderResult start(RPackageManager *pm, |
---|
| 33 | int numPackages = 0, |
---|
| 34 | int numPackagesTotal = 0) |
---|
| 35 | { |
---|
| 36 | return RInstallProgress::start(pm,numPackages,numPackagesTotal); |
---|
| 37 | }; |
---|
| 38 | }; |
---|
| 39 | |
---|
| 40 | class pkgAcquire; |
---|
| 41 | class pkgAcquireStatus; |
---|
| 42 | class Item; |
---|
| 43 | struct ItemDesc |
---|
| 44 | { |
---|
| 45 | string URI; |
---|
| 46 | string Description; |
---|
| 47 | string ShortDesc; |
---|
| 48 | Item *Owner; |
---|
| 49 | }; |
---|
| 50 | |
---|
| 51 | class SwigAcquireStatus : public pkgAcquireStatus |
---|
| 52 | { |
---|
| 53 | protected: |
---|
| 54 | virtual bool Pulse(pkgAcquire *Owner) { |
---|
| 55 | pkgAcquireStatus::Pulse(Owner); |
---|
| 56 | UpdatePulse(FetchedBytes, CurrentCPS, CurrentItems); |
---|
| 57 | }; |
---|
| 58 | public: |
---|
| 59 | // Called by items when they have finished a real download |
---|
| 60 | virtual void Fetched(unsigned long Size,unsigned long ResumePoint) { |
---|
| 61 | pkgAcquireStatus::Fetched(Size, ResumePoint); |
---|
| 62 | }; |
---|
| 63 | |
---|
| 64 | // Called to change media |
---|
| 65 | virtual bool MediaChange(string Media,string Drive) = 0; |
---|
| 66 | |
---|
| 67 | // Each of these is called by the workers when an event occures |
---|
| 68 | virtual void IMSHit(ItemDesc &/*Itm*/) {}; |
---|
| 69 | virtual void Fetch(ItemDesc &/*Itm*/) {}; |
---|
| 70 | virtual void Done(ItemDesc &/*Itm*/) {}; |
---|
| 71 | virtual void Fail(ItemDesc &/*Itm*/) {}; |
---|
| 72 | virtual void UpdatePulse(double FetchedBytes, double CurrentCPS, unsigned long CurrentItems) {}; |
---|
| 73 | virtual void Start() { |
---|
| 74 | pkgAcquireStatus::Start(); |
---|
| 75 | }; |
---|
| 76 | virtual void Stop() { |
---|
| 77 | pkgAcquireStatus::Stop(); |
---|
| 78 | }; |
---|
| 79 | |
---|
| 80 | }; |
---|