]>
Commit | Line | Data |
---|---|---|
0118833a AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
b3d44315 | 3 | // $Id: acquire-item.h,v 1.26.2.3 2004/01/02 18:51:00 mdz 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> | |
b2e465d6 | 24 | #include <apt-pkg/indexfile.h> |
b3d44315 MV |
25 | #include <apt-pkg/vendor.h> |
26 | #include <apt-pkg/sourcelist.h> | |
03e39e59 | 27 | #include <apt-pkg/pkgrecords.h> |
b3d44315 | 28 | #include <apt-pkg/indexrecords.h> |
0118833a AL |
29 | |
30 | #ifdef __GNUG__ | |
31 | #pragma interface "apt-pkg/acquire-item.h" | |
32 | #endif | |
33 | ||
34 | // Item to acquire | |
35 | class pkgAcquire::Item | |
36 | { | |
37 | protected: | |
38 | ||
17caf1b1 | 39 | // Some private helper methods for registering URIs |
0118833a | 40 | pkgAcquire *Owner; |
8267fe24 AL |
41 | inline void QueueURI(ItemDesc &Item) |
42 | {Owner->Enqueue(Item);}; | |
681d76d0 | 43 | inline void Dequeue() {Owner->Dequeue(this);}; |
0118833a | 44 | |
17caf1b1 | 45 | // Safe rename function with timestamp preservation |
8b89e57f AL |
46 | void Rename(string From,string To); |
47 | ||
0118833a AL |
48 | public: |
49 | ||
c88edf1d | 50 | // State of the item |
7e5f33eb MV |
51 | enum {StatIdle, StatFetching, StatDone, StatError, |
52 | StatAuthError, StatTransientNetworkError} Status; | |
c88edf1d | 53 | string ErrorText; |
8267fe24 | 54 | unsigned long FileSize; |
6b1ff003 | 55 | unsigned long PartialSize; |
b2e465d6 | 56 | const char *Mode; |
b98f2859 | 57 | unsigned long ID; |
8267fe24 | 58 | bool Complete; |
a6568219 | 59 | bool Local; |
30e1eab5 | 60 | |
0a8a80e5 | 61 | // Number of queues we are inserted into |
0118833a | 62 | unsigned int QueueCounter; |
0118833a | 63 | |
0a8a80e5 AL |
64 | // File to write the fetch into |
65 | string DestFile; | |
7d8afa39 | 66 | |
17caf1b1 | 67 | // Action members invoked by the worker |
7d8afa39 | 68 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); |
459681d3 AL |
69 | virtual void Done(string Message,unsigned long Size,string Md5Hash, |
70 | pkgAcquire::MethodConfig *Cnf); | |
8267fe24 | 71 | virtual void Start(string Message,unsigned long Size); |
17caf1b1 | 72 | virtual string Custom600Headers() {return string();}; |
36375005 | 73 | virtual string DescURI() = 0; |
b3d44315 | 74 | virtual string ShortDesc() {return DescURI();} |
ab559b35 | 75 | virtual void Finished() {}; |
17caf1b1 AL |
76 | |
77 | // Inquire functions | |
f7a08e33 | 78 | virtual string MD5Sum() {return string();}; |
c5ccf175 | 79 | pkgAcquire *GetOwner() {return Owner;}; |
b3d44315 | 80 | virtual bool IsTrusted() {return false;}; |
c5ccf175 | 81 | |
0118833a AL |
82 | Item(pkgAcquire *Owner); |
83 | virtual ~Item(); | |
84 | }; | |
85 | ||
86 | // Item class for index files | |
87 | class pkgAcqIndex : public pkgAcquire::Item | |
88 | { | |
89 | protected: | |
90 | ||
8b89e57f | 91 | bool Decompression; |
bfd22fc0 | 92 | bool Erase; |
8267fe24 | 93 | pkgAcquire::ItemDesc Desc; |
b2e465d6 | 94 | string RealURI; |
b3d44315 | 95 | string ExpectedMD5; |
13e8426f MV |
96 | string CompressionExtension; |
97 | ||
0118833a AL |
98 | public: |
99 | ||
17caf1b1 | 100 | // Specialized action members |
debc84b2 | 101 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); |
459681d3 AL |
102 | virtual void Done(string Message,unsigned long Size,string Md5Hash, |
103 | pkgAcquire::MethodConfig *Cnf); | |
0a8a80e5 | 104 | virtual string Custom600Headers(); |
13e8426f | 105 | virtual string DescURI() {return RealURI + CompressionExtension;}; |
0118833a | 106 | |
b2e465d6 | 107 | pkgAcqIndex(pkgAcquire *Owner,string URI,string URIDesc, |
b3d44315 | 108 | string ShortDesct, string ExpectedMD5, string compressExt=""); |
0118833a AL |
109 | }; |
110 | ||
b3d44315 MV |
111 | struct IndexTarget |
112 | { | |
113 | string URI; | |
114 | string Description; | |
115 | string ShortDesc; | |
116 | string MetaKey; | |
117 | }; | |
118 | ||
119 | // Item class for index signatures | |
120 | class pkgAcqMetaSig : public pkgAcquire::Item | |
0118833a AL |
121 | { |
122 | protected: | |
123 | ||
8267fe24 | 124 | pkgAcquire::ItemDesc Desc; |
b3d44315 MV |
125 | string RealURI,MetaIndexURI,MetaIndexURIDesc,MetaIndexShortDesc; |
126 | indexRecords* MetaIndexParser; | |
127 | const vector<struct IndexTarget*>* IndexTargets; | |
128 | ||
0118833a AL |
129 | public: |
130 | ||
17caf1b1 | 131 | // Specialized action members |
681d76d0 | 132 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); |
459681d3 | 133 | virtual void Done(string Message,unsigned long Size,string Md5Hash, |
b3d44315 | 134 | pkgAcquire::MethodConfig *Cnf); |
0a8a80e5 | 135 | virtual string Custom600Headers(); |
b3d44315 MV |
136 | virtual string DescURI() {return RealURI; }; |
137 | ||
138 | pkgAcqMetaSig(pkgAcquire *Owner,string URI,string URIDesc, string ShortDesc, | |
139 | string MetaIndexURI, string MetaIndexURIDesc, string MetaIndexShortDesc, | |
140 | const vector<struct IndexTarget*>* IndexTargets, | |
141 | indexRecords* MetaIndexParser); | |
142 | }; | |
143 | ||
144 | // Item class for index signatures | |
145 | class pkgAcqMetaIndex : public pkgAcquire::Item | |
146 | { | |
147 | protected: | |
148 | ||
149 | pkgAcquire::ItemDesc Desc; | |
150 | string RealURI; // FIXME: is this redundant w/ Desc.URI? | |
151 | string SigFile; | |
152 | const vector<struct IndexTarget*>* IndexTargets; | |
153 | indexRecords* MetaIndexParser; | |
154 | bool AuthPass; | |
ce424cd4 MV |
155 | // required to deal gracefully with problems caused by incorrect ims hits |
156 | bool IMSHit; | |
b3d44315 | 157 | |
ce424cd4 | 158 | bool VerifyVendor(string Message); |
b3d44315 MV |
159 | void RetrievalDone(string Message); |
160 | void AuthDone(string Message); | |
161 | void QueueIndexes(bool verify); | |
162 | ||
163 | public: | |
0a8a80e5 | 164 | |
b3d44315 MV |
165 | // Specialized action members |
166 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); | |
167 | virtual void Done(string Message,unsigned long Size,string Md5Hash, | |
168 | pkgAcquire::MethodConfig *Cnf); | |
169 | virtual string Custom600Headers(); | |
170 | virtual string DescURI() {return RealURI; }; | |
171 | ||
172 | pkgAcqMetaIndex(pkgAcquire *Owner, | |
173 | string URI,string URIDesc, string ShortDesc, | |
174 | string SigFile, | |
175 | const vector<struct IndexTarget*>* IndexTargets, | |
176 | indexRecords* MetaIndexParser); | |
0118833a AL |
177 | }; |
178 | ||
03e39e59 AL |
179 | // Item class for archive files |
180 | class pkgAcqArchive : public pkgAcquire::Item | |
181 | { | |
182 | protected: | |
183 | ||
17caf1b1 | 184 | // State information for the retry mechanism |
03e39e59 AL |
185 | pkgCache::VerIterator Version; |
186 | pkgAcquire::ItemDesc Desc; | |
187 | pkgSourceList *Sources; | |
188 | pkgRecords *Recs; | |
189 | string MD5; | |
30e1eab5 | 190 | string &StoreFilename; |
b185acc2 | 191 | pkgCache::VerFileIterator Vf; |
7d8afa39 | 192 | unsigned int Retries; |
b3d44315 | 193 | bool Trusted; |
17caf1b1 AL |
194 | |
195 | // Queue the next available file for download. | |
b185acc2 | 196 | bool QueueNext(); |
03e39e59 AL |
197 | |
198 | public: | |
199 | ||
17caf1b1 | 200 | // Specialized action members |
7d8afa39 | 201 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); |
459681d3 AL |
202 | virtual void Done(string Message,unsigned long Size,string Md5Hash, |
203 | pkgAcquire::MethodConfig *Cnf); | |
17caf1b1 | 204 | virtual string MD5Sum() {return MD5;}; |
36375005 | 205 | virtual string DescURI() {return Desc.URI;}; |
b3d44315 | 206 | virtual string ShortDesc() {return Desc.ShortDesc;}; |
ab559b35 | 207 | virtual void Finished(); |
b3d44315 | 208 | virtual bool IsTrusted(); |
03e39e59 AL |
209 | |
210 | pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, | |
30e1eab5 AL |
211 | pkgRecords *Recs,pkgCache::VerIterator const &Version, |
212 | string &StoreFilename); | |
03e39e59 AL |
213 | }; |
214 | ||
36375005 AL |
215 | // Fetch a generic file to the current directory |
216 | class pkgAcqFile : public pkgAcquire::Item | |
217 | { | |
218 | pkgAcquire::ItemDesc Desc; | |
b3c39978 | 219 | string Md5Hash; |
08cfc005 | 220 | unsigned int Retries; |
36375005 AL |
221 | |
222 | public: | |
223 | ||
224 | // Specialized action members | |
08cfc005 | 225 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); |
459681d3 AL |
226 | virtual void Done(string Message,unsigned long Size,string Md5Hash, |
227 | pkgAcquire::MethodConfig *Cnf); | |
b3c39978 | 228 | virtual string MD5Sum() {return Md5Hash;}; |
36375005 | 229 | virtual string DescURI() {return Desc.URI;}; |
46e00f9d MV |
230 | |
231 | // If DestFilename is empty, download to DestDir/<basename> if | |
232 | // DestDir is non-empty, $CWD/<basename> otherwise. If | |
233 | // DestFilename is NOT empty, DestDir is ignored and DestFilename | |
234 | // is the absolute name to which the file should be downloaded. | |
235 | pkgAcqFile(pkgAcquire *Owner, string URI, string MD5, unsigned long Size, | |
236 | string Desc, string ShortDesc, | |
237 | const string &DestDir="", const string &DestFilename=""); | |
36375005 AL |
238 | }; |
239 | ||
0118833a | 240 | #endif |