mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-19 00:13:01 +08:00
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
|
||||
if (uri.authority == "connection" && uri.path.startsWith("/new/")) {
|
||||
final peerId = uri.path.substring("/new/".length);
|
||||
var param = uri.queryParameters;
|
||||
String? switch_uuid = param["switch_uuid"];
|
||||
Future.delayed(Duration.zero, () {
|
||||
rustDeskWinManager.newRemoteDesktop(peerId);
|
||||
rustDeskWinManager.newRemoteDesktop(peerId, switch_uuid: switch_uuid);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -199,12 +199,6 @@ class FfiModel with ChangeNotifier {
|
||||
parent.target?.serverModel.setShowElevation(show);
|
||||
} else if (name == 'cancel_msgbox') {
|
||||
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') {
|
||||
final peer_id = evt['peer_id'].toString();
|
||||
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");
|
||||
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")]
|
||||
{
|
||||
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)]
|
||||
{
|
||||
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;
|
||||
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(
|
||||
"FLUTTER_RUNNER_WIN32_WINDOW",
|
||||
"RustDesk",
|
||||
|
@ -612,17 +612,3 @@ pub fn set_cur_session_id(id: String) {
|
||||
*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")]
|
||||
Some(misc::Union::SwitchSidesRequest(s)) => {
|
||||
crate::flutter::switch_sides(&self.lr.my_id, &s.uuid);
|
||||
return false;
|
||||
if let Ok(uuid) = uuid::Uuid::from_slice(&s.uuid.to_vec()[..]) {
|
||||
crate::run_me(vec![
|
||||
"--connect",
|
||||
&self.lr.my_id,
|
||||
"--switch_uuid",
|
||||
uuid.to_string().as_ref(),
|
||||
])
|
||||
.ok();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user