mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
simple_rc: win init simple resource pack
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -42,3 +42,6 @@ mod tray;
|
||||
|
||||
#[cfg(windows)]
|
||||
pub mod clipboard_file;
|
||||
|
||||
#[cfg(all(windows, feature = "with_rc"))]
|
||||
pub mod rc;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Specify the Windows subsystem to eliminate console window.
|
||||
// Requires Rust 1.18.
|
||||
//#![windows_subsystem = "windows"]
|
||||
#![windows_subsystem = "windows"]
|
||||
|
||||
use hbb_common::log;
|
||||
use librustdesk::*;
|
||||
@@ -104,6 +104,10 @@ fn main() {
|
||||
"".to_owned()
|
||||
));
|
||||
return;
|
||||
} else if args[0] == "--extract" {
|
||||
#[cfg(feature = "with_rc")]
|
||||
hbb_common::allow_err!(crate::rc::extract_resources(&args[1]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if args[0] == "--remove" {
|
||||
|
||||
@@ -10,7 +10,6 @@ use std::io::prelude::*;
|
||||
use std::{
|
||||
ffi::OsString,
|
||||
fs, io, mem,
|
||||
path::Path,
|
||||
sync::{Arc, Mutex},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
@@ -856,7 +855,7 @@ fn get_install_info_with_subkey(subkey: String) -> (String, String, String, Stri
|
||||
}
|
||||
|
||||
pub fn update_me() -> ResultType<()> {
|
||||
let (_, _, _, exe) = get_install_info();
|
||||
let (_, path, _, exe) = get_install_info();
|
||||
let src_exe = std::env::current_exe()?.to_str().unwrap_or("").to_owned();
|
||||
let cmds = format!(
|
||||
"
|
||||
@@ -865,12 +864,14 @@ pub fn update_me() -> ResultType<()> {
|
||||
taskkill /F /IM {broker_exe}
|
||||
taskkill /F /IM {app_name}.exe
|
||||
copy /Y \"{src_exe}\" \"{exe}\"
|
||||
\"{src_exe}\" --extract \"{path}\"
|
||||
sc start {app_name}
|
||||
{lic}
|
||||
",
|
||||
src_exe = src_exe,
|
||||
exe = exe,
|
||||
broker_exe = crate::ui::win_privacy::INJECTED_PROCESS_EXE,
|
||||
path = path,
|
||||
app_name = crate::get_app_name(),
|
||||
lic = register_licence(),
|
||||
);
|
||||
@@ -1023,6 +1024,7 @@ chcp 65001
|
||||
md \"{path}\"
|
||||
copy /Y \"{src_exe}\" \"{exe}\"
|
||||
copy /Y \"{ORIGIN_PROCESS_EXE}\" \"{path}\\{broker_exe}\"
|
||||
\"{src_exe}\" --extract \"{path}\"
|
||||
reg add {subkey} /f
|
||||
reg add {subkey} /f /v DisplayIcon /t REG_SZ /d \"{exe}\"
|
||||
reg add {subkey} /f /v DisplayName /t REG_SZ /d \"{app_name}\"
|
||||
|
||||
38
src/rc.rs
Normal file
38
src/rc.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use hbb_common::{bail, ResultType};
|
||||
use std::{
|
||||
fs::{self, File},
|
||||
io::prelude::*,
|
||||
path::Path,
|
||||
};
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn extract_resources(root_path: &str) -> ResultType<()> {
|
||||
let mut resources: Vec<(&str, &[u8])> = Vec::new();
|
||||
resources.push((outfile_4, &outdata_4));
|
||||
do_extract(root_path, resources)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn do_extract(root_path: &str, resources: Vec<(&str, &[u8])>) -> ResultType<()> {
|
||||
let mut root_path = root_path.replace("\\", "/");
|
||||
if !root_path.ends_with('/') {
|
||||
root_path.push('/');
|
||||
}
|
||||
let root_path = Path::new(&root_path);
|
||||
for (outfile, data) in resources {
|
||||
let outfile_path = root_path.join(outfile);
|
||||
match outfile_path.parent().and_then(|p| p.to_str()) {
|
||||
None => {
|
||||
bail!("Failed to get parent of {}", outfile_path.display());
|
||||
}
|
||||
Some(p) => {
|
||||
fs::create_dir_all(p)?;
|
||||
let mut of = File::create(outfile_path)?;
|
||||
of.write_all(data)?;
|
||||
of.flush()?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -24,8 +24,8 @@ use clipboard::{
|
||||
};
|
||||
use enigo::{self, Enigo, KeyboardControllable};
|
||||
use hbb_common::fs::{
|
||||
can_enable_overwrite_detection, get_string, new_send_confirm,
|
||||
DigestCheckResult, RemoveJobMeta, get_job,
|
||||
can_enable_overwrite_detection, get_job, get_string, new_send_confirm, DigestCheckResult,
|
||||
RemoveJobMeta,
|
||||
};
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
@@ -48,7 +48,7 @@ use hbb_common::{config::TransferSerde, fs::TransferJobMeta};
|
||||
use crate::clipboard_file::*;
|
||||
use crate::{
|
||||
client::*,
|
||||
common::{self, check_clipboard, update_clipboard, ClipboardContext, CLIPBOARD_INTERVAL}
|
||||
common::{self, check_clipboard, update_clipboard, ClipboardContext, CLIPBOARD_INTERVAL},
|
||||
};
|
||||
|
||||
type Video = AssetPtr<video_destination>;
|
||||
@@ -267,7 +267,8 @@ impl Handler {
|
||||
std::env::set_var("KEYBOARD_ONLY", "y"); // pass to rdev
|
||||
use rdev::{EventType::*, *};
|
||||
let func = move |evt: Event| {
|
||||
if !IS_IN.load(Ordering::SeqCst) || !SERVER_KEYBOARD_ENABLED.load(Ordering::SeqCst) {
|
||||
if !IS_IN.load(Ordering::SeqCst) || !SERVER_KEYBOARD_ENABLED.load(Ordering::SeqCst)
|
||||
{
|
||||
return;
|
||||
}
|
||||
let (key, down) = match evt.event_type {
|
||||
@@ -1660,7 +1661,12 @@ impl Remote {
|
||||
Data::AddJob((id, path, to, file_num, include_hidden, is_remote)) => {
|
||||
let od = can_enable_overwrite_detection(self.handler.lc.read().unwrap().version);
|
||||
if is_remote {
|
||||
log::debug!("new write waiting job {}, write to {} from remote {}", id, to, path);
|
||||
log::debug!(
|
||||
"new write waiting job {}, write to {} from remote {}",
|
||||
id,
|
||||
to,
|
||||
path
|
||||
);
|
||||
let mut job = fs::TransferJob::new_write(
|
||||
id,
|
||||
path.clone(),
|
||||
@@ -1708,15 +1714,27 @@ impl Remote {
|
||||
if let Some(job) = get_job(id, &mut self.write_jobs) {
|
||||
job.is_last_job = false;
|
||||
allow_err!(
|
||||
peer.send(&fs::new_send(id, job.remote.clone(), job.file_num, job.show_hidden))
|
||||
peer.send(&fs::new_send(
|
||||
id,
|
||||
job.remote.clone(),
|
||||
job.file_num,
|
||||
job.show_hidden
|
||||
))
|
||||
.await
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if let Some(job) = get_job(id, &mut self.read_jobs) {
|
||||
job.is_last_job = false;
|
||||
allow_err!(peer.send(&fs::new_receive(id, job.path.to_string_lossy().to_string(),
|
||||
job.file_num, job.files.clone())).await);
|
||||
allow_err!(
|
||||
peer.send(&fs::new_receive(
|
||||
id,
|
||||
job.path.to_string_lossy().to_string(),
|
||||
job.file_num,
|
||||
job.files.clone()
|
||||
))
|
||||
.await
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2024,6 +2042,9 @@ impl Remote {
|
||||
Some(message::Union::file_response(fr)) => {
|
||||
match fr.union {
|
||||
Some(file_response::Union::dir(fd)) => {
|
||||
#[cfg(windows)]
|
||||
let entries = fd.entries.to_vec();
|
||||
#[cfg(not(windows))]
|
||||
let mut entries = fd.entries.to_vec();
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user