mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -1261,23 +1261,28 @@ StreamSubscription? listenUniLinks() {
|
||||
|
||||
/// Returns true if we successfully handle the startup arguments.
|
||||
bool checkArguments() {
|
||||
// bootArgs:[--connect, 362587269, --switch_uuid, e3d531cc-5dce-41e0-bd06-5d4a2b1eec05]
|
||||
// check connect args
|
||||
final connectIndex = bootArgs.indexOf("--connect");
|
||||
if (connectIndex == -1) {
|
||||
return false;
|
||||
}
|
||||
String? arg =
|
||||
String? id =
|
||||
bootArgs.length < connectIndex + 1 ? null : bootArgs[connectIndex + 1];
|
||||
if (arg != null) {
|
||||
if (arg.startsWith(kUniLinksPrefix)) {
|
||||
return parseRustdeskUri(arg);
|
||||
final switchUuidIndex = bootArgs.indexOf("--switch_uuid");
|
||||
String? switchUuid = bootArgs.length < switchUuidIndex + 1
|
||||
? null
|
||||
: bootArgs[switchUuidIndex + 1];
|
||||
if (id != null) {
|
||||
if (id.startsWith(kUniLinksPrefix)) {
|
||||
return parseRustdeskUri(id);
|
||||
} else {
|
||||
// remove "--connect xxx" in the `bootArgs` array
|
||||
bootArgs.removeAt(connectIndex);
|
||||
bootArgs.removeAt(connectIndex);
|
||||
// fallback to peer id
|
||||
Future.delayed(Duration.zero, () {
|
||||
rustDeskWinManager.newRemoteDesktop(arg);
|
||||
rustDeskWinManager.newRemoteDesktop(id, switch_uuid: switchUuid);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
@@ -1307,8 +1312,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 false;
|
||||
}
|
||||
@@ -1606,3 +1613,7 @@ Widget dialogButton(String text,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
int version_cmp(String v1, String v2) {
|
||||
return bind.versionToNumber(v: v1) - bind.versionToNumber(v: v2);
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ void setPasswordDialog() async {
|
||||
final p1 = TextEditingController(text: pw);
|
||||
var errMsg0 = "";
|
||||
var errMsg1 = "";
|
||||
final RxString rxPass = p0.text.obs;
|
||||
final RxString rxPass = pw.trim().obs;
|
||||
final rules = [
|
||||
DigitValidationRule(),
|
||||
UppercaseValidationRule(),
|
||||
@@ -603,7 +603,7 @@ void setPasswordDialog() async {
|
||||
controller: p0,
|
||||
focusNode: FocusNode()..requestFocus(),
|
||||
onChanged: (value) {
|
||||
rxPass.value = value;
|
||||
rxPass.value = value.trim();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -33,10 +33,12 @@ class RemotePage extends StatefulWidget {
|
||||
Key? key,
|
||||
required this.id,
|
||||
required this.menubarState,
|
||||
this.switchUuid,
|
||||
}) : super(key: key);
|
||||
|
||||
final String id;
|
||||
final MenubarState menubarState;
|
||||
final String? switchUuid;
|
||||
final SimpleWrapper<State<RemotePage>?> _lastState = SimpleWrapper(null);
|
||||
|
||||
FFI get ffi => (_lastState.value! as _RemotePageState)._ffi;
|
||||
@@ -100,7 +102,10 @@ class _RemotePageState extends State<RemotePage>
|
||||
showKBLayoutTypeChooserIfNeeded(
|
||||
_ffi.ffiModel.pi.platform, _ffi.dialogManager);
|
||||
});
|
||||
_ffi.start(widget.id);
|
||||
_ffi.start(
|
||||
widget.id,
|
||||
switchUuid: widget.switchUuid,
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||
_ffi.dialogManager
|
||||
|
||||
@@ -64,6 +64,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
key: ValueKey(peerId),
|
||||
id: peerId,
|
||||
menubarState: _menubarState,
|
||||
switchUuid: params['switch_uuid'],
|
||||
),
|
||||
));
|
||||
_update_remote_count();
|
||||
@@ -84,6 +85,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
if (call.method == "new_remote_desktop") {
|
||||
final args = jsonDecode(call.arguments);
|
||||
final id = args['id'];
|
||||
final switchUuid = args['switch_uuid'];
|
||||
window_on_top(windowId());
|
||||
ConnectionTypeState.init(id);
|
||||
tabController.add(TabInfo(
|
||||
@@ -96,6 +98,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
key: ValueKey(id),
|
||||
id: id,
|
||||
menubarState: _menubarState,
|
||||
switchUuid: switchUuid,
|
||||
),
|
||||
));
|
||||
} else if (call.method == "onDestroy") {
|
||||
|
||||
@@ -516,6 +516,15 @@ class _CmControlPanel extends StatelessWidget {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Offstage(
|
||||
offstage: !client.fromSwitch,
|
||||
child: buildButton(context,
|
||||
color: Colors.purple,
|
||||
onClick: () => handleSwitchBack(context),
|
||||
icon: Icon(Icons.reply, color: Colors.white),
|
||||
text: "Switch Sides",
|
||||
textColor: Colors.white),
|
||||
),
|
||||
Offstage(
|
||||
offstage: !showElevation,
|
||||
child: buildButton(context, color: Colors.green[700], onClick: () {
|
||||
@@ -674,6 +683,10 @@ class _CmControlPanel extends StatelessWidget {
|
||||
windowManager.close();
|
||||
}
|
||||
}
|
||||
|
||||
void handleSwitchBack(BuildContext context) {
|
||||
bind.cmSwitchBack(connId: client.id);
|
||||
}
|
||||
}
|
||||
|
||||
void checkClickTime(int id, Function() callback) async {
|
||||
|
||||
@@ -509,6 +509,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
List<MenuEntryBase<String>> _getControlMenu(BuildContext context) {
|
||||
final pi = widget.ffi.ffiModel.pi;
|
||||
final perms = widget.ffi.ffiModel.permissions;
|
||||
final peer_version = widget.ffi.ffiModel.pi.version;
|
||||
const EdgeInsets padding = EdgeInsets.only(left: 14.0, right: 5.0);
|
||||
final List<MenuEntryBase<String>> displayMenu = [];
|
||||
displayMenu.addAll([
|
||||
@@ -651,6 +652,19 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
dismissOnClicked: true,
|
||||
));
|
||||
}
|
||||
if (pi.platform != kPeerPlatformAndroid &&
|
||||
version_cmp(peer_version, '1.2.0') >= 0) {
|
||||
displayMenu.add(MenuEntryButton<String>(
|
||||
childBuilder: (TextStyle? style) => Text(
|
||||
translate('Switch Sides'),
|
||||
style: style,
|
||||
),
|
||||
proc: () =>
|
||||
showConfirmSwitchSidesDialog(widget.id, widget.ffi.dialogManager),
|
||||
padding: padding,
|
||||
dismissOnClicked: true,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if (pi.version.isNotEmpty) {
|
||||
@@ -721,6 +735,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
List<MenuEntryBase<String>> _getDisplayMenu(
|
||||
dynamic futureData, int remoteCount) {
|
||||
const EdgeInsets padding = EdgeInsets.only(left: 18.0, right: 8.0);
|
||||
final peer_version = widget.ffi.ffiModel.pi.version;
|
||||
final displayMenu = [
|
||||
MenuEntryRadios<String>(
|
||||
text: translate('Ratio'),
|
||||
@@ -880,9 +895,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
final fpsSlider = Offstage(
|
||||
offstage:
|
||||
(await bind.mainIsUsingPublicServer() && direct != true) ||
|
||||
(await bind.versionToNumber(
|
||||
v: widget.ffi.ffiModel.pi.version) <
|
||||
await bind.versionToNumber(v: '1.2.0')),
|
||||
version_cmp(peer_version, '1.2.0') < 0,
|
||||
child: Row(
|
||||
children: [
|
||||
Obx((() => Slider(
|
||||
@@ -1391,16 +1404,33 @@ void showAuditDialog(String id, dialogManager) async {
|
||||
focusNode: focusNode,
|
||||
)),
|
||||
actions: [
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: close,
|
||||
child: Text(translate('Cancel')),
|
||||
),
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: submit,
|
||||
child: Text(translate('OK')),
|
||||
),
|
||||
dialogButton('Cancel', onPressed: close, isOutline: true),
|
||||
dialogButton('OK', onPressed: submit)
|
||||
],
|
||||
onSubmit: submit,
|
||||
onCancel: close,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void showConfirmSwitchSidesDialog(
|
||||
String id, OverlayDialogManager dialogManager) async {
|
||||
dialogManager.show((setState, close) {
|
||||
submit() async {
|
||||
await bind.sessionSwitchSides(id: id);
|
||||
closeConnection(id: id);
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('Switch Sides')),
|
||||
content: Column(
|
||||
children: [
|
||||
Text(translate('Please confirm if you want to share your desktop?')),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
dialogButton('Cancel', onPressed: close, isOutline: true),
|
||||
dialogButton('OK', onPressed: submit),
|
||||
],
|
||||
onSubmit: submit,
|
||||
onCancel: close,
|
||||
|
||||
@@ -184,13 +184,9 @@ class FfiModel with ChangeNotifier {
|
||||
} else if (name == 'update_privacy_mode') {
|
||||
updatePrivacyMode(evt, peerId);
|
||||
} else if (name == 'new_connection') {
|
||||
var arg = evt['peer_id'].toString();
|
||||
if (arg.startsWith(kUniLinksPrefix)) {
|
||||
parseRustdeskUri(arg);
|
||||
} else {
|
||||
Future.delayed(Duration.zero, () {
|
||||
rustDeskWinManager.newRemoteDesktop(arg);
|
||||
});
|
||||
var uni_links = evt['uni_links'].toString();
|
||||
if (uni_links.startsWith(kUniLinksPrefix)) {
|
||||
parseRustdeskUri(uni_links);
|
||||
}
|
||||
} else if (name == 'alias') {
|
||||
handleAliasChanged(evt);
|
||||
@@ -199,6 +195,10 @@ class FfiModel with ChangeNotifier {
|
||||
parent.target?.serverModel.setShowElevation(show);
|
||||
} else if (name == 'cancel_msgbox') {
|
||||
cancelMsgBox(evt, peerId);
|
||||
} else if (name == 'switch_back') {
|
||||
final peer_id = evt['peer_id'].toString();
|
||||
await bind.sessionSwitchSides(id: peer_id);
|
||||
closeConnection(id: peer_id);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1289,7 +1289,9 @@ class FFI {
|
||||
|
||||
/// Start with the given [id]. Only transfer file if [isFileTransfer], only port forward if [isPortForward].
|
||||
void start(String id,
|
||||
{bool isFileTransfer = false, bool isPortForward = false}) {
|
||||
{bool isFileTransfer = false,
|
||||
bool isPortForward = false,
|
||||
String? switchUuid}) {
|
||||
assert(!(isFileTransfer && isPortForward), 'more than one connect type');
|
||||
if (isFileTransfer) {
|
||||
connType = ConnType.fileTransfer;
|
||||
@@ -1305,19 +1307,23 @@ class FFI {
|
||||
}
|
||||
// ignore: unused_local_variable
|
||||
final addRes = bind.sessionAddSync(
|
||||
id: id, isFileTransfer: isFileTransfer, isPortForward: isPortForward);
|
||||
id: id,
|
||||
isFileTransfer: isFileTransfer,
|
||||
isPortForward: isPortForward,
|
||||
switchUuid: switchUuid ?? "",
|
||||
);
|
||||
final stream = bind.sessionStart(id: id);
|
||||
final cb = ffiModel.startEventListener(id);
|
||||
() async {
|
||||
await for (final message in stream) {
|
||||
if (message is Event) {
|
||||
if (message is EventToUI_Event) {
|
||||
try {
|
||||
Map<String, dynamic> event = json.decode(message.field0);
|
||||
await cb(event);
|
||||
} catch (e) {
|
||||
debugPrint('json.decode fail1(): $e, ${message.field0}');
|
||||
}
|
||||
} else if (message is Rgba) {
|
||||
} else if (message is EventToUI_Rgba) {
|
||||
imageModel.onRgba(message.field0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,6 +601,7 @@ class Client {
|
||||
bool restart = false;
|
||||
bool recording = false;
|
||||
bool disconnected = false;
|
||||
bool fromSwitch = false;
|
||||
|
||||
RxBool hasUnreadChatMessage = false.obs;
|
||||
|
||||
@@ -621,6 +622,7 @@ class Client {
|
||||
restart = json['restart'];
|
||||
recording = json['recording'];
|
||||
disconnected = json['disconnected'];
|
||||
fromSwitch = json['from_switch'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -638,6 +640,7 @@ class Client {
|
||||
data['restart'] = restart;
|
||||
data['recording'] = recording;
|
||||
data['disconnected'] = disconnected;
|
||||
data['from_switch'] = fromSwitch;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,13 @@ class RustDeskMultiWindowManager {
|
||||
int? _fileTransferWindowId;
|
||||
int? _portForwardWindowId;
|
||||
|
||||
Future<dynamic> newRemoteDesktop(String remoteId) async {
|
||||
final msg =
|
||||
jsonEncode({"type": WindowType.RemoteDesktop.index, "id": remoteId});
|
||||
Future<dynamic> newRemoteDesktop(String remoteId,
|
||||
{String? switch_uuid}) async {
|
||||
final msg = jsonEncode({
|
||||
"type": WindowType.RemoteDesktop.index,
|
||||
"id": remoteId,
|
||||
"switch_uuid": switch_uuid ?? ""
|
||||
});
|
||||
|
||||
try {
|
||||
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
||||
|
||||
Reference in New Issue
Block a user