Dogecoin Core  1.14.2
P2P Digital Currency
rpcconsole.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 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 #ifndef BITCOIN_QT_RPCCONSOLE_H
6 #define BITCOIN_QT_RPCCONSOLE_H
7 
8 #include "guiutil.h"
9 #include "peertablemodel.h"
10 
11 #include "net.h"
12 
13 #include <QWidget>
14 #include <QCompleter>
15 #include <QThread>
16 
17 class ClientModel;
18 class PlatformStyle;
19 class RPCTimerInterface;
20 
21 namespace Ui {
22  class RPCConsole;
23 }
24 
25 QT_BEGIN_NAMESPACE
26 class QMenu;
27 class QItemSelection;
28 QT_END_NAMESPACE
29 
31 class RPCConsole: public QWidget
32 {
33  Q_OBJECT
34 
35 public:
36  explicit RPCConsole(const PlatformStyle *platformStyle, QWidget *parent);
37  ~RPCConsole();
38 
39  static bool RPCParseCommandLine(std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = NULL);
40  static bool RPCExecuteCommandLine(std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = NULL) {
41  return RPCParseCommandLine(strResult, strCommand, true, pstrFilteredOut);
42  }
43 
44  void setClientModel(ClientModel *model);
45 
46  enum MessageClass {
51  CMD_ERROR
52  };
53 
54  enum TabTypes {
55  TAB_INFO = 0,
57  TAB_GRAPH = 2,
58  TAB_PEERS = 3
59  };
60 
61 protected:
62  virtual bool eventFilter(QObject* obj, QEvent *event);
63  void keyPressEvent(QKeyEvent *);
64 
65 private Q_SLOTS:
67  void on_tabWidget_currentChanged(int index);
71  void on_sldGraphRange_valueChanged(int value);
73  void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut);
74  void resizeEvent(QResizeEvent *event);
75  void showEvent(QShowEvent *event);
76  void hideEvent(QHideEvent *event);
78  void showPeersTableContextMenu(const QPoint& point);
80  void showBanTableContextMenu(const QPoint& point);
84  void clearSelectedNode();
85 
86 public Q_SLOTS:
87  void clear(bool clearHistory = true);
88  void fontBigger();
89  void fontSmaller();
90  void setFontSize(int newSize);
92  void message(int category, const QString &message, bool html = false);
94  void setNumConnections(int count);
96  void setNetworkActive(bool networkActive);
98  void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers);
100  void setMempoolSize(long numberOfTxs, size_t dynUsage);
102  void browseHistory(int offset);
104  void scrollToEnd();
106  void peerSelected(const QItemSelection &selected, const QItemSelection &deselected);
110  void peerLayoutChanged();
112  void disconnectSelectedNode();
114  void banSelectedNode(int bantime);
116  void unbanSelectedNode();
118  void setTabFocus(enum TabTypes tabType);
119 
120 Q_SIGNALS:
121  // For RPC command executor
122  void stopExecutor();
123  void cmdRequest(const QString &command);
124 
125 private:
126  static QString FormatBytes(quint64 bytes);
127  void startExecutor();
128  void setTrafficGraphRange(int mins);
130  void updateNodeDetail(const CNodeCombinedStats *stats);
131 
133  {
139 
140  };
141 
142  Ui::RPCConsole *ui;
144  QStringList history;
147  QList<NodeId> cachedNodeids;
153  QCompleter *autoCompleter;
154  QThread thread;
155 
157  void updateNetworkState();
158 };
159 
160 #endif // BITCOIN_QT_RPCCONSOLE_H
Model for Bitcoin network client.
Definition: clientmodel.h:42
Local Bitcoin RPC console.
Definition: rpcconsole.h:32
QMenu * peersTableContextMenu
Definition: rpcconsole.h:150
void updateNodeDetail(const CNodeCombinedStats *stats)
show detailed information on ui about selected node
void resizeEvent(QResizeEvent *event)
static bool RPCParseCommandLine(std::string &strResult, const std::string &strCommand, bool fExecute, std::string *const pstrFilteredOut=NULL)
Split shell command line into a list of arguments and optionally execute the command(s).
Definition: rpcconsole.cpp:149
void browseHistory(int offset)
Go forward or back in history.
Definition: rpcconsole.cpp:849
void peerSelected(const QItemSelection &selected, const QItemSelection &deselected)
Handle selection of peer in peers list.
Definition: rpcconsole.cpp:941
void fontSmaller()
Definition: rpcconsole.cpp:665
RPCTimerInterface * rpcTimerInterface
Definition: rpcconsole.h:149
void on_lineEdit_returnPressed()
Definition: rpcconsole.cpp:807
QStringList history
Definition: rpcconsole.h:144
void setClientModel(ClientModel *model)
Definition: rpcconsole.cpp:519
void setFontSize(int newSize)
Definition: rpcconsole.cpp:670
Ui::RPCConsole * ui
Definition: rpcconsole.h:142
void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
update traffic statistics
Definition: rpcconsole.cpp:935
void setTrafficGraphRange(int mins)
Definition: rpcconsole.cpp:929
void cmdRequest(const QString &command)
void updateNetworkState()
Update UI with latest network info from model.
Definition: rpcconsole.cpp:763
void disconnectSelectedNode()
Disconnect a selected node on the Peers tab.
@ BANTIME_COLUMN_WIDTH
Definition: rpcconsole.h:138
@ ADDRESS_COLUMN_WIDTH
Definition: rpcconsole.h:134
@ SUBVERSION_COLUMN_WIDTH
Definition: rpcconsole.h:135
@ PING_COLUMN_WIDTH
Definition: rpcconsole.h:136
@ BANSUBNET_COLUMN_WIDTH
Definition: rpcconsole.h:137
QCompleter * autoCompleter
Definition: rpcconsole.h:153
virtual bool eventFilter(QObject *obj, QEvent *event)
Definition: rpcconsole.cpp:475
void setMempoolSize(long numberOfTxs, size_t dynUsage)
Set size (number of transactions and memory usage) of the mempool in the UI.
Definition: rpcconsole.cpp:797
void setNumBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, bool headers)
Set number of blocks and last block date shown in the UI.
Definition: rpcconsole.cpp:789
static bool RPCExecuteCommandLine(std::string &strResult, const std::string &strCommand, std::string *const pstrFilteredOut=NULL)
Definition: rpcconsole.h:40
void clear(bool clearHistory=true)
Definition: rpcconsole.cpp:695
void keyPressEvent(QKeyEvent *)
Definition: rpcconsole.cpp:739
RPCConsole(const PlatformStyle *platformStyle, QWidget *parent)
Definition: rpcconsole.cpp:413
void showPeersTableContextMenu(const QPoint &point)
Show custom context menu on Peers tab.
QList< NodeId > cachedNodeids
Definition: rpcconsole.h:147
void unbanSelectedNode()
Unban a selected node on the Bans tab.
void clearSelectedNode()
clear the selected node
void on_sldGraphRange_valueChanged(int value)
change the time range of the network traffic graph
Definition: rpcconsole.cpp:910
int consoleFontSize
Definition: rpcconsole.h:152
const PlatformStyle * platformStyle
Definition: rpcconsole.h:148
void stopExecutor()
void setNumConnections(int count)
Set number of connections shown in the UI.
Definition: rpcconsole.cpp:776
ClientModel * clientModel
Definition: rpcconsole.h:143
void banSelectedNode(int bantime)
Ban a selected node on the Peers tab.
int historyPtr
Definition: rpcconsole.h:145
void scrollToEnd()
Scroll console view to end.
Definition: rpcconsole.cpp:904
void hideEvent(QHideEvent *event)
void on_tabWidget_currentChanged(int index)
Definition: rpcconsole.cpp:891
void startExecutor()
Definition: rpcconsole.cpp:870
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
Definition: rpcconsole.cpp:784
void fontBigger()
Definition: rpcconsole.cpp:660
QString cmdBeforeBrowsing
Definition: rpcconsole.h:146
void message(int category, const QString &message, bool html=false)
Append the message to the message widget.
Definition: rpcconsole.cpp:747
void on_openDebugLogfileButton_clicked()
open the debug.log from the current datadir
Definition: rpcconsole.cpp:899
void showBanTableContextMenu(const QPoint &point)
Show custom context menu on Bans tab.
void peerLayoutAboutToChange()
Handle selection caching before update.
Definition: rpcconsole.cpp:953
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
void showEvent(QShowEvent *event)
void showOrHideBanTableIfRequired()
Hides ban table if no bans are present.
QMenu * banTableContextMenu
Definition: rpcconsole.h:151
QThread thread
Definition: rpcconsole.h:154
void peerLayoutChanged()
Handle updated peer information.
Definition: rpcconsole.cpp:964
static QString FormatBytes(quint64 bytes)
Definition: rpcconsole.cpp:917
RPC timer "driver".
Definition: server.h:109