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