mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Update alert notification and GUI
This commit is contained in:
parent
bbb9d1d123
commit
92066344fd
28
src/main.cpp
28
src/main.cpp
@ -1565,6 +1565,26 @@ bool fLargeWorkForkFound = false;
|
|||||||
bool fLargeWorkInvalidChainFound = false;
|
bool fLargeWorkInvalidChainFound = false;
|
||||||
CBlockIndex *pindexBestForkTip = NULL, *pindexBestForkBase = NULL;
|
CBlockIndex *pindexBestForkTip = NULL, *pindexBestForkBase = NULL;
|
||||||
|
|
||||||
|
static void AlertNotify(const std::string& strMessage, bool fThread)
|
||||||
|
{
|
||||||
|
uiInterface.NotifyAlertChanged();
|
||||||
|
std::string strCmd = GetArg("-alertnotify", "");
|
||||||
|
if (strCmd.empty()) return;
|
||||||
|
|
||||||
|
// Alert text should be plain ascii coming from a trusted source, but to
|
||||||
|
// be safe we first strip anything not in safeChars, then add single quotes around
|
||||||
|
// the whole string before passing it to the shell:
|
||||||
|
std::string singleQuote("'");
|
||||||
|
std::string safeStatus = SanitizeString(strMessage);
|
||||||
|
safeStatus = singleQuote+safeStatus+singleQuote;
|
||||||
|
boost::replace_all(strCmd, "%s", safeStatus);
|
||||||
|
|
||||||
|
if (fThread)
|
||||||
|
boost::thread t(runCommand, strCmd); // thread runs free
|
||||||
|
else
|
||||||
|
runCommand(strCmd);
|
||||||
|
}
|
||||||
|
|
||||||
void CheckForkWarningConditions()
|
void CheckForkWarningConditions()
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
@ -1584,7 +1604,7 @@ void CheckForkWarningConditions()
|
|||||||
{
|
{
|
||||||
std::string warning = std::string("'Warning: Large-work fork detected, forking after block ") +
|
std::string warning = std::string("'Warning: Large-work fork detected, forking after block ") +
|
||||||
pindexBestForkBase->phashBlock->ToString() + std::string("'");
|
pindexBestForkBase->phashBlock->ToString() + std::string("'");
|
||||||
CAlert::Notify(warning, true);
|
AlertNotify(warning, true);
|
||||||
}
|
}
|
||||||
if (pindexBestForkTip && pindexBestForkBase)
|
if (pindexBestForkTip && pindexBestForkBase)
|
||||||
{
|
{
|
||||||
@ -2115,7 +2135,7 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const
|
|||||||
if (!strWarning.empty())
|
if (!strWarning.empty())
|
||||||
{
|
{
|
||||||
strMiscWarning = strWarning;
|
strMiscWarning = strWarning;
|
||||||
CAlert::Notify(strWarning, true);
|
AlertNotify(strWarning, true);
|
||||||
lastAlertTime = now;
|
lastAlertTime = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2545,7 +2565,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
|||||||
if (state == THRESHOLD_ACTIVE) {
|
if (state == THRESHOLD_ACTIVE) {
|
||||||
strMiscWarning = strprintf(_("Warning: unknown new rules activated (versionbit %i)"), bit);
|
strMiscWarning = strprintf(_("Warning: unknown new rules activated (versionbit %i)"), bit);
|
||||||
if (!fWarned) {
|
if (!fWarned) {
|
||||||
CAlert::Notify(strMiscWarning, true);
|
AlertNotify(strMiscWarning, true);
|
||||||
fWarned = true;
|
fWarned = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2567,7 +2587,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
|||||||
// strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user:
|
// strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user:
|
||||||
strMiscWarning = _("Warning: Unknown block versions being mined! It's possible unknown rules are in effect");
|
strMiscWarning = _("Warning: Unknown block versions being mined! It's possible unknown rules are in effect");
|
||||||
if (!fWarned) {
|
if (!fWarned) {
|
||||||
CAlert::Notify(strMiscWarning, true);
|
AlertNotify(strMiscWarning, true);
|
||||||
fWarned = true;
|
fWarned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,20 +121,8 @@ void ClientModel::updateNumConnections(int numConnections)
|
|||||||
Q_EMIT numConnectionsChanged(numConnections);
|
Q_EMIT numConnectionsChanged(numConnections);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientModel::updateAlert(const QString &hash, int status)
|
void ClientModel::updateAlert()
|
||||||
{
|
{
|
||||||
// Show error message notification for new alert
|
|
||||||
if(status == CT_NEW)
|
|
||||||
{
|
|
||||||
uint256 hash_256;
|
|
||||||
hash_256.SetHex(hash.toStdString());
|
|
||||||
CAlert alert = CAlert::getAlertByHash(hash_256);
|
|
||||||
if(!alert.IsNull())
|
|
||||||
{
|
|
||||||
Q_EMIT message(tr("Network Alert"), QString::fromStdString(alert.strStatusBar), CClientUIInterface::ICON_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_EMIT alertsChanged(getStatusBarWarnings());
|
Q_EMIT alertsChanged(getStatusBarWarnings());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,12 +214,10 @@ static void NotifyNumConnectionsChanged(ClientModel *clientmodel, int newNumConn
|
|||||||
Q_ARG(int, newNumConnections));
|
Q_ARG(int, newNumConnections));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void NotifyAlertChanged(ClientModel *clientmodel, const uint256 &hash, ChangeType status)
|
static void NotifyAlertChanged(ClientModel *clientmodel)
|
||||||
{
|
{
|
||||||
qDebug() << "NotifyAlertChanged: " + QString::fromStdString(hash.GetHex()) + " status=" + QString::number(status);
|
qDebug() << "NotifyAlertChanged";
|
||||||
QMetaObject::invokeMethod(clientmodel, "updateAlert", Qt::QueuedConnection,
|
QMetaObject::invokeMethod(clientmodel, "updateAlert", Qt::QueuedConnection);
|
||||||
Q_ARG(QString, QString::fromStdString(hash.GetHex())),
|
|
||||||
Q_ARG(int, status));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BannedListChanged(ClientModel *clientmodel)
|
static void BannedListChanged(ClientModel *clientmodel)
|
||||||
@ -265,7 +251,7 @@ void ClientModel::subscribeToCoreSignals()
|
|||||||
// Connect signals to client
|
// Connect signals to client
|
||||||
uiInterface.ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2));
|
uiInterface.ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2));
|
||||||
uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1));
|
uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1));
|
||||||
uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, _1, _2));
|
uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this));
|
||||||
uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this));
|
uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this));
|
||||||
uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2));
|
uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2));
|
||||||
}
|
}
|
||||||
@ -275,7 +261,7 @@ void ClientModel::unsubscribeFromCoreSignals()
|
|||||||
// Disconnect signals from client
|
// Disconnect signals from client
|
||||||
uiInterface.ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
|
uiInterface.ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
|
||||||
uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1));
|
uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1));
|
||||||
uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, _1, _2));
|
uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this));
|
||||||
uiInterface.BannedListChanged.disconnect(boost::bind(BannedListChanged, this));
|
uiInterface.BannedListChanged.disconnect(boost::bind(BannedListChanged, this));
|
||||||
uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2));
|
uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2));
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ Q_SIGNALS:
|
|||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void updateTimer();
|
void updateTimer();
|
||||||
void updateNumConnections(int numConnections);
|
void updateNumConnections(int numConnections);
|
||||||
void updateAlert(const QString &hash, int status);
|
void updateAlert();
|
||||||
void updateBanlist();
|
void updateBanlist();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,10 +83,9 @@ public:
|
|||||||
boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged;
|
boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New, updated or cancelled alert.
|
* Status bar alerts changed.
|
||||||
* @note called with lock cs_mapAlerts held.
|
|
||||||
*/
|
*/
|
||||||
boost::signals2::signal<void (const uint256 &hash, ChangeType status)> NotifyAlertChanged;
|
boost::signals2::signal<void ()> NotifyAlertChanged;
|
||||||
|
|
||||||
/** A wallet has been loaded. */
|
/** A wallet has been loaded. */
|
||||||
boost::signals2::signal<void (CWallet* wallet)> LoadWallet;
|
boost::signals2::signal<void (CWallet* wallet)> LoadWallet;
|
||||||
|
Loading…
Reference in New Issue
Block a user