]> git.saurik.com Git - apt.git/blame - apt-pkg/acquire-item.h
remove the longtime deprecated vendor{,list} stuff
[apt.git] / apt-pkg / acquire-item.h
CommitLineData
0118833a
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
0118833a
AL
3/* ######################################################################
4
5 Acquire Item - Item to acquire
6
7 When an item is instantiated it will add it self to the local list in
448c38bd
DK
8 the Owner Acquire class. Derived classes will then call QueueURI to
9 register all the URI's they wish to fetch at the initial moment.
10
770c32ec 11 Three item classes are provided to provide functionality for
a52f938b 12 downloading of Index, Translation and Packages files.
448c38bd 13
495e5cb2 14 A Archive class is provided for downloading .deb files. It does Hash
17caf1b1 15 checking and source location as well as a retry algorithm.
448c38bd 16
0118833a
AL
17 ##################################################################### */
18 /*}}}*/
19#ifndef PKGLIB_ACQUIRE_ITEM_H
20#define PKGLIB_ACQUIRE_ITEM_H
21
22#include <apt-pkg/acquire.h>
e3c1cfc7 23#include <apt-pkg/indexfile.h>
495e5cb2 24#include <apt-pkg/hashes.h>
229fb1a3 25#include <apt-pkg/weakptr.h>
472ff00e 26#include <apt-pkg/pkgcache.h>
453b82a3
DK
27#include <apt-pkg/cacheiterators.h>
28
29#include <string>
30#include <vector>
d3a869e3 31#include <map>
0118833a 32
b9dadc24 33#ifndef APT_8_CLEANER_HEADERS
b9dadc24
DK
34#include <apt-pkg/sourcelist.h>
35#include <apt-pkg/pkgrecords.h>
b9dadc24
DK
36#endif
37
3174e150
MV
38/** \addtogroup acquire
39 * @{
40 *
41 * \file acquire-item.h
42 */
43
472ff00e
DK
44class pkgRecords;
45class pkgSourceList;
3d8232bf
DK
46class pkgAcqMetaClearSig;
47class pkgAcqIndexMergeDiffs;
5ad0096a 48class metaIndex;
472ff00e 49
448c38bd
DK
50class pkgAcquire::Item : public WeakPointable /*{{{*/
51/** \brief Represents the process by which a pkgAcquire object should
3174e150
MV
52 * retrieve a file or a collection of files.
53 *
54 * By convention, Item subclasses should insert themselves into the
55 * acquire queue when they are created by calling QueueURI(), and
56 * remove themselves by calling Dequeue() when either Done() or
57 * Failed() is invoked. Item objects are also responsible for
58 * notifying the download progress indicator (accessible via
59 * #Owner->Log) of their status.
60 *
61 * \see pkgAcquire
62 */
448c38bd 63{
0118833a
AL
64 public:
65
3174e150
MV
66 /** \brief The current status of this item. */
67 enum ItemState
68 {
69 /** \brief The item is waiting to be downloaded. */
70 StatIdle,
71
72 /** \brief The item is currently being downloaded. */
73 StatFetching,
74
75 /** \brief The item has been successfully downloaded. */
76 StatDone,
77
78 /** \brief An error was encountered while downloading this
79 * item.
80 */
81 StatError,
82
83 /** \brief The item was downloaded but its authenticity could
84 * not be verified.
85 */
6ca714d5
MV
86 StatAuthError,
87
448c38bd 88 /** \brief The item was could not be downloaded because of
6ca714d5
MV
89 * a transient network error (e.g. network down)
90 */
56472095 91 StatTransientNetworkError,
3174e150
MV
92 } Status;
93
94 /** \brief Contains a textual description of the error encountered
255c9e4b 95 * if #ItemState is #StatError or #StatAuthError.
3174e150 96 */
472ff00e 97 std::string ErrorText;
3174e150
MV
98
99 /** \brief The size of the object to fetch. */
e2c66de5 100 unsigned long long FileSize;
3174e150
MV
101
102 /** \brief How much of the object was already fetched. */
e2c66de5 103 unsigned long long PartialSize;
3174e150
MV
104
105 /** \brief If not \b NULL, contains the name of a subprocess that
106 * is operating on this object (for instance, "gzip" or "gpgv").
107 */
ffbe056d
DK
108 APT_DEPRECATED const char *Mode;
109
110 /** \brief contains the name of the subprocess that is operating on this object
111 * (for instance, "gzip", "rred" or "gpgv"). This is obsoleting #Mode from above
112 * as it can manage the lifetime of included string properly. */
113 std::string ActiveSubprocess;
3174e150
MV
114
115 /** \brief A client-supplied unique identifier.
448c38bd 116 *
3174e150
MV
117 * This field is initalized to 0; it is meant to be filled in by
118 * clients that wish to use it to uniquely identify items.
119 *
448c38bd 120 * APT progress reporting will store an ID there as shown in "Get:42 …"
3174e150 121 */
b98f2859 122 unsigned long ID;
3174e150
MV
123
124 /** \brief If \b true, the entire object has been successfully fetched.
125 *
126 * Subclasses should set this to \b true when appropriate.
127 */
8267fe24 128 bool Complete;
3174e150
MV
129
130 /** \brief If \b true, the URI of this object is "local".
131 *
132 * The only effect of this field is to exclude the object from the
133 * download progress indicator's overall statistics.
134 */
a6568219 135 bool Local;
448c38bd 136
472ff00e 137 std::string UsedMirror;
30e1eab5 138
3174e150
MV
139 /** \brief The number of fetch queues into which this item has been
140 * inserted.
141 *
142 * There is one queue for each source from which an item could be
143 * downloaded.
144 *
145 * \sa pkgAcquire
146 */
0118833a 147 unsigned int QueueCounter;
d0cfa8ad
MV
148
149 /** \brief The number of additional fetch items that are expected
150 * once this item is done.
151 *
152 * Some items like pkgAcqMeta{Index,Sig} will queue additional
153 * items. This variable can be set by the methods if it knows
154 * in advance how many items to expect to get a more accurate
155 * progress.
156 */
157 unsigned int ExpectedAdditionalItems;
448c38bd 158
3174e150
MV
159 /** \brief The name of the file into which the retrieved object
160 * will be written.
161 */
472ff00e 162 std::string DestFile;
7d8afa39 163
3174e150
MV
164 /** \brief Invoked by the acquire worker when the object couldn't
165 * be fetched.
166 *
167 * This is a branch of the continuation of the fetch process.
168 *
169 * \param Message An RFC822-formatted message from the acquire
170 * method describing what went wrong. Use LookupTag() to parse
171 * it.
172 *
173 * \param Cnf The method via which the worker tried to fetch this object.
174 *
175 * \sa pkgAcqMethod
176 */
448c38bd 177 virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
3174e150
MV
178
179 /** \brief Invoked by the acquire worker when the object was
180 * fetched successfully.
181 *
182 * Note that the object might \e not have been written to
183 * DestFile; check for the presence of an Alt-Filename entry in
184 * Message to find the file to which it was really written.
185 *
186 * Done is often used to switch from one stage of the processing
187 * to the next (e.g. fetching, unpacking, copying). It is one
188 * branch of the continuation of the fetch process.
189 *
190 * \param Message Data from the acquire method. Use LookupTag()
191 * to parse it.
b3501edb 192 * \param Hashes The HashSums of the object that was fetched.
3174e150
MV
193 * \param Cnf The method via which the object was fetched.
194 *
195 * \sa pkgAcqMethod
196 */
448c38bd
DK
197 virtual void Done(std::string const &Message, HashStringList const &Hashes,
198 pkgAcquire::MethodConfig const * const Cnf);
3174e150
MV
199
200 /** \brief Invoked when the worker starts to fetch this object.
201 *
202 * \param Message RFC822-formatted data from the worker process.
203 * Use LookupTag() to parse it.
204 *
448c38bd 205 * \param Hashes The expected hashes of the object being fetched.
3174e150
MV
206 *
207 * \sa pkgAcqMethod
208 */
448c38bd 209 virtual void Start(std::string const &Message, unsigned long long const Size);
3174e150
MV
210
211 /** \brief Custom headers to be sent to the fetch process.
212 *
213 * \return a string containing RFC822-style headers that are to be
214 * inserted into the 600 URI Acquire message sent to the fetch
215 * subprocess. The headers are inserted after a newline-less
216 * line, so they should (if nonempty) have a leading newline and
217 * no trailing newline.
218 */
448c38bd 219 virtual std::string Custom600Headers() const;
3174e150
MV
220
221 /** \brief A "descriptive" URI-like string.
222 *
223 * \return a URI that should be used to describe what is being fetched.
224 */
448c38bd 225 virtual std::string DescURI() const = 0;
3174e150
MV
226 /** \brief Short item description.
227 *
228 * \return a brief description of the object being fetched.
229 */
448c38bd 230 virtual std::string ShortDesc() const;
3174e150
MV
231
232 /** \brief Invoked by the worker when the download is completely done. */
448c38bd
DK
233 virtual void Finished();
234
235 /** \return HashSums the DestFile is supposed to have in this stage */
236 virtual HashStringList GetExpectedHashes() const = 0;
237 /** \return the 'best' hash for display proposes like --print-uris */
238 std::string HashSum() const;
239
240 /** \return if having no hashes is a hard failure or not
3174e150 241 *
448c38bd
DK
242 * Idealy this is always \b true for every subclass, but thanks to
243 * historical grow we don't have hashes for all files in all cases
244 * in all steps, so it is slightly more complicated than it should be.
3174e150 245 */
448c38bd 246 virtual bool HashesRequired() const { return true; }
3174e150
MV
247
248 /** \return the acquire process with which this item is associated. */
448c38bd 249 pkgAcquire *GetOwner() const;
08ea7806 250 pkgAcquire::ItemDesc &GetItemDesc();
3174e150
MV
251
252 /** \return \b true if this object is being fetched from a trusted source. */
448c38bd
DK
253 virtual bool IsTrusted() const;
254
702c84fb 255 /** \brief Report mirror problem
448c38bd 256 *
702c84fb
MV
257 * This allows reporting mirror failures back to a centralized
258 * server. The apt-report-mirror-failure script is called for this
448c38bd 259 *
702c84fb
MV
260 * \param FailCode A short failure string that is send
261 */
448c38bd 262 void ReportMirrorFailure(std::string const &FailCode);
36280399 263
eeac6897
MV
264 /** \brief Set the name of the current active subprocess
265 *
266 * See also #ActiveSubprocess
267 */
448c38bd 268 void SetActiveSubprocess(std::string const &subprocess);
eeac6897 269
3174e150
MV
270 /** \brief Initialize an item.
271 *
272 * Adds the item to the list of items known to the acquire
273 * process, but does not place it into any fetch queues (you must
274 * manually invoke QueueURI() to do so).
275 *
3174e150
MV
276 * \param Owner The new owner of this item.
277 */
e8afd168 278 explicit Item(pkgAcquire * const Owner);
3174e150
MV
279
280 /** \brief Remove this item from its owner's queue by invoking
281 * pkgAcquire::Remove.
282 */
0118833a 283 virtual ~Item();
3c8030a4
DK
284
285 protected:
448c38bd
DK
286 /** \brief The acquire object with which this item is associated. */
287 pkgAcquire * const Owner;
288
289 /** \brief The item that is currently being downloaded. */
290 pkgAcquire::ItemDesc Desc;
3c8030a4
DK
291
292 enum RenameOnErrorState {
293 HashSumMismatch,
294 SizeMismatch,
631a7dc7
MV
295 InvalidFormat,
296 SignatureError,
297 NotClearsigned,
146f7715
DK
298 MaximumSizeExceeded,
299 PDiffError,
3c8030a4
DK
300 };
301
302 /** \brief Rename failed file and set error
303 *
304 * \param state respresenting the error we encountered
3c8030a4
DK
305 */
306 bool RenameOnError(RenameOnErrorState const state);
fa3b260f 307
448c38bd
DK
308 /** \brief Insert this item into its owner's queue.
309 *
310 * The method is designed to check if the request would end
311 * in an IMSHit and if it determines that it would, it isn't
312 * queueing the Item and instead sets it to completion instantly.
313 *
314 * \param Item Metadata about this item (its URI and
315 * description).
316 * \return true if the item was inserted, false if IMSHit was detected
317 */
318 virtual bool QueueURI(ItemDesc &Item);
319
320 /** \brief Remove this item from its owner's queue. */
321 void Dequeue();
322
323 /** \brief Rename a file without modifying its timestamp.
324 *
325 * Many item methods call this as their final action.
326 *
327 * \param From The file to be renamed.
328 *
329 * \param To The new name of \a From. If \a To exists it will be
330 * overwritten. If \a From and \a To are equal nothing happens.
331 */
332 bool Rename(std::string const &From, std::string const &To);
333
334 /** \brief Get the full pathname of the final file for the current URI */
335 virtual std::string GetFinalFilename() const;
336
337 private:
6c55f07a 338 void * const d;
448c38bd
DK
339
340 friend class pkgAcqMetaBase;
3d8232bf 341 friend class pkgAcqMetaClearSig;
448c38bd
DK
342};
343 /*}}}*/
344class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item /*{{{*/
345/** \brief baseclass for the indexes files to manage them all together */
346{
6c55f07a 347 void * const d;
448c38bd 348 protected:
dcbbb14d 349 IndexTarget const Target;
e8afd168 350 HashStringList GetExpectedHashesFor(std::string const &MetaKey) const;
448c38bd
DK
351
352 bool QueueURI(pkgAcquire::ItemDesc &Item);
353
354 public:
355 /** \brief storge name until a transaction is finished */
356 std::string PartialFile;
357
358 /** \brief TransactionManager */
3d8232bf 359 pkgAcqMetaClearSig * const TransactionManager;
448c38bd 360
146f7715
DK
361 enum TransactionStates {
362 TransactionCommit,
363 TransactionAbort,
364 };
365 virtual bool TransactionState(TransactionStates const state);
366
dcbbb14d 367 virtual std::string DescURI() const { return Target.URI; }
448c38bd
DK
368 virtual HashStringList GetExpectedHashes() const;
369 virtual std::string GetMetaKey() const;
370 virtual bool HashesRequired() const;
fa3b260f 371
3174e150 372
3d8232bf 373 pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, IndexTarget const &Target);
448c38bd 374 virtual ~pkgAcqTransactionItem();
f6d4ab9a 375
448c38bd 376 friend class pkgAcqMetaBase;
3d8232bf 377 friend class pkgAcqMetaClearSig;
002d9943 378};
92fcbfc1 379 /*}}}*/
448c38bd
DK
380class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem /*{{{*/
381/** \brief the manager of a transaction */
e6e89390 382{
6c55f07a 383 void * const d;
e6e89390 384 protected:
448c38bd 385 std::vector<pkgAcqTransactionItem*> Transaction;
715c65de 386
c045cc02
MV
387 /** \brief The index files which should be looked up in the meta-index
388 * and then downloaded.
389 */
dcbbb14d 390 std::vector<IndexTarget> const IndexTargets;
c045cc02 391
fa3a96a1
MV
392 /** \brief If \b true, the index's signature is currently being verified.
393 */
394 bool AuthPass;
395
c045cc02
MV
396 /** \brief Starts downloading the individual index files.
397 *
398 * \param verify If \b true, only indices whose expected hashsum
399 * can be determined from the meta-index will be downloaded, and
400 * the hashsums of indices will be checked (reporting
401 * #StatAuthError if there is a mismatch). If verify is \b false,
402 * no hashsum checking will be performed.
403 */
448c38bd 404 void QueueIndexes(bool const verify);
c045cc02 405
f3097647
MV
406 /** \brief Called when a file is finished being retrieved.
407 *
408 * If the file was not downloaded to DestFile, a copy process is
409 * set up to copy it to DestFile; otherwise, Complete is set to \b
410 * true and the file is moved to its final location.
411 *
412 * \param Message The message block received from the fetch
413 * subprocess.
414 */
448c38bd 415 bool CheckDownloadDone(pkgAcqTransactionItem * const I, const std::string &Message, HashStringList const &Hashes) const;
f3097647
MV
416
417 /** \brief Queue the downloaded Signature for verification */
448c38bd 418 void QueueForSignatureVerify(pkgAcqTransactionItem * const I, std::string const &File, std::string const &Signature);
f3097647 419
295d848b 420 virtual std::string Custom600Headers() const;
27e6c17a 421
f3097647
MV
422 /** \brief Called when authentication succeeded.
423 *
424 * Sanity-checks the authenticated file, queues up the individual
425 * index files for download, and saves the signature in the lists
426 * directory next to the authenticated list file.
427 *
428 * \param Message The message block received from the fetch
429 * subprocess.
430 */
448c38bd 431 bool CheckAuthDone(std::string const &Message);
f3097647 432
2d0a7bb4 433 /** Check if the current item should fail at this point */
6bf93605 434 bool CheckStopAuthentication(pkgAcquire::Item * const I, const std::string &Message);
2d0a7bb4 435
f3097647
MV
436 /** \brief Check that the release file is a release file for the
437 * correct distribution.
438 *
439 * \return \b true if no fatal errors were encountered.
440 */
448c38bd 441 bool VerifyVendor(std::string const &Message);
295d848b 442
6bf93605 443 virtual bool TransactionState(TransactionStates const state);
295d848b 444
715c65de 445 public:
ba6b79bd
DK
446 // This refers more to the Transaction-Manager than the actual file
447 bool IMSHit;
448
ba6b79bd 449 virtual bool QueueURI(pkgAcquire::ItemDesc &Item);
448c38bd
DK
450 virtual HashStringList GetExpectedHashes() const;
451 virtual bool HashesRequired() const;
295d848b 452
715c65de 453 // transaction code
448c38bd 454 void Add(pkgAcqTransactionItem * const I);
715c65de 455 void AbortTransaction();
448c38bd 456 bool TransactionHasError() const;
715c65de
MV
457 void CommitTransaction();
458
dce45dbe 459 /** \brief Stage (queue) a copy action when the transaction is committed
fa3a96a1 460 */
448c38bd
DK
461 void TransactionStageCopy(pkgAcqTransactionItem * const I,
462 const std::string &From,
fa3a96a1 463 const std::string &To);
dce45dbe 464 /** \brief Stage (queue) a removal action when the transaction is committed
fa3a96a1 465 */
448c38bd 466 void TransactionStageRemoval(pkgAcqTransactionItem * const I, const std::string &FinalFile);
fa3a96a1 467
6bf93605
DK
468 /** \brief Get the full pathname of the final file for the current URI */
469 virtual std::string GetFinalFilename() const;
470
3d8232bf 471 pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
e8afd168 472 std::vector<IndexTarget> const &IndexTargets,
3d8232bf 473 IndexTarget const &DataTarget);
c8a4ce6c 474 virtual ~pkgAcqMetaBase();
e6e89390 475};
dce45dbe 476 /*}}}*/
56472095
MV
477/** \brief An item that is responsible for downloading the meta-index {{{
478 * file (i.e., Release) itself and verifying its signature.
479 *
480 * Once the download and verification are complete, the downloads of
481 * the individual index files are queued up using pkgAcqDiffIndex.
482 * If the meta-index file had a valid signature, the expected hashsums
483 * of the index files will be the md5sums listed in the meta-index;
484 * otherwise, the expected hashsums will be "" (causing the
485 * authentication of the index files to be bypassed).
486 */
dce45dbe 487class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase
56472095 488{
6c55f07a 489 void * const d;
56472095 490 protected:
448c38bd 491 IndexTarget const DetachedSigTarget;
e05672e8
MV
492
493 /** \brief delayed constructor */
448c38bd
DK
494 void Init(std::string const &URIDesc, std::string const &ShortDesc);
495
56472095 496 public:
448c38bd 497 virtual std::string DescURI() const;
631a7dc7 498
56472095 499 // Specialized action members
448c38bd
DK
500 virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
501 virtual void Done(std::string const &Message, HashStringList const &Hashes,
502 pkgAcquire::MethodConfig const * const Cnf);
56472095
MV
503 virtual void Finished();
504
505 /** \brief Create a new pkgAcqMetaIndex. */
3d8232bf 506 pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
448c38bd 507 IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget,
3d8232bf 508 std::vector<IndexTarget> const &IndexTargets);
c8a4ce6c 509 virtual ~pkgAcqMetaIndex();
6bf93605
DK
510
511 friend class pkgAcqMetaSig;
512};
513 /*}}}*/
514/** \brief An acquire item that downloads the detached signature {{{
515 * of a meta-index (Release) file, then queues up the release
516 * file itself.
517 *
518 * \todo Why protected members?
519 *
520 * \sa pkgAcqMetaIndex
521 */
448c38bd 522class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem
6bf93605 523{
6c55f07a 524 void * const d;
6bf93605
DK
525
526 pkgAcqMetaIndex * const MetaIndex;
527
528 /** \brief The file we use to verify the MetaIndexFile with (not always set!) */
529 std::string MetaIndexFileSignature;
530
531 protected:
532
6bf93605
DK
533 /** \brief Get the full pathname of the final file for the current URI */
534 virtual std::string GetFinalFilename() const;
535
536 public:
448c38bd 537 virtual bool HashesRequired() const { return false; }
6bf93605
DK
538
539 // Specialized action members
448c38bd
DK
540 virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
541 virtual void Done(std::string const &Message, HashStringList const &Hashes,
542 pkgAcquire::MethodConfig const * const Cnf);
b0d40854 543 virtual std::string Custom600Headers() const;
6bf93605
DK
544
545 /** \brief Create a new pkgAcqMetaSig. */
3d8232bf
DK
546 pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
547 IndexTarget const &Target, pkgAcqMetaIndex * const MetaIndex);
6bf93605 548 virtual ~pkgAcqMetaSig();
56472095
MV
549};
550 /*}}}*/
551/** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/
dce45dbe 552class APT_HIDDEN pkgAcqMetaClearSig : public pkgAcqMetaIndex
56472095 553{
6c55f07a 554 void * const d;
60323ed7 555
448c38bd
DK
556 IndexTarget const ClearsignedTarget;
557 IndexTarget const DetachedDataTarget;
56472095 558
3d8232bf
DK
559 public:
560 /** \brief A package-system-specific parser for the meta-index file. */
5ad0096a
DK
561 metaIndex *MetaIndexParser;
562 metaIndex *LastMetaIndexParser;
3d8232bf 563
448c38bd 564 virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
56472095 565 virtual std::string Custom600Headers() const;
448c38bd
DK
566 virtual void Done(std::string const &Message, HashStringList const &Hashes,
567 pkgAcquire::MethodConfig const * const Cnf);
56472095
MV
568
569 /** \brief Create a new pkgAcqMetaClearSig. */
448c38bd
DK
570 pkgAcqMetaClearSig(pkgAcquire * const Owner,
571 IndexTarget const &ClearsignedTarget,
572 IndexTarget const &DetachedDataTarget,
573 IndexTarget const &DetachedSigTarget,
e8afd168 574 std::vector<IndexTarget> const &IndexTargets,
5ad0096a 575 metaIndex * const MetaIndexParser);
56472095
MV
576 virtual ~pkgAcqMetaClearSig();
577};
578 /*}}}*/
448c38bd
DK
579/** \brief Common base class for all classes that deal with fetching indexes {{{*/
580class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem
c2184314 581{
6c55f07a 582 void * const d;
60323ed7 583
448c38bd 584 public:
295d848b
DK
585 /** \brief Get the full pathname of the final file for the current URI */
586 virtual std::string GetFinalFilename() const;
587
3d8232bf 588 pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
e8afd168 589 IndexTarget const &Target);
c8a4ce6c 590 virtual ~pkgAcqBaseIndex();
c2184314 591};
0b58b3f8 592 /*}}}*/
92fcbfc1 593/** \brief An item that is responsible for fetching an index file of {{{
3174e150
MV
594 * package list diffs and starting the package list's download.
595 *
596 * This item downloads the Index file and parses it, then enqueues
597 * additional downloads of either the individual patches (using
598 * pkgAcqIndexDiffs) or the entire Packages file (using pkgAcqIndex).
599 *
600 * \sa pkgAcqIndexDiffs, pkgAcqIndex
601 */
dce45dbe 602class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex
2237bd01 603{
6c55f07a 604 void * const d;
3d8232bf 605 std::vector<pkgAcqIndexMergeDiffs*> * diffs;
60323ed7 606
2237bd01 607 protected:
3174e150 608 /** \brief If \b true, debugging information will be written to std::clog. */
2237bd01 609 bool Debug;
3174e150 610
3174e150
MV
611 /** \brief A description of the Packages file (stored in
612 * pkgAcquire::ItemDesc::Description).
613 */
472ff00e 614 std::string Description;
2237bd01 615
295d848b
DK
616 /** \brief Get the full pathname of the final file for the current URI */
617 virtual std::string GetFinalFilename() const;
618
ba6b79bd 619 virtual bool QueueURI(pkgAcquire::ItemDesc &Item);
146f7715
DK
620
621 virtual bool TransactionState(TransactionStates const state);
2237bd01
MV
622 public:
623 // Specialized action members
448c38bd
DK
624 virtual void Failed(std::string const &Message, pkgAcquire::MethodConfig const * const Cnf);
625 virtual void Done(std::string const &Message, HashStringList const &Hashes,
626 pkgAcquire::MethodConfig const * const Cnf);
dcbbb14d 627 virtual std::string DescURI() const {return Target.URI + "Index";};
b3501edb 628 virtual std::string Custom600Headers() const;
448c38bd 629 virtual std::string GetMetaKey() const;
2237bd01 630
3174e150
MV
631 /** \brief Parse the Index file for a set of Packages diffs.
632 *
633 * Parses the Index file and creates additional download items as
634 * necessary.
635 *
636 * \param IndexDiffFile The name of the Index file.
637 *
638 * \return \b true if the Index file was successfully parsed, \b
639 * false otherwise.
640 */
448c38bd 641 bool ParseDiffIndex(std::string const &IndexDiffFile);
3174e150
MV
642
643 /** \brief Create a new pkgAcqDiffIndex.
644 *
645 * \param Owner The Acquire object that owns this item.
646 *
647 * \param URI The URI of the list file to download.
648 *
649 * \param URIDesc A long description of the list file to download.
650 *
651 * \param ShortDesc A short description of the list file to download.
3174e150 652 */
3d8232bf 653 pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
e8afd168 654 IndexTarget const &Target);
c8a4ce6c 655 virtual ~pkgAcqDiffIndex();
ba6b79bd
DK
656 private:
657 APT_HIDDEN void QueueOnIMSHit() const;
002d9943 658};
92fcbfc1 659 /*}}}*/
448c38bd
DK
660struct APT_HIDDEN DiffInfo { /*{{{*/
661 /** The filename of the diff. */
662 std::string file;
663
4f51fd86 664 /** The hashes of the file after the diff is applied */
448c38bd
DK
665 HashStringList result_hashes;
666
4f51fd86 667 /** The hashes of the diff */
448c38bd
DK
668 HashStringList patch_hashes;
669
4f51fd86
DK
670 /** The hashes of the compressed diff */
671 HashStringList download_hashes;
448c38bd
DK
672};
673 /*}}}*/
47d2bc78
DK
674/** \brief An item that is responsible for fetching client-merge patches {{{
675 * that need to be applied to a given package index file.
676 *
677 * Instead of downloading and applying each patch one by one like its
678 * sister #pkgAcqIndexDiffs this class will download all patches at once
679 * and call rred with all the patches downloaded once. Rred will then
680 * merge and apply them in one go, which should be a lot faster – but is
681 * incompatible with server-based merges of patches like reprepro can do.
682 *
683 * \sa pkgAcqDiffIndex, pkgAcqIndex
684 */
dce45dbe 685class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
47d2bc78 686{
6c55f07a 687 void * const d;
60323ed7 688
47d2bc78
DK
689 protected:
690
691 /** \brief If \b true, debugging output will be written to
692 * std::clog.
693 */
694 bool Debug;
695
47d2bc78
DK
696 /** \brief description of the file being downloaded. */
697 std::string Description;
698
699 /** \brief information about the current patch */
700 struct DiffInfo const patch;
701
702 /** \brief list of all download items for the patches */
703 std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches;
704
705 /** The current status of this patch. */
706 enum DiffState
707 {
708 /** \brief The diff is currently being fetched. */
709 StateFetchDiff,
710
711 /** \brief The diff is currently being applied. */
712 StateApplyDiff,
713
714 /** \brief the work with this diff is done */
715 StateDoneDiff,
716
717 /** \brief something bad happened and fallback was triggered */
718 StateErrorDiff
719 } State;
720
721 public:
722 /** \brief Called when the patch file failed to be downloaded.
723 *
724 * This method will fall back to downloading the whole index file
725 * outright; its arguments are ignored.
726 */
448c38bd
DK
727 virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
728 virtual void Done(std::string const &Message, HashStringList const &Hashes,
729 pkgAcquire::MethodConfig const * const Cnf);
36795154 730 virtual std::string Custom600Headers() const;
dcbbb14d 731 virtual std::string DescURI() const {return Target.URI + "Index";};
448c38bd
DK
732 virtual HashStringList GetExpectedHashes() const;
733 virtual bool HashesRequired() const;
47d2bc78
DK
734
735 /** \brief Create an index merge-diff item.
736 *
737 * \param Owner The pkgAcquire object that owns this item.
738 *
739 * \param URI The URI of the package index file being
740 * reconstructed.
741 *
742 * \param URIDesc A long description of this item.
743 *
744 * \param ShortDesc A brief description of this item.
745 *
47d2bc78
DK
746 * \param patch contains infos about the patch this item is supposed
747 * to download which were read from the index
748 *
749 * \param allPatches contains all related items so that each item can
750 * check if it was the last one to complete the download step
751 */
3d8232bf 752 pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
e8afd168 753 IndexTarget const &Target, DiffInfo const &patch,
c2184314 754 std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches);
c8a4ce6c 755 virtual ~pkgAcqIndexMergeDiffs();
47d2bc78
DK
756};
757 /*}}}*/
758/** \brief An item that is responsible for fetching server-merge patches {{{
3174e150
MV
759 * that need to be applied to a given package index file.
760 *
761 * After downloading and applying a single patch, this item will
762 * enqueue a new pkgAcqIndexDiffs to download and apply the remaining
763 * patches. If no patch can be found that applies to an intermediate
764 * file or if one of the patches cannot be downloaded, falls back to
765 * downloading the entire package index file using pkgAcqIndex.
766 *
767 * \sa pkgAcqDiffIndex, pkgAcqIndex
768 */
dce45dbe 769class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
ac5b205a 770{
6c55f07a 771 void * const d;
60323ed7 772
3174e150
MV
773 private:
774
775 /** \brief Queue up the next diff download.
776 *
777 * Search for the next available diff that applies to the file
778 * that currently exists on disk, and enqueue it by calling
779 * QueueURI().
780 *
781 * \return \b true if an applicable diff was found, \b false
782 * otherwise.
783 */
3809194b 784 APT_HIDDEN bool QueueNextDiff();
3174e150
MV
785
786 /** \brief Handle tasks that must be performed after the item
787 * finishes downloading.
788 *
b3501edb
DK
789 * Dequeues the item and checks the resulting file's hashsums
790 * against ExpectedHashes after the last patch was applied.
3174e150
MV
791 * There is no need to check the md5/sha1 after a "normal"
792 * patch because QueueNextDiff() will check the sha1 later.
793 *
794 * \param allDone If \b true, the file was entirely reconstructed,
795 * and its md5sum is verified.
796 */
448c38bd 797 APT_HIDDEN void Finish(bool const allDone=false);
3174e150 798
ac5b205a 799 protected:
3174e150
MV
800
801 /** \brief If \b true, debugging output will be written to
802 * std::clog.
803 */
ac5b205a 804 bool Debug;
3174e150 805
3174e150 806 /** A description of the file being downloaded. */
472ff00e 807 std::string Description;
3174e150
MV
808
809 /** The patches that remain to be downloaded, including the patch
810 * being downloaded right now. This list should be ordered so
811 * that each diff appears before any diff that depends on it.
812 *
813 * \todo These are indexed by sha1sum; why not use some sort of
814 * dictionary instead of relying on ordering and stripping them
815 * off the front?
816 */
472ff00e 817 std::vector<DiffInfo> available_patches;
8a3207f4 818
3174e150
MV
819 /** The current status of this patch. */
820 enum DiffState
821 {
822 /** \brief The diff is in an unknown state. */
823 StateFetchUnkown,
824
825 /** \brief The diff is currently being fetched. */
826 StateFetchDiff,
3174e150
MV
827
828 /** \brief The diff is currently being applied. */
829 StateApplyDiff
830 } State;
6cb30d01 831
ac5b205a 832 public:
448c38bd 833
3174e150
MV
834 /** \brief Called when the patch file failed to be downloaded.
835 *
836 * This method will fall back to downloading the whole index file
837 * outright; its arguments are ignored.
838 */
448c38bd 839 virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
3174e150 840
448c38bd
DK
841 virtual void Done(std::string const &Message, HashStringList const &Hashes,
842 pkgAcquire::MethodConfig const * const Cnf);
36795154 843 virtual std::string Custom600Headers() const;
dcbbb14d 844 virtual std::string DescURI() const {return Target.URI + "IndexDiffs";};
448c38bd
DK
845 virtual HashStringList GetExpectedHashes() const;
846 virtual bool HashesRequired() const;
ac5b205a 847
3174e150
MV
848 /** \brief Create an index diff item.
849 *
850 * After filling in its basic fields, this invokes Finish(true) if
255c9e4b 851 * \a diffs is empty, or QueueNextDiff() otherwise.
3174e150
MV
852 *
853 * \param Owner The pkgAcquire object that owns this item.
854 *
855 * \param URI The URI of the package index file being
856 * reconstructed.
857 *
858 * \param URIDesc A long description of this item.
859 *
860 * \param ShortDesc A brief description of this item.
861 *
3174e150
MV
862 * \param diffs The remaining diffs from the index of diffs. They
863 * should be ordered so that each diff appears before any diff
864 * that depends on it.
865 */
3d8232bf 866 pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
e8afd168 867 IndexTarget const &Target,
448c38bd 868 std::vector<DiffInfo> const &diffs=std::vector<DiffInfo>());
c8a4ce6c 869 virtual ~pkgAcqIndexDiffs();
ac5b205a 870};
92fcbfc1
DK
871 /*}}}*/
872/** \brief An acquire item that is responsible for fetching an index {{{
3174e150
MV
873 * file (e.g., Packages or Sources).
874 *
875 * \sa pkgAcqDiffIndex, pkgAcqIndexDiffs, pkgAcqIndexTrans
876 *
877 * \todo Why does pkgAcqIndex have protected members?
878 */
dce45dbe 879class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex
0118833a 880{
6c55f07a 881 void * const d;
60323ed7 882
0118833a 883 protected:
3174e150 884
651bddad
MV
885 /** \brief The stages the method goes through
886 *
887 * The method first downloads the indexfile, then its decompressed (or
888 * copied) and verified
3174e150 889 */
651bddad
MV
890 enum AllStages {
891 STAGE_DOWNLOAD,
892 STAGE_DECOMPRESS_AND_VERIFY,
893 };
894 AllStages Stage;
3174e150 895
651bddad 896 /** \brief Handle what needs to be done when the download is done */
448c38bd 897 void StageDownloadDone(std::string const &Message,
651bddad 898 HashStringList const &Hashes,
448c38bd 899 pkgAcquire::MethodConfig const * const Cfg);
651bddad
MV
900
901 /** \brief Handle what needs to be done when the decompression/copy is
902 * done
3174e150 903 */
448c38bd 904 void StageDecompressDone(std::string const &Message,
651bddad 905 HashStringList const &Hashes,
448c38bd 906 pkgAcquire::MethodConfig const * const Cfg);
3174e150 907
1e8ba0d4
MV
908 /** \brief If \b set, this partially downloaded file will be
909 * removed when the download completes.
910 */
911 std::string EraseFileName;
912
5d885723
DK
913 /** \brief The compression-related file extensions that are being
914 * added to the downloaded file one by one if first fails (e.g., "gz bz2").
3174e150 915 */
651bddad
MV
916 std::string CompressionExtensions;
917
918 /** \brief The actual compression extension currently used */
1e8ba0d4 919 std::string CurrentCompressionExtension;
13e8426f 920
59194959 921 /** \brief Do the changes needed to fetch via AptByHash (if needed) */
448c38bd 922 void InitByHashIfNeeded();
59194959 923
56472095
MV
924 /** \brief Auto select the right compression to use */
925 void AutoSelectCompression();
926
63b7249e 927 /** \brief Schedule file for verification after a IMS hit */
916b8910 928 void ReverifyAfterIMS();
63b7249e 929
295d848b
DK
930 /** \brief Get the full pathname of the final file for the current URI */
931 virtual std::string GetFinalFilename() const;
932
146f7715
DK
933 virtual bool TransactionState(TransactionStates const state);
934
0118833a 935 public:
17caf1b1 936 // Specialized action members
448c38bd
DK
937 virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
938 virtual void Done(std::string const &Message, HashStringList const &Hashes,
939 pkgAcquire::MethodConfig const * const Cnf);
b3501edb 940 virtual std::string Custom600Headers() const;
448c38bd
DK
941 virtual std::string DescURI() const {return Desc.URI;};
942 virtual std::string GetMetaKey() const;
943
3d8232bf 944 pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
e8afd168 945 IndexTarget const &Target);
c8a4ce6c 946 virtual ~pkgAcqIndex();
0118833a 947
c8a4ce6c
DK
948 private:
949 APT_HIDDEN void Init(std::string const &URI, std::string const &URIDesc,
0b58b3f8 950 std::string const &ShortDesc);
0118833a 951};
92fcbfc1 952 /*}}}*/
92fcbfc1 953/** \brief An item that is responsible for fetching a package file. {{{
3174e150
MV
954 *
955 * If the package file already exists in the cache, nothing will be
956 * done.
957 */
03e39e59
AL
958class pkgAcqArchive : public pkgAcquire::Item
959{
6c55f07a 960 void * const d;
60323ed7 961
448c38bd
DK
962 bool LocalSource;
963 HashStringList ExpectedHashes;
964
03e39e59 965 protected:
3174e150 966 /** \brief The package version being fetched. */
03e39e59 967 pkgCache::VerIterator Version;
3174e150 968
3174e150
MV
969 /** \brief The list of sources from which to pick archives to
970 * download this package from.
971 */
03e39e59 972 pkgSourceList *Sources;
3174e150
MV
973
974 /** \brief A package records object, used to look up the file
975 * corresponding to each version of the package.
976 */
03e39e59 977 pkgRecords *Recs;
3174e150 978
3174e150
MV
979 /** \brief A location in which the actual filename of the package
980 * should be stored.
981 */
472ff00e 982 std::string &StoreFilename;
3174e150
MV
983
984 /** \brief The next file for this version to try to download. */
b185acc2 985 pkgCache::VerFileIterator Vf;
3174e150
MV
986
987 /** \brief How many (more) times to try to find a new source from
988 * which to download this package version if it fails.
989 *
990 * Set from Acquire::Retries.
991 */
7d8afa39 992 unsigned int Retries;
3174e150
MV
993
994 /** \brief \b true if this version file is being downloaded from a
995 * trusted source.
996 */
448c38bd 997 bool Trusted;
17caf1b1 998
3174e150 999 /** \brief Queue up the next available file for this version. */
b185acc2 1000 bool QueueNext();
295d848b
DK
1001
1002 /** \brief Get the full pathname of the final file for the current URI */
1003 virtual std::string GetFinalFilename() const;
1004
03e39e59 1005 public:
295d848b 1006
448c38bd
DK
1007 virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
1008 virtual void Done(std::string const &Message, HashStringList const &Hashes,
1009 pkgAcquire::MethodConfig const * const Cnf);
1010 virtual std::string DescURI() const;
1011 virtual std::string ShortDesc() const;
ab559b35 1012 virtual void Finished();
b3501edb 1013 virtual bool IsTrusted() const;
448c38bd
DK
1014 virtual HashStringList GetExpectedHashes() const;
1015 virtual bool HashesRequired() const;
02e20767 1016
3174e150
MV
1017 /** \brief Create a new pkgAcqArchive.
1018 *
1019 * \param Owner The pkgAcquire object with which this item is
1020 * associated.
1021 *
1022 * \param Sources The sources from which to download version
1023 * files.
1024 *
1025 * \param Recs A package records object, used to look up the file
1026 * corresponding to each version of the package.
1027 *
1028 * \param Version The package version to download.
1029 *
3c8030a4 1030 * \param[out] StoreFilename A location in which the actual filename of
3174e150
MV
1031 * the package should be stored. It will be set to a guessed
1032 * basename in the constructor, and filled in with a fully
1033 * qualified filename once the download finishes.
1034 */
448c38bd
DK
1035 pkgAcqArchive(pkgAcquire * const Owner,pkgSourceList * const Sources,
1036 pkgRecords * const Recs,pkgCache::VerIterator const &Version,
472ff00e 1037 std::string &StoreFilename);
c8a4ce6c 1038 virtual ~pkgAcqArchive();
03e39e59 1039};
92fcbfc1 1040 /*}}}*/
d56e2917
DK
1041/** \brief Retrieve the changelog for the given version {{{
1042 *
1043 * Downloads the changelog to a temporary file it will also remove again
1044 * while it is deconstructed or downloads it to a named location.
1045 */
1046class pkgAcqChangelog : public pkgAcquire::Item
1047{
6c55f07a 1048 void * const d;
d56e2917
DK
1049 std::string TemporaryDirectory;
1050 std::string const SrcName;
1051 std::string const SrcVersion;
1052
1053 public:
1054 // we will never have hashes for changelogs.
1055 // If you need verified ones, download the deb and extract the changelog.
1056 virtual HashStringList GetExpectedHashes() const { return HashStringList(); }
1057 virtual bool HashesRequired() const { return false; }
1058
1059 // Specialized action members
1060 virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
1061 virtual void Done(std::string const &Message, HashStringList const &CalcHashes,
1062 pkgAcquire::MethodConfig const * const Cnf);
1063 virtual std::string DescURI() const {return Desc.URI;};
1064
1065 /** returns the URI to the changelog of this version
1066 *
1067 * @param Ver is the version to get the changelog for
1068 * @return the URI which will be used to acquire the changelog
1069 */
1070 static std::string URI(pkgCache::VerIterator const &Ver);
1071
1072 /** returns the URI to the changelog of this version
1073 *
1074 * \param Rls is the Release file the package comes from
1075 * \param Component in which the package resides, can be empty
1076 * \param SrcName is the source package name
1077 * \param SrcVersion is the source package version
1078 * @return the URI which will be used to acquire the changelog
1079 */
1080 static std::string URI(pkgCache::RlsFileIterator const &Rls,
1081 char const * const Component, char const * const SrcName,
1082 char const * const SrcVersion);
1083
1084 /** returns the URI to the changelog of this version
1085 *
1086 * \param Template URI where CHANGEPATH has to be filled in
1087 * \param Component in which the package resides, can be empty
1088 * \param SrcName is the source package name
1089 * \param SrcVersion is the source package version
1090 * @return the URI which will be used to acquire the changelog
1091 */
1092 static std::string URI(std::string const &Template,
1093 char const * const Component, char const * const SrcName,
1094 char const * const SrcVersion);
1095
1096 /** returns the URI template for this release file
1097 *
1098 * \param Rls is a Release file
1099 * @return the URI template to use for this release file
1100 */
1101 static std::string URITemplate(pkgCache::RlsFileIterator const &Rls);
1102
1103 /** \brief Create a new pkgAcqChangelog object.
1104 *
1105 * \param Owner The pkgAcquire object with which this object is
1106 * associated.
1107 * \param Ver is the version to get the changelog for
1108 * \param DestDir The directory the file should be downloaded into.
1109 * Will be an autocreated (and cleaned up) temporary directory if not set.
1110 * \param DestFilename The filename the file should have in #DestDir
1111 * Defaults to sourcepackagename.changelog if not set.
1112 */
1113 pkgAcqChangelog(pkgAcquire * const Owner, pkgCache::VerIterator const &Ver,
1114 std::string const &DestDir="", std::string const &DestFilename="");
1115
1116 /** \brief Create a new pkgAcqChangelog object.
1117 *
1118 * \param Owner The pkgAcquire object with which this object is
1119 * associated.
1120 * \param Rls is the Release file the package comes from
1121 * \param Component in which the package resides, can be empty
1122 * \param SrcName is the source package name
1123 * \param SrcVersion is the source package version
1124 * \param DestDir The directory the file should be downloaded into.
1125 * Will be an autocreated (and cleaned up) temporary directory if not set.
1126 * \param DestFilename The filename the file should have in #DestDir
1127 * Defaults to sourcepackagename.changelog if not set.
1128 */
1129 pkgAcqChangelog(pkgAcquire * const Owner, pkgCache::RlsFileIterator const &Rls,
1130 char const * const Component, char const * const SrcName, char const * const SrcVersion,
1131 std::string const &DestDir="", std::string const &DestFilename="");
1132
1133 /** \brief Create a new pkgAcqChangelog object.
1134 *
1135 * \param Owner The pkgAcquire object with which this object is
1136 * associated.
1137 * \param URI is to be used to get the changelog
1138 * \param SrcName is the source package name
1139 * \param SrcVersion is the source package version
1140 * \param DestDir The directory the file should be downloaded into.
1141 * Will be an autocreated (and cleaned up) temporary directory if not set.
1142 * \param DestFilename The filename the file should have in #DestDir
1143 * Defaults to sourcepackagename.changelog if not set.
1144 */
1145 pkgAcqChangelog(pkgAcquire * const Owner, std::string const &URI,
1146 char const * const SrcName, char const * const SrcVersion,
1147 std::string const &DestDir="", std::string const &DestFilename="");
1148
1149 virtual ~pkgAcqChangelog();
1150
1151private:
1152 APT_HIDDEN void Init(std::string const &DestDir, std::string const &DestFilename);
1153};
1154 /*}}}*/
92fcbfc1 1155/** \brief Retrieve an arbitrary file to the current directory. {{{
3174e150
MV
1156 *
1157 * The file is retrieved even if it is accessed via a URL type that
1158 * normally is a NOP, such as "file". If the download fails, the
1159 * partial file is renamed to get a ".FAILED" extension.
1160 */
36375005
AL
1161class pkgAcqFile : public pkgAcquire::Item
1162{
6c55f07a 1163 void * const d;
60323ed7 1164
3174e150
MV
1165 /** \brief How many times to retry the download, set from
1166 * Acquire::Retries.
1167 */
08cfc005 1168 unsigned int Retries;
448c38bd 1169
77278c2b
MV
1170 /** \brief Should this file be considered a index file */
1171 bool IsIndexFile;
1172
448c38bd 1173 HashStringList const ExpectedHashes;
36375005 1174 public:
448c38bd
DK
1175 virtual HashStringList GetExpectedHashes() const;
1176 virtual bool HashesRequired() const;
1177
36375005 1178 // Specialized action members
448c38bd
DK
1179 virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
1180 virtual void Done(std::string const &Message, HashStringList const &CalcHashes,
1181 pkgAcquire::MethodConfig const * const Cnf);
1182 virtual std::string DescURI() const {return Desc.URI;};
b3501edb 1183 virtual std::string Custom600Headers() const;
3174e150
MV
1184
1185 /** \brief Create a new pkgAcqFile object.
1186 *
1187 * \param Owner The pkgAcquire object with which this object is
1188 * associated.
1189 *
1190 * \param URI The URI to download.
1191 *
b3501edb
DK
1192 * \param Hashes The hashsums of the file to download, if they are known;
1193 * otherwise empty list.
3174e150
MV
1194 *
1195 * \param Size The size of the file to download, if it is known;
1196 * otherwise 0.
1197 *
1198 * \param Desc A description of the file being downloaded.
1199 *
1200 * \param ShortDesc A brief description of the file being
1201 * downloaded.
39c7baef
MV
1202 *
1203 * \param DestDir The directory the file should be downloaded into.
1204 *
1205 * \param DestFilename The filename+path the file is downloaded to.
1206 *
77278c2b
MV
1207 * \param IsIndexFile The file is considered a IndexFile and cache-control
1208 * headers like "cache-control: max-age=0" are send
39c7baef 1209 *
255c9e4b
DK
1210 * If DestFilename is empty, download to DestDir/\<basename\> if
1211 * DestDir is non-empty, $CWD/\<basename\> otherwise. If
39c7baef
MV
1212 * DestFilename is NOT empty, DestDir is ignored and DestFilename
1213 * is the absolute name to which the file should be downloaded.
3174e150 1214 */
39c7baef 1215
448c38bd
DK
1216 pkgAcqFile(pkgAcquire * const Owner, std::string const &URI, HashStringList const &Hashes, unsigned long long const Size,
1217 std::string const &Desc, std::string const &ShortDesc,
1218 std::string const &DestDir="", std::string const &DestFilename="",
1219 bool const IsIndexFile=false);
c8a4ce6c 1220 virtual ~pkgAcqFile();
36375005 1221};
92fcbfc1 1222 /*}}}*/
3174e150
MV
1223/** @} */
1224
0118833a 1225#endif