i2pd/qt/i2pd_qt/ClientTunnelPane.cpp

221 lines
11 KiB
C++
Raw Normal View History

2017-03-14 15:34:01 +03:00
#include "ClientTunnelPane.h"
2017-06-02 18:43:33 +03:00
#include "ClientContext.h"
#include "SignatureTypeComboboxFactory.h"
2017-06-02 17:59:13 +03:00
#include "QVBoxLayout"
2017-03-14 15:34:01 +03:00
ClientTunnelPane::ClientTunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener, ClientTunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_, MainWindow* mainWindow):
TunnelPane(tunnelsPageUpdateListener, tunconf, wrongInputPane_, wrongInputLabel_, mainWindow) {}
2017-03-14 15:34:01 +03:00
2017-04-02 22:39:24 +03:00
void ClientTunnelPane::setGroupBoxTitle(const QString & title) {
clientTunnelNameGroupBox->setTitle(title);
}
2017-06-02 17:59:13 +03:00
void ClientTunnelPane::deleteClientTunnelForm() {
2017-09-08 10:59:19 +03:00
TunnelPane::deleteTunnelForm();
2017-06-02 17:59:13 +03:00
delete clientTunnelNameGroupBox;
2017-03-14 15:34:01 +03:00
clientTunnelNameGroupBox=nullptr;
2017-06-02 17:59:13 +03:00
//gridLayoutWidget_2->deleteLater();
//gridLayoutWidget_2=nullptr;
2017-04-02 22:39:24 +03:00
}
2017-06-02 17:59:13 +03:00
int ClientTunnelPane::appendClientTunnelForm(
ClientTunnelConfig* tunnelConfig, QWidget *tunnelsFormGridLayoutWidget, int tunnelsRow, int height) {
2017-04-02 22:39:24 +03:00
ClientTunnelPane& ui = *this;
clientTunnelNameGroupBox = new QGroupBox(tunnelsFormGridLayoutWidget);
clientTunnelNameGroupBox->setObjectName(QStringLiteral("clientTunnelNameGroupBox"));
//tunnel
2017-06-02 17:59:13 +03:00
gridLayoutWidget_2 = new QWidget(clientTunnelNameGroupBox);
2017-04-02 22:39:24 +03:00
QComboBox *tunnelTypeComboBox = new QComboBox(gridLayoutWidget_2);
tunnelTypeComboBox->setObjectName(QStringLiteral("tunnelTypeComboBox"));
tunnelTypeComboBox->addItem("Client", i2p::client::I2P_TUNNELS_SECTION_TYPE_CLIENT);
tunnelTypeComboBox->addItem("Socks", i2p::client::I2P_TUNNELS_SECTION_TYPE_SOCKS);
tunnelTypeComboBox->addItem("Websocks", i2p::client::I2P_TUNNELS_SECTION_TYPE_WEBSOCKS);
tunnelTypeComboBox->addItem("HTTP Proxy", i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTPPROXY);
tunnelTypeComboBox->addItem("UDP Client", i2p::client::I2P_TUNNELS_SECTION_TYPE_UDPCLIENT);
2017-06-02 17:59:13 +03:00
int h=(7+4)*60;
gridLayoutWidget_2->setGeometry(QRect(0, 0, 561, h));
clientTunnelNameGroupBox->setGeometry(QRect(0, 0, 561, h));
2017-04-02 22:39:24 +03:00
{
const QString& type = tunnelConfig->getType();
int index=0;
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_CLIENT)tunnelTypeComboBox->setCurrentIndex(index);
++index;
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_SOCKS)tunnelTypeComboBox->setCurrentIndex(index);
++index;
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_WEBSOCKS)tunnelTypeComboBox->setCurrentIndex(index);
++index;
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTPPROXY)tunnelTypeComboBox->setCurrentIndex(index);
++index;
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_UDPCLIENT)tunnelTypeComboBox->setCurrentIndex(index);
++index;
}
2017-06-02 17:59:13 +03:00
setupTunnelPane(tunnelConfig,
clientTunnelNameGroupBox,
gridLayoutWidget_2, tunnelTypeComboBox,
tunnelsFormGridLayoutWidget, tunnelsRow, height, h);
//this->tunnelGroupBox->setGeometry(QRect(0, tunnelsFormGridLayoutWidget->height()+10, 561, (7+5)*40+10));
2017-04-02 22:39:24 +03:00
/*
std::string destination;
2017-03-14 15:34:01 +03:00
*/
2017-04-02 22:39:24 +03:00
//host
ui.horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.destinationLabel = new QLabel(gridLayoutWidget_2);
destinationLabel->setObjectName(QStringLiteral("destinationLabel"));
horizontalLayout_2->addWidget(destinationLabel);
ui.destinationLineEdit = new QLineEdit(gridLayoutWidget_2);
destinationLineEdit->setObjectName(QStringLiteral("destinationLineEdit"));
destinationLineEdit->setText(tunnelConfig->getdest().c_str());
2017-06-02 17:59:13 +03:00
QObject::connect(destinationLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-04-02 22:39:24 +03:00
horizontalLayout_2->addWidget(destinationLineEdit);
ui.destinationHorizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(destinationHorizontalSpacer);
2017-06-02 17:59:13 +03:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-04-02 22:39:24 +03:00
/*
* int port;
*/
int gridIndex = 2;
{
int port = tunnelConfig->getport();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.portLabel = new QLabel(gridLayoutWidget_2);
portLabel->setObjectName(QStringLiteral("portLabel"));
horizontalLayout_2->addWidget(portLabel);
ui.portLineEdit = new QLineEdit(gridLayoutWidget_2);
portLineEdit->setObjectName(QStringLiteral("portLineEdit"));
portLineEdit->setText(QString::number(port));
portLineEdit->setMaximumWidth(80);
2017-06-02 17:59:13 +03:00
QObject::connect(portLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-04-02 22:39:24 +03:00
horizontalLayout_2->addWidget(portLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 17:59:13 +03:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-04-02 22:39:24 +03:00
}
/*
* std::string keys;
*/
{
std::string keys = tunnelConfig->getkeys();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.keysLabel = new QLabel(gridLayoutWidget_2);
keysLabel->setObjectName(QStringLiteral("keysLabel"));
horizontalLayout_2->addWidget(keysLabel);
ui.keysLineEdit = new QLineEdit(gridLayoutWidget_2);
keysLineEdit->setObjectName(QStringLiteral("keysLineEdit"));
keysLineEdit->setText(keys.c_str());
2017-06-02 17:59:13 +03:00
QObject::connect(keysLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-04-02 22:39:24 +03:00
horizontalLayout_2->addWidget(keysLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 17:59:13 +03:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-04-02 22:39:24 +03:00
}
/*
* std::string address;
*/
{
std::string address = tunnelConfig->getaddress();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.addressLabel = new QLabel(gridLayoutWidget_2);
addressLabel->setObjectName(QStringLiteral("addressLabel"));
horizontalLayout_2->addWidget(addressLabel);
ui.addressLineEdit = new QLineEdit(gridLayoutWidget_2);
addressLineEdit->setObjectName(QStringLiteral("addressLineEdit"));
addressLineEdit->setText(address.c_str());
2017-06-02 17:59:13 +03:00
QObject::connect(addressLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-04-02 22:39:24 +03:00
horizontalLayout_2->addWidget(addressLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 17:59:13 +03:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-04-02 22:39:24 +03:00
}
/*
int destinationPort;
i2p::data::SigningKeyType sigType;
*/
{
int destinationPort = tunnelConfig->getdestinationPort();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.destinationPortLabel = new QLabel(gridLayoutWidget_2);
destinationPortLabel->setObjectName(QStringLiteral("destinationPortLabel"));
horizontalLayout_2->addWidget(destinationPortLabel);
ui.destinationPortLineEdit = new QLineEdit(gridLayoutWidget_2);
destinationPortLineEdit->setObjectName(QStringLiteral("destinationPortLineEdit"));
destinationPortLineEdit->setText(QString::number(destinationPort));
destinationPortLineEdit->setMaximumWidth(80);
2017-06-02 17:59:13 +03:00
QObject::connect(destinationPortLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-04-02 22:39:24 +03:00
horizontalLayout_2->addWidget(destinationPortLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 17:59:13 +03:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-04-02 22:39:24 +03:00
}
2020-10-07 18:16:06 +03:00
{
int cryptoType = tunnelConfig->getcryptoType();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
ui.cryptoTypeLabel = new QLabel(gridLayoutWidget_2);
cryptoTypeLabel->setObjectName(QStringLiteral("cryptoTypeLabel"));
horizontalLayout_2->addWidget(cryptoTypeLabel);
ui.cryptoTypeLineEdit = new QLineEdit(gridLayoutWidget_2);
cryptoTypeLineEdit->setObjectName(QStringLiteral("cryptoTypeLineEdit"));
cryptoTypeLineEdit->setText(QString::number(cryptoType));
cryptoTypeLineEdit->setMaximumWidth(80);
QObject::connect(cryptoTypeLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
horizontalLayout_2->addWidget(cryptoTypeLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
tunnelGridLayout->addLayout(horizontalLayout_2);
}
2017-04-02 22:39:24 +03:00
{
i2p::data::SigningKeyType sigType = tunnelConfig->getsigType();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.sigTypeLabel = new QLabel(gridLayoutWidget_2);
sigTypeLabel->setObjectName(QStringLiteral("sigTypeLabel"));
horizontalLayout_2->addWidget(sigTypeLabel);
ui.sigTypeComboBox = SignatureTypeComboBoxFactory::createSignatureTypeComboBox(gridLayoutWidget_2, sigType);
sigTypeComboBox->setObjectName(QStringLiteral("sigTypeComboBox"));
2017-06-02 17:59:13 +03:00
QObject::connect(sigTypeComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(updated()));
horizontalLayout_2->addWidget(sigTypeComboBox);
QPushButton * lockButton2 = new QPushButton(gridLayoutWidget_2);
horizontalLayout_2->addWidget(lockButton2);
widgetlocks.add(new widgetlock(sigTypeComboBox, lockButton2));
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 17:59:13 +03:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-04-02 22:39:24 +03:00
}
{
I2CPParameters& i2cpParameters = tunnelConfig->getI2cpParameters();
appendControlsForI2CPParameters(i2cpParameters, gridIndex);
}
retranslateClientTunnelForm(ui);
tunnelGridLayout->invalidate();
2017-06-02 17:59:13 +03:00
return h;
2017-03-14 15:34:01 +03:00
}
ServerTunnelPane* ClientTunnelPane::asServerTunnelPane(){return nullptr;}
ClientTunnelPane* ClientTunnelPane::asClientTunnelPane(){return this;}