package daemon: Pass volume state CommitTransactionHandler

... and remove the getter from Volume again.
This commit is contained in:
Ingo Weinhold 2014-04-20 19:06:47 +02:00
parent 7a35d803d0
commit 7a3253f07c
4 changed files with 14 additions and 15 deletions

View File

@ -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);
}

View File

@ -25,6 +25,7 @@ typedef std::set<std::string> 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;

View File

@ -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 {

View File

@ -111,9 +111,6 @@ public:
void SetRoot(Root* root)
{ fRoot = root; }
VolumeState* State() const
{ return fState; }
PackageFileNameHashTable::Iterator PackagesByFileNameIterator()
const;