xref: /haiku/src/servers/package/PackageManager.h (revision 220d04022750f40f8bac8f01fa551211e28d04f2)
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::BJob;
22 using BPackageKit::BJobStateListener;
23 using BPackageKit::BPackageInstallationLocation;
24 using BPackageKit::BRepositoryConfig;
25 using BPackageKit::BSolverPackage;
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 	virtual	void				ProgressPackageDownloadComplete(
70 									const char* packageName);
71 	virtual	void				ProgressPackageChecksumStarted(
72 									const char* title);
73 	virtual	void				ProgressPackageChecksumComplete(
74 									const char* title);
75 
76 	virtual	void				ProgressStartApplyingChanges(
77 									InstalledRepository& repository);
78 	virtual	void				ProgressTransactionCommitted(
79 									InstalledRepository& repository,
80 									const BCommitTransactionResult& result);
81 	virtual	void				ProgressApplyingChangesDone(
82 									InstalledRepository& repository);
83 
84 private:
85 	// BJobStateListener
86 	virtual	void				JobFailed(BJob* job);
87 	virtual	void				JobAborted(BJob* job);
88 
89 private:
90 			typedef std::set<BSolverPackage*> SolverPackageSet;
91 			typedef std::map<Package*, BSolverPackage*> SolverPackageMap;
92 
93 private:
94 			bool				_AddResults(InstalledRepository& repository,
95 									ResultWindow* window);
96 
97 			BSolverPackage*		_SolverPackageFor(Package* package) const;
98 
99 			void				_InitGui();
100 
101 private:
102 			Root*				fRoot;
103 			Volume*				fVolume;
104 			SolverPackageMap	fSolverPackages;
105 			SolverPackageSet	fPackagesAddedByUser;
106 			SolverPackageSet	fPackagesRemovedByUser;
107 			ProblemWindow*		fProblemWindow;
108 };
109 
110 
111 #endif	// PACKAGE_MANAGER_H
112