diff --git a/src/apps/haikudepot/Jamfile b/src/apps/haikudepot/Jamfile index 6029f86bc4..ef70f5ceb7 100644 --- a/src/apps/haikudepot/Jamfile +++ b/src/apps/haikudepot/Jamfile @@ -4,7 +4,16 @@ UsePrivateHeaders interface shared storage package support net ; # source directories local sourceDirs = - edits_generic model textview ui ui_generic server server/dumpexportrepository tar util + edits_generic + model + textview + ui + ui_generic + server + server/dumpexportrepository + server/dumpexportpkg + tar + util ; local sourceDir ; @@ -76,6 +85,11 @@ Application HaikuDepot : UserLoginWindow.cpp # network + server - model + DumpExportPkg.cpp + DumpExportPkgCategory.cpp + DumpExportPkgJsonListener.cpp + DumpExportPkgScreenshot.cpp + DumpExportPkgVersion.cpp DumpExportRepository.cpp DumpExportRepositorySource.cpp DumpExportRepositoryJsonListener.cpp @@ -84,6 +98,7 @@ Application HaikuDepot : AbstractServerProcess.cpp ServerSettings.cpp WebAppInterface.cpp + PkgDataUpdateProcess.cpp RepositoryDataUpdateProcess.cpp ServerIconExportUpdateProcess.cpp StandardMetaDataJsonEventListener.cpp diff --git a/src/apps/haikudepot/model/LocalIconStore.cpp b/src/apps/haikudepot/model/LocalIconStore.cpp index a74c6b59be..c01bfd1bed 100644 --- a/src/apps/haikudepot/model/LocalIconStore.cpp +++ b/src/apps/haikudepot/model/LocalIconStore.cpp @@ -10,6 +10,7 @@ #include #include +#include "Logger.h" #include "ServerIconExportUpdateProcess.h" #include "StorageUtils.h" @@ -73,6 +74,10 @@ LocalIconStore::UpdateFromServerIfNecessary() const BPath iconStoragePath(fIconStoragePath); ServerIconExportUpdateProcess service(iconStoragePath); service.Run(); + + if (Logger::IsDebugEnabled()) { + printf("did update the icons from server\n"); + } } } diff --git a/src/apps/haikudepot/model/Model.cpp b/src/apps/haikudepot/model/Model.cpp index 262dd6a438..829fd3a70f 100644 --- a/src/apps/haikudepot/model/Model.cpp +++ b/src/apps/haikudepot/model/Model.cpp @@ -23,6 +23,7 @@ #include #include "Logger.h" +#include "PkgDataUpdateProcess.h" #include "RepositoryDataUpdateProcess.h" #include "StorageUtils.h" @@ -863,6 +864,30 @@ Model::_DumpExportRepositoryDataPath(BPath& path) const } +status_t +Model::_DumpExportPkgDataPath(BPath& path, + const BString& repositorySourceCode) const +{ + BPath repoDataPath; + BString leafName; + + leafName.SetToFormat("pkg-all-%s-%s.json.gz", repositorySourceCode.String(), + fPreferredLanguage.String()); + + if (find_directory(B_USER_CACHE_DIRECTORY, &repoDataPath) == B_OK + && repoDataPath.Append("HaikuDepot") == B_OK + && create_directory(repoDataPath.Path(), 0777) == B_OK + && repoDataPath.Append(leafName.String()) == B_OK) { + path.SetTo(repoDataPath.Path()); + return B_OK; + } + + path.Unset(); + fprintf(stdout, "unable to find the user cache file for pkgs' data"); + return B_ERROR; +} + + status_t Model::PopulateWebAppRepositoryCodes() { @@ -895,8 +920,7 @@ int32 Model::_PopulateAllPackagesEntry(void* cookie) { Model* model = static_cast(cookie); - model->_PopulateAllPackagesThread(true); - model->_PopulateAllPackagesThread(false); + model->_PopulateAllPackagesThread(); model->_PopulateAllPackagesIcons(); return 0; } @@ -948,430 +972,52 @@ Model::_PopulateAllPackagesIcons() void -Model::_PopulateAllPackagesThread(bool fromCacheOnly) +Model::_PopulatePackagesForDepot(const DepotInfo& depotInfo) +{ + BString repositorySourceCode = depotInfo.WebAppRepositorySourceCode(); + BPath repositorySourcePkgDataPath; + + if (B_OK != _DumpExportPkgDataPath(repositorySourcePkgDataPath, + repositorySourceCode)) { + printf("unable to obtain the path for storing data for [%s]\n", + repositorySourceCode.String()); + } else { + + printf("will fetch and process data for repository source [%s]\n", + repositorySourceCode.String()); + + PkgDataUpdateProcess process( + repositorySourcePkgDataPath, + fLock, repositorySourceCode, fPreferredLanguage, + depotInfo.Packages(), + fCategories); + + process.Run(); + + printf("did fetch and process data for repository source [%s]\n", + repositorySourceCode.String()); + } +} + + +void +Model::_PopulateAllPackagesThread() { int32 depotIndex = 0; - int32 packageIndex = 0; - PackageList bulkPackageList; + int32 count = 0; - while (!fStopPopulatingAllPackages) { - // Obtain PackageInfoRef while keeping the depot and package lists - // locked. - PackageInfoRef package; - { - BAutolock locker(&fLock); + for (depotIndex = 0; + depotIndex < fDepots.CountItems() && !fStopPopulatingAllPackages; + depotIndex++) { + const DepotInfo& depot = fDepots.ItemAt(depotIndex); - if (depotIndex >= fDepots.CountItems()) - break; - const DepotInfo& depot = fDepots.ItemAt(depotIndex); - - const PackageList& packages = depot.Packages(); - if (packageIndex >= packages.CountItems()) { - // Need the next depot - packageIndex = 0; - depotIndex++; - continue; - } - - package = packages.ItemAt(packageIndex); - packageIndex++; - } - - if (package.Get() == NULL) - continue; - - //_PopulatePackageInfo(package, fromCacheOnly); - bulkPackageList.Add(package); - if (bulkPackageList.CountItems() == 50) { - _PopulatePackageInfos(bulkPackageList, fromCacheOnly); - bulkPackageList.Clear(); - } - // TODO: Average user rating. It needs to be shown in the - // list view, so without the user clicking the package. - } - - if (bulkPackageList.CountItems() > 0) { - _PopulatePackageInfos(bulkPackageList, fromCacheOnly); - } -} - - -bool -Model::_GetCacheFile(BPath& path, BFile& file, directory_which directory, - const char* relativeLocation, const char* fileName, uint32 openMode) const -{ - if (find_directory(directory, &path) == B_OK - && path.Append(relativeLocation) == B_OK - && create_directory(path.Path(), 0777) == B_OK - && path.Append(fileName) == B_OK) { - // Try opening the file which will fail if its - // not a file or does not exist. - return file.SetTo(path.Path(), openMode) == B_OK; - } - return false; -} - - -bool -Model::_GetCacheFile(BPath& path, BFile& file, directory_which directory, - const char* relativeLocation, const char* fileName, - bool ignoreAge, time_t maxAge) const -{ - if (!_GetCacheFile(path, file, directory, relativeLocation, fileName, - B_READ_ONLY)) { - return false; - } - - if (ignoreAge) - return true; - - time_t modifiedTime; - file.GetModificationTime(&modifiedTime); - time_t now; - time(&now); - return now - modifiedTime < maxAge; -} - - -void -Model::_PopulatePackageInfos(PackageList& packages, bool fromCacheOnly) -{ - if (fStopPopulatingAllPackages) - return; - - // See if there are cached info files - for (int i = packages.CountItems() - 1; i >= 0; i--) { - if (fStopPopulatingAllPackages) - return; - - const PackageInfoRef& package = packages.ItemAtFast(i); - - BFile file; - BPath path; - BString name(package->Name()); - name << ".info"; - if (_GetCacheFile(path, file, B_USER_CACHE_DIRECTORY, - "HaikuDepot", name, fromCacheOnly, 60 * 60)) { - // Cache file is recent enough, just use it and return. - BMessage pkgInfo; - if (pkgInfo.Unflatten(&file) == B_OK) { - _PopulatePackageInfo(package, pkgInfo); - packages.Remove(i); - } - } - } - - if (fromCacheOnly || packages.IsEmpty()) - return; - - // Retrieve info from web-app - BMessage info; - - StringList packageNames; - StringList packageArchitectures; - StringList repositoryCodes; - - for (int i = 0; i < packages.CountItems(); i++) { - const PackageInfoRef& package = packages.ItemAtFast(i); - packageNames.Add(package->Name()); - - if (!packageArchitectures.Contains(package->Architecture())) - packageArchitectures.Add(package->Architecture()); - - const DepotInfo *depot = DepotForName(package->DepotName()); - - if (depot != NULL) { - BString repositoryCode = depot->WebAppRepositoryCode(); - - if (repositoryCode.Length() != 0 - && !repositoryCodes.Contains(repositoryCode)) { - repositoryCodes.Add(repositoryCode); - } - } - } - - if (repositoryCodes.CountItems() != 0) { - status_t status = fWebAppInterface.RetrieveBulkPackageInfo(packageNames, - packageArchitectures, repositoryCodes, info); - - if (status == B_OK) { - // Parse message - BMessage result; - BMessage pkgs; - if (info.FindMessage("result", &result) == B_OK - && result.FindMessage("pkgs", &pkgs) == B_OK) { - int32 index = 0; - while (true) { - if (fStopPopulatingAllPackages) - return; - BString name; - name << index++; - BMessage pkgInfo; - if (pkgs.FindMessage(name, &pkgInfo) != B_OK) - break; - - BString pkgName; - if (pkgInfo.FindString("name", &pkgName) != B_OK) - continue; - - // Find the PackageInfoRef - bool found = false; - for (int i = 0; i < packages.CountItems(); i++) { - const PackageInfoRef& package = packages.ItemAtFast(i); - if (pkgName == package->Name()) { - _PopulatePackageInfo(package, pkgInfo); - - // Store in cache - BFile file; - BPath path; - BString fileName(package->Name()); - fileName << ".info"; - if (_GetCacheFile(path, file, B_USER_CACHE_DIRECTORY, - "HaikuDepot", fileName, - B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE)) { - pkgInfo.Flatten(&file); - } - - packages.Remove(i); - found = true; - break; - } - } - if (!found) - printf("No matching package for %s\n", pkgName.String()); - } - } - } else { - printf("Error sending request: %s\n", strerror(status)); - int count = packages.CountItems(); - if (count >= 4) { - // Retry in smaller chunks - PackageList firstHalf; - PackageList secondHalf; - for (int i = 0; i < count / 2; i++) - firstHalf.Add(packages.ItemAtFast(i)); - for (int i = count / 2; i < count; i++) - secondHalf.Add(packages.ItemAtFast(i)); - packages.Clear(); - _PopulatePackageInfos(firstHalf, fromCacheOnly); - _PopulatePackageInfos(secondHalf, fromCacheOnly); - } else { - while (packages.CountItems() > 0) { - const PackageInfoRef& package = packages.ItemAtFast(0); - _PopulatePackageInfo(package, fromCacheOnly); - packages.Remove(0); - } - } - } - } - - if (packages.CountItems() > 0) { - uint32 count = 0; - bool debug_enabled = Logger::IsDebugEnabled(); - - for (int i = 0; i < packages.CountItems(); i++) { - const PackageInfoRef& package = packages.ItemAtFast(i); + if (depot.WebAppRepositorySourceCode().Length() > 0) { + _PopulatePackagesForDepot(depot); count++; - - if (debug_enabled) { - printf("No package info for %s\n", package->Name().String()); - } - } - - printf("No package info for %" B_PRIu32 " packages\n", count); - } -} - - -void -Model::_PopulatePackageInfo(const PackageInfoRef& package, bool fromCacheOnly) -{ - if (fromCacheOnly) - return; - - BString repositoryCode; - const DepotInfo* depot = DepotForName(package->DepotName()); - - if (depot != NULL) { - repositoryCode = depot->WebAppRepositoryCode(); - - if (repositoryCode.Length() > 0) { - // Retrieve info from web-app - BMessage info; - - status_t status = fWebAppInterface.RetrievePackageInfo( - package->Name(), package->Architecture(), repositoryCode, - info); - - if (status == B_OK) { - // Parse message - // info.PrintToStream(); - BMessage result; - if (info.FindMessage("result", &result) == B_OK) - _PopulatePackageInfo(package, result); - } - } else { - printf("unable to find the web app repository code for depot; %s\n", - package->DepotName().String()); - } - } else { - printf("no depot for name; %s\n", - package->DepotName().String()); - } -} - - -static void -append_word_list(BString& words, const char* word) -{ - if (words.Length() > 0) - words << ", "; - words << word; -} - - -void -Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data) -{ - bool debug_enabled = Logger::IsDebugEnabled(); - BAutolock locker(&fLock); - - BString foundInfo; - - BMessage versions; - if (data.FindMessage("versions", &versions) == B_OK) { - // Search a summary and description in the preferred language - int32 index = 0; - while (true) { - BString name; - name << index++; - BMessage version; - if (versions.FindMessage(name, &version) != B_OK) - break; - - BString title; - if (version.FindString("title", &title) == B_OK) { - package->SetTitle(title); - - if (debug_enabled) - append_word_list(foundInfo, "title"); - } - BString summary; - if (version.FindString("summary", &summary) == B_OK) { - package->SetShortDescription(summary); - - if (debug_enabled) - append_word_list(foundInfo, "summary"); - } - BString description; - if (version.FindString("description", &description) == B_OK) { - package->SetFullDescription(description); - - if (debug_enabled) - append_word_list(foundInfo, "description"); - } - double payloadLength; - if (version.FindDouble("payloadLength", &payloadLength) == B_OK) { - package->SetSize((int64)payloadLength); - - if (debug_enabled) - append_word_list(foundInfo, "size"); - } - break; } } - BMessage categories; - if (data.FindMessage("pkgCategoryCodes", &categories) == B_OK) { - bool foundCategory = false; - int32 index = 0; - while (true) { - BString name; - name << index++; - BString category; - if (categories.FindString(name, &category) != B_OK) - break; - - package->ClearCategories(); - 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 (debug_enabled && foundCategory) - append_word_list(foundInfo, "categories"); - } - - double derivedRating; - if (data.FindDouble("derivedRating", &derivedRating) == B_OK) { - RatingSummary summary; - summary.averageRating = derivedRating; - package->SetRatingSummary(summary); - - if (debug_enabled) - append_word_list(foundInfo, "rating"); - } - - double prominenceOrdering; - if (data.FindDouble("prominenceOrdering", &prominenceOrdering) == B_OK) { - package->SetProminence(prominenceOrdering); - - if (debug_enabled) - append_word_list(foundInfo, "prominence"); - } - - BString changelog; - if (data.FindString("pkgChangelogContent", &changelog) == B_OK) { - package->SetChangelog(changelog); - - if (debug_enabled) - append_word_list(foundInfo, "changelog"); - } - - BMessage screenshots; - if (data.FindMessage("pkgScreenshots", &screenshots) == B_OK) { - package->ClearScreenshotInfos(); - 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 (debug_enabled && foundScreenshot) - append_word_list(foundInfo, "screenshots"); - } - - if (debug_enabled && foundInfo.Length() > 0) { - printf("Populated package info for %s: %s\n", - package->Name().String(), foundInfo.String()); - } - - // If the user already clicked this package, remove it from the - // list of populated packages, so that clicking it again will - // populate any additional information. - // TODO: Trigger re-populating if the package is currently showing. - fPopulatedPackages.Remove(package); + printf("did populate package data for %" B_PRIi32 " depots\n", count); } diff --git a/src/apps/haikudepot/model/Model.h b/src/apps/haikudepot/model/Model.h index ba73bfcf2d..0394e83b60 100644 --- a/src/apps/haikudepot/model/Model.h +++ b/src/apps/haikudepot/model/Model.h @@ -153,10 +153,14 @@ public: private: status_t _DumpExportRepositoryDataPath( BPath& path) const; + status_t _DumpExportPkgDataPath(BPath& path, + const BString& repositorySourceCode) const; void _UpdateIsFeaturedFilter(); static int32 _PopulateAllPackagesEntry(void* cookie); - void _PopulateAllPackagesThread(bool fromCacheOnly); + void _PopulateAllPackagesThread(); + void _PopulatePackagesForDepot( + const DepotInfo& depotInfo); void _PopulateAllPackagesIcons(); @@ -171,15 +175,6 @@ private: const char* fileName, bool ignoreAge, time_t maxAge) const; - void _PopulatePackageInfos( - PackageList& packages, - bool fromCacheOnly); - void _PopulatePackageInfo( - const PackageInfoRef& package, - bool fromCacheOnly); - void _PopulatePackageInfo( - const PackageInfoRef& package, - const BMessage& data); status_t _PopulatePackageIcon( const PackageInfoRef& package); void _PopulatePackageScreenshot( diff --git a/src/apps/haikudepot/model/PackageInfo.cpp b/src/apps/haikudepot/model/PackageInfo.cpp index f19d8f9673..2e7e2e99d0 100644 --- a/src/apps/haikudepot/model/PackageInfo.cpp +++ b/src/apps/haikudepot/model/PackageInfo.cpp @@ -1000,7 +1000,8 @@ DepotInfo::DepotInfo(const BString& name) : fName(name), fPackages(), - fWebAppRepositoryCode() + fWebAppRepositoryCode(), + fWebAppRepositorySourceCode() { } @@ -1010,6 +1011,7 @@ DepotInfo::DepotInfo(const DepotInfo& other) fName(other.fName), fPackages(other.fPackages), fWebAppRepositoryCode(other.fWebAppRepositoryCode), + fWebAppRepositorySourceCode(other.fWebAppRepositorySourceCode), fBaseURL(other.fBaseURL) { } @@ -1022,6 +1024,7 @@ DepotInfo::operator=(const DepotInfo& other) fPackages = other.fPackages; fBaseURL = other.fBaseURL; fWebAppRepositoryCode = other.fWebAppRepositoryCode; + fWebAppRepositorySourceCode = other.fWebAppRepositorySourceCode; return *this; } diff --git a/src/apps/haikudepot/server/PkgDataUpdateProcess.cpp b/src/apps/haikudepot/server/PkgDataUpdateProcess.cpp new file mode 100644 index 0000000000..cafaaf041b --- /dev/null +++ b/src/apps/haikudepot/server/PkgDataUpdateProcess.cpp @@ -0,0 +1,275 @@ +/* + * Copyright 2017, Andrew Lindesay . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include "PkgDataUpdateProcess.h" + +#include +#include +#include + +#include +#include +#include + +#include "Logger.h" +#include "ServerSettings.h" +#include "StorageUtils.h" +#include "DumpExportPkg.h" +#include "DumpExportPkgCategory.h" +#include "DumpExportPkgJsonListener.h" +#include "DumpExportPkgScreenshot.h" +#include "DumpExportPkgVersion.h" + + +/*! This package listener (not at the JSON level) is feeding in the + packages as they are parsed and processing them. +*/ + +class PackageFillingPkgListener : public DumpExportPkgListener { +public: + PackageFillingPkgListener( + const PackageList& packages, + const CategoryList& categories, + BLocker& lock); + virtual ~PackageFillingPkgListener(); + + virtual void Handle(DumpExportPkg* item); + virtual void Complete(); + +private: + int32 IndexOfPackageByName(const BString& name) const; + int32 IndexOfCategoryByName( + const BString& name) const; + int32 IndexOfCategoryByCode( + const BString& code) const; + const PackageList& fPackages; + const CategoryList& fCategories; + BLocker& fLock; + + +}; + + +PackageFillingPkgListener::PackageFillingPkgListener( + const PackageList& packages, const CategoryList& categories, + BLocker& lock) + : + fPackages(packages), + fCategories(categories), + fLock(lock) +{ +} + + +PackageFillingPkgListener::~PackageFillingPkgListener() +{ +} + + + // TODO; performance could be improved by not needing the linear search + +int32 +PackageFillingPkgListener::IndexOfPackageByName( + const BString& name) const +{ + int32 i; + + for (i = 0; i < fPackages.CountItems(); i++) { + const PackageInfoRef& packageInfo = fPackages.ItemAt(i); + + if (packageInfo->Name() == name) + return i; + } + + return -1; +} + + + // TODO; performance could be improved by not needing the linear search + +int32 +PackageFillingPkgListener::IndexOfCategoryByName( + const BString& name) const +{ + int32 i; + + for (i = 0; i < fCategories.CountItems(); i++) { + const CategoryRef categoryRef = fCategories.ItemAtFast(i); + + if (categoryRef->Name() == name) + return i; + } + + return -1; +} + + +void +PackageFillingPkgListener::Handle(DumpExportPkg* pkg) +{ + BAutolock locker(fLock); // lock from the model. + int32 packageIndex = IndexOfPackageByName(*(pkg->Name())); + + if (packageIndex == -1) { + printf("unable to find package data for pkg name [%s]\n", + pkg->Name()->String()); + } else { + int32 i; + const PackageInfoRef& packageInfo = fPackages.ItemAt(packageIndex); + + if (0 != pkg->CountPkgVersions()) { + + // this makes the assumption that the only version will be the + // latest one. + + DumpExportPkgVersion* pkgVersion = pkg->PkgVersionsItemAt(0); + + if (!pkgVersion->TitleIsNull()) + packageInfo->SetTitle(*(pkgVersion->Title())); + + if (!pkgVersion->SummaryIsNull()) + packageInfo->SetShortDescription(*(pkgVersion->Summary())); + + if (!pkgVersion->DescriptionIsNull()) { + packageInfo->SetFullDescription(*(pkgVersion->Description())); + } + + if (!pkgVersion->PayloadLengthIsNull()) + packageInfo->SetSize(pkgVersion->PayloadLength()); + } + + for (i = 0; i < pkg->CountPkgCategories(); i++) { + BString* categoryCode = pkg->PkgCategoriesItemAt(i)->Code(); + int categoryIndex = IndexOfCategoryByName(*(categoryCode)); + + if (categoryIndex == -1) { + printf("unable to find the category for [%s]\n", + categoryCode->String()); + } else { + packageInfo->AddCategory(fCategories.ItemAtFast(i)); + } + } + + if (!pkg->DerivedRatingIsNull()) { + RatingSummary summary; + summary.averageRating = pkg->DerivedRating(); + packageInfo->SetRatingSummary(summary); + } + + if (!pkg->ProminenceOrderingIsNull()) { + packageInfo->SetProminence(pkg->ProminenceOrdering()); + } + + if (!pkg->PkgChangelogContentIsNull()) { + packageInfo->SetChangelog(*(pkg->PkgChangelogContent())); + } + + for (i = 0; i < pkg->CountPkgScreenshots(); i++) { + DumpExportPkgScreenshot* screenshot = pkg->PkgScreenshotsItemAt(i); + packageInfo->AddScreenshotInfo(ScreenshotInfo( + *(screenshot->Code()), + static_cast(screenshot->Width()), + static_cast(screenshot->Height()), + static_cast(screenshot->Length()) + )); + } + + if (Logger::IsDebugEnabled()) { + printf("did populate data for [%s]\n", pkg->Name()->String()); + } + } +} + + +void +PackageFillingPkgListener::Complete() +{ +} + + +PkgDataUpdateProcess::PkgDataUpdateProcess( + const BPath& localFilePath, + BLocker& lock, + BString repositorySourceCode, + BString naturalLanguageCode, + const PackageList& packages, + const CategoryList& categories) + : + fLocalFilePath(localFilePath), + fNaturalLanguageCode(naturalLanguageCode), + fRepositorySourceCode(repositorySourceCode), + fPackages(packages), + fCategories(categories), + fLock(lock) +{ +} + + +PkgDataUpdateProcess::~PkgDataUpdateProcess() +{ +} + + +status_t +PkgDataUpdateProcess::Run() +{ + printf("will fetch packages' data\n"); + + BString urlPath; + urlPath.SetToFormat("/__pkg/all-%s-%s.json.gz", + fRepositorySourceCode.String(), + fNaturalLanguageCode.String()); + + status_t result = DownloadToLocalFile(fLocalFilePath, + ServerSettings::CreateFullUrl(urlPath), + 0, 0); + + if (result == B_OK || result == APP_ERR_NOT_MODIFIED) { + printf("did fetch packages' data\n"); + + // now load the data in and process it. + + printf("will process packages' data\n"); + result = PopulateDataToDepots(); + printf("did process packages' data\n"); + } + + return result; +} + + +status_t +PkgDataUpdateProcess::PopulateDataToDepots() +{ + PackageFillingPkgListener* itemListener = + new PackageFillingPkgListener(fPackages, fCategories, fLock); + + BJsonEventListener* listener = + new BulkContainerDumpExportPkgJsonListener(itemListener); + + return ParseJsonFromFileWithListener(listener, fLocalFilePath); +} + + +void +PkgDataUpdateProcess::GetStandardMetaDataPath(BPath& path) const +{ + path.SetTo(fLocalFilePath.Path()); +} + + +void +PkgDataUpdateProcess::GetStandardMetaDataJsonPath( + BString& jsonPath) const +{ + jsonPath.SetTo("$.info"); +} + + +const char* +PkgDataUpdateProcess::LoggingName() const +{ + return "pkg-data-update"; +} \ No newline at end of file diff --git a/src/apps/haikudepot/server/PkgDataUpdateProcess.h b/src/apps/haikudepot/server/PkgDataUpdateProcess.h new file mode 100644 index 0000000000..749783acfc --- /dev/null +++ b/src/apps/haikudepot/server/PkgDataUpdateProcess.h @@ -0,0 +1,51 @@ +/* + * Copyright 2017, Andrew Lindesay . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#ifndef PACKAGE_DATA_UPDATE_PROCESS_H +#define PACKAGE_DATA_UPDATE_PROCESS_H + + +#include "AbstractServerProcess.h" + +#include "PackageInfo.h" + +#include +#include +#include +#include + + +class PkgDataUpdateProcess : public AbstractServerProcess { +public: + PkgDataUpdateProcess( + const BPath& localFilePath, + BLocker& lock, + BString naturalLanguageCode, + BString repositorySourceCode, + const PackageList& packages, + const CategoryList& categories); + virtual ~PkgDataUpdateProcess(); + + status_t Run(); + +protected: + void GetStandardMetaDataPath(BPath& path) const; + void GetStandardMetaDataJsonPath( + BString& jsonPath) const; + const char* LoggingName() const; + +private: + status_t PopulateDataToDepots(); + + BPath fLocalFilePath; + BString fNaturalLanguageCode; + BString fRepositorySourceCode; + const PackageList& fPackages; + const CategoryList& fCategories; + BLocker& fLock; + +}; + +#endif // PACKAGE_DATA_UPDATE_PROCESS_H diff --git a/src/apps/haikudepot/server/RepositoryDataUpdateProcess.cpp b/src/apps/haikudepot/server/RepositoryDataUpdateProcess.cpp index 5fccdb2ac2..cee773405d 100644 --- a/src/apps/haikudepot/server/RepositoryDataUpdateProcess.cpp +++ b/src/apps/haikudepot/server/RepositoryDataUpdateProcess.cpp @@ -78,7 +78,7 @@ DepotMatchingRepositoryListener::IsUnassociatedDepotByUrl( const DepotInfo& depotInfo, const BString& urlStr) const { if (depotInfo.BaseURL().Length() > 0 - && depotInfo.WebAppRepositoryCode().Length() == 0) { + && depotInfo.WebAppRepositorySourceCode().Length() == 0) { BUrl depotInfoBaseUrl(depotInfo.BaseURL()); BUrl url(urlStr); @@ -129,7 +129,7 @@ DepotMatchingRepositoryListener::Handle(DumpExportRepository* repository) BString(*(repositorySource->Code()))); fDepotList->Replace(depotIndex, modifiedDepotInfo); - printf("associated depot [%s] with haiku depot server" + printf("associated depot [%s] with server" " repository source [%s]\n", modifiedDepotInfo.Name().String(), repositorySource->Code()->String()); } @@ -182,7 +182,7 @@ RepositoryDataUpdateProcess::Run() ServerSettings::CreateFullUrl("/__repository/all-en.json.gz"), 0, 0); - if (result == B_OK) { + if (result == B_OK || result == APP_ERR_NOT_MODIFIED) { printf("did fetch repositories data\n"); // now load the data in and process it. @@ -190,6 +190,8 @@ RepositoryDataUpdateProcess::Run() printf("will process repository data and match to depots\n"); result = PopulateDataToDepots(); printf("did process repository data and match to depots\n"); + } else { + printf("an error has arisen downloading the repositories' data\n"); } return result; diff --git a/src/apps/haikudepot/server/RepositoryDataUpdateProcess.h b/src/apps/haikudepot/server/RepositoryDataUpdateProcess.h index 3e902a9bd2..1226a2aff4 100644 --- a/src/apps/haikudepot/server/RepositoryDataUpdateProcess.h +++ b/src/apps/haikudepot/server/RepositoryDataUpdateProcess.h @@ -41,4 +41,4 @@ private: }; -#endif // SERVER_ICON_EXPORT_UPDATE_PROCESS_H +#endif // REPOSITORY_DATA_UPDATE_PROCESS_H diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkg.cpp b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkg.cpp new file mode 100644 index 0000000000..1cdf2d912f --- /dev/null +++ b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkg.cpp @@ -0,0 +1,345 @@ +/* + * Generated Model Object + * source json-schema : dumpexport.json + * generated at : 2017-11-05T22:30:10.254264 + */ +#include "DumpExportPkg.h" + + +DumpExportPkg::DumpExportPkg() +{ + fPkgChangelogContent = NULL; + fName = NULL; + fPkgVersions = NULL; + fDerivedRating = NULL; + fPkgScreenshots = NULL; + fProminenceOrdering = NULL; + fPkgCategories = NULL; + fModifyTimestamp = NULL; +} + + +DumpExportPkg::~DumpExportPkg() +{ + int32 i; + + if (fPkgChangelogContent != NULL) { + delete fPkgChangelogContent; + } + + if (fName != NULL) { + delete fName; + } + + if (fPkgVersions != NULL) { + int32 count = fPkgVersions->CountItems(); + for (i = 0; i < count; i++) + delete fPkgVersions->ItemAt(i); + delete fPkgVersions; + } + + if (fDerivedRating != NULL) { + delete fDerivedRating; + } + + if (fPkgScreenshots != NULL) { + int32 count = fPkgScreenshots->CountItems(); + for (i = 0; i < count; i++) + delete fPkgScreenshots->ItemAt(i); + delete fPkgScreenshots; + } + + if (fProminenceOrdering != NULL) { + delete fProminenceOrdering; + } + + if (fPkgCategories != NULL) { + int32 count = fPkgCategories->CountItems(); + for (i = 0; i < count; i++) + delete fPkgCategories->ItemAt(i); + delete fPkgCategories; + } + + if (fModifyTimestamp != NULL) { + delete fModifyTimestamp; + } + +} + +BString* +DumpExportPkg::PkgChangelogContent() +{ + return fPkgChangelogContent; +} + + +void +DumpExportPkg::SetPkgChangelogContent(BString* value) +{ + fPkgChangelogContent = value; +} + + +void +DumpExportPkg::SetPkgChangelogContentNull() +{ + if (!PkgChangelogContentIsNull()) { + delete fPkgChangelogContent; + fPkgChangelogContent = NULL; + } +} + + +bool +DumpExportPkg::PkgChangelogContentIsNull() +{ + return fPkgChangelogContent == NULL; +} + + +BString* +DumpExportPkg::Name() +{ + return fName; +} + + +void +DumpExportPkg::SetName(BString* value) +{ + fName = value; +} + + +void +DumpExportPkg::SetNameNull() +{ + if (!NameIsNull()) { + delete fName; + fName = NULL; + } +} + + +bool +DumpExportPkg::NameIsNull() +{ + return fName == NULL; +} + + +void +DumpExportPkg::AddToPkgVersions(DumpExportPkgVersion* value) +{ + if (fPkgVersions == NULL) + fPkgVersions = new List(); + fPkgVersions->Add(value); +} + + +void +DumpExportPkg::SetPkgVersions(List* value) +{ + fPkgVersions = value; +} + + +int32 +DumpExportPkg::CountPkgVersions() +{ + if (fPkgVersions == NULL) + return 0; + return fPkgVersions->CountItems(); +} + + +DumpExportPkgVersion* +DumpExportPkg::PkgVersionsItemAt(int32 index) +{ + return fPkgVersions->ItemAt(index); +} + + +bool +DumpExportPkg::PkgVersionsIsNull() +{ + return fPkgVersions == NULL; +} + + +double +DumpExportPkg::DerivedRating() +{ + return *fDerivedRating; +} + + +void +DumpExportPkg::SetDerivedRating(double value) +{ + if (DerivedRatingIsNull()) + fDerivedRating = new double[1]; + fDerivedRating[0] = value; +} + + +void +DumpExportPkg::SetDerivedRatingNull() +{ + if (!DerivedRatingIsNull()) { + delete fDerivedRating; + fDerivedRating = NULL; + } +} + + +bool +DumpExportPkg::DerivedRatingIsNull() +{ + return fDerivedRating == NULL; +} + + +void +DumpExportPkg::AddToPkgScreenshots(DumpExportPkgScreenshot* value) +{ + if (fPkgScreenshots == NULL) + fPkgScreenshots = new List(); + fPkgScreenshots->Add(value); +} + + +void +DumpExportPkg::SetPkgScreenshots(List* value) +{ + fPkgScreenshots = value; +} + + +int32 +DumpExportPkg::CountPkgScreenshots() +{ + if (fPkgScreenshots == NULL) + return 0; + return fPkgScreenshots->CountItems(); +} + + +DumpExportPkgScreenshot* +DumpExportPkg::PkgScreenshotsItemAt(int32 index) +{ + return fPkgScreenshots->ItemAt(index); +} + + +bool +DumpExportPkg::PkgScreenshotsIsNull() +{ + return fPkgScreenshots == NULL; +} + + +int64 +DumpExportPkg::ProminenceOrdering() +{ + return *fProminenceOrdering; +} + + +void +DumpExportPkg::SetProminenceOrdering(int64 value) +{ + if (ProminenceOrderingIsNull()) + fProminenceOrdering = new int64[1]; + fProminenceOrdering[0] = value; +} + + +void +DumpExportPkg::SetProminenceOrderingNull() +{ + if (!ProminenceOrderingIsNull()) { + delete fProminenceOrdering; + fProminenceOrdering = NULL; + } +} + + +bool +DumpExportPkg::ProminenceOrderingIsNull() +{ + return fProminenceOrdering == NULL; +} + + +void +DumpExportPkg::AddToPkgCategories(DumpExportPkgCategory* value) +{ + if (fPkgCategories == NULL) + fPkgCategories = new List(); + fPkgCategories->Add(value); +} + + +void +DumpExportPkg::SetPkgCategories(List* value) +{ + fPkgCategories = value; +} + + +int32 +DumpExportPkg::CountPkgCategories() +{ + if (fPkgCategories == NULL) + return 0; + return fPkgCategories->CountItems(); +} + + +DumpExportPkgCategory* +DumpExportPkg::PkgCategoriesItemAt(int32 index) +{ + return fPkgCategories->ItemAt(index); +} + + +bool +DumpExportPkg::PkgCategoriesIsNull() +{ + return fPkgCategories == NULL; +} + + +int64 +DumpExportPkg::ModifyTimestamp() +{ + return *fModifyTimestamp; +} + + +void +DumpExportPkg::SetModifyTimestamp(int64 value) +{ + if (ModifyTimestampIsNull()) + fModifyTimestamp = new int64[1]; + fModifyTimestamp[0] = value; +} + + +void +DumpExportPkg::SetModifyTimestampNull() +{ + if (!ModifyTimestampIsNull()) { + delete fModifyTimestamp; + fModifyTimestamp = NULL; + } +} + + +bool +DumpExportPkg::ModifyTimestampIsNull() +{ + return fModifyTimestamp == NULL; +} + diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkg.h b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkg.h new file mode 100644 index 0000000000..c3b6648ed6 --- /dev/null +++ b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkg.h @@ -0,0 +1,79 @@ +/* + * Generated Model Object + * source json-schema : dumpexport.json + * generated at : 2017-11-05T22:30:10.253178 + */ + +#ifndef GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKG_H +#define GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKG_H + +#include "List.h" +#include "String.h" + +#include "DumpExportPkgVersion.h" +#include "DumpExportPkgScreenshot.h" +#include "DumpExportPkgCategory.h" + +class DumpExportPkg { +public: + DumpExportPkg(); + virtual ~DumpExportPkg(); + + BString* PkgChangelogContent(); + void SetPkgChangelogContent(BString* value); + void SetPkgChangelogContentNull(); + bool PkgChangelogContentIsNull(); + + BString* Name(); + void SetName(BString* value); + void SetNameNull(); + bool NameIsNull(); + + void AddToPkgVersions(DumpExportPkgVersion* value); + void SetPkgVersions(List* value); + int32 CountPkgVersions(); + DumpExportPkgVersion* PkgVersionsItemAt(int32 index); + bool PkgVersionsIsNull(); + + + double DerivedRating(); + void SetDerivedRating(double value); + void SetDerivedRatingNull(); + bool DerivedRatingIsNull(); + + void AddToPkgScreenshots(DumpExportPkgScreenshot* value); + void SetPkgScreenshots(List* value); + int32 CountPkgScreenshots(); + DumpExportPkgScreenshot* PkgScreenshotsItemAt(int32 index); + bool PkgScreenshotsIsNull(); + + + int64 ProminenceOrdering(); + void SetProminenceOrdering(int64 value); + void SetProminenceOrderingNull(); + bool ProminenceOrderingIsNull(); + + void AddToPkgCategories(DumpExportPkgCategory* value); + void SetPkgCategories(List* value); + int32 CountPkgCategories(); + DumpExportPkgCategory* PkgCategoriesItemAt(int32 index); + bool PkgCategoriesIsNull(); + + + int64 ModifyTimestamp(); + void SetModifyTimestamp(int64 value); + void SetModifyTimestampNull(); + bool ModifyTimestampIsNull(); + +private: + BString* fPkgChangelogContent; + BString* fName; + List * fPkgVersions; + double* fDerivedRating; + List * fPkgScreenshots; + int64* fProminenceOrdering; + List * fPkgCategories; + int64* fModifyTimestamp; +}; + +#endif // GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKG_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgCategory.cpp b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgCategory.cpp new file mode 100644 index 0000000000..d60355df2c --- /dev/null +++ b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgCategory.cpp @@ -0,0 +1,52 @@ +/* + * Generated Model Object + * source json-schema : dumpexport.json + * generated at : 2017-11-05T22:30:10.260503 + */ +#include "DumpExportPkgCategory.h" + + +DumpExportPkgCategory::DumpExportPkgCategory() +{ + fCode = NULL; +} + + +DumpExportPkgCategory::~DumpExportPkgCategory() +{ + if (fCode != NULL) { + delete fCode; + } + +} + +BString* +DumpExportPkgCategory::Code() +{ + return fCode; +} + + +void +DumpExportPkgCategory::SetCode(BString* value) +{ + fCode = value; +} + + +void +DumpExportPkgCategory::SetCodeNull() +{ + if (!CodeIsNull()) { + delete fCode; + fCode = NULL; + } +} + + +bool +DumpExportPkgCategory::CodeIsNull() +{ + return fCode == NULL; +} + diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgCategory.h b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgCategory.h new file mode 100644 index 0000000000..77dacb3899 --- /dev/null +++ b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgCategory.h @@ -0,0 +1,28 @@ +/* + * Generated Model Object + * source json-schema : dumpexport.json + * generated at : 2017-11-05T22:30:10.259170 + */ + +#ifndef GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGCATEGORY_H +#define GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGCATEGORY_H + +#include "List.h" +#include "String.h" + + +class DumpExportPkgCategory { +public: + DumpExportPkgCategory(); + virtual ~DumpExportPkgCategory(); + + BString* Code(); + void SetCode(BString* value); + void SetCodeNull(); + bool CodeIsNull(); + +private: + BString* fCode; +}; + +#endif // GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGCATEGORY_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgJsonListener.cpp b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgJsonListener.cpp new file mode 100644 index 0000000000..f1fa7a6838 --- /dev/null +++ b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgJsonListener.cpp @@ -0,0 +1,1318 @@ +/* + * Generated Listener Object + * source json-schema : dumpexport.json + * generated at : 2017-11-11T14:09:03.498648 + */ +#include "DumpExportPkgJsonListener.h" +#include "List.h" + +#include + +// #pragma mark - private interfaces for the stacked listeners + + +/*! This class is the top level of the stacked listeners. The stack structure + is maintained in a linked list and sub-classes implement specific behaviors + depending where in the parse tree the stacked listener is working at. +*/ +class AbstractStackedDumpExportPkgJsonListener : public BJsonEventListener { +public: + AbstractStackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent); + ~AbstractStackedDumpExportPkgJsonListener(); + + void HandleError(status_t status, int32 line, const char* message); + void Complete(); + + status_t ErrorStatus(); + + AbstractStackedDumpExportPkgJsonListener* Parent(); + + virtual void WillPop(); + +protected: + AbstractMainDumpExportPkgJsonListener* fMainListener; + + void Pop(); + void Push(AbstractStackedDumpExportPkgJsonListener* stackedListener); + +private: + AbstractStackedDumpExportPkgJsonListener* fParent; +}; + +class GeneralArrayStackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { +public: + GeneralArrayStackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent); + ~GeneralArrayStackedDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); +}; + +class GeneralObjectStackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { +public: + GeneralObjectStackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent); + ~GeneralObjectStackedDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); +}; + +class DumpExportPkg_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { +public: + DumpExportPkg_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent); + ~DumpExportPkg_StackedDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); + + DumpExportPkg* Target(); + +protected: + DumpExportPkg* fTarget; + BString fNextItemName; +}; + +class DumpExportPkg_List_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { +public: + DumpExportPkg_List_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent); + ~DumpExportPkg_List_StackedDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); + + List* Target(); // list of %s pointers + +private: + List* fTarget; +}; + +class DumpExportPkgVersion_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { +public: + DumpExportPkgVersion_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent); + ~DumpExportPkgVersion_StackedDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); + + DumpExportPkgVersion* Target(); + +protected: + DumpExportPkgVersion* fTarget; + BString fNextItemName; +}; + +class DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { +public: + DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent); + ~DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); + + List* Target(); // list of %s pointers + +private: + List* fTarget; +}; + +class DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { +public: + DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent); + ~DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); + + DumpExportPkgScreenshot* Target(); + +protected: + DumpExportPkgScreenshot* fTarget; + BString fNextItemName; +}; + +class DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { +public: + DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent); + ~DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); + + List* Target(); // list of %s pointers + +private: + List* fTarget; +}; + +class DumpExportPkgCategory_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { +public: + DumpExportPkgCategory_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent); + ~DumpExportPkgCategory_StackedDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); + + DumpExportPkgCategory* Target(); + +protected: + DumpExportPkgCategory* fTarget; + BString fNextItemName; +}; + +class DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { +public: + DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent); + ~DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); + + List* Target(); // list of %s pointers + +private: + List* fTarget; +}; + +class ItemEmittingStackedDumpExportPkgJsonListener : public DumpExportPkg_StackedDumpExportPkgJsonListener { +public: + ItemEmittingStackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent, + DumpExportPkgListener* itemListener); + ~ItemEmittingStackedDumpExportPkgJsonListener(); + + void WillPop(); + +private: + DumpExportPkgListener* fItemListener; +}; + + +class BulkContainerStackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { +public: + BulkContainerStackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent, + DumpExportPkgListener* itemListener); + ~BulkContainerStackedDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); + +private: + BString fNextItemName; + DumpExportPkgListener* fItemListener; +}; + + +class BulkContainerItemsStackedDumpExportPkgJsonListener : public AbstractStackedDumpExportPkgJsonListener { +public: + BulkContainerItemsStackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent, + DumpExportPkgListener* itemListener); + ~BulkContainerItemsStackedDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); + void WillPop(); + +private: + DumpExportPkgListener* fItemListener; +}; +// #pragma mark - implementations for the stacked listeners + + +AbstractStackedDumpExportPkgJsonListener::AbstractStackedDumpExportPkgJsonListener ( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent) +{ + fMainListener = mainListener; + fParent = parent; +} + +AbstractStackedDumpExportPkgJsonListener::~AbstractStackedDumpExportPkgJsonListener() +{ +} + +void +AbstractStackedDumpExportPkgJsonListener::HandleError(status_t status, int32 line, const char* message) +{ + fMainListener->HandleError(status, line, message); +} + +void +AbstractStackedDumpExportPkgJsonListener::Complete() +{ + fMainListener->Complete(); +} + +status_t +AbstractStackedDumpExportPkgJsonListener::ErrorStatus() +{ + return fMainListener->ErrorStatus(); +} + +AbstractStackedDumpExportPkgJsonListener* +AbstractStackedDumpExportPkgJsonListener::Parent() +{ + return fParent; +} + +void +AbstractStackedDumpExportPkgJsonListener::Push(AbstractStackedDumpExportPkgJsonListener* stackedListener) +{ + fMainListener->SetStackedListener(stackedListener); +} + +void +AbstractStackedDumpExportPkgJsonListener::WillPop() +{ +} + +void +AbstractStackedDumpExportPkgJsonListener::Pop() +{ + WillPop(); + fMainListener->SetStackedListener(fParent); +} + +GeneralObjectStackedDumpExportPkgJsonListener::GeneralObjectStackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent) + : + AbstractStackedDumpExportPkgJsonListener(mainListener, parent) +{ +} + +GeneralObjectStackedDumpExportPkgJsonListener::~GeneralObjectStackedDumpExportPkgJsonListener() +{ +} + +bool +GeneralObjectStackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_OBJECT_NAME: + case B_JSON_NUMBER: + case B_JSON_STRING: + case B_JSON_TRUE: + case B_JSON_FALSE: + case B_JSON_NULL: + // ignore + break; + + case B_JSON_OBJECT_START: + Push(new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this)); + break; + + case B_JSON_ARRAY_START: + Push(new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this)); + break; + + case B_JSON_ARRAY_END: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected end of array"); + break; + + case B_JSON_OBJECT_END: + Pop(); + delete this; + break; + + } + + return ErrorStatus() == B_OK; +} + +GeneralArrayStackedDumpExportPkgJsonListener::GeneralArrayStackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent) + : + AbstractStackedDumpExportPkgJsonListener(mainListener, parent) +{ +} + +GeneralArrayStackedDumpExportPkgJsonListener::~GeneralArrayStackedDumpExportPkgJsonListener() +{ +} + +bool +GeneralArrayStackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_OBJECT_NAME: + case B_JSON_NUMBER: + case B_JSON_STRING: + case B_JSON_TRUE: + case B_JSON_FALSE: + case B_JSON_NULL: + // ignore + break; + + case B_JSON_OBJECT_START: + Push(new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this)); + break; + + case B_JSON_ARRAY_START: + Push(new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this)); + break; + + case B_JSON_OBJECT_END: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected end of object"); + break; + + case B_JSON_ARRAY_END: + Pop(); + delete this; + break; + + } + + return ErrorStatus() == B_OK; +} + +DumpExportPkg_StackedDumpExportPkgJsonListener::DumpExportPkg_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent) + : + AbstractStackedDumpExportPkgJsonListener(mainListener, parent) +{ + fTarget = new DumpExportPkg(); +} + + +DumpExportPkg_StackedDumpExportPkgJsonListener::~DumpExportPkg_StackedDumpExportPkgJsonListener() +{ +} + + +DumpExportPkg* +DumpExportPkg_StackedDumpExportPkgJsonListener::Target() +{ + return fTarget; +} + + +bool +DumpExportPkg_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_ARRAY_END: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); + break; + + case B_JSON_OBJECT_NAME: + fNextItemName = event.Content(); + break; + + case B_JSON_OBJECT_END: + Pop(); + delete this; + break; + + case B_JSON_STRING: + + if (fNextItemName == "pkgChangelogContent") + fTarget->SetPkgChangelogContent(new BString(event.Content())); + + if (fNextItemName == "name") + fTarget->SetName(new BString(event.Content())); + fNextItemName.SetTo(""); + break; + case B_JSON_TRUE: + fNextItemName.SetTo(""); + break; + case B_JSON_FALSE: + fNextItemName.SetTo(""); + break; + case B_JSON_NULL: + { + + if (fNextItemName == "pkgChangelogContent") + fTarget->SetPkgChangelogContentNull(); + + if (fNextItemName == "name") + fTarget->SetNameNull(); + + if (fNextItemName == "derivedRating") + fTarget->SetDerivedRatingNull(); + + if (fNextItemName == "prominenceOrdering") + fTarget->SetProminenceOrderingNull(); + + if (fNextItemName == "modifyTimestamp") + fTarget->SetModifyTimestampNull(); + fNextItemName.SetTo(""); + break; + } + case B_JSON_NUMBER: + { + + if (fNextItemName == "derivedRating") + fTarget->SetDerivedRating(event.ContentDouble()); + + if (fNextItemName == "prominenceOrdering") + fTarget->SetProminenceOrdering(event.ContentInteger()); + + if (fNextItemName == "modifyTimestamp") + fTarget->SetModifyTimestamp(event.ContentInteger()); + fNextItemName.SetTo(""); + break; + } + case B_JSON_OBJECT_START: + { + if (1 == 1) { + GeneralObjectStackedDumpExportPkgJsonListener* nextListener = new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this); + Push(nextListener); + } + fNextItemName.SetTo(""); + break; + } + case B_JSON_ARRAY_START: + { + if (fNextItemName == "pkgVersions") { + DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener* nextListener = new DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener(fMainListener, this); + fTarget->SetPkgVersions(nextListener->Target()); + Push(nextListener); + } + else if (fNextItemName == "pkgScreenshots") { + DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener* nextListener = new DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener(fMainListener, this); + fTarget->SetPkgScreenshots(nextListener->Target()); + Push(nextListener); + } + else if (fNextItemName == "pkgCategories") { + DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener* nextListener = new DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener(fMainListener, this); + fTarget->SetPkgCategories(nextListener->Target()); + Push(nextListener); + } + else if (1 == 1) { + AbstractStackedDumpExportPkgJsonListener* nextListener = new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this); + Push(nextListener); + } + fNextItemName.SetTo(""); + break; + } + + } + + return ErrorStatus() == B_OK; +} + +DumpExportPkg_List_StackedDumpExportPkgJsonListener::DumpExportPkg_List_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent) + : + AbstractStackedDumpExportPkgJsonListener(mainListener, parent) +{ + fTarget = new List(); +} + + +DumpExportPkg_List_StackedDumpExportPkgJsonListener::~DumpExportPkg_List_StackedDumpExportPkgJsonListener() +{ +} + + +List* +DumpExportPkg_List_StackedDumpExportPkgJsonListener::Target() +{ + return fTarget; +} + + +bool +DumpExportPkg_List_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_ARRAY_END: + Pop(); + delete this; + break; + + case B_JSON_OBJECT_START: + { + DumpExportPkg_StackedDumpExportPkgJsonListener* nextListener = + new DumpExportPkg_StackedDumpExportPkgJsonListener(fMainListener, this); + fTarget->Add(nextListener->Target()); + Push(nextListener); + break; + } + + default: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, + "illegal state - unexpected json event parsing an array of DumpExportPkg"); + break; + } + + return ErrorStatus() == B_OK; +} + +DumpExportPkgVersion_StackedDumpExportPkgJsonListener::DumpExportPkgVersion_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent) + : + AbstractStackedDumpExportPkgJsonListener(mainListener, parent) +{ + fTarget = new DumpExportPkgVersion(); +} + + +DumpExportPkgVersion_StackedDumpExportPkgJsonListener::~DumpExportPkgVersion_StackedDumpExportPkgJsonListener() +{ +} + + +DumpExportPkgVersion* +DumpExportPkgVersion_StackedDumpExportPkgJsonListener::Target() +{ + return fTarget; +} + + +bool +DumpExportPkgVersion_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_ARRAY_END: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); + break; + + case B_JSON_OBJECT_NAME: + fNextItemName = event.Content(); + break; + + case B_JSON_OBJECT_END: + Pop(); + delete this; + break; + + case B_JSON_STRING: + + if (fNextItemName == "major") + fTarget->SetMajor(new BString(event.Content())); + + if (fNextItemName == "description") + fTarget->SetDescription(new BString(event.Content())); + + if (fNextItemName == "title") + fTarget->SetTitle(new BString(event.Content())); + + if (fNextItemName == "summary") + fTarget->SetSummary(new BString(event.Content())); + + if (fNextItemName == "micro") + fTarget->SetMicro(new BString(event.Content())); + + if (fNextItemName == "preRelease") + fTarget->SetPreRelease(new BString(event.Content())); + + if (fNextItemName == "architectureCode") + fTarget->SetArchitectureCode(new BString(event.Content())); + + if (fNextItemName == "minor") + fTarget->SetMinor(new BString(event.Content())); + fNextItemName.SetTo(""); + break; + case B_JSON_TRUE: + fNextItemName.SetTo(""); + break; + case B_JSON_FALSE: + fNextItemName.SetTo(""); + break; + case B_JSON_NULL: + { + + if (fNextItemName == "major") + fTarget->SetMajorNull(); + + if (fNextItemName == "payloadLength") + fTarget->SetPayloadLengthNull(); + + if (fNextItemName == "description") + fTarget->SetDescriptionNull(); + + if (fNextItemName == "title") + fTarget->SetTitleNull(); + + if (fNextItemName == "summary") + fTarget->SetSummaryNull(); + + if (fNextItemName == "micro") + fTarget->SetMicroNull(); + + if (fNextItemName == "preRelease") + fTarget->SetPreReleaseNull(); + + if (fNextItemName == "architectureCode") + fTarget->SetArchitectureCodeNull(); + + if (fNextItemName == "minor") + fTarget->SetMinorNull(); + + if (fNextItemName == "revision") + fTarget->SetRevisionNull(); + fNextItemName.SetTo(""); + break; + } + case B_JSON_NUMBER: + { + + if (fNextItemName == "payloadLength") + fTarget->SetPayloadLength(event.ContentInteger()); + + if (fNextItemName == "revision") + fTarget->SetRevision(event.ContentInteger()); + fNextItemName.SetTo(""); + break; + } + case B_JSON_OBJECT_START: + { + if (1 == 1) { + GeneralObjectStackedDumpExportPkgJsonListener* nextListener = new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this); + Push(nextListener); + } + fNextItemName.SetTo(""); + break; + } + case B_JSON_ARRAY_START: + { + if (1 == 1) { + AbstractStackedDumpExportPkgJsonListener* nextListener = new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this); + Push(nextListener); + } + fNextItemName.SetTo(""); + break; + } + + } + + return ErrorStatus() == B_OK; +} + +DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener::DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent) + : + AbstractStackedDumpExportPkgJsonListener(mainListener, parent) +{ + fTarget = new List(); +} + + +DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener::~DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener() +{ +} + + +List* +DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener::Target() +{ + return fTarget; +} + + +bool +DumpExportPkgVersion_List_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_ARRAY_END: + Pop(); + delete this; + break; + + case B_JSON_OBJECT_START: + { + DumpExportPkgVersion_StackedDumpExportPkgJsonListener* nextListener = + new DumpExportPkgVersion_StackedDumpExportPkgJsonListener(fMainListener, this); + fTarget->Add(nextListener->Target()); + Push(nextListener); + break; + } + + default: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, + "illegal state - unexpected json event parsing an array of DumpExportPkgVersion"); + break; + } + + return ErrorStatus() == B_OK; +} + +DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener::DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent) + : + AbstractStackedDumpExportPkgJsonListener(mainListener, parent) +{ + fTarget = new DumpExportPkgScreenshot(); +} + + +DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener::~DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener() +{ +} + + +DumpExportPkgScreenshot* +DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener::Target() +{ + return fTarget; +} + + +bool +DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_ARRAY_END: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); + break; + + case B_JSON_OBJECT_NAME: + fNextItemName = event.Content(); + break; + + case B_JSON_OBJECT_END: + Pop(); + delete this; + break; + + case B_JSON_STRING: + + if (fNextItemName == "code") + fTarget->SetCode(new BString(event.Content())); + fNextItemName.SetTo(""); + break; + case B_JSON_TRUE: + fNextItemName.SetTo(""); + break; + case B_JSON_FALSE: + fNextItemName.SetTo(""); + break; + case B_JSON_NULL: + { + + if (fNextItemName == "ordering") + fTarget->SetOrderingNull(); + + if (fNextItemName == "width") + fTarget->SetWidthNull(); + + if (fNextItemName == "length") + fTarget->SetLengthNull(); + + if (fNextItemName == "code") + fTarget->SetCodeNull(); + + if (fNextItemName == "height") + fTarget->SetHeightNull(); + fNextItemName.SetTo(""); + break; + } + case B_JSON_NUMBER: + { + + if (fNextItemName == "ordering") + fTarget->SetOrdering(event.ContentInteger()); + + if (fNextItemName == "width") + fTarget->SetWidth(event.ContentInteger()); + + if (fNextItemName == "length") + fTarget->SetLength(event.ContentInteger()); + + if (fNextItemName == "height") + fTarget->SetHeight(event.ContentInteger()); + fNextItemName.SetTo(""); + break; + } + case B_JSON_OBJECT_START: + { + if (1 == 1) { + GeneralObjectStackedDumpExportPkgJsonListener* nextListener = new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this); + Push(nextListener); + } + fNextItemName.SetTo(""); + break; + } + case B_JSON_ARRAY_START: + { + if (1 == 1) { + AbstractStackedDumpExportPkgJsonListener* nextListener = new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this); + Push(nextListener); + } + fNextItemName.SetTo(""); + break; + } + + } + + return ErrorStatus() == B_OK; +} + +DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener::DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent) + : + AbstractStackedDumpExportPkgJsonListener(mainListener, parent) +{ + fTarget = new List(); +} + + +DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener::~DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener() +{ +} + + +List* +DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener::Target() +{ + return fTarget; +} + + +bool +DumpExportPkgScreenshot_List_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_ARRAY_END: + Pop(); + delete this; + break; + + case B_JSON_OBJECT_START: + { + DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener* nextListener = + new DumpExportPkgScreenshot_StackedDumpExportPkgJsonListener(fMainListener, this); + fTarget->Add(nextListener->Target()); + Push(nextListener); + break; + } + + default: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, + "illegal state - unexpected json event parsing an array of DumpExportPkgScreenshot"); + break; + } + + return ErrorStatus() == B_OK; +} + +DumpExportPkgCategory_StackedDumpExportPkgJsonListener::DumpExportPkgCategory_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent) + : + AbstractStackedDumpExportPkgJsonListener(mainListener, parent) +{ + fTarget = new DumpExportPkgCategory(); +} + + +DumpExportPkgCategory_StackedDumpExportPkgJsonListener::~DumpExportPkgCategory_StackedDumpExportPkgJsonListener() +{ +} + + +DumpExportPkgCategory* +DumpExportPkgCategory_StackedDumpExportPkgJsonListener::Target() +{ + return fTarget; +} + + +bool +DumpExportPkgCategory_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_ARRAY_END: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); + break; + + case B_JSON_OBJECT_NAME: + fNextItemName = event.Content(); + break; + + case B_JSON_OBJECT_END: + Pop(); + delete this; + break; + + case B_JSON_STRING: + + if (fNextItemName == "code") + fTarget->SetCode(new BString(event.Content())); + fNextItemName.SetTo(""); + break; + case B_JSON_TRUE: + fNextItemName.SetTo(""); + break; + case B_JSON_FALSE: + fNextItemName.SetTo(""); + break; + case B_JSON_NULL: + { + + if (fNextItemName == "code") + fTarget->SetCodeNull(); + fNextItemName.SetTo(""); + break; + } + case B_JSON_NUMBER: + { + fNextItemName.SetTo(""); + break; + } + case B_JSON_OBJECT_START: + { + if (1 == 1) { + GeneralObjectStackedDumpExportPkgJsonListener* nextListener = new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this); + Push(nextListener); + } + fNextItemName.SetTo(""); + break; + } + case B_JSON_ARRAY_START: + { + if (1 == 1) { + AbstractStackedDumpExportPkgJsonListener* nextListener = new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this); + Push(nextListener); + } + fNextItemName.SetTo(""); + break; + } + + } + + return ErrorStatus() == B_OK; +} + +DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener::DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, + AbstractStackedDumpExportPkgJsonListener* parent) + : + AbstractStackedDumpExportPkgJsonListener(mainListener, parent) +{ + fTarget = new List(); +} + + +DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener::~DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener() +{ +} + + +List* +DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener::Target() +{ + return fTarget; +} + + +bool +DumpExportPkgCategory_List_StackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_ARRAY_END: + Pop(); + delete this; + break; + + case B_JSON_OBJECT_START: + { + DumpExportPkgCategory_StackedDumpExportPkgJsonListener* nextListener = + new DumpExportPkgCategory_StackedDumpExportPkgJsonListener(fMainListener, this); + fTarget->Add(nextListener->Target()); + Push(nextListener); + break; + } + + default: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, + "illegal state - unexpected json event parsing an array of DumpExportPkgCategory"); + break; + } + + return ErrorStatus() == B_OK; +} + +ItemEmittingStackedDumpExportPkgJsonListener::ItemEmittingStackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, AbstractStackedDumpExportPkgJsonListener* parent, + DumpExportPkgListener* itemListener) +: +DumpExportPkg_StackedDumpExportPkgJsonListener(mainListener, parent) +{ + fItemListener = itemListener; +} + + +ItemEmittingStackedDumpExportPkgJsonListener::~ItemEmittingStackedDumpExportPkgJsonListener() +{ +} + + +void +ItemEmittingStackedDumpExportPkgJsonListener::WillPop() +{ + fItemListener->Handle(fTarget); + delete fTarget; +} + + +BulkContainerStackedDumpExportPkgJsonListener::BulkContainerStackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, AbstractStackedDumpExportPkgJsonListener* parent, + DumpExportPkgListener* itemListener) +: +AbstractStackedDumpExportPkgJsonListener(mainListener, parent) +{ + fItemListener = itemListener; +} + + +BulkContainerStackedDumpExportPkgJsonListener::~BulkContainerStackedDumpExportPkgJsonListener() +{ +} + + +bool +BulkContainerStackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_ARRAY_END: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected start of array"); + break; + + case B_JSON_OBJECT_NAME: + fNextItemName = event.Content(); + break; + + case B_JSON_OBJECT_START: + Push(new GeneralObjectStackedDumpExportPkgJsonListener(fMainListener, this)); + break; + + case B_JSON_ARRAY_START: + if (fNextItemName == "items") + Push(new BulkContainerItemsStackedDumpExportPkgJsonListener(fMainListener, this, fItemListener)); + else + Push(new GeneralArrayStackedDumpExportPkgJsonListener(fMainListener, this)); + break; + + case B_JSON_OBJECT_END: + Pop(); + delete this; + break; + + default: + // ignore + break; + } + + return ErrorStatus() == B_OK; +} + + +BulkContainerItemsStackedDumpExportPkgJsonListener::BulkContainerItemsStackedDumpExportPkgJsonListener( + AbstractMainDumpExportPkgJsonListener* mainListener, AbstractStackedDumpExportPkgJsonListener* parent, + DumpExportPkgListener* itemListener) +: +AbstractStackedDumpExportPkgJsonListener(mainListener, parent) +{ + fItemListener = itemListener; +} + + +BulkContainerItemsStackedDumpExportPkgJsonListener::~BulkContainerItemsStackedDumpExportPkgJsonListener() +{ +} + + +bool +BulkContainerItemsStackedDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + switch (event.EventType()) { + + case B_JSON_OBJECT_START: + Push(new ItemEmittingStackedDumpExportPkgJsonListener(fMainListener, this, fItemListener)); + break; + + case B_JSON_ARRAY_END: + Pop(); + delete this; + break; + + default: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, "illegal state - unexpected json event"); + break; + } + + return ErrorStatus() == B_OK; +} + + +void +BulkContainerItemsStackedDumpExportPkgJsonListener::WillPop() +{ + fItemListener->Complete(); +} + + +// #pragma mark - implementations for the main listeners + + +AbstractMainDumpExportPkgJsonListener::AbstractMainDumpExportPkgJsonListener() +{ + fStackedListener = NULL; + fErrorStatus = B_OK; +} + + +AbstractMainDumpExportPkgJsonListener::~AbstractMainDumpExportPkgJsonListener() +{ +} + + +void +AbstractMainDumpExportPkgJsonListener::HandleError(status_t status, int32 line, const char* message) +{ + if (message != NULL) { + fprintf(stderr, "an error has arisen processing json for 'DumpExportPkg'; %s\n", message); + } else { + fprintf(stderr, "an error has arisen processing json for 'DumpExportPkg'\n"); + } + fErrorStatus = status; +} + + +void +AbstractMainDumpExportPkgJsonListener::Complete() +{ +} + + +status_t +AbstractMainDumpExportPkgJsonListener::ErrorStatus() +{ + return fErrorStatus; +} + +void +AbstractMainDumpExportPkgJsonListener::SetStackedListener( + AbstractStackedDumpExportPkgJsonListener* stackedListener) +{ + fStackedListener = stackedListener; +} + + +SingleDumpExportPkgJsonListener::SingleDumpExportPkgJsonListener() +: +AbstractMainDumpExportPkgJsonListener() +{ + fTarget = NULL; +} + + +SingleDumpExportPkgJsonListener::~SingleDumpExportPkgJsonListener() +{ +} + + +bool +SingleDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + if (fErrorStatus != B_OK) + return false; + + if (fStackedListener != NULL) + return fStackedListener->Handle(event); + + switch (event.EventType()) { + + case B_JSON_OBJECT_START: + { + DumpExportPkg_StackedDumpExportPkgJsonListener* nextListener = new DumpExportPkg_StackedDumpExportPkgJsonListener( + this, NULL); + fTarget = nextListener->Target(); + SetStackedListener(nextListener); + break; + } + + default: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, + "illegal state - unexpected json event parsing top level for DumpExportPkg"); + break; + } + + return ErrorStatus() == B_OK; +} + + +DumpExportPkg* +SingleDumpExportPkgJsonListener::Target() +{ + return fTarget; +} + + +BulkContainerDumpExportPkgJsonListener::BulkContainerDumpExportPkgJsonListener( + DumpExportPkgListener* itemListener) : AbstractMainDumpExportPkgJsonListener() +{ + fItemListener = itemListener; +} + + +BulkContainerDumpExportPkgJsonListener::~BulkContainerDumpExportPkgJsonListener() +{ +} + + +bool +BulkContainerDumpExportPkgJsonListener::Handle(const BJsonEvent& event) +{ + if (fErrorStatus != B_OK) + return false; + + if (fStackedListener != NULL) + return fStackedListener->Handle(event); + + switch (event.EventType()) { + + case B_JSON_OBJECT_START: + { + BulkContainerStackedDumpExportPkgJsonListener* nextListener = + new BulkContainerStackedDumpExportPkgJsonListener( + this, NULL, fItemListener); + SetStackedListener(nextListener); + return true; + break; + } + + default: + HandleError(B_NOT_ALLOWED, JSON_EVENT_LISTENER_ANY_LINE, + "illegal state - unexpected json event parsing top level for BulkContainerDumpExportPkgJsonListener"); + break; + } + + return ErrorStatus() == B_OK; +} + diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgJsonListener.h b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgJsonListener.h new file mode 100644 index 0000000000..ea778c994e --- /dev/null +++ b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgJsonListener.h @@ -0,0 +1,89 @@ +/* + * Generated Listener Object + * source json-schema : dumpexport.json + * generated at : 2017-11-11T14:09:03.498089 + */ + +#ifndef GEN_JSON_SCHEMA_PARSER__SINGLEDUMPEXPORTPKGJSONLISTENER_H +#define GEN_JSON_SCHEMA_PARSER__SINGLEDUMPEXPORTPKGJSONLISTENER_H + +#include + +#include "DumpExportPkg.h" + +class AbstractStackedDumpExportPkgJsonListener; + +class AbstractMainDumpExportPkgJsonListener : public BJsonEventListener { +friend class AbstractStackedDumpExportPkgJsonListener; +public: + AbstractMainDumpExportPkgJsonListener(); + virtual ~AbstractMainDumpExportPkgJsonListener(); + + void HandleError(status_t status, int32 line, const char* message); + void Complete(); + status_t ErrorStatus(); + +protected: + void SetStackedListener( + AbstractStackedDumpExportPkgJsonListener* listener); + status_t fErrorStatus; + AbstractStackedDumpExportPkgJsonListener* fStackedListener; +}; + + +/*! Use this listener when you want to parse some JSON data that contains + just a single instance of DumpExportPkg. +*/ +class SingleDumpExportPkgJsonListener + : public AbstractMainDumpExportPkgJsonListener { +friend class AbstractStackedDumpExportPkgJsonListener; +public: + SingleDumpExportPkgJsonListener(); + virtual ~SingleDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); + DumpExportPkg* Target(); + +private: + DumpExportPkg* fTarget; +}; + + +/*! Concrete sub-classes of this class are able to respond to each + DumpExportPkg* instance as + it is parsed from the bulk container. When the stream is + finished, the Complete() method is invoked. + + Note that the item object will be deleted after the Handle method + is invoked. The Handle method need not take responsibility + for deleting the item itself. +*/ +class DumpExportPkgListener { +public: + virtual void Handle(DumpExportPkg* item) = 0; + virtual void Complete() = 0; +}; + + +/*! Use this listener, together with an instance of a concrete + subclass of DumpExportPkgListener + in order to parse the JSON data in a specific "bulk + container" format. Each time that an instance of + DumpExportPkg + is parsed, the instance item listener will be invoked. +*/ +class BulkContainerDumpExportPkgJsonListener + : public AbstractMainDumpExportPkgJsonListener { +friend class AbstractStackedDumpExportPkgJsonListener; +public: + BulkContainerDumpExportPkgJsonListener( + DumpExportPkgListener* itemListener); + ~BulkContainerDumpExportPkgJsonListener(); + + bool Handle(const BJsonEvent& event); + +private: + DumpExportPkgListener* fItemListener; +}; + +#endif // GEN_JSON_SCHEMA_PARSER__SINGLEDUMPEXPORTPKGJSONLISTENER_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgScreenshot.cpp b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgScreenshot.cpp new file mode 100644 index 0000000000..34aa25ac88 --- /dev/null +++ b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgScreenshot.cpp @@ -0,0 +1,204 @@ +/* + * Generated Model Object + * source json-schema : dumpexport.json + * generated at : 2017-11-05T22:30:10.257444 + */ +#include "DumpExportPkgScreenshot.h" + + +DumpExportPkgScreenshot::DumpExportPkgScreenshot() +{ + fOrdering = NULL; + fWidth = NULL; + fLength = NULL; + fCode = NULL; + fHeight = NULL; +} + + +DumpExportPkgScreenshot::~DumpExportPkgScreenshot() +{ + if (fOrdering != NULL) { + delete fOrdering; + } + + if (fWidth != NULL) { + delete fWidth; + } + + if (fLength != NULL) { + delete fLength; + } + + if (fCode != NULL) { + delete fCode; + } + + if (fHeight != NULL) { + delete fHeight; + } + +} + +int64 +DumpExportPkgScreenshot::Ordering() +{ + return *fOrdering; +} + + +void +DumpExportPkgScreenshot::SetOrdering(int64 value) +{ + if (OrderingIsNull()) + fOrdering = new int64[1]; + fOrdering[0] = value; +} + + +void +DumpExportPkgScreenshot::SetOrderingNull() +{ + if (!OrderingIsNull()) { + delete fOrdering; + fOrdering = NULL; + } +} + + +bool +DumpExportPkgScreenshot::OrderingIsNull() +{ + return fOrdering == NULL; +} + + +int64 +DumpExportPkgScreenshot::Width() +{ + return *fWidth; +} + + +void +DumpExportPkgScreenshot::SetWidth(int64 value) +{ + if (WidthIsNull()) + fWidth = new int64[1]; + fWidth[0] = value; +} + + +void +DumpExportPkgScreenshot::SetWidthNull() +{ + if (!WidthIsNull()) { + delete fWidth; + fWidth = NULL; + } +} + + +bool +DumpExportPkgScreenshot::WidthIsNull() +{ + return fWidth == NULL; +} + + +int64 +DumpExportPkgScreenshot::Length() +{ + return *fLength; +} + + +void +DumpExportPkgScreenshot::SetLength(int64 value) +{ + if (LengthIsNull()) + fLength = new int64[1]; + fLength[0] = value; +} + + +void +DumpExportPkgScreenshot::SetLengthNull() +{ + if (!LengthIsNull()) { + delete fLength; + fLength = NULL; + } +} + + +bool +DumpExportPkgScreenshot::LengthIsNull() +{ + return fLength == NULL; +} + + +BString* +DumpExportPkgScreenshot::Code() +{ + return fCode; +} + + +void +DumpExportPkgScreenshot::SetCode(BString* value) +{ + fCode = value; +} + + +void +DumpExportPkgScreenshot::SetCodeNull() +{ + if (!CodeIsNull()) { + delete fCode; + fCode = NULL; + } +} + + +bool +DumpExportPkgScreenshot::CodeIsNull() +{ + return fCode == NULL; +} + + +int64 +DumpExportPkgScreenshot::Height() +{ + return *fHeight; +} + + +void +DumpExportPkgScreenshot::SetHeight(int64 value) +{ + if (HeightIsNull()) + fHeight = new int64[1]; + fHeight[0] = value; +} + + +void +DumpExportPkgScreenshot::SetHeightNull() +{ + if (!HeightIsNull()) { + delete fHeight; + fHeight = NULL; + } +} + + +bool +DumpExportPkgScreenshot::HeightIsNull() +{ + return fHeight == NULL; +} + diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgScreenshot.h b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgScreenshot.h new file mode 100644 index 0000000000..251ed55bd7 --- /dev/null +++ b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgScreenshot.h @@ -0,0 +1,56 @@ +/* + * Generated Model Object + * source json-schema : dumpexport.json + * generated at : 2017-11-05T22:30:10.256842 + */ + +#ifndef GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGSCREENSHOT_H +#define GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGSCREENSHOT_H + +#include "List.h" +#include "String.h" + + +class DumpExportPkgScreenshot { +public: + DumpExportPkgScreenshot(); + virtual ~DumpExportPkgScreenshot(); + + + int64 Ordering(); + void SetOrdering(int64 value); + void SetOrderingNull(); + bool OrderingIsNull(); + + + int64 Width(); + void SetWidth(int64 value); + void SetWidthNull(); + bool WidthIsNull(); + + + int64 Length(); + void SetLength(int64 value); + void SetLengthNull(); + bool LengthIsNull(); + + BString* Code(); + void SetCode(BString* value); + void SetCodeNull(); + bool CodeIsNull(); + + + int64 Height(); + void SetHeight(int64 value); + void SetHeightNull(); + bool HeightIsNull(); + +private: + int64* fOrdering; + int64* fWidth; + int64* fLength; + BString* fCode; + int64* fHeight; +}; + +#endif // GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGSCREENSHOT_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgVersion.cpp b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgVersion.cpp new file mode 100644 index 0000000000..f8703ce2bc --- /dev/null +++ b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgVersion.cpp @@ -0,0 +1,380 @@ +/* + * Generated Model Object + * source json-schema : dumpexport.json + * generated at : 2017-11-05T22:30:10.255929 + */ +#include "DumpExportPkgVersion.h" + + +DumpExportPkgVersion::DumpExportPkgVersion() +{ + fMajor = NULL; + fPayloadLength = NULL; + fDescription = NULL; + fTitle = NULL; + fSummary = NULL; + fMicro = NULL; + fPreRelease = NULL; + fArchitectureCode = NULL; + fMinor = NULL; + fRevision = NULL; +} + + +DumpExportPkgVersion::~DumpExportPkgVersion() +{ + if (fMajor != NULL) { + delete fMajor; + } + + if (fPayloadLength != NULL) { + delete fPayloadLength; + } + + if (fDescription != NULL) { + delete fDescription; + } + + if (fTitle != NULL) { + delete fTitle; + } + + if (fSummary != NULL) { + delete fSummary; + } + + if (fMicro != NULL) { + delete fMicro; + } + + if (fPreRelease != NULL) { + delete fPreRelease; + } + + if (fArchitectureCode != NULL) { + delete fArchitectureCode; + } + + if (fMinor != NULL) { + delete fMinor; + } + + if (fRevision != NULL) { + delete fRevision; + } + +} + +BString* +DumpExportPkgVersion::Major() +{ + return fMajor; +} + + +void +DumpExportPkgVersion::SetMajor(BString* value) +{ + fMajor = value; +} + + +void +DumpExportPkgVersion::SetMajorNull() +{ + if (!MajorIsNull()) { + delete fMajor; + fMajor = NULL; + } +} + + +bool +DumpExportPkgVersion::MajorIsNull() +{ + return fMajor == NULL; +} + + +int64 +DumpExportPkgVersion::PayloadLength() +{ + return *fPayloadLength; +} + + +void +DumpExportPkgVersion::SetPayloadLength(int64 value) +{ + if (PayloadLengthIsNull()) + fPayloadLength = new int64[1]; + fPayloadLength[0] = value; +} + + +void +DumpExportPkgVersion::SetPayloadLengthNull() +{ + if (!PayloadLengthIsNull()) { + delete fPayloadLength; + fPayloadLength = NULL; + } +} + + +bool +DumpExportPkgVersion::PayloadLengthIsNull() +{ + return fPayloadLength == NULL; +} + + +BString* +DumpExportPkgVersion::Description() +{ + return fDescription; +} + + +void +DumpExportPkgVersion::SetDescription(BString* value) +{ + fDescription = value; +} + + +void +DumpExportPkgVersion::SetDescriptionNull() +{ + if (!DescriptionIsNull()) { + delete fDescription; + fDescription = NULL; + } +} + + +bool +DumpExportPkgVersion::DescriptionIsNull() +{ + return fDescription == NULL; +} + + +BString* +DumpExportPkgVersion::Title() +{ + return fTitle; +} + + +void +DumpExportPkgVersion::SetTitle(BString* value) +{ + fTitle = value; +} + + +void +DumpExportPkgVersion::SetTitleNull() +{ + if (!TitleIsNull()) { + delete fTitle; + fTitle = NULL; + } +} + + +bool +DumpExportPkgVersion::TitleIsNull() +{ + return fTitle == NULL; +} + + +BString* +DumpExportPkgVersion::Summary() +{ + return fSummary; +} + + +void +DumpExportPkgVersion::SetSummary(BString* value) +{ + fSummary = value; +} + + +void +DumpExportPkgVersion::SetSummaryNull() +{ + if (!SummaryIsNull()) { + delete fSummary; + fSummary = NULL; + } +} + + +bool +DumpExportPkgVersion::SummaryIsNull() +{ + return fSummary == NULL; +} + + +BString* +DumpExportPkgVersion::Micro() +{ + return fMicro; +} + + +void +DumpExportPkgVersion::SetMicro(BString* value) +{ + fMicro = value; +} + + +void +DumpExportPkgVersion::SetMicroNull() +{ + if (!MicroIsNull()) { + delete fMicro; + fMicro = NULL; + } +} + + +bool +DumpExportPkgVersion::MicroIsNull() +{ + return fMicro == NULL; +} + + +BString* +DumpExportPkgVersion::PreRelease() +{ + return fPreRelease; +} + + +void +DumpExportPkgVersion::SetPreRelease(BString* value) +{ + fPreRelease = value; +} + + +void +DumpExportPkgVersion::SetPreReleaseNull() +{ + if (!PreReleaseIsNull()) { + delete fPreRelease; + fPreRelease = NULL; + } +} + + +bool +DumpExportPkgVersion::PreReleaseIsNull() +{ + return fPreRelease == NULL; +} + + +BString* +DumpExportPkgVersion::ArchitectureCode() +{ + return fArchitectureCode; +} + + +void +DumpExportPkgVersion::SetArchitectureCode(BString* value) +{ + fArchitectureCode = value; +} + + +void +DumpExportPkgVersion::SetArchitectureCodeNull() +{ + if (!ArchitectureCodeIsNull()) { + delete fArchitectureCode; + fArchitectureCode = NULL; + } +} + + +bool +DumpExportPkgVersion::ArchitectureCodeIsNull() +{ + return fArchitectureCode == NULL; +} + + +BString* +DumpExportPkgVersion::Minor() +{ + return fMinor; +} + + +void +DumpExportPkgVersion::SetMinor(BString* value) +{ + fMinor = value; +} + + +void +DumpExportPkgVersion::SetMinorNull() +{ + if (!MinorIsNull()) { + delete fMinor; + fMinor = NULL; + } +} + + +bool +DumpExportPkgVersion::MinorIsNull() +{ + return fMinor == NULL; +} + + +int64 +DumpExportPkgVersion::Revision() +{ + return *fRevision; +} + + +void +DumpExportPkgVersion::SetRevision(int64 value) +{ + if (RevisionIsNull()) + fRevision = new int64[1]; + fRevision[0] = value; +} + + +void +DumpExportPkgVersion::SetRevisionNull() +{ + if (!RevisionIsNull()) { + delete fRevision; + fRevision = NULL; + } +} + + +bool +DumpExportPkgVersion::RevisionIsNull() +{ + return fRevision == NULL; +} + diff --git a/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgVersion.h b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgVersion.h new file mode 100644 index 0000000000..8d71cbd906 --- /dev/null +++ b/src/apps/haikudepot/server/dumpexportpkg/DumpExportPkgVersion.h @@ -0,0 +1,84 @@ +/* + * Generated Model Object + * source json-schema : dumpexport.json + * generated at : 2017-11-05T22:30:10.255268 + */ + +#ifndef GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGVERSION_H +#define GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGVERSION_H + +#include "List.h" +#include "String.h" + + +class DumpExportPkgVersion { +public: + DumpExportPkgVersion(); + virtual ~DumpExportPkgVersion(); + + BString* Major(); + void SetMajor(BString* value); + void SetMajorNull(); + bool MajorIsNull(); + + + int64 PayloadLength(); + void SetPayloadLength(int64 value); + void SetPayloadLengthNull(); + bool PayloadLengthIsNull(); + + BString* Description(); + void SetDescription(BString* value); + void SetDescriptionNull(); + bool DescriptionIsNull(); + + BString* Title(); + void SetTitle(BString* value); + void SetTitleNull(); + bool TitleIsNull(); + + BString* Summary(); + void SetSummary(BString* value); + void SetSummaryNull(); + bool SummaryIsNull(); + + BString* Micro(); + void SetMicro(BString* value); + void SetMicroNull(); + bool MicroIsNull(); + + BString* PreRelease(); + void SetPreRelease(BString* value); + void SetPreReleaseNull(); + bool PreReleaseIsNull(); + + BString* ArchitectureCode(); + void SetArchitectureCode(BString* value); + void SetArchitectureCodeNull(); + bool ArchitectureCodeIsNull(); + + BString* Minor(); + void SetMinor(BString* value); + void SetMinorNull(); + bool MinorIsNull(); + + + int64 Revision(); + void SetRevision(int64 value); + void SetRevisionNull(); + bool RevisionIsNull(); + +private: + BString* fMajor; + int64* fPayloadLength; + BString* fDescription; + BString* fTitle; + BString* fSummary; + BString* fMicro; + BString* fPreRelease; + BString* fArchitectureCode; + BString* fMinor; + int64* fRevision; +}; + +#endif // GEN_JSON_SCHEMA_MODEL__DUMPEXPORTPKGVERSION_H \ No newline at end of file diff --git a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.cpp b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.cpp index 1d06248189..a921f10e77 100644 --- a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.cpp +++ b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.cpp @@ -1,7 +1,7 @@ /* * Generated Model Object * source json-schema : dumpexport.json - * generated at : 2017-10-12T21:34:32.334310 + * generated at : 2017-11-11T13:59:22.553529 */ #include "DumpExportRepository.h" @@ -59,6 +59,16 @@ DumpExportRepository::SetInformationUrl(BString* value) } +void +DumpExportRepository::SetInformationUrlNull() +{ + if (!InformationUrlIsNull()) { + delete fInformationUrl; + fInformationUrl = NULL; + } +} + + bool DumpExportRepository::InformationUrlIsNull() { @@ -80,6 +90,16 @@ DumpExportRepository::SetCode(BString* value) } +void +DumpExportRepository::SetCodeNull() +{ + if (!CodeIsNull()) { + delete fCode; + fCode = NULL; + } +} + + bool DumpExportRepository::CodeIsNull() { @@ -140,6 +160,16 @@ DumpExportRepository::SetName(BString* value) } +void +DumpExportRepository::SetNameNull() +{ + if (!NameIsNull()) { + delete fName; + fName = NULL; + } +} + + bool DumpExportRepository::NameIsNull() { @@ -161,6 +191,16 @@ DumpExportRepository::SetDescription(BString* value) } +void +DumpExportRepository::SetDescriptionNull() +{ + if (!DescriptionIsNull()) { + delete fDescription; + fDescription = NULL; + } +} + + bool DumpExportRepository::DescriptionIsNull() { diff --git a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.h b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.h index 9536a66dc5..0121403412 100644 --- a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.h +++ b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepository.h @@ -1,7 +1,7 @@ /* * Generated Model Object * source json-schema : dumpexport.json - * generated at : 2017-10-12T21:34:32.333203 + * generated at : 2017-11-11T13:59:22.550365 */ #ifndef GEN_JSON_SCHEMA_MODEL__DUMPEXPORTREPOSITORY_H @@ -19,10 +19,12 @@ public: BString* InformationUrl(); void SetInformationUrl(BString* value); + void SetInformationUrlNull(); bool InformationUrlIsNull(); BString* Code(); void SetCode(BString* value); + void SetCodeNull(); bool CodeIsNull(); void AddToRepositorySources(DumpExportRepositorySource* value); @@ -33,10 +35,12 @@ public: BString* Name(); void SetName(BString* value); + void SetNameNull(); bool NameIsNull(); BString* Description(); void SetDescription(BString* value); + void SetDescriptionNull(); bool DescriptionIsNull(); private: diff --git a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.cpp b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.cpp index 42a8cbd834..8061f185ff 100644 --- a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.cpp +++ b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.cpp @@ -1,7 +1,7 @@ /* * Generated Listener Object * source json-schema : dumpexport.json - * generated at : 2017-10-02T22:02:18.621800 + * generated at : 2017-11-11T14:08:39.276778 */ #include "DumpExportRepositoryJsonListener.h" #include "List.h" @@ -386,16 +386,16 @@ DumpExportRepository_StackedDumpExportRepositoryJsonListener::Handle(const BJson { if (fNextItemName == "informationUrl") - fTarget->SetInformationUrl(NULL); + fTarget->SetInformationUrlNull(); if (fNextItemName == "code") - fTarget->SetCode(NULL); + fTarget->SetCodeNull(); if (fNextItemName == "name") - fTarget->SetName(NULL); + fTarget->SetNameNull(); if (fNextItemName == "description") - fTarget->SetDescription(NULL); + fTarget->SetDescriptionNull(); fNextItemName.SetTo(""); break; } @@ -542,10 +542,10 @@ DumpExportRepositorySource_StackedDumpExportRepositoryJsonListener::Handle(const { if (fNextItemName == "url") - fTarget->SetUrl(NULL); + fTarget->SetUrlNull(); if (fNextItemName == "code") - fTarget->SetCode(NULL); + fTarget->SetCodeNull(); fNextItemName.SetTo(""); break; } @@ -767,7 +767,11 @@ AbstractMainDumpExportRepositoryJsonListener::~AbstractMainDumpExportRepositoryJ void AbstractMainDumpExportRepositoryJsonListener::HandleError(status_t status, int32 line, const char* message) { - printf("an error has arisen processing json for 'DumpExportRepository'; %s", message); + if (message != NULL) { + fprintf(stderr, "an error has arisen processing json for 'DumpExportRepository'; %s\n", message); + } else { + fprintf(stderr, "an error has arisen processing json for 'DumpExportRepository'\n"); + } fErrorStatus = status; } diff --git a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.h b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.h index 3b0db85ba6..cd8edde79a 100644 --- a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.h +++ b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositoryJsonListener.h @@ -1,7 +1,7 @@ /* * Generated Listener Object * source json-schema : dumpexport.json - * generated at : 2017-10-02T22:02:18.621102 + * generated at : 2017-11-11T14:08:39.274913 */ #ifndef GEN_JSON_SCHEMA_PARSER__SINGLEDUMPEXPORTREPOSITORYJSONLISTENER_H diff --git a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.cpp b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.cpp index 9e6898c9dc..e0e5998a74 100644 --- a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.cpp +++ b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.cpp @@ -1,7 +1,7 @@ /* * Generated Model Object * source json-schema : dumpexport.json - * generated at : 2017-10-12T21:34:32.334783 + * generated at : 2017-11-11T13:59:22.559632 */ #include "DumpExportRepositorySource.h" @@ -39,6 +39,16 @@ DumpExportRepositorySource::SetUrl(BString* value) } +void +DumpExportRepositorySource::SetUrlNull() +{ + if (!UrlIsNull()) { + delete fUrl; + fUrl = NULL; + } +} + + bool DumpExportRepositorySource::UrlIsNull() { @@ -60,6 +70,16 @@ DumpExportRepositorySource::SetCode(BString* value) } +void +DumpExportRepositorySource::SetCodeNull() +{ + if (!CodeIsNull()) { + delete fCode; + fCode = NULL; + } +} + + bool DumpExportRepositorySource::CodeIsNull() { diff --git a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.h b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.h index 8f7466c9a0..470c5d85a8 100644 --- a/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.h +++ b/src/apps/haikudepot/server/dumpexportrepository/DumpExportRepositorySource.h @@ -1,7 +1,7 @@ /* * Generated Model Object * source json-schema : dumpexport.json - * generated at : 2017-10-12T21:34:32.334652 + * generated at : 2017-11-11T13:59:22.559237 */ #ifndef GEN_JSON_SCHEMA_MODEL__DUMPEXPORTREPOSITORYSOURCE_H @@ -18,10 +18,12 @@ public: BString* Url(); void SetUrl(BString* value); + void SetUrlNull(); bool UrlIsNull(); BString* Code(); void SetCode(BString* value); + void SetCodeNull(); bool CodeIsNull(); private: