Skip to content

Commit

Permalink
Merge branch 'rustdesk:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
flusheDData authored Oct 24, 2024
2 parents 162e323 + b35b480 commit 318913c
Show file tree
Hide file tree
Showing 82 changed files with 859 additions and 445 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions flutter/lib/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2304,16 +2304,19 @@ connectMainDesktop(String id,
required bool isRDP,
bool? forceRelay,
String? password,
String? connToken,
bool? isSharedPassword}) async {
if (isFileTransfer) {
await rustDeskWinManager.newFileTransfer(id,
password: password,
isSharedPassword: isSharedPassword,
connToken: connToken,
forceRelay: forceRelay);
} else if (isTcpTunneling || isRDP) {
await rustDeskWinManager.newPortForward(id, isRDP,
password: password,
isSharedPassword: isSharedPassword,
connToken: connToken,
forceRelay: forceRelay);
} else {
await rustDeskWinManager.newRemoteDesktop(id,
Expand All @@ -2333,6 +2336,7 @@ connect(BuildContext context, String id,
bool isRDP = false,
bool forceRelay = false,
String? password,
String? connToken,
bool? isSharedPassword}) async {
if (id == '') return;
if (!isDesktop || desktopType == DesktopType.main) {
Expand Down Expand Up @@ -2374,6 +2378,7 @@ connect(BuildContext context, String id,
'password': password,
'isSharedPassword': isSharedPassword,
'forceRelay': forceRelay,
'connToken': connToken,
});
}
} else {
Expand Down
18 changes: 15 additions & 3 deletions flutter/lib/common/widgets/toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,32 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
child: Text(translate('Reset canvas')),
onPressed: () => ffi.cursorModel.reset()));
}

connectWithToken(
{required bool isFileTransfer, required bool isTcpTunneling}) {
final connToken = bind.sessionGetConnToken(sessionId: ffi.sessionId);
connect(context, id,
isFileTransfer: isFileTransfer,
isTcpTunneling: isTcpTunneling,
connToken: connToken);
}

