xref: /haiku/src/bin/pkgman/PackageManager.h (revision 4bd0c1066b227cec4b79883bdef697c7a27f2e90)
1 /*
2  * Copyright 2013-2015, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Ingo Weinhold <ingo_weinhold@gmx.de>
7  *		Rene Gollent <rene@gollent.com>
8  */
9 #ifndef PACKAGE_MANAGER_H
10 #define PACKAGE_MANAGER_H
11 
12 
13 #include <package/DaemonClient.h>
14 #include <package/manager/PackageManager.h>
15 
16 #include "DecisionProvider.h"
17 
18 
19 using namespace BPackageKit;
20 using BPackageKit::BPrivate::BDaemonClient;
21 using BManager::BPrivate::BPackageManager;
22 
23 
24 class PackageManager : public BPackageManager,
25 	private BPackageManager::UserInteractionHandler {
26 public:
27 								PackageManager(
28 									BPackageInstallationLocation location,
29 									bool interactive = true);
30 								~PackageManager();
31 
32 			void				SetInteractive(bool interactive);
33 
34 	virtual	void				JobFailed(BSupportKit::BJob* job);
35 	virtual	void				JobAborted(BSupportKit::BJob* job);
36 
37 private:
38 	// UserInteractionHandler
39 	virtual	void				HandleProblems();
40 	virtual	void				ConfirmChanges(bool fromMostSpecific);
41 
42 	virtual	void				Warn(status_t error, const char* format, ...);
43 
44 
45 	virtual	void				ProgressPackageDownloadStarted(
46 									const char* packageName);
47 	virtual	void				ProgressPackageDownloadActive(
48 									const char* packageName,
49 									float completionPercentage,
50 									off_t bytes, off_t totalBytes);
51 	virtual	void				ProgressPackageDownloadComplete(
52 									const char* packageName);
53 	virtual	void				ProgressPackageChecksumStarted(
54 									const char* packageName);
55 	virtual	void				ProgressPackageChecksumComplete(
56 									const char* packageName);
57 
58 	virtual	void				ProgressStartApplyingChanges(
59 									InstalledRepository& repository);
60 	virtual	void				ProgressTransactionCommitted(
61 									InstalledRepository& repository,
62 									const BCommitTransactionResult& result);
63 	virtual	void				ProgressApplyingChangesDone(
64 									InstalledRepository& repository);
65 
66 private:
67 			void				_PrintResult(InstalledRepository&
68 									installationRepository);
69 
70 private:
71 			DecisionProvider	fDecisionProvider;
72 			BPackageManager::ClientInstallationInterface
73 									fClientInstallationInterface;
74 			bool				fInteractive;
75 
76 			off_t				fLastBytes;
77 			bigtime_t			fLastRateCalcTime;
78 			float				fDownloadRate;
79 };
80 
81 
82 #endif	// PACKAGE_MANAGER_H
83