apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

acquire-method.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  Acquire Method - Method helper class + functions
6 
7  These functions are designed to be used within the method task to
8  ease communication with APT.
9 
10  ##################################################################### */
11  /*}}}*/
12 
13 /** \addtogroup acquire
14  * @{
15  *
16  * \file acquire-method.h
17  */
18 
19 #ifndef PKGLIB_ACQUIRE_METHOD_H
20 #define PKGLIB_ACQUIRE_METHOD_H
21 
22 #include <apt-pkg/hashes.h>
23 #include <apt-pkg/macros.h>
24 
25 #include <stdarg.h>
26 #include <time.h>
27 
28 #include <string>
29 #include <unordered_map>
30 #include <vector>
31 
32 
34 {
35  protected:
36 
37  struct FetchItem
38  {
40 
41  std::string Uri;
42  std::string DestFile;
44  time_t LastModified;
45  bool IndexFile;
46  bool FailIgnore;
48  // a maximum size we will download, this can be the exact filesize
49  // for when we know it or a arbitrary limit when we don't know the
50  // filesize (like a InRelease file)
51  unsigned long long MaximumSize;
52 
53  FetchItem();
54  virtual ~~FetchItem();
55  std::string Proxy(); // For internal use only.
56  void Proxy(std::string const &Proxy) APT_HIDDEN;
57 
58  private:
59  struct Private;
60  Private *const d;
61  };
62 
63  struct FetchResult
64  {
66  std::vector<std::string> GPGVOutput;
67  time_t LastModified;
68  bool IMSHit;
69  std::string Filename;
70  unsigned long long Size;
71  unsigned long long ResumePoint;
72 
73  void TakeHashes(class Hashes &Hash);
74  FetchResult();
75  virtual ~~FetchResult();
76  private:
77  void * const d;
78  };
79 
80  // State
81  std::vector<std::string> Messages;
84  std::string FailReason;
85  std::string UsedMirror;
86  std::string IP;
87 
88  // Handlers for messages
89  virtual bool Configuration(std::string Message);
90  virtual bool Fetch(FetchItem * /*Item*/) {return true;};
91  virtual bool URIAcquire(std::string const &/*Message*/, FetchItem *Itm) { return Fetch(Itm); };
92 
93  // Outgoing messages
94  void Fail(bool Transient = false);
95  inline void Fail(const char *Why, bool Transient = false) {Fail(std::string(Why),Transient);};
96  virtual void Fail(std::string Why, bool Transient = false);
97  virtual void URIStart(FetchResult &Res);
98  virtual void URIDone(FetchResult &Res,FetchResult *Alt = 0);
99  void SendMessage(std::string const &header, std::unordered_map<std::string, std::string> &&fields);
100 
101  bool MediaFail(std::string Required,std::string Drive);
102  virtual void Exit() {};
103 
104  APT_DEPRECATED_MSG("Use SendMessage instead") void PrintStatus(char const * const header, const char* Format, va_list &args) const;
105 
106  public:
107  enum CnfFlags
108  {
109  SingleInstance = (1 << 0),
110  Pipeline = (1 << 1),
111  SendConfig = (1 << 2),
112  LocalOnly = (1 << 3),
113  NeedsCleanup = (1 << 4),
114  Removable = (1 << 5),
115  AuxRequests = (1 << 6),
116  SendURIEncoded = (1 << 7),
117  };
118 
119  void Log(const char *Format,...);
120  void Status(const char *Format,...);
121 
122  void Redirect(const std::string &NewURI);
123 
124  int Run(bool Single = false);
125  inline void SetFailReason(std::string Msg) {FailReason = Msg;};
126  inline void SetIP(std::string aIP) {IP = aIP;};
127 
128  pkgAcqMethod(const char *Ver,unsigned long Flags = 0);
129  virtual ~~pkgAcqMethod();
130  void DropPrivsOrDie();
131  private:
132  APT_HIDDEN void Dequeue();
133 };
134 
135 /** @} */
136 
137 #endif
I Status
Definition: hashes.h:170
std::string UsedMirror
void Fail(const char *Why, bool Transient=false)
void SetIP(std::string aIP)
FetchItem * QueueBack
virtual void Exit()
virtual bool Fetch(FetchItem *)
void SetFailReason(std::string Msg)
std::vector< std::string > Messages
virtual bool URIAcquire(std::string const &, FetchItem *Itm)
std::string IP
std::string FailReason
FetchItem * Queue
APT_DEPRECATED_MSG("Use SendMessage instead") void PrintStatus(char const *const header
URI Proxy
Definition: ftp.cc:66
#define APT_PUBLIC
Definition: macros.h:77
#define APT_HIDDEN
Definition: macros.h:78
HashStringList ExpectedHashes
unsigned long long MaximumSize
unsigned long long Size
std::vector< std::string > GPGVOutput
unsigned long long ResumePoint