17575abbcSIngo Weinhold/*
27575abbcSIngo Weinhold * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
37575abbcSIngo Weinhold * Distributed under the terms of the MIT License.
47575abbcSIngo Weinhold */
57575abbcSIngo Weinhold
67575abbcSIngo Weinhold
77575abbcSIngo Weinhold#include <package/hpkg/v1/PackageInfoContentHandler.h>
87575abbcSIngo Weinhold
97575abbcSIngo Weinhold#include <package/PackageInfo.h>
107575abbcSIngo Weinhold#include <package/hpkg/ErrorOutput.h>
117575abbcSIngo Weinhold#include <package/hpkg/PackageInfoAttributeValue.h>
127575abbcSIngo Weinhold
137575abbcSIngo Weinhold
147575abbcSIngo Weinholdnamespace BPackageKit {
157575abbcSIngo Weinhold
167575abbcSIngo Weinholdnamespace BHPKG {
177575abbcSIngo Weinhold
187575abbcSIngo Weinholdnamespace V1 {
197575abbcSIngo Weinhold
207575abbcSIngo Weinhold
217575abbcSIngo WeinholdBPackageInfoContentHandler::BPackageInfoContentHandler(
227575abbcSIngo Weinhold	BPackageInfo& packageInfo, BErrorOutput* errorOutput)
237575abbcSIngo Weinhold	:
247575abbcSIngo Weinhold	fPackageInfo(packageInfo),
257575abbcSIngo Weinhold	fErrorOutput(errorOutput)
267575abbcSIngo Weinhold{
277575abbcSIngo Weinhold}
287575abbcSIngo Weinhold
297575abbcSIngo Weinhold
307575abbcSIngo WeinholdBPackageInfoContentHandler::~BPackageInfoContentHandler()
317575abbcSIngo Weinhold{
327575abbcSIngo Weinhold}
337575abbcSIngo Weinhold
347575abbcSIngo Weinhold
357575abbcSIngo Weinholdstatus_t
367575abbcSIngo WeinholdBPackageInfoContentHandler::HandleEntry(BPackageEntry* entry)
377575abbcSIngo Weinhold{
387575abbcSIngo Weinhold	return B_OK;
397575abbcSIngo Weinhold}
407575abbcSIngo Weinhold
417575abbcSIngo Weinhold
427575abbcSIngo Weinholdstatus_t
437575abbcSIngo WeinholdBPackageInfoContentHandler::HandleEntryAttribute(BPackageEntry* entry,
447575abbcSIngo Weinhold	BPackageEntryAttribute* attribute)
457575abbcSIngo Weinhold{
467575abbcSIngo Weinhold	return B_OK;
477575abbcSIngo Weinhold}
487575abbcSIngo Weinhold
497575abbcSIngo Weinhold
507575abbcSIngo Weinholdstatus_t
517575abbcSIngo WeinholdBPackageInfoContentHandler::HandleEntryDone(BPackageEntry* entry)
527575abbcSIngo Weinhold{
537575abbcSIngo Weinhold	return B_OK;
547575abbcSIngo Weinhold}
557575abbcSIngo Weinhold
567575abbcSIngo Weinhold
577575abbcSIngo Weinholdstatus_t
587575abbcSIngo WeinholdBPackageInfoContentHandler::HandlePackageAttribute(
597575abbcSIngo Weinhold	const BPackageInfoAttributeValue& value)
607575abbcSIngo Weinhold{
617575abbcSIngo Weinhold	switch (value.attributeID) {
627575abbcSIngo Weinhold		case B_PACKAGE_INFO_NAME:
637575abbcSIngo Weinhold			fPackageInfo.SetName(value.string);
647575abbcSIngo Weinhold			break;
657575abbcSIngo Weinhold
667575abbcSIngo Weinhold		case B_PACKAGE_INFO_SUMMARY:
677575abbcSIngo Weinhold			fPackageInfo.SetSummary(value.string);
687575abbcSIngo Weinhold			break;
697575abbcSIngo Weinhold
707575abbcSIngo Weinhold		case B_PACKAGE_INFO_DESCRIPTION:
717575abbcSIngo Weinhold			fPackageInfo.SetDescription(value.string);
727575abbcSIngo Weinhold			break;
737575abbcSIngo Weinhold
747575abbcSIngo Weinhold		case B_PACKAGE_INFO_VENDOR:
757575abbcSIngo Weinhold			fPackageInfo.SetVendor(value.string);
767575abbcSIngo Weinhold			break;
777575abbcSIngo Weinhold
787575abbcSIngo Weinhold		case B_PACKAGE_INFO_PACKAGER:
797575abbcSIngo Weinhold			fPackageInfo.SetPackager(value.string);
807575abbcSIngo Weinhold			break;
817575abbcSIngo Weinhold
827575abbcSIngo Weinhold		case B_PACKAGE_INFO_FLAGS:
837575abbcSIngo Weinhold			fPackageInfo.SetFlags(value.unsignedInt);
847575abbcSIngo Weinhold			break;
857575abbcSIngo Weinhold
867575abbcSIngo Weinhold		case B_PACKAGE_INFO_ARCHITECTURE:
877575abbcSIngo Weinhold			fPackageInfo.SetArchitecture(
887575abbcSIngo Weinhold				(BPackageArchitecture)value.unsignedInt);
897575abbcSIngo Weinhold			break;
907575abbcSIngo Weinhold
917575abbcSIngo Weinhold		case B_PACKAGE_INFO_VERSION:
927575abbcSIngo Weinhold			fPackageInfo.SetVersion(value.version);
937575abbcSIngo Weinhold			break;
947575abbcSIngo Weinhold
957575abbcSIngo Weinhold		case B_PACKAGE_INFO_COPYRIGHTS:
967575abbcSIngo Weinhold			fPackageInfo.AddCopyright(value.string);
977575abbcSIngo Weinhold			break;
987575abbcSIngo Weinhold
997575abbcSIngo Weinhold		case B_PACKAGE_INFO_LICENSES:
1007575abbcSIngo Weinhold			fPackageInfo.AddLicense(value.string);
1017575abbcSIngo Weinhold			break;
1027575abbcSIngo Weinhold
1037575abbcSIngo Weinhold		case B_PACKAGE_INFO_PROVIDES:
1047575abbcSIngo Weinhold			fPackageInfo.AddProvides(value.resolvable);
1057575abbcSIngo Weinhold			break;
1067575abbcSIngo Weinhold
1077575abbcSIngo Weinhold		case B_PACKAGE_INFO_REQUIRES:
1087575abbcSIngo Weinhold			fPackageInfo.AddRequires(value.resolvableExpression);
1097575abbcSIngo Weinhold			break;
1107575abbcSIngo Weinhold
1117575abbcSIngo Weinhold		case B_PACKAGE_INFO_SUPPLEMENTS:
1127575abbcSIngo Weinhold			fPackageInfo.AddSupplements(value.resolvableExpression);
1137575abbcSIngo Weinhold			break;
1147575abbcSIngo Weinhold
1157575abbcSIngo Weinhold		case B_PACKAGE_INFO_CONFLICTS:
1167575abbcSIngo Weinhold			fPackageInfo.AddConflicts(value.resolvableExpression);
1177575abbcSIngo Weinhold			break;
1187575abbcSIngo Weinhold
1197575abbcSIngo Weinhold		case B_PACKAGE_INFO_FRESHENS:
1207575abbcSIngo Weinhold			fPackageInfo.AddFreshens(value.resolvableExpression);
1217575abbcSIngo Weinhold			break;
1227575abbcSIngo Weinhold
1237575abbcSIngo Weinhold		case B_PACKAGE_INFO_REPLACES:
1247575abbcSIngo Weinhold			fPackageInfo.AddReplaces(value.string);
1257575abbcSIngo Weinhold			break;
1267575abbcSIngo Weinhold
1277575abbcSIngo Weinhold		case B_PACKAGE_INFO_URLS:
1287575abbcSIngo Weinhold			fPackageInfo.AddURL(value.string);
1297575abbcSIngo Weinhold			break;
1307575abbcSIngo Weinhold
1317575abbcSIngo Weinhold		case B_PACKAGE_INFO_SOURCE_URLS:
1327575abbcSIngo Weinhold			fPackageInfo.AddSourceURL(value.string);
1337575abbcSIngo Weinhold			break;
1347575abbcSIngo Weinhold
1357575abbcSIngo Weinhold		case B_PACKAGE_INFO_CHECKSUM:
1367575abbcSIngo Weinhold			fPackageInfo.SetChecksum(value.string);
1377575abbcSIngo Weinhold			break;
1387575abbcSIngo Weinhold
1397575abbcSIngo Weinhold		case B_PACKAGE_INFO_INSTALL_PATH:
1407575abbcSIngo Weinhold			fPackageInfo.SetInstallPath(value.string);
1417575abbcSIngo Weinhold			break;
1427575abbcSIngo Weinhold
1437575abbcSIngo Weinhold		default:
1447575abbcSIngo Weinhold			if (fErrorOutput != NULL) {
1457575abbcSIngo Weinhold				fErrorOutput->PrintError(
1467575abbcSIngo Weinhold					"Invalid package attribute section: unexpected package "
1477575abbcSIngo Weinhold					"attribute id %d encountered\n", value.attributeID);
1487575abbcSIngo Weinhold			}
1497575abbcSIngo Weinhold			return B_BAD_DATA;
1507575abbcSIngo Weinhold	}
1517575abbcSIngo Weinhold
1527575abbcSIngo Weinhold	return B_OK;
1537575abbcSIngo Weinhold}
1547575abbcSIngo Weinhold
1557575abbcSIngo Weinhold
1567575abbcSIngo Weinholdvoid
1577575abbcSIngo WeinholdBPackageInfoContentHandler::HandleErrorOccurred()
1587575abbcSIngo Weinhold{
1597575abbcSIngo Weinhold}
1607575abbcSIngo Weinhold
1617575abbcSIngo Weinhold
1627575abbcSIngo Weinhold}	// namespace V1
1637575abbcSIngo Weinhold
1647575abbcSIngo Weinhold}	// namespace BHPKG
1657575abbcSIngo Weinhold
1667575abbcSIngo Weinhold}	// namespace BPackageKit
167