1*a18f873fSAndrew Lindesay /* 2*a18f873fSAndrew Lindesay * Copyright 2013, Stephan Aßmus <superstippi@gmx.de>. 3*a18f873fSAndrew Lindesay * Copyright 2011, Ingo Weinhold, <ingo_weinhold@gmx.de> 4*a18f873fSAndrew Lindesay * Copyright 2013, Rene Gollent, <rene@gollent.com> 5*a18f873fSAndrew Lindesay * Copyright 2017, Julian Harnath <julian.harnath@rwth-aachen.de>. 6*a18f873fSAndrew Lindesay * Copyright 2021, Andrew Lindesay <apl@lindesay.co.nz>. 7*a18f873fSAndrew Lindesay * 8*a18f873fSAndrew Lindesay * All rights reserved. Distributed under the terms of the MIT License. 9*a18f873fSAndrew Lindesay */ 10*a18f873fSAndrew Lindesay #ifndef PACKAGE_MANAGER_H 11*a18f873fSAndrew Lindesay #define PACKAGE_MANAGER_H 12*a18f873fSAndrew Lindesay 13*a18f873fSAndrew Lindesay #include <Locker.h> 14*a18f873fSAndrew Lindesay 15*a18f873fSAndrew Lindesay #include <package/DaemonClient.h> 16*a18f873fSAndrew Lindesay #include <package/manager/PackageManager.h> 17*a18f873fSAndrew Lindesay 18*a18f873fSAndrew Lindesay #include "Collector.h" 19*a18f873fSAndrew Lindesay #include "DecisionProvider.h" 20*a18f873fSAndrew Lindesay #include "DeskbarLink.h" 21*a18f873fSAndrew Lindesay #include "JobStateListener.h" 22*a18f873fSAndrew Lindesay #include "PackageAction.h" 23*a18f873fSAndrew Lindesay #include "PackageInfo.h" 24*a18f873fSAndrew Lindesay #include "PackageProgressListener.h" 25*a18f873fSAndrew Lindesay 26*a18f873fSAndrew Lindesay 27*a18f873fSAndrew Lindesay namespace BPackageKit { 28*a18f873fSAndrew Lindesay class BSolverPackage; 29*a18f873fSAndrew Lindesay } 30*a18f873fSAndrew Lindesay 31*a18f873fSAndrew Lindesay class PackageManager; 32*a18f873fSAndrew Lindesay class ProblemWindow; 33*a18f873fSAndrew Lindesay class ResultWindow; 34*a18f873fSAndrew Lindesay 35*a18f873fSAndrew Lindesay 36*a18f873fSAndrew Lindesay using BPackageKit::BCommitTransactionResult; 37*a18f873fSAndrew Lindesay using BPackageKit::BContext; 38*a18f873fSAndrew Lindesay using BPackageKit::BPackageInstallationLocation; 39*a18f873fSAndrew Lindesay using BPackageKit::BRepositoryConfig; 40*a18f873fSAndrew Lindesay using BPackageKit::BPrivate::BDaemonClient; 41*a18f873fSAndrew Lindesay using BPackageKit::BManager::BPrivate::BPackageManager; 42*a18f873fSAndrew Lindesay 43*a18f873fSAndrew Lindesay 44*a18f873fSAndrew Lindesay class PackageManager : public BPackageManager, 45*a18f873fSAndrew Lindesay private BPackageManager::UserInteractionHandler { 46*a18f873fSAndrew Lindesay public: 47*a18f873fSAndrew Lindesay PackageManager( 48*a18f873fSAndrew Lindesay BPackageInstallationLocation location); 49*a18f873fSAndrew Lindesay virtual ~PackageManager(); 50*a18f873fSAndrew Lindesay 51*a18f873fSAndrew Lindesay virtual PackageState GetPackageState(const PackageInfo& package); 52*a18f873fSAndrew Lindesay virtual void CollectPackageActions(PackageInfoRef package, 53*a18f873fSAndrew Lindesay Collector<PackageActionRef>& actionList); 54*a18f873fSAndrew Lindesay 55*a18f873fSAndrew Lindesay void SetCurrentActionPackage( 56*a18f873fSAndrew Lindesay PackageInfoRef package, 57*a18f873fSAndrew Lindesay bool install); 58*a18f873fSAndrew Lindesay 59*a18f873fSAndrew Lindesay virtual status_t RefreshRepository( 60*a18f873fSAndrew Lindesay const BRepositoryConfig& repoConfig); 61*a18f873fSAndrew Lindesay virtual status_t DownloadPackage(const BString& fileURL, 62*a18f873fSAndrew Lindesay const BEntry& targetEntry, 63*a18f873fSAndrew Lindesay const BString& checksum); 64*a18f873fSAndrew Lindesay 65*a18f873fSAndrew Lindesay void AddProgressListener( 66*a18f873fSAndrew Lindesay PackageProgressListener* listener); 67*a18f873fSAndrew Lindesay void RemoveProgressListener( 68*a18f873fSAndrew Lindesay PackageProgressListener* listener); 69*a18f873fSAndrew Lindesay 70*a18f873fSAndrew Lindesay private: 71*a18f873fSAndrew Lindesay // UserInteractionHandler 72*a18f873fSAndrew Lindesay virtual void HandleProblems(); 73*a18f873fSAndrew Lindesay virtual void ConfirmChanges(bool fromMostSpecific); 74*a18f873fSAndrew Lindesay 75*a18f873fSAndrew Lindesay virtual void Warn(status_t error, const char* format, ...); 76*a18f873fSAndrew Lindesay 77*a18f873fSAndrew Lindesay virtual void ProgressPackageDownloadStarted( 78*a18f873fSAndrew Lindesay const char* packageName); 79*a18f873fSAndrew Lindesay virtual void ProgressPackageDownloadActive( 80*a18f873fSAndrew Lindesay const char* packageName, 81*a18f873fSAndrew Lindesay float completionPercentage, 82*a18f873fSAndrew Lindesay off_t bytes, off_t totalBytes); 83*a18f873fSAndrew Lindesay 84*a18f873fSAndrew Lindesay virtual void ProgressPackageDownloadComplete( 85*a18f873fSAndrew Lindesay const char* packageName); 86*a18f873fSAndrew Lindesay virtual void ProgressPackageChecksumStarted( 87*a18f873fSAndrew Lindesay const char* title); 88*a18f873fSAndrew Lindesay virtual void ProgressPackageChecksumComplete( 89*a18f873fSAndrew Lindesay const char* title); 90*a18f873fSAndrew Lindesay 91*a18f873fSAndrew Lindesay virtual void ProgressStartApplyingChanges( 92*a18f873fSAndrew Lindesay InstalledRepository& repository); 93*a18f873fSAndrew Lindesay virtual void ProgressTransactionCommitted( 94*a18f873fSAndrew Lindesay InstalledRepository& repository, 95*a18f873fSAndrew Lindesay const BCommitTransactionResult& result); 96*a18f873fSAndrew Lindesay virtual void ProgressApplyingChangesDone( 97*a18f873fSAndrew Lindesay InstalledRepository& repository); 98*a18f873fSAndrew Lindesay 99*a18f873fSAndrew Lindesay private: 100*a18f873fSAndrew Lindesay PackageActionRef _CreateUninstallPackageAction( 101*a18f873fSAndrew Lindesay const PackageInfoRef& package); 102*a18f873fSAndrew Lindesay PackageActionRef _CreateInstallPackageAction( 103*a18f873fSAndrew Lindesay const PackageInfoRef& package); 104*a18f873fSAndrew Lindesay PackageActionRef _CreateOpenPackageAction( 105*a18f873fSAndrew Lindesay const PackageInfoRef& package, 106*a18f873fSAndrew Lindesay const DeskbarLink& link); 107*a18f873fSAndrew Lindesay 108*a18f873fSAndrew Lindesay void _CollectPackageActionsForActivatedOrInstalled( 109*a18f873fSAndrew Lindesay PackageInfoRef package, 110*a18f873fSAndrew Lindesay Collector<PackageActionRef>& actionList); 111*a18f873fSAndrew Lindesay bool _AddResults( 112*a18f873fSAndrew Lindesay BPackageManager::InstalledRepository& 113*a18f873fSAndrew Lindesay repository, 114*a18f873fSAndrew Lindesay ResultWindow* window); 115*a18f873fSAndrew Lindesay void _NotifyChangesConfirmed(); 116*a18f873fSAndrew Lindesay 117*a18f873fSAndrew Lindesay BPackageKit::BSolverPackage* 118*a18f873fSAndrew Lindesay _GetSolverPackage(PackageInfoRef package); 119*a18f873fSAndrew Lindesay 120*a18f873fSAndrew Lindesay private: 121*a18f873fSAndrew Lindesay DecisionProvider fDecisionProvider; 122*a18f873fSAndrew Lindesay BPackageManager::ClientInstallationInterface 123*a18f873fSAndrew Lindesay fClientInstallationInterface; 124*a18f873fSAndrew Lindesay 125*a18f873fSAndrew Lindesay ProblemWindow* fProblemWindow; 126*a18f873fSAndrew Lindesay BPackageKit::BSolverPackage* 127*a18f873fSAndrew Lindesay fCurrentInstallPackage; 128*a18f873fSAndrew Lindesay BPackageKit::BSolverPackage* 129*a18f873fSAndrew Lindesay fCurrentUninstallPackage; 130*a18f873fSAndrew Lindesay 131*a18f873fSAndrew Lindesay PackageProgressListenerList 132*a18f873fSAndrew Lindesay fPackageProgressListeners; 133*a18f873fSAndrew Lindesay }; 134*a18f873fSAndrew Lindesay 135*a18f873fSAndrew Lindesay #endif // PACKAGE_MANAGER_H 136