mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge branch 'master' into hwcodec
This commit is contained in:
26
src/lang.rs
26
src/lang.rs
@@ -1,21 +1,43 @@
|
||||
use serde_json::{json, value::Value};
|
||||
use std::ops::Deref;
|
||||
|
||||
mod cn;
|
||||
mod cs;
|
||||
mod da;
|
||||
mod sk;
|
||||
mod de;
|
||||
mod en;
|
||||
mod es;
|
||||
mod eo;
|
||||
mod es;
|
||||
mod fr;
|
||||
mod id;
|
||||
mod it;
|
||||
mod ptbr;
|
||||
mod ru;
|
||||
mod sk;
|
||||
mod tr;
|
||||
mod tw;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref LANGS: Value =
|
||||
json!(vec![
|
||||
("en", "English"),
|
||||
("it", "Italiano"),
|
||||
("fr", "Français"),
|
||||
("de", "Deutsch"),
|
||||
("cn", "简体中文"),
|
||||
("tw", "繁體中文"),
|
||||
("pt", "Português"),
|
||||
("es", "Español"),
|
||||
("ru", "Русский"),
|
||||
("sk", "Slovenčina"),
|
||||
("id", "Indonesia"),
|
||||
("cs", "Čeština"),
|
||||
("da", "Dansk"),
|
||||
("eo", "Esperanto"),
|
||||
("tr", "Türkçe"),
|
||||
]);
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
pub fn translate(name: String) -> String {
|
||||
let locale = sys_locale::get_locale().unwrap_or_default().to_lowercase();
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "退出"),
|
||||
("In privacy mode", "进入隐私模式"),
|
||||
("Out privacy mode", "退出隐私模式"),
|
||||
("Language", "语言"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "Vypnutý"),
|
||||
("In privacy mode", "v režimu soukromí"),
|
||||
("Out privacy mode", "mimo režim soukromí"),
|
||||
("Language", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "Slukket"),
|
||||
("In privacy mode", "I databeskyttelsestilstand"),
|
||||
("Out privacy mode", "Databeskyttelsestilstand fra"),
|
||||
("Language", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "Ausgeschaltet"),
|
||||
("In privacy mode", "im Datenschutzmodus"),
|
||||
("Out privacy mode", "Datenschutzmodus aus"),
|
||||
("Language", "Sprache"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", ""),
|
||||
("In privacy mode", ""),
|
||||
("Out privacy mode", ""),
|
||||
("Language", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "Apagado"),
|
||||
("In privacy mode", "En modo de privacidad"),
|
||||
("Out privacy mode", "Fuera del modo de privacidad"),
|
||||
("Language", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "Éteindre"),
|
||||
("In privacy mode", "en mode privé"),
|
||||
("Out privacy mode", "hors mode de confidentialité"),
|
||||
("Language", "Langue"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "Matikan"),
|
||||
("In privacy mode", "Dalam mode privasi"),
|
||||
("Out privacy mode", "Keluar dari mode privasi"),
|
||||
("Language", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "Spegni"),
|
||||
("In privacy mode", "In modalità privacy"),
|
||||
("Out privacy mode", "Fuori modalità privacy"),
|
||||
("Language", "Linguaggio"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "Desligado"),
|
||||
("In privacy mode", "No modo de privacidade"),
|
||||
("Out privacy mode", "Fora do modo de privacidade"),
|
||||
("Language", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "Выключен"),
|
||||
("In privacy mode", "В режиме конфиденциальности"),
|
||||
("Out privacy mode", "Выход из режима конфиденциальности"),
|
||||
("Language", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "Vypnutý"),
|
||||
("In privacy mode", "V režime súkromia"),
|
||||
("Out privacy mode", "Mimo režimu súkromia"),
|
||||
("Language", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", ""),
|
||||
("In privacy mode", ""),
|
||||
("Out privacy mode", ""),
|
||||
("Language", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "Kapalı"),
|
||||
("In privacy mode", "Gizlilik modunda"),
|
||||
("Out privacy mode", "Gizlilik modu dışında"),
|
||||
("Language", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -283,5 +283,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Turned off", "退出"),
|
||||
("In privacy mode", "開啟隱私模式"),
|
||||
("Out privacy mode", "退出隱私模式"),
|
||||
("Language", "語言"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -1020,6 +1020,22 @@ copy /Y \"{tmp_path}\\Uninstall {app_name}.lnk\" \"{start_menu}\\\"
|
||||
// https://docs.microsoft.com/zh-cn/windows/win32/msi/uninstall-registry-key?redirectedfrom=MSDNa
|
||||
// https://www.windowscentral.com/how-edit-registry-using-command-prompt-windows-10
|
||||
// https://www.tenforums.com/tutorials/70903-add-remove-allowed-apps-through-windows-firewall-windows-10-a.html
|
||||
// Note: without if exist, the bat may exit in advance on some Windows7 https://github.com/rustdesk/rustdesk/issues/895
|
||||
let dels = format!(
|
||||
"
|
||||
if exist \"{mk_shortcut}\" del /f /q \"{mk_shortcut}\"
|
||||
if exist \"{uninstall_shortcut}\" del /f /q \"{uninstall_shortcut}\"
|
||||
if exist \"{tray_shortcut}\" del /f /q \"{tray_shortcut}\"
|
||||
if exist \"{tmp_path}\\{app_name}.lnk\" del /f /q \"{tmp_path}\\{app_name}.lnk\"
|
||||
if exist \"{tmp_path}\\Uninstall {app_name}.lnk\" del /f /q \"{tmp_path}\\Uninstall {app_name}.lnk\"
|
||||
if exist \"{tmp_path}\\{app_name} Tray.lnk\" del /f /q \"{tmp_path}\\{app_name} Tray.lnk\"
|
||||
",
|
||||
mk_shortcut = mk_shortcut,
|
||||
uninstall_shortcut = uninstall_shortcut,
|
||||
tray_shortcut = tray_shortcut,
|
||||
tmp_path = tmp_path,
|
||||
app_name = crate::get_app_name(),
|
||||
);
|
||||
let cmds = format!(
|
||||
"
|
||||
{uninstall_str}
|
||||
@@ -1048,17 +1064,13 @@ cscript \"{tray_shortcut}\"
|
||||
copy /Y \"{tmp_path}\\{app_name} Tray.lnk\" \"%PROGRAMDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\\"
|
||||
{shortcuts}
|
||||
copy /Y \"{tmp_path}\\Uninstall {app_name}.lnk\" \"{path}\\\"
|
||||
del /f \"{mk_shortcut}\"
|
||||
del /f \"{uninstall_shortcut}\"
|
||||
del /f \"{tray_shortcut}\"
|
||||
del /f \"{tmp_path}\\{app_name}.lnk\"
|
||||
del /f \"{tmp_path}\\Uninstall {app_name}.lnk\"
|
||||
del /f \"{tmp_path}\\{app_name} Tray.lnk\"
|
||||
{dels}
|
||||
sc create {app_name} binpath= \"\\\"{exe}\\\" --import-config \\\"{config_path}\\\"\" start= auto DisplayName= \"{app_name} Service\"
|
||||
sc start {app_name}
|
||||
sc stop {app_name}
|
||||
sc delete {app_name}
|
||||
{after_install}
|
||||
{sleep}
|
||||
",
|
||||
uninstall_str=uninstall_str,
|
||||
path=path,
|
||||
@@ -1081,6 +1093,16 @@ sc delete {app_name}
|
||||
config_path=Config::file().to_str().unwrap_or(""),
|
||||
lic=register_licence(),
|
||||
after_install=get_after_install(&exe),
|
||||
sleep=if debug {
|
||||
"timeout 300"
|
||||
} else {
|
||||
""
|
||||
},
|
||||
dels=if debug {
|
||||
""
|
||||
} else {
|
||||
&dels
|
||||
},
|
||||
);
|
||||
run_cmds(cmds, debug, "install")?;
|
||||
std::thread::sleep(std::time::Duration::from_millis(2000));
|
||||
@@ -1126,10 +1148,10 @@ fn get_uninstall() -> String {
|
||||
"
|
||||
{before_uninstall}
|
||||
reg delete {subkey} /f
|
||||
rd /s /q \"{path}\"
|
||||
rd /s /q \"{start_menu}\"
|
||||
del /f /q \"%PUBLIC%\\Desktop\\{app_name}*\"
|
||||
del /f /q \"%PROGRAMDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\{app_name} Tray.lnk\"
|
||||
if exist \"{path}\" rd /s /q \"{path}\"
|
||||
if exist \"{start_menu}\" rd /s /q \"{start_menu}\"
|
||||
if exist \"%PUBLIC%\\Desktop\\{app_name}.lnk\" del /f /q \"%PUBLIC%\\Desktop\\{app_name}.lnk\"
|
||||
if exist \"%PROGRAMDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\{app_name} Tray.lnk\" del /f /q \"%PROGRAMDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\{app_name} Tray.lnk\"
|
||||
",
|
||||
before_uninstall=get_before_uninstall(),
|
||||
subkey=subkey,
|
||||
@@ -1176,11 +1198,8 @@ fn run_cmds(cmds: String, show: bool, tip: &str) -> ResultType<()> {
|
||||
.show(show)
|
||||
.force_prompt(true)
|
||||
.status();
|
||||
// leave the file for debug if execution failed
|
||||
if let Ok(res) = res {
|
||||
if res.success() {
|
||||
allow_err!(std::fs::remove_file(tmp));
|
||||
}
|
||||
if !show {
|
||||
allow_err!(std::fs::remove_file(tmp));
|
||||
}
|
||||
let _ = res?;
|
||||
Ok(())
|
||||
|
||||
@@ -3,9 +3,9 @@ mod cm;
|
||||
mod inline;
|
||||
#[cfg(target_os = "macos")]
|
||||
mod macos;
|
||||
pub mod remote;
|
||||
#[cfg(target_os = "windows")]
|
||||
pub mod win_privacy;
|
||||
pub mod remote;
|
||||
use crate::common::SOFTWARE_UPDATE_URL;
|
||||
use crate::ipc;
|
||||
use hbb_common::{
|
||||
@@ -760,6 +760,10 @@ impl UI {
|
||||
#[cfg(feature = "hwcodec")]
|
||||
return true;
|
||||
}
|
||||
|
||||
fn get_langs(&self) -> String {
|
||||
crate::lang::LANGS.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl sciter::EventHandler for UI {
|
||||
@@ -837,6 +841,7 @@ impl sciter::EventHandler for UI {
|
||||
fn get_lan_peers();
|
||||
fn get_uuid();
|
||||
fn has_hwcodec();
|
||||
fn get_langs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,40 @@ class AudioInputs: Reactor.Component {
|
||||
}
|
||||
this.toggleMenuState();
|
||||
}
|
||||
};
|
||||
|
||||
class Languages: Reactor.Component {
|
||||
function render() {
|
||||
var langs = JSON.parse(handler.get_langs());
|
||||
var me = this;
|
||||
self.timer(1ms, function() { me.toggleMenuState() });
|
||||
return <li>{translate('Language')}
|
||||
<menu #languages key={langs.length}>
|
||||
<li id="default"><span>{svg_checkmark}</span>Default</li>
|
||||
<div .separator />
|
||||
{langs.map(function(lang) {
|
||||
return <li id={lang[0]}><span>{svg_checkmark}</span>{lang[1]}</li>;
|
||||
})}
|
||||
</menu>
|
||||
</li>;
|
||||
}
|
||||
|
||||
|
||||
function toggleMenuState() {
|
||||
var cur = handler.get_local_option("lang") || "default";
|
||||
for (var el in this.$$(menu#languages>li)) {
|
||||
var selected = cur == el.id;
|
||||
el.attributes.toggleClass("selected", selected);
|
||||
}
|
||||
}
|
||||
|
||||
event click $(menu#languages>li) (_, me) {
|
||||
var v = me.id;
|
||||
if (v == "default") v = "";
|
||||
handler.set_local_option("lang", v);
|
||||
app.update();
|
||||
this.toggleMenuState();
|
||||
}
|
||||
}
|
||||
|
||||
var enhancementsMenu;
|
||||
@@ -202,7 +236,6 @@ class Enhancements: Reactor.Component {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getUserName() {
|
||||
try {
|
||||
return JSON.parse(handler.get_local_option("user_info")).name;
|
||||
@@ -261,7 +294,7 @@ class MyIdMenu: Reactor.Component {
|
||||
{handler.is_ok_change_id() && key_confirmed ? <li #change-id>{translate('Change ID')}</li> : ""}
|
||||
<div .separator />
|
||||
<li #allow-darktheme><span>{svg_checkmark}</span>{translate('Dark Theme')}</li>
|
||||
<div .separator />
|
||||
<Languages />
|
||||
<li #about>{translate('About')} {" "}{handler.get_app_name()}</li>
|
||||
</menu>
|
||||
</popup>;
|
||||
|
||||
@@ -2001,11 +2001,11 @@ impl Remote {
|
||||
let mut config: PeerConfig = self.handler.load_config();
|
||||
let mut transfer_metas = TransferSerde::default();
|
||||
for job in self.read_jobs.iter() {
|
||||
let json_str = serde_json::to_string(&job.gen_meta()).unwrap();
|
||||
let json_str = serde_json::to_string(&job.gen_meta()).unwrap_or_default();
|
||||
transfer_metas.read_jobs.push(json_str);
|
||||
}
|
||||
for job in self.write_jobs.iter() {
|
||||
let json_str = serde_json::to_string(&job.gen_meta()).unwrap();
|
||||
let json_str = serde_json::to_string(&job.gen_meta()).unwrap_or_default();
|
||||
transfer_metas.write_jobs.push(json_str);
|
||||
}
|
||||
log::info!("meta: {:?}", transfer_metas);
|
||||
|
||||
Reference in New Issue
Block a user