1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/media/MediaCurl.h
12 #ifndef ZYPP_MEDIA_MEDIACURL_H
13 #define ZYPP_MEDIA_MEDIACURL_H
15 #include "zypp/media/MediaHandler.h"
16 #include "zypp/ZYppCallbacks.h"
18 #include <curl/curl.h>
23 ///////////////////////////////////////////////////////////////////
25 // CLASS NAME : MediaCurl
27 * @short Implementation class for FTP, HTTP and HTTPS MediaHandler
30 class MediaCurl : public MediaHandler {
34 virtual void attachTo (bool next = false);
35 virtual void releaseFrom( const std::string & ejectDev );
36 virtual void getFile( const Pathname & filename ) const;
37 virtual void getDir( const Pathname & dirname, bool recurse_r ) const;
38 virtual void getDirInfo( std::list<std::string> & retlist,
39 const Pathname & dirname, bool dots = true ) const;
40 virtual void getDirInfo( filesystem::DirContent & retlist,
41 const Pathname & dirname, bool dots = true ) const;
43 * Repeatedly calls doGetDoesFileExist() until it successfully returns,
44 * fails unexpectedly, or user cancels the operation. This is used to
45 * handle authentication or similar retry scenarios on media level.
47 virtual bool getDoesFileExist( const Pathname & filename ) const;
50 * \see MediaHandler::getDoesFileExist
52 virtual bool doGetDoesFileExist( const Pathname & filename ) const;
56 * \throws MediaException
59 virtual void disconnectFrom();
62 * \throws MediaException
65 virtual void getFileCopy( const Pathname & srcFilename, const Pathname & targetFilename) const;
69 * \throws MediaException
72 virtual void doGetFileCopy( const Pathname & srcFilename, const Pathname & targetFilename, callback::SendReport<DownloadProgressReport> & _report) const;
75 virtual bool checkAttachPoint(const Pathname &apoint) const;
79 MediaCurl( const Url & url_r,
80 const Pathname & attach_point_hint_r );
82 virtual ~MediaCurl() { try { release(); } catch(...) {} }
84 static void setCookieFile( const Pathname & );
89 virtual ~Callbacks() {}
90 virtual bool progress( int percent ) = 0;
95 static int progressCallback( void *clientp, double dltotal, double dlnow,
96 double ultotal, double ulnow );
98 /** The user agent string */
99 static const char *const agentString();
103 * Return a comma separated list of available authentication methods
104 * supported by server.
106 std::string getAuthHint() const;
110 char _curlError[ CURL_ERROR_SIZE ];
113 mutable std::string _userpwd;
115 std::string _proxyuserpwd;
116 std::string _currentCookieFile;
117 std::string _ca_path;
120 static Pathname _cookieFile;
123 ///////////////////////////////////////////////////////////////////
128 #endif // ZYPP_MEDIA_MEDIACURL_H