- Removed deprecated reattach functions
[platform/upstream/libzypp.git] / zypp / media / MediaCurl.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/media/MediaCurl.h
10  *
11 */
12 #ifndef ZYPP_MEDIA_MEDIACURL_H
13 #define ZYPP_MEDIA_MEDIACURL_H
14
15 #include "zypp/media/MediaHandler.h"
16 #include "zypp/ZYppCallbacks.h"
17
18 #include <curl/curl.h>
19
20 namespace zypp {
21   namespace media {
22
23 ///////////////////////////////////////////////////////////////////
24 //
25 //      CLASS NAME : MediaCurl
26 /**
27  * @short Implementation class for FTP, HTTP and HTTPS MediaHandler
28  * @see MediaHandler
29  **/
30 class MediaCurl : public MediaHandler {
31
32   protected:
33
34     MEDIA_HANDLER_API;
35     /**
36      *
37      * \throws MediaException
38      *
39      */
40     virtual void disconnectFrom();
41     /**
42      *
43      * \throws MediaException
44      *
45      */
46     virtual void getFileCopy( const Pathname & srcFilename, const Pathname & targetFilename) const;
47
48     /**
49      *
50      * \throws MediaException
51      *
52      */
53     virtual void doGetFileCopy( const Pathname & srcFilename, const Pathname & targetFilename, callback::SendReport<DownloadProgressReport> & _report) const;
54
55
56     virtual bool checkAttachPoint(const Pathname &apoint) const;
57
58   public:
59
60     MediaCurl( const Url &      url_r,
61                const Pathname & attach_point_hint_r );
62
63     virtual ~MediaCurl() { try { release(); } catch(...) {} }
64
65     static void setCookieFile( const Pathname & );
66
67     class Callbacks
68     {
69       public:
70         virtual ~Callbacks() {}
71         virtual bool progress( int percent ) = 0;
72     };
73
74   protected:
75
76     static int progressCallback( void *clientp, double dltotal, double dlnow,
77                                  double ultotal, double ulnow );
78
79   private:
80     CURL *_curl;
81     char _curlError[ CURL_ERROR_SIZE ];
82
83     std::string _userpwd;
84     std::string _proxy;
85     std::string _proxyuserpwd;
86     std::string _currentCookieFile;
87
88     static Pathname _cookieFile;
89
90     bool _connected;
91
92     static bool _globalInit;
93
94     static std::string _agent;
95 };
96
97 ///////////////////////////////////////////////////////////////////
98
99   } // namespace media
100 } // namespace zypp
101
102 #endif // ZYPP_MEDIA_MEDIACURL_H