exclude ui module (sciter) for flutter
This commit is contained in:
parent
9d88a06cdf
commit
be09728bf5
@ -36,7 +36,7 @@ impl Session {
|
|||||||
.lc
|
.lc
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.initialize(id.to_owned(), ConnType::PORT_FORWARD);
|
.initialize(id.to_owned(), ConnType::PORT_FORWARD, None);
|
||||||
session
|
session
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ pub trait FileManager: Interface {
|
|||||||
fs::get_home_as_string()
|
fs::get_home_as_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli", feature = "flutter")))]
|
||||||
fn read_dir(&self, path: String, include_hidden: bool) -> sciter::Value {
|
fn read_dir(&self, path: String, include_hidden: bool) -> sciter::Value {
|
||||||
match fs::read_dir(&fs::get_path(&path), include_hidden) {
|
match fs::read_dir(&fs::get_path(&path), include_hidden) {
|
||||||
Err(_) => sciter::Value::null(),
|
Err(_) => sciter::Value::null(),
|
||||||
@ -20,7 +20,7 @@ pub trait FileManager: Interface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli", feature = "flutter"))]
|
||||||
fn read_dir(&self, path: &str, include_hidden: bool) -> String {
|
fn read_dir(&self, path: &str, include_hidden: bool) -> String {
|
||||||
use crate::common::make_fd_to_json;
|
use crate::common::make_fd_to_json;
|
||||||
match fs::read_dir(&fs::get_path(path), include_hidden) {
|
match fs::read_dir(&fs::get_path(path), include_hidden) {
|
||||||
|
@ -762,3 +762,14 @@ pub fn make_fd_to_json(id: i32, path: String, entries: &Vec<FileEntry>) -> Strin
|
|||||||
fd_json.insert("entries".into(), json!(entries_out));
|
fd_json.insert("entries".into(), json!(entries_out));
|
||||||
serde_json::to_string(&fd_json).unwrap_or("".into())
|
serde_json::to_string(&fd_json).unwrap_or("".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The function to handle the url scheme sent by the system.
|
||||||
|
///
|
||||||
|
/// 1. Try to send the url scheme from ipc.
|
||||||
|
/// 2. If failed to send the url scheme, we open a new main window to handle this url scheme.
|
||||||
|
pub fn handle_url_scheme(url: String) {
|
||||||
|
if let Err(err) = crate::ipc::send_url_scheme(url.clone()) {
|
||||||
|
log::debug!("Send the url to the existing flutter process failed, {}. Let's open a new program to handle this.", err);
|
||||||
|
let _ = crate::run_me(vec![url]);
|
||||||
|
}
|
||||||
|
}
|
@ -1119,13 +1119,6 @@ pub fn cm_switch_back(conn_id: i32) {
|
|||||||
crate::ui_cm_interface::switch_back(conn_id);
|
crate::ui_cm_interface::switch_back(conn_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main_get_icon() -> String {
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))]
|
|
||||||
return ui_interface::get_icon();
|
|
||||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
|
||||||
return String::new();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main_get_build_date() -> String {
|
pub fn main_get_build_date() -> String {
|
||||||
crate::BUILD_DATE.to_string()
|
crate::BUILD_DATE.to_string()
|
||||||
}
|
}
|
||||||
@ -1305,7 +1298,7 @@ pub fn main_start_ipc_url_server() {
|
|||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
pub fn send_url_scheme(_url: String) {
|
pub fn send_url_scheme(_url: String) {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
std::thread::spawn(move || crate::ui::macos::handle_url_scheme(_url));
|
std::thread::spawn(move || crate::handle_url_scheme(_url));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
|
@ -20,7 +20,7 @@ pub use self::rendezvous_mediator::*;
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
#[cfg(not(any(target_os = "ios")))]
|
#[cfg(not(any(target_os = "ios")))]
|
||||||
pub mod ipc;
|
pub mod ipc;
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli", feature = "flutter")))]
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
mod version;
|
mod version;
|
||||||
pub use version::*;
|
pub use version::*;
|
||||||
|
13
src/main.rs
13
src/main.rs
@ -2,6 +2,7 @@
|
|||||||
// Requires Rust 1.18.
|
// Requires Rust 1.18.
|
||||||
//#![windows_subsystem = "windows"]
|
//#![windows_subsystem = "windows"]
|
||||||
|
|
||||||
|
#[cfg(not(feature = "flutter"))]
|
||||||
use librustdesk::*;
|
use librustdesk::*;
|
||||||
|
|
||||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
@ -16,7 +17,12 @@ fn main() {
|
|||||||
common::global_clean();
|
common::global_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))]
|
#[cfg(not(any(
|
||||||
|
target_os = "android",
|
||||||
|
target_os = "ios",
|
||||||
|
feature = "cli",
|
||||||
|
feature = "flutter"
|
||||||
|
)))]
|
||||||
fn main() {
|
fn main() {
|
||||||
if !common::global_init() {
|
if !common::global_init() {
|
||||||
return;
|
return;
|
||||||
@ -27,6 +33,11 @@ fn main() {
|
|||||||
common::global_clean();
|
common::global_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "flutter")]
|
||||||
|
fn main() {
|
||||||
|
hbb_common::log::info!("Hello world!");
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "cli")]
|
#[cfg(feature = "cli")]
|
||||||
fn main() {
|
fn main() {
|
||||||
if !common::global_init() {
|
if !common::global_init() {
|
||||||
|
109
src/ui.rs
109
src/ui.rs
@ -9,7 +9,7 @@ use sciter::Value;
|
|||||||
|
|
||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
allow_err,
|
allow_err,
|
||||||
config::{self, PeerConfig},
|
config::{self, LocalConfig, PeerConfig},
|
||||||
log,
|
log,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,6 +38,7 @@ lazy_static::lazy_static! {
|
|||||||
#[cfg(not(any(feature = "flutter", feature = "cli")))]
|
#[cfg(not(any(feature = "flutter", feature = "cli")))]
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
pub static ref CUR_SESSION: Arc<Mutex<Option<Session<remote::SciterHandler>>>> = Default::default();
|
pub static ref CUR_SESSION: Arc<Mutex<Option<Session<remote::SciterHandler>>>> = Default::default();
|
||||||
|
static ref CHILDREN : Children = Default::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UIHostHandler;
|
struct UIHostHandler;
|
||||||
@ -190,11 +191,11 @@ impl UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_remote_id(&mut self) -> String {
|
fn get_remote_id(&mut self) -> String {
|
||||||
get_remote_id()
|
LocalConfig::get_remote_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_remote_id(&mut self, id: String) {
|
fn set_remote_id(&mut self, id: String) {
|
||||||
set_remote_id(id);
|
LocalConfig::set_remote_id(&id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn goto_install(&mut self) {
|
fn goto_install(&mut self) {
|
||||||
@ -309,7 +310,10 @@ impl UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_release(&self) -> bool {
|
fn is_release(&self) -> bool {
|
||||||
is_release()
|
#[cfg(not(debug_assertions))]
|
||||||
|
return true;
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_rdp_service_open(&self) -> bool {
|
fn is_rdp_service_open(&self) -> bool {
|
||||||
@ -329,11 +333,18 @@ impl UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn closing(&mut self, x: i32, y: i32, w: i32, h: i32) {
|
fn closing(&mut self, x: i32, y: i32, w: i32, h: i32) {
|
||||||
closing(x, y, w, h)
|
crate::server::input_service::fix_key_down_timeout_at_exit();
|
||||||
|
LocalConfig::set_size(x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_size(&mut self) -> Value {
|
fn get_size(&mut self) -> Value {
|
||||||
Value::from_iter(get_size())
|
let s = LocalConfig::get_size();
|
||||||
|
let mut v = Vec::new();
|
||||||
|
v.push(s.0);
|
||||||
|
v.push(s.1);
|
||||||
|
v.push(s.2);
|
||||||
|
v.push(s.3);
|
||||||
|
Value::from_iter(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_mouse_time(&self) -> f64 {
|
fn get_mouse_time(&self) -> f64 {
|
||||||
@ -388,7 +399,7 @@ impl UI {
|
|||||||
|
|
||||||
fn get_recent_sessions(&mut self) -> Value {
|
fn get_recent_sessions(&mut self) -> Value {
|
||||||
// to-do: limit number of recent sessions, and remove old peer file
|
// to-do: limit number of recent sessions, and remove old peer file
|
||||||
let peers: Vec<Value> = get_recent_sessions()
|
let peers: Vec<Value> = PeerConfig::peers()
|
||||||
.drain(..)
|
.drain(..)
|
||||||
.map(|p| Self::get_peer_value(p.0, p.2))
|
.map(|p| Self::get_peer_value(p.0, p.2))
|
||||||
.collect();
|
.collect();
|
||||||
@ -396,11 +407,11 @@ impl UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_icon(&mut self) -> String {
|
fn get_icon(&mut self) -> String {
|
||||||
get_icon()
|
crate::get_icon()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_peer(&mut self, id: String) {
|
fn remove_peer(&mut self, id: String) {
|
||||||
remove_peer(id)
|
PeerConfig::remove(&id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_discovered(&mut self, id: String) {
|
fn remove_discovered(&mut self, id: String) {
|
||||||
@ -442,7 +453,7 @@ impl UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_software_update_url(&self) -> String {
|
fn get_software_update_url(&self) -> String {
|
||||||
get_software_update_url()
|
crate::SOFTWARE_UPDATE_URL.lock().unwrap().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_new_version(&self) -> String {
|
fn get_new_version(&self) -> String {
|
||||||
@ -458,14 +469,30 @@ impl UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_software_ext(&self) -> String {
|
fn get_software_ext(&self) -> String {
|
||||||
get_software_ext()
|
#[cfg(windows)]
|
||||||
|
let p = "exe";
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
let p = "dmg";
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
let p = "deb";
|
||||||
|
p.to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_software_store_path(&self) -> String {
|
fn get_software_store_path(&self) -> String {
|
||||||
get_software_store_path()
|
let mut p = std::env::temp_dir();
|
||||||
|
let name = crate::SOFTWARE_UPDATE_URL
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.split("/")
|
||||||
|
.last()
|
||||||
|
.map(|x| x.to_owned())
|
||||||
|
.unwrap_or(crate::get_app_name());
|
||||||
|
p.push(name);
|
||||||
|
format!("{}.{}", p.to_string_lossy(), self.get_software_ext())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_shortcut(&self, _id: String) {
|
fn create_shortcut(&self, _id: String) {
|
||||||
|
#[cfg(windows)]
|
||||||
create_shortcut(_id)
|
create_shortcut(_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +522,17 @@ impl UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn open_url(&self, url: String) {
|
fn open_url(&self, url: String) {
|
||||||
open_url(url)
|
#[cfg(windows)]
|
||||||
|
let p = "explorer";
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
let p = "open";
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
let p = if std::path::Path::new("/usr/bin/firefox").exists() {
|
||||||
|
"firefox"
|
||||||
|
} else {
|
||||||
|
"xdg-open"
|
||||||
|
};
|
||||||
|
allow_err!(std::process::Command::new(p).arg(url).spawn());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn change_id(&self, id: String) {
|
fn change_id(&self, id: String) {
|
||||||
@ -508,7 +545,7 @@ impl UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_ok_change_id(&self) -> bool {
|
fn is_ok_change_id(&self) -> bool {
|
||||||
is_ok_change_id()
|
machine_uid::get().is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_async_job_status(&self) -> String {
|
fn get_async_job_status(&self) -> String {
|
||||||
@ -516,11 +553,11 @@ impl UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn t(&self, name: String) -> String {
|
fn t(&self, name: String) -> String {
|
||||||
t(name)
|
crate::client::translate(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_xfce(&self) -> bool {
|
fn is_xfce(&self) -> bool {
|
||||||
is_xfce()
|
crate::platform::is_xfce()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_api_server(&self) -> String {
|
fn get_api_server(&self) -> String {
|
||||||
@ -683,3 +720,43 @@ pub fn value_crash_workaround(values: &[Value]) -> Arc<Vec<Value>> {
|
|||||||
STUPID_VALUES.lock().unwrap().push(persist.clone());
|
STUPID_VALUES.lock().unwrap().push(persist.clone());
|
||||||
persist
|
persist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn new_remote(id: String, remote_type: String) {
|
||||||
|
let mut lock = CHILDREN.lock().unwrap();
|
||||||
|
let args = vec![format!("--{}", remote_type), id.clone()];
|
||||||
|
let key = (id.clone(), remote_type.clone());
|
||||||
|
if let Some(c) = lock.1.get_mut(&key) {
|
||||||
|
if let Ok(Some(_)) = c.try_wait() {
|
||||||
|
lock.1.remove(&key);
|
||||||
|
} else {
|
||||||
|
if remote_type == "rdp" {
|
||||||
|
allow_err!(c.kill());
|
||||||
|
std::thread::sleep(std::time::Duration::from_millis(30));
|
||||||
|
c.try_wait().ok();
|
||||||
|
lock.1.remove(&key);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match crate::run_me(args) {
|
||||||
|
Ok(child) => {
|
||||||
|
lock.1.insert(key, child);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
log::error!("Failed to spawn remote: {}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn recent_sessions_updated() -> bool {
|
||||||
|
let mut children = CHILDREN.lock().unwrap();
|
||||||
|
if children.0 {
|
||||||
|
children.0 = false;
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -180,22 +180,11 @@ extern "C" fn handle_menu_item(this: &mut Object, _: Sel, item: id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The function to handle the url scheme sent by the system.
|
|
||||||
///
|
|
||||||
/// 1. Try to send the url scheme from ipc.
|
|
||||||
/// 2. If failed to send the url scheme, we open a new main window to handle this url scheme.
|
|
||||||
pub fn handle_url_scheme(url: String) {
|
|
||||||
if let Err(err) = crate::ipc::send_url_scheme(url.clone()) {
|
|
||||||
log::debug!("Send the url to the existing flutter process failed, {}. Let's open a new program to handle this.", err);
|
|
||||||
let _ = crate::run_me(vec![url]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn handle_apple_event(_this: &Object, _cmd: Sel, event: u64, _reply: u64) {
|
extern "C" fn handle_apple_event(_this: &Object, _cmd: Sel, event: u64, _reply: u64) {
|
||||||
let event = event as *mut Object;
|
let event = event as *mut Object;
|
||||||
let url = fruitbasket::parse_url_event(event);
|
let url = fruitbasket::parse_url_event(event);
|
||||||
log::debug!("an event was received: {}", url);
|
log::debug!("an event was received: {}", url);
|
||||||
std::thread::spawn(move || handle_url_scheme(url));
|
std::thread::spawn(move || crate::handle_url_scheme(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn make_menu_item(title: &str, key: &str, tag: u32) -> *mut Object {
|
unsafe fn make_menu_item(title: &str, key: &str, tag: u32) -> *mut Object {
|
||||||
|
@ -2,7 +2,6 @@ use std::{
|
|||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
process::Child,
|
process::Child,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
time::SystemTime,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
@ -31,7 +30,6 @@ pub type Children = Arc<Mutex<(bool, HashMap<(String, String), Child>)>>;
|
|||||||
type Status = (i32, bool, i64, String); // (status_num, key_confirmed, mouse_time, id)
|
type Status = (i32, bool, i64, String); // (status_num, key_confirmed, mouse_time, id)
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref CHILDREN : Children = Default::default();
|
|
||||||
static ref UI_STATUS : Arc<Mutex<Status>> = Arc::new(Mutex::new((0, false, 0, "".to_owned())));
|
static ref UI_STATUS : Arc<Mutex<Status>> = Arc::new(Mutex::new((0, false, 0, "".to_owned())));
|
||||||
static ref OPTIONS : Arc<Mutex<HashMap<String, String>>> = Arc::new(Mutex::new(Config::get_options()));
|
static ref OPTIONS : Arc<Mutex<HashMap<String, String>>> = Arc::new(Mutex::new(Config::get_options()));
|
||||||
static ref ASYNC_JOB_STATUS : Arc<Mutex<String>> = Default::default();
|
static ref ASYNC_JOB_STATUS : Arc<Mutex<String>> = Default::default();
|
||||||
@ -44,17 +42,6 @@ lazy_static::lazy_static! {
|
|||||||
pub static ref SENDER : Mutex<mpsc::UnboundedSender<ipc::Data>> = Mutex::new(check_connect_status(true));
|
pub static ref SENDER : Mutex<mpsc::UnboundedSender<ipc::Data>> = Mutex::new(check_connect_status(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn recent_sessions_updated() -> bool {
|
|
||||||
let mut children = CHILDREN.lock().unwrap();
|
|
||||||
if children.0 {
|
|
||||||
children.0 = false;
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
|
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_id() -> String {
|
pub fn get_id() -> String {
|
||||||
@ -64,16 +51,6 @@ pub fn get_id() -> String {
|
|||||||
return ipc::get_id();
|
return ipc::get_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_remote_id() -> String {
|
|
||||||
LocalConfig::get_remote_id()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn set_remote_id(id: String) {
|
|
||||||
LocalConfig::set_remote_id(&id);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn goto_install() {
|
pub fn goto_install() {
|
||||||
allow_err!(crate::run_me(vec!["--install"]));
|
allow_err!(crate::run_me(vec!["--install"]));
|
||||||
@ -419,24 +396,6 @@ pub fn is_installed_lower_version() -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn closing(x: i32, y: i32, w: i32, h: i32) {
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
|
||||||
crate::server::input_service::fix_key_down_timeout_at_exit();
|
|
||||||
LocalConfig::set_size(x, y, w, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_size() -> Vec<i32> {
|
|
||||||
let s = LocalConfig::get_size();
|
|
||||||
let mut v = Vec::new();
|
|
||||||
v.push(s.0);
|
|
||||||
v.push(s.1);
|
|
||||||
v.push(s.2);
|
|
||||||
v.push(s.3);
|
|
||||||
v
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_mouse_time() -> f64 {
|
pub fn get_mouse_time() -> f64 {
|
||||||
let ui_status = UI_STATUS.lock().unwrap();
|
let ui_status = UI_STATUS.lock().unwrap();
|
||||||
@ -507,51 +466,6 @@ pub fn store_fav(fav: Vec<String>) {
|
|||||||
LocalConfig::set_fav(fav);
|
LocalConfig::set_fav(fav);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_recent_sessions() -> Vec<(String, SystemTime, PeerConfig)> {
|
|
||||||
PeerConfig::peers()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))]
|
|
||||||
pub fn get_icon() -> String {
|
|
||||||
crate::get_icon()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn remove_peer(id: String) {
|
|
||||||
PeerConfig::remove(&id);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn new_remote(id: String, remote_type: String) {
|
|
||||||
let mut lock = CHILDREN.lock().unwrap();
|
|
||||||
let args = vec![format!("--{}", remote_type), id.clone()];
|
|
||||||
let key = (id.clone(), remote_type.clone());
|
|
||||||
if let Some(c) = lock.1.get_mut(&key) {
|
|
||||||
if let Ok(Some(_)) = c.try_wait() {
|
|
||||||
lock.1.remove(&key);
|
|
||||||
} else {
|
|
||||||
if remote_type == "rdp" {
|
|
||||||
allow_err!(c.kill());
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(30));
|
|
||||||
c.try_wait().ok();
|
|
||||||
lock.1.remove(&key);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
match crate::run_me(args) {
|
|
||||||
Ok(child) => {
|
|
||||||
lock.1.insert(key, child);
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
log::error!("Failed to spawn remote: {}", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_process_trusted(_prompt: bool) -> bool {
|
pub fn is_process_trusted(_prompt: bool) -> bool {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
@ -622,11 +536,6 @@ pub fn current_is_wayland() -> bool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_software_update_url() -> String {
|
|
||||||
SOFTWARE_UPDATE_URL.lock().unwrap().clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_new_version() -> String {
|
pub fn get_new_version() -> String {
|
||||||
hbb_common::get_version_from_url(&*SOFTWARE_UPDATE_URL.lock().unwrap())
|
hbb_common::get_version_from_url(&*SOFTWARE_UPDATE_URL.lock().unwrap())
|
||||||
@ -643,36 +552,9 @@ pub fn get_app_name() -> String {
|
|||||||
crate::get_app_name()
|
crate::get_app_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[cfg(windows)]
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
|
||||||
pub fn get_software_ext() -> String {
|
|
||||||
#[cfg(windows)]
|
|
||||||
let p = "exe";
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
let p = "dmg";
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
let p = "deb";
|
|
||||||
p.to_owned()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
|
||||||
pub fn get_software_store_path() -> String {
|
|
||||||
let mut p = std::env::temp_dir();
|
|
||||||
let name = SOFTWARE_UPDATE_URL
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.split("/")
|
|
||||||
.last()
|
|
||||||
.map(|x| x.to_owned())
|
|
||||||
.unwrap_or(crate::get_app_name());
|
|
||||||
p.push(name);
|
|
||||||
format!("{}.{}", p.to_string_lossy(), get_software_ext())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn create_shortcut(_id: String) {
|
pub fn create_shortcut(_id: String) {
|
||||||
#[cfg(windows)]
|
|
||||||
crate::platform::windows::create_shortcut(&_id).ok();
|
crate::platform::windows::create_shortcut(&_id).ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,22 +601,6 @@ pub fn get_uuid() -> String {
|
|||||||
base64::encode(hbb_common::get_uuid())
|
base64::encode(hbb_common::get_uuid())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))]
|
|
||||||
pub fn open_url(url: String) {
|
|
||||||
#[cfg(windows)]
|
|
||||||
let p = "explorer";
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
let p = "open";
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
let p = if std::path::Path::new("/usr/bin/firefox").exists() {
|
|
||||||
"firefox"
|
|
||||||
} else {
|
|
||||||
"xdg-open"
|
|
||||||
};
|
|
||||||
allow_err!(std::process::Command::new(p).arg(url).spawn());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
|
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn change_id(id: String) {
|
pub fn change_id(id: String) {
|
||||||
@ -756,23 +622,11 @@ pub fn post_request(url: String, body: String, header: String) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
|
||||||
pub fn is_ok_change_id() -> bool {
|
|
||||||
machine_uid::get().is_ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_async_job_status() -> String {
|
pub fn get_async_job_status() -> String {
|
||||||
ASYNC_JOB_STATUS.lock().unwrap().clone()
|
ASYNC_JOB_STATUS.lock().unwrap().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))]
|
|
||||||
pub fn t(name: String) -> String {
|
|
||||||
crate::client::translate(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_langs() -> String {
|
pub fn get_langs() -> String {
|
||||||
crate::lang::LANGS.to_string()
|
crate::lang::LANGS.to_string()
|
||||||
@ -813,11 +667,6 @@ pub fn default_video_save_directory() -> String {
|
|||||||
"".to_owned()
|
"".to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn is_xfce() -> bool {
|
|
||||||
crate::platform::is_xfce()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_api_server() -> String {
|
pub fn get_api_server() -> String {
|
||||||
crate::get_api_server(
|
crate::get_api_server(
|
||||||
@ -834,14 +683,6 @@ pub fn has_hwcodec() -> bool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn is_release() -> bool {
|
|
||||||
#[cfg(not(debug_assertions))]
|
|
||||||
return true;
|
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_root() -> bool {
|
pub fn is_root() -> bool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user