mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
feat: add audio switch ui
This commit is contained in:
@@ -1252,6 +1252,27 @@ impl LoginConfigHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse the audio mode option.
|
||||
/// Return [`AudioMode`] if the option is valid, otherwise return `None`.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `q` - The audio mode option.
|
||||
/// * `ignore_default` - Ignore the default value.
|
||||
fn get_audio_mode_enum(&self, q: &str, ignore_default: bool) -> Option<AudioMode> {
|
||||
if q == "guest-to-host" {
|
||||
Some(AudioMode::GuestToHost)
|
||||
} else if q == "two-way" {
|
||||
Some(AudioMode::TwoWay)
|
||||
} else {
|
||||
if ignore_default {
|
||||
None
|
||||
} else {
|
||||
Some(AudioMode::GuestToHost)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the status of a toggle option.
|
||||
///
|
||||
/// # Arguments
|
||||
@@ -1338,6 +1359,24 @@ impl LoginConfigHandler {
|
||||
res
|
||||
}
|
||||
|
||||
pub fn save_audio_mode(&mut self, value: String) -> Option<Message> {
|
||||
let mut res = None;
|
||||
if let Some(q) = self.get_audio_mode_enum(&value, false) {
|
||||
let mut misc = Misc::new();
|
||||
misc.set_option(OptionMessage {
|
||||
audio_mode: q.into(),
|
||||
..Default::default()
|
||||
});
|
||||
let mut msg_out = Message::new();
|
||||
msg_out.set_misc(misc);
|
||||
res = Some(msg_out);
|
||||
}
|
||||
let mut config = self.load_config();
|
||||
config.audio_mode = value;
|
||||
self.save_config(config);
|
||||
res
|
||||
}
|
||||
|
||||
/// Create a [`Message`] for saving custom fps.
|
||||
///
|
||||
/// # Arguments
|
||||
|
||||
@@ -233,6 +233,20 @@ pub fn session_set_image_quality(id: String, value: String) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_audio_mode(id: String) -> Option<String> {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
Some(session.get_audio_mode())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_set_audio_mode(id: String, value: String) {
|
||||
if let Some(session) = SESSIONS.write().unwrap().get_mut(&id) {
|
||||
session.save_audio_mode(value);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_keyboard_mode(id: String) -> Option<String> {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
Some(session.get_keyboard_mode())
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "帧率"),
|
||||
("Auto", "自动"),
|
||||
("Other Default Options", "其它默认选项"),
|
||||
("Guest to Host", "被控到主机"),
|
||||
("Two way", "双向"),
|
||||
("Audio Transmission Mode", "音频传输模式"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -436,6 +436,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Switch Sides", ""),
|
||||
("Please confirm if you want to share your desktop?", ""),
|
||||
("Closed as expected", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
("Display", ""),
|
||||
("Default View Style", ""),
|
||||
("Default Scroll Style", ""),
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "fps"),
|
||||
("Auto", "Automatisch"),
|
||||
("Other Default Options", "Weitere Standardoptionen"),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", "Otras opciones predeterminadas"),
|
||||
("Closed as expected", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "FPS"),
|
||||
("Auto", "خودکار"),
|
||||
("Other Default Options", "سایر گزینه های پیش فرض"),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "FPS"),
|
||||
("Auto", "Auto"),
|
||||
("Other Default Options", "Autres options par défaut"),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "FPS"),
|
||||
("Auto", "Auto"),
|
||||
("Other Default Options", "Altre Opzioni Predefinite"),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "FPS"),
|
||||
("Auto", "Auto"),
|
||||
("Other Default Options", "Inne opcje domyślne"),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "FPS"),
|
||||
("Auto", "Авто"),
|
||||
("Other Default Options", "Другие параметры по умолчанию"),
|
||||
("Please confirm if you want to share your desktop?", "Подтвердите, что хотите поделиться своим рабочим столом?"),
|
||||
("Closed as expected", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", "幀率"),
|
||||
("Auto", "自動"),
|
||||
("Other Default Options", "其它默認選項"),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -445,5 +445,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("FPS", ""),
|
||||
("Auto", ""),
|
||||
("Other Default Options", ""),
|
||||
("Guest to Host", ""),
|
||||
("Two way", ""),
|
||||
("Audio Transmission Mode", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -89,6 +89,18 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
self.lc.write().unwrap().save_keyboard_mode(value);
|
||||
}
|
||||
|
||||
pub fn get_audio_mode(&self) -> String {
|
||||
self.lc.read().unwrap().audio_mode.clone()
|
||||
}
|
||||
|
||||
pub fn save_audio_mode(&self, value: String) {
|
||||
let msg = self.lc.write().unwrap().save_audio_mode(value);
|
||||
// Notify remote guest that the audio mode has been changed.
|
||||
if let Some(msg) = msg {
|
||||
self.send(Data::Message(msg));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn save_view_style(&mut self, value: String) {
|
||||
self.lc.write().unwrap().save_view_style(value);
|
||||
}
|
||||
@@ -653,6 +665,13 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_audio_transmission_mode(&self, id: &str) {
|
||||
|
||||
}
|
||||
fn set_audio_transmission_mode(&self, id: &str, mode: String) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pub trait InvokeUiSession: Send + Sync + Clone + 'static + Sized + Default {
|
||||
|
||||
Reference in New Issue
Block a user