From fa5c8097c9eddf48e05e70cd0dc6b389532fcaa3 Mon Sep 17 00:00:00 2001 From: Andrew Lindesay Date: Sat, 25 Jul 2020 23:28:44 +1200 Subject: [PATCH] HaikuDepot: Languages List Abstacts the list of supported languages into the LanguageModel class preventing use of List. Also; fix a few cases where newer logging techniques may have caused incorrect logic flow. Relates To #15534 Change-Id: I144fe4788abdaf0d93e53eeabc97b3f7aa2ec710 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3085 Reviewed-by: Adrien Destugues --- src/apps/haikudepot/model/Captcha.cpp | 5 +- src/apps/haikudepot/model/Captcha.h | 1 - .../haikudepot/model/CreateUserDetail.cpp | 1 - src/apps/haikudepot/model/CreateUserDetail.h | 1 - src/apps/haikudepot/model/LanguageModel.cpp | 94 +++++++++++++------ src/apps/haikudepot/model/LanguageModel.h | 16 ++-- src/apps/haikudepot/model/Logger.h | 4 +- src/apps/haikudepot/model/Model.cpp | 64 ++++++------- src/apps/haikudepot/model/Model.h | 8 +- src/apps/haikudepot/model/PackageInfo.cpp | 4 +- src/apps/haikudepot/model/PackageManager.cpp | 28 +++--- .../haikudepot/model/UserUsageConditions.cpp | 7 +- .../haikudepot/server/AbstractProcess.cpp | 6 +- .../server/AbstractServerProcess.cpp | 30 +++--- .../AbstractSingleFileServerProcess.cpp | 18 ++-- .../server/LocalPkgDataLoadProcess.cpp | 18 ++-- .../server/LocalRepositoryUpdateProcess.cpp | 14 +-- .../haikudepot/server/ProcessCoordinator.cpp | 6 +- .../server/ProcessCoordinatorFactory.cpp | 9 +- src/apps/haikudepot/server/ProcessNode.cpp | 8 +- .../server/ServerIconExportUpdateProcess.cpp | 31 +++--- .../server/ServerPkgDataUpdateProcess.cpp | 12 +-- .../ServerReferenceDataUpdateProcess.cpp | 24 ++--- .../ServerRepositoryDataUpdateProcess.cpp | 6 +- src/apps/haikudepot/server/ServerSettings.cpp | 12 +-- .../StandardMetaDataJsonEventListener.cpp | 2 +- .../server/UserDetailVerifierProcess.cpp | 10 +- .../haikudepot/server/WebAppInterface.cpp | 22 ++--- src/apps/haikudepot/tar/TarArchiveHeader.cpp | 2 +- src/apps/haikudepot/tar/TarArchiveService.cpp | 19 ++-- src/apps/haikudepot/ui/App.cpp | 2 +- .../haikudepot/ui/FeaturedPackagesView.cpp | 7 +- src/apps/haikudepot/ui/MainWindow.cpp | 38 ++++---- .../haikudepot/ui/PackageContentsView.cpp | 6 +- src/apps/haikudepot/ui/PackageInfoView.cpp | 2 +- src/apps/haikudepot/ui/RatePackageWindow.cpp | 27 +++--- src/apps/haikudepot/ui/ScreenshotWindow.cpp | 11 +-- .../ui/ToLatestUserUsageConditionsWindow.cpp | 2 +- src/apps/haikudepot/ui/UserLoginWindow.cpp | 39 ++++---- .../ui/UserUsageConditionsWindow.cpp | 14 +-- .../haikudepot/ui_generic/SharedBitmap.cpp | 2 +- .../haikudepot/util/LanguageMenuUtils.cpp | 20 ++-- src/apps/haikudepot/util/LanguageMenuUtils.h | 4 +- src/apps/haikudepot/util/StorageUtils.cpp | 24 ++--- .../util/ToFileUrlProtocolListener.cpp | 6 +- 45 files changed, 352 insertions(+), 334 deletions(-) diff --git a/src/apps/haikudepot/model/Captcha.cpp b/src/apps/haikudepot/model/Captcha.cpp index 86bcbff741..1e6f648a3f 100644 --- a/src/apps/haikudepot/model/Captcha.cpp +++ b/src/apps/haikudepot/model/Captcha.cpp @@ -1,6 +1,5 @@ /* * Copyright 2019-2020, Andrew Lindesay . - * * All rights reserved. Distributed under the terms of the MIT License. */ #include "Captcha.h" @@ -23,14 +22,14 @@ Captcha::Captcha(BMessage* from) { if (from->FindString(KEY_TOKEN, &fToken) != B_OK) { HDERROR("expected key [%s] in the message data when creating a " - "captcha", KEY_TOKEN) + "captcha", KEY_TOKEN); } const void* data; ssize_t len; if (from->FindData(KEY_PNG_IMAGE_DATA, B_ANY_TYPE, &data, &len) != B_OK) - HDERROR("expected key [%s] in the message data", KEY_PNG_IMAGE_DATA) + HDERROR("expected key [%s] in the message data", KEY_PNG_IMAGE_DATA); else SetPngImageData(data, len); } diff --git a/src/apps/haikudepot/model/Captcha.h b/src/apps/haikudepot/model/Captcha.h index 9b619d1020..c54aca8288 100644 --- a/src/apps/haikudepot/model/Captcha.h +++ b/src/apps/haikudepot/model/Captcha.h @@ -1,6 +1,5 @@ /* * Copyright 2019, Andrew Lindesay . - * * All rights reserved. Distributed under the terms of the MIT License. */ #ifndef CAPTCHA_H diff --git a/src/apps/haikudepot/model/CreateUserDetail.cpp b/src/apps/haikudepot/model/CreateUserDetail.cpp index f81a16f5a5..fa1ea76134 100644 --- a/src/apps/haikudepot/model/CreateUserDetail.cpp +++ b/src/apps/haikudepot/model/CreateUserDetail.cpp @@ -1,6 +1,5 @@ /* * Copyright 2019, Andrew Lindesay . - * * All rights reserved. Distributed under the terms of the MIT License. */ #include "CreateUserDetail.h" diff --git a/src/apps/haikudepot/model/CreateUserDetail.h b/src/apps/haikudepot/model/CreateUserDetail.h index 917c0c5f44..9bef0d0abf 100644 --- a/src/apps/haikudepot/model/CreateUserDetail.h +++ b/src/apps/haikudepot/model/CreateUserDetail.h @@ -1,6 +1,5 @@ /* * Copyright 2019, Andrew Lindesay . - * * All rights reserved. Distributed under the terms of the MIT License. */ #ifndef CREATE_USER_DETAIL_H diff --git a/src/apps/haikudepot/model/LanguageModel.cpp b/src/apps/haikudepot/model/LanguageModel.cpp index c573420979..51d5155577 100644 --- a/src/apps/haikudepot/model/LanguageModel.cpp +++ b/src/apps/haikudepot/model/LanguageModel.cpp @@ -4,6 +4,8 @@ */ #include "LanguageModel.h" +#include + #include #include #include @@ -14,7 +16,7 @@ static int32 -LanguagesCompareFn(const LanguageRef& l1, const LanguageRef& l2) +_LanguagesCompareFn(const LanguageRef& l1, const LanguageRef& l2) { BCollator* collator = LocaleUtils::GetSharedCollator(); BString name1; @@ -30,13 +32,19 @@ LanguagesCompareFn(const LanguageRef& l1, const LanguageRef& l2) } +static bool +_IsLanguageBefore(const LanguageRef& l1, const LanguageRef& l2) +{ + return _LanguagesCompareFn(l1, l2) < 0; +} + + LanguageModel::LanguageModel() : - fSupportedLanguages(LanguagesCompareFn, NULL), fPreferredLanguage(LanguageRef(new Language(LANGUAGE_DEFAULT))) { const Language defaultLanguage = _DeriveDefaultLanguage(); - fSupportedLanguages.Add(LanguageRef( + fSupportedLanguages.push_back(LanguageRef( new Language(defaultLanguage), true)); _SetPreferredLanguage(defaultLanguage); } @@ -47,19 +55,55 @@ LanguageModel::~LanguageModel() } -void -LanguageModel::AddSupportedLanguages(const LanguageList& languages) +const int32 +LanguageModel::CountSupportedLanguages() const { - for (int32 i = 0; i < languages.CountItems(); i++) { - const LanguageRef language = languages.ItemAt(i); - int32 index = IndexOfSupportedLanguage(language->Code()); + return fSupportedLanguages.size(); +} - if (index == -1) - fSupportedLanguages.Add(language); - else - fSupportedLanguages.Replace(index, language); + +const LanguageRef +LanguageModel::SupportedLanguageAt(int32 index) const +{ + return fSupportedLanguages[index]; +} + + +int32 +LanguageModel::IndexOfSupportedLanguage(const BString& languageCode) const +{ + for (uint32 i = 0; i < fSupportedLanguages.size(); i++) { + if (fSupportedLanguages[i]->Code() == languageCode) + return i; } + return -1; +} + + +void +LanguageModel::AddSupportedLanguage(const LanguageRef& value) +{ + int32 index = IndexOfSupportedLanguage(value->Code()); + + if (-1 == index) { + std::vector::iterator itInsertionPt + = std::lower_bound( + fSupportedLanguages.begin(), fSupportedLanguages.end(), + value, &_IsLanguageBefore); + fSupportedLanguages.insert(itInsertionPt, value); + HDTRACE("did add the supported language [%s]" , value->Code()); + } + else { + fSupportedLanguages[index] = value; + HDTRACE("did replace the supported language [%s]", value->Code()); + } +} + + +void +LanguageModel::SetPreferredLanguageToSystemDefault() +{ // it could be that the preferred language does not exist in the // list. In this case it is necessary to choose one from the list. _SetPreferredLanguage(_DeriveDefaultLanguage()); @@ -70,19 +114,7 @@ void LanguageModel::_SetPreferredLanguage(const Language& language) { fPreferredLanguage = LanguageRef(new Language(language)); - HDDEBUG("set preferred language [%s]", language.Code()) -} - - -int32 -LanguageModel::IndexOfSupportedLanguage(const BString& languageCode) const -{ - for (int32 i = 0; i < fSupportedLanguages.CountItems(); i++) { - if (fSupportedLanguages.ItemAt(i)->Code() == languageCode) - return i; - } - - return -1; + HDDEBUG("set preferred language [%s]", language.Code()); } @@ -97,14 +129,14 @@ Language LanguageModel::_DeriveDefaultLanguage() const { Language defaultLanguage = _DeriveSystemDefaultLanguage(); - HDDEBUG("derived system default language [%s]", defaultLanguage.Code()) + HDDEBUG("derived system default language [%s]", defaultLanguage.Code()); // if there are no supported languages; as is the case to start with as the // application starts, the default language from the system is used anyway. // The data queried in HDS will handle the case where the language is not // 'known' at the HDS end so it doesn't matter if it is invalid. - if (fSupportedLanguages.IsEmpty()) + if (fSupportedLanguages.empty()) return defaultLanguage; // if there are supported languages defined then the preferred language @@ -115,15 +147,15 @@ LanguageModel::_DeriveDefaultLanguage() const if (foundSupportedLanguage == NULL) { HDERROR("unable to find the language [%s] - looking for app default", - defaultLanguage.Code()) + defaultLanguage.Code()); foundSupportedLanguage = _FindSupportedLanguage( LANGUAGE_DEFAULT.Code()); } if (foundSupportedLanguage == NULL) { HDERROR("unable to find the app default language - using the first " - "supported language") - foundSupportedLanguage = fSupportedLanguages.ItemAt(0); + "supported language"); + foundSupportedLanguage = fSupportedLanguages[0]; } return Language(*foundSupportedLanguage); @@ -157,5 +189,5 @@ LanguageModel::_FindSupportedLanguage(const BString& code) const int32 index = IndexOfSupportedLanguage(code); if (-1 == index) return NULL; - return fSupportedLanguages.ItemAt(index); + return fSupportedLanguages[index]; } \ No newline at end of file diff --git a/src/apps/haikudepot/model/LanguageModel.h b/src/apps/haikudepot/model/LanguageModel.h index b748f41007..f9942c2644 100644 --- a/src/apps/haikudepot/model/LanguageModel.h +++ b/src/apps/haikudepot/model/LanguageModel.h @@ -5,15 +5,14 @@ #ifndef LANGUAGE_MODEL_H #define LANGUAGE_MODEL_H +#include #include -#include "List.h" #include "PackageInfo.h" typedef BReference LanguageRef; -typedef List LanguageList; class LanguageModel { @@ -21,14 +20,14 @@ public: LanguageModel(); virtual ~LanguageModel(); - const LanguageList& SupportedLanguages() const - { return fSupportedLanguages; } - void AddSupportedLanguages( - const LanguageList& languages); + const int32 CountSupportedLanguages() const; + const LanguageRef SupportedLanguageAt(int32 index) const; + void AddSupportedLanguage(const LanguageRef& value); int32 IndexOfSupportedLanguage( const BString& languageCode) const; + void SetPreferredLanguageToSystemDefault(); - const LanguageRef PreferredLanguage() const + const LanguageRef PreferredLanguage() const { return fPreferredLanguage; } private: @@ -39,7 +38,8 @@ private: void _SetPreferredLanguage(const Language& language); private: - LanguageList fSupportedLanguages; + std::vector + fSupportedLanguages; LanguageRef fPreferredLanguage; }; diff --git a/src/apps/haikudepot/model/Logger.h b/src/apps/haikudepot/model/Logger.h index a07870af37..cb16728499 100644 --- a/src/apps/haikudepot/model/Logger.h +++ b/src/apps/haikudepot/model/Logger.h @@ -24,11 +24,11 @@ #define HDLOGPREFIX(L) printf("{%c} ", toupper(Logger::NameForLevel(L)[0])); -#define HDLOG(L, M...) if (Logger::IsLevelEnabled(L)) { \ +#define HDLOG(L, M...) do { if (Logger::IsLevelEnabled(L)) { \ HDLOGPREFIX(L) \ printf(M); \ putchar('\n'); \ -} +} } while (0) #define HDINFO(M...) HDLOG(LOG_LEVEL_INFO, M) #define HDDEBUG(M...) HDLOG(LOG_LEVEL_DEBUG, M) diff --git a/src/apps/haikudepot/model/Model.cpp b/src/apps/haikudepot/model/Model.cpp index b355f42ebb..f30fb3c268 100644 --- a/src/apps/haikudepot/model/Model.cpp +++ b/src/apps/haikudepot/model/Model.cpp @@ -334,10 +334,10 @@ Model::~Model() } -LanguageModel& +LanguageModel* Model::Language() { - return fLanguageModel; + return &fLanguageModel; } @@ -645,16 +645,16 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags) BString code; if (item.FindString("code", &code) != B_OK) { HDERROR("corrupt user rating at index %" B_PRIi32, - index) + index); continue; } BString user; BMessage userInfo; if (item.FindMessage("user", &userInfo) != B_OK - || userInfo.FindString("nickname", &user) != B_OK) { + || userInfo.FindString("nickname", &user) != B_OK) { HDERROR("ignored user rating [%s] without a user " - "nickname", code.String()) + "nickname", code.String()); continue; } @@ -668,7 +668,7 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags) rating = -1; if (comment.Length() == 0 && rating == -1) { HDERROR("rating [%s] has no comment or rating so will" - " be ignored", code.String()) + " be ignored", code.String()); continue; } @@ -712,16 +712,15 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags) comment, languageCode, versionString, (uint64) createTimestamp); package->AddUserRating(userRating); - HDDEBUG("rating [%s] retrieved from server", code.String()) + HDDEBUG("rating [%s] retrieved from server", code.String()); } HDDEBUG("did retrieve %" B_PRIi32 " user ratings for [%s]", - index - 1, packageName.String()) + index - 1, packageName.String()); } else { _MaybeLogJsonRpcError(info, "retrieve user ratings"); } - } else { - HDERROR("unable to retrieve user ratings") - } + } else + HDERROR("unable to retrieve user ratings"); } if ((flags & POPULATE_SCREEN_SHOTS) != 0) { @@ -761,16 +760,14 @@ Model::_PopulatePackageChangelog(const PackageInfoRef& package) && 0 != content.Length()) { BAutolock locker(&fLock); package->SetChangelog(content); - HDDEBUG("changelog populated for [%s]", packageName.String()) - } else { - HDDEBUG("no changelog present for [%s]", packageName.String()) - } - } else { + HDDEBUG("changelog populated for [%s]", packageName.String()); + } else + HDDEBUG("no changelog present for [%s]", packageName.String()); + } else _MaybeLogJsonRpcError(info, "populate package changelog"); - } } else { HDERROR("unable to obtain the changelog for the package [%s]", - packageName.String()) + packageName.String()); } } @@ -792,14 +789,14 @@ model_remove_key_for_user(const BString& nickname) result = keyStore.RemoveKey(kHaikuDepotKeyring, key); if (result != B_OK) { HDERROR("error occurred when removing password for nickname " - "[%s] : %s", nickname.String(), strerror(result)) + "[%s] : %s", nickname.String(), strerror(result)); } break; case B_ENTRY_NOT_FOUND: return; default: HDERROR("error occurred when finding password for nickname " - "[%s] : %s", nickname.String(), strerror(result)) + "[%s] : %s", nickname.String(), strerror(result)); break; } } @@ -884,11 +881,11 @@ Model::SetAuthorization(const BString& nickname, const BString& passwordClear, */ status_t -Model::DumpExportRepositoryDataPath(BPath& path) const +Model::DumpExportRepositoryDataPath(BPath& path) { BString leaf; leaf.SetToFormat("repository-all_%s.json.gz", - LanguageModel().PreferredLanguage()->Code()); + Language()->PreferredLanguage()->Code()); return StorageUtils::LocalWorkingFilesPath(leaf, path); } @@ -899,11 +896,11 @@ Model::DumpExportRepositoryDataPath(BPath& path) const */ status_t -Model::DumpExportReferenceDataPath(BPath& path) const +Model::DumpExportReferenceDataPath(BPath& path) { BString leaf; leaf.SetToFormat("reference-all_%s.json.gz", - LanguageModel().PreferredLanguage()->Code()); + Language()->PreferredLanguage()->Code()); return StorageUtils::LocalWorkingFilesPath(leaf, path); } @@ -917,11 +914,11 @@ Model::IconStoragePath(BPath& path) const status_t Model::DumpExportPkgDataPath(BPath& path, - const BString& repositorySourceCode) const + const BString& repositorySourceCode) { BString leaf; leaf.SetToFormat("pkg-all-%s-%s.json.gz", repositorySourceCode.String(), - LanguageModel().PreferredLanguage()->Code()); + Language()->PreferredLanguage()->Code()); return StorageUtils::LocalWorkingFilesPath(leaf, path); } @@ -938,7 +935,7 @@ Model::_PopulatePackageScreenshot(const PackageInfoRef& package, "Screenshots", screenshotCachePath); if (result != B_OK) { - HDERROR("unable to get the screenshot dir - unable to proceed") + HDERROR("unable to get the screenshot dir - unable to proceed"); return; } @@ -991,7 +988,7 @@ Model::_PopulatePackageScreenshot(const PackageInfoRef& package, } else { HDERROR("Failed to retrieve screenshot for code '%s' " "at %" B_PRIi32 "x%" B_PRIi32 ".", info.Code().String(), - scaledWidth, scaledHeight) + scaledWidth, scaledHeight); } } @@ -1055,11 +1052,11 @@ Model::LogDepotsWithNoWebAppRepositoryCode() const if (depot.URL().Length() > 0) { HDINFO("depot [%s] (%s) correlates with no repository in the" " the haiku depot server system", depot.Name().String(), - depot.URL().String()) + depot.URL().String()); } else { HDINFO("depot [%s] correlates with no repository in the" - " the haiku depot server system", depot.Name().String()) + " the haiku depot server system", depot.Name().String()); } } } @@ -1078,10 +1075,9 @@ Model::_MaybeLogJsonRpcError(const BMessage &responsePayload, && error.FindString("message", &errorMessage) == B_OK && error.FindDouble("code", &errorCode) == B_OK) { HDERROR("[%s] --> error : [%s] (%f)", sourceDescription, - errorMessage.String(), errorCode) - } else { - HDERROR("[%s] --> an undefined error has occurred", sourceDescription) - } + errorMessage.String(), errorCode); + } else + HDERROR("[%s] --> an undefined error has occurred", sourceDescription); } diff --git a/src/apps/haikudepot/model/Model.h b/src/apps/haikudepot/model/Model.h index 7612cf98ca..2ca85f72b5 100644 --- a/src/apps/haikudepot/model/Model.h +++ b/src/apps/haikudepot/model/Model.h @@ -70,7 +70,7 @@ public: Model(); virtual ~Model(); - LanguageModel& Language(); + LanguageModel* Language(); BLocker* Lock() { return &fLock; } @@ -153,10 +153,10 @@ public: void* context); status_t IconStoragePath(BPath& path) const; - status_t DumpExportReferenceDataPath(BPath& path) const; - status_t DumpExportRepositoryDataPath(BPath& path) const; + status_t DumpExportReferenceDataPath(BPath& path); + status_t DumpExportRepositoryDataPath(BPath& path); status_t DumpExportPkgDataPath(BPath& path, - const BString& repositorySourceCode) const; + const BString& repositorySourceCode); void LogDepotsWithNoWebAppRepositoryCode() const; diff --git a/src/apps/haikudepot/model/PackageInfo.cpp b/src/apps/haikudepot/model/PackageInfo.cpp index 0f023d56e1..f36cee2e1f 100644 --- a/src/apps/haikudepot/model/PackageInfo.cpp +++ b/src/apps/haikudepot/model/PackageInfo.cpp @@ -1176,7 +1176,7 @@ DepotInfo::SyncPackages(const PackageList& otherPackages) } if (!found) { HDINFO("%s: new package: '%s'", fName.String(), - otherPackage->Name().String()) + otherPackage->Name().String()); fPackages.Add(otherPackage); } } @@ -1184,7 +1184,7 @@ DepotInfo::SyncPackages(const PackageList& otherPackages) for (int32 i = packages.CountItems() - 1; i >= 0; i--) { const PackageInfoRef& package = packages.ItemAtFast(i); HDINFO("%s: removing package: '%s'", fName.String(), - package->Name().String()) + package->Name().String()); fPackages.Remove(package); } } diff --git a/src/apps/haikudepot/model/PackageManager.cpp b/src/apps/haikudepot/model/PackageManager.cpp index e18d528947..b7855286c5 100644 --- a/src/apps/haikudepot/model/PackageManager.cpp +++ b/src/apps/haikudepot/model/PackageManager.cpp @@ -164,17 +164,17 @@ public: return ex.Error(); } catch (BAbortedByUserException& ex) { HDINFO("Installation of package %s is aborted by user: %s", - packageNameString, ex.Message().String()) + packageNameString, ex.Message().String()); _SetDownloadedPackagesState(NONE); ref->SetState(state); return B_OK; } catch (BNothingToDoException& ex) { HDINFO("Nothing to do while installing package %s: %s", - packageNameString, ex.Message().String()) + packageNameString, ex.Message().String()); return B_OK; } catch (BException& ex) { HDERROR("Exception occurred while installing package %s: %s", - packageNameString, ex.Message().String()) + packageNameString, ex.Message().String()); _SetDownloadedPackagesState(NONE); ref->SetState(state); return B_ERROR; @@ -291,7 +291,7 @@ public: return B_OK; } catch (BException& ex) { HDERROR("Exception occurred while uninstalling package %s: %s", - packageName, ex.Message().String()) + packageName, ex.Message().String()); ref->SetState(state); return B_ERROR; } @@ -391,7 +391,7 @@ public: if (path.FindFirst("data/deskbar/menu") == 0 && entry->SymlinkPath() != NULL) { HDINFO("found deskbar entry: %s -> %s", - path.String(), entry->SymlinkPath()) + path.String(), entry->SymlinkPath()); fDeskbarLinks.Add(DeskbarLink(path, entry->SymlinkPath())); } return B_OK; @@ -463,7 +463,7 @@ public: BPath path; if (fDeskbarLink.link.FindFirst('/') == 0) { status = path.SetTo(fDeskbarLink.link); - HDINFO("trying to launch (absolute link): %s", path.Path()) + HDINFO("trying to launch (absolute link): %s", path.Path()); } else { int32 location = InstallLocation(); if (location == B_PACKAGE_INSTALLATION_LOCATION_SYSTEM) { @@ -483,7 +483,7 @@ public: status = path.GetParent(&path); if (status == B_OK) { status = path.Append(fDeskbarLink.link, true); - HDINFO("trying to launch: %s", path.Path()) + HDINFO("trying to launch: %s", path.Path()); } } @@ -518,7 +518,7 @@ public: } } else { HDINFO("OpenPackageAction::FindAppToLaunch(): " - "unknown install location") + "unknown install location"); return false; } @@ -531,7 +531,7 @@ public: if (status != B_OK) { HDINFO("OpenPackageAction::FindAppToLaunch(): " "failed to init BPackageReader(%s): %s", - packagePath.Path(), strerror(status)) + packagePath.Path(), strerror(status)); return false; } @@ -541,7 +541,7 @@ public: if (status != B_OK) { HDINFO("OpenPackageAction::FindAppToLaunch(): " "failed parse package contents (%s): %s", - packagePath.Path(), strerror(status)) + packagePath.Path(), strerror(status)); return false; } @@ -635,11 +635,11 @@ PackageManager::RefreshRepository(const BRepositoryConfig& repoConfig) result = BPackageManager::RefreshRepository(repoConfig); } catch (BFatalErrorException& ex) { HDERROR("Fatal error occurred while refreshing repository: " - "%s (%s)", ex.Message().String(), ex.Details().String()) + "%s (%s)", ex.Message().String(), ex.Details().String()); result = ex.Error(); } catch (BException& ex) { HDERROR("Exception occurred while refreshing " - "repository: %s\n", ex.Message().String()) + "repository: %s\n", ex.Message().String()); result = B_ERROR; } @@ -658,11 +658,11 @@ PackageManager::DownloadPackage(const BString& fileURL, } catch (BFatalErrorException& ex) { HDERROR("Fatal error occurred while downloading package: " "%s: %s (%s)", fileURL.String(), ex.Message().String(), - ex.Details().String()) + ex.Details().String()); result = ex.Error(); } catch (BException& ex) { HDERROR("Exception occurred while downloading package " - "%s: %s", fileURL.String(), ex.Message().String()) + "%s: %s", fileURL.String(), ex.Message().String()); result = B_ERROR; } diff --git a/src/apps/haikudepot/model/UserUsageConditions.cpp b/src/apps/haikudepot/model/UserUsageConditions.cpp index 55f0b8abfc..1659f3eed4 100644 --- a/src/apps/haikudepot/model/UserUsageConditions.cpp +++ b/src/apps/haikudepot/model/UserUsageConditions.cpp @@ -24,14 +24,13 @@ UserUsageConditions::UserUsageConditions(BMessage* from) int16 minimumAge; if (from->FindInt16(KEY_MINIMUM_AGE, &minimumAge) != B_OK) - HDERROR("expected key [%s] in the message data", KEY_MINIMUM_AGE) + HDERROR("expected key [%s] in the message data", KEY_MINIMUM_AGE); fMinimumAge = (uint8) minimumAge; if (from->FindString(KEY_CODE, &fCode) != B_OK) - HDERROR("expected key [%s] in the message data", KEY_CODE) - + HDERROR("expected key [%s] in the message data", KEY_CODE); if (from->FindString(KEY_COPY_MARKDOWN, &fCopyMarkdown) != B_OK) - HDERROR("expected key [%s] in the message data", KEY_COPY_MARKDOWN) + HDERROR("expected key [%s] in the message data", KEY_COPY_MARKDOWN); } diff --git a/src/apps/haikudepot/server/AbstractProcess.cpp b/src/apps/haikudepot/server/AbstractProcess.cpp index 31d104ba6f..9c949fcb4a 100644 --- a/src/apps/haikudepot/server/AbstractProcess.cpp +++ b/src/apps/haikudepot/server/AbstractProcess.cpp @@ -47,12 +47,12 @@ AbstractProcess::Run() AutoLocker locker(&fLock); if (ProcessState() != PROCESS_INITIAL) { - HDINFO("cannot start process as it is not idle") + HDINFO("cannot start process as it is not idle"); return B_NOT_ALLOWED; } if (fWasStopped) { - HDINFO("cannot start process as it was stopped") + HDINFO("cannot start process as it was stopped"); return B_CANCELED; } @@ -62,7 +62,7 @@ AbstractProcess::Run() status_t runResult = RunInternal(); if (runResult != B_OK) - HDERROR("[%s] an error has arisen; %s", Name(), strerror(runResult)) + HDERROR("[%s] an error has arisen; %s", Name(), strerror(runResult)); BReference listener; diff --git a/src/apps/haikudepot/server/AbstractServerProcess.cpp b/src/apps/haikudepot/server/AbstractServerProcess.cpp index 957d1b9297..6010a705dc 100644 --- a/src/apps/haikudepot/server/AbstractServerProcess.cpp +++ b/src/apps/haikudepot/server/AbstractServerProcess.cpp @@ -124,7 +124,7 @@ AbstractServerProcess::IfModifiedSinceHeaderValue(BString& headerValue, } else { HDERROR("unable to parse the meta-data date and time from [%s]" " - cannot set the 'If-Modified-Since' header", - metaDataPath.Path()) + metaDataPath.Path()); } return result; @@ -149,7 +149,7 @@ AbstractServerProcess::PopulateMetaData( if (!metaData.IsPopulated()) { HDERROR("the meta data was read from [%s], but no values " - "were extracted", path.Path()) + "were extracted", path.Path()); return B_BAD_DATA; } @@ -180,7 +180,7 @@ AbstractServerProcess::ParseJsonFromFileWithListener( if (file == NULL) { HDERROR("[%s] unable to find the meta data file at [%s]", Name(), - path.Path()) + path.Path()); return B_FILE_NOT_FOUND; } @@ -241,7 +241,7 @@ AbstractServerProcess::DownloadToLocalFileAtomically( if (result == B_OK && hasFile && size > 0) { if (rename(temporaryFilePath.Path(), targetFilePath.Path()) != 0) { HDINFO("[%s] did rename [%s] --> [%s]", - Name(), temporaryFilePath.Path(), targetFilePath.Path()) + Name(), temporaryFilePath.Path(), targetFilePath.Path()); result = B_IO_ERROR; } } @@ -260,17 +260,17 @@ AbstractServerProcess::DownloadToLocalFile(const BPath& targetFilePath, if (redirects > MAX_REDIRECTS) { HDINFO("[%s] exceeded %d redirects --> failure", Name(), - MAX_REDIRECTS) + MAX_REDIRECTS); return B_IO_ERROR; } if (failures > MAX_FAILURES) { - HDINFO("[%s] exceeded %d failures", Name(), MAX_FAILURES) + HDINFO("[%s] exceeded %d failures", Name(), MAX_FAILURES); return B_IO_ERROR; } HDINFO("[%s] will stream '%s' to [%s]", Name(), url.UrlString().String(), - targetFilePath.Path()) + targetFilePath.Path()); ToFileUrlProtocolListener listener(targetFilePath, Name(), Logger::IsTraceEnabled()); @@ -315,11 +315,11 @@ AbstractServerProcess::DownloadToLocalFile(const BPath& targetFilePath, if (BHttpRequest::IsSuccessStatusCode(statusCode)) { HDINFO("[%s] did complete streaming data [%" - B_PRIdSSIZE " bytes]", Name(), listener.ContentLength()) + B_PRIdSSIZE " bytes]", Name(), listener.ContentLength()); return B_OK; } else if (statusCode == B_HTTP_STATUS_NOT_MODIFIED) { HDINFO("[%s] remote data has not changed since [%s]", Name(), - ifModifiedSinceHeader.String()) + ifModifiedSinceHeader.String()); return HD_ERR_NOT_MODIFIED; } else if (statusCode == B_HTTP_STATUS_PRECONDITION_FAILED) { ServerHelper::NotifyClientTooOld(responseHeaders); @@ -328,23 +328,23 @@ AbstractServerProcess::DownloadToLocalFile(const BPath& targetFilePath, if (location.Length() != 0) { BUrl redirectUrl(result.Url(), location); HDINFO("[%s] will redirect to; %s", - Name(), redirectUrl.UrlString().String()) + Name(), redirectUrl.UrlString().String()); return DownloadToLocalFile(targetFilePath, redirectUrl, redirects + 1, 0); } - HDERROR("[%s] unable to find 'Location' header for redirect", Name()) + HDERROR("[%s] unable to find 'Location' header for redirect", Name()); return B_IO_ERROR; } else { if (statusCode == 0 || (statusCode / 100) == 5) { HDERROR("error response from server [%" B_PRId32 "] --> retry...", - statusCode) + statusCode); return DownloadToLocalFile(targetFilePath, url, redirects, failures + 1); } HDERROR("[%s] unexpected response from server [%" B_PRId32 "]", - Name(), statusCode) + Name(), statusCode); return B_IO_ERROR; } } @@ -378,12 +378,12 @@ AbstractServerProcess::MoveDamagedFileAside(const BPath& currentFilePath) if (0 != rename(currentFilePath.Path(), damagedFilePath.Path())) { HDERROR("[%s] unable to move damaged file [%s] aside to [%s]", - Name(), currentFilePath.Path(), damagedFilePath.Path()) + Name(), currentFilePath.Path(), damagedFilePath.Path()); return B_IO_ERROR; } HDINFO("[%s] did move damaged file [%s] aside to [%s]", - Name(), currentFilePath.Path(), damagedFilePath.Path()) + Name(), currentFilePath.Path(), damagedFilePath.Path()); return B_OK; } diff --git a/src/apps/haikudepot/server/AbstractSingleFileServerProcess.cpp b/src/apps/haikudepot/server/AbstractSingleFileServerProcess.cpp index e7c052a566..a506f662d9 100644 --- a/src/apps/haikudepot/server/AbstractSingleFileServerProcess.cpp +++ b/src/apps/haikudepot/server/AbstractSingleFileServerProcess.cpp @@ -29,7 +29,7 @@ AbstractSingleFileServerProcess::~AbstractSingleFileServerProcess() status_t AbstractSingleFileServerProcess::RunInternal() { - HDINFO("[%s] will fetch data", Name()) + HDINFO("[%s] will fetch data", Name()); BPath localPath; status_t result = GetLocalPath(localPath); @@ -57,14 +57,12 @@ AbstractSingleFileServerProcess::RunInternal() if (!IsSuccess(result)) { if (hasData) { HDINFO("[%s] failed to update data, but have old data " - "anyway so carry on with that", Name()) + "anyway so carry on with that", Name()); result = B_OK; - } else { - HDERROR("[%s] failed to obtain data", Name()) - } - } else { - HDINFO("[%s] did fetch data", Name()) - } + } else + HDERROR("[%s] failed to obtain data", Name()); + } else + HDINFO("[%s] did fetch data", Name()); } if (IsSuccess(result)) { @@ -78,12 +76,12 @@ AbstractSingleFileServerProcess::RunInternal() } if (IsSuccess(result)) { - HDINFO("[%s] will process data", Name()) + HDINFO("[%s] will process data", Name()); result = ProcessLocalData(); switch (result) { case B_OK: - HDINFO("[%s] did process data", Name()) + HDINFO("[%s] did process data", Name()); break; default: MoveDamagedFileAside(localPath); diff --git a/src/apps/haikudepot/server/LocalPkgDataLoadProcess.cpp b/src/apps/haikudepot/server/LocalPkgDataLoadProcess.cpp index aeda14d8b3..63fc7cbc87 100644 --- a/src/apps/haikudepot/server/LocalPkgDataLoadProcess.cpp +++ b/src/apps/haikudepot/server/LocalPkgDataLoadProcess.cpp @@ -89,7 +89,7 @@ LocalPkgDataLoadProcess::Description() const status_t LocalPkgDataLoadProcess::RunInternal() { - HDDEBUG("[%s] will refresh the package list", Name()) + HDDEBUG("[%s] will refresh the package list", Name()); BPackageRoster roster; BStringList repositoryNames; @@ -110,11 +110,11 @@ LocalPkgDataLoadProcess::RunInternal() if (getRepositoryConfigStatus == B_OK) { depotInfo.SetURL(repoConfig.Identifier()); HDDEBUG("[%s] local repository [%s] identifier; [%s]", - Name(), repoName.String(), repoConfig.Identifier().String()) + Name(), repoName.String(), repoConfig.Identifier().String()); } else { HDINFO("[%s] unable to obtain the repository config for local " "repository '%s'; %s", Name(), - repoName.String(), strerror(getRepositoryConfigStatus)) + repoName.String(), strerror(getRepositoryConfigStatus)); } depots[i] = depotInfo; @@ -221,7 +221,7 @@ LocalPkgDataLoadProcess::RunInternal() if (it == depots.end()) { HDDEBUG("pkg [%s] repository [%s] not recognized --> ignored", - modelInfo->Name().String(), repositoryName.String()) + modelInfo->Name().String(), repositoryName.String()); } else { it->AddPackage(modelInfo); HDTRACE("pkg [%s] assigned to [%s]", @@ -352,18 +352,18 @@ LocalPkgDataLoadProcess::RunInternal() } } catch (BFatalErrorException& ex) { HDERROR("Fatal exception occurred while resolving system dependencies: " - "%s, details: %s", strerror(ex.Error()), ex.Details().String()) + "%s, details: %s", strerror(ex.Error()), ex.Details().String()); } catch (BNothingToDoException&) { // do nothing } catch (BException& ex) { HDERROR("Exception occurred while resolving system dependencies: %s", - ex.Message().String()) + ex.Message().String()); } catch (...) { HDERROR("Unknown exception occurred while resolving system " - "dependencies.") + "dependencies."); } - HDDEBUG("did refresh the package list") + HDDEBUG("did refresh the package list"); return B_OK; } @@ -373,7 +373,7 @@ void LocalPkgDataLoadProcess::_NotifyError(const BString& messageText) const { HDERROR("an error has arisen loading data of packages from local : %s", - messageText.String()) + messageText.String()); AppUtils::NotifySimpleError( B_TRANSLATE("Local repository load error"), messageText); diff --git a/src/apps/haikudepot/server/LocalRepositoryUpdateProcess.cpp b/src/apps/haikudepot/server/LocalRepositoryUpdateProcess.cpp index d963e62dc0..201d5e1431 100644 --- a/src/apps/haikudepot/server/LocalRepositoryUpdateProcess.cpp +++ b/src/apps/haikudepot/server/LocalRepositoryUpdateProcess.cpp @@ -66,7 +66,7 @@ LocalRepositoryUpdateProcess::RunInternal() { BPackageRoster roster; BStringList repoNames; - HDINFO("[%s] will update local repositories' caches", Name()) + HDINFO("[%s] will update local repositories' caches", Name()); status_t result = roster.GetRepositoryNames(repoNames); @@ -90,7 +90,7 @@ LocalRepositoryUpdateProcess::RunInternal() if (result == B_OK) { HDINFO("[%s] did update %" B_PRIi32 " local repositories' caches", - Name(), repoNames.CountStrings()) + Name(), repoNames.CountStrings()); } return result; @@ -104,24 +104,24 @@ LocalRepositoryUpdateProcess::_ShouldRunForRepositoryName( { if (fForce) { HDINFO("[%s] am refreshing cache for repo [%s] as it was forced", - Name(), repoName.String()) + Name(), repoName.String()); return true; } if (roster.GetRepositoryCache(repoName, cache) != B_OK) { HDINFO("[%s] am updating cache for repo [%s] as there was no cache", - Name(), repoName.String()) + Name(), repoName.String()); return true; } if (static_cast(be_app)->IsFirstRun()) { HDINFO("[%s] am updating cache for repo [%s] as this is the first" - " time that the application has run", Name(), repoName.String()) + " time that the application has run", Name(), repoName.String()); return true; } HDDEBUG("[%s] skipped update local repo [%s] cache", Name(), - repoName.String()) + repoName.String()); return false; } @@ -169,7 +169,7 @@ LocalRepositoryUpdateProcess::_NotifyError(const BString& error, const BString& details) const { HDINFO("an error has arisen updating the local repositories : %s", - error.String()) + error.String()); BString alertText(B_TRANSLATE("An error occurred while refreshing the " "repository: %error%")); diff --git a/src/apps/haikudepot/server/ProcessCoordinator.cpp b/src/apps/haikudepot/server/ProcessCoordinator.cpp index 0845daaed2..68e414b9f7 100644 --- a/src/apps/haikudepot/server/ProcessCoordinator.cpp +++ b/src/apps/haikudepot/server/ProcessCoordinator.cpp @@ -142,7 +142,7 @@ ProcessCoordinator::Stop() AutoLocker locker(&fLock); if (!fWasStopped) { fWasStopped = true; - HDINFO("[Coordinator] will stop process coordinator") + HDINFO("[Coordinator] will stop process coordinator"); for (int32 i = 0; i < fNodes.CountItems(); i++) { ProcessNode* node = fNodes.ItemAt(i); if (node->Process()->ErrorStatus() != B_OK) { @@ -263,7 +263,7 @@ ProcessCoordinator::_CoordinateAndCallListener() ProcessCoordinatorState ProcessCoordinator::_Coordinate() { - HDTRACE("[Coordinator] will coordinate nodes") + HDTRACE("[Coordinator] will coordinate nodes"); AutoLocker locker(&fLock); _StopSuccessorNodesToErroredOrStoppedNodes(); @@ -315,7 +315,7 @@ ProcessCoordinator::_StopSuccessorNodes(ProcessNode* predecessorNode) if (process->ProcessState() == PROCESS_INITIAL) { HDDEBUG("[Coordinator] [%s] (failed) --> [%s] (stopping)", - predecessorNode->Process()->Name(), process->Name()) + predecessorNode->Process()->Name(), process->Name()); node->StopProcess(); _StopSuccessorNodes(node); } diff --git a/src/apps/haikudepot/server/ProcessCoordinatorFactory.cpp b/src/apps/haikudepot/server/ProcessCoordinatorFactory.cpp index 6c817eeaf1..8c65869cd7 100644 --- a/src/apps/haikudepot/server/ProcessCoordinatorFactory.cpp +++ b/src/apps/haikudepot/server/ProcessCoordinatorFactory.cpp @@ -108,15 +108,14 @@ ProcessCoordinatorFactory::CreateBulkLoadCoordinator( for (int32 i = 0; i < repoNames.CountStrings(); i++) { ProcessNode* processNode = new ProcessNode( new ServerPkgDataUpdateProcess( - model->Language().PreferredLanguage()->Code(), + model->Language()->PreferredLanguage()->Code(), repoNames.StringAt(i), model, serverProcessOptions)); processNode->AddPredecessor(serverRepositoryDataUpdate); processNode->AddPredecessor(serverReferenceDataUpdate); processCoordinator->AddNode(processNode); } - } else { - HDERROR("a problem has arisen getting the repository names.") - } + } else + HDERROR("a problem has arisen getting the repository names."); } return processCoordinator; @@ -130,7 +129,7 @@ ProcessCoordinatorFactory::_CalculateServerProcessOptions() if (ServerSettings::IsClientTooOld()) { HDINFO("bulk load proceeding without network communications " - "because the client is too old") + "because the client is too old"); processOptions |= SERVER_PROCESS_NO_NETWORKING; } diff --git a/src/apps/haikudepot/server/ProcessNode.cpp b/src/apps/haikudepot/server/ProcessNode.cpp index ad0c93b1ec..cff516b24e 100644 --- a/src/apps/haikudepot/server/ProcessNode.cpp +++ b/src/apps/haikudepot/server/ProcessNode.cpp @@ -59,7 +59,7 @@ ProcessNode::_SpinUntilProcessState( if (real_time_clock() - start > timeoutSeconds) { HDERROR("[Node<%s>] timeout waiting for process state", - Process()->Name()) + Process()->Name()); return B_ERROR; } } @@ -75,7 +75,7 @@ ProcessNode::StartProcess() if (fWorker != B_BAD_THREAD_ID) return B_BUSY; - HDINFO("[Node<%s>] initiating", Process()->Name()) + HDINFO("[Node<%s>] initiating", Process()->Name()); fWorker = spawn_thread(&_StartProcess, Process()->Name(), B_NORMAL_PRIORITY, Process()); @@ -106,7 +106,7 @@ ProcessNode::StopProcess() if (waitResult != B_OK) { HDINFO("[%s] process did not stop within timeout - will be stopped " - "uncleanly", Process()->Name()) + "uncleanly", Process()->Name()); kill_thread(fWorker); } @@ -129,7 +129,7 @@ ProcessNode::_StartProcess(void* cookie) { AbstractProcess* process = static_cast(cookie); - HDINFO("[Node<%s>] starting process", process->Name()) + HDINFO("[Node<%s>] starting process", process->Name()); process->Run(); return B_OK; diff --git a/src/apps/haikudepot/server/ServerIconExportUpdateProcess.cpp b/src/apps/haikudepot/server/ServerIconExportUpdateProcess.cpp index 2f45ad8916..e0b3a29305 100644 --- a/src/apps/haikudepot/server/ServerIconExportUpdateProcess.cpp +++ b/src/apps/haikudepot/server/ServerIconExportUpdateProcess.cpp @@ -39,7 +39,7 @@ ServerIconExportUpdateProcess::ServerIconExportUpdateProcess( { AutoLocker locker(fModel->Lock()); if (fModel->IconStoragePath(fLocalIconStoragePath) != B_OK) { - HDINFO("[%s] unable to obtain the path for storing icons", Name()) + HDINFO("[%s] unable to obtain the path for storing icons", Name()); fLocalIconStoragePath.Unset(); fLocalIconStore = NULL; } else { @@ -116,7 +116,7 @@ ServerIconExportUpdateProcess::Populate() } HDDEBUG("[%s] will populate icons for %" B_PRId32 " depots", Name(), - depots.CountItems()) + depots.CountItems()); for (int32 i = 0; (i < depots.CountItems()) && !WasStopped() && (result == B_OK); @@ -129,7 +129,7 @@ ServerIconExportUpdateProcess::Populate() if (Logger::IsInfoEnabled()) { double secs = watch.ElapsedTime() / 1000000.0; HDINFO("[%s] did populate %" B_PRId32 " packages' icons (%6.3g secs)", - Name(), fCountIconsSet, secs) + Name(), fCountIconsSet, secs); } return result; @@ -142,7 +142,7 @@ status_t ServerIconExportUpdateProcess::PopulateForDepot(const DepotInfo& depot) { HDINFO("[%s] will populate icons for depot [%s]", - Name(), depot.Name().String()) + Name(), depot.Name().String()); status_t result = B_OK; const PackageList& packages = depot.Packages(); for(int32 j = 0; @@ -174,7 +174,7 @@ ServerIconExportUpdateProcess::PopulateForPkg(const PackageInfoRef& package) package->SetIcon(bitmapRef); HDDEBUG("[%s] have set the package icon for [%s] from [%s]", - Name(), package->Name().String(), bestIconPath.Path()) + Name(), package->Name().String(), bestIconPath.Path()); fCountIconsSet++; @@ -182,7 +182,7 @@ ServerIconExportUpdateProcess::PopulateForPkg(const PackageInfoRef& package) } HDDEBUG("[%s] did not set the package icon for [%s]; no data", - Name(), package->Name().String()) + Name(), package->Name().String()); return B_FILE_NOT_FOUND; } @@ -194,15 +194,14 @@ ServerIconExportUpdateProcess::_DownloadAndUnpack() BPath tarGzFilePath(tmpnam(NULL)); status_t result = B_OK; - HDINFO("[%s] will start fetching icons", Name()) + HDINFO("[%s] will start fetching icons", Name()); result = _Download(tarGzFilePath); switch (result) { case HD_ERR_NOT_MODIFIED: - HDINFO("[%s] icons not modified - will use existing", Name()) + HDINFO("[%s] icons not modified - will use existing", Name()); return result; - break; case B_OK: return _Unpack(tarGzFilePath); default: @@ -225,13 +224,13 @@ ServerIconExportUpdateProcess::_HandleDownloadFailure() if (result == B_OK) { if (hasData) { HDINFO("[%s] failed to update data, but have old data anyway " - "so will carry on with that", Name()) + "so will carry on with that", Name()); } else { - HDINFO("[%s] failed to obtain data", Name()) + HDINFO("[%s] failed to obtain data", Name()); result = HD_ERR_NO_DATA; } } else { - HDERROR("[%s] unable to detect if there is local data\n", Name()) + HDERROR("[%s] unable to detect if there is local data\n", Name()); } return result; @@ -246,7 +245,7 @@ status_t ServerIconExportUpdateProcess::_Unpack(BPath& tarGzFilePath) { status_t result; - HDINFO("[%s] delete any existing stored data", Name()) + HDINFO("[%s] delete any existing stored data", Name()); StorageUtils::RemoveDirectoryContents(fLocalIconStoragePath); BFile *tarGzFile = new BFile(tarGzFilePath.Path(), O_RDONLY); @@ -269,17 +268,17 @@ ServerIconExportUpdateProcess::_Unpack(BPath& tarGzFilePath) if (result == B_OK) { double secs = watch.ElapsedTime() / 1000000.0; - HDINFO("[%s] did unpack icon tgz in (%6.3g secs)", Name(), secs) + HDINFO("[%s] did unpack icon tgz in (%6.3g secs)", Name(), secs); if (0 != remove(tarGzFilePath.Path())) { HDERROR("[%s] unable to delete the temporary tgz path; %s", - Name(), tarGzFilePath.Path()) + Name(), tarGzFilePath.Path()); } } } delete tarGzFile; - HDINFO("[%s] did complete unpacking icons", Name()) + HDINFO("[%s] did complete unpacking icons", Name()); return result; } diff --git a/src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp b/src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp index 04de547d6d..c932d9236e 100644 --- a/src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp +++ b/src/apps/haikudepot/server/ServerPkgDataUpdateProcess.cpp @@ -144,7 +144,7 @@ PackageFillingPkgListener::ConsumePackage(const PackageInfoRef& package, if (categoryIndex == -1) { HDERROR("unable to find the category for [%s]", - categoryCode->String()) + categoryCode->String()); } else { package->AddCategory( fCategories.ItemAtFast(categoryIndex)); @@ -177,7 +177,7 @@ PackageFillingPkgListener::ConsumePackage(const PackageInfoRef& package, } HDDEBUG("did populate data for [%s] (%s)", pkg->Name()->String(), - fDepotName.String()) + fDepotName.String()); fCount++; @@ -212,11 +212,11 @@ PackageFillingPkgListener::Handle(DumpExportPkg* pkg) ConsumePackage(packageInfoRef, pkg); } else { HDINFO("[PackageFillingPkgListener] unable to find the pkg [%s]", - packageName.String()) + packageName.String()); } } else { HDINFO("[PackageFillingPkgListener] unable to find the depot [%s]", - fDepotName.String()) + fDepotName.String()); } return !fStoppable->WasStopped(); @@ -321,7 +321,7 @@ ServerPkgDataUpdateProcess::ProcessLocalData() if (Logger::IsInfoEnabled()) { double secs = watch.ElapsedTime() / 1000000.0; HDINFO("[%s] did process %" B_PRIi32 " packages' data " - "in (%6.3g secs)", Name(), itemListener->Count(), secs) + "in (%6.3g secs)", Name(), itemListener->Count(), secs); } return listener->ErrorStatus(); @@ -362,7 +362,7 @@ ServerPkgDataUpdateProcess::RunInternal() if (_DeriveWebAppRepositorySourceCode().IsEmpty()) { HDINFO("[%s] am not updating data for depot [%s] as there is no" " web app repository source code available", - Name(), fDepotName.String()) + Name(), fDepotName.String()); return B_OK; } diff --git a/src/apps/haikudepot/server/ServerReferenceDataUpdateProcess.cpp b/src/apps/haikudepot/server/ServerReferenceDataUpdateProcess.cpp index c0680c0fe0..04348c91d7 100644 --- a/src/apps/haikudepot/server/ServerReferenceDataUpdateProcess.cpp +++ b/src/apps/haikudepot/server/ServerReferenceDataUpdateProcess.cpp @@ -66,7 +66,7 @@ ServerReferenceDataUpdateProcess::UrlPathComponent() BString result; AutoLocker locker(fModel->Lock()); result.SetToFormat("/__reference/all-%s.json.gz", - fModel->Language().PreferredLanguage()->Code()); + fModel->Language()->PreferredLanguage()->Code()); return result; } @@ -122,29 +122,29 @@ ServerReferenceDataUpdateProcess::_ProcessNaturalLanguages( DumpExportReference* data) { HDINFO("[%s] will populate %" B_PRId32 " natural languages", - Name(), data->CountNaturalLanguages()) - - LanguageList result; + Name(), data->CountNaturalLanguages()); + AutoLocker locker(fModel->Lock()); + LanguageModel* languageModel = fModel->Language(); + int32 count = 0; for (int32 i = 0; i < data->CountNaturalLanguages(); i++) { DumpExportReferenceNaturalLanguage* naturalLanguage = data->NaturalLanguagesItemAt(i); - result.Add(LanguageRef( + languageModel->AddSupportedLanguage(LanguageRef( new Language( *(naturalLanguage->Code()), *(naturalLanguage->Name()), naturalLanguage->IsPopular() ), - true)); + true) + ); + count++; } - { - AutoLocker locker(fModel->Lock()); - fModel->Language().AddSupportedLanguages(result); - } + languageModel->SetPreferredLanguageToSystemDefault(); HDINFO("[%s] did add %" B_PRId32 " supported languages", - Name(), result.CountItems()) + Name(), count); return B_OK; } @@ -155,7 +155,7 @@ ServerReferenceDataUpdateProcess::_ProcessPkgCategories( DumpExportReference* data) { HDINFO("[%s] will populate %" B_PRId32 " pkg categories", - Name(), data->CountPkgCategories()) + Name(), data->CountPkgCategories()); CategoryList result; diff --git a/src/apps/haikudepot/server/ServerRepositoryDataUpdateProcess.cpp b/src/apps/haikudepot/server/ServerRepositoryDataUpdateProcess.cpp index 8a19e0da98..0aa1d6afd5 100644 --- a/src/apps/haikudepot/server/ServerRepositoryDataUpdateProcess.cpp +++ b/src/apps/haikudepot/server/ServerRepositoryDataUpdateProcess.cpp @@ -108,12 +108,12 @@ DepotMatchingRepositoryListener::MapDepot(const DepotInfo& depot, void *context) modifiedDepotInfo.URL().String(), repositorySourceCode->String(), repositoryAndRepositorySource - ->repositorySource->Identifier()->String()) + ->repositorySource->Identifier()->String()); } else { HDINFO("[DepotMatchingRepositoryListener] associated depot [%s] with " "server repository source [%s]", modifiedDepotInfo.Name().String(), - repositorySourceCode->String()) + repositorySourceCode->String()); } return modifiedDepotInfo; @@ -206,7 +206,7 @@ ServerRepositoryDataUpdateProcess::UrlPathComponent() BString result; AutoLocker locker(fModel->Lock()); result.SetToFormat("/__repository/all-%s.json.gz", - fModel->Language().PreferredLanguage()->Code()); + fModel->Language()->PreferredLanguage()->Code()); return result; } diff --git a/src/apps/haikudepot/server/ServerSettings.cpp b/src/apps/haikudepot/server/ServerSettings.cpp index 8479117dac..c477868f00 100644 --- a/src/apps/haikudepot/server/ServerSettings.cpp +++ b/src/apps/haikudepot/server/ServerSettings.cpp @@ -37,12 +37,12 @@ status_t ServerSettings::SetBaseUrl(const BUrl& value) { if (!value.IsValid()) { - HDERROR("the url is not valid") + HDERROR("the url is not valid"); return B_BAD_VALUE; } if (value.Protocol() != "http" && value.Protocol() != "https") { - HDERROR("the url protocol must be 'http' or 'https'") + HDERROR("the url protocol must be 'http' or 'https'"); return B_BAD_VALUE; } @@ -83,7 +83,7 @@ ServerSettings::_GetUserAgentVersionString() app_info info; if (be_app->GetAppInfo(&info) != B_OK) { - HDERROR("Unable to get the application info") + HDERROR("Unable to get the application info"); be_app->Quit(); return BString(USERAGENT_FALLBACK_VERSION); } @@ -91,7 +91,7 @@ ServerSettings::_GetUserAgentVersionString() BFile file(&info.ref, B_READ_ONLY); if (file.InitCheck() != B_OK) { - HDERROR("Unable to access the application info file") + HDERROR("Unable to access the application info file"); be_app->Quit(); return BString(USERAGENT_FALLBACK_VERSION); } @@ -100,8 +100,8 @@ ServerSettings::_GetUserAgentVersionString() version_info versionInfo; if (appFileInfo.GetVersionInfo( - &versionInfo, B_APP_VERSION_KIND) != B_OK) { - HDERROR("Unable to establish the application version") + &versionInfo, B_APP_VERSION_KIND) != B_OK) { + HDERROR("Unable to establish the application version"); be_app->Quit(); return BString(USERAGENT_FALLBACK_VERSION); } diff --git a/src/apps/haikudepot/server/StandardMetaDataJsonEventListener.cpp b/src/apps/haikudepot/server/StandardMetaDataJsonEventListener.cpp index 1573732239..28077f86c5 100644 --- a/src/apps/haikudepot/server/StandardMetaDataJsonEventListener.cpp +++ b/src/apps/haikudepot/server/StandardMetaDataJsonEventListener.cpp @@ -385,7 +385,7 @@ StandardMetaDataJsonEventListener::HandleError(status_t status, int32 line, const char* message) { HDERROR("an error has arisen processing the standard " - "meta data; %s", message) + "meta data; %s", message); fErrorStatus = status; } diff --git a/src/apps/haikudepot/server/UserDetailVerifierProcess.cpp b/src/apps/haikudepot/server/UserDetailVerifierProcess.cpp index 000accc2f2..b7195cb4a6 100644 --- a/src/apps/haikudepot/server/UserDetailVerifierProcess.cpp +++ b/src/apps/haikudepot/server/UserDetailVerifierProcess.cpp @@ -63,7 +63,7 @@ UserDetailVerifierProcess::RunInternal() case B_OK: if (!userDetail.Agreement().IsLatest()) { HDINFO("the user has not agreed to the latest user usage" - " conditions.") + " conditions."); fListener->UserUsageConditionsNotLatest(userDetail); } break; @@ -80,7 +80,7 @@ bool UserDetailVerifierProcess::_ShouldVerify() { if (!ServerHelper::IsNetworkAvailable()) { - HDINFO("no network --> will not verify user") + HDINFO("no network --> will not verify user"); return false; } @@ -106,7 +106,7 @@ UserDetailVerifierProcess::_TryFetchUserDetail(UserDetail& userDetail) result = interface.RetrieveCurrentUserDetail(userDetailResponse); if (result != B_OK) { HDERROR("a problem has arisen retrieving the current user detail: %s", - strerror(result)) + strerror(result)); } if (result == B_OK) { @@ -120,7 +120,7 @@ UserDetailVerifierProcess::_TryFetchUserDetail(UserDetail& userDetail) default: HDERROR("a problem has arisen retrieving the current user " "detail for user [%s]: jrpc error code %" B_PRId32 "", - fModel->Nickname().String(), errorCode) + fModel->Nickname().String(), errorCode); result = B_ERROR; break; } @@ -134,7 +134,7 @@ UserDetailVerifierProcess::_TryFetchUserDetail(UserDetail& userDetail) result = interface.UnpackUserDetail(userDetailResponse, userDetail); if (result != B_OK) - HDERROR("it was not possible to unpack the user details.") + HDERROR("it was not possible to unpack the user details."); } return result; diff --git a/src/apps/haikudepot/server/WebAppInterface.cpp b/src/apps/haikudepot/server/WebAppInterface.cpp index 8cc415ac2c..9a1cba7f07 100644 --- a/src/apps/haikudepot/server/WebAppInterface.cpp +++ b/src/apps/haikudepot/server/WebAppInterface.cpp @@ -83,7 +83,7 @@ public: virtual void DebugMessage(BUrlRequest* caller, BUrlProtocolDebugMessage type, const char* text) { - HDTRACE("jrpc: %s", text) + HDTRACE("jrpc: %s", text); } void SetDownloadIO(BDataIO* downloadIO) @@ -400,7 +400,7 @@ WebAppInterface::RetrieveUserUsageConditions(const BString& code, BMessage resultMessage; if (responseEnvelopeMessage.FindMessage("result", &resultMessage) != B_OK) { - HDERROR("bad response envelope missing 'result' entry") + HDERROR("bad response envelope missing 'result' entry"); return B_BAD_DATA; } @@ -412,7 +412,7 @@ WebAppInterface::RetrieveUserUsageConditions(const BString& code, || (resultMessage.FindDouble( "minimumAge", &metaDataMinimumAge) != B_OK) ) { HDERROR("unexpected response from server with missing user usage " - "conditions data") + "conditions data"); return B_BAD_DATA; } @@ -806,27 +806,27 @@ WebAppInterface::_SendJsonRequest(const char* domain, size_t requestDataSize, uint32 flags, BMessage& reply) const { if (requestDataSize == 0) { - HDINFO("jrpc; empty request payload") + HDINFO("jrpc; empty request payload"); return B_ERROR; } if (!ServerHelper::IsNetworkAvailable()) { HDDEBUG("jrpc; dropping request to ...[%s] as network is not" - " available", domain) + " available", domain); delete requestData; return HD_NETWORK_INACCESSIBLE; } if (ServerSettings::IsClientTooOld()) { HDDEBUG("jrpc; dropping request to ...[%s] as client is too old", - domain) + domain); delete requestData; return HD_CLIENT_TOO_OLD; } BUrl url = ServerSettings::CreateFullUrl(BString("/__api/v1/") << domain); bool isSecure = url.Protocol() == "https"; - HDDEBUG("jrpc; will make request to [%s]", url.UrlString().String()) + HDDEBUG("jrpc; will make request to [%s]", url.UrlString().String()); // If the request payload is logged then it must be copied to local memory // from the stream. This then requires that the request data is then @@ -874,7 +874,7 @@ WebAppInterface::_SendJsonRequest(const char* domain, int32 statusCode = result.StatusCode(); HDDEBUG("jrpc; did receive http-status [%" B_PRId32 "] from [%s]", - statusCode, url.UrlString().String()) + statusCode, url.UrlString().String()); switch (statusCode) { case B_HTTP_STATUS_OK: @@ -886,7 +886,7 @@ WebAppInterface::_SendJsonRequest(const char* domain, default: HDERROR("jrpc request to endpoint [.../%s] failed with http " - "status [%" B_PRId32 "]\n", domain, statusCode) + "status [%" B_PRId32 "]\n", domain, statusCode); return B_ERROR; } @@ -906,7 +906,7 @@ WebAppInterface::_SendJsonRequest(const char* domain, if (Logger::IsTraceEnabled() && status == B_BAD_DATA) { BString resultString(static_cast(replyData.Buffer()), replyData.BufferLength()); - HDERROR("Parser choked on JSON:\n%s", resultString.String()) + HDERROR("Parser choked on JSON:\n%s", resultString.String()); } return status; } @@ -954,7 +954,7 @@ WebAppInterface::_SendRawGetRequest(const BString urlPathComponents, return B_OK; HDERROR("failed to get data from '%s': %" B_PRIi32 "", - url.UrlString().String(), statusCode) + url.UrlString().String(), statusCode); return B_ERROR; } diff --git a/src/apps/haikudepot/tar/TarArchiveHeader.cpp b/src/apps/haikudepot/tar/TarArchiveHeader.cpp index 1720f99244..387cc7bc53 100644 --- a/src/apps/haikudepot/tar/TarArchiveHeader.cpp +++ b/src/apps/haikudepot/tar/TarArchiveHeader.cpp @@ -117,7 +117,7 @@ TarArchiveHeader::CreateFromBlock(const unsigned char* block) if(actualChecksum != expectedChecksum) { HDERROR("tar archive header has bad checksum;" "expected %" B_PRIu32 " actual %" B_PRIu32, - expectedChecksum, actualChecksum) + expectedChecksum, actualChecksum); } else { return new TarArchiveHeader( _ReadString(&block[OFFSET_FILENAME], LENGTH_FILENAME), diff --git a/src/apps/haikudepot/tar/TarArchiveService.cpp b/src/apps/haikudepot/tar/TarArchiveService.cpp index dcc25f0f4f..42d2654806 100644 --- a/src/apps/haikudepot/tar/TarArchiveService.cpp +++ b/src/apps/haikudepot/tar/TarArchiveService.cpp @@ -26,7 +26,7 @@ TarArchiveService::Unpack(BDataIO& tarDataIo, BPath& targetDirectory, status_t result = B_OK; uint32_t count_items_read = 0; - HDINFO("will unpack to [%s]", targetDirectory.Path()) + HDINFO("will unpack to [%s]", targetDirectory.Path()); memset(zero_buffer, 0, sizeof zero_buffer); @@ -37,14 +37,14 @@ TarArchiveService::Unpack(BDataIO& tarDataIo, BPath& targetDirectory, count_items_read++; if (0 == memcmp(zero_buffer, buffer, sizeof zero_buffer)) { - HDDEBUG("detected end of tar-ball") + HDDEBUG("detected end of tar-ball"); return B_OK; // end of tar-ball. } else { TarArchiveHeader* header = TarArchiveHeader::CreateFromBlock( buffer); if (NULL == header) { - HDERROR("unable to parse a tar header") + HDERROR("unable to parse a tar header"); result = B_ERROR; } @@ -55,10 +55,10 @@ TarArchiveService::Unpack(BDataIO& tarDataIo, BPath& targetDirectory, } } - HDERROR("did unpack %d tar items", count_items_read) + HDERROR("did unpack %d tar items", count_items_read); if (B_OK != result) { - HDERROR("error occurred unpacking tar items; %s", strerror(result)) + HDERROR("error occurred unpacking tar items; %s", strerror(result)); } return result; @@ -79,7 +79,7 @@ TarArchiveService::_EnsurePathToTarItemFile( BString component = components.StringAt(i); if (_ValidatePathComponent(component) != B_OK) { - HDERROR("malformed component; [%s]", component.String()) + HDERROR("malformed component; [%s]", component.String()); return B_ERROR; } } @@ -109,7 +109,7 @@ TarArchiveService::_UnpackItem(BDataIO& tarDataIo, uint32 entryLength = header.GetLength(); HDDEBUG("will unpack item [%s] length [%" B_PRIu32 "]b", - entryFileName.String(), entryLength) + entryFileName.String(), entryLength); // if the path ends in "/" then it is a directory and there's no need to // unpack it although if there is a length, it will need to be skipped. @@ -165,8 +165,9 @@ TarArchiveService::_UnpackItemData(BDataIO& tarDataIo, remainingInItem -= writeFromBuffer; } - if (result != B_OK) - HDERROR("unable to unpack item data to; [%s]", targetFilePath.Path()) + if (result != B_OK) { + HDERROR("unable to unpack item data to; [%s]", targetFilePath.Path()); + } return result; } diff --git a/src/apps/haikudepot/ui/App.cpp b/src/apps/haikudepot/ui/App.cpp index 6f14363fd7..649e89f1f5 100644 --- a/src/apps/haikudepot/ui/App.cpp +++ b/src/apps/haikudepot/ui/App.cpp @@ -531,7 +531,7 @@ App::_CheckIsFirstRun() status_t status = StorageUtils::LocalWorkingFilesPath("testfile.txt", testFilePath, false); if (status != B_OK) { - HDERROR("unable to establish the location of the test file") + HDERROR("unable to establish the location of the test file"); } else status = StorageUtils::ExistsObject(testFilePath, &exists, NULL, NULL); diff --git a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp index aa94f01388..6db503d0f8 100644 --- a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp +++ b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp @@ -81,9 +81,8 @@ public: case MSG_UPDATE_PACKAGE: { BString name; - if (message->FindString("name", &name) != B_OK) { - HDINFO("expected 'name' key on package update message") - } + if (message->FindString("name", &name) != B_OK) + HDINFO("expected 'name' key on package update message"); else _HandleUpdatePackage(name); break; @@ -654,7 +653,7 @@ FeaturedPackagesView::RemovePackage(const PackageInfoRef& package) void FeaturedPackagesView::Clear() { - HDINFO("did clear the featured packages view") + HDINFO("did clear the featured packages view"); fPackagesView->Clear(); _AdjustViews(); } diff --git a/src/apps/haikudepot/ui/MainWindow.cpp b/src/apps/haikudepot/ui/MainWindow.cpp index aa82397fb9..a1988c04cd 100644 --- a/src/apps/haikudepot/ui/MainWindow.cpp +++ b/src/apps/haikudepot/ui/MainWindow.cpp @@ -302,7 +302,7 @@ MainWindow::MessageReceived(BMessage* message) if (message->FindInt64(KEY_ERROR_STATUS, &errorStatus64) == B_OK) _BulkLoadCompleteReceived((status_t) errorStatus64); else - HDERROR("expected [%s] value in message", KEY_ERROR_STATUS) + HDERROR("expected [%s] value in message", KEY_ERROR_STATUS); break; } case B_SIMPLE_DATA: @@ -414,7 +414,7 @@ MainWindow::MessageReceived(BMessage* message) } else { HDDEBUG("pkg [%s] is updated on the server, but is " "not selected so will not be updated.", - name.String()) + name.String()); } } break; @@ -821,7 +821,7 @@ MainWindow::_AdoptModelControls() void MainWindow::_AdoptModel() { - HDTRACE("adopting model to main window ui") + HDTRACE("adopting model to main window ui"); if (fSinglePackageMode) return; @@ -1037,7 +1037,7 @@ MainWindow::_PopulatePackageAsync(bool forcePopulate) release_sem_etc(fPackageToPopulateSem, 1, 0); HDDEBUG("pkg [%s] will be updated from the server.", - fPackageToPopulate->Name().String()) + fPackageToPopulate->Name().String()); } @@ -1070,7 +1070,7 @@ MainWindow::_PopulatePackageWorker(void* arg) window->fModel.PopulatePackage(package, populateFlags); - HDDEBUG("populating package [%s]", package->Name().String()) + HDDEBUG("populating package [%s]", package->Name().String()); } } @@ -1176,22 +1176,21 @@ MainWindow::_SelectedPackageHasWebAppRepositoryCode() const BString depotName = package->DepotName(); if (depotName.IsEmpty()) { - HDDEBUG("the package [%s] has no depot name", package->Name().String()) + HDDEBUG("the package [%s] has no depot name", package->Name().String()); } else { const DepotInfo* depot = fModel.DepotForName(depotName); if (depot == NULL) { HDINFO("the depot [%s] was not able to be found", - depotName.String()) + depotName.String()); } else { BString repositoryCode = depot->WebAppRepositoryCode(); if (repositoryCode.IsEmpty()) { HDINFO("the depot [%s] has no web app repository code", - depotName.String()) - } else { + depotName.String()); + } else return true; - } } } @@ -1301,7 +1300,7 @@ MainWindow::UserUsageConditionsNotLatest(const UserDetail& userDetail) BMessage detailsMessage; if (userDetail.Archive(&detailsMessage, true) != B_OK || message.AddMessage("userDetail", &detailsMessage) != B_OK) { - HDERROR("unable to archive the user detail into a message") + HDERROR("unable to archive the user detail into a message"); } else BMessenger(this).SendMessage(&message); @@ -1327,7 +1326,7 @@ MainWindow::_AddProcessCoordinator(ProcessCoordinator* item) if (acquire_sem(fCoordinatorRunningSem) != B_OK) debugger("unable to acquire the process coordinator sem"); HDINFO("adding and starting a process coordinator [%s]", - item->Name().String()) + item->Name().String()); fCoordinator = BReference(item); fCoordinator->Start(); } @@ -1359,7 +1358,7 @@ MainWindow::_SpinUntilProcessCoordinatorComplete() void MainWindow::_StopProcessCoordinators() { - HDINFO("will stop all process coordinators") + HDINFO("will stop all process coordinators"); { AutoLocker lock(&fCoordinatorLock); @@ -1368,7 +1367,7 @@ MainWindow::_StopProcessCoordinators() BReference processCoordinator = fCoordinatorQueue.front(); HDINFO("will drop queued process coordinator [%s]", - processCoordinator->Name().String()) + processCoordinator->Name().String()); fCoordinatorQueue.pop(); } @@ -1377,11 +1376,11 @@ MainWindow::_StopProcessCoordinators() } } - HDINFO("will wait until the process coordinator has stopped") + HDINFO("will wait until the process coordinator has stopped"); _SpinUntilProcessCoordinatorComplete(); - HDINFO("did stop all process coordinators") + HDINFO("did stop all process coordinators"); } @@ -1401,7 +1400,7 @@ MainWindow::CoordinatorChanged(ProcessCoordinatorState& coordinatorState) if (release_sem(fCoordinatorRunningSem) != B_OK) debugger("unable to release the process coordinator sem"); HDINFO("process coordinator [%s] did complete", - fCoordinator->Name().String()) + fCoordinator->Name().String()); // complete the last one that just finished BMessage* message = fCoordinator->Message(); @@ -1435,9 +1434,8 @@ MainWindow::CoordinatorChanged(ProcessCoordinatorState& coordinatorState) coordinatorState.Progress()); // show the progress to the user. } - } else { - HDINFO("! unknown process coordinator changed") - } + } else + HDINFO("! unknown process coordinator changed"); } diff --git a/src/apps/haikudepot/ui/PackageContentsView.cpp b/src/apps/haikudepot/ui/PackageContentsView.cpp index f5ee6adfb7..25288f6bb0 100644 --- a/src/apps/haikudepot/ui/PackageContentsView.cpp +++ b/src/apps/haikudepot/ui/PackageContentsView.cpp @@ -383,7 +383,7 @@ PackageContentsView::_PopulatePackageContents(const PackageInfo& package) } } else { HDINFO("PackageContentsView::_PopulatePackageContents(): " - "unknown install location") + "unknown install location"); return false; } @@ -398,7 +398,7 @@ PackageContentsView::_PopulatePackageContents(const PackageInfo& package) if (status != B_OK) { HDINFO("PackageContentsView::_PopulatePackageContents(): " "failed to init BPackageReader(%s): %s", - packagePath.Path(), strerror(status)) + packagePath.Path(), strerror(status)); return false; } @@ -408,7 +408,7 @@ PackageContentsView::_PopulatePackageContents(const PackageInfo& package) status = reader.ParseContent(&contentHandler); if (status != B_OK) { HDINFO("PackageContentsView::_PopulatePackageContents(): " - "failed parse package contents: %s", strerror(status)) + "failed parse package contents: %s", strerror(status)); // NOTE: Do not return false, since it taken to mean this // is a remote package, but is it not, we simply want to stop // populating the contents early. diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp b/src/apps/haikudepot/ui/PackageInfoView.cpp index 8c25969476..8623a23cbc 100644 --- a/src/apps/haikudepot/ui/PackageInfoView.cpp +++ b/src/apps/haikudepot/ui/PackageInfoView.cpp @@ -627,7 +627,7 @@ private: HDERROR("Failed to schedule action: %s '%s': %s", action->Label(), action->Package()->Name().String(), - strerror(result)) + strerror(result)); BString message(B_TRANSLATE("The package action " "could not be scheduled: %Error%")); message.ReplaceAll("%Error%", strerror(result)); diff --git a/src/apps/haikudepot/ui/RatePackageWindow.cpp b/src/apps/haikudepot/ui/RatePackageWindow.cpp index 26d5b7654e..5919c62ca8 100644 --- a/src/apps/haikudepot/ui/RatePackageWindow.cpp +++ b/src/apps/haikudepot/ui/RatePackageWindow.cpp @@ -247,16 +247,14 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame, { AutoLocker locker(fModel.Lock()); - fCommentLanguageCode = fModel.Language().PreferredLanguage()->Code(); + fCommentLanguageCode = fModel.Language()->PreferredLanguage()->Code(); // Construct languages popup BPopUpMenu* languagesMenu = new BPopUpMenu(B_TRANSLATE("Language")); fCommentLanguageField = new BMenuField("language", B_TRANSLATE("Comment language:"), languagesMenu); - LanguageMenuUtils::AddLanguagesToMenu( - fModel.Language().SupportedLanguages(), - languagesMenu); + LanguageMenuUtils::AddLanguagesToMenu(fModel.Language(), languagesMenu); languagesMenu->SetTargetForItems(this); LanguageMenuUtils::MarkLanguageInMenu(fCommentLanguageCode, languagesMenu); @@ -530,9 +528,8 @@ RatePackageWindow::_RelayServerDataToUI(BMessage& response) fSendButton->SetLabel(B_TRANSLATE("Update")); Unlock(); - } else { + } else HDERROR("unable to acquire lock to update the ui"); - } } @@ -568,7 +565,7 @@ RatePackageWindow::_QueryRatingThread() if (repositoryCode.IsEmpty()) { HDERROR("unable to obtain the repository code for depot; %s", - package->DepotName().String()) + package->DepotName().String()); BMessenger(this).SendMessage(B_QUIT_REQUESTED); } else { status_t status = interface @@ -587,7 +584,7 @@ RatePackageWindow::_QueryRatingThread() if (info.FindMessage("result", &result) == B_OK) { _RelayServerDataToUI(result); } else { - HDERROR("bad response envelope missing 'result' entry") + HDERROR("bad response envelope missing 'result' entry"); ServerHelper::NotifyTransportError(B_BAD_VALUE); BMessenger(this).SendMessage(B_QUIT_REQUESTED); } @@ -597,7 +594,7 @@ RatePackageWindow::_QueryRatingThread() // an expected response HDINFO("there was no previous rating for this" " user on this version of this package so a new rating" - " will be added.") + " will be added."); break; default: ServerHelper::NotifyServerJsonRpcError(info); @@ -607,7 +604,7 @@ RatePackageWindow::_QueryRatingThread() } else { HDERROR("an error has arisen communicating with the" " server to obtain data for an existing rating [%s]", - strerror(status)) + strerror(status)); ServerHelper::NotifyTransportError(status); BMessenger(this).SendMessage(B_QUIT_REQUESTED); } @@ -630,7 +627,7 @@ void RatePackageWindow::_SendRatingThread() { if (!Lock()) { - HDERROR("upload rating: Failed to lock window") + HDERROR("upload rating: Failed to lock window"); return; } @@ -660,7 +657,7 @@ RatePackageWindow::_SendRatingThread() if (repositoryCode.Length() == 0) { HDERROR("unable to find the web app repository code for the local " "depot %s", - fPackage->DepotName().String()) + fPackage->DepotName().String()); return; } @@ -670,11 +667,11 @@ RatePackageWindow::_SendRatingThread() status_t status; BMessage info; if (ratingID.Length() > 0) { - HDINFO("will update the existing user rating [%s]", ratingID.String()) + HDINFO("will update the existing user rating [%s]", ratingID.String()); status = interface.UpdateUserRating(ratingID, languageCode, comment, stability, rating, active, info); } else { - HDINFO("will create a new user rating for pkg [%s]", package.String()) + HDINFO("will create a new user rating for pkg [%s]", package.String()); status = interface.CreateUserRating(package, fPackage->Version(), architecture, repositoryCode, languageCode, comment, stability, rating, info); @@ -699,7 +696,7 @@ RatePackageWindow::_SendRatingThread() } else { HDERROR("an error has arisen communicating with the" " server to obtain data for an existing rating [%s]", - strerror(status)) + strerror(status)); ServerHelper::NotifyTransportError(status); } diff --git a/src/apps/haikudepot/ui/ScreenshotWindow.cpp b/src/apps/haikudepot/ui/ScreenshotWindow.cpp index 42d816fd1c..713eae372b 100644 --- a/src/apps/haikudepot/ui/ScreenshotWindow.cpp +++ b/src/apps/haikudepot/ui/ScreenshotWindow.cpp @@ -255,7 +255,7 @@ void ScreenshotWindow::_DownloadThread() { if (!Lock()) { - HDERROR("failed to lock screenshot window") + HDERROR("failed to lock screenshot window"); return; } @@ -268,7 +268,7 @@ ScreenshotWindow::_DownloadThread() Unlock(); if (screenshotInfos.CountItems() == 0) { - HDINFO("package has no screenshots") + HDINFO("package has no screenshots"); return; } @@ -295,14 +295,13 @@ ScreenshotWindow::_DownloadThread() messenger.SendMessage(MSG_DOWNLOAD_STOP); if (status == B_OK && Lock()) { - HDINFO("got screenshot") + HDINFO("got screenshot"); fScreenshot = BitmapRef(new(std::nothrow)SharedBitmap(buffer), true); fScreenshotView->SetBitmap(fScreenshot); _ResizeToFitAndCenter(); Unlock(); - } else { - HDERROR("failed to download screenshot") - } + } else + HDERROR("failed to download screenshot"); } diff --git a/src/apps/haikudepot/ui/ToLatestUserUsageConditionsWindow.cpp b/src/apps/haikudepot/ui/ToLatestUserUsageConditionsWindow.cpp index e9a2b5313c..6374b7123b 100644 --- a/src/apps/haikudepot/ui/ToLatestUserUsageConditionsWindow.cpp +++ b/src/apps/haikudepot/ui/ToLatestUserUsageConditionsWindow.cpp @@ -212,7 +212,7 @@ ToLatestUserUsageConditionsWindow::QuitRequested() if (fWorkerThread >= 0) { if (Logger::IsDebugEnabled()) HDINFO("quit requested while worker thread is operating -- will " - "try again once the worker thread has completed") + "try again once the worker thread has completed"); fQuitRequestedDuringWorkerThread = true; return false; } diff --git a/src/apps/haikudepot/ui/UserLoginWindow.cpp b/src/apps/haikudepot/ui/UserLoginWindow.cpp index 07cd240e4c..3d611ecaa7 100644 --- a/src/apps/haikudepot/ui/UserLoginWindow.cpp +++ b/src/apps/haikudepot/ui/UserLoginWindow.cpp @@ -146,19 +146,18 @@ UserLoginWindow::UserLoginWindow(BWindow* parent, BRect frame, Model& model) { AutoLocker locker(fModel.Lock()); - fPreferredLanguageCode = fModel.Language().PreferredLanguage()->Code(); + fPreferredLanguageCode = fModel.Language()->PreferredLanguage()->Code(); // Construct languages popup BPopUpMenu* languagesMenu = new BPopUpMenu(B_TRANSLATE("Language")); fLanguageCodeField = new BMenuField("language", B_TRANSLATE("Preferred language:"), languagesMenu); LanguageMenuUtils::AddLanguagesToMenu( - fModel.Language().SupportedLanguages(), - languagesMenu); + fModel.Language(), languagesMenu); languagesMenu->SetTargetForItems(this); HDINFO("using preferred language code [%s]", - fPreferredLanguageCode.String()) + fPreferredLanguageCode.String()); LanguageMenuUtils::MarkLanguageInMenu(fPreferredLanguageCode, languagesMenu); } @@ -298,7 +297,7 @@ UserLoginWindow::MessageReceived(BMessage* message) } case MSG_CREATE_ACCOUNT_SETUP_ERROR: - HDERROR("failed to setup for account setup - window must quit") + HDERROR("failed to setup for account setup - window must quit"); BMessenger(this).SendMessage(B_QUIT_REQUESTED); break; @@ -369,9 +368,8 @@ UserLoginWindow::QuitRequested() BAutolock locker(&fLock); if (fWorkerThread >= 0) { - if (Logger::IsDebugEnabled()) - HDINFO("quit requested while worker thread is operating -- will " - "try again once the worker thread has completed") + HDDEBUG("quit requested while worker thread is operating -- will " + "try again once the worker thread has completed"); fQuitRequestedDuringWorkerThread = true; return false; } @@ -529,10 +527,12 @@ UserLoginWindow::_AuthenticateThread(UserCredentials& userCredentials) userCredentials.SetIsSuccessful(!token.IsEmpty()); if (Logger::IsDebugEnabled()) { - if (token.IsEmpty()) - HDINFO("authentication failed") - else - HDINFO("authentication successful") + if (token.IsEmpty()) { + HDINFO("authentication failed"); + } + else { + HDINFO("authentication successful"); + } } BMessenger messenger(this); @@ -751,7 +751,7 @@ UserLoginWindow::_CreateAccountSetupThreadEntry(void* data) } if (result == B_OK) { HDDEBUG("successfully completed collection of create account " - "data from the server in background thread") + "data from the server in background thread"); messenger.SendMessage(&message); } else { debugger("unable to configure the " @@ -862,6 +862,8 @@ UserLoginWindow::_UnpackCaptcha(BMessage& responsePayload, Captcha& captcha) if (decodedSize <= 0) result = B_ERROR; } + else + HDERROR("obtained a captcha with no image data"); char* buffer = NULL; if (result == B_OK) { @@ -876,6 +878,9 @@ UserLoginWindow::_UnpackCaptcha(BMessage& responsePayload, Captcha& captcha) captcha.SetPngImageData(buffer, decodedSize); } delete[] buffer; + + HDDEBUG("did obtain a captcha image of size %" B_PRIuSIZE " bytes", + decodedSize); } return result; @@ -885,7 +890,7 @@ UserLoginWindow::_UnpackCaptcha(BMessage& responsePayload, Captcha& captcha) void UserLoginWindow::_HandleCreateAccountSetupSuccess(BMessage* message) { - HDDEBUG("handling account setup success") + HDDEBUG("handling account setup success"); BMessage captchaMessage; BMessage userUsageConditionsMessage; @@ -905,7 +910,7 @@ UserLoginWindow::_HandleCreateAccountSetupSuccess(BMessage* message) void UserLoginWindow::_SetCaptcha(Captcha* captcha) { - HDDEBUG("setting captcha") + HDDEBUG("setting captcha"); if (fCaptcha != NULL) delete fCaptcha; fCaptcha = captcha; @@ -931,7 +936,7 @@ void UserLoginWindow::_SetUserUsageConditions( UserUsageConditions* userUsageConditions) { - HDDEBUG("setting user usage conditions") + HDDEBUG("setting user usage conditions"); if (fUserUsageConditions != NULL) delete fUserUsageConditions; fUserUsageConditions = userUsageConditions; @@ -1270,7 +1275,7 @@ UserLoginWindow::_CreateAccountThread(CreateUserDetail* detail) _ValidationFailuresToString(validationFailures, debugString); HDDEBUG("create account validation issues; %s", - debugString.String()) + debugString.String()); } BMessage validationFailuresMessage; validationFailures.Archive(&validationFailuresMessage); diff --git a/src/apps/haikudepot/ui/UserUsageConditionsWindow.cpp b/src/apps/haikudepot/ui/UserUsageConditionsWindow.cpp index bb8209e16b..f064780e25 100644 --- a/src/apps/haikudepot/ui/UserUsageConditionsWindow.cpp +++ b/src/apps/haikudepot/ui/UserUsageConditionsWindow.cpp @@ -216,7 +216,7 @@ UserUsageConditionsWindow::QuitRequested() if (fWorkerThread == -1) return true; HDINFO("unable to quit when the user usage " - "conditions window is still fetching data") + "conditions window is still fetching data"); return false; } @@ -360,7 +360,7 @@ UserUsageConditionsWindow::_FetchUserUsageConditionsCodeForUserPerform( } else { HDERROR("an error has arisen communicating with the" " server to obtain data for a user's user usage conditions" - " [%s]", strerror(result)) + " [%s]", strerror(result)); ServerHelper::NotifyTransportError(result); } @@ -368,11 +368,11 @@ UserUsageConditionsWindow::_FetchUserUsageConditionsCodeForUserPerform( BString userUsageConditionsCode = userDetail.Agreement().Code(); HDDEBUG("the user [%s] has agreed to uuc [%s]", interface.Nickname().String(), - userUsageConditionsCode.String()) + userUsageConditionsCode.String()); code.SetTo(userUsageConditionsCode); } else { HDDEBUG("unable to get details of the user [%s]", - interface.Nickname().String()) + interface.Nickname().String()); } return result; @@ -393,9 +393,9 @@ UserUsageConditionsWindow::_NotifyFetchProblem() void UserUsageConditionsWindow::_SetWorkerThread(thread_id thread) { - if (!Lock()) { - HDERROR("failed to lock window") - } else { + if (!Lock()) + HDERROR("failed to lock window"); + else { fWorkerThread = thread; Unlock(); } diff --git a/src/apps/haikudepot/ui_generic/SharedBitmap.cpp b/src/apps/haikudepot/ui_generic/SharedBitmap.cpp index d5c581c261..21b328d394 100644 --- a/src/apps/haikudepot/ui_generic/SharedBitmap.cpp +++ b/src/apps/haikudepot/ui_generic/SharedBitmap.cpp @@ -101,7 +101,7 @@ SharedBitmap::SharedBitmap(BPositionIO& data) fSize = 0; } else { HDERROR("SharedBitmap(): Stream too large: %" B_PRIi64 - ", max: %" B_PRIi64, fSize, kMaxSize) + ", max: %" B_PRIi64, fSize, kMaxSize); } fBitmap[0] = NULL; diff --git a/src/apps/haikudepot/util/LanguageMenuUtils.cpp b/src/apps/haikudepot/util/LanguageMenuUtils.cpp index 9648a18d77..f3d597730d 100644 --- a/src/apps/haikudepot/util/LanguageMenuUtils.cpp +++ b/src/apps/haikudepot/util/LanguageMenuUtils.cpp @@ -21,23 +21,23 @@ /* static */ void LanguageMenuUtils::AddLanguagesToMenu( - const LanguageList& languages, BMenu* menu) + const LanguageModel* languagesModel, BMenu* menu) { - if (languages.IsEmpty()) - HDINFO("there are no languages defined") + if (languagesModel->CountSupportedLanguages() == 0) + HDINFO("there are no languages defined"); int32 addedPopular = LanguageMenuUtils::_AddLanguagesToMenu( - languages, menu, true); + languagesModel, menu, true); if (addedPopular > 0) menu->AddSeparatorItem(); int32 addedNonPopular = LanguageMenuUtils::_AddLanguagesToMenu( - languages, menu, false); + languagesModel, menu, false); HDDEBUG("did add %" B_PRId32 " popular languages and %" B_PRId32 " non-popular languages to a menu", addedPopular, - addedNonPopular) + addedNonPopular); } @@ -55,7 +55,7 @@ LanguageMenuUtils::MarkLanguageInMenu( if (index == -1) { HDINFO("unable to find the language [%s] in the menu", - languageCode.String()) + languageCode.String()); menu->ItemAt(0)->SetMarked(true); } else @@ -86,13 +86,13 @@ LanguageMenuUtils::_AddLanguageToMenu( /* static */ int32 -LanguageMenuUtils::_AddLanguagesToMenu(const LanguageList& languages, +LanguageMenuUtils::_AddLanguagesToMenu(const LanguageModel* languageModel, BMenu* menu, bool isPopular) { int32 count = 0; - for (int32 i = 0; i < languages.CountItems(); i++) { - const LanguageRef language = languages.ItemAtFast(i); + for (int32 i = 0; i < languageModel->CountSupportedLanguages(); i++) { + const LanguageRef language = languageModel->SupportedLanguageAt(i); if (language->IsPopular() == isPopular) { LanguageMenuUtils::_AddLanguageToMenu(language, menu); diff --git a/src/apps/haikudepot/util/LanguageMenuUtils.h b/src/apps/haikudepot/util/LanguageMenuUtils.h index 420d711af8..bf33c70ffa 100644 --- a/src/apps/haikudepot/util/LanguageMenuUtils.h +++ b/src/apps/haikudepot/util/LanguageMenuUtils.h @@ -16,7 +16,7 @@ class LanguageMenuUtils { public: static void AddLanguagesToMenu( - const LanguageList& languages, + const LanguageModel* languagesModel, BMenu* menu); static void MarkLanguageInMenu( const BString& languageCode, @@ -29,7 +29,7 @@ private: static status_t _GetLanguageAtIndexInMenu(BMenu* menu, int32 index, BString* result); static int32 _AddLanguagesToMenu( - const LanguageList& languages, + const LanguageModel* languagesModel, BMenu* menu, bool isPopular); static void _AddLanguageToMenu( const LanguageRef& language, diff --git a/src/apps/haikudepot/util/StorageUtils.cpp b/src/apps/haikudepot/util/StorageUtils.cpp index 02d50cb6a6..2a425400f6 100644 --- a/src/apps/haikudepot/util/StorageUtils.cpp +++ b/src/apps/haikudepot/util/StorageUtils.cpp @@ -85,10 +85,10 @@ StorageUtils::RemoveDirectoryContents(BPath& path) if (isDirectory) RemoveDirectoryContents(directoryEntryPath); - if (remove(directoryEntryPath.Path()) == 0) { - HDDEBUG("did delete [%s]", directoryEntryPath.Path()) - } else { - HDERROR("unable to delete [%s]", directoryEntryPath.Path()) + if (remove(directoryEntryPath.Path()) == 0) + HDDEBUG("did delete [%s]", directoryEntryPath.Path()); + else { + HDERROR("unable to delete [%s]", directoryEntryPath.Path()); result = B_ERROR; } } @@ -164,12 +164,12 @@ StorageUtils::CheckCanWriteTo(const BPath& path) if (result == B_OK && exists) { HDTRACE("an object exists at the candidate path " - "[%s] - it will be deleted", path.Path()) + "[%s] - it will be deleted", path.Path()); if (remove(path.Path()) == 0) { - HDTRACE("did delete the candidate file [%s]", path.Path()) + HDTRACE("did delete the candidate file [%s]", path.Path()); } else { - HDERROR("unable to delete the candidate file [%s]", path.Path()) + HDERROR("unable to delete the candidate file [%s]", path.Path()); result = B_ERROR; } } @@ -178,7 +178,7 @@ StorageUtils::CheckCanWriteTo(const BPath& path) BFile file(path.Path(), O_WRONLY | O_CREAT); if (file.Write(buffer, 16) != 16) { HDERROR("unable to write test data to candidate file [%s]", - path.Path()) + path.Path()); result = B_ERROR; } } @@ -188,14 +188,14 @@ StorageUtils::CheckCanWriteTo(const BPath& path) uint8 readBuffer[16]; if (file.Read(readBuffer, 16) != 16) { HDERROR("unable to read test data from candidate file [%s]", - path.Path()) + path.Path()); result = B_ERROR; } for (int i = 0; result == B_OK && i < 16; i++) { if (readBuffer[i] != buffer[i]) { HDERROR("mismatched read..write check on candidate file [%s]", - path.Path()) + path.Path()); result = B_ERROR; } } @@ -238,7 +238,7 @@ StorageUtils::LocalWorkingFilesPath(const BString leaf, BPath& path, else { path.Unset(); HDERROR("unable to find the user cache file for " - "[%s] data; %s", leaf.String(), strerror(result)) + "[%s] data; %s", leaf.String(), strerror(result)); } return result; @@ -273,7 +273,7 @@ StorageUtils::LocalWorkingDirectoryPath(const BString leaf, BPath& path, else { path.Unset(); HDERROR("unable to find the user cache directory for " - "[%s] data; %s", leaf.String(), strerror(result)) + "[%s] data; %s", leaf.String(), strerror(result)); } return result; diff --git a/src/apps/haikudepot/util/ToFileUrlProtocolListener.cpp b/src/apps/haikudepot/util/ToFileUrlProtocolListener.cpp index 3f75a33311..9395fc892a 100644 --- a/src/apps/haikudepot/util/ToFileUrlProtocolListener.cpp +++ b/src/apps/haikudepot/util/ToFileUrlProtocolListener.cpp @@ -59,7 +59,7 @@ ToFileUrlProtocolListener::HeadersReceived(BUrlRequest* caller, if (!BHttpRequest::IsSuccessStatusCode(statusCode)) { HDINFO("received http status %" B_PRId32 - " --> will not store download to file", statusCode) + " --> will not store download to file", statusCode); fShouldDownload = false; } @@ -83,7 +83,7 @@ ToFileUrlProtocolListener::DataReceived(BUrlRequest* caller, const char* data, } while (remaining > 0 && written > 0); if (remaining > 0) - HDERROR("unable to write all of the data to the file") + HDERROR("unable to write all of the data to the file"); } } @@ -112,7 +112,7 @@ void ToFileUrlProtocolListener::DebugMessage(BUrlRequest* caller, BUrlProtocolDebugMessage type, const char* text) { - HDTRACE("url->file <%s>; %s", fTraceLoggingIdentifier.String(), text) + HDTRACE("url->file <%s>; %s", fTraceLoggingIdentifier.String(), text); }