// transferFile
if (isDesktop) {
v.add(
TTextMenu(
child: Text(translate('Transfer file')),
onPressed: () => connect(context, id, isFileTransfer: true)),
onPressed: () =>
connectWithToken(isFileTransfer: true, isTcpTunneling: false)),
);
}
// tcpTunneling
if (isDesktop) {
v.add(
TTextMenu(
child: Text(translate('TCP tunneling')),
onPressed: () => connect(context, id, isTcpTunneling: true)),
onPressed: () =>
connectWithToken(isFileTransfer: false, isTcpTunneling: true)),
);
}
// note
Expand All @@ -183,7 +195,7 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
(pi.platform == kPeerPlatformLinux || pi.sasEnabled)) {
v.add(
TTextMenu(
child: Text('${translate("Insert")} Ctrl + Alt + Del'),
child: Text('${translate("Insert Ctrl + Alt + Del")}'),
onPressed: () => bind.sessionCtrlAltDel(sessionId: sessionId)),
);
}
Expand Down
1 change: 1 addition & 0 deletions flutter/lib/consts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const String kOptionAllowAutoDisconnect = "allow-auto-disconnect";
const String kOptionAutoDisconnectTimeout = "auto-disconnect-timeout";
const String kOptionEnableHwcodec = "enable-hwcodec";
const String kOptionAllowAutoRecordIncoming = "allow-auto-record-incoming";
const String kOptionAllowAutoRecordOutgoing = "allow-auto-record-outgoing";
const String kOptionVideoSaveDirectory = "video-save-directory";
const String kOptionAccessMode = "access-mode";
const String kOptionEnableKeyboard = "enable-keyboard";
Expand Down
1 change: 1 addition & 0 deletions flutter/lib/desktop/pages/desktop_home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
isRDP: call.arguments['isRDP'],
password: call.arguments['password'],
forceRelay: call.arguments['forceRelay'],
connToken: call.arguments['connToken'],
);
} else if (call.method == kWindowEventMoveTabToNewWindow) {
final args = call.arguments.split(',');
Expand Down
94 changes: 52 additions & 42 deletions flutter/lib/desktop/pages/desktop_setting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,18 @@ class _GeneralState extends State<_General> {
bool root_dir_exists = map['root_dir_exists']!;
bool user_dir_exists = map['user_dir_exists']!;
return _Card(title: 'Recording', children: [
_OptionCheckBox(context, 'Automatically record incoming sessions',
kOptionAllowAutoRecordIncoming),
if (showRootDir)
if (!bind.isOutgoingOnly())
_OptionCheckBox(context, 'Automatically record incoming sessions',
kOptionAllowAutoRecordIncoming),
if (!bind.isIncomingOnly())
_OptionCheckBox(context, 'Automatically record outgoing sessions',
kOptionAllowAutoRecordOutgoing,
isServer: false),
if (showRootDir && !bind.isOutgoingOnly())
Row(
children: [
Text('${translate("Incoming")}:'),
Text(
'${translate(bind.isIncomingOnly() ? "Directory" : "Incoming")}:'),
Expanded(
child: GestureDetector(
onTap: root_dir_exists
Expand All @@ -597,45 +603,49 @@ class _GeneralState extends State<_General> {
),
],
).marginOnly(left: _kContentHMargin),
Row(
children: [
Text('${translate(showRootDir ? "Outgoing" : "Directory")}:'),
Expanded(
child: GestureDetector(
onTap: user_dir_exists
? () => launchUrl(Uri.file(user_dir))
: null,
child: Text(
user_dir,
softWrap: true,
style: user_dir_exists
? const TextStyle(decoration: TextDecoration.underline)
if (!(showRootDir && bind.isIncomingOnly()))
Row(
children: [
Text(
'${translate((showRootDir && !bind.isOutgoingOnly()) ? "Outgoing" : "Directory")}:'),
Expanded(
child: GestureDetector(
onTap: user_dir_exists
? () => launchUrl(Uri.file(user_dir))
: null,
)).marginOnly(left: 10),
),
ElevatedButton(
onPressed: isOptionFixed(kOptionVideoSaveDirectory)
? null
: () async {
String? initialDirectory;
if (await Directory.fromUri(Uri.directory(user_dir))
.exists()) {
initialDirectory = user_dir;
}
String? selectedDirectory =
await FilePicker.platform.getDirectoryPath(
initialDirectory: initialDirectory);
if (selectedDirectory != null) {
await bind.mainSetOption(
key: kOptionVideoSaveDirectory,
value: selectedDirectory);
setState(() {});
}
},
child: Text(translate('Change')))
.marginOnly(left: 5),
],
).marginOnly(left: _kContentHMargin),
child: Text(
user_dir,
softWrap: true,
style: user_dir_exists
? const TextStyle(
decoration: TextDecoration.underline)
: null,
)).marginOnly(left: 10),
),
ElevatedButton(
onPressed: isOptionFixed(kOptionVideoSaveDirectory)
? null
: () async {
String? initialDirectory;
if (await Directory.fromUri(
Uri.directory(user_dir))
.exists()) {
initialDirectory = user_dir;
}
String? selectedDirectory =
await FilePicker.platform.getDirectoryPath(
initialDirectory: initialDirectory);
if (selectedDirectory != null) {
await bind.mainSetLocalOption(
key: kOptionVideoSaveDirectory,
value: selectedDirectory);
setState(() {});
}
},
child: Text(translate('Change')))
.marginOnly(left: 5),
],
).marginOnly(left: _kContentHMargin),
]);
});
}
Expand Down
3 changes: 3 additions & 0 deletions flutter/lib/desktop/pages/file_manager_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ class FileManagerPage extends StatefulWidget {
required this.password,
required this.isSharedPassword,
this.tabController,
this.connToken,
this.forceRelay})
: super(key: key);
final String id;
final String? password;
final bool? isSharedPassword;
final bool? forceRelay;
final String? connToken;
final DesktopTabController? tabController;

@override
Expand All @@ -90,6 +92,7 @@ class _FileManagerPageState extends State<FileManagerPage>
isFileTransfer: true,
password: widget.password,
isSharedPassword: widget.isSharedPassword,
connToken: widget.connToken,
forceRelay: widget.forceRelay);
WidgetsBinding.instance.addPostFrameCallback((_) {
_ffi.dialogManager
Expand Down
4 changes: 3 additions & 1 deletion flutter/lib/desktop/pages/file_manager_tab_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
isSharedPassword: params['isSharedPassword'],
tabController: tabController,
forceRelay: params['forceRelay'],
connToken: params['connToken'],
)));
}

Expand All @@ -56,7 +57,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
super.initState();

rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
print(
debugPrint(
"[FileTransfer] call ${call.method} with args ${call.arguments} from window $fromWindowId to ${windowId()}");
// for simplify, just replace connectionId
if (call.method == kWindowEventNewFileTransfer) {
Expand All @@ -76,6 +77,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
isSharedPassword: args['isSharedPassword'],
tabController: tabController,
forceRelay: args['forceRelay'],
connToken: args['connToken'],
)));
} else if (call.method == "onDestroy") {
tabController.clear();
Expand Down
3 changes: 3 additions & 0 deletions flutter/lib/desktop/pages/port_forward_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ class PortForwardPage extends StatefulWidget {
required this.isRDP,
required this.isSharedPassword,
this.forceRelay,
this.connToken,
}) : super(key: key);
final String id;
final String? password;
final DesktopTabController tabController;
final bool isRDP;
final bool? forceRelay;
final bool? isSharedPassword;
final String? connToken;

@override
State<PortForwardPage> createState() => _PortForwardPageState();
Expand All @@ -62,6 +64,7 @@ class _PortForwardPageState extends State<PortForwardPage>
password: widget.password,
isSharedPassword: widget.isSharedPassword,
forceRelay: widget.forceRelay,
connToken: widget.connToken,
isRdp: widget.isRDP);
Get.put<FFI>(_ffi, tag: 'pf_${widget.id}');
debugPrint("Port forward page init success with id ${widget.id}");
Expand Down
2 changes: 2 additions & 0 deletions flutter/lib/desktop/pages/port_forward_tab_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
tabController: tabController,
isRDP: isRDP,
forceRelay: params['forceRelay'],
connToken: params['connToken'],
)));
}

Expand Down Expand Up @@ -82,6 +83,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
isRDP: isRDP,
tabController: tabController,
forceRelay: args['forceRelay'],
connToken: args['connToken'],
)));
} else if (call.method == "onDestroy") {
tabController.clear();
Expand Down
3 changes: 2 additions & 1 deletion flutter/lib/desktop/pages/remote_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class _RemotePageState extends State<RemotePage>
_ffi.imageModel.addCallbackOnFirstImage((String peerId) {
showKBLayoutTypeChooserIfNeeded(
_ffi.ffiModel.pi.platform, _ffi.dialogManager);
_ffi.recordingModel
.updateStatus(bind.sessionGetIsRecording(sessionId: _ffi.sessionId));
});
_ffi.start(
widget.id,
Expand Down Expand Up @@ -253,7 +255,6 @@ class _RemotePageState extends State<RemotePage>
_ffi.dialogManager.hideMobileActionsOverlay();
_ffi.imageModel.disposeImage();
_ffi.cursorModel.disposeImages();
_ffi.recordingModel.onClose();
_rawKeyFocusNode.dispose();
await _ffi.close(closeSession: closeSession);
_timer?.cancel();
Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/desktop/pages/remote_tab_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
RemoteCountState.find().value = tabController.length;

Future<dynamic> _remoteMethodHandler(call, fromWindowId) async {
print(
debugPrint(
"[Remote Page] call ${call.method} with args ${call.arguments} from window $fromWindowId");

dynamic returnValue;
Expand Down
3 changes: 1 addition & 2 deletions flutter/lib/desktop/widgets/remote_toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1924,8 +1924,7 @@ class _RecordMenu extends StatelessWidget {
var ffi = Provider.of<FfiModel>(context);
var recordingModel = Provider.of<RecordingModel>(context);
final visible =
(recordingModel.start || ffi.permissions['recording'] != false) &&
ffi.pi.currentDisplay != kAllDisplayValue;
(recordingModel.start || ffi.permissions['recording'] != false);
if (!visible) return Offstage();
return _IconMenuButton(
assetName: 'assets/rec.svg',
Expand Down
9 changes: 8 additions & 1 deletion flutter/lib/mobile/pages/remote_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ class _RemotePageState extends State<RemotePage> {
gFFI.chatModel
.changeCurrentKey(MessageKey(widget.id, ChatModel.clientModeID));
_blockableOverlayState.applyFfi(gFFI);
gFFI.imageModel.addCallbackOnFirstImage((String peerId) {
gFFI.recordingModel
.updateStatus(bind.sessionGetIsRecording(sessionId: gFFI.sessionId));
if (gFFI.recordingModel.start) {
showToast(translate('Automatically record outgoing sessions'));
}
});
}

@override
Expand Down Expand Up @@ -207,7 +214,7 @@ class _RemotePageState extends State<RemotePage> {
}

void _handleNonIOSSoftKeyboardInput(String newValue) {
_composingTimer?.cancel();
_composingTimer?.cancel();
if (_textController.value.isComposingRangeValid) {
_composingTimer = Timer(Duration(milliseconds: 25), () {
_handleNonIOSSoftKeyboardInput(_textController.value.text);
Expand Down
Loading

0 comments on commit 318913c

Please sign in to comment.