]> git.saurik.com Git - apt.git/blob - apt-pkg/acquire-item.h
Speeling fix
[apt.git] / apt-pkg / acquire-item.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: acquire-item.h,v 1.24 2000/01/27 04:15:09 jgg Exp $
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
10 register all the URI's they wish to fetch at the initial moment.
11
12 Two item classes are provided to provide functionality for downloading
13 of Index files and downloading of Packages.
14
15 A Archive class is provided for downloading .deb files. It does Md5
16 checking and source location as well as a retry algorithm.
17
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>
25 #include <apt-pkg/pkgrecords.h>
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
36 // Some private helper methods for registering URIs
37 pkgAcquire *Owner;
38 inline void QueueURI(ItemDesc &Item)
39 {Owner->Enqueue(Item);};
40 inline void Dequeue() {Owner->Dequeue(this);};
41
42 // Safe rename function with timestamp preservation
43 void Rename(string From,string To);
44
45 public:
46
47 // State of the item
48 enum {StatIdle, StatFetching, StatDone, StatError} Status;
49 string ErrorText;
50 unsigned long FileSize;
51 unsigned long PartialSize;
52 char *Mode;
53 unsigned long ID;
54 bool Complete;
55 bool Local;
56
57 // Number of queues we are inserted into
58 unsigned int QueueCounter;
59
60 // File to write the fetch into
61 string DestFile;
62
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() {};
71
72 // Inquire functions
73 virtual string MD5Sum() {return string();};
74 pkgAcquire *GetOwner() {return Owner;};
75
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
85 const pkgSourceList::Item *Location;
86 bool Decompression;
87 bool Erase;
88 pkgAcquire::ItemDesc Desc;
89
90 public:
91
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 Location->PackagesURI();};
97
98 pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location);
99 };
100
101 // Item class for index files
102 class pkgAcqIndexRel : public pkgAcquire::Item
103 {
104 protected:
105
106 const pkgSourceList::Item *Location;
107 pkgAcquire::ItemDesc Desc;
108
109 public:
110
111 // Specialized action members
112 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
113 virtual void Done(string Message,unsigned long Size,string Md5Hash,
114 pkgAcquire::MethodConfig *Cnf);
115 virtual string Custom600Headers();
116 virtual string DescURI() {return Location->ReleaseURI();};
117
118 pkgAcqIndexRel(pkgAcquire *Owner,const pkgSourceList::Item *Location);
119 };
120
121 // Item class for archive files
122 class pkgAcqArchive : public pkgAcquire::Item
123 {
124 protected:
125
126 // State information for the retry mechanism
127 pkgCache::VerIterator Version;
128 pkgAcquire::ItemDesc Desc;
129 pkgSourceList *Sources;
130 pkgRecords *Recs;
131 string MD5;
132 string &StoreFilename;
133 pkgCache::VerFileIterator Vf;
134 unsigned int Retries;
135
136 // Queue the next available file for download.
137 bool QueueNext();
138
139 public:
140
141 // Specialized action members
142 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
143 virtual void Done(string Message,unsigned long Size,string Md5Hash,
144 pkgAcquire::MethodConfig *Cnf);
145 virtual string MD5Sum() {return MD5;};
146 virtual string DescURI() {return Desc.URI;};
147 virtual void Finished();
148
149 pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
150 pkgRecords *Recs,pkgCache::VerIterator const &Version,
151 string &StoreFilename);
152 };
153
154 // Fetch a generic file to the current directory
155 class pkgAcqFile : public pkgAcquire::Item
156 {
157 pkgAcquire::ItemDesc Desc;
158 string Md5Hash;
159 unsigned int Retries;
160
161 public:
162
163 // Specialized action members
164 virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
165 virtual void Done(string Message,unsigned long Size,string Md5Hash,
166 pkgAcquire::MethodConfig *Cnf);
167 virtual string MD5Sum() {return Md5Hash;};
168 virtual string DescURI() {return Desc.URI;};
169
170 pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,unsigned long Size,
171 string Desc,string ShortDesc);
172 };
173
174 #endif