]>
Commit | Line | Data |
---|---|---|
0118833a AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
40285ffd | 3 | // $Id: acquire-item.h,v 1.26 2003/02/02 03:13:13 doogie 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> |
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 | |
32 | class 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; |
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; |
ab559b35 | 70 | virtual void Finished() {}; |
17caf1b1 AL |
71 | |
72 | // Inquire functions | |
f7a08e33 | 73 | virtual string MD5Sum() {return string();}; |
c5ccf175 AL |
74 | pkgAcquire *GetOwner() {return Owner;}; |
75 | ||
0118833a AL |
76 | Item(pkgAcquire *Owner); |
77 | virtual ~Item(); | |
78 | }; | |
79 | ||
80 | // Item class for index files | |
81 | class pkgAcqIndex : public pkgAcquire::Item | |
82 | { | |
83 | protected: | |
84 | ||
8b89e57f | 85 | bool Decompression; |
bfd22fc0 | 86 | bool Erase; |
8267fe24 | 87 | pkgAcquire::ItemDesc Desc; |
b2e465d6 | 88 | string RealURI; |
0118833a AL |
89 | |
90 | public: | |
91 | ||
17caf1b1 | 92 | // Specialized action members |
debc84b2 | 93 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); |
459681d3 AL |
94 | virtual void Done(string Message,unsigned long Size,string Md5Hash, |
95 | pkgAcquire::MethodConfig *Cnf); | |
0a8a80e5 | 96 | virtual string Custom600Headers(); |
40285ffd | 97 | virtual string DescURI() {return RealURI + ".gz";}; |
0118833a | 98 | |
b2e465d6 AL |
99 | pkgAcqIndex(pkgAcquire *Owner,string URI,string URIDesc, |
100 | string ShortDesct); | |
0118833a AL |
101 | }; |
102 | ||
103 | // Item class for index files | |
104 | class pkgAcqIndexRel : public pkgAcquire::Item | |
105 | { | |
106 | protected: | |
107 | ||
8267fe24 | 108 | pkgAcquire::ItemDesc Desc; |
b2e465d6 | 109 | string RealURI; |
0118833a AL |
110 | |
111 | public: | |
112 | ||
17caf1b1 | 113 | // Specialized action members |
681d76d0 | 114 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); |
459681d3 AL |
115 | virtual void Done(string Message,unsigned long Size,string Md5Hash, |
116 | pkgAcquire::MethodConfig *Cnf); | |
0a8a80e5 | 117 | virtual string Custom600Headers(); |
b2e465d6 | 118 | virtual string DescURI() {return RealURI;}; |
0a8a80e5 | 119 | |
b2e465d6 AL |
120 | pkgAcqIndexRel(pkgAcquire *Owner,string URI,string URIDesc, |
121 | string ShortDesct); | |
0118833a AL |
122 | }; |
123 | ||
03e39e59 AL |
124 | // Item class for archive files |
125 | class pkgAcqArchive : public pkgAcquire::Item | |
126 | { | |
127 | protected: | |
128 | ||
17caf1b1 | 129 | // State information for the retry mechanism |
03e39e59 AL |
130 | pkgCache::VerIterator Version; |
131 | pkgAcquire::ItemDesc Desc; | |
132 | pkgSourceList *Sources; | |
133 | pkgRecords *Recs; | |
134 | string MD5; | |
30e1eab5 | 135 | string &StoreFilename; |
b185acc2 | 136 | pkgCache::VerFileIterator Vf; |
7d8afa39 | 137 | unsigned int Retries; |
17caf1b1 AL |
138 | |
139 | // Queue the next available file for download. | |
b185acc2 | 140 | bool QueueNext(); |
03e39e59 AL |
141 | |
142 | public: | |
143 | ||
17caf1b1 | 144 | // Specialized action members |
7d8afa39 | 145 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); |
459681d3 AL |
146 | virtual void Done(string Message,unsigned long Size,string Md5Hash, |
147 | pkgAcquire::MethodConfig *Cnf); | |
17caf1b1 | 148 | virtual string MD5Sum() {return MD5;}; |
36375005 | 149 | virtual string DescURI() {return Desc.URI;}; |
ab559b35 | 150 | virtual void Finished(); |
03e39e59 AL |
151 | |
152 | pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, | |
30e1eab5 AL |
153 | pkgRecords *Recs,pkgCache::VerIterator const &Version, |
154 | string &StoreFilename); | |
03e39e59 AL |
155 | }; |
156 | ||
36375005 AL |
157 | // Fetch a generic file to the current directory |
158 | class pkgAcqFile : public pkgAcquire::Item | |
159 | { | |
160 | pkgAcquire::ItemDesc Desc; | |
b3c39978 | 161 | string Md5Hash; |
08cfc005 | 162 | unsigned int Retries; |
36375005 AL |
163 | |
164 | public: | |
165 | ||
166 | // Specialized action members | |
08cfc005 | 167 | virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); |
459681d3 AL |
168 | virtual void Done(string Message,unsigned long Size,string Md5Hash, |
169 | pkgAcquire::MethodConfig *Cnf); | |
b3c39978 | 170 | virtual string MD5Sum() {return Md5Hash;}; |
36375005 AL |
171 | virtual string DescURI() {return Desc.URI;}; |
172 | ||
173 | pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,unsigned long Size, | |
174 | string Desc,string ShortDesc); | |
175 | }; | |
176 | ||
0118833a | 177 | #endif |