hpkg format: Generalize user/global settings file attributes
* For all identifiers: Rename global settings file to global writable file. We want to use the respective attribute also for other writable files, not only settings files. * User settings file/global writable file info/attribute: Add isDirectory property/child attribute. This allows declaring global/ user settings directories associated with the package.
This commit is contained in:
@@ -1 +0,0 @@
|
||||
#include <../os/package/GlobalSettingsFileInfo.h>
|
||||
@@ -0,0 +1 @@
|
||||
#include <../os/package/GlobalWritableFileInfo.h>
|
||||
@@ -1 +0,0 @@
|
||||
#include <../os/package/SettingsFileUpdateType.h>
|
||||
@@ -0,0 +1 @@
|
||||
#include <../os/package/WritableFileUpdateType.h>
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__GLOBAL_SETTINGS_FILE_INFO_H_
|
||||
#define _PACKAGE__GLOBAL_SETTINGS_FILE_INFO_H_
|
||||
|
||||
|
||||
#include <package/SettingsFileUpdateType.h>
|
||||
#include <String.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
namespace BHPKG {
|
||||
struct BGlobalSettingsFileInfoData;
|
||||
}
|
||||
|
||||
|
||||
class BGlobalSettingsFileInfo {
|
||||
public:
|
||||
BGlobalSettingsFileInfo();
|
||||
BGlobalSettingsFileInfo(
|
||||
const BHPKG::BGlobalSettingsFileInfoData&
|
||||
infoData);
|
||||
BGlobalSettingsFileInfo(const BString& path,
|
||||
BSettingsFileUpdateType updateType);
|
||||
~BGlobalSettingsFileInfo();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
const BString& Path() const;
|
||||
bool IsIncluded() const;
|
||||
BSettingsFileUpdateType UpdateType() const;
|
||||
|
||||
void SetTo(const BString& path,
|
||||
BSettingsFileUpdateType updateType);
|
||||
|
||||
private:
|
||||
BString fPath;
|
||||
BSettingsFileUpdateType fUpdateType;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__GLOBAL_SETTINGS_FILE_INFO_H_
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__GLOBAL_WRITABLE_FILE_INFO_H_
|
||||
#define _PACKAGE__GLOBAL_WRITABLE_FILE_INFO_H_
|
||||
|
||||
|
||||
#include <package/WritableFileUpdateType.h>
|
||||
#include <String.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
namespace BHPKG {
|
||||
struct BGlobalWritableFileInfoData;
|
||||
}
|
||||
|
||||
|
||||
class BGlobalWritableFileInfo {
|
||||
public:
|
||||
BGlobalWritableFileInfo();
|
||||
BGlobalWritableFileInfo(
|
||||
const BHPKG::BGlobalWritableFileInfoData&
|
||||
infoData);
|
||||
BGlobalWritableFileInfo(const BString& path,
|
||||
BWritableFileUpdateType updateType,
|
||||
bool isDirectory);
|
||||
~BGlobalWritableFileInfo();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
const BString& Path() const;
|
||||
bool IsIncluded() const;
|
||||
BWritableFileUpdateType UpdateType() const;
|
||||
bool IsDirectory() const;
|
||||
|
||||
void SetTo(const BString& path,
|
||||
BWritableFileUpdateType updateType,
|
||||
bool isDirectory);
|
||||
|
||||
private:
|
||||
BString fPath;
|
||||
BWritableFileUpdateType fUpdateType;
|
||||
bool fIsDirectory;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__GLOBAL_WRITABLE_FILE_INFO_H_
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <String.h>
|
||||
#include <StringList.h>
|
||||
|
||||
#include <package/GlobalSettingsFileInfo.h>
|
||||
#include <package/GlobalWritableFileInfo.h>
|
||||
#include <package/PackageArchitecture.h>
|
||||
#include <package/PackageFlags.h>
|
||||
#include <package/PackageInfoAttributes.h>
|
||||
@@ -82,8 +82,8 @@ public:
|
||||
const BStringList& URLList() const;
|
||||
const BStringList& SourceURLList() const;
|
||||
|
||||
const BObjectList<BGlobalSettingsFileInfo>&
|
||||
GlobalSettingsFileInfos() const;
|
||||
const BObjectList<BGlobalWritableFileInfo>&
|
||||
GlobalWritableFileInfos() const;
|
||||
const BObjectList<BUserSettingsFileInfo>&
|
||||
UserSettingsFileInfos() const;
|
||||
|
||||
@@ -133,9 +133,9 @@ public:
|
||||
void ClearSourceURLList();
|
||||
status_t AddSourceURL(const BString& url);
|
||||
|
||||
void ClearGlobalSettingsFileInfos();
|
||||
status_t AddGlobalSettingsFileInfo(
|
||||
const BGlobalSettingsFileInfo& info);
|
||||
void ClearGlobalWritableFileInfos();
|
||||
status_t AddGlobalWritableFileInfo(
|
||||
const BGlobalWritableFileInfo& info);
|
||||
|
||||
void ClearUserSettingsFileInfos();
|
||||
status_t AddUserSettingsFileInfo(
|
||||
@@ -193,7 +193,7 @@ public:
|
||||
public:
|
||||
static const char* const kElementNames[];
|
||||
static const char* const kArchitectureNames[];
|
||||
static const char* const kSettingsFileUpdateTypes[];
|
||||
static const char* const kWritableFileUpdateTypes[];
|
||||
|
||||
private:
|
||||
class Parser;
|
||||
@@ -206,8 +206,8 @@ private:
|
||||
typedef BObjectList<BPackageResolvableExpression>
|
||||
ResolvableExpressionList;
|
||||
|
||||
typedef BObjectList<BGlobalSettingsFileInfo>
|
||||
GlobalSettingsFileInfoList;
|
||||
typedef BObjectList<BGlobalWritableFileInfo>
|
||||
GlobalWritableFileInfoList;
|
||||
typedef BObjectList<BUserSettingsFileInfo>
|
||||
UserSettingsFileInfoList;
|
||||
|
||||
@@ -227,9 +227,9 @@ private:
|
||||
const char* field,
|
||||
const ResolvableExpressionList&
|
||||
expressions);
|
||||
static status_t _AddGlobalSettingsFileInfos(BMessage* archive,
|
||||
static status_t _AddGlobalWritableFileInfos(BMessage* archive,
|
||||
const char* field,
|
||||
const GlobalSettingsFileInfoList&
|
||||
const GlobalWritableFileInfoList&
|
||||
infos);
|
||||
static status_t _AddUserSettingsFileInfos(BMessage* archive,
|
||||
const char* field,
|
||||
@@ -249,9 +249,9 @@ private:
|
||||
static status_t _ExtractResolvableExpressions(BMessage* archive,
|
||||
const char* field,
|
||||
ResolvableExpressionList& _expressions);
|
||||
static status_t _ExtractGlobalSettingsFileInfos(
|
||||
static status_t _ExtractGlobalWritableFileInfos(
|
||||
BMessage* archive, const char* field,
|
||||
GlobalSettingsFileInfoList& _infos);
|
||||
GlobalWritableFileInfoList& _infos);
|
||||
static status_t _ExtractUserSettingsFileInfos(
|
||||
BMessage* archive, const char* field,
|
||||
UserSettingsFileInfoList& _infos);
|
||||
@@ -277,7 +277,7 @@ private:
|
||||
BStringList fURLList;
|
||||
BStringList fSourceURLList;
|
||||
|
||||
BObjectList<BGlobalSettingsFileInfo> fGlobalSettingsFileInfos;
|
||||
BObjectList<BGlobalWritableFileInfo> fGlobalWritableFileInfos;
|
||||
BObjectList<BUserSettingsFileInfo> fUserSettingsFileInfos;
|
||||
|
||||
UserList fUsers;
|
||||
|
||||
@@ -41,8 +41,8 @@ enum BPackageInfoAttributeID {
|
||||
B_PACKAGE_INFO_INSTALL_PATH, // package install path; only for package
|
||||
// building
|
||||
B_PACKAGE_INFO_BASE_PACKAGE, // name of the base package for this package
|
||||
B_PACKAGE_INFO_GLOBAL_SETTINGS_FILES,
|
||||
// list of global settings file infos
|
||||
B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES,
|
||||
// list of global writable file infos
|
||||
B_PACKAGE_INFO_USER_SETTINGS_FILES,
|
||||
// list of user settings file infos
|
||||
B_PACKAGE_INFO_USERS,
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__SETTINGS_FILE_UPDATE_TYPE_H_
|
||||
#define _PACKAGE__SETTINGS_FILE_UPDATE_TYPE_H_
|
||||
|
||||
|
||||
#include <String.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
// global settings file update types -- specifies behavior in case the previous
|
||||
// version of a settings file provided by a package has been changed by the
|
||||
// user.
|
||||
enum BSettingsFileUpdateType {
|
||||
B_SETTINGS_FILE_UPDATE_TYPE_KEEP_OLD = 0,
|
||||
// the old settings file can be kept
|
||||
B_SETTINGS_FILE_UPDATE_TYPE_MANUAL = 1,
|
||||
// the old settings file needs to be updated manually
|
||||
B_SETTINGS_FILE_UPDATE_TYPE_AUTO_MERGE = 2,
|
||||
// try a three-way merge
|
||||
|
||||
B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT,
|
||||
|
||||
B_SETTINGS_FILE_UPDATE_TYPE_DEFAULT = B_SETTINGS_FILE_UPDATE_TYPE_KEEP_OLD
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__SETTINGS_FILE_UPDATE_TYPE_H_
|
||||
@@ -25,19 +25,25 @@ public:
|
||||
infoData);
|
||||
BUserSettingsFileInfo(const BString& path,
|
||||
const BString& templatePath = BString());
|
||||
BUserSettingsFileInfo(const BString& path,
|
||||
bool isDirectory);
|
||||
~BUserSettingsFileInfo();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
const BString& Path() const;
|
||||
const BString& TemplatePath() const;
|
||||
bool IsDirectory() const;
|
||||
|
||||
void SetTo(const BString& path,
|
||||
const BString& templatePath = BString());
|
||||
void SetTo(const BString& path,
|
||||
bool isDirectory);
|
||||
|
||||
private:
|
||||
BString fPath;
|
||||
BString fTemplatePath;
|
||||
bool fIsDirectory;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__WRITABLE_FILE_UPDATE_TYPE_H_
|
||||
#define _PACKAGE__WRITABLE_FILE_UPDATE_TYPE_H_
|
||||
|
||||
|
||||
#include <String.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
// global writable file update types -- specifies behavior in case the previous
|
||||
// version of a writable file provided by a package has been changed by the
|
||||
// user.
|
||||
enum BWritableFileUpdateType {
|
||||
B_WRITABLE_FILE_UPDATE_TYPE_KEEP_OLD = 0,
|
||||
// the old writable file can be kept
|
||||
B_WRITABLE_FILE_UPDATE_TYPE_MANUAL = 1,
|
||||
// the old writable file needs to be updated manually
|
||||
B_WRITABLE_FILE_UPDATE_TYPE_AUTO_MERGE = 2,
|
||||
// try a three-way merge
|
||||
|
||||
B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT,
|
||||
|
||||
B_WRITABLE_FILE_UPDATE_TYPE_DEFAULT = B_WRITABLE_FILE_UPDATE_TYPE_KEEP_OLD
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__WRITABLE_FILE_UPDATE_TYPE_H_
|
||||
@@ -62,12 +62,12 @@ B_DEFINE_HPKG_ATTRIBUTE(40, STRING, "package:install-path",
|
||||
PACKAGE_INSTALL_PATH)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(41, STRING, "package:base-package",
|
||||
PACKAGE_BASE_PACKAGE)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(42, STRING, "package:global-settings-file",
|
||||
PACKAGE_GLOBAL_SETTINGS_FILE)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(42, STRING, "package:global-writable-file",
|
||||
PACKAGE_GLOBAL_WRITABLE_FILE)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(43, STRING, "package:user-settings-file",
|
||||
PACKAGE_USER_SETTINGS_FILE)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(44, UINT, "package:settings-file-update-type",
|
||||
PACKAGE_SETTINGS_FILE_UPDATE_TYPE)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(44, UINT, "package:writable-file-update-type",
|
||||
PACKAGE_WRITABLE_FILE_UPDATE_TYPE)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(45, STRING, "package:settings-file-template",
|
||||
PACKAGE_SETTINGS_FILE_TEMPLATE)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(46, STRING, "package:user", PACKAGE_USER)
|
||||
@@ -79,3 +79,5 @@ B_DEFINE_HPKG_ATTRIBUTE(50, STRING, "package:user.group", PACKAGE_USER_GROUP)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(51, STRING, "package:group", PACKAGE_GROUP)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(52, STRING, "package:post-install-script",
|
||||
PACKAGE_POST_INSTALL_SCRIPT)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(53, UINT, "package:is-writable-directory",
|
||||
PACKAGE_IS_WRITABLE_DIRECTORY)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <package/PackageArchitecture.h>
|
||||
#include <package/PackageInfoAttributes.h>
|
||||
#include <package/PackageResolvableOperator.h>
|
||||
#include <package/SettingsFileUpdateType.h>
|
||||
#include <package/WritableFileUpdateType.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
@@ -47,15 +47,17 @@ struct BPackageResolvableExpressionData {
|
||||
};
|
||||
|
||||
|
||||
struct BGlobalSettingsFileInfoData {
|
||||
struct BGlobalWritableFileInfoData {
|
||||
const char* path;
|
||||
BSettingsFileUpdateType updateType;
|
||||
BWritableFileUpdateType updateType;
|
||||
bool isDirectory;
|
||||
};
|
||||
|
||||
|
||||
struct BUserSettingsFileInfoData {
|
||||
const char* path;
|
||||
const char* templatePath;
|
||||
bool isDirectory;
|
||||
};
|
||||
|
||||
|
||||
@@ -76,7 +78,7 @@ struct BPackageInfoAttributeValue {
|
||||
BPackageVersionData version;
|
||||
BPackageResolvableData resolvable;
|
||||
BPackageResolvableExpressionData resolvableExpression;
|
||||
BGlobalSettingsFileInfoData globalSettingsFileInfo;
|
||||
BGlobalWritableFileInfoData globalWritableFileInfo;
|
||||
BUserSettingsFileInfoData userSettingsFileInfo;
|
||||
BUserData user;
|
||||
};
|
||||
|
||||
@@ -102,7 +102,7 @@ protected:
|
||||
class PackageVersionAttributeHandler;
|
||||
class PackageResolvableAttributeHandler;
|
||||
class PackageResolvableExpressionAttributeHandler;
|
||||
class GlobalSettingsFileInfoAttributeHandler;
|
||||
class GlobalWritableFileInfoAttributeHandler;
|
||||
class UserSettingsFileInfoAttributeHandler;
|
||||
class UserAttributeHandler;
|
||||
class PackageAttributeHandler;
|
||||
@@ -318,10 +318,10 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class ReaderImplBase::GlobalSettingsFileInfoAttributeHandler
|
||||
class ReaderImplBase::GlobalWritableFileInfoAttributeHandler
|
||||
: public PackageInfoAttributeHandlerBase {
|
||||
public:
|
||||
GlobalSettingsFileInfoAttributeHandler(
|
||||
GlobalWritableFileInfoAttributeHandler(
|
||||
BPackageInfoAttributeValue&
|
||||
packageInfoValue);
|
||||
|
||||
|
||||
@@ -288,14 +288,16 @@ struct PackageContentListHandler : VersionPolicy::PackageContentHandler {
|
||||
printf("\treplaces: %s\n", value.string);
|
||||
break;
|
||||
|
||||
case B_PACKAGE_INFO_GLOBAL_SETTINGS_FILES:
|
||||
printf("\tglobal settings file: %s",
|
||||
value.globalSettingsFileInfo.path);
|
||||
if (value.globalSettingsFileInfo.updateType
|
||||
< B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT) {
|
||||
case B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES:
|
||||
printf("\tglobal writable file: %s",
|
||||
value.globalWritableFileInfo.path);
|
||||
if (value.globalWritableFileInfo.isDirectory)
|
||||
printf( " directory");
|
||||
if (value.globalWritableFileInfo.updateType
|
||||
< B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT) {
|
||||
printf(" %s\n",
|
||||
BPackageInfo::kSettingsFileUpdateTypes[
|
||||
value.globalSettingsFileInfo.updateType]);
|
||||
BPackageInfo::kWritableFileUpdateTypes[
|
||||
value.globalWritableFileInfo.updateType]);
|
||||
} else
|
||||
printf("\n");
|
||||
break;
|
||||
@@ -303,7 +305,9 @@ struct PackageContentListHandler : VersionPolicy::PackageContentHandler {
|
||||
case B_PACKAGE_INFO_USER_SETTINGS_FILES:
|
||||
printf("\tuser settings file: %s",
|
||||
value.userSettingsFileInfo.path);
|
||||
if (value.userSettingsFileInfo.templatePath != NULL) {
|
||||
if (value.globalWritableFileInfo.isDirectory) {
|
||||
printf( " directory\n");
|
||||
} else if (value.userSettingsFileInfo.templatePath != NULL) {
|
||||
printf(" template %s\n",
|
||||
value.userSettingsFileInfo.templatePath);
|
||||
} else
|
||||
|
||||
@@ -31,7 +31,7 @@ HPKG_SOURCES =
|
||||
DataWriters.cpp
|
||||
ErrorOutput.cpp
|
||||
FDDataReader.cpp
|
||||
GlobalSettingsFileInfo.cpp
|
||||
GlobalWritableFileInfo.cpp
|
||||
HPKGDefs.cpp
|
||||
PackageContentHandler.cpp
|
||||
PackageData.cpp
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <package/GlobalSettingsFileInfo.h>
|
||||
|
||||
#include <package/hpkg/PackageInfoAttributeValue.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
BGlobalSettingsFileInfo::BGlobalSettingsFileInfo()
|
||||
:
|
||||
fPath(),
|
||||
fUpdateType(B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BGlobalSettingsFileInfo::BGlobalSettingsFileInfo(
|
||||
const BHPKG::BGlobalSettingsFileInfoData& infoData)
|
||||
:
|
||||
fPath(infoData.path),
|
||||
fUpdateType(infoData.updateType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BGlobalSettingsFileInfo::BGlobalSettingsFileInfo(const BString& path,
|
||||
BSettingsFileUpdateType updateType)
|
||||
:
|
||||
fPath(path),
|
||||
fUpdateType(updateType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BGlobalSettingsFileInfo::~BGlobalSettingsFileInfo()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BGlobalSettingsFileInfo::InitCheck() const
|
||||
{
|
||||
if (fPath.IsEmpty())
|
||||
return B_NO_INIT;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
const BString&
|
||||
BGlobalSettingsFileInfo::Path() const
|
||||
{
|
||||
return fPath;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BGlobalSettingsFileInfo::IsIncluded() const
|
||||
{
|
||||
return fUpdateType != B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT;
|
||||
}
|
||||
|
||||
|
||||
BSettingsFileUpdateType
|
||||
BGlobalSettingsFileInfo::UpdateType() const
|
||||
{
|
||||
return fUpdateType;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGlobalSettingsFileInfo::SetTo(const BString& path,
|
||||
BSettingsFileUpdateType updateType)
|
||||
{
|
||||
fPath = path;
|
||||
fUpdateType = updateType;
|
||||
}
|
||||
|
||||
|
||||
} // namespace BPackageKit
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <package/GlobalWritableFileInfo.h>
|
||||
|
||||
#include <package/hpkg/PackageInfoAttributeValue.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
BGlobalWritableFileInfo::BGlobalWritableFileInfo()
|
||||
:
|
||||
fPath(),
|
||||
fUpdateType(B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BGlobalWritableFileInfo::BGlobalWritableFileInfo(
|
||||
const BHPKG::BGlobalWritableFileInfoData& infoData)
|
||||
:
|
||||
fPath(infoData.path),
|
||||
fUpdateType(infoData.updateType),
|
||||
fIsDirectory(infoData.isDirectory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BGlobalWritableFileInfo::BGlobalWritableFileInfo(const BString& path,
|
||||
BWritableFileUpdateType updateType, bool isDirectory)
|
||||
:
|
||||
fPath(path),
|
||||
fUpdateType(updateType),
|
||||
fIsDirectory(isDirectory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BGlobalWritableFileInfo::~BGlobalWritableFileInfo()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BGlobalWritableFileInfo::InitCheck() const
|
||||
{
|
||||
if (fPath.IsEmpty())
|
||||
return B_NO_INIT;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
const BString&
|
||||
BGlobalWritableFileInfo::Path() const
|
||||
{
|
||||
return fPath;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BGlobalWritableFileInfo::IsIncluded() const
|
||||
{
|
||||
return fUpdateType != B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT;
|
||||
}
|
||||
|
||||
|
||||
BWritableFileUpdateType
|
||||
BGlobalWritableFileInfo::UpdateType() const
|
||||
{
|
||||
return fUpdateType;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BGlobalWritableFileInfo::IsDirectory() const
|
||||
{
|
||||
return fIsDirectory;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BGlobalWritableFileInfo::SetTo(const BString& path,
|
||||
BWritableFileUpdateType updateType, bool isDirectory)
|
||||
{
|
||||
fPath = path;
|
||||
fUpdateType = updateType;
|
||||
fIsDirectory = isDirectory;
|
||||
}
|
||||
|
||||
|
||||
} // namespace BPackageKit
|
||||
@@ -21,7 +21,7 @@ HPKG_SOURCES =
|
||||
DataWriters.cpp
|
||||
ErrorOutput.cpp
|
||||
FDDataReader.cpp
|
||||
GlobalSettingsFileInfo.cpp
|
||||
GlobalWritableFileInfo.cpp
|
||||
HPKGDefs.cpp
|
||||
PackageContentHandler.cpp
|
||||
PackageData.cpp
|
||||
|
||||
@@ -51,7 +51,7 @@ const char* const BPackageInfo::kElementNames[B_PACKAGE_INFO_ENUM_COUNT] = {
|
||||
"checksum", // not being parsed, computed externally
|
||||
NULL, // install-path -- not settable via .PackageInfo
|
||||
"base-package",
|
||||
"global-settings-files",
|
||||
"global-writable-files",
|
||||
"user-settings-files",
|
||||
"users",
|
||||
"groups",
|
||||
@@ -68,8 +68,8 @@ BPackageInfo::kArchitectureNames[B_PACKAGE_ARCHITECTURE_ENUM_COUNT] = {
|
||||
};
|
||||
|
||||
|
||||
const char* const BPackageInfo::kSettingsFileUpdateTypes[
|
||||
B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT] = {
|
||||
const char* const BPackageInfo::kWritableFileUpdateTypes[
|
||||
B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT] = {
|
||||
"keep-old",
|
||||
"manual",
|
||||
"auto-merge",
|
||||
@@ -168,7 +168,7 @@ BPackageInfo::BPackageInfo()
|
||||
fLicenseList(4),
|
||||
fURLList(4),
|
||||
fSourceURLList(4),
|
||||
fGlobalSettingsFileInfos(4, true),
|
||||
fGlobalWritableFileInfos(4, true),
|
||||
fUserSettingsFileInfos(4, true),
|
||||
fUsers(4, true),
|
||||
fGroups(4),
|
||||
@@ -192,7 +192,7 @@ BPackageInfo::BPackageInfo(BMessage* archive, status_t* _error)
|
||||
fLicenseList(4),
|
||||
fURLList(4),
|
||||
fSourceURLList(4),
|
||||
fGlobalSettingsFileInfos(4, true),
|
||||
fGlobalWritableFileInfos(4, true),
|
||||
fUserSettingsFileInfos(4, true),
|
||||
fUsers(4, true),
|
||||
fGroups(4),
|
||||
@@ -222,8 +222,8 @@ BPackageInfo::BPackageInfo(BMessage* archive, status_t* _error)
|
||||
&& (error = _ExtractStringList(archive, "urls", fURLList)) == B_OK
|
||||
&& (error = _ExtractStringList(archive, "source-urls", fSourceURLList))
|
||||
== B_OK
|
||||
&& (error = _ExtractGlobalSettingsFileInfos(archive,
|
||||
"global-settings-files", fGlobalSettingsFileInfos)) == B_OK
|
||||
&& (error = _ExtractGlobalWritableFileInfos(archive,
|
||||
"global-writable-files", fGlobalWritableFileInfos)) == B_OK
|
||||
&& (error = _ExtractUserSettingsFileInfos(archive, "user-settings-files",
|
||||
fUserSettingsFileInfos)) == B_OK
|
||||
&& (error = _ExtractUsers(archive, "users", fUsers)) == B_OK
|
||||
@@ -340,11 +340,11 @@ BPackageInfo::InitCheck() const
|
||||
|| fProvidesList.IsEmpty())
|
||||
return B_NO_INIT;
|
||||
|
||||
// check global settings files
|
||||
int32 globalSettingsFileCount = fGlobalSettingsFileInfos.CountItems();
|
||||
for (int32 i = 0; i < globalSettingsFileCount; i++) {
|
||||
const BGlobalSettingsFileInfo* info
|
||||
= fGlobalSettingsFileInfos.ItemAt(i);
|
||||
// check global writable files
|
||||
int32 globalWritableFileCount = fGlobalWritableFileInfos.CountItems();
|
||||
for (int32 i = 0; i < globalWritableFileCount; i++) {
|
||||
const BGlobalWritableFileInfo* info
|
||||
= fGlobalWritableFileInfos.ItemAt(i);
|
||||
status_t error = info->InitCheck();
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
@@ -493,10 +493,10 @@ BPackageInfo::SourceURLList() const
|
||||
}
|
||||
|
||||
|
||||
const BObjectList<BGlobalSettingsFileInfo>&
|
||||
BPackageInfo::GlobalSettingsFileInfos() const
|
||||
const BObjectList<BGlobalWritableFileInfo>&
|
||||
BPackageInfo::GlobalWritableFileInfos() const
|
||||
{
|
||||
return fGlobalSettingsFileInfos;
|
||||
return fGlobalWritableFileInfos;
|
||||
}
|
||||
|
||||
|
||||
@@ -716,18 +716,18 @@ BPackageInfo::AddSourceURL(const BString& url)
|
||||
|
||||
|
||||
void
|
||||
BPackageInfo::ClearGlobalSettingsFileInfos()
|
||||
BPackageInfo::ClearGlobalWritableFileInfos()
|
||||
{
|
||||
fGlobalSettingsFileInfos.MakeEmpty();
|
||||
fGlobalWritableFileInfos.MakeEmpty();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BPackageInfo::AddGlobalSettingsFileInfo(const BGlobalSettingsFileInfo& info)
|
||||
BPackageInfo::AddGlobalWritableFileInfo(const BGlobalWritableFileInfo& info)
|
||||
{
|
||||
BGlobalSettingsFileInfo* newInfo
|
||||
= new (std::nothrow) BGlobalSettingsFileInfo(info);
|
||||
if (newInfo == NULL || !fGlobalSettingsFileInfos.AddItem(newInfo)) {
|
||||
BGlobalWritableFileInfo* newInfo
|
||||
= new (std::nothrow) BGlobalWritableFileInfo(info);
|
||||
if (newInfo == NULL || !fGlobalWritableFileInfos.AddItem(newInfo)) {
|
||||
delete newInfo;
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
@@ -932,7 +932,7 @@ BPackageInfo::Clear()
|
||||
fLicenseList.MakeEmpty();
|
||||
fURLList.MakeEmpty();
|
||||
fSourceURLList.MakeEmpty();
|
||||
fGlobalSettingsFileInfos.MakeEmpty();
|
||||
fGlobalWritableFileInfos.MakeEmpty();
|
||||
fUserSettingsFileInfos.MakeEmpty();
|
||||
fUsers.MakeEmpty();
|
||||
fGroups.MakeEmpty();
|
||||
@@ -968,8 +968,8 @@ BPackageInfo::Archive(BMessage* archive, bool deep) const
|
||||
|| (error = archive->AddStrings("urls", fURLList)) != B_OK
|
||||
|| (error = archive->AddStrings("source-urls", fSourceURLList))
|
||||
!= B_OK
|
||||
|| (error = _AddGlobalSettingsFileInfos(archive,
|
||||
"global-settings-files", fGlobalSettingsFileInfos)) != B_OK
|
||||
|| (error = _AddGlobalWritableFileInfos(archive,
|
||||
"global-writable-files", fGlobalWritableFileInfos)) != B_OK
|
||||
|| (error = _AddUserSettingsFileInfos(archive,
|
||||
"user-settings-files", fUserSettingsFileInfos)) != B_OK
|
||||
|| (error = _AddUsers(archive, "users", fUsers)) != B_OK
|
||||
@@ -1019,7 +1019,7 @@ BPackageInfo::GetConfigString(BString& _string) const
|
||||
.Write("licenses", fLicenseList)
|
||||
.Write("urls", fURLList)
|
||||
.Write("source-urls", fSourceURLList)
|
||||
.Write("global-settings-files", fGlobalSettingsFileInfos)
|
||||
.Write("global-writable-files", fGlobalWritableFileInfos)
|
||||
.Write("user-settings-files", fUserSettingsFileInfos)
|
||||
.Write("users", fUsers)
|
||||
.Write("groups", fGroups)
|
||||
@@ -1219,24 +1219,29 @@ BPackageInfo::_AddResolvableExpressions(BMessage* archive, const char* field,
|
||||
|
||||
|
||||
/*static*/ status_t
|
||||
BPackageInfo::_AddGlobalSettingsFileInfos(BMessage* archive, const char* field,
|
||||
const GlobalSettingsFileInfoList& infos)
|
||||
BPackageInfo::_AddGlobalWritableFileInfos(BMessage* archive, const char* field,
|
||||
const GlobalWritableFileInfoList& infos)
|
||||
{
|
||||
// construct the field names we need
|
||||
FieldName pathField(field, ":path");
|
||||
FieldName updateTypeField(field, ":version");
|
||||
FieldName updateTypeField(field, ":updateType");
|
||||
FieldName isDirectoryField(field, ":isDirectory");
|
||||
|
||||
if (!pathField.IsValid() || !updateTypeField.IsValid())
|
||||
if (!pathField.IsValid() || !updateTypeField.IsValid()
|
||||
|| !isDirectoryField.IsValid()) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
// add fields
|
||||
int32 count = infos.CountItems();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
const BGlobalSettingsFileInfo* info = infos.ItemAt(i);
|
||||
const BGlobalWritableFileInfo* info = infos.ItemAt(i);
|
||||
status_t error;
|
||||
if ((error = archive->AddString(pathField, info->Path())) != B_OK
|
||||
|| (error = archive->AddInt32(updateTypeField, info->UpdateType()))
|
||||
!= B_OK) {
|
||||
!= B_OK
|
||||
|| (error = archive->AddBool(isDirectoryField,
|
||||
info->IsDirectory())) != B_OK) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@@ -1252,9 +1257,12 @@ BPackageInfo::_AddUserSettingsFileInfos(BMessage* archive, const char* field,
|
||||
// construct the field names we need
|
||||
FieldName pathField(field, ":path");
|
||||
FieldName templatePathField(field, ":templatePath");
|
||||
FieldName isDirectoryField(field, ":isDirectory");
|
||||
|
||||
if (!pathField.IsValid() || !templatePathField.IsValid())
|
||||
if (!pathField.IsValid() || !templatePathField.IsValid()
|
||||
|| !isDirectoryField.IsValid()) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
// add fields
|
||||
int32 count = infos.CountItems();
|
||||
@@ -1263,7 +1271,9 @@ BPackageInfo::_AddUserSettingsFileInfos(BMessage* archive, const char* field,
|
||||
status_t error;
|
||||
if ((error = archive->AddString(pathField, info->Path())) != B_OK
|
||||
|| (error = archive->AddString(templatePathField,
|
||||
info->TemplatePath())) != B_OK) {
|
||||
info->TemplatePath())) != B_OK
|
||||
|| (error = archive->AddBool(isDirectoryField,
|
||||
info->IsDirectory())) != B_OK) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@@ -1486,15 +1496,18 @@ BPackageInfo::_ExtractResolvableExpressions(BMessage* archive,
|
||||
|
||||
|
||||
/*static*/ status_t
|
||||
BPackageInfo::_ExtractGlobalSettingsFileInfos(BMessage* archive,
|
||||
const char* field, GlobalSettingsFileInfoList& _infos)
|
||||
BPackageInfo::_ExtractGlobalWritableFileInfos(BMessage* archive,
|
||||
const char* field, GlobalWritableFileInfoList& _infos)
|
||||
{
|
||||
// construct the field names we need
|
||||
FieldName pathField(field, ":path");
|
||||
FieldName updateTypeField(field, ":version");
|
||||
FieldName updateTypeField(field, ":updateType");
|
||||
FieldName isDirectoryField(field, ":isDirectory");
|
||||
|
||||
if (!pathField.IsValid() || !updateTypeField.IsValid())
|
||||
if (!pathField.IsValid() || !updateTypeField.IsValid()
|
||||
|| !isDirectoryField.IsValid()) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
// get the number of items
|
||||
type_code type;
|
||||
@@ -1516,13 +1529,18 @@ BPackageInfo::_ExtractGlobalSettingsFileInfos(BMessage* archive,
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
if (updateType < 0
|
||||
|| updateType > B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT) {
|
||||
|| updateType > B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT) {
|
||||
return B_BAD_DATA;
|
||||
}
|
||||
|
||||
BGlobalSettingsFileInfo* info
|
||||
= new(std::nothrow) BGlobalSettingsFileInfo(path,
|
||||
(BSettingsFileUpdateType)updateType);
|
||||
bool isDirectory;
|
||||
error = archive->FindBool(isDirectoryField, i, &isDirectory);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
BGlobalWritableFileInfo* info
|
||||
= new(std::nothrow) BGlobalWritableFileInfo(path,
|
||||
(BWritableFileUpdateType)updateType, isDirectory);
|
||||
if (info == NULL || !_infos.AddItem(info)) {
|
||||
delete info;
|
||||
return B_NO_MEMORY;
|
||||
@@ -1540,9 +1558,12 @@ BPackageInfo::_ExtractUserSettingsFileInfos(BMessage* archive,
|
||||
// construct the field names we need
|
||||
FieldName pathField(field, ":path");
|
||||
FieldName templatePathField(field, ":templatePath");
|
||||
FieldName isDirectoryField(field, ":isDirectory");
|
||||
|
||||
if (!pathField.IsValid() || !templatePathField.IsValid())
|
||||
if (!pathField.IsValid() || !templatePathField.IsValid()
|
||||
|| !isDirectoryField.IsValid()) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
// get the number of items
|
||||
type_code type;
|
||||
@@ -1564,8 +1585,14 @@ BPackageInfo::_ExtractUserSettingsFileInfos(BMessage* archive,
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
BUserSettingsFileInfo* info
|
||||
= new(std::nothrow) BUserSettingsFileInfo(path, templatePath);
|
||||
bool isDirectory;
|
||||
error = archive->FindBool(isDirectoryField, i, &isDirectory);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
BUserSettingsFileInfo* info = isDirectory
|
||||
? new(std::nothrow) BUserSettingsFileInfo(path, true)
|
||||
: new(std::nothrow) BUserSettingsFileInfo(path, templatePath);
|
||||
if (info == NULL || !_infos.AddItem(info)) {
|
||||
delete info;
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@@ -143,9 +143,9 @@ BPackageInfoContentHandler::HandlePackageAttribute(
|
||||
fPackageInfo.SetBasePackage(value.string);
|
||||
break;
|
||||
|
||||
case B_PACKAGE_INFO_GLOBAL_SETTINGS_FILES:
|
||||
fPackageInfo.AddGlobalSettingsFileInfo(
|
||||
value.globalSettingsFileInfo);
|
||||
case B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES:
|
||||
fPackageInfo.AddGlobalWritableFileInfo(
|
||||
value.globalWritableFileInfo);
|
||||
break;
|
||||
|
||||
case B_PACKAGE_INFO_USER_SETTINGS_FILES:
|
||||
|
||||
@@ -604,15 +604,15 @@ BPackageInfo::Parser::_ParseResolvableExprList(
|
||||
|
||||
|
||||
void
|
||||
BPackageInfo::Parser::_ParseGlobalSettingsFileInfos(
|
||||
GlobalSettingsFileInfoList* infos)
|
||||
BPackageInfo::Parser::_ParseGlobalWritableFileInfos(
|
||||
GlobalWritableFileInfoList* infos)
|
||||
{
|
||||
struct GlobalSettingsFileInfoParser : public ListElementParser {
|
||||
struct GlobalWritableFileInfoParser : public ListElementParser {
|
||||
Parser& parser;
|
||||
GlobalSettingsFileInfoList* infos;
|
||||
GlobalWritableFileInfoList* infos;
|
||||
|
||||
GlobalSettingsFileInfoParser(Parser& parser,
|
||||
GlobalSettingsFileInfoList* infos)
|
||||
GlobalWritableFileInfoParser(Parser& parser,
|
||||
GlobalWritableFileInfoList* infos)
|
||||
:
|
||||
parser(parser),
|
||||
infos(infos)
|
||||
@@ -626,21 +626,27 @@ BPackageInfo::Parser::_ParseGlobalSettingsFileInfos(
|
||||
token.pos);
|
||||
}
|
||||
|
||||
BSettingsFileUpdateType updateType
|
||||
= B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT;
|
||||
BWritableFileUpdateType updateType
|
||||
= B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT;
|
||||
bool isDirectory = false;
|
||||
|
||||
Token nextToken = parser._NextToken();
|
||||
if (nextToken.type == TOKEN_WORD && nextToken.text == "directory") {
|
||||
isDirectory = true;
|
||||
nextToken = parser._NextToken();
|
||||
}
|
||||
|
||||
if (nextToken.type == TOKEN_WORD) {
|
||||
const char* const* end = kSettingsFileUpdateTypes
|
||||
+ B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT;
|
||||
const char* const* found = std::find(kSettingsFileUpdateTypes,
|
||||
const char* const* end = kWritableFileUpdateTypes
|
||||
+ B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT;
|
||||
const char* const* found = std::find(kWritableFileUpdateTypes,
|
||||
end, nextToken.text);
|
||||
if (found == end) {
|
||||
throw ParseError(BString("expected an update type"),
|
||||
nextToken.pos);
|
||||
}
|
||||
updateType = (BSettingsFileUpdateType)(
|
||||
found - kSettingsFileUpdateTypes);
|
||||
updateType = (BWritableFileUpdateType)(
|
||||
found - kWritableFileUpdateTypes);
|
||||
} else if (nextToken.type == TOKEN_ITEM_SEPARATOR
|
||||
|| nextToken.type == TOKEN_CLOSE_BRACE) {
|
||||
parser._RewindTo(nextToken);
|
||||
@@ -650,8 +656,8 @@ BPackageInfo::Parser::_ParseGlobalSettingsFileInfos(
|
||||
nextToken.pos);
|
||||
}
|
||||
|
||||
if (!infos->AddItem(new BGlobalSettingsFileInfo(token.text,
|
||||
updateType))) {
|
||||
if (!infos->AddItem(new BGlobalWritableFileInfo(token.text,
|
||||
updateType, isDirectory))) {
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
}
|
||||
@@ -685,9 +691,13 @@ BPackageInfo::Parser::_ParseUserSettingsFileInfos(
|
||||
}
|
||||
|
||||
BString templatePath;
|
||||
bool isDirectory = false;
|
||||
|
||||
Token nextToken = parser._NextToken();
|
||||
if (nextToken.type == TOKEN_WORD && nextToken.text == "template") {
|
||||
if (nextToken.type == TOKEN_WORD && nextToken.text == "directory") {
|
||||
isDirectory = true;
|
||||
} else if (nextToken.type == TOKEN_WORD
|
||||
&& nextToken.text == "template") {
|
||||
nextToken = parser._NextToken();
|
||||
if (nextToken.type != TOKEN_WORD
|
||||
&& nextToken.type != TOKEN_QUOTED_STRING) {
|
||||
@@ -705,8 +715,10 @@ BPackageInfo::Parser::_ParseUserSettingsFileInfos(
|
||||
nextToken.pos);
|
||||
}
|
||||
|
||||
if (!infos->AddItem(new BUserSettingsFileInfo(token.text,
|
||||
templatePath))) {
|
||||
if (isDirectory
|
||||
? !infos->AddItem(new BUserSettingsFileInfo(token.text, true))
|
||||
: !infos->AddItem(new BUserSettingsFileInfo(token.text,
|
||||
templatePath))) {
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
}
|
||||
@@ -929,9 +941,9 @@ BPackageInfo::Parser::_Parse(BPackageInfo* packageInfo)
|
||||
_ParseStringList(&packageInfo->fSourceURLList);
|
||||
break;
|
||||
|
||||
case B_PACKAGE_INFO_GLOBAL_SETTINGS_FILES:
|
||||
_ParseGlobalSettingsFileInfos(
|
||||
&packageInfo->fGlobalSettingsFileInfos);
|
||||
case B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES:
|
||||
_ParseGlobalWritableFileInfos(
|
||||
&packageInfo->fGlobalWritableFileInfos);
|
||||
break;
|
||||
|
||||
case B_PACKAGE_INFO_USER_SETTINGS_FILES:
|
||||
|
||||
@@ -75,8 +75,8 @@ private:
|
||||
BObjectList<BPackageResolvableExpression>*
|
||||
value,
|
||||
BString* _basePackage = NULL);
|
||||
void _ParseGlobalSettingsFileInfos(
|
||||
GlobalSettingsFileInfoList* infos);
|
||||
void _ParseGlobalWritableFileInfos(
|
||||
GlobalWritableFileInfoList* infos);
|
||||
void _ParseUserSettingsFileInfos(
|
||||
UserSettingsFileInfoList* infos);
|
||||
void _ParseUsers(UserList* users);
|
||||
|
||||
@@ -157,19 +157,25 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void _WriteListElement(const BGlobalSettingsFileInfo* value)
|
||||
void _WriteListElement(const BGlobalWritableFileInfo* value)
|
||||
{
|
||||
_WriteMaybeQuoted(value->Path());
|
||||
if (value->IsDirectory()) {
|
||||
_Write(' ');
|
||||
_Write("directory");
|
||||
}
|
||||
if (value->IsIncluded()) {
|
||||
_Write(' ');
|
||||
_Write(kSettingsFileUpdateTypes[value->UpdateType()]);
|
||||
_Write(kWritableFileUpdateTypes[value->UpdateType()]);
|
||||
}
|
||||
}
|
||||
|
||||
void _WriteListElement(const BUserSettingsFileInfo* value)
|
||||
{
|
||||
_WriteMaybeQuoted(value->Path());
|
||||
if (!value->TemplatePath().IsEmpty()) {
|
||||
if (value->IsDirectory()) {
|
||||
_Write(" directory");
|
||||
} else if (!value->TemplatePath().IsEmpty()) {
|
||||
_Write(" template ");
|
||||
_WriteMaybeQuoted(value->TemplatePath());
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ BUserSettingsFileInfo::BUserSettingsFileInfo(
|
||||
const BHPKG::BUserSettingsFileInfoData& infoData)
|
||||
:
|
||||
fPath(infoData.path),
|
||||
fTemplatePath(infoData.templatePath)
|
||||
fTemplatePath(infoData.templatePath),
|
||||
fIsDirectory(infoData.isDirectory)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -33,7 +34,18 @@ BUserSettingsFileInfo::BUserSettingsFileInfo(const BString& path,
|
||||
const BString& templatePath)
|
||||
:
|
||||
fPath(path),
|
||||
fTemplatePath(templatePath)
|
||||
fTemplatePath(templatePath),
|
||||
fIsDirectory(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BUserSettingsFileInfo::BUserSettingsFileInfo(const BString& path,
|
||||
bool isDirectory)
|
||||
:
|
||||
fPath(path),
|
||||
fTemplatePath(),
|
||||
fIsDirectory(isDirectory)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -64,11 +76,28 @@ BUserSettingsFileInfo::TemplatePath() const
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BUserSettingsFileInfo::IsDirectory() const
|
||||
{
|
||||
return fIsDirectory;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BUserSettingsFileInfo::SetTo(const BString& path, const BString& templatePath)
|
||||
{
|
||||
fPath = path;
|
||||
fTemplatePath = templatePath;
|
||||
fIsDirectory = false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BUserSettingsFileInfo::SetTo(const BString& path, bool isDirectory)
|
||||
{
|
||||
fPath = path;
|
||||
fTemplatePath.Truncate(0);
|
||||
fIsDirectory = isDirectory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -321,11 +321,11 @@ ReaderImplBase::PackageResolvableExpressionAttributeHandler::HandleAttribute(
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - GlobalSettingsFileInfoAttributeHandler
|
||||
// #pragma mark - GlobalWritableFileInfoAttributeHandler
|
||||
|
||||
|
||||
ReaderImplBase::GlobalSettingsFileInfoAttributeHandler
|
||||
::GlobalSettingsFileInfoAttributeHandler(
|
||||
ReaderImplBase::GlobalWritableFileInfoAttributeHandler
|
||||
::GlobalWritableFileInfoAttributeHandler(
|
||||
BPackageInfoAttributeValue& packageInfoValue)
|
||||
:
|
||||
PackageInfoAttributeHandlerBase(packageInfoValue)
|
||||
@@ -334,21 +334,21 @@ ReaderImplBase::GlobalSettingsFileInfoAttributeHandler
|
||||
|
||||
|
||||
status_t
|
||||
ReaderImplBase::GlobalSettingsFileInfoAttributeHandler::HandleAttribute(
|
||||
ReaderImplBase::GlobalWritableFileInfoAttributeHandler::HandleAttribute(
|
||||
AttributeHandlerContext* context, uint8 id, const AttributeValue& value,
|
||||
AttributeHandler** _handler)
|
||||
{
|
||||
switch (id) {
|
||||
case B_HPKG_ATTRIBUTE_ID_PACKAGE_SETTINGS_FILE_UPDATE_TYPE:
|
||||
if (value.unsignedInt >= B_PACKAGE_RESOLVABLE_OP_ENUM_COUNT) {
|
||||
case B_HPKG_ATTRIBUTE_ID_PACKAGE_WRITABLE_FILE_UPDATE_TYPE:
|
||||
if (value.unsignedInt >= B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT) {
|
||||
context->errorOutput->PrintError(
|
||||
"Error: Invalid package attribute section: invalid "
|
||||
"global settings file update type %" B_PRIu64
|
||||
" encountered\n", value.unsignedInt);
|
||||
return B_BAD_DATA;
|
||||
}
|
||||
fPackageInfoValue.globalSettingsFileInfo.updateType
|
||||
= (BSettingsFileUpdateType)value.unsignedInt;
|
||||
fPackageInfoValue.globalWritableFileInfo.updateType
|
||||
= (BWritableFileUpdateType)value.unsignedInt;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -604,15 +604,15 @@ ReaderImplBase::PackageAttributeHandler::HandleAttribute(
|
||||
fPackageInfoValue.SetTo(B_PACKAGE_INFO_INSTALL_PATH, value.string);
|
||||
break;
|
||||
|
||||
case B_HPKG_ATTRIBUTE_ID_PACKAGE_GLOBAL_SETTINGS_FILE:
|
||||
fPackageInfoValue.globalSettingsFileInfo.path = value.string;
|
||||
fPackageInfoValue.globalSettingsFileInfo.updateType
|
||||
= B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT;
|
||||
case B_HPKG_ATTRIBUTE_ID_PACKAGE_GLOBAL_WRITABLE_FILE:
|
||||
fPackageInfoValue.globalWritableFileInfo.path = value.string;
|
||||
fPackageInfoValue.globalWritableFileInfo.updateType
|
||||
= B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT;
|
||||
fPackageInfoValue.attributeID
|
||||
= B_PACKAGE_INFO_GLOBAL_SETTINGS_FILES;
|
||||
= B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES;
|
||||
if (_handler != NULL) {
|
||||
*_handler
|
||||
= new(std::nothrow) GlobalSettingsFileInfoAttributeHandler(
|
||||
= new(std::nothrow) GlobalWritableFileInfoAttributeHandler(
|
||||
fPackageInfoValue);
|
||||
if (*_handler == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@@ -379,18 +379,27 @@ WriterImplBase::RegisterPackageInfo(PackageAttributeList& attributeList,
|
||||
_AddStringAttributeList(B_HPKG_ATTRIBUTE_ID_PACKAGE_REPLACES,
|
||||
packageInfo.ReplacesList(), attributeList);
|
||||
|
||||
// global settings file info list
|
||||
const BObjectList<BGlobalSettingsFileInfo>& globalSettingsFileInfos
|
||||
= packageInfo.GlobalSettingsFileInfos();
|
||||
for (int32 i = 0; i < globalSettingsFileInfos.CountItems(); ++i) {
|
||||
BGlobalSettingsFileInfo* info = globalSettingsFileInfos.ItemAt(i);
|
||||
// global writable file info list
|
||||
const BObjectList<BGlobalWritableFileInfo>& globalWritableFileInfos
|
||||
= packageInfo.GlobalWritableFileInfos();
|
||||
for (int32 i = 0; i < globalWritableFileInfos.CountItems(); ++i) {
|
||||
BGlobalWritableFileInfo* info = globalWritableFileInfos.ItemAt(i);
|
||||
PackageAttribute* attribute = _AddStringAttribute(
|
||||
B_HPKG_ATTRIBUTE_ID_PACKAGE_GLOBAL_SETTINGS_FILE, info->Path(),
|
||||
B_HPKG_ATTRIBUTE_ID_PACKAGE_GLOBAL_WRITABLE_FILE, info->Path(),
|
||||
attributeList);
|
||||
|
||||
if (info->IsDirectory()) {
|
||||
PackageAttribute* isDirectoryAttribute = new PackageAttribute(
|
||||
B_HPKG_ATTRIBUTE_ID_PACKAGE_IS_WRITABLE_DIRECTORY,
|
||||
B_HPKG_ATTRIBUTE_TYPE_UINT,
|
||||
B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT);
|
||||
isDirectoryAttribute->unsignedInt = 1;
|
||||
attribute->children.Add(isDirectoryAttribute);
|
||||
}
|
||||
|
||||
if (info->IsIncluded()) {
|
||||
PackageAttribute* updateTypeAttribute = new PackageAttribute(
|
||||
B_HPKG_ATTRIBUTE_ID_PACKAGE_SETTINGS_FILE_UPDATE_TYPE,
|
||||
B_HPKG_ATTRIBUTE_ID_PACKAGE_WRITABLE_FILE_UPDATE_TYPE,
|
||||
B_HPKG_ATTRIBUTE_TYPE_UINT,
|
||||
B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT);
|
||||
updateTypeAttribute->unsignedInt = info->UpdateType();
|
||||
@@ -407,9 +416,18 @@ WriterImplBase::RegisterPackageInfo(PackageAttributeList& attributeList,
|
||||
B_HPKG_ATTRIBUTE_ID_PACKAGE_USER_SETTINGS_FILE, info->Path(),
|
||||
attributeList);
|
||||
|
||||
_AddStringAttributeIfNotEmpty(
|
||||
B_HPKG_ATTRIBUTE_ID_PACKAGE_SETTINGS_FILE_TEMPLATE,
|
||||
info->TemplatePath(), attribute->children);
|
||||
if (info->IsDirectory()) {
|
||||
PackageAttribute* isDirectoryAttribute = new PackageAttribute(
|
||||
B_HPKG_ATTRIBUTE_ID_PACKAGE_IS_WRITABLE_DIRECTORY,
|
||||
B_HPKG_ATTRIBUTE_TYPE_UINT,
|
||||
B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT);
|
||||
isDirectoryAttribute->unsignedInt = 1;
|
||||
attribute->children.Add(isDirectoryAttribute);
|
||||
} else {
|
||||
_AddStringAttributeIfNotEmpty(
|
||||
B_HPKG_ATTRIBUTE_ID_PACKAGE_SETTINGS_FILE_TEMPLATE,
|
||||
info->TemplatePath(), attribute->children);
|
||||
}
|
||||
}
|
||||
|
||||
// user list
|
||||
|
||||
Reference in New Issue
Block a user