rustdesk/src/ui.rs

740 lines
34 KiB
Rust
Raw Normal View History

use std::{
collections::HashMap,
iter::FromIterator,
2022-08-01 14:33:08 +08:00
process::Child,
sync::{Arc, Mutex},
};
use sciter::Value;
2021-03-29 15:59:14 +08:00
use hbb_common::{
allow_err,
config::{LocalConfig, PeerConfig},
2022-05-12 17:35:25 +08:00
log,
2021-03-29 15:59:14 +08:00
};
2022-08-01 14:33:08 +08:00
#[cfg(not(any(feature = "flutter", feature = "cli")))]
use crate::ui_session_interface::Session;
use crate::{common::get_app_name, ipc, ui_interface::*};
2022-08-01 14:33:08 +08:00
mod cm;
#[cfg(feature = "inline")]
2022-09-08 18:21:17 +08:00
pub mod inline;
2022-08-01 14:33:08 +08:00
pub mod remote;
2022-05-12 17:35:25 +08:00
pub type Children = Arc<Mutex<(bool, HashMap<(String, String), Child>)>>;
#[allow(dead_code)]
2022-05-12 17:35:25 +08:00
type Status = (i32, bool, i64, String);
2021-03-29 15:59:14 +08:00
lazy_static::lazy_static! {
// stupid workaround for https://sciter.com/forums/topic/crash-on-latest-tis-mac-sdk-sometimes/
static ref STUPID_VALUES: Mutex<Vec<Arc<Vec<Value>>>> = Default::default();
2022-05-25 23:09:14 +08:00
}
#[cfg(not(any(feature = "flutter", feature = "cli")))]
lazy_static::lazy_static! {
pub static ref CUR_SESSION: Arc<Mutex<Option<Session<remote::SciterHandler>>>> = Default::default();
2023-02-10 17:09:31 +08:00
static ref CHILDREN : Children = Default::default();
}
struct UIHostHandler;
2021-03-29 15:59:14 +08:00
pub fn start(args: &mut [String]) {
2022-04-28 21:54:27 +08:00
#[cfg(target_os = "macos")]
2023-03-02 13:32:21 +08:00
crate::platform::delegate::show_dock();
2022-04-18 15:45:12 +08:00
#[cfg(all(target_os = "linux", feature = "inline"))]
2022-05-29 10:14:22 +08:00
{
#[cfg(feature = "appimage")]
2022-05-29 10:14:22 +08:00
let prefix = std::env::var("APPDIR").unwrap_or("".to_string());
#[cfg(not(feature = "appimage"))]
let prefix = "".to_string();
#[cfg(feature = "flatpak")]
let dir = "/app";
#[cfg(not(feature = "flatpak"))]
let dir = "/usr";
sciter::set_library(&(prefix + dir + "/lib/rustdesk/libsciter-gtk.so")).ok();
2022-05-29 10:14:22 +08:00
}
2023-03-27 11:21:23 +08:00
#[cfg(windows)]
// Check if there is a sciter.dll nearby.
if let Ok(exe) = std::env::current_exe() {
if let Some(parent) = exe.parent() {
let sciter_dll_path = parent.join("sciter.dll");
if sciter_dll_path.exists() {
// Try to set the sciter dll.
let p = sciter_dll_path.to_string_lossy().to_string();
2023-03-29 09:38:24 +08:00
log::debug!("Found dll:{}, \n {:?}", p, sciter::set_library(&p));
2023-03-27 11:21:23 +08:00
}
}
}
// https://github.com/c-smile/sciter-sdk/blob/master/include/sciter-x-types.h
// https://github.com/rustdesk/rustdesk/issues/132#issuecomment-886069737
#[cfg(windows)]
allow_err!(sciter::set_options(sciter::RuntimeOptions::GfxLayer(
sciter::GFX_LAYER::WARP
)));
2021-03-29 15:59:14 +08:00
use sciter::SCRIPT_RUNTIME_FEATURES::*;
allow_err!(sciter::set_options(sciter::RuntimeOptions::ScriptFeatures(
ALLOW_FILE_IO as u8 | ALLOW_SOCKET_IO as u8 | ALLOW_EVAL as u8 | ALLOW_SYSINFO as u8
)));
let mut frame = sciter::WindowBuilder::main_window().create();
#[cfg(windows)]
allow_err!(sciter::set_options(sciter::RuntimeOptions::UxTheming(true)));
2022-04-29 16:21:18 +08:00
frame.set_title(&crate::get_app_name());
2021-03-29 15:59:14 +08:00
#[cfg(target_os = "macos")]
2023-03-02 13:32:21 +08:00
crate::platform::delegate::make_menubar(frame.get_host(), args.is_empty());
2021-03-29 15:59:14 +08:00
let page;
if args.len() > 1 && args[0] == "--play" {
args[0] = "--connect".to_owned();
let path: std::path::PathBuf = (&args[1]).into();
let id = path
.file_stem()
.map(|p| p.to_str().unwrap_or(""))
.unwrap_or("")
.to_owned();
args[1] = id;
}
2022-04-29 16:21:18 +08:00
if args.is_empty() {
std::thread::spawn(move || check_zombie());
2021-03-29 15:59:14 +08:00
crate::common::check_software_update();
2022-05-25 23:09:14 +08:00
frame.event_handler(UI {});
frame.sciter_handler(UIHostHandler {});
2021-03-29 15:59:14 +08:00
page = "index.html";
2023-01-30 11:15:47 +08:00
// Start pulse audio local server.
#[cfg(target_os = "linux")]
std::thread::spawn(crate::ipc::start_pa);
2021-03-29 15:59:14 +08:00
} else if args[0] == "--install" {
2022-05-25 23:09:14 +08:00
frame.event_handler(UI {});
frame.sciter_handler(UIHostHandler {});
2021-03-29 15:59:14 +08:00
page = "install.html";
} else if args[0] == "--cm" {
frame.register_behavior("connection-manager", move || {
Box::new(cm::SciterConnectionManager::new())
2021-03-29 15:59:14 +08:00
});
page = "cm.html";
} else if (args[0] == "--connect"
|| args[0] == "--file-transfer"
|| args[0] == "--port-forward"
|| args[0] == "--rdp")
&& args.len() > 1
{
2022-05-12 17:35:25 +08:00
#[cfg(windows)]
{
let hw = frame.get_host().get_hwnd();
crate::platform::windows::enable_lowlevel_keyboard(hw as _);
}
2021-03-29 15:59:14 +08:00
let mut iter = args.iter();
let Some(cmd) = iter.next() else {
log::error!("Failed to get cmd arg");
return;
};
let cmd = cmd.to_owned();
let Some(id) = iter.next() else {
log::error!("Failed to get id arg");
return;
};
let id = id.to_owned();
2022-07-27 00:31:20 +08:00
let pass = iter.next().unwrap_or(&"".to_owned()).clone();
2021-03-29 15:59:14 +08:00
let args: Vec<String> = iter.map(|x| x.clone()).collect();
frame.set_title(&id);
frame.register_behavior("native-remote", move || {
2022-12-28 13:52:13 +08:00
let handler =
remote::SciterSession::new(cmd.clone(), id.clone(), pass.clone(), args.clone());
#[cfg(not(any(feature = "flutter", feature = "cli")))]
{
*CUR_SESSION.lock().unwrap() = Some(handler.inner());
}
Box::new(handler)
2021-03-29 15:59:14 +08:00
});
page = "remote.html";
} else {
log::error!("Wrong command: {:?}", args);
return;
}
#[cfg(feature = "inline")]
{
let html = if page == "index.html" {
inline::get_index()
} else if page == "cm.html" {
inline::get_cm()
} else if page == "install.html" {
inline::get_install()
} else {
inline::get_remote()
};
frame.load_html(html.as_bytes(), Some(page));
}
#[cfg(not(feature = "inline"))]
frame.load_file(&format!(
"file://{}/src/ui/{}",
std::env::current_dir()
.map(|c| c.display().to_string())
.unwrap_or("".to_owned()),
page
));
2022-04-29 16:21:18 +08:00
frame.run_app();
2021-03-29 15:59:14 +08:00
}
2022-05-25 23:09:14 +08:00
struct UI {}
2021-03-29 15:59:14 +08:00
2022-05-25 23:09:14 +08:00
impl UI {
fn recent_sessions_updated(&self) -> bool {
recent_sessions_updated()
2021-03-29 15:59:14 +08:00
}
2022-05-12 17:35:25 +08:00
fn get_id(&self) -> String {
2022-08-01 14:33:08 +08:00
ipc::get_id()
2021-03-29 15:59:14 +08:00
}
fn temporary_password(&mut self) -> String {
2022-08-01 14:33:08 +08:00
temporary_password()
}
fn update_temporary_password(&self) {
2022-08-01 14:33:08 +08:00
update_temporary_password()
2021-03-29 15:59:14 +08:00
}
fn permanent_password(&self) -> String {
2022-08-01 14:33:08 +08:00
permanent_password()
}
fn set_permanent_password(&self, password: String) {
set_permanent_password(password);
2021-03-29 15:59:14 +08:00
}
fn get_remote_id(&mut self) -> String {
2023-02-10 17:09:31 +08:00
LocalConfig::get_remote_id()
2021-03-29 15:59:14 +08:00
}
fn set_remote_id(&mut self, id: String) {
2023-02-10 17:09:31 +08:00
LocalConfig::set_remote_id(&id);
2021-03-29 15:59:14 +08:00
}
fn goto_install(&mut self) {
2022-05-25 23:09:14 +08:00
goto_install();
2021-03-29 15:59:14 +08:00
}
2022-05-12 17:35:25 +08:00
fn install_me(&mut self, _options: String, _path: String) {
install_me(_options, _path, false, false);
2021-03-29 15:59:14 +08:00
}
fn update_me(&self, _path: String) {
2022-05-25 23:09:14 +08:00
update_me(_path);
2021-03-29 15:59:14 +08:00
}
2022-05-12 17:35:25 +08:00
fn run_without_install(&self) {
2022-05-25 23:09:14 +08:00
run_without_install();
2022-05-12 17:35:25 +08:00
}
fn show_run_without_install(&self) -> bool {
2022-05-25 23:09:14 +08:00
show_run_without_install()
2022-05-12 17:35:25 +08:00
}
fn get_license(&self) -> String {
2022-05-25 23:09:14 +08:00
get_license()
2022-05-12 17:35:25 +08:00
}
2021-03-29 15:59:14 +08:00
fn get_option(&self, key: String) -> String {
2022-05-25 23:22:14 +08:00
get_option(key)
2021-03-29 15:59:14 +08:00
}
fn get_local_option(&self, key: String) -> String {
2022-05-25 23:09:14 +08:00
get_local_option(key)
2022-04-26 11:19:45 +08:00
}
fn set_local_option(&self, key: String, value: String) {
2022-05-25 23:09:14 +08:00
set_local_option(key, value);
}
fn peer_has_password(&self, id: String) -> bool {
2022-05-25 23:09:14 +08:00
peer_has_password(id)
}
fn forget_password(&self, id: String) {
2022-05-25 23:09:14 +08:00
forget_password(id)
}
fn get_peer_option(&self, id: String, name: String) -> String {
2022-05-25 23:09:14 +08:00
get_peer_option(id, name)
}
fn set_peer_option(&self, id: String, name: String, value: String) {
2022-05-25 23:09:14 +08:00
set_peer_option(id, name, value)
}
2022-05-12 17:35:25 +08:00
fn using_public_server(&self) -> bool {
2022-05-25 23:09:14 +08:00
using_public_server()
2022-05-12 17:35:25 +08:00
}
2021-03-29 15:59:14 +08:00
fn get_options(&self) -> Value {
let hashmap: HashMap<String, String> =
serde_json::from_str(&get_options()).unwrap_or_default();
2021-03-29 15:59:14 +08:00
let mut m = Value::map();
2022-05-25 23:09:14 +08:00
for (k, v) in hashmap {
2021-03-29 15:59:14 +08:00
m.set_item(k, v);
}
m
}
fn test_if_valid_server(&self, host: String) -> String {
2022-05-25 23:09:14 +08:00
test_if_valid_server(host)
2021-03-29 15:59:14 +08:00
}
fn get_sound_inputs(&self) -> Value {
2022-05-25 23:09:14 +08:00
Value::from_iter(get_sound_inputs())
2021-03-29 15:59:14 +08:00
}
fn set_options(&self, v: Value) {
let mut m = HashMap::new();
for (k, v) in v.items() {
if let Some(k) = k.as_string() {
if let Some(v) = v.as_string() {
if !v.is_empty() {
m.insert(k, v);
}
}
}
}
2022-05-25 23:09:14 +08:00
set_options(m);
2021-03-29 15:59:14 +08:00
}
2021-10-08 00:16:10 +08:00
fn set_option(&self, key: String, value: String) {
2022-05-25 23:09:14 +08:00
set_option(key, value);
2021-10-08 00:16:10 +08:00
}
2021-03-29 15:59:14 +08:00
fn install_path(&mut self) -> String {
2022-05-25 23:09:14 +08:00
install_path()
2021-03-29 15:59:14 +08:00
}
2022-01-05 18:34:30 +08:00
fn get_socks(&self) -> Value {
2022-05-25 23:09:14 +08:00
Value::from_iter(get_socks())
2022-01-05 18:34:30 +08:00
}
fn set_socks(&self, proxy: String, username: String, password: String) {
2022-05-25 23:09:14 +08:00
set_socks(proxy, username, password)
2022-01-05 18:34:30 +08:00
}
2022-05-12 17:35:25 +08:00
fn is_installed(&self) -> bool {
2022-05-25 23:09:14 +08:00
is_installed()
2021-03-29 15:59:14 +08:00
}
fn is_root(&self) -> bool {
is_root()
}
fn is_release(&self) -> bool {
2023-02-10 17:09:31 +08:00
#[cfg(not(debug_assertions))]
return true;
#[cfg(debug_assertions)]
return false;
}
2022-05-12 17:35:25 +08:00
fn is_rdp_service_open(&self) -> bool {
2022-05-25 23:09:14 +08:00
is_rdp_service_open()
2022-05-12 17:35:25 +08:00
}
fn is_share_rdp(&self) -> bool {
2022-05-25 23:09:14 +08:00
is_share_rdp()
2022-05-12 17:35:25 +08:00
}
fn set_share_rdp(&self, _enable: bool) {
2022-05-25 23:09:14 +08:00
set_share_rdp(_enable);
2022-05-12 17:35:25 +08:00
}
2021-03-29 15:59:14 +08:00
fn is_installed_lower_version(&self) -> bool {
2022-05-25 23:09:14 +08:00
is_installed_lower_version()
2021-03-29 15:59:14 +08:00
}
fn closing(&mut self, x: i32, y: i32, w: i32, h: i32) {
2023-02-10 17:09:31 +08:00
crate::server::input_service::fix_key_down_timeout_at_exit();
LocalConfig::set_size(x, y, w, h);
2021-03-29 15:59:14 +08:00
}
fn get_size(&mut self) -> Value {
2023-02-10 17:09:31 +08:00
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)
2021-03-29 15:59:14 +08:00
}
2022-05-12 17:35:25 +08:00
fn get_mouse_time(&self) -> f64 {
2022-05-25 23:09:14 +08:00
get_mouse_time()
2022-05-12 17:35:25 +08:00
}
fn check_mouse_time(&self) {
2022-05-25 23:09:14 +08:00
check_mouse_time()
2022-05-12 17:35:25 +08:00
}
2021-03-29 15:59:14 +08:00
fn get_connect_status(&mut self) -> Value {
let mut v = Value::array(0);
2022-05-25 23:09:14 +08:00
let x = get_connect_status();
v.push(x.status_num);
v.push(x.key_confirmed);
v.push(x.id);
2021-03-29 15:59:14 +08:00
v
}
2022-01-02 21:56:04 +08:00
#[inline]
fn get_peer_value(id: String, p: PeerConfig) -> Value {
let values = vec![
id,
p.info.username.clone(),
p.info.hostname.clone(),
p.info.platform.clone(),
p.options.get("alias").unwrap_or(&"".to_owned()).to_owned(),
];
Value::from_iter(values)
}
fn get_peer(&self, id: String) -> Value {
2022-05-25 23:09:14 +08:00
let c = get_peer(id.clone());
2022-01-02 21:56:04 +08:00
Self::get_peer_value(id, c)
}
fn get_fav(&self) -> Value {
2022-05-25 23:09:14 +08:00
Value::from_iter(get_fav())
2022-01-02 21:56:04 +08:00
}
fn store_fav(&self, fav: Value) {
let mut tmp = vec![];
fav.values().for_each(|v| {
if let Some(v) = v.as_string() {
if !v.is_empty() {
tmp.push(v);
}
}
});
2022-05-25 23:09:14 +08:00
store_fav(tmp);
2022-01-02 21:56:04 +08:00
}
2021-03-29 15:59:14 +08:00
fn get_recent_sessions(&mut self) -> Value {
2022-04-26 11:19:45 +08:00
// to-do: limit number of recent sessions, and remove old peer file
let peers: Vec<Value> = PeerConfig::peers(None)
2022-01-02 21:56:04 +08:00
.drain(..)
.map(|p| Self::get_peer_value(p.0, p.2))
2021-03-29 15:59:14 +08:00
.collect();
Value::from_iter(peers)
}
fn get_icon(&mut self) -> String {
2023-02-11 00:21:19 +08:00
get_icon()
2021-03-29 15:59:14 +08:00
}
fn remove_peer(&mut self, id: String) {
2023-02-10 17:09:31 +08:00
PeerConfig::remove(&id);
2021-03-29 15:59:14 +08:00
}
fn remove_discovered(&mut self, id: String) {
remove_discovered(id);
}
fn send_wol(&mut self, id: String) {
crate::lan::send_wol(id)
}
fn new_remote(&mut self, id: String, remote_type: String, force_relay: bool) {
new_remote(id, remote_type, force_relay)
2021-03-29 15:59:14 +08:00
}
fn is_process_trusted(&mut self, _prompt: bool) -> bool {
2022-05-25 23:09:14 +08:00
is_process_trusted(_prompt)
2021-03-29 15:59:14 +08:00
}
fn is_can_screen_recording(&mut self, _prompt: bool) -> bool {
2022-05-25 23:09:14 +08:00
is_can_screen_recording(_prompt)
2021-03-29 15:59:14 +08:00
}
2022-01-13 19:23:41 +08:00
fn is_installed_daemon(&mut self, _prompt: bool) -> bool {
2022-05-25 23:09:14 +08:00
is_installed_daemon(_prompt)
2022-01-13 19:23:41 +08:00
}
2021-03-29 15:59:14 +08:00
fn get_error(&mut self) -> String {
2022-05-25 23:09:14 +08:00
get_error()
2021-03-29 15:59:14 +08:00
}
fn is_login_wayland(&mut self) -> bool {
2022-05-25 23:09:14 +08:00
is_login_wayland()
2021-03-29 15:59:14 +08:00
}
fn current_is_wayland(&mut self) -> bool {
2022-05-25 23:09:14 +08:00
current_is_wayland()
}
2021-03-29 15:59:14 +08:00
fn get_software_update_url(&self) -> String {
2023-02-10 17:09:31 +08:00
crate::SOFTWARE_UPDATE_URL.lock().unwrap().clone()
2021-03-29 15:59:14 +08:00
}
fn get_new_version(&self) -> String {
2022-05-25 23:09:14 +08:00
get_new_version()
2021-03-29 15:59:14 +08:00
}
fn get_version(&self) -> String {
2022-05-25 23:09:14 +08:00
get_version()
2021-03-29 15:59:14 +08:00
}
fn get_fingerprint(&self) -> String {
get_fingerprint()
}
2021-03-29 15:59:14 +08:00
fn get_app_name(&self) -> String {
2022-05-25 23:09:14 +08:00
get_app_name()
2021-03-29 15:59:14 +08:00
}
fn get_software_ext(&self) -> String {
2023-02-10 17:09:31 +08:00
#[cfg(windows)]
let p = "exe";
#[cfg(target_os = "macos")]
let p = "dmg";
#[cfg(target_os = "linux")]
let p = "deb";
p.to_owned()
2021-03-29 15:59:14 +08:00
}
fn get_software_store_path(&self) -> String {
2023-02-10 17:09:31 +08:00
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())
2021-03-29 15:59:14 +08:00
}
2021-07-27 23:53:12 +08:00
fn create_shortcut(&self, _id: String) {
2023-02-10 17:09:31 +08:00
#[cfg(windows)]
2022-05-25 23:09:14 +08:00
create_shortcut(_id)
}
fn discover(&self) {
std::thread::spawn(move || {
allow_err!(crate::lan::discover());
});
}
fn get_lan_peers(&self) -> String {
// let peers = get_lan_peers()
// .into_iter()
// .map(|mut peer| {
// (
// peer.remove("id").unwrap_or_default(),
// peer.remove("username").unwrap_or_default(),
// peer.remove("hostname").unwrap_or_default(),
// peer.remove("platform").unwrap_or_default(),
// )
// })
// .collect::<Vec<(String, String, String, String)>>();
2022-09-21 21:20:19 +08:00
serde_json::to_string(&get_lan_peers()).unwrap_or_default()
}
2022-05-12 17:35:25 +08:00
fn get_uuid(&self) -> String {
2022-05-25 23:09:14 +08:00
get_uuid()
2022-05-12 17:35:25 +08:00
}
2021-03-29 15:59:14 +08:00
fn open_url(&self, url: String) {
2023-02-10 17:09:31 +08:00
#[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());
2021-03-29 15:59:14 +08:00
}
2021-05-02 21:19:48 +08:00
2022-05-12 17:35:25 +08:00
fn change_id(&self, id: String) {
reset_async_job_status();
2022-08-01 14:33:08 +08:00
let old_id = self.get_id();
2022-12-28 13:52:13 +08:00
change_id_shared(id, old_id);
2022-05-12 17:35:25 +08:00
}
fn post_request(&self, url: String, body: String, header: String) {
2022-05-25 23:09:14 +08:00
post_request(url, body, header)
2022-05-12 17:35:25 +08:00
}
fn is_ok_change_id(&self) -> bool {
hbb_common::machine_uid::get().is_ok()
2022-05-12 17:35:25 +08:00
}
fn get_async_job_status(&self) -> String {
2022-05-25 23:09:14 +08:00
get_async_job_status()
2022-05-12 17:35:25 +08:00
}
2021-12-25 16:45:22 +08:00
fn t(&self, name: String) -> String {
2023-02-10 17:09:31 +08:00
crate::client::translate(name)
2021-12-25 16:45:22 +08:00
}
2021-05-02 21:19:48 +08:00
fn is_xfce(&self) -> bool {
2023-02-10 17:09:31 +08:00
crate::platform::is_xfce()
2021-05-02 21:19:48 +08:00
}
2022-05-12 17:35:25 +08:00
fn get_api_server(&self) -> String {
2022-05-25 23:09:14 +08:00
get_api_server()
2022-05-12 17:35:25 +08:00
}
2022-06-30 16:19:36 +08:00
fn has_hwcodec(&self) -> bool {
has_hwcodec()
2022-06-30 16:19:36 +08:00
}
2022-07-06 18:57:14 +08:00
fn get_langs(&self) -> String {
get_langs()
}
fn default_video_save_directory(&self) -> String {
default_video_save_directory()
}
fn handle_relay_id(&self, id: String) -> String {
handle_relay_id(id)
}
fn get_login_device_info(&self) -> String {
get_login_device_info_json()
}
2021-03-29 15:59:14 +08:00
}
impl sciter::EventHandler for UI {
sciter::dispatch_script_call! {
2021-12-25 16:45:22 +08:00
fn t(String);
2022-05-12 17:35:25 +08:00
fn get_api_server();
2021-05-02 21:19:48 +08:00
fn is_xfce();
2022-05-12 17:35:25 +08:00
fn using_public_server();
2021-03-29 15:59:14 +08:00
fn get_id();
fn temporary_password();
fn update_temporary_password();
fn permanent_password();
fn set_permanent_password(String);
2021-03-29 15:59:14 +08:00
fn get_remote_id();
fn set_remote_id(String);
fn closing(i32, i32, i32, i32);
2021-03-29 15:59:14 +08:00
fn get_size();
fn new_remote(String, String, bool);
fn send_wol(String);
2021-03-29 15:59:14 +08:00
fn remove_peer(String);
fn remove_discovered(String);
2021-03-29 15:59:14 +08:00
fn get_connect_status();
2022-05-12 17:35:25 +08:00
fn get_mouse_time();
fn check_mouse_time();
2021-03-29 15:59:14 +08:00
fn get_recent_sessions();
2022-01-02 21:56:04 +08:00
fn get_peer(String);
fn get_fav();
fn store_fav(Value);
2021-03-29 15:59:14 +08:00
fn recent_sessions_updated();
fn get_icon();
2022-05-12 17:35:25 +08:00
fn install_me(String, String);
2021-03-29 15:59:14 +08:00
fn is_installed();
fn is_root();
fn is_release();
2022-01-05 18:34:30 +08:00
fn set_socks(String, String, String);
fn get_socks();
2022-05-12 17:35:25 +08:00
fn is_rdp_service_open();
fn is_share_rdp();
fn set_share_rdp(bool);
2021-03-29 15:59:14 +08:00
fn is_installed_lower_version();
fn install_path();
fn goto_install();
fn is_process_trusted(bool);
fn is_can_screen_recording(bool);
2022-01-13 19:23:41 +08:00
fn is_installed_daemon(bool);
2021-03-29 15:59:14 +08:00
fn get_error();
fn is_login_wayland();
fn current_is_wayland();
2021-03-29 15:59:14 +08:00
fn get_options();
fn get_option(String);
fn get_local_option(String);
2022-04-26 11:19:45 +08:00
fn set_local_option(String, String);
fn get_peer_option(String, String);
fn peer_has_password(String);
fn forget_password(String);
fn set_peer_option(String, String, String);
2022-05-12 17:35:25 +08:00
fn get_license();
2021-03-29 15:59:14 +08:00
fn test_if_valid_server(String);
fn get_sound_inputs();
fn set_options(Value);
2021-10-08 00:16:10 +08:00
fn set_option(String, String);
2021-03-29 15:59:14 +08:00
fn get_software_update_url();
fn get_new_version();
fn get_version();
fn get_fingerprint();
2021-03-29 15:59:14 +08:00
fn update_me(String);
2022-05-12 17:35:25 +08:00
fn show_run_without_install();
fn run_without_install();
2021-03-29 15:59:14 +08:00
fn get_app_name();
fn get_software_store_path();
fn get_software_ext();
fn open_url(String);
2022-05-12 17:35:25 +08:00
fn change_id(String);
fn get_async_job_status();
fn post_request(String, String, String);
fn is_ok_change_id();
fn create_shortcut(String);
fn discover();
fn get_lan_peers();
2022-05-12 17:35:25 +08:00
fn get_uuid();
2022-06-30 16:19:36 +08:00
fn has_hwcodec();
fn get_langs();
fn default_video_save_directory();
fn handle_relay_id(String);
fn get_login_device_info();
2021-03-29 15:59:14 +08:00
}
}
impl sciter::host::HostHandler for UIHostHandler {
fn on_graphics_critical_failure(&mut self) {
log::error!("Critical rendering error: e.g. DirectX gfx driver error. Most probably bad gfx drivers.");
}
}
2021-03-29 15:59:14 +08:00
#[cfg(not(target_os = "linux"))]
fn get_sound_inputs() -> Vec<String> {
let mut out = Vec::new();
use cpal::traits::{DeviceTrait, HostTrait};
let host = cpal::default_host();
if let Ok(devices) = host.devices() {
for device in devices {
if device.default_input_config().is_err() {
continue;
}
if let Ok(name) = device.name() {
out.push(name);
}
}
}
out
}
#[cfg(target_os = "linux")]
fn get_sound_inputs() -> Vec<String> {
crate::platform::linux::get_pa_sources()
.drain(..)
.map(|x| x.1)
.collect()
}
// sacrifice some memory
pub fn value_crash_workaround(values: &[Value]) -> Arc<Vec<Value>> {
let persist = Arc::new(values.to_vec());
STUPID_VALUES.lock().unwrap().push(persist.clone());
persist
}
2023-02-10 17:09:31 +08:00
2023-02-11 00:21:19 +08:00
pub fn get_icon() -> String {
// 128x128
#[cfg(target_os = "macos")]
// 128x128 on 160x160 canvas, then shrink to 128, mac looks better with padding
{
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAABhGlDQ1BJQ0MgcHJvZmlsZQAAeJx9kT1Iw0AYht+mSkUqHewg4pChOlkQFXHUVihChVArtOpgcukfNGlIUlwcBdeCgz+LVQcXZ10dXAVB8AfE1cVJ0UVK/C4ptIjxjuMe3vvel7vvAKFZZZrVMwFoum1mUgkxl18VQ68QEEKYZkRmljEvSWn4jq97BPh+F+dZ/nV/jgG1YDEgIBLPMcO0iTeIZzZtg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3DzqS4lCETx/azTiVO7e5Y1Z/ePwm+/J+5XYx3FV+G+ZAKhK4bXAhJsAys+JONeIAA8YkCOCeJbxH78pmtdjcsO03rF4oewiLvo3JJApAlp7WGF3YUAcHxtwE0DJSX/ul9LMu9YwU9ON6GjSV+4nWIwGTEmOxdLjdskdXVeH336+SX8C2Hval1jJbf0rDfPwgPY9wHMjTOlpwtJjdskdXVeH39vQjF9x2oSHmwD2nQ1MKGSJIJZxP76PfgUwvlsMjLSfgBhsutGqncqsLm7PyE0Ah2p92V92r5+A23sYYDbqr/j3g6qBYR2N2FVPBMoXwaFGnQmAdtCovggo7f8f3l0f7f4b4ZZO0S0CUDD4VWV3e3c447FJFRcBnG2kQaCAEzJFkJmkfwEMshhl+kKXw9McqpomD3qY1K8OuQigjqa6icravxS+bwf9Fv9+9DYbrkqrPBHUNetIAFanKClx1zNGV7P+BZAU4yvFFIqgpT9BfXARQJN/3qdCEXBq+moKasm0XgVIE4F/V1O1wakV
}
#[cfg(not(target_os = "macos"))] // 128x128 no padding
{
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAEiuAABIrgHwmhA7AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAEx9JREFUeJztnXmYHMV5h9+vZnZ0rHYRum8J4/AErQlgAQbMsRIWBEFCjK2AgwTisGILMBFCIMug1QLiPgIYE/QY2QQwiMVYjoSlODxEAgLEHMY8YuUEbEsOp3Z1X7vanf7yR8/MztEz0zPTPTO7M78/tnurvqn6uuqdr6q7a7pFVelrkpaPhhAMTEaYjJHDUWsEARkODANGAfWgINEPxLb7QNtBPkdoR7Ud0T8iphUTbtXp4z8pyQH5KOntAEhL2yCCnALW6aAnIDQAI+3MqFHkGJM73BkCO93JXnQnsAl4C8MGuoIv69mj2rw9ouKq1wEgzRiO2noSlp6DoRHleISgnQkJnRpLw0sI4v9X4H2E9Yj172zf+2udOflgYUdYXPUaA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