switch sides: windows
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
e57949d472
commit
c25796e44d
@ -1307,8 +1307,10 @@ bool callUniLinksUriHandler(Uri uri) {
|
|||||||
// new connection
|
// new connection
|
||||||
if (uri.authority == "connection" && uri.path.startsWith("/new/")) {
|
if (uri.authority == "connection" && uri.path.startsWith("/new/")) {
|
||||||
final peerId = uri.path.substring("/new/".length);
|
final peerId = uri.path.substring("/new/".length);
|
||||||
|
var param = uri.queryParameters;
|
||||||
|
String? switch_uuid = param["switch_uuid"];
|
||||||
Future.delayed(Duration.zero, () {
|
Future.delayed(Duration.zero, () {
|
||||||
rustDeskWinManager.newRemoteDesktop(peerId);
|
rustDeskWinManager.newRemoteDesktop(peerId, switch_uuid: switch_uuid);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -199,12 +199,6 @@ class FfiModel with ChangeNotifier {
|
|||||||
parent.target?.serverModel.setShowElevation(show);
|
parent.target?.serverModel.setShowElevation(show);
|
||||||
} else if (name == 'cancel_msgbox') {
|
} else if (name == 'cancel_msgbox') {
|
||||||
cancelMsgBox(evt, peerId);
|
cancelMsgBox(evt, peerId);
|
||||||
} else if (name == 'switch_sides') {
|
|
||||||
final peer_id = evt['peer_id'].toString();
|
|
||||||
final uuid = evt['uuid'].toString();
|
|
||||||
Future.delayed(Duration.zero, () {
|
|
||||||
rustDeskWinManager.newRemoteDesktop(peer_id, switch_uuid: uuid);
|
|
||||||
});
|
|
||||||
} else if (name == 'switch_back') {
|
} else if (name == 'switch_back') {
|
||||||
final peer_id = evt['peer_id'].toString();
|
final peer_id = evt['peer_id'].toString();
|
||||||
await bind.sessionSwitchSides(id: peer_id);
|
await bind.sessionSwitchSides(id: peer_id);
|
||||||
|
@ -298,6 +298,13 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin
|
|||||||
eprintln!("please provide a valid peer id");
|
eprintln!("please provide a valid peer id");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
let mut switch_uuid = None;
|
||||||
|
while let Some(item) = args.next() {
|
||||||
|
if item == "--switch_uuid" {
|
||||||
|
switch_uuid = args.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
use crate::dbus::invoke_new_connection;
|
use crate::dbus::invoke_new_connection;
|
||||||
@ -315,8 +322,14 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin
|
|||||||
}
|
}
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
|
let switch_uuid = switch_uuid.map_or("".to_string(), |p| format!("switch_uuid={}", p));
|
||||||
|
let params = vec![switch_uuid].join("&");
|
||||||
|
let params_flag = if params.is_empty() { "" } else { "?" };
|
||||||
use winapi::um::winuser::WM_USER;
|
use winapi::um::winuser::WM_USER;
|
||||||
let uni_links = format!("rustdesk://connection/new/{}", peer_id);
|
let uni_links = format!(
|
||||||
|
"rustdesk://connection/new/{}{}{}",
|
||||||
|
peer_id, params_flag, params
|
||||||
|
);
|
||||||
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",
|
"RustDesk",
|
||||||
|
@ -612,17 +612,3 @@ pub fn set_cur_session_id(id: String) {
|
|||||||
*CUR_SESSION_ID.write().unwrap() = id;
|
*CUR_SESSION_ID.write().unwrap() = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn switch_sides(peer_id: &str, uuid: &Bytes) {
|
|
||||||
if let Some(stream) = GLOBAL_EVENT_STREAM.read().unwrap().get(APP_TYPE_MAIN) {
|
|
||||||
if let Ok(uuid) = uuid::Uuid::from_slice(uuid.to_vec().as_ref()) {
|
|
||||||
let uuid = uuid.to_string();
|
|
||||||
let data = HashMap::from([
|
|
||||||
("name", "switch_sides"),
|
|
||||||
("peer_id", peer_id),
|
|
||||||
("uuid", &uuid),
|
|
||||||
]);
|
|
||||||
stream.add(serde_json::ser::to_string(&data).unwrap_or("".into()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1573,8 +1573,16 @@ impl Connection {
|
|||||||
},
|
},
|
||||||
#[cfg(feature = "flutter")]
|
#[cfg(feature = "flutter")]
|
||||||
Some(misc::Union::SwitchSidesRequest(s)) => {
|
Some(misc::Union::SwitchSidesRequest(s)) => {
|
||||||
crate::flutter::switch_sides(&self.lr.my_id, &s.uuid);
|
if let Ok(uuid) = uuid::Uuid::from_slice(&s.uuid.to_vec()[..]) {
|
||||||
return false;
|
crate::run_me(vec![
|
||||||
|
"--connect",
|
||||||
|
&self.lr.my_id,
|
||||||
|
"--switch_uuid",
|
||||||
|
uuid.to_string().as_ref(),
|
||||||
|
])
|
||||||
|
.ok();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user