Remove resolvable provides type

* Remove BPackageResolvableType and respective property from
  BPackageResolvable.
* Remove package attribute B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES_TYPE.
This commit is contained in:
Ingo Weinhold 2013-05-13 17:43:31 +02:00
parent 9172ffdb06
commit df29539688
10 changed files with 18 additions and 126 deletions

View File

@ -8,7 +8,6 @@
#include <String.h>
#include <package/PackageResolvableType.h>
#include <package/PackageVersion.h>
@ -49,8 +48,6 @@ public:
BPackageResolvable(
const BPackageResolvableData& data);
BPackageResolvable(const BString& name,
BPackageResolvableType type
= B_PACKAGE_RESOLVABLE_TYPE_DEFAULT,
const BPackageVersion& version
= BPackageVersion(),
const BPackageVersion& compatibleVersion
@ -59,27 +56,20 @@ public:
status_t InitCheck() const;
const BString& Name() const;
BPackageResolvableType Type() const;
const BPackageVersion& Version() const;
const BPackageVersion& CompatibleVersion() const;
BString ToString() const;
void SetTo(const BString& name,
BPackageResolvableType type
= B_PACKAGE_RESOLVABLE_TYPE_DEFAULT,
const BPackageVersion& version
= BPackageVersion(),
const BPackageVersion& compatibleVersion
= BPackageVersion());
void Clear();
public:
static const char* kTypeNames[];
private:
BString fName;
BPackageResolvableType fType;
BPackageVersion fVersion;
BPackageVersion fCompatibleVersion;
};

View File

