1 /* 2 * Copyright 2013-2014, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef PACKAGE_MANAGER_H 6 #define PACKAGE_MANAGER_H 7 8 9 #include <map> 10 #include <set> 11 12 #include <package/Context.h> 13 #include <package/Job.h> 14 15 #include <package/DaemonClient.h> 16 #include <package/manager/PackageManager.h> 17 18 19 using BPackageKit::BCommitTransactionResult; 20 using BPackageKit::BContext; 21 using BPackageKit::BPackageInstallationLocation; 22 using BPackageKit::BRepositoryConfig; 23 using BPackageKit::BSolverPackage; 24 using BSupportKit::BJob; 25 using BSupportKit::BJobStateListener; 26 27 using BPackageKit::BPrivate::BDaemonClient; 28 using BPackageKit::BManager::BPrivate::BPackageManager; 29 30 31 class Package; 32 class ProblemWindow; 33 class ResultWindow; 34 class Root; 35 class Volume; 36 37 38 class PackageManager : public BPackageManager, 39 private BPackageManager::InstallationInterface, 40 private BPackageManager::UserInteractionHandler { 41 public: 42 PackageManager(Root* root, Volume* volume); 43 ~PackageManager(); 44 45 void HandleUserChanges(); 46 47 private: 48 // InstallationInterface 49 virtual void InitInstalledRepository( 50 InstalledRepository& repository); 51 virtual void ResultComputed(InstalledRepository& repository); 52 53 virtual status_t PrepareTransaction(Transaction& transaction); 54 virtual status_t CommitTransaction(Transaction& transaction, 55 BCommitTransactionResult& _result); 56 57 private: 58 // UserInteractionHandler 59 virtual void HandleProblems(); 60 virtual void ConfirmChanges(bool fromMostSpecific); 61 62 virtual void Warn(status_t error, const char* format, ...); 63 64 virtual void ProgressPackageDownloadStarted( 65 const char* packageName); 66 virtual void ProgressPackageDownloadActive( 67 const char* packageName, 68 float completionPercentage, 69 off_t bytes, off_t totalBytes); 70 virtual void ProgressPackageDownloadComplete( 71 const char* packageName); 72 virtual void ProgressPackageChecksumStarted( 73 const char* title); 74 virtual void ProgressPackageChecksumComplete( 75 const char* title); 76 77 virtual void ProgressStartApplyingChanges( 78 InstalledRepository& repository); 79 virtual void ProgressTransactionCommitted( 80 InstalledRepository& repository, 81 const BCommitTransactionResult& result); 82 virtual void ProgressApplyingChangesDone( 83 InstalledRepository& repository); 84 85 private: 86 // BJobStateListener 87 virtual void JobFailed(BSupportKit::BJob* job); 88 virtual void JobAborted(BSupportKit::BJob* job); 89 90 private: 91 typedef std::set<BSolverPackage*> SolverPackageSet; 92 typedef std::map<Package*, BSolverPackage*> SolverPackageMap; 93 94 private: 95 bool _AddResults(InstalledRepository& repository, 96 ResultWindow* window); 97 98 BSolverPackage* _SolverPackageFor(Package* package) const; 99 100 void _InitGui(); 101 102 private: 103 Root* fRoot; 104 Volume* fVolume; 105 SolverPackageMap fSolverPackages; 106 SolverPackageSet fPackagesAddedByUser; 107 SolverPackageSet fPackagesRemovedByUser; 108 ProblemWindow* fProblemWindow; 109 }; 110 111 112 #endif // PACKAGE_MANAGER_H 113