Make ThreadSafe{MessageBox|Question} bilingual
This commit is contained in:
14 files changed
+82
-64
No files matched your search
+1
-1
@@ -252,7 +252,7 @@ static bool InitRPCAuthentication()
|
|||||||
LogPrintf("No rpcpassword set - using random cookie authentication.\n");
|
LogPrintf("No rpcpassword set - using random cookie authentication.\n");
|
||||||
if (!GenerateAuthCookie(&strRPCUserColonPass)) {
|
if (!GenerateAuthCookie(&strRPCUserColonPass)) {
|
||||||
uiInterface.ThreadSafeMessageBox(
|
uiInterface.ThreadSafeMessageBox(
|
||||||
_("Error: A fatal internal error occurred, see debug.log for details").translated, // Same message as AbortNode
|
_("Error: A fatal internal error occurred, see debug.log for details"), // Same message as AbortNode
|
||||||
"", CClientUIInterface::MSG_ERROR);
|
"", CClientUIInterface::MSG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-4
@@ -6,14 +6,15 @@
|
|||||||
|
|
||||||
#include <chainparamsbase.h>
|
#include <chainparamsbase.h>
|
||||||
#include <compat.h>
|
#include <compat.h>
|
||||||
#include <util/threadnames.h>
|
|
||||||
#include <util/system.h>
|
|
||||||
#include <util/strencodings.h>
|
|
||||||
#include <netbase.h>
|
#include <netbase.h>
|
||||||
#include <rpc/protocol.h> // For HTTP status codes
|
#include <rpc/protocol.h> // For HTTP status codes
|
||||||
#include <shutdown.h>
|
#include <shutdown.h>
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <ui_interface.h>
|
#include <ui_interface.h>
|
||||||
|
#include <util/strencodings.h>
|
||||||
|
#include <util/system.h>
|
||||||
|
#include <util/threadnames.h>
|
||||||
|
#include <util/translation.h>
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -175,7 +176,7 @@ static bool InitHTTPAllowList()
|
|||||||
LookupSubNet(strAllow, subnet);
|
LookupSubNet(strAllow, subnet);
|
||||||
if (!subnet.IsValid()) {
|
if (!subnet.IsValid()) {
|
||||||
uiInterface.ThreadSafeMessageBox(
|
uiInterface.ThreadSafeMessageBox(
|
||||||
strprintf("Invalid -rpcallowip subnet specification: %s. Valid are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24).", strAllow),
|
strprintf(Untranslated("Invalid -rpcallowip subnet specification: %s. Valid are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24)."), strAllow),
|
||||||
"", CClientUIInterface::MSG_ERROR);
|
"", CClientUIInterface::MSG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -8,6 +8,7 @@
|
|||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
#include <ui_interface.h>
|
#include <ui_interface.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
#include <util/translation.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <warnings.h>
|
#include <warnings.h>
|
||||||
|
|
||||||
@@ -23,7 +24,7 @@ static void FatalError(const char* fmt, const Args&... args)
|
|||||||
SetMiscWarning(strMessage);
|
SetMiscWarning(strMessage);
|
||||||
LogPrintf("*** %s\n", strMessage);
|
LogPrintf("*** %s\n", strMessage);
|
||||||
uiInterface.ThreadSafeMessageBox(
|
uiInterface.ThreadSafeMessageBox(
|
||||||
"Error: A fatal internal error occurred, see debug.log for details",
|
Untranslated("Error: A fatal internal error occurred, see debug.log for details"),
|
||||||
"", CClientUIInterface::MSG_ERROR);
|
"", CClientUIInterface::MSG_ERROR);
|
||||||
StartShutdown();
|
StartShutdown();
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-16
@@ -1542,7 +1542,7 @@ bool AppInitMain(NodeContext& node)
|
|||||||
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
||||||
return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull();
|
return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull();
|
||||||
};
|
};
|
||||||
std::string strLoadError;
|
bilingual_str strLoadError;
|
||||||
|
|
||||||
uiInterface.InitMessage(_("Loading block index...").translated);
|
uiInterface.InitMessage(_("Loading block index...").translated);
|
||||||
|
|
||||||
@@ -1573,7 +1573,7 @@ bool AppInitMain(NodeContext& node)
|
|||||||
// From here on out fReindex and fReset mean something different!
|
// From here on out fReindex and fReset mean something different!
|
||||||
if (!LoadBlockIndex(chainparams)) {
|
if (!LoadBlockIndex(chainparams)) {
|
||||||
if (ShutdownRequested()) break;
|
if (ShutdownRequested()) break;
|
||||||
strLoadError = _("Error loading block database").translated;
|
strLoadError = _("Error loading block database");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1587,7 +1587,7 @@ bool AppInitMain(NodeContext& node)
|
|||||||
// Check for changed -prune state. What we are concerned about is a user who has pruned blocks
|
// Check for changed -prune state. What we are concerned about is a user who has pruned blocks
|
||||||
// in the past, but is now trying to run unpruned.
|
// in the past, but is now trying to run unpruned.
|
||||||
if (fHavePruned && !fPruneMode) {
|
if (fHavePruned && !fPruneMode) {
|
||||||
strLoadError = _("You need to rebuild the database using -reindex to go back to unpruned mode. This will redownload the entire blockchain").translated;
|
strLoadError = _("You need to rebuild the database using -reindex to go back to unpruned mode. This will redownload the entire blockchain");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1596,7 +1596,7 @@ bool AppInitMain(NodeContext& node)
|
|||||||
// (otherwise we use the one already on disk).
|
// (otherwise we use the one already on disk).
|
||||||
// This is called again in ThreadImport after the reindex completes.
|
// This is called again in ThreadImport after the reindex completes.
|
||||||
if (!fReindex && !LoadGenesisBlock(chainparams)) {
|
if (!fReindex && !LoadGenesisBlock(chainparams)) {
|
||||||
strLoadError = _("Error initializing block database").translated;
|
strLoadError = _("Error initializing block database");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1614,21 +1614,21 @@ bool AppInitMain(NodeContext& node)
|
|||||||
|
|
||||||
chainstate->CoinsErrorCatcher().AddReadErrCallback([]() {
|
chainstate->CoinsErrorCatcher().AddReadErrCallback([]() {
|
||||||
uiInterface.ThreadSafeMessageBox(
|
uiInterface.ThreadSafeMessageBox(
|
||||||
_("Error reading from database, shutting down.").translated,
|
_("Error reading from database, shutting down."),
|
||||||
"", CClientUIInterface::MSG_ERROR);
|
"", CClientUIInterface::MSG_ERROR);
|
||||||
});
|
});
|
||||||
|
|
||||||
// If necessary, upgrade from older database format.
|
// If necessary, upgrade from older database format.
|
||||||
// This is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate
|
// This is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate
|
||||||
if (!chainstate->CoinsDB().Upgrade()) {
|
if (!chainstate->CoinsDB().Upgrade()) {
|
||||||
strLoadError = _("Error upgrading chainstate database").translated;
|
strLoadError = _("Error upgrading chainstate database");
|
||||||
failed_chainstate_init = true;
|
failed_chainstate_init = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReplayBlocks is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate
|
// ReplayBlocks is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate
|
||||||
if (!chainstate->ReplayBlocks(chainparams)) {
|
if (!chainstate->ReplayBlocks(chainparams)) {
|
||||||
strLoadError = _("Unable to replay blocks. You will need to rebuild the database using -reindex-chainstate.").translated;
|
strLoadError = _("Unable to replay blocks. You will need to rebuild the database using -reindex-chainstate.");
|
||||||
failed_chainstate_init = true;
|
failed_chainstate_init = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1640,7 +1640,7 @@ bool AppInitMain(NodeContext& node)
|
|||||||
if (!is_coinsview_empty(chainstate)) {
|
if (!is_coinsview_empty(chainstate)) {
|
||||||
// LoadChainTip initializes the chain based on CoinsTip()'s best block
|
// LoadChainTip initializes the chain based on CoinsTip()'s best block
|
||||||
if (!chainstate->LoadChainTip(chainparams)) {
|
if (!chainstate->LoadChainTip(chainparams)) {
|
||||||
strLoadError = _("Error initializing block database").translated;
|
strLoadError = _("Error initializing block database");
|
||||||
failed_chainstate_init = true;
|
failed_chainstate_init = true;
|
||||||
break; // out of the per-chainstate loop
|
break; // out of the per-chainstate loop
|
||||||
}
|
}
|
||||||
@@ -1653,7 +1653,7 @@ bool AppInitMain(NodeContext& node)
|
|||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
LogPrintf("%s\n", e.what());
|
LogPrintf("%s\n", e.what());
|
||||||
strLoadError = _("Error opening block database").translated;
|
strLoadError = _("Error opening block database");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1669,7 +1669,7 @@ bool AppInitMain(NodeContext& node)
|
|||||||
if (!chainstate->RewindBlockIndex(chainparams)) {
|
if (!chainstate->RewindBlockIndex(chainparams)) {
|
||||||
strLoadError = _(
|
strLoadError = _(
|
||||||
"Unable to rewind the database to a pre-fork state. "
|
"Unable to rewind the database to a pre-fork state. "
|
||||||
"You will need to redownload the blockchain").translated;
|
"You will need to redownload the blockchain");
|
||||||
failed_rewind = true;
|
failed_rewind = true;
|
||||||
break; // out of the per-chainstate loop
|
break; // out of the per-chainstate loop
|
||||||
}
|
}
|
||||||
@@ -1698,7 +1698,7 @@ bool AppInitMain(NodeContext& node)
|
|||||||
if (tip && tip->nTime > GetAdjustedTime() + 2 * 60 * 60) {
|
if (tip && tip->nTime > GetAdjustedTime() + 2 * 60 * 60) {
|
||||||
strLoadError = _("The block database contains a block which appears to be from the future. "
|
strLoadError = _("The block database contains a block which appears to be from the future. "
|
||||||
"This may be due to your computer's date and time being set incorrectly. "
|
"This may be due to your computer's date and time being set incorrectly. "
|
||||||
"Only rebuild the block database if you are sure that your computer's date and time are correct").translated;
|
"Only rebuild the block database if you are sure that your computer's date and time are correct");
|
||||||
failed_verification = true;
|
failed_verification = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1710,7 +1710,7 @@ bool AppInitMain(NodeContext& node)
|
|||||||
chainparams, &chainstate->CoinsDB(),
|
chainparams, &chainstate->CoinsDB(),
|
||||||
gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL),
|
gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL),
|
||||||
gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) {
|
gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) {
|
||||||
strLoadError = _("Corrupted block database detected").translated;
|
strLoadError = _("Corrupted block database detected");
|
||||||
failed_verification = true;
|
failed_verification = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1718,7 +1718,7 @@ bool AppInitMain(NodeContext& node)
|
|||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
LogPrintf("%s\n", e.what());
|
LogPrintf("%s\n", e.what());
|
||||||
strLoadError = _("Error opening block database").translated;
|
strLoadError = _("Error opening block database");
|
||||||
failed_verification = true;
|
failed_verification = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1733,8 +1733,8 @@ bool AppInitMain(NodeContext& node)
|
|||||||
// first suggest a reindex
|
// first suggest a reindex
|
||||||
if (!fReset) {
|
if (!fReset) {
|
||||||
bool fRet = uiInterface.ThreadSafeQuestion(
|
bool fRet = uiInterface.ThreadSafeQuestion(
|
||||||
strLoadError + ".\n\n" + _("Do you want to rebuild the block database now?").translated,
|
strLoadError + Untranslated(".\n\n") + _("Do you want to rebuild the block database now?"),
|
||||||
strLoadError + ".\nPlease restart with -reindex or -reindex-chainstate to recover.",
|
strLoadError.original + ".\nPlease restart with -reindex or -reindex-chainstate to recover.",
|
||||||
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT);
|
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT);
|
||||||
if (fRet) {
|
if (fRet) {
|
||||||
fReindex = true;
|
fReindex = true;
|
||||||
@@ -1744,7 +1744,7 @@ bool AppInitMain(NodeContext& node)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return InitError(strLoadError);
|
return InitError(strLoadError.translated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,11 +213,11 @@ public:
|
|||||||
|
|
||||||
//! Register handler for message box messages.
|
//! Register handler for message box messages.
|
||||||
using MessageBoxFn =
|
using MessageBoxFn =
|
||||||
std::function<bool(const std::string& message, const std::string& caption, unsigned int style)>;
|
std::function<bool(const bilingual_str& message, const std::string& caption, unsigned int style)>;
|
||||||
virtual std::unique_ptr<Handler> handleMessageBox(MessageBoxFn fn) = 0;
|
virtual std::unique_ptr<Handler> handleMessageBox(MessageBoxFn fn) = 0;
|
||||||
|
|
||||||
//! Register handler for question messages.
|
//! Register handler for question messages.
|
||||||
using QuestionFn = std::function<bool(const std::string& message,
|
using QuestionFn = std::function<bool(const bilingual_str& message,
|
||||||
const std::string& non_interactive_message,
|
const std::string& non_interactive_message,
|
||||||
const std::string& caption,
|
const std::string& caption,
|
||||||
unsigned int style)>;
|
unsigned int style)>;
|
||||||
|
|||||||
+13
-14
@@ -2068,9 +2068,8 @@ void CConnman::ThreadMessageHandler()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool CConnman::BindListenPort(const CService& addrBind, std::string& strError, NetPermissionFlags permissions)
|
bool CConnman::BindListenPort(const CService& addrBind, bilingual_str& strError, NetPermissionFlags permissions)
|
||||||
{
|
{
|
||||||
strError = "";
|
|
||||||
int nOne = 1;
|
int nOne = 1;
|
||||||
|
|
||||||
// Create socket for listening for incoming connections
|
// Create socket for listening for incoming connections
|
||||||
@@ -2078,16 +2077,16 @@ bool CConnman::BindListenPort(const CService& addrBind, std::string& strError, N
|
|||||||
socklen_t len = sizeof(sockaddr);
|
socklen_t len = sizeof(sockaddr);
|
||||||
if (!addrBind.GetSockAddr((struct sockaddr*)&sockaddr, &len))
|
if (!addrBind.GetSockAddr((struct sockaddr*)&sockaddr, &len))
|
||||||
{
|
{
|
||||||
strError = strprintf("Error: Bind address family for %s not supported", addrBind.ToString());
|
strError = strprintf(Untranslated("Error: Bind address family for %s not supported"), addrBind.ToString());
|
||||||
LogPrintf("%s\n", strError);
|
LogPrintf("%s\n", strError.original);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCKET hListenSocket = CreateSocket(addrBind);
|
SOCKET hListenSocket = CreateSocket(addrBind);
|
||||||
if (hListenSocket == INVALID_SOCKET)
|
if (hListenSocket == INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
strError = strprintf("Error: Couldn't open socket for incoming connections (socket returned error %s)", NetworkErrorString(WSAGetLastError()));
|
strError = strprintf(Untranslated("Error: Couldn't open socket for incoming connections (socket returned error %s)"), NetworkErrorString(WSAGetLastError()));
|
||||||
LogPrintf("%s\n", strError);
|
LogPrintf("%s\n", strError.original);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2111,10 +2110,10 @@ bool CConnman::BindListenPort(const CService& addrBind, std::string& strError, N
|
|||||||
{
|
{
|
||||||
int nErr = WSAGetLastError();
|
int nErr = WSAGetLastError();
|
||||||
if (nErr == WSAEADDRINUSE)
|
if (nErr == WSAEADDRINUSE)
|
||||||
strError = strprintf(_("Unable to bind to %s on this computer. %s is probably already running.").translated, addrBind.ToString(), PACKAGE_NAME);
|
strError = strprintf(_("Unable to bind to %s on this computer. %s is probably already running."), addrBind.ToString(), PACKAGE_NAME);
|
||||||
else
|
else
|
||||||
strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %s)").translated, addrBind.ToString(), NetworkErrorString(nErr));
|
strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %s)"), addrBind.ToString(), NetworkErrorString(nErr));
|
||||||
LogPrintf("%s\n", strError);
|
LogPrintf("%s\n", strError.original);
|
||||||
CloseSocket(hListenSocket);
|
CloseSocket(hListenSocket);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2123,8 +2122,8 @@ bool CConnman::BindListenPort(const CService& addrBind, std::string& strError, N
|
|||||||
// Listen for incoming connections
|
// Listen for incoming connections
|
||||||
if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR)
|
if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
strError = strprintf(_("Error: Listening for incoming connections failed (listen returned error %s)").translated, NetworkErrorString(WSAGetLastError()));
|
strError = strprintf(_("Error: Listening for incoming connections failed (listen returned error %s)"), NetworkErrorString(WSAGetLastError()));
|
||||||
LogPrintf("%s\n", strError);
|
LogPrintf("%s\n", strError.original);
|
||||||
CloseSocket(hListenSocket);
|
CloseSocket(hListenSocket);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2218,7 +2217,7 @@ NodeId CConnman::GetNewNodeId()
|
|||||||
bool CConnman::Bind(const CService &addr, unsigned int flags, NetPermissionFlags permissions) {
|
bool CConnman::Bind(const CService &addr, unsigned int flags, NetPermissionFlags permissions) {
|
||||||
if (!(flags & BF_EXPLICIT) && !IsReachable(addr))
|
if (!(flags & BF_EXPLICIT) && !IsReachable(addr))
|
||||||
return false;
|
return false;
|
||||||
std::string strError;
|
bilingual_str strError;
|
||||||
if (!BindListenPort(addr, strError, permissions)) {
|
if (!BindListenPort(addr, strError, permissions)) {
|
||||||
if ((flags & BF_REPORT_ERROR) && clientInterface) {
|
if ((flags & BF_REPORT_ERROR) && clientInterface) {
|
||||||
clientInterface->ThreadSafeMessageBox(strError, "", CClientUIInterface::MSG_ERROR);
|
clientInterface->ThreadSafeMessageBox(strError, "", CClientUIInterface::MSG_ERROR);
|
||||||
@@ -2265,7 +2264,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
|
|||||||
if (fListen && !InitBinds(connOptions.vBinds, connOptions.vWhiteBinds)) {
|
if (fListen && !InitBinds(connOptions.vBinds, connOptions.vWhiteBinds)) {
|
||||||
if (clientInterface) {
|
if (clientInterface) {
|
||||||
clientInterface->ThreadSafeMessageBox(
|
clientInterface->ThreadSafeMessageBox(
|
||||||
_("Failed to listen on any port. Use -listen=0 if you want this.").translated,
|
_("Failed to listen on any port. Use -listen=0 if you want this."),
|
||||||
"", CClientUIInterface::MSG_ERROR);
|
"", CClientUIInterface::MSG_ERROR);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -2331,7 +2330,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
|
|||||||
if (connOptions.m_use_addrman_outgoing && !connOptions.m_specified_outgoing.empty()) {
|
if (connOptions.m_use_addrman_outgoing && !connOptions.m_specified_outgoing.empty()) {
|
||||||
if (clientInterface) {
|
if (clientInterface) {
|
||||||
clientInterface->ThreadSafeMessageBox(
|
clientInterface->ThreadSafeMessageBox(
|
||||||
_("Cannot provide specific connections and have addrman find outgoing connections at the same.").translated,
|
_("Cannot provide specific connections and have addrman find outgoing connections at the same."),
|
||||||
"", CClientUIInterface::MSG_ERROR);
|
"", CClientUIInterface::MSG_ERROR);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
#include <random.h>
|
#include <random.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <uint256.h>
|
|
||||||
#include <threadinterrupt.h>
|
#include <threadinterrupt.h>
|
||||||
|
#include <uint256.h>
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
@@ -39,6 +39,7 @@
|
|||||||
class CScheduler;
|
class CScheduler;
|
||||||
class CNode;
|
class CNode;
|
||||||
class BanMan;
|
class BanMan;
|
||||||
|
struct bilingual_str;
|
||||||
|
|
||||||
/** Default for -whitelistrelay. */
|
/** Default for -whitelistrelay. */
|
||||||
static const bool DEFAULT_WHITELISTRELAY = true;
|
static const bool DEFAULT_WHITELISTRELAY = true;
|
||||||
@@ -334,7 +335,7 @@ private:
|
|||||||
NetPermissionFlags m_permissions;
|
NetPermissionFlags m_permissions;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool BindListenPort(const CService& bindAddr, std::string& strError, NetPermissionFlags permissions);
|
bool BindListenPort(const CService& bindAddr, bilingual_str& strError, NetPermissionFlags permissions);
|
||||||
bool Bind(const CService& addr, unsigned int flags, NetPermissionFlags permissions);
|
bool Bind(const CService& addr, unsigned int flags, NetPermissionFlags permissions);
|
||||||
bool InitBinds(const std::vector<CService>& binds, const std::vector<NetWhitebindPermissions>& whiteBinds);
|
bool InitBinds(const std::vector<CService>& binds, const std::vector<NetWhitebindPermissions>& whiteBinds);
|
||||||
void ThreadOpenAddedConnections();
|
void ThreadOpenAddedConnections();
|
||||||
|
|||||||
+10
-9
@@ -5,8 +5,9 @@
|
|||||||
|
|
||||||
#include <noui.h>
|
#include <noui.h>
|
||||||
|
|
||||||
|
#include <logging.h>
|
||||||
#include <ui_interface.h>
|
#include <ui_interface.h>
|
||||||
#include <util/system.h>
|
#include <util/translation.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ boost::signals2::connection noui_ThreadSafeMessageBoxConn;
|
|||||||
boost::signals2::connection noui_ThreadSafeQuestionConn;
|
boost::signals2::connection noui_ThreadSafeQuestionConn;
|
||||||
boost::signals2::connection noui_InitMessageConn;
|
boost::signals2::connection noui_InitMessageConn;
|
||||||
|
|
||||||
bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
|
bool noui_ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style)
|
||||||
{
|
{
|
||||||
bool fSecure = style & CClientUIInterface::SECURE;
|
bool fSecure = style & CClientUIInterface::SECURE;
|
||||||
style &= ~CClientUIInterface::SECURE;
|
style &= ~CClientUIInterface::SECURE;
|
||||||
@@ -43,15 +44,15 @@ bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& ca
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!fSecure) {
|
if (!fSecure) {
|
||||||
LogPrintf("%s%s\n", strCaption, message);
|
LogPrintf("%s%s\n", strCaption, message.original);
|
||||||
}
|
}
|
||||||
tfm::format(std::cerr, "%s%s\n", strCaption, message);
|
tfm::format(std::cerr, "%s%s\n", strCaption, message.original);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool noui_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
|
bool noui_ThreadSafeQuestion(const bilingual_str& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
|
||||||
{
|
{
|
||||||
return noui_ThreadSafeMessageBox(message, caption, style);
|
return noui_ThreadSafeMessageBox(Untranslated(message), caption, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void noui_InitMessage(const std::string& message)
|
void noui_InitMessage(const std::string& message)
|
||||||
@@ -66,13 +67,13 @@ void noui_connect()
|
|||||||
noui_InitMessageConn = uiInterface.InitMessage_connect(noui_InitMessage);
|
noui_InitMessageConn = uiInterface.InitMessage_connect(noui_InitMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool noui_ThreadSafeMessageBoxRedirect(const std::string& message, const std::string& caption, unsigned int style)
|
bool noui_ThreadSafeMessageBoxRedirect(const bilingual_str& message, const std::string& caption, unsigned int style)
|
||||||
{
|
{
|
||||||
LogPrintf("%s: %s\n", caption, message);
|
LogPrintf("%s: %s\n", caption, message.original);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool noui_ThreadSafeQuestionRedirect(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
|
bool noui_ThreadSafeQuestionRedirect(const bilingual_str& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
|
||||||
{
|
{
|
||||||
LogPrintf("%s: %s\n", caption, message);
|
LogPrintf("%s: %s\n", caption, message);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+4
-2
@@ -7,10 +7,12 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
struct bilingual_str;
|
||||||
|
|
||||||
/** Non-GUI handler, which logs and prints messages. */
|
/** Non-GUI handler, which logs and prints messages. */
|
||||||
bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style);
|
bool noui_ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style);
|
||||||
/** Non-GUI handler, which logs and prints questions. */
|
/** Non-GUI handler, which logs and prints questions. */
|
||||||
bool noui_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style);
|
bool noui_ThreadSafeQuestion(const bilingual_str& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style);
|
||||||
/** Non-GUI handler, which only logs a message. */
|
/** Non-GUI handler, which only logs a message. */
|
||||||
void noui_InitMessage(const std::string& message);
|
void noui_InitMessage(const std::string& message);
|
||||||
|
|
||||||
|
|||||||
+11
-3
@@ -36,6 +36,7 @@
|
|||||||
#include <interfaces/node.h>
|
#include <interfaces/node.h>
|
||||||
#include <ui_interface.h>
|
#include <ui_interface.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
#include <util/translation.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@@ -1369,20 +1370,27 @@ void BitcoinGUI::showModalOverlay()
|
|||||||
modalOverlay->toggleVisibility();
|
modalOverlay->toggleVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ThreadSafeMessageBox(BitcoinGUI* gui, const std::string& message, const std::string& caption, unsigned int style)
|
static bool ThreadSafeMessageBox(BitcoinGUI* gui, const bilingual_str& message, const std::string& caption, unsigned int style)
|
||||||
{
|
{
|
||||||
bool modal = (style & CClientUIInterface::MODAL);
|
bool modal = (style & CClientUIInterface::MODAL);
|
||||||
// The SECURE flag has no effect in the Qt GUI.
|
// The SECURE flag has no effect in the Qt GUI.
|
||||||
// bool secure = (style & CClientUIInterface::SECURE);
|
// bool secure = (style & CClientUIInterface::SECURE);
|
||||||
style &= ~CClientUIInterface::SECURE;
|
style &= ~CClientUIInterface::SECURE;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
|
QString detailed_message; // This is original message, in English, for googling and referencing.
|
||||||
|
if (message.original != message.translated) {
|
||||||
|
detailed_message = BitcoinGUI::tr("Original message:") + "\n" + QString::fromStdString(message.original);
|
||||||
|
}
|
||||||
|
|
||||||
// In case of modal message, use blocking connection to wait for user to click a button
|
// In case of modal message, use blocking connection to wait for user to click a button
|
||||||
bool invoked = QMetaObject::invokeMethod(gui, "message",
|
bool invoked = QMetaObject::invokeMethod(gui, "message",
|
||||||
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
|
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
|
||||||
Q_ARG(QString, QString::fromStdString(caption)),
|
Q_ARG(QString, QString::fromStdString(caption)),
|
||||||
Q_ARG(QString, QString::fromStdString(message)),
|
Q_ARG(QString, QString::fromStdString(message.translated)),
|
||||||
Q_ARG(unsigned int, style),
|
Q_ARG(unsigned int, style),
|
||||||
Q_ARG(bool*, &ret));
|
Q_ARG(bool*, &ret),
|
||||||
|
Q_ARG(QString, detailed_message));
|
||||||
assert(invoked);
|
assert(invoked);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -101,8 +101,8 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
|
|||||||
if (!fMatch)
|
if (!fMatch)
|
||||||
{
|
{
|
||||||
fDone = true;
|
fDone = true;
|
||||||
std::string strMessage = strprintf(_("Please check that your computer's date and time are correct! If your clock is wrong, %s will not work properly.").translated, PACKAGE_NAME);
|
bilingual_str strMessage = strprintf(_("Please check that your computer's date and time are correct! If your clock is wrong, %s will not work properly."), PACKAGE_NAME);
|
||||||
SetMiscWarning(strMessage);
|
SetMiscWarning(strMessage.translated);
|
||||||
uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING);
|
uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include <ui_interface.h>
|
#include <ui_interface.h>
|
||||||
|
|
||||||
|
#include <util/translation.h>
|
||||||
|
|
||||||
#include <boost/signals2/last_value.hpp>
|
#include <boost/signals2/last_value.hpp>
|
||||||
#include <boost/signals2/signal.hpp>
|
#include <boost/signals2/signal.hpp>
|
||||||
|
|
||||||
@@ -40,8 +42,8 @@ ADD_SIGNALS_IMPL_WRAPPER(NotifyBlockTip);
|
|||||||
ADD_SIGNALS_IMPL_WRAPPER(NotifyHeaderTip);
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyHeaderTip);
|
||||||
ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged);
|
ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged);
|
||||||
|
|
||||||
bool CClientUIInterface::ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style); }
|
bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style); }
|
||||||
bool CClientUIInterface::ThreadSafeQuestion(const std::string& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style); }
|
bool CClientUIInterface::ThreadSafeQuestion(const bilingual_str& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style); }
|
||||||
void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); }
|
void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); }
|
||||||
void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); }
|
void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); }
|
||||||
void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); }
|
void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); }
|
||||||
@@ -54,11 +56,11 @@ void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListCha
|
|||||||
|
|
||||||
bool InitError(const std::string& str)
|
bool InitError(const std::string& str)
|
||||||
{
|
{
|
||||||
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
|
uiInterface.ThreadSafeMessageBox(Untranslated(str), "", CClientUIInterface::MSG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitWarning(const std::string& str)
|
void InitWarning(const std::string& str)
|
||||||
{
|
{
|
||||||
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
|
uiInterface.ThreadSafeMessageBox(Untranslated(str), "", CClientUIInterface::MSG_WARNING);
|
||||||
}
|
}
|
||||||
+4
-2
@@ -11,6 +11,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
|
struct bilingual_str;
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace signals2 {
|
namespace signals2 {
|
||||||
class connection;
|
class connection;
|
||||||
@@ -82,10 +84,10 @@ public:
|
|||||||
boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn);
|
boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn);
|
||||||
|
|
||||||
/** Show message box. */
|
/** Show message box. */
|
||||||
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const std::string& message, const std::string& caption, unsigned int style);
|
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const bilingual_str& message, const std::string& caption, unsigned int style);
|
||||||
|
|
||||||
/** If possible, ask the user a question. If not, falls back to ThreadSafeMessageBox(noninteractive_message, caption, style) and returns false. */
|
/** If possible, ask the user a question. If not, falls back to ThreadSafeMessageBox(noninteractive_message, caption, style) and returns false. */
|
||||||
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeQuestion, bool, const std::string& message, const std::string& noninteractive_message, const std::string& caption, unsigned int style);
|
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeQuestion, bool, const bilingual_str& message, const std::string& noninteractive_message, const std::string& caption, unsigned int style);
|
||||||
|
|
||||||
/** Progress message during initialization. */
|
/** Progress message during initialization. */
|
||||||
ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message);
|
ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message);
|
||||||
|
|||||||
+3
-2
@@ -1651,14 +1651,15 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Abort with a message */
|
/** Abort with a message */
|
||||||
|
// TODO: AbortNode() should take bilingual_str userMessage parameter.
|
||||||
static bool AbortNode(const std::string& strMessage, const std::string& userMessage = "", unsigned int prefix = 0)
|
static bool AbortNode(const std::string& strMessage, const std::string& userMessage = "", unsigned int prefix = 0)
|
||||||
{
|
{
|
||||||
SetMiscWarning(strMessage);
|
SetMiscWarning(strMessage);
|
||||||
LogPrintf("*** %s\n", strMessage);
|
LogPrintf("*** %s\n", strMessage);
|
||||||
if (!userMessage.empty()) {
|
if (!userMessage.empty()) {
|
||||||
uiInterface.ThreadSafeMessageBox(userMessage, "", CClientUIInterface::MSG_ERROR | prefix);
|
uiInterface.ThreadSafeMessageBox(Untranslated(userMessage), "", CClientUIInterface::MSG_ERROR | prefix);
|
||||||
} else {
|
} else {
|
||||||
uiInterface.ThreadSafeMessageBox(_("Error: A fatal internal error occurred, see debug.log for details").translated, "", CClientUIInterface::MSG_ERROR | CClientUIInterface::MSG_NOPREFIX);
|
uiInterface.ThreadSafeMessageBox(_("Error: A fatal internal error occurred, see debug.log for details"), "", CClientUIInterface::MSG_ERROR | CClientUIInterface::MSG_NOPREFIX);
|
||||||
}
|
}
|
||||||
StartShutdown();
|
StartShutdown();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in new issue
Block a user