acquire-method.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 FailExtra;
  47. // Handlers for messages
  48. virtual bool Configuration(string Message);
  49. virtual bool Fetch(FetchItem * /*Item*/) {return true;};
  50. // Outgoing messages
  51. void Fail(bool Transient = false);
  52. inline void Fail(const char *Why, bool Transient = false) {Fail(string(Why),Transient);};
  53. void Fail(string Why, bool Transient = false);
  54. void URIStart(FetchResult &Res);
  55. void URIDone(FetchResult &Res,FetchResult *Alt = 0);
  56. bool MediaFail(string Required,string Drive);
  57. virtual void Exit() {};
  58. public:
  59. enum CnfFlags {SingleInstance = (1<<0),
  60. Pipeline = (1<<1), SendConfig = (1<<2),
  61. LocalOnly = (1<<3), NeedsCleanup = (1<<4),
  62. Removable = (1<<5)};
  63. void Log(const char *Format,...);
  64. void Status(const char *Format,...);
  65. int Run(bool Single = false);
  66. inline void SetFailExtraMsg(string Msg) {FailExtra = Msg;};
  67. pkgAcqMethod(const char *Ver,unsigned long Flags = 0);
  68. virtual ~pkgAcqMethod() {};
  69. };
  70. #endif