HaikuDepot: Store the screenshot info...
... from the bulk request results in each PackageInfo.
This commit is contained in:
@@ -910,6 +910,7 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data)
|
|||||||
if (foundCategory)
|
if (foundCategory)
|
||||||
append_word_list(foundInfo, "categories");
|
append_word_list(foundInfo, "categories");
|
||||||
}
|
}
|
||||||
|
|
||||||
double derivedRating;
|
double derivedRating;
|
||||||
double derivedRatingSampleSize;
|
double derivedRatingSampleSize;
|
||||||
if (data.FindDouble("derivedRating", &derivedRating) == B_OK
|
if (data.FindDouble("derivedRating", &derivedRating) == B_OK
|
||||||
@@ -924,6 +925,36 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data)
|
|||||||
append_word_list(foundInfo, "rating");
|
append_word_list(foundInfo, "rating");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BMessage screenshots;
|
||||||
|
if (data.FindMessage("pkgScreenshots", &screenshots) == B_OK) {
|
||||||
|
bool foundScreenshot = false;
|
||||||
|
int32 index = 0;
|
||||||
|
while (true) {
|
||||||
|
BString name;
|
||||||
|
name << index++;
|
||||||
|
|
||||||
|
BMessage screenshot;
|
||||||
|
if (screenshots.FindMessage(name, &screenshot) != B_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
BString code;
|
||||||
|
double width;
|
||||||
|
double height;
|
||||||
|
double dataSize;
|
||||||
|
if (screenshot.FindString("code", &code) == B_OK
|
||||||
|
&& screenshot.FindDouble("width", &width) == B_OK
|
||||||
|
&& screenshot.FindDouble("height", &height) == B_OK
|
||||||
|
&& screenshot.FindDouble("length", &dataSize) == B_OK) {
|
||||||
|
package->AddScreenshotInfo(ScreenshotInfo(code, (int32)width,
|
||||||
|
(int32)height, (int32)dataSize));
|
||||||
|
foundScreenshot = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (foundScreenshot)
|
||||||
|
append_word_list(foundInfo, "screenshots");
|
||||||
|
}
|
||||||
|
|
||||||
if (foundInfo.Length() > 0) {
|
if (foundInfo.Length() > 0) {
|
||||||
printf("Populated package info for %s: %s\n",
|
printf("Populated package info for %s: %s\n",
|
||||||
package->Title().String(), foundInfo.String());
|
package->Title().String(), foundInfo.String());
|
||||||
|
|||||||
@@ -551,6 +551,68 @@ PackageCategory::operator!=(const PackageCategory& other) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - ScreenshotInfo
|
||||||
|
|
||||||
|
|
||||||
|
ScreenshotInfo::ScreenshotInfo()
|
||||||
|
:
|
||||||
|
fCode(),
|
||||||
|
fWidth(),
|
||||||
|
fHeight(),
|
||||||
|
fDataSize()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ScreenshotInfo::ScreenshotInfo(const BString& code,
|
||||||
|
int32 width, int32 height, int32 dataSize)
|
||||||
|
:
|
||||||
|
fCode(code),
|
||||||
|
fWidth(width),
|
||||||
|
fHeight(height),
|
||||||
|
fDataSize(dataSize)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ScreenshotInfo::ScreenshotInfo(const ScreenshotInfo& other)
|
||||||
|
:
|
||||||
|
fCode(other.fCode),
|
||||||
|
fWidth(other.fWidth),
|
||||||
|
fHeight(other.fHeight),
|
||||||
|
fDataSize(other.fDataSize)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ScreenshotInfo&
|
||||||
|
ScreenshotInfo::operator=(const ScreenshotInfo& other)
|
||||||
|
{
|
||||||
|
fCode = other.fCode;
|
||||||
|
fWidth = other.fWidth;
|
||||||
|
fHeight = other.fHeight;
|
||||||
|
fDataSize = other.fDataSize;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
ScreenshotInfo::operator==(const ScreenshotInfo& other) const
|
||||||
|
{
|
||||||
|
return fCode == other.fCode
|
||||||
|
&& fWidth == other.fWidth
|
||||||
|
&& fHeight == other.fHeight
|
||||||
|
&& fDataSize == other.fDataSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
ScreenshotInfo::operator!=(const ScreenshotInfo& other) const
|
||||||
|
{
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - PackageInfo
|
// #pragma mark - PackageInfo
|
||||||
|
|
||||||
|
|
||||||
@@ -565,6 +627,7 @@ PackageInfo::PackageInfo()
|
|||||||
fChangelog(),
|
fChangelog(),
|
||||||
fUserRatings(),
|
fUserRatings(),
|
||||||
fCachedRatingSummary(),
|
fCachedRatingSummary(),
|
||||||
|
fScreenshotInfos(),
|
||||||
fScreenshots(),
|
fScreenshots(),
|
||||||
fState(NONE),
|
fState(NONE),
|
||||||
fDownloadProgress(0.0),
|
fDownloadProgress(0.0),
|
||||||
@@ -590,6 +653,7 @@ PackageInfo::PackageInfo(const BString& title,
|
|||||||
fCategories(),
|
fCategories(),
|
||||||
fUserRatings(),
|
fUserRatings(),
|
||||||
fCachedRatingSummary(),
|
fCachedRatingSummary(),
|
||||||
|
fScreenshotInfos(),
|
||||||
fScreenshots(),
|
fScreenshots(),
|
||||||
fState(NONE),
|
fState(NONE),
|
||||||
fDownloadProgress(0.0),
|
fDownloadProgress(0.0),
|
||||||
@@ -612,6 +676,7 @@ PackageInfo::PackageInfo(const PackageInfo& other)
|
|||||||
fCategories(other.fCategories),
|
fCategories(other.fCategories),
|
||||||
fUserRatings(other.fUserRatings),
|
fUserRatings(other.fUserRatings),
|
||||||
fCachedRatingSummary(other.fCachedRatingSummary),
|
fCachedRatingSummary(other.fCachedRatingSummary),
|
||||||
|
fScreenshotInfos(other.fScreenshotInfos),
|
||||||
fScreenshots(other.fScreenshots),
|
fScreenshots(other.fScreenshots),
|
||||||
fState(other.fState),
|
fState(other.fState),
|
||||||
fInstallationLocations(other.fInstallationLocations),
|
fInstallationLocations(other.fInstallationLocations),
|
||||||
@@ -636,6 +701,7 @@ PackageInfo::operator=(const PackageInfo& other)
|
|||||||
fCategories = other.fCategories;
|
fCategories = other.fCategories;
|
||||||
fUserRatings = other.fUserRatings;
|
fUserRatings = other.fUserRatings;
|
||||||
fCachedRatingSummary = other.fCachedRatingSummary;
|
fCachedRatingSummary = other.fCachedRatingSummary;
|
||||||
|
fScreenshotInfos = other.fScreenshotInfos;
|
||||||
fScreenshots = other.fScreenshots;
|
fScreenshots = other.fScreenshots;
|
||||||
fState = other.fState;
|
fState = other.fState;
|
||||||
fInstallationLocations = other.fInstallationLocations;
|
fInstallationLocations = other.fInstallationLocations;
|
||||||
@@ -660,6 +726,7 @@ PackageInfo::operator==(const PackageInfo& other) const
|
|||||||
&& fCategories == other.fCategories
|
&& fCategories == other.fCategories
|
||||||
&& fUserRatings == other.fUserRatings
|
&& fUserRatings == other.fUserRatings
|
||||||
&& fCachedRatingSummary == other.fCachedRatingSummary
|
&& fCachedRatingSummary == other.fCachedRatingSummary
|
||||||
|
&& fScreenshotInfos == other.fScreenshotInfos
|
||||||
&& fScreenshots == other.fScreenshots
|
&& fScreenshots == other.fScreenshots
|
||||||
&& fState == other.fState
|
&& fState == other.fState
|
||||||
&& fFlags == other.fFlags
|
&& fFlags == other.fFlags
|
||||||
@@ -840,6 +907,13 @@ PackageInfo::CalculateRatingSummary() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
PackageInfo::AddScreenshotInfo(const ScreenshotInfo& info)
|
||||||
|
{
|
||||||
|
return fScreenshotInfos.Add(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PackageInfo::AddScreenshot(const BitmapRef& screenshot)
|
PackageInfo::AddScreenshot(const BitmapRef& screenshot)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -202,9 +202,41 @@ typedef BReference<PackageCategory> CategoryRef;
|
|||||||
typedef List<CategoryRef, false> CategoryList;
|
typedef List<CategoryRef, false> CategoryList;
|
||||||
|
|
||||||
|
|
||||||
|
class ScreenshotInfo {
|
||||||
|
public:
|
||||||
|
ScreenshotInfo();
|
||||||
|
ScreenshotInfo(const BString& code,
|
||||||
|
int32 width, int32 height, int32 dataSize);
|
||||||
|
ScreenshotInfo(const ScreenshotInfo& other);
|
||||||
|
|
||||||
|
ScreenshotInfo& operator=(const ScreenshotInfo& other);
|
||||||
|
bool operator==(const ScreenshotInfo& other) const;
|
||||||
|
bool operator!=(const ScreenshotInfo& other) const;
|
||||||
|
|
||||||
|
const BString& Code() const
|
||||||
|
{ return fCode; }
|
||||||
|
int32 Width() const
|
||||||
|
{ return fWidth; }
|
||||||
|
int32 Height() const
|
||||||
|
{ return fHeight; }
|
||||||
|
int32 DataSize() const
|
||||||
|
{ return fDataSize; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
BString fCode;
|
||||||
|
int32 fWidth;
|
||||||
|
int32 fHeight;
|
||||||
|
int32 fDataSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef List<ScreenshotInfo, false, 2> ScreenshotInfoList;
|
||||||
|
|
||||||
|
|
||||||
typedef List<PackageInfoListenerRef, false, 2> PackageListenerList;
|
typedef List<PackageInfoListenerRef, false, 2> PackageListenerList;
|
||||||
typedef std::set<int32> PackageInstallationLocationSet;
|
typedef std::set<int32> PackageInstallationLocationSet;
|
||||||
|
|
||||||
|
|
||||||
enum PackageState {
|
enum PackageState {
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
INSTALLED = 1,
|
INSTALLED = 1,
|
||||||
@@ -286,6 +318,10 @@ public:
|
|||||||
void SetRatingSummary(const RatingSummary& summary);
|
void SetRatingSummary(const RatingSummary& summary);
|
||||||
RatingSummary CalculateRatingSummary() const;
|
RatingSummary CalculateRatingSummary() const;
|
||||||
|
|
||||||
|
bool AddScreenshotInfo(const ScreenshotInfo& info);
|
||||||
|
const ScreenshotInfoList& ScreenshotInfos() const
|
||||||
|
{ return fScreenshotInfos; }
|
||||||
|
|
||||||
bool AddScreenshot(const BitmapRef& screenshot);
|
bool AddScreenshot(const BitmapRef& screenshot);
|
||||||
const BitmapList& Screenshots() const
|
const BitmapList& Screenshots() const
|
||||||
{ return fScreenshots; }
|
{ return fScreenshots; }
|
||||||
@@ -309,6 +345,7 @@ private:
|
|||||||
CategoryList fCategories;
|
CategoryList fCategories;
|
||||||
UserRatingList fUserRatings;
|
UserRatingList fUserRatings;
|
||||||
RatingSummary fCachedRatingSummary;
|
RatingSummary fCachedRatingSummary;
|
||||||
|
ScreenshotInfoList fScreenshotInfos;
|
||||||
BitmapList fScreenshots;
|
BitmapList fScreenshots;
|
||||||
PackageState fState;
|
PackageState fState;
|
||||||
PackageInstallationLocationSet
|
PackageInstallationLocationSet
|
||||||
|
|||||||
Reference in New Issue
Block a user