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:
Stephan Aßmus
2014-09-03 22:54:04 +02:00
parent 5fa80ab691
commit 2b411c028e
3 changed files with 21 additions and 31 deletions
+16 -29
View File
@@ -321,6 +321,10 @@ Model::Model()
fCategories.Add(fCategoryInternetAndNetwork);
fCategories.Add(fCategoryDevelopment);
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.
fUserCategories.Add(CategoryRef(new PackageCategory(
@@ -688,12 +692,15 @@ Model::_PopulatePackageInfos(PackageList& packages, bool fromCacheOnly,
BMessage info;
StringList packageNames;
StringList packageArchitectures;
for (int i = 0; i < packages.CountItems(); i++) {
const PackageInfoRef& package = packages.ItemAtFast(i);
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) {
// Parse message
// info.PrintToStream();
@@ -835,34 +842,14 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data)
if (categories.FindString(name, &category) != B_OK)
break;
if (category == "AUDIO")
package->AddCategory(CategoryAudio());
else if (category == "BUSINESS")
package->AddCategory(CategoryBusiness());
else if (category == "DEVELOPMENT")
package->AddCategory(CategoryDevelopment());
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;
for (int i = fCategories.CountItems() - 1; i >= 0; i--) {
const CategoryRef& categoryRef = fCategories.ItemAtFast(i);
if (categoryRef->Name() == category) {
package->AddCategory(categoryRef);
foundCategory = true;
break;
}
}
}
if (foundCategory)
append_word_list(foundInfo, "categories");
+4 -2
View File
@@ -285,7 +285,7 @@ WebAppInterface::RetrievePackageInfo(const BString& packageName,
status_t
WebAppInterface::RetrieveBulkPackageInfo(const StringList& packageNames,
BMessage& message)
const StringList& packageArchitectures, BMessage& message)
{
BString jsonString = JsonBuilder()
.AddValue("jsonrpc", "2.0")
@@ -296,7 +296,9 @@ WebAppInterface::RetrieveBulkPackageInfo(const StringList& packageNames,
.AddArray("pkgNames")
.AddStrings(packageNames)
.EndArray()
.AddValue("architectureCode", "x86_gcc2")
.AddArray("architectureCodes")
.AddStrings(packageArchitectures)
.EndArray()
.AddValue("naturalLanguageCode", fLanguage)
.AddValue("versionType", "LATEST")
.AddArray("filter")
+1
View File
@@ -35,6 +35,7 @@ public:
status_t RetrieveBulkPackageInfo(
const StringList& packageNames,
const StringList& packageArchitectures,
BMessage& message);
status_t RetrievePackageIcon(