mac help cards

two mac issues:
1) windows position not saved, position not got, win manager issue?
2) freeCache not found from custom cursor channel
This commit is contained in:
rustdesk 2022-11-29 22:00:27 +08:00
parent e13e0ab18f
commit 420dd9c9db
8 changed files with 136 additions and 58 deletions

View File

@ -42,7 +42,7 @@ class _ConnectionPageState extends State<ConnectionPage>
final RxBool _idInputFocused = false.obs; final RxBool _idInputFocused = false.obs;
final FocusNode _idFocusNode = FocusNode(); final FocusNode _idFocusNode = FocusNode();
var svcStopped = false.obs; var svcStopped = Get.find<RxBool>(tag: 'stop-service');
var svcStatusCode = 0.obs; var svcStatusCode = 0.obs;
var svcIsUsingPublicServer = true.obs; var svcIsUsingPublicServer = true.obs;
@ -67,7 +67,6 @@ class _ConnectionPageState extends State<ConnectionPage>
_idFocusNode.addListener(() { _idFocusNode.addListener(() {
_idInputFocused.value = _idFocusNode.hasFocus; _idInputFocused.value = _idFocusNode.hasFocus;
}); });
Get.put<RxBool>(svcStopped, tag: 'service-stop');
windowManager.addListener(this); windowManager.addListener(this);
} }
@ -75,7 +74,6 @@ class _ConnectionPageState extends State<ConnectionPage>
void dispose() { void dispose() {
_idController.dispose(); _idController.dispose();
_updateTimer?.cancel(); _updateTimer?.cancel();
Get.delete<RxBool>(tag: 'service-stop');
windowManager.removeListener(this); windowManager.removeListener(this);
super.dispose(); super.dispose();
} }
@ -296,7 +294,7 @@ class _ConnectionPageState extends State<ConnectionPage>
// stop // stop
Offstage( Offstage(
offstage: !svcStopped.value, offstage: !svcStopped.value,
child: GestureDetector( child: InkWell(
onTap: () async { onTap: () async {
bool checked = !bind.mainIsInstalled() || bool checked = !bind.mainIsInstalled() ||
await bind.mainCheckSuperUserPermission(); await bind.mainCheckSuperUserPermission();
@ -357,7 +355,6 @@ class _ConnectionPageState extends State<ConnectionPage>
} }
updateStatus() async { updateStatus() async {
svcStopped.value = await bind.mainGetOption(key: "stop-service") == "Y";
final status = final status =
jsonDecode(await bind.mainGetConnectStatus()) as Map<String, dynamic>; jsonDecode(await bind.mainGetConnectStatus()) as Map<String, dynamic>;
svcStatusCode.value = status["status_num"]; svcStatusCode.value = status["status_num"];

View File

@ -40,7 +40,12 @@ class _DesktopHomePageState extends State<DesktopHomePage>
@override @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
var updateUrl = ''; var updateUrl = '';
var systemError = '';
StreamSubscription? _uniLinksSubscription; StreamSubscription? _uniLinksSubscription;
var svcStopped = false.obs;
var watchIsCanScreenRecording = false;
var watchIsProcessTrust = false;
Timer? _updateTimer;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -317,13 +322,37 @@ class _DesktopHomePageState extends State<DesktopHomePage>
await launchUrl(url); await launchUrl(url);
}); });
} }
if (Platform.isMacOS) {} if (systemError.isNotEmpty) {
return buildInstallCard("", systemError, "", () {});
}
if (Platform.isMacOS) {
if (!bind.mainIsCanScreenRecording(prompt: false)) {
return buildInstallCard("Permissions", "config_screen", "Configure",
() async {
bind.mainIsCanScreenRecording(prompt: true);
watchIsCanScreenRecording = true;
}, help: 'Help', link: translate("doc_mac_permission"));
} else if (!bind.mainIsProcessTrusted(prompt: false)) {
return buildInstallCard("Permissions", "config_acc", "Configure",
() async {
bind.mainIsProcessTrusted(prompt: true);
watchIsProcessTrust = true;
}, help: 'Help', link: translate("doc_mac_permission"));
} else if (!svcStopped.value &&
bind.mainIsInstalled() &&
!bind.mainIsInstalledDaemon(prompt: false)) {
return buildInstallCard("", "install_daemon_tip", "Install", () async {
bind.mainIsInstalledDaemon(prompt: true);
});
}
}
if (bind.mainIsInstalledLowerVersion()) {} if (bind.mainIsInstalledLowerVersion()) {}
return Container(); return Container();
} }
Widget buildInstallCard(String title, String content, String btnText, Widget buildInstallCard(String title, String content, String btnText,
GestureTapCallback onPressed) { GestureTapCallback onPressed,
{String? help, String? link}) {
return Container( return Container(
margin: EdgeInsets.only(top: 20), margin: EdgeInsets.only(top: 20),
child: Container( child: Container(
@ -360,8 +389,13 @@ class _DesktopHomePageState extends State<DesktopHomePage>
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.normal, fontWeight: FontWeight.normal,
fontSize: 13), fontSize: 13),
).marginOnly(bottom: 20), ).marginOnly(bottom: 20)
Row(mainAxisAlignment: MainAxisAlignment.center, children: [ ] +
(btnText.isNotEmpty
? <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FixedWidthButton( FixedWidthButton(
width: 150, width: 150,
padding: 8, padding: 8,
@ -373,9 +407,24 @@ class _DesktopHomePageState extends State<DesktopHomePage>
radius: 10, radius: 10,
onTap: onPressed, onTap: onPressed,
) )
]), ])
], ]
)), : <Widget>[]) +
(help != null
? <Widget>[
Center(
child: InkWell(
onTap: () async =>
await launchUrl(Uri.parse(link!)),
child: Text(
translate(help),
style: TextStyle(
decoration: TextDecoration.underline,
color: Colors.white,
fontSize: 12),
)).marginOnly(top: 6)),
]
: <Widget>[]))),
); );
} }
@ -412,10 +461,36 @@ class _DesktopHomePageState extends State<DesktopHomePage>
void initState() { void initState() {
super.initState(); super.initState();
bind.mainStartGrabKeyboard(); bind.mainStartGrabKeyboard();
Timer(const Duration(seconds: 5), () async { _updateTimer = Timer.periodic(const Duration(seconds: 1), (timer) async {
updateUrl = await bind.mainGetSoftwareUpdateUrl(); final url = await bind.mainGetSoftwareUpdateUrl();
if (updateUrl.isNotEmpty) setState(() {}); if (updateUrl != url) {
updateUrl = url;
setState(() {});
}
final error = await bind.mainGetError();
if (systemError != error) {
systemError = error;
setState(() {});
}
final v = await bind.mainGetOption(key: "stop-service") == "Y";
if (v != svcStopped.value) {
svcStopped.value = v;
setState(() {});
}
if (watchIsCanScreenRecording) {
if (bind.mainIsCanScreenRecording(prompt: false)) {
watchIsCanScreenRecording = false;
setState(() {});
}
}
if (watchIsProcessTrust) {
if (bind.mainIsProcessTrusted(prompt: false)) {
watchIsProcessTrust = false;
setState(() {});
}
}
}); });
Get.put<RxBool>(svcStopped, tag: 'stop-service');
// disable this tray because we use tray function provided by rust now // disable this tray because we use tray function provided by rust now
// initTray(); // initTray();
trayManager.addListener(this); trayManager.addListener(this);
@ -475,6 +550,8 @@ class _DesktopHomePageState extends State<DesktopHomePage>
// rustDeskWinManager.unregisterActiveWindowListener(onActiveWindowChanged); // rustDeskWinManager.unregisterActiveWindowListener(onActiveWindowChanged);
trayManager.removeListener(this); trayManager.removeListener(this);
_uniLinksSubscription?.cancel(); _uniLinksSubscription?.cancel();
Get.delete<RxBool>(tag: 'stop-service');
_updateTimer?.cancel();
super.dispose(); super.dispose();
} }
} }

