]> git.saurik.com Git - apt.git/blame - apt-pkg/acquire-item.h
Arranged to rename downloaded files to include all impo...
[apt.git] / apt-pkg / acquire-item.h
CommitLineData
0118833a
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
17caf1b1 3// $Id: acquire-item.h,v 1.16 1999/02/01 02:22:11 jgg 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>
24#include <apt-pkg/sourcelist.h>
03e39e59 25#include <apt-pkg/pkgrecords.h>
0118833a
AL
26
27#ifdef __GNUG__
28#pragma interface "apt-pkg/acquire-item.h"
29#endif
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
AL
47 // State of the item
48 enum {StatIdle, StatFetching, StatDone, StatError} Status;
49 string ErrorText;
8267fe24 50 unsigned long FileSize;
b98f2859
AL
51 char *Mode;
52 unsigned long ID;
8267fe24 53 bool Complete;
a6568219 54 bool Local;
30e1eab5 55
0a8a80e5 56 // Number of queues we are inserted into
0118833a 57 unsigned int QueueCounter;
0118833a 58
0a8a80e5
AL
59 // File to write the fetch into
60 string DestFile;
7d8afa39 61
17caf1b1 62 // Action members invoked by the worker
7d8afa39 63 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
c88edf1d 64 virtual void Done(string Message,unsigned long Size,string Md5Hash);
8267fe24 65 virtual void Start(string Message,unsigned long Size);
17caf1b1
AL
66 virtual string Custom600Headers() {return string();};
67
68 // Inquire functions
f7a08e33 69 virtual string MD5Sum() {return string();};
30e1eab5 70 virtual string Describe() = 0;
17caf1b1 71
0118833a
AL
72 Item(pkgAcquire *Owner);
73 virtual ~Item();
74};
75
76// Item class for index files
77class pkgAcqIndex : public pkgAcquire::Item
78{
79 protected:
80
81 const pkgSourceList::Item *Location;
8b89e57f 82 bool Decompression;
bfd22fc0 83 bool Erase;
8267fe24 84 pkgAcquire::ItemDesc Desc;
0118833a
AL
85
86 public:
87
17caf1b1 88 // Specialized action members
8b89e57f 89 virtual void Done(string Message,unsigned long Size,string Md5Hash);
0a8a80e5 90 virtual string Custom600Headers();
30e1eab5 91 virtual string Describe();
0118833a
AL
92
93 pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location);
94};
95
96// Item class for index files
97class pkgAcqIndexRel : public pkgAcquire::Item
98{
99 protected:
100
101 const pkgSourceList::Item *Location;
8267fe24 102 pkgAcquire::ItemDesc Desc;
0118833a
AL
103
104 public:
105
17caf1b1 106 // Specialized action members
681d76d0 107 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
8b89e57f 108 virtual void Done(string Message,unsigned long Size,string Md5Hash);
0a8a80e5 109 virtual string Custom600Headers();
30e1eab5 110 virtual string Describe();
0a8a80e5 111
0118833a
AL
112 pkgAcqIndexRel(pkgAcquire *Owner,const pkgSourceList::Item *Location);
113};
114
03e39e59
AL
115// Item class for archive files
116class pkgAcqArchive : public pkgAcquire::Item
117{
118 protected:
119
17caf1b1 120 // State information for the retry mechanism
03e39e59
AL
121 pkgCache::VerIterator Version;
122 pkgAcquire::ItemDesc Desc;
123 pkgSourceList *Sources;
124 pkgRecords *Recs;
125 string MD5;
30e1eab5 126 string &StoreFilename;
b185acc2 127 pkgCache::VerFileIterator Vf;
7d8afa39 128 unsigned int Retries;
17caf1b1
AL
129
130 // Queue the next available file for download.
b185acc2 131 bool QueueNext();
03e39e59
AL
132
133 public:
134
17caf1b1 135 // Specialized action members
7d8afa39 136 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
03e39e59 137 virtual void Done(string Message,unsigned long Size,string Md5Hash);
30e1eab5 138 virtual string Describe();
17caf1b1 139 virtual string MD5Sum() {return MD5;};
03e39e59
AL
140
141 pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
30e1eab5
AL
142 pkgRecords *Recs,pkgCache::VerIterator const &Version,
143 string &StoreFilename);
03e39e59
AL
144};
145
0118833a 146#endif