|
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 <apt-pkg/configuration.h> 00024 #include <apt-pkg/strutl.h> 00025 00026 #include <stdarg.h> 00027 00028 class Hashes; 00029 class pkgAcqMethod 00030 { 00031 protected: 00032 00033 struct FetchItem 00034 { 00035 FetchItem *Next; 00036 00037 string Uri; 00038 string DestFile; 00039 time_t LastModified; 00040 bool IndexFile; 00041 bool FailIgnore; 00042 }; 00043 00044 struct FetchResult 00045 { 00046 string MD5Sum; 00047 string SHA1Sum; 00048 string SHA256Sum; 00049 vector<string> GPGVOutput; 00050 time_t LastModified; 00051 bool IMSHit; 00052 string Filename; 00053 unsigned long Size; 00054 unsigned long ResumePoint; 00055 00056 void TakeHashes(Hashes &Hash); 00057 FetchResult(); 00058 }; 00059 00060 // State 00061 vector<string> Messages; 00062 FetchItem *Queue; 00063 FetchItem *QueueBack; 00064 string FailReason; 00065 string UsedMirror; 00066 string IP; 00067 00068 // Handlers for messages 00069 virtual bool Configuration(string Message); 00070 virtual bool Fetch(FetchItem * /*Item*/) {return true;}; 00071 00072 // Outgoing messages 00073 void Fail(bool Transient = false); 00074 inline void Fail(const char *Why, bool Transient = false) {Fail(string(Why),Transient);}; 00075 virtual void Fail(string Why, bool Transient = false); 00076 virtual void URIStart(FetchResult &Res); 00077 virtual void URIDone(FetchResult &Res,FetchResult *Alt = 0); 00078 00079 bool MediaFail(string Required,string Drive); 00080 virtual void Exit() {}; 00081 00082 void PrintStatus(char const * const header, const char* Format, va_list &args) const; 00083 00084 public: 00085 enum CnfFlags {SingleInstance = (1<<0), 00086 Pipeline = (1<<1), SendConfig = (1<<2), 00087 LocalOnly = (1<<3), NeedsCleanup = (1<<4), 00088 Removable = (1<<5)}; 00089 00090 void Log(const char *Format,...); 00091 void Status(const char *Format,...); 00092 00093 void Redirect(const string &NewURI); 00094 00095 int Run(bool Single = false); 00096 inline void SetFailReason(string Msg) {FailReason = Msg;}; 00097 inline void SetIP(string aIP) {IP = aIP;}; 00098 00099 pkgAcqMethod(const char *Ver,unsigned long Flags = 0); 00100 virtual ~pkgAcqMethod() {}; 00101 }; 00102 00105 #endif
1.7.4