Merge pull request #1707 from Kingtous/master
feat: add rustdesk uni links protocol
This commit is contained in:
commit
7559e0acac
@ -1135,10 +1135,36 @@ void checkArguments() {
|
||||
if (connectIndex == -1) {
|
||||
return;
|
||||
}
|
||||
String? peerId = bootArgs.length < connectIndex + 1 ? null: bootArgs[connectIndex + 1];
|
||||
if (peerId != null) {
|
||||
rustDeskWinManager.newRemoteDesktop(peerId);
|
||||
bootArgs.removeAt(connectIndex); bootArgs.removeAt(connectIndex);
|
||||
String? arg =
|
||||
bootArgs.length < connectIndex + 1 ? null : bootArgs[connectIndex + 1];
|
||||
if (arg != null) {
|
||||
if (arg.startsWith(kUniLinksPrefix)) {
|
||||
parseRustdeskUri(arg);
|
||||
} else {
|
||||
// fallback to peer id
|
||||
rustDeskWinManager.newRemoteDesktop(arg);
|
||||
bootArgs.removeAt(connectIndex);
|
||||
bootArgs.removeAt(connectIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse `rustdesk://` unilinks
|
||||
///
|
||||
/// [Functions]
|
||||
/// 1. New Connection: rustdesk://connection/new/your_peer_id
|
||||
void parseRustdeskUri(String uriPath) {
|
||||
final uri = Uri.tryParse(uriPath);
|
||||
if (uri == null) {
|
||||
print("uri is not valid: $uriPath");
|
||||
return;
|
||||
}
|
||||
// new connection
|
||||
if (uri.authority == "connection" && uri.path.startsWith("/new/")) {
|
||||
final peerId = uri.path.substring("/new/".length);
|
||||
Future.delayed(Duration.zero, () {
|
||||
rustDeskWinManager.newRemoteDesktop(peerId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,9 @@ const String kAppTypeDesktopRemote = "remote";
|
||||
const String kAppTypeDesktopFileTransfer = "file transfer";
|
||||
const String kAppTypeDesktopPortForward = "port forward";
|
||||
|
||||
const String kUniLinksPrefix = "rustdesk://";
|
||||
const String kActionNewConnection = "connection/new/";
|
||||
|
||||
const String kTabLabelHomePage = "Home";
|
||||
const String kTabLabelSettingPage = "Settings";
|
||||
|
||||
|
@ -29,7 +29,7 @@ late List<String> bootArgs;
|
||||
Future<void> main(List<String> args) async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
debugPrint("launch args: $args");
|
||||
bootArgs = args;
|
||||
bootArgs = List.from(args);
|
||||
|
||||
if (!isDesktop) {
|
||||
runMobileApp();
|
||||
|
@ -178,8 +178,14 @@ class FfiModel with ChangeNotifier {
|
||||
} else if (name == 'update_privacy_mode') {
|
||||
updatePrivacyMode(evt, peerId);
|
||||
} else if (name == 'new_connection') {
|
||||
final remoteId = evt['peer_id'];
|
||||
rustDeskWinManager.newRemoteDesktop(remoteId);
|
||||
var arg = evt['peer_id'].toString();
|
||||
if (arg.startsWith(kUniLinksPrefix)) {
|
||||
parseRustdeskUri(arg);
|
||||
} else {
|
||||
Future.delayed(Duration.zero, () {
|
||||
rustDeskWinManager.newRemoteDesktop(arg);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user