acquire-method.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. /** \addtogroup acquire
  11. * @{
  12. *
  13. * \file acquire-method.h
  14. */
  15. #ifndef PKGLIB_ACQUIRE_METHOD_H
  16. #define PKGLIB_ACQUIRE_METHOD_H
  17. #include <apt-pkg/configuration.h>
  18. #include <apt-pkg/strutl.h>
  19. class Hashes;
  20. class pkgAcqMethod
  21. {
  22. protected:
  23. struct FetchItem
  24. {
  25. FetchItem *Next;
  26. string Uri;
  27. string DestFile;
  28. time_t LastModified;
  29. bool IndexFile;
  30. };
  31. struct FetchResult
  32. {
  33. string MD5Sum;
  34. string SHA1Sum;
  35. vector<string> GPGVOutput;
  36. time_t LastModified;
  37. bool IMSHit;
  38. string Filename;
  39. unsigned long Size;
  40. unsigned long ResumePoint;
  41. void TakeHashes(Hashes &Hash);
  42. FetchResult();
  43. };
  44. // State
  45. vector<string> Messages;
  46. FetchItem *Queue;
  47. FetchItem *QueueBack;
  48. string FailExtra;
  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. void Fail(string Why, bool Transient = false);
  56. void URIStart(FetchResult &Res);
  57. 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 SetFailExtraMsg(string Msg) {FailExtra = Msg;};
  69. pkgAcqMethod(const char *Ver,unsigned long Flags = 0);
  70. virtual ~pkgAcqMethod() {};
  71. };
  72. /** @} */
  73. #endif