Refact. Qs, do not check qs on startup. (#7272)

Process will not exit if early return on the flutter side.

core_main.rs has checked qs already.

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2024-02-27 17:29:12 +08:00 committed by GitHub
parent e6953c8883
commit 96792bec78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 25 deletions

View File

@ -98,11 +98,9 @@ Future<void> main(List<String> args) async {
} }
} }
Future<bool> initEnv(String appType) async { Future<void> initEnv(String appType) async {
// global shared preference // global shared preference
if (!await platformFFI.init(appType)) { await platformFFI.init(appType);
return false;
}
// global FFI, use this **ONLY** for global configuration // global FFI, use this **ONLY** for global configuration
// for convenience, use global FFI on mobile platform // for convenience, use global FFI on mobile platform
// focus on multi-ffi on desktop first // focus on multi-ffi on desktop first
@ -111,14 +109,11 @@ Future<bool> initEnv(String appType) async {
_registerEventHandler(); _registerEventHandler();
// Update the system theme. // Update the system theme.
updateSystemWindowTheme(); updateSystemWindowTheme();
return true;
} }
void runMainApp(bool startService) async { void runMainApp(bool startService) async {
// register uni links // register uni links
if (!await initEnv(kAppTypeMain)) { await initEnv(kAppTypeMain);
return;
}
// trigger connection status updater // trigger connection status updater
await bind.mainCheckConnectStatus(); await bind.mainCheckConnectStatus();
if (startService) { if (startService) {
@ -152,9 +147,7 @@ void runMainApp(bool startService) async {
} }
void runMobileApp() async { void runMobileApp() async {
if (!await initEnv(kAppTypeMain)) { await initEnv(kAppTypeMain);
return;
}
if (isAndroid) androidChannelInit(); if (isAndroid) androidChannelInit();
platformFFI.syncAndroidServiceAppDirConfigPath(); platformFFI.syncAndroidServiceAppDirConfigPath();
await Future.wait([gFFI.abModel.loadCache(), gFFI.groupModel.loadCache()]); await Future.wait([gFFI.abModel.loadCache(), gFFI.groupModel.loadCache()]);
@ -167,9 +160,7 @@ void runMultiWindow(
Map<String, dynamic> argument, Map<String, dynamic> argument,
String appType, String appType,
) async { ) async {
if (!await initEnv(appType)) { await initEnv(appType);
return;
}
final title = getWindowName(); final title = getWindowName();
// set prevent close to true, we handle close event manually // set prevent close to true, we handle close event manually
WindowController.fromWindowId(kWindowId!).setPreventClose(true); WindowController.fromWindowId(kWindowId!).setPreventClose(true);
@ -232,9 +223,7 @@ void runMultiWindow(
} }
void runConnectionManagerScreen() async { void runConnectionManagerScreen() async {
if (!await initEnv(kAppTypeConnectionManager)) { await initEnv(kAppTypeConnectionManager);
return;
}
_runApp( _runApp(
'', '',
const DesktopServerPage(), const DesktopServerPage(),
@ -337,9 +326,7 @@ void _runApp(
void runInstallPage() async { void runInstallPage() async {
await windowManager.ensureInitialized(); await windowManager.ensureInitialized();
if (!await initEnv(kAppTypeMain)) { await initEnv(kAppTypeMain);
return;
}
_runApp('', const InstallPage(), MyTheme.currentThemeMode()); _runApp('', const InstallPage(), MyTheme.currentThemeMode());
WindowOptions windowOptions = WindowOptions windowOptions =
getHiddenTitleBarWindowOptions(size: Size(800, 600), center: true); getHiddenTitleBarWindowOptions(size: Size(800, 600), center: true);

View File

@ -109,7 +109,7 @@ class PlatformFFI {
sessionId: sessionId, display: display, ptr: ptr); sessionId: sessionId, display: display, ptr: ptr);
/// Init the FFI class, loads the native Rust core library. /// Init the FFI class, loads the native Rust core library.
Future<bool> init(String appType) async { Future<void> init(String appType) async {
_appType = appType; _appType = appType;
final dylib = Platform.isAndroid final dylib = Platform.isAndroid
? DynamicLibrary.open('librustdesk.so') ? DynamicLibrary.open('librustdesk.so')
@ -130,9 +130,6 @@ class PlatformFFI {
debugPrint('Failed to get documents directory: $e'); debugPrint('Failed to get documents directory: $e');
} }
_ffiBind = RustdeskImpl(dylib); _ffiBind = RustdeskImpl(dylib);
if (_ffiBind.isQs() && (_appType != kAppTypeMain && _appType != kAppTypeConnectionManager)) {
return false;
}
if (Platform.isLinux) { if (Platform.isLinux) {
// Start a dbus service, no need to await // Start a dbus service, no need to await
@ -206,7 +203,6 @@ class PlatformFFI {
debugPrintStack(label: 'initialize failed: $e'); debugPrintStack(label: 'initialize failed: $e');
} }
version = await getVersion(); version = await getVersion();
return true;
} }
Future<bool> tryHandle(Map<String, dynamic> evt) async { Future<bool> tryHandle(Map<String, dynamic> evt) async {