mirror.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/// $Id: http.h,v 1.12 2002/04/18 05:09:38 jgg Exp $
  3. // $Id: http.h,v 1.12 2002/04/18 05:09:38 jgg Exp $
  4. /* ######################################################################
  5. MIRROR Acquire Method - This is the MIRROR acquire method for APT.
  6. ##################################################################### */
  7. /*}}}*/
  8. #ifndef APT_MIRROR_H
  9. #define APT_MIRROR_H
  10. #include <apt-pkg/acquire-method.h>
  11. #include <iostream>
  12. #include <string>
  13. #include <vector>
  14. using std::cout;
  15. using std::cerr;
  16. using std::endl;
  17. #include "http.h"
  18. class MirrorMethod : public HttpMethod
  19. {
  20. FetchResult Res;
  21. // we simply transform between BaseUri and Mirror
  22. std::string BaseUri; // the original mirror://... url
  23. std::string Mirror; // the selected mirror uri (http://...)
  24. std::vector<std::string> AllMirrors; // all available mirrors
  25. std::string MirrorFile; // the file that contains the list of mirrors
  26. bool DownloadedMirrorFile; // already downloaded this session
  27. std::string Dist; // the target distrubtion (e.g. sid, oneiric)
  28. bool Debug;
  29. protected:
  30. bool DownloadMirrorFile(std::string uri);
  31. bool RandomizeMirrorFile(std::string file);
  32. std::string GetMirrorFileName(std::string uri);
  33. bool InitMirrors();
  34. bool TryNextMirror();
  35. void CurrentQueueUriToMirror();
  36. bool Clean(std::string dir);
  37. // we need to overwrite those to transform the url back
  38. virtual void Fail(std::string Why, bool Transient = false) APT_OVERRIDE;
  39. virtual void URIStart(FetchResult &Res) APT_OVERRIDE;
  40. virtual void URIDone(FetchResult &Res,FetchResult *Alt = 0) APT_OVERRIDE;
  41. virtual bool Configuration(std::string Message) APT_OVERRIDE;
  42. public:
  43. MirrorMethod();
  44. virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE;
  45. };
  46. #endif