acquire-method.h 2.2 KB

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