]> git.saurik.com Git - apt.git/blob - apt-pkg/acquire-item.h
4a2a4e38559148fbe7efe43ae70d3b4b9679ae37
[apt.git] / apt-pkg / acquire-item.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: acquire-item.h,v 1.11 1998/12/11 06:01:25 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 for 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.
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 pkgAcquire *Owner;
37 inline void QueueURI(ItemDesc &Item)
38 {Owner->Enqueue(Item);};
39
40 void Rename(string From,string To);
41
42 public:
43
44 // State of the item
45 enum {StatIdle, StatFetching, StatDone, StatError} Status;
46 string ErrorText;
47 unsigned long FileSize;
48 char *Mode;
49 unsigned long ID;
50 bool Complete;
51 bool Local;
52
53 // Number of queues we are inserted into
54 unsigned int QueueCounter;
55
56 // File to write the fetch into
57 string DestFile;
58
59 virtual void Failed(string Message);
60 virtual void Done(string Message,unsigned long Size,string Md5Hash);
61 virtual void Start(string Message,unsigned long Size);
62 virtual string Describe() = 0;
63
64 virtual string Custom600Headers() {return string();};
65
66 Item(pkgAcquire *Owner);
67 virtual ~Item();
68 };
69
70 // Item class for index files
71 class pkgAcqIndex : public pkgAcquire::Item
72 {
73 protected:
74
75 const pkgSourceList::Item *Location;
76 bool Decompression;
77 bool Erase;
78 pkgAcquire::ItemDesc Desc;
79
80 public:
81
82 virtual void Done(string Message,unsigned long Size,string Md5Hash);
83 virtual string Custom600Headers();
84 virtual string Describe();
85
86 pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location);
87 };
88
89 // Item class for index files
90 class pkgAcqIndexRel : public pkgAcquire::Item
91 {
92 protected:
93
94 const pkgSourceList::Item *Location;
95 pkgAcquire::ItemDesc Desc;
96
97 public:
98
99 virtual void Done(string Message,unsigned long Size,string Md5Hash);
100 virtual string Custom600Headers();
101 virtual string Describe();
102
103 pkgAcqIndexRel(pkgAcquire *Owner,const pkgSourceList::Item *Location);
104 };
105
106 // Item class for archive files
107 class pkgAcqArchive : public pkgAcquire::Item
108 {
109 protected:
110
111 pkgCache::VerIterator Version;
112 pkgAcquire::ItemDesc Desc;
113 pkgSourceList *Sources;
114 pkgRecords *Recs;
115 string MD5;
116 string &StoreFilename;
117 pkgCache::VerFileIterator Vf;
118
119 bool QueueNext();
120
121 public:
122
123 virtual void Done(string Message,unsigned long Size,string Md5Hash);
124 virtual string Describe();
125
126 pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
127 pkgRecords *Recs,pkgCache::VerIterator const &Version,
128 string &StoreFilename);
129 };
130
131 #endif