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