MediaCurl.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
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 //      CLASS NAME : MediaCurl
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;
00042     virtual bool getDoesFileExist( const Pathname & filename ) const;
00043 
00049     virtual void disconnectFrom();
00055     virtual void getFileCopy( const Pathname & srcFilename, const Pathname & targetFilename) const;
00056 
00062     virtual void doGetFileCopy( const Pathname & srcFilename, const Pathname & targetFilename, callback::SendReport<DownloadProgressReport> & _report) const;
00063 
00064 
00065     virtual bool checkAttachPoint(const Pathname &apoint) const;
00066 
00067   public:
00068 
00069     MediaCurl( const Url &      url_r,
00070                const Pathname & attach_point_hint_r );
00071 
00072     virtual ~MediaCurl() { try { release(); } catch(...) {} }
00073 
00074     static void setCookieFile( const Pathname & );
00075 
00076     class Callbacks
00077     {
00078       public:
00079         virtual ~Callbacks() {}
00080         virtual bool progress( int percent ) = 0;
00081     };
00082 
00083   protected:
00084 
00085     static int progressCallback( void *clientp, double dltotal, double dlnow,
00086                                  double ultotal, double ulnow );
00087 
00088   private:
00089     CURL *_curl;
00090     char _curlError[ CURL_ERROR_SIZE ];
00091     long _curlDebug;
00092 
00093     std::string _userpwd;
00094     std::string _proxy;
00095     std::string _proxyuserpwd;
00096     std::string _currentCookieFile;
00097     std::string _ca_path;
00098     long        _xfer_timeout;
00099 
00100     static Pathname _cookieFile;
00101     static std::string _agent;
00102 };
00103 
00105 
00106   } // namespace media
00107 } // namespace zypp
00108 
00109 #endif // ZYPP_MEDIA_MEDIACURL_H

Generated on Tue Nov 28 16:49:29 2006 for zypp by  doxygen 1.5.0