Raven Core  3.0.0
P2P Digital Currency
rpcconsole.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef RAVEN_QT_RPCCONSOLE_H
7 #define RAVEN_QT_RPCCONSOLE_H
8 
9 #include "guiutil.h"
10 #include "peertablemodel.h"
11 
12 #include "net.h"
13 
14 #include <QWidget>
15 #include <QCompleter>
16 #include <QThread>
17 
18 class ClientModel;
19 class PlatformStyle;
20 class RPCTimerInterface;
21 
22 namespace Ui {
23  class RPCConsole;
24 }
25 
26 QT_BEGIN_NAMESPACE
27 class QMenu;
28 class QItemSelection;
29 QT_END_NAMESPACE
30 
32 class RPCConsole: public QWidget
33 {
34  Q_OBJECT
35 
36 public:
37  explicit RPCConsole(const PlatformStyle *platformStyle, QWidget *parent);
38  ~RPCConsole();
39 
40  static bool RPCParseCommandLine(std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr);
41  static bool RPCExecuteCommandLine(std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr) {
42  return RPCParseCommandLine(strResult, strCommand, true, pstrFilteredOut);
43  }
44 
45  void setClientModel(ClientModel *model);
46 
47  enum MessageClass {
52  CMD_ERROR
53  };
54 
55  enum TabTypes {
56  TAB_INFO = 0,
57  TAB_CONSOLE = 1,
58  TAB_GRAPH = 2,
59  TAB_PEERS = 3,
60  TAB_REPAIR = 4
61  };
62 
63 protected:
64  virtual bool eventFilter(QObject* obj, QEvent *event);
65  void keyPressEvent(QKeyEvent *);
66 
67 private Q_SLOTS:
68  void on_lineEdit_returnPressed();
69  void on_tabWidget_currentChanged(int index);
71  void on_openDebugLogfileButton_clicked();
73  void on_sldGraphRange_valueChanged(int value);
75  void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut);
76  void resizeEvent(QResizeEvent *event);
77  void showEvent(QShowEvent *event);
78  void hideEvent(QHideEvent *event);
80  void showPeersTableContextMenu(const QPoint& point);
82  void showBanTableContextMenu(const QPoint& point);
84  void showOrHideBanTableIfRequired();
86  void clearSelectedNode();
87 
88 public Q_SLOTS:
89  void clear(bool clearHistory = true);
90  void fontBigger();
91  void fontSmaller();
92  void setFontSize(int newSize);
93 
95  void walletRescan();
96  void walletZaptxes1();
97  void walletReindex();
98 
100  void message(int category, const QString &message, bool html = false);
102  void setNumConnections(int count);
104  void setNetworkActive(bool networkActive);
106  void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers);
108  void setMempoolSize(long numberOfTxs, size_t dynUsage);
110  void browseHistory(int offset);
112  void scrollToEnd();
114  void peerSelected(const QItemSelection &selected, const QItemSelection &deselected);
116  void peerLayoutAboutToChange();
118  void peerLayoutChanged();
120  void disconnectSelectedNode();
122  void banSelectedNode(int bantime);
124  void unbanSelectedNode();
126  void setTabFocus(enum TabTypes tabType);
127 
128 Q_SIGNALS:
129  // For RPC command executor
130  void stopExecutor();
131  void cmdRequest(const QString &command);
133  void handleRestart(QStringList args);
134 
135 private:
136  void startExecutor();
137  void setTrafficGraphRange(int mins);
139  void buildParameterlist(QString arg);
141  void updateNodeDetail(const CNodeCombinedStats *stats);
142 
144  {
145  ADDRESS_COLUMN_WIDTH = 200,
146  SUBVERSION_COLUMN_WIDTH = 150,
147  PING_COLUMN_WIDTH = 80,
148  BANSUBNET_COLUMN_WIDTH = 200,
149  BANTIME_COLUMN_WIDTH = 250
150 
151  };
152 
153  Ui::RPCConsole *ui;
155  QStringList history;
158  QList<NodeId> cachedNodeids;
164  QCompleter *autoCompleter;
165  QThread thread;
166 
168  void updateNetworkState();
169 };
170 
171 #endif // RAVEN_QT_RPCCONSOLE_H
Local Raven RPC console.
Definition: rpcconsole.h:32
RPC timer "driver".
Definition: server.h:101
QString cmdBeforeBrowsing
Definition: rpcconsole.h:157
static bool RPCExecuteCommandLine(std::string &strResult, const std::string &strCommand, std::string *const pstrFilteredOut=nullptr)
Definition: rpcconsole.h:41
QStringList history
Definition: rpcconsole.h:155
QThread thread
Definition: rpcconsole.h:165
QMenu * peersTableContextMenu
Definition: rpcconsole.h:161
int historyPtr
Definition: rpcconsole.h:156
RPCTimerInterface * rpcTimerInterface
Definition: rpcconsole.h:160
Model for Raven network client.
Definition: clientmodel.h:39
ClientModel * clientModel
Definition: rpcconsole.h:154
QMenu * banTableContextMenu
Definition: rpcconsole.h:162
QList< NodeId > cachedNodeids
Definition: rpcconsole.h:158
int consoleFontSize
Definition: rpcconsole.h:163
Ui::RPCConsole * ui
Definition: rpcconsole.h:153
QCompleter * autoCompleter
Definition: rpcconsole.h:164
const PlatformStyle * platformStyle
Definition: rpcconsole.h:159