acquire-method.h 2.3 KB

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