]>
git.saurik.com Git - apt.git/blob - apt-pkg/acquire-item.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: acquire-item.h,v 1.16 1999/02/01 02:22:11 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
;
56 // Number of queues we are inserted into
57 unsigned int QueueCounter
;
59 // File to write the fetch into
62 // Action members invoked by the worker
63 virtual void Failed(string Message
,pkgAcquire::MethodConfig
*Cnf
);
64 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
);
65 virtual void Start(string Message
,unsigned long Size
);
66 virtual string
Custom600Headers() {return string();};
69 virtual string
MD5Sum() {return string();};
70 virtual string
Describe() = 0;
72 Item(pkgAcquire
*Owner
);
76 // Item class for index files
77 class pkgAcqIndex
: public pkgAcquire::Item
81 const pkgSourceList::Item
*Location
;
84 pkgAcquire::ItemDesc Desc
;
88 // Specialized action members
89 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
);
90 virtual string
Custom600Headers();
91 virtual string
Describe();
93 pkgAcqIndex(pkgAcquire
*Owner
,const pkgSourceList::Item
*Location
);
96 // Item class for index files
97 class pkgAcqIndexRel
: public pkgAcquire::Item
101 const pkgSourceList::Item
*Location
;
102 pkgAcquire::ItemDesc Desc
;
106 // Specialized action members
107 virtual void Failed(string Message
,pkgAcquire::MethodConfig
*Cnf
);
108 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
);
109 virtual string
Custom600Headers();
110 virtual string
Describe();
112 pkgAcqIndexRel(pkgAcquire
*Owner
,const pkgSourceList::Item
*Location
);
115 // Item class for archive files
116 class pkgAcqArchive
: public pkgAcquire::Item
120 // State information for the retry mechanism
121 pkgCache::VerIterator Version
;
122 pkgAcquire::ItemDesc Desc
;
123 pkgSourceList
*Sources
;
126 string
&StoreFilename
;
127 pkgCache::VerFileIterator Vf
;
128 unsigned int Retries
;
130 // Queue the next available file for download.
135 // Specialized action members
136 virtual void Failed(string Message
,pkgAcquire::MethodConfig
*Cnf
);
137 virtual void Done(string Message
,unsigned long Size
,string Md5Hash
);
138 virtual string
Describe();
139 virtual string
MD5Sum() {return MD5
;};
141 pkgAcqArchive(pkgAcquire
*Owner
,pkgSourceList
*Sources
,
142 pkgRecords
*Recs
,pkgCache::VerIterator
const &Version
,
143 string
&StoreFilename
);