aboutsummaryrefslogtreecommitdiff
path: root/src/qt/rpcconsole.cpp
diff options
context:
space:
mode:
authorShafil Alam <[email protected]>2021-04-16 14:24:27 -0400
committerShafil Alam <[email protected]>2021-06-05 15:23:01 -0400
commite0d1683bff37e1b845980ab0b00401b82a4c779d (patch)
treed9bd14cc0e23a9c40fac59038d0afe6321b37a37 /src/qt/rpcconsole.cpp
parentMerge pull request #1774 from patricklodder/1.14.3-readme (diff)
downloaddiscoin-e0d1683bff37e1b845980ab0b00401b82a4c779d.tar.xz
discoin-e0d1683bff37e1b845980ab0b00401b82a4c779d.zip
Add a form dialog for adding peers
Fixed tabIndex and width in debugwindow.ui Added Qt UI files for each dialog Added Qt UI files Added separate thread for peer dialogs to run RPC commands Fixed tabIndex Remove unneeded includes Fixed error Replaced RPCExecutor with g_connman Replaced RPCExecutor with g_connman Added two input fields for peer address and port Remove peerThread Validate IP addresses Remove Peer now uses selected IP address in peerWidget Interpret RPC response Remove redundant include Use a regular expression to validate IPs Disconnect node if it has been discovered Use port based on current chain Change peerAddress -> peerPort Allowed DNS names to be entered Update src/qt/peerdialog.cpp Co-authored-by: Ross Nicoll <[email protected]> Fix typo Co-authored-by: Ross Nicoll <[email protected]> Use LookupHost to check address Co-authored-by: Ross Nicoll <[email protected]> Fix syntax typo
Diffstat (limited to 'src/qt/rpcconsole.cpp')
-rw-r--r--src/qt/rpcconsole.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 77e5e03e6..075da382c 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -2,11 +2,13 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include "bitcoingui.h"
#if defined(HAVE_CONFIG_H)
#include "config/bitcoin-config.h"
#endif
#include "rpcconsole.h"
+#include "peerdialog.h"
#include "ui_debugwindow.h"
#include "bantablemodel.h"
@@ -14,6 +16,7 @@
#include "guiutil.h"
#include "platformstyle.h"
#include "bantablemodel.h"
+#include "utilitydialog.h"
#include "chainparams.h"
#include "netbase.h"
@@ -39,6 +42,7 @@
#include <QTime>
#include <QTimer>
#include <QStringList>
+#include <QThread>
#if QT_VERSION < 0x050000
#include <QUrl>
@@ -441,6 +445,15 @@ RPCConsole::RPCConsole(const PlatformStyle *_platformStyle, QWidget *parent) :
connect(ui->fontSmallerButton, SIGNAL(clicked()), this, SLOT(fontSmaller()));
connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, SLOT(clear()));
+ // Allow user to add new peer
+ connect(ui->peerAdd, SIGNAL(clicked()), this, SLOT(on_addPeer_clicked()));
+
+ // Allow user to remove peer
+ connect(ui->peerRemove, SIGNAL(clicked()), this, SLOT(on_removePeer_clicked()));
+
+ // Allow user to test peer
+ connect(ui->peerTest, SIGNAL(clicked()), this, SLOT(on_testPeer_clicked()));
+
// set library version labels
#ifdef ENABLE_WALLET
ui->berkeleyDBVersion->setText(DbEnv::version(0, 0, 0));
@@ -901,6 +914,54 @@ void RPCConsole::on_openDebugLogfileButton_clicked()
GUIUtil::openDebugLogfile();
}
+void RPCConsole::on_addPeer_clicked()
+{
+
+ QWidget *win = new AddPeerDialog(0);
+
+ win->showNormal();
+ win->show();
+ win->raise();
+ win->activateWindow();
+
+ /** Center window */
+ const QPoint global = ui->tabWidget->mapToGlobal(ui->tabWidget->rect().center());
+ win->move(global.x() - win->width() / 2, global.y() - win->height() / 2);
+}
+
+void RPCConsole::on_removePeer_clicked()
+{
+ QList<QModelIndex> ips = GUIUtil::getEntryData(ui->peerWidget, PeerTableModel::Address);
+
+ if(ips.size() != 0)
+ {
+ QString address = ips[0].data().toString();
+
+ if(QMessageBox::Yes == QMessageBox::question(this, "Remove Peer", "Are you sure you want to remove the peer: " + address + "?", QMessageBox::Yes | QMessageBox::No))
+ {
+ QMessageBox::information(this, "Remove Peer", PeerTools::ManagePeer("remove", address), QMessageBox::Ok, QMessageBox::Ok);
+ }
+
+ } else
+ {
+ QMessageBox::information(this, "Remove Peer", "No peer was selected.", QMessageBox::Ok, QMessageBox::Ok);
+ }
+}
+
+void RPCConsole::on_testPeer_clicked()
+{
+ QWidget *win = new TestPeerDialog(0);
+
+ win->showNormal();
+ win->show();
+ win->raise();
+ win->activateWindow();
+
+ /** Center window */
+ const QPoint global = ui->tabWidget->mapToGlobal(ui->tabWidget->rect().center());
+ win->move(global.x() - win->width() / 2, global.y() - win->height() / 2);
+}
+
void RPCConsole::scrollToEnd()
{
QScrollBar *scrollbar = ui->messagesWidget->verticalScrollBar();