port forward ui

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-08-26 11:35:28 +08:00
parent 7b4a655eaf
commit 6ea16e4cdb
10 changed files with 769 additions and 29 deletions

View File

@@ -35,6 +35,7 @@ class RustDeskMultiWindowManager {
int? _remoteDesktopWindowId;
int? _fileTransferWindowId;
int? _portForwardWindowId;
Future<dynamic> new_remote_desktop(String remote_id) async {
final msg =
@@ -87,6 +88,34 @@ class RustDeskMultiWindowManager {
}
}
Future<dynamic> new_port_forward(String remote_id, bool isRDP) async {
final msg = jsonEncode({
"type": WindowType.PortForward.index,
"id": remote_id,
"isRDP": isRDP
});
try {
final ids = await DesktopMultiWindow.getAllSubWindowIds();
if (!ids.contains(_portForwardWindowId)) {
_portForwardWindowId = null;
}
} on Error {
_portForwardWindowId = null;
}
if (_portForwardWindowId == null) {
final portForwardController = await DesktopMultiWindow.createWindow(msg);
portForwardController
..setFrame(const Offset(0, 0) & const Size(1280, 720))
..center()
..setTitle("rustdesk - port forward")
..show();
_portForwardWindowId = portForwardController.windowId;
} else {
return call(WindowType.PortForward, "new_port_forward", msg);
}
}
Future<dynamic> call(WindowType type, String methodName, dynamic args) async {
int? windowId = findWindowByType(type);
if (windowId == null) {
@@ -104,7 +133,7 @@ class RustDeskMultiWindowManager {
case WindowType.FileTransfer:
return _fileTransferWindowId;
case WindowType.PortForward:
break;
return _portForwardWindowId;
case WindowType.Unknown:
break;
}
@@ -120,7 +149,7 @@ class RustDeskMultiWindowManager {
await Future.wait(WindowType.values.map((e) => closeWindows(e)));
}
Future<void> closeWindows(WindowType type) async {
Future<void> closeWindows(WindowType type) async {
if (type == WindowType.Main) {
// skip main window, use window manager instead
return;