From 4284b6c93ad90effc93057772d6e4595043cbf3d Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 2 May 2014 11:27:09 +0200 Subject: [PATCH] BInstallationLocationInfo: Provide more info * If the active state is not the latest state, also provide a package set for it. * If an old state has been booted, provide its name. --- headers/os/package/InstallationLocationInfo.h | 9 +++++ src/kits/package/DaemonClient.cpp | 23 ++++++++----- src/kits/package/InstallationLocationInfo.cpp | 33 +++++++++++++++++++ src/servers/package/Volume.cpp | 23 ++++++++++++- 4 files changed, 79 insertions(+), 9 deletions(-) diff --git a/headers/os/package/InstallationLocationInfo.h b/headers/os/package/InstallationLocationInfo.h index d07cae95bb..950011fcfb 100644 --- a/headers/os/package/InstallationLocationInfo.h +++ b/headers/os/package/InstallationLocationInfo.h @@ -7,6 +7,7 @@ #include +#include #include #include @@ -39,8 +40,14 @@ public: const BPackageInfoSet& LatestInactivePackageInfos() const; void SetLatestInactivePackageInfos( const BPackageInfoSet& infos); + + const BPackageInfoSet& CurrentlyActivePackageInfos() const; + void SetCurrentlyActivePackageInfos( const BPackageInfoSet& infos); + const BString& OldStateName() const; + void SetOldStateName(const BString& name); + int64 ChangeCount() const; void SetChangeCount(int64 changeCount); @@ -50,6 +57,8 @@ private: node_ref fPackageDirectoryRef; BPackageInfoSet fLatestActivePackageInfos; BPackageInfoSet fLatestInactivePackageInfos; + BPackageInfoSet fCurrentlyActivePackageInfos; + BString fOldStateName; int64 fChangeCount; }; diff --git a/src/kits/package/DaemonClient.cpp b/src/kits/package/DaemonClient.cpp index 243d15e5cc..0e7a44d8e3 100644 --- a/src/kits/package/DaemonClient.cpp +++ b/src/kits/package/DaemonClient.cpp @@ -63,9 +63,11 @@ BDaemonClient::GetInstallationLocationInfo( int64 baseDirectoryNode; int32 packagesDirectoryDevice; int64 packagesDirectoryNode; + BString oldStateName; int64 changeCount; - BPackageInfoSet activePackages; - BPackageInfoSet inactivePackages; + BPackageInfoSet latestActivePackages; + BPackageInfoSet latestInactivePackages; + BPackageInfoSet currentlyActivePackages; if ((error = reply.FindInt32("base directory device", &baseDirectoryDevice)) != B_OK || (error = reply.FindInt64("base directory node", &baseDirectoryNode)) @@ -74,10 +76,13 @@ BDaemonClient::GetInstallationLocationInfo( &packagesDirectoryDevice)) != B_OK || (error = reply.FindInt64("packages directory node", &packagesDirectoryNode)) != B_OK - || (error = _ExtractPackageInfoSet(reply, "active packages", - activePackages)) != B_OK - || (error = _ExtractPackageInfoSet(reply, "inactive packages", - inactivePackages)) != B_OK + || (error = _ExtractPackageInfoSet(reply, "latest active packages", + latestActivePackages)) != B_OK + || (error = _ExtractPackageInfoSet(reply, "latest inactive packages", + latestInactivePackages)) != B_OK + || (error = _ExtractPackageInfoSet(reply, "currently active packages", + currentlyActivePackages)) != B_OK + || (error = reply.FindString("old state", &oldStateName)) != B_OK || (error = reply.FindInt64("change count", &changeCount)) != B_OK) { return error; } @@ -87,8 +92,10 @@ BDaemonClient::GetInstallationLocationInfo( _info.SetBaseDirectoryRef(node_ref(baseDirectoryDevice, baseDirectoryNode)); _info.SetPackagesDirectoryRef( node_ref(packagesDirectoryDevice, packagesDirectoryNode)); - _info.SetLatestActivePackageInfos(activePackages); - _info.SetLatestInactivePackageInfos(inactivePackages); + _info.SetLatestActivePackageInfos(latestActivePackages); + _info.SetLatestInactivePackageInfos(latestInactivePackages); + _info.SetCurrentlyActivePackageInfos(currentlyActivePackages); + _info.SetOldStateName(oldStateName); _info.SetChangeCount(changeCount); return B_OK; diff --git a/src/kits/package/InstallationLocationInfo.cpp b/src/kits/package/InstallationLocationInfo.cpp index 06d55983f1..b4434e9237 100644 --- a/src/kits/package/InstallationLocationInfo.cpp +++ b/src/kits/package/InstallationLocationInfo.cpp @@ -20,6 +20,8 @@ BInstallationLocationInfo::BInstallationLocationInfo() fPackageDirectoryRef(), fLatestActivePackageInfos(), fLatestInactivePackageInfos(), + fCurrentlyActivePackageInfos(), + fOldStateName(), fChangeCount(0) { } @@ -38,6 +40,8 @@ BInstallationLocationInfo::Unset() fPackageDirectoryRef = node_ref(); fLatestActivePackageInfos.MakeEmpty(); fLatestInactivePackageInfos.MakeEmpty(); + fCurrentlyActivePackageInfos.MakeEmpty(); + fOldStateName.Truncate(0); fChangeCount = 0; } @@ -116,6 +120,35 @@ BInstallationLocationInfo::SetLatestInactivePackageInfos( } +const BPackageInfoSet& +BInstallationLocationInfo::CurrentlyActivePackageInfos() const +{ + return fCurrentlyActivePackageInfos; +} + + +void +BInstallationLocationInfo::SetCurrentlyActivePackageInfos( + const BPackageInfoSet& infos) +{ + fCurrentlyActivePackageInfos = infos; +} + + +const BString& +BInstallationLocationInfo::OldStateName() const +{ + return fOldStateName; +} + + +void +BInstallationLocationInfo::SetOldStateName(const BString& name) +{ + fOldStateName = name; +} + + int64 BInstallationLocationInfo::ChangeCount() const { diff --git a/src/servers/package/Volume.cpp b/src/servers/package/Volume.cpp index 9b0822c64c..97a79e2c78 100644 --- a/src/servers/package/Volume.cpp +++ b/src/servers/package/Volume.cpp @@ -476,7 +476,7 @@ Volume::HandleGetLocationInfoRequest(BMessage* message) = fLatestState->ByFileNameIterator(); it.HasNext();) { Package* package = it.Next(); const char* fieldName = package->IsActive() - ? "active packages" : "inactive packages"; + ? "latest active packages" : "latest inactive packages"; BMessage packageArchive; if (package->Info().Archive(&packageArchive) != B_OK || fLocationInfoReply.AddMessage(fieldName, &packageArchive) @@ -485,6 +485,27 @@ Volume::HandleGetLocationInfoRequest(BMessage* message) } } + if (fActiveState != fLatestState) { + if (fPackagesDirectoryCount > 1) { + fLocationInfoReply.AddString("old state", + fPackagesDirectories[fPackagesDirectoryCount - 1].Name()); + } + + for (PackageFileNameHashTable::Iterator it + = fActiveState->ByFileNameIterator(); it.HasNext();) { + Package* package = it.Next(); + if (!package->IsActive()) + continue; + + BMessage packageArchive; + if (package->Info().Archive(&packageArchive) != B_OK + || fLocationInfoReply.AddMessage("currently active packages", + &packageArchive) != B_OK) { + return; + } + } + } + if (fLocationInfoReply.AddInt64("change count", fChangeCount) != B_OK) return;