mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -29,6 +29,7 @@ typedef HandleEvent = Future<void> Function(Map<String, dynamic> evt);
|
||||
/// Hides the platform differences.
|
||||
class PlatformFFI {
|
||||
String _dir = '';
|
||||
// _homeDir is only needed for Android and IOS.
|
||||
String _homeDir = '';
|
||||
F2? _translate;
|
||||
final _eventHandlers = <String, Map<String, HandleEvent>>{};
|
||||
@@ -119,8 +120,10 @@ class PlatformFFI {
|
||||
if (isAndroid) {
|
||||
// only support for android
|
||||
_homeDir = (await ExternalPath.getExternalStorageDirectories())[0];
|
||||
} else if (isIOS) {
|
||||
_homeDir = _ffiBind.mainGetDataDirIos();
|
||||
} else {
|
||||
_homeDir = (await getDownloadsDirectory())?.path ?? '';
|
||||
// no need to set home dir
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('initialize failed: $e');
|
||||
@@ -159,8 +162,13 @@ class PlatformFFI {
|
||||
name = macOsInfo.computerName;
|
||||
id = macOsInfo.systemGUID ?? '';
|
||||
}
|
||||
debugPrint(
|
||||
'_appType:$_appType,info1-id:$id,info2-name:$name,dir:$_dir,homeDir:$_homeDir');
|
||||
if (isAndroid || isIOS) {
|
||||
debugPrint(
|
||||
'_appType:$_appType,info1-id:$id,info2-name:$name,dir:$_dir,homeDir:$_homeDir');
|
||||
} else {
|
||||
debugPrint(
|
||||
'_appType:$_appType,info1-id:$id,info2-name:$name,dir:$_dir');
|
||||
}
|
||||
await _ffiBind.mainDeviceId(id: id);
|
||||
await _ffiBind.mainDeviceName(name: name);
|
||||
await _ffiBind.mainSetHomeDir(home: _homeDir);
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:tray_manager/tray_manager.dart';
|
||||
|
||||
import '../common.dart';
|
||||
|
||||
const kTrayItemShowKey = "show";
|
||||
const kTrayItemQuitKey = "quit";
|
||||
|
||||
Future<void> initTray({List<MenuItem>? extra_item}) async {
|
||||
List<MenuItem> items = [
|
||||
MenuItem(key: kTrayItemShowKey, label: translate("Show RustDesk")),
|
||||
MenuItem.separator(),
|
||||
MenuItem(key: kTrayItemQuitKey, label: translate("Quit")),
|
||||
];
|
||||
if (extra_item != null) {
|
||||
items.insertAll(0, extra_item);
|
||||
}
|
||||
if (Platform.isMacOS || Platform.isWindows) {
|
||||
await trayManager.setToolTip("rustdesk");
|
||||
}
|
||||
if (Platform.isMacOS || Platform.isLinux) {
|
||||
await trayManager.setTitle("rustdesk");
|
||||
}
|
||||
await trayManager
|
||||
.setIcon(Platform.isWindows ? "assets/logo.ico" : "assets/logo.png");
|
||||
await trayManager.setContextMenu(Menu(items: items));
|
||||
}
|
||||
|
||||
Future<void> destoryTray() async {
|
||||
return trayManager.destroy();
|
||||
}
|
||||
Reference in New Issue
Block a user