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:
Sahil Yeole
2024-02-14 21:29:17 +05:30
committed by GitHub
parent 236687ae53
commit 4bf3764b5d
55 changed files with 607 additions and 22 deletions

View File

@@ -461,3 +461,18 @@ div#msgbox div.set-password input {
div#msgbox #error {
color: red;
}
div.user-session .title {
font-size: 1.2em;
margin-bottom: 2em;
}
div.user-session select {
width: 98%;
height: 2em;
border-radius: 0.5em;
border: color(border) solid 1px;
background: color(bg);
color: color(text);
padding-left: 0.5em;
}

View File

@@ -304,7 +304,21 @@ function msgbox(type, title, content, link="", callback=null, height=180, width=
return;
}
};
}
} else if (type === "multiple-sessions") {
var parts = content.split("-");
var ids = parts[0].split(",");
var names = parts[1].split(",");
var sessionData = [];
for (var i = 0; i < ids.length; i++) {
sessionData.push({ id: ids[i], name: names[i] });
}
content = <MultipleSessionComponent sessions={sessionData} />;
callback = function () {
retryConnect();
return;
};
height += 50;
}
last_msgbox_tag = type + "-" + title + "-" + content + "-" + link;
$(#msgbox).content(<MsgboxComponent width={width} height={height} autoLogin={autoLogin} type={type} title={title} content={content} link={link} remember={remember} callback={callback} contentStyle={contentStyle} hasRetry={hasRetry} />);
}
@@ -339,7 +353,7 @@ handler.msgbox_retry = function(type, title, text, link, hasRetry) {
function retryConnect(cancelTimer=false) {
if (cancelTimer) self.timer(0, retryConnect);
if (!is_port_forward) connecting();
handler.reconnect(false);
handler.reconnect(false, "");
}
/******************** end of msgbox ****************************************/
@@ -458,3 +472,37 @@ function awake() {
view.focus = self;
}
class MultipleSessionComponent extends Reactor.Component {
this var sessions = [];
this var selectedSessionId = null;
this var sessionlength = 0;
this var messageText = translate("Please select the user you want to connect to");
function this(params) {
if (params && params.sessions) {
this.sessions = params.sessions;
this.selectedSessionId = params.sessions[0].id;
this.sessions.map(session => {
this.sessionlength += session.name.length;
});
}
handler.set_selected_user_session_id(this.selectedSessionId);
}
function render() {
return <div .user-session>
<div .title>{this.messageText}</div>
<select>
{this.sessions.map(session =>
<option value={session.id}>{session.name}</option>
)}
</select>
</div>;
}
event change {
var selectedSessionName = this.value.substr(this.messageText.length + this.sessionlength);
this.selectedSessionId = this.sessions.find(session => session.name == selectedSessionName).id;
handler.set_selected_user_session_id(this.selectedSessionId);
}
}

View File

@@ -527,6 +527,10 @@ handler.updateDisplays = function(v) {
}
}
handler.setMultipleUserSession = function(usid,uname) {
msgbox("multiple-sessions", translate("Multiple active user sessions found"), usid+"-"+uname, "", function(res) {});
}
function updatePrivacyMode() {
var el = $(li#privacy-mode);
if (el) {

View File

@@ -259,6 +259,15 @@ impl InvokeUiSession for SciterHandler {
// Ignore for sciter version.
}
fn set_multiple_user_session(&self, sessions: Vec<hbb_common::message_proto::RdpUserSession>) {
let formatted_sessions: Vec<String> = sessions.iter()
.map(|session| format!("{}-{}", session.user_session_id, session.user_name))
.collect();
let u_sids: String = formatted_sessions.iter().map(|s| s.split("-").next().unwrap().to_string()).collect::<Vec<String>>().join(",");
let u_names:String = formatted_sessions.iter().map(|s| s.split("-").nth(1).unwrap().to_string()).collect::<Vec<String>>().join(",");
self.call("setMultipleUserSession", &make_args!(u_sids, u_names));
}
fn on_connected(&self, conn_type: ConnType) {
match conn_type {
ConnType::RDP => {}
@@ -346,6 +355,7 @@ impl sciter::EventHandler for SciterSession {
}
fn detached(&mut self, _root: HELEMENT) {
self.set_selected_user_session_id("".to_string());
*self.element.lock().unwrap() = None;
self.sender.write().unwrap().take().map(|sender| {
sender.send(Data::Close).ok();
@@ -376,7 +386,7 @@ impl sciter::EventHandler for SciterSession {
let site = AssetPtr::adopt(ptr as *mut video_destination);
log::debug!("[video] start video");
*VIDEO.lock().unwrap() = Some(site);
self.reconnect(false);
self.reconnect(false, "".to_string());
}
}
BEHAVIOR_EVENTS::VIDEO_INITIALIZED => {
@@ -426,7 +436,7 @@ impl sciter::EventHandler for SciterSession {
fn transfer_file();
fn tunnel();
fn lock_screen();
fn reconnect(bool);
fn reconnect(bool, String);
fn get_chatbox();
fn get_icon();
fn get_home_dir();
@@ -477,6 +487,7 @@ impl sciter::EventHandler for SciterSession {
fn request_voice_call();
fn close_voice_call();
fn version_cmp(String, String);
fn set_selected_user_session_id(String);
}
}
@@ -580,6 +591,10 @@ impl SciterSession {
log::info!("size saved");
}
fn set_selected_user_session_id(&mut self, u_sid: String) {
self.lc.write().unwrap().selected_user_session_id = u_sid;
}
fn get_port_forwards(&mut self) -> Value {
let port_forwards = self.lc.read().unwrap().port_forwards.clone();
let mut v = Value::array(0);