BPicture: Fix archive constructor.
[haiku.git] / src / kits / package / PackageInfoContentHandler.cpp
blob62ae30d6d67e2e5b942c75b671abe3c3148aa1dc
1 /*
2 * Copyright 2011-2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
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()
34 status_t
35 BPackageInfoContentHandler::HandleEntry(BPackageEntry* entry)
37 return B_OK;
41 status_t
42 BPackageInfoContentHandler::HandleEntryAttribute(BPackageEntry* entry,
43 BPackageEntryAttribute* attribute)
45 return B_OK;
49 status_t
50 BPackageInfoContentHandler::HandleEntryDone(BPackageEntry* entry)
52 return B_OK;
56 status_t
57 BPackageInfoContentHandler::HandlePackageAttribute(
58 const BPackageInfoAttributeValue& value)
60 switch (value.attributeID) {
61 case B_PACKAGE_INFO_NAME:
62 fPackageInfo.SetName(value.string);
63 break;
65 case B_PACKAGE_INFO_SUMMARY:
66 fPackageInfo.SetSummary(value.string);
67 break;
69 case B_PACKAGE_INFO_DESCRIPTION:
70 fPackageInfo.SetDescription(value.string);
71 break;
73 case B_PACKAGE_INFO_VENDOR:
74 fPackageInfo.SetVendor(value.string);
75 break;
77 case B_PACKAGE_INFO_PACKAGER:
78 fPackageInfo.SetPackager(value.string);
79 break;
81 case B_PACKAGE_INFO_FLAGS:
82 fPackageInfo.SetFlags(value.unsignedInt);
83 break;
85 case B_PACKAGE_INFO_ARCHITECTURE:
86 fPackageInfo.SetArchitecture(
87 (BPackageArchitecture)value.unsignedInt);
88 break;
90 case B_PACKAGE_INFO_VERSION:
91 fPackageInfo.SetVersion(value.version);
92 break;
94 case B_PACKAGE_INFO_COPYRIGHTS:
95 fPackageInfo.AddCopyright(value.string);
96 break;
98 case B_PACKAGE_INFO_LICENSES:
99 fPackageInfo.AddLicense(value.string);
100 break;
102 case B_PACKAGE_INFO_PROVIDES:
103 fPackageInfo.AddProvides(value.resolvable);
104 break;
106 case B_PACKAGE_INFO_REQUIRES:
107 fPackageInfo.AddRequires(value.resolvableExpression);
108 break;
110 case B_PACKAGE_INFO_SUPPLEMENTS:
111 fPackageInfo.AddSupplements(value.resolvableExpression);
112 break;
114 case B_PACKAGE_INFO_CONFLICTS:
115 fPackageInfo.AddConflicts(value.resolvableExpression);
116 break;
118 case B_PACKAGE_INFO_FRESHENS:
119 fPackageInfo.AddFreshens(value.resolvableExpression);
120 break;
122 case B_PACKAGE_INFO_REPLACES:
123 fPackageInfo.AddReplaces(value.string);
124 break;
126 case B_PACKAGE_INFO_URLS:
127 fPackageInfo.AddURL(value.string);
128 break;
130 case B_PACKAGE_INFO_SOURCE_URLS:
131 fPackageInfo.AddSourceURL(value.string);
132 break;
134 case B_PACKAGE_INFO_CHECKSUM:
135 fPackageInfo.SetChecksum(value.string);
136 break;
138 case B_PACKAGE_INFO_INSTALL_PATH:
139 fPackageInfo.SetInstallPath(value.string);
140 break;
142 case B_PACKAGE_INFO_BASE_PACKAGE:
143 fPackageInfo.SetBasePackage(value.string);
144 break;
146 case B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES:
147 fPackageInfo.AddGlobalWritableFileInfo(
148 value.globalWritableFileInfo);
149 break;
151 case B_PACKAGE_INFO_USER_SETTINGS_FILES:
152 fPackageInfo.AddUserSettingsFileInfo(value.userSettingsFileInfo);
153 break;
155 case B_PACKAGE_INFO_USERS:
156 fPackageInfo.AddUser(value.user);
157 break;
159 case B_PACKAGE_INFO_GROUPS:
160 fPackageInfo.AddGroup(value.string);
161 break;
163 case B_PACKAGE_INFO_POST_INSTALL_SCRIPTS:
164 fPackageInfo.AddPostInstallScript(value.string);
165 break;
167 default:
168 if (fErrorOutput != NULL) {
169 fErrorOutput->PrintError(
170 "Invalid package attribute section: unexpected package "
171 "attribute id %d encountered\n", value.attributeID);
173 return B_BAD_DATA;
176 return B_OK;
180 void
181 BPackageInfoContentHandler::HandleErrorOccurred()
186 } // namespace BPackageKit