chore: added changelog text processing depend on OS
This commit is contained in:
parent
c627b5a3cc
commit
449a8070c1
5 changed files with 68 additions and 43 deletions
|
|
@ -141,6 +141,9 @@ void CoreController::initControllers()
|
||||||
|
|
||||||
m_apiConfigsController.reset(new ApiConfigsController(m_serversModel, m_apiServicesModel, m_settings));
|
m_apiConfigsController.reset(new ApiConfigsController(m_serversModel, m_apiServicesModel, m_settings));
|
||||||
m_engine->rootContext()->setContextProperty("ApiConfigsController", m_apiConfigsController.get());
|
m_engine->rootContext()->setContextProperty("ApiConfigsController", m_apiConfigsController.get());
|
||||||
|
|
||||||
|
m_updateController.reset(new UpdateController(m_settings));
|
||||||
|
m_engine->rootContext()->setContextProperty("UpdateController", m_updateController.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreController::initAndroidController()
|
void CoreController::initAndroidController()
|
||||||
|
|
@ -213,6 +216,7 @@ void CoreController::initSignalHandlers()
|
||||||
initAutoConnectHandler();
|
initAutoConnectHandler();
|
||||||
initAmneziaDnsToggledHandler();
|
initAmneziaDnsToggledHandler();
|
||||||
initPrepareConfigHandler();
|
initPrepareConfigHandler();
|
||||||
|
initUpdateFoundHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreController::initNotificationHandler()
|
void CoreController::initNotificationHandler()
|
||||||
|
|
@ -339,6 +343,16 @@ void CoreController::initPrepareConfigHandler()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CoreController::initUpdateFoundHandler()
|
||||||
|
{
|
||||||
|
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||||
|
connect(m_updateController.get(), &UpdateController::updateFound, this,
|
||||||
|
[this]() { QTimer::singleShot(1000, this, [this]() { m_pageController->showChangelogDrawer(); }); });
|
||||||
|
|
||||||
|
m_updateController->checkForUpdates();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
QSharedPointer<PageController> CoreController::pageController() const
|
QSharedPointer<PageController> CoreController::pageController() const
|
||||||
{
|
{
|
||||||
return m_pageController;
|
return m_pageController;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#include "ui/controllers/settingsController.h"
|
#include "ui/controllers/settingsController.h"
|
||||||
#include "ui/controllers/sitesController.h"
|
#include "ui/controllers/sitesController.h"
|
||||||
#include "ui/controllers/systemController.h"
|
#include "ui/controllers/systemController.h"
|
||||||
|
#include "ui/controllers/updateController.h"
|
||||||
|
|
||||||
#include "ui/models/containers_model.h"
|
#include "ui/models/containers_model.h"
|
||||||
#include "ui/models/languageModel.h"
|
#include "ui/models/languageModel.h"
|
||||||
|
|
@ -80,6 +81,7 @@ private:
|
||||||
void initAutoConnectHandler();
|
void initAutoConnectHandler();
|
||||||
void initAmneziaDnsToggledHandler();
|
void initAmneziaDnsToggledHandler();
|
||||||
void initPrepareConfigHandler();
|
void initPrepareConfigHandler();
|
||||||
|
void initUpdateFoundHandler();
|
||||||
|
|
||||||
QQmlApplicationEngine *m_engine {}; // TODO use parent child system here?
|
QQmlApplicationEngine *m_engine {}; // TODO use parent child system here?
|
||||||
std::shared_ptr<Settings> m_settings;
|
std::shared_ptr<Settings> m_settings;
|
||||||
|
|
@ -102,6 +104,7 @@ private:
|
||||||
QScopedPointer<SitesController> m_sitesController;
|
QScopedPointer<SitesController> m_sitesController;
|
||||||
QScopedPointer<SystemController> m_systemController;
|
QScopedPointer<SystemController> m_systemController;
|
||||||
QScopedPointer<AppSplitTunnelingController> m_appSplitTunnelingController;
|
QScopedPointer<AppSplitTunnelingController> m_appSplitTunnelingController;
|
||||||
|
QScopedPointer<UpdateController> m_updateController;
|
||||||
|
|
||||||
QScopedPointer<ApiSettingsController> m_apiSettingsController;
|
QScopedPointer<ApiSettingsController> m_apiSettingsController;
|
||||||
QScopedPointer<ApiConfigsController> m_apiConfigsController;
|
QScopedPointer<ApiConfigsController> m_apiConfigsController;
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,13 @@ namespace
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
const QString installerPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN.dmg";
|
const QString installerPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN.dmg";
|
||||||
#elif defined Q_OS_WINDOWS
|
#elif defined Q_OS_WINDOWS
|
||||||
const QString installerPath =
|
const QString installerPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN_installer.exe";
|
||||||
QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN_installer.exe";
|
|
||||||
#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
||||||
const QString installerPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN.tar.zip";
|
const QString installerPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN.tar.zip";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateController::UpdateController(const std::shared_ptr<Settings> &settings, QObject *parent)
|
UpdateController::UpdateController(const std::shared_ptr<Settings> &settings, QObject *parent) : QObject(parent), m_settings(settings)
|
||||||
: QObject(parent), m_settings(settings)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,7 +35,34 @@ QString UpdateController::getHeaderText()
|
||||||
|
|
||||||
QString UpdateController::getChangelogText()
|
QString UpdateController::getChangelogText()
|
||||||
{
|
{
|
||||||
return m_changelogText;
|
QStringList lines = m_changelogText.split("\n");
|
||||||
|
QStringList filteredChangeLogText;
|
||||||
|
bool add = false;
|
||||||
|
QString osSection;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
osSection = "### Windows";
|
||||||
|
#elif defined(Q_OS_MACOS)
|
||||||
|
osSection = "### macOS";
|
||||||
|
#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
||||||
|
osSection = "### Linux";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (const QString &line : lines) {
|
||||||
|
if (line.startsWith("### General")) {
|
||||||
|
add = true;
|
||||||
|
} else if (line.startsWith("### ") && line != osSection) {
|
||||||
|
add = false;
|
||||||
|
} else if (line == osSection) {
|
||||||
|
add = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (add) {
|
||||||
|
filteredChangeLogText.append(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return filteredChangeLogText.join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateController::checkForUpdates()
|
void UpdateController::checkForUpdates()
|
||||||
|
|
@ -47,7 +72,7 @@ void UpdateController::checkForUpdates()
|
||||||
QString endpoint = "https://api.github.com/repos/amnezia-vpn/amnezia-client/releases/latest";
|
QString endpoint = "https://api.github.com/repos/amnezia-vpn/amnezia-client/releases/latest";
|
||||||
request.setUrl(endpoint);
|
request.setUrl(endpoint);
|
||||||
|
|
||||||
QNetworkReply *reply = amnApp->manager()->get(request);
|
QNetworkReply *reply = amnApp->networkManager()->get(request);
|
||||||
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [this, reply]() {
|
QObject::connect(reply, &QNetworkReply::finished, [this, reply]() {
|
||||||
if (reply->error() == QNetworkReply::NoError) {
|
if (reply->error() == QNetworkReply::NoError) {
|
||||||
|
|
@ -127,21 +152,19 @@ void UpdateController::runInstaller()
|
||||||
request.setTransferTimeout(7000);
|
request.setTransferTimeout(7000);
|
||||||
request.setUrl(m_downloadUrl);
|
request.setUrl(m_downloadUrl);
|
||||||
|
|
||||||
QNetworkReply *reply = amnApp->manager()->get(request);
|
QNetworkReply *reply = amnApp->networkManager()->get(request);
|
||||||
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [this, reply]() {
|
QObject::connect(reply, &QNetworkReply::finished, [this, reply]() {
|
||||||
if (reply->error() == QNetworkReply::NoError) {
|
if (reply->error() == QNetworkReply::NoError) {
|
||||||
QFile file(installerPath);
|
QFile file(installerPath);
|
||||||
if (!file.open(QIODevice::WriteOnly)) {
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
logger.error() << "Failed to open installer file for writing:" << installerPath
|
logger.error() << "Failed to open installer file for writing:" << installerPath << "Error:" << file.errorString();
|
||||||
<< "Error:" << file.errorString();
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.write(reply->readAll()) == -1) {
|
if (file.write(reply->readAll()) == -1) {
|
||||||
logger.error() << "Failed to write installer data to file:" << installerPath
|
logger.error() << "Failed to write installer data to file:" << installerPath << "Error:" << file.errorString();
|
||||||
<< "Error:" << file.errorString();
|
|
||||||
file.close();
|
file.close();
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
return;
|
return;
|
||||||
|
|
@ -228,8 +251,8 @@ int UpdateController::runMacInstaller(const QString &installerPath)
|
||||||
|
|
||||||
// Start detached process
|
// Start detached process
|
||||||
qint64 pid;
|
qint64 pid;
|
||||||
bool success = QProcess::startDetached(
|
bool success =
|
||||||
"/bin/bash", QStringList() << scriptPath << extractDir.path() << installerPath, extractDir.path(), &pid);
|
QProcess::startDetached("/bin/bash", QStringList() << scriptPath << extractDir.path() << installerPath, extractDir.path(), &pid);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
logger.info() << "Installation process started with PID:" << pid;
|
logger.info() << "Installation process started with PID:" << pid;
|
||||||
|
|
@ -273,8 +296,8 @@ int UpdateController::runLinuxInstaller(const QString &installerPath)
|
||||||
|
|
||||||
// Start detached process
|
// Start detached process
|
||||||
qint64 pid;
|
qint64 pid;
|
||||||
bool success = QProcess::startDetached(
|
bool success =
|
||||||
"/bin/bash", QStringList() << scriptPath << extractDir.path() << installerPath, extractDir.path(), &pid);
|
QProcess::startDetached("/bin/bash", QStringList() << scriptPath << extractDir.path() << installerPath, extractDir.path(), &pid);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
logger.info() << "Installation process started with PID:" << pid;
|
logger.info() << "Installation process started with PID:" << pid;
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "router.h"
|
#include "router.h"
|
||||||
|
|
||||||
#include "../client/protocols/protocols_defs.h"
|
|
||||||
#include "../core/networkUtilities.h"
|
#include "../core/networkUtilities.h"
|
||||||
|
#include "../client/protocols/protocols_defs.h"
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include "../client/platforms/windows/daemon/windowsdaemon.h"
|
#include "../client/platforms/windows/daemon/windowsdaemon.h"
|
||||||
#include "../client/platforms/windows/daemon/windowsfirewall.h"
|
#include "../client/platforms/windows/daemon/windowsfirewall.h"
|
||||||
|
|
@ -55,23 +55,10 @@ int IpcServer::createPrivilegedProcess()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(pd.serverNode.data(), &QRemoteObjectHost::error, this, [pd](QRemoteObjectNode::ErrorCode errorCode) {
|
QObject::connect(pd.serverNode.data(), &QRemoteObjectHost::error, this,
|
||||||
qDebug() << "QRemoteObjectHost::error" << errorCode;
|
[pd](QRemoteObjectNode::ErrorCode errorCode) { qDebug() << "QRemoteObjectHost::error" << errorCode; });
|
||||||
});
|
|
||||||
|
|
||||||
QObject::connect(pd.serverNode.data(), &QRemoteObjectHost::destroyed, this,
|
QObject::connect(pd.serverNode.data(), &QRemoteObjectHost::destroyed, this, [pd]() { qDebug() << "QRemoteObjectHost::destroyed"; });
|
||||||
[pd]() { qDebug() << "QRemoteObjectHost::destroyed"; });
|
|
||||||
|
|
||||||
// connect(pd.ipcProcess.data(), &IpcServerProcess::finished, this, [this, pid=m_localpid](int exitCode,
|
|
||||||
// QProcess::ExitStatus exitStatus){
|
|
||||||
// qDebug() << "IpcServerProcess finished" << exitCode << exitStatus;
|
|
||||||
//// if (m_processes.contains(pid)) {
|
|
||||||
//// m_processes[pid].ipcProcess.reset();
|
|
||||||
//// m_processes[pid].serverNode.reset();
|
|
||||||
//// m_processes[pid].localServer.reset();
|
|
||||||
//// m_processes.remove(pid);
|
|
||||||
//// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
m_processes.insert(m_localpid, pd);
|
m_processes.insert(m_localpid, pd);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef IPCSERVER_H
|
#ifndef IPCSERVER_H
|
||||||
#define IPCSERVER_H
|
#define IPCSERVER_H
|
||||||
|
|
||||||
#include "../client/daemon/interfaceconfig.h"
|
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QLocalServer>
|
#include <QLocalServer>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QRemoteObjectNode>
|
#include <QRemoteObjectNode>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include "../client/daemon/interfaceconfig.h"
|
||||||
|
|
||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
#include "ipcserverprocess.h"
|
#include "ipcserverprocess.h"
|
||||||
|
|
@ -42,10 +42,8 @@ public:
|
||||||
private:
|
private:
|
||||||
int m_localpid = 0;
|
int m_localpid = 0;
|
||||||
|
|
||||||
struct ProcessDescriptor
|
struct ProcessDescriptor {
|
||||||
{
|
ProcessDescriptor (QObject *parent = nullptr) {
|
||||||
ProcessDescriptor(QObject *parent = nullptr)
|
|
||||||
{
|
|
||||||
serverNode = QSharedPointer<QRemoteObjectHost>(new QRemoteObjectHost(parent));
|
serverNode = QSharedPointer<QRemoteObjectHost>(new QRemoteObjectHost(parent));
|
||||||
ipcProcess = QSharedPointer<IpcServerProcess>(new IpcServerProcess(parent));
|
ipcProcess = QSharedPointer<IpcServerProcess>(new IpcServerProcess(parent));
|
||||||
tun2socksProcess = QSharedPointer<IpcProcessTun2Socks>(new IpcProcessTun2Socks(parent));
|
tun2socksProcess = QSharedPointer<IpcProcessTun2Socks>(new IpcProcessTun2Socks(parent));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue