Files

84 lines
2.0 KiB
C++
Raw Permalink Normal View History

2021-08-09 00:41:52 +07:00
#include <QDebug>
2023-06-30 00:21:56 +01:00
#include <QTimer>
2020-11-23 16:20:25 +03:00
2022-08-25 12:47:02 +03:00
#include "amnezia_application.h"
2025-12-01 10:45:06 +08:00
#include "core/osSignalHandler.h"
#include "migrations.h"
#include "version.h"
2021-08-19 01:51:02 +03:00
Prebuilt binaries for third-party submodules (#252) * Add prebuilt submodule * Remove Android native library * Add links for Android prebuilt library * Update OpenSSL to prebuilt binaries * Setup links for prebuilt OpenSSL * Set correct OpenSSL header dir * Update prebuilt submodule * Use static OpenSSL for linux build * Use prebuilt binary from 3rd-prebuilt for Win installer * Use prebuilt binary from 3rd-prebuilt for Linux installer * Use prebuilt binary from 3rd-prebuilt for MacOS installer * Use Android prebuilt openvpn libs * Cleanup some unneeded code * Add new maven repo for gradle-versions-plugin * Use jitpack version of jsocks * Fix some unnecessary header copy * Fix issue with package name of original WG libs * Change submodule path to https (3rd-prebuilt) * Fix windows installer * MacOS deploy fixes * NetworkChange detection for OpenVPN protocol (#256) * NetworkChange detection for OpenVPN protocol * Update android native libs * Always on VPN mode for OpenVPN, Cloak+OpenVPN * Set foregroundService type * Android 14 require to set foregroundServiceType * Remove unused code and cleanup submodules * Cleanup gradle build script * Fix start button status * Pull OpenSSL prebuilt for MacOS, iOS * Update links for OpenSSL MacOS, iOS prebuilt * Update OpenSSL binaries path * Refactor some OpenSSL includes * Update MacOS OpenVPN binary with statically linked dependency * Use prebilt for LibSSH * Android resources cleanup * Set static runtime linux * Use shared LibSSH for Android * Update SS Android lib name * Fix Linux install path and file permissions * Feature/iOS GitHub actions (#265) * Move Android cpp code to openvpn-pt-android repo * Remove unused OpenVPN2 Android Libs * Cleanup Gemfile --------- Co-authored-by: Mazay B <pokamest@gmail.com>
2023-08-04 20:35:43 +03:00
#include <QTimer>
2021-02-24 23:40:57 +03:00
#ifdef Q_OS_WIN
#include "Windows.h"
2021-02-24 23:40:57 +03:00
#endif
2022-07-11 16:08:57 +06:00
#if defined(Q_OS_IOS)
#include "platforms/ios/QtAppDelegate-C-Interface.h"
2022-07-11 16:08:57 +06:00
#endif
feat: macos with network extension Implementation (#1468) * 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>
2025-08-10 06:12:19 +03:00
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) && !defined(MACOS_NE)
bool isAnotherInstanceRunning()
{
QLocalSocket socket;
socket.connectToServer("DefaultVPNInstance");
if (socket.waitForConnected(500)) {
qWarning() << "DefaultVPN is already running";
return true;
}
return false;
}
#endif
2020-11-23 16:20:25 +03:00
int main(int argc, char *argv[])
{
Migrations migrationsManager;
migrationsManager.doMigrations();
2021-02-24 23:40:57 +03:00
#ifdef Q_OS_WIN
AllowSetForegroundWindow(ASFW_ANY);
#endif
2023-10-08 20:08:32 +03:00
#ifdef Q_OS_ANDROID
// QTBUG-95974 QTBUG-95764 QTBUG-102168
2023-10-08 20:08:32 +03:00
qputenv("QT_ANDROID_DISABLE_ACCESSIBILITY", "1");
2024-04-14 14:07:26 +03:00
qputenv("ANDROID_OPENSSL_SUFFIX", "_3");
2023-10-08 20:08:32 +03:00
#endif
2022-08-25 12:47:02 +03:00
AmneziaApplication app(argc, argv);
2025-12-01 10:45:06 +08:00
OsSignalHandler::setup();
2021-02-24 23:40:57 +03:00
feat: macos with network extension Implementation (#1468) * 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>
2025-08-10 06:12:19 +03:00
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) && !defined(MACOS_NE)
if (isAnotherInstanceRunning()) {
QTimer::singleShot(1000, &app, [&]() { app.quit(); });
2021-03-06 14:59:55 +03:00
return app.exec();
}
app.startLocalServer();
2021-08-08 18:10:09 +03:00
#endif
2022-08-25 12:47:02 +03:00
// Allow to raise app window if secondary instance launched
2021-02-24 23:40:57 +03:00
#ifdef Q_OS_WIN
AllowSetForegroundWindow(0);
#endif
2020-11-23 16:20:25 +03:00
2022-08-25 12:47:02 +03:00
app.registerTypes();
2020-11-23 16:20:25 +03:00
2020-12-04 00:45:21 +03:00
app.setApplicationName(APPLICATION_NAME);
app.setOrganizationName(ORGANIZATION_NAME);
app.setApplicationDisplayName(APPLICATION_NAME);
2020-11-23 16:20:25 +03:00
2022-08-25 12:47:02 +03:00
app.loadFonts();
2022-08-31 16:54:46 +03:00
bool doExec = app.parseCommands();
2021-02-24 23:40:57 +03:00
2022-08-31 16:54:46 +03:00
if (doExec) {
app.init();
2024-03-09 00:21:57 +03:00
qInfo().noquote() << QString("Started %1 version %2 %3").arg(APPLICATION_NAME, APP_VERSION, GIT_COMMIT_HASH);
qInfo().noquote() << QString("%1 (%2)").arg(QSysInfo::prettyProductName(), QSysInfo::currentCpuArchitecture());
qInfo().noquote() << QString("SSL backend: %1").arg(QSslSocket::sslLibraryVersionString());
2022-08-31 16:54:46 +03:00
return app.exec();
}
return 0;
2020-11-23 16:20:25 +03:00
}