mirror of
https://github.com/outbackdingo/amnezia-client.git
synced 2026-01-27 10:18:14 +00:00
* There's a common issue of building iOS apps on Qt 6.8 because of new introduced ffmpeg dependency in multimedia Qt package ref: https://community.esri.com/t5/qt-maps-sdk-questions/build-failure-on-ios-with-qt-6-8/m-p/1548701#M5339 * Cmake related changes * Source code changes * Various entitlements * Ci-cd config update * Resources changes * Submodules updated * Remove me * QtWidget exclusion omitted * Distribution errors fixed * Outdated files deleted * macos_ne cmake fixed * fix: update provisioning profile specifiers for macOS network extension * fix: update provisioning profile specifiers and code sign flags for macOS build * Revert me (temporary 3rd-build commit pointer) * fix: Welcome screen fix * fix: ci/cd hanging forever fix * fix: Fixed error popup on macos on file save * refactor: rename networkextension target to AmneziaVPNNetworkExtension in macos build configuration * feat: add autostart support for Mac App Store builds on macOS Fixes: QA-8 * feat: add debug logging to Autostart functionality on macOS * Revert "feat: add autostart support for Mac App Store builds on macOS" This reverts commit 3bd25656fb4986d01e5bd6dd265f7279a73bd2a8. * feat: add platform-specific close window behavior for macOS App Store build with Network Extension Closes: QA-12 * When the application starts with "Start minimized" enabled on macOS (especially the sandboxed App-Store build compiled with MACOS_NE), fully hiding the window prevents it from being restored by clicking the Dock icon. The proper behaviour is to start the window in the *minimized* state instead. That way the window is still part of the window list and the system automatically brings it back when the user clicks the Dock icon, replicating the native experience. On the other platforms we keep the old behaviour (hide the window completely and rely on the tray icon), therefore we switch at runtime by checking the current OS. Closes: QA-7 Closes: QA-8 * Revert "When the application starts with "Start minimized" enabled on macOS (especially the" This reverts commit 7b0d17987cdfdbc4cedc3822bf3fd2e4973da452. * feat: MACOS_NE systray menu support * feat: add macOS notification handler and install event filter on main window * feat: implement custom close behavior for Amnezia application on different platforms * fix: update provisioning profile specifiers for macos builds * fix: Fatal error in logs CLI-216 * fix: disabled unavailable on macos ne service logs * fix: dock icon now hides only when window is closed; menubar icon shows always Initial state of the docker icon to be presented follows "Start minimized" setting in app settings. * temp-fix: temporary disable all OpenVPN options of VPN on MACOS_NE since it's not working yet. * fix: build script updated * feat: add macOS NE build workflow to GitHub Actions * fix: Not working Auto start toggle is hidden * fix: Log spamming during xray connection fixed * 3rd-prebuild points to commit that stores macos_ne universal binaries. * fix: missing native dependency on linking stage fixed * chore: update link to submodule --------- Co-authored-by: vladimir.kuznetsov <nethiuswork@gmail.com>
171 lines
4.6 KiB
C++
171 lines
4.6 KiB
C++
#include "systemController.h"
|
|
|
|
#include <QDesktopServices>
|
|
#include <QDir>
|
|
#include <QEventLoop>
|
|
#include <QFile>
|
|
#include <QFileInfo>
|
|
#include <QQuickItem>
|
|
#include <QStandardPaths>
|
|
#include <QUrl>
|
|
#include <QtConcurrent>
|
|
|
|
#ifdef Q_OS_ANDROID
|
|
#include "platforms/android/android_controller.h"
|
|
#endif
|
|
|
|
#if defined(Q_OS_IOS) || defined(MACOS_NE)
|
|
#include "platforms/ios/ios_controller.h"
|
|
#include <CoreFoundation/CoreFoundation.h>
|
|
#endif
|
|
|
|
SystemController::SystemController(const std::shared_ptr<Settings> &settings, QObject *parent)
|
|
: QObject(parent), m_settings(settings)
|
|
{
|
|
}
|
|
|
|
void SystemController::saveFile(const QString &fileName, const QString &data)
|
|
{
|
|
#if defined Q_OS_ANDROID
|
|
AndroidController::instance()->saveFile(fileName, data);
|
|
return;
|
|
#endif
|
|
|
|
#ifdef Q_OS_IOS
|
|
QUrl fileUrl = QDir::tempPath() + "/" + fileName;
|
|
QFile file(fileUrl.toString());
|
|
#else
|
|
QFile file(fileName);
|
|
#endif
|
|
|
|
// todo check if save successful
|
|
file.open(QIODevice::WriteOnly);
|
|
file.write(data.toUtf8());
|
|
file.close();
|
|
|
|
#ifdef Q_OS_IOS
|
|
QStringList filesToSend;
|
|
filesToSend.append(fileUrl.toString());
|
|
// todo check if save successful
|
|
IosController::Instance()->shareText(filesToSend);
|
|
return;
|
|
#else
|
|
QFileInfo fi(fileName);
|
|
|
|
#ifdef Q_OS_MAC
|
|
const auto url = "file://" + fi.absoluteDir().absolutePath();
|
|
#else
|
|
const auto url = fi.absoluteDir().absolutePath();
|
|
#endif
|
|
|
|
#ifndef MACOS_NE
|
|
QDesktopServices::openUrl(url);
|
|
#endif
|
|
#endif
|
|
}
|
|
|
|
bool SystemController::readFile(const QString &fileName, QByteArray &data)
|
|
{
|
|
#ifdef Q_OS_ANDROID
|
|
int fd = AndroidController::instance()->getFd(fileName);
|
|
if (fd == -1) return false;
|
|
QFile file;
|
|
if(!file.open(fd, QIODevice::ReadOnly)) return false;
|
|
data = file.readAll();
|
|
AndroidController::instance()->closeFd();
|
|
#else
|
|
QFile file(fileName);
|
|
if (!file.open(QIODevice::ReadOnly)) return false;
|
|
data = file.readAll();
|
|
#endif
|
|
return true;
|
|
}
|
|
|
|
bool SystemController::readFile(const QString &fileName, QString &data)
|
|
{
|
|
QByteArray byteArray;
|
|
if(!readFile(fileName, byteArray)) return false;
|
|
data = byteArray;
|
|
return true;
|
|
}
|
|
|
|
QString SystemController::getFileName(const QString &acceptLabel, const QString &nameFilter,
|
|
const QString &selectedFile, const bool isSaveMode, const QString &defaultSuffix)
|
|
{
|
|
QString fileName;
|
|
#ifdef Q_OS_ANDROID
|
|
Q_ASSERT(!isSaveMode);
|
|
return AndroidController::instance()->openFile(nameFilter);
|
|
#endif
|
|
|
|
#ifdef Q_OS_IOS
|
|
|
|
fileName = IosController::Instance()->openFile();
|
|
if (fileName.isEmpty()) {
|
|
return fileName;
|
|
}
|
|
|
|
CFURLRef url = CFURLCreateWithFileSystemPath(
|
|
kCFAllocatorDefault,
|
|
CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(fileName.unicode()), fileName.length()),
|
|
kCFURLPOSIXPathStyle, 0);
|
|
|
|
if (!CFURLStartAccessingSecurityScopedResource(url)) {
|
|
qDebug() << "Could not access path " << QUrl::fromLocalFile(fileName).toString();
|
|
}
|
|
|
|
return fileName;
|
|
#endif
|
|
|
|
QObject *mainFileDialog = m_qmlRoot->findChild<QObject>("mainFileDialog").parent();
|
|
if (!mainFileDialog) {
|
|
return "";
|
|
}
|
|
|
|
mainFileDialog->setProperty("acceptLabel", QVariant::fromValue(acceptLabel));
|
|
mainFileDialog->setProperty("nameFilters", QVariant::fromValue(QStringList(nameFilter)));
|
|
mainFileDialog->setProperty("defaultSuffix", QVariant::fromValue(defaultSuffix));
|
|
mainFileDialog->setProperty("isSaveMode", QVariant::fromValue(isSaveMode));
|
|
if (!selectedFile.isEmpty()) {
|
|
mainFileDialog->setProperty("selectedFile", QVariant::fromValue(QUrl(selectedFile)));
|
|
}
|
|
QMetaObject::invokeMethod(mainFileDialog, "open");
|
|
|
|
bool isFileDialogAccepted = false;
|
|
QEventLoop wait;
|
|
QObject::connect(this, &SystemController::fileDialogClosed, [&wait, &isFileDialogAccepted](const bool isAccepted) {
|
|
isFileDialogAccepted = isAccepted;
|
|
wait.quit();
|
|
});
|
|
wait.exec();
|
|
QObject::disconnect(this, &SystemController::fileDialogClosed, nullptr, nullptr);
|
|
|
|
if (!isFileDialogAccepted) {
|
|
return "";
|
|
}
|
|
|
|
fileName = mainFileDialog->property("selectedFile").toString();
|
|
return QUrl(fileName).toLocalFile();
|
|
}
|
|
|
|
void SystemController::setQmlRoot(QObject *qmlRoot)
|
|
{
|
|
m_qmlRoot = qmlRoot;
|
|
}
|
|
|
|
bool SystemController::isAuthenticated()
|
|
{
|
|
#ifdef Q_OS_ANDROID
|
|
return AndroidController::instance()->requestAuthentication();
|
|
#else
|
|
return true;
|
|
#endif
|
|
}
|
|
|
|
void SystemController::sendTouch(float x, float y)
|
|
{
|
|
#ifdef Q_OS_ANDROID
|
|
AndroidController::instance()->sendTouch(x, y);
|
|
#endif
|
|
}
|