From 7a3253f07c1268b15f6a16bf15cb0a8607ade304 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 20 Apr 2014 19:06:47 +0200 Subject: [PATCH] package daemon: Pass volume state CommitTransactionHandler ... and remove the getter from Volume again. --- .../package/CommitTransactionHandler.cpp | 18 +++++++++--------- src/servers/package/CommitTransactionHandler.h | 2 ++ src/servers/package/Volume.cpp | 6 +++--- src/servers/package/Volume.h | 3 --- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/servers/package/CommitTransactionHandler.cpp b/src/servers/package/CommitTransactionHandler.cpp index 4302ccf6a3..eef8bb9d3f 100644 --- a/src/servers/package/CommitTransactionHandler.cpp +++ b/src/servers/package/CommitTransactionHandler.cpp @@ -32,10 +32,11 @@ using namespace BPackageKit::BPrivate; CommitTransactionHandler::CommitTransactionHandler(Volume* volume, - const PackageSet& packagesAlreadyAdded, + VolumeState* volumeState, const PackageSet& packagesAlreadyAdded, const PackageSet& packagesAlreadyRemoved) : fVolume(volume), + fVolumeState(volumeState), fPackagesToActivate(), fPackagesToDeactivate(), fAddedPackages(), @@ -86,7 +87,7 @@ CommitTransactionHandler::HandleRequest( const BActivationTransaction& transaction, BMessage* reply) { // check the change count - if (transaction.ChangeCount() != fVolume->State()->ChangeCount()) + if (transaction.ChangeCount() != fVolumeState->ChangeCount()) throw Exception(B_DAEMON_CHANGE_COUNT_MISMATCH); // collect the packages to deactivate @@ -156,7 +157,7 @@ CommitTransactionHandler::_GetPackagesToDeactivate( for (int32 i = 0; i < packagesToDeactivateCount; i++) { BString packageName = packagesToDeactivate.StringAt(i); - Package* package = fVolume->State()->FindPackage(packageName); + Package* package = fVolumeState->FindPackage(packageName); if (package == NULL) { throw Exception(B_DAEMON_NO_SUCH_PACKAGE, "no such package", packageName); @@ -213,7 +214,7 @@ CommitTransactionHandler::_ReadPackagesToActivate( BString packageName = packagesToActivate.StringAt(i); // make sure it doesn't clash with an already existing package - Package* package = fVolume->State()->FindPackage(packageName); + Package* package = fVolumeState->FindPackage(packageName); if (package != NULL) { if (fPackagesAlreadyAdded.find(package) != fPackagesAlreadyAdded.end()) { @@ -419,7 +420,7 @@ CommitTransactionHandler::_AddPackagesToActivate() } // also add the package to the volume - fVolume->State()->AddPackage(package); + fVolumeState->AddPackage(package); _PreparePackageToActivate(package); } @@ -937,7 +938,7 @@ CommitTransactionHandler::_RevertAddPackagesToActivate() continue; } - fVolume->State()->RemovePackage(package); + fVolumeState->RemovePackage(package); if (transactionDirectory.InitCheck() != B_OK) continue; @@ -1294,7 +1295,7 @@ CommitTransactionHandler::_CreateActivationFileContent( { BString activationFileContent; for (PackageFileNameHashTable::Iterator it - = fVolume->State()->ByFileNameIterator(); + = fVolumeState->ByFileNameIterator(); Package* package = it.Next();) { if (package->IsActive() && toDeactivate.find(package) == toDeactivate.end()) { @@ -1435,8 +1436,7 @@ CommitTransactionHandler::_ChangePackageActivation( // Update our state, i.e. remove deactivated packages and mark activated // packages accordingly. - fVolume->State()->ActivationChanged(packagesToActivate, - packagesToDeactivate); + fVolumeState->ActivationChanged(packagesToActivate, packagesToDeactivate); } diff --git a/src/servers/package/CommitTransactionHandler.h b/src/servers/package/CommitTransactionHandler.h index c04939a561..2a2c9ccee4 100644 --- a/src/servers/package/CommitTransactionHandler.h +++ b/src/servers/package/CommitTransactionHandler.h @@ -25,6 +25,7 @@ typedef std::set StringSet; class CommitTransactionHandler { public: CommitTransactionHandler(Volume* volume, + VolumeState* volumeState, const PackageSet& packagesAlreadyAdded, const PackageSet& packagesAlreadyRemoved); ~CommitTransactionHandler(); @@ -125,6 +126,7 @@ private: private: Volume* fVolume; + VolumeState* fVolumeState; PackageList fPackagesToActivate; PackageSet fPackagesToDeactivate; PackageSet fAddedPackages; diff --git a/src/servers/package/Volume.cpp b/src/servers/package/Volume.cpp index 256b55a17f..248d458fa9 100644 --- a/src/servers/package/Volume.cpp +++ b/src/servers/package/Volume.cpp @@ -397,7 +397,7 @@ Volume::HandleCommitTransactionRequest(BMessage* message) // perform the request PackageSet dummy; - CommitTransactionHandler handler(this, dummy, dummy); + CommitTransactionHandler handler(this, fState, dummy, dummy); int32 error; try { handler.HandleRequest(message, &reply); @@ -569,7 +569,7 @@ Volume::ProcessPendingPackageActivationChanges() return; // perform the request - CommitTransactionHandler handler(this, fPackagesToBeActivated, + CommitTransactionHandler handler(this, fState, fPackagesToBeActivated, fPackagesToBeDeactivated); int32 error; try { @@ -654,7 +654,7 @@ Volume::CommitTransaction(const BActivationTransaction& transaction, BDaemonClient::BCommitTransactionResult& _result) { // perform the request - CommitTransactionHandler handler(this, packagesAlreadyAdded, + CommitTransactionHandler handler(this, fState, packagesAlreadyAdded, packagesAlreadyRemoved); int32 error; try { diff --git a/src/servers/package/Volume.h b/src/servers/package/Volume.h index 6422d03961..0afbcf7cb7 100644 --- a/src/servers/package/Volume.h +++ b/src/servers/package/Volume.h @@ -111,9 +111,6 @@ public: void SetRoot(Root* root) { fRoot = root; } - VolumeState* State() const - { return fState; } - PackageFileNameHashTable::Iterator PackagesByFileNameIterator() const;