xref: /haiku/src/apps/softwareupdater/UpdateManager.h (revision 2897df967633aab846ff4917b53e2af7d1e54eeb)
1 /*
2  * Copyright 2013-2017, 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  *		Brian Hill <supernova@tycho.email>
9  */
10 #ifndef UPDATE_MANAGER_H
11 #define UPDATE_MANAGER_H
12 
13 
14 #include <package/DaemonClient.h>
15 #include <package/manager/PackageManager.h>
16 
17 #include "constants.h"
18 #include "SoftwareUpdaterWindow.h"
19 
20 class ProblemWindow;
21 
22 //using namespace BPackageKit;
23 using BPackageKit::BPackageInstallationLocation;
24 using BPackageKit::BPrivate::BDaemonClient;
25 using BPackageKit::BManager::BPrivate::BPackageManager;
26 
27 
28 class UpdateManager : public BPackageManager,
29 	private BPackageManager::UserInteractionHandler {
30 public:
31 								UpdateManager(
32 									BPackageInstallationLocation location,
33 									bool verbose);
34 								~UpdateManager();
35 
36 			void				CheckNetworkConnection();
37 			update_type			GetUpdateType();
38 			void				CheckRepositories();
39 	virtual	void				JobFailed(BSupportKit::BJob* job);
40 	virtual	void				JobAborted(BSupportKit::BJob* job);
41 			void				FinalUpdate(const char* header,
42 									const char* text);
43 private:
44 	// UserInteractionHandler
45 	virtual	void				HandleProblems();
46 	virtual	void				ConfirmChanges(bool fromMostSpecific);
47 	virtual	void				Warn(status_t error, const char* format, ...);
48 
49 	virtual	void				ProgressPackageDownloadStarted(
50 									const char* packageName);
51 	virtual	void				ProgressPackageDownloadActive(
52 									const char* packageName,
53 									float completionValue,
54 									off_t bytes, off_t totalBytes);
55 	virtual	void				ProgressPackageDownloadComplete(
56 									const char* packageName);
57 	virtual	void				ProgressPackageChecksumStarted(
58 									const char* packageName);
59 	virtual	void				ProgressPackageChecksumComplete(
60 									const char* packageName);
61 
62 	virtual	void				ProgressStartApplyingChanges(
63 									InstalledRepository& repository);
64 	virtual	void				ProgressTransactionCommitted(
65 									InstalledRepository& repository,
66 									const BPackageKit::BCommitTransactionResult& result);
67 	virtual	void				ProgressApplyingChangesDone(
68 									InstalledRepository& repository);
69 
70 private:
71 			void				_PrintResult(InstalledRepository&
72 									installationRepository,
73 									int32& upgradeCount,
74 									int32& installCount,
75 									int32& uninstallCount);
76 			void				_UpdateStatusWindow(const char* header,
77 									const char* detail);
78 			void				_UpdateDownloadProgress(const char* header,
79 									const char* packageName,
80 									float percentageComplete);
81 			void				_FinalUpdate(const char* header,
82 									const char* text);
83 			void				_SetCurrentStep(int32 step);
84 
85 private:
86 			BPackageManager::ClientInstallationInterface
87 									fClientInstallationInterface;
88 
89 			SoftwareUpdaterWindow*	fStatusWindow;
90 			ProblemWindow*			fProblemWindow;
91 			uint32					fCurrentStep;
92 			bool					fChangesConfirmed;
93 			bool					fNewDownloadStarted;
94 			int32					fPackageDownloadsTotal;
95 			int32					fPackageDownloadsCount;
96 			bool					fVerbose;
97 };
98 
99 
100 #endif	// UPDATE_MANAGER_H
101