i2pd/qt/i2pd_qt/ServerTunnelPane.cpp

262 lines
14 KiB
C++
Raw Normal View History

2017-03-14 12:34:01 +00:00
#include "ServerTunnelPane.h"
2017-06-02 15:43:33 +00:00
#include "ClientContext.h"
#include "SignatureTypeComboboxFactory.h"
2017-03-14 12:34:01 +00:00
ServerTunnelPane::ServerTunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener, ServerTunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_, MainWindow* mainWindow):
TunnelPane(tunnelsPageUpdateListener, tunconf, wrongInputPane_, wrongInputLabel_, mainWindow) {}
2017-03-14 12:34:01 +00:00
void ServerTunnelPane::setGroupBoxTitle(const QString & title) {
serverTunnelNameGroupBox->setTitle(title);
}
2017-06-02 14:59:13 +00:00
int ServerTunnelPane::appendServerTunnelForm(
ServerTunnelConfig* tunnelConfig, QWidget *tunnelsFormGridLayoutWidget, int tunnelsRow, int height) {
2017-03-14 12:34:01 +00:00
ServerTunnelPane& ui = *this;
serverTunnelNameGroupBox = new QGroupBox(tunnelsFormGridLayoutWidget);
serverTunnelNameGroupBox->setObjectName(QStringLiteral("serverTunnelNameGroupBox"));
//tunnel
2017-06-02 14:59:13 +00:00
gridLayoutWidget_2 = new QWidget(serverTunnelNameGroupBox);
2017-03-14 12:34:01 +00:00
QComboBox *tunnelTypeComboBox = new QComboBox(gridLayoutWidget_2);
tunnelTypeComboBox->setObjectName(QStringLiteral("tunnelTypeComboBox"));
tunnelTypeComboBox->addItem("Server", i2p::client::I2P_TUNNELS_SECTION_TYPE_SERVER);
tunnelTypeComboBox->addItem("HTTP", i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP);
tunnelTypeComboBox->addItem("IRC", i2p::client::I2P_TUNNELS_SECTION_TYPE_IRC);
tunnelTypeComboBox->addItem("UDP Server", i2p::client::I2P_TUNNELS_SECTION_TYPE_UDPSERVER);
2017-06-02 14:59:13 +00:00
int h=19*60;
gridLayoutWidget_2->setGeometry(QRect(0, 0, 561, h));
serverTunnelNameGroupBox->setGeometry(QRect(0, 0, 561, h));
2017-03-14 12:34:01 +00:00
{
const QString& type = tunnelConfig->getType();
int index=0;
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_SERVER)tunnelTypeComboBox->setCurrentIndex(index);
++index;
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP)tunnelTypeComboBox->setCurrentIndex(index);
++index;
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_IRC)tunnelTypeComboBox->setCurrentIndex(index);
++index;
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_UDPSERVER)tunnelTypeComboBox->setCurrentIndex(index);
++index;
}
2017-06-02 14:59:13 +00:00
setupTunnelPane(tunnelConfig,
serverTunnelNameGroupBox,
gridLayoutWidget_2, tunnelTypeComboBox,
tunnelsFormGridLayoutWidget, tunnelsRow, height, h);
//this->tunnelGroupBox->setGeometry(QRect(0, tunnelsFormGridLayoutWidget->height()+10, 561, 18*40+10));
2017-03-14 12:34:01 +00:00
//host
ui.horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.hostLabel = new QLabel(gridLayoutWidget_2);
hostLabel->setObjectName(QStringLiteral("hostLabel"));
horizontalLayout_2->addWidget(hostLabel);
ui.hostLineEdit = new QLineEdit(gridLayoutWidget_2);
hostLineEdit->setObjectName(QStringLiteral("hostLineEdit"));
hostLineEdit->setText(tunnelConfig->gethost().c_str());
2017-06-02 14:59:13 +00:00
QObject::connect(hostLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-03-14 12:34:01 +00:00
horizontalLayout_2->addWidget(hostLineEdit);
ui.hostHorizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(hostHorizontalSpacer);
2017-06-02 14:59:13 +00:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-03-14 12:34:01 +00:00
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 14:59:13 +00:00
QObject::connect(portLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-03-14 12:34:01 +00:00
horizontalLayout_2->addWidget(portLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 14:59:13 +00:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-03-14 12:34:01 +00:00
}
{
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 14:59:13 +00:00
QObject::connect(keysLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-03-14 12:34:01 +00:00
horizontalLayout_2->addWidget(keysLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 14:59:13 +00:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-03-14 12:34:01 +00:00
}
{
int inPort = tunnelConfig->getinPort();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.inPortLabel = new QLabel(gridLayoutWidget_2);
inPortLabel->setObjectName(QStringLiteral("inPortLabel"));
horizontalLayout_2->addWidget(inPortLabel);
ui.inPortLineEdit = new QLineEdit(gridLayoutWidget_2);
inPortLineEdit->setObjectName(QStringLiteral("inPortLineEdit"));
inPortLineEdit->setText(QString::number(inPort));
inPortLineEdit->setMaximumWidth(80);
2017-06-02 14:59:13 +00:00
QObject::connect(inPortLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-03-14 12:34:01 +00:00
horizontalLayout_2->addWidget(inPortLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 14:59:13 +00:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-03-14 12:34:01 +00:00
}
{
std::string accessList = tunnelConfig->getaccessList();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.accessListLabel = new QLabel(gridLayoutWidget_2);
accessListLabel->setObjectName(QStringLiteral("accessListLabel"));
horizontalLayout_2->addWidget(accessListLabel);
ui.accessListLineEdit = new QLineEdit(gridLayoutWidget_2);
accessListLineEdit->setObjectName(QStringLiteral("accessListLineEdit"));
accessListLineEdit->setText(accessList.c_str());
2017-06-02 14:59:13 +00:00
QObject::connect(accessListLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-03-14 12:34:01 +00:00
horizontalLayout_2->addWidget(accessListLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 14:59:13 +00:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-03-14 12:34:01 +00:00
}
{
std::string hostOverride = tunnelConfig->gethostOverride();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.hostOverrideLabel = new QLabel(gridLayoutWidget_2);
hostOverrideLabel->setObjectName(QStringLiteral("hostOverrideLabel"));
horizontalLayout_2->addWidget(hostOverrideLabel);
ui.hostOverrideLineEdit = new QLineEdit(gridLayoutWidget_2);
hostOverrideLineEdit->setObjectName(QStringLiteral("hostOverrideLineEdit"));
hostOverrideLineEdit->setText(hostOverride.c_str());
2017-06-02 14:59:13 +00:00
QObject::connect(hostOverrideLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-03-14 12:34:01 +00:00
horizontalLayout_2->addWidget(hostOverrideLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 14:59:13 +00:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-03-14 12:34:01 +00:00
}
{
std::string webIRCPass = tunnelConfig->getwebircpass();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.webIRCPassLabel = new QLabel(gridLayoutWidget_2);
webIRCPassLabel->setObjectName(QStringLiteral("webIRCPassLabel"));
horizontalLayout_2->addWidget(webIRCPassLabel);
ui.webIRCPassLineEdit = new QLineEdit(gridLayoutWidget_2);
webIRCPassLineEdit->setObjectName(QStringLiteral("webIRCPassLineEdit"));
webIRCPassLineEdit->setText(webIRCPass.c_str());
2017-06-02 14:59:13 +00:00
QObject::connect(webIRCPassLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-03-14 12:34:01 +00:00
horizontalLayout_2->addWidget(webIRCPassLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 14:59:13 +00:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-03-14 12:34:01 +00:00
}
{
bool gzip = tunnelConfig->getgzip();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.gzipCheckBox = new QCheckBox(gridLayoutWidget_2);
gzipCheckBox->setObjectName(QStringLiteral("gzipCheckBox"));
gzipCheckBox->setChecked(gzip);
2017-06-02 14:59:13 +00:00
QObject::connect(gzipCheckBox, SIGNAL(stateChanged(int)),
this, SLOT(updated()));
2017-03-14 12:34:01 +00:00
horizontalLayout_2->addWidget(gzipCheckBox);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 14:59:13 +00:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-03-14 12:34:01 +00: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 14:59:13 +00: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 14:59:13 +00:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-03-14 12:34:01 +00:00
}
{
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 14:59:13 +00:00
QObject::connect(addressLineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(updated()));
2017-03-14 12:34:01 +00:00
horizontalLayout_2->addWidget(addressLineEdit);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 14:59:13 +00:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-03-14 12:34:01 +00:00
}
{
bool isUniqueLocal = tunnelConfig->getisUniqueLocal();
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
ui.isUniqueLocalCheckBox = new QCheckBox(gridLayoutWidget_2);
isUniqueLocalCheckBox->setObjectName(QStringLiteral("isUniqueLocalCheckBox"));
isUniqueLocalCheckBox->setChecked(isUniqueLocal);
2017-06-02 14:59:13 +00:00
QObject::connect(gzipCheckBox, SIGNAL(stateChanged(int)),
this, SLOT(updated()));
2017-03-14 12:34:01 +00:00
horizontalLayout_2->addWidget(isUniqueLocalCheckBox);
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
2017-06-02 14:59:13 +00:00
tunnelGridLayout->addLayout(horizontalLayout_2);
2017-03-14 12:34:01 +00:00
}
{
I2CPParameters& i2cpParameters = tunnelConfig->getI2cpParameters();
appendControlsForI2CPParameters(i2cpParameters, gridIndex);
}
retranslateServerTunnelForm(ui);
tunnelGridLayout->invalidate();
2017-03-14 12:34:01 +00:00
2017-06-02 14:59:13 +00:00
return h;
}
2017-03-14 12:34:01 +00:00
2017-06-02 14:59:13 +00:00
void ServerTunnelPane::deleteServerTunnelForm() {
2017-09-08 07:59:19 +00:00
TunnelPane::deleteTunnelForm();
2017-06-02 14:59:13 +00:00
delete serverTunnelNameGroupBox;//->deleteLater();
serverTunnelNameGroupBox=nullptr;
2017-03-14 12:34:01 +00:00
2017-06-02 14:59:13 +00:00
//gridLayoutWidget_2->deleteLater();
//gridLayoutWidget_2=nullptr;
2017-03-14 12:34:01 +00:00
}
ServerTunnelPane* ServerTunnelPane::asServerTunnelPane(){return this;}
ClientTunnelPane* ServerTunnelPane::asClientTunnelPane(){return nullptr;}