HaikuDepot: Better Logging
Changes the logging in HD to use a macro for the various log levels to declutter the code and to make it easier to more systematically log. Change-Id: I025970707a0a11e7e3aaa4b52fc91288af0183f5 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3018 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019, 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"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <DataIO.h>
|
#include <DataIO.h>
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
// These are keys that are used to store this object's data into a BMessage
|
// These are keys that are used to store this object's data into a BMessage
|
||||||
// instance.
|
// instance.
|
||||||
|
|
||||||
@@ -22,15 +22,15 @@ Captcha::Captcha(BMessage* from)
|
|||||||
fPngImageData(NULL)
|
fPngImageData(NULL)
|
||||||
{
|
{
|
||||||
if (from->FindString(KEY_TOKEN, &fToken) != B_OK) {
|
if (from->FindString(KEY_TOKEN, &fToken) != B_OK) {
|
||||||
printf("expected key [%s] in the message data when creating a "
|
HDERROR("expected key [%s] in the message data when creating a "
|
||||||
"Captcha\n", 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)
|
||||||
printf("expected key [%s] in the message data\n", KEY_PNG_IMAGE_DATA);
|
HDERROR("expected key [%s] in the message data", KEY_PNG_IMAGE_DATA)
|
||||||
else
|
else
|
||||||
SetPngImageData(data, len);
|
SetPngImageData(data, len);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ void
|
|||||||
LanguageModel::_SetPreferredLanguage(const Language& language)
|
LanguageModel::_SetPreferredLanguage(const Language& language)
|
||||||
{
|
{
|
||||||
fPreferredLanguage = LanguageRef(new Language(language));
|
fPreferredLanguage = LanguageRef(new Language(language));
|
||||||
if(Logger::IsDebugEnabled())
|
HDDEBUG("set preferred language [%s]", language.Code())
|
||||||
printf("set preferred language [%s]\n", language.Code());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -98,11 +97,7 @@ Language
|
|||||||
LanguageModel::_DeriveDefaultLanguage() const
|
LanguageModel::_DeriveDefaultLanguage() const
|
||||||
{
|
{
|
||||||
Language defaultLanguage = _DeriveSystemDefaultLanguage();
|
Language defaultLanguage = _DeriveSystemDefaultLanguage();
|
||||||
|
HDDEBUG("derived system default language [%s]", defaultLanguage.Code())
|
||||||
if(Logger::IsDebugEnabled()) {
|
|
||||||
printf("derived system default language [%s]\n",
|
|
||||||
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.
|
||||||
@@ -119,15 +114,15 @@ LanguageModel::_DeriveDefaultLanguage() const
|
|||||||
defaultLanguage.Code());
|
defaultLanguage.Code());
|
||||||
|
|
||||||
if (foundSupportedLanguage == NULL) {
|
if (foundSupportedLanguage == NULL) {
|
||||||
printf("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) {
|
||||||
printf("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.ItemAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017, Andrew Lindesay <[email protected]>.
|
* Copyright 2017-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 "Logger.h"
|
#include "Logger.h"
|
||||||
@@ -22,7 +22,28 @@ Logger::SetLevel(log_level value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
/*static*/
|
||||||
|
const char*
|
||||||
|
Logger::NameForLevel(log_level value)
|
||||||
|
{
|
||||||
|
switch (value) {
|
||||||
|
case LOG_LEVEL_OFF:
|
||||||
|
return "off";
|
||||||
|
case LOG_LEVEL_INFO:
|
||||||
|
return "info";
|
||||||
|
case LOG_LEVEL_DEBUG:
|
||||||
|
return "debug";
|
||||||
|
case LOG_LEVEL_TRACE:
|
||||||
|
return "trace";
|
||||||
|
case LOG_LEVEL_ERROR:
|
||||||
|
return "error";
|
||||||
|
default:
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*static*/ bool
|
||||||
Logger::SetLevelByName(const char *name)
|
Logger::SetLevelByName(const char *name)
|
||||||
{
|
{
|
||||||
if (strcmp(name, "off") == 0) {
|
if (strcmp(name, "off") == 0) {
|
||||||
@@ -33,6 +54,8 @@ Logger::SetLevelByName(const char *name)
|
|||||||
fLevel = LOG_LEVEL_DEBUG;
|
fLevel = LOG_LEVEL_DEBUG;
|
||||||
} else if (strcmp(name, "trace") == 0) {
|
} else if (strcmp(name, "trace") == 0) {
|
||||||
fLevel = LOG_LEVEL_TRACE;
|
fLevel = LOG_LEVEL_TRACE;
|
||||||
|
} else if (strcmp(name, "error") == 0) {
|
||||||
|
fLevel = LOG_LEVEL_ERROR;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -41,22 +64,30 @@ Logger::SetLevelByName(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*static*/
|
||||||
|
bool
|
||||||
|
Logger::IsLevelEnabled(log_level value)
|
||||||
|
{
|
||||||
|
return fLevel >= value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Logger::IsInfoEnabled()
|
Logger::IsInfoEnabled()
|
||||||
{
|
{
|
||||||
return fLevel >= LOG_LEVEL_INFO;
|
return IsLevelEnabled(LOG_LEVEL_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Logger::IsDebugEnabled()
|
Logger::IsDebugEnabled()
|
||||||
{
|
{
|
||||||
return fLevel >= LOG_LEVEL_DEBUG;
|
return IsLevelEnabled(LOG_LEVEL_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Logger::IsTraceEnabled()
|
Logger::IsTraceEnabled()
|
||||||
{
|
{
|
||||||
return fLevel >= LOG_LEVEL_TRACE;
|
return IsLevelEnabled(LOG_LEVEL_TRACE);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017, Andrew Lindesay <[email protected]>.
|
* Copyright 2017-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.
|
||||||
*/
|
*/
|
||||||
#ifndef LOGGER_H
|
#ifndef LOGGER_H
|
||||||
@@ -9,14 +9,38 @@
|
|||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
|
||||||
#include "PackageInfo.h"
|
#include <ctype.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
// These macros allow for standardized logging to be output.
|
||||||
|
// The use of macros in this way means that the use of the log is concise where
|
||||||
|
// it is used and also because the macro unwraps to a block contained with a
|
||||||
|
// condition statement, if the log level is not sufficient to trigger the log
|
||||||
|
// line then there is no computational cost to running over the log space. This
|
||||||
|
// is because the arguments will not be evaluated. Avoiding all of the
|
||||||
|
// conditional clauses in the code to prevent this otherwise would be
|
||||||
|
// cumbersome.
|
||||||
|
|
||||||
|
#define HDLOGPREFIX(L) printf("{%c} ", toupper(Logger::NameForLevel(L)[0]));
|
||||||
|
|
||||||
|
#define HDLOG(L, M...) if (Logger::IsLevelEnabled(L)) { \
|
||||||
|
HDLOGPREFIX(L) \
|
||||||
|
printf(M); \
|
||||||
|
putchar('\n'); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define HDINFO(M...) HDLOG(LOG_LEVEL_INFO, M)
|
||||||
|
#define HDDEBUG(M...) HDLOG(LOG_LEVEL_DEBUG, M)
|
||||||
|
#define HDTRACE(M...) HDLOG(LOG_LEVEL_TRACE, M)
|
||||||
|
#define HDERROR(M...) HDLOG(LOG_LEVEL_ERROR, M)
|
||||||
|
|
||||||
typedef enum log_level {
|
typedef enum log_level {
|
||||||
LOG_LEVEL_OFF = 1,
|
LOG_LEVEL_OFF = 1,
|
||||||
LOG_LEVEL_INFO = 2,
|
LOG_LEVEL_ERROR = 2,
|
||||||
LOG_LEVEL_DEBUG = 3,
|
LOG_LEVEL_INFO = 3,
|
||||||
LOG_LEVEL_TRACE = 4
|
LOG_LEVEL_DEBUG = 4,
|
||||||
|
LOG_LEVEL_TRACE = 5
|
||||||
} log_level;
|
} log_level;
|
||||||
|
|
||||||
|
|
||||||
@@ -26,6 +50,9 @@ public:
|
|||||||
static void SetLevel(log_level value);
|
static void SetLevel(log_level value);
|
||||||
static bool SetLevelByName(const char *name);
|
static bool SetLevelByName(const char *name);
|
||||||
|
|
||||||
|
static const char* NameForLevel(log_level value);
|
||||||
|
|
||||||
|
static bool IsLevelEnabled(log_level value);
|
||||||
static bool IsInfoEnabled();
|
static bool IsInfoEnabled();
|
||||||
static bool IsDebugEnabled();
|
static bool IsDebugEnabled();
|
||||||
static bool IsTraceEnabled();
|
static bool IsTraceEnabled();
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
@@ -187,13 +186,9 @@ public:
|
|||||||
if (package.Get() == NULL)
|
if (package.Get() == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
printf("TEST %s\n", package->Name().String());
|
|
||||||
|
|
||||||
for (int32 i = 0; i < fPackageLists.CountItems(); i++) {
|
for (int32 i = 0; i < fPackageLists.CountItems(); i++) {
|
||||||
if (fPackageLists.ItemAtFast(i)->Contains(package)) {
|
if (fPackageLists.ItemAtFast(i)->Contains(package))
|
||||||
printf(" contained in %" B_PRId32 "\n", i);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -649,8 +644,8 @@ 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) {
|
||||||
printf("corrupt user rating at index %" B_PRIi32 "\n",
|
HDERROR("corrupt user rating at index %" B_PRIi32,
|
||||||
index);
|
index)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -658,8 +653,8 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags)
|
|||||||
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) {
|
||||||
printf("ignored user rating [%s] without a user "
|
HDERROR("ignored user rating [%s] without a user "
|
||||||
"nickname\n", code.String());
|
"nickname", code.String())
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -672,8 +667,8 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags)
|
|||||||
if (item.FindDouble("rating", &rating) != B_OK)
|
if (item.FindDouble("rating", &rating) != B_OK)
|
||||||
rating = -1;
|
rating = -1;
|
||||||
if (comment.Length() == 0 && rating == -1) {
|
if (comment.Length() == 0 && rating == -1) {
|
||||||
printf("rating [%s] has no comment or rating so will be"
|
HDERROR("rating [%s] has no comment or rating so will"
|
||||||
"ignored\n", code.String());
|
" be ignored", code.String())
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,22 +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())
|
||||||
if (Logger::IsDebugEnabled()) {
|
|
||||||
printf("rating [%s] retrieved from server\n",
|
|
||||||
code.String());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Logger::IsDebugEnabled()) {
|
|
||||||
printf("did retrieve %" B_PRIi32 " user ratings for [%s]\n",
|
|
||||||
index - 1, packageName.String());
|
|
||||||
}
|
}
|
||||||
|
HDDEBUG("did retrieve %" B_PRIi32 " user ratings for [%s]",
|
||||||
|
index - 1, packageName.String())
|
||||||
} else {
|
} else {
|
||||||
_MaybeLogJsonRpcError(info, "retrieve user ratings");
|
_MaybeLogJsonRpcError(info, "retrieve user ratings");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("unable to retrieve user ratings\n");
|
HDERROR("unable to retrieve user ratings")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -773,22 +761,16 @@ Model::_PopulatePackageChangelog(const PackageInfoRef& package)
|
|||||||
&& 0 != content.Length()) {
|
&& 0 != content.Length()) {
|
||||||
BAutolock locker(&fLock);
|
BAutolock locker(&fLock);
|
||||||
package->SetChangelog(content);
|
package->SetChangelog(content);
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("changelog populated for [%s]", packageName.String())
|
||||||
fprintf(stdout, "changelog populated for [%s]\n",
|
|
||||||
packageName.String());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("no changelog present for [%s]", packageName.String())
|
||||||
fprintf(stdout, "no changelog present for [%s]\n",
|
|
||||||
packageName.String());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_MaybeLogJsonRpcError(info, "populate package changelog");
|
_MaybeLogJsonRpcError(info, "populate package changelog");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stdout, "unable to obtain the changelog for the package"
|
HDERROR("unable to obtain the changelog for the package [%s]",
|
||||||
" [%s]\n", packageName.String());
|
packageName.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -809,15 +791,15 @@ model_remove_key_for_user(const BString& nickname)
|
|||||||
case B_OK:
|
case B_OK:
|
||||||
result = keyStore.RemoveKey(kHaikuDepotKeyring, key);
|
result = keyStore.RemoveKey(kHaikuDepotKeyring, key);
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
printf("! error occurred when removing password for nickname "
|
HDERROR("error occurred when removing password for nickname "
|
||||||
"[%s] : %s\n", 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:
|
||||||
printf("! error occurred when finding password for nickname "
|
HDERROR("error occurred when finding password for nickname "
|
||||||
"[%s] : %s\n", nickname.String(), strerror(result));
|
"[%s] : %s", nickname.String(), strerror(result))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -956,7 +938,7 @@ Model::_PopulatePackageScreenshot(const PackageInfoRef& package,
|
|||||||
"Screenshots", screenshotCachePath);
|
"Screenshots", screenshotCachePath);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
printf("[!] unable to get the screenshot dir - unable to proceed");
|
HDERROR("unable to get the screenshot dir - unable to proceed")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1007,9 +989,9 @@ Model::_PopulatePackageScreenshot(const PackageInfoRef& package,
|
|||||||
screenshotFile.Write(buffer.Buffer(), buffer.BufferLength());
|
screenshotFile.Write(buffer.Buffer(), buffer.BufferLength());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Failed to retrieve screenshot for code '%s' "
|
HDERROR("Failed to retrieve screenshot for code '%s' "
|
||||||
"at %" B_PRIi32 "x%" B_PRIi32 ".\n", info.Code().String(),
|
"at %" B_PRIi32 "x%" B_PRIi32 ".", info.Code().String(),
|
||||||
scaledWidth, scaledHeight);
|
scaledWidth, scaledHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1070,13 +1052,15 @@ Model::LogDepotsWithNoWebAppRepositoryCode() const
|
|||||||
const DepotInfo& depot = fDepots.ItemAt(i);
|
const DepotInfo& depot = fDepots.ItemAt(i);
|
||||||
|
|
||||||
if (depot.WebAppRepositoryCode().Length() == 0) {
|
if (depot.WebAppRepositoryCode().Length() == 0) {
|
||||||
printf("depot [%s]", depot.Name().String());
|
if (depot.URL().Length() > 0) {
|
||||||
|
HDINFO("depot [%s] (%s) correlates with no repository in the"
|
||||||
if (depot.URL().Length() > 0)
|
" the haiku depot server system", depot.Name().String(),
|
||||||
printf(" (%s)", depot.URL().String());
|
depot.URL().String())
|
||||||
|
}
|
||||||
printf(" correlates with no repository in the haiku"
|
else {
|
||||||
"depot server system\n");
|
HDINFO("depot [%s] correlates with no repository in the"
|
||||||
|
" the haiku depot server system", depot.Name().String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1093,11 +1077,10 @@ Model::_MaybeLogJsonRpcError(const BMessage &responsePayload,
|
|||||||
if (responsePayload.FindMessage("error", &error) == B_OK
|
if (responsePayload.FindMessage("error", &error) == B_OK
|
||||||
&& error.FindString("message", &errorMessage) == B_OK
|
&& error.FindString("message", &errorMessage) == B_OK
|
||||||
&& error.FindDouble("code", &errorCode) == B_OK) {
|
&& error.FindDouble("code", &errorCode) == B_OK) {
|
||||||
printf("[%s] --> error : [%s] (%f)\n", sourceDescription,
|
HDERROR("[%s] --> error : [%s] (%f)", sourceDescription,
|
||||||
errorMessage.String(), errorCode);
|
errorMessage.String(), errorCode)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("[%s] --> an undefined error has occurred\n", sourceDescription);
|
HDERROR("[%s] --> an undefined error has occurred", sourceDescription)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,12 @@
|
|||||||
|
|
||||||
#include "PackageInfo.h"
|
#include "PackageInfo.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <package/PackageDefs.h>
|
#include <package/PackageDefs.h>
|
||||||
#include <package/PackageFlags.h>
|
#include <package/PackageFlags.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
// #pragma mark - Language
|
// #pragma mark - Language
|
||||||
|
|
||||||
@@ -1176,16 +1175,16 @@ DepotInfo::SyncPackages(const PackageList& otherPackages)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
printf("%s: new package: '%s'\n", fName.String(),
|
HDINFO("%s: new package: '%s'", fName.String(),
|
||||||
otherPackage->Name().String());
|
otherPackage->Name().String())
|
||||||
fPackages.Add(otherPackage);
|
fPackages.Add(otherPackage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
printf("%s: removing package: '%s'\n", fName.String(),
|
HDINFO("%s: removing package: '%s'", fName.String(),
|
||||||
package->Name().String());
|
package->Name().String())
|
||||||
fPackages.Remove(package);
|
fPackages.Remove(package);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2017, Haiku, Inc. All Rights Reserved.
|
* Copyright 2013-2020, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,13 +7,12 @@
|
|||||||
* Stephan Aßmus <[email protected]>
|
* Stephan Aßmus <[email protected]>
|
||||||
* Rene Gollent <[email protected]>
|
* Rene Gollent <[email protected]>
|
||||||
* Julian Harnath <[email protected]>
|
* Julian Harnath <[email protected]>
|
||||||
|
* Andrew Lindesay <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "PackageManager.h"
|
#include "PackageManager.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
@@ -36,6 +35,7 @@
|
|||||||
|
|
||||||
#include "AutoDeleter.h"
|
#include "AutoDeleter.h"
|
||||||
#include "AutoLocker.h"
|
#include "AutoLocker.h"
|
||||||
|
#include "Logger.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
#include "PackageInfo.h"
|
#include "PackageInfo.h"
|
||||||
#include "ProblemWindow.h"
|
#include "ProblemWindow.h"
|
||||||
@@ -163,19 +163,18 @@ public:
|
|||||||
ref->SetState(state);
|
ref->SetState(state);
|
||||||
return ex.Error();
|
return ex.Error();
|
||||||
} catch (BAbortedByUserException& ex) {
|
} catch (BAbortedByUserException& ex) {
|
||||||
fprintf(stderr, "Installation of package "
|
HDINFO("Installation of package %s is aborted by user: %s",
|
||||||
"%s aborted by user: %s\n", packageNameString,
|
packageNameString, ex.Message().String())
|
||||||
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) {
|
||||||
fprintf(stderr, "Nothing to do while installing package "
|
HDINFO("Nothing to do while installing package %s: %s",
|
||||||
"%s: %s\n", packageNameString, ex.Message().String());
|
packageNameString, ex.Message().String())
|
||||||
return B_OK;
|
return B_OK;
|
||||||
} catch (BException& ex) {
|
} catch (BException& ex) {
|
||||||
fprintf(stderr, "Exception occurred while installing package "
|
HDERROR("Exception occurred while installing package %s: %s",
|
||||||
"%s: %s\n", 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,8 +290,8 @@ public:
|
|||||||
} catch (BNothingToDoException& ex) {
|
} catch (BNothingToDoException& ex) {
|
||||||
return B_OK;
|
return B_OK;
|
||||||
} catch (BException& ex) {
|
} catch (BException& ex) {
|
||||||
fprintf(stderr, "Exception occurred while uninstalling package "
|
HDERROR("Exception occurred while uninstalling package %s: %s",
|
||||||
"%s: %s\n", packageName, ex.Message().String());
|
packageName, ex.Message().String())
|
||||||
ref->SetState(state);
|
ref->SetState(state);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
@@ -390,9 +389,9 @@ public:
|
|||||||
{
|
{
|
||||||
BString path = MakePath(entry);
|
BString path = MakePath(entry);
|
||||||
if (path.FindFirst("data/deskbar/menu") == 0
|
if (path.FindFirst("data/deskbar/menu") == 0
|
||||||
&& entry->SymlinkPath() != NULL) {
|
&& entry->SymlinkPath() != NULL) {
|
||||||
printf("found deskbar entry: %s -> %s\n", path.String(),
|
HDINFO("found deskbar entry: %s -> %s",
|
||||||
entry->SymlinkPath());
|
path.String(), entry->SymlinkPath())
|
||||||
fDeskbarLinks.Add(DeskbarLink(path, entry->SymlinkPath()));
|
fDeskbarLinks.Add(DeskbarLink(path, entry->SymlinkPath()));
|
||||||
}
|
}
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -464,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);
|
||||||
printf("trying to launch (absolute link): %s\n", 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) {
|
||||||
@@ -484,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);
|
||||||
printf("trying to launch: %s\n", path.Path());
|
HDINFO("trying to launch: %s", path.Path())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,8 +517,8 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("OpenPackageAction::FindAppToLaunch(): "
|
HDINFO("OpenPackageAction::FindAppToLaunch(): "
|
||||||
"unknown install location");
|
"unknown install location")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,9 +529,9 @@ public:
|
|||||||
|
|
||||||
status_t status = reader.Init(packagePath.Path());
|
status_t status = reader.Init(packagePath.Path());
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
printf("OpenPackageAction::FindAppToLaunch(): "
|
HDINFO("OpenPackageAction::FindAppToLaunch(): "
|
||||||
"failed to init BPackageReader(%s): %s\n",
|
"failed to init BPackageReader(%s): %s",
|
||||||
packagePath.Path(), strerror(status));
|
packagePath.Path(), strerror(status))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,9 +539,9 @@ public:
|
|||||||
DeskbarLinkFinder contentHandler(foundLinks);
|
DeskbarLinkFinder contentHandler(foundLinks);
|
||||||
status = reader.ParseContent(&contentHandler);
|
status = reader.ParseContent(&contentHandler);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
printf("OpenPackageAction::FindAppToLaunch(): "
|
HDINFO("OpenPackageAction::FindAppToLaunch(): "
|
||||||
"failed parse package contents (%s): %s\n",
|
"failed parse package contents (%s): %s",
|
||||||
packagePath.Path(), strerror(status));
|
packagePath.Path(), strerror(status))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,12 +634,12 @@ PackageManager::RefreshRepository(const BRepositoryConfig& repoConfig)
|
|||||||
try {
|
try {
|
||||||
result = BPackageManager::RefreshRepository(repoConfig);
|
result = BPackageManager::RefreshRepository(repoConfig);
|
||||||
} catch (BFatalErrorException& ex) {
|
} catch (BFatalErrorException& ex) {
|
||||||
fprintf(stderr, "Fatal error occurred while refreshing repository: "
|
HDERROR("Fatal error occurred while refreshing repository: "
|
||||||
"%s (%s)\n", 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) {
|
||||||
fprintf(stderr, "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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,13 +656,13 @@ PackageManager::DownloadPackage(const BString& fileURL,
|
|||||||
result = BPackageManager::DownloadPackage(fileURL, targetEntry,
|
result = BPackageManager::DownloadPackage(fileURL, targetEntry,
|
||||||
checksum);
|
checksum);
|
||||||
} catch (BFatalErrorException& ex) {
|
} catch (BFatalErrorException& ex) {
|
||||||
fprintf(stderr, "Fatal error occurred while downloading package: "
|
HDERROR("Fatal error occurred while downloading package: "
|
||||||
"%s: %s (%s)\n", 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) {
|
||||||
fprintf(stderr, "Exception occurred while downloading package "
|
HDERROR("Exception occurred while downloading package "
|
||||||
"%s: %s\n", fileURL.String(), ex.Message().String());
|
"%s: %s", fileURL.String(), ex.Message().String())
|
||||||
result = B_ERROR;
|
result = B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019, 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 "UserUsageConditions.h"
|
#include "UserUsageConditions.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "Logger.h"
|
||||||
|
|
||||||
// These are keys that are used to store this object's data into a BMessage
|
// These are keys that are used to store this object's data into a BMessage
|
||||||
// instance.
|
// instance.
|
||||||
@@ -24,14 +24,14 @@ 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)
|
||||||
printf("expected key [%s] in the message data\n", 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)
|
||||||
printf("expected key [%s] in the message data\n", 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)
|
||||||
printf("expected key [%s] in the message data\n", KEY_COPY_MARKDOWN);
|
HDERROR("expected key [%s] in the message data", KEY_COPY_MARKDOWN)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018, Andrew Lindesay <[email protected]>.
|
* Copyright 2018-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 "AbstractProcess.h"
|
#include "AbstractProcess.h"
|
||||||
@@ -47,12 +47,12 @@ AbstractProcess::Run()
|
|||||||
AutoLocker<BLocker> locker(&fLock);
|
AutoLocker<BLocker> locker(&fLock);
|
||||||
|
|
||||||
if (ProcessState() != PROCESS_INITIAL) {
|
if (ProcessState() != PROCESS_INITIAL) {
|
||||||
printf("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) {
|
||||||
printf("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)
|
||||||
printf("[%s] an error has arisen; %s\n", Name(), strerror(runResult));
|
HDERROR("[%s] an error has arisen; %s", Name(), strerror(runResult))
|
||||||
|
|
||||||
BReference<AbstractProcessListener> listener;
|
BReference<AbstractProcessListener> listener;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2018, Andrew Lindesay <[email protected]>.
|
* Copyright 2017-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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -122,9 +122,9 @@ AbstractServerProcess::IfModifiedSinceHeaderValue(BString& headerValue,
|
|||||||
headerValue.SetTo(modifiedHttpTime
|
headerValue.SetTo(modifiedHttpTime
|
||||||
.ToString(BPrivate::B_HTTP_TIME_FORMAT_COOKIE));
|
.ToString(BPrivate::B_HTTP_TIME_FORMAT_COOKIE));
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "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\n",
|
" - cannot set the 'If-Modified-Since' header",
|
||||||
metaDataPath.Path());
|
metaDataPath.Path())
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -148,8 +148,8 @@ AbstractServerProcess::PopulateMetaData(
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (!metaData.IsPopulated()) {
|
if (!metaData.IsPopulated()) {
|
||||||
fprintf(stderr, "the meta data was read from [%s], but no values "
|
HDERROR("the meta data was read from [%s], but no values "
|
||||||
"were extracted\n", path.Path());
|
"were extracted", path.Path())
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,8 +179,8 @@ AbstractServerProcess::ParseJsonFromFileWithListener(
|
|||||||
FILE* file = fopen(pathStr, "rb");
|
FILE* file = fopen(pathStr, "rb");
|
||||||
|
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
printf("[%s] unable to find the meta data file at [%s]\n", 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,8 +240,8 @@ 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) {
|
||||||
printf("[%s] did rename [%s] --> [%s]\n",
|
HDINFO("[%s] did rename [%s] --> [%s]",
|
||||||
Name(), temporaryFilePath.Path(), targetFilePath.Path());
|
Name(), temporaryFilePath.Path(), targetFilePath.Path())
|
||||||
result = B_IO_ERROR;
|
result = B_IO_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,18 +259,18 @@ AbstractServerProcess::DownloadToLocalFile(const BPath& targetFilePath,
|
|||||||
return B_CANCELED;
|
return B_CANCELED;
|
||||||
|
|
||||||
if (redirects > MAX_REDIRECTS) {
|
if (redirects > MAX_REDIRECTS) {
|
||||||
printf("[%s] exceeded %d redirects --> failure\n", 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) {
|
||||||
printf("[%s] exceeded %d failures\n", Name(), MAX_FAILURES);
|
HDINFO("[%s] exceeded %d failures", Name(), MAX_FAILURES)
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[%s] will stream '%s' to [%s]\n", 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());
|
||||||
@@ -314,12 +314,12 @@ AbstractServerProcess::DownloadToLocalFile(const BPath& targetFilePath,
|
|||||||
fRequest = NULL;
|
fRequest = NULL;
|
||||||
|
|
||||||
if (BHttpRequest::IsSuccessStatusCode(statusCode)) {
|
if (BHttpRequest::IsSuccessStatusCode(statusCode)) {
|
||||||
fprintf(stdout, "[%s] did complete streaming data [%"
|
HDINFO("[%s] did complete streaming data [%"
|
||||||
B_PRIdSSIZE " bytes]\n", 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) {
|
||||||
fprintf(stdout, "[%s] remote data has not changed since [%s]\n",
|
HDINFO("[%s] remote data has not changed since [%s]", Name(),
|
||||||
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);
|
||||||
@@ -327,25 +327,24 @@ AbstractServerProcess::DownloadToLocalFile(const BPath& targetFilePath,
|
|||||||
} else if (BHttpRequest::IsRedirectionStatusCode(statusCode)) {
|
} else if (BHttpRequest::IsRedirectionStatusCode(statusCode)) {
|
||||||
if (location.Length() != 0) {
|
if (location.Length() != 0) {
|
||||||
BUrl redirectUrl(result.Url(), location);
|
BUrl redirectUrl(result.Url(), location);
|
||||||
fprintf(stdout, "[%s] will redirect to; %s\n",
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout, "[%s] unable to find 'Location' header for redirect\n",
|
HDERROR("[%s] unable to find 'Location' header for redirect", Name())
|
||||||
Name());
|
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
} else {
|
} else {
|
||||||
if (statusCode == 0 || (statusCode / 100) == 5) {
|
if (statusCode == 0 || (statusCode / 100) == 5) {
|
||||||
fprintf(stdout, "error response from server [%" B_PRId32 "] --> "
|
HDERROR("error response from server [%" B_PRId32 "] --> retry...",
|
||||||
"retry...\n", statusCode);
|
statusCode)
|
||||||
return DownloadToLocalFile(targetFilePath, url, redirects,
|
return DownloadToLocalFile(targetFilePath, url, redirects,
|
||||||
failures + 1);
|
failures + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout, "[%s] unexpected response from server [%" B_PRId32 "]\n",
|
HDERROR("[%s] unexpected response from server [%" B_PRId32 "]",
|
||||||
Name(), statusCode);
|
Name(), statusCode)
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -378,13 +377,13 @@ AbstractServerProcess::MoveDamagedFileAside(const BPath& currentFilePath)
|
|||||||
damagedFilePath.Append(damagedLeaf.String());
|
damagedFilePath.Append(damagedLeaf.String());
|
||||||
|
|
||||||
if (0 != rename(currentFilePath.Path(), damagedFilePath.Path())) {
|
if (0 != rename(currentFilePath.Path(), damagedFilePath.Path())) {
|
||||||
printf("[%s] unable to move damaged file [%s] aside to [%s]\n",
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[%s] did move damaged file [%s] aside to [%s]\n",
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2018, Andrew Lindesay <[email protected]>.
|
* Copyright 2017-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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -29,9 +29,7 @@ AbstractSingleFileServerProcess::~AbstractSingleFileServerProcess()
|
|||||||
status_t
|
status_t
|
||||||
AbstractSingleFileServerProcess::RunInternal()
|
AbstractSingleFileServerProcess::RunInternal()
|
||||||
{
|
{
|
||||||
if (Logger::IsInfoEnabled())
|
HDINFO("[%s] will fetch data", Name())
|
||||||
printf("[%s] will fetch data\n", Name());
|
|
||||||
|
|
||||||
BPath localPath;
|
BPath localPath;
|
||||||
status_t result = GetLocalPath(localPath);
|
status_t result = GetLocalPath(localPath);
|
||||||
|
|
||||||
@@ -58,15 +56,14 @@ AbstractSingleFileServerProcess::RunInternal()
|
|||||||
|
|
||||||
if (!IsSuccess(result)) {
|
if (!IsSuccess(result)) {
|
||||||
if (hasData) {
|
if (hasData) {
|
||||||
printf("[%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\n", Name());
|
"anyway so carry on with that", Name())
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
} else {
|
} else {
|
||||||
printf("[%s] failed to obtain data\n", Name());
|
HDERROR("[%s] failed to obtain data", Name())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Logger::IsInfoEnabled())
|
HDINFO("[%s] did fetch data", Name())
|
||||||
printf("[%s] did fetch data\n", Name());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,12 +78,12 @@ AbstractSingleFileServerProcess::RunInternal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IsSuccess(result)) {
|
if (IsSuccess(result)) {
|
||||||
printf("[%s] will process data\n", Name());
|
HDINFO("[%s] will process data", Name())
|
||||||
result = ProcessLocalData();
|
result = ProcessLocalData();
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case B_OK:
|
case B_OK:
|
||||||
printf("[%s] did process data\n", Name());
|
HDINFO("[%s] did process data", Name())
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
MoveDamagedFileAside(localPath);
|
MoveDamagedFileAside(localPath);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018, Andrew Lindesay <[email protected]>.
|
* Copyright 2018-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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -89,9 +89,7 @@ LocalPkgDataLoadProcess::Description() const
|
|||||||
status_t
|
status_t
|
||||||
LocalPkgDataLoadProcess::RunInternal()
|
LocalPkgDataLoadProcess::RunInternal()
|
||||||
{
|
{
|
||||||
if (Logger::IsDebugEnabled())
|
HDDEBUG("[%s] will refresh the package list", Name())
|
||||||
printf("[%s] will refresh the package list\n", Name());
|
|
||||||
|
|
||||||
BPackageRoster roster;
|
BPackageRoster roster;
|
||||||
BStringList repositoryNames;
|
BStringList repositoryNames;
|
||||||
|
|
||||||
@@ -111,16 +109,12 @@ 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]",
|
||||||
if (Logger::IsDebugEnabled()) {
|
Name(), repoName.String(), repoConfig.Identifier().String())
|
||||||
printf("[%s] local repository [%s] info;\n"
|
|
||||||
" * url [%s]\n", Name(), repoName.String(),
|
|
||||||
repoConfig.Identifier().String());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
printf("[%s] unable to obtain the repository config for local "
|
HDINFO("[%s] unable to obtain the repository config for local "
|
||||||
"repository '%s'; %s\n", Name(),
|
"repository '%s'; %s", Name(),
|
||||||
repoName.String(), strerror(getRepositoryConfigStatus));
|
repoName.String(), strerror(getRepositoryConfigStatus))
|
||||||
}
|
}
|
||||||
|
|
||||||
depots[i] = depotInfo;
|
depots[i] = depotInfo;
|
||||||
@@ -226,18 +220,12 @@ LocalPkgDataLoadProcess::RunInternal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (it == depots.end()) {
|
if (it == depots.end()) {
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("pkg [%s] repository [%s] not recognized --> ignored",
|
||||||
printf("pkg [%s] repository [%s] not recognized"
|
modelInfo->Name().String(), repositoryName.String())
|
||||||
" --> ignored\n",
|
|
||||||
modelInfo->Name().String(), repositoryName.String());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
it->AddPackage(modelInfo);
|
it->AddPackage(modelInfo);
|
||||||
|
HDTRACE("pkg [%s] assigned to [%s]",
|
||||||
if (Logger::IsTraceEnabled()) {
|
modelInfo->Name().String(), repositoryName.String());
|
||||||
printf("pkg [%s] assigned to [%s]\n",
|
|
||||||
modelInfo->Name().String(), repositoryName.String());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remotePackages[modelInfo->Name()] = modelInfo;
|
remotePackages[modelInfo->Name()] = modelInfo;
|
||||||
@@ -363,20 +351,19 @@ LocalPkgDataLoadProcess::RunInternal()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (BFatalErrorException& ex) {
|
} catch (BFatalErrorException& ex) {
|
||||||
printf("Fatal exception occurred while resolving system dependencies: "
|
HDERROR("Fatal exception occurred while resolving system dependencies: "
|
||||||
"%s, details: %s\n", 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) {
|
||||||
printf("Exception occurred while resolving system dependencies: %s\n",
|
HDERROR("Exception occurred while resolving system dependencies: %s",
|
||||||
ex.Message().String());
|
ex.Message().String())
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
printf("Unknown exception occurred while resolving system "
|
HDERROR("Unknown exception occurred while resolving system "
|
||||||
"dependencies.\n");
|
"dependencies.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Logger::IsDebugEnabled())
|
HDDEBUG("did refresh the package list")
|
||||||
printf("did refresh the package list\n");
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -385,8 +372,8 @@ LocalPkgDataLoadProcess::RunInternal()
|
|||||||
void
|
void
|
||||||
LocalPkgDataLoadProcess::_NotifyError(const BString& messageText) const
|
LocalPkgDataLoadProcess::_NotifyError(const BString& messageText) const
|
||||||
{
|
{
|
||||||
printf("an error has arisen loading data of packages from local : %s\n",
|
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,10 +66,7 @@ LocalRepositoryUpdateProcess::RunInternal()
|
|||||||
{
|
{
|
||||||
BPackageRoster roster;
|
BPackageRoster roster;
|
||||||
BStringList repoNames;
|
BStringList repoNames;
|
||||||
|
HDINFO("[%s] will update local repositories' caches", Name())
|
||||||
if (Logger::IsInfoEnabled()) {
|
|
||||||
printf("[%s] will update local repositories' caches\n", Name());
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t result = roster.GetRepositoryNames(repoNames);
|
status_t result = roster.GetRepositoryNames(repoNames);
|
||||||
|
|
||||||
@@ -91,9 +88,9 @@ LocalRepositoryUpdateProcess::RunInternal()
|
|||||||
result = B_ERROR;
|
result = B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == B_OK && Logger::IsInfoEnabled()) {
|
if (result == B_OK) {
|
||||||
printf("[%s] did update %" B_PRIi32 " local repositories' caches\n",
|
HDINFO("[%s] did update %" B_PRIi32 " local repositories' caches",
|
||||||
Name(), repoNames.CountStrings());
|
Name(), repoNames.CountStrings())
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -106,34 +103,25 @@ LocalRepositoryUpdateProcess::_ShouldRunForRepositoryName(
|
|||||||
BPackageKit::BRepositoryCache* cache)
|
BPackageKit::BRepositoryCache* cache)
|
||||||
{
|
{
|
||||||
if (fForce) {
|
if (fForce) {
|
||||||
if (Logger::IsInfoEnabled()) {
|
HDINFO("[%s] am refreshing cache for repo [%s] as it was forced",
|
||||||
printf("[%s] am refreshing cache for repo [%s] as it was forced\n",
|
Name(), repoName.String())
|
||||||
Name(), repoName.String());
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roster.GetRepositoryCache(repoName, cache) != B_OK) {
|
if (roster.GetRepositoryCache(repoName, cache) != B_OK) {
|
||||||
if (Logger::IsInfoEnabled()) {
|
HDINFO("[%s] am updating cache for repo [%s] as there was no cache",
|
||||||
printf("[%s] am updating cache for repo [%s] as there was no"
|
Name(), repoName.String())
|
||||||
" cache\n", Name(), repoName.String());
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (static_cast<App*>(be_app)->IsFirstRun()) {
|
if (static_cast<App*>(be_app)->IsFirstRun()) {
|
||||||
if (Logger::IsInfoEnabled()) {
|
HDINFO("[%s] am updating cache for repo [%s] as this is the first"
|
||||||
printf("[%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\n", Name(),
|
|
||||||
repoName.String());
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("[%s] skipped update local repo [%s] cache", Name(),
|
||||||
printf("[%s] skipped update local repo [%s] cache\n", Name(),
|
repoName.String())
|
||||||
repoName.String());
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -152,10 +140,8 @@ LocalRepositoryUpdateProcess::_RunForRepositoryName(const BString& repoName,
|
|||||||
try {
|
try {
|
||||||
BRefreshRepositoryRequest refreshRequest(context, repoConfig);
|
BRefreshRepositoryRequest refreshRequest(context, repoConfig);
|
||||||
result = refreshRequest.Process();
|
result = refreshRequest.Process();
|
||||||
if (Logger::IsInfoEnabled()) {
|
HDINFO("[%s] did update local repo [%s] cache", Name(),
|
||||||
printf("[%s] did update local repo [%s] cache\n", Name(),
|
repoName.String());
|
||||||
repoName.String());
|
|
||||||
}
|
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
} catch (BFatalErrorException& ex) {
|
} catch (BFatalErrorException& ex) {
|
||||||
_NotifyError(ex.Message(), ex.Details());
|
_NotifyError(ex.Message(), ex.Details());
|
||||||
@@ -182,8 +168,8 @@ void
|
|||||||
LocalRepositoryUpdateProcess::_NotifyError(const BString& error,
|
LocalRepositoryUpdateProcess::_NotifyError(const BString& error,
|
||||||
const BString& details) const
|
const BString& details) const
|
||||||
{
|
{
|
||||||
printf("an error has arisen updating the local repositories : %s\n",
|
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,13 +142,16 @@ ProcessCoordinator::Stop()
|
|||||||
AutoLocker<BLocker> locker(&fLock);
|
AutoLocker<BLocker> locker(&fLock);
|
||||||
if (!fWasStopped) {
|
if (!fWasStopped) {
|
||||||
fWasStopped = true;
|
fWasStopped = true;
|
||||||
printf("[Coordinator] will stop process coordinator\n");
|
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);
|
||||||
printf("[%s] stopping process", node->Process()->Name());
|
if (node->Process()->ErrorStatus() != B_OK) {
|
||||||
if (node->Process()->ErrorStatus() != B_OK)
|
HDINFO("[Coordinator] stopping process [%s] (owing to error)",
|
||||||
printf(" (error)\n");
|
node->Process()->Name());
|
||||||
printf("\n");
|
} else {
|
||||||
|
HDINFO("[Coordinator] stopping process [%s]",
|
||||||
|
node->Process()->Name());
|
||||||
|
}
|
||||||
node->StopProcess();
|
node->StopProcess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,11 +263,8 @@ ProcessCoordinator::_CoordinateAndCallListener()
|
|||||||
ProcessCoordinatorState
|
ProcessCoordinatorState
|
||||||
ProcessCoordinator::_Coordinate()
|
ProcessCoordinator::_Coordinate()
|
||||||
{
|
{
|
||||||
if (Logger::IsTraceEnabled())
|
HDTRACE("[Coordinator] will coordinate nodes")
|
||||||
printf("[Coordinator] will coordinate nodes\n");
|
|
||||||
|
|
||||||
AutoLocker<BLocker> locker(&fLock);
|
AutoLocker<BLocker> locker(&fLock);
|
||||||
|
|
||||||
_StopSuccessorNodesToErroredOrStoppedNodes();
|
_StopSuccessorNodesToErroredOrStoppedNodes();
|
||||||
|
|
||||||
// go through the nodes and find those that are still to be run and
|
// go through the nodes and find those that are still to be run and
|
||||||
@@ -276,16 +276,12 @@ ProcessCoordinator::_Coordinate()
|
|||||||
if (node->AllPredecessorsComplete())
|
if (node->AllPredecessorsComplete())
|
||||||
node->StartProcess();
|
node->StartProcess();
|
||||||
else {
|
else {
|
||||||
if (Logger::IsTraceEnabled()) {
|
HDTRACE("[Coordinator] all predecessors not complete -> "
|
||||||
printf("[Coordinator] all predecessors not complete -> "
|
"[%s] not started", node->Process()->Name());
|
||||||
"[%s] not started\n", node->Process()->Name());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Logger::IsTraceEnabled()) {
|
HDTRACE("[Coordinator] process [%s] running or complete",
|
||||||
printf("[Coordinator] process [%s] running or complete\n",
|
node->Process()->Name());
|
||||||
node->Process()->Name());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,10 +314,8 @@ ProcessCoordinator::_StopSuccessorNodes(ProcessNode* predecessorNode)
|
|||||||
AbstractProcess* process = node->Process();
|
AbstractProcess* process = node->Process();
|
||||||
|
|
||||||
if (process->ProcessState() == PROCESS_INITIAL) {
|
if (process->ProcessState() == PROCESS_INITIAL) {
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("[Coordinator] [%s] (failed) --> [%s] (stopping)",
|
||||||
printf("[Coordinator] [%s] (failed) --> [%s] (stopping)\n",
|
predecessorNode->Process()->Name(), process->Name())
|
||||||
predecessorNode->Process()->Name(), process->Name());
|
|
||||||
}
|
|
||||||
node->StopProcess();
|
node->StopProcess();
|
||||||
_StopSuccessorNodes(node);
|
_StopSuccessorNodes(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "HaikuDepotConstants.h"
|
#include "HaikuDepotConstants.h"
|
||||||
#include "LocalPkgDataLoadProcess.h"
|
#include "LocalPkgDataLoadProcess.h"
|
||||||
#include "LocalRepositoryUpdateProcess.h"
|
#include "LocalRepositoryUpdateProcess.h"
|
||||||
|
#include "Logger.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
#include "PackageInfoListener.h"
|
#include "PackageInfoListener.h"
|
||||||
#include "ProcessCoordinator.h"
|
#include "ProcessCoordinator.h"
|
||||||
@@ -114,7 +115,7 @@ ProcessCoordinatorFactory::CreateBulkLoadCoordinator(
|
|||||||
processCoordinator->AddNode(processNode);
|
processCoordinator->AddNode(processNode);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("a problem has arisen getting the repository names.\n");
|
HDERROR("a problem has arisen getting the repository names.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,8 +129,8 @@ ProcessCoordinatorFactory::_CalculateServerProcessOptions()
|
|||||||
uint32 processOptions = 0;
|
uint32 processOptions = 0;
|
||||||
|
|
||||||
if (ServerSettings::IsClientTooOld()) {
|
if (ServerSettings::IsClientTooOld()) {
|
||||||
printf("bulk load proceeding without network communications "
|
HDINFO("bulk load proceeding without network communications "
|
||||||
"because the client is too old\n");
|
"because the client is too old")
|
||||||
processOptions |= SERVER_PROCESS_NO_NETWORKING;
|
processOptions |= SERVER_PROCESS_NO_NETWORKING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ ProcessNode::_SpinUntilProcessState(
|
|||||||
usleep(SPIN_UNTIL_STARTED_DELAY_MI);
|
usleep(SPIN_UNTIL_STARTED_DELAY_MI);
|
||||||
|
|
||||||
if (real_time_clock() - start > timeoutSeconds) {
|
if (real_time_clock() - start > timeoutSeconds) {
|
||||||
printf("[Node<%s>] timeout waiting for process state\n",
|
HDERROR("[Node<%s>] timeout waiting for process state",
|
||||||
Process()->Name());
|
Process()->Name())
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,8 +75,7 @@ ProcessNode::StartProcess()
|
|||||||
if (fWorker != B_BAD_THREAD_ID)
|
if (fWorker != B_BAD_THREAD_ID)
|
||||||
return B_BUSY;
|
return B_BUSY;
|
||||||
|
|
||||||
if (Logger::IsInfoEnabled())
|
HDINFO("[Node<%s>] initiating", Process()->Name())
|
||||||
printf("[Node<%s>] initiating\n", Process()->Name());
|
|
||||||
|
|
||||||
fWorker = spawn_thread(&_StartProcess, Process()->Name(),
|
fWorker = spawn_thread(&_StartProcess, Process()->Name(),
|
||||||
B_NORMAL_PRIORITY, Process());
|
B_NORMAL_PRIORITY, Process());
|
||||||
@@ -106,8 +105,8 @@ ProcessNode::StopProcess()
|
|||||||
// down.
|
// down.
|
||||||
|
|
||||||
if (waitResult != B_OK) {
|
if (waitResult != B_OK) {
|
||||||
printf("[%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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,9 +129,7 @@ ProcessNode::_StartProcess(void* cookie)
|
|||||||
{
|
{
|
||||||
AbstractProcess* process = static_cast<AbstractProcess*>(cookie);
|
AbstractProcess* process = static_cast<AbstractProcess*>(cookie);
|
||||||
|
|
||||||
if (Logger::IsInfoEnabled()) {
|
HDINFO("[Node<%s>] starting process", process->Name())
|
||||||
printf("[Node<%s>] starting process\n", process->Name());
|
|
||||||
}
|
|
||||||
|
|
||||||
process->Run();
|
process->Run();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2018, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2017-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ServerIconExportUpdateProcess.h"
|
#include "ServerIconExportUpdateProcess.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@@ -40,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) {
|
||||||
printf("[%s] unable to obtain the path for storing icons\n", Name());
|
HDINFO("[%s] unable to obtain the path for storing icons", Name())
|
||||||
fLocalIconStoragePath.Unset();
|
fLocalIconStoragePath.Unset();
|
||||||
fLocalIconStore = NULL;
|
fLocalIconStore = NULL;
|
||||||
} else {
|
} else {
|
||||||
@@ -116,10 +115,8 @@ ServerIconExportUpdateProcess::Populate()
|
|||||||
depots = fModel->Depots();
|
depots = fModel->Depots();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("[%s] will populate icons for %" B_PRId32 " depots", Name(),
|
||||||
printf("[%s] will populate icons for %" B_PRId32 " depots\n", 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);
|
||||||
@@ -131,8 +128,8 @@ ServerIconExportUpdateProcess::Populate()
|
|||||||
|
|
||||||
if (Logger::IsInfoEnabled()) {
|
if (Logger::IsInfoEnabled()) {
|
||||||
double secs = watch.ElapsedTime() / 1000000.0;
|
double secs = watch.ElapsedTime() / 1000000.0;
|
||||||
printf("[%s] did populate %" B_PRId32 " packages' icons (%6.3g secs)\n",
|
HDINFO("[%s] did populate %" B_PRId32 " packages' icons (%6.3g secs)",
|
||||||
Name(), fCountIconsSet, secs);
|
Name(), fCountIconsSet, secs)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -144,8 +141,8 @@ ServerIconExportUpdateProcess::Populate()
|
|||||||
status_t
|
status_t
|
||||||
ServerIconExportUpdateProcess::PopulateForDepot(const DepotInfo& depot)
|
ServerIconExportUpdateProcess::PopulateForDepot(const DepotInfo& depot)
|
||||||
{
|
{
|
||||||
printf("[%s] will populate icons for depot [%s]\n",
|
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;
|
||||||
@@ -176,20 +173,16 @@ ServerIconExportUpdateProcess::PopulateForPkg(const PackageInfoRef& package)
|
|||||||
BitmapRef bitmapRef(new(std::nothrow)SharedBitmap(bestIconFile), true);
|
BitmapRef bitmapRef(new(std::nothrow)SharedBitmap(bestIconFile), true);
|
||||||
package->SetIcon(bitmapRef);
|
package->SetIcon(bitmapRef);
|
||||||
|
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("[%s] have set the package icon for [%s] from [%s]",
|
||||||
printf("[%s] have set the package icon for [%s] from [%s]\n",
|
Name(), package->Name().String(), bestIconPath.Path())
|
||||||
Name(), package->Name().String(), bestIconPath.Path());
|
|
||||||
}
|
|
||||||
|
|
||||||
fCountIconsSet++;
|
fCountIconsSet++;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("[%s] did not set the package icon for [%s]; no data",
|
||||||
printf("[%s] did not set the package icon for [%s]; no data\n",
|
Name(), package->Name().String())
|
||||||
Name(), package->Name().String());
|
|
||||||
}
|
|
||||||
|
|
||||||
return B_FILE_NOT_FOUND;
|
return B_FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
@@ -201,13 +194,13 @@ ServerIconExportUpdateProcess::_DownloadAndUnpack()
|
|||||||
BPath tarGzFilePath(tmpnam(NULL));
|
BPath tarGzFilePath(tmpnam(NULL));
|
||||||
status_t result = B_OK;
|
status_t result = B_OK;
|
||||||
|
|
||||||
printf("[%s] will start fetching icons\n", 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:
|
||||||
printf("[%s] icons not modified - will use existing\n", Name());
|
HDINFO("[%s] icons not modified - will use existing", Name())
|
||||||
return result;
|
return result;
|
||||||
break;
|
break;
|
||||||
case B_OK:
|
case B_OK:
|
||||||
@@ -231,14 +224,14 @@ ServerIconExportUpdateProcess::_HandleDownloadFailure()
|
|||||||
|
|
||||||
if (result == B_OK) {
|
if (result == B_OK) {
|
||||||
if (hasData) {
|
if (hasData) {
|
||||||
printf("[%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\n", Name());
|
"so will carry on with that", Name())
|
||||||
} else {
|
} else {
|
||||||
printf("[%s] failed to obtain data\n", Name());
|
HDINFO("[%s] failed to obtain data", Name())
|
||||||
result = HD_ERR_NO_DATA;
|
result = HD_ERR_NO_DATA;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("[%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;
|
||||||
@@ -253,7 +246,7 @@ status_t
|
|||||||
ServerIconExportUpdateProcess::_Unpack(BPath& tarGzFilePath)
|
ServerIconExportUpdateProcess::_Unpack(BPath& tarGzFilePath)
|
||||||
{
|
{
|
||||||
status_t result;
|
status_t result;
|
||||||
printf("[%s] delete any existing stored data\n", 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);
|
||||||
@@ -276,18 +269,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;
|
||||||
printf("[%s] did unpack icon tgz in (%6.3g secs)\n", Name(),
|
HDINFO("[%s] did unpack icon tgz in (%6.3g secs)", Name(), secs)
|
||||||
secs);
|
|
||||||
|
|
||||||
if (0 != remove(tarGzFilePath.Path())) {
|
if (0 != remove(tarGzFilePath.Path())) {
|
||||||
printf("unable to delete the temporary tgz path; %s\n",
|
HDERROR("[%s] unable to delete the temporary tgz path; %s",
|
||||||
tarGzFilePath.Path());
|
Name(), tarGzFilePath.Path())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete tarGzFile;
|
delete tarGzFile;
|
||||||
printf("[%s] did complete unpacking icons\n", Name());
|
HDINFO("[%s] did complete unpacking icons", Name())
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,8 +143,8 @@ PackageFillingPkgListener::ConsumePackage(const PackageInfoRef& package,
|
|||||||
int categoryIndex = IndexOfCategoryByCode(*(categoryCode));
|
int categoryIndex = IndexOfCategoryByCode(*(categoryCode));
|
||||||
|
|
||||||
if (categoryIndex == -1) {
|
if (categoryIndex == -1) {
|
||||||
printf("unable to find the category for [%s]\n",
|
HDERROR("unable to find the category for [%s]",
|
||||||
categoryCode->String());
|
categoryCode->String())
|
||||||
} else {
|
} else {
|
||||||
package->AddCategory(
|
package->AddCategory(
|
||||||
fCategories.ItemAtFast(categoryIndex));
|
fCategories.ItemAtFast(categoryIndex));
|
||||||
@@ -176,10 +176,8 @@ PackageFillingPkgListener::ConsumePackage(const PackageInfoRef& package,
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fDebugEnabled) {
|
HDDEBUG("did populate data for [%s] (%s)", pkg->Name()->String(),
|
||||||
printf("did populate data for [%s] (%s)\n", pkg->Name()->String(),
|
fDepotName.String())
|
||||||
fDepotName.String());
|
|
||||||
}
|
|
||||||
|
|
||||||
fCount++;
|
fCount++;
|
||||||
|
|
||||||
@@ -213,12 +211,12 @@ PackageFillingPkgListener::Handle(DumpExportPkg* pkg)
|
|||||||
AutoLocker<BLocker> locker(fModel->Lock());
|
AutoLocker<BLocker> locker(fModel->Lock());
|
||||||
ConsumePackage(packageInfoRef, pkg);
|
ConsumePackage(packageInfoRef, pkg);
|
||||||
} else {
|
} else {
|
||||||
printf("[PackageFillingPkgListener] unable to find the pkg [%s]\n",
|
HDINFO("[PackageFillingPkgListener] unable to find the pkg [%s]",
|
||||||
packageName.String());
|
packageName.String())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("[PackageFillingPkgListener] unable to find the depot [%s]\n",
|
HDINFO("[PackageFillingPkgListener] unable to find the depot [%s]",
|
||||||
fDepotName.String());
|
fDepotName.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
return !fStoppable->WasStopped();
|
return !fStoppable->WasStopped();
|
||||||
@@ -322,8 +320,8 @@ ServerPkgDataUpdateProcess::ProcessLocalData()
|
|||||||
|
|
||||||
if (Logger::IsInfoEnabled()) {
|
if (Logger::IsInfoEnabled()) {
|
||||||
double secs = watch.ElapsedTime() / 1000000.0;
|
double secs = watch.ElapsedTime() / 1000000.0;
|
||||||
printf("[%s] did process %" B_PRIi32 " packages' data "
|
HDINFO("[%s] did process %" B_PRIi32 " packages' data "
|
||||||
"in (%6.3g secs)\n", Name(), itemListener->Count(), secs);
|
"in (%6.3g secs)", Name(), itemListener->Count(), secs)
|
||||||
}
|
}
|
||||||
|
|
||||||
return listener->ErrorStatus();
|
return listener->ErrorStatus();
|
||||||
@@ -362,11 +360,9 @@ status_t
|
|||||||
ServerPkgDataUpdateProcess::RunInternal()
|
ServerPkgDataUpdateProcess::RunInternal()
|
||||||
{
|
{
|
||||||
if (_DeriveWebAppRepositorySourceCode().IsEmpty()) {
|
if (_DeriveWebAppRepositorySourceCode().IsEmpty()) {
|
||||||
if (Logger::IsInfoEnabled()) {
|
HDINFO("[%s] am not updating data for depot [%s] as there is no"
|
||||||
printf("[%s] am not updating data for depot [%s] as there is no"
|
" web app repository source code available",
|
||||||
" web app repository source code available\n",
|
Name(), fDepotName.String())
|
||||||
Name(), fDepotName.String());
|
|
||||||
}
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ status_t
|
|||||||
ServerReferenceDataUpdateProcess::_ProcessNaturalLanguages(
|
ServerReferenceDataUpdateProcess::_ProcessNaturalLanguages(
|
||||||
DumpExportReference* data)
|
DumpExportReference* data)
|
||||||
{
|
{
|
||||||
printf("[%s] will populate %" B_PRId32 " natural languages\n",
|
HDINFO("[%s] will populate %" B_PRId32 " natural languages",
|
||||||
Name(), data->CountNaturalLanguages());
|
Name(), data->CountNaturalLanguages())
|
||||||
|
|
||||||
LanguageList result;
|
LanguageList result;
|
||||||
|
|
||||||
@@ -143,8 +143,8 @@ ServerReferenceDataUpdateProcess::_ProcessNaturalLanguages(
|
|||||||
fModel->Language().AddSupportedLanguages(result);
|
fModel->Language().AddSupportedLanguages(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[%s] did add %" B_PRId32 " supported languages\n",
|
HDINFO("[%s] did add %" B_PRId32 " supported languages",
|
||||||
Name(), result.CountItems());
|
Name(), result.CountItems())
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -154,8 +154,8 @@ status_t
|
|||||||
ServerReferenceDataUpdateProcess::_ProcessPkgCategories(
|
ServerReferenceDataUpdateProcess::_ProcessPkgCategories(
|
||||||
DumpExportReference* data)
|
DumpExportReference* data)
|
||||||
{
|
{
|
||||||
printf("[%s] will populate %" B_PRId32 " pkg categories\n",
|
HDINFO("[%s] will populate %" B_PRId32 " pkg categories",
|
||||||
Name(), data->CountPkgCategories());
|
Name(), data->CountPkgCategories())
|
||||||
|
|
||||||
CategoryList result;
|
CategoryList result;
|
||||||
|
|
||||||
|
|||||||
@@ -102,18 +102,18 @@ DepotMatchingRepositoryListener::MapDepot(const DepotInfo& depot, void *context)
|
|||||||
BString(*repositorySourceCode));
|
BString(*repositorySourceCode));
|
||||||
|
|
||||||
if (Logger::IsDebugEnabled()) {
|
if (Logger::IsDebugEnabled()) {
|
||||||
printf("[DepotMatchingRepositoryListener] associated depot [%s] (%s) "
|
HDDEBUG("[DepotMatchingRepositoryListener] associated depot [%s] (%s) "
|
||||||
"with server repository source [%s] (%s)\n",
|
"with server repository source [%s] (%s)",
|
||||||
modifiedDepotInfo.Name().String(),
|
modifiedDepotInfo.Name().String(),
|
||||||
modifiedDepotInfo.URL().String(),
|
modifiedDepotInfo.URL().String(),
|
||||||
repositorySourceCode->String(),
|
repositorySourceCode->String(),
|
||||||
repositoryAndRepositorySource
|
repositoryAndRepositorySource
|
||||||
->repositorySource->Identifier()->String());
|
->repositorySource->Identifier()->String())
|
||||||
} else {
|
} else {
|
||||||
printf("[DepotMatchingRepositoryListener] associated depot [%s] with "
|
HDINFO("[DepotMatchingRepositoryListener] associated depot [%s] with "
|
||||||
"server repository source [%s]\n",
|
"server repository source [%s]",
|
||||||
modifiedDepotInfo.Name().String(),
|
modifiedDepotInfo.Name().String(),
|
||||||
repositorySourceCode->String());
|
repositorySourceCode->String())
|
||||||
}
|
}
|
||||||
|
|
||||||
return modifiedDepotInfo;
|
return modifiedDepotInfo;
|
||||||
@@ -133,7 +133,8 @@ DepotMatchingRepositoryListener::Handle(const BString& identifier,
|
|||||||
void
|
void
|
||||||
DepotMatchingRepositoryListener::Handle(repository_and_repository_source& pair)
|
DepotMatchingRepositoryListener::Handle(repository_and_repository_source& pair)
|
||||||
{
|
{
|
||||||
Handle(*(pair.repositorySource->Identifier()), pair);
|
if (!pair.repositorySource->IdentifierIsNull())
|
||||||
|
Handle(*(pair.repositorySource->Identifier()), pair);
|
||||||
|
|
||||||
// there may be additional identifiers for the remote repository and
|
// there may be additional identifiers for the remote repository and
|
||||||
// these should also be taken into consideration.
|
// these should also be taken into consideration.
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2018, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2017-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ServerSettings.h"
|
#include "ServerSettings.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
@@ -17,6 +16,8 @@
|
|||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <Url.h>
|
#include <Url.h>
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
|
|
||||||
#define BASEURL_DEFAULT "https://depot.haiku-os.org"
|
#define BASEURL_DEFAULT "https://depot.haiku-os.org"
|
||||||
#define USERAGENT_FALLBACK_VERSION "0.0.0"
|
#define USERAGENT_FALLBACK_VERSION "0.0.0"
|
||||||
@@ -36,12 +37,12 @@ status_t
|
|||||||
ServerSettings::SetBaseUrl(const BUrl& value)
|
ServerSettings::SetBaseUrl(const BUrl& value)
|
||||||
{
|
{
|
||||||
if (!value.IsValid()) {
|
if (!value.IsValid()) {
|
||||||
fprintf(stderr, "the url is not valid\n");
|
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") {
|
||||||
fprintf(stderr, "the url protocol must be 'http' or 'https'\n");
|
HDERROR("the url protocol must be 'http' or 'https'")
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,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) {
|
||||||
fprintf(stderr, "Unable to get the application info\n");
|
HDERROR("Unable to get the application info")
|
||||||
be_app->Quit();
|
be_app->Quit();
|
||||||
return BString(USERAGENT_FALLBACK_VERSION);
|
return BString(USERAGENT_FALLBACK_VERSION);
|
||||||
}
|
}
|
||||||
@@ -90,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) {
|
||||||
fprintf(stderr, "Unable to access the application info file\n");
|
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,7 +101,7 @@ ServerSettings::_GetUserAgentVersionString()
|
|||||||
|
|
||||||
if (appFileInfo.GetVersionInfo(
|
if (appFileInfo.GetVersionInfo(
|
||||||
&versionInfo, B_APP_VERSION_KIND) != B_OK) {
|
&versionInfo, B_APP_VERSION_KIND) != B_OK) {
|
||||||
fprintf(stderr, "Unable to establish the application version\n");
|
HDERROR("Unable to establish the application version")
|
||||||
be_app->Quit();
|
be_app->Quit();
|
||||||
return BString(USERAGENT_FALLBACK_VERSION);
|
return BString(USERAGENT_FALLBACK_VERSION);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2017-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "StandardMetaDataJsonEventListener.h"
|
#include "StandardMetaDataJsonEventListener.h"
|
||||||
|
|
||||||
#include "stdio.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
|
|
||||||
#define KEY_CREATE_TIMESTAMP "createTimestamp"
|
#define KEY_CREATE_TIMESTAMP "createTimestamp"
|
||||||
@@ -384,8 +384,8 @@ void
|
|||||||
StandardMetaDataJsonEventListener::HandleError(status_t status, int32 line,
|
StandardMetaDataJsonEventListener::HandleError(status_t status, int32 line,
|
||||||
const char* message)
|
const char* message)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "an error has arisen processing the standard "
|
HDERROR("an error has arisen processing the standard "
|
||||||
"meta data; %s\n", message);
|
"meta data; %s", message)
|
||||||
fErrorStatus = status;
|
fErrorStatus = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ UserDetailVerifierProcess::RunInternal()
|
|||||||
break;
|
break;
|
||||||
case B_OK:
|
case B_OK:
|
||||||
if (!userDetail.Agreement().IsLatest()) {
|
if (!userDetail.Agreement().IsLatest()) {
|
||||||
printf("! the user has not agreed to the latest user usage"
|
HDINFO("the user has not agreed to the latest user usage"
|
||||||
" conditions.\n");
|
" conditions.")
|
||||||
fListener->UserUsageConditionsNotLatest(userDetail);
|
fListener->UserUsageConditionsNotLatest(userDetail);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -80,14 +80,14 @@ bool
|
|||||||
UserDetailVerifierProcess::_ShouldVerify()
|
UserDetailVerifierProcess::_ShouldVerify()
|
||||||
{
|
{
|
||||||
if (!ServerHelper::IsNetworkAvailable()) {
|
if (!ServerHelper::IsNetworkAvailable()) {
|
||||||
printf("no network --> will not verify user\n");
|
HDINFO("no network --> will not verify user")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
AutoLocker<BLocker> locker(fModel->Lock());
|
AutoLocker<BLocker> locker(fModel->Lock());
|
||||||
if (fModel->Nickname().IsEmpty()) {
|
if (fModel->Nickname().IsEmpty()) {
|
||||||
printf("no nickname --> will not verify user\n");
|
HDINFO("no nickname --> will not verify user");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,8 +105,8 @@ UserDetailVerifierProcess::_TryFetchUserDetail(UserDetail& userDetail)
|
|||||||
|
|
||||||
result = interface.RetrieveCurrentUserDetail(userDetailResponse);
|
result = interface.RetrieveCurrentUserDetail(userDetailResponse);
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
printf("a problem has arisen retrieving the current user detail: %s\n",
|
HDERROR("a problem has arisen retrieving the current user detail: %s",
|
||||||
strerror(result));
|
strerror(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == B_OK) {
|
if (result == B_OK) {
|
||||||
@@ -118,9 +118,9 @@ UserDetailVerifierProcess::_TryFetchUserDetail(UserDetail& userDetail)
|
|||||||
result = B_PERMISSION_DENIED;
|
result = B_PERMISSION_DENIED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("! 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 "\n",
|
"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)
|
||||||
printf("! it was not possible to unpack the user details.\n");
|
HDERROR("it was not possible to unpack the user details.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
#include "WebAppInterface.h"
|
#include "WebAppInterface.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <HttpHeaders.h>
|
#include <HttpHeaders.h>
|
||||||
#include <HttpRequest.h>
|
#include <HttpRequest.h>
|
||||||
@@ -35,10 +33,9 @@
|
|||||||
|
|
||||||
class ProtocolListener : public BUrlProtocolListener {
|
class ProtocolListener : public BUrlProtocolListener {
|
||||||
public:
|
public:
|
||||||
ProtocolListener(bool traceLogging)
|
ProtocolListener()
|
||||||
:
|
:
|
||||||
fDownloadIO(NULL),
|
fDownloadIO(NULL)
|
||||||
fTraceLogging(traceLogging)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +83,7 @@ public:
|
|||||||
virtual void DebugMessage(BUrlRequest* caller,
|
virtual void DebugMessage(BUrlRequest* caller,
|
||||||
BUrlProtocolDebugMessage type, const char* text)
|
BUrlProtocolDebugMessage type, const char* text)
|
||||||
{
|
{
|
||||||
if (fTraceLogging)
|
HDTRACE("jrpc: %s", text)
|
||||||
printf("jrpc: %s\n", text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDownloadIO(BDataIO* downloadIO)
|
void SetDownloadIO(BDataIO* downloadIO)
|
||||||
@@ -97,7 +93,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BDataIO* fDownloadIO;
|
BDataIO* fDownloadIO;
|
||||||
bool fTraceLogging;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -342,7 +337,7 @@ WebAppInterface::UnpackUserDetail(BMessage& responseEnvelopeMessage,
|
|||||||
"result", &resultMessage);
|
"result", &resultMessage);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
fprintf(stderr, "bad response envelope missing 'result' entry\n");
|
HDERROR("bad response envelope missing 'result' entry");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,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) {
|
||||||
fprintf(stderr, "bad response envelope missing 'result' entry\n");
|
HDERROR("bad response envelope missing 'result' entry")
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,10 +409,10 @@ WebAppInterface::RetrieveUserUsageConditions(const BString& code,
|
|||||||
BString copyMarkdown;
|
BString copyMarkdown;
|
||||||
|
|
||||||
if ( (resultMessage.FindString("code", &metaDataCode) != B_OK)
|
if ( (resultMessage.FindString("code", &metaDataCode) != B_OK)
|
||||||
|| (resultMessage.FindDouble(
|
|| (resultMessage.FindDouble(
|
||||||
"minimumAge", &metaDataMinimumAge) != B_OK) ) {
|
"minimumAge", &metaDataMinimumAge) != B_OK) ) {
|
||||||
printf("unexpected response from server with missing user usage "
|
HDERROR("unexpected response from server with missing user usage "
|
||||||
"conditions data\n");
|
"conditions data")
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -811,48 +806,40 @@ 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) {
|
||||||
if (Logger::IsInfoEnabled())
|
HDINFO("jrpc; empty request payload")
|
||||||
printf("jrpc; empty request payload\n");
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ServerHelper::IsNetworkAvailable()) {
|
if (!ServerHelper::IsNetworkAvailable()) {
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("jrpc; dropping request to ...[%s] as network is not"
|
||||||
printf("jrpc; dropping request to ...[%s] as network is not "
|
" available", domain)
|
||||||
"available\n", domain);
|
|
||||||
}
|
|
||||||
delete requestData;
|
delete requestData;
|
||||||
return HD_NETWORK_INACCESSIBLE;
|
return HD_NETWORK_INACCESSIBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ServerSettings::IsClientTooOld()) {
|
if (ServerSettings::IsClientTooOld()) {
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("jrpc; dropping request to ...[%s] as client is too old",
|
||||||
printf("jrpc; dropping request to ...[%s] as client is too "
|
domain)
|
||||||
"old\n", 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())
|
||||||
if (Logger::IsDebugEnabled()) {
|
|
||||||
printf("jrpc; will make request to [%s]\n",
|
|
||||||
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
|
||||||
// delivered from memory.
|
// delivered from memory.
|
||||||
|
|
||||||
if (Logger::IsTraceEnabled()) {
|
if (Logger::IsTraceEnabled()) {
|
||||||
|
HDLOGPREFIX(LOG_LEVEL_TRACE)
|
||||||
printf("jrpc request; ");
|
printf("jrpc request; ");
|
||||||
_LogPayload(requestData, requestDataSize);
|
_LogPayload(requestData, requestDataSize);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolListener listener(Logger::IsTraceEnabled());
|
ProtocolListener listener;
|
||||||
BUrlContext context;
|
BUrlContext context;
|
||||||
|
|
||||||
BHttpHeaders headers;
|
BHttpHeaders headers;
|
||||||
@@ -886,10 +873,8 @@ WebAppInterface::_SendJsonRequest(const char* domain,
|
|||||||
|
|
||||||
int32 statusCode = result.StatusCode();
|
int32 statusCode = result.StatusCode();
|
||||||
|
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("jrpc; did receive http-status [%" B_PRId32 "] from [%s]",
|
||||||
printf("jrpc; did receive http-status [%" B_PRId32 "] "
|
statusCode, url.UrlString().String())
|
||||||
"from [%s]\n", statusCode, url.UrlString().String());
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (statusCode) {
|
switch (statusCode) {
|
||||||
case B_HTTP_STATUS_OK:
|
case B_HTTP_STATUS_OK:
|
||||||
@@ -900,14 +885,15 @@ WebAppInterface::_SendJsonRequest(const char* domain,
|
|||||||
return HD_CLIENT_TOO_OLD;
|
return HD_CLIENT_TOO_OLD;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("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;
|
||||||
}
|
}
|
||||||
|
|
||||||
replyData.Seek(0, SEEK_SET);
|
replyData.Seek(0, SEEK_SET);
|
||||||
|
|
||||||
if (Logger::IsTraceEnabled()) {
|
if (Logger::IsTraceEnabled()) {
|
||||||
|
HDLOGPREFIX(LOG_LEVEL_TRACE)
|
||||||
printf("jrpc response; ");
|
printf("jrpc response; ");
|
||||||
_LogPayload(&replyData, replyData.BufferLength());
|
_LogPayload(&replyData, replyData.BufferLength());
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -920,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());
|
||||||
printf("Parser choked on JSON:\n%s\n", resultString.String());
|
HDERROR("Parser choked on JSON:\n%s", resultString.String())
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -946,7 +932,7 @@ WebAppInterface::_SendRawGetRequest(const BString urlPathComponents,
|
|||||||
BUrl url = ServerSettings::CreateFullUrl(urlPathComponents);
|
BUrl url = ServerSettings::CreateFullUrl(urlPathComponents);
|
||||||
bool isSecure = url.Protocol() == "https";
|
bool isSecure = url.Protocol() == "https";
|
||||||
|
|
||||||
ProtocolListener listener(Logger::IsTraceEnabled());
|
ProtocolListener listener;
|
||||||
listener.SetDownloadIO(stream);
|
listener.SetDownloadIO(stream);
|
||||||
|
|
||||||
BHttpHeaders headers;
|
BHttpHeaders headers;
|
||||||
@@ -967,8 +953,8 @@ WebAppInterface::_SendRawGetRequest(const BString urlPathComponents,
|
|||||||
if (statusCode == 200)
|
if (statusCode == 200)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
fprintf(stderr, "failed to get data from '%s': %" B_PRIi32 "\n",
|
HDERROR("failed to get data from '%s': %" B_PRIi32 "",
|
||||||
url.UrlString().String(), statusCode);
|
url.UrlString().String(), statusCode)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -983,7 +969,7 @@ WebAppInterface::_LogPayload(BPositionIO* requestData, size_t size)
|
|||||||
size = LOG_PAYLOAD_LIMIT;
|
size = LOG_PAYLOAD_LIMIT;
|
||||||
|
|
||||||
if (B_OK != requestData->ReadExactly(buffer, size)) {
|
if (B_OK != requestData->ReadExactly(buffer, size)) {
|
||||||
printf("jrpc; error logging payload\n");
|
printf("jrpc; error logging payload");
|
||||||
} else {
|
} else {
|
||||||
for (uint32 i = 0; i < size; i++) {
|
for (uint32 i = 0; i < size; i++) {
|
||||||
bool esc = buffer[i] > 126 ||
|
bool esc = buffer[i] > 126 ||
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2017-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "TarArchiveHeader.h"
|
#include "TarArchiveHeader.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "Logger.h"
|
||||||
|
|
||||||
|
|
||||||
#define OFFSET_FILENAME 0
|
#define OFFSET_FILENAME 0
|
||||||
#define OFFSET_LENGTH 124
|
#define OFFSET_LENGTH 124
|
||||||
@@ -116,9 +115,9 @@ TarArchiveHeader::CreateFromBlock(const unsigned char* block)
|
|||||||
LENGTH_CHECKSUM);
|
LENGTH_CHECKSUM);
|
||||||
|
|
||||||
if(actualChecksum != expectedChecksum) {
|
if(actualChecksum != expectedChecksum) {
|
||||||
fprintf(stderr, "tar archive header has bad checksum;"
|
HDERROR("tar archive header has bad checksum;"
|
||||||
"expected %" B_PRIu32 " actual %" B_PRIu32 "\n",
|
"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),
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2018, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2017-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "TarArchiveService.h"
|
#include "TarArchiveService.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <StringList.h>
|
#include <StringList.h>
|
||||||
@@ -28,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;
|
||||||
|
|
||||||
fprintf(stdout, "will unpack to [%s]\n", targetDirectory.Path());
|
HDINFO("will unpack to [%s]", targetDirectory.Path())
|
||||||
|
|
||||||
memset(zero_buffer, 0, sizeof zero_buffer);
|
memset(zero_buffer, 0, sizeof zero_buffer);
|
||||||
|
|
||||||
@@ -39,15 +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)) {
|
||||||
if (Logger::IsDebugEnabled())
|
HDDEBUG("detected end of tar-ball")
|
||||||
printf("detected end of tar-ball\n");
|
|
||||||
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) {
|
||||||
fprintf(stderr, "unable to parse a tar header\n");
|
HDERROR("unable to parse a tar header")
|
||||||
result = B_ERROR;
|
result = B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,11 +55,10 @@ TarArchiveService::Unpack(BDataIO& tarDataIo, BPath& targetDirectory,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout, "did unpack %d tar items\n", count_items_read);
|
HDERROR("did unpack %d tar items", count_items_read)
|
||||||
|
|
||||||
if (B_OK != result) {
|
if (B_OK != result) {
|
||||||
fprintf(stdout, "error occurred unpacking tar items; %s\n",
|
HDERROR("error occurred unpacking tar items; %s", strerror(result))
|
||||||
strerror(result));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -83,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) {
|
||||||
fprintf(stdout, "malformed component; [%s]\n", component.String());
|
HDERROR("malformed component; [%s]", component.String())
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,10 +108,8 @@ TarArchiveService::_UnpackItem(BDataIO& tarDataIo,
|
|||||||
BString entryFileName = header.GetFileName();
|
BString entryFileName = header.GetFileName();
|
||||||
uint32 entryLength = header.GetLength();
|
uint32 entryLength = header.GetLength();
|
||||||
|
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("will unpack item [%s] length [%" B_PRIu32 "]b",
|
||||||
fprintf(stdout, "will unpack item [%s] length [%" B_PRIu32 "]b\n",
|
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.
|
||||||
@@ -172,8 +166,7 @@ TarArchiveService::_UnpackItemData(BDataIO& tarDataIo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
fprintf(stdout, "unable to unpack item data to; [%s]\n",
|
HDERROR("unable to unpack item data to; [%s]", targetFilePath.Path())
|
||||||
targetFilePath.Path());
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -530,8 +530,9 @@ App::_CheckIsFirstRun()
|
|||||||
bool exists = false;
|
bool exists = false;
|
||||||
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) {
|
||||||
printf("! unable to establish the location of the test file\n");
|
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);
|
||||||
return !exists;
|
return !exists;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include "FeaturedPackagesView.h"
|
#include "FeaturedPackagesView.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdio.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
@@ -23,6 +22,7 @@
|
|||||||
|
|
||||||
#include "BitmapView.h"
|
#include "BitmapView.h"
|
||||||
#include "HaikuDepotConstants.h"
|
#include "HaikuDepotConstants.h"
|
||||||
|
#include "Logger.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "MarkupTextView.h"
|
#include "MarkupTextView.h"
|
||||||
#include "MessagePackageListener.h"
|
#include "MessagePackageListener.h"
|
||||||
@@ -81,8 +81,9 @@ 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) {
|
||||||
printf("expected 'name' key on package update message\n");
|
HDINFO("expected 'name' key on package update message")
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_HandleUpdatePackage(name);
|
_HandleUpdatePackage(name);
|
||||||
break;
|
break;
|
||||||
@@ -653,7 +654,7 @@ FeaturedPackagesView::RemovePackage(const PackageInfoRef& package)
|
|||||||
void
|
void
|
||||||
FeaturedPackagesView::Clear()
|
FeaturedPackagesView::Clear()
|
||||||
{
|
{
|
||||||
printf("did clear the featured packages view\n");
|
HDINFO("did clear the featured packages view")
|
||||||
fPackagesView->Clear();
|
fPackagesView->Clear();
|
||||||
_AdjustViews();
|
_AdjustViews();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
printf("! expected [%s] value in message\n", KEY_ERROR_STATUS);
|
HDERROR("expected [%s] value in message", KEY_ERROR_STATUS)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_SIMPLE_DATA:
|
case B_SIMPLE_DATA:
|
||||||
@@ -412,11 +412,9 @@ MainWindow::MessageReceived(BMessage* message)
|
|||||||
if (fPackageInfoView->Package()->Name() == name) {
|
if (fPackageInfoView->Package()->Name() == name) {
|
||||||
_PopulatePackageAsync(true);
|
_PopulatePackageAsync(true);
|
||||||
} else {
|
} else {
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("pkg [%s] is updated on the server, but is "
|
||||||
printf("pkg [%s] is updated on the server, but is "
|
"not selected so will not be updated.",
|
||||||
"not selected so will not be updated.\n",
|
name.String())
|
||||||
name.String());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -823,8 +821,7 @@ MainWindow::_AdoptModelControls()
|
|||||||
void
|
void
|
||||||
MainWindow::_AdoptModel()
|
MainWindow::_AdoptModel()
|
||||||
{
|
{
|
||||||
if (Logger::IsTraceEnabled())
|
HDTRACE("adopting model to main window ui")
|
||||||
printf("adopting model to main window ui\n");
|
|
||||||
|
|
||||||
if (fSinglePackageMode)
|
if (fSinglePackageMode)
|
||||||
return;
|
return;
|
||||||
@@ -1039,10 +1036,8 @@ MainWindow::_PopulatePackageAsync(bool forcePopulate)
|
|||||||
}
|
}
|
||||||
release_sem_etc(fPackageToPopulateSem, 1, 0);
|
release_sem_etc(fPackageToPopulateSem, 1, 0);
|
||||||
|
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("pkg [%s] will be updated from the server.",
|
||||||
printf("pkg [%s] will be updated from the server.\n",
|
fPackageToPopulate->Name().String())
|
||||||
fPackageToPopulate->Name().String());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1075,10 +1070,7 @@ MainWindow::_PopulatePackageWorker(void* arg)
|
|||||||
|
|
||||||
window->fModel.PopulatePackage(package, populateFlags);
|
window->fModel.PopulatePackage(package, populateFlags);
|
||||||
|
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("populating package [%s]", package->Name().String())
|
||||||
printf("populating package [%s]\n",
|
|
||||||
package->Name().String());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1184,22 +1176,19 @@ MainWindow::_SelectedPackageHasWebAppRepositoryCode()
|
|||||||
const BString depotName = package->DepotName();
|
const BString depotName = package->DepotName();
|
||||||
|
|
||||||
if (depotName.IsEmpty()) {
|
if (depotName.IsEmpty()) {
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("the package [%s] has no depot name", package->Name().String())
|
||||||
printf("the package [%s] has no depot name\n",
|
|
||||||
package->Name().String());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const DepotInfo* depot = fModel.DepotForName(depotName);
|
const DepotInfo* depot = fModel.DepotForName(depotName);
|
||||||
|
|
||||||
if (depot == NULL) {
|
if (depot == NULL) {
|
||||||
printf("the depot [%s] was not able to be found\n",
|
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()) {
|
||||||
printf("the depot [%s] has no web app repository code\n",
|
HDINFO("the depot [%s] has no web app repository code",
|
||||||
depotName.String());
|
depotName.String())
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1312,7 +1301,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) {
|
||||||
printf("!! unable to archive the user detail into a message\n");
|
HDERROR("unable to archive the user detail into a message")
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
BMessenger(this).SendMessage(&message);
|
BMessenger(this).SendMessage(&message);
|
||||||
@@ -1337,18 +1326,14 @@ MainWindow::_AddProcessCoordinator(ProcessCoordinator* item)
|
|||||||
if (fCoordinator.Get() == NULL) {
|
if (fCoordinator.Get() == NULL) {
|
||||||
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");
|
||||||
if (Logger::IsInfoEnabled()) {
|
HDINFO("adding and starting a process coordinator [%s]",
|
||||||
printf("adding and starting a process coordinator [%s]\n",
|
item->Name().String())
|
||||||
item->Name().String());
|
|
||||||
}
|
|
||||||
fCoordinator = BReference<ProcessCoordinator>(item);
|
fCoordinator = BReference<ProcessCoordinator>(item);
|
||||||
fCoordinator->Start();
|
fCoordinator->Start();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (Logger::IsInfoEnabled()) {
|
HDINFO("adding process coordinator [%s] to the queue",
|
||||||
printf("adding process coordinator [%s] to the queue\n",
|
item->Name().String());
|
||||||
item->Name().String());
|
|
||||||
}
|
|
||||||
fCoordinatorQueue.push(item);
|
fCoordinatorQueue.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1374,18 +1359,16 @@ MainWindow::_SpinUntilProcessCoordinatorComplete()
|
|||||||
void
|
void
|
||||||
MainWindow::_StopProcessCoordinators()
|
MainWindow::_StopProcessCoordinators()
|
||||||
{
|
{
|
||||||
if (Logger::IsInfoEnabled())
|
HDINFO("will stop all process coordinators")
|
||||||
printf("will stop all process coordinators\n");
|
|
||||||
|
|
||||||
{
|
{
|
||||||
AutoLocker<BLocker> lock(&fCoordinatorLock);
|
AutoLocker<BLocker> lock(&fCoordinatorLock);
|
||||||
|
|
||||||
while (!fCoordinatorQueue.empty()) {
|
while (!fCoordinatorQueue.empty()) {
|
||||||
BReference<ProcessCoordinator> processCoordinator = fCoordinatorQueue.front();
|
BReference<ProcessCoordinator> processCoordinator
|
||||||
if (Logger::IsInfoEnabled()) {
|
= fCoordinatorQueue.front();
|
||||||
printf("will drop queued process coordinator [%s]\n",
|
HDINFO("will drop queued process coordinator [%s]",
|
||||||
processCoordinator->Name().String());
|
processCoordinator->Name().String())
|
||||||
}
|
|
||||||
fCoordinatorQueue.pop();
|
fCoordinatorQueue.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1394,13 +1377,11 @@ MainWindow::_StopProcessCoordinators()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Logger::IsInfoEnabled())
|
HDINFO("will wait until the process coordinator has stopped")
|
||||||
printf("will wait until the process coordinator has stopped\n");
|
|
||||||
|
|
||||||
_SpinUntilProcessCoordinatorComplete();
|
_SpinUntilProcessCoordinatorComplete();
|
||||||
|
|
||||||
if (Logger::IsInfoEnabled())
|
HDINFO("did stop all process coordinators")
|
||||||
printf("did stop all process coordinators\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1419,10 +1400,8 @@ MainWindow::CoordinatorChanged(ProcessCoordinatorState& coordinatorState)
|
|||||||
if (!coordinatorState.IsRunning()) {
|
if (!coordinatorState.IsRunning()) {
|
||||||
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");
|
||||||
if (Logger::IsInfoEnabled()) {
|
HDINFO("process coordinator [%s] did complete",
|
||||||
printf("process coordinator [%s] did complete\n",
|
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();
|
||||||
|
|
||||||
@@ -1442,10 +1421,8 @@ MainWindow::CoordinatorChanged(ProcessCoordinatorState& coordinatorState)
|
|||||||
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");
|
||||||
fCoordinator = fCoordinatorQueue.front();
|
fCoordinator = fCoordinatorQueue.front();
|
||||||
if (Logger::IsInfoEnabled()) {
|
HDINFO("starting next process coordinator [%s]",
|
||||||
printf("starting next process coordinator [%s]\n",
|
fCoordinator->Name().String());
|
||||||
fCoordinator->Name().String());
|
|
||||||
}
|
|
||||||
fCoordinatorQueue.pop();
|
fCoordinatorQueue.pop();
|
||||||
fCoordinator->Start();
|
fCoordinator->Start();
|
||||||
}
|
}
|
||||||
@@ -1459,8 +1436,7 @@ MainWindow::CoordinatorChanged(ProcessCoordinatorState& coordinatorState)
|
|||||||
// show the progress to the user.
|
// show the progress to the user.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Logger::IsInfoEnabled())
|
HDINFO("! unknown process coordinator changed")
|
||||||
printf("! unknown process coordinator changed\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#include <StringFormat.h>
|
#include <StringFormat.h>
|
||||||
#include <StringItem.h>
|
#include <StringItem.h>
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
#include <package/PackageDefs.h>
|
#include <package/PackageDefs.h>
|
||||||
#include <package/hpkg/NoErrorOutput.h>
|
#include <package/hpkg/NoErrorOutput.h>
|
||||||
#include <package/hpkg/PackageContentHandler.h>
|
#include <package/hpkg/PackageContentHandler.h>
|
||||||
@@ -122,16 +124,11 @@ public:
|
|||||||
|
|
||||||
virtual status_t HandleEntry(BPackageEntry* entry)
|
virtual status_t HandleEntry(BPackageEntry* entry)
|
||||||
{
|
{
|
||||||
// printf("HandleEntry(%s/%s)\n",
|
|
||||||
// entry->Parent() != NULL ? entry->Parent()->Name() : "NULL",
|
|
||||||
// entry->Name());
|
|
||||||
|
|
||||||
if (fListView->LockLooperWithTimeout(1000000) != B_OK)
|
if (fListView->LockLooperWithTimeout(1000000) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
// Check if we are still supposed to popuplate the list
|
// Check if we are still supposed to popuplate the list
|
||||||
if (fPackageInfoRef.Get() != fPackageInfoToPopulate) {
|
if (fPackageInfoRef.Get() != fPackageInfoToPopulate) {
|
||||||
// printf("stopping package content population\n");
|
|
||||||
fListView->UnlockLooper();
|
fListView->UnlockLooper();
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
@@ -148,17 +145,14 @@ public:
|
|||||||
PackageEntryItem* item = new PackageEntryItem(entry, path);
|
PackageEntryItem* item = new PackageEntryItem(entry, path);
|
||||||
|
|
||||||
if (entry->Parent() == NULL) {
|
if (entry->Parent() == NULL) {
|
||||||
// printf(" adding root entry\n");
|
|
||||||
fListView->AddItem(item);
|
fListView->AddItem(item);
|
||||||
fLastParentEntry = NULL;
|
fLastParentEntry = NULL;
|
||||||
fLastParentItem = NULL;
|
fLastParentItem = NULL;
|
||||||
} else if (entry->Parent() == fLastEntry) {
|
} else if (entry->Parent() == fLastEntry) {
|
||||||
// printf(" adding to last entry %s\n", fLastEntry->Name());
|
|
||||||
fListView->AddUnder(item, fLastItem);
|
fListView->AddUnder(item, fLastItem);
|
||||||
fLastParentEntry = fLastEntry;
|
fLastParentEntry = fLastEntry;
|
||||||
fLastParentItem = fLastItem;
|
fLastParentItem = fLastItem;
|
||||||
} else if (entry->Parent() == fLastParentEntry) {
|
} else if (entry->Parent() == fLastParentEntry) {
|
||||||
// printf(" adding to last parent %s\n", fLastParentEntry->Name());
|
|
||||||
fListView->AddUnder(item, fLastParentItem);
|
fListView->AddUnder(item, fLastParentItem);
|
||||||
} else {
|
} else {
|
||||||
// Not the last parent entry, need to search for the parent
|
// Not the last parent entry, need to search for the parent
|
||||||
@@ -173,7 +167,6 @@ public:
|
|||||||
if (listItem->EntryPath() == path) {
|
if (listItem->EntryPath() == path) {
|
||||||
fLastParentEntry = entry->Parent();
|
fLastParentEntry = entry->Parent();
|
||||||
fLastParentItem = listItem;
|
fLastParentItem = listItem;
|
||||||
// printf(" found parent %s\n", listItem->Text());
|
|
||||||
fListView->AddUnder(item, listItem);
|
fListView->AddUnder(item, listItem);
|
||||||
foundParent = true;
|
foundParent = true;
|
||||||
break;
|
break;
|
||||||
@@ -182,8 +175,6 @@ public:
|
|||||||
if (!foundParent) {
|
if (!foundParent) {
|
||||||
// NOTE: Should not happen. Just add this entry at the
|
// NOTE: Should not happen. Just add this entry at the
|
||||||
// root level.
|
// root level.
|
||||||
// printf("Did not find parent entry for %s (%s)!\n",
|
|
||||||
// entry->Name(), entry->Parent()->Name());
|
|
||||||
fListView->AddItem(item);
|
fListView->AddItem(item);
|
||||||
fLastParentEntry = NULL;
|
fLastParentEntry = NULL;
|
||||||
fLastParentItem = NULL;
|
fLastParentItem = NULL;
|
||||||
@@ -391,8 +382,8 @@ PackageContentsView::_PopulatePackageContents(const PackageInfo& package)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("PackageContentsView::_PopulatePackageContents(): "
|
HDINFO("PackageContentsView::_PopulatePackageContents(): "
|
||||||
"unknown install location");
|
"unknown install location")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,9 +396,9 @@ PackageContentsView::_PopulatePackageContents(const PackageInfo& package)
|
|||||||
|
|
||||||
status_t status = reader.Init(packagePath.Path());
|
status_t status = reader.Init(packagePath.Path());
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
printf("PackageContentsView::_PopulatePackageContents(): "
|
HDINFO("PackageContentsView::_PopulatePackageContents(): "
|
||||||
"failed to init BPackageReader(%s): %s\n",
|
"failed to init BPackageReader(%s): %s",
|
||||||
packagePath.Path(), strerror(status));
|
packagePath.Path(), strerror(status))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,8 +407,8 @@ PackageContentsView::_PopulatePackageContents(const PackageInfo& package)
|
|||||||
fPackageLock, fPackage);
|
fPackageLock, fPackage);
|
||||||
status = reader.ParseContent(&contentHandler);
|
status = reader.ParseContent(&contentHandler);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
printf("PackageContentsView::_PopulatePackageContents(): "
|
HDINFO("PackageContentsView::_PopulatePackageContents(): "
|
||||||
"failed parse package contents: %s\n", 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.
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "PackageInfoView.h"
|
#include "PackageInfoView.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
@@ -39,6 +38,7 @@
|
|||||||
#include "LinkView.h"
|
#include "LinkView.h"
|
||||||
#include "LinkedBitmapView.h"
|
#include "LinkedBitmapView.h"
|
||||||
#include "LocaleUtils.h"
|
#include "LocaleUtils.h"
|
||||||
|
#include "Logger.h"
|
||||||
#include "MarkupTextView.h"
|
#include "MarkupTextView.h"
|
||||||
#include "MessagePackageListener.h"
|
#include "MessagePackageListener.h"
|
||||||
#include "PackageActionHandler.h"
|
#include "PackageActionHandler.h"
|
||||||
@@ -624,10 +624,10 @@ private:
|
|||||||
= fPackageActionHandler->SchedulePackageActions(actions);
|
= fPackageActionHandler->SchedulePackageActions(actions);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
fprintf(stderr, "Failed to schedule action: "
|
HDERROR("Failed to schedule action: %s '%s': %s",
|
||||||
"%s '%s': %s\n", 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));
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "HaikuDepotConstants.h"
|
#include "HaikuDepotConstants.h"
|
||||||
#include "LanguageMenuUtils.h"
|
#include "LanguageMenuUtils.h"
|
||||||
|
#include "Logger.h"
|
||||||
#include "MarkupParser.h"
|
#include "MarkupParser.h"
|
||||||
#include "RatingView.h"
|
#include "RatingView.h"
|
||||||
#include "ServerHelper.h"
|
#include "ServerHelper.h"
|
||||||
@@ -530,7 +531,7 @@ RatePackageWindow::_RelayServerDataToUI(BMessage& response)
|
|||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "unable to acquire lock to update the ui\n");
|
HDERROR("unable to acquire lock to update the ui");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,7 +540,7 @@ void
|
|||||||
RatePackageWindow::_QueryRatingThread()
|
RatePackageWindow::_QueryRatingThread()
|
||||||
{
|
{
|
||||||
if (!Lock()) {
|
if (!Lock()) {
|
||||||
fprintf(stderr, "rating query: Failed to lock window\n");
|
HDERROR("rating query: Failed to lock window");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,7 +553,7 @@ RatePackageWindow::_QueryRatingThread()
|
|||||||
locker.Unlock();
|
locker.Unlock();
|
||||||
|
|
||||||
if (package.Get() == NULL) {
|
if (package.Get() == NULL) {
|
||||||
fprintf(stderr, "rating query: No package\n");
|
HDERROR("rating query: No package");
|
||||||
_SetWorkerThread(-1);
|
_SetWorkerThread(-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -566,8 +567,8 @@ RatePackageWindow::_QueryRatingThread()
|
|||||||
repositoryCode = depot->WebAppRepositoryCode();
|
repositoryCode = depot->WebAppRepositoryCode();
|
||||||
|
|
||||||
if (repositoryCode.IsEmpty()) {
|
if (repositoryCode.IsEmpty()) {
|
||||||
printf("unable to obtain the repository code for depot; %s\n",
|
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
|
||||||
@@ -586,8 +587,7 @@ RatePackageWindow::_QueryRatingThread()
|
|||||||
if (info.FindMessage("result", &result) == B_OK) {
|
if (info.FindMessage("result", &result) == B_OK) {
|
||||||
_RelayServerDataToUI(result);
|
_RelayServerDataToUI(result);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "bad response envelope missing 'result'"
|
HDERROR("bad response envelope missing 'result' entry")
|
||||||
"entry\n");
|
|
||||||
ServerHelper::NotifyTransportError(B_BAD_VALUE);
|
ServerHelper::NotifyTransportError(B_BAD_VALUE);
|
||||||
BMessenger(this).SendMessage(B_QUIT_REQUESTED);
|
BMessenger(this).SendMessage(B_QUIT_REQUESTED);
|
||||||
}
|
}
|
||||||
@@ -595,9 +595,9 @@ RatePackageWindow::_QueryRatingThread()
|
|||||||
}
|
}
|
||||||
case ERROR_CODE_OBJECTNOTFOUND:
|
case ERROR_CODE_OBJECTNOTFOUND:
|
||||||
// an expected response
|
// an expected response
|
||||||
fprintf(stderr, "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.\n");
|
" will be added.")
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ServerHelper::NotifyServerJsonRpcError(info);
|
ServerHelper::NotifyServerJsonRpcError(info);
|
||||||
@@ -605,9 +605,9 @@ RatePackageWindow::_QueryRatingThread()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "an error has arisen communicating with the"
|
HDERROR("an error has arisen communicating with the"
|
||||||
" server to obtain data for an existing rating [%s]\n",
|
" 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 +630,7 @@ void
|
|||||||
RatePackageWindow::_SendRatingThread()
|
RatePackageWindow::_SendRatingThread()
|
||||||
{
|
{
|
||||||
if (!Lock()) {
|
if (!Lock()) {
|
||||||
fprintf(stderr, "upload rating: Failed to lock window\n");
|
HDERROR("upload rating: Failed to lock window")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -658,9 +658,9 @@ RatePackageWindow::_SendRatingThread()
|
|||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
if (repositoryCode.Length() == 0) {
|
if (repositoryCode.Length() == 0) {
|
||||||
printf("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\n",
|
"depot %s",
|
||||||
fPackage->DepotName().String());
|
fPackage->DepotName().String())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -670,13 +670,11 @@ RatePackageWindow::_SendRatingThread()
|
|||||||
status_t status;
|
status_t status;
|
||||||
BMessage info;
|
BMessage info;
|
||||||
if (ratingID.Length() > 0) {
|
if (ratingID.Length() > 0) {
|
||||||
printf("will update the existing user rating [%s]\n",
|
HDINFO("will update the existing user rating [%s]", ratingID.String())
|
||||||
ratingID.String());
|
|
||||||
status = interface.UpdateUserRating(ratingID,
|
status = interface.UpdateUserRating(ratingID,
|
||||||
languageCode, comment, stability, rating, active, info);
|
languageCode, comment, stability, rating, active, info);
|
||||||
} else {
|
} else {
|
||||||
printf("will create a new user rating for pkg [%s]\n",
|
HDINFO("will create a new user rating for pkg [%s]", package.String())
|
||||||
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,9 +697,9 @@ RatePackageWindow::_SendRatingThread()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "an error has arisen communicating with the"
|
HDERROR("an error has arisen communicating with the"
|
||||||
" server to obtain data for an existing rating [%s]\n",
|
" server to obtain data for an existing rating [%s]",
|
||||||
strerror(status));
|
strerror(status))
|
||||||
ServerHelper::NotifyTransportError(status);
|
ServerHelper::NotifyTransportError(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014, Stephan Aßmus <superstippi@gmx.de>.
|
* Copyright 2014, Stephan Aßmus <superstippi@gmx.de>.
|
||||||
* Copyright 2017, Julian Harnath <julian.harnath@rwth-aachen.de>.
|
* Copyright 2017, Julian Harnath <julian.harnath@rwth-aachen.de>.
|
||||||
|
* Copyright 2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ScreenshotWindow.h"
|
#include "ScreenshotWindow.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "BarberPole.h"
|
#include "BarberPole.h"
|
||||||
#include "BitmapView.h"
|
#include "BitmapView.h"
|
||||||
#include "HaikuDepotConstants.h"
|
#include "HaikuDepotConstants.h"
|
||||||
|
#include "Logger.h"
|
||||||
#include "WebAppInterface.h"
|
#include "WebAppInterface.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -253,9 +254,8 @@ ScreenshotWindow::_DownloadThreadEntry(void* data)
|
|||||||
void
|
void
|
||||||
ScreenshotWindow::_DownloadThread()
|
ScreenshotWindow::_DownloadThread()
|
||||||
{
|
{
|
||||||
printf("_DownloadThread()\n");
|
|
||||||
if (!Lock()) {
|
if (!Lock()) {
|
||||||
printf(" failed to lock screenshot window\n");
|
HDERROR("failed to lock screenshot window")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ ScreenshotWindow::_DownloadThread()
|
|||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
if (screenshotInfos.CountItems() == 0) {
|
if (screenshotInfos.CountItems() == 0) {
|
||||||
printf(" package has no screenshots\n");
|
HDINFO("package has no screenshots")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,13 +295,13 @@ ScreenshotWindow::_DownloadThread()
|
|||||||
messenger.SendMessage(MSG_DOWNLOAD_STOP);
|
messenger.SendMessage(MSG_DOWNLOAD_STOP);
|
||||||
|
|
||||||
if (status == B_OK && Lock()) {
|
if (status == B_OK && Lock()) {
|
||||||
printf("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 {
|
||||||
printf(" failed to download screenshot\n");
|
HDERROR("failed to download screenshot")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,8 +211,8 @@ ToLatestUserUsageConditionsWindow::QuitRequested()
|
|||||||
|
|
||||||
if (fWorkerThread >= 0) {
|
if (fWorkerThread >= 0) {
|
||||||
if (Logger::IsDebugEnabled())
|
if (Logger::IsDebugEnabled())
|
||||||
printf("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\n");
|
"try again once the worker thread has completed")
|
||||||
fQuitRequestedDuringWorkerThread = true;
|
fQuitRequestedDuringWorkerThread = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <mail_encoding.h>
|
#include <mail_encoding.h>
|
||||||
|
|
||||||
@@ -158,8 +157,8 @@ UserLoginWindow::UserLoginWindow(BWindow* parent, BRect frame, Model& model)
|
|||||||
languagesMenu);
|
languagesMenu);
|
||||||
languagesMenu->SetTargetForItems(this);
|
languagesMenu->SetTargetForItems(this);
|
||||||
|
|
||||||
printf("using preferred language code [%s]\n",
|
HDINFO("using preferred language code [%s]",
|
||||||
fPreferredLanguageCode.String());
|
fPreferredLanguageCode.String())
|
||||||
LanguageMenuUtils::MarkLanguageInMenu(fPreferredLanguageCode,
|
LanguageMenuUtils::MarkLanguageInMenu(fPreferredLanguageCode,
|
||||||
languagesMenu);
|
languagesMenu);
|
||||||
}
|
}
|
||||||
@@ -299,7 +298,7 @@ UserLoginWindow::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case MSG_CREATE_ACCOUNT_SETUP_ERROR:
|
case MSG_CREATE_ACCOUNT_SETUP_ERROR:
|
||||||
printf("failed to setup for account setup - window must quit\n");
|
HDERROR("failed to setup for account setup - window must quit")
|
||||||
BMessenger(this).SendMessage(B_QUIT_REQUESTED);
|
BMessenger(this).SendMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -371,8 +370,8 @@ UserLoginWindow::QuitRequested()
|
|||||||
|
|
||||||
if (fWorkerThread >= 0) {
|
if (fWorkerThread >= 0) {
|
||||||
if (Logger::IsDebugEnabled())
|
if (Logger::IsDebugEnabled())
|
||||||
printf("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\n");
|
"try again once the worker thread has completed")
|
||||||
fQuitRequestedDuringWorkerThread = true;
|
fQuitRequestedDuringWorkerThread = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -531,9 +530,9 @@ UserLoginWindow::_AuthenticateThread(UserCredentials& userCredentials)
|
|||||||
|
|
||||||
if (Logger::IsDebugEnabled()) {
|
if (Logger::IsDebugEnabled()) {
|
||||||
if (token.IsEmpty())
|
if (token.IsEmpty())
|
||||||
printf("authentication failed\n");
|
HDINFO("authentication failed")
|
||||||
else
|
else
|
||||||
printf("authentication successful\n");
|
HDINFO("authentication successful")
|
||||||
}
|
}
|
||||||
|
|
||||||
BMessenger messenger(this);
|
BMessenger messenger(this);
|
||||||
@@ -751,9 +750,8 @@ UserLoginWindow::_CreateAccountSetupThreadEntry(void* data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result == B_OK) {
|
if (result == B_OK) {
|
||||||
if (Logger::IsDebugEnabled())
|
HDDEBUG("successfully completed collection of create account "
|
||||||
printf("successfully completed collection of create account "
|
"data from the server in background thread")
|
||||||
"data from the server in background thread\n");
|
|
||||||
messenger.SendMessage(&message);
|
messenger.SendMessage(&message);
|
||||||
} else {
|
} else {
|
||||||
debugger("unable to configure the "
|
debugger("unable to configure the "
|
||||||
@@ -887,9 +885,7 @@ UserLoginWindow::_UnpackCaptcha(BMessage& responsePayload, Captcha& captcha)
|
|||||||
void
|
void
|
||||||
UserLoginWindow::_HandleCreateAccountSetupSuccess(BMessage* message)
|
UserLoginWindow::_HandleCreateAccountSetupSuccess(BMessage* message)
|
||||||
{
|
{
|
||||||
if (Logger::IsDebugEnabled())
|
HDDEBUG("handling account setup success")
|
||||||
printf("handling account setup success\n");
|
|
||||||
|
|
||||||
BMessage captchaMessage;
|
BMessage captchaMessage;
|
||||||
BMessage userUsageConditionsMessage;
|
BMessage userUsageConditionsMessage;
|
||||||
|
|
||||||
@@ -909,8 +905,7 @@ UserLoginWindow::_HandleCreateAccountSetupSuccess(BMessage* message)
|
|||||||
void
|
void
|
||||||
UserLoginWindow::_SetCaptcha(Captcha* captcha)
|
UserLoginWindow::_SetCaptcha(Captcha* captcha)
|
||||||
{
|
{
|
||||||
if (Logger::IsDebugEnabled())
|
HDDEBUG("setting captcha")
|
||||||
printf("setting captcha\n");
|
|
||||||
if (fCaptcha != NULL)
|
if (fCaptcha != NULL)
|
||||||
delete fCaptcha;
|
delete fCaptcha;
|
||||||
fCaptcha = captcha;
|
fCaptcha = captcha;
|
||||||
@@ -936,8 +931,7 @@ void
|
|||||||
UserLoginWindow::_SetUserUsageConditions(
|
UserLoginWindow::_SetUserUsageConditions(
|
||||||
UserUsageConditions* userUsageConditions)
|
UserUsageConditions* userUsageConditions)
|
||||||
{
|
{
|
||||||
if (Logger::IsDebugEnabled())
|
HDDEBUG("setting user usage conditions")
|
||||||
printf("setting user usage conditions\n");
|
|
||||||
if (fUserUsageConditions != NULL)
|
if (fUserUsageConditions != NULL)
|
||||||
delete fUserUsageConditions;
|
delete fUserUsageConditions;
|
||||||
fUserUsageConditions = userUsageConditions;
|
fUserUsageConditions = userUsageConditions;
|
||||||
@@ -1275,8 +1269,8 @@ UserLoginWindow::_CreateAccountThread(CreateUserDetail* detail)
|
|||||||
BString debugString;
|
BString debugString;
|
||||||
_ValidationFailuresToString(validationFailures,
|
_ValidationFailuresToString(validationFailures,
|
||||||
debugString);
|
debugString);
|
||||||
printf("create account validation issues; %s\n",
|
HDDEBUG("create account validation issues; %s",
|
||||||
debugString.String());
|
debugString.String())
|
||||||
}
|
}
|
||||||
BMessage validationFailuresMessage;
|
BMessage validationFailuresMessage;
|
||||||
validationFailures.Archive(&validationFailuresMessage);
|
validationFailures.Archive(&validationFailuresMessage);
|
||||||
|
|||||||
@@ -215,10 +215,8 @@ UserUsageConditionsWindow::QuitRequested()
|
|||||||
|
|
||||||
if (fWorkerThread == -1)
|
if (fWorkerThread == -1)
|
||||||
return true;
|
return true;
|
||||||
if (Logger::IsInfoEnabled()) {
|
HDINFO("unable to quit when the user usage "
|
||||||
fprintf(stderr, "unable to quit when the user usage "
|
"conditions window is still fetching data")
|
||||||
"conditions window is still fetching data\n");
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,25 +358,21 @@ UserUsageConditionsWindow::_FetchUserUsageConditionsCodeForUserPerform(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "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]\n", strerror(result));
|
" [%s]", strerror(result))
|
||||||
ServerHelper::NotifyTransportError(result);
|
ServerHelper::NotifyTransportError(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == B_OK) {
|
if (result == B_OK) {
|
||||||
BString userUsageConditionsCode = userDetail.Agreement().Code();
|
BString userUsageConditionsCode = userDetail.Agreement().Code();
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("the user [%s] has agreed to uuc [%s]",
|
||||||
printf("the user [%s] has agreed to uuc [%s]\n",
|
interface.Nickname().String(),
|
||||||
interface.Nickname().String(),
|
userUsageConditionsCode.String())
|
||||||
userUsageConditionsCode.String());
|
|
||||||
}
|
|
||||||
code.SetTo(userUsageConditionsCode);
|
code.SetTo(userUsageConditionsCode);
|
||||||
} else {
|
} else {
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("unable to get details of the user [%s]",
|
||||||
printf("unable to get details of the user [%s]\n",
|
interface.Nickname().String())
|
||||||
interface.Nickname().String());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -400,8 +394,7 @@ void
|
|||||||
UserUsageConditionsWindow::_SetWorkerThread(thread_id thread)
|
UserUsageConditionsWindow::_SetWorkerThread(thread_id thread)
|
||||||
{
|
{
|
||||||
if (!Lock()) {
|
if (!Lock()) {
|
||||||
if (Logger::IsInfoEnabled())
|
HDERROR("failed to lock window")
|
||||||
fprintf(stderr, "failed to lock window\n");
|
|
||||||
} else {
|
} else {
|
||||||
fWorkerThread = thread;
|
fWorkerThread = thread;
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
||||||
|
* Copyright 2020, Andrew Lindesay <apl@lindesay.co.nz>
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SharedBitmap.h"
|
#include "SharedBitmap.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
@@ -17,6 +17,8 @@
|
|||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -98,8 +100,8 @@ SharedBitmap::SharedBitmap(BPositionIO& data)
|
|||||||
} else
|
} else
|
||||||
fSize = 0;
|
fSize = 0;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "SharedBitmap(): Stream too large: %" B_PRIi64
|
HDERROR("SharedBitmap(): Stream too large: %" B_PRIi64
|
||||||
", max: %" B_PRIi64 "\n", fSize, kMaxSize);
|
", max: %" B_PRIi64, fSize, kMaxSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
fBitmap[0] = NULL;
|
fBitmap[0] = NULL;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2019-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#include "LanguageMenuUtils.h"
|
#include "LanguageMenuUtils.h"
|
||||||
@@ -23,8 +23,8 @@
|
|||||||
LanguageMenuUtils::AddLanguagesToMenu(
|
LanguageMenuUtils::AddLanguagesToMenu(
|
||||||
const LanguageList& languages, BMenu* menu)
|
const LanguageList& languages, BMenu* menu)
|
||||||
{
|
{
|
||||||
if (languages.IsEmpty() && Logger::IsInfoEnabled())
|
if (languages.IsEmpty())
|
||||||
printf("there are no languages defined\n");
|
HDINFO("there are no languages defined")
|
||||||
|
|
||||||
int32 addedPopular = LanguageMenuUtils::_AddLanguagesToMenu(
|
int32 addedPopular = LanguageMenuUtils::_AddLanguagesToMenu(
|
||||||
languages, menu, true);
|
languages, menu, true);
|
||||||
@@ -35,11 +35,9 @@ LanguageMenuUtils::AddLanguagesToMenu(
|
|||||||
int32 addedNonPopular = LanguageMenuUtils::_AddLanguagesToMenu(
|
int32 addedNonPopular = LanguageMenuUtils::_AddLanguagesToMenu(
|
||||||
languages, menu, false);
|
languages, menu, false);
|
||||||
|
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("did add %" B_PRId32 " popular languages and %" B_PRId32
|
||||||
printf("did add %" B_PRId32 " popular languages and %" B_PRId32
|
" non-popular languages to a menu", addedPopular,
|
||||||
" non-popular languages to a menu\n", addedPopular,
|
addedNonPopular)
|
||||||
addedNonPopular);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -56,8 +54,8 @@ LanguageMenuUtils::MarkLanguageInMenu(
|
|||||||
languageCode, menu);
|
languageCode, menu);
|
||||||
|
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
printf("unable to find the language [%s] in the menu\n",
|
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
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
#include "StorageUtils.h"
|
#include "StorageUtils.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
@@ -86,13 +86,9 @@ StorageUtils::RemoveDirectoryContents(BPath& path)
|
|||||||
RemoveDirectoryContents(directoryEntryPath);
|
RemoveDirectoryContents(directoryEntryPath);
|
||||||
|
|
||||||
if (remove(directoryEntryPath.Path()) == 0) {
|
if (remove(directoryEntryPath.Path()) == 0) {
|
||||||
if (Logger::IsDebugEnabled()) {
|
HDDEBUG("did delete [%s]", directoryEntryPath.Path())
|
||||||
fprintf(stdout, "did delete [%s]\n",
|
|
||||||
directoryEntryPath.Path());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "unable to delete [%s]\n",
|
HDERROR("unable to delete [%s]", directoryEntryPath.Path())
|
||||||
directoryEntryPath.Path());
|
|
||||||
result = B_ERROR;
|
result = B_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,17 +163,13 @@ StorageUtils::CheckCanWriteTo(const BPath& path)
|
|||||||
result = ExistsObject(path, &exists, NULL, NULL);
|
result = ExistsObject(path, &exists, NULL, NULL);
|
||||||
|
|
||||||
if (result == B_OK && exists) {
|
if (result == B_OK && exists) {
|
||||||
if (Logger::IsTraceEnabled()) {
|
HDTRACE("an object exists at the candidate path "
|
||||||
printf("an object exists at the candidate path "
|
"[%s] - it will be deleted", path.Path())
|
||||||
"[%s] - it will be deleted\n", path.Path());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remove(path.Path()) == 0) {
|
if (remove(path.Path()) == 0) {
|
||||||
if (Logger::IsTraceEnabled()) {
|
HDTRACE("did delete the candidate file [%s]", path.Path())
|
||||||
printf("did delete the candidate file [%s]\n", path.Path());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
printf("unable to delete the candidate file [%s]\n", path.Path());
|
HDERROR("unable to delete the candidate file [%s]", path.Path())
|
||||||
result = B_ERROR;
|
result = B_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,8 +177,8 @@ StorageUtils::CheckCanWriteTo(const BPath& path)
|
|||||||
if (result == B_OK) {
|
if (result == B_OK) {
|
||||||
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) {
|
||||||
printf("unable to write test data to candidate file [%s]\n",
|
HDERROR("unable to write test data to candidate file [%s]",
|
||||||
path.Path());
|
path.Path())
|
||||||
result = B_ERROR;
|
result = B_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,15 +187,15 @@ StorageUtils::CheckCanWriteTo(const BPath& path)
|
|||||||
BFile file(path.Path(), O_RDONLY);
|
BFile file(path.Path(), O_RDONLY);
|
||||||
uint8 readBuffer[16];
|
uint8 readBuffer[16];
|
||||||
if (file.Read(readBuffer, 16) != 16) {
|
if (file.Read(readBuffer, 16) != 16) {
|
||||||
printf("unable to read test data from candidate file [%s]\n",
|
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]) {
|
||||||
printf("mismatched read..write check on candidate file [%s]\n",
|
HDERROR("mismatched read..write check on candidate file [%s]",
|
||||||
path.Path());
|
path.Path())
|
||||||
result = B_ERROR;
|
result = B_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,8 +237,8 @@ StorageUtils::LocalWorkingFilesPath(const BString leaf, BPath& path,
|
|||||||
path.SetTo(resultPath.Path());
|
path.SetTo(resultPath.Path());
|
||||||
else {
|
else {
|
||||||
path.Unset();
|
path.Unset();
|
||||||
fprintf(stdout, "unable to find the user cache file for "
|
HDERROR("unable to find the user cache file for "
|
||||||
"[%s] data; %s\n", leaf.String(), strerror(result));
|
"[%s] data; %s", leaf.String(), strerror(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -280,8 +272,8 @@ StorageUtils::LocalWorkingDirectoryPath(const BString leaf, BPath& path,
|
|||||||
path.SetTo(resultPath.Path());
|
path.SetTo(resultPath.Path());
|
||||||
else {
|
else {
|
||||||
path.Unset();
|
path.Unset();
|
||||||
fprintf(stdout, "unable to find the user cache directory for "
|
HDERROR("unable to find the user cache directory for "
|
||||||
"[%s] data; %s\n", leaf.String(), strerror(result));
|
"[%s] data; %s", leaf.String(), strerror(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2018, Andrew Lindesay <apl@lindesay.co.nz>.
|
* Copyright 2017-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -8,8 +8,7 @@
|
|||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <HttpRequest.h>
|
#include <HttpRequest.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "Logger.h"
|
||||||
|
|
||||||
|
|
||||||
ToFileUrlProtocolListener::ToFileUrlProtocolListener(BPath path,
|
ToFileUrlProtocolListener::ToFileUrlProtocolListener(BPath path,
|
||||||
BString traceLoggingIdentifier, bool traceLogging)
|
BString traceLoggingIdentifier, bool traceLogging)
|
||||||
@@ -59,8 +58,8 @@ ToFileUrlProtocolListener::HeadersReceived(BUrlRequest* caller,
|
|||||||
int32 statusCode = httpResult.StatusCode();
|
int32 statusCode = httpResult.StatusCode();
|
||||||
|
|
||||||
if (!BHttpRequest::IsSuccessStatusCode(statusCode)) {
|
if (!BHttpRequest::IsSuccessStatusCode(statusCode)) {
|
||||||
fprintf(stdout, "received http status %" B_PRId32
|
HDINFO("received http status %" B_PRId32
|
||||||
" --> will not store download to file\n", statusCode);
|
" --> will not store download to file", statusCode)
|
||||||
fShouldDownload = false;
|
fShouldDownload = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,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)
|
||||||
fprintf(stdout, "unable to write all of the data to the file\n");
|
HDERROR("unable to write all of the data to the file")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,10 +112,7 @@ void
|
|||||||
ToFileUrlProtocolListener::DebugMessage(BUrlRequest* caller,
|
ToFileUrlProtocolListener::DebugMessage(BUrlRequest* caller,
|
||||||
BUrlProtocolDebugMessage type, const char* text)
|
BUrlProtocolDebugMessage type, const char* text)
|
||||||
{
|
{
|
||||||
if (fTraceLogging) {
|
HDTRACE("url->file <%s>; %s", fTraceLoggingIdentifier.String(), text)
|
||||||
fprintf(stdout, "url->file <%s>; %s\n",
|
|
||||||
fTraceLoggingIdentifier.String(), text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user