mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 11:04:00 +01:00
some work + fixed red errors on malformed input
This commit is contained in:
parent
1efc2a9b5d
commit
96cb663fa8
|
@ -3,8 +3,8 @@
|
||||||
#include "SignatureTypeComboboxFactory.h"
|
#include "SignatureTypeComboboxFactory.h"
|
||||||
#include "QVBoxLayout"
|
#include "QVBoxLayout"
|
||||||
|
|
||||||
ClientTunnelPane::ClientTunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener, ClientTunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_):
|
ClientTunnelPane::ClientTunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener, ClientTunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_, MainWindow* mainWindow):
|
||||||
TunnelPane(tunnelsPageUpdateListener, tunconf, wrongInputPane_, wrongInputLabel_) {}
|
TunnelPane(tunnelsPageUpdateListener, tunconf, wrongInputPane_, wrongInputLabel_, mainWindow) {}
|
||||||
|
|
||||||
void ClientTunnelPane::setGroupBoxTitle(const QString & title) {
|
void ClientTunnelPane::setGroupBoxTitle(const QString & title) {
|
||||||
clientTunnelNameGroupBox->setTitle(title);
|
clientTunnelNameGroupBox->setTitle(title);
|
||||||
|
|
|
@ -14,7 +14,7 @@ class TunnelPane;
|
||||||
class ClientTunnelPane : public TunnelPane {
|
class ClientTunnelPane : public TunnelPane {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ClientTunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener, ClientTunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_);
|
ClientTunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener, ClientTunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_, MainWindow* mainWindow);
|
||||||
virtual ~ClientTunnelPane(){}
|
virtual ~ClientTunnelPane(){}
|
||||||
virtual ServerTunnelPane* asServerTunnelPane();
|
virtual ServerTunnelPane* asServerTunnelPane();
|
||||||
virtual ClientTunnelPane* asClientTunnelPane();
|
virtual ClientTunnelPane* asClientTunnelPane();
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include "ClientContext.h"
|
#include "ClientContext.h"
|
||||||
#include "SignatureTypeComboboxFactory.h"
|
#include "SignatureTypeComboboxFactory.h"
|
||||||
|
|
||||||
ServerTunnelPane::ServerTunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener, ServerTunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_):
|
ServerTunnelPane::ServerTunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener, ServerTunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_, MainWindow* mainWindow):
|
||||||
TunnelPane(tunnelsPageUpdateListener, tunconf, wrongInputPane_, wrongInputLabel_) {}
|
TunnelPane(tunnelsPageUpdateListener, tunconf, wrongInputPane_, wrongInputLabel_, mainWindow) {}
|
||||||
|
|
||||||
void ServerTunnelPane::setGroupBoxTitle(const QString & title) {
|
void ServerTunnelPane::setGroupBoxTitle(const QString & title) {
|
||||||
serverTunnelNameGroupBox->setTitle(title);
|
serverTunnelNameGroupBox->setTitle(title);
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
#ifndef SERVERTUNNELPANE_H
|
#ifndef SERVERTUNNELPANE_H
|
||||||
#define SERVERTUNNELPANE_H
|
#define SERVERTUNNELPANE_H
|
||||||
|
|
||||||
#include "TunnelPane.h"
|
|
||||||
#include "TunnelsPageUpdateListener.h"
|
|
||||||
|
|
||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
#include <QtWidgets/QAction>
|
#include <QtWidgets/QAction>
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
|
@ -23,6 +20,9 @@
|
||||||
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
|
|
||||||
|
#include "TunnelPane.h"
|
||||||
|
#include "TunnelsPageUpdateListener.h"
|
||||||
|
|
||||||
class ServerTunnelConfig;
|
class ServerTunnelConfig;
|
||||||
|
|
||||||
class ClientTunnelPane;
|
class ClientTunnelPane;
|
||||||
|
@ -31,7 +31,7 @@ class ServerTunnelPane : public TunnelPane {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ServerTunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener, ServerTunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_);
|
ServerTunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener, ServerTunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_, MainWindow* mainWindow);
|
||||||
virtual ~ServerTunnelPane(){}
|
virtual ~ServerTunnelPane(){}
|
||||||
|
|
||||||
virtual ServerTunnelPane* asServerTunnelPane();
|
virtual ServerTunnelPane* asServerTunnelPane();
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
#include "TunnelPane.h"
|
#include "TunnelPane.h"
|
||||||
#include "QMessageBox"
|
|
||||||
|
|
||||||
TunnelPane::TunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener_, TunnelConfig* tunnelConfig_, QWidget* wrongInputPane_, QLabel* wrongInputLabel_):
|
#include "QMessageBox"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
TunnelPane::TunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener_, TunnelConfig* tunnelConfig_, QWidget* wrongInputPane_, QLabel* wrongInputLabel_, MainWindow* mainWindow_):
|
||||||
QObject(),
|
QObject(),
|
||||||
|
mainWindow(mainWindow_),
|
||||||
wrongInputPane(wrongInputPane_),
|
wrongInputPane(wrongInputPane_),
|
||||||
wrongInputLabel(wrongInputLabel_),
|
wrongInputLabel(wrongInputLabel_),
|
||||||
tunnelConfig(tunnelConfig_),
|
tunnelConfig(tunnelConfig_),
|
||||||
|
@ -181,7 +184,7 @@ void TunnelPane::appendControlsForI2CPParameters(I2CPParameters& i2cpParameters,
|
||||||
|
|
||||||
void TunnelPane::updated() {
|
void TunnelPane::updated() {
|
||||||
std::string oldName=tunnelConfig->getName();
|
std::string oldName=tunnelConfig->getName();
|
||||||
if(!applyDataFromUIToTunnelConfig())return;//TODO visualise bad input
|
if(!applyDataFromUIToTunnelConfig())return;
|
||||||
tunnelsPageUpdateListener->updated(oldName, tunnelConfig);
|
tunnelsPageUpdateListener->updated(oldName, tunnelConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,3 +227,10 @@ i2p::data::SigningKeyType TunnelPane::readSigTypeComboboxUI(QComboBox* sigTypeCo
|
||||||
void TunnelPane::deleteTunnelForm() {
|
void TunnelPane::deleteTunnelForm() {
|
||||||
widgetlocks.deleteListeners();
|
widgetlocks.deleteListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TunnelPane::highlightWrongInput(QString warningText, QWidget* controlWithWrongInput) {
|
||||||
|
wrongInputPane->setVisible(true);
|
||||||
|
wrongInputLabel->setText(warningText);
|
||||||
|
if(controlWithWrongInput)controlWithWrongInput->setFocus();
|
||||||
|
mainWindow->showTunnelsPage();
|
||||||
|
}
|
||||||
|
|
|
@ -23,27 +23,26 @@ class ClientTunnelPane;
|
||||||
class TunnelConfig;
|
class TunnelConfig;
|
||||||
class I2CPParameters;
|
class I2CPParameters;
|
||||||
|
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
class TunnelPane : public QObject {
|
class TunnelPane : public QObject {
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener_, TunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_);
|
TunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener_, TunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_, MainWindow* mainWindow_);
|
||||||
virtual ~TunnelPane(){}
|
virtual ~TunnelPane(){}
|
||||||
|
|
||||||
void deleteTunnelForm();
|
void deleteTunnelForm();
|
||||||
|
|
||||||
void hideWrongInputLabel() { wrongInputPane->setVisible(false); }
|
void hideWrongInputLabel() const { wrongInputPane->setVisible(false); }
|
||||||
void highlightWrongInput(QString warningText, QWidget* controlWithWrongInput) {
|
void highlightWrongInput(QString warningText, QWidget* controlWithWrongInput);
|
||||||
wrongInputPane->setVisible(true);
|
|
||||||
wrongInputLabel->setText(warningText);
|
|
||||||
if(controlWithWrongInput)controlWithWrongInput->setFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ServerTunnelPane* asServerTunnelPane()=0;
|
virtual ServerTunnelPane* asServerTunnelPane()=0;
|
||||||
virtual ClientTunnelPane* asClientTunnelPane()=0;
|
virtual ClientTunnelPane* asClientTunnelPane()=0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
MainWindow* mainWindow;
|
||||||
QWidget * wrongInputPane;
|
QWidget * wrongInputPane;
|
||||||
QLabel* wrongInputLabel;
|
QLabel* wrongInputLabel;
|
||||||
TunnelConfig* tunnelConfig;
|
TunnelConfig* tunnelConfig;
|
||||||
|
@ -93,6 +92,7 @@ protected:
|
||||||
//should be created by factory
|
//should be created by factory
|
||||||
i2p::data::SigningKeyType readSigTypeComboboxUI(QComboBox* sigTypeComboBox);
|
i2p::data::SigningKeyType readSigTypeComboboxUI(QComboBox* sigTypeComboBox);
|
||||||
|
|
||||||
|
public:
|
||||||
//returns false when invalid data at UI
|
//returns false when invalid data at UI
|
||||||
virtual bool applyDataFromUIToTunnelConfig() {
|
virtual bool applyDataFromUIToTunnelConfig() {
|
||||||
hideWrongInputLabel();
|
hideWrongInputLabel();
|
||||||
|
@ -106,7 +106,7 @@ protected:
|
||||||
i2cpParams.setCrypto_tagsToSend(crypto_tagsToSendLineEdit->text());
|
i2cpParams.setCrypto_tagsToSend(crypto_tagsToSendLineEdit->text());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
protected:
|
||||||
void setupTunnelPane(
|
void setupTunnelPane(
|
||||||
TunnelConfig* tunnelConfig,
|
TunnelConfig* tunnelConfig,
|
||||||
QGroupBox *tunnelGroupBox,
|
QGroupBox *tunnelGroupBox,
|
||||||
|
|
|
@ -699,22 +699,28 @@ void MainWindow::appendTunnelForms(std::string tunnelNameToFocus) {
|
||||||
TunnelConfig* tunconf = it->second;
|
TunnelConfig* tunconf = it->second;
|
||||||
ServerTunnelConfig* stc = tunconf->asServerTunnelConfig();
|
ServerTunnelConfig* stc = tunconf->asServerTunnelConfig();
|
||||||
if(stc){
|
if(stc){
|
||||||
ServerTunnelPane * tunnelPane=new ServerTunnelPane(&tunnelsPageUpdateListener, stc, ui->wrongInputLabel, ui->wrongInputLabel);
|
ServerTunnelPane * tunnelPane=new ServerTunnelPane(&tunnelsPageUpdateListener, stc, ui->wrongInputLabel, ui->wrongInputLabel, this);
|
||||||
int h=tunnelPane->appendServerTunnelForm(stc, ui->tunnelsScrollAreaWidgetContents, tunnelPanes.size(), height);
|
int h=tunnelPane->appendServerTunnelForm(stc, ui->tunnelsScrollAreaWidgetContents, tunnelPanes.size(), height);
|
||||||
height+=h;
|
height+=h;
|
||||||
//qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size();
|
//qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size();
|
||||||
tunnelPanes.push_back(tunnelPane);
|
tunnelPanes.push_back(tunnelPane);
|
||||||
if(name==tunnelNameToFocus)tunnelPane->getNameLineEdit()->setFocus();
|
if(name==tunnelNameToFocus){
|
||||||
|
tunnelPane->getNameLineEdit()->setFocus();
|
||||||
|
//todo ui->settingsScrollArea->###scroll
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ClientTunnelConfig* ctc = tunconf->asClientTunnelConfig();
|
ClientTunnelConfig* ctc = tunconf->asClientTunnelConfig();
|
||||||
if(ctc){
|
if(ctc){
|
||||||
ClientTunnelPane * tunnelPane=new ClientTunnelPane(&tunnelsPageUpdateListener, ctc, ui->wrongInputLabel, ui->wrongInputLabel);
|
ClientTunnelPane * tunnelPane=new ClientTunnelPane(&tunnelsPageUpdateListener, ctc, ui->wrongInputLabel, ui->wrongInputLabel, this);
|
||||||
int h=tunnelPane->appendClientTunnelForm(ctc, ui->tunnelsScrollAreaWidgetContents, tunnelPanes.size(), height);
|
int h=tunnelPane->appendClientTunnelForm(ctc, ui->tunnelsScrollAreaWidgetContents, tunnelPanes.size(), height);
|
||||||
height+=h;
|
height+=h;
|
||||||
//qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size();
|
//qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size();
|
||||||
tunnelPanes.push_back(tunnelPane);
|
tunnelPanes.push_back(tunnelPane);
|
||||||
if(name==tunnelNameToFocus)tunnelPane->getNameLineEdit()->setFocus();
|
if(name==tunnelNameToFocus){
|
||||||
|
tunnelPane->getNameLineEdit()->setFocus();
|
||||||
|
//todo ui->settingsScrollArea->###scroll
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
throw "unknown TunnelConfig subtype";
|
throw "unknown TunnelConfig subtype";
|
||||||
|
@ -759,6 +765,15 @@ void MainWindow::reloadTunnelsConfigAndUI(std::string tunnelNameToFocus) {
|
||||||
void MainWindow::SaveTunnelsConfig() {
|
void MainWindow::SaveTunnelsConfig() {
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
|
//validate and show red if wrong
|
||||||
|
for (std::list<TunnelPane*>::iterator it=tunnelPanes.begin(); it!=tunnelPanes.end(); ++it) {
|
||||||
|
TunnelPane* tunpane = *it;
|
||||||
|
if(!tunpane->applyDataFromUIToTunnelConfig()) {
|
||||||
|
//!valid
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (std::map<std::string,TunnelConfig*>::iterator it=tunnelConfigs.begin(); it!=tunnelConfigs.end(); ++it) {
|
for (std::map<std::string,TunnelConfig*>::iterator it=tunnelConfigs.begin(); it!=tunnelConfigs.end(); ++it) {
|
||||||
const std::string& name = it->first;
|
const std::string& name = it->first;
|
||||||
TunnelConfig* tunconf = it->second;
|
TunnelConfig* tunconf = it->second;
|
||||||
|
@ -788,7 +803,7 @@ void MainWindow::TunnelsPageUpdateListenerMainWindowImpl::updated(std::string ol
|
||||||
if(it!=mainWindow->tunnelConfigs.end())mainWindow->tunnelConfigs.erase(it);
|
if(it!=mainWindow->tunnelConfigs.end())mainWindow->tunnelConfigs.erase(it);
|
||||||
mainWindow->tunnelConfigs[tunConf->getName()]=tunConf;
|
mainWindow->tunnelConfigs[tunConf->getName()]=tunConf;
|
||||||
}
|
}
|
||||||
mainWindow->SaveTunnelsConfig();
|
mainWindow->saveAllConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::TunnelsPageUpdateListenerMainWindowImpl::needsDeleting(std::string oldName){
|
void MainWindow::TunnelsPageUpdateListenerMainWindowImpl::needsDeleting(std::string oldName){
|
||||||
|
@ -849,4 +864,5 @@ void MainWindow::highlightWrongInput(QString warningText, QWidget* widgetToFocus
|
||||||
ui->wrongInputLabel->setVisible(true);
|
ui->wrongInputLabel->setVisible(true);
|
||||||
ui->wrongInputLabel->setText(warningText);
|
ui->wrongInputLabel->setText(warningText);
|
||||||
if(widgetToFocus)widgetToFocus->setFocus();
|
if(widgetToFocus)widgetToFocus->setFocus();
|
||||||
|
showSettingsPage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,7 +411,7 @@ private slots:
|
||||||
void runPeerTest();
|
void runPeerTest();
|
||||||
void enableTransit();
|
void enableTransit();
|
||||||
void disableTransit();
|
void disableTransit();
|
||||||
|
public slots:
|
||||||
void showStatus_local_destinations_Page();
|
void showStatus_local_destinations_Page();
|
||||||
void showStatus_leasesets_Page();
|
void showStatus_leasesets_Page();
|
||||||
void showStatus_tunnels_Page();
|
void showStatus_tunnels_Page();
|
||||||
|
@ -572,9 +572,9 @@ private:
|
||||||
TunnelConfig* tc=it->second;
|
TunnelConfig* tc=it->second;
|
||||||
tunnelConfigs.erase(it);
|
tunnelConfigs.erase(it);
|
||||||
delete tc;
|
delete tc;
|
||||||
SaveTunnelsConfig();
|
|
||||||
reloadTunnelsConfigAndUI("");
|
|
||||||
}
|
}
|
||||||
|
saveAllConfigs();
|
||||||
|
reloadTunnelsConfigAndUI("");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GenerateNewTunnelName() {
|
std::string GenerateNewTunnelName() {
|
||||||
|
@ -609,7 +609,7 @@ private:
|
||||||
destinationPort,
|
destinationPort,
|
||||||
sigType);
|
sigType);
|
||||||
|
|
||||||
SaveTunnelsConfig();
|
saveAllConfigs();
|
||||||
reloadTunnelsConfigAndUI(name);
|
reloadTunnelsConfigAndUI(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ private:
|
||||||
isUniqueLocal);
|
isUniqueLocal);
|
||||||
|
|
||||||
|
|
||||||
SaveTunnelsConfig();
|
saveAllConfigs();
|
||||||
reloadTunnelsConfigAndUI(name);
|
reloadTunnelsConfigAndUI(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -624,7 +624,7 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="statusPage">
|
<widget class="QWidget" name="statusPage">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -719,8 +719,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>80</width>
|
<width>689</width>
|
||||||
<height>26</height>
|
<height>496</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
Loading…
Reference in a new issue