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