mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
feat, multi_flutter_ui_sessions
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
@@ -4,7 +4,7 @@ use crate::{
|
||||
client::file_trait::FileManager,
|
||||
common::is_keyboard_mode_supported,
|
||||
common::make_fd_to_json,
|
||||
flutter::{self, session_add, session_start_, sessions},
|
||||
flutter::{self, session_add, session_add_existed, session_start_, sessions},
|
||||
input::*,
|
||||
ui_interface::{self, *},
|
||||
};
|
||||
@@ -16,6 +16,7 @@ use hbb_common::{
|
||||
config::{self, LocalConfig, PeerConfig, PeerInfoSerde},
|
||||
fs, lazy_static, log,
|
||||
message_proto::KeyboardMode,
|
||||
rendezvous_proto::ConnType,
|
||||
ResultType,
|
||||
};
|
||||
use std::{
|
||||
@@ -67,7 +68,7 @@ pub fn stop_global_event_stream(app_type: String) {
|
||||
}
|
||||
pub enum EventToUI {
|
||||
Event(String),
|
||||
Rgba,
|
||||
Rgba(usize),
|
||||
}
|
||||
|
||||
pub fn host_stop_system_key_propagate(_stopped: bool) {
|
||||
@@ -75,8 +76,26 @@ pub fn host_stop_system_key_propagate(_stopped: bool) {
|
||||
crate::platform::windows::stop_system_key_propagate(_stopped);
|
||||
}
|
||||
|
||||
// FIXME: -> ResultType<()> cannot be parsed by frb_codegen
|
||||
// thread 'main' panicked at 'Failed to parse function output type `ResultType<()>`', $HOME\.cargo\git\checkouts\flutter_rust_bridge-ddba876d3ebb2a1e\e5adce5\frb_codegen\src\parser\mod.rs:151:25
|
||||
// This function is only used to count the number of control sessions.
|
||||
pub fn peer_get_default_sessions_count(id: String) -> SyncReturn<usize> {
|
||||
SyncReturn(sessions::get_session_count(id, ConnType::DEFAULT_CONN))
|
||||
}
|
||||
|
||||
pub fn session_add_existed_sync(id: String, session_id: SessionID) -> SyncReturn<String> {
|
||||
if let Err(e) = session_add_existed(id.clone(), session_id) {
|
||||
SyncReturn(format!("Failed to add session with id {}, {}", &id, e))
|
||||
} else {
|
||||
SyncReturn("".to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_try_add_display(session_id: SessionID, displays: Vec<i32>) -> SyncReturn<()> {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.capture_displays(displays, vec![], vec![]);
|
||||
}
|
||||
SyncReturn(())
|
||||
}
|
||||
|
||||
pub fn session_add_sync(
|
||||
session_id: SessionID,
|
||||
id: String,
|
||||
@@ -112,7 +131,7 @@ pub fn session_start(
|
||||
}
|
||||
|
||||
pub fn session_get_remember(session_id: SessionID) -> Option<bool> {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
Some(session.get_remember())
|
||||
} else {
|
||||
None
|
||||
@@ -120,7 +139,7 @@ pub fn session_get_remember(session_id: SessionID) -> Option<bool> {
|
||||
}
|
||||
|
||||
pub fn session_get_toggle_option(session_id: SessionID, arg: String) -> Option<bool> {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
Some(session.get_toggle_option(arg))
|
||||
} else {
|
||||
None
|
||||
@@ -133,7 +152,7 @@ pub fn session_get_toggle_option_sync(session_id: SessionID, arg: String) -> Syn
|
||||
}
|
||||
|
||||
pub fn session_get_option(session_id: SessionID, arg: String) -> Option<String> {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
Some(session.get_option(arg))
|
||||
} else {
|
||||
None
|
||||
@@ -147,55 +166,61 @@ pub fn session_login(
|
||||
password: String,
|
||||
remember: bool,
|
||||
) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.login(os_username, os_password, password, remember);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_close(session_id: SessionID) {
|
||||
if let Some(session) = sessions::remove_session(&session_id) {
|
||||
session.close_event_stream();
|
||||
if let Some(session) = sessions::remove_session_by_session_id(&session_id) {
|
||||
session.close_event_stream(session_id);
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_refresh(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
session.refresh_video();
|
||||
pub fn session_refresh(session_id: SessionID, display: usize) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.refresh_video(display);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_record_screen(session_id: SessionID, start: bool, width: usize, height: usize) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
session.record_screen(start, width as _, height as _);
|
||||
pub fn session_record_screen(
|
||||
session_id: SessionID,
|
||||
start: bool,
|
||||
display: usize,
|
||||
width: usize,
|
||||
height: usize,
|
||||
) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.record_screen(start, display as _, width as _, height as _);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_record_status(session_id: SessionID, status: bool) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.record_status(status);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_reconnect(session_id: SessionID, force_relay: bool) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.reconnect(force_relay);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_toggle_option(session_id: SessionID, value: String) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
log::warn!("toggle option {}", &value);
|
||||
session.toggle_option(value.clone());
|
||||
}
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
if sessions::get_session(&session_id).is_some() && value == "disable-clipboard" {
|
||||
if sessions::get_session_by_session_id(&session_id).is_some() && value == "disable-clipboard" {
|
||||
crate::flutter::update_text_clipboard_required();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_flutter_option(session_id: SessionID, k: String) -> Option<String> {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
Some(session.get_flutter_option(k))
|
||||
} else {
|
||||
None
|
||||
@@ -203,13 +228,14 @@ pub fn session_get_flutter_option(session_id: SessionID, k: String) -> Option<St
|
||||
}
|
||||
|
||||
pub fn session_set_flutter_option(session_id: SessionID, k: String, v: String) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.save_flutter_option(k, v);
|
||||
}
|
||||
}
|
||||
|
||||
// This function is only used for the default connection session.
|
||||
pub fn session_get_flutter_option_by_peer_id(id: String, k: String) -> Option<String> {
|
||||
if let Some(session) = sessions::get_session_by_peer_id(&id) {
|
||||
if let Some(session) = sessions::get_session_by_peer_id(id, ConnType::DEFAULT_CONN) {
|
||||
Some(session.get_flutter_option(k))
|
||||
} else {
|
||||
None
|
||||
@@ -238,7 +264,7 @@ pub fn set_local_kb_layout_type(kb_layout_type: String) {
|
||||
}
|
||||
|
||||
pub fn session_get_view_style(session_id: SessionID) -> Option<String> {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
Some(session.get_view_style())
|
||||
} else {
|
||||
None
|
||||
@@ -246,13 +272,13 @@ pub fn session_get_view_style(session_id: SessionID) -> Option<String> {
|
||||
}
|
||||
|
||||
pub fn session_set_view_style(session_id: SessionID, value: String) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.save_view_style(value);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_scroll_style(session_id: SessionID) -> Option<String> {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
Some(session.get_scroll_style())
|
||||
} else {
|
||||
None
|
||||
@@ -260,13 +286,13 @@ pub fn session_get_scroll_style(session_id: SessionID) -> Option<String> {
|
||||
}
|
||||
|
||||
pub fn session_set_scroll_style(session_id: SessionID, value: String) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.save_scroll_style(value);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_image_quality(session_id: SessionID) -> Option<String> {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
Some(session.get_image_quality())
|
||||
} else {
|
||||
None
|
||||
@@ -274,13 +300,13 @@ pub fn session_get_image_quality(session_id: SessionID) -> Option<String> {
|
||||
}
|
||||
|
||||
pub fn session_set_image_quality(session_id: SessionID, value: String) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.save_image_quality(value);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_keyboard_mode(session_id: SessionID) -> Option<String> {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
Some(session.get_keyboard_mode())
|
||||
} else {
|
||||
None
|
||||
@@ -289,7 +315,7 @@ pub fn session_get_keyboard_mode(session_id: SessionID) -> Option<String> {
|
||||
|
||||
pub fn session_set_keyboard_mode(session_id: SessionID, value: String) {
|
||||
let mut _mode_updated = false;
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.save_keyboard_mode(value.clone());
|
||||
_mode_updated = true;
|
||||
}
|
||||
@@ -300,7 +326,7 @@ pub fn session_set_keyboard_mode(session_id: SessionID, value: String) {
|
||||
}
|
||||
|
||||
pub fn session_get_reverse_mouse_wheel(session_id: SessionID) -> Option<String> {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
Some(session.get_reverse_mouse_wheel())
|
||||
} else {
|
||||
None
|
||||
@@ -308,13 +334,13 @@ pub fn session_get_reverse_mouse_wheel(session_id: SessionID) -> Option<String>
|
||||
}
|
||||
|
||||
pub fn session_set_reverse_mouse_wheel(session_id: SessionID, value: String) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.save_reverse_mouse_wheel(value);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_custom_image_quality(session_id: SessionID) -> Option<Vec<i32>> {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
Some(session.get_custom_image_quality())
|
||||
} else {
|
||||
None
|
||||
@@ -322,7 +348,7 @@ pub fn session_get_custom_image_quality(session_id: SessionID) -> Option<Vec<i32
|
||||
}
|
||||
|
||||
pub fn session_is_keyboard_mode_supported(session_id: SessionID, mode: String) -> SyncReturn<bool> {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
if let Ok(mode) = KeyboardMode::from_str(&mode[..]) {
|
||||
SyncReturn(is_keyboard_mode_supported(
|
||||
&mode,
|
||||
@@ -337,32 +363,36 @@ pub fn session_is_keyboard_mode_supported(session_id: SessionID, mode: String) -
|
||||
}
|
||||
|
||||
pub fn session_set_custom_image_quality(session_id: SessionID, value: i32) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.save_custom_image_quality(value);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_set_custom_fps(session_id: SessionID, fps: i32) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.set_custom_fps(fps);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_lock_screen(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.lock_screen();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_ctrl_alt_del(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.ctrl_alt_del();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_switch_display(session_id: SessionID, value: i32) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
session.switch_display(value);
|
||||
pub fn session_switch_display(session_id: SessionID, value: Vec<i32>) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
if value.len() == 1 {
|
||||
session.switch_display(value[0]);
|
||||
} else {
|
||||
session.capture_displays(vec![], vec![], value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,7 +404,7 @@ pub fn session_handle_flutter_key_event(
|
||||
lock_modes: i32,
|
||||
down_or_up: bool,
|
||||
) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
let keyboard_mode = session.get_keyboard_mode();
|
||||
session.handle_flutter_key_event(
|
||||
&keyboard_mode,
|
||||
@@ -395,7 +425,7 @@ pub fn session_handle_flutter_key_event(
|
||||
// This will cause the keyboard input to take no effect.
|
||||
pub fn session_enter_or_leave(_session_id: SessionID, _enter: bool) -> SyncReturn<()> {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
if let Some(session) = sessions::get_session(&_session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&_session_id) {
|
||||
let keyboard_mode = session.get_keyboard_mode();
|
||||
if _enter {
|
||||
set_cur_session_id_(_session_id, &keyboard_mode);
|
||||
@@ -417,14 +447,14 @@ pub fn session_input_key(
|
||||
shift: bool,
|
||||
command: bool,
|
||||
) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
// #[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
session.input_key(&name, down, press, alt, ctrl, shift, command);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_input_string(session_id: SessionID, value: String) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
// #[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
session.input_string(&value);
|
||||
}
|
||||
@@ -432,33 +462,33 @@ pub fn session_input_string(session_id: SessionID, value: String) {
|
||||
|
||||
// chat_client_mode
|
||||
pub fn session_send_chat(session_id: SessionID, text: String) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.send_chat(text);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_peer_option(session_id: SessionID, name: String, value: String) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.set_option(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_peer_option(session_id: SessionID, name: String) -> String {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
return session.get_option(name);
|
||||
}
|
||||
"".to_string()
|
||||
}
|
||||
|
||||
pub fn session_input_os_password(session_id: SessionID, value: String) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.input_os_password(value, true);
|
||||
}
|
||||
}
|
||||
|
||||
// File Action
|
||||
pub fn session_read_remote_dir(session_id: SessionID, path: String, include_hidden: bool) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.read_remote_dir(path, include_hidden);
|
||||
}
|
||||
}
|
||||
@@ -472,7 +502,7 @@ pub fn session_send_files(
|
||||
include_hidden: bool,
|
||||
is_remote: bool,
|
||||
) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.send_files(act_id, path, to, file_num, include_hidden, is_remote);
|
||||
}
|
||||
}
|
||||
@@ -485,7 +515,7 @@ pub fn session_set_confirm_override_file(
|
||||
remember: bool,
|
||||
is_upload: bool,
|
||||
) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.set_confirm_override_file(act_id, file_num, need_override, remember, is_upload);
|
||||
}
|
||||
}
|
||||
@@ -497,7 +527,7 @@ pub fn session_remove_file(
|
||||
file_num: i32,
|
||||
is_remote: bool,
|
||||
) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.remove_file(act_id, path, file_num, is_remote);
|
||||
}
|
||||
}
|
||||
@@ -509,7 +539,7 @@ pub fn session_read_dir_recursive(
|
||||
is_remote: bool,
|
||||
show_hidden: bool,
|
||||
) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.remove_dir_all(act_id, path, is_remote, show_hidden);
|
||||
}
|
||||
}
|
||||
@@ -520,19 +550,19 @@ pub fn session_remove_all_empty_dirs(
|
||||
path: String,
|
||||
is_remote: bool,
|
||||
) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.remove_dir(act_id, path, is_remote);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_cancel_job(session_id: SessionID, act_id: i32) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.cancel_job(act_id);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_create_dir(session_id: SessionID, act_id: i32, path: String, is_remote: bool) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.create_dir(act_id, path, is_remote);
|
||||
}
|
||||
}
|
||||
@@ -549,14 +579,14 @@ pub fn session_read_local_dir_sync(
|
||||
}
|
||||
|
||||
pub fn session_get_platform(session_id: SessionID, is_remote: bool) -> String {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
return session.get_platform(is_remote);
|
||||
}
|
||||
"".to_string()
|
||||
}
|
||||
|
||||
pub fn session_load_last_transfer_jobs(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
return session.load_last_jobs();
|
||||
} else {
|
||||
// a tip for flutter dev
|
||||
@@ -576,46 +606,44 @@ pub fn session_add_job(
|
||||
include_hidden: bool,
|
||||
is_remote: bool,
|
||||
) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.add_job(act_id, path, to, file_num, include_hidden, is_remote);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_resume_job(session_id: SessionID, act_id: i32, is_remote: bool) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.resume_job(act_id, is_remote);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_elevate_direct(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.elevate_direct();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_elevate_with_logon(session_id: SessionID, username: String, password: String) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.elevate_with_logon(username, password);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_switch_sides(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.switch_sides();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_change_resolution(session_id: SessionID, display: i32, width: i32, height: i32) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.change_resolution(display, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_set_size(_session_id: SessionID, _width: usize, _height: usize) {
|
||||
pub fn session_set_size(_session_id: SessionID, _display: usize, _width: usize, _height: usize) {
|
||||
#[cfg(feature = "flutter_texture_render")]
|
||||
if let Some(session) = sessions::get_session(&_session_id) {
|
||||
session.set_size(_width, _height);
|
||||
}
|
||||
super::flutter::session_set_size(_session_id, _display, _width, _height)
|
||||
}
|
||||
|
||||
pub fn main_get_sound_inputs() -> Vec<String> {
|
||||
@@ -1008,18 +1036,22 @@ pub fn main_handle_relay_id(id: String) -> String {
|
||||
handle_relay_id(id)
|
||||
}
|
||||
|
||||
pub fn main_get_current_display() -> SyncReturn<String> {
|
||||
#[cfg(not(target_os = "ios"))]
|
||||
let display_info = match crate::video_service::get_current_display() {
|
||||
Ok((_, _, display)) => serde_json::to_string(&HashMap::from([
|
||||
("w", display.width()),
|
||||
("h", display.height()),
|
||||
]))
|
||||
.unwrap_or_default(),
|
||||
Err(..) => "".to_string(),
|
||||
};
|
||||
pub fn main_get_main_display() -> SyncReturn<String> {
|
||||
#[cfg(target_os = "ios")]
|
||||
let display_info = "".to_owned();
|
||||
#[cfg(not(target_os = "ios"))]
|
||||
let mut display_info = "".to_owned();
|
||||
#[cfg(not(target_os = "ios"))]
|
||||
if let Ok(displays) = crate::display_service::try_get_displays() {
|
||||
// to-do: Need to detect current display index.
|
||||
if let Some(display) = displays.iter().next() {
|
||||
display_info = serde_json::to_string(&HashMap::from([
|
||||
("w", display.width()),
|
||||
("h", display.height()),
|
||||
]))
|
||||
.unwrap_or_default();
|
||||
}
|
||||
}
|
||||
SyncReturn(display_info)
|
||||
}
|
||||
|
||||
@@ -1029,31 +1061,31 @@ pub fn session_add_port_forward(
|
||||
remote_host: String,
|
||||
remote_port: i32,
|
||||
) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.add_port_forward(local_port, remote_host, remote_port);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_remove_port_forward(session_id: SessionID, local_port: i32) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.remove_port_forward(local_port);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_new_rdp(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.new_rdp();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_request_voice_call(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.request_voice_call();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_close_voice_call(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.close_voice_call();
|
||||
}
|
||||
}
|
||||
@@ -1238,20 +1270,20 @@ pub fn session_send_mouse(session_id: SessionID, msg: String) {
|
||||
_ => 0,
|
||||
} << 3;
|
||||
}
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.send_mouse(mask, x, y, alt, ctrl, shift, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_restart_remote_device(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.restart_remote_device();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_audit_server_sync(session_id: SessionID, typ: String) -> SyncReturn<String> {
|
||||
let res = if let Some(session) = sessions::get_session(&session_id) {
|
||||
let res = if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.get_audit_server(typ)
|
||||
} else {
|
||||
"".to_owned()
|
||||
@@ -1260,13 +1292,13 @@ pub fn session_get_audit_server_sync(session_id: SessionID, typ: String) -> Sync
|
||||
}
|
||||
|
||||
pub fn session_send_note(session_id: SessionID, note: String) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.send_note(note)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_alternative_codecs(session_id: SessionID) -> String {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
let (vp8, av1, h264, h265) = session.alternative_codecs();
|
||||
let msg = HashMap::from([("vp8", vp8), ("av1", av1), ("h264", h264), ("h265", h265)]);
|
||||
serde_json::ser::to_string(&msg).unwrap_or("".to_owned())
|
||||
@@ -1276,15 +1308,13 @@ pub fn session_alternative_codecs(session_id: SessionID) -> String {
|
||||
}
|
||||
|
||||
pub fn session_change_prefer_codec(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.change_prefer_codec();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_on_waiting_for_image_dialog_show(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
session.ui_handler.on_waiting_for_image_dialog_show();
|
||||
}
|
||||
super::flutter::session_on_waiting_for_image_dialog_show(session_id);
|
||||
}
|
||||
|
||||
pub fn main_set_home_dir(_home: String) {
|
||||
@@ -1434,16 +1464,22 @@ pub fn translate(name: String, locale: String) -> SyncReturn<String> {
|
||||
SyncReturn(crate::client::translate_locale(name, &locale))
|
||||
}
|
||||
|
||||
pub fn session_get_rgba_size(session_id: SessionID) -> SyncReturn<usize> {
|
||||
SyncReturn(super::flutter::session_get_rgba_size(session_id))
|
||||
pub fn session_get_rgba_size(session_id: SessionID, display: usize) -> SyncReturn<usize> {
|
||||
SyncReturn(super::flutter::session_get_rgba_size(session_id, display))
|
||||
}
|
||||
|
||||
pub fn session_next_rgba(session_id: SessionID) -> SyncReturn<()> {
|
||||
SyncReturn(super::flutter::session_next_rgba(session_id))
|
||||
pub fn session_next_rgba(session_id: SessionID, display: usize) -> SyncReturn<()> {
|
||||
SyncReturn(super::flutter::session_next_rgba(session_id, display))
|
||||
}
|
||||
|
||||
pub fn session_register_texture(session_id: SessionID, ptr: usize) -> SyncReturn<()> {
|
||||
SyncReturn(super::flutter::session_register_texture(session_id, ptr))
|
||||
pub fn session_register_texture(
|
||||
session_id: SessionID,
|
||||
display: usize,
|
||||
ptr: usize,
|
||||
) -> SyncReturn<()> {
|
||||
SyncReturn(super::flutter::session_register_texture(
|
||||
session_id, display, ptr,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn query_onlines(ids: Vec<String>) {
|
||||
@@ -1522,7 +1558,7 @@ pub fn main_update_me() -> SyncReturn<bool> {
|
||||
}
|
||||
|
||||
pub fn set_cur_session_id(session_id: SessionID) {
|
||||
if let Some(session) = sessions::get_session(&session_id) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
set_cur_session_id_(session_id, &session.get_keyboard_mode())
|
||||
}
|
||||
}
|
||||
@@ -1808,6 +1844,10 @@ pub fn plugin_install(_id: String, _b: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_support_multi_ui_session(version: String) -> SyncReturn<bool> {
|
||||
SyncReturn(crate::common::is_support_multi_ui_session(&version))
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub mod server_side {
|
||||
use hbb_common::{config, log};
|
||||
|
||||
Reference in New Issue
Block a user