libzypp  10.5.0
MediaMultiCurl.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_MEDIA_MEDIAMULTICURL_H
00013 #define ZYPP_MEDIA_MEDIAMULTICURL_H
00014 
00015 #include <string>
00016 #include <vector>
00017 #include <list>
00018 #include <set>
00019 
00020 #include "zypp/media/MediaHandler.h"
00021 #include "zypp/media/MediaCurl.h"
00022 #include "zypp/media/MediaBlockList.h"
00023 #include "zypp/media/TransferSettings.h"
00024 #include "zypp/ZYppCallbacks.h"
00025 
00026 namespace zypp {
00027   namespace media {
00028 
00037 class multifetchrequest;
00038 class multifetchworker;
00039 
00040 class MediaMultiCurl : public MediaCurl {
00041 public:
00042   friend class multifetchrequest;
00043   friend class multifetchworker;
00044 
00045   MediaMultiCurl(const Url &url_r, const Pathname & attach_point_hint_r);
00046   ~MediaMultiCurl();
00047 
00048   virtual void doGetFileCopy( const Pathname & srcFilename, const Pathname & targetFilename, callback::SendReport<DownloadProgressReport> & _report, RequestOptions options = OPTION_NONE ) const;
00049 
00050   void multifetch(const Pathname &filename, FILE *fp, std::vector<Url> *urllist, callback::SendReport<DownloadProgressReport> *report = 0, MediaBlockList *blklist = 0, off_t filesize = off_t(-1)) const;
00051 
00052 protected:
00053 
00054   bool isDNSok(const std::string &host) const;
00055   void setDNSok(const std::string &host) const;
00056 
00057   CURL *fromEasyPool(const std::string &host) const;
00058   void toEasyPool(const std::string &host, CURL *easy) const;
00059 
00060   virtual void setupEasy();
00061   void checkFileDigest(Url &url, FILE *fp, MediaBlockList *blklist) const;
00062 
00063 private:
00064   // the custom headers from MediaCurl plus a "Accept: metalink" header
00065   curl_slist *_customHeadersMetalink;
00066   mutable CURLM *_multi;        // reused for all fetches so we can make use of the dns cache
00067   mutable std::set<std::string> _dnsok;
00068   mutable std::map<std::string, CURL *> _easypool;
00069 };
00070 
00072 
00073   } // namespace media
00074 } // namespace zypp
00075 
00076 #endif // ZYPP_MEDIA_MEDIAMULTICURL_H