mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Make ThreadSafe{MessageBox|Question} bilingual
This commit is contained in:
parent
23b9fa2e5e
commit
917ca93553
14 changed files with 82 additions and 64 deletions
|
@ -252,7 +252,7 @@ static bool InitRPCAuthentication()
|
|||
LogPrintf("No rpcpassword set - using random cookie authentication.\n");
|
||||
if (!GenerateAuthCookie(&strRPCUserColonPass)) {
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -6,14 +6,15 @@
|
|||
|
||||
#include <chainparamsbase.h>
|
||||
#include <compat.h>
|
||||
#include <util/threadnames.h>
|
||||
#include <util/system.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <netbase.h>
|
||||
#include <rpc/protocol.h> // For HTTP status codes
|
||||
#include <shutdown.h>
|
||||
#include <sync.h>
|
||||
#include <ui_interface.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
#include <util/threadnames.h>
|
||||
#include <util/translation.h>
|
||||
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
|
@ -175,7 +176,7 @@ static bool InitHTTPAllowList()
|
|||
LookupSubNet(strAllow, subnet);
|
||||
if (!subnet.IsValid()) {
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <tinyformat.h>
|
||||
#include <ui_interface.h>
|
||||
#include <util/system.h>
|
||||
#include <util/translation.h>
|
||||
#include <validation.h>
|
||||
#include <warnings.h>
|
||||
|
||||
|
@ -23,7 +24,7 @@ static void FatalError(const char* fmt, const Args&... args)
|
|||
SetMiscWarning(strMessage);
|
||||
LogPrintf("*** %s\n", strMessage);
|
||||
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);
|
||||
StartShutdown();
|
||||
}
|
||||
|
|
32
src/init.cpp
32
src/init.cpp
|
@ -1542,7 +1542,7 @@ bool AppInitMain(NodeContext& node)
|
|||
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
||||
return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull();
|
||||
};
|
||||
std::string strLoadError;
|
||||
bilingual_str strLoadError;
|
||||
|
||||
uiInterface.InitMessage(_("Loading block index...").translated);
|
||||
|
||||
|
@ -1573,7 +1573,7 @@ bool AppInitMain(NodeContext& node)
|
|||
// From here on out fReindex and fReset mean something different!
|
||||
if (!LoadBlockIndex(chainparams)) {
|
||||
if (ShutdownRequested()) break;
|
||||
strLoadError = _("Error loading block database").translated;
|
||||
strLoadError = _("Error loading block database");
|
||||
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
|
||||
// in the past, but is now trying to run unpruned.
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1596,7 +1596,7 @@ bool AppInitMain(NodeContext& node)
|
|||
// (otherwise we use the one already on disk).
|
||||
// This is called again in ThreadImport after the reindex completes.
|
||||
if (!fReindex && !LoadGenesisBlock(chainparams)) {
|
||||
strLoadError = _("Error initializing block database").translated;
|
||||
strLoadError = _("Error initializing block database");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1614,21 +1614,21 @@ bool AppInitMain(NodeContext& node)
|
|||
|
||||
chainstate->CoinsErrorCatcher().AddReadErrCallback([]() {
|
||||
uiInterface.ThreadSafeMessageBox(
|
||||
_("Error reading from database, shutting down.").translated,
|
||||
_("Error reading from database, shutting down."),
|
||||
"", CClientUIInterface::MSG_ERROR);
|
||||
});
|
||||
|
||||
// If necessary, upgrade from older database format.
|
||||
// This is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate
|
||||
if (!chainstate->CoinsDB().Upgrade()) {
|
||||
strLoadError = _("Error upgrading chainstate database").translated;
|
||||
strLoadError = _("Error upgrading chainstate database");
|
||||
failed_chainstate_init = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// ReplayBlocks is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -1640,7 +1640,7 @@ bool AppInitMain(NodeContext& node)
|
|||
if (!is_coinsview_empty(chainstate)) {
|
||||
// LoadChainTip initializes the chain based on CoinsTip()'s best block
|
||||
if (!chainstate->LoadChainTip(chainparams)) {
|
||||
strLoadError = _("Error initializing block database").translated;
|
||||
strLoadError = _("Error initializing block database");
|
||||
failed_chainstate_init = true;
|
||||
break; // out of the per-chainstate loop
|
||||
}
|
||||
|
@ -1653,7 +1653,7 @@ bool AppInitMain(NodeContext& node)
|
|||
}
|
||||
} catch (const std::exception& e) {
|
||||
LogPrintf("%s\n", e.what());
|
||||
strLoadError = _("Error opening block database").translated;
|
||||
strLoadError = _("Error opening block database");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1669,7 +1669,7 @@ bool AppInitMain(NodeContext& node)
|
|||
if (!chainstate->RewindBlockIndex(chainparams)) {
|
||||
strLoadError = _(
|
||||
"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;
|
||||
break; // out of the per-chainstate loop
|
||||
}
|
||||
|
@ -1698,7 +1698,7 @@ bool AppInitMain(NodeContext& node)
|
|||
if (tip && tip->nTime > GetAdjustedTime() + 2 * 60 * 60) {
|
||||
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. "
|
||||
"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;
|
||||
break;
|
||||
}
|
||||
|
@ -1710,7 +1710,7 @@ bool AppInitMain(NodeContext& node)
|
|||
chainparams, &chainstate->CoinsDB(),
|
||||
gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL),
|
||||
gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) {
|
||||
strLoadError = _("Corrupted block database detected").translated;
|
||||
strLoadError = _("Corrupted block database detected");
|
||||
failed_verification = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1718,7 +1718,7 @@ bool AppInitMain(NodeContext& node)
|
|||
}
|
||||
} catch (const std::exception& e) {
|
||||
LogPrintf("%s\n", e.what());
|
||||
strLoadError = _("Error opening block database").translated;
|
||||
strLoadError = _("Error opening block database");
|
||||
failed_verification = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1733,8 +1733,8 @@ bool AppInitMain(NodeContext& node)
|
|||
// first suggest a reindex
|
||||
if (!fReset) {
|
||||
bool fRet = uiInterface.ThreadSafeQuestion(
|
||||
strLoadError + ".\n\n" + _("Do you want to rebuild the block database now?").translated,
|
||||
strLoadError + ".\nPlease restart with -reindex or -reindex-chainstate to recover.",
|
||||
strLoadError + Untranslated(".\n\n") + _("Do you want to rebuild the block database now?"),
|
||||
strLoadError.original + ".\nPlease restart with -reindex or -reindex-chainstate to recover.",
|
||||
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT);
|
||||
if (fRet) {
|
||||
fReindex = true;
|
||||
|
@ -1744,7 +1744,7 @@ bool AppInitMain(NodeContext& node)
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
return InitError(strLoadError);
|
||||
return InitError(strLoadError.translated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,11 +213,11 @@ public:
|
|||
|
||||
//! Register handler for message box messages.
|
||||
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;
|
||||
|
||||
//! 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& caption,
|
||||
unsigned int style)>;
|
||||
|
|
27
src/net.cpp
27
src/net.cpp
|
@ -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;
|
||||
|
||||
// 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);
|
||||
if (!addrBind.GetSockAddr((struct sockaddr*)&sockaddr, &len))
|
||||
{
|
||||
strError = strprintf("Error: Bind address family for %s not supported", addrBind.ToString());
|
||||
LogPrintf("%s\n", strError);
|
||||
strError = strprintf(Untranslated("Error: Bind address family for %s not supported"), addrBind.ToString());
|
||||
LogPrintf("%s\n", strError.original);
|
||||
return false;
|
||||
}
|
||||
|
||||
SOCKET hListenSocket = CreateSocket(addrBind);
|
||||
if (hListenSocket == INVALID_SOCKET)
|
||||
{
|
||||
strError = strprintf("Error: Couldn't open socket for incoming connections (socket returned error %s)", NetworkErrorString(WSAGetLastError()));
|
||||
LogPrintf("%s\n", strError);
|
||||
strError = strprintf(Untranslated("Error: Couldn't open socket for incoming connections (socket returned error %s)"), NetworkErrorString(WSAGetLastError()));
|
||||
LogPrintf("%s\n", strError.original);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2111,10 +2110,10 @@ bool CConnman::BindListenPort(const CService& addrBind, std::string& strError, N
|
|||
{
|
||||
int nErr = WSAGetLastError();
|
||||
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
|
||||
strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %s)").translated, addrBind.ToString(), NetworkErrorString(nErr));
|
||||
LogPrintf("%s\n", strError);
|
||||
strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %s)"), addrBind.ToString(), NetworkErrorString(nErr));
|
||||
LogPrintf("%s\n", strError.original);
|
||||
CloseSocket(hListenSocket);
|
||||
return false;
|
||||
}
|
||||
|
@ -2123,8 +2122,8 @@ bool CConnman::BindListenPort(const CService& addrBind, std::string& strError, N
|
|||
// Listen for incoming connections
|
||||
if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR)
|
||||
{
|
||||
strError = strprintf(_("Error: Listening for incoming connections failed (listen returned error %s)").translated, NetworkErrorString(WSAGetLastError()));
|
||||
LogPrintf("%s\n", strError);
|
||||
strError = strprintf(_("Error: Listening for incoming connections failed (listen returned error %s)"), NetworkErrorString(WSAGetLastError()));
|
||||
LogPrintf("%s\n", strError.original);
|
||||
CloseSocket(hListenSocket);
|
||||
return false;
|
||||
}
|
||||
|
@ -2218,7 +2217,7 @@ NodeId CConnman::GetNewNodeId()
|
|||
bool CConnman::Bind(const CService &addr, unsigned int flags, NetPermissionFlags permissions) {
|
||||
if (!(flags & BF_EXPLICIT) && !IsReachable(addr))
|
||||
return false;
|
||||
std::string strError;
|
||||
bilingual_str strError;
|
||||
if (!BindListenPort(addr, strError, permissions)) {
|
||||
if ((flags & BF_REPORT_ERROR) && clientInterface) {
|
||||
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 (clientInterface) {
|
||||
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);
|
||||
}
|
||||
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 (clientInterface) {
|
||||
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);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include <random.h>
|
||||
#include <streams.h>
|
||||
#include <sync.h>
|
||||
#include <uint256.h>
|
||||
#include <threadinterrupt.h>
|
||||
#include <uint256.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <deque>
|
||||
|
@ -39,6 +39,7 @@
|
|||
class CScheduler;
|
||||
class CNode;
|
||||
class BanMan;
|
||||
struct bilingual_str;
|
||||
|
||||
/** Default for -whitelistrelay. */
|
||||
static const bool DEFAULT_WHITELISTRELAY = true;
|
||||
|
@ -334,7 +335,7 @@ private:
|
|||
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 InitBinds(const std::vector<CService>& binds, const std::vector<NetWhitebindPermissions>& whiteBinds);
|
||||
void ThreadOpenAddedConnections();
|
||||
|
|
19
src/noui.cpp
19
src/noui.cpp
|
@ -5,8 +5,9 @@
|
|||
|
||||
#include <noui.h>
|
||||
|
||||
#include <logging.h>
|
||||
#include <ui_interface.h>
|
||||
#include <util/system.h>
|
||||
#include <util/translation.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -18,7 +19,7 @@ boost::signals2::connection noui_ThreadSafeMessageBoxConn;
|
|||
boost::signals2::connection noui_ThreadSafeQuestionConn;
|
||||
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;
|
||||
style &= ~CClientUIInterface::SECURE;
|
||||
|
@ -43,15 +44,15 @@ bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& ca
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -66,13 +67,13 @@ void noui_connect()
|
|||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
return false;
|
||||
|
|
|
@ -7,10 +7,12 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
struct bilingual_str;
|
||||
|
||||
/** 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. */
|
||||
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. */
|
||||
void noui_InitMessage(const std::string& message);
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <interfaces/node.h>
|
||||
#include <ui_interface.h>
|
||||
#include <util/system.h>
|
||||
#include <util/translation.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
|
@ -1369,20 +1370,27 @@ void BitcoinGUI::showModalOverlay()
|
|||
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);
|
||||
// The SECURE flag has no effect in the Qt GUI.
|
||||
// bool secure = (style & CClientUIInterface::SECURE);
|
||||
style &= ~CClientUIInterface::SECURE;
|
||||
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
|
||||
bool invoked = QMetaObject::invokeMethod(gui, "message",
|
||||
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
|
||||
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(bool*, &ret));
|
||||
Q_ARG(bool*, &ret),
|
||||
Q_ARG(QString, detailed_message));
|
||||
assert(invoked);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -101,8 +101,8 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
|
|||
if (!fMatch)
|
||||
{
|
||||
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);
|
||||
SetMiscWarning(strMessage);
|
||||
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.translated);
|
||||
uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include <ui_interface.h>
|
||||
|
||||
#include <util/translation.h>
|
||||
|
||||
#include <boost/signals2/last_value.hpp>
|
||||
#include <boost/signals2/signal.hpp>
|
||||
|
||||
|
@ -40,8 +42,8 @@ ADD_SIGNALS_IMPL_WRAPPER(NotifyBlockTip);
|
|||
ADD_SIGNALS_IMPL_WRAPPER(NotifyHeaderTip);
|
||||
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::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::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(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::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); }
|
||||
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)
|
||||
{
|
||||
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
|
||||
uiInterface.ThreadSafeMessageBox(Untranslated(str), "", CClientUIInterface::MSG_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
void InitWarning(const std::string& str)
|
||||
{
|
||||
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
|
||||
uiInterface.ThreadSafeMessageBox(Untranslated(str), "", CClientUIInterface::MSG_WARNING);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <string>
|
||||
|
||||
class CBlockIndex;
|
||||
struct bilingual_str;
|
||||
|
||||
namespace boost {
|
||||
namespace signals2 {
|
||||
class connection;
|
||||
|
@ -82,10 +84,10 @@ public:
|
|||
boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn);
|
||||
|
||||
/** 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. */
|
||||
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. */
|
||||
ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message);
|
||||
|
|
|
@ -1651,14 +1651,15 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
|
|||
}
|
||||
|
||||
/** 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)
|
||||
{
|
||||
SetMiscWarning(strMessage);
|
||||
LogPrintf("*** %s\n", strMessage);
|
||||
if (!userMessage.empty()) {
|
||||
uiInterface.ThreadSafeMessageBox(userMessage, "", CClientUIInterface::MSG_ERROR | prefix);
|
||||
uiInterface.ThreadSafeMessageBox(Untranslated(userMessage), "", CClientUIInterface::MSG_ERROR | prefix);
|
||||
} 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();
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue