]> Git Repo - VerusCoin.git/blobdiff - src/alert.cpp
Clearly separate PUSHDATA and numeric argument MINIMALDATA tests
[VerusCoin.git] / src / alert.cpp
index 4dd3716e801719ab1de33a92b128f024bc722bf1..d495849206d46a7cccf6bd168456347b358b0310 100644 (file)
@@ -5,18 +5,21 @@
 
 #include "alert.h"
 
+#include "chainparams.h"
 #include "key.h"
 #include "net.h"
+#include "timedata.h"
 #include "ui_interface.h"
 #include "util.h"
 
+#include <stdint.h>
 #include <algorithm>
-#include <inttypes.h>
 #include <map>
 
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/foreach.hpp>
+#include <boost/thread.hpp>
 
 using namespace std;
 
@@ -52,8 +55,8 @@ std::string CUnsignedAlert::ToString() const
     return strprintf(
         "CAlert(\n"
         "    nVersion     = %d\n"
-        "    nRelayUntil  = %"PRId64"\n"
-        "    nExpiration  = %"PRId64"\n"
+        "    nRelayUntil  = %d\n"
+        "    nExpiration  = %d\n"
         "    nID          = %d\n"
         "    nCancel      = %d\n"
         "    setCancel    = %s\n"
@@ -78,11 +81,6 @@ std::string CUnsignedAlert::ToString() const
         strStatusBar);
 }
 
-void CUnsignedAlert::print() const
-{
-    LogPrintf("%s", ToString());
-}
-
 void CAlert::SetNull()
 {
     CUnsignedAlert::SetNull();
@@ -235,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);
+}
This page took 0.02504 seconds and 4 git commands to generate.