|
|
@ -33,8 +33,7 @@ |
|
|
|
# include <QtDebug> |
|
|
|
# include <QtDebug> |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#include "controller/i2pd_daemon_controller.h" |
|
|
|
#include "DaemonQT.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "SignatureTypeComboboxFactory.h" |
|
|
|
#include "SignatureTypeComboboxFactory.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "logviewermanager.h" |
|
|
|
#include "logviewermanager.h" |
|
|
@ -64,24 +63,22 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren |
|
|
|
,routerCommandsParent(new QWidget(this)) |
|
|
|
,routerCommandsParent(new QWidget(this)) |
|
|
|
,widgetlocks() |
|
|
|
,widgetlocks() |
|
|
|
,i2pController(nullptr) |
|
|
|
,i2pController(nullptr) |
|
|
|
|
|
|
|
,configItems() |
|
|
|
,datadir() |
|
|
|
,datadir() |
|
|
|
,confpath() |
|
|
|
,confpath() |
|
|
|
,tunconfpath() |
|
|
|
,tunconfpath() |
|
|
|
,ignoreUpdatesOnAppendForms(false) |
|
|
|
,tunnelConfigs() |
|
|
|
,volatileDataHolder(new ConcurrentHolder<VolatileData*>(new VolatileData())) |
|
|
|
|
|
|
|
,tunnelsPageUpdateListener(this) |
|
|
|
,tunnelsPageUpdateListener(this) |
|
|
|
,preventSaveTunnelsBool(false) |
|
|
|
,preventSaveTunnelsBool(false) |
|
|
|
,saverPtr(nullptr) |
|
|
|
,saverPtr( |
|
|
|
|
|
|
|
new SaverImpl(this, |
|
|
|
|
|
|
|
&configItems, |
|
|
|
|
|
|
|
&tunnelConfigs)) |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
assert(delayedSaveManagerPtr!=nullptr); |
|
|
|
assert(delayedSaveManagerPtr!=nullptr); |
|
|
|
assert(volatileDataHolder!=nullptr); |
|
|
|
|
|
|
|
assert(volatileDataHolder->getData()!=nullptr); |
|
|
|
|
|
|
|
saverPtr=new SaverImpl(this); |
|
|
|
|
|
|
|
assert(saverPtr!=nullptr); |
|
|
|
assert(saverPtr!=nullptr); |
|
|
|
|
|
|
|
|
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
|
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->setupUi(this); |
|
|
|
ui->setupUi(this); |
|
|
|
statusButtonsUI->setupUi(ui->statusButtonsPane); |
|
|
|
statusButtonsUI->setupUi(ui->statusButtonsPane); |
|
|
|
routerCommandsUI->setupUi(routerCommandsParent); |
|
|
|
routerCommandsUI->setupUi(routerCommandsParent); |
|
|
@ -211,8 +208,8 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren |
|
|
|
initFolderChooser( OPTION("","datadir",[]{return "";}), uiSettings->dataFolderLineEdit, uiSettings->dataFolderBrowsePushButton); |
|
|
|
initFolderChooser( OPTION("","datadir",[]{return "";}), uiSettings->dataFolderLineEdit, uiSettings->dataFolderBrowsePushButton); |
|
|
|
initIPAddressBox( OPTION("","host",[]{return "";}), uiSettings->routerExternalHostLineEdit, tr("Router external address -> Host")); |
|
|
|
initIPAddressBox( OPTION("","host",[]{return "";}), uiSettings->routerExternalHostLineEdit, tr("Router external address -> Host")); |
|
|
|
initTCPPortBox( OPTION("","port",[]{return "";}), uiSettings->routerExternalPortLineEdit, tr("Router external address -> Port")); |
|
|
|
initTCPPortBox( OPTION("","port",[]{return "";}), uiSettings->routerExternalPortLineEdit, tr("Router external address -> Port")); |
|
|
|
daemonOption=initNonGUIOption( OPTION("","daemon",[]{return "";}),type_bool); |
|
|
|
daemonOption=initNonGUIOption( OPTION("","daemon",[]{return "";})); |
|
|
|
serviceOption=initNonGUIOption( OPTION("","service",[]{return "";}),type_bool); |
|
|
|
serviceOption=initNonGUIOption( OPTION("","service",[]{return "";})); |
|
|
|
initStringBox( OPTION("","ifname4",[]{return "";}), uiSettings->ifname4LineEdit);//Network interface to bind to for IPv4
|
|
|
|
initStringBox( OPTION("","ifname4",[]{return "";}), uiSettings->ifname4LineEdit);//Network interface to bind to for IPv4
|
|
|
|
initStringBox( OPTION("","ifname6",[]{return "";}), uiSettings->ifname6LineEdit);//Network interface to bind to for IPv6
|
|
|
|
initStringBox( OPTION("","ifname6",[]{return "";}), uiSettings->ifname6LineEdit);//Network interface to bind to for IPv6
|
|
|
|
initCheckBox( OPTION("","nat",[]{return "true";}), uiSettings->natCheckBox);//If true, assume we are behind NAT. true by default
|
|
|
|
initCheckBox( OPTION("","nat",[]{return "true";}), uiSettings->natCheckBox);//If true, assume we are behind NAT. true by default
|
|
|
@ -391,7 +388,7 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren |
|
|
|
uiSettings->configFileLineEdit->setText(confpath); |
|
|
|
uiSettings->configFileLineEdit->setText(confpath); |
|
|
|
uiSettings->tunnelsConfigFileLineEdit->setText(tunconfpath); |
|
|
|
uiSettings->tunnelsConfigFileLineEdit->setText(tunconfpath); |
|
|
|
|
|
|
|
|
|
|
|
for(QList<MainWindowItem*>::iterator it = vdata->configItems.begin(); it!= vdata->configItems.end(); ++it) { |
|
|
|
for(QList<MainWindowItem*>::iterator it = configItems.begin(); it!= configItems.end(); ++it) { |
|
|
|
MainWindowItem* item = *it; |
|
|
|
MainWindowItem* item = *it; |
|
|
|
item->installListeners(this); |
|
|
|
item->installListeners(this); |
|
|
|
} |
|
|
|
} |
|
|
@ -604,7 +601,7 @@ void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) { |
|
|
|
setVisible(!isVisible()); |
|
|
|
setVisible(!isVisible()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
qDebug() << "MainWindow::iconActivated(): unknown reason: " << reason << Qt::endl; |
|
|
|
qDebug() << "MainWindow::iconActivated(): unknown reason: " << reason << endl; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -667,13 +664,11 @@ MainWindow::~MainWindow() |
|
|
|
delete statusPageUpdateTimer; |
|
|
|
delete statusPageUpdateTimer; |
|
|
|
delete delayedSaveManagerPtr; |
|
|
|
delete delayedSaveManagerPtr; |
|
|
|
delete saverPtr; |
|
|
|
delete saverPtr; |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
for(QList<MainWindowItem*>::iterator it = configItems.begin(); it!= configItems.end(); ++it) { |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
for(QList<MainWindowItem*>::iterator it = vdata->configItems.begin(); it!= vdata->configItems.end(); ++it) { |
|
|
|
|
|
|
|
MainWindowItem* item = *it; |
|
|
|
MainWindowItem* item = *it; |
|
|
|
item->deleteLater(); |
|
|
|
item->deleteLater(); |
|
|
|
} |
|
|
|
} |
|
|
|
vdata->configItems.clear(); |
|
|
|
configItems.clear(); |
|
|
|
//QMessageBox::information(0, "Debug", "mw destructor 1");
|
|
|
|
//QMessageBox::information(0, "Debug", "mw destructor 1");
|
|
|
|
//delete ui;
|
|
|
|
//delete ui;
|
|
|
|
//QMessageBox::information(0, "Debug", "mw destructor 2");
|
|
|
|
//QMessageBox::information(0, "Debug", "mw destructor 2");
|
|
|
@ -683,82 +678,53 @@ FileChooserItem* MainWindow::initFileChooser(ConfigOption option, QLineEdit* fil |
|
|
|
FileChooserItem* retVal; |
|
|
|
FileChooserItem* retVal; |
|
|
|
retVal=new FileChooserItem(option, fileNameLineEdit, fileBrowsePushButton, this, requireExistingFile, readOnly); |
|
|
|
retVal=new FileChooserItem(option, fileNameLineEdit, fileBrowsePushButton, this, requireExistingFile, readOnly); |
|
|
|
MainWindowItem* super=retVal; |
|
|
|
MainWindowItem* super=retVal; |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(super); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(super); |
|
|
|
|
|
|
|
return retVal; |
|
|
|
return retVal; |
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::initFolderChooser(ConfigOption option, QLineEdit* folderLineEdit, QPushButton* folderBrowsePushButton){ |
|
|
|
void MainWindow::initFolderChooser(ConfigOption option, QLineEdit* folderLineEdit, QPushButton* folderBrowsePushButton){ |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(new FolderChooserItem(option, folderLineEdit, folderBrowsePushButton, this, true)); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(new FolderChooserItem(option, folderLineEdit, folderBrowsePushButton, this, true)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
/*void MainWindow::initCombobox(ConfigOption option, QComboBox* comboBox){
|
|
|
|
/*void MainWindow::initCombobox(ConfigOption option, QComboBox* comboBox){
|
|
|
|
configItems.append(new ComboBoxItem(option, comboBox)); |
|
|
|
configItems.append(new ComboBoxItem(option, comboBox)); |
|
|
|
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(saveAllConfigs())); |
|
|
|
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(saveAllConfigs())); |
|
|
|
}*/ |
|
|
|
}*/ |
|
|
|
void MainWindow::initLogDestinationCombobox(ConfigOption option, QComboBox* comboBox){ |
|
|
|
void MainWindow::initLogDestinationCombobox(ConfigOption option, QComboBox* comboBox){ |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(new LogDestinationComboBoxItem(option, comboBox)); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(new LogDestinationComboBoxItem(option, comboBox)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::initLogLevelCombobox(ConfigOption option, QComboBox* comboBox){ |
|
|
|
void MainWindow::initLogLevelCombobox(ConfigOption option, QComboBox* comboBox){ |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(new LogLevelComboBoxItem(option, comboBox)); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(new LogLevelComboBoxItem(option, comboBox)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::initSignatureTypeCombobox(ConfigOption option, QComboBox* comboBox){ |
|
|
|
void MainWindow::initSignatureTypeCombobox(ConfigOption option, QComboBox* comboBox){ |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(new SignatureTypeComboBoxItem(option, comboBox)); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(new SignatureTypeComboBoxItem(option, comboBox)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::initIPAddressBox(ConfigOption option, QLineEdit* addressLineEdit, QString fieldNameTranslated){ |
|
|
|
void MainWindow::initIPAddressBox(ConfigOption option, QLineEdit* addressLineEdit, QString fieldNameTranslated){ |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(new IPAddressStringItem(option, addressLineEdit, fieldNameTranslated, this)); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(new IPAddressStringItem(option, addressLineEdit, fieldNameTranslated, this)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::initTCPPortBox(ConfigOption option, QLineEdit* portLineEdit, QString fieldNameTranslated){ |
|
|
|
void MainWindow::initTCPPortBox(ConfigOption option, QLineEdit* portLineEdit, QString fieldNameTranslated){ |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(new TCPPortStringItem(option, portLineEdit, fieldNameTranslated, this)); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(new TCPPortStringItem(option, portLineEdit, fieldNameTranslated, this)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::initCheckBox(ConfigOption option, QCheckBox* checkBox) { |
|
|
|
void MainWindow::initCheckBox(ConfigOption option, QCheckBox* checkBox) { |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(new CheckBoxItem(option, checkBox)); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(new CheckBoxItem(option, checkBox)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::initIntegerBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){ |
|
|
|
void MainWindow::initIntegerBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){ |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(new IntegerStringItem(option, numberLineEdit, fieldNameTranslated, this)); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(new IntegerStringItem(option, numberLineEdit, fieldNameTranslated, this)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::initUInt32Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){ |
|
|
|
void MainWindow::initUInt32Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){ |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(new UInt32StringItem(option, numberLineEdit, fieldNameTranslated, this)); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(new UInt32StringItem(option, numberLineEdit, fieldNameTranslated, this)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::initUInt16Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){ |
|
|
|
void MainWindow::initUInt16Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){ |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(new UInt16StringItem(option, numberLineEdit, fieldNameTranslated, this)); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(new UInt16StringItem(option, numberLineEdit, fieldNameTranslated, this)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::initStringBox(ConfigOption option, QLineEdit* lineEdit){ |
|
|
|
void MainWindow::initStringBox(ConfigOption option, QLineEdit* lineEdit){ |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(new BaseStringItem(option, lineEdit, QString(), this)); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(new BaseStringItem(option, lineEdit, QString(), this)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
NonGUIOptionItem* MainWindow::initNonGUIOption(ConfigOption option, TypeEnum optionValueType) { |
|
|
|
NonGUIOptionItem* MainWindow::initNonGUIOption(ConfigOption option) { |
|
|
|
NonGUIOptionItem * retValue; |
|
|
|
NonGUIOptionItem * retValue; |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
configItems.append(retValue=new NonGUIOptionItem(option)); |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
vdata->configItems.append(retValue=new NonGUIOptionItem(option)); |
|
|
|
|
|
|
|
retValue->optionValueType=optionValueType; |
|
|
|
|
|
|
|
return retValue; |
|
|
|
return retValue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::loadAllConfigs(SaverImpl* saverPtr){ |
|
|
|
void MainWindow::loadAllConfigs(SaverImpl* saverPtr){ |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
|
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//BORROWED FROM ??? //TODO move this code into single location
|
|
|
|
//BORROWED FROM ??? //TODO move this code into single location
|
|
|
|
std::string config; i2p::config::GetOption("conf", config); |
|
|
|
std::string config; i2p::config::GetOption("conf", config); |
|
|
@ -802,7 +768,7 @@ void MainWindow::loadAllConfigs(SaverImpl* saverPtr){ |
|
|
|
saverPtr->setConfPath(this->confpath); |
|
|
|
saverPtr->setConfPath(this->confpath); |
|
|
|
saverPtr->setTunnelsConfPath(this->tunconfpath); |
|
|
|
saverPtr->setTunnelsConfPath(this->tunconfpath); |
|
|
|
|
|
|
|
|
|
|
|
for(QList<MainWindowItem*>::iterator it = vdata->configItems.begin(); it!= vdata->configItems.end(); ++it) { |
|
|
|
for(QList<MainWindowItem*>::iterator it = configItems.begin(); it!= configItems.end(); ++it) { |
|
|
|
MainWindowItem* item = *it; |
|
|
|
MainWindowItem* item = *it; |
|
|
|
item->loadFromConfigOption(); |
|
|
|
item->loadFromConfigOption(); |
|
|
|
} |
|
|
|
} |
|
|
@ -821,14 +787,12 @@ void MainWindow::DisableTunnelsPage() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::layoutTunnels() { |
|
|
|
void MainWindow::layoutTunnels() { |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
|
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int height=0; |
|
|
|
int height=0; |
|
|
|
ui->tunnelsScrollAreaWidgetContents->setGeometry(0,0,0,0); |
|
|
|
ui->tunnelsScrollAreaWidgetContents->setGeometry(0,0,0,0); |
|
|
|
for(const auto& it : vdata->tunnelConfigs) { |
|
|
|
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; |
|
|
|
TunnelPane * tunnelPane=tunconf->getTunnelPane(); |
|
|
|
TunnelPane * tunnelPane=tunconf->getTunnelPane(); |
|
|
|
if(!tunnelPane)continue; |
|
|
|
if(!tunnelPane)continue; |
|
|
|
int h=tunnelPane->height(); |
|
|
|
int h=tunnelPane->height(); |
|
|
@ -844,12 +808,9 @@ void MainWindow::layoutTunnels() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::deleteTunnelFromUI(std::string tunnelName, TunnelConfig* cnf) { |
|
|
|
void MainWindow::deleteTunnelFromUI(std::string tunnelName, TunnelConfig* cnf) { |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
|
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TunnelPane* tp = cnf->getTunnelPane(); |
|
|
|
TunnelPane* tp = cnf->getTunnelPane(); |
|
|
|
if(!tp)return; |
|
|
|
if(!tp)return; |
|
|
|
vdata->tunnelPanes.remove(tp); |
|
|
|
tunnelPanes.remove(tp); |
|
|
|
tp->deleteWidget(); |
|
|
|
tp->deleteWidget(); |
|
|
|
layoutTunnels(); |
|
|
|
layoutTunnels(); |
|
|
|
} |
|
|
|
} |
|
|
@ -863,10 +824,7 @@ bool MainWindow::saveAllConfigs(bool reloadAfterSave, FocusEnum focusOn, std::st |
|
|
|
daemonOption->optionValue=boost::any(false); |
|
|
|
daemonOption->optionValue=boost::any(false); |
|
|
|
serviceOption->optionValue=boost::any(false); |
|
|
|
serviceOption->optionValue=boost::any(false); |
|
|
|
|
|
|
|
|
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
for(QList<MainWindowItem*>::iterator it = configItems.begin(); it!= configItems.end(); ++it) { |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(QList<MainWindowItem*>::iterator it = vdata->configItems.begin(); it != vdata->configItems.end(); ++it) { |
|
|
|
|
|
|
|
MainWindowItem* item = *it; |
|
|
|
MainWindowItem* item = *it; |
|
|
|
bool alreadyDisplayedIfWrong=false; |
|
|
|
bool alreadyDisplayedIfWrong=false; |
|
|
|
if(!item->isValid(alreadyDisplayedIfWrong)){ |
|
|
|
if(!item->isValid(alreadyDisplayedIfWrong)){ |
|
|
@ -925,39 +883,34 @@ void MainWindow::updated() { |
|
|
|
void MainWindowItem::installListeners(MainWindow *mainWindow) {} |
|
|
|
void MainWindowItem::installListeners(MainWindow *mainWindow) {} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::appendTunnelForms(std::string tunnelNameToFocus) { |
|
|
|
void MainWindow::appendTunnelForms(std::string tunnelNameToFocus) { |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
|
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ignoreUpdatesOnAppendForms = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int height=0; |
|
|
|
int height=0; |
|
|
|
ui->tunnelsScrollAreaWidgetContents->setGeometry(0,0,0,0); |
|
|
|
ui->tunnelsScrollAreaWidgetContents->setGeometry(0,0,0,0); |
|
|
|
std::unordered_map<std::string, TunnelConfig*> tunnelConfigsCopy(vdata->tunnelConfigs); |
|
|
|
for(std::map<std::string, TunnelConfig*>::iterator it = tunnelConfigs.begin(); it != tunnelConfigs.end(); ++it) { |
|
|
|
for(const auto& it : tunnelConfigsCopy) { |
|
|
|
const std::string& name=it->first; |
|
|
|
const std::string& name=it.first; |
|
|
|
TunnelConfig* tunconf = it->second; |
|
|
|
ServerTunnelConfig* stc = it.second->asServerTunnelConfig(); |
|
|
|
ServerTunnelConfig* stc = tunconf->asServerTunnelConfig(); |
|
|
|
if(stc){ |
|
|
|
if(stc){ |
|
|
|
ServerTunnelPane * tunnelPane=new ServerTunnelPane(&tunnelsPageUpdateListener, stc, ui->wrongInputLabel, ui->wrongInputLabel, this); |
|
|
|
ServerTunnelPane * tunnelPane=new ServerTunnelPane(&tunnelsPageUpdateListener, stc, ui->wrongInputLabel, ui->wrongInputLabel, this); |
|
|
|
stc->setTunnelPane(tunnelPane); |
|
|
|
tunconf->setTunnelPane(tunnelPane); |
|
|
|
int h=tunnelPane->appendServerTunnelForm(stc, ui->tunnelsScrollAreaWidgetContents, vdata->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();
|
|
|
|
vdata->tunnelPanes.push_back(tunnelPane); |
|
|
|
tunnelPanes.push_back(tunnelPane); |
|
|
|
if(name.compare(tunnelNameToFocus)==0){ |
|
|
|
if(name==tunnelNameToFocus){ |
|
|
|
tunnelPane->getNameLineEdit()->setFocus(); |
|
|
|
tunnelPane->getNameLineEdit()->setFocus(); |
|
|
|
ui->tunnelsScrollArea->ensureWidgetVisible(tunnelPane->getNameLineEdit()); |
|
|
|
ui->tunnelsScrollArea->ensureWidgetVisible(tunnelPane->getNameLineEdit()); |
|
|
|
} |
|
|
|
} |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
ClientTunnelConfig* ctc = it.second->asClientTunnelConfig(); |
|
|
|
ClientTunnelConfig* ctc = tunconf->asClientTunnelConfig(); |
|
|
|
if(ctc){ |
|
|
|
if(ctc){ |
|
|
|
ClientTunnelPane * tunnelPane=new ClientTunnelPane(&tunnelsPageUpdateListener, ctc, ui->wrongInputLabel, ui->wrongInputLabel, this); |
|
|
|
ClientTunnelPane * tunnelPane=new ClientTunnelPane(&tunnelsPageUpdateListener, ctc, ui->wrongInputLabel, ui->wrongInputLabel, this); |
|
|
|
ctc->setTunnelPane(tunnelPane); |
|
|
|
tunconf->setTunnelPane(tunnelPane); |
|
|
|
int h=tunnelPane->appendClientTunnelForm(ctc, ui->tunnelsScrollAreaWidgetContents, vdata->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();
|
|
|
|
vdata->tunnelPanes.push_back(tunnelPane); |
|
|
|
tunnelPanes.push_back(tunnelPane); |
|
|
|
if(name.compare(tunnelNameToFocus)==0){ |
|
|
|
if(name==tunnelNameToFocus){ |
|
|
|
tunnelPane->getNameLineEdit()->setFocus(); |
|
|
|
tunnelPane->getNameLineEdit()->setFocus(); |
|
|
|
ui->tunnelsScrollArea->ensureWidgetVisible(tunnelPane->getNameLineEdit()); |
|
|
|
ui->tunnelsScrollArea->ensureWidgetVisible(tunnelPane->getNameLineEdit()); |
|
|
|
} |
|
|
|
} |
|
|
@ -970,12 +923,9 @@ void MainWindow::appendTunnelForms(std::string tunnelNameToFocus) { |
|
|
|
QList<QWidget*> childWidgets = ui->tunnelsScrollAreaWidgetContents->findChildren<QWidget*>(); |
|
|
|
QList<QWidget*> childWidgets = ui->tunnelsScrollAreaWidgetContents->findChildren<QWidget*>(); |
|
|
|
foreach(QWidget* widget, childWidgets) |
|
|
|
foreach(QWidget* widget, childWidgets) |
|
|
|
widget->show(); |
|
|
|
widget->show(); |
|
|
|
ignoreUpdatesOnAppendForms = false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::deleteTunnelForms() { |
|
|
|
void MainWindow::deleteTunnelForms() { |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
for(std::list<TunnelPane*>::iterator it = tunnelPanes.begin(); it != tunnelPanes.end(); ++it) { |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
for(std::list<TunnelPane*>::iterator it = vdata->tunnelPanes.begin(); it != vdata->tunnelPanes.end(); ++it) { |
|
|
|
|
|
|
|
TunnelPane* tp = *it; |
|
|
|
TunnelPane* tp = *it; |
|
|
|
ServerTunnelPane* stp = tp->asServerTunnelPane(); |
|
|
|
ServerTunnelPane* stp = tp->asServerTunnelPane(); |
|
|
|
if(stp){ |
|
|
|
if(stp){ |
|
|
@ -991,13 +941,11 @@ void MainWindow::deleteTunnelForms() { |
|
|
|
} |
|
|
|
} |
|
|
|
throw "unknown TunnelPane subtype"; |
|
|
|
throw "unknown TunnelPane subtype"; |
|
|
|
} |
|
|
|
} |
|
|
|
vdata->tunnelPanes.clear(); |
|
|
|
tunnelPanes.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool MainWindow::applyTunnelsUiToConfigs() { |
|
|
|
bool MainWindow::applyTunnelsUiToConfigs() { |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
for(std::list<TunnelPane*>::iterator it = tunnelPanes.begin(); it != tunnelPanes.end(); ++it) { |
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
for(std::list<TunnelPane*>::iterator it = vdata->tunnelPanes.begin(); it != vdata->tunnelPanes.end(); ++it) { |
|
|
|
|
|
|
|
TunnelPane* tp = *it; |
|
|
|
TunnelPane* tp = *it; |
|
|
|
if(!tp->applyDataFromUIToTunnelConfig())return false; |
|
|
|
if(!tp->applyDataFromUIToTunnelConfig())return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -1009,32 +957,23 @@ void MainWindow::reloadTunnelsConfigAndUI_QString(QString tunnelNameToFocus) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::reloadTunnelsConfigAndUI(std::string tunnelNameToFocus, QWidget* widgetToFocus) { |
|
|
|
void MainWindow::reloadTunnelsConfigAndUI(std::string tunnelNameToFocus, QWidget* widgetToFocus) { |
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
|
|
|
|
VolatileData* vdata = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
deleteTunnelForms(); |
|
|
|
deleteTunnelForms(); |
|
|
|
const std::unordered_map<std::string, TunnelConfig*> tunnelConfigsCopy(vdata->tunnelConfigs); |
|
|
|
for (std::map<std::string,TunnelConfig*>::iterator it=tunnelConfigs.begin(); it!=tunnelConfigs.end(); ++it) { |
|
|
|
for (const auto& it : tunnelConfigsCopy) { |
|
|
|
TunnelConfig* tunconf = it->second; |
|
|
|
TunnelConfig* tunconf = it.second; |
|
|
|
|
|
|
|
vdata->tunnelConfigs[tunconf->getName()]=nullptr; |
|
|
|
|
|
|
|
vdata->tunnelConfigsById[tunconf->get_TunnelId()]=nullptr; |
|
|
|
|
|
|
|
delete tunconf; |
|
|
|
delete tunconf; |
|
|
|
} |
|
|
|
} |
|
|
|
vdata->tunnelConfigs.clear(); |
|
|
|
tunnelConfigs.clear(); |
|
|
|
vdata->tunnelConfigsById.clear(); |
|
|
|
|
|
|
|
ReadTunnelsConfig(); |
|
|
|
ReadTunnelsConfig(); |
|
|
|
appendTunnelForms(tunnelNameToFocus); |
|
|
|
appendTunnelForms(tunnelNameToFocus); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::TunnelsPageUpdateListenerMainWindowImpl::updated(std::string oldName, TunnelConfig* tunConf) { |
|
|
|
void MainWindow::TunnelsPageUpdateListenerMainWindowImpl::updated(std::string oldName, TunnelConfig* tunConf) { |
|
|
|
MutexWrapperLock lock(mainWindow->volatileDataHolder->getMutex()); |
|
|
|
if(oldName!=tunConf->getName()) { |
|
|
|
VolatileData* vdata = mainWindow->volatileDataHolder->getData(); |
|
|
|
|
|
|
|
if(mainWindow->ignoreUpdatesOnAppendForms)return; |
|
|
|
|
|
|
|
if(oldName.compare(tunConf->getName())!=0) { |
|
|
|
|
|
|
|
//name has changed
|
|
|
|
//name has changed
|
|
|
|
auto it=vdata->tunnelConfigs.find(oldName); |
|
|
|
std::map<std::string,TunnelConfig*>::const_iterator it=mainWindow->tunnelConfigs.find(oldName); |
|
|
|
if(it!=vdata->tunnelConfigs.end())vdata->tunnelConfigs.erase(it); |
|
|
|
if(it!=mainWindow->tunnelConfigs.end())mainWindow->tunnelConfigs.erase(it); |
|
|
|
vdata->tunnelConfigs[tunConf->getName()]=tunConf; |
|
|
|
mainWindow->tunnelConfigs[tunConf->getName()]=tunConf; |
|
|
|
mainWindow->saveAllConfigs(false, FocusEnum::focusOnTunnelName, tunConf->getName()); |
|
|
|
mainWindow->saveAllConfigs(true, FocusEnum::focusOnTunnelName, tunConf->getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
mainWindow->saveAllConfigs(false, FocusEnum::noFocus); |
|
|
|
mainWindow->saveAllConfigs(false, FocusEnum::noFocus); |
|
|
@ -1213,18 +1152,3 @@ bool MainWindow::isPreventSaveTunnelsMode() { |
|
|
|
void MainWindow::showTunnelsPagePreventedMessage() { |
|
|
|
void MainWindow::showTunnelsPagePreventedMessage() { |
|
|
|
QMessageBox::critical(this,QObject::tr("Error"),QObject::tr("Not saving tunnels configuration due to previous errors with it.")); |
|
|
|
QMessageBox::critical(this,QObject::tr("Error"),QObject::tr("Not saving tunnels configuration due to previous errors with it.")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::DeleteTunnelNamed(std::string name) { |
|
|
|
|
|
|
|
MutexWrapperLock lock(volatileDataHolder->getMutex()); |
|
|
|
|
|
|
|
VolatileData* tunnels = volatileDataHolder->getData(); |
|
|
|
|
|
|
|
auto it=tunnels->tunnelConfigs.find(name); |
|
|
|
|
|
|
|
if(it!=tunnels->tunnelConfigs.end()){ |
|
|
|
|
|
|
|
TunnelConfig* tc=it->second; |
|
|
|
|
|
|
|
deleteTunnelFromUI(name, tc); |
|
|
|
|
|
|
|
tunnels->tunnelConfigs.erase(it); |
|
|
|
|
|
|
|
tunnels->tunnelConfigsById.erase(tc->get_TunnelId()); |
|
|
|
|
|
|
|
delete tc; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
saveAllConfigs(true, FocusEnum::noFocus); |
|
|
|
|
|
|
|
delayedSaveManagerPtr->saveNow(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|