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