xref: /haiku/src/bin/pkgman/PackageManager.h (revision efafab643ce980e3f3c916795ed302599f6b4f66)
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 
36 private:
37 	// UserInteractionHandler
38 	virtual	void				HandleProblems();
39 	virtual	void				ConfirmChanges(bool fromMostSpecific);
40 
41 	virtual	void				Warn(status_t error, const char* format, ...);
42 
43 
44 	virtual	void				ProgressPackageDownloadStarted(
45 									const char* packageName);
46 	virtual	void				ProgressPackageDownloadActive(
47 									const char* packageName,
48 									float completionPercentage,
49 									off_t bytes, off_t totalBytes);
50 	virtual	void				ProgressPackageDownloadComplete(
51 									const char* packageName);
52 	virtual	void				ProgressPackageChecksumStarted(
53 									const char* packageName);
54 	virtual	void				ProgressPackageChecksumComplete(
55 									const char* packageName);
56 
57 	virtual	void				ProgressStartApplyingChanges(
58 									InstalledRepository& repository);
59 	virtual	void				ProgressTransactionCommitted(
60 									InstalledRepository& repository,
61 									const BCommitTransactionResult& result);
62 	virtual	void				ProgressApplyingChangesDone(
63 									InstalledRepository& repository);
64 
65 private:
66 			void				_PrintResult(InstalledRepository&
67 									installationRepository);
68 
69 private:
70 			DecisionProvider	fDecisionProvider;
71 			BPackageManager::ClientInstallationInterface
72 									fClientInstallationInterface;
73 			bool				fInteractive;
74 
75 			off_t				fLastBytes;
76 			bigtime_t			fLastRateCalcTime;
77 			float				fDownloadRate;
78 };
79 
80 
81 #endif	// PACKAGE_MANAGER_H
82