mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Feat: Windows connect to a specific user session (#6825)
* feat windows connect to specific user session Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * fix import Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * fix multiple user session fields Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * fix build Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * fix build Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * fix file transfer Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * fix text color on light theme Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * feat windows connect to specific user session code changes and sciter support Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * update texts Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * fix sciter selected user session Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * add translations Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * Use Y,N options * feat windows specific user code changes Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * Update dialog.dart * Update connection.rs * Update connection.rs * feat windows specific user code changes Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * fix sciter Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * use lr.union Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * remove unused peer options Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * select user only when authorised and no existing connection Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * check for multiple users only once Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * optimise and add check for client version Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * use misc option message Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * update rdp user session proto Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * fix show cm on user session Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * Update pl.rs * update on_message Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * fix cm Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * remove user_session_id Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * fix cm Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> * fix multiple connections Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com> --------- Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>
This commit is contained in:
@@ -1861,3 +1861,106 @@ void enter2FaDialog(
|
||||
onCancel: cancel);
|
||||
});
|
||||
}
|
||||
|
||||
void showWindowsSessionsDialog(
|
||||
String type,
|
||||
String title,
|
||||
String text,
|
||||
OverlayDialogManager dialogManager,
|
||||
SessionID sessionId,
|
||||
String peerId,
|
||||
String sessions) {
|
||||
List<String> sessionsList = sessions.split(',');
|
||||
Map<String, String> sessionMap = {};
|
||||
for (var session in sessionsList) {
|
||||
var sessionInfo = session.split('-');
|
||||
if (sessionInfo.isNotEmpty) {
|
||||
sessionMap[sessionInfo[0]] = sessionInfo[1];
|
||||
}
|
||||
}
|
||||
String selectedUserValue = sessionMap.keys.first;
|
||||
dialogManager.dismissAll();
|
||||
dialogManager.show((setState, close, context) {
|
||||
onConnect() {
|
||||
bind.sessionReconnect(
|
||||
sessionId: sessionId,
|
||||
forceRelay: false,
|
||||
userSessionId: selectedUserValue);
|
||||
dialogManager.dismissAll();
|
||||
dialogManager.showLoading(translate('Connecting...'),
|
||||
onCancel: closeConnection);
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: null,
|
||||
content: msgboxContent(type, title, text),
|
||||
actions: [
|
||||
SessionsDropdown(peerId, sessionId, sessionMap, (value) {
|
||||
setState(() {
|
||||
selectedUserValue = value;
|
||||
});
|
||||
}),
|
||||
dialogButton('Connect', onPressed: onConnect, isOutline: false),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
class SessionsDropdown extends StatefulWidget {
|
||||
final String peerId;
|
||||
final SessionID sessionId;
|
||||
final Map<String, String> sessions;
|
||||
final Function(String) onValueChanged;
|
||||
|
||||
SessionsDropdown(
|
||||
this.peerId, this.sessionId, this.sessions, this.onValueChanged);
|
||||
|
||||
@override
|
||||
_SessionsDropdownState createState() => _SessionsDropdownState();
|
||||
}
|
||||
|
||||
class _SessionsDropdownState extends State<SessionsDropdown> {
|
||||
late String selectedValue;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
selectedValue = widget.sessions.keys.first;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: 300,
|
||||
child: DropdownButton<String>(
|
||||
value: selectedValue,
|
||||
isExpanded: true,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
items: widget.sessions.entries.map((entry) {
|
||||
return DropdownMenuItem(
|
||||
value: entry.key,
|
||||
child: Text(
|
||||
entry.value,
|
||||
style: TextStyle(
|
||||
color: MyTheme.currentThemeMode() == ThemeMode.dark
|
||||
? Colors.white
|
||||
: MyTheme.dark,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
setState(() {
|
||||
selectedValue = value;
|
||||
});
|
||||
widget.onValueChanged(value);
|
||||
}
|
||||
},
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
|
||||
import 'package:flutter_hbb/models/file_model.dart';
|
||||
import 'package:flutter_hbb/models/platform_model.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:toggle_switch/toggle_switch.dart';
|
||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||
|
||||
@@ -245,6 +245,8 @@ class FfiModel with ChangeNotifier {
|
||||
var name = evt['name'];
|
||||
if (name == 'msgbox') {
|
||||
handleMsgBox(evt, sessionId, peerId);
|
||||
} else if (name == 'set_multiple_user_session') {
|
||||
handleMultipleUserSession(evt, sessionId, peerId);
|
||||
} else if (name == 'peer_info') {
|
||||
handlePeerInfo(evt, peerId, false);
|
||||
} else if (name == 'sync_peer_info') {
|
||||
@@ -488,6 +490,19 @@ class FfiModel with ChangeNotifier {
|
||||
dialogManager.dismissByTag(tag);
|
||||
}
|
||||
|
||||
handleMultipleUserSession(
|
||||
Map<String, dynamic> evt, SessionID sessionId, String peerId) {
|
||||
if (parent.target == null) return;
|
||||
final dialogManager = parent.target!.dialogManager;
|
||||
final sessions = evt['user_sessions'];
|
||||
final title = translate('Multiple active user sessions found');
|
||||
final text = translate('Please select the user you want to connect to');
|
||||
final type = "";
|
||||
|
||||
showWindowsSessionsDialog(
|
||||
type, title, text, dialogManager, sessionId, peerId, sessions);
|
||||
}
|
||||
|
||||
/// Handle the message box event based on [evt] and [id].
|
||||
handleMsgBox(Map<String, dynamic> evt, SessionID sessionId, String peerId) {
|
||||
if (parent.target == null) return;
|
||||
@@ -549,7 +564,8 @@ class FfiModel with ChangeNotifier {
|
||||
|
||||
void reconnect(OverlayDialogManager dialogManager, SessionID sessionId,
|
||||
bool forceRelay) {
|
||||
bind.sessionReconnect(sessionId: sessionId, forceRelay: forceRelay);
|
||||
bind.sessionReconnect(
|
||||
sessionId: sessionId, forceRelay: forceRelay, userSessionId: "");
|
||||
clearPermissions();
|
||||
dialogManager.dismissAll();
|
||||
dialogManager.showLoading(translate('Connecting...'),
|
||||
|
||||
Reference in New Issue
Block a user