mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-09 11:31:29 +03:00
refact: win idd, x86 on x64 (#7796)
* refact: win idd, x86 on x64 Signed-off-by: fufesou <shuanglongchen@yeah.net> * comments Signed-off-by: fufesou <shuanglongchen@yeah.net> * typo Signed-off-by: fufesou <shuanglongchen@yeah.net> * refact: win idd, check if x64 and deviceinstaller64 exits Signed-off-by: fufesou <shuanglongchen@yeah.net> * refact: win idd Signed-off-by: fufesou <shuanglongchen@yeah.net> * refact: win idd, add logs Signed-off-by: fufesou <shuanglongchen@yeah.net> --------- Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -6,7 +6,12 @@ use crate::{
|
||||
display_service,
|
||||
ipc::{connect, Data},
|
||||
};
|
||||
use hbb_common::{anyhow::anyhow, bail, lazy_static, tokio, ResultType};
|
||||
use hbb_common::{
|
||||
anyhow::anyhow,
|
||||
bail, lazy_static,
|
||||
tokio::{self, sync::oneshot},
|
||||
ResultType,
|
||||
};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
@@ -51,6 +56,8 @@ pub enum PrivacyModeState {
|
||||
}
|
||||
|
||||
pub trait PrivacyMode: Sync + Send {
|
||||
fn is_async_privacy_mode(&self) -> bool;
|
||||
|
||||
fn init(&self) -> ResultType<()>;
|
||||
fn clear(&mut self);
|
||||
fn turn_on_privacy(&mut self, conn_id: i32) -> ResultType<bool>;
|
||||
@@ -200,7 +207,40 @@ fn get_supported_impl(impl_key: &str) -> String {
|
||||
cur_impl
|
||||
}
|
||||
|
||||
pub fn turn_on_privacy(impl_key: &str, conn_id: i32) -> Option<ResultType<bool>> {
|
||||
pub async fn turn_on_privacy(impl_key: &str, conn_id: i32) -> Option<ResultType<bool>> {
|
||||
if is_async_privacy_mode() {
|
||||
turn_on_privacy_async(impl_key.to_string(), conn_id).await
|
||||
} else {
|
||||
turn_on_privacy_sync(impl_key, conn_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_async_privacy_mode() -> bool {
|
||||
PRIVACY_MODE
|
||||
.lock()
|
||||
.unwrap()
|
||||
.as_ref()
|
||||
.map_or(false, |m| m.is_async_privacy_mode())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
async fn turn_on_privacy_async(impl_key: String, conn_id: i32) -> Option<ResultType<bool>> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
std::thread::spawn(move || {
|
||||
let res = turn_on_privacy_sync(&impl_key, conn_id);
|
||||
let _ = tx.send(res);
|
||||
});
|
||||
match hbb_common::timeout(5000, rx).await {
|
||||
Ok(res) => match res {
|
||||
Ok(res) => res,
|
||||
Err(e) => Some(Err(anyhow!(e.to_string()))),
|
||||
},
|
||||
Err(e) => Some(Err(anyhow!(e.to_string()))),
|
||||
}
|
||||
}
|
||||
|
||||
fn turn_on_privacy_sync(impl_key: &str, conn_id: i32) -> Option<ResultType<bool>> {
|
||||
// Check if privacy mode is already on or occupied by another one
|
||||
let mut privacy_mode_lock = PRIVACY_MODE.lock().unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user