mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -17,6 +17,8 @@ use crate::{client::*, flutter_ffi::EventToUI};
|
||||
pub(super) const APP_TYPE_MAIN: &str = "main";
|
||||
pub(super) const APP_TYPE_DESKTOP_REMOTE: &str = "remote";
|
||||
pub(super) const APP_TYPE_DESKTOP_FILE_TRANSFER: &str = "file transfer";
|
||||
pub(super) const APP_TYPE_DESKTOP_PORT_FORWARD: &str = "port forward";
|
||||
pub(super) const APP_TYPE_DESKTOP_RDP: &str = "rdp";
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref SESSIONS: RwLock<HashMap<String,Session<FlutterHandler>>> = Default::default();
|
||||
@@ -376,6 +378,10 @@ pub mod connection_manager {
|
||||
vec![("id", &id.to_string()), ("text", &text)],
|
||||
);
|
||||
}
|
||||
|
||||
fn change_theme(&self, dark: bool) {
|
||||
self.push_event("theme", vec![("dark", &dark.to_string())]);
|
||||
}
|
||||
}
|
||||
|
||||
impl FlutterHandler {
|
||||
|
||||
@@ -23,7 +23,7 @@ use crate::ui_interface::{
|
||||
get_app_name, get_async_job_status, get_connect_status, get_fav, get_id, get_lan_peers,
|
||||
get_langs, get_license, get_local_option, get_mouse_time, get_option, get_options, get_peer,
|
||||
get_peer_option, get_socks, get_sound_inputs, get_uuid, get_version, has_hwcodec,
|
||||
has_rendezvous_service, post_request, set_local_option, set_option, set_options,
|
||||
has_rendezvous_service, post_request, send_to_cm, set_local_option, set_option, set_options,
|
||||
set_peer_option, set_permanent_password, set_socks, store_fav, test_if_valid_server,
|
||||
update_temporary_password, using_public_server,
|
||||
};
|
||||
@@ -659,6 +659,23 @@ pub fn main_load_lan_peers() {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn main_change_theme(dark: bool) {
|
||||
let apps = vec![
|
||||
flutter::APP_TYPE_DESKTOP_REMOTE,
|
||||
flutter::APP_TYPE_DESKTOP_FILE_TRANSFER,
|
||||
flutter::APP_TYPE_DESKTOP_PORT_FORWARD,
|
||||
flutter::APP_TYPE_DESKTOP_RDP,
|
||||
];
|
||||
|
||||
for app in apps {
|
||||
if let Some(s) = flutter::GLOBAL_EVENT_STREAM.read().unwrap().get(app) {
|
||||
let data = HashMap::from([("name", "theme".to_owned()), ("dark", dark.to_string())]);
|
||||
s.add(serde_json::ser::to_string(&data).unwrap_or("".to_owned()));
|
||||
};
|
||||
}
|
||||
send_to_cm(&crate::ipc::Data::Theme(dark));
|
||||
}
|
||||
|
||||
pub fn session_add_port_forward(
|
||||
id: String,
|
||||
local_port: i32,
|
||||
|
||||
@@ -182,6 +182,7 @@ pub enum Data {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))]
|
||||
Mouse(DataMouse),
|
||||
Control(DataControl),
|
||||
Theme(bool),
|
||||
Empty,
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,10 @@ impl InvokeUiCM for SciterHandler {
|
||||
fn new_message(&self, id: i32, text: String) {
|
||||
self.call("newMessage", &make_args!(id, text));
|
||||
}
|
||||
|
||||
fn change_theme(&self, _dark: bool) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
impl SciterHandler {
|
||||
|
||||
@@ -60,6 +60,8 @@ pub trait InvokeUiCM: Send + Clone + 'static + Sized {
|
||||
fn remove_connection(&self, id: i32);
|
||||
|
||||
fn new_message(&self, id: i32, text: String);
|
||||
|
||||
fn change_theme(&self, dark: bool);
|
||||
}
|
||||
|
||||
impl<T: InvokeUiCM> Deref for ConnectionManager<T> {
|
||||
@@ -280,6 +282,9 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
|
||||
.send(ClipboardFileData::Enable((conn_id, enabled)))
|
||||
.ok();
|
||||
}
|
||||
Data::Theme(dark) => {
|
||||
cm.change_theme(dark);
|
||||
}
|
||||
_ => {
|
||||
|
||||
}
|
||||
|
||||
@@ -373,7 +373,8 @@ pub fn get_mouse_time() -> f64 {
|
||||
}
|
||||
|
||||
pub fn check_mouse_time() {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]{
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
let sender = SENDER.lock().unwrap();
|
||||
allow_err!(sender.send(ipc::Data::MouseMoveTime(0)));
|
||||
}
|
||||
@@ -779,6 +780,13 @@ pub(crate) async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedRe
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
pub(crate) async fn send_to_cm(data: &ipc::Data) {
|
||||
if let Ok(mut c) = ipc::connect(1000, "_cm").await {
|
||||
c.send(data).await.ok();
|
||||
}
|
||||
}
|
||||
|
||||
const INVALID_FORMAT: &'static str = "Invalid format";
|
||||
const UNKNOWN_ERROR: &'static str = "Unknown error";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user