138c62dfbSIngo Weinhold /* 20de3219eSIngo Weinhold * Copyright 2013-2014, Ingo Weinhold, ingo_weinhold@gmx.de. 338c62dfbSIngo Weinhold * Distributed under the terms of the MIT License. 438c62dfbSIngo Weinhold */ 538c62dfbSIngo Weinhold #ifndef PACKAGE_MANAGER_H 638c62dfbSIngo Weinhold #define PACKAGE_MANAGER_H 738c62dfbSIngo Weinhold 838c62dfbSIngo Weinhold 938c62dfbSIngo Weinhold #include <map> 1038c62dfbSIngo Weinhold #include <set> 1138c62dfbSIngo Weinhold 1238c62dfbSIngo Weinhold #include <package/Context.h> 1338c62dfbSIngo Weinhold #include <package/Job.h> 1438c62dfbSIngo Weinhold 1538c62dfbSIngo Weinhold #include <package/DaemonClient.h> 1638c62dfbSIngo Weinhold #include <package/manager/PackageManager.h> 1738c62dfbSIngo Weinhold 1838c62dfbSIngo Weinhold 190de3219eSIngo Weinhold using BPackageKit::BCommitTransactionResult; 2038c62dfbSIngo Weinhold using BPackageKit::BContext; 2138c62dfbSIngo Weinhold using BPackageKit::BPackageInstallationLocation; 2238c62dfbSIngo Weinhold using BPackageKit::BRepositoryConfig; 2338c62dfbSIngo Weinhold using BPackageKit::BSolverPackage; 24*e711e6e4SAxel Dörfler using BSupportKit::BJob; 25*e711e6e4SAxel Dörfler using BSupportKit::BJobStateListener; 2638c62dfbSIngo Weinhold 2738c62dfbSIngo Weinhold using BPackageKit::BPrivate::BDaemonClient; 2838c62dfbSIngo Weinhold using BPackageKit::BManager::BPrivate::BPackageManager; 2938c62dfbSIngo Weinhold 3038c62dfbSIngo Weinhold 3138c62dfbSIngo Weinhold class Package; 3238c62dfbSIngo Weinhold class ProblemWindow; 336c883121SIngo Weinhold class ResultWindow; 3438c62dfbSIngo Weinhold class Root; 3538c62dfbSIngo Weinhold class Volume; 3638c62dfbSIngo Weinhold 3738c62dfbSIngo Weinhold 3838c62dfbSIngo Weinhold class PackageManager : public BPackageManager, 3938c62dfbSIngo Weinhold private BPackageManager::InstallationInterface, 403d97f9a0SRene Gollent private BPackageManager::UserInteractionHandler { 4138c62dfbSIngo Weinhold public: 4238c62dfbSIngo Weinhold PackageManager(Root* root, Volume* volume); 4338c62dfbSIngo Weinhold ~PackageManager(); 4438c62dfbSIngo Weinhold 4538c62dfbSIngo Weinhold void HandleUserChanges(); 4638c62dfbSIngo Weinhold 4738c62dfbSIngo Weinhold private: 4838c62dfbSIngo Weinhold // InstallationInterface 4938c62dfbSIngo Weinhold virtual void InitInstalledRepository( 5038c62dfbSIngo Weinhold InstalledRepository& repository); 5138c62dfbSIngo Weinhold virtual void ResultComputed(InstalledRepository& repository); 5238c62dfbSIngo Weinhold 5338c62dfbSIngo Weinhold virtual status_t PrepareTransaction(Transaction& transaction); 5438c62dfbSIngo Weinhold virtual status_t CommitTransaction(Transaction& transaction, 550de3219eSIngo Weinhold BCommitTransactionResult& _result); 5638c62dfbSIngo Weinhold 5738c62dfbSIngo Weinhold private: 5838c62dfbSIngo Weinhold // UserInteractionHandler 5938c62dfbSIngo Weinhold virtual void HandleProblems(); 6038c62dfbSIngo Weinhold virtual void ConfirmChanges(bool fromMostSpecific); 6138c62dfbSIngo Weinhold 6238c62dfbSIngo Weinhold virtual void Warn(status_t error, const char* format, ...); 639345049aSRene Gollent 649345049aSRene Gollent virtual void ProgressPackageDownloadStarted( 659345049aSRene Gollent const char* packageName); 669345049aSRene Gollent virtual void ProgressPackageDownloadActive( 679345049aSRene Gollent const char* packageName, 681aaa0c21SAxel Dörfler float completionPercentage, 691aaa0c21SAxel Dörfler off_t bytes, off_t totalBytes); 709345049aSRene Gollent virtual void ProgressPackageDownloadComplete( 719345049aSRene Gollent const char* packageName); 729345049aSRene Gollent virtual void ProgressPackageChecksumStarted( 739345049aSRene Gollent const char* title); 749345049aSRene Gollent virtual void ProgressPackageChecksumComplete( 759345049aSRene Gollent const char* title); 769345049aSRene Gollent 7738c62dfbSIngo Weinhold virtual void ProgressStartApplyingChanges( 7838c62dfbSIngo Weinhold InstalledRepository& repository); 7938c62dfbSIngo Weinhold virtual void ProgressTransactionCommitted( 8038c62dfbSIngo Weinhold InstalledRepository& repository, 81eee42275SIngo Weinhold const BCommitTransactionResult& result); 8238c62dfbSIngo Weinhold virtual void ProgressApplyingChangesDone( 8338c62dfbSIngo Weinhold InstalledRepository& repository); 8438c62dfbSIngo Weinhold 8538c62dfbSIngo Weinhold private: 8638c62dfbSIngo Weinhold // BJobStateListener 87*e711e6e4SAxel Dörfler virtual void JobFailed(BSupportKit::BJob* job); 88*e711e6e4SAxel Dörfler virtual void JobAborted(BSupportKit::BJob* job); 8938c62dfbSIngo Weinhold 9038c62dfbSIngo Weinhold private: 9138c62dfbSIngo Weinhold typedef std::set<BSolverPackage*> SolverPackageSet; 9238c62dfbSIngo Weinhold typedef std::map<Package*, BSolverPackage*> SolverPackageMap; 9338c62dfbSIngo Weinhold 9438c62dfbSIngo Weinhold private: 956c883121SIngo Weinhold bool _AddResults(InstalledRepository& repository, 966c883121SIngo Weinhold ResultWindow* window); 9738c62dfbSIngo Weinhold 9838c62dfbSIngo Weinhold BSolverPackage* _SolverPackageFor(Package* package) const; 9938c62dfbSIngo Weinhold 10038c62dfbSIngo Weinhold void _InitGui(); 10138c62dfbSIngo Weinhold 10238c62dfbSIngo Weinhold private: 10338c62dfbSIngo Weinhold Root* fRoot; 10438c62dfbSIngo Weinhold Volume* fVolume; 10538c62dfbSIngo Weinhold SolverPackageMap fSolverPackages; 10638c62dfbSIngo Weinhold SolverPackageSet fPackagesAddedByUser; 10738c62dfbSIngo Weinhold SolverPackageSet fPackagesRemovedByUser; 10838c62dfbSIngo Weinhold ProblemWindow* fProblemWindow; 10938c62dfbSIngo Weinhold }; 11038c62dfbSIngo Weinhold 11138c62dfbSIngo Weinhold 11238c62dfbSIngo Weinhold #endif // PACKAGE_MANAGER_H 113