Windows build
This commit is contained in:
parent
bd733bc108
commit
948580b288
@ -43,7 +43,7 @@ pub struct Remote<T: InvokeUiSession> {
|
|||||||
last_update_jobs_status: (Instant, HashMap<i32, u64>),
|
last_update_jobs_status: (Instant, HashMap<i32, u64>),
|
||||||
first_frame: bool,
|
first_frame: bool,
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
clipboard_file_context: Option<Box<CliprdrClientContext>>,
|
clipboard_file_context: Option<Box<clipboard::cliprdr::CliprdrClientContext>>,
|
||||||
data_count: Arc<AtomicUsize>,
|
data_count: Arc<AtomicUsize>,
|
||||||
frame_count: Arc<AtomicUsize>,
|
frame_count: Arc<AtomicUsize>,
|
||||||
video_format: CodecFormat,
|
video_format: CodecFormat,
|
||||||
@ -107,7 +107,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
|||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
let (_tx_holder, mut rx_clip_client) = mpsc::unbounded_channel::<i32>();
|
let (_tx_holder, mut rx_clip_client) = mpsc::unbounded_channel::<i32>();
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let mut rx_clip_client = get_rx_clip_client().lock().await;
|
let mut rx_clip_client = clipboard::get_rx_clip_client().lock().await;
|
||||||
|
|
||||||
let mut status_timer = time::interval(Duration::new(1, 0));
|
let mut status_timer = time::interval(Duration::new(1, 0));
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
match _msg {
|
match _msg {
|
||||||
Some((_, clip)) => {
|
Some((_, clip)) => {
|
||||||
allow_err!(peer.send(&clip_2_msg(clip)).await);
|
allow_err!(peer.send(&crate::clipboard_file::clip_2_msg(clip)).await);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// unreachable!()
|
// unreachable!()
|
||||||
@ -357,7 +357,13 @@ impl<T: InvokeUiSession> Remote<T> {
|
|||||||
to,
|
to,
|
||||||
job.files().len()
|
job.files().len()
|
||||||
);
|
);
|
||||||
self.handler.update_folder_files(job.id(), job.files(), path,!is_remote, true);
|
self.handler.update_folder_files(
|
||||||
|
job.id(),
|
||||||
|
job.files(),
|
||||||
|
path,
|
||||||
|
!is_remote,
|
||||||
|
true,
|
||||||
|
);
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
let files = job.files().clone();
|
let files = job.files().clone();
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@ -416,7 +422,13 @@ impl<T: InvokeUiSession> Remote<T> {
|
|||||||
to,
|
to,
|
||||||
job.files().len()
|
job.files().len()
|
||||||
);
|
);
|
||||||
self.handler.update_folder_files(job.id(), job.files(), path,!is_remote, true);
|
self.handler.update_folder_files(
|
||||||
|
job.id(),
|
||||||
|
job.files(),
|
||||||
|
path,
|
||||||
|
!is_remote,
|
||||||
|
true,
|
||||||
|
);
|
||||||
job.is_last_job = true;
|
job.is_last_job = true;
|
||||||
self.read_jobs.push(job);
|
self.read_jobs.push(job);
|
||||||
self.timer = time::interval(MILLI1);
|
self.timer = time::interval(MILLI1);
|
||||||
@ -528,7 +540,13 @@ impl<T: InvokeUiSession> Remote<T> {
|
|||||||
} else {
|
} else {
|
||||||
match fs::get_recursive_files(&path, include_hidden) {
|
match fs::get_recursive_files(&path, include_hidden) {
|
||||||
Ok(entries) => {
|
Ok(entries) => {
|
||||||
self.handler.update_folder_files(id, &entries, path.clone(),!is_remote, false);
|
self.handler.update_folder_files(
|
||||||
|
id,
|
||||||
|
&entries,
|
||||||
|
path.clone(),
|
||||||
|
!is_remote,
|
||||||
|
false,
|
||||||
|
);
|
||||||
self.remove_jobs
|
self.remove_jobs
|
||||||
.insert(id, RemoveJob::new(entries, path, sep, is_remote));
|
.insert(id, RemoveJob::new(entries, path, sep, is_remote));
|
||||||
}
|
}
|
||||||
@ -785,8 +803,8 @@ impl<T: InvokeUiSession> Remote<T> {
|
|||||||
Some(message::Union::Cliprdr(clip)) => {
|
Some(message::Union::Cliprdr(clip)) => {
|
||||||
if !self.handler.lc.read().unwrap().disable_clipboard {
|
if !self.handler.lc.read().unwrap().disable_clipboard {
|
||||||
if let Some(context) = &mut self.clipboard_file_context {
|
if let Some(context) = &mut self.clipboard_file_context {
|
||||||
if let Some(clip) = msg_2_clip(clip) {
|
if let Some(clip) = crate::clipboard_file::msg_2_clip(clip) {
|
||||||
server_clip_file(context, 0, clip);
|
clipboard::server_clip_file(context, 0, clip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -804,7 +822,13 @@ impl<T: InvokeUiSession> Remote<T> {
|
|||||||
fs::transform_windows_path(&mut entries);
|
fs::transform_windows_path(&mut entries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.handler.update_folder_files(fd.id, &entries, fd.path, false, fd.id > 0);
|
self.handler.update_folder_files(
|
||||||
|
fd.id,
|
||||||
|
&entries,
|
||||||
|
fd.path,
|
||||||
|
false,
|
||||||
|
fd.id > 0,
|
||||||
|
);
|
||||||
if let Some(job) = fs::get_job(fd.id, &mut self.write_jobs) {
|
if let Some(job) = fs::get_job(fd.id, &mut self.write_jobs) {
|
||||||
log::info!("job set_files: {:?}", entries);
|
log::info!("job set_files: {:?}", entries);
|
||||||
job.set_files(entries);
|
job.set_files(entries);
|
||||||
@ -1132,7 +1156,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
|||||||
&& self.handler.lc.read().unwrap().enable_file_transfer;
|
&& self.handler.lc.read().unwrap().enable_file_transfer;
|
||||||
if enabled == self.clipboard_file_context.is_none() {
|
if enabled == self.clipboard_file_context.is_none() {
|
||||||
self.clipboard_file_context = if enabled {
|
self.clipboard_file_context = if enabled {
|
||||||
match create_clipboard_file_context(true, false) {
|
match clipboard::create_cliprdr_context(true, false) {
|
||||||
Ok(context) => {
|
Ok(context) => {
|
||||||
log::info!("clipboard context for file transfer created.");
|
log::info!("clipboard context for file transfer created.");
|
||||||
Some(context)
|
Some(context)
|
||||||
|
@ -396,13 +396,10 @@ pub mod connection_manager {
|
|||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
pub fn start_listen_ipc_thread() {
|
pub fn start_listen_ipc_thread() {
|
||||||
use crate::{
|
use crate::ui_cm_interface::{start_ipc, ConnectionManager};
|
||||||
ipc::start_pa,
|
|
||||||
ui_cm_interface::{start_ipc, ConnectionManager},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
std::thread::spawn(start_pa);
|
std::thread::spawn(crate::ipc::start_pa);
|
||||||
|
|
||||||
let cm = ConnectionManager {
|
let cm = ConnectionManager {
|
||||||
ui_handler: FlutterHandler {},
|
ui_handler: FlutterHandler {},
|
||||||
@ -411,7 +408,7 @@ pub mod connection_manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
use hbb_common::tokio::sync::mpsc::{UnboundedReceiver,UnboundedSender};
|
use hbb_common::tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
pub fn start_channel(
|
pub fn start_channel(
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
sync::{
|
sync::{atomic::Ordering, Arc, Mutex},
|
||||||
atomic::Ordering,
|
|
||||||
Arc, Mutex,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use sciter::{
|
use sciter::{
|
||||||
@ -40,9 +37,6 @@ lazy_static::lazy_static! {
|
|||||||
static ref VIDEO: Arc<Mutex<Option<Video>>> = Default::default();
|
static ref VIDEO: Arc<Mutex<Option<Video>>> = Default::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
static mut IS_ALT_GR: bool = false;
|
|
||||||
|
|
||||||
/// SciterHandler
|
/// SciterHandler
|
||||||
/// * element
|
/// * element
|
||||||
/// * close_state for file path when close
|
/// * close_state for file path when close
|
||||||
|
@ -268,19 +268,18 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
|
|||||||
Data::FS(fs) => {
|
Data::FS(fs) => {
|
||||||
handle_fs(fs, &mut write_jobs, &tx).await;
|
handle_fs(fs, &mut write_jobs, &tx).await;
|
||||||
}
|
}
|
||||||
// TODO ClipbaordFile
|
#[cfg(windows)]
|
||||||
// #[cfg(windows)]
|
Data::ClipbaordFile(_clip) => {
|
||||||
// Data::ClipbaordFile(_clip) => {
|
tx_file
|
||||||
// tx_file
|
.send(ClipboardFileData::Clip((conn_id, _clip)))
|
||||||
// .send(ClipboardFileData::Clip((id, _clip)))
|
.ok();
|
||||||
// .ok();
|
}
|
||||||
// }
|
#[cfg(windows)]
|
||||||
// #[cfg(windows)]
|
Data::ClipboardFileEnabled(enabled) => {
|
||||||
// Data::ClipboardFileEnabled(enabled) => {
|
tx_file
|
||||||
// tx_file
|
.send(ClipboardFileData::Enable((conn_id, enabled)))
|
||||||
// .send(ClipboardFileData::Enable((id, enabled)))
|
.ok();
|
||||||
// .ok();
|
}
|
||||||
// }
|
|
||||||
_ => {
|
_ => {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -316,7 +315,11 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
|
|||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
#[tokio::main(flavor = "current_thread")]
|
#[tokio::main(flavor = "current_thread")]
|
||||||
pub async fn start_listen<T: InvokeUiCM>(cm: ConnectionManager<T>, mut rx: mpsc::UnboundedReceiver<Data>, tx: mpsc::UnboundedSender<Data>) {
|
pub async fn start_listen<T: InvokeUiCM>(
|
||||||
|
cm: ConnectionManager<T>,
|
||||||
|
mut rx: mpsc::UnboundedReceiver<Data>,
|
||||||
|
tx: mpsc::UnboundedSender<Data>,
|
||||||
|
) {
|
||||||
let mut current_id = 0;
|
let mut current_id = 0;
|
||||||
let mut write_jobs: Vec<fs::TransferJob> = Vec::new();
|
let mut write_jobs: Vec<fs::TransferJob> = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
@ -596,19 +599,18 @@ fn send_raw(msg: Message, tx: &UnboundedSender<Data>) {
|
|||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[tokio::main(flavor = "current_thread")]
|
#[tokio::main(flavor = "current_thread")]
|
||||||
pub async fn start_clipboard_file(
|
pub async fn start_clipboard_file<T: InvokeUiCM>(
|
||||||
cm: ConnectionManager,
|
cm: ConnectionManager<T>,
|
||||||
mut rx: mpsc::UnboundedReceiver<ClipboardFileData>,
|
mut rx: mpsc::UnboundedReceiver<ClipboardFileData>,
|
||||||
) {
|
) {
|
||||||
let mut cliprdr_context = None;
|
let mut cliprdr_context = None;
|
||||||
let mut rx_clip_client = get_rx_clip_client().lock().await;
|
let mut rx_clip_client = clipboard::get_rx_clip_client().lock().await;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
clip_file = rx_clip_client.recv() => match clip_file {
|
clip_file = rx_clip_client.recv() => match clip_file {
|
||||||
Some((conn_id, clip)) => {
|
Some((conn_id, clip)) => {
|
||||||
cmd_inner_send(
|
cmd_inner_send(
|
||||||
&cm,
|
|
||||||
conn_id,
|
conn_id,
|
||||||
Data::ClipbaordFile(clip)
|
Data::ClipbaordFile(clip)
|
||||||
);
|
);
|
||||||
@ -620,12 +622,12 @@ pub async fn start_clipboard_file(
|
|||||||
server_msg = rx.recv() => match server_msg {
|
server_msg = rx.recv() => match server_msg {
|
||||||
Some(ClipboardFileData::Clip((conn_id, clip))) => {
|
Some(ClipboardFileData::Clip((conn_id, clip))) => {
|
||||||
if let Some(ctx) = cliprdr_context.as_mut() {
|
if let Some(ctx) = cliprdr_context.as_mut() {
|
||||||
server_clip_file(ctx, conn_id, clip);
|
clipboard::server_clip_file(ctx, conn_id, clip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(ClipboardFileData::Enable((id, enabled))) => {
|
Some(ClipboardFileData::Enable((id, enabled))) => {
|
||||||
if enabled && cliprdr_context.is_none() {
|
if enabled && cliprdr_context.is_none() {
|
||||||
cliprdr_context = Some(match create_cliprdr_context(true, false) {
|
cliprdr_context = Some(match clipboard::create_cliprdr_context(true, false) {
|
||||||
Ok(context) => {
|
Ok(context) => {
|
||||||
log::info!("clipboard context for file transfer created.");
|
log::info!("clipboard context for file transfer created.");
|
||||||
context
|
context
|
||||||
@ -639,10 +641,10 @@ pub async fn start_clipboard_file(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
set_conn_enabled(id, enabled);
|
clipboard::set_conn_enabled(id, enabled);
|
||||||
if !enabled {
|
if !enabled {
|
||||||
if let Some(ctx) = cliprdr_context.as_mut() {
|
if let Some(ctx) = cliprdr_context.as_mut() {
|
||||||
empty_clipboard(ctx, id);
|
clipboard::empty_clipboard(ctx, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -655,15 +657,15 @@ pub async fn start_clipboard_file(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn cmd_inner_send(cm: &ConnectionManager, id: i32, data: Data) {
|
fn cmd_inner_send(id: i32, data: Data) {
|
||||||
let lock = cm.read().unwrap();
|
let lock = CLIENTS.read().unwrap();
|
||||||
if id != 0 {
|
if id != 0 {
|
||||||
if let Some(s) = lock.senders.get(&id) {
|
if let Some(s) = lock.get(&id) {
|
||||||
allow_err!(s.send(data));
|
allow_err!(s.tx.send(data));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for s in lock.senders.values() {
|
for s in lock.values() {
|
||||||
allow_err!(s.send(data.clone()));
|
allow_err!(s.tx.send(data.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@ use std::sync::{Arc, Mutex, RwLock};
|
|||||||
pub static IS_IN: AtomicBool = AtomicBool::new(false);
|
pub static IS_IN: AtomicBool = AtomicBool::new(false);
|
||||||
static KEYBOARD_HOOKED: AtomicBool = AtomicBool::new(false);
|
static KEYBOARD_HOOKED: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
static mut IS_ALT_GR: bool = false;
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub struct Session<T: InvokeUiSession> {
|
pub struct Session<T: InvokeUiSession> {
|
||||||
pub cmd: String,
|
pub cmd: String,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user