100% open source

This commit is contained in:
rustdesk
2022-05-12 17:35:25 +08:00
parent 9098619162
commit c1bad84a86
58 changed files with 8397 additions and 3292 deletions

View File

@@ -536,7 +536,7 @@ pub fn run_as_user(arg: &str) -> ResultType<Option<std::process::Child>> {
// -E required for opensuse
let task = std::process::Command::new("sudo")
.args(vec![
"-E",
"-E",
&format!("XDG_RUNTIME_DIR=/run/user/{}", uid) as &str,
"-u",
&get_active_username(),
@@ -587,7 +587,10 @@ pub fn get_pa_sources() -> Vec<(String, String)> {
}
pub fn lock_screen() {
std::process::Command::new("xdg-screensaver").arg("lock").spawn().ok();
std::process::Command::new("xdg-screensaver")
.arg("lock")
.spawn()
.ok();
}
pub fn toggle_blank_screen(_v: bool) {
@@ -604,11 +607,7 @@ pub fn is_installed() -> bool {
fn run_cmds(cmds: String) -> ResultType<Option<String>> {
let mut tmp = std::env::temp_dir();
tmp.push(format!(
"{}_{}",
hbb_common::config::APP_NAME,
crate::get_time()
));
tmp.push(format!("{}_{}", crate::get_app_name(), crate::get_time()));
let mut file = std::fs::File::create(&tmp)?;
file.write_all(cmds.as_bytes())?;
file.sync_all()?;

View File

@@ -1,58 +1,76 @@
#[cfg(target_os = "linux")]
pub use linux::*;
#[cfg(target_os = "macos")]
pub use macos::*;
#[cfg(windows)]
pub use windows::*;
#[cfg(windows)]
pub mod windows;
#[cfg(target_os = "macos")]
pub mod macos;
#[cfg(target_os = "linux")]
pub mod linux;
use hbb_common::{message_proto::CursorData, ResultType};
#[cfg(not(target_os = "macos"))]
const SERVICE_INTERVAL: u64 = 300;
pub fn is_xfce() -> bool {
#[cfg(target_os = "linux")]
{
return std::env::var_os("XDG_CURRENT_DESKTOP") == Some(std::ffi::OsString::from("XFCE"));
}
#[cfg(not(target_os = "linux"))]
{
return false;
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_cursor_data() {
for _ in 0..30 {
if let Some(hc) = get_cursor().unwrap() {
let cd = get_cursor_data(hc).unwrap();
repng::encode(
std::fs::File::create("cursor.png").unwrap(),
cd.width as _,
cd.height as _,
&cd.colors[..],
)
.unwrap();
}
#[cfg(target_os = "macos")]
macos::is_process_trusted(false);
}
}
#[test]
fn test_get_cursor_pos() {
for _ in 0..30 {
assert!(!get_cursor_pos().is_none());
}
}
}
#[cfg(target_os = "linux")]
pub use linux::*;
#[cfg(target_os = "macos")]
pub use macos::*;
#[cfg(windows)]
pub use windows::*;
#[cfg(windows)]
pub mod windows;
#[cfg(target_os = "macos")]
pub mod macos;
#[cfg(target_os = "linux")]
pub mod linux;
use hbb_common::{message_proto::CursorData, ResultType};
#[cfg(not(target_os = "macos"))]
const SERVICE_INTERVAL: u64 = 300;
pub fn get_license_key() -> String {
#[cfg(windows)]
if let Some(lic) = windows::get_license() {
return lic.key;
}
Default::default()
}
pub fn is_xfce() -> bool {
#[cfg(target_os = "linux")]
{
return std::env::var_os("XDG_CURRENT_DESKTOP") == Some(std::ffi::OsString::from("XFCE"));
}
#[cfg(not(target_os = "linux"))]
{
return false;
}
}
// Android
#[cfg(target_os = "android")]
pub fn get_active_username() -> String {
// TODO
"android".into()
}
#[cfg(target_os = "android")]
pub const PA_SAMPLE_RATE: u32 = 48000;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_cursor_data() {
for _ in 0..30 {
if let Some(hc) = get_cursor().unwrap() {
let cd = get_cursor_data(hc).unwrap();
repng::encode(
std::fs::File::create("cursor.png").unwrap(),
cd.width as _,
cd.height as _,
&cd.colors[..],
)
.unwrap();
}
#[cfg(target_os = "macos")]
macos::is_process_trusted(false);
}
}
#[test]
fn test_get_cursor_pos() {
for _ in 0..30 {
assert!(!get_cursor_pos().is_none());
}
}
}

File diff suppressed because it is too large Load Diff