mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-19 22:23:19 +03:00
add: include_hidden parameters, migrate to bridge
This commit is contained in:
@@ -15,6 +15,7 @@ use magnum_opus::{Channels::*, Decoder as AudioDecoder};
|
||||
use sha2::{Digest, Sha256};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub use file_trait::FileManager;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
anyhow::{anyhow, Context},
|
||||
@@ -30,13 +31,14 @@ use hbb_common::{
|
||||
tokio::time::Duration,
|
||||
AddrMangle, ResultType, Stream,
|
||||
};
|
||||
pub use helper::LatencyController;
|
||||
use scrap::{Decoder, Image, VideoCodecId};
|
||||
|
||||
pub use super::lang::*;
|
||||
|
||||
pub mod file_trait;
|
||||
pub use file_trait::FileManager;
|
||||
pub mod helper;
|
||||
pub use helper::LatencyController;
|
||||
|
||||
pub const SEC30: Duration = Duration::from_secs(30);
|
||||
|
||||
/// Client of the remote desktop.
|
||||
@@ -1535,7 +1537,7 @@ pub enum Data {
|
||||
Login((String, bool)),
|
||||
Message(Message),
|
||||
SendFiles((i32, String, String, i32, bool, bool)),
|
||||
RemoveDirAll((i32, String, bool)),
|
||||
RemoveDirAll((i32, String, bool, bool)),
|
||||
ConfirmDeleteFiles((i32, i32)),
|
||||
SetNoConfirm(i32),
|
||||
RemoveDir((i32, String)),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use super::{Data, Interface};
|
||||
use hbb_common::{fs, message_proto::*};
|
||||
|
||||
use super::{Data, Interface};
|
||||
|
||||
pub trait FileManager: Interface {
|
||||
fn get_home_dir(&self) -> String {
|
||||
fs::get_home_as_string()
|
||||
@@ -48,8 +49,8 @@ pub trait FileManager: Interface {
|
||||
self.send(Data::RemoveFile((id, path, file_num, is_remote)));
|
||||
}
|
||||
|
||||
fn remove_dir_all(&self, id: i32, path: String, is_remote: bool) {
|
||||
self.send(Data::RemoveDirAll((id, path, is_remote)));
|
||||
fn remove_dir_all(&self, id: i32, path: String, is_remote: bool, include_hidden: bool) {
|
||||
self.send(Data::RemoveDirAll((id, path, is_remote, include_hidden)));
|
||||
}
|
||||
|
||||
fn confirm_delete_files(&self, id: i32, file_num: i32) {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
use crate::common::make_fd_to_json;
|
||||
use crate::{client::*, flutter_ffi::EventToUI};
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
sync::{Arc, Mutex, RwLock},
|
||||
};
|
||||
|
||||
use flutter_rust_bridge::{StreamSink, ZeroCopyBuffer};
|
||||
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
compress::decompress,
|
||||
@@ -21,10 +25,9 @@ use hbb_common::{
|
||||
},
|
||||
Stream,
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
sync::{Arc, Mutex, RwLock},
|
||||
};
|
||||
|
||||
use crate::common::make_fd_to_json;
|
||||
use crate::{client::*, flutter_ffi::EventToUI};
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
// static ref SESSION: Arc<RwLock<Option<Session>>> = Default::default();
|
||||
@@ -52,9 +55,9 @@ impl Session {
|
||||
/// * `id` - The identifier of the remote session with prefix. Regex: [\w]*[\_]*[\d]+
|
||||
/// * `is_file_transfer` - If the session is used for file transfer.
|
||||
pub fn start(identifier: &str, is_file_transfer: bool, events2ui: StreamSink<EventToUI>) {
|
||||
LocalConfig::set_remote_id(&identifier);
|
||||
// TODO check same id
|
||||
let session_id = get_session_id(identifier.to_owned());
|
||||
LocalConfig::set_remote_id(&session_id);
|
||||
// TODO close
|
||||
// Self::close();
|
||||
let events2ui = Arc::new(RwLock::new(events2ui));
|
||||
@@ -502,7 +505,11 @@ impl Interface for Session {
|
||||
|
||||
if lc.is_file_transfer {
|
||||
if pi.username.is_empty() {
|
||||
self.msgbox("error", "Error", "No active console user logged on, please connect and logon first.");
|
||||
self.msgbox(
|
||||
"error",
|
||||
"Error",
|
||||
"No active console user logged on, please connect and logon first.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -992,20 +999,20 @@ impl Connection {
|
||||
}
|
||||
}
|
||||
}
|
||||
Data::RemoveDirAll((id, path, is_remote)) => {
|
||||
Data::RemoveDirAll((id, path, is_remote, include_hidden)) => {
|
||||
if is_remote {
|
||||
let mut msg_out = Message::new();
|
||||
let mut file_action = FileAction::new();
|
||||
file_action.set_all_files(ReadAllFiles {
|
||||
id,
|
||||
path: path.clone(),
|
||||
include_hidden: true,
|
||||
include_hidden,
|
||||
..Default::default()
|
||||
});
|
||||
msg_out.set_file_action(file_action);
|
||||
allow_err!(peer.send(&msg_out).await);
|
||||
} else {
|
||||
match fs::get_recursive_files(&path, true) {
|
||||
match fs::get_recursive_files(&path, include_hidden) {
|
||||
Ok(entries) => {
|
||||
let mut fd = FileDirectory::new();
|
||||
fd.id = id;
|
||||
@@ -1235,9 +1242,8 @@ pub mod connection_manager {
|
||||
sync::{Mutex, RwLock},
|
||||
};
|
||||
|
||||
use crate::ipc;
|
||||
use crate::ipc::Data;
|
||||
use crate::server::Connection as Conn;
|
||||
use serde_derive::Serialize;
|
||||
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
config::Config,
|
||||
@@ -1254,7 +1260,10 @@ pub mod connection_manager {
|
||||
};
|
||||
#[cfg(any(target_os = "android"))]
|
||||
use scrap::android::call_main_service_set_by_name;
|
||||
use serde_derive::Serialize;
|
||||
|
||||
use crate::ipc;
|
||||
use crate::ipc::Data;
|
||||
use crate::server::Connection as Conn;
|
||||
|
||||
use super::GLOBAL_EVENT_STREAM;
|
||||
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
ffi::{CStr, CString},
|
||||
os::raw::c_char,
|
||||
};
|
||||
|
||||
use flutter_rust_bridge::{StreamSink, SyncReturn, ZeroCopyBuffer};
|
||||
use serde_json::{Number, Value};
|
||||
|
||||
use hbb_common::ResultType;
|
||||
use hbb_common::{
|
||||
config::{self, Config, LocalConfig, PeerConfig, ONLINE},
|
||||
fs, log,
|
||||
};
|
||||
|
||||
use crate::client::file_trait::FileManager;
|
||||
use crate::common::make_fd_to_json;
|
||||
use crate::flutter::connection_manager::{self, get_clients_length, get_clients_state};
|
||||
use crate::flutter::{self, Session, SESSIONS};
|
||||
use crate::start_server;
|
||||
use crate::ui_interface;
|
||||
use flutter_rust_bridge::{StreamSink, SyncReturn, ZeroCopyBuffer};
|
||||
use hbb_common::ResultType;
|
||||
use hbb_common::{
|
||||
config::{self, Config, LocalConfig, PeerConfig, ONLINE},
|
||||
fs, log,
|
||||
};
|
||||
use serde_json::{Number, Value};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
ffi::{CStr, CString},
|
||||
os::raw::c_char,
|
||||
};
|
||||
|
||||
fn initialize(app_dir: &str) {
|
||||
*config::APP_DIR.write().unwrap() = app_dir.to_owned();
|
||||
@@ -244,6 +247,13 @@ pub fn session_peer_option(id: String, name: String, value: String) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_peer_option(id: String, name: String) -> String {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
return session.get_option(&name);
|
||||
}
|
||||
"".to_string()
|
||||
}
|
||||
|
||||
pub fn session_input_os_password(id: String, value: String) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
session.input_os_password(value, true);
|
||||
@@ -290,9 +300,15 @@ pub fn session_remove_file(id: String, act_id: i32, path: String, file_num: i32,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_read_dir_recursive(id: String, act_id: i32, path: String, is_remote: bool) {
|
||||
pub fn session_read_dir_recursive(
|
||||
id: String,
|
||||
act_id: i32,
|
||||
path: String,
|
||||
is_remote: bool,
|
||||
show_hidden: bool,
|
||||
) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
session.remove_dir_all(act_id, path, is_remote);
|
||||
session.remove_dir_all(act_id, path, is_remote, show_hidden);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -814,13 +830,14 @@ unsafe extern "C" fn set_by_name(name: *const c_char, value: *const c_char) {
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub mod server_side {
|
||||
use hbb_common::{config::Config, log};
|
||||
use jni::{
|
||||
objects::{JClass, JString},
|
||||
sys::jstring,
|
||||
JNIEnv,
|
||||
};
|
||||
|
||||
use hbb_common::{config::Config, log};
|
||||
|
||||
use crate::start_server;
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
@@ -188,7 +188,8 @@ class JobTable: Reactor.Component {
|
||||
job.confirmed = true;
|
||||
return;
|
||||
}else if (job.type == "del-dir"){
|
||||
handler.remove_dir_all(job.id, job.path, job.is_remote);
|
||||
// TODO: include_hidden is always true
|
||||
handler.remove_dir_all(job.id, job.path, job.is_remote, true);
|
||||
job.confirmed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ impl sciter::EventHandler for Handler {
|
||||
fn read_remote_dir(String, bool);
|
||||
fn send_chat(String);
|
||||
fn switch_display(i32);
|
||||
fn remove_dir_all(i32, String, bool);
|
||||
fn remove_dir_all(i32, String, bool, bool);
|
||||
fn confirm_delete_files(i32, i32);
|
||||
fn set_no_confirm(i32);
|
||||
fn cancel_job(i32);
|
||||
@@ -1793,7 +1793,7 @@ impl Remote {
|
||||
}
|
||||
}
|
||||
}
|
||||
Data::RemoveDirAll((id, path, is_remote)) => {
|
||||
Data::RemoveDirAll((id, path, is_remote, include_hidden)) => {
|
||||
let sep = self.handler.get_path_sep(is_remote);
|
||||
if is_remote {
|
||||
let mut msg_out = Message::new();
|
||||
@@ -1801,7 +1801,7 @@ impl Remote {
|
||||
file_action.set_all_files(ReadAllFiles {
|
||||
id,
|
||||
path: path.clone(),
|
||||
include_hidden: true,
|
||||
include_hidden,
|
||||
..Default::default()
|
||||
});
|
||||
msg_out.set_file_action(file_action);
|
||||
@@ -1809,7 +1809,7 @@ impl Remote {
|
||||
self.remove_jobs
|
||||
.insert(id, RemoveJob::new(Vec::new(), path, sep, is_remote));
|
||||
} else {
|
||||
match fs::get_recursive_files(&path, true) {
|
||||
match fs::get_recursive_files(&path, include_hidden) {
|
||||
Ok(entries) => {
|
||||
let m = make_fd(id, &entries, true);
|
||||
self.handler.call("updateFolderFiles", &make_args!(m));
|
||||
@@ -2370,7 +2370,7 @@ impl Remote {
|
||||
}
|
||||
back_notification::PrivacyModeState::OffSucceeded => {
|
||||
self.handler
|
||||
.msgbox("custom-nocancel", "Privacy mode", "Out privacy mode");
|
||||
.msgbox("custom-nocancel", "Privacy mode", "Out privacy mode");
|
||||
self.update_privacy_mode(false);
|
||||
}
|
||||
back_notification::PrivacyModeState::OffByPeer => {
|
||||
|
||||
Reference in New Issue
Block a user