mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-10-15 00:09:39 +08:00
[fix] preserve current MiniRTC fixes with bounded DTLS recovery
This commit is contained in:
@@ -1363,6 +1363,12 @@ void GuiApplication::BindMainCallbacks() {
|
||||
LOG_WARN("Copy local id failed: {}", SDL_GetError());
|
||||
}
|
||||
});
|
||||
main->on_signal_reconnect_requested([this] {
|
||||
LOG_INFO("Signal reconnect requested from the status bar");
|
||||
if (ForceSignalReconnect() != 0) {
|
||||
LOG_WARN("Signal reconnect could not be started");
|
||||
}
|
||||
});
|
||||
main->on_toggle_password_visibility([this] {
|
||||
show_password_ = !show_password_;
|
||||
ui_->main->set_password_visible(show_password_);
|
||||
@@ -1880,6 +1886,7 @@ void GuiApplication::Tick() {
|
||||
HandlePasswordChangeResult();
|
||||
HandleCredentialRecovery();
|
||||
if (!peer_) {
|
||||
signal_connection_indicator_.Reset();
|
||||
CreateConnectionPeer();
|
||||
}
|
||||
#ifdef __linux__
|
||||
@@ -2471,7 +2478,10 @@ void GuiApplication::SyncMainWindow() {
|
||||
std::lock_guard<std::mutex> lock(password_change_mutex_);
|
||||
ui_->main->set_password_change_pending(password_change_pending_);
|
||||
}
|
||||
ui_->main->set_signal_connected(signal_connected_);
|
||||
const bool signal_online = signal_connected_.load();
|
||||
ui_->main->set_signal_connected(signal_online);
|
||||
ui_->main->set_signal_reconnecting(
|
||||
signal_connection_indicator_.Update(signal_online));
|
||||
ui_->main->set_signal_tls_error(signal_status_ ==
|
||||
SignalStatus::SignalTlsCertError);
|
||||
ui_->main->set_update_available(update_available_);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <remote_action.h>
|
||||
|
||||
#include "application/signal_connection_indicator.h"
|
||||
#include "runtime/cursor_state_provider.h"
|
||||
#include "runtime/gui_runtime.h"
|
||||
|
||||
@@ -106,6 +107,7 @@ private:
|
||||
cursor_delivery_states_;
|
||||
uint32_t cursor_state_sequence_ = 0;
|
||||
std::chrono::steady_clock::time_point next_video_frame_time_{};
|
||||
SignalConnectionIndicator signal_connection_indicator_;
|
||||
#if defined(__linux__) && !defined(__APPLE__)
|
||||
bool use_xwayland_gui_ = false;
|
||||
bool use_x11_custom_titlebar_ = false;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef CROSSDESK_SIGNAL_CONNECTION_INDICATOR_H_
|
||||
#define CROSSDESK_SIGNAL_CONNECTION_INDICATOR_H_
|
||||
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
|
||||
namespace crossdesk {
|
||||
|
||||
// Presentation state only. The actual connected flag remains authoritative
|
||||
// for actions and other UI consumers, including the announcement inbox.
|
||||
class SignalConnectionIndicator {
|
||||
public:
|
||||
using Clock = std::chrono::steady_clock;
|
||||
|
||||
bool Update(bool connected, Clock::time_point now = Clock::now()) {
|
||||
if (connected) {
|
||||
disconnected_at_.reset();
|
||||
} else if (was_connected_) {
|
||||
disconnected_at_ = now;
|
||||
}
|
||||
was_connected_ = connected;
|
||||
return disconnected_at_ &&
|
||||
now - *disconnected_at_ < std::chrono::seconds(10);
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
was_connected_ = false;
|
||||
disconnected_at_.reset();
|
||||
}
|
||||
|
||||
private:
|
||||
bool was_connected_ = false;
|
||||
std::optional<Clock::time_point> disconnected_at_;
|
||||
};
|
||||
|
||||
} // namespace crossdesk
|
||||
|
||||
#endif
|
||||
@@ -258,6 +258,9 @@ struct TranslationRow {
|
||||
X(signal_connected, u8"已连接服务器", "Connected", u8"Подключено к серверу") \
|
||||
X(signal_disconnected, u8"未连接服务器", "Disconnected", \
|
||||
u8"Нет подключения к серверу") \
|
||||
X(signal_reconnect, u8"重新连接", "Reconnect", u8"Переподключиться") \
|
||||
X(signal_reconnecting, u8"正在重新连接...", "Reconnecting...", \
|
||||
u8"Переподключение...") \
|
||||
X(signal_tls_cert_error, u8"证书验证失败,请重新安装自托管根证书", \
|
||||
"Certificate verification failed. Reinstall the self-hosted root " \
|
||||
"certificate.", \
|
||||
|
||||
@@ -227,6 +227,14 @@ int GuiRuntime::RequestSingleDevicePresence(const std::string& remote_id,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int GuiRuntime::ForceSignalReconnect() {
|
||||
if (!peer_) {
|
||||
LOG_WARN("Signal reconnect requested with no connection peer");
|
||||
return -1;
|
||||
}
|
||||
return ReconnectSignal(peer_);
|
||||
}
|
||||
|
||||
void GuiRuntime::CloseRemoteSession(std::shared_ptr<RemoteSession> props) {
|
||||
if (!props || props->closing_.exchange(true)) return;
|
||||
if (props->peer_events_) props->peer_events_->Deactivate();
|
||||
|
||||
@@ -54,6 +54,7 @@ class GuiRuntime : protected gui_detail::GuiState {
|
||||
bool remember_password, bool bypass_presence_check = false);
|
||||
int RequestSingleDevicePresence(const std::string& remote_id,
|
||||
const char* password, bool remember_password);
|
||||
int ForceSignalReconnect();
|
||||
|
||||
void HandleRecentConnections();
|
||||
void HandleConnectionStatusChange();
|
||||
|
||||
@@ -65,6 +65,8 @@ export global UiStrings {
|
||||
in-out property <string> signal-connected: "Signal server connected";
|
||||
in-out property <string> signal-disconnected: "Signal server disconnected";
|
||||
in-out property <string> tls-error: "Signal server TLS certificate error";
|
||||
in-out property <string> signal-reconnect: "Reconnect";
|
||||
in-out property <string> signal-reconnecting: "Reconnecting...";
|
||||
in-out property <string> update-available: "A new version is available";
|
||||
in-out property <string> new-version: "New version";
|
||||
in-out property <string> check-for-updates: "Check for updates";
|
||||
@@ -305,6 +307,7 @@ export component MainWindow inherits Window {
|
||||
in property <bool> password-visible: true;
|
||||
in property <bool> password-change-pending: false;
|
||||
in property <bool> signal-connected: false;
|
||||
in property <bool> signal-reconnecting: false;
|
||||
in property <bool> signal-tls-error: false;
|
||||
in property <[RecentConnection]> recent-connections;
|
||||
in property <[AnnouncementItem]> announcements;
|
||||
@@ -402,6 +405,7 @@ export component MainWindow inherits Window {
|
||||
callback browse-save-path;
|
||||
callback open-download;
|
||||
callback check-for-updates;
|
||||
callback signal-reconnect-requested;
|
||||
callback connection-cancel;
|
||||
callback connection-acknowledge;
|
||||
callback connection-submit-password(string, bool);
|
||||
@@ -1209,7 +1213,7 @@ export component MainWindow inherits Window {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 4px;
|
||||
background: root.signal-tls-error ? #f59e0b : #ef4444;
|
||||
background: root.signal-tls-error || root.signal-reconnecting ? #f59e0b : #ef4444;
|
||||
}
|
||||
Text {
|
||||
x: 28px;
|
||||
@@ -1217,11 +1221,31 @@ export component MainWindow inherits Window {
|
||||
height: 18px;
|
||||
text: root.signal-tls-error ? UiStrings.tls-error
|
||||
: root.signal-connected ? UiStrings.signal-connected
|
||||
: root.signal-reconnecting ? UiStrings.signal-reconnecting
|
||||
: UiStrings.signal-disconnected;
|
||||
color: #343941;
|
||||
font-size: ImGuiFontStyle.base;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
if !root.signal-connected && !root.signal-tls-error: Rectangle {
|
||||
x: parent.width - self.width - 12px;
|
||||
y: 3px;
|
||||
height: 18px;
|
||||
width: reconnect-label.preferred-width;
|
||||
reconnect-label := Text {
|
||||
text: UiStrings.signal-reconnect;
|
||||
color: #2563eb;
|
||||
font-size: ImGuiFontStyle.base;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.signal-reconnect-requested();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,10 @@ inline int ApplyMainWindowStrings(
|
||||
strings.set_signal_disconnected(
|
||||
Text(localization::signal_disconnected[language]));
|
||||
strings.set_tls_error(Text(localization::signal_tls_cert_error[language]));
|
||||
strings.set_signal_reconnect(
|
||||
Text(localization::signal_reconnect[language]));
|
||||
strings.set_signal_reconnecting(
|
||||
Text(localization::signal_reconnecting[language]));
|
||||
strings.set_update_available(
|
||||
Text(localization::new_version_available[language]));
|
||||
strings.set_new_version(Text(localization::new_version[language]));
|
||||
|
||||
Vendored
+1
-1
Submodule deps/submodules/minirtc updated: 9d5860dfe6...029e31c6aa
Reference in New Issue
Block a user