remove more "rustdesk" built-in

This commit is contained in:
rustdesk 2024-02-25 13:29:06 +08:00
parent 9ff1dfe019
commit a28c9f8f36
15 changed files with 66 additions and 50 deletions

View File

@ -1889,7 +1889,7 @@ bool handleUriLink({List<String>? cmdArgs, Uri? uri, String? uriString}) {
if (cmdArgs != null && cmdArgs.isNotEmpty) { if (cmdArgs != null && cmdArgs.isNotEmpty) {
args = cmdArgs; args = cmdArgs;
// rustdesk <uri link> // rustdesk <uri link>
if (args[0].startsWith(kUniLinksPrefix)) { if (args[0].startsWith(bind.mainUriPrefixSync())) {
final uri = Uri.tryParse(args[0]); final uri = Uri.tryParse(args[0]);
if (uri != null) { if (uri != null) {
args = urlLinkToCmdArgs(uri); args = urlLinkToCmdArgs(uri);
@ -2429,19 +2429,20 @@ int versionCmp(String v1, String v2) {
} }
String getWindowName({WindowType? overrideType}) { String getWindowName({WindowType? overrideType}) {
final name = bind.mainGetAppNameSync();
switch (overrideType ?? kWindowType) { switch (overrideType ?? kWindowType) {
case WindowType.Main: case WindowType.Main:
return "RustDesk"; return name;
case WindowType.FileTransfer: case WindowType.FileTransfer:
return "File Transfer - RustDesk"; return "File Transfer - $name";
case WindowType.PortForward: case WindowType.PortForward:
return "Port Forward - RustDesk"; return "Port Forward - $name";
case WindowType.RemoteDesktop: case WindowType.RemoteDesktop:
return "Remote Desktop - RustDesk"; return "Remote Desktop - $name";
default: default:
break; break;
} }
return "RustDesk"; return name;
} }
String getWindowNameWithId(String id, {WindowType? overrideType}) { String getWindowNameWithId(String id, {WindowType? overrideType}) {

View File

@ -71,7 +71,6 @@ const String kOptionOpenInWindows = "allow-open-in-windows";
const String kOptionForceAlwaysRelay = "force-always-relay"; const String kOptionForceAlwaysRelay = "force-always-relay";
const String kOptionViewOnly = "view-only"; const String kOptionViewOnly = "view-only";
const String kUniLinksPrefix = "rustdesk://";
const String kUrlActionClose = "close"; const String kUrlActionClose = "close";
const String kTabLabelHomePage = "Home"; const String kTabLabelHomePage = "Home";

View File

@ -322,7 +322,9 @@ class _DesktopHomePageState extends State<DesktopHomePage>
} }
Future<Widget> buildHelpCards() async { Future<Widget> buildHelpCards() async {
if (updateUrl.isNotEmpty && !isCardClosed) { if (updateUrl.isNotEmpty &&
!isCardClosed &&
bind.mainUriPrefixSync().contains('rustdesk')) {
return buildInstallCard( return buildInstallCard(
"Status", "Status",
"There is a newer version of ${bind.mainGetAppNameSync()} ${bind.mainGetNewVersion()} available.", "There is a newer version of ${bind.mainGetAppNameSync()} ${bind.mainGetNewVersion()} available.",

View File

@ -8,7 +8,7 @@ import 'package:qr_code_scanner/qr_code_scanner.dart';
import 'package:zxing2/qrcode.dart'; import 'package:zxing2/qrcode.dart';
import '../../common.dart'; import '../../common.dart';
import '../../consts.dart'; import '../../models/platform_model.dart';
import '../widgets/dialog.dart'; import '../widgets/dialog.dart';
class ScanPage extends StatefulWidget { class ScanPage extends StatefulWidget {
@ -61,7 +61,7 @@ class _ScanPageState extends State<ScanPage> {
var reader = QRCodeReader(); var reader = QRCodeReader();
try { try {
var result = reader.decode(bitmap); var result = reader.decode(bitmap);
if (result.text.startsWith(kUniLinksPrefix)) { if (result.text.startsWith(bind.mainUriPrefixSync())) {
handleUriLink(uriString: result.text); handleUriLink(uriString: result.text);
} else { } else {
showServerSettingFromQr(result.text); showServerSettingFromQr(result.text);

View File

@ -379,7 +379,7 @@ class FfiModel with ChangeNotifier {
onUrlSchemeReceived(Map<String, dynamic> evt) { onUrlSchemeReceived(Map<String, dynamic> evt) {
final url = evt['url'].toString().trim(); final url = evt['url'].toString().trim();
if (url.startsWith(kUniLinksPrefix) && handleUriLink(uriString: url)) { if (url.startsWith(bind.mainUriPrefixSync()) && handleUriLink(uriString: url)) {
return; return;
} }
switch (url) { switch (url) {

View File

@ -10,9 +10,6 @@ PODS:
- flutter_custom_cursor (0.0.1): - flutter_custom_cursor (0.0.1):
- FlutterMacOS - FlutterMacOS
- FlutterMacOS (1.0.0) - FlutterMacOS (1.0.0)
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- package_info_plus (0.0.1): - package_info_plus (0.0.1):
- FlutterMacOS - FlutterMacOS
- path_provider_foundation (0.0.1): - path_provider_foundation (0.0.1):
@ -20,9 +17,9 @@ PODS:
- FlutterMacOS - FlutterMacOS
- screen_retriever (0.0.1): - screen_retriever (0.0.1):
- FlutterMacOS - FlutterMacOS
- sqflite (0.0.2): - sqflite (0.0.3):
- Flutter
- FlutterMacOS - FlutterMacOS
- FMDB (>= 2.7.5)
- texture_rgba_renderer (0.0.1): - texture_rgba_renderer (0.0.1):
- FlutterMacOS - FlutterMacOS
- uni_links_desktop (0.0.1): - uni_links_desktop (0.0.1):
@ -49,7 +46,7 @@ DEPENDENCIES:
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`) - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
- sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/macos`) - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`)
- texture_rgba_renderer (from `Flutter/ephemeral/.symlinks/plugins/texture_rgba_renderer/macos`) - texture_rgba_renderer (from `Flutter/ephemeral/.symlinks/plugins/texture_rgba_renderer/macos`)
- uni_links_desktop (from `Flutter/ephemeral/.symlinks/plugins/uni_links_desktop/macos`) - uni_links_desktop (from `Flutter/ephemeral/.symlinks/plugins/uni_links_desktop/macos`)
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
@ -58,10 +55,6 @@ DEPENDENCIES:
- window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`)
- window_size (from `Flutter/ephemeral/.symlinks/plugins/window_size/macos`) - window_size (from `Flutter/ephemeral/.symlinks/plugins/window_size/macos`)
SPEC REPOS:
trunk:
- FMDB
EXTERNAL SOURCES: EXTERNAL SOURCES:
desktop_drop: desktop_drop:
:path: Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos :path: Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos
@ -82,7 +75,7 @@ EXTERNAL SOURCES:
screen_retriever: screen_retriever:
:path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos :path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos
sqflite: sqflite:
:path: Flutter/ephemeral/.symlinks/plugins/sqflite/macos :path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin
texture_rgba_renderer: texture_rgba_renderer:
:path: Flutter/ephemeral/.symlinks/plugins/texture_rgba_renderer/macos :path: Flutter/ephemeral/.symlinks/plugins/texture_rgba_renderer/macos
uni_links_desktop: uni_links_desktop:
@ -105,15 +98,14 @@ SPEC CHECKSUMS:
file_selector_macos: 468fb6b81fac7c0e88d71317f3eec34c3b008ff9 file_selector_macos: 468fb6b81fac7c0e88d71317f3eec34c3b008ff9
flutter_custom_cursor: 629957115075c672287bd0fa979d863ccf6024f7 flutter_custom_cursor: 629957115075c672287bd0fa979d863ccf6024f7
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
sqflite: a5789cceda41d54d23f31d6de539d65bb14100ea sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
texture_rgba_renderer: cbed959a3c127122194a364e14b8577bd62dc8f2 texture_rgba_renderer: cbed959a3c127122194a364e14b8577bd62dc8f2
uni_links_desktop: 45900fb319df48fcdea2df0756e9c2626696b026 uni_links_desktop: 45900fb319df48fcdea2df0756e9c2626696b026
url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95
video_player_avfoundation: 8563f13d8fc8b2c29dc2d09e60b660e4e8128837 video_player_avfoundation: 02011213dab73ae3687df27ce441fbbcc82b5579
wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269 wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
window_size: 339dafa0b27a95a62a843042038fa6c3c48de195 window_size: 339dafa0b27a95a62a843042038fa6c3c48de195

View File

@ -1527,15 +1527,12 @@ impl<T: InvokeUiSession> Remote<T> {
}, },
Some(message::Union::MessageBox(msgbox)) => { Some(message::Union::MessageBox(msgbox)) => {
let mut link = msgbox.link; let mut link = msgbox.link;
// Links from the remote side must be verified.
if !link.starts_with("rustdesk://") {
if let Some(v) = hbb_common::config::HELPER_URL.get(&link as &str) { if let Some(v) = hbb_common::config::HELPER_URL.get(&link as &str) {
link = v.to_string(); link = v.to_string();
} else { } else {
log::warn!("Message box ignore link {} for security", &link); log::warn!("Message box ignore link {} for security", &link);
link = "".to_string(); link = "".to_string();
} }
}
self.handler self.handler
.msgbox(&msgbox.msgtype, &msgbox.title, &msgbox.text, &link); .msgbox(&msgbox.msgtype, &msgbox.title, &msgbox.text, &link);
} }

View File

@ -979,10 +979,16 @@ async fn check_software_update_() -> hbb_common::ResultType<()> {
Ok(()) Ok(())
} }
#[inline]
pub fn get_app_name() -> String { pub fn get_app_name() -> String {
hbb_common::config::APP_NAME.read().unwrap().clone() hbb_common::config::APP_NAME.read().unwrap().clone()
} }
#[inline]
pub fn get_uri_prefix() -> String {
format!("{}://", get_app_name().to_lowercase())
}
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
pub fn get_full_name() -> String { pub fn get_full_name() -> String {
format!( format!(

View File

@ -24,10 +24,11 @@ macro_rules! my_println{
#[inline] #[inline]
fn is_empty_uni_link(arg: &str) -> bool { fn is_empty_uni_link(arg: &str) -> bool {
if !arg.starts_with("rustdesk://") { let prefix = crate::get_uri_prefix();
if !arg.starts_with(&prefix) {
return false; return false;
} }
arg["rustdesk://".len()..].chars().all(|c| c == '/') arg[prefix.len()..].chars().all(|c| c == '/')
} }
/// shared by flutter and sciter main function /// shared by flutter and sciter main function
@ -135,7 +136,7 @@ pub fn core_main() -> Option<Vec<String>> {
// linux uni (url) go here. // linux uni (url) go here.
#[cfg(all(target_os = "linux", feature = "flutter"))] #[cfg(all(target_os = "linux", feature = "flutter"))]
if args.len() > 0 && args[0].starts_with("rustdesk:") { if args.len() > 0 && args[0].starts_with(&crate::get_uri_prefix()) {
return try_send_by_dbus(args[0].clone()); return try_send_by_dbus(args[0].clone());
} }
@ -551,7 +552,14 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin
} }
let params = param_array.join("&"); let params = param_array.join("&");
let params_flag = if params.is_empty() { "" } else { "?" }; let params_flag = if params.is_empty() { "" } else { "?" };
uni_links = format!("rustdesk://{}/{}{}{}", authority, id, params_flag, params); uni_links = format!(
"{}{}/{}{}{}",
crate::get_uri_prefix(),
authority,
id,
params_flag,
params
);
} }
} }
if uni_links.is_empty() { if uni_links.is_empty() {
@ -566,7 +574,7 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin
use winapi::um::winuser::WM_USER; use winapi::um::winuser::WM_USER;
let res = crate::platform::send_message_to_hnwd( let res = crate::platform::send_message_to_hnwd(
"FLUTTER_RUNNER_WIN32_WINDOW", "FLUTTER_RUNNER_WIN32_WINDOW",
"RustDesk", &crate::get_app_name(),
(WM_USER + 2) as _, // referred from unilinks desktop pub (WM_USER + 2) as _, // referred from unilinks desktop pub
uni_links.as_str(), uni_links.as_str(),
false, false,

View File

@ -804,6 +804,10 @@ pub fn main_get_app_name_sync() -> SyncReturn<String> {
SyncReturn(get_app_name()) SyncReturn(get_app_name())
} }
pub fn main_uri_prefix_sync() -> SyncReturn<String> {
SyncReturn(crate::get_uri_prefix())
}
pub fn main_get_license() -> String { pub fn main_get_license() -> String {
get_license() get_license()
} }

View File

@ -158,21 +158,21 @@ pub fn is_installed_daemon(prompt: bool) -> bool {
let Some(install_script) = PRIVILEGES_SCRIPTS_DIR.get_file("install.scpt") else { let Some(install_script) = PRIVILEGES_SCRIPTS_DIR.get_file("install.scpt") else {
return false; return false;
}; };
let Some(install_script_body) = install_script.contents_utf8() else { let Some(install_script_body) = install_script.contents_utf8().map(correct_app_name) else {
return false; return false;
}; };
let Some(daemon_plist) = PRIVILEGES_SCRIPTS_DIR.get_file(&daemon) else { let Some(daemon_plist) = PRIVILEGES_SCRIPTS_DIR.get_file("daemon.plist") else {
return false; return false;
}; };
let Some(daemon_plist_body) = daemon_plist.contents_utf8() else { let Some(daemon_plist_body) = daemon_plist.contents_utf8().map(correct_app_name) else {
return false; return false;
}; };
let Some(agent_plist) = PRIVILEGES_SCRIPTS_DIR.get_file(&agent) else { let Some(agent_plist) = PRIVILEGES_SCRIPTS_DIR.get_file("agent.plist") else {
return false; return false;
}; };
let Some(agent_plist_body) = agent_plist.contents_utf8() else { let Some(agent_plist_body) = agent_plist.contents_utf8().map(correct_app_name) else {
return false; return false;
}; };
@ -213,6 +213,12 @@ pub fn is_installed_daemon(prompt: bool) -> bool {
false false
} }
fn correct_app_name(s: &str) -> String {
let s = s.replace("rustdesk", &crate::get_app_name().to_lowercase());
let s = s.replace("RustDesk", &crate::get_app_name());
s
}
pub fn uninstall_service(show_new_window: bool) -> bool { pub fn uninstall_service(show_new_window: bool) -> bool {
// to-do: do together with win/linux about refactory start/stop service // to-do: do together with win/linux about refactory start/stop service
if !is_installed_daemon(false) { if !is_installed_daemon(false) {
@ -222,7 +228,7 @@ pub fn uninstall_service(show_new_window: bool) -> bool {
let Some(script_file) = PRIVILEGES_SCRIPTS_DIR.get_file("uninstall.scpt") else { let Some(script_file) = PRIVILEGES_SCRIPTS_DIR.get_file("uninstall.scpt") else {
return false; return false;
}; };
let Some(script_body) = script_file.contents_utf8() else { let Some(script_body) = script_file.contents_utf8().map(correct_app_name) else {
return false; return false;
}; };
@ -625,7 +631,7 @@ pub fn handle_application_should_open_untitled_file() {
let x = std::env::args().nth(1).unwrap_or_default(); let x = std::env::args().nth(1).unwrap_or_default();
if x == "--server" || x == "--cm" || x == "--tray" { if x == "--server" || x == "--cm" || x == "--tray" {
if crate::platform::macos::check_main_window() { if crate::platform::macos::check_main_window() {
allow_err!(crate::ipc::send_url_scheme("rustdesk:".into())); allow_err!(crate::ipc::send_url_scheme(crate::get_uri_prefix()));
} }
} }
} }

View File

@ -2408,11 +2408,12 @@ sc start {app_name}
fn run_after_run_cmds(silent: bool) { fn run_after_run_cmds(silent: bool) {
let (_, _, _, exe) = get_install_info(); let (_, _, _, exe) = get_install_info();
let app = crate::get_app_name().to_lowercase();
if !silent { if !silent {
log::debug!("Spawn new window"); log::debug!("Spawn new window");
allow_err!(std::process::Command::new("cmd") allow_err!(std::process::Command::new("cmd")
.arg("/c") .arg("/c")
.arg("timeout /t 2 & start rustdesk://") .arg("timeout /t 2 & start {app}://")
.creation_flags(winapi::um::winbase::CREATE_NO_WINDOW) .creation_flags(winapi::um::winbase::CREATE_NO_WINDOW)
.spawn()); .spawn());
} }

View File

@ -91,14 +91,14 @@ pub fn make_tray() -> hbb_common::ResultType<()> {
use std::process::Command; use std::process::Command;
Command::new("cmd") Command::new("cmd")
.arg("/c") .arg("/c")
.arg("start rustdesk://") .arg(&format!("start {}", crate::get_uri_prefix()))
.creation_flags(winapi::um::winbase::CREATE_NO_WINDOW) .creation_flags(winapi::um::winbase::CREATE_NO_WINDOW)
.spawn() .spawn()
.ok(); .ok();
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
if !std::process::Command::new("xdg-open") if !std::process::Command::new("xdg-open")
.arg("rustdesk://") .arg(&crate::get_uri_prefix())
.spawn() .spawn()
.is_ok() .is_ok()
{ {