View File

@ -434,7 +434,7 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
bool locked = bind.mainIsInstalled(); bool locked = bind.mainIsInstalled();
final scrollController = ScrollController(); final scrollController = ScrollController();
final RxBool serviceStop = Get.find<RxBool>(tag: 'service-stop'); final RxBool serviceStop = Get.find<RxBool>(tag: 'stop-service');
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -439,7 +439,7 @@
"$(inherited)", "$(inherited)",
../../target/profile, ../../target/profile,
); );
MACOSX_DEPLOYMENT_TARGET = 10.15; MACOSX_DEPLOYMENT_TARGET = 10.14;
PRODUCT_BUNDLE_IDENTIFIER = com.carriez.rustdesk; PRODUCT_BUNDLE_IDENTIFIER = com.carriez.rustdesk;
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
@ -499,7 +499,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.15; MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx; SDKROOT = macosx;
@ -547,7 +547,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.15; MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx; SDKROOT = macosx;
@ -574,7 +574,7 @@
"$(inherited)", "$(inherited)",
../../target/debug, ../../target/debug,
); );
MACOSX_DEPLOYMENT_TARGET = 10.15; MACOSX_DEPLOYMENT_TARGET = 10.14;
PRODUCT_BUNDLE_IDENTIFIER = com.carriez.rustdesk; PRODUCT_BUNDLE_IDENTIFIER = com.carriez.rustdesk;
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
"SWIFT_OBJC_BRIDGING_HEADER[arch=*]" = Runner/bridge_generated.h; "SWIFT_OBJC_BRIDGING_HEADER[arch=*]" = Runner/bridge_generated.h;
@ -601,7 +601,7 @@
"$(inherited)", "$(inherited)",
../../target/release, ../../target/release,
); );
MACOSX_DEPLOYMENT_TARGET = 10.15; MACOSX_DEPLOYMENT_TARGET = 10.14;
PRODUCT_BUNDLE_IDENTIFIER = com.carriez.rustdesk; PRODUCT_BUNDLE_IDENTIFIER = com.carriez.rustdesk;
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
"SWIFT_OBJC_BRIDGING_HEADER[arch=*]" = Runner/bridge_generated.h; "SWIFT_OBJC_BRIDGING_HEADER[arch=*]" = Runner/bridge_generated.h;

