mirror.h 1.7 KB

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