diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2014-10-09 10:33:05 -0400 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2014-10-09 10:39:29 -0400 |
commit | 3222802ea11053f0dd69c99fc2f33edff554dc17 (patch) | |
tree | 8db1800655df86b016a4a5ef042a855f321bde02 /src/alert.cpp | |
parent | dec58922d07241f0b502c96f8e5131abccbd5dc1 (diff) | |
parent | dbca89b74b76610331d21656cd6747f5bf8375d6 (diff) |
Merge pull request #5059
dbca89b Trigger -alertnotify if network is upgrading without you (Gavin Andresen)
e01a793 Refactor -alertnotify code (Gavin Andresen)
Signed-off-by: Gavin Andresen <gavinandresen@gmail.com>
Diffstat (limited to 'src/alert.cpp')
-rw-r--r-- | src/alert.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/alert.cpp b/src/alert.cpp index 3271ecfbfd..d495849206 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -233,25 +233,30 @@ bool CAlert::ProcessAlert(bool fThread) if(AppliesToMe()) { uiInterface.NotifyAlertChanged(GetHash(), CT_NEW); - std::string strCmd = GetArg("-alertnotify", ""); - if (!strCmd.empty()) - { - // 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(strStatusBar); - safeStatus = singleQuote+safeStatus+singleQuote; - boost::replace_all(strCmd, "%s", safeStatus); - - if (fThread) - boost::thread t(runCommand, strCmd); // thread runs free - else - runCommand(strCmd); - } + Notify(strStatusBar, fThread); } } LogPrint("alert", "accepted alert %d, AppliesToMe()=%d\n", nID, AppliesToMe()); return true; } + +void +CAlert::Notify(const std::string& strMessage, bool fThread) +{ + 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); +} |