mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
@@ -42,6 +43,9 @@ class FileModel extends ChangeNotifier {
|
||||
/// JobTable <jobId, JobProgress>
|
||||
final _jobTable = List<JobProgress>.empty(growable: true).obs;
|
||||
|
||||
/// `isLocal` bool
|
||||
Function(bool)? onDirChanged;
|
||||
|
||||
RxList<JobProgress> get jobTable => _jobTable;
|
||||
|
||||
bool get isLocal => _isSelectedLocal;
|
||||
@@ -141,18 +145,14 @@ class FileModel extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
bool get currentShowHidden =>
|
||||
_isSelectedLocal ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
|
||||
bool getCurrentShowHidden(bool isLocal) {
|
||||
return isLocal ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
bool getCurrentShowHidden([bool? isLocal]) {
|
||||
final isLocal_ = isLocal ?? _isSelectedLocal;
|
||||
return isLocal_ ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
}
|
||||
|
||||
bool get currentIsWindows =>
|
||||
_isSelectedLocal ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
|
||||
bool getCurrentIsWindows(bool isLocal) {
|
||||
return isLocal ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
bool getCurrentIsWindows([bool? isLocal]) {
|
||||
final isLocal_ = isLocal ?? _isSelectedLocal;
|
||||
return isLocal_ ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
}
|
||||
|
||||
final _fileFetcher = FileFetcher();
|
||||
@@ -327,13 +327,13 @@ class FileModel extends ChangeNotifier {
|
||||
_localOption.showHidden = (await bind.sessionGetPeerOption(
|
||||
id: parent.target?.id ?? "", name: "local_show_hidden"))
|
||||
.isNotEmpty;
|
||||
_localOption.isWindows = Platform.isWindows;
|
||||
|
||||
_remoteOption.showHidden = (await bind.sessionGetPeerOption(
|
||||
id: parent.target?.id ?? "", name: "remote_show_hidden"))
|
||||
.isNotEmpty;
|
||||
_remoteOption.isWindows = parent.target?.ffiModel.pi.platform == "Windows";
|
||||
|
||||
debugPrint("remote platform: ${parent.target?.ffiModel.pi.platform}");
|
||||
_remoteOption.isWindows =
|
||||
parent.target?.ffiModel.pi.platform.toLowerCase() == "windows";
|
||||
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
|
||||
@@ -354,10 +354,12 @@ class FileModel extends ChangeNotifier {
|
||||
await bind.sessionLoadLastTransferJobs(id: '${parent.target?.id}');
|
||||
}
|
||||
|
||||
onClose() {
|
||||
Future<void> onClose() async {
|
||||
parent.target?.dialogManager.dismissAll();
|
||||
jobReset();
|
||||
|
||||
onDirChanged = null;
|
||||
|
||||
// save config
|
||||
Map<String, String> msgMap = {};
|
||||
|
||||
@@ -367,7 +369,7 @@ class FileModel extends ChangeNotifier {
|
||||
msgMap["remote_show_hidden"] = _remoteOption.showHidden ? "Y" : "";
|
||||
final id = parent.target?.id ?? "";
|
||||
for (final msg in msgMap.entries) {
|
||||
bind.sessionPeerOption(id: id, name: msg.key, value: msg.value);
|
||||
await bind.sessionPeerOption(id: id, name: msg.key, value: msg.value);
|
||||
}
|
||||
_currentLocalDir.clear();
|
||||
_currentRemoteDir.clear();
|
||||
@@ -399,14 +401,10 @@ class FileModel extends ChangeNotifier {
|
||||
if (!isBack) {
|
||||
pushHistory(isLocal);
|
||||
}
|
||||
final showHidden =
|
||||
isLocal ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
final isWindows =
|
||||
isLocal ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
final showHidden = getCurrentShowHidden(isLocal);
|
||||
final isWindows = getCurrentIsWindows(isLocal);
|
||||
// process /C:\ -> C:\ on Windows
|
||||
if (isLocal
|
||||
? _localOption.isWindows
|
||||
: _remoteOption.isWindows && path.length > 1 && path[0] == '/') {
|
||||
if (isWindows && path.length > 1 && path[0] == '/') {
|
||||
path = path.substring(1);
|
||||
if (path[path.length - 1] != '\\') {
|
||||
path = "$path\\";
|
||||
@@ -421,6 +419,7 @@ class FileModel extends ChangeNotifier {
|
||||
_currentRemoteDir = fd;
|
||||
}
|
||||
notifyListeners();
|
||||
onDirChanged?.call(isLocal);
|
||||
} catch (e) {
|
||||
debugPrint("Failed to openDirectory $path: $e");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user