HaikuDepot: Changelog & Contents Tabs
Disable the changelog tab in the case that a package has no changelog. Also disable the contents tab and do not attempt to load the package contents in the case where a package is not installed on the host. Resolves #15299 Change-Id: Id17daf46aba6709f35438db2ee30f3485fc251ea Reviewed-on: https://review.haiku-os.org/c/haiku/+/2749 Reviewed-by: humdinger <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
05bd53615a
commit
8c6ebdec76
@@ -605,7 +605,7 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags)
|
|||||||
fPopulatedPackages.Add(package);
|
fPopulatedPackages.Add(package);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & POPULATE_CHANGELOG) != 0) {
|
if ((flags & POPULATE_CHANGELOG) != 0 && package->HasChangelog()) {
|
||||||
_PopulatePackageChangelog(package);
|
_PopulatePackageChangelog(package);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2014, Stephan Aßmus <[email protected]>.
|
* Copyright 2013-2014, Stephan Aßmus <[email protected]>.
|
||||||
* Copyright 2013, Rene Gollent <[email protected]>.
|
* Copyright 2013, Rene Gollent <[email protected]>.
|
||||||
* Copyright 2016-2019, Andrew Lindesay <[email protected]>.
|
* Copyright 2016-2020, Andrew Lindesay <[email protected]>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -471,6 +471,7 @@ PackageInfo::PackageInfo()
|
|||||||
fPublisher(),
|
fPublisher(),
|
||||||
fShortDescription(),
|
fShortDescription(),
|
||||||
fFullDescription(),
|
fFullDescription(),
|
||||||
|
fHasChangelog(false),
|
||||||
fChangelog(),
|
fChangelog(),
|
||||||
fUserRatings(),
|
fUserRatings(),
|
||||||
fCachedRatingSummary(),
|
fCachedRatingSummary(),
|
||||||
@@ -501,6 +502,7 @@ PackageInfo::PackageInfo(const BPackageInfo& info)
|
|||||||
fPublisher(),
|
fPublisher(),
|
||||||
fShortDescription(info.Summary()),
|
fShortDescription(info.Summary()),
|
||||||
fFullDescription(info.Description()),
|
fFullDescription(info.Description()),
|
||||||
|
fHasChangelog(false),
|
||||||
fChangelog(),
|
fChangelog(),
|
||||||
fUserRatings(),
|
fUserRatings(),
|
||||||
fCachedRatingSummary(),
|
fCachedRatingSummary(),
|
||||||
@@ -547,6 +549,7 @@ PackageInfo::PackageInfo(const BString& name,
|
|||||||
fPublisher(publisher),
|
fPublisher(publisher),
|
||||||
fShortDescription(shortDescription),
|
fShortDescription(shortDescription),
|
||||||
fFullDescription(fullDescription),
|
fFullDescription(fullDescription),
|
||||||
|
fHasChangelog(false),
|
||||||
fChangelog(),
|
fChangelog(),
|
||||||
fCategories(),
|
fCategories(),
|
||||||
fUserRatings(),
|
fUserRatings(),
|
||||||
@@ -578,6 +581,7 @@ PackageInfo::PackageInfo(const PackageInfo& other)
|
|||||||
fPublisher(other.fPublisher),
|
fPublisher(other.fPublisher),
|
||||||
fShortDescription(other.fShortDescription),
|
fShortDescription(other.fShortDescription),
|
||||||
fFullDescription(other.fFullDescription),
|
fFullDescription(other.fFullDescription),
|
||||||
|
fHasChangelog(other.fHasChangelog),
|
||||||
fChangelog(other.fChangelog),
|
fChangelog(other.fChangelog),
|
||||||
fCategories(other.fCategories),
|
fCategories(other.fCategories),
|
||||||
fUserRatings(other.fUserRatings),
|
fUserRatings(other.fUserRatings),
|
||||||
@@ -611,6 +615,7 @@ PackageInfo::operator=(const PackageInfo& other)
|
|||||||
fPublisher = other.fPublisher;
|
fPublisher = other.fPublisher;
|
||||||
fShortDescription = other.fShortDescription;
|
fShortDescription = other.fShortDescription;
|
||||||
fFullDescription = other.fFullDescription;
|
fFullDescription = other.fFullDescription;
|
||||||
|
fHasChangelog = other.fHasChangelog;
|
||||||
fChangelog = other.fChangelog;
|
fChangelog = other.fChangelog;
|
||||||
fCategories = other.fCategories;
|
fCategories = other.fCategories;
|
||||||
fUserRatings = other.fUserRatings;
|
fUserRatings = other.fUserRatings;
|
||||||
@@ -642,6 +647,7 @@ PackageInfo::operator==(const PackageInfo& other) const
|
|||||||
&& fPublisher == other.fPublisher
|
&& fPublisher == other.fPublisher
|
||||||
&& fShortDescription == other.fShortDescription
|
&& fShortDescription == other.fShortDescription
|
||||||
&& fFullDescription == other.fFullDescription
|
&& fFullDescription == other.fFullDescription
|
||||||
|
&& fHasChangelog == other.fHasChangelog
|
||||||
&& fChangelog == other.fChangelog
|
&& fChangelog == other.fChangelog
|
||||||
&& fCategories == other.fCategories
|
&& fCategories == other.fCategories
|
||||||
&& fUserRatings == other.fUserRatings
|
&& fUserRatings == other.fUserRatings
|
||||||
@@ -714,6 +720,13 @@ PackageInfo::SetIcon(const BitmapRef& icon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageInfo::SetHasChangelog(bool value)
|
||||||
|
{
|
||||||
|
fHasChangelog = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageInfo::SetChangelog(const BString& changelog)
|
PackageInfo::SetChangelog(const BString& changelog)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
||||||
* Copyright 2016-2019, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2016-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef PACKAGE_INFO_H
|
#ifndef PACKAGE_INFO_H
|
||||||
@@ -286,6 +286,10 @@ public:
|
|||||||
void SetIcon(const BitmapRef& icon);
|
void SetIcon(const BitmapRef& icon);
|
||||||
const BitmapRef& Icon() const
|
const BitmapRef& Icon() const
|
||||||
{ return fIcon; }
|
{ return fIcon; }
|
||||||
|
|
||||||
|
void SetHasChangelog(bool value);
|
||||||
|
bool HasChangelog() const
|
||||||
|
{ return fHasChangelog; }
|
||||||
void SetChangelog(const BString& changelog);
|
void SetChangelog(const BString& changelog);
|
||||||
const BString& Changelog() const
|
const BString& Changelog() const
|
||||||
{ return fChangelog; }
|
{ return fChangelog; }
|
||||||
@@ -380,6 +384,7 @@ private:
|
|||||||
PublisherInfo fPublisher;
|
PublisherInfo fPublisher;
|
||||||
BString fShortDescription;
|
BString fShortDescription;
|
||||||
BString fFullDescription;
|
BString fFullDescription;
|
||||||
|
bool fHasChangelog;
|
||||||
BString fChangelog;
|
BString fChangelog;
|
||||||
CategoryList fCategories;
|
CategoryList fCategories;
|
||||||
UserRatingList fUserRatings;
|
UserRatingList fUserRatings;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2019, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2017-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -159,6 +159,8 @@ PackageFillingPkgListener::ConsumePackage(const PackageInfoRef& package,
|
|||||||
|
|
||||||
package->SetRatingSummary(summary);
|
package->SetRatingSummary(summary);
|
||||||
|
|
||||||
|
package->SetHasChangelog(pkg->HasChangelog());
|
||||||
|
|
||||||
if (!pkg->ProminenceOrderingIsNull())
|
if (!pkg->ProminenceOrderingIsNull())
|
||||||
package->SetProminence(pkg->ProminenceOrdering());
|
package->SetProminence(pkg->ProminenceOrdering());
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
"derivedRating": {
|
"derivedRating": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"hasChangelog": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"pkgScreenshots": {
|
"pkgScreenshots": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|||||||
@@ -5,68 +5,71 @@
|
|||||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReference",
|
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReference",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"naturalLanguages": {
|
"naturalLanguages": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceNaturalLanguage",
|
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceNaturalLanguage",
|
||||||
"properties": {
|
"properties": {
|
||||||
"code": {
|
"code": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"isPopular": {
|
"isPopular": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pkgCategories": {
|
"pkgCategories": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferencePkgCategory",
|
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferencePkgCategory",
|
||||||
"properties": {
|
"properties": {
|
||||||
"code": {
|
"code": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"userRatingStabilities": {
|
"userRatingStabilities": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceUserRatingStability",
|
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceUserRatingStability",
|
||||||
"properties": {
|
"properties": {
|
||||||
"code": {
|
"code": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
},
|
||||||
}
|
"ordering": {
|
||||||
}
|
"type": "integer"
|
||||||
},
|
}
|
||||||
"countries": {
|
}
|
||||||
"type": "array",
|
}
|
||||||
"items": {
|
},
|
||||||
"type": "object",
|
"countries": {
|
||||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceCountry",
|
"type": "array",
|
||||||
"properties": {
|
"items": {
|
||||||
"code": {
|
"type": "object",
|
||||||
"type": "string"
|
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceCountry",
|
||||||
},
|
"properties": {
|
||||||
"name": {
|
"code": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
},
|
||||||
}
|
"name": {
|
||||||
}
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015, TigerKid001.
|
* Copyright 2015, TigerKid001.
|
||||||
|
* Copyright 2020, Andrew Lindesay <apl@lindesay.co.nz>
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -293,9 +294,6 @@ PackageContentsView::SetPackage(const PackageInfoRef& package)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("PackageContentsView::SetPackage(%s)\n",
|
|
||||||
// package.Get() != NULL ? package->Name().String() : "NULL");
|
|
||||||
|
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -303,7 +301,12 @@ PackageContentsView::SetPackage(const PackageInfoRef& package)
|
|||||||
fPackage = package;
|
fPackage = package;
|
||||||
fLastPackageState = package.Get() != NULL ? package->State() : NONE;
|
fLastPackageState = package.Get() != NULL ? package->State() : NONE;
|
||||||
}
|
}
|
||||||
release_sem_etc(fContentPopulatorSem, 1, 0);
|
|
||||||
|
// if the package is not installed then there is no point in attempting to
|
||||||
|
// populate data for it.
|
||||||
|
|
||||||
|
if (package.Get() != NULL && package->State() == ACTIVATED)
|
||||||
|
release_sem_etc(fContentPopulatorSem, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -349,7 +352,7 @@ PackageContentsView::_ContentPopulatorThread(void* arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (package.Get() != NULL) {
|
if (package.Get() != NULL) {
|
||||||
if (!view->_PopuplatePackageContens(*package.Get())) {
|
if (!view->_PopulatePackageContents(*package.Get())) {
|
||||||
if (view->LockLooperWithTimeout(1000000) == B_OK) {
|
if (view->LockLooperWithTimeout(1000000) == B_OK) {
|
||||||
view->fContentListView->AddItem(
|
view->fContentListView->AddItem(
|
||||||
new BStringItem(B_TRANSLATE("<Package contents not "
|
new BStringItem(B_TRANSLATE("<Package contents not "
|
||||||
@@ -365,7 +368,7 @@ PackageContentsView::_ContentPopulatorThread(void* arg)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PackageContentsView::_PopuplatePackageContens(const PackageInfo& package)
|
PackageContentsView::_PopulatePackageContents(const PackageInfo& package)
|
||||||
{
|
{
|
||||||
BPath packagePath;
|
BPath packagePath;
|
||||||
|
|
||||||
@@ -386,7 +389,7 @@ PackageContentsView::_PopuplatePackageContens(const PackageInfo& package)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("PackageContentsView::_PopuplatePackageContens(): "
|
printf("PackageContentsView::_PopulatePackageContents(): "
|
||||||
"unknown install location");
|
"unknown install location");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -400,7 +403,7 @@ PackageContentsView::_PopuplatePackageContens(const PackageInfo& package)
|
|||||||
|
|
||||||
status_t status = reader.Init(packagePath.Path());
|
status_t status = reader.Init(packagePath.Path());
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
printf("PackageContentsView::_PopuplatePackageContens(): "
|
printf("PackageContentsView::_PopulatePackageContents(): "
|
||||||
"failed to init BPackageReader(%s): %s\n",
|
"failed to init BPackageReader(%s): %s\n",
|
||||||
packagePath.Path(), strerror(status));
|
packagePath.Path(), strerror(status));
|
||||||
return false;
|
return false;
|
||||||
@@ -411,7 +414,7 @@ PackageContentsView::_PopuplatePackageContens(const PackageInfo& package)
|
|||||||
fPackageLock, fPackage);
|
fPackageLock, fPackage);
|
||||||
status = reader.ParseContent(&contentHandler);
|
status = reader.ParseContent(&contentHandler);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
printf("PackageContentsView::_PopuplatePackageContens(): "
|
printf("PackageContentsView::_PopulatePackageContents(): "
|
||||||
"failed parse package contents: %s\n", strerror(status));
|
"failed parse package contents: %s\n", strerror(status));
|
||||||
// NOTE: Do not return false, since it taken to mean this
|
// NOTE: Do not return false, since it taken to mean this
|
||||||
// is a remote package, but is it not, we simply want to stop
|
// is a remote package, but is it not, we simply want to stop
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015, TigerKid001.
|
* Copyright 2015, TigerKid001.
|
||||||
|
* Copyright 2020, Andrew Lindesay <apl@lindesay.co.nz>
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef PACKAGE_CONTENTS_VIEW_H
|
#ifndef PACKAGE_CONTENTS_VIEW_H
|
||||||
@@ -27,7 +28,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void _InitContentPopulator();
|
void _InitContentPopulator();
|
||||||
static int32 _ContentPopulatorThread(void* arg);
|
static int32 _ContentPopulatorThread(void* arg);
|
||||||
bool _PopuplatePackageContens(
|
bool _PopulatePackageContents(
|
||||||
const PackageInfo& package);
|
const PackageInfo& package);
|
||||||
int32 _InstallLocation(
|
int32 _InstallLocation(
|
||||||
const PackageInfo& package) const;
|
const PackageInfo& package) const;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
||||||
* Copyright 2018-2019, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2018-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -54,6 +54,14 @@
|
|||||||
#define B_TRANSLATION_CONTEXT "PackageInfoView"
|
#define B_TRANSLATION_CONTEXT "PackageInfoView"
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TAB_ABOUT = 0,
|
||||||
|
TAB_RATINGS = 1,
|
||||||
|
TAB_CHANGELOG = 2,
|
||||||
|
TAB_CONTENTS = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static const float kContentTint = (B_NO_TINT + B_LIGHTEN_1_TINT) / 2.0f;
|
static const float kContentTint = (B_NO_TINT + B_LIGHTEN_1_TINT) / 2.0f;
|
||||||
|
|
||||||
|
|
||||||
@@ -1222,12 +1230,12 @@ public:
|
|||||||
AddTab(fChangelogView);
|
AddTab(fChangelogView);
|
||||||
AddTab(fContentsView);
|
AddTab(fContentsView);
|
||||||
|
|
||||||
TabAt(0)->SetLabel(B_TRANSLATE("About"));
|
TabAt(TAB_ABOUT)->SetLabel(B_TRANSLATE("About"));
|
||||||
TabAt(1)->SetLabel(B_TRANSLATE("Ratings"));
|
TabAt(TAB_RATINGS)->SetLabel(B_TRANSLATE("Ratings"));
|
||||||
TabAt(2)->SetLabel(B_TRANSLATE("Changelog"));
|
TabAt(TAB_CHANGELOG)->SetLabel(B_TRANSLATE("Changelog"));
|
||||||
TabAt(3)->SetLabel(B_TRANSLATE("Contents"));
|
TabAt(TAB_CONTENTS)->SetLabel(B_TRANSLATE("Contents"));
|
||||||
|
|
||||||
Select(0);
|
Select(TAB_ABOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~PagesView()
|
virtual ~PagesView()
|
||||||
@@ -1238,7 +1246,15 @@ public:
|
|||||||
void SetPackage(const PackageInfoRef& package, bool switchToDefaultTab)
|
void SetPackage(const PackageInfoRef& package, bool switchToDefaultTab)
|
||||||
{
|
{
|
||||||
if (switchToDefaultTab)
|
if (switchToDefaultTab)
|
||||||
Select(0);
|
Select(TAB_ABOUT);
|
||||||
|
|
||||||
|
TabAt(TAB_CHANGELOG)->SetEnabled(
|
||||||
|
package.Get() != NULL && package->HasChangelog());
|
||||||
|
TabAt(TAB_CONTENTS)->SetEnabled(
|
||||||
|
package.Get() != NULL && package->State() == ACTIVATED);
|
||||||
|
Invalidate(TabFrame(TAB_CHANGELOG));
|
||||||
|
Invalidate(TabFrame(TAB_CONTENTS));
|
||||||
|
|
||||||
fAboutView->SetPackage(*package.Get());
|
fAboutView->SetPackage(*package.Get());
|
||||||
fUserRatingsView->SetPackage(*package.Get());
|
fUserRatingsView->SetPackage(*package.Get());
|
||||||
fChangelogView->SetPackage(*package.Get());
|
fChangelogView->SetPackage(*package.Get());
|
||||||
|
|||||||
Reference in New Issue
Block a user