1 // -*- mode: cpp; mode: fold -*-
3 /* ######################################################################
5 Acquire Method - Method helper class + functions
7 These functions are designed to be used within the method task to
8 ease communication with APT.
10 ##################################################################### */
13 /** \addtogroup acquire
16 * \file acquire-method.h
19 #ifndef PKGLIB_ACQUIRE_METHOD_H
20 #define PKGLIB_ACQUIRE_METHOD_H
22 #include <apt-pkg/hashes.h>
23 #include <apt-pkg/macros.h>
31 #ifndef APT_8_CLEANER_HEADERS
32 #include <apt-pkg/configuration.h>
33 #include <apt-pkg/strutl.h>
50 HashStringList ExpectedHashes
;
51 // a maximum size we will download, this can be the exact filesize
52 // for when we know it or a arbitrary limit when we don't know the
53 // filesize (like a InRelease file)
54 unsigned long long MaximumSize
;
64 HashStringList Hashes
;
65 std::vector
<std::string
> GPGVOutput
;
69 unsigned long long Size
;
70 unsigned long long ResumePoint
;
72 void TakeHashes(class Hashes
&Hash
);
74 virtual ~FetchResult();
80 std::vector
<std::string
> Messages
;
83 std::string FailReason
;
84 std::string UsedMirror
;
87 // Handlers for messages
88 virtual bool Configuration(std::string Message
);
89 virtual bool Fetch(FetchItem
* /*Item*/) {return true;};
90 virtual bool URIAcquire(std::string
const &/*Message*/, FetchItem
*Itm
) { return Fetch(Itm
); };
93 void Fail(bool Transient
= false);
94 inline void Fail(const char *Why
, bool Transient
= false) {Fail(std::string(Why
),Transient
);};
95 virtual void Fail(std::string Why
, bool Transient
= false);
96 virtual void URIStart(FetchResult
&Res
);
97 virtual void URIDone(FetchResult
&Res
,FetchResult
*Alt
= 0);
99 bool MediaFail(std::string Required
,std::string Drive
);
100 virtual void Exit() {};
102 void PrintStatus(char const * const header
, const char* Format
, va_list &args
) const;
105 enum CnfFlags
{SingleInstance
= (1<<0),
106 Pipeline
= (1<<1), SendConfig
= (1<<2),
107 LocalOnly
= (1<<3), NeedsCleanup
= (1<<4),
110 void Log(const char *Format
,...);
111 void Status(const char *Format
,...);
113 void Redirect(const std::string
&NewURI
);
115 int Run(bool Single
= false);
116 inline void SetFailReason(std::string Msg
) {FailReason
= Msg
;};
117 inline void SetIP(std::string aIP
) {IP
= aIP
;};
119 pkgAcqMethod(const char *Ver
,unsigned long Flags
= 0);
120 virtual ~pkgAcqMethod();
121 void DropPrivsOrDie();
123 APT_HIDDEN
void Dequeue();