00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: MediaCurl.h 00014 00015 Author: Klaus Kaempf <kkaempf@suse.de> 00016 Maintainer: Klaus Kaempf <kkaempf@suse.de> 00017 00018 Purpose: Implementation class for FTP, HTTP and HTTPS MediaHandler 00019 00020 /-*/ 00021 #ifndef MediaCurl_h 00022 #define MediaCurl_h 00023 00024 #include <y2pm/MediaHandler.h> 00025 00026 #include <curl/curl.h> 00027 00029 // 00030 // CLASS NAME : MediaCurl 00035 class MediaCurl : public MediaHandler { 00036 00037 protected: 00038 00039 MEDIA_HANDLER_API; 00040 00041 virtual PMError disconnectFrom(); 00042 virtual PMError getFileCopy( const Pathname & srcFilename, const Pathname & targetFilename) const; 00043 00044 00045 public: 00046 00047 MediaCurl( const Url & url_r, 00048 const Pathname & attach_point_hint_r ); 00049 00050 virtual ~MediaCurl() { release(); } 00051 00052 static void setCookieFile( const Pathname & ); 00053 00054 class Callbacks 00055 { 00056 public: 00057 virtual ~Callbacks() {} 00058 virtual bool progress( int percent ) = 0; 00059 }; 00060 00061 static void setCallbacks( Callbacks *c ) { _callbacks = c; } 00062 00063 protected: 00064 00065 static int progressCallback( void *clientp, double dltotal, double dlnow, 00066 double ultotal, double ulnow ); 00067 00068 private: 00069 CURL *_curl; 00070 char _curlError[ CURL_ERROR_SIZE ]; 00071 00072 std::string _userpwd; 00073 std::string _proxy; 00074 std::string _proxyuserpwd; 00075 std::string _currentCookieFile; 00076 00077 static Pathname _cookieFile; 00078 00079 static Callbacks *_callbacks; 00080 00081 bool _connected; 00082 00083 static bool _globalInit; 00084 }; 00085 00087 00088 #endif // MediaCurl_h
1.4.4