xref: /haiku/src/apps/haikudepot/packagemanagement/AbstractPackageProcess.cpp (revision 52f7c9389475e19fc21487b38064b4390eeb6fea)
1 /*
2  * Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
3  * Copyright 2013, Rene Gollent, <rene@gollent.com>
4  * Copyright 2020-2022, Andrew Lindesay <apl@lindesay.co.nz>
5  *
6  * All rights reserved. Distributed under the terms of the MIT License.
7  */
8 
9 
10 #include "AbstractPackageProcess.h"
11 
12 #include "Model.h"
13 #include "PackageManager.h"
14 #include "PackageUtils.h"
15 
16 
17 using namespace BPackageKit;
18 
19 // #pragma mark - PackageAction
20 
21 
22 AbstractPackageProcess::AbstractPackageProcess(
23 		PackageInfoRef package, Model* model)
24 	:
25 	fPackage(package),
26 	fModel(model)
27 {
28 	if (package.IsSet())
29 		fInstallLocation = PackageUtils::DeriveInstallLocation(package.Get());
30 	else
31 		fInstallLocation = B_PACKAGE_INSTALLATION_LOCATION_SYSTEM;
32 
33 	// TODO: ideally if the package is installed at multiple locations,
34 	// the user should be able to pick which one to remove.
35 	// TODO: allow configuring the installation location
36 	fPackageManager = new(std::nothrow) PackageManager(
37 		(BPackageInstallationLocation)fInstallLocation);
38 }
39 
40 
41 AbstractPackageProcess::~AbstractPackageProcess()
42 {
43 	delete fPackageManager;
44 }
45 
46 
47 PackageInfoRef
48 AbstractPackageProcess::FindPackageByName(const BString& name)
49 {
50 	return fModel->PackageForName(name);
51 }
52 
53 
54