LCOV - code coverage report
Current view: top level - src/node - ui_interface.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 22 29 75.9 %
Date: 2020-09-26 01:30:44 Functions: 21 27 77.8 %

          Line data    Source code
       1             : // Copyright (c) 2010-2020 The Bitcoin Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #include <node/ui_interface.h>
       6             : 
       7             : #include <util/translation.h>
       8             : 
       9             : #include <boost/signals2/optional_last_value.hpp>
      10             : #include <boost/signals2/signal.hpp>
      11             : 
      12             : CClientUIInterface uiInterface;
      13             : 
      14        2560 : struct UISignals {
      15             :     boost::signals2::signal<CClientUIInterface::ThreadSafeMessageBoxSig, boost::signals2::optional_last_value<bool>> ThreadSafeMessageBox;
      16             :     boost::signals2::signal<CClientUIInterface::ThreadSafeQuestionSig, boost::signals2::optional_last_value<bool>> ThreadSafeQuestion;
      17             :     boost::signals2::signal<CClientUIInterface::InitMessageSig> InitMessage;
      18             :     boost::signals2::signal<CClientUIInterface::NotifyNumConnectionsChangedSig> NotifyNumConnectionsChanged;
      19             :     boost::signals2::signal<CClientUIInterface::NotifyNetworkActiveChangedSig> NotifyNetworkActiveChanged;
      20             :     boost::signals2::signal<CClientUIInterface::NotifyAlertChangedSig> NotifyAlertChanged;
      21             :     boost::signals2::signal<CClientUIInterface::ShowProgressSig> ShowProgress;
      22             :     boost::signals2::signal<CClientUIInterface::NotifyBlockTipSig> NotifyBlockTip;
      23             :     boost::signals2::signal<CClientUIInterface::NotifyHeaderTipSig> NotifyHeaderTip;
      24             :     boost::signals2::signal<CClientUIInterface::BannedListChangedSig> BannedListChanged;
      25             : };
      26         640 : static UISignals g_ui_signals;
      27             : 
      28             : #define ADD_SIGNALS_IMPL_WRAPPER(signal_name)                                                                 \
      29             :     boost::signals2::connection CClientUIInterface::signal_name##_connect(std::function<signal_name##Sig> fn) \
      30             :     {                                                                                                         \
      31             :         return g_ui_signals.signal_name.connect(fn);                                                          \
      32             :     }
      33             : 
      34         652 : ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeMessageBox);
      35         652 : ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeQuestion);
      36        1178 : ADD_SIGNALS_IMPL_WRAPPER(InitMessage);
      37           0 : ADD_SIGNALS_IMPL_WRAPPER(NotifyNumConnectionsChanged);
      38           0 : ADD_SIGNALS_IMPL_WRAPPER(NotifyNetworkActiveChanged);
      39           0 : ADD_SIGNALS_IMPL_WRAPPER(NotifyAlertChanged);
      40           0 : ADD_SIGNALS_IMPL_WRAPPER(ShowProgress);
      41         720 : ADD_SIGNALS_IMPL_WRAPPER(NotifyBlockTip);
      42           0 : ADD_SIGNALS_IMPL_WRAPPER(NotifyHeaderTip);
      43           0 : ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged);
      44             : 
      45          58 : bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style).value_or(false);}
      46           1 : 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).value_or(false);}
      47        4609 : void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); }
      48         989 : void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); }
      49           8 : void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); }
      50           2 : void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); }
      51        6310 : void CClientUIInterface::ShowProgress(const std::string& title, int nProgress, bool resume_possible) { return g_ui_signals.ShowProgress(title, nProgress, resume_possible); }
      52       43894 : void CClientUIInterface::NotifyBlockTip(SynchronizationState s, const CBlockIndex* i) { return g_ui_signals.NotifyBlockTip(s, i); }
      53       35843 : void CClientUIInterface::NotifyHeaderTip(SynchronizationState s, const CBlockIndex* i) { return g_ui_signals.NotifyHeaderTip(s, i); }
      54          13 : void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListChanged(); }
      55             : 
      56          56 : bool InitError(const bilingual_str& str)
      57             : {
      58          56 :     uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
      59          56 :     return false;
      60           0 : }
      61             : 
      62           1 : void InitWarning(const bilingual_str& str)
      63             : {
      64           1 :     uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
      65           1 : }

Generated by: LCOV version 1.15