]>
Commit | Line | Data |
---|---|---|
0118833a AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
6b1ff003 | 3 | // $Id: acquire-item.h,v 1.17 1999/03/27 03:02:38 jgg Exp $ |
0118833a AL |
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 | |
17caf1b1 | 10 | register all the URI's they wish to fetch at the initial moment. |
0118833a AL |
11 | |
12 | Two item classes are provided to provide functionality for downloading | |
13 | of Index files and downloading of Packages. | |
14 | ||
b185acc2 | 15 | A Archive class is provided for downloading .deb files. It does Md5 |
17caf1b1 | 16 | checking and source location as well as a retry algorithm. |
b185acc2 | 17 | |
0118833a AL |
18 | ##################################################################### */ |
19 | /*}}}*/ | |
20 | #ifndef PKGLIB_ACQUIRE_ITEM_H | |
21 | #define PKGLIB_ACQUIRE_ITEM_H | |
22 | ||
23 | #include <apt-pkg/acquire.h> | |
24 | #include <apt-pkg/sourcelist.h> | |
03e39e59 | 25 | #include <apt-pkg/pkgrecords.h> |
0118833a AL |
26 | |
27 | #ifdef __GNUG__ | |
28 | #pragma interface "apt-pkg/acquire-item.h" | |
29 | #endif | |
30 | ||
31 | // Item to acquire | |
32 | class pkgAcquire::Item | |
33 | { | |
34 | protected: | |
35 | ||
17caf1b1 | 36 | // Some private helper methods for registering URIs |
0118833a | 37 | pkgAcquire *Owner; |
8267fe24 AL |
38 | inline void QueueURI(ItemDesc &Item) |
39 | {Owner->Enqueue(Item);}; | |
681d76d0 | 40 | inline void Dequeue() {Owner->Dequeue(this);}; |
0118833a | 41 | |
17caf1b1 | 42 | // Safe rename function with timestamp preservation |
8b89e57f AL |
43 | void Rename(string From,string To); |
44 | ||
0118833a AL |
45 | public: |
46 | ||
c88edf1d AL |
47 | // State of the item |
48 | enum {StatIdle, StatFetching, StatDone, StatError} Status; | |
49 | string ErrorText; | |
8267fe24 | 50 | unsigned long FileSize; |
6b1ff003 | 51 | unsigned long PartialSize; |
b98f2859 AL |
52 | char *Mode; |
53 | unsigned long ID; | |
8267fe24 | 54 | bool Complete; |
a6568219 | 55 | bool Local; |
30e1eab5 | 56 | |
0a8a80e5 | 57 | // Number of queues we are inserted into |
0118833a | 58 | unsigned int QueueCounter; |
0118833a | 59 | |
0a8a80e5 AL |
60 | // File to write the fetch into |
61 | string DestFile; | |
7d8afa39 | 62 | |
17caf1b1 | 63 | // Action members invoked by the worker |
7d8afa39 | 64 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); |
c88edf1d | 65 | virtual void Done(string Message,unsigned long Size,string Md5Hash); |
8267fe24 | 66 | virtual void Start(string Message,unsigned long Size); |
17caf1b1 AL |
67 | virtual string Custom600Headers() {return string();}; |
68 | ||
69 | // Inquire functions | |
f7a08e33 | 70 | virtual string MD5Sum() {return string();}; |
30e1eab5 | 71 | virtual string Describe() = 0; |
17caf1b1 | 72 | |
0118833a AL |
73 | Item(pkgAcquire *Owner); |
74 | virtual ~Item(); | |
75 | }; | |
76 | ||
77 | // Item class for index files | |
78 | class pkgAcqIndex : public pkgAcquire::Item | |
79 | { | |
80 | protected: | |
81 | ||
82 | const pkgSourceList::Item *Location; | |
8b89e57f | 83 | bool Decompression; |
bfd22fc0 | 84 | bool Erase; |
8267fe24 | 85 | pkgAcquire::ItemDesc Desc; |
0118833a AL |
86 | |
87 | public: | |
88 | ||
17caf1b1 | 89 | // Specialized action members |
8b89e57f | 90 | virtual void Done(string Message,unsigned long Size,string Md5Hash); |
0a8a80e5 | 91 | virtual string Custom600Headers(); |
30e1eab5 | 92 | virtual string Describe(); |
0118833a AL |
93 | |
94 | pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location); | |
95 | }; | |
96 | ||
97 | // Item class for index files | |
98 | class pkgAcqIndexRel : public pkgAcquire::Item | |
99 | { | |
100 | protected: | |
101 | ||
102 | const pkgSourceList::Item *Location; | |
8267fe24 | 103 | pkgAcquire::ItemDesc Desc; |
0118833a AL |
104 | |
105 | public: | |
106 | ||
17caf1b1 | 107 | // Specialized action members |
681d76d0 | 108 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); |
8b89e57f | 109 | virtual void Done(string Message,unsigned long Size,string Md5Hash); |
0a8a80e5 | 110 | virtual string Custom600Headers(); |
30e1eab5 | 111 | virtual string Describe(); |
0a8a80e5 | 112 | |
0118833a AL |
113 | pkgAcqIndexRel(pkgAcquire *Owner,const pkgSourceList::Item *Location); |
114 | }; | |
115 | ||
03e39e59 AL |
116 | // Item class for archive files |
117 | class pkgAcqArchive : public pkgAcquire::Item | |
118 | { | |
119 | protected: | |
120 | ||
17caf1b1 | 121 | // State information for the retry mechanism |
03e39e59 AL |
122 | pkgCache::VerIterator Version; |
123 | pkgAcquire::ItemDesc Desc; | |
124 | pkgSourceList *Sources; | |
125 | pkgRecords *Recs; | |
126 | string MD5; | |
30e1eab5 | 127 | string &StoreFilename; |
b185acc2 | 128 | pkgCache::VerFileIterator Vf; |
7d8afa39 | 129 | unsigned int Retries; |
17caf1b1 AL |
130 | |
131 | // Queue the next available file for download. | |
b185acc2 | 132 | bool QueueNext(); |
03e39e59 AL |
133 | |
134 | public: | |
135 | ||
17caf1b1 | 136 | // Specialized action members |
7d8afa39 | 137 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); |
03e39e59 | 138 | virtual void Done(string Message,unsigned long Size,string Md5Hash); |
30e1eab5 | 139 | virtual string Describe(); |
17caf1b1 | 140 | virtual string MD5Sum() {return MD5;}; |
03e39e59 AL |
141 | |
142 | pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, | |
30e1eab5 AL |
143 | pkgRecords *Recs,pkgCache::VerIterator const &Version, |
144 | string &StoreFilename); | |
03e39e59 AL |
145 | }; |
146 | ||
0118833a | 147 | #endif |