mirror.h 1.7 KB

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