]>
git.saurik.com Git - apt.git/blob - apt-pkg/acquire-item.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: acquire-item.h,v 1.20 1999/05/24 03:39:37 jgg 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/sourcelist.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 virtual void Start(string Message
,unsigned long Size
);
67 virtual string
Custom600Headers() {return string();};
68 virtual string
DescURI() = 0;
69 virtual void Finished() {};
72 virtual string
MD5Sum() {return string();};
74 Item(pkgAcquire
*Owner
);
78 // Item class for index files
79 class pkgAcqIndex
: public pkgAcquire::Item
83 const pkgSourceList::Item
*Location
;
86 pkgAcquire::ItemDesc Desc
;
90 // Specialized action members
91 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
);
92 virtual string
Custom600Headers();
93 virtual string
DescURI() {return Location
->PackagesURI();};
95 pkgAcqIndex(pkgAcquire
*Owner
,const pkgSourceList::Item
*Location
);
98 // Item class for index files
99 class pkgAcqIndexRel
: public pkgAcquire::Item
103 const pkgSourceList::Item
*Location
;
104 pkgAcquire::ItemDesc Desc
;
108 // Specialized action members
109 virtual void Failed(string Message
,pkgAcquire::MethodConfig
*Cnf
);
110 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
);
111 virtual string
Custom600Headers();
112 virtual string
DescURI() {return Location
->ReleaseURI();};
114 pkgAcqIndexRel(pkgAcquire
*Owner
,const pkgSourceList::Item
*Location
);
117 // Item class for archive files
118 class pkgAcqArchive
: public pkgAcquire::Item
122 // State information for the retry mechanism
123 pkgCache::VerIterator Version
;
124 pkgAcquire::ItemDesc Desc
;
125 pkgSourceList
*Sources
;
128 string
&StoreFilename
;
129 pkgCache::VerFileIterator Vf
;
130 unsigned int Retries
;
132 // Queue the next available file for download.
137 // Specialized action members
138 virtual void Failed(string Message
,pkgAcquire::MethodConfig
*Cnf
);
139 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
);
140 virtual string
MD5Sum() {return MD5
;};
141 virtual string
DescURI() {return Desc
.URI
;};
142 virtual void Finished();
144 pkgAcqArchive(pkgAcquire
*Owner
,pkgSourceList
*Sources
,
145 pkgRecords
*Recs
,pkgCache::VerIterator
const &Version
,
146 string
&StoreFilename
);
149 // Fetch a generic file to the current directory
150 class pkgAcqFile
: public pkgAcquire::Item
152 pkgAcquire::ItemDesc Desc
;
157 // Specialized action members
158 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
);
159 virtual string
MD5Sum() {return MD5
;};
160 virtual string
DescURI() {return Desc
.URI
;};
162 pkgAcqFile(pkgAcquire
*Owner
,string URI
,string MD5
,unsigned long Size
,
163 string Desc
,string ShortDesc
);