]> git.saurik.com Git - apt.git/blame - apt-pkg/acquire-item.h
merged from apt--mvo
[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
AL
29
30#ifdef __GNUG__
31#pragma interface "apt-pkg/acquire-item.h"
32#endif
33
34// Item to acquire
35class 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
87class 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
770c32ec 111// Item class for translated package index files
a52f938b
OS
112class pkgAcqIndexTrans : public pkgAcqIndex
113{
114 public:
115
116 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
117 pkgAcqIndexTrans(pkgAcquire *Owner,string URI,string URIDesc,
118 string ShortDesct);
119};
120
b3d44315
MV
121struct IndexTarget
122{
123 string URI;
124 string Description;
125 string ShortDesc;
126 string MetaKey;
127};
128
129// Item class for index signatures
130class pkgAcqMetaSig : public pkgAcquire::Item
0118833a
AL
131{
132 protected:
133
8267fe24 134 pkgAcquire::ItemDesc Desc;
b3d44315
MV
135 string RealURI,MetaIndexURI,MetaIndexURIDesc,MetaIndexShortDesc;
136 indexRecords* MetaIndexParser;
137 const vector<struct IndexTarget*>* IndexTargets;
138
0118833a
AL
139 public:
140
17caf1b1 141 // Specialized action members
681d76d0 142 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
459681d3 143 virtual void Done(string Message,unsigned long Size,string Md5Hash,
b3d44315 144 pkgAcquire::MethodConfig *Cnf);
0a8a80e5 145 virtual string Custom600Headers();
b3d44315
MV
146 virtual string DescURI() {return RealURI; };
147
148 pkgAcqMetaSig(pkgAcquire *Owner,string URI,string URIDesc, string ShortDesc,
149 string MetaIndexURI, string MetaIndexURIDesc, string MetaIndexShortDesc,
150 const vector<struct IndexTarget*>* IndexTargets,
151 indexRecords* MetaIndexParser);
152};
153
154// Item class for index signatures
155class pkgAcqMetaIndex : public pkgAcquire::Item
156{
157 protected:
158
159 pkgAcquire::ItemDesc Desc;
160 string RealURI; // FIXME: is this redundant w/ Desc.URI?
161 string SigFile;
162 const vector<struct IndexTarget*>* IndexTargets;
163 indexRecords* MetaIndexParser;
164 bool AuthPass;
ce424cd4
MV
165 // required to deal gracefully with problems caused by incorrect ims hits
166 bool IMSHit;
b3d44315 167
ce424cd4 168 bool VerifyVendor(string Message);
b3d44315
MV
169 void RetrievalDone(string Message);
170 void AuthDone(string Message);
171 void QueueIndexes(bool verify);
172
173 public:
0a8a80e5 174
b3d44315
MV
175 // Specialized action members
176 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
177 virtual void Done(string Message,unsigned long Size,string Md5Hash,
178 pkgAcquire::MethodConfig *Cnf);
179 virtual string Custom600Headers();
180 virtual string DescURI() {return RealURI; };
181
182 pkgAcqMetaIndex(pkgAcquire *Owner,
183 string URI,string URIDesc, string ShortDesc,
184 string SigFile,
185 const vector<struct IndexTarget*>* IndexTargets,
186 indexRecords* MetaIndexParser);
0118833a
AL
187};
188
03e39e59
AL
189// Item class for archive files
190class pkgAcqArchive : public pkgAcquire::Item
191{
192 protected:
193
17caf1b1 194 // State information for the retry mechanism
03e39e59
AL
195 pkgCache::VerIterator Version;
196 pkgAcquire::ItemDesc Desc;
197 pkgSourceList *Sources;
198 pkgRecords *Recs;
199 string MD5;
30e1eab5 200 string &StoreFilename;
b185acc2 201 pkgCache::VerFileIterator Vf;
7d8afa39 202 unsigned int Retries;
b3d44315 203 bool Trusted;
17caf1b1
AL
204
205 // Queue the next available file for download.
b185acc2 206 bool QueueNext();
03e39e59
AL
207
208 public:
209
17caf1b1 210 // Specialized action members
7d8afa39 211 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
459681d3
AL
212 virtual void Done(string Message,unsigned long Size,string Md5Hash,
213 pkgAcquire::MethodConfig *Cnf);
17caf1b1 214 virtual string MD5Sum() {return MD5;};
36375005 215 virtual string DescURI() {return Desc.URI;};
b3d44315 216 virtual string ShortDesc() {return Desc.ShortDesc;};
ab559b35 217 virtual void Finished();
b3d44315 218 virtual bool IsTrusted();
03e39e59
AL
219
220 pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
30e1eab5
AL
221 pkgRecords *Recs,pkgCache::VerIterator const &Version,
222 string &StoreFilename);
03e39e59
AL
223};
224
36375005
AL
225// Fetch a generic file to the current directory
226class pkgAcqFile : public pkgAcquire::Item
227{
228 pkgAcquire::ItemDesc Desc;
b3c39978 229 string Md5Hash;
08cfc005 230 unsigned int Retries;
36375005
AL
231
232 public:
233
234 // Specialized action members
08cfc005 235 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
459681d3
AL
236 virtual void Done(string Message,unsigned long Size,string Md5Hash,
237 pkgAcquire::MethodConfig *Cnf);
b3c39978 238 virtual string MD5Sum() {return Md5Hash;};
36375005 239 virtual string DescURI() {return Desc.URI;};
46e00f9d
MV
240
241 // If DestFilename is empty, download to DestDir/<basename> if
242 // DestDir is non-empty, $CWD/<basename> otherwise. If
243 // DestFilename is NOT empty, DestDir is ignored and DestFilename
244 // is the absolute name to which the file should be downloaded.
245 pkgAcqFile(pkgAcquire *Owner, string URI, string MD5, unsigned long Size,
246 string Desc, string ShortDesc,
247 const string &DestDir="", const string &DestFilename="");
36375005
AL
248};
249
0118833a 250#endif