Add url and sourceURL properties to BPackageInfo
Also extend the parser to accept "url" and "source-url" attributes.
This commit is contained in:
@@ -65,6 +65,8 @@ public:
|
|||||||
|
|
||||||
const BObjectList<BString>& CopyrightList() const;
|
const BObjectList<BString>& CopyrightList() const;
|
||||||
const BObjectList<BString>& LicenseList() const;
|
const BObjectList<BString>& LicenseList() const;
|
||||||
|
const BObjectList<BString>& URLList() const;
|
||||||
|
const BObjectList<BString>& SourceURLList() const;
|
||||||
|
|
||||||
const BObjectList<BPackageResolvable>& ProvidesList() const;
|
const BObjectList<BPackageResolvable>& ProvidesList() const;
|
||||||
const BObjectList<BPackageResolvableExpression>&
|
const BObjectList<BPackageResolvableExpression>&
|
||||||
@@ -97,6 +99,12 @@ public:
|
|||||||
void ClearLicenseList();
|
void ClearLicenseList();
|
||||||
status_t AddLicense(const BString& license);
|
status_t AddLicense(const BString& license);
|
||||||
|
|
||||||
|
void ClearURLList();
|
||||||
|
status_t AddURL(const BString& url);
|
||||||
|
|
||||||
|
void ClearSourceURLList();
|
||||||
|
status_t AddSourceURL(const BString& url);
|
||||||
|
|
||||||
void ClearProvidesList();
|
void ClearProvidesList();
|
||||||
status_t AddProvides(const BPackageResolvable& provides);
|
status_t AddProvides(const BPackageResolvable& provides);
|
||||||
|
|
||||||
@@ -146,6 +154,8 @@ private:
|
|||||||
|
|
||||||
BObjectList<BString> fCopyrightList;
|
BObjectList<BString> fCopyrightList;
|
||||||
BObjectList<BString> fLicenseList;
|
BObjectList<BString> fLicenseList;
|
||||||
|
BObjectList<BString> fURLList;
|
||||||
|
BObjectList<BString> fSourceURLList;
|
||||||
|
|
||||||
BObjectList<BPackageResolvable> fProvidesList;
|
BObjectList<BPackageResolvable> fProvidesList;
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ enum BPackageInfoAttributeID {
|
|||||||
B_PACKAGE_INFO_REPLACES, // list of resolvables that this package
|
B_PACKAGE_INFO_REPLACES, // list of resolvables that this package
|
||||||
// will replace (upon update)
|
// will replace (upon update)
|
||||||
B_PACKAGE_INFO_FLAGS,
|
B_PACKAGE_INFO_FLAGS,
|
||||||
|
B_PACKAGE_INFO_URLS, // list
|
||||||
|
B_PACKAGE_INFO_SOURCE_URLS, // list
|
||||||
B_PACKAGE_INFO_CHECKSUM, // sha256-checksum
|
B_PACKAGE_INFO_CHECKSUM, // sha256-checksum
|
||||||
//
|
//
|
||||||
B_PACKAGE_INFO_ENUM_COUNT,
|
B_PACKAGE_INFO_ENUM_COUNT,
|
||||||
|
|||||||
@@ -773,6 +773,32 @@ BPackageInfo::Parser::_Parse(BPackageInfo* packageInfo)
|
|||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
packageInfo->AddLicense(*(licenseList.ItemAt(i)));
|
packageInfo->AddLicense(*(licenseList.ItemAt(i)));
|
||||||
seen[B_PACKAGE_INFO_LICENSES] = true;
|
seen[B_PACKAGE_INFO_LICENSES] = true;
|
||||||
|
} else if (t.text.ICompare(names[B_PACKAGE_INFO_URLS]) == 0) {
|
||||||
|
if (seen[B_PACKAGE_INFO_URLS]) {
|
||||||
|
BString error = BString(names[B_PACKAGE_INFO_URLS])
|
||||||
|
<< " already seen!";
|
||||||
|
throw ParseError(error, t.pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
BObjectList<BString> urlList;
|
||||||
|
_ParseStringList(&urlList);
|
||||||
|
int count = urlList.CountItems();
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
packageInfo->AddURL(*(urlList.ItemAt(i)));
|
||||||
|
seen[B_PACKAGE_INFO_URLS] = true;
|
||||||
|
} else if (t.text.ICompare(names[B_PACKAGE_INFO_SOURCE_URLS]) == 0) {
|
||||||
|
if (seen[B_PACKAGE_INFO_SOURCE_URLS]) {
|
||||||
|
BString error = BString(names[B_PACKAGE_INFO_SOURCE_URLS])
|
||||||
|
<< " already seen!";
|
||||||
|
throw ParseError(error, t.pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
BObjectList<BString> urlList;
|
||||||
|
_ParseStringList(&urlList);
|
||||||
|
int count = urlList.CountItems();
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
packageInfo->AddSourceURL(*(urlList.ItemAt(i)));
|
||||||
|
seen[B_PACKAGE_INFO_SOURCE_URLS] = true;
|
||||||
} else if (t.text.ICompare(names[B_PACKAGE_INFO_PROVIDES]) == 0) {
|
} else if (t.text.ICompare(names[B_PACKAGE_INFO_PROVIDES]) == 0) {
|
||||||
if (seen[B_PACKAGE_INFO_PROVIDES]) {
|
if (seen[B_PACKAGE_INFO_PROVIDES]) {
|
||||||
BString error = BString(names[B_PACKAGE_INFO_PROVIDES])
|
BString error = BString(names[B_PACKAGE_INFO_PROVIDES])
|
||||||
@@ -890,6 +916,8 @@ const char* BPackageInfo::kElementNames[B_PACKAGE_INFO_ENUM_COUNT] = {
|
|||||||
"freshens",
|
"freshens",
|
||||||
"replaces",
|
"replaces",
|
||||||
"flags",
|
"flags",
|
||||||
|
"urls",
|
||||||
|
"source-urls",
|
||||||
"checksum", // not being parsed, computed externally
|
"checksum", // not being parsed, computed externally
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -908,6 +936,8 @@ BPackageInfo::BPackageInfo()
|
|||||||
fArchitecture(B_PACKAGE_ARCHITECTURE_ENUM_COUNT),
|
fArchitecture(B_PACKAGE_ARCHITECTURE_ENUM_COUNT),
|
||||||
fCopyrightList(5, true),
|
fCopyrightList(5, true),
|
||||||
fLicenseList(5, true),
|
fLicenseList(5, true),
|
||||||
|
fURLList(5, true),
|
||||||
|
fSourceURLList(5, true),
|
||||||
fProvidesList(20, true),
|
fProvidesList(20, true),
|
||||||
fRequiresList(20, true),
|
fRequiresList(20, true),
|
||||||
fSupplementsList(20, true),
|
fSupplementsList(20, true),
|
||||||
@@ -1060,6 +1090,20 @@ BPackageInfo::LicenseList() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BObjectList<BString>&
|
||||||
|
BPackageInfo::URLList() const
|
||||||
|
{
|
||||||
|
return fURLList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BObjectList<BString>&
|
||||||
|
BPackageInfo::SourceURLList() const
|
||||||
|
{
|
||||||
|
return fSourceURLList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const BObjectList<BPackageResolvable>&
|
const BObjectList<BPackageResolvable>&
|
||||||
BPackageInfo::ProvidesList() const
|
BPackageInfo::ProvidesList() const
|
||||||
{
|
{
|
||||||
@@ -1201,6 +1245,42 @@ BPackageInfo::AddLicense(const BString& license)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BPackageInfo::ClearURLList()
|
||||||
|
{
|
||||||
|
fURLList.MakeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BPackageInfo::AddURL(const BString& url)
|
||||||
|
{
|
||||||
|
BString* newURL = new (std::nothrow) BString(url);
|
||||||
|
if (newURL == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
return fURLList.AddItem(newURL) ? B_OK : B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BPackageInfo::ClearSourceURLList()
|
||||||
|
{
|
||||||
|
fSourceURLList.MakeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BPackageInfo::AddSourceURL(const BString& url)
|
||||||
|
{
|
||||||
|
BString* newURL = new (std::nothrow) BString(url);
|
||||||
|
if (newURL == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
return fSourceURLList.AddItem(newURL) ? B_OK : B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPackageInfo::ClearProvidesList()
|
BPackageInfo::ClearProvidesList()
|
||||||
{
|
{
|
||||||
@@ -1328,6 +1408,8 @@ BPackageInfo::Clear()
|
|||||||
fVersion.Clear();
|
fVersion.Clear();
|
||||||
fCopyrightList.MakeEmpty();
|
fCopyrightList.MakeEmpty();
|
||||||
fLicenseList.MakeEmpty();
|
fLicenseList.MakeEmpty();
|
||||||
|
fURLList.MakeEmpty();
|
||||||
|
fSourceURLList.MakeEmpty();
|
||||||
fRequiresList.MakeEmpty();
|
fRequiresList.MakeEmpty();
|
||||||
fProvidesList.MakeEmpty();
|
fProvidesList.MakeEmpty();
|
||||||
fSupplementsList.MakeEmpty();
|
fSupplementsList.MakeEmpty();
|
||||||
|
|||||||
Reference in New Issue
Block a user