request elevation menu

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-02-24 15:51:13 +08:00
parent 0ad6bca9ce
commit a9598e006a
8 changed files with 59 additions and 23 deletions

View File

@@ -203,6 +203,8 @@ class FfiModel with ChangeNotifier {
final peer_id = evt['peer_id'].toString();
await bind.sessionSwitchSides(id: peer_id);
closeConnection(id: peer_id);
} else if (name == 'portable_service_running') {
parent.target?.elevationModel.onPortableServiceRunning(evt);
} else if (name == "on_url_scheme_received") {
final url = evt['url'].toString();
parseRustdeskUri(url);
@@ -439,6 +441,7 @@ class FfiModel with ChangeNotifier {
Map<String, dynamic> features = json.decode(evt['features']);
_pi.features.privacyMode = features['privacy_mode'] == 1;
handleResolutions(peerId, evt["resolutions"]);
parent.target?.elevationModel.onPeerInfo(_pi);
}
notifyListeners();
}
@@ -1395,6 +1398,21 @@ class RecordingModel with ChangeNotifier {
}
}
class ElevationModel with ChangeNotifier {
WeakReference<FFI> parent;
ElevationModel(this.parent);
bool _running = false;
bool _canElevate = false;
bool get showRequestMenu => _canElevate && !_running;
onPeerInfo(PeerInfo pi) {
_canElevate = pi.platform == kPeerPlatformWindows && pi.sasEnabled == false;
}
onPortableServiceRunning(Map<String, dynamic> evt) {
_running = evt['running'] == 'true';
}
}
enum ConnType { defaultConn, fileTransfer, portForward, rdp }
/// Flutter state manager and data communication with the Rust core.
@@ -1420,6 +1438,7 @@ class FFI {
late final QualityMonitorModel qualityMonitorModel; // session
late final RecordingModel recordingModel; // session
late final InputModel inputModel; // session
late final ElevationModel elevationModel; // session
FFI() {
imageModel = ImageModel(WeakReference(this));
@@ -1436,6 +1455,7 @@ class FFI {
qualityMonitorModel = QualityMonitorModel(WeakReference(this));
recordingModel = RecordingModel(WeakReference(this));
inputModel = InputModel(WeakReference(this));
elevationModel = ElevationModel(WeakReference(this));
}
/// Start with the given [id]. Only transfer file if [isFileTransfer], only port forward if [isPortForward].