acquire-method.h 2.2 KB

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