2015-12-13 17:58:29 +01:00
|
|
|
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 16:20:43 +01:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#ifndef BITCOIN_QT_RPCCONSOLE_H
|
|
|
|
#define BITCOIN_QT_RPCCONSOLE_H
|
2012-04-09 21:07:25 +02:00
|
|
|
|
2014-05-23 19:09:59 +02:00
|
|
|
#include "guiutil.h"
|
|
|
|
#include "peertablemodel.h"
|
|
|
|
|
2014-06-03 14:42:20 +02:00
|
|
|
#include "net.h"
|
|
|
|
|
2014-11-10 16:41:57 +01:00
|
|
|
#include <QWidget>
|
2016-02-27 04:57:12 +01:00
|
|
|
#include <QCompleter>
|
2016-11-18 16:35:14 +01:00
|
|
|
#include <QThread>
|
2012-04-09 21:07:25 +02:00
|
|
|
|
2013-04-13 07:13:08 +02:00
|
|
|
class ClientModel;
|
2015-07-28 15:20:14 +02:00
|
|
|
class PlatformStyle;
|
2015-08-28 16:46:20 +02:00
|
|
|
class RPCTimerInterface;
|
2013-04-13 07:13:08 +02:00
|
|
|
|
2012-04-09 21:07:25 +02:00
|
|
|
namespace Ui {
|
|
|
|
class RPCConsole;
|
|
|
|
}
|
|
|
|
|
2014-09-05 13:18:35 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
2015-06-01 15:32:25 +02:00
|
|
|
class QMenu;
|
2014-09-05 13:18:35 +02:00
|
|
|
class QItemSelection;
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2012-05-13 16:09:14 +02:00
|
|
|
/** Local Bitcoin RPC console. */
|
2014-11-10 16:41:57 +01:00
|
|
|
class RPCConsole: public QWidget
|
2012-04-09 21:07:25 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-07-28 15:20:14 +02:00
|
|
|
explicit RPCConsole(const PlatformStyle *platformStyle, QWidget *parent);
|
2012-04-09 21:07:25 +02:00
|
|
|
~RPCConsole();
|
|
|
|
|
2016-08-20 11:19:35 +02:00
|
|
|
static bool RPCExecuteCommandLine(std::string &strResult, const std::string &strCommand);
|
|
|
|
|
2012-04-09 21:07:25 +02:00
|
|
|
void setClientModel(ClientModel *model);
|
|
|
|
|
|
|
|
enum MessageClass {
|
|
|
|
MC_ERROR,
|
|
|
|
MC_DEBUG,
|
|
|
|
CMD_REQUEST,
|
|
|
|
CMD_REPLY,
|
|
|
|
CMD_ERROR
|
|
|
|
};
|
|
|
|
|
2015-11-12 12:59:26 +01:00
|
|
|
enum TabTypes {
|
|
|
|
TAB_INFO = 0,
|
|
|
|
TAB_CONSOLE = 1,
|
|
|
|
TAB_GRAPH = 2,
|
|
|
|
TAB_PEERS = 3
|
|
|
|
};
|
|
|
|
|
2012-04-09 21:07:25 +02:00
|
|
|
protected:
|
|
|
|
virtual bool eventFilter(QObject* obj, QEvent *event);
|
2014-11-10 16:41:57 +01:00
|
|
|
void keyPressEvent(QKeyEvent *);
|
2012-04-09 21:07:25 +02:00
|
|
|
|
2015-07-14 13:59:05 +02:00
|
|
|
private Q_SLOTS:
|
2012-04-09 21:07:25 +02:00
|
|
|
void on_lineEdit_returnPressed();
|
2012-05-09 17:12:05 +02:00
|
|
|
void on_tabWidget_currentChanged(int index);
|
2012-05-18 14:11:55 +02:00
|
|
|
/** open the debug.log from the current datadir */
|
2012-05-09 22:07:00 +02:00
|
|
|
void on_openDebugLogfileButton_clicked();
|
2013-08-22 18:09:32 +02:00
|
|
|
/** change the time range of the network traffic graph */
|
|
|
|
void on_sldGraphRange_valueChanged(int value);
|
|
|
|
/** update traffic statistics */
|
|
|
|
void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut);
|
2014-05-23 19:09:59 +02:00
|
|
|
void resizeEvent(QResizeEvent *event);
|
|
|
|
void showEvent(QShowEvent *event);
|
|
|
|
void hideEvent(QHideEvent *event);
|
2015-06-01 15:32:25 +02:00
|
|
|
/** Show custom context menu on Peers tab */
|
2015-06-20 20:55:21 +02:00
|
|
|
void showPeersTableContextMenu(const QPoint& point);
|
|
|
|
/** Show custom context menu on Bans tab */
|
|
|
|
void showBanTableContextMenu(const QPoint& point);
|
2015-06-20 21:48:10 +02:00
|
|
|
/** Hides ban table if no bans are present */
|
|
|
|
void showOrHideBanTableIfRequired();
|
2015-06-26 10:23:51 +02:00
|
|
|
/** clear the selected node */
|
|
|
|
void clearSelectedNode();
|
2012-05-09 17:12:05 +02:00
|
|
|
|
2015-07-14 13:59:05 +02:00
|
|
|
public Q_SLOTS:
|
2016-03-11 17:57:10 +01:00
|
|
|
void clear(bool clearHistory = true);
|
2016-01-22 18:00:36 +01:00
|
|
|
void fontBigger();
|
|
|
|
void fontSmaller();
|
|
|
|
void setFontSize(int newSize);
|
2015-10-22 13:33:58 +02:00
|
|
|
/** Append the message to the message widget */
|
2012-05-12 12:30:07 +02:00
|
|
|
void message(int category, const QString &message, bool html = false);
|
2012-04-09 21:07:25 +02:00
|
|
|
/** Set number of connections shown in the UI */
|
|
|
|
void setNumConnections(int count);
|
2013-03-26 03:07:06 +01:00
|
|
|
/** Set network state shown in the UI */
|
|
|
|
void setNetworkActive(bool networkActive);
|
2015-02-09 11:19:01 +01:00
|
|
|
/** Set number of blocks and last block date shown in the UI */
|
2016-04-28 16:18:45 +02:00
|
|
|
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers);
|
2015-11-09 11:45:07 +01:00
|
|
|
/** Set size (number of transactions and memory usage) of the mempool in the UI */
|
|
|
|
void setMempoolSize(long numberOfTxs, size_t dynUsage);
|
2012-04-09 21:07:25 +02:00
|
|
|
/** Go forward or back in history */
|
|
|
|
void browseHistory(int offset);
|
2012-05-14 18:17:12 +02:00
|
|
|
/** Scroll console view to end */
|
|
|
|
void scrollToEnd();
|
2014-05-23 19:09:59 +02:00
|
|
|
/** Handle selection of peer in peers list */
|
|
|
|
void peerSelected(const QItemSelection &selected, const QItemSelection &deselected);
|
2016-11-08 16:41:23 +01:00
|
|
|
/** Handle selection caching before update */
|
|
|
|
void peerLayoutAboutToChange();
|
2014-05-23 19:09:59 +02:00
|
|
|
/** Handle updated peer information */
|
|
|
|
void peerLayoutChanged();
|
2015-06-06 10:38:15 +02:00
|
|
|
/** Disconnect a selected node on the Peers tab */
|
2015-06-01 15:32:25 +02:00
|
|
|
void disconnectSelectedNode();
|
2015-06-19 13:24:34 +02:00
|
|
|
/** Ban a selected node on the Peers tab */
|
|
|
|
void banSelectedNode(int bantime);
|
2015-06-20 20:55:21 +02:00
|
|
|
/** Unban a selected node on the Bans tab */
|
|
|
|
void unbanSelectedNode();
|
2015-11-12 12:59:26 +01:00
|
|
|
/** set which tab has the focus (is visible) */
|
|
|
|
void setTabFocus(enum TabTypes tabType);
|
2013-11-08 08:13:08 +01:00
|
|
|
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_SIGNALS:
|
2012-04-09 21:07:25 +02:00
|
|
|
// For RPC command executor
|
|
|
|
void stopExecutor();
|
|
|
|
void cmdRequest(const QString &command);
|
|
|
|
|
|
|
|
private:
|
2013-08-22 18:09:32 +02:00
|
|
|
static QString FormatBytes(quint64 bytes);
|
2014-06-04 12:06:18 +02:00
|
|
|
void startExecutor();
|
2013-08-22 18:09:32 +02:00
|
|
|
void setTrafficGraphRange(int mins);
|
2014-06-04 12:06:18 +02:00
|
|
|
/** show detailed information on ui about selected node */
|
|
|
|
void updateNodeDetail(const CNodeCombinedStats *stats);
|
|
|
|
|
|
|
|
enum ColumnWidths
|
|
|
|
{
|
|
|
|
ADDRESS_COLUMN_WIDTH = 200,
|
2016-01-20 23:02:24 +01:00
|
|
|
SUBVERSION_COLUMN_WIDTH = 150,
|
2015-06-20 21:48:10 +02:00
|
|
|
PING_COLUMN_WIDTH = 80,
|
2015-06-26 14:55:52 +02:00
|
|
|
BANSUBNET_COLUMN_WIDTH = 200,
|
|
|
|
BANTIME_COLUMN_WIDTH = 250
|
2015-06-20 21:48:10 +02:00
|
|
|
|
2014-06-04 12:06:18 +02:00
|
|
|
};
|
2013-08-22 18:09:32 +02:00
|
|
|
|
2012-04-09 21:07:25 +02:00
|
|
|
Ui::RPCConsole *ui;
|
|
|
|
ClientModel *clientModel;
|
|
|
|
QStringList history;
|
|
|
|
int historyPtr;
|
2015-03-13 21:51:27 +01:00
|
|
|
QString cmdBeforeBrowsing;
|
2016-11-08 16:41:23 +01:00
|
|
|
QList<NodeId> cachedNodeids;
|
2015-07-28 15:20:14 +02:00
|
|
|
const PlatformStyle *platformStyle;
|
2015-08-28 16:46:20 +02:00
|
|
|
RPCTimerInterface *rpcTimerInterface;
|
2015-06-20 20:55:21 +02:00
|
|
|
QMenu *peersTableContextMenu;
|
|
|
|
QMenu *banTableContextMenu;
|
2016-01-22 18:00:36 +01:00
|
|
|
int consoleFontSize;
|
2016-02-27 04:57:12 +01:00
|
|
|
QCompleter *autoCompleter;
|
2016-11-18 16:35:14 +01:00
|
|
|
QThread thread;
|
2013-03-26 03:07:06 +01:00
|
|
|
|
|
|
|
/** Update UI with latest network info from model. */
|
|
|
|
void updateNetworkState();
|
2012-04-09 21:07:25 +02:00
|
|
|
};
|
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#endif // BITCOIN_QT_RPCCONSOLE_H
|