2024-01-20 16:02:35 +03:00
|
|
|
#ifndef AMNEZIA_APPLICATION_H
|
|
|
|
|
#define AMNEZIA_APPLICATION_H
|
|
|
|
|
|
|
|
|
|
#include <QCommandLineParser>
|
2024-05-16 06:19:56 -07:00
|
|
|
#include <QNetworkAccessManager>
|
2024-01-20 16:02:35 +03:00
|
|
|
#include <QQmlApplicationEngine>
|
|
|
|
|
#include <QQmlContext>
|
|
|
|
|
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
2025-08-10 06:12:19 +03:00
|
|
|
#include <QGuiApplication>
|
2024-01-20 16:02:35 +03:00
|
|
|
#else
|
2025-08-10 06:12:19 +03:00
|
|
|
#include <QApplication>
|
2024-01-20 16:02:35 +03:00
|
|
|
#endif
|
2025-02-22 14:42:09 +07:00
|
|
|
#include <QClipboard>
|
2026-05-13 17:41:26 +03:00
|
|
|
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
|
|
|
|
#include <QEvent>
|
|
|
|
|
#endif
|
2024-01-20 16:02:35 +03:00
|
|
|
|
2025-02-15 11:50:42 +07:00
|
|
|
#include "core/controllers/coreController.h"
|
2026-04-30 14:53:03 +08:00
|
|
|
#include "secureQSettings.h"
|
|
|
|
|
#include "vpnConnection.h"
|
|
|
|
|
#include "ui/models/containerProps.h"
|
|
|
|
|
#include "ui/models/protocolProps.h"
|
2024-01-20 16:02:35 +03:00
|
|
|
|
|
|
|
|
#define amnApp (static_cast<AmneziaApplication *>(QCoreApplication::instance()))
|
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
2025-08-10 06:12:19 +03:00
|
|
|
#define AMNEZIA_BASE_CLASS QGuiApplication
|
2024-01-20 16:02:35 +03:00
|
|
|
#else
|
2025-08-10 06:12:19 +03:00
|
|
|
#define AMNEZIA_BASE_CLASS QApplication
|
2024-01-20 16:02:35 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
class AmneziaApplication : public AMNEZIA_BASE_CLASS
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
AmneziaApplication(int &argc, char *argv[]);
|
|
|
|
|
virtual ~AmneziaApplication();
|
|
|
|
|
|
|
|
|
|
void init();
|
|
|
|
|
void registerTypes();
|
|
|
|
|
void loadFonts();
|
|
|
|
|
bool parseCommands();
|
|
|
|
|
|
2025-08-10 06:12:19 +03:00
|
|
|
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) && !defined(MACOS_NE)
|
2024-09-25 11:22:16 +05:00
|
|
|
void startLocalServer();
|
2026-05-14 16:28:31 +03:00
|
|
|
static void markSecondaryInstanceForDeepLink();
|
2024-09-25 11:22:16 +05:00
|
|
|
#endif
|
|
|
|
|
|
2024-01-20 16:02:35 +03:00
|
|
|
QQmlApplicationEngine *qmlEngine() const;
|
2025-02-22 14:42:09 +07:00
|
|
|
QNetworkAccessManager *networkManager();
|
|
|
|
|
QClipboard *getClipboard();
|
2024-01-20 16:02:35 +03:00
|
|
|
|
2025-12-11 18:54:24 +08:00
|
|
|
public slots:
|
|
|
|
|
void forceQuit();
|
|
|
|
|
|
2024-01-20 16:02:35 +03:00
|
|
|
private:
|
2025-12-11 18:54:24 +08:00
|
|
|
static bool m_forceQuit;
|
2024-01-20 16:02:35 +03:00
|
|
|
QQmlApplicationEngine *m_engine {};
|
2026-04-30 14:53:03 +08:00
|
|
|
SecureQSettings* m_settings;
|
2024-01-20 16:02:35 +03:00
|
|
|
|
2025-02-15 11:50:42 +07:00
|
|
|
QScopedPointer<CoreController> m_coreController;
|
|
|
|
|
|
2024-01-20 16:02:35 +03:00
|
|
|
QSharedPointer<ContainerProps> m_containerProps;
|
|
|
|
|
QSharedPointer<ProtocolProps> m_protocolProps;
|
|
|
|
|
|
|
|
|
|
QCommandLineParser m_parser;
|
|
|
|
|
|
2025-09-03 08:03:45 +04:00
|
|
|
QCommandLineOption m_optAutostart;
|
|
|
|
|
QCommandLineOption m_optCleanup;
|
2025-12-11 18:54:24 +08:00
|
|
|
QCommandLineOption m_optConnect;
|
|
|
|
|
QCommandLineOption m_optImport;
|
2025-09-03 08:03:45 +04:00
|
|
|
|
2026-05-13 17:41:26 +03:00
|
|
|
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
|
|
|
|
void deliverVpnDeepLink(const QString &payload);
|
2026-05-14 16:28:31 +03:00
|
|
|
QString m_pendingVpnDeepLink;
|
2026-05-13 17:41:26 +03:00
|
|
|
#endif
|
|
|
|
|
|
2024-01-20 16:02:35 +03:00
|
|
|
QSharedPointer<VpnConnection> m_vpnConnection;
|
2025-02-06 15:26:47 +07:00
|
|
|
|
2024-05-16 06:19:56 -07:00
|
|
|
QNetworkAccessManager *m_nam;
|
2025-08-10 06:12:19 +03:00
|
|
|
protected:
|
|
|
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
2026-05-13 17:41:26 +03:00
|
|
|
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
|
|
|
|
bool event(QEvent *event) override;
|
|
|
|
|
#endif
|
2024-01-20 16:02:35 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // AMNEZIA_APPLICATION_H
|