Merge pull request #2412 from fufesou/fix_ios_get_data_dir

Fix ios get data dir
This commit is contained in:
RustDesk 2022-12-01 23:20:08 +08:00 committed by GitHub
commit fa8f09e1a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 39 additions and 50 deletions

View File

@ -151,7 +151,7 @@ hound = "3.5"
name = "RustDesk"
identifier = "com.carriez.rustdesk"
icon = ["res/32x32.png", "res/128x128.png", "res/128x128@2x.png"]
deb_depends = ["libgtk-3-0", "libxcb-randr0", "libxdo3", "libxfixes3", "libxcb-shape0", "libxcb-xfixes0", "libasound2", "libsystemd0", "curl", "libappindicator3-1", "libvdpau1", "libva2"]
deb_depends = ["libgtk-3-0", "libxcb-randr0", "libxdo3", "libxfixes3", "libxcb-shape0", "libxcb-xfixes0", "libasound2", "libsystemd0", "curl", "libvdpau1", "libva2"]
osx_minimum_system_version = "10.14"
resources = ["res/mac-tray-light.png","res/mac-tray-dark.png"]

View File

@ -70,7 +70,7 @@ Please download sciter dynamic library yourself.
```sh
sudo apt install -y zip g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev \
libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake make \
libclang-dev ninja-build libappindicator3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
libclang-dev ninja-build libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
```
### openSUSE Tumbleweed

View File

@ -217,7 +217,7 @@ Version: %s
Architecture: amd64
Maintainer: open-trade <info@rustdesk.com>
Homepage: https://rustdesk.com
Depends: libgtk-3-0, libxcb-randr0, libxdo3, libxfixes3, libxcb-shape0, libxcb-xfixes0, libasound2, libsystemd0, curl, libappindicator3-1, libva-drm2, libva-x11-2, libvdpau1, libgstreamer-plugins-base1.0-0
Depends: libgtk-3-0, libxcb-randr0, libxdo3, libxfixes3, libxcb-shape0, libxcb-xfixes0, libasound2, libsystemd0, curl, libva-drm2, libva-x11-2, libvdpau1, libgstreamer-plugins-base1.0-0
Description: A remote control software.
""" % version

View File

@ -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);

View File

@ -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();
}

View File

@ -998,12 +998,10 @@ packages:
uni_links_desktop:
dependency: "direct main"
description:
path: "."
ref: "5be5113d59c753989dbf1106241379e3fd4c9b18"
resolved-ref: "5be5113d59c753989dbf1106241379e3fd4c9b18"
url: "https://github.com/fufesou/uni_links_desktop.git"
source: git
version: "0.1.3"
name: uni_links_desktop
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
uni_links_platform_interface:
dependency: transitive
description:

View File

@ -91,10 +91,7 @@ dependencies:
# url: https://github.com/Kingtous/flutter_improved_scrolling
# ref: 62f09545149f320616467c306c8c5f71714a18e6
uni_links: ^0.5.1
uni_links_desktop:
git:
url: https://github.com/fufesou/uni_links_desktop.git
ref: 5be5113d59c753989dbf1106241379e3fd4c9b18
uni_links_desktop: ^0.1.4
path: ^1.8.1
auto_size_text: ^3.0.0
bot_toast: ^4.0.3

View File

@ -57,6 +57,10 @@ lazy_static::lazy_static! {
lazy_static::lazy_static! {
pub static ref APP_DIR: Arc<RwLock<String>> = Default::default();
}
#[cfg(any(target_os = "android", target_os = "ios"))]
lazy_static::lazy_static! {
pub static ref APP_HOME_DIR: Arc<RwLock<String>> = Default::default();
}

View File

@ -967,8 +967,22 @@ pub fn session_change_prefer_codec(id: String) {
}
}
pub fn main_set_home_dir(home: String) {
*config::APP_HOME_DIR.write().unwrap() = home;
pub fn main_set_home_dir(_home: String) {
#[cfg(any(target_os = "android", target_os = "ios"))]
{
*config::APP_HOME_DIR.write().unwrap() = _home;
}
}
// This is a temporary method to get data dir for ios
pub fn main_get_data_dir_ios() -> SyncReturn<String> {
let data_dir = config::Config::path("data");
if !data_dir.exists() {
if let Err(e) = std::fs::create_dir_all(&data_dir) {
log::warn!("Failed to create data dir {}", e);
}
}
SyncReturn(data_dir.to_string_lossy().to_string())
}
pub fn main_stop_service() {