@ -1,26 +0,0 @@
/*
* Copyright 2011, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _PACKAGE__PACKAGE_RESOLVABLE_TYPE_H_
#define _PACKAGE__PACKAGE_RESOLVABLE_TYPE_H_
namespace BPackageKit {
enum BPackageResolvableType {
B_PACKAGE_RESOLVABLE_TYPE_DEFAULT = 0,
B_PACKAGE_RESOLVABLE_TYPE_LIBRARY = 1,
B_PACKAGE_RESOLVABLE_TYPE_COMMAND = 2,
B_PACKAGE_RESOLVABLE_TYPE_APPLICATION = 3,
B_PACKAGE_RESOLVABLE_TYPE_ADD_ON = 4,
//
B_PACKAGE_RESOLVABLE_TYPE_ENUM_COUNT,
};
} // namespace BPackageKit
#endif // _PACKAGE__PACKAGE_RESOLVABLE_TYPE_H_

View File

@ -116,19 +116,18 @@ enum BHPKGAttributeID {
B_HPKG_ATTRIBUTE_ID_PACKAGE_COPYRIGHT = 29,
B_HPKG_ATTRIBUTE_ID_PACKAGE_LICENSE = 30,
B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES = 31,
B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES_TYPE = 32,
B_HPKG_ATTRIBUTE_ID_PACKAGE_REQUIRES = 33,
B_HPKG_ATTRIBUTE_ID_PACKAGE_SUPPLEMENTS = 34,
B_HPKG_ATTRIBUTE_ID_PACKAGE_CONFLICTS = 35,
B_HPKG_ATTRIBUTE_ID_PACKAGE_FRESHENS = 36,
B_HPKG_ATTRIBUTE_ID_PACKAGE_REPLACES = 37,
B_HPKG_ATTRIBUTE_ID_PACKAGE_RESOLVABLE_OPERATOR = 38,
B_HPKG_ATTRIBUTE_ID_PACKAGE_CHECKSUM = 39,
B_HPKG_ATTRIBUTE_ID_PACKAGE_VERSION_PRE_RELEASE = 40,
B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES_COMPATIBLE = 41,
B_HPKG_ATTRIBUTE_ID_PACKAGE_URL = 42,
B_HPKG_ATTRIBUTE_ID_PACKAGE_SOURCE_URL = 43,
B_HPKG_ATTRIBUTE_ID_PACKAGE_INSTALL_PATH = 44,
B_HPKG_ATTRIBUTE_ID_PACKAGE_REQUIRES = 32,
B_HPKG_ATTRIBUTE_ID_PACKAGE_SUPPLEMENTS = 33,
B_HPKG_ATTRIBUTE_ID_PACKAGE_CONFLICTS = 34,
B_HPKG_ATTRIBUTE_ID_PACKAGE_FRESHENS = 35,
B_HPKG_ATTRIBUTE_ID_PACKAGE_REPLACES = 36,
B_HPKG_ATTRIBUTE_ID_PACKAGE_RESOLVABLE_OPERATOR = 37,
B_HPKG_ATTRIBUTE_ID_PACKAGE_CHECKSUM = 38,
B_HPKG_ATTRIBUTE_ID_PACKAGE_VERSION_PRE_RELEASE = 39,
B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES_COMPATIBLE = 40,
B_HPKG_ATTRIBUTE_ID_PACKAGE_URL = 41,
B_HPKG_ATTRIBUTE_ID_PACKAGE_SOURCE_URL = 42,
B_HPKG_ATTRIBUTE_ID_PACKAGE_INSTALL_PATH = 43,
//
B_HPKG_ATTRIBUTE_ID_ENUM_COUNT,
};

View File

@ -13,7 +13,6 @@
#include <package/PackageArchitecture.h>
#include <package/PackageInfoAttributes.h>
#include <package/PackageResolvableOperator.h>
#include <package/PackageResolvableType.h>
namespace BPackageKit {
@ -31,7 +30,6 @@ struct BPackageVersionData {
struct BPackageResolvableData {
BPackageResolvableType type;
const char* name;
bool haveVersion;
bool haveCompatibleVersion;

View File

@ -639,30 +639,6 @@ BPackageInfo::Parser::_ParseResolvableList(
token.pos);
}
BPackageResolvableType type = B_PACKAGE_RESOLVABLE_TYPE_DEFAULT;
int32 colonPos = token.text.FindFirst(':');
if (colonPos >= 0) {
BString typeName(token.text, colonPos);
for (int i = 0; i < B_PACKAGE_RESOLVABLE_TYPE_ENUM_COUNT; ++i) {
if (typeName.ICompare(BPackageResolvable::kTypeNames[i])
== 0) {
type = (BPackageResolvableType)i;
break;
}
}
if (type == B_PACKAGE_RESOLVABLE_TYPE_DEFAULT) {
BString error("resolvable type (<type>:) must be one of [");
for (int i = 1; i < B_PACKAGE_RESOLVABLE_TYPE_ENUM_COUNT;
++i) {
if (i > 1)
error << ",";
error << BPackageResolvable::kTypeNames[i];
}
error << "]";
throw ParseError(error, token.pos);
}
}
int32 errorPos;
if (!_IsValidResolvableName(token.text, &errorPos)) {
throw ParseError("invalid character in resolvable name",
@ -694,7 +670,7 @@ BPackageInfo::Parser::_ParseResolvableList(
} else
parser._RewindTo(compatible);
value->AddItem(new BPackageResolvable(token.text, type, version,
value->AddItem(new BPackageResolvable(token.text, version,
compatibleVersion));
}
} resolvableParser(*this, value);
@ -2097,8 +2073,6 @@ BPackageInfo::_AddResolvables(BMessage* archive, const char* field,
const BPackageResolvable* resolvable = resolvables.ItemAt(i);
status_t error;
if ((error = archive->AddString(nameField, resolvable->Name())) != B_OK
|| (error = archive->AddInt32(typeField, resolvable->Type()))
!= B_OK
|| (error = _AddVersion(archive, versionField,
resolvable->Version())) != B_OK
|| (error = _AddVersion(archive, compatibleVersionField,
@ -2239,13 +2213,6 @@ BPackageInfo::_ExtractResolvables(BMessage* archive, const char* field,
if (error != B_OK)
return error;
int32 type;
error = archive->FindInt32(typeField, i, &type);
if (error != B_OK)
return error;
if (type < 0 || type > B_PACKAGE_RESOLVABLE_TYPE_ENUM_COUNT)
return B_BAD_DATA;
BPackageVersion version;
error = _ExtractVersion(archive, versionField, i, version);
if (error != B_OK)
@ -2258,7 +2225,7 @@ BPackageInfo::_ExtractResolvables(BMessage* archive, const char* field,
return error;
BPackageResolvable* resolvable = new(std::nothrow) BPackageResolvable(
name, (BPackageResolvableType)type, version, compatibleVersion);
name, version, compatibleVersion);
if (resolvable == NULL || !_resolvables.AddItem(resolvable)) {
delete resolvable;
return B_NO_MEMORY;

View File

@ -12,19 +12,7 @@
namespace BPackageKit {
const char*
BPackageResolvable::kTypeNames[B_PACKAGE_RESOLVABLE_TYPE_ENUM_COUNT] = {
"",
"lib",
"cmd",
"app",
"add_on",
};
BPackageResolvable::BPackageResolvable()
:
fType(B_PACKAGE_RESOLVABLE_TYPE_DEFAULT)
{
}
@ -32,7 +20,6 @@ BPackageResolvable::BPackageResolvable()
BPackageResolvable::BPackageResolvable(const BPackageResolvableData& data)
:
fName(data.name),
fType(data.type),
fVersion(data.version),
fCompatibleVersion(data.compatibleVersion)
{
@ -40,11 +27,9 @@ BPackageResolvable::BPackageResolvable(const BPackageResolvableData& data)
BPackageResolvable::BPackageResolvable(const BString& name,
BPackageResolvableType type, const BPackageVersion& version,
const BPackageVersion& compatibleVersion)
const BPackageVersion& version, const BPackageVersion& compatibleVersion)
:
fName(name),
fType(type),
fVersion(version),
fCompatibleVersion(compatibleVersion)
{
@ -66,13 +51,6 @@ BPackageResolvable::Name() const
}
BPackageResolvableType
BPackageResolvable::Type() const
{
return fType;
}
const BPackageVersion&
BPackageResolvable::Version() const
{
@ -104,11 +82,10 @@ BPackageResolvable::ToString() const
void
BPackageResolvable::SetTo(const BString& name, BPackageResolvableType type,
const BPackageVersion& version, const BPackageVersion& compatibleVersion)
BPackageResolvable::SetTo(const BString& name, const BPackageVersion& version,
const BPackageVersion& compatibleVersion)
{
fName = name;
fType = type;
fVersion = version;
fCompatibleVersion = compatibleVersion;

View File

@ -48,7 +48,6 @@ static const char* kAttributeNames[B_HPKG_ATTRIBUTE_ID_ENUM_COUNT + 1] = {
"package:copyright",
"package:license",
"package:provides",
"package:provides.type",
"package:requires",
"package:supplements",
"package:conflicts",

View File

@ -185,11 +185,6 @@ ReaderImplBase::PackageResolvableAttributeHandler::HandleAttribute(
AttributeHandler** _handler)
{
switch (id) {
case B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES_TYPE:
fPackageInfoValue.resolvable.type
= (BPackageResolvableType)value.unsignedInt;
break;
case B_HPKG_ATTRIBUTE_ID_PACKAGE_VERSION_MAJOR:
fPackageInfoValue.resolvable.haveVersion = true;
fPackageInfoValue.resolvable.version.major = value.string;

View File

@ -472,12 +472,6 @@ WriterImplBase::RegisterPackageInfo(PackageAttributeList& attributeList,
provides->string = fPackageStringCache.Get(resolvable->Name().String());
attributeList.Add(provides);
PackageAttribute* providesType = new PackageAttribute(
B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES_TYPE,
B_HPKG_ATTRIBUTE_TYPE_UINT, B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT);
providesType->unsignedInt = resolvable->Type();
provides->children.Add(providesType);
if (hasVersion)
RegisterPackageVersion(provides->children, resolvable->Version());

View File

@ -191,8 +191,7 @@ ReaderImplBase::PackageResolvableAttributeHandler::HandleAttribute(
{
switch (id) {
case B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES_TYPE:
fPackageInfoValue.resolvable.type
= (BPackageResolvableType)value.unsignedInt;
// obsolete
break;
case B_HPKG_ATTRIBUTE_ID_PACKAGE_VERSION_MAJOR: