acquire-method.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: acquire-method.h,v 1.15.2.1 2003/12/24 23:09:17 mdz Exp $
  4. /* ######################################################################
  5. Acquire Method - Method helper class + functions
  6. These functions are designed to be used within the method task to
  7. ease communication with APT.
  8. ##################################################################### */
  9. /*}}}*/
  10. #ifndef PKGLIB_ACQUIRE_METHOD_H
  11. #define PKGLIB_ACQUIRE_METHOD_H
  12. #include <apt-pkg/configuration.h>
  13. #include <apt-pkg/strutl.h>
  14. #ifdef __GNUG__
  15. #pragma interface "apt-pkg/acquire-method.h"
  16. #endif
  17. class Hashes;
  18. class pkgAcqMethod
  19. {
  20. protected:
  21. struct FetchItem
  22. {
  23. FetchItem *Next;
  24. string Uri;
  25. string DestFile;
  26. time_t LastModified;
  27. bool IndexFile;
  28. };
  29. struct FetchResult
  30. {
  31. string MD5Sum;
  32. string SHA1Sum;
  33. vector<string> GPGVOutput;
  34. time_t LastModified;
  35. bool IMSHit;
  36. string Filename;
  37. unsigned long Size;
  38. unsigned long ResumePoint;
  39. void TakeHashes(Hashes &Hash);
  40. FetchResult();
  41. };
  42. // State
  43. vector<string> Messages;
  44. FetchItem *Queue;
  45. FetchItem *QueueBack;
  46. string FailReason;
  47. string UsedMirror;
  48. string IP;
  49. // Handlers for messages
  50. virtual bool Configuration(string Message);
  51. virtual bool Fetch(FetchItem * /*Item*/) {return true;};
  52. // Outgoing messages
  53. void Fail(bool Transient = false);
  54. inline void Fail(const char *Why, bool Transient = false) {Fail(string(Why),Transient);};
  55. virtual void Fail(string Why, bool Transient = false);
  56. virtual void URIStart(FetchResult &Res);
  57. virtual void URIDone(FetchResult &Res,FetchResult *Alt = 0);
  58. bool MediaFail(string Required,string Drive);
  59. virtual void Exit() {};
  60. public:
  61. enum CnfFlags {SingleInstance = (1<<0),
  62. Pipeline = (1<<1), SendConfig = (1<<2),
  63. LocalOnly = (1<<3), NeedsCleanup = (1<<4),
  64. Removable = (1<<5)};
  65. void Log(const char *Format,...);
  66. void Status(const char *Format,...);
  67. int Run(bool Single = false);
  68. inline void SetFailReason(string Msg) {FailReason = Msg;};
  69. inline void SetIP(string aIP) {IP = aIP;};
  70. pkgAcqMethod(const char *Ver,unsigned long Flags = 0);
  71. virtual ~pkgAcqMethod() {};
  72. };
  73. #endif