aboutsummaryrefslogtreecommitdiff
path: root/src/alert.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/alert.cpp')
-rw-r--r--src/alert.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/alert.cpp b/src/alert.cpp
index e00847aadb..7f7e59ee10 100644
--- a/src/alert.cpp
+++ b/src/alert.cpp
@@ -2,17 +2,20 @@
// Alert system
//
-#include <algorithm>
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/replace.hpp>
-#include <boost/foreach.hpp>
-#include <map>
-
#include "alert.h"
+
#include "key.h"
#include "net.h"
-#include "sync.h"
#include "ui_interface.h"
+#include "util.h"
+
+#include <algorithm>
+#include <inttypes.h>
+#include <map>
+
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/replace.hpp>
+#include <boost/foreach.hpp>
using namespace std;
@@ -48,8 +51,8 @@ std::string CUnsignedAlert::ToString() const
return strprintf(
"CAlert(\n"
" nVersion = %d\n"
- " nRelayUntil = %"PRI64d"\n"
- " nExpiration = %"PRI64d"\n"
+ " nRelayUntil = %"PRId64"\n"
+ " nExpiration = %"PRId64"\n"
" nID = %d\n"
" nCancel = %d\n"
" setCancel = %s\n"
@@ -76,7 +79,7 @@ std::string CUnsignedAlert::ToString() const
void CUnsignedAlert::print() const
{
- printf("%s", ToString().c_str());
+ LogPrintf("%s", ToString().c_str());
}
void CAlert::SetNull()
@@ -200,13 +203,13 @@ bool CAlert::ProcessAlert(bool fThread)
const CAlert& alert = (*mi).second;
if (Cancels(alert))
{
- printf("cancelling alert %d\n", alert.nID);
+ LogPrint("alert", "cancelling alert %d\n", alert.nID);
uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
mapAlerts.erase(mi++);
}
else if (!alert.IsInEffect())
{
- printf("expiring alert %d\n", alert.nID);
+ LogPrint("alert", "expiring alert %d\n", alert.nID);
uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
mapAlerts.erase(mi++);
}
@@ -220,7 +223,7 @@ bool CAlert::ProcessAlert(bool fThread)
const CAlert& alert = item.second;
if (alert.Cancels(*this))
{
- printf("alert already cancelled by %d\n", alert.nID);
+ LogPrint("alert", "alert already cancelled by %d\n", alert.nID);
return false;
}
}
@@ -238,15 +241,7 @@ bool CAlert::ProcessAlert(bool fThread)
// 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("'");
- // safeChars chosen to allow simple messages/URLs/email addresses, but avoid anything
- // even possibly remotely dangerous like & or >
- std::string safeChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 .,;_/:?@");
- std::string safeStatus;
- for (std::string::size_type i = 0; i < strStatusBar.size(); i++)
- {
- if (safeChars.find(strStatusBar[i]) != std::string::npos)
- safeStatus.push_back(strStatusBar[i]);
- }
+ std::string safeStatus = SanitizeString(strStatusBar);
safeStatus = singleQuote+safeStatus+singleQuote;
boost::replace_all(strCmd, "%s", safeStatus);
@@ -258,6 +253,6 @@ bool CAlert::ProcessAlert(bool fThread)
}
}
- printf("accepted alert %d, AppliesToMe()=%d\n", nID, AppliesToMe());
+ LogPrint("alert", "accepted alert %d, AppliesToMe()=%d\n", nID, AppliesToMe());
return true;
}