1/*
2 * Copyright 2013, Stephan A��mus <superstippi@gmx.de>.
3 * Copyright 2011, Ingo Weinhold, <ingo_weinhold@gmx.de>
4 * Copyright 2013, Rene Gollent, <rene@gollent.com>
5 * Copyright 2017, Julian Harnath <julian.harnath@rwth-aachen.de>.
6 * Copyright 2021, Andrew Lindesay <apl@lindesay.co.nz>.
7 *
8 * All rights reserved. Distributed under the terms of the MIT License.
9 *
10 * Note that this file has been re-factored from `PackageManager.h` and
11 * copyrights have been carried across in 2021.
12 */
13#ifndef INSTALL_PACKAGE_PROCESS_H
14#define INSTALL_PACKAGE_PROCESS_H
15
16#include <vector>
17
18#include "AbstractPackageProcess.h"
19#include "PackageProgressListener.h"
20
21
22typedef std::set<PackageInfoRef> PackageInfoSet;
23
24
25class DownloadProgress;
26
27
28class InstallPackageProcess
29	: public AbstractPackageProcess,
30		private PackageProgressListener {
31public:
32								InstallPackageProcess(
33									PackageInfoRef package, Model* model);
34	virtual						~InstallPackageProcess();
35
36	virtual	const char*			Name() const;
37	virtual	const char*			Description() const;
38	virtual float				Progress();
39
40	// DownloadProgressListener
41	virtual void 				DownloadProgressChanged(
42									const char* packageName,
43									float progress);
44	virtual void				DownloadProgressComplete(
45									const char* packageName);
46	virtual	void				ConfirmedChanges(
47									BPackageManager::InstalledRepository&
48									repository);
49
50protected:
51	virtual	status_t			RunInternal();
52
53private:
54	static	status_t			_DeriveSimplePackageName(
55									const BString& canonicalForm,
56									BString& simplePackageName);
57
58			void				_SetDownloadedPackagesState(
59									PackageState state);
60
61			void				_SetDownloadProgress(
62									const BString& simplePackageName,
63									float progress);
64
65private:
66			std::vector<DownloadProgress>
67								fDownloadProgresses;
68			BString				fDescription;
69			bigtime_t			fLastDownloadUpdate;
70			PackageInfoSet		fDownloadedPackages;
71};
72
73#endif // INSTALL_PACKAGE_PROCESS_H
74