acquire-method.h 2.0 KB

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