View File

@ -25,7 +25,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
return EXIT_FAILURE; return EXIT_FAILURE;
} }
FUNC_RUSTDESK_CORE_MAIN rustdesk_core_main = FUNC_RUSTDESK_CORE_MAIN rustdesk_core_main =
(FUNC_RUSTDESK_CORE_MAIN)GetProcAddress(hInstance, "rustdesk_core_main"); (FUNC_RUSTDESK_CORE_MAIN)GetProcAddress(hInstance, "rustdesk_core_main_args");
if (!rustdesk_core_main) if (!rustdesk_core_main)
{ {
std::cout << "Failed to get rustdesk_core_main" << std::endl; std::cout << "Failed to get rustdesk_core_main" << std::endl;

View File

@ -40,7 +40,7 @@ pub extern "C" fn rustdesk_core_main() -> bool {
#[cfg(windows)] #[cfg(windows)]
#[no_mangle] #[no_mangle]
pub extern "C" fn rustdesk_core_main(args_len: *mut c_int) -> *mut *mut c_char { pub extern "C" fn rustdesk_core_main_args(args_len: *mut c_int) -> *mut *mut c_char {
unsafe { std::ptr::write(args_len, 0) }; unsafe { std::ptr::write(args_len, 0) };
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
{ {

View File

@ -483,6 +483,10 @@ pub fn main_get_option(key: String) -> String {
get_option(key) get_option(key)
} }
pub fn main_get_error() -> String {
get_error()
}
pub fn main_set_option(key: String, value: String) { pub fn main_set_option(key: String, value: String) {
if key.eq("custom-rendezvous-server") { if key.eq("custom-rendezvous-server") {
set_option(key, value); set_option(key, value);

View File

@ -110,7 +110,7 @@ pub fn translate_locale(name: String, locale: &str) -> String {
"fa" => fa::T.deref(), "fa" => fa::T.deref(),
"ca" => ca::T.deref(), "ca" => ca::T.deref(),
"gr" => gr::T.deref(), "gr" => gr::T.deref(),
"gr" => sv::T.deref(), "sv" => sv::T.deref(),
_ => en::T.deref(), _ => en::T.deref(),
}; };
if let Some(v) = m.get(&name as &str) { if let Some(v) = m.get(&name as &str) {