]> git.saurik.com Git - apt.git/blob - apt-pkg/metaindex.h
add sources.list Check-Valid-Until and Valid-Until-{Max,Min} options
[apt.git] / apt-pkg / metaindex.h
1 #ifndef PKGLIB_METAINDEX_H
2 #define PKGLIB_METAINDEX_H
3
4 #include <apt-pkg/indexfile.h>
5 #include <apt-pkg/init.h>
6
7 #include <stddef.h>
8
9 #include <string>
10 #include <vector>
11
12 #ifndef APT_10_CLEANER_HEADERS
13 #include <apt-pkg/pkgcache.h>
14 class pkgCacheGenerator;
15 class OpProgress;
16 #endif
17 #ifndef APT_8_CLEANER_HEADERS
18 #include <apt-pkg/srcrecords.h>
19 #include <apt-pkg/pkgrecords.h>
20 #include <apt-pkg/vendor.h>
21 using std::string;
22 #endif
23
24 class pkgAcquire;
25 class IndexTarget;
26 class pkgCacheGenerator;
27 class OpProgress;
28
29 class metaIndex
30 {
31 public:
32 APT_IGNORE_DEPRECATED_PUSH
33 struct checkSum
34 {
35 std::string MetaKeyFilename;
36 HashStringList Hashes;
37 unsigned long long Size;
38
39 APT_DEPRECATED HashString Hash;
40 };
41 APT_IGNORE_DEPRECATED_POP
42
43 enum APT_HIDDEN TriState {
44 TRI_YES, TRI_DONTCARE, TRI_NO, TRI_UNSET
45 };
46 private:
47 void * const d;
48 protected:
49 std::vector <pkgIndexFile *> *Indexes;
50 // parsed from the sources.list
51 const char *Type;
52 std::string URI;
53 std::string Dist;
54 TriState Trusted;
55 TriState LoadedSuccessfully;
56
57 // parsed from a file
58 std::string Suite;
59 std::string Codename;
60 time_t Date;
61 time_t ValidUntil;
62 bool SupportsAcquireByHash;
63 std::map<std::string, checkSum *> Entries;
64
65 public:
66 // Various accessors
67 std::string GetURI() const;
68 std::string GetDist() const;
69 const char* GetType() const;
70 TriState GetTrusted() const;
71
72 std::string GetCodename() const;
73 std::string GetSuite() const;
74 bool GetSupportsAcquireByHash() const;
75 time_t GetValidUntil() const;
76 time_t GetDate() const;
77
78 std::string GetExpectedDist() const;
79 bool CheckDist(std::string const &MaybeDist) const;
80
81 // Interface for acquire
82 virtual std::string Describe() const;
83 virtual std::string ArchiveURI(std::string const& File) const = 0;
84 virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) = 0;
85 virtual std::vector<IndexTarget> GetIndexTargets() const = 0;
86 virtual std::vector<pkgIndexFile *> *GetIndexFiles() = 0;
87 virtual bool IsTrusted() const = 0;
88 virtual bool Load(std::string const &Filename, std::string * const ErrorText) = 0;
89 /** @return a new metaIndex object based on this one, but without information from #Load */
90 virtual metaIndex * UnloadedClone() const = 0;
91 // the given metaIndex is potentially invalid after this call and should be deleted
92 void swapLoad(metaIndex * const OldMetaIndex);
93
94 // Lookup functions for parsed Hashes
95 checkSum *Lookup(std::string const &MetaKey) const;
96 /** \brief tests if a checksum for this file is available */
97 bool Exists(std::string const &MetaKey) const;
98 std::vector<std::string> MetaKeys() const;
99 TriState GetLoadedSuccessfully() const;
100
101 // Interfaces for pkgCacheGen
102 virtual pkgCache::RlsFileIterator FindInCache(pkgCache &Cache, bool const ModifyCheck) const;
103 virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
104
105
106 metaIndex(std::string const &URI, std::string const &Dist,
107 char const * const Type);
108 virtual ~metaIndex();
109 };
110
111 #endif