fix peer widget overflow and tile bug, add more sync ffi

This commit is contained in:
rustdesk 2022-09-22 15:59:51 +08:00
parent f5b7c34c81
commit aeeffad33b
3 changed files with 160 additions and 48 deletions

96
Cargo.lock generated
View File

@ -58,6 +58,21 @@ dependencies = [
"atomic", "atomic",
] ]
[[package]]
name = "alloc-no-stdlib"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
[[package]]
name = "alloc-stdlib"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece"
dependencies = [
"alloc-no-stdlib",
]
[[package]] [[package]]
name = "alsa" name = "alsa"
version = "0.6.0" version = "0.6.0"
@ -420,6 +435,27 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "brotli"
version = "3.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68"
dependencies = [
"alloc-no-stdlib",
"alloc-stdlib",
"brotli-decompressor",
]
[[package]]
name = "brotli-decompressor"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59ad2d4653bf5ca36ae797b1f4bb4dbddb60ce49ca4aed8a2ce4829f60425b80"
dependencies = [
"alloc-no-stdlib",
"alloc-stdlib",
]
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.11.0" version = "3.11.0"
@ -1359,6 +1395,19 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]]
name = "embed-resource"
version = "1.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecc24ff8d764818e9ab17963b0593c535f077a513f565e75e4352d758bc4d8c0"
dependencies = [
"cc",
"rustc_version 0.4.0",
"toml",
"vswhom",
"winreg 0.10.1",
]
[[package]] [[package]]
name = "encoding_rs" name = "encoding_rs"
version = "0.8.31" version = "0.8.31"
@ -1548,7 +1597,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e1c54951450cbd39f3dbcf1005ac413b49487dabf18a720ad2383eccfeffb92" checksum = "1e1c54951450cbd39f3dbcf1005ac413b49487dabf18a720ad2383eccfeffb92"
dependencies = [ dependencies = [
"memoffset", "memoffset",
"rustc_version", "rustc_version 0.3.3",
] ]
[[package]] [[package]]
@ -2822,6 +2871,12 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "md5"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
[[package]] [[package]]
name = "memalloc" name = "memalloc"
version = "0.1.0" version = "0.1.0"
@ -4230,6 +4285,15 @@ dependencies = [
"semver 0.11.0", "semver 0.11.0",
] ]
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver 1.0.13",
]
[[package]] [[package]]
name = "rustdesk" name = "rustdesk"
version = "1.2.0" version = "1.2.0"
@ -4305,6 +4369,16 @@ dependencies = [
"wol-rs", "wol-rs",
] ]
[[package]]
name = "rustdesk-portable-packer"
version = "0.1.0"
dependencies = [
"brotli",
"dirs",
"embed-resource",
"md5",
]
[[package]] [[package]]
name = "rustfft" name = "rustfft"
version = "6.0.1" version = "6.0.1"
@ -5374,6 +5448,26 @@ dependencies = [
"thiserror", "thiserror",
] ]
[[package]]
name = "vswhom"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b"
dependencies = [
"libc",
"vswhom-sys",
]
[[package]]
name = "vswhom-sys"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22025f6d8eb903ebf920ea6933b70b1e495be37e2cb4099e62c80454aaf57c39"
dependencies = [
"cc",
"libc",
]
[[package]] [[package]]
name = "waker-fn" name = "waker-fn"
version = "1.1.0" version = "1.1.0"

View File

