* some more debug output
[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
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
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
b3d44315 51 enum {StatIdle, StatFetching, StatDone, StatError, StatAuthError} Status;
c88edf1d 52 string ErrorText;
8267fe24 53 unsigned long FileSize;
6b1ff003 54 unsigned long PartialSize;
b2e465d6 55 const char *Mode;
b98f2859 56 unsigned long ID;
8267fe24 57 bool Complete;
a6568219 58 bool Local;
30e1eab5 59
0a8a80e5 60 // Number of queues we are inserted into
0118833a 61 unsigned int QueueCounter;
0118833a 62
0a8a80e5
AL
63 // File to write the fetch into
64 string DestFile;
7d8afa39 65
17caf1b1 66 // Action members invoked by the worker
7d8afa39 67 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
459681d3
AL
68 virtual void Done(string Message,unsigned long Size,string Md5Hash,
69 pkgAcquire::MethodConfig *Cnf);
8267fe24 70 virtual void Start(string Message,unsigned long Size);
17caf1b1 71 virtual string Custom600Headers() {return string();};
36375005 72 virtual string DescURI() = 0;
b3d44315 73 virtual string ShortDesc() {return DescURI();}
ab559b35 74 virtual void Finished() {};
17caf1b1
AL
75
76 // Inquire functions
f7a08e33 77 virtual string MD5Sum() {return string();};
c5ccf175 78 pkgAcquire *GetOwner() {return Owner;};
b3d44315 79 virtual bool IsTrusted() {return false;};
c5ccf175 80
0118833a
AL
81 Item(pkgAcquire *Owner);
82 virtual ~Item();
83};
84
85// Item class for index files
86class pkgAcqIndex : public pkgAcquire::Item
87{
88 protected:
89
8b89e57f 90 bool Decompression;
bfd22fc0 91 bool Erase;
8267fe24 92 pkgAcquire::ItemDesc Desc;
b2e465d6 93 string RealURI;
b3d44315 94 string ExpectedMD5;
13e8426f
MV
95 string CompressionExtension;
96
0118833a
AL
97 public:
98
17caf1b1 99 // Specialized action members
debc84b2 100 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
459681d3
AL
101 virtual void Done(string Message,unsigned long Size,string Md5Hash,
102 pkgAcquire::MethodConfig *Cnf);
0a8a80e5 103 virtual string Custom600Headers();
13e8426f 104 virtual string DescURI() {return RealURI + CompressionExtension;};
0118833a 105
b2e465d6 106 pkgAcqIndex(pkgAcquire *Owner,string URI,string URIDesc,
b3d44315 107 string ShortDesct, string ExpectedMD5, string compressExt="");
0118833a
AL
108};
109
b3d44315
MV
110struct IndexTarget
111{
112 string URI;
113 string Description;
114 string ShortDesc;
115 string MetaKey;
116};
117
118// Item class for index signatures
119class pkgAcqMetaSig : public pkgAcquire::Item
0118833a
AL
120{
121 protected:
122
8267fe24 123 pkgAcquire::ItemDesc Desc;
b3d44315
MV
124 string RealURI,MetaIndexURI,MetaIndexURIDesc,MetaIndexShortDesc;
125 indexRecords* MetaIndexParser;
126 const vector<struct IndexTarget*>* IndexTargets;
127
0118833a
AL
128 public:
129
17caf1b1 130 // Specialized action members
681d76d0 131 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
459681d3 132 virtual void Done(string Message,unsigned long Size,string Md5Hash,
b3d44315 133 pkgAcquire::MethodConfig *Cnf);
0a8a80e5 134 virtual string Custom600Headers();
b3d44315
MV
135 virtual string DescURI() {return RealURI; };
136
137 pkgAcqMetaSig(pkgAcquire *Owner,string URI,string URIDesc, string ShortDesc,
138 string MetaIndexURI, string MetaIndexURIDesc, string MetaIndexShortDesc,
139 const vector<struct IndexTarget*>* IndexTargets,
140 indexRecords* MetaIndexParser);
141};
142
143// Item class for index signatures
144class pkgAcqMetaIndex : public pkgAcquire::Item
145{
146 protected:
147
148 pkgAcquire::ItemDesc Desc;
149 string RealURI; // FIXME: is this redundant w/ Desc.URI?
150 string SigFile;
151 const vector<struct IndexTarget*>* IndexTargets;
152 indexRecords* MetaIndexParser;
153 bool AuthPass;
154
155 bool VerifyVendor();
156 void RetrievalDone(string Message);
157 void AuthDone(string Message);
158 void QueueIndexes(bool verify);
159
160 public:
0a8a80e5 161
b3d44315
MV
162 // Specialized action members
163 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
164 virtual void Done(string Message,unsigned long Size,string Md5Hash,
165 pkgAcquire::MethodConfig *Cnf);
166 virtual string Custom600Headers();
167 virtual string DescURI() {return RealURI; };
168
169 pkgAcqMetaIndex(pkgAcquire *Owner,
170 string URI,string URIDesc, string ShortDesc,
171 string SigFile,
172 const vector<struct IndexTarget*>* IndexTargets,
173 indexRecords* MetaIndexParser);
0118833a
AL
174};
175
03e39e59
AL
176// Item class for archive files
177class pkgAcqArchive : public pkgAcquire::Item
178{
179 protected:
180
17caf1b1 181 // State information for the retry mechanism
03e39e59
AL
182 pkgCache::VerIterator Version;
183 pkgAcquire::ItemDesc Desc;
184 pkgSourceList *Sources;
185 pkgRecords *Recs;
186 string MD5;
30e1eab5 187 string &StoreFilename;
b185acc2 188 pkgCache::VerFileIterator Vf;
7d8afa39 189 unsigned int Retries;
b3d44315 190 bool Trusted;
17caf1b1
AL
191
192 // Queue the next available file for download.
b185acc2 193 bool QueueNext();
03e39e59
AL
194
195 public:
196
17caf1b1 197 // Specialized action members
7d8afa39 198 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
459681d3
AL
199 virtual void Done(string Message,unsigned long Size,string Md5Hash,
200 pkgAcquire::MethodConfig *Cnf);
17caf1b1 201 virtual string MD5Sum() {return MD5;};
36375005 202 virtual string DescURI() {return Desc.URI;};
b3d44315 203 virtual string ShortDesc() {return Desc.ShortDesc;};
ab559b35 204 virtual void Finished();
b3d44315 205 virtual bool IsTrusted();
03e39e59
AL
206
207 pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
30e1eab5
AL
208 pkgRecords *Recs,pkgCache::VerIterator const &Version,
209 string &StoreFilename);
03e39e59
AL
210};
211
36375005
AL
212// Fetch a generic file to the current directory
213class pkgAcqFile : public pkgAcquire::Item
214{
215 pkgAcquire::ItemDesc Desc;
b3c39978 216 string Md5Hash;
08cfc005 217 unsigned int Retries;
36375005
AL
218
219 public:
220
221 // Specialized action members
08cfc005 222 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
459681d3
AL
223 virtual void Done(string Message,unsigned long Size,string Md5Hash,
224 pkgAcquire::MethodConfig *Cnf);
b3c39978 225 virtual string MD5Sum() {return Md5Hash;};
36375005
AL
226 virtual string DescURI() {return Desc.URI;};
227
228 pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,unsigned long Size,
229 string Desc,string ShortDesc);
230};
231
0118833a 232#endif