moved vpnConnection to separate thread

- added tabbar blocking when installing/removing containers
This commit is contained in:
vladimir.kuznetsov 2023-08-09 18:17:29 +05:00
parent e0d93eaa9f
commit 591d98d8b6
14 changed files with 128 additions and 95 deletions

View file

@ -88,6 +88,7 @@ signals:
void showNotificationMessage(const QString &message);
void showBusyIndicator(bool visible);
void enableTabBar(bool enabled);
void hideMainWindow();
void raiseMainWindow();

View file

@ -36,12 +36,13 @@ void SitesController::addSite(QString hostname)
m_sitesModel->addSite(hostname, ip);
if (!ip.isEmpty()) {
m_vpnConnection->addRoutes(QStringList() << ip);
m_vpnConnection->flushDns();
QMetaObject::invokeMethod(m_vpnConnection.get(), "addRoutes", Qt::QueuedConnection,
Q_ARG(QStringList, QStringList() << ip));
} else if (Utils::ipAddressWithSubnetRegExp().exactMatch(hostname)) {
m_vpnConnection->addRoutes(QStringList() << hostname);
m_vpnConnection->flushDns();
QMetaObject::invokeMethod(m_vpnConnection.get(), "addRoutes", Qt::QueuedConnection,
Q_ARG(QStringList, QStringList() << hostname));
}
QMetaObject::invokeMethod(m_vpnConnection.get(), "flushDns", Qt::QueuedConnection);
};
const auto &resolveCallback = [this, processSite](const QHostInfo &hostInfo) {
@ -70,6 +71,10 @@ void SitesController::removeSite(int index)
auto hostname = m_sitesModel->data(modelIndex, SitesModel::Roles::UrlRole).toString();
m_sitesModel->removeSite(modelIndex);
QMetaObject::invokeMethod(m_vpnConnection.get(), "deleteRoutes", Qt::QueuedConnection,
Q_ARG(QStringList, QStringList() << hostname));
QMetaObject::invokeMethod(m_vpnConnection.get(), "flushDns", Qt::QueuedConnection);
emit finished(tr("Site removed: ") + hostname);
}
@ -124,8 +129,8 @@ void SitesController::importSites(bool replaceExisting)
m_sitesModel->addSites(sites, replaceExisting);
m_vpnConnection->addRoutes(QStringList() << ips);
m_vpnConnection->flushDns();
QMetaObject::invokeMethod(m_vpnConnection.get(), "addRoutes", Qt::QueuedConnection, Q_ARG(QStringList, ips));
QMetaObject::invokeMethod(m_vpnConnection.get(), "flushDns", Qt::QueuedConnection);
emit finished(tr("Import completed"));
}

View file

@ -66,18 +66,14 @@ void SitesLogic::onPushButtonAddCustomSitesClicked()
m_settings->addVpnSite(mode, newSite, ip);
if (!ip.isEmpty()) {
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "addRoutes",
Qt::QueuedConnection,
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "addRoutes", Qt::QueuedConnection,
Q_ARG(QStringList, QStringList() << ip));
}
else if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) {
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "addRoutes",
Qt::QueuedConnection,
} else if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) {
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "addRoutes", Qt::QueuedConnection,
Q_ARG(QStringList, QStringList() << newSite));
}
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "flushDns",
Qt::QueuedConnection);
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "flushDns", Qt::QueuedConnection);
onUpdatePage();
};
@ -124,19 +120,16 @@ void SitesLogic::onPushButtonSitesDeleteClicked(QStringList items)
return;
// sites.append(siteModel->data(row, 0).toString());
if (uiLogic()->m_vpnConnection && uiLogic()->m_vpnConnection->connectionState() == VpnProtocol::Connected) {
ips.append(siteModel->data(row, 1).toString());
}
// if (uiLogic()->m_vpnConnection && uiLogic()->m_vpnConnection->connectionState() == VpnProtocol::Connected) {
// ips.append(siteModel->data(row, 1).toString());
// }
}
m_settings->removeVpnSites(mode, sites);
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "deleteRoutes",
Qt::QueuedConnection,
Q_ARG(QStringList, ips));
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "deleteRoutes", Qt::QueuedConnection, Q_ARG(QStringList, ips));
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "flushDns",
Qt::QueuedConnection);
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "flushDns", Qt::QueuedConnection);
onUpdatePage();
}
@ -197,12 +190,9 @@ void SitesLogic::onPushButtonSitesImportClicked(const QString &fileName)
m_settings->addVpnIps(mode, ips);
m_settings->addVpnSites(mode, sites);
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "addRoutes",
Qt::QueuedConnection,
Q_ARG(QStringList, ips));
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "addRoutes", Qt::QueuedConnection, Q_ARG(QStringList, ips));
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "flushDns",
Qt::QueuedConnection);
QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "flushDns", Qt::QueuedConnection);
onUpdatePage();
}

View file

@ -14,6 +14,9 @@ import "../Config"
PageType {
id: root
Component.onCompleted: PageController.enableTabBar(false)
Component.onDestruction: PageController.enableTabBar(true)
SortFilterProxyModel {
id: proxyServersModel
sourceModel: ServersModel

View file

@ -299,6 +299,12 @@ PageType {
checked: additionalClientCommands !== ""
text: qsTr("Additional client configuration commands")
onCheckedChanged: {
if (!checked) {
additionalClientCommands = ""
}
}
}
TextAreaType {

View file

@ -21,7 +21,7 @@ PageType {
function onRestoreBackupFinished() {
PageController.showNotificationMessage(qsTr("Settings restored from backup file"))
goToStartPage()
//goToStartPage()
PageController.goToPageHome()
}
}

View file

@ -166,7 +166,7 @@ PageType {
questionDrawer.visible = false
goToPage(PageEnum.PageDeinstalling)
if (ServersModel.isDefaultServerCurrentlyProcessed() && ConnectionController.isConnected) {
ConnectionController.closeVpnConnection()
ConnectionController.closeConnection()
}
InstallController.removeAllContainers()
}

View file

@ -14,6 +14,9 @@ import "../Config"
PageType {
id: root
Component.onCompleted: PageController.enableTabBar(false)
Component.onDestruction: PageController.enableTabBar(true)
Connections {
target: InstallController

View file

@ -18,12 +18,12 @@ PageType {
function onGoToPageHome() {
tabBar.currentIndex = 0
tabBarStackView.goToTabBarPage(PageController.getPagePath(PageEnum.PageHome))
tabBarStackView.goToTabBarPage(PageEnum.PageHome)
}
function onGoToPageSettings() {
tabBar.currentIndex = 2
tabBarStackView.goToTabBarPage(PageController.getPagePath(PageEnum.PageSettings))
tabBarStackView.goToTabBarPage(PageEnum.PageSettings)
}
function onGoToPageViewConfig() {
@ -37,6 +37,10 @@ PageType {
tabBar.enabled = !visible
}
function onEnableTabBar(enabled) {
tabBar.enabled = enabled
}
function onClosePage() {
if (tabBarStackView.depth <= 1) {
return

View file

@ -157,9 +157,6 @@ void UiLogic::initializeUiLogic()
// }
m_selectedServerIndex = m_settings->defaultServerIndex();
qInfo().noquote() << QString("Started %1 version %2").arg(APPLICATION_NAME).arg(APP_VERSION);
qInfo().noquote() << QString("%1 (%2)").arg(QSysInfo::prettyProductName()).arg(QSysInfo::currentCpuArchitecture());
}
void UiLogic::showOnStartup()