diff --git a/src/nvhttp.cpp b/src/nvhttp.cpp index cf4ab098..74d918f5 100644 --- a/src/nvhttp.cpp +++ b/src/nvhttp.cpp @@ -613,6 +613,11 @@ namespace nvhttp { auto hash = util::hex(crypto::hash(one_time_pin + ptr->second.async_insert_pin.salt + otp_passphrase), true); if (hash.to_string_view() == it->second) { + +#if defined SUNSHINE_TRAY && SUNSHINE_TRAY >= 1 + system_tray::update_tray_otp_pair(ptr->second.client.name); +#endif + if (!otp_device_name.empty()) { ptr->second.client.name = std::move(otp_device_name); } diff --git a/src/system_tray.cpp b/src/system_tray.cpp index fff08267..d39ab1c0 100644 --- a/src/system_tray.cpp +++ b/src/system_tray.cpp @@ -381,5 +381,30 @@ namespace system_tray { tray_update(&tray); } + void + update_tray_otp_pair(std::string device_name) { + if (!tray_initialized) { + return; + } + + tray.notification_title = NULL; + tray.notification_text = NULL; + tray.notification_cb = NULL; + tray.notification_icon = NULL; + tray.icon = TRAY_ICON; + tray_update(&tray); + char msg[256]; + snprintf(msg, std::size(msg), "OTP Pairing started for device \"%s\". Please make sure you have access to the device initiating the pairing request.", device_name.c_str()); + #ifdef _WIN32 + strcpy(msg, convertUtf8ToCurrentCodepage(msg).c_str()); + #endif + tray.icon = TRAY_ICON; + tray.notification_title = "Incoming OTP Pairing Request"; + tray.notification_text = msg; + tray.notification_icon = TRAY_ICON_LOCKED; + tray.tooltip = PROJECT_NAME; + tray_update(&tray); + } + } // namespace system_tray #endif diff --git a/src/system_tray.h b/src/system_tray.h index f3fe9b25..a1243c63 100644 --- a/src/system_tray.h +++ b/src/system_tray.h @@ -84,4 +84,7 @@ namespace system_tray { */ void update_tray_require_pin(); + + void + update_tray_otp_pair(std::string device_name); } // namespace system_tray