2017-03-14 12:34:01 +00:00
|
|
|
#ifndef CLIENTTUNNELPANE_H
|
|
|
|
#define CLIENTTUNNELPANE_H
|
|
|
|
|
|
|
|
#include "QGridLayout"
|
2017-06-02 14:59:13 +00:00
|
|
|
#include "QVBoxLayout"
|
2017-03-14 12:34:01 +00:00
|
|
|
|
|
|
|
#include "TunnelPane.h"
|
|
|
|
|
2017-04-02 19:39:24 +00:00
|
|
|
class ClientTunnelConfig;
|
|
|
|
|
2017-03-14 12:34:01 +00:00
|
|
|
class ServerTunnelPane;
|
|
|
|
class TunnelPane;
|
|
|
|
|
|
|
|
class ClientTunnelPane : public TunnelPane {
|
2017-04-02 19:39:24 +00:00
|
|
|
Q_OBJECT
|
2017-03-14 12:34:01 +00:00
|
|
|
public:
|
2017-09-08 10:58:04 +00:00
|
|
|
ClientTunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener, ClientTunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_, MainWindow* mainWindow);
|
2017-04-02 19:39:24 +00:00
|
|
|
virtual ~ClientTunnelPane(){}
|
2017-03-14 12:34:01 +00:00
|
|
|
virtual ServerTunnelPane* asServerTunnelPane();
|
|
|
|
virtual ClientTunnelPane* asClientTunnelPane();
|
2017-06-02 14:59:13 +00:00
|
|
|
int appendClientTunnelForm(ClientTunnelConfig* tunnelConfig, QWidget *tunnelsFormGridLayoutWidget,
|
|
|
|
int tunnelsRow, int height);
|
|
|
|
void deleteClientTunnelForm();
|
2017-04-02 19:39:24 +00:00
|
|
|
private:
|
|
|
|
QGroupBox *clientTunnelNameGroupBox;
|
|
|
|
|
|
|
|
//tunnel
|
|
|
|
QWidget *gridLayoutWidget_2;
|
|
|
|
|
|
|
|
//destination
|
|
|
|
QHBoxLayout *horizontalLayout_2;
|
|
|
|
QLabel *destinationLabel;
|
|
|
|
QLineEdit *destinationLineEdit;
|
|
|
|
QSpacerItem *destinationHorizontalSpacer;
|
|
|
|
|
|
|
|
//port
|
|
|
|
QLabel * portLabel;
|
|
|
|
QLineEdit * portLineEdit;
|
|
|
|
|
|
|
|
//keys
|
|
|
|
QLabel * keysLabel;
|
|
|
|
QLineEdit * keysLineEdit;
|
|
|
|
|
|
|
|
//address
|
|
|
|
QLabel * addressLabel;
|
|
|
|
QLineEdit * addressLineEdit;
|
|
|
|
|
|
|
|
//destinationPort
|
|
|
|
QLabel * destinationPortLabel;
|
|
|
|
QLineEdit * destinationPortLineEdit;
|
|
|
|
|
2017-04-03 13:45:56 +00:00
|
|
|
//sigType
|
|
|
|
QLabel * sigTypeLabel;
|
|
|
|
QComboBox * sigTypeComboBox;
|
|
|
|
|
2020-10-07 15:16:06 +00:00
|
|
|
//cryptoType
|
|
|
|
QLabel * cryptoTypeLabel;
|
|
|
|
QLineEdit * cryptoTypeLineEdit;
|
|
|
|
|
2017-03-14 12:34:01 +00:00
|
|
|
protected slots:
|
2017-04-02 19:39:24 +00:00
|
|
|
virtual void setGroupBoxTitle(const QString & title);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void retranslateClientTunnelForm(ClientTunnelPane& /*ui*/) {
|
2017-04-03 13:45:56 +00:00
|
|
|
typeLabel->setText(QApplication::translate("cltTunForm", "Client tunnel type:", 0));
|
|
|
|
destinationLabel->setText(QApplication::translate("cltTunForm", "Destination:", 0));
|
|
|
|
portLabel->setText(QApplication::translate("cltTunForm", "Port:", 0));
|
2020-10-07 15:16:06 +00:00
|
|
|
cryptoTypeLabel->setText(QApplication::translate("cltTunForm", "Crypto type:", 0));
|
2017-04-03 13:45:56 +00:00
|
|
|
keysLabel->setText(QApplication::translate("cltTunForm", "Keys:", 0));
|
|
|
|
destinationPortLabel->setText(QApplication::translate("cltTunForm", "Destination port:", 0));
|
|
|
|
addressLabel->setText(QApplication::translate("cltTunForm", "Address:", 0));
|
|
|
|
sigTypeLabel->setText(QApplication::translate("cltTunForm", "Signature type:", 0));
|
2017-04-02 19:39:24 +00:00
|
|
|
}
|
2017-06-02 14:59:13 +00:00
|
|
|
protected:
|
|
|
|
virtual bool applyDataFromUIToTunnelConfig() {
|
2017-09-08 09:57:15 +00:00
|
|
|
QString cannotSaveSettings = QApplication::tr("Cannot save settings.");
|
2017-06-02 14:59:13 +00:00
|
|
|
bool ok=TunnelPane::applyDataFromUIToTunnelConfig();
|
|
|
|
if(!ok)return false;
|
|
|
|
ClientTunnelConfig* ctc=tunnelConfig->asClientTunnelConfig();
|
|
|
|
assert(ctc!=nullptr);
|
2017-04-02 19:39:24 +00:00
|
|
|
|
2017-06-02 14:59:13 +00:00
|
|
|
//destination
|
|
|
|
ctc->setdest(destinationLineEdit->text().toStdString());
|
|
|
|
|
|
|
|
auto portStr=portLineEdit->text();
|
|
|
|
int portInt=portStr.toInt(&ok);
|
2017-09-08 09:57:15 +00:00
|
|
|
|
|
|
|
if(!ok){
|
|
|
|
highlightWrongInput(QApplication::tr("Bad port, must be int.")+" "+cannotSaveSettings,portLineEdit);
|
|
|
|
return false;
|
|
|
|
}
|
2017-06-02 14:59:13 +00:00
|
|
|
ctc->setport(portInt);
|
|
|
|
|
2020-10-07 15:16:06 +00:00
|
|
|
auto cryptoTypeStr=cryptoTypeLineEdit->text();
|
|
|
|
int cryptoTypeInt=cryptoTypeStr.toInt(&ok);
|
|
|
|
if(!ok){
|
|
|
|
highlightWrongInput(QApplication::tr("Bad crypto type, must be int.")+" "+cannotSaveSettings,cryptoTypeLineEdit);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ctc->setcryptoType(cryptoTypeInt);
|
|
|
|
|
2017-06-02 14:59:13 +00:00
|
|
|
ctc->setkeys(keysLineEdit->text().toStdString());
|
|
|
|
|
|
|
|
ctc->setaddress(addressLineEdit->text().toStdString());
|
|
|
|
|
2017-08-27 04:39:00 +00:00
|
|
|
auto dportStr=destinationPortLineEdit->text();
|
2017-06-02 14:59:13 +00:00
|
|
|
int dportInt=dportStr.toInt(&ok);
|
2017-09-08 09:57:15 +00:00
|
|
|
if(!ok){
|
|
|
|
highlightWrongInput(QApplication::tr("Bad destinationPort, must be int.")+" "+cannotSaveSettings,destinationPortLineEdit);
|
|
|
|
return false;
|
|
|
|
}
|
2017-06-02 14:59:13 +00:00
|
|
|
ctc->setdestinationPort(dportInt);
|
|
|
|
|
|
|
|
ctc->setsigType(readSigTypeComboboxUI(sigTypeComboBox));
|
2017-07-28 01:21:25 +00:00
|
|
|
return true;
|
2017-06-02 14:59:13 +00:00
|
|
|
}
|
2017-03-14 12:34:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CLIENTTUNNELPANE_H
|