HaikuDepot: Update for web-app API changes.
* Category identifyers are lower-case, we can use the "name" facility which already existed for this purpose and simply iterate the list of known categories. * The getBulkPkg method now takes the architectures as a list as well, helps with finding the right package in case there is a mix of architectures across the requested package names.
This commit is contained in:
@@ -321,6 +321,10 @@ Model::Model()
|
|||||||
fCategories.Add(fCategoryInternetAndNetwork);
|
fCategories.Add(fCategoryInternetAndNetwork);
|
||||||
fCategories.Add(fCategoryDevelopment);
|
fCategories.Add(fCategoryDevelopment);
|
||||||
fCategories.Add(fCategoryScienceAndMathematics);
|
fCategories.Add(fCategoryScienceAndMathematics);
|
||||||
|
// TODO: The server will eventually support an API to
|
||||||
|
// get the defined categories and their translated names.
|
||||||
|
// This should then be used instead of hard-coded
|
||||||
|
// categories and translations in the app.
|
||||||
|
|
||||||
// A category for packages that the user installed.
|
// A category for packages that the user installed.
|
||||||
fUserCategories.Add(CategoryRef(new PackageCategory(
|
fUserCategories.Add(CategoryRef(new PackageCategory(
|
||||||
@@ -688,12 +692,15 @@ Model::_PopulatePackageInfos(PackageList& packages, bool fromCacheOnly,
|
|||||||
BMessage info;
|
BMessage info;
|
||||||
|
|
||||||
StringList packageNames;
|
StringList packageNames;
|
||||||
|
StringList packageArchitectures;
|
||||||
for (int i = 0; i < packages.CountItems(); i++) {
|
for (int i = 0; i < packages.CountItems(); i++) {
|
||||||
const PackageInfoRef& package = packages.ItemAtFast(i);
|
const PackageInfoRef& package = packages.ItemAtFast(i);
|
||||||
packageNames.Add(package->Title());
|
packageNames.Add(package->Title());
|
||||||
|
packageArchitectures.Add(package->Architecture());
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t status = interface.RetrieveBulkPackageInfo(packageNames, info);
|
status_t status = interface.RetrieveBulkPackageInfo(packageNames,
|
||||||
|
packageArchitectures, info);
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
// Parse message
|
// Parse message
|
||||||
// info.PrintToStream();
|
// info.PrintToStream();
|
||||||
@@ -835,34 +842,14 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data)
|
|||||||
if (categories.FindString(name, &category) != B_OK)
|
if (categories.FindString(name, &category) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (category == "AUDIO")
|
for (int i = fCategories.CountItems() - 1; i >= 0; i--) {
|
||||||
package->AddCategory(CategoryAudio());
|
const CategoryRef& categoryRef = fCategories.ItemAtFast(i);
|
||||||
else if (category == "BUSINESS")
|
if (categoryRef->Name() == category) {
|
||||||
package->AddCategory(CategoryBusiness());
|
package->AddCategory(categoryRef);
|
||||||
else if (category == "DEVELOPMENT")
|
foundCategory = true;
|
||||||
package->AddCategory(CategoryDevelopment());
|
break;
|
||||||
else if (category == "EDUCATION")
|
}
|
||||||
package->AddCategory(CategoryEducation());
|
}
|
||||||
else if (category == "GAMES")
|
|
||||||
package->AddCategory(CategoryGames());
|
|
||||||
else if (category == "GRAPHICS")
|
|
||||||
package->AddCategory(CategoryGraphics());
|
|
||||||
else if (category == "INTERNETANDNETWORK")
|
|
||||||
package->AddCategory(CategoryInternetAndNetwork());
|
|
||||||
else if (category == "PRODUCTIVITY")
|
|
||||||
package->AddCategory(CategoryProductivity());
|
|
||||||
else if (category == "SCIENCEANDMATHEMATICS")
|
|
||||||
package->AddCategory(CategoryScienceAndMathematics());
|
|
||||||
else if (category == "SYSTEMANDUTILITIES")
|
|
||||||
package->AddCategory(CategorySystemAndUtilities());
|
|
||||||
else if (category == "VIDEO")
|
|
||||||
package->AddCategory(CategoryVideo());
|
|
||||||
// TODO: The server will eventually support an API to
|
|
||||||
// get the defined categories and their translated names.
|
|
||||||
// This should then be used instead of hard-coded
|
|
||||||
// categories and translations in the app.
|
|
||||||
|
|
||||||
foundCategory = true;
|
|
||||||
}
|
}
|
||||||
if (foundCategory)
|
if (foundCategory)
|
||||||
append_word_list(foundInfo, "categories");
|
append_word_list(foundInfo, "categories");
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ WebAppInterface::RetrievePackageInfo(const BString& packageName,
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
WebAppInterface::RetrieveBulkPackageInfo(const StringList& packageNames,
|
WebAppInterface::RetrieveBulkPackageInfo(const StringList& packageNames,
|
||||||
BMessage& message)
|
const StringList& packageArchitectures, BMessage& message)
|
||||||
{
|
{
|
||||||
BString jsonString = JsonBuilder()
|
BString jsonString = JsonBuilder()
|
||||||
.AddValue("jsonrpc", "2.0")
|
.AddValue("jsonrpc", "2.0")
|
||||||
@@ -296,7 +296,9 @@ WebAppInterface::RetrieveBulkPackageInfo(const StringList& packageNames,
|
|||||||
.AddArray("pkgNames")
|
.AddArray("pkgNames")
|
||||||
.AddStrings(packageNames)
|
.AddStrings(packageNames)
|
||||||
.EndArray()
|
.EndArray()
|
||||||
.AddValue("architectureCode", "x86_gcc2")
|
.AddArray("architectureCodes")
|
||||||
|
.AddStrings(packageArchitectures)
|
||||||
|
.EndArray()
|
||||||
.AddValue("naturalLanguageCode", fLanguage)
|
.AddValue("naturalLanguageCode", fLanguage)
|
||||||
.AddValue("versionType", "LATEST")
|
.AddValue("versionType", "LATEST")
|
||||||
.AddArray("filter")
|
.AddArray("filter")
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public:
|
|||||||
|
|
||||||
status_t RetrieveBulkPackageInfo(
|
status_t RetrieveBulkPackageInfo(
|
||||||
const StringList& packageNames,
|
const StringList& packageNames,
|
||||||
|
const StringList& packageArchitectures,
|
||||||
BMessage& message);
|
BMessage& message);
|
||||||
|
|
||||||
status_t RetrievePackageIcon(
|
status_t RetrievePackageIcon(
|
||||||
|
|||||||
Reference in New Issue
Block a user