From 6087375fb0b291ce7b5a951922bd41bd2b6a1142 Mon Sep 17 00:00:00 2001 From: dranik Date: Mon, 4 May 2026 23:38:27 +0300 Subject: [PATCH 1/4] Fixed: push notifications on VPN connect/disconnect --- client/android/res/values-ru/strings.xml | 3 + client/android/res/values/strings.xml | 3 + .../src/org/amnezia/vpn/AmneziaActivity.kt | 5 + .../org/amnezia/vpn/ServiceNotification.kt | 37 ++++++++ client/cmake/macos_ne.cmake | 2 + client/cmake/sources.cmake | 8 ++ client/core/controllers/coreController.h | 6 +- .../core/controllers/coreSignalHandlers.cpp | 9 +- .../platforms/android/android_controller.cpp | 10 ++ client/platforms/android/android_controller.h | 1 + .../android/android_notificationhandler.cpp | 19 ++++ .../android/android_notificationhandler.h | 16 ++++ .../platforms/ios/iosnotificationhandler.mm | 18 ++-- .../macos/macos_ne_vpn_notification.h | 8 ++ .../macos/macos_ne_vpn_notification.mm | 91 +++++++++++++++++++ client/ui/utils/notificationHandler.cpp | 9 +- .../utils/systemTrayNotificationHandler.cpp | 10 ++ 17 files changed, 238 insertions(+), 17 deletions(-) create mode 100644 client/platforms/android/android_notificationhandler.cpp create mode 100644 client/platforms/android/android_notificationhandler.h create mode 100644 client/platforms/macos/macos_ne_vpn_notification.h create mode 100644 client/platforms/macos/macos_ne_vpn_notification.mm diff --git a/client/android/res/values-ru/strings.xml b/client/android/res/values-ru/strings.xml index 5e35bba51..e0c066f36 100644 --- a/client/android/res/values-ru/strings.xml +++ b/client/android/res/values-ru/strings.xml @@ -24,5 +24,8 @@ Для показа уведомлений необходимо включить уведомления в системных настройках Открыть настройки уведомлений + Уведомления о VPN + Краткие оповещения при подключении и отключении VPN + Пожалуйста, установите приложение для просмотра файлов \ No newline at end of file diff --git a/client/android/res/values/strings.xml b/client/android/res/values/strings.xml index bf8d76d1d..bc2aa5e9b 100644 --- a/client/android/res/values/strings.xml +++ b/client/android/res/values/strings.xml @@ -24,5 +24,8 @@ To show notifications, you must enable notifications in the system settings Open notification settings + VPN connection alerts + Brief alerts when VPN connects or disconnects + Please install a file management utility to browse files \ No newline at end of file diff --git a/client/android/src/org/amnezia/vpn/AmneziaActivity.kt b/client/android/src/org/amnezia/vpn/AmneziaActivity.kt index dca70ee5c..04f604df4 100644 --- a/client/android/src/org/amnezia/vpn/AmneziaActivity.kt +++ b/client/android/src/org/amnezia/vpn/AmneziaActivity.kt @@ -1003,6 +1003,11 @@ class AmneziaActivity : QtActivity() { @Suppress("unused") fun isNotificationPermissionGranted(): Boolean = applicationContext.isNotificationPermissionGranted() + @Suppress("unused") + fun showVpnStateNotification(title: String, message: String) { + ServiceNotification.showVpnStateEvent(applicationContext, title, message) + } + @Suppress("unused") fun requestNotificationPermission() { val shouldShowPreRequest = shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS) diff --git a/client/android/src/org/amnezia/vpn/ServiceNotification.kt b/client/android/src/org/amnezia/vpn/ServiceNotification.kt index 47e8f2634..ac350119e 100644 --- a/client/android/src/org/amnezia/vpn/ServiceNotification.kt +++ b/client/android/src/org/amnezia/vpn/ServiceNotification.kt @@ -26,6 +26,9 @@ private const val OLD_NOTIFICATION_CHANNEL_ID: String = "org.amnezia.vpn.notific private const val NOTIFICATION_CHANNEL_ID: String = "org.amnezia.vpn.notifications" const val NOTIFICATION_ID = 1337 +const val VPN_STATE_EVENT_NOTIFICATION_ID = 1338 +private const val VPN_STATE_EVENT_CHANNEL_ID = "org.amnezia.vpn.vpn_state_events" + private const val GET_ACTIVITY_REQUEST_CODE = 0 private const val CONNECT_REQUEST_CODE = 1 private const val DISCONNECT_REQUEST_CODE = 2 @@ -162,8 +165,42 @@ class ServiceNotification(private val context: Context) { .setDescription(context.resources.getString(R.string.notificationChannelDescription)) .build() ) + createNotificationChannel( + Builder(VPN_STATE_EVENT_CHANNEL_ID, NotificationManagerCompat.IMPORTANCE_DEFAULT) + .setShowBadge(false) + .setSound(null, null) + .setVibrationEnabled(false) + .setLightsEnabled(false) + .setName(context.getString(R.string.vpnStateEventChannelName)) + .setDescription(context.getString(R.string.vpnStateEventChannelDescription)) + .build() + ) } } + + /** Brief alert when VPN connects or disconnects (invoked from Qt via AmneziaActivity). */ + fun showVpnStateEvent(context: Context, title: String, message: String) { + if (!context.isNotificationPermissionGranted()) return + val nm = NotificationManagerCompat.from(context) + val notification = NotificationCompat.Builder(context, VPN_STATE_EVENT_CHANNEL_ID) + .setSmallIcon(R.drawable.ic_amnezia_round) + .setContentTitle(title) + .setContentText(message) + .setPriority(NotificationCompat.PRIORITY_DEFAULT) + .setCategory(NotificationCompat.CATEGORY_STATUS) + .setAutoCancel(true) + .setOnlyAlertOnce(true) + .setContentIntent( + PendingIntent.getActivity( + context, + GET_ACTIVITY_REQUEST_CODE, + Intent(context, AmneziaActivity::class.java), + PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT + ) + ) + .build() + nm.notify(VPN_STATE_EVENT_NOTIFICATION_ID, notification) + } } } diff --git a/client/cmake/macos_ne.cmake b/client/cmake/macos_ne.cmake index ac1796ad0..840b6e5fa 100644 --- a/client/cmake/macos_ne.cmake +++ b/client/cmake/macos_ne.cmake @@ -31,6 +31,7 @@ set(LIBS ${LIBS} set(HEADERS ${HEADERS} + ${CMAKE_CURRENT_SOURCE_DIR}/platforms/macos/macos_ne_vpn_notification.h ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/ios_controller.h ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/ios_controller_wrapper.h ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/iosnotificationhandler.h @@ -42,6 +43,7 @@ set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/ios_contro set(SOURCES ${SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/platforms/macos/macos_ne_vpn_notification.mm ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/ios_controller.mm ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/ios_controller_wrapper.mm ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/iosnotificationhandler.mm diff --git a/client/cmake/sources.cmake b/client/cmake/sources.cmake index 497757757..13e15def4 100644 --- a/client/cmake/sources.cmake +++ b/client/cmake/sources.cmake @@ -84,6 +84,10 @@ if(NOT ANDROID) set(HEADERS ${HEADERS} ${CLIENT_ROOT_DIR}/ui/utils/notificationHandler.h ) +else() + set(HEADERS ${HEADERS} + ${CLIENT_ROOT_DIR}/platforms/android/android_notificationhandler.h + ) endif() set(SOURCES ${SOURCES} @@ -174,6 +178,10 @@ if(NOT ANDROID) set(SOURCES ${SOURCES} ${CLIENT_ROOT_DIR}/ui/utils/notificationHandler.cpp ) +else() + set(SOURCES ${SOURCES} + ${CLIENT_ROOT_DIR}/platforms/android/android_notificationhandler.cpp + ) endif() set(COMMON_FILES_H diff --git a/client/core/controllers/coreController.h b/client/core/controllers/coreController.h index 0d77c5167..57e3bff23 100644 --- a/client/core/controllers/coreController.h +++ b/client/core/controllers/coreController.h @@ -5,9 +5,7 @@ #include #include -#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) - #include "ui/utils/systemTrayNotificationHandler.h" -#endif +#include "ui/utils/systemTrayNotificationHandler.h" #include "ui/controllers/api/subscriptionUiController.h" #include "ui/controllers/api/apiNewsUiController.h" @@ -141,9 +139,7 @@ private: SecureServersRepository* m_serversRepository; SecureAppSettingsRepository* m_appSettingsRepository; -#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) NotificationHandler* m_notificationHandler; -#endif QMetaObject::Connection m_reloadConfigErrorOccurredConnection; diff --git a/client/core/controllers/coreSignalHandlers.cpp b/client/core/controllers/coreSignalHandlers.cpp index 449a8af1d..46d91207c 100644 --- a/client/core/controllers/coreSignalHandlers.cpp +++ b/client/core/controllers/coreSignalHandlers.cpp @@ -407,9 +407,12 @@ void CoreSignalHandlers::initNotificationHandler() &ConnectionUiController::closeConnection); connect(m_coreController, &CoreController::translationsUpdated, m_coreController->m_notificationHandler, &NotificationHandler::onTranslationsUpdated); - auto* trayHandler = qobject_cast(m_coreController->m_notificationHandler); - connect(m_coreController, &CoreController::websiteUrlChanged, trayHandler, &SystemTrayNotificationHandler::updateWebsiteUrl); -#endif +#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) + if (auto *trayHandler = qobject_cast(m_coreController->m_notificationHandler)) { + connect(m_coreController, &CoreController::websiteUrlChanged, trayHandler, &SystemTrayNotificationHandler::updateWebsiteUrl); + } +#endif +#endif } void CoreSignalHandlers::initUpdateFoundHandler() diff --git a/client/platforms/android/android_controller.cpp b/client/platforms/android/android_controller.cpp index c7f972132..b05fbc5fb 100644 --- a/client/platforms/android/android_controller.cpp +++ b/client/platforms/android/android_controller.cpp @@ -307,6 +307,16 @@ void AndroidController::requestNotificationPermission() callActivityMethod("requestNotificationPermission", "()V"); } +void AndroidController::showVpnStateNotification(const QString &title, const QString &message) +{ + if (!isNotificationPermissionGranted()) { + return; + } + callActivityMethod("showVpnStateNotification", "(Ljava/lang/String;Ljava/lang/String;)V", + QJniObject::fromString(title).object(), + QJniObject::fromString(message).object()); +} + bool AndroidController::requestAuthentication() { QEventLoop wait; diff --git a/client/platforms/android/android_controller.h b/client/platforms/android/android_controller.h index 2294cc78b..fc7bff118 100644 --- a/client/platforms/android/android_controller.h +++ b/client/platforms/android/android_controller.h @@ -53,6 +53,7 @@ public: QPixmap getAppIcon(const QString &package, QSize *size, const QSize &requestedSize); bool isNotificationPermissionGranted(); void requestNotificationPermission(); + void showVpnStateNotification(const QString &title, const QString &message); bool requestAuthentication(); void sendTouch(float x, float y); diff --git a/client/platforms/android/android_notificationhandler.cpp b/client/platforms/android/android_notificationhandler.cpp new file mode 100644 index 000000000..dc18ff7cc --- /dev/null +++ b/client/platforms/android/android_notificationhandler.cpp @@ -0,0 +1,19 @@ +#include "android_notificationhandler.h" + +#include "android_controller.h" + +AndroidNotificationHandler::AndroidNotificationHandler(QObject *parent) + : NotificationHandler(parent) +{ +} + +void AndroidNotificationHandler::notify(Message type, const QString &title, const QString &message, int timerMsec) +{ + Q_UNUSED(type); + Q_UNUSED(timerMsec); + // Permission is checked on the Kotlin side as well; avoid JNI if already denied. + if (!AndroidController::instance()->isNotificationPermissionGranted()) { + return; + } + AndroidController::instance()->showVpnStateNotification(title, message); +} diff --git a/client/platforms/android/android_notificationhandler.h b/client/platforms/android/android_notificationhandler.h new file mode 100644 index 000000000..79e1fbf6f --- /dev/null +++ b/client/platforms/android/android_notificationhandler.h @@ -0,0 +1,16 @@ +#ifndef ANDROID_NOTIFICATIONHANDLER_H +#define ANDROID_NOTIFICATIONHANDLER_H + +#include "ui/notificationhandler.h" + +class AndroidNotificationHandler final : public NotificationHandler { + Q_OBJECT + +public: + explicit AndroidNotificationHandler(QObject *parent = nullptr); + +protected: + void notify(Message type, const QString &title, const QString &message, int timerMsec) override; +}; + +#endif // ANDROID_NOTIFICATIONHANDLER_H diff --git a/client/platforms/ios/iosnotificationhandler.mm b/client/platforms/ios/iosnotificationhandler.mm index 773c6297a..730e899c7 100644 --- a/client/platforms/ios/iosnotificationhandler.mm +++ b/client/platforms/ios/iosnotificationhandler.mm @@ -61,6 +61,7 @@ IOSNotificationHandler::~IOSNotificationHandler() { } void IOSNotificationHandler::notify(NotificationHandler::Message type, const QString& title, const QString& message, int timerMsec) { Q_UNUSED(type); + Q_UNUSED(timerMsec); if (!m_delegate) { return; @@ -71,11 +72,13 @@ void IOSNotificationHandler::notify(NotificationHandler::Message type, const QSt content.body = message.toNSString(); content.sound = [UNNotificationSound defaultSound]; - int timerSec = timerMsec / 1000; + NSTimeInterval delay = 0.1; UNTimeIntervalNotificationTrigger* trigger = - [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:timerSec repeats:NO]; + [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:delay repeats:NO]; - UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:@"amneziavpn" + NSString* requestId = [NSString stringWithFormat:@"amneziavpn.vpnstate.%lld", + (long long)([[NSDate date] timeIntervalSince1970] * 1000.0)]; + UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:requestId content:content trigger:trigger]; @@ -143,6 +146,7 @@ IOSNotificationHandler::~IOSNotificationHandler() { } void IOSNotificationHandler::notify(NotificationHandler::Message type, const QString& title, const QString& message, int timerMsec) { Q_UNUSED(type); + Q_UNUSED(timerMsec); if (!m_delegate) { return; @@ -153,11 +157,13 @@ void IOSNotificationHandler::notify(NotificationHandler::Message type, const QSt content.body = message.toNSString(); content.sound = [UNNotificationSound defaultSound]; - int timerSec = timerMsec / 1000; + NSTimeInterval delay = 0.1; UNTimeIntervalNotificationTrigger* trigger = - [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:timerSec repeats:NO]; + [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:delay repeats:NO]; - UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:@"amneziavpn" + NSString* requestId = [NSString stringWithFormat:@"amneziavpn.vpnstate.%lld", + (long long)([[NSDate date] timeIntervalSince1970] * 1000.0)]; + UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:requestId content:content trigger:trigger]; diff --git a/client/platforms/macos/macos_ne_vpn_notification.h b/client/platforms/macos/macos_ne_vpn_notification.h new file mode 100644 index 000000000..233c25d57 --- /dev/null +++ b/client/platforms/macos/macos_ne_vpn_notification.h @@ -0,0 +1,8 @@ +#ifndef MACOS_NE_VPN_NOTIFICATION_H +#define MACOS_NE_VPN_NOTIFICATION_H + +class QString; + +void macosNePostVpnStateNotification(const QString &title, const QString &message); + +#endif diff --git a/client/platforms/macos/macos_ne_vpn_notification.mm b/client/platforms/macos/macos_ne_vpn_notification.mm new file mode 100644 index 000000000..f4a0ae957 --- /dev/null +++ b/client/platforms/macos/macos_ne_vpn_notification.mm @@ -0,0 +1,91 @@ +#include "macos_ne_vpn_notification.h" + +#include +#include + +#import +#import + +namespace { + +@interface MacosNeVpnNotificationDelegate : NSObject +@end + +@implementation MacosNeVpnNotificationDelegate + +- (void)userNotificationCenter:(UNUserNotificationCenter *)center + willPresentNotification:(UNNotification *)notification + withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler +{ + Q_UNUSED(center) + Q_UNUSED(notification) + completionHandler(UNNotificationPresentationOptionList | UNNotificationPresentationOptionBanner); +} + +- (void)userNotificationCenter:(UNUserNotificationCenter *)center + didReceiveNotificationResponse:(UNNotificationResponse *)response + withCompletionHandler:(void (^)(void))completionHandler +{ + Q_UNUSED(center) + Q_UNUSED(response) + completionHandler(); +} + +@end + +MacosNeVpnNotificationDelegate *delegateInstance() +{ + static MacosNeVpnNotificationDelegate *d; + static dispatch_once_t once; + dispatch_once(&once, ^{ + d = [[MacosNeVpnNotificationDelegate alloc] init]; + }); + return d; +} + +void ensureNotificationCenterSetup() +{ + static dispatch_once_t once; + dispatch_once(&once, ^{ + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | + UNAuthorizationOptionBadge) + completionHandler:^(BOOL granted, NSError *_Nullable error) { + Q_UNUSED(granted); + if (!error) { + center.delegate = delegateInstance(); + } + }]; + }); +} + +} // namespace + +void macosNePostVpnStateNotification(const QString &title, const QString &message) +{ + ensureNotificationCenterSetup(); + + UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; + content.title = title.toNSString(); + content.body = message.toNSString(); + content.sound = nil; + + NSTimeInterval delay = 0.1; + UNTimeIntervalNotificationTrigger *trigger = + [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:delay repeats:NO]; + + NSString *identifier = + [NSString stringWithFormat:@"amneziavpn.vpnstate.%lld", (long long)([[NSDate date] timeIntervalSince1970] * 1000.0)]; + + UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier + content:content + trigger:trigger]; + + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center addNotificationRequest:request + withCompletionHandler:^(NSError *_Nullable error) { + if (error) { + NSLog(@"macosNePostVpnStateNotification failed: %@", error); + } + }]; +} diff --git a/client/ui/utils/notificationHandler.cpp b/client/ui/utils/notificationHandler.cpp index 46f3628ca..193a70406 100644 --- a/client/ui/utils/notificationHandler.cpp +++ b/client/ui/utils/notificationHandler.cpp @@ -5,16 +5,19 @@ #include #include "notificationHandler.h" -#if defined(Q_OS_IOS) +#if defined(Q_OS_ANDROID) +# include "platforms/android/android_notificationhandler.h" +#elif defined(Q_OS_IOS) # include "platforms/ios/iosnotificationhandler.h" #else # include "systemTrayNotificationHandler.h" #endif - // static NotificationHandler* NotificationHandler::create(QObject* parent) { -#if defined(Q_OS_IOS) +#if defined(Q_OS_ANDROID) + return new AndroidNotificationHandler(parent); +#elif defined(Q_OS_IOS) return new IOSNotificationHandler(parent); #else return new SystemTrayNotificationHandler(parent); diff --git a/client/ui/utils/systemTrayNotificationHandler.cpp b/client/ui/utils/systemTrayNotificationHandler.cpp index 8cbcbe67e..87f9ef3a1 100644 --- a/client/ui/utils/systemTrayNotificationHandler.cpp +++ b/client/ui/utils/systemTrayNotificationHandler.cpp @@ -10,6 +10,10 @@ # include "platforms/macos/macosutils.h" #endif +#ifdef MACOS_NE +# include "platforms/macos/macos_ne_vpn_notification.h" +#endif + #include #include #include @@ -152,6 +156,12 @@ void SystemTrayNotificationHandler::notify(NotificationHandler::Message type, int timerMsec) { Q_UNUSED(type); +#ifdef MACOS_NE + Q_UNUSED(timerMsec); + macosNePostVpnStateNotification(title, message); + return; +#endif + QIcon icon(ConnectedTrayIconName); m_systemTrayIcon.showMessage(title, message, icon, timerMsec); } From c9a1b2e4510ab89c8d26cf45dfa5bdbd30fc9610 Mon Sep 17 00:00:00 2001 From: dranik Date: Tue, 5 May 2026 14:57:36 +0300 Subject: [PATCH 2/4] fix build iOS --- client/core/controllers/coreController.h | 6 +++++- client/platforms/ios/ios_controller.mm | 2 +- client/ui/controllers/api/subscriptionUiController.cpp | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/client/core/controllers/coreController.h b/client/core/controllers/coreController.h index 57e3bff23..0d77c5167 100644 --- a/client/core/controllers/coreController.h +++ b/client/core/controllers/coreController.h @@ -5,7 +5,9 @@ #include #include -#include "ui/utils/systemTrayNotificationHandler.h" +#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) + #include "ui/utils/systemTrayNotificationHandler.h" +#endif #include "ui/controllers/api/subscriptionUiController.h" #include "ui/controllers/api/apiNewsUiController.h" @@ -139,7 +141,9 @@ private: SecureServersRepository* m_serversRepository; SecureAppSettingsRepository* m_appSettingsRepository; +#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) NotificationHandler* m_notificationHandler; +#endif QMetaObject::Connection m_reloadConfigErrorOccurredConnection; diff --git a/client/platforms/ios/ios_controller.mm b/client/platforms/ios/ios_controller.mm index 73aa02484..150ae7261 100644 --- a/client/platforms/ios/ios_controller.mm +++ b/client/platforms/ios/ios_controller.mm @@ -220,7 +220,7 @@ bool IosController::connectVpn(amnezia::Proto proto, const QJsonObject& configur m_rawConfig = configuration; m_serverAddress = configuration.value(configKey::hostName).toString().toNSString(); - const QString serverDescription = configuration.value(config_key::description).toString().trimmed(); + const QString serverDescription = configuration.value(configKey::description).toString().trimmed(); QString tunnelName; if (serverDescription.isEmpty()) { tunnelName = ProtocolUtils::protoToString(proto); diff --git a/client/ui/controllers/api/subscriptionUiController.cpp b/client/ui/controllers/api/subscriptionUiController.cpp index 75d96553e..a8a73ff35 100644 --- a/client/ui/controllers/api/subscriptionUiController.cpp +++ b/client/ui/controllers/api/subscriptionUiController.cpp @@ -17,6 +17,10 @@ #include #include +#ifdef Q_OS_IOS + #include "platforms/ios/ios_controller.h" +#endif + namespace { namespace configKey From 5e52f7fcb0376d341bbcbd3ae7ce629f7fe48fed Mon Sep 17 00:00:00 2001 From: dranik Date: Tue, 5 May 2026 15:05:07 +0300 Subject: [PATCH 3/4] fix path include --- client/platforms/android/android_notificationhandler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/platforms/android/android_notificationhandler.h b/client/platforms/android/android_notificationhandler.h index 79e1fbf6f..2589c222d 100644 --- a/client/platforms/android/android_notificationhandler.h +++ b/client/platforms/android/android_notificationhandler.h @@ -1,7 +1,7 @@ #ifndef ANDROID_NOTIFICATIONHANDLER_H #define ANDROID_NOTIFICATIONHANDLER_H -#include "ui/notificationhandler.h" +#include "ui/utils/notificationHandler.h" class AndroidNotificationHandler final : public NotificationHandler { Q_OBJECT From 426a95c425695cd34b116f48cfe366521ae9ac1f Mon Sep 17 00:00:00 2001 From: dranik Date: Tue, 5 May 2026 15:20:23 +0300 Subject: [PATCH 4/4] fixed compile file --- client/cmake/sources.cmake | 2 ++ client/core/controllers/coreController.h | 8 ++------ client/core/controllers/coreSignalHandlers.cpp | 8 +++----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/client/cmake/sources.cmake b/client/cmake/sources.cmake index 13e15def4..48e5ec90b 100644 --- a/client/cmake/sources.cmake +++ b/client/cmake/sources.cmake @@ -86,6 +86,7 @@ if(NOT ANDROID) ) else() set(HEADERS ${HEADERS} + ${CLIENT_ROOT_DIR}/ui/utils/notificationHandler.h ${CLIENT_ROOT_DIR}/platforms/android/android_notificationhandler.h ) endif() @@ -180,6 +181,7 @@ if(NOT ANDROID) ) else() set(SOURCES ${SOURCES} + ${CLIENT_ROOT_DIR}/ui/utils/notificationHandler.cpp ${CLIENT_ROOT_DIR}/platforms/android/android_notificationhandler.cpp ) endif() diff --git a/client/core/controllers/coreController.h b/client/core/controllers/coreController.h index 0d77c5167..20d101980 100644 --- a/client/core/controllers/coreController.h +++ b/client/core/controllers/coreController.h @@ -72,9 +72,7 @@ #include "ui/models/ipSplitTunnelingModel.h" #include "ui/models/newsModel.h" -#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) - #include "ui/utils/notificationHandler.h" -#endif +class NotificationHandler; class CoreSignalHandlers; class TestMultipleImports; @@ -141,9 +139,7 @@ private: SecureServersRepository* m_serversRepository; SecureAppSettingsRepository* m_appSettingsRepository; -#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) - NotificationHandler* m_notificationHandler; -#endif + NotificationHandler* m_notificationHandler {}; QMetaObject::Connection m_reloadConfigErrorOccurredConnection; diff --git a/client/core/controllers/coreSignalHandlers.cpp b/client/core/controllers/coreSignalHandlers.cpp index 46d91207c..46d81abed 100644 --- a/client/core/controllers/coreSignalHandlers.cpp +++ b/client/core/controllers/coreSignalHandlers.cpp @@ -36,8 +36,8 @@ #include "ui/models/containersModel.h" #include "core/utils/containerEnum.h" +#include "ui/utils/notificationHandler.h" #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) - #include "ui/utils/notificationHandler.h" #include "ui/utils/systemTrayNotificationHandler.h" #endif @@ -394,25 +394,23 @@ void CoreSignalHandlers::initIosSettingsHandler() void CoreSignalHandlers::initNotificationHandler() { -#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) m_coreController->m_notificationHandler = NotificationHandler::create(m_coreController); connect(m_coreController->m_connectionController, &ConnectionController::connectionStateChanged, m_coreController->m_notificationHandler, &NotificationHandler::setConnectionState); + connect(m_coreController, &CoreController::translationsUpdated, m_coreController->m_notificationHandler, &NotificationHandler::onTranslationsUpdated); +#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) connect(m_coreController->m_notificationHandler, &NotificationHandler::raiseRequested, m_coreController->m_pageController, &PageController::raiseMainWindow); connect(m_coreController->m_notificationHandler, &NotificationHandler::connectRequested, m_coreController->m_connectionUiController, static_cast(&ConnectionUiController::openConnection)); connect(m_coreController->m_notificationHandler, &NotificationHandler::disconnectRequested, m_coreController->m_connectionUiController, &ConnectionUiController::closeConnection); - connect(m_coreController, &CoreController::translationsUpdated, m_coreController->m_notificationHandler, &NotificationHandler::onTranslationsUpdated); -#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) if (auto *trayHandler = qobject_cast(m_coreController->m_notificationHandler)) { connect(m_coreController, &CoreController::websiteUrlChanged, trayHandler, &SystemTrayNotificationHandler::updateWebsiteUrl); } #endif -#endif } void CoreSignalHandlers::initUpdateFoundHandler()