00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_MEDIA_MEDIACURL_H
00013 #define ZYPP_MEDIA_MEDIACURL_H
00014
00015 #include "zypp/media/MediaHandler.h"
00016 #include "zypp/ZYppCallbacks.h"
00017
00018 #include <curl/curl.h>
00019
00020 namespace zypp {
00021 namespace media {
00022
00024
00025
00030 class MediaCurl : public MediaHandler {
00031
00032 protected:
00033
00034 virtual void attachTo (bool next = false);
00035 virtual void releaseFrom( bool eject );
00036 virtual void getFile( const Pathname & filename ) const;
00037 virtual void getDir( const Pathname & dirname, bool recurse_r ) const;
00038 virtual void getDirInfo( std::list<std::string> & retlist,
00039 const Pathname & dirname, bool dots = true ) const;
00040 virtual void getDirInfo( filesystem::DirContent & retlist,
00041 const Pathname & dirname, bool dots = true ) const;
00047 virtual bool getDoesFileExist( const Pathname & filename ) const;
00048
00052 virtual bool doGetDoesFileExist( const Pathname & filename ) const;
00053
00059 virtual void disconnectFrom();
00065 virtual void getFileCopy( const Pathname & srcFilename, const Pathname & targetFilename) const;
00066
00072 virtual void doGetFileCopy( const Pathname & srcFilename, const Pathname & targetFilename, callback::SendReport<DownloadProgressReport> & _report) const;
00073
00074
00075 virtual bool checkAttachPoint(const Pathname &apoint) const;
00076
00077 public:
00078
00079 MediaCurl( const Url & url_r,
00080 const Pathname & attach_point_hint_r );
00081
00082 virtual ~MediaCurl() { try { release(); } catch(...) {} }
00083
00084 static void setCookieFile( const Pathname & );
00085
00086 class Callbacks
00087 {
00088 public:
00089 virtual ~Callbacks() {}
00090 virtual bool progress( int percent ) = 0;
00091 };
00092
00093 protected:
00094
00095 static int progressCallback( void *clientp, double dltotal, double dlnow,
00096 double ultotal, double ulnow );
00097 private:
00102 std::string getAuthHint() const;
00103
00104 private:
00105 CURL *_curl;
00106 char _curlError[ CURL_ERROR_SIZE ];
00107 long _curlDebug;
00108
00109 mutable std::string _userpwd;
00110 std::string _proxy;
00111 std::string _proxyuserpwd;
00112 std::string _currentCookieFile;
00113 std::string _ca_path;
00114 long _xfer_timeout;
00115
00116 static Pathname _cookieFile;
00117 static std::string _agent;
00118 };
00119
00121
00122 }
00123 }
00124
00125 #endif // ZYPP_MEDIA_MEDIACURL_H