acquire-method.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. #ifdef __GNUG__
  20. #pragma interface "apt-pkg/acquire-method.h"
  21. #endif
  22. class Hashes;
  23. class pkgAcqMethod
  24. {
  25. protected:
  26. struct FetchItem
  27. {
  28. FetchItem *Next;
  29. string Uri;
  30. string DestFile;
  31. time_t LastModified;
  32. bool IndexFile;
  33. };
  34. struct FetchResult
  35. {
  36. string MD5Sum;
  37. string SHA1Sum;
  38. vector<string> GPGVOutput;
  39. time_t LastModified;
  40. bool IMSHit;
  41. string Filename;
  42. unsigned long Size;
  43. unsigned long ResumePoint;
  44. void TakeHashes(Hashes &Hash);
  45. FetchResult();
  46. };
  47. // State
  48. vector<string> Messages;
  49. FetchItem *Queue;
  50. FetchItem *QueueBack;
  51. string FailExtra;
  52. // Handlers for messages
  53. virtual bool Configuration(string Message);
  54. virtual bool Fetch(FetchItem * /*Item*/) {return true;};
  55. // Outgoing messages
  56. void Fail(bool Transient = false);
  57. inline void Fail(const char *Why, bool Transient = false) {Fail(string(Why),Transient);};
  58. void Fail(string Why, bool Transient = false);
  59. void URIStart(FetchResult &Res);
  60. void URIDone(FetchResult &Res,FetchResult *Alt = 0);
  61. bool MediaFail(string Required,string Drive);
  62. virtual void Exit() {};
  63. public:
  64. enum CnfFlags {SingleInstance = (1<<0),
  65. Pipeline = (1<<1), SendConfig = (1<<2),
  66. LocalOnly = (1<<3), NeedsCleanup = (1<<4),
  67. Removable = (1<<5)};
  68. void Log(const char *Format,...);
  69. void Status(const char *Format,...);
  70. int Run(bool Single = false);
  71. inline void SetFailExtraMsg(string Msg) {FailExtra = Msg;};
  72. pkgAcqMethod(const char *Ver,unsigned long Flags = 0);
  73. virtual ~pkgAcqMethod() {};
  74. };
  75. /** @} */
  76. #endif