1 /* 2 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <package/PackageInfoContentHandler.h> 8 9 #include <package/PackageInfo.h> 10 #include <package/hpkg/ErrorOutput.h> 11 #include <package/hpkg/PackageInfoAttributeValue.h> 12 13 14 namespace BPackageKit { 15 16 17 using namespace BHPKG; 18 19 20 BPackageInfoContentHandler::BPackageInfoContentHandler( 21 BPackageInfo& packageInfo, BErrorOutput* errorOutput) 22 : 23 fPackageInfo(packageInfo), 24 fErrorOutput(errorOutput) 25 { 26 } 27 28 29 BPackageInfoContentHandler::~BPackageInfoContentHandler() 30 { 31 } 32 33 34 status_t 35 BPackageInfoContentHandler::HandleEntry(BPackageEntry* entry) 36 { 37 return B_OK; 38 } 39 40 41 status_t 42 BPackageInfoContentHandler::HandleEntryAttribute(BPackageEntry* entry, 43 BPackageEntryAttribute* attribute) 44 { 45 return B_OK; 46 } 47 48 49 status_t 50 BPackageInfoContentHandler::HandleEntryDone(BPackageEntry* entry) 51 { 52 return B_OK; 53 } 54 55 56 status_t 57 BPackageInfoContentHandler::HandlePackageAttribute( 58 const BPackageInfoAttributeValue& value) 59 { 60 switch (value.attributeID) { 61 case B_PACKAGE_INFO_NAME: 62 fPackageInfo.SetName(value.string); 63 break; 64 65 case B_PACKAGE_INFO_SUMMARY: 66 fPackageInfo.SetSummary(value.string); 67 break; 68 69 case B_PACKAGE_INFO_DESCRIPTION: 70 fPackageInfo.SetDescription(value.string); 71 break; 72 73 case B_PACKAGE_INFO_VENDOR: 74 fPackageInfo.SetVendor(value.string); 75 break; 76 77 case B_PACKAGE_INFO_PACKAGER: 78 fPackageInfo.SetPackager(value.string); 79 break; 80 81 case B_PACKAGE_INFO_FLAGS: 82 fPackageInfo.SetFlags(value.unsignedInt); 83 break; 84 85 case B_PACKAGE_INFO_ARCHITECTURE: 86 fPackageInfo.SetArchitecture( 87 (BPackageArchitecture)value.unsignedInt); 88 break; 89 90 case B_PACKAGE_INFO_VERSION: 91 fPackageInfo.SetVersion(value.version); 92 break; 93 94 case B_PACKAGE_INFO_COPYRIGHTS: 95 fPackageInfo.AddCopyright(value.string); 96 break; 97 98 case B_PACKAGE_INFO_LICENSES: 99 fPackageInfo.AddLicense(value.string); 100 break; 101 102 case B_PACKAGE_INFO_PROVIDES: 103 fPackageInfo.AddProvides(value.resolvable); 104 break; 105 106 case B_PACKAGE_INFO_REQUIRES: 107 fPackageInfo.AddRequires(value.resolvableExpression); 108 break; 109 110 case B_PACKAGE_INFO_SUPPLEMENTS: 111 fPackageInfo.AddSupplements(value.resolvableExpression); 112 break; 113 114 case B_PACKAGE_INFO_CONFLICTS: 115 fPackageInfo.AddConflicts(value.resolvableExpression); 116 break; 117 118 case B_PACKAGE_INFO_FRESHENS: 119 fPackageInfo.AddFreshens(value.resolvableExpression); 120 break; 121 122 case B_PACKAGE_INFO_REPLACES: 123 fPackageInfo.AddReplaces(value.string); 124 break; 125 126 case B_PACKAGE_INFO_URLS: 127 fPackageInfo.AddURL(value.string); 128 break; 129 130 case B_PACKAGE_INFO_SOURCE_URLS: 131 fPackageInfo.AddSourceURL(value.string); 132 break; 133 134 case B_PACKAGE_INFO_CHECKSUM: 135 fPackageInfo.SetChecksum(value.string); 136 break; 137 138 case B_PACKAGE_INFO_INSTALL_PATH: 139 fPackageInfo.SetInstallPath(value.string); 140 break; 141 142 default: 143 if (fErrorOutput != NULL) { 144 fErrorOutput->PrintError( 145 "Invalid package attribute section: unexpected package " 146 "attribute id %d encountered\n", value.attributeID); 147 } 148 return B_BAD_DATA; 149 } 150 151 return B_OK; 152 } 153 154 155 void 156 BPackageInfoContentHandler::HandleErrorOccurred() 157 { 158 } 159 160 161 } // namespace BPackageKit 162