2 * Copyright 2011-2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
7 #include <package/PackageInfoContentHandler.h>
9 #include <package/PackageInfo.h>
10 #include <package/hpkg/ErrorOutput.h>
11 #include <package/hpkg/PackageInfoAttributeValue.h>
14 namespace BPackageKit
{
17 using namespace BHPKG
;
20 BPackageInfoContentHandler::BPackageInfoContentHandler(
21 BPackageInfo
& packageInfo
, BErrorOutput
* errorOutput
)
23 fPackageInfo(packageInfo
),
24 fErrorOutput(errorOutput
)
29 BPackageInfoContentHandler::~BPackageInfoContentHandler()
35 BPackageInfoContentHandler::HandleEntry(BPackageEntry
* entry
)
42 BPackageInfoContentHandler::HandleEntryAttribute(BPackageEntry
* entry
,
43 BPackageEntryAttribute
* attribute
)
50 BPackageInfoContentHandler::HandleEntryDone(BPackageEntry
* entry
)
57 BPackageInfoContentHandler::HandlePackageAttribute(
58 const BPackageInfoAttributeValue
& value
)
60 switch (value
.attributeID
) {
61 case B_PACKAGE_INFO_NAME
:
62 fPackageInfo
.SetName(value
.string
);
65 case B_PACKAGE_INFO_SUMMARY
:
66 fPackageInfo
.SetSummary(value
.string
);
69 case B_PACKAGE_INFO_DESCRIPTION
:
70 fPackageInfo
.SetDescription(value
.string
);
73 case B_PACKAGE_INFO_VENDOR
:
74 fPackageInfo
.SetVendor(value
.string
);
77 case B_PACKAGE_INFO_PACKAGER
:
78 fPackageInfo
.SetPackager(value
.string
);
81 case B_PACKAGE_INFO_FLAGS
:
82 fPackageInfo
.SetFlags(value
.unsignedInt
);
85 case B_PACKAGE_INFO_ARCHITECTURE
:
86 fPackageInfo
.SetArchitecture(
87 (BPackageArchitecture
)value
.unsignedInt
);
90 case B_PACKAGE_INFO_VERSION
:
91 fPackageInfo
.SetVersion(value
.version
);
94 case B_PACKAGE_INFO_COPYRIGHTS
:
95 fPackageInfo
.AddCopyright(value
.string
);
98 case B_PACKAGE_INFO_LICENSES
:
99 fPackageInfo
.AddLicense(value
.string
);
102 case B_PACKAGE_INFO_PROVIDES
:
103 fPackageInfo
.AddProvides(value
.resolvable
);
106 case B_PACKAGE_INFO_REQUIRES
:
107 fPackageInfo
.AddRequires(value
.resolvableExpression
);
110 case B_PACKAGE_INFO_SUPPLEMENTS
:
111 fPackageInfo
.AddSupplements(value
.resolvableExpression
);
114 case B_PACKAGE_INFO_CONFLICTS
:
115 fPackageInfo
.AddConflicts(value
.resolvableExpression
);
118 case B_PACKAGE_INFO_FRESHENS
:
119 fPackageInfo
.AddFreshens(value
.resolvableExpression
);
122 case B_PACKAGE_INFO_REPLACES
:
123 fPackageInfo
.AddReplaces(value
.string
);
126 case B_PACKAGE_INFO_URLS
:
127 fPackageInfo
.AddURL(value
.string
);
130 case B_PACKAGE_INFO_SOURCE_URLS
:
131 fPackageInfo
.AddSourceURL(value
.string
);
134 case B_PACKAGE_INFO_CHECKSUM
:
135 fPackageInfo
.SetChecksum(value
.string
);
138 case B_PACKAGE_INFO_INSTALL_PATH
:
139 fPackageInfo
.SetInstallPath(value
.string
);
142 case B_PACKAGE_INFO_BASE_PACKAGE
:
143 fPackageInfo
.SetBasePackage(value
.string
);
146 case B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES
:
147 fPackageInfo
.AddGlobalWritableFileInfo(
148 value
.globalWritableFileInfo
);
151 case B_PACKAGE_INFO_USER_SETTINGS_FILES
:
152 fPackageInfo
.AddUserSettingsFileInfo(value
.userSettingsFileInfo
);
155 case B_PACKAGE_INFO_USERS
:
156 fPackageInfo
.AddUser(value
.user
);
159 case B_PACKAGE_INFO_GROUPS
:
160 fPackageInfo
.AddGroup(value
.string
);
163 case B_PACKAGE_INFO_POST_INSTALL_SCRIPTS
:
164 fPackageInfo
.AddPostInstallScript(value
.string
);
168 if (fErrorOutput
!= NULL
) {
169 fErrorOutput
->PrintError(
170 "Invalid package attribute section: unexpected package "
171 "attribute id %d encountered\n", value
.attributeID
);
181 BPackageInfoContentHandler::HandleErrorOccurred()
186 } // namespace BPackageKit