libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_REPO_PACKAGEPROVIDER_H 00013 #define ZYPP_REPO_PACKAGEPROVIDER_H 00014 00015 #include <iosfwd> 00016 00017 #include "zypp/base/NonCopyable.h" 00018 00019 #include "zypp/ZYppCallbacks.h" 00020 #include "zypp/Package.h" 00021 #include "zypp/ManagedFile.h" 00022 #include "zypp/repo/RepoProvideFile.h" 00023 #include "zypp/repo/DeltaCandidates.h" 00024 00026 namespace zypp 00027 { 00028 00029 namespace repo 00030 { 00031 00033 // 00034 // CLASS NAME : PackageProviderPolicy 00035 // 00037 class PackageProviderPolicy 00038 { 00039 public: 00041 typedef function<bool ( const std::string &, const Edition &, const Arch & )> QueryInstalledCB; 00042 00044 PackageProviderPolicy & queryInstalledCB( QueryInstalledCB queryInstalledCB_r ) 00045 { _queryInstalledCB = queryInstalledCB_r; return *this; } 00046 00048 bool queryInstalled( const std::string & name_r, 00049 const Edition & ed_r, 00050 const Arch & arch_r ) const; 00051 00052 private: 00053 QueryInstalledCB _queryInstalledCB; 00054 }; 00056 00058 // 00059 // CLASS NAME : PackageProvider 00060 // 00064 class PackageProvider : private base::NonCopyable 00065 { 00066 typedef shared_ptr<void> ScopedGuard; 00067 typedef callback::SendReport<repo::DownloadResolvableReport> Report; 00068 00069 typedef packagedelta::DeltaRpm DeltaRpm; 00070 00071 public: 00073 PackageProvider( RepoMediaAccess &access, 00074 const Package::constPtr & package, 00075 const DeltaCandidates & deltas, 00076 const PackageProviderPolicy & policy_r = PackageProviderPolicy() ); 00077 ~PackageProvider(); 00078 00079 public: 00083 ManagedFile providePackage() const; 00084 00085 private: 00086 ManagedFile doProvidePackage() const; 00087 ManagedFile tryDelta( const DeltaRpm & delta_r ) const; 00088 00089 private: 00090 ScopedGuard newReport() const; 00091 Report & report() const; 00092 bool progressDeltaDownload( int value ) const; 00093 void progressDeltaApply( int value ) const; 00094 bool progressPackageDownload( int value ) const; 00095 bool failOnChecksumError() const; 00096 bool queryInstalled( const Edition & ed_r = Edition() ) const; 00097 00098 private: 00099 PackageProviderPolicy _policy; 00100 Package::constPtr _package; 00101 mutable bool _retry; 00102 mutable shared_ptr<Report> _report; 00103 DeltaCandidates _deltas; 00104 RepoMediaAccess & _access; 00105 }; 00107 00109 } // namespace repo 00112 } // namespace zypp 00114 #endif // ZYPP_SOURCE_PACKAGEPROVIDER_H