[feat] add Windows pre-login remote control and fix autostart

This commit is contained in:
dijunkun
2026-10-04 12:49:26 +08:00
parent b8f704abb9
commit 7f7b91851e
33 changed files with 1902 additions and 70 deletions
@@ -29,6 +29,9 @@ public:
~GuiApplication();
int Run();
#ifdef _WIN32
int RunUnattended(void* stop_event);
#endif
private:
struct SlintUi;
@@ -115,7 +115,7 @@ void SessionDeviceManager::RecordCaptureCadence(
}
void SessionDeviceManager::Initialize() {
InitializeAudioOutput();
if (!owner_.unattended_host_) InitializeAudioOutput();
screen_capturer_factory_ = new ScreenCapturerFactory();
device_controller_factory_ = new DeviceControllerFactory();
keyboard_capturer_ =
@@ -329,6 +329,7 @@ void SessionDeviceManager::ReleaseRemoteMouseButtons() {
#endif
void SessionDeviceManager::StartSpeakerCapturer() {
if (owner_.unattended_host_) return;
speaker_capture_.SetEnabled(true);
}
@@ -229,6 +229,13 @@ bool SettingsManager::ReadV2Locked() {
return true;
}
std::string SettingsManager::ActiveIdentity() const {
std::lock_guard<std::mutex> lock(cache_mutex_);
return owner_.config_center_->IsSelfHosted()
? cache_v2_.self_hosted_id
: cache_v2_.client_id_with_password;
}
int SettingsManager::Load() {
std::unique_lock<std::mutex> lock(cache_mutex_);
@@ -20,6 +20,7 @@ public:
int Save();
int Load();
std::string ActiveIdentity() const;
int LoadRecentConnectionAliases();
int SaveRecentConnectionAliases() const;
+5
View File
@@ -11,5 +11,10 @@ Render::Render() : application_(std::make_unique<GuiApplication>()) {}
Render::~Render() = default;
int Render::Run() { return application_->Run(); }
#ifdef _WIN32
int Render::RunUnattended(void* stop_event) {
return application_->RunUnattended(stop_event);
}
#endif
} // namespace crossdesk
+3
View File
@@ -24,6 +24,9 @@ public:
Render &operator=(const Render &) = delete;
int Run();
#ifdef _WIN32
int RunUnattended(void* stop_event);
#endif
private:
std::unique_ptr<GuiApplication> application_;
@@ -100,6 +100,8 @@ class GuiRuntime : protected gui_detail::GuiState {
#endif
PrivacyController privacy_;
// Set before initializing callbacks; immutable for the process lifetime.
bool unattended_host_ = false;
AnnouncementInbox announcements_;
PrivacySessionPolicy privacy_sessions_;
std::mutex privacy_commands_mutex_;
@@ -91,6 +91,13 @@ void PeerEventHandler::OnReceiveDataBuffer(
}
std::string source_id = std::string(src_id, src_id_size);
// The service-owned host runs as SYSTEM. Do not expose filesystem or
// clipboard operations in that security context.
if (runtime->unattended_host_ &&
(source_id == runtime->file_label_ ||
source_id == runtime->file_feedback_label_ ||
source_id == runtime->clipboard_label_))
return;
if (source_id == runtime->file_label_) {
std::string remote_user_id = std::string(user_id, user_id_size);
@@ -209,6 +216,7 @@ void PeerEventHandler::OnReceiveDataBuffer(
return;
}
if (remote_action.type == ControlType::privacy_command) {
if (runtime->unattended_host_) return;
if (source_id == runtime->control_data_label_)
runtime->QueuePrivacyCommand(remote_id, remote_action.pc);
return;
@@ -278,8 +278,8 @@ void PeerEventHandler::OnConnectionStatus(ConnectionStatus status,
{
RemoteAction remote_action = MakeHostInformation(
GetHostName(), runtime->devices_.host_display_list(),
/*supports_privacy_screen=*/true, CROSSDESK_VERSION,
kClientPlatform);
/*supports_privacy_screen=*/!runtime->unattended_host_,
CROSSDESK_VERSION, kClientPlatform);
remote_action.i.supports_video_settings = true;
for (std::size_t i = 0; i < remote_action.i.display_num; i++) {
LOG_INFO("Local display [{}:{}]", i + 1,
@@ -413,8 +413,8 @@ void PeerEventHandler::OnConnectionStatus(ConnectionStatus status,
{
RemoteAction remote_action = MakeHostInformation(
GetHostName(), runtime->devices_.host_display_list(),
/*supports_privacy_screen=*/true, CROSSDESK_VERSION,
kClientPlatform);
/*supports_privacy_screen=*/!runtime->unattended_host_,
CROSSDESK_VERSION, kClientPlatform);
remote_action.i.supports_video_settings = true;
for (std::size_t i = 0; i < remote_action.i.display_num; i++) {
LOG_INFO("Local display [{}:{}]", i + 1,
@@ -201,7 +201,7 @@ void PeerEventHandler::OnReceiveAudioBuffer(
auto callback = handler->EnterCallback();
if (!callback) return;
GuiRuntime* runtime = handler ? &handler->owner_ : nullptr;
if (!runtime) {
if (!runtime || runtime->unattended_host_) {
return;
}