@ -128,7 +128,8 @@ class _PeerCardState extends State<_PeerCard>
Widget _buildPeerTile( Widget _buildPeerTile(
BuildContext context, Peer peer, Rx<BoxDecoration?> deco) { BuildContext context, Peer peer, Rx<BoxDecoration?> deco) {
final greyStyle = final greyStyle =
TextStyle(fontSize: 12, color: MyTheme.color(context).lighterText); TextStyle(fontSize: 11, color: MyTheme.color(context).lighterText);
final alias = bind.mainGetPeerOptionSync(id: peer.id, key: 'alias');
return Obx( return Obx(
() => Container( () => Container(
foregroundDecoration: deco.value, foregroundDecoration: deco.value,
@ -150,7 +151,6 @@ class _PeerCardState extends State<_PeerCard>
children: [ children: [
Expanded( Expanded(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
Row(children: [ Row(children: [
Padding( Padding(
@ -160,42 +160,21 @@ class _PeerCardState extends State<_PeerCard>
backgroundColor: peer.online backgroundColor: peer.online
? Colors.green ? Colors.green
: Colors.yellow)), : Colors.yellow)),
Text( Expanded(
formatID(peer.id), child: Text(
alias.isEmpty ? formatID(peer.id) : alias,
style: style:
const TextStyle(fontWeight: FontWeight.w400), const TextStyle(fontWeight: FontWeight.w400),
), overflow: TextOverflow.ellipsis,
)),
]), ]),
Align( Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: FutureBuilder<String>( child: Text(
future: bind.mainGetPeerOption( '${peer.username}@${peer.hostname}',
id: peer.id, key: 'alias'), style: greyStyle,
builder: (_, snapshot) { textAlign: TextAlign.start,
if (snapshot.hasData) { overflow: TextOverflow.ellipsis,
final name = snapshot.data!.isEmpty
? '${peer.username}@${peer.hostname}'
: snapshot.data!;
return Tooltip(
message: name,
waitDuration: const Duration(seconds: 1),
child: Text(
name,
style: greyStyle,
textAlign: TextAlign.start,
overflow: TextOverflow.ellipsis,
),
);
} else {
// alias has not arrived
return Text(
'${peer.username}@${peer.hostname}',
style: greyStyle,
textAlign: TextAlign.start,
overflow: TextOverflow.ellipsis,
);
}
},
), ),
), ),
], ],
@ -203,7 +182,7 @@ class _PeerCardState extends State<_PeerCard>
), ),
_actionMore(peer), _actionMore(peer),
], ],
).paddingSymmetric(horizontal: 4.0), ).paddingOnly(left: 10.0, top: 3.0),
), ),
) )
], ],
@ -272,7 +251,8 @@ class _PeerCardState extends State<_PeerCard>
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Row(children: [ Expanded(
child: Row(children: [
Padding( Padding(
padding: const EdgeInsets.fromLTRB(0, 4, 8, 4), padding: const EdgeInsets.fromLTRB(0, 4, 8, 4),
child: CircleAvatar( child: CircleAvatar(
@ -280,9 +260,12 @@ class _PeerCardState extends State<_PeerCard>
backgroundColor: peer.online backgroundColor: peer.online
? Colors.green ? Colors.green
: Colors.yellow)), : Colors.yellow)),
Text( Expanded(
peer.alias.isEmpty ? formatID(peer.id) : peer.alias) child: Text(
]).paddingSymmetric(vertical: 8), peer.alias.isEmpty ? formatID(peer.id) : peer.alias,
overflow: TextOverflow.ellipsis,
)),
]).paddingSymmetric(vertical: 8)),
_actionMore(peer), _actionMore(peer),
], ],
).paddingSymmetric(horizontal: 12.0), ).paddingSymmetric(horizontal: 12.0),

View File

