From 6722e1ae43d51bb855e472045e84bb45592751cd Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 21 Nov 2013 12:54:20 +0100 Subject: [PATCH] BPackageManager: Add mandatory constructor parameters Require the installation interface and the user interaction handle to be passed to the constructor. Formerly, derived classes set them manually in their constructors. This makes using the class without having to subclass it possible. --- headers/private/package/manager/PackageManager.h | 6 +++++- src/apps/haiku-depot/PackageManager.cpp | 5 +---- src/bin/pkgman/PackageManager.cpp | 4 +--- src/kits/package/manager/PackageManager.cpp | 8 +++++--- src/servers/package/PackageManager.cpp | 4 +--- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/headers/private/package/manager/PackageManager.h b/headers/private/package/manager/PackageManager.h index bdbaf404b1..dd55ae6558 100644 --- a/headers/private/package/manager/PackageManager.h +++ b/headers/private/package/manager/PackageManager.h @@ -57,7 +57,11 @@ public: public: BPackageManager( - BPackageInstallationLocation location); + BPackageInstallationLocation location, + InstallationInterface* + installationInterface, + UserInteractionHandler* + userInteractionHandler); virtual ~BPackageManager(); void Init(uint32 flags); diff --git a/src/apps/haiku-depot/PackageManager.cpp b/src/apps/haiku-depot/PackageManager.cpp index a28046df51..559772bd89 100644 --- a/src/apps/haiku-depot/PackageManager.cpp +++ b/src/apps/haiku-depot/PackageManager.cpp @@ -273,7 +273,7 @@ private: PackageManager::PackageManager(BPackageInstallationLocation location) : - BPackageManager(location), + BPackageManager(location, &fClientInstallationInterface, this), BPackageManager::UserInteractionHandler(), fDecisionProvider(), fClientInstallationInterface(), @@ -281,8 +281,6 @@ PackageManager::PackageManager(BPackageInstallationLocation location) fCurrentInstallPackage(NULL), fCurrentUninstallPackage(NULL) { - fInstallationInterface = &fClientInstallationInterface; - fUserInteractionHandler = this; } @@ -293,7 +291,6 @@ PackageManager::~PackageManager() } - PackageState PackageManager::GetPackageState(const PackageInfo& package) { diff --git a/src/bin/pkgman/PackageManager.cpp b/src/bin/pkgman/PackageManager.cpp index d85673f87d..a3ac077fe3 100644 --- a/src/bin/pkgman/PackageManager.cpp +++ b/src/bin/pkgman/PackageManager.cpp @@ -24,14 +24,12 @@ using namespace BPackageKit::BPrivate; PackageManager::PackageManager(BPackageInstallationLocation location) : - BPackageManager(location), + BPackageManager(location, &fClientInstallationInterface, this), BPackageManager::UserInteractionHandler(), fDecisionProvider(), fClientInstallationInterface(), fPreviousDownloadPercentage(0) { - fInstallationInterface = &fClientInstallationInterface; - fUserInteractionHandler = this; } diff --git a/src/kits/package/manager/PackageManager.cpp b/src/kits/package/manager/PackageManager.cpp index 7b06dca144..645c8f948d 100644 --- a/src/kits/package/manager/PackageManager.cpp +++ b/src/kits/package/manager/PackageManager.cpp @@ -46,7 +46,9 @@ namespace BPrivate { // #pragma mark - BPackageManager -BPackageManager::BPackageManager(BPackageInstallationLocation location) +BPackageManager::BPackageManager(BPackageInstallationLocation location, + InstallationInterface* installationInterface, + UserInteractionHandler* userInteractionHandler) : fLocation(location), fSolver(NULL), @@ -57,8 +59,8 @@ BPackageManager::BPackageManager(BPackageInstallationLocation location) fInstalledRepositories(10), fOtherRepositories(10, true), fTransactions(5, true), - fInstallationInterface(NULL), - fUserInteractionHandler(NULL) + fInstallationInterface(installationInterface), + fUserInteractionHandler(userInteractionHandler) { } diff --git a/src/servers/package/PackageManager.cpp b/src/servers/package/PackageManager.cpp index ce24d8e568..02222020d6 100644 --- a/src/servers/package/PackageManager.cpp +++ b/src/servers/package/PackageManager.cpp @@ -32,7 +32,7 @@ using BPackageKit::BManager::BPrivate::BRepositoryBuilder; PackageManager::PackageManager(Root* root, Volume* volume) : - BPackageManager(volume->Location()), + BPackageManager(volume->Location(), this, this), BPackageManager::UserInteractionHandler(), fRoot(root), fVolume(volume), @@ -41,8 +41,6 @@ PackageManager::PackageManager(Root* root, Volume* volume) fPackagesRemovedByUser(), fProblemWindow(NULL) { - fInstallationInterface = this; - fUserInteractionHandler = this; }