|
apt @VERSION@
|
00001 // -*- mode: cpp; mode: fold -*- 00002 // Description /*{{{*/ 00003 // $Id: acquire-method.h,v 1.15.2.1 2003/12/24 23:09:17 mdz Exp $ 00004 /* ###################################################################### 00005 00006 Acquire Method - Method helper class + functions 00007 00008 These functions are designed to be used within the method task to 00009 ease communication with APT. 00010 00011 ##################################################################### */ 00012 /*}}}*/ 00013 00020 #ifndef PKGLIB_ACQUIRE_METHOD_H 00021 #define PKGLIB_ACQUIRE_METHOD_H 00022 00023 #include <stdarg.h> 00024 00025 #include <string> 00026 #include <vector> 00027 00028 class Hashes; 00029 class pkgAcqMethod 00030 { 00031 protected: 00032 00033 struct FetchItem 00034 { 00035 FetchItem *Next; 00036 00037 std::string Uri; 00038 std::string DestFile; 00039 time_t LastModified; 00040 bool IndexFile; 00041 bool FailIgnore; 00042 }; 00043 00044 struct FetchResult 00045 { 00046 std::string MD5Sum; 00047 std::string SHA1Sum; 00048 std::string SHA256Sum; 00049 std::string SHA512Sum; 00050 std::vector<std::string> GPGVOutput; 00051 time_t LastModified; 00052 bool IMSHit; 00053 std::string Filename; 00054 unsigned long long Size; 00055 unsigned long long ResumePoint; 00056 00057 void TakeHashes(Hashes &Hash); 00058 FetchResult(); 00059 }; 00060 00061 // State 00062 std::vector<std::string> Messages; 00063 FetchItem *Queue; 00064 FetchItem *QueueBack; 00065 std::string FailReason; 00066 std::string UsedMirror; 00067 std::string IP; 00068 00069 // Handlers for messages 00070 virtual bool Configuration(std::string Message); 00071 virtual bool Fetch(FetchItem * /*Item*/) {return true;}; 00072 00073 // Outgoing messages 00074 void Fail(bool Transient = false); 00075 inline void Fail(const char *Why, bool Transient = false) {Fail(std::string(Why),Transient);}; 00076 virtual void Fail(std::string Why, bool Transient = false); 00077 virtual void URIStart(FetchResult &Res); 00078 virtual void URIDone(FetchResult &Res,FetchResult *Alt = 0); 00079 00080 bool MediaFail(std::string Required,std::string Drive); 00081 virtual void Exit() {}; 00082 00083 void PrintStatus(char const * const header, const char* Format, va_list &args) const; 00084 00085 public: 00086 enum CnfFlags {SingleInstance = (1<<0), 00087 Pipeline = (1<<1), SendConfig = (1<<2), 00088 LocalOnly = (1<<3), NeedsCleanup = (1<<4), 00089 Removable = (1<<5)}; 00090 00091 void Log(const char *Format,...); 00092 void Status(const char *Format,...); 00093 00094 void Redirect(const std::string &NewURI); 00095 00096 int Run(bool Single = false); 00097 inline void SetFailReason(std::string Msg) {FailReason = Msg;}; 00098 inline void SetIP(std::string aIP) {IP = aIP;}; 00099 00100 pkgAcqMethod(const char *Ver,unsigned long Flags = 0); 00101 virtual ~pkgAcqMethod() {}; 00102 }; 00103 00106 #endif
1.7.4