mirror.h 1.6 KB

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