]>
git.saurik.com Git - apt.git/blob - apt-pkg/acquire-item.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: acquire-item.h,v 1.26 2003/02/02 03:13:13 doogie Exp $
4 /* ######################################################################
6 Acquire Item - Item to acquire
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
10 register all the URI's they wish to fetch at the initial moment.
12 Two item classes are provided to provide functionality for downloading
13 of Index files and downloading of Packages.
15 A Archive class is provided for downloading .deb files. It does Md5
16 checking and source location as well as a retry algorithm.
18 ##################################################################### */
20 #ifndef PKGLIB_ACQUIRE_ITEM_H
21 #define PKGLIB_ACQUIRE_ITEM_H
23 #include <apt-pkg/acquire.h>
24 #include <apt-pkg/indexfile.h>
25 #include <apt-pkg/pkgrecords.h>
28 #pragma interface "apt-pkg/acquire-item.h"
32 class pkgAcquire::Item
36 // Some private helper methods for registering URIs
38 inline void QueueURI(ItemDesc
&Item
)
39 {Owner
->Enqueue(Item
);};
40 inline void Dequeue() {Owner
->Dequeue(this);};
42 // Safe rename function with timestamp preservation
43 void Rename(string From
,string To
);
48 enum {StatIdle
, StatFetching
, StatDone
, StatError
} Status
;
50 unsigned long FileSize
;
51 unsigned long PartialSize
;
57 // Number of queues we are inserted into
58 unsigned int QueueCounter
;
60 // File to write the fetch into
63 // Action members invoked by the worker
64 virtual void Failed(string Message
,pkgAcquire::MethodConfig
*Cnf
);
65 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
,
66 pkgAcquire::MethodConfig
*Cnf
);
67 virtual void Start(string Message
,unsigned long Size
);
68 virtual string
Custom600Headers() {return string();};
69 virtual string
DescURI() = 0;
70 virtual void Finished() {};
73 virtual string
MD5Sum() {return string();};
74 pkgAcquire
*GetOwner() {return Owner
;};
76 Item(pkgAcquire
*Owner
);
80 // Item class for index files
81 class pkgAcqIndex
: public pkgAcquire::Item
87 pkgAcquire::ItemDesc Desc
;
92 // Specialized action members
93 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
,
94 pkgAcquire::MethodConfig
*Cnf
);
95 virtual string
Custom600Headers();
96 virtual string
DescURI() {return RealURI
+ ".gz";};
98 pkgAcqIndex(pkgAcquire
*Owner
,string URI
,string URIDesc
,
102 // Item class for index files
103 class pkgAcqIndexRel
: public pkgAcquire::Item
107 pkgAcquire::ItemDesc Desc
;
112 // Specialized action members
113 virtual void Failed(string Message
,pkgAcquire::MethodConfig
*Cnf
);
114 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
,
115 pkgAcquire::MethodConfig
*Cnf
);
116 virtual string
Custom600Headers();
117 virtual string
DescURI() {return RealURI
;};
119 pkgAcqIndexRel(pkgAcquire
*Owner
,string URI
,string URIDesc
,
123 // Item class for archive files
124 class pkgAcqArchive
: public pkgAcquire::Item
128 // State information for the retry mechanism
129 pkgCache::VerIterator Version
;
130 pkgAcquire::ItemDesc Desc
;
131 pkgSourceList
*Sources
;
134 string
&StoreFilename
;
135 pkgCache::VerFileIterator Vf
;
136 unsigned int Retries
;
138 // Queue the next available file for download.
143 // Specialized action members
144 virtual void Failed(string Message
,pkgAcquire::MethodConfig
*Cnf
);
145 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
,
146 pkgAcquire::MethodConfig
*Cnf
);
147 virtual string
MD5Sum() {return MD5
;};
148 virtual string
DescURI() {return Desc
.URI
;};
149 virtual void Finished();
151 pkgAcqArchive(pkgAcquire
*Owner
,pkgSourceList
*Sources
,
152 pkgRecords
*Recs
,pkgCache::VerIterator
const &Version
,
153 string
&StoreFilename
);
156 // Fetch a generic file to the current directory
157 class pkgAcqFile
: public pkgAcquire::Item
159 pkgAcquire::ItemDesc Desc
;
161 unsigned int Retries
;
165 // Specialized action members
166 virtual void Failed(string Message
,pkgAcquire::MethodConfig
*Cnf
);
167 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
,
168 pkgAcquire::MethodConfig
*Cnf
);
169 virtual string
MD5Sum() {return Md5Hash
;};
170 virtual string
DescURI() {return Desc
.URI
;};
172 pkgAcqFile(pkgAcquire
*Owner
,string URI
,string MD5
,unsigned long Size
,
173 string Desc
,string ShortDesc
);