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