acquire-method.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: acquire-method.h,v 1.3 1998/11/14 01:39:43 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 <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. };
  27. struct FetchResult
  28. {
  29. string MD5Sum;
  30. time_t LastModified;
  31. bool IMSHit;
  32. string Filename;
  33. unsigned long Size;
  34. unsigned long ResumePoint;
  35. FetchResult();
  36. };
  37. // State
  38. vector<string> Messages;
  39. FetchItem *Queue;
  40. // Handlers for messages
  41. virtual bool Configuration(string Message);
  42. virtual bool Fetch(FetchItem *Item) {return true;};
  43. // Outgoing messages
  44. void Fail();
  45. void Fail(string Why);
  46. void URIStart(FetchResult &Res);
  47. void URIDone(FetchResult &Res,FetchResult *Alt = 0);
  48. public:
  49. enum CnfFlags {SingleInstance = (1<<0), PreScan = (1<<1),
  50. Pipeline = (1<<2), SendConfig = (1<<3),
  51. LocalOnly = (1<<4)};
  52. void Log(const char *Format,...);
  53. void Status(const char *Format,...);
  54. int Run(bool Single = false);
  55. pkgAcqMethod(const char *Ver,unsigned long Flags = 0);
  56. virtual ~pkgAcqMethod() {};
  57. };
  58. #endif