mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -1296,7 +1296,12 @@ impl LoginConfigHandler {
|
||||
if let Some(custom_fps) = self.options.get("custom-fps") {
|
||||
msg.custom_fps = custom_fps.parse().unwrap_or(30);
|
||||
}
|
||||
if self.get_toggle_option("show-remote-cursor") {
|
||||
let view_only = self.get_toggle_option("view-only");
|
||||
if view_only {
|
||||
msg.disable_keyboard = BoolOption::Yes.into();
|
||||
n += 1;
|
||||
}
|
||||
if view_only || self.get_toggle_option("show-remote-cursor") {
|
||||
msg.show_remote_cursor = BoolOption::Yes.into();
|
||||
n += 1;
|
||||
}
|
||||
@@ -1312,7 +1317,7 @@ impl LoginConfigHandler {
|
||||
msg.enable_file_transfer = BoolOption::Yes.into();
|
||||
n += 1;
|
||||
}
|
||||
if self.get_toggle_option("disable-clipboard") {
|
||||
if view_only || self.get_toggle_option("disable-clipboard") {
|
||||
msg.disable_clipboard = BoolOption::Yes.into();
|
||||
n += 1;
|
||||
}
|
||||
|
||||
@@ -543,6 +543,12 @@ pub fn session_set_size(_id: String, _width: i32, _height: i32) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_set_view_only(id: String, view_only: bool) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
session.set_view_only(view_only);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main_get_sound_inputs() -> Vec<String> {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
return get_sound_inputs();
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", "此文件与对方的一致"),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", "浏览模式"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", "Mig"),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", "Ich"),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", "Yo"),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", "من"),
|
||||
("identical_file_tip", "این فایل با فایل همتا یکسان است."),
|
||||
("show_monitors_tip", "نمایش مانیتورها در نوار ابزار"),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", "Io"),
|
||||
("identical_file_tip", "Questo file è identico a quello del peer."),
|
||||
("show_monitors_tip", "Mostra schermi nella barra degli strumenti"),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", "瀏覽模式"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -479,5 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", ""),
|
||||
("identical_file_tip", ""),
|
||||
("show_monitors_tip", ""),
|
||||
("View Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -103,6 +103,9 @@ pub struct Connection {
|
||||
show_remote_cursor: bool,
|
||||
// by peer
|
||||
ip: String,
|
||||
// by peer
|
||||
disable_keyboard: bool,
|
||||
// by peer
|
||||
disable_clipboard: bool,
|
||||
// by peer
|
||||
disable_audio: bool,
|
||||
@@ -219,6 +222,7 @@ impl Connection {
|
||||
disable_audio: false,
|
||||
enable_file_transfer: false,
|
||||
disable_clipboard: false,
|
||||
disable_keyboard: false,
|
||||
tx_input,
|
||||
video_ack_required: false,
|
||||
peer_info: Default::default(),
|
||||
@@ -327,7 +331,7 @@ impl Connection {
|
||||
if let Some(s) = conn.server.upgrade() {
|
||||
s.write().unwrap().subscribe(
|
||||
super::clipboard_service::NAME,
|
||||
conn.inner.clone(), conn.clipboard_enabled() && conn.keyboard);
|
||||
conn.inner.clone(), conn.clipboard_enabled() && conn.peer_keyboard_enabled());
|
||||
}
|
||||
} else if &name == "audio" {
|
||||
conn.audio = enabled;
|
||||
@@ -939,13 +943,13 @@ impl Connection {
|
||||
} else if sub_service {
|
||||
if let Some(s) = self.server.upgrade() {
|
||||
let mut noperms = Vec::new();
|
||||
if !self.keyboard && !self.show_remote_cursor {
|
||||
if !self.peer_keyboard_enabled() && !self.show_remote_cursor {
|
||||
noperms.push(NAME_CURSOR);
|
||||
}
|
||||
if !self.show_remote_cursor {
|
||||
noperms.push(NAME_POS);
|
||||
}
|
||||
if !self.clipboard_enabled() || !self.keyboard {
|
||||
if !self.clipboard_enabled() || !self.peer_keyboard_enabled() {
|
||||
noperms.push(super::clipboard_service::NAME);
|
||||
}
|
||||
if !self.audio_enabled() {
|
||||
@@ -959,6 +963,10 @@ impl Connection {
|
||||
}
|
||||
}
|
||||
|
||||
fn peer_keyboard_enabled(&self) -> bool {
|
||||
self.keyboard && !self.disable_keyboard
|
||||
}
|
||||
|
||||
fn clipboard_enabled(&self) -> bool {
|
||||
self.clipboard && !self.disable_clipboard
|
||||
}
|
||||
@@ -1312,7 +1320,7 @@ impl Connection {
|
||||
log::debug!("call_main_service_mouse_input fail:{}", e);
|
||||
}
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
if self.keyboard {
|
||||
if self.peer_keyboard_enabled() {
|
||||
if is_left_up(&me) {
|
||||
CLICK_TIME.store(get_time(), Ordering::SeqCst);
|
||||
} else {
|
||||
@@ -1323,7 +1331,7 @@ impl Connection {
|
||||
}
|
||||
Some(message::Union::KeyEvent(me)) => {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
if self.keyboard {
|
||||
if self.peer_keyboard_enabled() {
|
||||
if is_enter(&me) {
|
||||
CLICK_TIME.store(get_time(), Ordering::SeqCst);
|
||||
}
|
||||
@@ -1750,7 +1758,7 @@ impl Connection {
|
||||
s.write().unwrap().subscribe(
|
||||
NAME_CURSOR,
|
||||
self.inner.clone(),
|
||||
self.keyboard || self.show_remote_cursor,
|
||||
self.peer_keyboard_enabled() || self.show_remote_cursor,
|
||||
);
|
||||
s.write().unwrap().subscribe(
|
||||
NAME_POS,
|
||||
@@ -1788,7 +1796,24 @@ impl Connection {
|
||||
s.write().unwrap().subscribe(
|
||||
super::clipboard_service::NAME,
|
||||
self.inner.clone(),
|
||||
self.clipboard_enabled() && self.keyboard,
|
||||
self.clipboard_enabled() && self.peer_keyboard_enabled(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Ok(q) = o.disable_keyboard.enum_value() {
|
||||
if q != BoolOption::NotSet {
|
||||
self.disable_keyboard = q == BoolOption::Yes;
|
||||
if let Some(s) = self.server.upgrade() {
|
||||
s.write().unwrap().subscribe(
|
||||
super::clipboard_service::NAME,
|
||||
self.inner.clone(),
|
||||
self.clipboard_enabled() && self.peer_keyboard_enabled(),
|
||||
);
|
||||
s.write().unwrap().subscribe(
|
||||
NAME_CURSOR,
|
||||
self.inner.clone(),
|
||||
self.peer_keyboard_enabled() || self.show_remote_cursor,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use std::time::{Duration, SystemTime};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use bytes::Bytes;
|
||||
use hbb_common::message_proto::option_message::BoolOption;
|
||||
use rdev::{Event, EventType::*};
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -374,7 +375,6 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
}
|
||||
|
||||
pub fn swab_modifier_key(&self, msg: &mut KeyEvent) {
|
||||
|
||||
let allow_swap_key = self.get_toggle_option("allow_swap_key".to_string());
|
||||
if allow_swap_key {
|
||||
if let Some(key_event::Union::ControlKey(ck)) = msg.union {
|
||||
@@ -388,19 +388,22 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
};
|
||||
msg.set_control_key(ck);
|
||||
}
|
||||
msg.modifiers = msg.modifiers.iter().map(|ck| {
|
||||
let ck = ck.enum_value_or_default();
|
||||
let ck = match ck {
|
||||
ControlKey::Control => ControlKey::Meta,
|
||||
ControlKey::Meta => ControlKey::Control,
|
||||
ControlKey::RControl => ControlKey::Meta,
|
||||
ControlKey::RWin => ControlKey::Control,
|
||||
_ => ck,
|
||||
};
|
||||
hbb_common::protobuf::EnumOrUnknown::new(ck)
|
||||
}).collect();
|
||||
|
||||
|
||||
msg.modifiers = msg
|
||||
.modifiers
|
||||
.iter()
|
||||
.map(|ck| {
|
||||
let ck = ck.enum_value_or_default();
|
||||
let ck = match ck {
|
||||
ControlKey::Control => ControlKey::Meta,
|
||||
ControlKey::Meta => ControlKey::Control,
|
||||
ControlKey::RControl => ControlKey::Meta,
|
||||
ControlKey::RWin => ControlKey::Control,
|
||||
_ => ck,
|
||||
};
|
||||
hbb_common::protobuf::EnumOrUnknown::new(ck)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let code = msg.chr();
|
||||
if code != 0 {
|
||||
let mut peer = self.peer_platform().to_lowercase();
|
||||
@@ -444,7 +447,6 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
msg.set_chr(key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub fn send_key_event(&self, evt: &KeyEvent) {
|
||||
@@ -841,6 +843,37 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn set_view_only(&self, view_only: bool) {
|
||||
let mut option = OptionMessage::default();
|
||||
let f = |b: bool| {
|
||||
if b {
|
||||
BoolOption::Yes.into()
|
||||
} else {
|
||||
BoolOption::No.into()
|
||||
}
|
||||
};
|
||||
if view_only {
|
||||
option.disable_keyboard = f(true);
|
||||
option.disable_clipboard = f(true);
|
||||
option.show_remote_cursor = f(true);
|
||||
} else {
|
||||
option.disable_keyboard = f(false);
|
||||
option.disable_clipboard = f(self.get_toggle_option("disable-clipboard".to_string()));
|
||||
option.show_remote_cursor = f(self.get_toggle_option("show-remote-cursor".to_string()));
|
||||
}
|
||||
let mut misc = Misc::new();
|
||||
misc.set_option(option);
|
||||
let mut msg = Message::new();
|
||||
msg.set_misc(misc);
|
||||
self.send(Data::Message(msg));
|
||||
if self.get_toggle_option("view-only".to_string()) != view_only {
|
||||
self.lc
|
||||
.write()
|
||||
.unwrap()
|
||||
.toggle_option("view-only".to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait InvokeUiSession: Send + Sync + Clone + 'static + Sized + Default {
|
||||
@@ -1011,21 +1044,25 @@ impl<T: InvokeUiSession> Interface for Session<T> {
|
||||
handle_test_delay(t, peer).await;
|
||||
}
|
||||
}
|
||||
|
||||
fn swap_modifier_mouse(&self, msg : &mut hbb_common::protos::message::MouseEvent) {
|
||||
|
||||
fn swap_modifier_mouse(&self, msg: &mut hbb_common::protos::message::MouseEvent) {
|
||||
let allow_swap_key = self.get_toggle_option("allow_swap_key".to_string());
|
||||
if allow_swap_key {
|
||||
msg.modifiers = msg.modifiers.iter().map(|ck| {
|
||||
let ck = ck.enum_value_or_default();
|
||||
let ck = match ck {
|
||||
ControlKey::Control => ControlKey::Meta,
|
||||
ControlKey::Meta => ControlKey::Control,
|
||||
ControlKey::RControl => ControlKey::Meta,
|
||||
ControlKey::RWin => ControlKey::Control,
|
||||
_ => ck,
|
||||
};
|
||||
hbb_common::protobuf::EnumOrUnknown::new(ck)
|
||||
}).collect();
|
||||
if allow_swap_key {
|
||||
msg.modifiers = msg
|
||||
.modifiers
|
||||
.iter()
|
||||
.map(|ck| {
|
||||
let ck = ck.enum_value_or_default();
|
||||
let ck = match ck {
|
||||
ControlKey::Control => ControlKey::Meta,
|
||||
ControlKey::Meta => ControlKey::Control,
|
||||
ControlKey::RControl => ControlKey::Meta,
|
||||
ControlKey::RWin => ControlKey::Control,
|
||||
_ => ck,
|
||||
};
|
||||
hbb_common::protobuf::EnumOrUnknown::new(ck)
|
||||
})
|
||||
.collect();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user