@ -15,17 +15,18 @@ use hbb_common::{message_proto::Hash, ResultType};
use crate::flutter::{self, SESSIONS}; use crate::flutter::{self, SESSIONS};
use crate::start_server; use crate::start_server;
use crate::ui_interface;
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
use crate::ui_interface::get_sound_inputs; use crate::ui_interface::get_sound_inputs;
use crate::ui_interface::{ use crate::ui_interface::{
change_id, check_mouse_time, check_super_user_permission, discover, forget_password, self, change_id, check_mouse_time, check_super_user_permission, discover, forget_password,
get_api_server, get_app_name, get_async_job_status, get_connect_status, get_fav, get_id, get_api_server, get_app_name, get_async_job_status, get_connect_status, get_fav, get_id,
get_lan_peers, get_langs, get_license, get_local_option, get_mouse_time, get_option, get_lan_peers, get_langs, get_license, get_local_option, get_mouse_time, get_option,
get_options, get_peer, get_peer_option, get_socks, get_uuid, get_version, has_hwcodec, get_options, get_peer, get_peer_option, get_socks, get_uuid, get_version, has_hwcodec,
has_rendezvous_service, post_request, send_to_cm, set_local_option, set_option, set_options, has_rendezvous_service, is_can_screen_recording, is_installed, is_installed_daemon,
set_peer_option, set_permanent_password, set_socks, store_fav, test_if_valid_server, is_installed_lower_version, is_process_trusted, is_rdp_service_open, is_share_rdp,
update_temporary_password, using_public_server, post_request, send_to_cm, set_local_option, set_option, set_options, set_peer_option,
set_permanent_password, set_socks, store_fav, test_if_valid_server, update_temporary_password,
using_public_server,
}; };
use crate::{ use crate::{
client::file_trait::FileManager, client::file_trait::FileManager,
@ -557,10 +558,19 @@ pub fn main_get_peer_option(id: String, key: String) -> String {
get_peer_option(id, key) get_peer_option(id, key)
} }
pub fn main_get_peer_option_sync(id: String, key: String) -> SyncReturn<String> {
SyncReturn(get_peer_option(id, key))
}
pub fn main_set_peer_option(id: String, key: String, value: String) { pub fn main_set_peer_option(id: String, key: String, value: String) {
set_peer_option(id, key, value) set_peer_option(id, key, value)
} }
pub fn main_set_peer_option_sync(id: String, key: String, value: String) -> SyncReturn<bool> {
set_peer_option(id, key, value);
SyncReturn(true)
}
pub fn main_forget_password(id: String) { pub fn main_forget_password(id: String) {
forget_password(id) forget_password(id)
} }
@ -693,10 +703,7 @@ fn main_broadcast_message(data: &HashMap<&str, &str>) {
} }
pub fn main_change_theme(dark: String) { pub fn main_change_theme(dark: String) {
main_broadcast_message(&HashMap::from([ main_broadcast_message(&HashMap::from([("name", "theme"), ("dark", &dark)]));
("name", "theme"),
("dark", &dark),
]));
send_to_cm(&crate::ipc::Data::Theme(dark)); send_to_cm(&crate::ipc::Data::Theme(dark));
} }
@ -972,6 +979,34 @@ pub fn query_onlines(ids: Vec<String>) {
crate::rendezvous_mediator::query_online_states(ids, handle_query_onlines) crate::rendezvous_mediator::query_online_states(ids, handle_query_onlines)
} }
pub fn main_is_installed() -> SyncReturn<bool> {
SyncReturn(is_installed())
}
pub fn main_is_installed_lower_version() -> SyncReturn<bool> {
SyncReturn(is_installed_lower_version())
}
pub fn main_is_installed_daemon(prompt: bool) -> SyncReturn<bool> {
SyncReturn(is_installed_daemon(prompt))
}
pub fn main_is_process_trusted(prompt: bool) -> SyncReturn<bool> {
SyncReturn(is_process_trusted(prompt))
}
pub fn main_is_can_screen_recording(prompt: bool) -> SyncReturn<bool> {
SyncReturn(is_can_screen_recording(prompt))
}
pub fn main_is_share_rdp() -> SyncReturn<bool> {
SyncReturn(is_share_rdp())
}
pub fn main_is_rdp_service_open() -> SyncReturn<bool> {
SyncReturn(is_rdp_service_open())
}
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
pub mod server_side { pub mod server_side {
use jni::{ use jni::{