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