fix linux uni (url) and tray exit
This commit is contained in:
parent
9799758c96
commit
7fba1800ec
@ -549,6 +549,7 @@ void window_on_top(int? id) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
|
print("Bring window on top");
|
||||||
// main window
|
// main window
|
||||||
windowManager.restore();
|
windowManager.restore();
|
||||||
windowManager.show();
|
windowManager.show();
|
||||||
|
@ -198,11 +198,6 @@ class FfiModel with ChangeNotifier {
|
|||||||
updateBlockInputState(evt, peerId);
|
updateBlockInputState(evt, peerId);
|
||||||
} else if (name == 'update_privacy_mode') {
|
} else if (name == 'update_privacy_mode') {
|
||||||
updatePrivacyMode(evt, sessionId, peerId);
|
updatePrivacyMode(evt, sessionId, peerId);
|
||||||
} else if (name == 'new_connection') {
|
|
||||||
var uni_links = evt['uni_links'].toString();
|
|
||||||
if (uni_links.startsWith(kUniLinksPrefix)) {
|
|
||||||
parseRustdeskUri(uni_links);
|
|
||||||
}
|
|
||||||
} else if (name == 'alias') {
|
} else if (name == 'alias') {
|
||||||
handleAliasChanged(evt);
|
handleAliasChanged(evt);
|
||||||
} else if (name == 'show_elevation') {
|
} else if (name == 'show_elevation') {
|
||||||
@ -217,6 +212,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
} else if (name == 'portable_service_running') {
|
} else if (name == 'portable_service_running') {
|
||||||
parent.target?.elevationModel.onPortableServiceRunning(evt);
|
parent.target?.elevationModel.onPortableServiceRunning(evt);
|
||||||
} else if (name == 'on_url_scheme_received') {
|
} else if (name == 'on_url_scheme_received') {
|
||||||
|
// currently comes from "_url" ipc of mac and dbus of linux
|
||||||
onUrlSchemeReceived(evt);
|
onUrlSchemeReceived(evt);
|
||||||
} else if (name == 'on_voice_call_waiting') {
|
} else if (name == 'on_voice_call_waiting') {
|
||||||
// Waiting for the response from the peer.
|
// Waiting for the response from the peer.
|
||||||
@ -252,13 +248,9 @@ 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 we invoke uri with blank path, we just bring the main window to the top.
|
if (url.startsWith(kUniLinksPrefix) && parseRustdeskUri(url)) {
|
||||||
if (url.isEmpty) {
|
return;
|
||||||
window_on_top(null);
|
}
|
||||||
} else if (url.startsWith(kUniLinksPrefix)) {
|
|
||||||
parseRustdeskUri(url);
|
|
||||||
} else {
|
|
||||||
// action
|
|
||||||
switch (url) {
|
switch (url) {
|
||||||
case kUrlActionClose:
|
case kUrlActionClose:
|
||||||
debugPrint("closing all instances");
|
debugPrint("closing all instances");
|
||||||
@ -268,11 +260,10 @@ class FfiModel with ChangeNotifier {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
debugPrint("Unknown url received: $url");
|
window_on_top(null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Bind the event listener to receive events from the Rust core.
|
/// Bind the event listener to receive events from the Rust core.
|
||||||
updateEventListener(SessionID sessionId, String peerId) {
|
updateEventListener(SessionID sessionId, String peerId) {
|
||||||
|
@ -94,6 +94,13 @@ pub fn core_main() -> Option<Vec<String>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hbb_common::init_log(false, &log_name);
|
hbb_common::init_log(false, &log_name);
|
||||||
|
|
||||||
|
// linux uni (url) go here.
|
||||||
|
#[cfg(all(target_os = "linux", feature = "flutter"))]
|
||||||
|
if args.len() > 0 && args[0].starts_with("rustdesk:") {
|
||||||
|
return try_send_by_dbus(args[0].clone());
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if !crate::platform::is_installed()
|
if !crate::platform::is_installed()
|
||||||
&& args.is_empty()
|
&& args.is_empty()
|
||||||
@ -343,20 +350,8 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
return try_send_by_dbus(uni_links);
|
||||||
use crate::dbus::invoke_new_connection;
|
|
||||||
|
|
||||||
match invoke_new_connection(uni_links) {
|
|
||||||
Ok(()) => {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
log::error!("{}", err.as_ref());
|
|
||||||
// return Some to invoke this new connection by self
|
|
||||||
return Some(Vec::new());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
use winapi::um::winuser::WM_USER;
|
use winapi::um::winuser::WM_USER;
|
||||||
@ -378,3 +373,19 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(all(target_os = "linux", feature = "flutter"))]
|
||||||
|
fn try_send_by_dbus(uni_links: String) -> Option<Vec<String>> {
|
||||||
|
use crate::dbus::invoke_new_connection;
|
||||||
|
|
||||||
|
match invoke_new_connection(uni_links) {
|
||||||
|
Ok(()) => {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
log::error!("{}", err.as_ref());
|
||||||
|
// return Some to invoke this url by self
|
||||||
|
return Some(Vec::new());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1145,7 +1145,7 @@ pub fn uninstall_service(show_new_window: bool) -> bool {
|
|||||||
if show_new_window {
|
if show_new_window {
|
||||||
run_me_with(2);
|
run_me_with(2);
|
||||||
}
|
}
|
||||||
true
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn install_service() -> bool {
|
pub fn install_service() -> bool {
|
||||||
|
@ -2171,7 +2171,7 @@ pub fn uninstall_service(show_new_window: bool) -> bool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
run_after_run_cmds(!show_new_window);
|
run_after_run_cmds(!show_new_window);
|
||||||
true
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn install_service() -> bool {
|
pub fn install_service() -> bool {
|
||||||
|
@ -36,6 +36,7 @@ impl Error for DbusError {}
|
|||||||
/// - use dbus-send command:
|
/// - use dbus-send command:
|
||||||
/// `dbus-send --session --print-reply --dest=org.rustdesk.rustdesk /dbus org.rustdesk.rustdesk.NewConnection string:'PEER_ID'`
|
/// `dbus-send --session --print-reply --dest=org.rustdesk.rustdesk /dbus org.rustdesk.rustdesk.NewConnection string:'PEER_ID'`
|
||||||
pub fn invoke_new_connection(uni_links: String) -> Result<(), Box<dyn Error>> {
|
pub fn invoke_new_connection(uni_links: String) -> Result<(), Box<dyn Error>> {
|
||||||
|
log::info!("Starting dbus service for uni");
|
||||||
let conn = Connection::new_session()?;
|
let conn = Connection::new_session()?;
|
||||||
let proxy = conn.with_proxy(DBUS_NAME, DBUS_PREFIX, DBUS_TIMEOUT);
|
let proxy = conn.with_proxy(DBUS_NAME, DBUS_PREFIX, DBUS_TIMEOUT);
|
||||||
let (ret,): (String,) =
|
let (ret,): (String,) =
|
||||||
@ -73,8 +74,8 @@ fn handle_client_message(builder: &mut IfaceBuilder<()>) {
|
|||||||
{
|
{
|
||||||
use crate::flutter;
|
use crate::flutter;
|
||||||
let data = HashMap::from([
|
let data = HashMap::from([
|
||||||
("name", "new_connection"),
|
("name", "on_url_scheme_received"),
|
||||||
("uni_links", _uni_links.as_str()),
|
("url", _uni_links.as_str()),
|
||||||
]);
|
]);
|
||||||
let event = serde_json::ser::to_string(&data).unwrap_or("".to_string());
|
let event = serde_json::ser::to_string(&data).unwrap_or("".to_string());
|
||||||
match crate::flutter::push_global_event(flutter::APP_TYPE_MAIN, event) {
|
match crate::flutter::push_global_event(flutter::APP_TYPE_MAIN, event) {
|
||||||
|
@ -74,9 +74,14 @@ pub fn make_tray() -> hbb_common::ResultType<()> {
|
|||||||
.spawn()
|
.spawn()
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
// xdg-open?
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
if !std::process::Command::new("xdg-open")
|
||||||
|
.arg("rustdesk://")
|
||||||
|
.spawn()
|
||||||
|
.is_ok()
|
||||||
|
{
|
||||||
crate::run_me::<&str>(vec![]).ok();
|
crate::run_me::<&str>(vec![]).ok();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
event_loop.run(move |_event, _, control_flow| {
|
event_loop.run(move |_event, _, control_flow| {
|
||||||
@ -92,7 +97,6 @@ pub fn make_tray() -> hbb_common::ResultType<()> {
|
|||||||
if let Ok(event) = menu_channel.try_recv() {
|
if let Ok(event) = menu_channel.try_recv() {
|
||||||
if event.id == quit_i.id() {
|
if event.id == quit_i.id() {
|
||||||
crate::platform::uninstall_service(false);
|
crate::platform::uninstall_service(false);
|
||||||
*control_flow = ControlFlow::Exit;
|
|
||||||
} else if event.id == open_i.id() {
|
} else if event.id == open_i.id() {
|
||||||
open_func();
|
open_func();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user