tmp commit

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-03-30 10:48:18 +08:00
parent 9448e35b46
commit 3fd1da05f4
6 changed files with 92 additions and 12 deletions

View File

@ -625,7 +625,7 @@ _connectDialog(
osAccountWidget(), osAccountWidget(),
osUsernameController == null || passwordController == null osUsernameController == null || passwordController == null
? Offstage() ? Offstage()
: Container(height: 10), : Container(height: 12),
passwdWidget(), passwdWidget(),
]), ]),
actions: [ actions: [

View File

@ -639,7 +639,7 @@ class _ControlMenu extends StatelessWidget {
ffi: ffi, ffi: ffi,
menuChildren: [ menuChildren: [
requestElevation(), requestElevation(),
osPassword(), ffi.ffiModel.pi.is_headless ? osAccount() : osPassword(),
transferFile(context), transferFile(context),
tcpTunneling(context), tcpTunneling(context),
note(), note(),
@ -662,6 +662,72 @@ class _ControlMenu extends StatelessWidget {
onPressed: () => showRequestElevationDialog(id, ffi.dialogManager)); onPressed: () => showRequestElevationDialog(id, ffi.dialogManager));
} }
osAccount() {
return _MenuItemButton(
child: Text(translate('OS Account')),
trailingIcon: Transform.scale(scale: 0.8, child: Icon(Icons.edit)),
ffi: ffi,
onPressed: () => _showSetOSAccount(id, false, ffi.dialogManager));
}
_showSetOSAccount(
String id, bool login, OverlayDialogManager dialogManager) async {
final usernameController = TextEditingController();
final passwdController = TextEditingController();
var username =
await bind.sessionGetOption(id: id, arg: 'os-username') ?? '';
var password =
await bind.sessionGetOption(id: id, arg: 'os-password') ?? '';
usernameController.text = username;
passwdController.text = password;
dialogManager.show((setState, close) {
submit() {
final username = usernameController.text.trim();
final password = usernameController.text.trim();
bind.sessionPeerOption(id: id, name: 'os-username', value: username);
bind.sessionPeerOption(id: id, name: 'os-password', value: password);
close();
}
return CustomAlertDialog(
title: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.password_rounded, color: MyTheme.accent),
Text(translate('OS Password')).paddingOnly(left: 10),
],
),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
DialogTextField(
title: translate(DialogTextField.kUsernameTitle),
controller: usernameController,
prefixIcon: DialogTextField.kUsernameIcon,
errorText: null,
),
PasswordWidget(controller: passwdController),
],
),
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
onPressed: close,
isOutline: true,
),
dialogButton(
"OK",
icon: Icon(Icons.done_rounded),
onPressed: submit,
),
],
onSubmit: submit,
onCancel: close,
);
});
}
osPassword() { osPassword() {
return _MenuItemButton( return _MenuItemButton(
child: Text(translate('OS Password')), child: Text(translate('OS Password')),

View File

@ -1725,6 +1725,7 @@ class PeerInfo {
Map<String, dynamic> platform_additions = {}; Map<String, dynamic> platform_additions = {};
bool get is_wayland => platform_additions['is_wayland'] == true; bool get is_wayland => platform_additions['is_wayland'] == true;
bool get is_headless => platform_additions['headless'] == true;
} }
const canvasKey = 'canvas'; const canvasKey = 'canvas';

View File

@ -54,12 +54,12 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("empty_address_book_tip", "Oh dear, it appears that there are currently no peers listed in your address book."), ("empty_address_book_tip", "Oh dear, it appears that there are currently no peers listed in your address book."),
("identical_file_tip", "This file is identical with the peer's one."), ("identical_file_tip", "This file is identical with the peer's one."),
("show_monitors_tip", "Show monitors in toolbar."), ("show_monitors_tip", "Show monitors in toolbar."),
("enter_rustdesk_passwd_tip", "Enter RustDesk password."), ("enter_rustdesk_passwd_tip", "Enter RustDesk password"),
("remember_rustdesk_passwd_tip", "Remember RustDesk password."), ("remember_rustdesk_passwd_tip", "Remember RustDesk password"),
("login_linux_tip", "Login to remote Linux account."), ("login_linux_tip", "Login to remote Linux account"),
("login_linux_tooltip_tip", "You need to login to remote Linux account to enable a X desktop session."), ("login_linux_tooltip_tip", "You need to login to remote Linux account to enable a X desktop session"),
("verify_rustdesk_password_tip", "Veryfy RustDesk password."), ("verify_rustdesk_password_tip", "Veryfy RustDesk password"),
("remember_account_tip", "Remember this account."), ("remember_account_tip", "Remember this account"),
("remember_password_tip", "Remember password."), ("remember_password_tip", "Remember password"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -80,6 +80,15 @@ pub fn try_start_x_session(username: &str, password: &str) -> ResultType<(String
} }
} }
#[inline]
pub fn is_headless() -> bool {
DESKTOP_MANAGER
.lock()
.unwrap()
.as_ref()
.map_or(false, |manager| manager.x11_username.is_empty())
}
pub fn get_username() -> String { pub fn get_username() -> String {
match &*DESKTOP_MANAGER.lock().unwrap() { match &*DESKTOP_MANAGER.lock().unwrap() {
Some(manager) => { Some(manager) => {

View File

@ -3,6 +3,8 @@ use super::{input_service::*, *};
use crate::clipboard_file::*; use crate::clipboard_file::*;
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
use crate::common::update_clipboard; use crate::common::update_clipboard;
#[cfg(target_os = "linux")]
use crate::platform::linux_desktop_manager;
#[cfg(windows)] #[cfg(windows)]
use crate::portable_service::client as portable_client; use crate::portable_service::client as portable_client;
use crate::{ use crate::{
@ -866,6 +868,9 @@ impl Connection {
if crate::platform::current_is_wayland() { if crate::platform::current_is_wayland() {
platform_additions.insert("is_wayland".into(), json!(true)); platform_additions.insert("is_wayland".into(), json!(true));
} }
if linux_desktop_manager::is_headless() {
platform_additions.insert("headless".into(), json!(true));
}
if !platform_additions.is_empty() { if !platform_additions.is_empty() {
pi.platform_additions = pi.platform_additions =
serde_json::to_string(&platform_additions).unwrap_or("".into()); serde_json::to_string(&platform_additions).unwrap_or("".into());
@ -1074,7 +1079,7 @@ impl Connection {
fn try_start_desktop(_username: &str, _passsword: &str) -> String { fn try_start_desktop(_username: &str, _passsword: &str) -> String {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
if _username.is_empty() { if _username.is_empty() {
let username = crate::platform::linux_desktop_manager::get_username(); let username = linux_desktop_manager::get_username();
if username.is_empty() { if username.is_empty() {
LOGIN_MSG_XSESSION_NOT_READY LOGIN_MSG_XSESSION_NOT_READY
} else { } else {
@ -1082,8 +1087,7 @@ impl Connection {
} }
.to_owned() .to_owned()
} else { } else {
match crate::platform::linux_desktop_manager::try_start_x_session(_username, _passsword) match linux_desktop_manager::try_start_x_session(_username, _passsword) {
{
Ok((username, x11_ready)) => { Ok((username, x11_ready)) => {
if x11_ready { if x11_ready {
if _username != username { if _username != username {