Files

82 lines
1.9 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"
#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
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
bool isAnotherInstanceRunning()
{
QLocalSocket socket;
socket.connectToServer("AmneziaVPNInstance");
if (socket.waitForConnected(500)) {
qWarning() << "AmneziaVPN 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);
2021-02-24 23:40:57 +03:00
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
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
}