* add support to storing names and texts of licenses that require
approval to repository-info git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40427 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <Archivable.h>
|
#include <Archivable.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
|
#include <ObjectList.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <package/PackageArchitecture.h>
|
#include <package/PackageArchitecture.h>
|
||||||
@@ -37,6 +38,8 @@ public:
|
|||||||
const BString& Summary() const;
|
const BString& Summary() const;
|
||||||
uint8 Priority() const;
|
uint8 Priority() const;
|
||||||
BPackageArchitecture Architecture() const;
|
BPackageArchitecture Architecture() const;
|
||||||
|
const BObjectList<BString>& LicenseNames() const;
|
||||||
|
const BObjectList<BString>& LicenseTexts() const;
|
||||||
|
|
||||||
void SetName(const BString& name);
|
void SetName(const BString& name);
|
||||||
void SetOriginalBaseURL(const BString& url);
|
void SetOriginalBaseURL(const BString& url);
|
||||||
@@ -45,6 +48,10 @@ public:
|
|||||||
void SetPriority(uint8 priority);
|
void SetPriority(uint8 priority);
|
||||||
void SetArchitecture(BPackageArchitecture arch);
|
void SetArchitecture(BPackageArchitecture arch);
|
||||||
|
|
||||||
|
status_t AddLicense(const BString& licenseName,
|
||||||
|
const BString& licenseText);
|
||||||
|
void ClearLicenses();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static BRepositoryInfo* Instantiate(BMessage* data);
|
static BRepositoryInfo* Instantiate(BMessage* data);
|
||||||
|
|
||||||
@@ -56,6 +63,8 @@ public:
|
|||||||
static const char* kSummaryField;
|
static const char* kSummaryField;
|
||||||
static const char* kPriorityField;
|
static const char* kPriorityField;
|
||||||
static const char* kArchitectureField;
|
static const char* kArchitectureField;
|
||||||
|
static const char* kLicenseNameField;
|
||||||
|
static const char* kLicenseTextField;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t fInitStatus;
|
status_t fInitStatus;
|
||||||
@@ -66,6 +75,8 @@ private:
|
|||||||
BString fSummary;
|
BString fSummary;
|
||||||
uint8 fPriority;
|
uint8 fPriority;
|
||||||
BPackageArchitecture fArchitecture;
|
BPackageArchitecture fArchitecture;
|
||||||
|
BObjectList<BString> fLicenseNames;
|
||||||
|
BObjectList<BString> fLicenseTexts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ const char* BRepositoryInfo::kVendorField = "vendor";
|
|||||||
const char* BRepositoryInfo::kSummaryField = "summary";
|
const char* BRepositoryInfo::kSummaryField = "summary";
|
||||||
const char* BRepositoryInfo::kPriorityField = "priority";
|
const char* BRepositoryInfo::kPriorityField = "priority";
|
||||||
const char* BRepositoryInfo::kArchitectureField = "architecture";
|
const char* BRepositoryInfo::kArchitectureField = "architecture";
|
||||||
|
const char* BRepositoryInfo::kLicenseNameField = "licenseName";
|
||||||
|
const char* BRepositoryInfo::kLicenseTextField = "licenseText";
|
||||||
|
|
||||||
|
|
||||||
BRepositoryInfo::BRepositoryInfo()
|
BRepositoryInfo::BRepositoryInfo()
|
||||||
@@ -43,7 +45,8 @@ BRepositoryInfo::BRepositoryInfo()
|
|||||||
|
|
||||||
BRepositoryInfo::BRepositoryInfo(BMessage* data)
|
BRepositoryInfo::BRepositoryInfo(BMessage* data)
|
||||||
:
|
:
|
||||||
inherited(data)
|
inherited(data),
|
||||||
|
fLicenseTexts(5, true)
|
||||||
{
|
{
|
||||||
fInitStatus = SetTo(data);
|
fInitStatus = SetTo(data);
|
||||||
}
|
}
|
||||||
@@ -90,6 +93,16 @@ BRepositoryInfo::Archive(BMessage* data, bool deep) const
|
|||||||
return result;
|
return result;
|
||||||
if ((result = data->AddUInt8(kArchitectureField, fArchitecture)) != B_OK)
|
if ((result = data->AddUInt8(kArchitectureField, fArchitecture)) != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
for (int i = 0; i < fLicenseNames.CountItems(); ++i) {
|
||||||
|
result = data->AddString(kLicenseNameField, *fLicenseNames.ItemAt(i));
|
||||||
|
if (result != B_OK)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < fLicenseTexts.CountItems(); ++i) {
|
||||||
|
result = data->AddString(kLicenseTextField, *fLicenseTexts.ItemAt(i));
|
||||||
|
if (result != B_OK)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -124,6 +137,20 @@ BRepositoryInfo::SetTo(const BMessage* data)
|
|||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
const char* licenseName;
|
||||||
|
const char* licenseText;
|
||||||
|
for (int i = 0;
|
||||||
|
data->FindString(kLicenseNameField, i, &licenseName) == B_OK
|
||||||
|
&& data->FindString(kLicenseTextField, i, &licenseText) == B_OK;
|
||||||
|
++i) {
|
||||||
|
BString* newLicenseName = new (std::nothrow) BString(licenseName);
|
||||||
|
if (newLicenseName == NULL || !fLicenseNames.AddItem(newLicenseName))
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
BString* newLicenseText = new (std::nothrow) BString(licenseText);
|
||||||
|
if (newLicenseText == NULL || !fLicenseTexts.AddItem(newLicenseText))
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,6 +266,20 @@ BRepositoryInfo::Architecture() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BObjectList<BString>&
|
||||||
|
BRepositoryInfo::LicenseNames() const
|
||||||
|
{
|
||||||
|
return fLicenseNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BObjectList<BString>&
|
||||||
|
BRepositoryInfo::LicenseTexts() const
|
||||||
|
{
|
||||||
|
return fLicenseTexts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BRepositoryInfo::SetName(const BString& name)
|
BRepositoryInfo::SetName(const BString& name)
|
||||||
{
|
{
|
||||||
@@ -281,4 +322,28 @@ BRepositoryInfo::SetArchitecture(BPackageArchitecture architecture)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BRepositoryInfo::AddLicense(const BString& licenseName,
|
||||||
|
const BString& licenseText)
|
||||||
|
{
|
||||||
|
BString* newLicenseName = new (std::nothrow) BString(licenseName);
|
||||||
|
if (newLicenseName == NULL || !fLicenseNames.AddItem(newLicenseName))
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
BString* newLicenseText = new (std::nothrow) BString(licenseText);
|
||||||
|
if (newLicenseText == NULL || !fLicenseTexts.AddItem(newLicenseText))
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BRepositoryInfo::ClearLicenses()
|
||||||
|
{
|
||||||
|
fLicenseNames.MakeEmpty();
|
||||||
|
fLicenseTexts.MakeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPackageKit
|
} // namespace BPackageKit
|
||||||
|
|||||||
Reference in New Issue
Block a user