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.
This commit is contained in:
Ingo Weinhold 2014-05-02 11:27:09 +02:00
parent 5a1c6a7089
commit 4284b6c93a
4 changed files with 79 additions and 9 deletions

View File

@ -7,6 +7,7 @@
#include <Node.h>
#include <String.h>
#include <package/PackageDefs.h>
#include <package/PackageInfoSet.h>
@ -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;
};

View File

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

View File

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

View File

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