| 1 | // -*- mode: cpp; mode: fold -*- |
| 2 | // Description /*{{{*/ |
| 3 | // $Id: acquire-item.h,v 1.5 1998/11/05 07:21:36 jgg Exp $ |
| 4 | /* ###################################################################### |
| 5 | |
| 6 | Acquire Item - Item to acquire |
| 7 | |
| 8 | When an item is instantiated it will add it self to the local list in |
| 9 | the Owner Acquire class. Derived classes will then call QueueURI to |
| 10 | register all the URI's they wish to fetch for at the initial moment. |
| 11 | |
| 12 | Two item classes are provided to provide functionality for downloading |
| 13 | of Index files and downloading of Packages. |
| 14 | |
| 15 | ##################################################################### */ |
| 16 | /*}}}*/ |
| 17 | #ifndef PKGLIB_ACQUIRE_ITEM_H |
| 18 | #define PKGLIB_ACQUIRE_ITEM_H |
| 19 | |
| 20 | #include <apt-pkg/acquire.h> |
| 21 | #include <apt-pkg/sourcelist.h> |
| 22 | |
| 23 | #ifdef __GNUG__ |
| 24 | #pragma interface "apt-pkg/acquire-item.h" |
| 25 | #endif |
| 26 | |
| 27 | // Item to acquire |
| 28 | class pkgAcquire::Item |
| 29 | { |
| 30 | protected: |
| 31 | |
| 32 | pkgAcquire *Owner; |
| 33 | inline void QueueURI(string URI,string Description) |
| 34 | {Owner->Enqueue(this,URI,Description);}; |
| 35 | |
| 36 | void Rename(string From,string To); |
| 37 | |
| 38 | public: |
| 39 | |
| 40 | // State of the item |
| 41 | enum {StatIdle, StatFetching, StatDone, StatError} Status; |
| 42 | string ErrorText; |
| 43 | |
| 44 | // Number of queues we are inserted into |
| 45 | unsigned int QueueCounter; |
| 46 | |
| 47 | // File to write the fetch into |
| 48 | string DestFile; |
| 49 | |
| 50 | virtual void Failed(string Message); |
| 51 | virtual void Done(string Message,unsigned long Size,string Md5Hash); |
| 52 | |
| 53 | virtual string Custom600Headers() {return string();}; |
| 54 | |
| 55 | Item(pkgAcquire *Owner); |
| 56 | virtual ~Item(); |
| 57 | }; |
| 58 | |
| 59 | // Item class for index files |
| 60 | class pkgAcqIndex : public pkgAcquire::Item |
| 61 | { |
| 62 | protected: |
| 63 | |
| 64 | const pkgSourceList::Item *Location; |
| 65 | bool Decompression; |
| 66 | bool Erase; |
| 67 | |
| 68 | public: |
| 69 | |
| 70 | virtual void Done(string Message,unsigned long Size,string Md5Hash); |
| 71 | virtual string Custom600Headers(); |
| 72 | |
| 73 | pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location); |
| 74 | }; |
| 75 | |
| 76 | // Item class for index files |
| 77 | class pkgAcqIndexRel : public pkgAcquire::Item |
| 78 | { |
| 79 | protected: |
| 80 | |
| 81 | const pkgSourceList::Item *Location; |
| 82 | |
| 83 | public: |
| 84 | |
| 85 | virtual void Done(string Message,unsigned long Size,string Md5Hash); |
| 86 | virtual string Custom600Headers(); |
| 87 | |
| 88 | pkgAcqIndexRel(pkgAcquire *Owner,const pkgSourceList::Item *Location); |
| 89 | }; |
| 90 | |
| 91 | #endif |