mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge pull request #759 from Kingtous/flutter_desktop
refactor: make multi FFI object && initial flutter multi sessions support
This commit is contained in:
commit
d6047a69e2
@ -3,6 +3,7 @@ import 'dart:async';
|
|||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:get/instance_manager.dart';
|
||||||
|
|
||||||
import 'models/model.dart';
|
import 'models/model.dart';
|
||||||
|
|
||||||
@ -274,7 +275,7 @@ class PermissionManager {
|
|||||||
static Future<bool> check(String type) {
|
static Future<bool> check(String type) {
|
||||||
if (!permissions.contains(type))
|
if (!permissions.contains(type))
|
||||||
return Future.error("Wrong permission!$type");
|
return Future.error("Wrong permission!$type");
|
||||||
return FFI.invokeMethod("check_permission", type);
|
return gFFI.invokeMethod("check_permission", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> request(String type) {
|
static Future<bool> request(String type) {
|
||||||
@ -283,7 +284,7 @@ class PermissionManager {
|
|||||||
|
|
||||||
_current = type;
|
_current = type;
|
||||||
_completer = Completer<bool>();
|
_completer = Completer<bool>();
|
||||||
FFI.invokeMethod("request_permission", type);
|
gFFI.invokeMethod("request_permission", type);
|
||||||
|
|
||||||
// timeout
|
// timeout
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
@ -307,3 +308,21 @@ class PermissionManager {
|
|||||||
_current = "";
|
_current = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// find ffi, tag is Remote ID
|
||||||
|
/// for session specific usage
|
||||||
|
FFI ffi(String? tag) {
|
||||||
|
return Get.find<FFI>(tag: tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Global FFI object
|
||||||
|
late FFI _globalFFI;
|
||||||
|
|
||||||
|
FFI get gFFI => _globalFFI;
|
||||||
|
|
||||||
|
Future<void> initGlobalFFI() async {
|
||||||
|
_globalFFI = FFI();
|
||||||
|
// after `put`, can also be globally found by Get.find<FFI>();
|
||||||
|
Get.put(_globalFFI, permanent: true);
|
||||||
|
await _globalFFI.ffiModel.init();
|
||||||
|
}
|
||||||
@ -44,7 +44,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Provider.of<FfiModel>(context);
|
Provider.of<FfiModel>(context);
|
||||||
if (_idController.text.isEmpty) _idController.text = FFI.getId();
|
if (_idController.text.isEmpty) _idController.text = gFFI.getId();
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@ -258,7 +258,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
width = size.width / n - 2 * space;
|
width = size.width / n - 2 * space;
|
||||||
}
|
}
|
||||||
final cards = <Widget>[];
|
final cards = <Widget>[];
|
||||||
var peers = FFI.peers();
|
var peers = gFFI.peers();
|
||||||
peers.forEach((p) {
|
peers.forEach((p) {
|
||||||
cards.add(Container(
|
cards.add(Container(
|
||||||
width: width,
|
width: width,
|
||||||
@ -316,7 +316,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
elevation: 8,
|
elevation: 8,
|
||||||
);
|
);
|
||||||
if (value == 'remove') {
|
if (value == 'remove') {
|
||||||
setState(() => FFI.setByName('remove', '$id'));
|
setState(() => gFFI.setByName('remove', '$id'));
|
||||||
() async {
|
() async {
|
||||||
removePreference(id);
|
removePreference(id);
|
||||||
}();
|
}();
|
||||||
|
|||||||
@ -61,7 +61,7 @@ class _DesktopHomePageState extends State<DesktopHomePage> with TrayListener {
|
|||||||
|
|
||||||
buildServerInfo(BuildContext context) {
|
buildServerInfo(BuildContext context) {
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
value: FFI.serverModel,
|
value: gFFI.serverModel,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(color: MyTheme.white),
|
decoration: BoxDecoration(color: MyTheme.white),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -88,7 +88,7 @@ class _DesktopHomePageState extends State<DesktopHomePage> with TrayListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildIDBoard(BuildContext context) {
|
buildIDBoard(BuildContext context) {
|
||||||
final model = FFI.serverModel;
|
final model = gFFI.serverModel;
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
margin: EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -123,7 +123,7 @@ class _DesktopHomePageState extends State<DesktopHomePage> with TrayListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildPasswordBoard(BuildContext context) {
|
buildPasswordBoard(BuildContext context) {
|
||||||
final model = FFI.serverModel;
|
final model = gFFI.serverModel;
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
margin: EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@ -8,6 +8,8 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:flutter_hbb/mobile/widgets/gesture_help.dart';
|
import 'package:flutter_hbb/mobile/widgets/gesture_help.dart';
|
||||||
import 'package:flutter_hbb/models/chat_model.dart';
|
import 'package:flutter_hbb/models/chat_model.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:get/route_manager.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:wakelock/wakelock.dart';
|
import 'package:wakelock/wakelock.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
@ -45,10 +47,15 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
var _showEdit = false; // use soft keyboard
|
var _showEdit = false; // use soft keyboard
|
||||||
var _isPhysicalMouse = false;
|
var _isPhysicalMouse = false;
|
||||||
|
|
||||||
|
FFI get _ffi => ffi(widget.id);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
FFI.connect(widget.id);
|
final ffi = Get.put(FFI(), tag: widget.id);
|
||||||
|
// note: a little trick
|
||||||
|
ffi.ffiModel.platformFFI = gFFI.ffiModel.platformFFI;
|
||||||
|
ffi.connect(widget.id);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||||
showLoading(translate('Connecting...'));
|
showLoading(translate('Connecting...'));
|
||||||
@ -59,8 +66,8 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
Wakelock.enable();
|
Wakelock.enable();
|
||||||
}
|
}
|
||||||
_physicalFocusNode.requestFocus();
|
_physicalFocusNode.requestFocus();
|
||||||
// FFI.ffiModel.updateEventListener(widget.id);
|
ffi.ffiModel.updateEventListener(widget.id);
|
||||||
FFI.listenToMouse(true);
|
ffi.listenToMouse(true);
|
||||||
WindowManager.instance.addListener(this);
|
WindowManager.instance.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,11 +75,11 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
print("remote page dispose");
|
print("remote page dispose");
|
||||||
hideMobileActionsOverlay();
|
hideMobileActionsOverlay();
|
||||||
FFI.listenToMouse(false);
|
_ffi.listenToMouse(false);
|
||||||
FFI.invokeMethod("enable_soft_keyboard", true);
|
_ffi.invokeMethod("enable_soft_keyboard", true);
|
||||||
_mobileFocusNode.dispose();
|
_mobileFocusNode.dispose();
|
||||||
_physicalFocusNode.dispose();
|
_physicalFocusNode.dispose();
|
||||||
FFI.close();
|
_ffi.close();
|
||||||
_interval?.cancel();
|
_interval?.cancel();
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
@ -82,11 +89,12 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
Wakelock.disable();
|
Wakelock.disable();
|
||||||
}
|
}
|
||||||
WindowManager.instance.removeListener(this);
|
WindowManager.instance.removeListener(this);
|
||||||
|
Get.delete<FFI>(tag: widget.id);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetTool() {
|
void resetTool() {
|
||||||
FFI.resetModifiers();
|
_ffi.resetModifiers();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isKeyboardShown() {
|
bool isKeyboardShown() {
|
||||||
@ -105,8 +113,8 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
overlays: []);
|
overlays: []);
|
||||||
// [pi.version.isNotEmpty] -> check ready or not,avoid login without soft-keyboard
|
// [pi.version.isNotEmpty] -> check ready or not,avoid login without soft-keyboard
|
||||||
if (chatWindowOverlayEntry == null &&
|
if (chatWindowOverlayEntry == null &&
|
||||||
FFI.ffiModel.pi.version.isNotEmpty) {
|
_ffi.ffiModel.pi.version.isNotEmpty) {
|
||||||
FFI.invokeMethod("enable_soft_keyboard", false);
|
_ffi.invokeMethod("enable_soft_keyboard", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -138,12 +146,12 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
newValue[common] == oldValue[common];
|
newValue[common] == oldValue[common];
|
||||||
++common);
|
++common);
|
||||||
for (i = 0; i < oldValue.length - common; ++i) {
|
for (i = 0; i < oldValue.length - common; ++i) {
|
||||||
FFI.inputKey('VK_BACK');
|
_ffi.inputKey('VK_BACK');
|
||||||
}
|
}
|
||||||
if (newValue.length > common) {
|
if (newValue.length > common) {
|
||||||
var s = newValue.substring(common);
|
var s = newValue.substring(common);
|
||||||
if (s.length > 1) {
|
if (s.length > 1) {
|
||||||
FFI.bind.sessionInputString(id: widget.id, value: s);
|
_ffi.bind.sessionInputString(id: widget.id, value: s);
|
||||||
} else {
|
} else {
|
||||||
inputChar(s);
|
inputChar(s);
|
||||||
}
|
}
|
||||||
@ -161,7 +169,7 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
// ?
|
// ?
|
||||||
} else if (newValue.length < oldValue.length) {
|
} else if (newValue.length < oldValue.length) {
|
||||||
final char = 'VK_BACK';
|
final char = 'VK_BACK';
|
||||||
FFI.inputKey(char);
|
_ffi.inputKey(char);
|
||||||
} else {
|
} else {
|
||||||
final content = newValue.substring(oldValue.length);
|
final content = newValue.substring(oldValue.length);
|
||||||
if (content.length > 1) {
|
if (content.length > 1) {
|
||||||
@ -177,11 +185,11 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
content == '()' ||
|
content == '()' ||
|
||||||
content == '【】')) {
|
content == '【】')) {
|
||||||
// can not only input content[0], because when input ], [ are also auo insert, which cause ] never be input
|
// can not only input content[0], because when input ], [ are also auo insert, which cause ] never be input
|
||||||
FFI.bind.sessionInputString(id: widget.id, value: content);
|
_ffi.bind.sessionInputString(id: widget.id, value: content);
|
||||||
openKeyboard();
|
openKeyboard();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FFI.bind.sessionInputString(id: widget.id, value: content);
|
_ffi.bind.sessionInputString(id: widget.id, value: content);
|
||||||
} else {
|
} else {
|
||||||
inputChar(content);
|
inputChar(content);
|
||||||
}
|
}
|
||||||
@ -194,11 +202,11 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
} else if (char == ' ') {
|
} else if (char == ' ') {
|
||||||
char = 'VK_SPACE';
|
char = 'VK_SPACE';
|
||||||
}
|
}
|
||||||
FFI.inputKey(char);
|
_ffi.inputKey(char);
|
||||||
}
|
}
|
||||||
|
|
||||||
void openKeyboard() {
|
void openKeyboard() {
|
||||||
FFI.invokeMethod("enable_soft_keyboard", true);
|
_ffi.invokeMethod("enable_soft_keyboard", true);
|
||||||
// destroy first, so that our _value trick can work
|
// destroy first, so that our _value trick can work
|
||||||
_value = initText;
|
_value = initText;
|
||||||
setState(() => _showEdit = false);
|
setState(() => _showEdit = false);
|
||||||
@ -221,7 +229,7 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
final label = _logicalKeyMap[e.logicalKey.keyId] ??
|
final label = _logicalKeyMap[e.logicalKey.keyId] ??
|
||||||
_physicalKeyMap[e.physicalKey.usbHidUsage] ??
|
_physicalKeyMap[e.physicalKey.usbHidUsage] ??
|
||||||
e.logicalKey.keyLabel;
|
e.logicalKey.keyLabel;
|
||||||
FFI.inputKey(label, down: down, press: press ?? false);
|
_ffi.inputKey(label, down: down, press: press ?? false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -229,7 +237,7 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
final pi = Provider.of<FfiModel>(context).pi;
|
final pi = Provider.of<FfiModel>(context).pi;
|
||||||
final hideKeyboard = isKeyboardShown() && _showEdit;
|
final hideKeyboard = isKeyboardShown() && _showEdit;
|
||||||
final showActionButton = !_showBar || hideKeyboard;
|
final showActionButton = !_showBar || hideKeyboard;
|
||||||
final keyboard = FFI.ffiModel.permissions['keyboard'] != false;
|
final keyboard = _ffi.ffiModel.permissions['keyboard'] != false;
|
||||||
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
@ -251,7 +259,7 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
setState(() {
|
setState(() {
|
||||||
if (hideKeyboard) {
|
if (hideKeyboard) {
|
||||||
_showEdit = false;
|
_showEdit = false;
|
||||||
FFI.invokeMethod("enable_soft_keyboard", false);
|
_ffi.invokeMethod("enable_soft_keyboard", false);
|
||||||
_mobileFocusNode.unfocus();
|
_mobileFocusNode.unfocus();
|
||||||
_physicalFocusNode.requestFocus();
|
_physicalFocusNode.requestFocus();
|
||||||
} else {
|
} else {
|
||||||
@ -291,7 +299,7 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_isPhysicalMouse) {
|
if (_isPhysicalMouse) {
|
||||||
FFI.handleMouse(getEvent(e, 'mousemove'));
|
_ffi.handleMouse(getEvent(e, 'mousemove'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPointerDown: (e) {
|
onPointerDown: (e) {
|
||||||
@ -303,19 +311,19 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_isPhysicalMouse) {
|
if (_isPhysicalMouse) {
|
||||||
FFI.handleMouse(getEvent(e, 'mousedown'));
|
_ffi.handleMouse(getEvent(e, 'mousedown'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPointerUp: (e) {
|
onPointerUp: (e) {
|
||||||
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
||||||
if (_isPhysicalMouse) {
|
if (_isPhysicalMouse) {
|
||||||
FFI.handleMouse(getEvent(e, 'mouseup'));
|
_ffi.handleMouse(getEvent(e, 'mouseup'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPointerMove: (e) {
|
onPointerMove: (e) {
|
||||||
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
||||||
if (_isPhysicalMouse) {
|
if (_isPhysicalMouse) {
|
||||||
FFI.handleMouse(getEvent(e, 'mousemove'));
|
_ffi.handleMouse(getEvent(e, 'mousemove'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPointerSignal: (e) {
|
onPointerSignal: (e) {
|
||||||
@ -328,7 +336,7 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
if (dy > 0)
|
if (dy > 0)
|
||||||
dy = -1;
|
dy = -1;
|
||||||
else if (dy < 0) dy = 1;
|
else if (dy < 0) dy = 1;
|
||||||
FFI.setByName('send_mouse',
|
_ffi.setByName('send_mouse',
|
||||||
'{"id": "${widget.id}", "type": "wheel", "x": "$dx", "y": "$dy"}');
|
'{"id": "${widget.id}", "type": "wheel", "x": "$dx", "y": "$dy"}');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -346,14 +354,14 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
if (e.repeat) {
|
if (e.repeat) {
|
||||||
sendRawKey(e, press: true);
|
sendRawKey(e, press: true);
|
||||||
} else {
|
} else {
|
||||||
if (e.isAltPressed && !FFI.alt) {
|
if (e.isAltPressed && !_ffi.alt) {
|
||||||
FFI.alt = true;
|
_ffi.alt = true;
|
||||||
} else if (e.isControlPressed && !FFI.ctrl) {
|
} else if (e.isControlPressed && !_ffi.ctrl) {
|
||||||
FFI.ctrl = true;
|
_ffi.ctrl = true;
|
||||||
} else if (e.isShiftPressed && !FFI.shift) {
|
} else if (e.isShiftPressed && !_ffi.shift) {
|
||||||
FFI.shift = true;
|
_ffi.shift = true;
|
||||||
} else if (e.isMetaPressed && !FFI.command) {
|
} else if (e.isMetaPressed && !_ffi.command) {
|
||||||
FFI.command = true;
|
_ffi.command = true;
|
||||||
}
|
}
|
||||||
sendRawKey(e, down: true);
|
sendRawKey(e, down: true);
|
||||||
}
|
}
|
||||||
@ -362,16 +370,16 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
if (!_showEdit && e is RawKeyUpEvent) {
|
if (!_showEdit && e is RawKeyUpEvent) {
|
||||||
if (key == LogicalKeyboardKey.altLeft ||
|
if (key == LogicalKeyboardKey.altLeft ||
|
||||||
key == LogicalKeyboardKey.altRight) {
|
key == LogicalKeyboardKey.altRight) {
|
||||||
FFI.alt = false;
|
_ffi.alt = false;
|
||||||
} else if (key == LogicalKeyboardKey.controlLeft ||
|
} else if (key == LogicalKeyboardKey.controlLeft ||
|
||||||
key == LogicalKeyboardKey.controlRight) {
|
key == LogicalKeyboardKey.controlRight) {
|
||||||
FFI.ctrl = false;
|
_ffi.ctrl = false;
|
||||||
} else if (key == LogicalKeyboardKey.shiftRight ||
|
} else if (key == LogicalKeyboardKey.shiftRight ||
|
||||||
key == LogicalKeyboardKey.shiftLeft) {
|
key == LogicalKeyboardKey.shiftLeft) {
|
||||||
FFI.shift = false;
|
_ffi.shift = false;
|
||||||
} else if (key == LogicalKeyboardKey.metaLeft ||
|
} else if (key == LogicalKeyboardKey.metaLeft ||
|
||||||
key == LogicalKeyboardKey.metaRight) {
|
key == LogicalKeyboardKey.metaRight) {
|
||||||
FFI.command = false;
|
_ffi.command = false;
|
||||||
}
|
}
|
||||||
sendRawKey(e);
|
sendRawKey(e);
|
||||||
}
|
}
|
||||||
@ -410,7 +418,7 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
] +
|
] +
|
||||||
(isWebDesktop
|
(isWebDesktop
|
||||||
? []
|
? []
|
||||||
: FFI.ffiModel.isPeerAndroid
|
: _ffi.ffiModel.isPeerAndroid
|
||||||
? [
|
? [
|
||||||
IconButton(
|
IconButton(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@ -431,7 +439,7 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
onPressed: openKeyboard),
|
onPressed: openKeyboard),
|
||||||
IconButton(
|
IconButton(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
icon: Icon(FFI.ffiModel.touchMode
|
icon: Icon(_ffi.ffiModel.touchMode
|
||||||
? Icons.touch_app
|
? Icons.touch_app
|
||||||
: Icons.mouse),
|
: Icons.mouse),
|
||||||
onPressed: changeTouchMode,
|
onPressed: changeTouchMode,
|
||||||
@ -444,7 +452,7 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
icon: Icon(Icons.message),
|
icon: Icon(Icons.message),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
FFI.chatModel
|
_ffi.chatModel
|
||||||
.changeCurrentID(ChatModel.clientModeID);
|
.changeCurrentID(ChatModel.clientModeID);
|
||||||
toggleChatOverlay();
|
toggleChatOverlay();
|
||||||
},
|
},
|
||||||
@ -482,89 +490,89 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
/// HoldDrag -> left drag
|
/// HoldDrag -> left drag
|
||||||
|
|
||||||
Widget getBodyForMobileWithGesture() {
|
Widget getBodyForMobileWithGesture() {
|
||||||
final touchMode = FFI.ffiModel.touchMode;
|
final touchMode = _ffi.ffiModel.touchMode;
|
||||||
return getMixinGestureDetector(
|
return getMixinGestureDetector(
|
||||||
child: getBodyForMobile(),
|
child: getBodyForMobile(),
|
||||||
onTapUp: (d) {
|
onTapUp: (d) {
|
||||||
if (touchMode) {
|
if (touchMode) {
|
||||||
FFI.cursorModel.touch(
|
_ffi.cursorModel.touch(
|
||||||
d.localPosition.dx, d.localPosition.dy, MouseButtons.left);
|
d.localPosition.dx, d.localPosition.dy, MouseButtons.left);
|
||||||
} else {
|
} else {
|
||||||
FFI.tap(MouseButtons.left);
|
_ffi.tap(MouseButtons.left);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDoubleTapDown: (d) {
|
onDoubleTapDown: (d) {
|
||||||
if (touchMode) {
|
if (touchMode) {
|
||||||
FFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
_ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDoubleTap: () {
|
onDoubleTap: () {
|
||||||
FFI.tap(MouseButtons.left);
|
_ffi.tap(MouseButtons.left);
|
||||||
FFI.tap(MouseButtons.left);
|
_ffi.tap(MouseButtons.left);
|
||||||
},
|
},
|
||||||
onLongPressDown: (d) {
|
onLongPressDown: (d) {
|
||||||
if (touchMode) {
|
if (touchMode) {
|
||||||
FFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
_ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
FFI.tap(MouseButtons.right);
|
_ffi.tap(MouseButtons.right);
|
||||||
},
|
},
|
||||||
onDoubleFinerTap: (d) {
|
onDoubleFinerTap: (d) {
|
||||||
if (!touchMode) {
|
if (!touchMode) {
|
||||||
FFI.tap(MouseButtons.right);
|
_ffi.tap(MouseButtons.right);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onHoldDragStart: (d) {
|
onHoldDragStart: (d) {
|
||||||
if (!touchMode) {
|
if (!touchMode) {
|
||||||
FFI.sendMouse('down', MouseButtons.left);
|
_ffi.sendMouse('down', MouseButtons.left);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onHoldDragUpdate: (d) {
|
onHoldDragUpdate: (d) {
|
||||||
if (!touchMode) {
|
if (!touchMode) {
|
||||||
FFI.cursorModel.updatePan(d.delta.dx, d.delta.dy, touchMode);
|
_ffi.cursorModel.updatePan(d.delta.dx, d.delta.dy, touchMode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onHoldDragEnd: (_) {
|
onHoldDragEnd: (_) {
|
||||||
if (!touchMode) {
|
if (!touchMode) {
|
||||||
FFI.sendMouse('up', MouseButtons.left);
|
_ffi.sendMouse('up', MouseButtons.left);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onOneFingerPanStart: (d) {
|
onOneFingerPanStart: (d) {
|
||||||
if (touchMode) {
|
if (touchMode) {
|
||||||
FFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
_ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||||
FFI.sendMouse('down', MouseButtons.left);
|
_ffi.sendMouse('down', MouseButtons.left);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onOneFingerPanUpdate: (d) {
|
onOneFingerPanUpdate: (d) {
|
||||||
FFI.cursorModel.updatePan(d.delta.dx, d.delta.dy, touchMode);
|
_ffi.cursorModel.updatePan(d.delta.dx, d.delta.dy, touchMode);
|
||||||
},
|
},
|
||||||
onOneFingerPanEnd: (d) {
|
onOneFingerPanEnd: (d) {
|
||||||
if (touchMode) {
|
if (touchMode) {
|
||||||
FFI.sendMouse('up', MouseButtons.left);
|
_ffi.sendMouse('up', MouseButtons.left);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// scale + pan event
|
// scale + pan event
|
||||||
onTwoFingerScaleUpdate: (d) {
|
onTwoFingerScaleUpdate: (d) {
|
||||||
FFI.canvasModel.updateScale(d.scale / _scale);
|
_ffi.canvasModel.updateScale(d.scale / _scale);
|
||||||
_scale = d.scale;
|
_scale = d.scale;
|
||||||
FFI.canvasModel.panX(d.focalPointDelta.dx);
|
_ffi.canvasModel.panX(d.focalPointDelta.dx);
|
||||||
FFI.canvasModel.panY(d.focalPointDelta.dy);
|
_ffi.canvasModel.panY(d.focalPointDelta.dy);
|
||||||
},
|
},
|
||||||
onTwoFingerScaleEnd: (d) {
|
onTwoFingerScaleEnd: (d) {
|
||||||
_scale = 1;
|
_scale = 1;
|
||||||
FFI.bind
|
_ffi.bind
|
||||||
.sessionPeerOption(id: widget.id, name: "view-style", value: "");
|
.sessionPeerOption(id: widget.id, name: "view-style", value: "");
|
||||||
},
|
},
|
||||||
onThreeFingerVerticalDragUpdate: FFI.ffiModel.isPeerAndroid
|
onThreeFingerVerticalDragUpdate: _ffi.ffiModel.isPeerAndroid
|
||||||
? null
|
? null
|
||||||
: (d) {
|
: (d) {
|
||||||
_mouseScrollIntegral += d.delta.dy / 4;
|
_mouseScrollIntegral += d.delta.dy / 4;
|
||||||
if (_mouseScrollIntegral > 1) {
|
if (_mouseScrollIntegral > 1) {
|
||||||
FFI.scroll(1);
|
_ffi.scroll(1);
|
||||||
_mouseScrollIntegral = 0;
|
_mouseScrollIntegral = 0;
|
||||||
} else if (_mouseScrollIntegral < -1) {
|
} else if (_mouseScrollIntegral < -1) {
|
||||||
FFI.scroll(-1);
|
_ffi.scroll(-1);
|
||||||
_mouseScrollIntegral = 0;
|
_mouseScrollIntegral = 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -574,8 +582,8 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
return Container(
|
return Container(
|
||||||
color: MyTheme.canvasColor,
|
color: MyTheme.canvasColor,
|
||||||
child: Stack(children: [
|
child: Stack(children: [
|
||||||
ImagePaint(),
|
ImagePaint(id: widget.id),
|
||||||
CursorPaint(),
|
CursorPaint(id: widget.id),
|
||||||
getHelpTools(),
|
getHelpTools(),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 0,
|
width: 0,
|
||||||
@ -599,11 +607,17 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget getBodyForDesktopWithListener(bool keyboard) {
|
Widget getBodyForDesktopWithListener(bool keyboard) {
|
||||||
var paints = <Widget>[ImagePaint()];
|
var paints = <Widget>[
|
||||||
final cursor = FFI.bind
|
ImagePaint(
|
||||||
|
id: widget.id,
|
||||||
|
)
|
||||||
|
];
|
||||||
|
final cursor = _ffi.bind
|
||||||
.getSessionToggleOptionSync(id: widget.id, arg: 'show-remote-cursor');
|
.getSessionToggleOptionSync(id: widget.id, arg: 'show-remote-cursor');
|
||||||
if (keyboard || cursor) {
|
if (keyboard || cursor) {
|
||||||
paints.add(CursorPaint());
|
paints.add(CursorPaint(
|
||||||
|
id: widget.id,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
return Container(
|
return Container(
|
||||||
color: MyTheme.canvasColor, child: Stack(children: paints));
|
color: MyTheme.canvasColor, child: Stack(children: paints));
|
||||||
@ -616,10 +630,10 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
out['type'] = type;
|
out['type'] = type;
|
||||||
out['x'] = evt.position.dx;
|
out['x'] = evt.position.dx;
|
||||||
out['y'] = evt.position.dy;
|
out['y'] = evt.position.dy;
|
||||||
if (FFI.alt) out['alt'] = 'true';
|
if (_ffi.alt) out['alt'] = 'true';
|
||||||
if (FFI.shift) out['shift'] = 'true';
|
if (_ffi.shift) out['shift'] = 'true';
|
||||||
if (FFI.ctrl) out['ctrl'] = 'true';
|
if (_ffi.ctrl) out['ctrl'] = 'true';
|
||||||
if (FFI.command) out['command'] = 'true';
|
if (_ffi.command) out['command'] = 'true';
|
||||||
out['buttons'] = evt
|
out['buttons'] = evt
|
||||||
.buttons; // left button: 1, right button: 2, middle button: 4, 1 | 2 = 3 (left + right)
|
.buttons; // left button: 1, right button: 2, middle button: 4, 1 | 2 = 3 (left + right)
|
||||||
if (evt.buttons != 0) {
|
if (evt.buttons != 0) {
|
||||||
@ -635,8 +649,8 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
final x = 120.0;
|
final x = 120.0;
|
||||||
final y = size.height;
|
final y = size.height;
|
||||||
final more = <PopupMenuItem<String>>[];
|
final more = <PopupMenuItem<String>>[];
|
||||||
final pi = FFI.ffiModel.pi;
|
final pi = _ffi.ffiModel.pi;
|
||||||
final perms = FFI.ffiModel.permissions;
|
final perms = _ffi.ffiModel.permissions;
|
||||||
if (pi.version.isNotEmpty) {
|
if (pi.version.isNotEmpty) {
|
||||||
more.add(PopupMenuItem<String>(
|
more.add(PopupMenuItem<String>(
|
||||||
child: Text(translate('Refresh')), value: 'refresh'));
|
child: Text(translate('Refresh')), value: 'refresh'));
|
||||||
@ -672,11 +686,11 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
more.add(PopupMenuItem<String>(
|
more.add(PopupMenuItem<String>(
|
||||||
child: Text(translate('Insert Lock')), value: 'lock'));
|
child: Text(translate('Insert Lock')), value: 'lock'));
|
||||||
if (pi.platform == 'Windows' &&
|
if (pi.platform == 'Windows' &&
|
||||||
await FFI.bind.getSessionToggleOption(id: id, arg: 'privacy-mode') !=
|
await _ffi.bind.getSessionToggleOption(id: id, arg: 'privacy-mode') !=
|
||||||
true) {
|
true) {
|
||||||
more.add(PopupMenuItem<String>(
|
more.add(PopupMenuItem<String>(
|
||||||
child: Text(translate(
|
child: Text(translate((_ffi.ffiModel.inputBlocked ? 'Unb' : 'B') +
|
||||||
(FFI.ffiModel.inputBlocked ? 'Unb' : 'B') + 'lock user input')),
|
'lock user input')),
|
||||||
value: 'block-input'));
|
value: 'block-input'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -688,33 +702,33 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
elevation: 8,
|
elevation: 8,
|
||||||
);
|
);
|
||||||
if (value == 'cad') {
|
if (value == 'cad') {
|
||||||
FFI.bind.sessionCtrlAltDel(id: widget.id);
|
_ffi.bind.sessionCtrlAltDel(id: widget.id);
|
||||||
} else if (value == 'lock') {
|
} else if (value == 'lock') {
|
||||||
FFI.bind.sessionLockScreen(id: widget.id);
|
_ffi.bind.sessionLockScreen(id: widget.id);
|
||||||
} else if (value == 'block-input') {
|
} else if (value == 'block-input') {
|
||||||
FFI.bind.sessionToggleOption(
|
_ffi.bind.sessionToggleOption(
|
||||||
id: widget.id,
|
id: widget.id,
|
||||||
value: (FFI.ffiModel.inputBlocked ? 'un' : '') + 'block-input');
|
value: (_ffi.ffiModel.inputBlocked ? 'un' : '') + 'block-input');
|
||||||
FFI.ffiModel.inputBlocked = !FFI.ffiModel.inputBlocked;
|
_ffi.ffiModel.inputBlocked = !_ffi.ffiModel.inputBlocked;
|
||||||
} else if (value == 'refresh') {
|
} else if (value == 'refresh') {
|
||||||
FFI.bind.sessionRefresh(id: widget.id);
|
_ffi.bind.sessionRefresh(id: widget.id);
|
||||||
} else if (value == 'paste') {
|
} else if (value == 'paste') {
|
||||||
() async {
|
() async {
|
||||||
ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain);
|
ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain);
|
||||||
if (data != null && data.text != null) {
|
if (data != null && data.text != null) {
|
||||||
FFI.bind.sessionInputString(id: widget.id, value: data.text ?? "");
|
_ffi.bind.sessionInputString(id: widget.id, value: data.text ?? "");
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
} else if (value == 'enter_os_password') {
|
} else if (value == 'enter_os_password') {
|
||||||
var password =
|
var password =
|
||||||
await FFI.bind.getSessionOption(id: id, arg: "os-password");
|
await _ffi.bind.getSessionOption(id: id, arg: "os-password");
|
||||||
if (password != null) {
|
if (password != null) {
|
||||||
FFI.bind.sessionInputOsPassword(id: widget.id, value: password);
|
_ffi.bind.sessionInputOsPassword(id: widget.id, value: password);
|
||||||
} else {
|
} else {
|
||||||
showSetOSPassword(widget.id, true);
|
showSetOSPassword(widget.id, true);
|
||||||
}
|
}
|
||||||
} else if (value == 'reset_canvas') {
|
} else if (value == 'reset_canvas') {
|
||||||
FFI.cursorModel.reset();
|
_ffi.cursorModel.reset();
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
@ -733,11 +747,11 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
padding: EdgeInsets.symmetric(vertical: 10),
|
padding: EdgeInsets.symmetric(vertical: 10),
|
||||||
child: GestureHelp(
|
child: GestureHelp(
|
||||||
touchMode: FFI.ffiModel.touchMode,
|
touchMode: _ffi.ffiModel.touchMode,
|
||||||
onTouchModeChange: (t) {
|
onTouchModeChange: (t) {
|
||||||
FFI.ffiModel.toggleTouchMode();
|
_ffi.ffiModel.toggleTouchMode();
|
||||||
final v = FFI.ffiModel.touchMode ? 'Y' : '';
|
final v = _ffi.ffiModel.touchMode ? 'Y' : '';
|
||||||
FFI.bind.sessionPeerOption(
|
_ffi.bind.sessionPeerOption(
|
||||||
id: widget.id, name: "touch-mode", value: v);
|
id: widget.id, name: "touch-mode", value: v);
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
@ -769,21 +783,21 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
style: TextStyle(color: Colors.white, fontSize: 11)),
|
style: TextStyle(color: Colors.white, fontSize: 11)),
|
||||||
onPressed: onPressed);
|
onPressed: onPressed);
|
||||||
};
|
};
|
||||||
final pi = FFI.ffiModel.pi;
|
final pi = _ffi.ffiModel.pi;
|
||||||
final isMac = pi.platform == "Mac OS";
|
final isMac = pi.platform == "Mac OS";
|
||||||
final modifiers = <Widget>[
|
final modifiers = <Widget>[
|
||||||
wrap('Ctrl ', () {
|
wrap('Ctrl ', () {
|
||||||
setState(() => FFI.ctrl = !FFI.ctrl);
|
setState(() => _ffi.ctrl = !_ffi.ctrl);
|
||||||
}, FFI.ctrl),
|
}, _ffi.ctrl),
|
||||||
wrap(' Alt ', () {
|
wrap(' Alt ', () {
|
||||||
setState(() => FFI.alt = !FFI.alt);
|
setState(() => _ffi.alt = !_ffi.alt);
|
||||||
}, FFI.alt),
|
}, _ffi.alt),
|
||||||
wrap('Shift', () {
|
wrap('Shift', () {
|
||||||
setState(() => FFI.shift = !FFI.shift);
|
setState(() => _ffi.shift = !_ffi.shift);
|
||||||
}, FFI.shift),
|
}, _ffi.shift),
|
||||||
wrap(isMac ? ' Cmd ' : ' Win ', () {
|
wrap(isMac ? ' Cmd ' : ' Win ', () {
|
||||||
setState(() => FFI.command = !FFI.command);
|
setState(() => _ffi.command = !_ffi.command);
|
||||||
}, FFI.command),
|
}, _ffi.command),
|
||||||
];
|
];
|
||||||
final keys = <Widget>[
|
final keys = <Widget>[
|
||||||
wrap(
|
wrap(
|
||||||
@ -815,53 +829,53 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
for (var i = 1; i <= 12; ++i) {
|
for (var i = 1; i <= 12; ++i) {
|
||||||
final name = 'F' + i.toString();
|
final name = 'F' + i.toString();
|
||||||
fn.add(wrap(name, () {
|
fn.add(wrap(name, () {
|
||||||
FFI.inputKey('VK_' + name);
|
_ffi.inputKey('VK_' + name);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
final more = <Widget>[
|
final more = <Widget>[
|
||||||
SizedBox(width: 9999),
|
SizedBox(width: 9999),
|
||||||
wrap('Esc', () {
|
wrap('Esc', () {
|
||||||
FFI.inputKey('VK_ESCAPE');
|
_ffi.inputKey('VK_ESCAPE');
|
||||||
}),
|
}),
|
||||||
wrap('Tab', () {
|
wrap('Tab', () {
|
||||||
FFI.inputKey('VK_TAB');
|
_ffi.inputKey('VK_TAB');
|
||||||
}),
|
}),
|
||||||
wrap('Home', () {
|
wrap('Home', () {
|
||||||
FFI.inputKey('VK_HOME');
|
_ffi.inputKey('VK_HOME');
|
||||||
}),
|
}),
|
||||||
wrap('End', () {
|
wrap('End', () {
|
||||||
FFI.inputKey('VK_END');
|
_ffi.inputKey('VK_END');
|
||||||
}),
|
}),
|
||||||
wrap('Del', () {
|
wrap('Del', () {
|
||||||
FFI.inputKey('VK_DELETE');
|
_ffi.inputKey('VK_DELETE');
|
||||||
}),
|
}),
|
||||||
wrap('PgUp', () {
|
wrap('PgUp', () {
|
||||||
FFI.inputKey('VK_PRIOR');
|
_ffi.inputKey('VK_PRIOR');
|
||||||
}),
|
}),
|
||||||
wrap('PgDn', () {
|
wrap('PgDn', () {
|
||||||
FFI.inputKey('VK_NEXT');
|
_ffi.inputKey('VK_NEXT');
|
||||||
}),
|
}),
|
||||||
SizedBox(width: 9999),
|
SizedBox(width: 9999),
|
||||||
wrap('', () {
|
wrap('', () {
|
||||||
FFI.inputKey('VK_LEFT');
|
_ffi.inputKey('VK_LEFT');
|
||||||
}, false, Icons.keyboard_arrow_left),
|
}, false, Icons.keyboard_arrow_left),
|
||||||
wrap('', () {
|
wrap('', () {
|
||||||
FFI.inputKey('VK_UP');
|
_ffi.inputKey('VK_UP');
|
||||||
}, false, Icons.keyboard_arrow_up),
|
}, false, Icons.keyboard_arrow_up),
|
||||||
wrap('', () {
|
wrap('', () {
|
||||||
FFI.inputKey('VK_DOWN');
|
_ffi.inputKey('VK_DOWN');
|
||||||
}, false, Icons.keyboard_arrow_down),
|
}, false, Icons.keyboard_arrow_down),
|
||||||
wrap('', () {
|
wrap('', () {
|
||||||
FFI.inputKey('VK_RIGHT');
|
_ffi.inputKey('VK_RIGHT');
|
||||||
}, false, Icons.keyboard_arrow_right),
|
}, false, Icons.keyboard_arrow_right),
|
||||||
wrap(isMac ? 'Cmd+C' : 'Ctrl+C', () {
|
wrap(isMac ? 'Cmd+C' : 'Ctrl+C', () {
|
||||||
sendPrompt(isMac, 'VK_C');
|
sendPrompt(widget.id, isMac, 'VK_C');
|
||||||
}),
|
}),
|
||||||
wrap(isMac ? 'Cmd+V' : 'Ctrl+V', () {
|
wrap(isMac ? 'Cmd+V' : 'Ctrl+V', () {
|
||||||
sendPrompt(isMac, 'VK_V');
|
sendPrompt(widget.id, isMac, 'VK_V');
|
||||||
}),
|
}),
|
||||||
wrap(isMac ? 'Cmd+S' : 'Ctrl+S', () {
|
wrap(isMac ? 'Cmd+S' : 'Ctrl+S', () {
|
||||||
sendPrompt(isMac, 'VK_S');
|
sendPrompt(widget.id, isMac, 'VK_S');
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
final space = size.width > 320 ? 4.0 : 2.0;
|
final space = size.width > 320 ? 4.0 : 2.0;
|
||||||
@ -884,11 +898,11 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
print("window event: $eventName");
|
print("window event: $eventName");
|
||||||
switch (eventName) {
|
switch (eventName) {
|
||||||
case 'resize':
|
case 'resize':
|
||||||
FFI.canvasModel.updateViewStyle();
|
_ffi.canvasModel.updateViewStyle();
|
||||||
break;
|
break;
|
||||||
case 'maximize':
|
case 'maximize':
|
||||||
Future.delayed(Duration(milliseconds: 100), () {
|
Future.delayed(Duration(milliseconds: 100), () {
|
||||||
FFI.canvasModel.updateViewStyle();
|
_ffi.canvasModel.updateViewStyle();
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -896,11 +910,15 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ImagePaint extends StatelessWidget {
|
class ImagePaint extends StatelessWidget {
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
const ImagePaint({Key? key, required this.id}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final m = Provider.of<ImageModel>(context);
|
final m = ffi(this.id).imageModel;
|
||||||
final c = Provider.of<CanvasModel>(context);
|
final c = ffi(this.id).canvasModel;
|
||||||
final adjust = FFI.cursorModel.adjustForKeyboard();
|
final adjust = ffi(this.id).cursorModel.adjustForKeyboard();
|
||||||
var s = c.scale;
|
var s = c.scale;
|
||||||
return CustomPaint(
|
return CustomPaint(
|
||||||
painter: new ImagePainter(
|
painter: new ImagePainter(
|
||||||
@ -910,11 +928,15 @@ class ImagePaint extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CursorPaint extends StatelessWidget {
|
class CursorPaint extends StatelessWidget {
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
const CursorPaint({Key? key, required this.id}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final m = Provider.of<CursorModel>(context);
|
final m = ffi(this.id).cursorModel;
|
||||||
final c = Provider.of<CanvasModel>(context);
|
final c = ffi(this.id).canvasModel;
|
||||||
final adjust = FFI.cursorModel.adjustForKeyboard();
|
final adjust = ffi(this.id).cursorModel.adjustForKeyboard();
|
||||||
var s = c.scale;
|
var s = c.scale;
|
||||||
return CustomPaint(
|
return CustomPaint(
|
||||||
painter: new ImagePainter(
|
painter: new ImagePainter(
|
||||||
@ -954,12 +976,12 @@ class ImagePainter extends CustomPainter {
|
|||||||
|
|
||||||
CheckboxListTile getToggle(
|
CheckboxListTile getToggle(
|
||||||
String id, void Function(void Function()) setState, option, name) {
|
String id, void Function(void Function()) setState, option, name) {
|
||||||
final opt = FFI.bind.getSessionToggleOptionSync(id: id, arg: option);
|
final opt = ffi(id).bind.getSessionToggleOptionSync(id: id, arg: option);
|
||||||
return CheckboxListTile(
|
return CheckboxListTile(
|
||||||
value: opt,
|
value: opt,
|
||||||
onChanged: (v) {
|
onChanged: (v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
FFI.bind.sessionToggleOption(id: id, value: option);
|
ffi(id).bind.sessionToggleOption(id: id, value: option);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
dense: true,
|
dense: true,
|
||||||
@ -979,13 +1001,14 @@ RadioListTile<String> getRadio(String name, String toValue, String curValue,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showOptions(String id) async {
|
void showOptions(String id) async {
|
||||||
String quality = await FFI.bind.getSessionImageQuality(id: id) ?? 'balanced';
|
String quality =
|
||||||
|
await ffi(id).bind.getSessionImageQuality(id: id) ?? 'balanced';
|
||||||
if (quality == '') quality = 'balanced';
|
if (quality == '') quality = 'balanced';
|
||||||
String viewStyle =
|
String viewStyle =
|
||||||
await FFI.bind.getSessionOption(id: id, arg: 'view-style') ?? '';
|
await ffi(id).bind.getSessionOption(id: id, arg: 'view-style') ?? '';
|
||||||
var displays = <Widget>[];
|
var displays = <Widget>[];
|
||||||
final pi = FFI.ffiModel.pi;
|
final pi = ffi(id).ffiModel.pi;
|
||||||
final image = FFI.ffiModel.getConnectionImage();
|
final image = ffi(id).ffiModel.getConnectionImage();
|
||||||
if (image != null)
|
if (image != null)
|
||||||
displays.add(Padding(padding: const EdgeInsets.only(top: 8), child: image));
|
displays.add(Padding(padding: const EdgeInsets.only(top: 8), child: image));
|
||||||
if (pi.displays.length > 1) {
|
if (pi.displays.length > 1) {
|
||||||
@ -995,7 +1018,7 @@ void showOptions(String id) async {
|
|||||||
children.add(InkWell(
|
children.add(InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (i == cur) return;
|
if (i == cur) return;
|
||||||
FFI.bind.sessionSwitchDisplay(id: id, value: i);
|
ffi(id).bind.sessionSwitchDisplay(id: id, value: i);
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
},
|
},
|
||||||
child: Ink(
|
child: Ink(
|
||||||
@ -1019,7 +1042,7 @@ void showOptions(String id) async {
|
|||||||
if (displays.isNotEmpty) {
|
if (displays.isNotEmpty) {
|
||||||
displays.add(Divider(color: MyTheme.border));
|
displays.add(Divider(color: MyTheme.border));
|
||||||
}
|
}
|
||||||
final perms = FFI.ffiModel.permissions;
|
final perms = ffi(id).ffiModel.permissions;
|
||||||
|
|
||||||
DialogManager.show((setState, close) {
|
DialogManager.show((setState, close) {
|
||||||
final more = <Widget>[];
|
final more = <Widget>[];
|
||||||
@ -1040,15 +1063,17 @@ void showOptions(String id) async {
|
|||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
quality = value;
|
quality = value;
|
||||||
FFI.bind.sessionSetImageQuality(id: id, value: value);
|
ffi(id).bind.sessionSetImageQuality(id: id, value: value);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var setViewStyle = (String? value) {
|
var setViewStyle = (String? value) {
|
||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
viewStyle = value;
|
viewStyle = value;
|
||||||
FFI.bind.sessionPeerOption(id: id, name: "view-style", value: value);
|
ffi(id)
|
||||||
FFI.canvasModel.updateViewStyle();
|
.bind
|
||||||
|
.sessionPeerOption(id: id, name: "view-style", value: value);
|
||||||
|
ffi(id).canvasModel.updateViewStyle();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
@ -1078,9 +1103,9 @@ void showOptions(String id) async {
|
|||||||
void showSetOSPassword(String id, bool login) async {
|
void showSetOSPassword(String id, bool login) async {
|
||||||
final controller = TextEditingController();
|
final controller = TextEditingController();
|
||||||
var password =
|
var password =
|
||||||
await FFI.bind.getSessionOption(id: id, arg: "os-password") ?? "";
|
await ffi(id).bind.getSessionOption(id: id, arg: "os-password") ?? "";
|
||||||
var autoLogin =
|
var autoLogin =
|
||||||
await FFI.bind.getSessionOption(id: id, arg: "auto-login") != "";
|
await ffi(id).bind.getSessionOption(id: id, arg: "auto-login") != "";
|
||||||
controller.text = password;
|
controller.text = password;
|
||||||
DialogManager.show((setState, close) {
|
DialogManager.show((setState, close) {
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
@ -1113,12 +1138,13 @@ void showSetOSPassword(String id, bool login) async {
|
|||||||
style: flatButtonStyle,
|
style: flatButtonStyle,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
var text = controller.text.trim();
|
var text = controller.text.trim();
|
||||||
FFI.bind
|
ffi(id)
|
||||||
|
.bind
|
||||||
.sessionPeerOption(id: id, name: "os-password", value: text);
|
.sessionPeerOption(id: id, name: "os-password", value: text);
|
||||||
FFI.bind.sessionPeerOption(
|
ffi(id).bind.sessionPeerOption(
|
||||||
id: id, name: "auto-login", value: autoLogin ? 'Y' : '');
|
id: id, name: "auto-login", value: autoLogin ? 'Y' : '');
|
||||||
if (text != "" && login) {
|
if (text != "" && login) {
|
||||||
FFI.bind.sessionInputOsPassword(id: id, value: text);
|
ffi(id).bind.sessionInputOsPassword(id: id, value: text);
|
||||||
}
|
}
|
||||||
close();
|
close();
|
||||||
},
|
},
|
||||||
@ -1128,18 +1154,19 @@ void showSetOSPassword(String id, bool login) async {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendPrompt(bool isMac, String key) {
|
void sendPrompt(String id, bool isMac, String key) {
|
||||||
final old = isMac ? FFI.command : FFI.ctrl;
|
FFI _ffi = ffi(id);
|
||||||
|
final old = isMac ? _ffi.command : _ffi.ctrl;
|
||||||
if (isMac) {
|
if (isMac) {
|
||||||
FFI.command = true;
|
_ffi.command = true;
|
||||||
} else {
|
} else {
|
||||||
FFI.ctrl = true;
|
_ffi.ctrl = true;
|
||||||
}
|
}
|
||||||
FFI.inputKey(key);
|
_ffi.inputKey(key);
|
||||||
if (isMac) {
|
if (isMac) {
|
||||||
FFI.command = old;
|
_ffi.command = old;
|
||||||
} else {
|
} else {
|
||||||
FFI.ctrl = old;
|
_ffi.ctrl = old;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hbb/common.dart';
|
import 'package:flutter_hbb/common.dart';
|
||||||
import 'package:flutter_hbb/desktop/pages/connection_tab_page.dart';
|
import 'package:flutter_hbb/desktop/pages/connection_tab_page.dart';
|
||||||
import 'package:flutter_hbb/models/model.dart';
|
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
@ -15,10 +14,10 @@ class DesktopRemoteScreen extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider.value(value: FFI.ffiModel),
|
ChangeNotifierProvider.value(value: gFFI.ffiModel),
|
||||||
ChangeNotifierProvider.value(value: FFI.imageModel),
|
ChangeNotifierProvider.value(value: gFFI.imageModel),
|
||||||
ChangeNotifierProvider.value(value: FFI.cursorModel),
|
ChangeNotifierProvider.value(value: gFFI.cursorModel),
|
||||||
ChangeNotifierProvider.value(value: FFI.canvasModel),
|
ChangeNotifierProvider.value(value: gFFI.canvasModel),
|
||||||
],
|
],
|
||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
navigatorKey: globalKey,
|
navigatorKey: globalKey,
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart';
|
|||||||
import 'package:flutter_hbb/desktop/screen/desktop_remote_screen.dart';
|
import 'package:flutter_hbb/desktop/screen/desktop_remote_screen.dart';
|
||||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:get/route_manager.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
@ -13,13 +14,15 @@ import 'common.dart';
|
|||||||
import 'mobile/pages/home_page.dart';
|
import 'mobile/pages/home_page.dart';
|
||||||
import 'mobile/pages/server_page.dart';
|
import 'mobile/pages/server_page.dart';
|
||||||
import 'mobile/pages/settings_page.dart';
|
import 'mobile/pages/settings_page.dart';
|
||||||
import 'models/model.dart';
|
|
||||||
|
|
||||||
int? windowId;
|
int? windowId;
|
||||||
|
|
||||||
Future<Null> main(List<String> args) async {
|
Future<Null> main(List<String> args) async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await FFI.ffiModel.init();
|
// global FFI, use this **ONLY** for global configuration
|
||||||
|
// for convenience, use global FFI on mobile platform
|
||||||
|
// focus on multi-ffi on desktop first
|
||||||
|
initGlobalFFI();
|
||||||
// await Firebase.initializeApp();
|
// await Firebase.initializeApp();
|
||||||
if (isAndroid) {
|
if (isAndroid) {
|
||||||
toAndroidChannelInit();
|
toAndroidChannelInit();
|
||||||
@ -54,7 +57,7 @@ void runRustDeskApp(List<String> args) async {
|
|||||||
} else {
|
} else {
|
||||||
// disable tray
|
// disable tray
|
||||||
// initTray();
|
// initTray();
|
||||||
FFI.serverModel.startService();
|
gFFI.serverModel.startService();
|
||||||
runApp(App());
|
runApp(App());
|
||||||
doWhenWindowReady(() {
|
doWhenWindowReady(() {
|
||||||
const initialSize = Size(1280, 720);
|
const initialSize = Size(1280, 720);
|
||||||
@ -72,12 +75,13 @@ class App extends StatelessWidget {
|
|||||||
// final analytics = FirebaseAnalytics.instance;
|
// final analytics = FirebaseAnalytics.instance;
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider.value(value: FFI.ffiModel),
|
// TODO remove it, only for compile
|
||||||
ChangeNotifierProvider.value(value: FFI.imageModel),
|
ChangeNotifierProvider.value(value: gFFI.ffiModel),
|
||||||
ChangeNotifierProvider.value(value: FFI.cursorModel),
|
ChangeNotifierProvider.value(value: gFFI.imageModel),
|
||||||
ChangeNotifierProvider.value(value: FFI.canvasModel),
|
ChangeNotifierProvider.value(value: gFFI.cursorModel),
|
||||||
|
ChangeNotifierProvider.value(value: gFFI.canvasModel),
|
||||||
],
|
],
|
||||||
child: MaterialApp(
|
child: GetMaterialApp(
|
||||||
navigatorKey: globalKey,
|
navigatorKey: globalKey,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
title: 'RustDesk',
|
title: 'RustDesk',
|
||||||
@ -88,8 +92,8 @@ class App extends StatelessWidget {
|
|||||||
home: isDesktop
|
home: isDesktop
|
||||||
? DesktopHomePage()
|
? DesktopHomePage()
|
||||||
: !isAndroid
|
: !isAndroid
|
||||||
? WebHomePage()
|
? WebHomePage()
|
||||||
: HomePage(),
|
: HomePage(),
|
||||||
navigatorObservers: [
|
navigatorObservers: [
|
||||||
// FirebaseAnalyticsObserver(analytics: analytics),
|
// FirebaseAnalyticsObserver(analytics: analytics),
|
||||||
FlutterSmartDialog.observer
|
FlutterSmartDialog.observer
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_hbb/common.dart';
|
import 'package:flutter_hbb/common.dart';
|
||||||
import 'package:flutter_hbb/models/chat_model.dart';
|
import 'package:flutter_hbb/models/chat_model.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
import 'home_page.dart';
|
import 'home_page.dart';
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ class ChatPage extends StatelessWidget implements PageShape {
|
|||||||
PopupMenuButton<int>(
|
PopupMenuButton<int>(
|
||||||
icon: Icon(Icons.group),
|
icon: Icon(Icons.group),
|
||||||
itemBuilder: (context) {
|
itemBuilder: (context) {
|
||||||
final chatModel = FFI.chatModel;
|
final chatModel = gFFI.chatModel;
|
||||||
return chatModel.messages.entries.map((entry) {
|
return chatModel.messages.entries.map((entry) {
|
||||||
final id = entry.key;
|
final id = entry.key;
|
||||||
final user = entry.value.chatUser;
|
final user = entry.value.chatUser;
|
||||||
@ -31,14 +32,14 @@ class ChatPage extends StatelessWidget implements PageShape {
|
|||||||
}).toList();
|
}).toList();
|
||||||
},
|
},
|
||||||
onSelected: (id) {
|
onSelected: (id) {
|
||||||
FFI.chatModel.changeCurrentID(id);
|
gFFI.chatModel.changeCurrentID(id);
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
value: FFI.chatModel,
|
value: gFFI.chatModel,
|
||||||
child: Container(
|
child: Container(
|
||||||
color: MyTheme.grayBg,
|
color: MyTheme.grayBg,
|
||||||
child: Consumer<ChatModel>(builder: (context, chatModel, child) {
|
child: Consumer<ChatModel>(builder: (context, chatModel, child) {
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hbb/mobile/pages/file_manager_page.dart';
|
import 'package:flutter_hbb/mobile/pages/file_manager_page.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import 'dart:async';
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
import 'home_page.dart';
|
import 'home_page.dart';
|
||||||
import 'remote_page.dart';
|
import 'remote_page.dart';
|
||||||
import 'settings_page.dart';
|
|
||||||
import 'scan_page.dart';
|
import 'scan_page.dart';
|
||||||
|
import 'settings_page.dart';
|
||||||
|
|
||||||
/// Connection page for connecting to a remote peer.
|
/// Connection page for connecting to a remote peer.
|
||||||
class ConnectionPage extends StatefulWidget implements PageShape {
|
class ConnectionPage extends StatefulWidget implements PageShape {
|
||||||
@ -41,7 +43,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
if (isAndroid) {
|
if (isAndroid) {
|
||||||
Timer(Duration(seconds: 5), () {
|
Timer(Duration(seconds: 5), () {
|
||||||
_updateUrl = FFI.getByName('software_update_url');
|
_updateUrl = gFFI.getByName('software_update_url');
|
||||||
if (_updateUrl.isNotEmpty) setState(() {});
|
if (_updateUrl.isNotEmpty) setState(() {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -50,7 +52,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Provider.of<FfiModel>(context);
|
Provider.of<FfiModel>(context);
|
||||||
if (_idController.text.isEmpty) _idController.text = FFI.getId();
|
if (_idController.text.isEmpty) _idController.text = gFFI.getId();
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@ -220,7 +222,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
width = size.width / n - 2 * space;
|
width = size.width / n - 2 * space;
|
||||||
}
|
}
|
||||||
final cards = <Widget>[];
|
final cards = <Widget>[];
|
||||||
var peers = FFI.peers();
|
var peers = gFFI.peers();
|
||||||
peers.forEach((p) {
|
peers.forEach((p) {
|
||||||
cards.add(Container(
|
cards.add(Container(
|
||||||
width: width,
|
width: width,
|
||||||
@ -278,7 +280,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
elevation: 8,
|
elevation: 8,
|
||||||
);
|
);
|
||||||
if (value == 'remove') {
|
if (value == 'remove') {
|
||||||
setState(() => FFI.setByName('remove', '$id'));
|
setState(() => gFFI.setByName('remove', '$id'));
|
||||||
() async {
|
() async {
|
||||||
removePreference(id);
|
removePreference(id);
|
||||||
}();
|
}();
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
|
||||||
import 'package:flutter_hbb/models/file_model.dart';
|
import 'package:flutter_hbb/models/file_model.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
|
|
||||||
import 'package:wakelock/wakelock.dart';
|
|
||||||
import 'package:toggle_switch/toggle_switch.dart';
|
import 'package:toggle_switch/toggle_switch.dart';
|
||||||
|
import 'package:wakelock/wakelock.dart';
|
||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
@ -20,22 +21,22 @@ class FileManagerPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _FileManagerPageState extends State<FileManagerPage> {
|
class _FileManagerPageState extends State<FileManagerPage> {
|
||||||
final model = FFI.fileModel;
|
final model = gFFI.fileModel;
|
||||||
final _selectedItems = SelectedItems();
|
final _selectedItems = SelectedItems();
|
||||||
final _breadCrumbScroller = ScrollController();
|
final _breadCrumbScroller = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
FFI.connect(widget.id, isFileTransfer: true);
|
gFFI.connect(widget.id, isFileTransfer: true);
|
||||||
FFI.ffiModel.updateEventListener(widget.id);
|
gFFI.ffiModel.updateEventListener(widget.id);
|
||||||
Wakelock.enable();
|
Wakelock.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
model.onClose();
|
model.onClose();
|
||||||
FFI.close();
|
gFFI.close();
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
Wakelock.disable();
|
Wakelock.disable();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@ -43,7 +44,7 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => ChangeNotifierProvider.value(
|
Widget build(BuildContext context) => ChangeNotifierProvider.value(
|
||||||
value: FFI.fileModel,
|
value: gFFI.fileModel,
|
||||||
child: Consumer<FileModel>(builder: (_context, _model, _child) {
|
child: Consumer<FileModel>(builder: (_context, _model, _child) {
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
|
|||||||
@ -46,7 +46,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
FFI.connect(widget.id);
|
gFFI.connect(widget.id);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||||
showLoading(translate('Connecting...'));
|
showLoading(translate('Connecting...'));
|
||||||
@ -55,18 +55,18 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
});
|
});
|
||||||
Wakelock.enable();
|
Wakelock.enable();
|
||||||
_physicalFocusNode.requestFocus();
|
_physicalFocusNode.requestFocus();
|
||||||
FFI.ffiModel.updateEventListener(widget.id);
|
gFFI.ffiModel.updateEventListener(widget.id);
|
||||||
FFI.listenToMouse(true);
|
gFFI.listenToMouse(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
hideMobileActionsOverlay();
|
hideMobileActionsOverlay();
|
||||||
FFI.listenToMouse(false);
|
gFFI.listenToMouse(false);
|
||||||
FFI.invokeMethod("enable_soft_keyboard", true);
|
gFFI.invokeMethod("enable_soft_keyboard", true);
|
||||||
_mobileFocusNode.dispose();
|
_mobileFocusNode.dispose();
|
||||||
_physicalFocusNode.dispose();
|
_physicalFocusNode.dispose();
|
||||||
FFI.close();
|
gFFI.close();
|
||||||
_interval?.cancel();
|
_interval?.cancel();
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
@ -77,7 +77,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void resetTool() {
|
void resetTool() {
|
||||||
FFI.resetModifiers();
|
gFFI.resetModifiers();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isKeyboardShown() {
|
bool isKeyboardShown() {
|
||||||
@ -96,8 +96,8 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
overlays: []);
|
overlays: []);
|
||||||
// [pi.version.isNotEmpty] -> check ready or not,avoid login without soft-keyboard
|
// [pi.version.isNotEmpty] -> check ready or not,avoid login without soft-keyboard
|
||||||
if (chatWindowOverlayEntry == null &&
|
if (chatWindowOverlayEntry == null &&
|
||||||
FFI.ffiModel.pi.version.isNotEmpty) {
|
gFFI.ffiModel.pi.version.isNotEmpty) {
|
||||||
FFI.invokeMethod("enable_soft_keyboard", false);
|
gFFI.invokeMethod("enable_soft_keyboard", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -129,12 +129,12 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
newValue[common] == oldValue[common];
|
newValue[common] == oldValue[common];
|
||||||
++common);
|
++common);
|
||||||
for (i = 0; i < oldValue.length - common; ++i) {
|
for (i = 0; i < oldValue.length - common; ++i) {
|
||||||
FFI.inputKey('VK_BACK');
|
gFFI.inputKey('VK_BACK');
|
||||||
}
|
}
|
||||||
if (newValue.length > common) {
|
if (newValue.length > common) {
|
||||||
var s = newValue.substring(common);
|
var s = newValue.substring(common);
|
||||||
if (s.length > 1) {
|
if (s.length > 1) {
|
||||||
FFI.setByName('input_string', s);
|
gFFI.setByName('input_string', s);
|
||||||
} else {
|
} else {
|
||||||
inputChar(s);
|
inputChar(s);
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
// ?
|
// ?
|
||||||
} else if (newValue.length < oldValue.length) {
|
} else if (newValue.length < oldValue.length) {
|
||||||
final char = 'VK_BACK';
|
final char = 'VK_BACK';
|
||||||
FFI.inputKey(char);
|
gFFI.inputKey(char);
|
||||||
} else {
|
} else {
|
||||||
final content = newValue.substring(oldValue.length);
|
final content = newValue.substring(oldValue.length);
|
||||||
if (content.length > 1) {
|
if (content.length > 1) {
|
||||||
@ -168,11 +168,11 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
content == '()' ||
|
content == '()' ||
|
||||||
content == '【】')) {
|
content == '【】')) {
|
||||||
// can not only input content[0], because when input ], [ are also auo insert, which cause ] never be input
|
// can not only input content[0], because when input ], [ are also auo insert, which cause ] never be input
|
||||||
FFI.setByName('input_string', content);
|
gFFI.setByName('input_string', content);
|
||||||
openKeyboard();
|
openKeyboard();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FFI.setByName('input_string', content);
|
gFFI.setByName('input_string', content);
|
||||||
} else {
|
} else {
|
||||||
inputChar(content);
|
inputChar(content);
|
||||||
}
|
}
|
||||||
@ -185,11 +185,11 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
} else if (char == ' ') {
|
} else if (char == ' ') {
|
||||||
char = 'VK_SPACE';
|
char = 'VK_SPACE';
|
||||||
}
|
}
|
||||||
FFI.inputKey(char);
|
gFFI.inputKey(char);
|
||||||
}
|
}
|
||||||
|
|
||||||
void openKeyboard() {
|
void openKeyboard() {
|
||||||
FFI.invokeMethod("enable_soft_keyboard", true);
|
gFFI.invokeMethod("enable_soft_keyboard", true);
|
||||||
// destroy first, so that our _value trick can work
|
// destroy first, so that our _value trick can work
|
||||||
_value = initText;
|
_value = initText;
|
||||||
setState(() => _showEdit = false);
|
setState(() => _showEdit = false);
|
||||||
@ -212,7 +212,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
final label = _logicalKeyMap[e.logicalKey.keyId] ??
|
final label = _logicalKeyMap[e.logicalKey.keyId] ??
|
||||||
_physicalKeyMap[e.physicalKey.usbHidUsage] ??
|
_physicalKeyMap[e.physicalKey.usbHidUsage] ??
|
||||||
e.logicalKey.keyLabel;
|
e.logicalKey.keyLabel;
|
||||||
FFI.inputKey(label, down: down, press: press ?? false);
|
gFFI.inputKey(label, down: down, press: press ?? false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -220,7 +220,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
final pi = Provider.of<FfiModel>(context).pi;
|
final pi = Provider.of<FfiModel>(context).pi;
|
||||||
final hideKeyboard = isKeyboardShown() && _showEdit;
|
final hideKeyboard = isKeyboardShown() && _showEdit;
|
||||||
final showActionButton = !_showBar || hideKeyboard;
|
final showActionButton = !_showBar || hideKeyboard;
|
||||||
final keyboard = FFI.ffiModel.permissions['keyboard'] != false;
|
final keyboard = gFFI.ffiModel.permissions['keyboard'] != false;
|
||||||
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
@ -230,7 +230,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
child: getRawPointerAndKeyBody(
|
child: getRawPointerAndKeyBody(
|
||||||
keyboard,
|
keyboard,
|
||||||
Scaffold(
|
Scaffold(
|
||||||
// resizeToAvoidBottomInset: true,
|
// resizeToAvoidBottomInset: true,
|
||||||
floatingActionButton: !showActionButton
|
floatingActionButton: !showActionButton
|
||||||
? null
|
? null
|
||||||
: FloatingActionButton(
|
: FloatingActionButton(
|
||||||
@ -241,14 +241,14 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (hideKeyboard) {
|
if (hideKeyboard) {
|
||||||
_showEdit = false;
|
_showEdit = false;
|
||||||
FFI.invokeMethod("enable_soft_keyboard", false);
|
gFFI.invokeMethod("enable_soft_keyboard", false);
|
||||||
_mobileFocusNode.unfocus();
|
_mobileFocusNode.unfocus();
|
||||||
_physicalFocusNode.requestFocus();
|
_physicalFocusNode.requestFocus();
|
||||||
} else {
|
} else {
|
||||||
_showBar = !_showBar;
|
_showBar = !_showBar;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
bottomNavigationBar: _showBar && pi.displays.length > 0
|
bottomNavigationBar: _showBar && pi.displays.length > 0
|
||||||
? getBottomAppBar(keyboard)
|
? getBottomAppBar(keyboard)
|
||||||
@ -282,7 +282,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_isPhysicalMouse) {
|
if (_isPhysicalMouse) {
|
||||||
FFI.handleMouse(getEvent(e, 'mousemove'));
|
gFFI.handleMouse(getEvent(e, 'mousemove'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPointerDown: (e) {
|
onPointerDown: (e) {
|
||||||
@ -294,19 +294,19 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_isPhysicalMouse) {
|
if (_isPhysicalMouse) {
|
||||||
FFI.handleMouse(getEvent(e, 'mousedown'));
|
gFFI.handleMouse(getEvent(e, 'mousedown'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPointerUp: (e) {
|
onPointerUp: (e) {
|
||||||
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
||||||
if (_isPhysicalMouse) {
|
if (_isPhysicalMouse) {
|
||||||
FFI.handleMouse(getEvent(e, 'mouseup'));
|
gFFI.handleMouse(getEvent(e, 'mouseup'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPointerMove: (e) {
|
onPointerMove: (e) {
|
||||||
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
||||||
if (_isPhysicalMouse) {
|
if (_isPhysicalMouse) {
|
||||||
FFI.handleMouse(getEvent(e, 'mousemove'));
|
gFFI.handleMouse(getEvent(e, 'mousemove'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPointerSignal: (e) {
|
onPointerSignal: (e) {
|
||||||
@ -319,7 +319,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
if (dy > 0)
|
if (dy > 0)
|
||||||
dy = -1;
|
dy = -1;
|
||||||
else if (dy < 0) dy = 1;
|
else if (dy < 0) dy = 1;
|
||||||
FFI.setByName(
|
gFFI.setByName(
|
||||||
'send_mouse', '{"type": "wheel", "x": "$dx", "y": "$dy"}');
|
'send_mouse', '{"type": "wheel", "x": "$dx", "y": "$dy"}');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -337,14 +337,14 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
if (e.repeat) {
|
if (e.repeat) {
|
||||||
sendRawKey(e, press: true);
|
sendRawKey(e, press: true);
|
||||||
} else {
|
} else {
|
||||||
if (e.isAltPressed && !FFI.alt) {
|
if (e.isAltPressed && !gFFI.alt) {
|
||||||
FFI.alt = true;
|
gFFI.alt = true;
|
||||||
} else if (e.isControlPressed && !FFI.ctrl) {
|
} else if (e.isControlPressed && !gFFI.ctrl) {
|
||||||
FFI.ctrl = true;
|
gFFI.ctrl = true;
|
||||||
} else if (e.isShiftPressed && !FFI.shift) {
|
} else if (e.isShiftPressed && !gFFI.shift) {
|
||||||
FFI.shift = true;
|
gFFI.shift = true;
|
||||||
} else if (e.isMetaPressed && !FFI.command) {
|
} else if (e.isMetaPressed && !gFFI.command) {
|
||||||
FFI.command = true;
|
gFFI.command = true;
|
||||||
}
|
}
|
||||||
sendRawKey(e, down: true);
|
sendRawKey(e, down: true);
|
||||||
}
|
}
|
||||||
@ -353,16 +353,16 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
if (!_showEdit && e is RawKeyUpEvent) {
|
if (!_showEdit && e is RawKeyUpEvent) {
|
||||||
if (key == LogicalKeyboardKey.altLeft ||
|
if (key == LogicalKeyboardKey.altLeft ||
|
||||||
key == LogicalKeyboardKey.altRight) {
|
key == LogicalKeyboardKey.altRight) {
|
||||||
FFI.alt = false;
|
gFFI.alt = false;
|
||||||
} else if (key == LogicalKeyboardKey.controlLeft ||
|
} else if (key == LogicalKeyboardKey.controlLeft ||
|
||||||
key == LogicalKeyboardKey.controlRight) {
|
key == LogicalKeyboardKey.controlRight) {
|
||||||
FFI.ctrl = false;
|
gFFI.ctrl = false;
|
||||||
} else if (key == LogicalKeyboardKey.shiftRight ||
|
} else if (key == LogicalKeyboardKey.shiftRight ||
|
||||||
key == LogicalKeyboardKey.shiftLeft) {
|
key == LogicalKeyboardKey.shiftLeft) {
|
||||||
FFI.shift = false;
|
gFFI.shift = false;
|
||||||
} else if (key == LogicalKeyboardKey.metaLeft ||
|
} else if (key == LogicalKeyboardKey.metaLeft ||
|
||||||
key == LogicalKeyboardKey.metaRight) {
|
key == LogicalKeyboardKey.metaRight) {
|
||||||
FFI.command = false;
|
gFFI.command = false;
|
||||||
}
|
}
|
||||||
sendRawKey(e);
|
sendRawKey(e);
|
||||||
}
|
}
|
||||||
@ -401,32 +401,32 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
] +
|
] +
|
||||||
(isWebDesktop
|
(isWebDesktop
|
||||||
? []
|
? []
|
||||||
: FFI.ffiModel.isPeerAndroid
|
: gFFI.ffiModel.isPeerAndroid
|
||||||
? [
|
? [
|
||||||
IconButton(
|
IconButton(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
icon: Icon(Icons.build),
|
icon: Icon(Icons.build),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (mobileActionsOverlayEntry == null) {
|
if (mobileActionsOverlayEntry == null) {
|
||||||
showMobileActionsOverlay();
|
showMobileActionsOverlay();
|
||||||
} else {
|
} else {
|
||||||
hideMobileActionsOverlay();
|
hideMobileActionsOverlay();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
IconButton(
|
IconButton(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
icon: Icon(Icons.keyboard),
|
icon: Icon(Icons.keyboard),
|
||||||
onPressed: openKeyboard),
|
onPressed: openKeyboard),
|
||||||
IconButton(
|
IconButton(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
icon: Icon(FFI.ffiModel.touchMode
|
icon: Icon(gFFI.ffiModel.touchMode
|
||||||
? Icons.touch_app
|
? Icons.touch_app
|
||||||
: Icons.mouse),
|
: Icons.mouse),
|
||||||
onPressed: changeTouchMode,
|
onPressed: changeTouchMode,
|
||||||
),
|
),
|
||||||
]) +
|
]) +
|
||||||
(isWeb
|
(isWeb
|
||||||
? []
|
? []
|
||||||
@ -435,10 +435,10 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
icon: Icon(Icons.message),
|
icon: Icon(Icons.message),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
FFI.chatModel
|
gFFI.chatModel
|
||||||
.changeCurrentID(ChatModel.clientModeID);
|
.changeCurrentID(ChatModel.clientModeID);
|
||||||
toggleChatOverlay();
|
toggleChatOverlay();
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
]) +
|
]) +
|
||||||
[
|
[
|
||||||
@ -473,91 +473,91 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
/// HoldDrag -> left drag
|
/// HoldDrag -> left drag
|
||||||
|
|
||||||
Widget getBodyForMobileWithGesture() {
|
Widget getBodyForMobileWithGesture() {
|
||||||
final touchMode = FFI.ffiModel.touchMode;
|
final touchMode = gFFI.ffiModel.touchMode;
|
||||||
return getMixinGestureDetector(
|
return getMixinGestureDetector(
|
||||||
child: getBodyForMobile(),
|
child: getBodyForMobile(),
|
||||||
onTapUp: (d) {
|
onTapUp: (d) {
|
||||||
if (touchMode) {
|
if (touchMode) {
|
||||||
FFI.cursorModel.touch(
|
gFFI.cursorModel.touch(
|
||||||
d.localPosition.dx, d.localPosition.dy, MouseButtons.left);
|
d.localPosition.dx, d.localPosition.dy, MouseButtons.left);
|
||||||
} else {
|
} else {
|
||||||
FFI.tap(MouseButtons.left);
|
gFFI.tap(MouseButtons.left);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDoubleTapDown: (d) {
|
onDoubleTapDown: (d) {
|
||||||
if (touchMode) {
|
if (touchMode) {
|
||||||
FFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
gFFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDoubleTap: () {
|
onDoubleTap: () {
|
||||||
FFI.tap(MouseButtons.left);
|
gFFI.tap(MouseButtons.left);
|
||||||
FFI.tap(MouseButtons.left);
|
gFFI.tap(MouseButtons.left);
|
||||||
},
|
},
|
||||||
onLongPressDown: (d) {
|
onLongPressDown: (d) {
|
||||||
if (touchMode) {
|
if (touchMode) {
|
||||||
FFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
gFFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
FFI.tap(MouseButtons.right);
|
gFFI.tap(MouseButtons.right);
|
||||||
},
|
},
|
||||||
onDoubleFinerTap: (d) {
|
onDoubleFinerTap: (d) {
|
||||||
if (!touchMode) {
|
if (!touchMode) {
|
||||||
FFI.tap(MouseButtons.right);
|
gFFI.tap(MouseButtons.right);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onHoldDragStart: (d) {
|
onHoldDragStart: (d) {
|
||||||
if (!touchMode) {
|
if (!touchMode) {
|
||||||
FFI.sendMouse('down', MouseButtons.left);
|
gFFI.sendMouse('down', MouseButtons.left);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onHoldDragUpdate: (d) {
|
onHoldDragUpdate: (d) {
|
||||||
if (!touchMode) {
|
if (!touchMode) {
|
||||||
FFI.cursorModel.updatePan(d.delta.dx, d.delta.dy, touchMode);
|
gFFI.cursorModel.updatePan(d.delta.dx, d.delta.dy, touchMode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onHoldDragEnd: (_) {
|
onHoldDragEnd: (_) {
|
||||||
if (!touchMode) {
|
if (!touchMode) {
|
||||||
FFI.sendMouse('up', MouseButtons.left);
|
gFFI.sendMouse('up', MouseButtons.left);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onOneFingerPanStart: (d) {
|
onOneFingerPanStart: (d) {
|
||||||
if (touchMode) {
|
if (touchMode) {
|
||||||
FFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
gFFI.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||||
FFI.sendMouse('down', MouseButtons.left);
|
gFFI.sendMouse('down', MouseButtons.left);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onOneFingerPanUpdate: (d) {
|
onOneFingerPanUpdate: (d) {
|
||||||
FFI.cursorModel.updatePan(d.delta.dx, d.delta.dy, touchMode);
|
gFFI.cursorModel.updatePan(d.delta.dx, d.delta.dy, touchMode);
|
||||||
},
|
},
|
||||||
onOneFingerPanEnd: (d) {
|
onOneFingerPanEnd: (d) {
|
||||||
if (touchMode) {
|
if (touchMode) {
|
||||||
FFI.sendMouse('up', MouseButtons.left);
|
gFFI.sendMouse('up', MouseButtons.left);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// scale + pan event
|
// scale + pan event
|
||||||
onTwoFingerScaleUpdate: (d) {
|
onTwoFingerScaleUpdate: (d) {
|
||||||
FFI.canvasModel.updateScale(d.scale / _scale);
|
gFFI.canvasModel.updateScale(d.scale / _scale);
|
||||||
_scale = d.scale;
|
_scale = d.scale;
|
||||||
FFI.canvasModel.panX(d.focalPointDelta.dx);
|
gFFI.canvasModel.panX(d.focalPointDelta.dx);
|
||||||
FFI.canvasModel.panY(d.focalPointDelta.dy);
|
gFFI.canvasModel.panY(d.focalPointDelta.dy);
|
||||||
},
|
},
|
||||||
onTwoFingerScaleEnd: (d) {
|
onTwoFingerScaleEnd: (d) {
|
||||||
_scale = 1;
|
_scale = 1;
|
||||||
FFI.setByName('peer_option', '{"name": "view-style", "value": ""}');
|
gFFI.setByName('peer_option', '{"name": "view-style", "value": ""}');
|
||||||
},
|
},
|
||||||
onThreeFingerVerticalDragUpdate: FFI.ffiModel.isPeerAndroid
|
onThreeFingerVerticalDragUpdate: gFFI.ffiModel.isPeerAndroid
|
||||||
? null
|
? null
|
||||||
: (d) {
|
: (d) {
|
||||||
_mouseScrollIntegral += d.delta.dy / 4;
|
_mouseScrollIntegral += d.delta.dy / 4;
|
||||||
if (_mouseScrollIntegral > 1) {
|
if (_mouseScrollIntegral > 1) {
|
||||||
FFI.scroll(1);
|
gFFI.scroll(1);
|
||||||
_mouseScrollIntegral = 0;
|
_mouseScrollIntegral = 0;
|
||||||
} else if (_mouseScrollIntegral < -1) {
|
} else if (_mouseScrollIntegral < -1) {
|
||||||
FFI.scroll(-1);
|
gFFI.scroll(-1);
|
||||||
_mouseScrollIntegral = 0;
|
_mouseScrollIntegral = 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getBodyForMobile() {
|
Widget getBodyForMobile() {
|
||||||
@ -591,7 +591,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
Widget getBodyForDesktopWithListener(bool keyboard) {
|
Widget getBodyForDesktopWithListener(bool keyboard) {
|
||||||
var paints = <Widget>[ImagePaint()];
|
var paints = <Widget>[ImagePaint()];
|
||||||
if (keyboard ||
|
if (keyboard ||
|
||||||
FFI.getByName('toggle_option', 'show-remote-cursor') == 'true') {
|
gFFI.getByName('toggle_option', 'show-remote-cursor') == 'true') {
|
||||||
paints.add(CursorPaint());
|
paints.add(CursorPaint());
|
||||||
}
|
}
|
||||||
return Container(
|
return Container(
|
||||||
@ -605,10 +605,10 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
out['type'] = type;
|
out['type'] = type;
|
||||||
out['x'] = evt.position.dx;
|
out['x'] = evt.position.dx;
|
||||||
out['y'] = evt.position.dy;
|
out['y'] = evt.position.dy;
|
||||||
if (FFI.alt) out['alt'] = 'true';
|
if (gFFI.alt) out['alt'] = 'true';
|
||||||
if (FFI.shift) out['shift'] = 'true';
|
if (gFFI.shift) out['shift'] = 'true';
|
||||||
if (FFI.ctrl) out['ctrl'] = 'true';
|
if (gFFI.ctrl) out['ctrl'] = 'true';
|
||||||
if (FFI.command) out['command'] = 'true';
|
if (gFFI.command) out['command'] = 'true';
|
||||||
out['buttons'] = evt
|
out['buttons'] = evt
|
||||||
.buttons; // left button: 1, right button: 2, middle button: 4, 1 | 2 = 3 (left + right)
|
.buttons; // left button: 1, right button: 2, middle button: 4, 1 | 2 = 3 (left + right)
|
||||||
if (evt.buttons != 0) {
|
if (evt.buttons != 0) {
|
||||||
@ -624,8 +624,8 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
final x = 120.0;
|
final x = 120.0;
|
||||||
final y = size.height;
|
final y = size.height;
|
||||||
final more = <PopupMenuItem<String>>[];
|
final more = <PopupMenuItem<String>>[];
|
||||||
final pi = FFI.ffiModel.pi;
|
final pi = gFFI.ffiModel.pi;
|
||||||
final perms = FFI.ffiModel.permissions;
|
final perms = gFFI.ffiModel.permissions;
|
||||||
if (pi.version.isNotEmpty) {
|
if (pi.version.isNotEmpty) {
|
||||||
more.add(PopupMenuItem<String>(
|
more.add(PopupMenuItem<String>(
|
||||||
child: Text(translate('Refresh')), value: 'refresh'));
|
child: Text(translate('Refresh')), value: 'refresh'));
|
||||||
@ -633,16 +633,16 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
more.add(PopupMenuItem<String>(
|
more.add(PopupMenuItem<String>(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: ([
|
children: ([
|
||||||
Container(width: 100.0, child: Text(translate('OS Password'))),
|
Container(width: 100.0, child: Text(translate('OS Password'))),
|
||||||
TextButton(
|
TextButton(
|
||||||
style: flatButtonStyle,
|
style: flatButtonStyle,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
showSetOSPassword(false);
|
showSetOSPassword(false);
|
||||||
},
|
},
|
||||||
child: Icon(Icons.edit, color: MyTheme.accent),
|
child: Icon(Icons.edit, color: MyTheme.accent),
|
||||||
)
|
)
|
||||||
])),
|
])),
|
||||||
value: 'enter_os_password'));
|
value: 'enter_os_password'));
|
||||||
if (!isWebDesktop) {
|
if (!isWebDesktop) {
|
||||||
if (perms['keyboard'] != false && perms['clipboard'] != false) {
|
if (perms['keyboard'] != false && perms['clipboard'] != false) {
|
||||||
@ -661,10 +661,10 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
more.add(PopupMenuItem<String>(
|
more.add(PopupMenuItem<String>(
|
||||||
child: Text(translate('Insert Lock')), value: 'lock'));
|
child: Text(translate('Insert Lock')), value: 'lock'));
|
||||||
if (pi.platform == 'Windows' &&
|
if (pi.platform == 'Windows' &&
|
||||||
FFI.getByName('toggle_option', 'privacy-mode') != 'true') {
|
gFFI.getByName('toggle_option', 'privacy-mode') != 'true') {
|
||||||
more.add(PopupMenuItem<String>(
|
more.add(PopupMenuItem<String>(
|
||||||
child: Text(translate(
|
child: Text(translate((gFFI.ffiModel.inputBlocked ? 'Unb' : 'B') +
|
||||||
(FFI.ffiModel.inputBlocked ? 'Unb' : 'B') + 'lock user input')),
|
'lock user input')),
|
||||||
value: 'block-input'));
|
value: 'block-input'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -676,31 +676,31 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
elevation: 8,
|
elevation: 8,
|
||||||
);
|
);
|
||||||
if (value == 'cad') {
|
if (value == 'cad') {
|
||||||
FFI.setByName('ctrl_alt_del');
|
gFFI.setByName('ctrl_alt_del');
|
||||||
} else if (value == 'lock') {
|
} else if (value == 'lock') {
|
||||||
FFI.setByName('lock_screen');
|
gFFI.setByName('lock_screen');
|
||||||
} else if (value == 'block-input') {
|
} else if (value == 'block-input') {
|
||||||
FFI.setByName('toggle_option',
|
gFFI.setByName('toggle_option',
|
||||||
(FFI.ffiModel.inputBlocked ? 'un' : '') + 'block-input');
|
(gFFI.ffiModel.inputBlocked ? 'un' : '') + 'block-input');
|
||||||
FFI.ffiModel.inputBlocked = !FFI.ffiModel.inputBlocked;
|
gFFI.ffiModel.inputBlocked = !gFFI.ffiModel.inputBlocked;
|
||||||
} else if (value == 'refresh') {
|
} else if (value == 'refresh') {
|
||||||
FFI.setByName('refresh');
|
gFFI.setByName('refresh');
|
||||||
} else if (value == 'paste') {
|
} else if (value == 'paste') {
|
||||||
() async {
|
() async {
|
||||||
ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain);
|
ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain);
|
||||||
if (data != null && data.text != null) {
|
if (data != null && data.text != null) {
|
||||||
FFI.setByName('input_string', '${data.text}');
|
gFFI.setByName('input_string', '${data.text}');
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
} else if (value == 'enter_os_password') {
|
} else if (value == 'enter_os_password') {
|
||||||
var password = FFI.getByName('peer_option', "os-password");
|
var password = gFFI.getByName('peer_option', "os-password");
|
||||||
if (password != "") {
|
if (password != "") {
|
||||||
FFI.setByName('input_os_password', password);
|
gFFI.setByName('input_os_password', password);
|
||||||
} else {
|
} else {
|
||||||
showSetOSPassword(true);
|
showSetOSPassword(true);
|
||||||
}
|
}
|
||||||
} else if (value == 'reset_canvas') {
|
} else if (value == 'reset_canvas') {
|
||||||
FFI.cursorModel.reset();
|
gFFI.cursorModel.reset();
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
@ -719,11 +719,11 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
padding: EdgeInsets.symmetric(vertical: 10),
|
padding: EdgeInsets.symmetric(vertical: 10),
|
||||||
child: GestureHelp(
|
child: GestureHelp(
|
||||||
touchMode: FFI.ffiModel.touchMode,
|
touchMode: gFFI.ffiModel.touchMode,
|
||||||
onTouchModeChange: (t) {
|
onTouchModeChange: (t) {
|
||||||
FFI.ffiModel.toggleTouchMode();
|
gFFI.ffiModel.toggleTouchMode();
|
||||||
final v = FFI.ffiModel.touchMode ? 'Y' : '';
|
final v = gFFI.ffiModel.touchMode ? 'Y' : '';
|
||||||
FFI.setByName('peer_option',
|
gFFI.setByName('peer_option',
|
||||||
'{"name": "touch-mode", "value": "$v"}');
|
'{"name": "touch-mode", "value": "$v"}');
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
@ -752,24 +752,24 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
child: icon != null
|
child: icon != null
|
||||||
? Icon(icon, size: 17, color: Colors.white)
|
? Icon(icon, size: 17, color: Colors.white)
|
||||||
: Text(translate(text),
|
: Text(translate(text),
|
||||||
style: TextStyle(color: Colors.white, fontSize: 11)),
|
style: TextStyle(color: Colors.white, fontSize: 11)),
|
||||||
onPressed: onPressed);
|
onPressed: onPressed);
|
||||||
};
|
};
|
||||||
final pi = FFI.ffiModel.pi;
|
final pi = gFFI.ffiModel.pi;
|
||||||
final isMac = pi.platform == "Mac OS";
|
final isMac = pi.platform == "Mac OS";
|
||||||
final modifiers = <Widget>[
|
final modifiers = <Widget>[
|
||||||
wrap('Ctrl ', () {
|
wrap('Ctrl ', () {
|
||||||
setState(() => FFI.ctrl = !FFI.ctrl);
|
setState(() => gFFI.ctrl = !gFFI.ctrl);
|
||||||
}, FFI.ctrl),
|
}, gFFI.ctrl),
|
||||||
wrap(' Alt ', () {
|
wrap(' Alt ', () {
|
||||||
setState(() => FFI.alt = !FFI.alt);
|
setState(() => gFFI.alt = !gFFI.alt);
|
||||||
}, FFI.alt),
|
}, gFFI.alt),
|
||||||
wrap('Shift', () {
|
wrap('Shift', () {
|
||||||
setState(() => FFI.shift = !FFI.shift);
|
setState(() => gFFI.shift = !gFFI.shift);
|
||||||
}, FFI.shift),
|
}, gFFI.shift),
|
||||||
wrap(isMac ? ' Cmd ' : ' Win ', () {
|
wrap(isMac ? ' Cmd ' : ' Win ', () {
|
||||||
setState(() => FFI.command = !FFI.command);
|
setState(() => gFFI.command = !gFFI.command);
|
||||||
}, FFI.command),
|
}, gFFI.command),
|
||||||
];
|
];
|
||||||
final keys = <Widget>[
|
final keys = <Widget>[
|
||||||
wrap(
|
wrap(
|
||||||
@ -801,44 +801,44 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
for (var i = 1; i <= 12; ++i) {
|
for (var i = 1; i <= 12; ++i) {
|
||||||
final name = 'F' + i.toString();
|
final name = 'F' + i.toString();
|
||||||
fn.add(wrap(name, () {
|
fn.add(wrap(name, () {
|
||||||
FFI.inputKey('VK_' + name);
|
gFFI.inputKey('VK_' + name);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
final more = <Widget>[
|
final more = <Widget>[
|
||||||
SizedBox(width: 9999),
|
SizedBox(width: 9999),
|
||||||
wrap('Esc', () {
|
wrap('Esc', () {
|
||||||
FFI.inputKey('VK_ESCAPE');
|
gFFI.inputKey('VK_ESCAPE');
|
||||||
}),
|
}),
|
||||||
wrap('Tab', () {
|
wrap('Tab', () {
|
||||||
FFI.inputKey('VK_TAB');
|
gFFI.inputKey('VK_TAB');
|
||||||
}),
|
}),
|
||||||
wrap('Home', () {
|
wrap('Home', () {
|
||||||
FFI.inputKey('VK_HOME');
|
gFFI.inputKey('VK_HOME');
|
||||||
}),
|
}),
|
||||||
wrap('End', () {
|
wrap('End', () {
|
||||||
FFI.inputKey('VK_END');
|
gFFI.inputKey('VK_END');
|
||||||
}),
|
}),
|
||||||
wrap('Del', () {
|
wrap('Del', () {
|
||||||
FFI.inputKey('VK_DELETE');
|
gFFI.inputKey('VK_DELETE');
|
||||||
}),
|
}),
|
||||||
wrap('PgUp', () {
|
wrap('PgUp', () {
|
||||||
FFI.inputKey('VK_PRIOR');
|
gFFI.inputKey('VK_PRIOR');
|
||||||
}),
|
}),
|
||||||
wrap('PgDn', () {
|
wrap('PgDn', () {
|
||||||
FFI.inputKey('VK_NEXT');
|
gFFI.inputKey('VK_NEXT');
|
||||||
}),
|
}),
|
||||||
SizedBox(width: 9999),
|
SizedBox(width: 9999),
|
||||||
wrap('', () {
|
wrap('', () {
|
||||||
FFI.inputKey('VK_LEFT');
|
gFFI.inputKey('VK_LEFT');
|
||||||
}, false, Icons.keyboard_arrow_left),
|
}, false, Icons.keyboard_arrow_left),
|
||||||
wrap('', () {
|
wrap('', () {
|
||||||
FFI.inputKey('VK_UP');
|
gFFI.inputKey('VK_UP');
|
||||||
}, false, Icons.keyboard_arrow_up),
|
}, false, Icons.keyboard_arrow_up),
|
||||||
wrap('', () {
|
wrap('', () {
|
||||||
FFI.inputKey('VK_DOWN');
|
gFFI.inputKey('VK_DOWN');
|
||||||
}, false, Icons.keyboard_arrow_down),
|
}, false, Icons.keyboard_arrow_down),
|
||||||
wrap('', () {
|
wrap('', () {
|
||||||
FFI.inputKey('VK_RIGHT');
|
gFFI.inputKey('VK_RIGHT');
|
||||||
}, false, Icons.keyboard_arrow_right),
|
}, false, Icons.keyboard_arrow_right),
|
||||||
wrap(isMac ? 'Cmd+C' : 'Ctrl+C', () {
|
wrap(isMac ? 'Cmd+C' : 'Ctrl+C', () {
|
||||||
sendPrompt(isMac, 'VK_C');
|
sendPrompt(isMac, 'VK_C');
|
||||||
@ -871,7 +871,7 @@ class ImagePaint extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final m = Provider.of<ImageModel>(context);
|
final m = Provider.of<ImageModel>(context);
|
||||||
final c = Provider.of<CanvasModel>(context);
|
final c = Provider.of<CanvasModel>(context);
|
||||||
final adjust = FFI.cursorModel.adjustForKeyboard();
|
final adjust = gFFI.cursorModel.adjustForKeyboard();
|
||||||
var s = c.scale;
|
var s = c.scale;
|
||||||
return CustomPaint(
|
return CustomPaint(
|
||||||
painter: new ImagePainter(
|
painter: new ImagePainter(
|
||||||
@ -885,7 +885,7 @@ class CursorPaint extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final m = Provider.of<CursorModel>(context);
|
final m = Provider.of<CursorModel>(context);
|
||||||
final c = Provider.of<CanvasModel>(context);
|
final c = Provider.of<CanvasModel>(context);
|
||||||
final adjust = FFI.cursorModel.adjustForKeyboard();
|
final adjust = gFFI.cursorModel.adjustForKeyboard();
|
||||||
var s = c.scale;
|
var s = c.scale;
|
||||||
return CustomPaint(
|
return CustomPaint(
|
||||||
painter: new ImagePainter(
|
painter: new ImagePainter(
|
||||||
@ -925,10 +925,10 @@ class ImagePainter extends CustomPainter {
|
|||||||
|
|
||||||
CheckboxListTile getToggle(void Function(void Function()) setState, option, name) {
|
CheckboxListTile getToggle(void Function(void Function()) setState, option, name) {
|
||||||
return CheckboxListTile(
|
return CheckboxListTile(
|
||||||
value: FFI.getByName('toggle_option', option) == 'true',
|
value: gFFI.getByName('toggle_option', option) == 'true',
|
||||||
onChanged: (v) {
|
onChanged: (v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
FFI.setByName('toggle_option', option);
|
gFFI.setByName('toggle_option', option);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
dense: true,
|
dense: true,
|
||||||
@ -948,12 +948,12 @@ RadioListTile<String> getRadio(String name, String toValue, String curValue,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showOptions() {
|
void showOptions() {
|
||||||
String quality = FFI.getByName('image_quality');
|
String quality = gFFI.getByName('image_quality');
|
||||||
if (quality == '') quality = 'balanced';
|
if (quality == '') quality = 'balanced';
|
||||||
String viewStyle = FFI.getByName('peer_option', 'view-style');
|
String viewStyle = gFFI.getByName('peer_option', 'view-style');
|
||||||
var displays = <Widget>[];
|
var displays = <Widget>[];
|
||||||
final pi = FFI.ffiModel.pi;
|
final pi = gFFI.ffiModel.pi;
|
||||||
final image = FFI.ffiModel.getConnectionImage();
|
final image = gFFI.ffiModel.getConnectionImage();
|
||||||
if (image != null)
|
if (image != null)
|
||||||
displays.add(Padding(padding: const EdgeInsets.only(top: 8), child: image));
|
displays.add(Padding(padding: const EdgeInsets.only(top: 8), child: image));
|
||||||
if (pi.displays.length > 1) {
|
if (pi.displays.length > 1) {
|
||||||
@ -963,7 +963,7 @@ void showOptions() {
|
|||||||
children.add(InkWell(
|
children.add(InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (i == cur) return;
|
if (i == cur) return;
|
||||||
FFI.setByName('switch_display', i.toString());
|
gFFI.setByName('switch_display', i.toString());
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
},
|
},
|
||||||
child: Ink(
|
child: Ink(
|
||||||
@ -987,7 +987,7 @@ void showOptions() {
|
|||||||
if (displays.isNotEmpty) {
|
if (displays.isNotEmpty) {
|
||||||
displays.add(Divider(color: MyTheme.border));
|
displays.add(Divider(color: MyTheme.border));
|
||||||
}
|
}
|
||||||
final perms = FFI.ffiModel.permissions;
|
final perms = gFFI.ffiModel.permissions;
|
||||||
|
|
||||||
DialogManager.show((setState, close) {
|
DialogManager.show((setState, close) {
|
||||||
final more = <Widget>[];
|
final more = <Widget>[];
|
||||||
@ -1007,16 +1007,16 @@ void showOptions() {
|
|||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
quality = value;
|
quality = value;
|
||||||
FFI.setByName('image_quality', value);
|
gFFI.setByName('image_quality', value);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var setViewStyle = (String? value) {
|
var setViewStyle = (String? value) {
|
||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
viewStyle = value;
|
viewStyle = value;
|
||||||
FFI.setByName(
|
gFFI.setByName(
|
||||||
'peer_option', '{"name": "view-style", "value": "$value"}');
|
'peer_option', '{"name": "view-style", "value": "$value"}');
|
||||||
FFI.canvasModel.updateViewStyle();
|
gFFI.canvasModel.updateViewStyle();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
@ -1044,8 +1044,8 @@ void showOptions() {
|
|||||||
|
|
||||||
void showSetOSPassword(bool login) {
|
void showSetOSPassword(bool login) {
|
||||||
final controller = TextEditingController();
|
final controller = TextEditingController();
|
||||||
var password = FFI.getByName('peer_option', "os-password");
|
var password = gFFI.getByName('peer_option', "os-password");
|
||||||
var autoLogin = FFI.getByName('peer_option', "auto-login") != "";
|
var autoLogin = gFFI.getByName('peer_option', "auto-login") != "";
|
||||||
controller.text = password;
|
controller.text = password;
|
||||||
DialogManager.show((setState, close) {
|
DialogManager.show((setState, close) {
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
@ -1078,12 +1078,12 @@ void showSetOSPassword(bool login) {
|
|||||||
style: flatButtonStyle,
|
style: flatButtonStyle,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
var text = controller.text.trim();
|
var text = controller.text.trim();
|
||||||
FFI.setByName(
|
gFFI.setByName(
|
||||||
'peer_option', '{"name": "os-password", "value": "$text"}');
|
'peer_option', '{"name": "os-password", "value": "$text"}');
|
||||||
FFI.setByName('peer_option',
|
gFFI.setByName('peer_option',
|
||||||
'{"name": "auto-login", "value": "${autoLogin ? 'Y' : ''}"}');
|
'{"name": "auto-login", "value": "${autoLogin ? 'Y' : ''}"}');
|
||||||
if (text != "" && login) {
|
if (text != "" && login) {
|
||||||
FFI.setByName('input_os_password', text);
|
gFFI.setByName('input_os_password', text);
|
||||||
}
|
}
|
||||||
close();
|
close();
|
||||||
},
|
},
|
||||||
@ -1094,17 +1094,17 @@ void showSetOSPassword(bool login) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sendPrompt(bool isMac, String key) {
|
void sendPrompt(bool isMac, String key) {
|
||||||
final old = isMac ? FFI.command : FFI.ctrl;
|
final old = isMac ? gFFI.command : gFFI.ctrl;
|
||||||
if (isMac) {
|
if (isMac) {
|
||||||
FFI.command = true;
|
gFFI.command = true;
|
||||||
} else {
|
} else {
|
||||||
FFI.ctrl = true;
|
gFFI.ctrl = true;
|
||||||
}
|
}
|
||||||
FFI.inputKey(key);
|
gFFI.inputKey(key);
|
||||||
if (isMac) {
|
if (isMac) {
|
||||||
FFI.command = old;
|
gFFI.command = old;
|
||||||
} else {
|
} else {
|
||||||
FFI.ctrl = old;
|
gFFI.ctrl = old;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:qr_code_scanner/qr_code_scanner.dart';
|
|
||||||
import 'package:image_picker/image_picker.dart';
|
|
||||||
import 'package:image/image.dart' as img;
|
|
||||||
import 'package:zxing2/qrcode.dart';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:image/image.dart' as img;
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
import 'package:qr_code_scanner/qr_code_scanner.dart';
|
||||||
|
import 'package:zxing2/qrcode.dart';
|
||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
|
|
||||||
@ -153,10 +155,10 @@ class _ScanPageState extends State<ScanPage> {
|
|||||||
void showServerSettingsWithValue(
|
void showServerSettingsWithValue(
|
||||||
String id, String relay, String key, String api) {
|
String id, String relay, String key, String api) {
|
||||||
final formKey = GlobalKey<FormState>();
|
final formKey = GlobalKey<FormState>();
|
||||||
final id0 = FFI.getByName('option', 'custom-rendezvous-server');
|
final id0 = gFFI.getByName('option', 'custom-rendezvous-server');
|
||||||
final relay0 = FFI.getByName('option', 'relay-server');
|
final relay0 = gFFI.getByName('option', 'relay-server');
|
||||||
final api0 = FFI.getByName('option', 'api-server');
|
final api0 = gFFI.getByName('option', 'api-server');
|
||||||
final key0 = FFI.getByName('option', 'key');
|
final key0 = gFFI.getByName('option', 'key');
|
||||||
DialogManager.show((setState, close) {
|
DialogManager.show((setState, close) {
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
title: Text(translate('ID/Relay Server')),
|
title: Text(translate('ID/Relay Server')),
|
||||||
@ -227,17 +229,17 @@ void showServerSettingsWithValue(
|
|||||||
formKey.currentState!.validate()) {
|
formKey.currentState!.validate()) {
|
||||||
formKey.currentState!.save();
|
formKey.currentState!.save();
|
||||||
if (id != id0)
|
if (id != id0)
|
||||||
FFI.setByName('option',
|
gFFI.setByName('option',
|
||||||
'{"name": "custom-rendezvous-server", "value": "$id"}');
|
'{"name": "custom-rendezvous-server", "value": "$id"}');
|
||||||
if (relay != relay0)
|
if (relay != relay0)
|
||||||
FFI.setByName(
|
gFFI.setByName(
|
||||||
'option', '{"name": "relay-server", "value": "$relay"}');
|
'option', '{"name": "relay-server", "value": "$relay"}');
|
||||||
if (key != key0)
|
if (key != key0)
|
||||||
FFI.setByName('option', '{"name": "key", "value": "$key"}');
|
gFFI.setByName('option', '{"name": "key", "value": "$key"}');
|
||||||
if (api != api0)
|
if (api != api0)
|
||||||
FFI.setByName(
|
gFFI.setByName(
|
||||||
'option', '{"name": "api-server", "value": "$api"}');
|
'option', '{"name": "api-server", "value": "$api"}');
|
||||||
FFI.ffiModel.updateUser();
|
gFFI.ffiModel.updateUser();
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -253,6 +255,6 @@ String? validate(value) {
|
|||||||
if (value.isEmpty) {
|
if (value.isEmpty) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final res = FFI.getByName('test_if_valid_server', value);
|
final res = gFFI.getByName('test_if_valid_server', value);
|
||||||
return res.isEmpty ? null : res;
|
return res.isEmpty ? null : res;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hbb/models/model.dart';
|
|
||||||
import 'package:flutter_hbb/mobile/widgets/dialog.dart';
|
import 'package:flutter_hbb/mobile/widgets/dialog.dart';
|
||||||
|
import 'package:flutter_hbb/models/model.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
|
import '../../models/model.dart';
|
||||||
import '../../models/server_model.dart';
|
import '../../models/server_model.dart';
|
||||||
import 'home_page.dart';
|
import 'home_page.dart';
|
||||||
import '../../models/model.dart';
|
|
||||||
|
|
||||||
class ServerPage extends StatelessWidget implements PageShape {
|
class ServerPage extends StatelessWidget implements PageShape {
|
||||||
@override
|
@override
|
||||||
@ -30,12 +30,12 @@ class ServerPage extends StatelessWidget implements PageShape {
|
|||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text(translate("Set your own password")),
|
child: Text(translate("Set your own password")),
|
||||||
value: "changePW",
|
value: "changePW",
|
||||||
enabled: FFI.serverModel.isStart,
|
enabled: gFFI.serverModel.isStart,
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text(translate("Refresh random password")),
|
child: Text(translate("Refresh random password")),
|
||||||
value: "refreshPW",
|
value: "refreshPW",
|
||||||
enabled: FFI.serverModel.isStart,
|
enabled: gFFI.serverModel.isStart,
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
@ -47,7 +47,7 @@ class ServerPage extends StatelessWidget implements PageShape {
|
|||||||
} else if (value == "refreshPW") {
|
} else if (value == "refreshPW") {
|
||||||
() async {
|
() async {
|
||||||
showLoading(translate("Waiting"));
|
showLoading(translate("Waiting"));
|
||||||
if (await FFI.serverModel.updatePassword("")) {
|
if (await gFFI.serverModel.updatePassword("")) {
|
||||||
showSuccess();
|
showSuccess();
|
||||||
} else {
|
} else {
|
||||||
showError();
|
showError();
|
||||||
@ -62,10 +62,10 @@ class ServerPage extends StatelessWidget implements PageShape {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
checkService();
|
checkService();
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
value: FFI.serverModel,
|
value: gFFI.serverModel,
|
||||||
child: Consumer<ServerModel>(
|
child: Consumer<ServerModel>(
|
||||||
builder: (context, serverModel, child) => SingleChildScrollView(
|
builder: (context, serverModel, child) => SingleChildScrollView(
|
||||||
controller: FFI.serverModel.controller,
|
controller: gFFI.serverModel.controller,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@ -82,9 +82,9 @@ class ServerPage extends StatelessWidget implements PageShape {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void checkService() async {
|
void checkService() async {
|
||||||
FFI.invokeMethod("check_service"); // jvm
|
gFFI.invokeMethod("check_service"); // jvm
|
||||||
// for Android 10/11,MANAGE_EXTERNAL_STORAGE permission from a system setting page
|
// for Android 10/11,MANAGE_EXTERNAL_STORAGE permission from a system setting page
|
||||||
if (PermissionManager.isWaitingFile() && !FFI.serverModel.fileOk) {
|
if (PermissionManager.isWaitingFile() && !gFFI.serverModel.fileOk) {
|
||||||
PermissionManager.complete("file", await PermissionManager.check("file"));
|
PermissionManager.complete("file", await PermissionManager.check("file"));
|
||||||
debugPrint("file permission finished");
|
debugPrint("file permission finished");
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ class ServerInfo extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ServerInfoState extends State<ServerInfo> {
|
class _ServerInfoState extends State<ServerInfo> {
|
||||||
final model = FFI.serverModel;
|
final model = gFFI.serverModel;
|
||||||
var _passwdShow = false;
|
var _passwdShow = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -327,7 +327,7 @@ class ConnectionManager extends StatelessWidget {
|
|||||||
? SizedBox.shrink()
|
? SizedBox.shrink()
|
||||||
: IconButton(
|
: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
FFI.chatModel
|
gFFI.chatModel
|
||||||
.changeCurrentID(entry.value.id);
|
.changeCurrentID(entry.value.id);
|
||||||
final bar =
|
final bar =
|
||||||
navigationBarKey.currentWidget;
|
navigationBarKey.currentWidget;
|
||||||
@ -355,8 +355,9 @@ class ConnectionManager extends StatelessWidget {
|
|||||||
MaterialStateProperty.all(Colors.red)),
|
MaterialStateProperty.all(Colors.red)),
|
||||||
icon: Icon(Icons.close),
|
icon: Icon(Icons.close),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
FFI.setByName("close_conn", entry.key.toString());
|
gFFI.setByName(
|
||||||
FFI.invokeMethod(
|
"close_conn", entry.key.toString());
|
||||||
|
gFFI.invokeMethod(
|
||||||
"cancel_notification", entry.key);
|
"cancel_notification", entry.key);
|
||||||
},
|
},
|
||||||
label: Text(translate("Close")))
|
label: Text(translate("Close")))
|
||||||
@ -461,14 +462,14 @@ Widget clientInfo(Client client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void toAndroidChannelInit() {
|
void toAndroidChannelInit() {
|
||||||
FFI.setMethodCallHandler((method, arguments) {
|
gFFI.setMethodCallHandler((method, arguments) {
|
||||||
debugPrint("flutter got android msg,$method,$arguments");
|
debugPrint("flutter got android msg,$method,$arguments");
|
||||||
try {
|
try {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "start_capture":
|
case "start_capture":
|
||||||
{
|
{
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
FFI.serverModel.updateClientState();
|
gFFI.serverModel.updateClientState();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "on_state_changed":
|
case "on_state_changed":
|
||||||
@ -476,7 +477,7 @@ void toAndroidChannelInit() {
|
|||||||
var name = arguments["name"] as String;
|
var name = arguments["name"] as String;
|
||||||
var value = arguments["value"] as String == "true";
|
var value = arguments["value"] as String == "true";
|
||||||
debugPrint("from jvm:on_state_changed,$name:$value");
|
debugPrint("from jvm:on_state_changed,$name:$value");
|
||||||
FFI.serverModel.changeStatue(name, value);
|
gFFI.serverModel.changeStatue(name, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "on_android_permission_result":
|
case "on_android_permission_result":
|
||||||
@ -488,7 +489,7 @@ void toAndroidChannelInit() {
|
|||||||
}
|
}
|
||||||
case "on_media_projection_canceled":
|
case "on_media_projection_canceled":
|
||||||
{
|
{
|
||||||
FFI.serverModel.stopService();
|
gFFI.serverModel.stopService();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
import 'package:settings_ui/settings_ui.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:settings_ui/settings_ui.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
import '../widgets/dialog.dart';
|
|
||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
|
import '../widgets/dialog.dart';
|
||||||
import 'home_page.dart';
|
import 'home_page.dart';
|
||||||
import 'scan_page.dart';
|
import 'scan_page.dart';
|
||||||
|
|
||||||
@ -89,10 +91,10 @@ class _SettingsState extends State<SettingsPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showServerSettings() {
|
void showServerSettings() {
|
||||||
final id = FFI.getByName('option', 'custom-rendezvous-server');
|
final id = gFFI.getByName('option', 'custom-rendezvous-server');
|
||||||
final relay = FFI.getByName('option', 'relay-server');
|
final relay = gFFI.getByName('option', 'relay-server');
|
||||||
final api = FFI.getByName('option', 'api-server');
|
final api = gFFI.getByName('option', 'api-server');
|
||||||
final key = FFI.getByName('option', 'key');
|
final key = gFFI.getByName('option', 'key');
|
||||||
showServerSettingsWithValue(id, relay, key, api);
|
showServerSettingsWithValue(id, relay, key, api);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,8 +147,8 @@ fetch('http://localhost:21114/api/login', {
|
|||||||
final body = {
|
final body = {
|
||||||
'username': name,
|
'username': name,
|
||||||
'password': pass,
|
'password': pass,
|
||||||
'id': FFI.getByName('server_id'),
|
'id': gFFI.getByName('server_id'),
|
||||||
'uuid': FFI.getByName('uuid')
|
'uuid': gFFI.getByName('uuid')
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
final response = await http.post(Uri.parse('${url}/api/login'),
|
final response = await http.post(Uri.parse('${url}/api/login'),
|
||||||
@ -166,24 +168,25 @@ String parseResp(String body) {
|
|||||||
}
|
}
|
||||||
final token = data['access_token'];
|
final token = data['access_token'];
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
FFI.setByName('option', '{"name": "access_token", "value": "$token"}');
|
gFFI.setByName('option', '{"name": "access_token", "value": "$token"}');
|
||||||
}
|
}
|
||||||
final info = data['user'];
|
final info = data['user'];
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
final value = json.encode(info);
|
final value = json.encode(info);
|
||||||
FFI.setByName('option', json.encode({"name": "user_info", "value": value}));
|
gFFI.setByName(
|
||||||
FFI.ffiModel.updateUser();
|
'option', json.encode({"name": "user_info", "value": value}));
|
||||||
|
gFFI.ffiModel.updateUser();
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
void refreshCurrentUser() async {
|
void refreshCurrentUser() async {
|
||||||
final token = FFI.getByName("option", "access_token");
|
final token = gFFI.getByName("option", "access_token");
|
||||||
if (token == '') return;
|
if (token == '') return;
|
||||||
final url = getUrl();
|
final url = getUrl();
|
||||||
final body = {
|
final body = {
|
||||||
'id': FFI.getByName('server_id'),
|
'id': gFFI.getByName('server_id'),
|
||||||
'uuid': FFI.getByName('uuid')
|
'uuid': gFFI.getByName('uuid')
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
final response = await http.post(Uri.parse('${url}/api/currentUser'),
|
final response = await http.post(Uri.parse('${url}/api/currentUser'),
|
||||||
@ -204,12 +207,12 @@ void refreshCurrentUser() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void logout() async {
|
void logout() async {
|
||||||
final token = FFI.getByName("option", "access_token");
|
final token = gFFI.getByName("option", "access_token");
|
||||||
if (token == '') return;
|
if (token == '') return;
|
||||||
final url = getUrl();
|
final url = getUrl();
|
||||||
final body = {
|
final body = {
|
||||||
'id': FFI.getByName('server_id'),
|
'id': gFFI.getByName('server_id'),
|
||||||
'uuid': FFI.getByName('uuid')
|
'uuid': gFFI.getByName('uuid')
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
await http.post(Uri.parse('${url}/api/logout'),
|
await http.post(Uri.parse('${url}/api/logout'),
|
||||||
@ -225,15 +228,15 @@ void logout() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void resetToken() {
|
void resetToken() {
|
||||||
FFI.setByName('option', '{"name": "access_token", "value": ""}');
|
gFFI.setByName('option', '{"name": "access_token", "value": ""}');
|
||||||
FFI.setByName('option', '{"name": "user_info", "value": ""}');
|
gFFI.setByName('option', '{"name": "user_info", "value": ""}');
|
||||||
FFI.ffiModel.updateUser();
|
gFFI.ffiModel.updateUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getUrl() {
|
String getUrl() {
|
||||||
var url = FFI.getByName('option', 'api-server');
|
var url = gFFI.getByName('option', 'api-server');
|
||||||
if (url == '') {
|
if (url == '') {
|
||||||
url = FFI.getByName('option', 'custom-rendezvous-server');
|
url = gFFI.getByName('option', 'custom-rendezvous-server');
|
||||||
if (url != '') {
|
if (url != '') {
|
||||||
if (url.contains(':')) {
|
if (url.contains(':')) {
|
||||||
final tmp = url.split(':');
|
final tmp = url.split(':');
|
||||||
@ -323,10 +326,10 @@ void showLogin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String? getUsername() {
|
String? getUsername() {
|
||||||
final token = FFI.getByName("option", "access_token");
|
final token = gFFI.getByName("option", "access_token");
|
||||||
String? username;
|
String? username;
|
||||||
if (token != "") {
|
if (token != "") {
|
||||||
final info = FFI.getByName("option", "user_info");
|
final info = gFFI.getByName("option", "user_info");
|
||||||
if (info != "") {
|
if (info != "") {
|
||||||
try {
|
try {
|
||||||
Map<String, dynamic> tmp = json.decode(info);
|
Map<String, dynamic> tmp = json.decode(info);
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ void updatePasswordDialog() {
|
|||||||
? () async {
|
? () async {
|
||||||
close();
|
close();
|
||||||
showLoading(translate("Waiting"));
|
showLoading(translate("Waiting"));
|
||||||
if (await FFI.serverModel.updatePassword(p0.text)) {
|
if (await gFFI.serverModel.updatePassword(p0.text)) {
|
||||||
showSuccess();
|
showSuccess();
|
||||||
} else {
|
} else {
|
||||||
showError();
|
showError();
|
||||||
@ -102,7 +103,7 @@ void updatePasswordDialog() {
|
|||||||
|
|
||||||
void enterPasswordDialog(String id) {
|
void enterPasswordDialog(String id) {
|
||||||
final controller = TextEditingController();
|
final controller = TextEditingController();
|
||||||
var remember = FFI.getByName('remember', id) == 'true';
|
var remember = gFFI.getByName('remember', id) == 'true';
|
||||||
DialogManager.show((setState, close) {
|
DialogManager.show((setState, close) {
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
title: Text(translate('Password Required')),
|
title: Text(translate('Password Required')),
|
||||||
@ -137,7 +138,7 @@ void enterPasswordDialog(String id) {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
var text = controller.text.trim();
|
var text = controller.text.trim();
|
||||||
if (text == '') return;
|
if (text == '') return;
|
||||||
FFI.login(id, text, remember);
|
gFFI.login(id, text, remember);
|
||||||
close();
|
close();
|
||||||
showLoading(translate('Logging in...'));
|
showLoading(translate('Logging in...'));
|
||||||
},
|
},
|
||||||
|
|||||||
@ -157,7 +157,7 @@ hideChatWindowOverlay() {
|
|||||||
|
|
||||||
toggleChatOverlay() {
|
toggleChatOverlay() {
|
||||||
if (chatIconOverlayEntry == null || chatWindowOverlayEntry == null) {
|
if (chatIconOverlayEntry == null || chatWindowOverlayEntry == null) {
|
||||||
FFI.invokeMethod("enable_soft_keyboard", true);
|
gFFI.invokeMethod("enable_soft_keyboard", true);
|
||||||
showChatIconOverlay();
|
showChatIconOverlay();
|
||||||
showChatWindowOverlay();
|
showChatWindowOverlay();
|
||||||
} else {
|
} else {
|
||||||
@ -248,12 +248,12 @@ showMobileActionsOverlay() {
|
|||||||
position: Offset(left, top),
|
position: Offset(left, top),
|
||||||
width: overlayW,
|
width: overlayW,
|
||||||
height: overlayH,
|
height: overlayH,
|
||||||
onBackPressed: () => FFI.tap(MouseButtons.right),
|
onBackPressed: () => gFFI.tap(MouseButtons.right),
|
||||||
onHomePressed: () => FFI.tap(MouseButtons.wheel),
|
onHomePressed: () => gFFI.tap(MouseButtons.wheel),
|
||||||
onRecentPressed: () async {
|
onRecentPressed: () async {
|
||||||
FFI.sendMouse('down', MouseButtons.wheel);
|
gFFI.sendMouse('down', MouseButtons.wheel);
|
||||||
await Future.delayed(Duration(milliseconds: 500));
|
await Future.delayed(Duration(milliseconds: 500));
|
||||||
FFI.sendMouse('up', MouseButtons.wheel);
|
gFFI.sendMouse('up', MouseButtons.wheel);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -41,6 +41,11 @@ class ChatModel with ChangeNotifier {
|
|||||||
|
|
||||||
int get currentID => _currentID;
|
int get currentID => _currentID;
|
||||||
|
|
||||||
|
WeakReference<FFI> _ffi;
|
||||||
|
|
||||||
|
/// Constructor
|
||||||
|
ChatModel(this._ffi);
|
||||||
|
|
||||||
ChatUser get currentUser {
|
ChatUser get currentUser {
|
||||||
final user = messages[currentID]?.chatUser;
|
final user = messages[currentID]?.chatUser;
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
@ -56,7 +61,7 @@ class ChatModel with ChangeNotifier {
|
|||||||
_currentID = id;
|
_currentID = id;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} else {
|
} else {
|
||||||
final client = FFI.serverModel.clients[id];
|
final client = _ffi.target?.serverModel.clients[id];
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
return debugPrint(
|
return debugPrint(
|
||||||
"Failed to changeCurrentID,remote user doesn't exist");
|
"Failed to changeCurrentID,remote user doesn't exist");
|
||||||
@ -80,11 +85,11 @@ class ChatModel with ChangeNotifier {
|
|||||||
late final chatUser;
|
late final chatUser;
|
||||||
if (id == clientModeID) {
|
if (id == clientModeID) {
|
||||||
chatUser = ChatUser(
|
chatUser = ChatUser(
|
||||||
name: FFI.ffiModel.pi.username,
|
name: _ffi.target?.ffiModel.pi.username,
|
||||||
uid: FFI.getId(),
|
uid: _ffi.target?.getId(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final client = FFI.serverModel.clients[id];
|
final client = _ffi.target?.serverModel.clients[id];
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
return debugPrint("Failed to receive msg,user doesn't exist");
|
return debugPrint("Failed to receive msg,user doesn't exist");
|
||||||
}
|
}
|
||||||
@ -112,12 +117,12 @@ class ChatModel with ChangeNotifier {
|
|||||||
if (message.text != null && message.text!.isNotEmpty) {
|
if (message.text != null && message.text!.isNotEmpty) {
|
||||||
_messages[_currentID]?.add(message);
|
_messages[_currentID]?.add(message);
|
||||||
if (_currentID == clientModeID) {
|
if (_currentID == clientModeID) {
|
||||||
FFI.setByName("chat_client_mode", message.text!);
|
_ffi.target?.setByName("chat_client_mode", message.text!);
|
||||||
} else {
|
} else {
|
||||||
final msg = Map()
|
final msg = Map()
|
||||||
..["id"] = _currentID
|
..["id"] = _currentID
|
||||||
..["text"] = message.text!;
|
..["text"] = message.text!;
|
||||||
FFI.setByName("chat_server_mode", jsonEncode(msg));
|
_ffi.target?.setByName("chat_server_mode", jsonEncode(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:flutter_hbb/common.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hbb/common.dart';
|
||||||
import 'package:flutter_hbb/mobile/pages/file_manager_page.dart';
|
import 'package:flutter_hbb/mobile/pages/file_manager_page.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:path/path.dart' as Path;
|
import 'package:path/path.dart' as Path;
|
||||||
@ -69,6 +70,10 @@ class FileModel extends ChangeNotifier {
|
|||||||
|
|
||||||
final _jobResultListener = JobResultListener<Map<String, dynamic>>();
|
final _jobResultListener = JobResultListener<Map<String, dynamic>>();
|
||||||
|
|
||||||
|
final WeakReference<FFI> _ffi;
|
||||||
|
|
||||||
|
FileModel(this._ffi);
|
||||||
|
|
||||||
toggleSelectMode() {
|
toggleSelectMode() {
|
||||||
if (jobState == JobState.inProgress) {
|
if (jobState == JobState.inProgress) {
|
||||||
return;
|
return;
|
||||||
@ -162,7 +167,7 @@ class FileModel extends ChangeNotifier {
|
|||||||
// overwrite
|
// overwrite
|
||||||
msg['need_override'] = 'true';
|
msg['need_override'] = 'true';
|
||||||
}
|
}
|
||||||
FFI.setByName("set_confirm_override_file", jsonEncode(msg));
|
_ffi.target?.setByName("set_confirm_override_file", jsonEncode(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,20 +177,23 @@ class FileModel extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onReady() async {
|
onReady() async {
|
||||||
_localOption.home = FFI.getByName("get_home_dir");
|
_localOption.home = _ffi.target?.getByName("get_home_dir") ?? "";
|
||||||
_localOption.showHidden =
|
_localOption.showHidden =
|
||||||
FFI.getByName("peer_option", "local_show_hidden").isNotEmpty;
|
_ffi.target?.getByName("peer_option", "local_show_hidden").isNotEmpty ??
|
||||||
|
false;
|
||||||
|
|
||||||
_remoteOption.showHidden =
|
_remoteOption.showHidden = _ffi.target
|
||||||
FFI.getByName("peer_option", "remote_show_hidden").isNotEmpty;
|
?.getByName("peer_option", "remote_show_hidden")
|
||||||
_remoteOption.isWindows = FFI.ffiModel.pi.platform == "Windows";
|
.isNotEmpty ??
|
||||||
|
false;
|
||||||
|
_remoteOption.isWindows = _ffi.target?.ffiModel.pi.platform == "Windows";
|
||||||
|
|
||||||
debugPrint("remote platform: ${FFI.ffiModel.pi.platform}");
|
debugPrint("remote platform: ${_ffi.target?.ffiModel.pi.platform}");
|
||||||
|
|
||||||
await Future.delayed(Duration(milliseconds: 100));
|
await Future.delayed(Duration(milliseconds: 100));
|
||||||
|
|
||||||
final local = FFI.getByName("peer_option", "local_dir");
|
final local = _ffi.target?.getByName("peer_option", "local_dir") ?? "";
|
||||||
final remote = FFI.getByName("peer_option", "remote_dir");
|
final remote = _ffi.target?.getByName("peer_option", "remote_dir") ?? "";
|
||||||
openDirectory(local.isEmpty ? _localOption.home : local, isLocal: true);
|
openDirectory(local.isEmpty ? _localOption.home : local, isLocal: true);
|
||||||
openDirectory(remote.isEmpty ? _remoteOption.home : remote, isLocal: false);
|
openDirectory(remote.isEmpty ? _remoteOption.home : remote, isLocal: false);
|
||||||
await Future.delayed(Duration(seconds: 1));
|
await Future.delayed(Duration(seconds: 1));
|
||||||
@ -205,19 +213,19 @@ class FileModel extends ChangeNotifier {
|
|||||||
|
|
||||||
msg["name"] = "local_dir";
|
msg["name"] = "local_dir";
|
||||||
msg["value"] = _currentLocalDir.path;
|
msg["value"] = _currentLocalDir.path;
|
||||||
FFI.setByName('peer_option', jsonEncode(msg));
|
_ffi.target?.setByName('peer_option', jsonEncode(msg));
|
||||||
|
|
||||||
msg["name"] = "local_show_hidden";
|
msg["name"] = "local_show_hidden";
|
||||||
msg["value"] = _localOption.showHidden ? "Y" : "";
|
msg["value"] = _localOption.showHidden ? "Y" : "";
|
||||||
FFI.setByName('peer_option', jsonEncode(msg));
|
_ffi.target?.setByName('peer_option', jsonEncode(msg));
|
||||||
|
|
||||||
msg["name"] = "remote_dir";
|
msg["name"] = "remote_dir";
|
||||||
msg["value"] = _currentRemoteDir.path;
|
msg["value"] = _currentRemoteDir.path;
|
||||||
FFI.setByName('peer_option', jsonEncode(msg));
|
_ffi.target?.setByName('peer_option', jsonEncode(msg));
|
||||||
|
|
||||||
msg["name"] = "remote_show_hidden";
|
msg["name"] = "remote_show_hidden";
|
||||||
msg["value"] = _remoteOption.showHidden ? "Y" : "";
|
msg["value"] = _remoteOption.showHidden ? "Y" : "";
|
||||||
FFI.setByName('peer_option', jsonEncode(msg));
|
_ffi.target?.setByName('peer_option', jsonEncode(msg));
|
||||||
_currentLocalDir.clear();
|
_currentLocalDir.clear();
|
||||||
_currentRemoteDir.clear();
|
_currentRemoteDir.clear();
|
||||||
_localOption.clear();
|
_localOption.clear();
|
||||||
@ -279,7 +287,7 @@ class FileModel extends ChangeNotifier {
|
|||||||
"show_hidden": showHidden.toString(),
|
"show_hidden": showHidden.toString(),
|
||||||
"is_remote": (!(items.isLocal!)).toString()
|
"is_remote": (!(items.isLocal!)).toString()
|
||||||
};
|
};
|
||||||
FFI.setByName("send_files", jsonEncode(msg));
|
_ffi.target?.setByName("send_files", jsonEncode(msg));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,7 +486,7 @@ class FileModel extends ChangeNotifier {
|
|||||||
"file_num": fileNum.toString(),
|
"file_num": fileNum.toString(),
|
||||||
"is_remote": (!(isLocal)).toString()
|
"is_remote": (!(isLocal)).toString()
|
||||||
};
|
};
|
||||||
FFI.setByName("remove_file", jsonEncode(msg));
|
_ffi.target?.setByName("remove_file", jsonEncode(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
sendRemoveEmptyDir(String path, int fileNum, bool isLocal) {
|
sendRemoveEmptyDir(String path, int fileNum, bool isLocal) {
|
||||||
@ -487,7 +495,7 @@ class FileModel extends ChangeNotifier {
|
|||||||
"path": path,
|
"path": path,
|
||||||
"is_remote": (!isLocal).toString()
|
"is_remote": (!isLocal).toString()
|
||||||
};
|
};
|
||||||
FFI.setByName("remove_all_empty_dirs", jsonEncode(msg));
|
_ffi.target?.setByName("remove_all_empty_dirs", jsonEncode(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
createDir(String path) {
|
createDir(String path) {
|
||||||
@ -497,11 +505,11 @@ class FileModel extends ChangeNotifier {
|
|||||||
"path": path,
|
"path": path,
|
||||||
"is_remote": (!isLocal).toString()
|
"is_remote": (!isLocal).toString()
|
||||||
};
|
};
|
||||||
FFI.setByName("create_dir", jsonEncode(msg));
|
_ffi.target?.setByName("create_dir", jsonEncode(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelJob(int id) {
|
cancelJob(int id) {
|
||||||
FFI.setByName("cancel_job", id.toString());
|
_ffi.target?.setByName("cancel_job", id.toString());
|
||||||
jobReset();
|
jobReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,11 +635,11 @@ class FileFetcher {
|
|||||||
try {
|
try {
|
||||||
final msg = {"path": path, "show_hidden": showHidden.toString()};
|
final msg = {"path": path, "show_hidden": showHidden.toString()};
|
||||||
if (isLocal) {
|
if (isLocal) {
|
||||||
final res = FFI.getByName("read_local_dir_sync", jsonEncode(msg));
|
final res = gFFI.getByName("read_local_dir_sync", jsonEncode(msg));
|
||||||
final fd = FileDirectory.fromJson(jsonDecode(res));
|
final fd = FileDirectory.fromJson(jsonDecode(res));
|
||||||
return fd;
|
return fd;
|
||||||
} else {
|
} else {
|
||||||
FFI.setByName("read_remote_dir", jsonEncode(msg));
|
gFFI.setByName("read_remote_dir", jsonEncode(msg));
|
||||||
return registerReadTask(isLocal, path);
|
return registerReadTask(isLocal, path);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -649,7 +657,7 @@ class FileFetcher {
|
|||||||
"show_hidden": showHidden.toString(),
|
"show_hidden": showHidden.toString(),
|
||||||
"is_remote": (!isLocal).toString()
|
"is_remote": (!isLocal).toString()
|
||||||
};
|
};
|
||||||
FFI.setByName("read_dir_recursive", jsonEncode(msg));
|
gFFI.setByName("read_dir_recursive", jsonEncode(msg));
|
||||||
return registerReadRecursiveTask(id);
|
return registerReadRecursiveTask(id);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Future.error(e);
|
return Future.error(e);
|
||||||
|
|||||||
@ -25,6 +25,8 @@ bool _waitForImage = false;
|
|||||||
class FfiModel with ChangeNotifier {
|
class FfiModel with ChangeNotifier {
|
||||||
PeerInfo _pi = PeerInfo();
|
PeerInfo _pi = PeerInfo();
|
||||||
Display _display = Display();
|
Display _display = Display();
|
||||||
|
PlatformFFI _platformFFI = PlatformFFI();
|
||||||
|
|
||||||
var _inputBlocked = false;
|
var _inputBlocked = false;
|
||||||
final _permissions = Map<String, bool>();
|
final _permissions = Map<String, bool>();
|
||||||
bool? _secure;
|
bool? _secure;
|
||||||
@ -32,11 +34,18 @@ class FfiModel with ChangeNotifier {
|
|||||||
bool _touchMode = false;
|
bool _touchMode = false;
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
var _reconnects = 1;
|
var _reconnects = 1;
|
||||||
|
WeakReference<FFI> parent;
|
||||||
|
|
||||||
Map<String, bool> get permissions => _permissions;
|
Map<String, bool> get permissions => _permissions;
|
||||||
|
|
||||||
Display get display => _display;
|
Display get display => _display;
|
||||||
|
|
||||||
|
PlatformFFI get platformFFI => _platformFFI;
|
||||||
|
|
||||||
|
set platformFFI(PlatformFFI value) {
|
||||||
|
_platformFFI = value;
|
||||||
|
}
|
||||||
|
|
||||||
bool? get secure => _secure;
|
bool? get secure => _secure;
|
||||||
|
|
||||||
bool? get direct => _direct;
|
bool? get direct => _direct;
|
||||||
@ -53,13 +62,13 @@ class FfiModel with ChangeNotifier {
|
|||||||
_inputBlocked = v;
|
_inputBlocked = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
FfiModel() {
|
FfiModel(this.parent) {
|
||||||
Translator.call = translate;
|
Translator.call = translate;
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
await PlatformFFI.init();
|
await _platformFFI.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleTouchMode() {
|
void toggleTouchMode() {
|
||||||
@ -130,41 +139,41 @@ class FfiModel with ChangeNotifier {
|
|||||||
} else if (name == 'peer_info') {
|
} else if (name == 'peer_info') {
|
||||||
handlePeerInfo(evt, peerId);
|
handlePeerInfo(evt, peerId);
|
||||||
} else if (name == 'connection_ready') {
|
} else if (name == 'connection_ready') {
|
||||||
FFI.ffiModel.setConnectionType(
|
setConnectionType(evt['secure'] == 'true', evt['direct'] == 'true');
|
||||||
evt['secure'] == 'true', evt['direct'] == 'true');
|
|
||||||
} else if (name == 'switch_display') {
|
} else if (name == 'switch_display') {
|
||||||
handleSwitchDisplay(evt);
|
handleSwitchDisplay(evt);
|
||||||
} else if (name == 'cursor_data') {
|
} else if (name == 'cursor_data') {
|
||||||
FFI.cursorModel.updateCursorData(evt);
|
parent.target?.cursorModel.updateCursorData(evt);
|
||||||
} else if (name == 'cursor_id') {
|
} else if (name == 'cursor_id') {
|
||||||
FFI.cursorModel.updateCursorId(evt);
|
parent.target?.cursorModel.updateCursorId(evt);
|
||||||
} else if (name == 'cursor_position') {
|
} else if (name == 'cursor_position') {
|
||||||
FFI.cursorModel.updateCursorPosition(evt);
|
parent.target?.cursorModel.updateCursorPosition(evt);
|
||||||
} else if (name == 'clipboard') {
|
} else if (name == 'clipboard') {
|
||||||
Clipboard.setData(ClipboardData(text: evt['content']));
|
Clipboard.setData(ClipboardData(text: evt['content']));
|
||||||
} else if (name == 'permission') {
|
} else if (name == 'permission') {
|
||||||
FFI.ffiModel.updatePermission(evt);
|
parent.target?.ffiModel.updatePermission(evt);
|
||||||
} else if (name == 'chat_client_mode') {
|
} else if (name == 'chat_client_mode') {
|
||||||
FFI.chatModel.receive(ChatModel.clientModeID, evt['text'] ?? "");
|
parent.target?.chatModel
|
||||||
|
.receive(ChatModel.clientModeID, evt['text'] ?? "");
|
||||||
} else if (name == 'chat_server_mode') {
|
} else if (name == 'chat_server_mode') {
|
||||||
FFI.chatModel
|
parent.target?.chatModel
|
||||||
.receive(int.parse(evt['id'] as String), evt['text'] ?? "");
|
.receive(int.parse(evt['id'] as String), evt['text'] ?? "");
|
||||||
} else if (name == 'file_dir') {
|
} else if (name == 'file_dir') {
|
||||||
FFI.fileModel.receiveFileDir(evt);
|
parent.target?.fileModel.receiveFileDir(evt);
|
||||||
} else if (name == 'job_progress') {
|
} else if (name == 'job_progress') {
|
||||||
FFI.fileModel.tryUpdateJobProgress(evt);
|
parent.target?.fileModel.tryUpdateJobProgress(evt);
|
||||||
} else if (name == 'job_done') {
|
} else if (name == 'job_done') {
|
||||||
FFI.fileModel.jobDone(evt);
|
parent.target?.fileModel.jobDone(evt);
|
||||||
} else if (name == 'job_error') {
|
} else if (name == 'job_error') {
|
||||||
FFI.fileModel.jobError(evt);
|
parent.target?.fileModel.jobError(evt);
|
||||||
} else if (name == 'override_file_confirm') {
|
} else if (name == 'override_file_confirm') {
|
||||||
FFI.fileModel.overrideFileConfirm(evt);
|
parent.target?.fileModel.overrideFileConfirm(evt);
|
||||||
} else if (name == 'try_start_without_auth') {
|
} else if (name == 'try_start_without_auth') {
|
||||||
FFI.serverModel.loginRequest(evt);
|
parent.target?.serverModel.loginRequest(evt);
|
||||||
} else if (name == 'on_client_authorized') {
|
} else if (name == 'on_client_authorized') {
|
||||||
FFI.serverModel.onClientAuthorized(evt);
|
parent.target?.serverModel.onClientAuthorized(evt);
|
||||||
} else if (name == 'on_client_remove') {
|
} else if (name == 'on_client_remove') {
|
||||||
FFI.serverModel.onClientRemove(evt);
|
parent.target?.serverModel.onClientRemove(evt);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -178,44 +187,45 @@ class FfiModel with ChangeNotifier {
|
|||||||
} else if (name == 'peer_info') {
|
} else if (name == 'peer_info') {
|
||||||
handlePeerInfo(evt, peerId);
|
handlePeerInfo(evt, peerId);
|
||||||
} else if (name == 'connection_ready') {
|
} else if (name == 'connection_ready') {
|
||||||
FFI.ffiModel.setConnectionType(
|
parent.target?.ffiModel.setConnectionType(
|
||||||
evt['secure'] == 'true', evt['direct'] == 'true');
|
evt['secure'] == 'true', evt['direct'] == 'true');
|
||||||
} else if (name == 'switch_display') {
|
} else if (name == 'switch_display') {
|
||||||
handleSwitchDisplay(evt);
|
handleSwitchDisplay(evt);
|
||||||
} else if (name == 'cursor_data') {
|
} else if (name == 'cursor_data') {
|
||||||
FFI.cursorModel.updateCursorData(evt);
|
parent.target?.cursorModel.updateCursorData(evt);
|
||||||
} else if (name == 'cursor_id') {
|
} else if (name == 'cursor_id') {
|
||||||
FFI.cursorModel.updateCursorId(evt);
|
parent.target?.cursorModel.updateCursorId(evt);
|
||||||
} else if (name == 'cursor_position') {
|
} else if (name == 'cursor_position') {
|
||||||
FFI.cursorModel.updateCursorPosition(evt);
|
parent.target?.cursorModel.updateCursorPosition(evt);
|
||||||
} else if (name == 'clipboard') {
|
} else if (name == 'clipboard') {
|
||||||
Clipboard.setData(ClipboardData(text: evt['content']));
|
Clipboard.setData(ClipboardData(text: evt['content']));
|
||||||
} else if (name == 'permission') {
|
} else if (name == 'permission') {
|
||||||
FFI.ffiModel.updatePermission(evt);
|
parent.target?.ffiModel.updatePermission(evt);
|
||||||
} else if (name == 'chat_client_mode') {
|
} else if (name == 'chat_client_mode') {
|
||||||
FFI.chatModel.receive(ChatModel.clientModeID, evt['text'] ?? "");
|
parent.target?.chatModel
|
||||||
|
.receive(ChatModel.clientModeID, evt['text'] ?? "");
|
||||||
} else if (name == 'chat_server_mode') {
|
} else if (name == 'chat_server_mode') {
|
||||||
FFI.chatModel
|
parent.target?.chatModel
|
||||||
.receive(int.parse(evt['id'] as String), evt['text'] ?? "");
|
.receive(int.parse(evt['id'] as String), evt['text'] ?? "");
|
||||||
} else if (name == 'file_dir') {
|
} else if (name == 'file_dir') {
|
||||||
FFI.fileModel.receiveFileDir(evt);
|
parent.target?.fileModel.receiveFileDir(evt);
|
||||||
} else if (name == 'job_progress') {
|
} else if (name == 'job_progress') {
|
||||||
FFI.fileModel.tryUpdateJobProgress(evt);
|
parent.target?.fileModel.tryUpdateJobProgress(evt);
|
||||||
} else if (name == 'job_done') {
|
} else if (name == 'job_done') {
|
||||||
FFI.fileModel.jobDone(evt);
|
parent.target?.fileModel.jobDone(evt);
|
||||||
} else if (name == 'job_error') {
|
} else if (name == 'job_error') {
|
||||||
FFI.fileModel.jobError(evt);
|
parent.target?.fileModel.jobError(evt);
|
||||||
} else if (name == 'override_file_confirm') {
|
} else if (name == 'override_file_confirm') {
|
||||||
FFI.fileModel.overrideFileConfirm(evt);
|
parent.target?.fileModel.overrideFileConfirm(evt);
|
||||||
} else if (name == 'try_start_without_auth') {
|
} else if (name == 'try_start_without_auth') {
|
||||||
FFI.serverModel.loginRequest(evt);
|
parent.target?.serverModel.loginRequest(evt);
|
||||||
} else if (name == 'on_client_authorized') {
|
} else if (name == 'on_client_authorized') {
|
||||||
FFI.serverModel.onClientAuthorized(evt);
|
parent.target?.serverModel.onClientAuthorized(evt);
|
||||||
} else if (name == 'on_client_remove') {
|
} else if (name == 'on_client_remove') {
|
||||||
FFI.serverModel.onClientRemove(evt);
|
parent.target?.serverModel.onClientRemove(evt);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
PlatformFFI.setEventCallback(cb);
|
platformFFI.setEventCallback(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSwitchDisplay(Map<String, dynamic> evt) {
|
void handleSwitchDisplay(Map<String, dynamic> evt) {
|
||||||
@ -226,7 +236,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
_display.width = int.parse(evt['width']);
|
_display.width = int.parse(evt['width']);
|
||||||
_display.height = int.parse(evt['height']);
|
_display.height = int.parse(evt['height']);
|
||||||
if (old != _pi.currentDisplay)
|
if (old != _pi.currentDisplay)
|
||||||
FFI.cursorModel.updateDisplayOrigin(_display.x, _display.y);
|
parent.target?.cursorModel.updateDisplayOrigin(_display.x, _display.y);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +262,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
if (hasRetry) {
|
if (hasRetry) {
|
||||||
_timer = Timer(Duration(seconds: _reconnects), () {
|
_timer = Timer(Duration(seconds: _reconnects), () {
|
||||||
FFI.bind.sessionReconnect(id: id);
|
parent.target?.bind.sessionReconnect(id: id);
|
||||||
clearPermissions();
|
clearPermissions();
|
||||||
showLoading(translate('Connecting...'));
|
showLoading(translate('Connecting...'));
|
||||||
});
|
});
|
||||||
@ -274,16 +284,17 @@ class FfiModel with ChangeNotifier {
|
|||||||
|
|
||||||
if (isPeerAndroid) {
|
if (isPeerAndroid) {
|
||||||
_touchMode = true;
|
_touchMode = true;
|
||||||
if (FFI.ffiModel.permissions['keyboard'] != false) {
|
if (parent.target?.ffiModel.permissions['keyboard'] != false) {
|
||||||
Timer(Duration(milliseconds: 100), showMobileActionsOverlay);
|
Timer(Duration(milliseconds: 100), showMobileActionsOverlay);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_touchMode =
|
_touchMode = await parent.target?.bind
|
||||||
await FFI.bind.getSessionOption(id: peerId, arg: "touch-mode") != '';
|
.getSessionOption(id: peerId, arg: "touch-mode") !=
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt['is_file_transfer'] == "true") {
|
if (evt['is_file_transfer'] == "true") {
|
||||||
FFI.fileModel.onReady();
|
parent.target?.fileModel.onReady();
|
||||||
} else {
|
} else {
|
||||||
_pi.displays = [];
|
_pi.displays = [];
|
||||||
List<dynamic> displays = json.decode(evt['displays']);
|
List<dynamic> displays = json.decode(evt['displays']);
|
||||||
@ -316,18 +327,22 @@ class ImageModel with ChangeNotifier {
|
|||||||
|
|
||||||
String _id = "";
|
String _id = "";
|
||||||
|
|
||||||
|
WeakReference<FFI> parent;
|
||||||
|
|
||||||
|
ImageModel(this.parent);
|
||||||
|
|
||||||
void onRgba(Uint8List rgba) {
|
void onRgba(Uint8List rgba) {
|
||||||
if (_waitForImage) {
|
if (_waitForImage) {
|
||||||
_waitForImage = false;
|
_waitForImage = false;
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
}
|
}
|
||||||
final pid = FFI.id;
|
final pid = parent.target?.id;
|
||||||
ui.decodeImageFromPixels(
|
ui.decodeImageFromPixels(
|
||||||
rgba,
|
rgba,
|
||||||
FFI.ffiModel.display.width,
|
parent.target?.ffiModel.display.width ?? 0,
|
||||||
FFI.ffiModel.display.height,
|
parent.target?.ffiModel.display.height ?? 0,
|
||||||
isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888, (image) {
|
isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888, (image) {
|
||||||
if (FFI.id != pid) return;
|
if (parent.target?.id != pid) return;
|
||||||
try {
|
try {
|
||||||
// my throw exception, because the listener maybe already dispose
|
// my throw exception, because the listener maybe already dispose
|
||||||
update(image);
|
update(image);
|
||||||
@ -340,19 +355,21 @@ class ImageModel with ChangeNotifier {
|
|||||||
void update(ui.Image? image) {
|
void update(ui.Image? image) {
|
||||||
if (_image == null && image != null) {
|
if (_image == null && image != null) {
|
||||||
if (isWebDesktop) {
|
if (isWebDesktop) {
|
||||||
FFI.canvasModel.updateViewStyle();
|
parent.target?.canvasModel.updateViewStyle();
|
||||||
} else {
|
} else {
|
||||||
final size = MediaQueryData.fromWindow(ui.window).size;
|
final size = MediaQueryData.fromWindow(ui.window).size;
|
||||||
final xscale = size.width / image.width;
|
final xscale = size.width / image.width;
|
||||||
final yscale = size.height / image.height;
|
final yscale = size.height / image.height;
|
||||||
FFI.canvasModel.scale = max(xscale, yscale);
|
parent.target?.canvasModel.scale = max(xscale, yscale);
|
||||||
|
}
|
||||||
|
if (parent.target != null) {
|
||||||
|
initializeCursorAndCanvas(parent.target!);
|
||||||
}
|
}
|
||||||
initializeCursorAndCanvas();
|
|
||||||
Future.delayed(Duration(milliseconds: 1), () {
|
Future.delayed(Duration(milliseconds: 1), () {
|
||||||
if (FFI.ffiModel.isPeerAndroid) {
|
if (parent.target?.ffiModel.isPeerAndroid ?? false) {
|
||||||
FFI.bind
|
parent.target?.bind
|
||||||
.sessionPeerOption(id: _id, name: "view-style", value: "shrink");
|
.sessionPeerOption(id: _id, name: "view-style", value: "shrink");
|
||||||
FFI.canvasModel.updateViewStyle();
|
parent.target?.canvasModel.updateViewStyle();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -383,7 +400,9 @@ class CanvasModel with ChangeNotifier {
|
|||||||
double _scale = 1.0;
|
double _scale = 1.0;
|
||||||
String id = ""; // TODO multi canvas model
|
String id = ""; // TODO multi canvas model
|
||||||
|
|
||||||
CanvasModel();
|
WeakReference<FFI> parent;
|
||||||
|
|
||||||
|
CanvasModel(this.parent);
|
||||||
|
|
||||||
double get x => _x;
|
double get x => _x;
|
||||||
|
|
||||||
@ -392,13 +411,14 @@ class CanvasModel with ChangeNotifier {
|
|||||||
double get scale => _scale;
|
double get scale => _scale;
|
||||||
|
|
||||||
void updateViewStyle() async {
|
void updateViewStyle() async {
|
||||||
final s = await FFI.bind.getSessionOption(id: id, arg: 'view-style');
|
final s =
|
||||||
|
await parent.target?.bind.getSessionOption(id: id, arg: 'view-style');
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final size = MediaQueryData.fromWindow(ui.window).size;
|
final size = MediaQueryData.fromWindow(ui.window).size;
|
||||||
final s1 = size.width / FFI.ffiModel.display.width;
|
final s1 = size.width / (parent.target?.ffiModel.display.width ?? 720);
|
||||||
final s2 = size.height / FFI.ffiModel.display.height;
|
final s2 = size.height / (parent.target?.ffiModel.display.height ?? 1280);
|
||||||
if (s == 'shrink') {
|
if (s == 'shrink') {
|
||||||
final s = s1 < s2 ? s1 : s2;
|
final s = s1 < s2 ? s1 : s2;
|
||||||
if (s < 1) {
|
if (s < 1) {
|
||||||
@ -412,8 +432,8 @@ class CanvasModel with ChangeNotifier {
|
|||||||
} else {
|
} else {
|
||||||
_scale = 1;
|
_scale = 1;
|
||||||
}
|
}
|
||||||
_x = (size.width - FFI.ffiModel.display.width * _scale) / 2;
|
_x = (size.width - getDisplayWidth() * _scale) / 2;
|
||||||
_y = (size.height - FFI.ffiModel.display.height * _scale) / 2;
|
_y = (size.height - getDisplayHeight() * _scale) / 2;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,10 +444,18 @@ class CanvasModel with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getDisplayWidth() {
|
||||||
|
return parent.target?.ffiModel.display.width ?? 1080;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getDisplayHeight() {
|
||||||
|
return parent.target?.ffiModel.display.height ?? 720;
|
||||||
|
}
|
||||||
|
|
||||||
void moveDesktopMouse(double x, double y) {
|
void moveDesktopMouse(double x, double y) {
|
||||||
final size = MediaQueryData.fromWindow(ui.window).size;
|
final size = MediaQueryData.fromWindow(ui.window).size;
|
||||||
final dw = FFI.ffiModel.display.width * _scale;
|
final dw = getDisplayWidth() * _scale;
|
||||||
final dh = FFI.ffiModel.display.height * _scale;
|
final dh = getDisplayHeight() * _scale;
|
||||||
var dxOffset = 0;
|
var dxOffset = 0;
|
||||||
var dyOffset = 0;
|
var dyOffset = 0;
|
||||||
if (dw > size.width) {
|
if (dw > size.width) {
|
||||||
@ -441,7 +469,7 @@ class CanvasModel with ChangeNotifier {
|
|||||||
if (dxOffset != 0 || dyOffset != 0) {
|
if (dxOffset != 0 || dyOffset != 0) {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
FFI.cursorModel.moveLocal(x, y);
|
parent.target?.cursorModel.moveLocal(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
set scale(v) {
|
set scale(v) {
|
||||||
@ -470,17 +498,17 @@ class CanvasModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateScale(double v) {
|
void updateScale(double v) {
|
||||||
if (FFI.imageModel.image == null) return;
|
if (parent.target?.imageModel.image == null) return;
|
||||||
final offset = FFI.cursorModel.offset;
|
final offset = parent.target?.cursorModel.offset ?? Offset(0, 0);
|
||||||
var r = FFI.cursorModel.getVisibleRect();
|
var r = parent.target?.cursorModel.getVisibleRect() ?? Rect.zero;
|
||||||
final px0 = (offset.dx - r.left) * _scale;
|
final px0 = (offset.dx - r.left) * _scale;
|
||||||
final py0 = (offset.dy - r.top) * _scale;
|
final py0 = (offset.dy - r.top) * _scale;
|
||||||
_scale *= v;
|
_scale *= v;
|
||||||
final maxs = FFI.imageModel.maxScale;
|
final maxs = parent.target?.imageModel.maxScale ?? 1;
|
||||||
final mins = FFI.imageModel.minScale;
|
final mins = parent.target?.imageModel.minScale ?? 1;
|
||||||
if (_scale > maxs) _scale = maxs;
|
if (_scale > maxs) _scale = maxs;
|
||||||
if (_scale < mins) _scale = mins;
|
if (_scale < mins) _scale = mins;
|
||||||
r = FFI.cursorModel.getVisibleRect();
|
r = parent.target?.cursorModel.getVisibleRect() ?? Rect.zero;
|
||||||
final px1 = (offset.dx - r.left) * _scale;
|
final px1 = (offset.dx - r.left) * _scale;
|
||||||
final py1 = (offset.dy - r.top) * _scale;
|
final py1 = (offset.dy - r.top) * _scale;
|
||||||
_x -= px1 - px0;
|
_x -= px1 - px0;
|
||||||
@ -506,6 +534,7 @@ class CursorModel with ChangeNotifier {
|
|||||||
double _displayOriginX = 0;
|
double _displayOriginX = 0;
|
||||||
double _displayOriginY = 0;
|
double _displayOriginY = 0;
|
||||||
String id = ""; // TODO multi cursor model
|
String id = ""; // TODO multi cursor model
|
||||||
|
WeakReference<FFI> parent;
|
||||||
|
|
||||||
ui.Image? get image => _image;
|
ui.Image? get image => _image;
|
||||||
|
|
||||||
@ -519,12 +548,14 @@ class CursorModel with ChangeNotifier {
|
|||||||
|
|
||||||
double get hoty => _hoty;
|
double get hoty => _hoty;
|
||||||
|
|
||||||
|
CursorModel(this.parent);
|
||||||
|
|
||||||
// remote physical display coordinate
|
// remote physical display coordinate
|
||||||
Rect getVisibleRect() {
|
Rect getVisibleRect() {
|
||||||
final size = MediaQueryData.fromWindow(ui.window).size;
|
final size = MediaQueryData.fromWindow(ui.window).size;
|
||||||
final xoffset = FFI.canvasModel.x;
|
final xoffset = parent.target?.canvasModel.x ?? 0;
|
||||||
final yoffset = FFI.canvasModel.y;
|
final yoffset = parent.target?.canvasModel.y ?? 0;
|
||||||
final scale = FFI.canvasModel.scale;
|
final scale = parent.target?.canvasModel.scale ?? 1;
|
||||||
final x0 = _displayOriginX - xoffset / scale;
|
final x0 = _displayOriginX - xoffset / scale;
|
||||||
final y0 = _displayOriginY - yoffset / scale;
|
final y0 = _displayOriginY - yoffset / scale;
|
||||||
return Rect.fromLTWH(x0, y0, size.width / scale, size.height / scale);
|
return Rect.fromLTWH(x0, y0, size.width / scale, size.height / scale);
|
||||||
@ -535,7 +566,7 @@ class CursorModel with ChangeNotifier {
|
|||||||
var keyboardHeight = m.viewInsets.bottom;
|
var keyboardHeight = m.viewInsets.bottom;
|
||||||
final size = m.size;
|
final size = m.size;
|
||||||
if (keyboardHeight < 100) return 0;
|
if (keyboardHeight < 100) return 0;
|
||||||
final s = FFI.canvasModel.scale;
|
final s = parent.target?.canvasModel.scale ?? 1.0;
|
||||||
final thresh = (size.height - keyboardHeight) / 2;
|
final thresh = (size.height - keyboardHeight) / 2;
|
||||||
var h = (_y - getVisibleRect().top) * s; // local physical display height
|
var h = (_y - getVisibleRect().top) * s; // local physical display height
|
||||||
return h - thresh;
|
return h - thresh;
|
||||||
@ -543,19 +574,19 @@ class CursorModel with ChangeNotifier {
|
|||||||
|
|
||||||
void touch(double x, double y, MouseButtons button) {
|
void touch(double x, double y, MouseButtons button) {
|
||||||
moveLocal(x, y);
|
moveLocal(x, y);
|
||||||
FFI.moveMouse(_x, _y);
|
parent.target?.moveMouse(_x, _y);
|
||||||
FFI.tap(button);
|
parent.target?.tap(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void move(double x, double y) {
|
void move(double x, double y) {
|
||||||
moveLocal(x, y);
|
moveLocal(x, y);
|
||||||
FFI.moveMouse(_x, _y);
|
parent.target?.moveMouse(_x, _y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveLocal(double x, double y) {
|
void moveLocal(double x, double y) {
|
||||||
final scale = FFI.canvasModel.scale;
|
final scale = parent.target?.canvasModel.scale ?? 1.0;
|
||||||
final xoffset = FFI.canvasModel.x;
|
final xoffset = parent.target?.canvasModel.x ?? 0;
|
||||||
final yoffset = FFI.canvasModel.y;
|
final yoffset = parent.target?.canvasModel.y ?? 0;
|
||||||
_x = (x - xoffset) / scale + _displayOriginX;
|
_x = (x - xoffset) / scale + _displayOriginX;
|
||||||
_y = (y - yoffset) / scale + _displayOriginY;
|
_y = (y - yoffset) / scale + _displayOriginY;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@ -564,22 +595,22 @@ class CursorModel with ChangeNotifier {
|
|||||||
void reset() {
|
void reset() {
|
||||||
_x = _displayOriginX;
|
_x = _displayOriginX;
|
||||||
_y = _displayOriginY;
|
_y = _displayOriginY;
|
||||||
FFI.moveMouse(_x, _y);
|
parent.target?.moveMouse(_x, _y);
|
||||||
FFI.canvasModel.clear(true);
|
parent.target?.canvasModel.clear(true);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updatePan(double dx, double dy, bool touchMode) {
|
void updatePan(double dx, double dy, bool touchMode) {
|
||||||
if (FFI.imageModel.image == null) return;
|
if (parent.target?.imageModel.image == null) return;
|
||||||
if (touchMode) {
|
if (touchMode) {
|
||||||
final scale = FFI.canvasModel.scale;
|
final scale = parent.target?.canvasModel.scale ?? 1.0;
|
||||||
_x += dx / scale;
|
_x += dx / scale;
|
||||||
_y += dy / scale;
|
_y += dy / scale;
|
||||||
FFI.moveMouse(_x, _y);
|
parent.target?.moveMouse(_x, _y);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final scale = FFI.canvasModel.scale;
|
final scale = parent.target?.canvasModel.scale ?? 1.0;
|
||||||
dx /= scale;
|
dx /= scale;
|
||||||
dy /= scale;
|
dy /= scale;
|
||||||
final r = getVisibleRect();
|
final r = getVisibleRect();
|
||||||
@ -588,7 +619,7 @@ class CursorModel with ChangeNotifier {
|
|||||||
var tryMoveCanvasX = false;
|
var tryMoveCanvasX = false;
|
||||||
if (dx > 0) {
|
if (dx > 0) {
|
||||||
final maxCanvasCanMove = _displayOriginX +
|
final maxCanvasCanMove = _displayOriginX +
|
||||||
FFI.imageModel.image!.width -
|
(parent.target?.imageModel.image!.width ?? 1280) -
|
||||||
r.right.roundToDouble();
|
r.right.roundToDouble();
|
||||||
tryMoveCanvasX = _x + dx > cx && maxCanvasCanMove > 0;
|
tryMoveCanvasX = _x + dx > cx && maxCanvasCanMove > 0;
|
||||||
if (tryMoveCanvasX) {
|
if (tryMoveCanvasX) {
|
||||||
@ -610,7 +641,7 @@ class CursorModel with ChangeNotifier {
|
|||||||
var tryMoveCanvasY = false;
|
var tryMoveCanvasY = false;
|
||||||
if (dy > 0) {
|
if (dy > 0) {
|
||||||
final mayCanvasCanMove = _displayOriginY +
|
final mayCanvasCanMove = _displayOriginY +
|
||||||
FFI.imageModel.image!.height -
|
(parent.target?.imageModel.image!.height ?? 720) -
|
||||||
r.bottom.roundToDouble();
|
r.bottom.roundToDouble();
|
||||||
tryMoveCanvasY = _y + dy > cy && mayCanvasCanMove > 0;
|
tryMoveCanvasY = _y + dy > cy && mayCanvasCanMove > 0;
|
||||||
if (tryMoveCanvasY) {
|
if (tryMoveCanvasY) {
|
||||||
@ -634,13 +665,13 @@ class CursorModel with ChangeNotifier {
|
|||||||
_x += dx;
|
_x += dx;
|
||||||
_y += dy;
|
_y += dy;
|
||||||
if (tryMoveCanvasX && dx != 0) {
|
if (tryMoveCanvasX && dx != 0) {
|
||||||
FFI.canvasModel.panX(-dx);
|
parent.target?.canvasModel.panX(-dx);
|
||||||
}
|
}
|
||||||
if (tryMoveCanvasY && dy != 0) {
|
if (tryMoveCanvasY && dy != 0) {
|
||||||
FFI.canvasModel.panY(-dy);
|
parent.target?.canvasModel.panY(-dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
FFI.moveMouse(_x, _y);
|
parent.target?.moveMouse(_x, _y);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -652,10 +683,10 @@ class CursorModel with ChangeNotifier {
|
|||||||
var height = int.parse(evt['height']);
|
var height = int.parse(evt['height']);
|
||||||
List<dynamic> colors = json.decode(evt['colors']);
|
List<dynamic> colors = json.decode(evt['colors']);
|
||||||
final rgba = Uint8List.fromList(colors.map((s) => s as int).toList());
|
final rgba = Uint8List.fromList(colors.map((s) => s as int).toList());
|
||||||
var pid = FFI.id;
|
var pid = parent.target?.id;
|
||||||
ui.decodeImageFromPixels(rgba, width, height, ui.PixelFormat.rgba8888,
|
ui.decodeImageFromPixels(rgba, width, height, ui.PixelFormat.rgba8888,
|
||||||
(image) {
|
(image) {
|
||||||
if (FFI.id != pid) return;
|
if (parent.target?.id != pid) return;
|
||||||
_image = image;
|
_image = image;
|
||||||
_images[id] = Tuple3(image, _hotx, _hoty);
|
_images[id] = Tuple3(image, _hotx, _hoty);
|
||||||
try {
|
try {
|
||||||
@ -688,8 +719,8 @@ class CursorModel with ChangeNotifier {
|
|||||||
_displayOriginY = y;
|
_displayOriginY = y;
|
||||||
_x = x + 1;
|
_x = x + 1;
|
||||||
_y = y + 1;
|
_y = y + 1;
|
||||||
FFI.moveMouse(x, y);
|
parent.target?.moveMouse(x, y);
|
||||||
FFI.canvasModel.resetOffset();
|
parent.target?.canvasModel.resetOffset();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,7 +730,7 @@ class CursorModel with ChangeNotifier {
|
|||||||
_displayOriginY = y;
|
_displayOriginY = y;
|
||||||
_x = xCursor;
|
_x = xCursor;
|
||||||
_y = yCursor;
|
_y = yCursor;
|
||||||
FFI.moveMouse(x, y);
|
parent.target?.moveMouse(x, y);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,33 +760,43 @@ extension ToString on MouseButtons {
|
|||||||
|
|
||||||
/// FFI class for communicating with the Rust core.
|
/// FFI class for communicating with the Rust core.
|
||||||
class FFI {
|
class FFI {
|
||||||
static var id = "";
|
var id = "";
|
||||||
static var shift = false;
|
var shift = false;
|
||||||
static var ctrl = false;
|
var ctrl = false;
|
||||||
static var alt = false;
|
var alt = false;
|
||||||
static var command = false;
|
var command = false;
|
||||||
static var version = "";
|
var version = "";
|
||||||
static final imageModel = ImageModel();
|
late final ImageModel imageModel;
|
||||||
static final ffiModel = FfiModel();
|
late final FfiModel ffiModel;
|
||||||
static final cursorModel = CursorModel();
|
late final CursorModel cursorModel;
|
||||||
static final canvasModel = CanvasModel();
|
late final CanvasModel canvasModel;
|
||||||
static final serverModel = ServerModel();
|
late final ServerModel serverModel;
|
||||||
static final chatModel = ChatModel();
|
late final ChatModel chatModel;
|
||||||
static final fileModel = FileModel();
|
late final FileModel fileModel;
|
||||||
|
|
||||||
|
FFI() {
|
||||||
|
this.imageModel = ImageModel(WeakReference(this));
|
||||||
|
this.ffiModel = FfiModel(WeakReference(this));
|
||||||
|
this.cursorModel = CursorModel(WeakReference(this));
|
||||||
|
this.canvasModel = CanvasModel(WeakReference(this));
|
||||||
|
this.serverModel = ServerModel(WeakReference(this)); // use global FFI
|
||||||
|
this.chatModel = ChatModel(WeakReference(this));
|
||||||
|
this.fileModel = FileModel(WeakReference(this));
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the remote id for current client.
|
/// Get the remote id for current client.
|
||||||
static String getId() {
|
String getId() {
|
||||||
return getByName('remote_id'); // TODO
|
return getByName('remote_id'); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a mouse tap event(down and up).
|
/// Send a mouse tap event(down and up).
|
||||||
static void tap(MouseButtons button) {
|
void tap(MouseButtons button) {
|
||||||
sendMouse('down', button);
|
sendMouse('down', button);
|
||||||
sendMouse('up', button);
|
sendMouse('up', button);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send scroll event with scroll distance [y].
|
/// Send scroll event with scroll distance [y].
|
||||||
static void scroll(int y) {
|
void scroll(int y) {
|
||||||
setByName('send_mouse',
|
setByName('send_mouse',
|
||||||
json.encode(modify({'id': id, 'type': 'wheel', 'y': y.toString()})));
|
json.encode(modify({'id': id, 'type': 'wheel', 'y': y.toString()})));
|
||||||
}
|
}
|
||||||
@ -763,16 +804,16 @@ class FFI {
|
|||||||
/// Reconnect to the remote peer.
|
/// Reconnect to the remote peer.
|
||||||
// static void reconnect() {
|
// static void reconnect() {
|
||||||
// setByName('reconnect');
|
// setByName('reconnect');
|
||||||
// FFI.ffiModel.clearPermissions();
|
// parent.target?.ffiModel.clearPermissions();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/// Reset key modifiers to false, including [shift], [ctrl], [alt] and [command].
|
/// Reset key modifiers to false, including [shift], [ctrl], [alt] and [command].
|
||||||
static void resetModifiers() {
|
void resetModifiers() {
|
||||||
shift = ctrl = alt = command = false;
|
shift = ctrl = alt = command = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Modify the given modifier map [evt] based on current modifier key status.
|
/// Modify the given modifier map [evt] based on current modifier key status.
|
||||||
static Map<String, String> modify(Map<String, String> evt) {
|
Map<String, String> modify(Map<String, String> evt) {
|
||||||
if (ctrl) evt['ctrl'] = 'true';
|
if (ctrl) evt['ctrl'] = 'true';
|
||||||
if (shift) evt['shift'] = 'true';
|
if (shift) evt['shift'] = 'true';
|
||||||
if (alt) evt['alt'] = 'true';
|
if (alt) evt['alt'] = 'true';
|
||||||
@ -781,7 +822,7 @@ class FFI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Send mouse press event.
|
/// Send mouse press event.
|
||||||
static void sendMouse(String type, MouseButtons button) {
|
void sendMouse(String type, MouseButtons button) {
|
||||||
if (!ffiModel.keyboard()) return;
|
if (!ffiModel.keyboard()) return;
|
||||||
setByName('send_mouse',
|
setByName('send_mouse',
|
||||||
json.encode(modify({'id': id, 'type': type, 'buttons': button.value})));
|
json.encode(modify({'id': id, 'type': type, 'buttons': button.value})));
|
||||||
@ -790,7 +831,7 @@ class FFI {
|
|||||||
/// Send key stroke event.
|
/// Send key stroke event.
|
||||||
/// [down] indicates the key's state(down or up).
|
/// [down] indicates the key's state(down or up).
|
||||||
/// [press] indicates a click event(down and up).
|
/// [press] indicates a click event(down and up).
|
||||||
static void inputKey(String name, {bool? down, bool? press}) {
|
void inputKey(String name, {bool? down, bool? press}) {
|
||||||
if (!ffiModel.keyboard()) return;
|
if (!ffiModel.keyboard()) return;
|
||||||
// final Map<String, String> out = Map();
|
// final Map<String, String> out = Map();
|
||||||
// out['name'] = name;
|
// out['name'] = name;
|
||||||
@ -804,7 +845,7 @@ class FFI {
|
|||||||
// }
|
// }
|
||||||
// setByName('input_key', json.encode(modify(out)));
|
// setByName('input_key', json.encode(modify(out)));
|
||||||
// TODO id
|
// TODO id
|
||||||
FFI.bind.sessionInputKey(
|
bind.sessionInputKey(
|
||||||
id: id,
|
id: id,
|
||||||
name: name,
|
name: name,
|
||||||
down: down ?? false,
|
down: down ?? false,
|
||||||
@ -816,7 +857,7 @@ class FFI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Send mouse movement event with distance in [x] and [y].
|
/// Send mouse movement event with distance in [x] and [y].
|
||||||
static void moveMouse(double x, double y) {
|
void moveMouse(double x, double y) {
|
||||||
if (!ffiModel.keyboard()) return;
|
if (!ffiModel.keyboard()) return;
|
||||||
var x2 = x.toInt();
|
var x2 = x.toInt();
|
||||||
var y2 = y.toInt();
|
var y2 = y.toInt();
|
||||||
@ -825,7 +866,7 @@ class FFI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// List the saved peers.
|
/// List the saved peers.
|
||||||
static List<Peer> peers() {
|
List<Peer> peers() {
|
||||||
try {
|
try {
|
||||||
var str = getByName('peers'); // TODO
|
var str = getByName('peers'); // TODO
|
||||||
if (str == "") return [];
|
if (str == "") return [];
|
||||||
@ -842,19 +883,19 @@ class FFI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Connect with the given [id]. Only transfer file if [isFileTransfer].
|
/// Connect with the given [id]. Only transfer file if [isFileTransfer].
|
||||||
static void connect(String id, {bool isFileTransfer = false}) {
|
void connect(String id, {bool isFileTransfer = false}) {
|
||||||
if (isFileTransfer) {
|
if (isFileTransfer) {
|
||||||
setByName('connect_file_transfer', id);
|
setByName('connect_file_transfer', id);
|
||||||
} else {
|
} else {
|
||||||
FFI.chatModel.resetClientMode();
|
chatModel.resetClientMode();
|
||||||
// setByName('connect', id);
|
// setByName('connect', id);
|
||||||
// TODO multi model instances
|
// TODO multi model instances
|
||||||
FFI.canvasModel.id = id;
|
canvasModel.id = id;
|
||||||
FFI.imageModel._id = id;
|
imageModel._id = id;
|
||||||
FFI.cursorModel.id = id;
|
cursorModel.id = id;
|
||||||
final stream =
|
final stream =
|
||||||
FFI.bind.sessionConnect(id: id, isFileTransfer: isFileTransfer);
|
bind.sessionConnect(id: id, isFileTransfer: isFileTransfer);
|
||||||
final cb = FFI.ffiModel.startEventListener(id);
|
final cb = ffiModel.startEventListener(id);
|
||||||
() async {
|
() async {
|
||||||
await for (final message in stream) {
|
await for (final message in stream) {
|
||||||
if (message is Event) {
|
if (message is Event) {
|
||||||
@ -866,28 +907,28 @@ class FFI {
|
|||||||
print('json.decode fail(): $e');
|
print('json.decode fail(): $e');
|
||||||
}
|
}
|
||||||
} else if (message is Rgba) {
|
} else if (message is Rgba) {
|
||||||
FFI.imageModel.onRgba(message.field0);
|
imageModel.onRgba(message.field0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
// every instance will bind a stream
|
// every instance will bind a stream
|
||||||
}
|
}
|
||||||
FFI.id = id;
|
id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Login with [password], choose if the client should [remember] it.
|
/// Login with [password], choose if the client should [remember] it.
|
||||||
static void login(String id, String password, bool remember) {
|
void login(String id, String password, bool remember) {
|
||||||
FFI.bind.sessionLogin(id: id, password: password, remember: remember);
|
bind.sessionLogin(id: id, password: password, remember: remember);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Close the remote session.
|
/// Close the remote session.
|
||||||
static void close() {
|
void close() {
|
||||||
chatModel.close();
|
chatModel.close();
|
||||||
if (FFI.imageModel.image != null && !isWebDesktop) {
|
if (imageModel.image != null && !isWebDesktop) {
|
||||||
savePreference(id, cursorModel.x, cursorModel.y, canvasModel.x,
|
savePreference(id, cursorModel.x, cursorModel.y, canvasModel.x,
|
||||||
canvasModel.y, canvasModel.scale, ffiModel.pi.currentDisplay);
|
canvasModel.y, canvasModel.scale, ffiModel.pi.currentDisplay);
|
||||||
}
|
}
|
||||||
FFI.bind.sessionClose(id: id);
|
bind.sessionClose(id: id);
|
||||||
id = "";
|
id = "";
|
||||||
imageModel.update(null);
|
imageModel.update(null);
|
||||||
cursorModel.clear();
|
cursorModel.clear();
|
||||||
@ -898,18 +939,18 @@ class FFI {
|
|||||||
|
|
||||||
/// Send **get** command to the Rust core based on [name] and [arg].
|
/// Send **get** command to the Rust core based on [name] and [arg].
|
||||||
/// Return the result as a string.
|
/// Return the result as a string.
|
||||||
static String getByName(String name, [String arg = '']) {
|
String getByName(String name, [String arg = '']) {
|
||||||
return PlatformFFI.getByName(name, arg);
|
return ffiModel.platformFFI.getByName(name, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send **set** command to the Rust core based on [name] and [value].
|
/// Send **set** command to the Rust core based on [name] and [value].
|
||||||
static void setByName(String name, [String value = '']) {
|
void setByName(String name, [String value = '']) {
|
||||||
PlatformFFI.setByName(name, value);
|
ffiModel.platformFFI.setByName(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RustdeskImpl get bind => PlatformFFI.ffiBind;
|
RustdeskImpl get bind => ffiModel.platformFFI.ffiBind;
|
||||||
|
|
||||||
static handleMouse(Map<String, dynamic> evt) {
|
handleMouse(Map<String, dynamic> evt) {
|
||||||
var type = '';
|
var type = '';
|
||||||
var isMove = false;
|
var isMove = false;
|
||||||
switch (evt['type']) {
|
switch (evt['type']) {
|
||||||
@ -929,16 +970,16 @@ class FFI {
|
|||||||
var x = evt['x'];
|
var x = evt['x'];
|
||||||
var y = evt['y'];
|
var y = evt['y'];
|
||||||
if (isMove) {
|
if (isMove) {
|
||||||
FFI.canvasModel.moveDesktopMouse(x, y);
|
canvasModel.moveDesktopMouse(x, y);
|
||||||
}
|
}
|
||||||
final d = FFI.ffiModel.display;
|
final d = ffiModel.display;
|
||||||
x -= FFI.canvasModel.x;
|
x -= canvasModel.x;
|
||||||
y -= FFI.canvasModel.y;
|
y -= canvasModel.y;
|
||||||
if (!isMove && (x < 0 || x > d.width || y < 0 || y > d.height)) {
|
if (!isMove && (x < 0 || x > d.width || y < 0 || y > d.height)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
x /= FFI.canvasModel.scale;
|
x /= canvasModel.scale;
|
||||||
y /= FFI.canvasModel.scale;
|
y /= canvasModel.scale;
|
||||||
x += d.x;
|
x += d.x;
|
||||||
y += d.y;
|
y += d.y;
|
||||||
if (type != '') {
|
if (type != '') {
|
||||||
@ -964,20 +1005,20 @@ class FFI {
|
|||||||
setByName('send_mouse', json.encode(evt));
|
setByName('send_mouse', json.encode(evt));
|
||||||
}
|
}
|
||||||
|
|
||||||
static listenToMouse(bool yesOrNo) {
|
listenToMouse(bool yesOrNo) {
|
||||||
if (yesOrNo) {
|
if (yesOrNo) {
|
||||||
PlatformFFI.startDesktopWebListener();
|
ffiModel.platformFFI.startDesktopWebListener();
|
||||||
} else {
|
} else {
|
||||||
PlatformFFI.stopDesktopWebListener();
|
ffiModel.platformFFI.stopDesktopWebListener();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setMethodCallHandler(FMethod callback) {
|
void setMethodCallHandler(FMethod callback) {
|
||||||
PlatformFFI.setMethodCallHandler(callback);
|
ffiModel.platformFFI.setMethodCallHandler(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> invokeMethod(String method, [dynamic arguments]) async {
|
Future<bool> invokeMethod(String method, [dynamic arguments]) async {
|
||||||
return await PlatformFFI.invokeMethod(method, arguments);
|
return await ffiModel.platformFFI.invokeMethod(method, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1038,15 +1079,15 @@ void removePreference(String id) async {
|
|||||||
prefs.remove('peer' + id);
|
prefs.remove('peer' + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initializeCursorAndCanvas() async {
|
void initializeCursorAndCanvas(FFI ffi) async {
|
||||||
var p = await getPreference(FFI.id);
|
var p = await getPreference(ffi.id);
|
||||||
int currentDisplay = 0;
|
int currentDisplay = 0;
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
currentDisplay = p['currentDisplay'];
|
currentDisplay = p['currentDisplay'];
|
||||||
}
|
}
|
||||||
if (p == null || currentDisplay != FFI.ffiModel.pi.currentDisplay) {
|
if (p == null || currentDisplay != ffi.ffiModel.pi.currentDisplay) {
|
||||||
FFI.cursorModel
|
ffi.cursorModel
|
||||||
.updateDisplayOrigin(FFI.ffiModel.display.x, FFI.ffiModel.display.y);
|
.updateDisplayOrigin(ffi.ffiModel.display.x, ffi.ffiModel.display.y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double xCursor = p['xCursor'];
|
double xCursor = p['xCursor'];
|
||||||
@ -1054,17 +1095,19 @@ void initializeCursorAndCanvas() async {
|
|||||||
double xCanvas = p['xCanvas'];
|
double xCanvas = p['xCanvas'];
|
||||||
double yCanvas = p['yCanvas'];
|
double yCanvas = p['yCanvas'];
|
||||||
double scale = p['scale'];
|
double scale = p['scale'];
|
||||||
FFI.cursorModel.updateDisplayOriginWithCursor(
|
ffi.cursorModel.updateDisplayOriginWithCursor(
|
||||||
FFI.ffiModel.display.x, FFI.ffiModel.display.y, xCursor, yCursor);
|
ffi.ffiModel.display.x, ffi.ffiModel.display.y, xCursor, yCursor);
|
||||||
FFI.canvasModel.update(xCanvas, yCanvas, scale);
|
ffi.canvasModel.update(xCanvas, yCanvas, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translate text based on the pre-defined dictionary.
|
/// Translate text based on the pre-defined dictionary.
|
||||||
String translate(String name) {
|
/// note: params [FFI?] can be used to replace global FFI implementation
|
||||||
|
/// for example: during global initialization, gFFI not exists yet.
|
||||||
|
String translate(String name, {FFI? ffi}) {
|
||||||
if (name.startsWith('Failed to') && name.contains(': ')) {
|
if (name.startsWith('Failed to') && name.contains(': ')) {
|
||||||
return name.split(': ').map((x) => translate(x)).join(': ');
|
return name.split(': ').map((x) => translate(x)).join(': ');
|
||||||
}
|
}
|
||||||
var a = 'translate';
|
var a = 'translate';
|
||||||
var b = '{"locale": "$localeName", "text": "$name"}';
|
var b = '{"locale": "$localeName", "text": "$name"}';
|
||||||
return FFI.getByName(a, b);
|
return (ffi ?? gFFI).getByName(a, b);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,15 +25,15 @@ typedef F3 = void Function(Pointer<Utf8>, Pointer<Utf8>);
|
|||||||
/// FFI wrapper around the native Rust core.
|
/// FFI wrapper around the native Rust core.
|
||||||
/// Hides the platform differences.
|
/// Hides the platform differences.
|
||||||
class PlatformFFI {
|
class PlatformFFI {
|
||||||
static Pointer<RgbaFrame>? _lastRgbaFrame;
|
Pointer<RgbaFrame>? _lastRgbaFrame;
|
||||||
static String _dir = '';
|
String _dir = '';
|
||||||
static String _homeDir = '';
|
String _homeDir = '';
|
||||||
static F2? _getByName;
|
F2? _getByName;
|
||||||
static F3? _setByName;
|
F3? _setByName;
|
||||||
static late RustdeskImpl _ffiBind;
|
late RustdeskImpl _ffiBind;
|
||||||
static void Function(Map<String, dynamic>)? _eventCallback;
|
void Function(Map<String, dynamic>)? _eventCallback;
|
||||||
|
|
||||||
static RustdeskImpl get ffiBind => _ffiBind;
|
RustdeskImpl get ffiBind => _ffiBind;
|
||||||
|
|
||||||
static Future<String> getVersion() async {
|
static Future<String> getVersion() async {
|
||||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||||
@ -42,7 +42,7 @@ class PlatformFFI {
|
|||||||
|
|
||||||
/// Send **get** command to the Rust core based on [name] and [arg].
|
/// Send **get** command to the Rust core based on [name] and [arg].
|
||||||
/// Return the result as a string.
|
/// Return the result as a string.
|
||||||
static String getByName(String name, [String arg = '']) {
|
String getByName(String name, [String arg = '']) {
|
||||||
if (_getByName == null) return '';
|
if (_getByName == null) return '';
|
||||||
var a = name.toNativeUtf8();
|
var a = name.toNativeUtf8();
|
||||||
var b = arg.toNativeUtf8();
|
var b = arg.toNativeUtf8();
|
||||||
@ -56,7 +56,7 @@ class PlatformFFI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Send **set** command to the Rust core based on [name] and [value].
|
/// Send **set** command to the Rust core based on [name] and [value].
|
||||||
static void setByName(String name, [String value = '']) {
|
void setByName(String name, [String value = '']) {
|
||||||
if (_setByName == null) return;
|
if (_setByName == null) return;
|
||||||
var a = name.toNativeUtf8();
|
var a = name.toNativeUtf8();
|
||||||
var b = value.toNativeUtf8();
|
var b = value.toNativeUtf8();
|
||||||
@ -66,7 +66,7 @@ class PlatformFFI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Init the FFI class, loads the native Rust core library.
|
/// Init the FFI class, loads the native Rust core library.
|
||||||
static Future<Null> init() async {
|
Future<Null> init() async {
|
||||||
isIOS = Platform.isIOS;
|
isIOS = Platform.isIOS;
|
||||||
isAndroid = Platform.isAndroid;
|
isAndroid = Platform.isAndroid;
|
||||||
isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
||||||
@ -134,7 +134,7 @@ class PlatformFFI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Start listening to the Rust core's events and frames.
|
/// Start listening to the Rust core's events and frames.
|
||||||
static void _startListenEvent(RustdeskImpl rustdeskImpl) {
|
void _startListenEvent(RustdeskImpl rustdeskImpl) {
|
||||||
() async {
|
() async {
|
||||||
await for (final message in rustdeskImpl.startGlobalEventStream()) {
|
await for (final message in rustdeskImpl.startGlobalEventStream()) {
|
||||||
if (_eventCallback != null) {
|
if (_eventCallback != null) {
|
||||||
@ -149,24 +149,24 @@ class PlatformFFI {
|
|||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setEventCallback(void Function(Map<String, dynamic>) fun) async {
|
void setEventCallback(void Function(Map<String, dynamic>) fun) async {
|
||||||
_eventCallback = fun;
|
_eventCallback = fun;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setRgbaCallback(void Function(Uint8List) fun) async {}
|
void setRgbaCallback(void Function(Uint8List) fun) async {}
|
||||||
|
|
||||||
static void startDesktopWebListener() {}
|
void startDesktopWebListener() {}
|
||||||
|
|
||||||
static void stopDesktopWebListener() {}
|
void stopDesktopWebListener() {}
|
||||||
|
|
||||||
static void setMethodCallHandler(FMethod callback) {
|
void setMethodCallHandler(FMethod callback) {
|
||||||
toAndroidChannel.setMethodCallHandler((call) async {
|
toAndroidChannel.setMethodCallHandler((call) async {
|
||||||
callback(call.method, call.arguments);
|
callback(call.method, call.arguments);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static invokeMethod(String method, [dynamic arguments]) async {
|
invokeMethod(String method, [dynamic arguments]) async {
|
||||||
if (!isAndroid) return Future<bool>(() => false);
|
if (!isAndroid) return Future<bool>(() => false);
|
||||||
return await toAndroidChannel.invokeMethod(method, arguments);
|
return await toAndroidChannel.invokeMethod(method, arguments);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import '../mobile/pages/server_page.dart';
|
|||||||
import 'model.dart';
|
import 'model.dart';
|
||||||
|
|
||||||
const loginDialogTag = "LOGIN";
|
const loginDialogTag = "LOGIN";
|
||||||
final _emptyIdShow = translate("Generating ...");
|
|
||||||
|
|
||||||
class ServerModel with ChangeNotifier {
|
class ServerModel with ChangeNotifier {
|
||||||
bool _isStart = false; // Android MainService status
|
bool _isStart = false; // Android MainService status
|
||||||
@ -20,7 +19,8 @@ class ServerModel with ChangeNotifier {
|
|||||||
bool _fileOk = false;
|
bool _fileOk = false;
|
||||||
int _connectStatus = 0; // Rendezvous Server status
|
int _connectStatus = 0; // Rendezvous Server status
|
||||||
|
|
||||||
final _serverId = TextEditingController(text: _emptyIdShow);
|
late String _emptyIdShow;
|
||||||
|
late final TextEditingController _serverId;
|
||||||
final _serverPasswd = TextEditingController(text: "");
|
final _serverPasswd = TextEditingController(text: "");
|
||||||
|
|
||||||
Map<int, Client> _clients = {};
|
Map<int, Client> _clients = {};
|
||||||
@ -45,8 +45,12 @@ class ServerModel with ChangeNotifier {
|
|||||||
|
|
||||||
final controller = ScrollController();
|
final controller = ScrollController();
|
||||||
|
|
||||||
ServerModel() {
|
WeakReference<FFI> parent;
|
||||||
|
|
||||||
|
ServerModel(this.parent) {
|
||||||
() async {
|
() async {
|
||||||
|
_emptyIdShow = translate("Generating ...", ffi: this.parent.target);
|
||||||
|
_serverId = TextEditingController(text: this._emptyIdShow);
|
||||||
/**
|
/**
|
||||||
* 1. check android permission
|
* 1. check android permission
|
||||||
* 2. check config
|
* 2. check config
|
||||||
@ -59,39 +63,42 @@ class ServerModel with ChangeNotifier {
|
|||||||
// audio
|
// audio
|
||||||
if (androidVersion < 30 || !await PermissionManager.check("audio")) {
|
if (androidVersion < 30 || !await PermissionManager.check("audio")) {
|
||||||
_audioOk = false;
|
_audioOk = false;
|
||||||
FFI.setByName(
|
parent.target?.setByName(
|
||||||
'option',
|
'option',
|
||||||
jsonEncode(Map()
|
jsonEncode(Map()
|
||||||
..["name"] = "enable-audio"
|
..["name"] = "enable-audio"
|
||||||
..["value"] = "N"));
|
..["value"] = "N"));
|
||||||
} else {
|
} else {
|
||||||
final audioOption = FFI.getByName('option', 'enable-audio');
|
final audioOption = parent.target?.getByName('option', 'enable-audio');
|
||||||
_audioOk = audioOption.isEmpty;
|
_audioOk = audioOption?.isEmpty ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// file
|
// file
|
||||||
if (!await PermissionManager.check("file")) {
|
if (!await PermissionManager.check("file")) {
|
||||||
_fileOk = false;
|
_fileOk = false;
|
||||||
FFI.setByName(
|
parent.target?.setByName(
|
||||||
'option',
|
'option',
|
||||||
jsonEncode(Map()
|
jsonEncode(Map()
|
||||||
..["name"] = "enable-file-transfer"
|
..["name"] = "enable-file-transfer"
|
||||||
..["value"] = "N"));
|
..["value"] = "N"));
|
||||||
} else {
|
} else {
|
||||||
final fileOption = FFI.getByName('option', 'enable-file-transfer');
|
final fileOption =
|
||||||
_fileOk = fileOption.isEmpty;
|
parent.target?.getByName('option', 'enable-file-transfer');
|
||||||
|
_fileOk = fileOption?.isEmpty ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// input (mouse control)
|
// input (mouse control)
|
||||||
Map<String, String> res = Map()
|
Map<String, String> res = Map()
|
||||||
..["name"] = "enable-keyboard"
|
..["name"] = "enable-keyboard"
|
||||||
..["value"] = 'N';
|
..["value"] = 'N';
|
||||||
FFI.setByName('option', jsonEncode(res)); // input false by default
|
parent.target
|
||||||
|
?.setByName('option', jsonEncode(res)); // input false by default
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}();
|
}();
|
||||||
|
|
||||||
Timer.periodic(Duration(seconds: 1), (timer) {
|
Timer.periodic(Duration(seconds: 1), (timer) {
|
||||||
var status = int.tryParse(FFI.getByName('connect_statue')) ?? 0;
|
var status =
|
||||||
|
int.tryParse(parent.target?.getByName('connect_statue') ?? "") ?? 0;
|
||||||
if (status > 0) {
|
if (status > 0) {
|
||||||
status = 1;
|
status = 1;
|
||||||
}
|
}
|
||||||
@ -99,8 +106,9 @@ class ServerModel with ChangeNotifier {
|
|||||||
_connectStatus = status;
|
_connectStatus = status;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
final res =
|
final res = parent.target
|
||||||
FFI.getByName('check_clients_length', _clients.length.toString());
|
?.getByName('check_clients_length', _clients.length.toString()) ??
|
||||||
|
"";
|
||||||
if (res.isNotEmpty) {
|
if (res.isNotEmpty) {
|
||||||
debugPrint("clients not match!");
|
debugPrint("clients not match!");
|
||||||
updateClientState(res);
|
updateClientState(res);
|
||||||
@ -121,7 +129,7 @@ class ServerModel with ChangeNotifier {
|
|||||||
Map<String, String> res = Map()
|
Map<String, String> res = Map()
|
||||||
..["name"] = "enable-audio"
|
..["name"] = "enable-audio"
|
||||||
..["value"] = _audioOk ? '' : 'N';
|
..["value"] = _audioOk ? '' : 'N';
|
||||||
FFI.setByName('option', jsonEncode(res));
|
parent.target?.setByName('option', jsonEncode(res));
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,15 +146,17 @@ class ServerModel with ChangeNotifier {
|
|||||||
Map<String, String> res = Map()
|
Map<String, String> res = Map()
|
||||||
..["name"] = "enable-file-transfer"
|
..["name"] = "enable-file-transfer"
|
||||||
..["value"] = _fileOk ? '' : 'N';
|
..["value"] = _fileOk ? '' : 'N';
|
||||||
FFI.setByName('option', jsonEncode(res));
|
parent.target?.setByName('option', jsonEncode(res));
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleInput() {
|
toggleInput() {
|
||||||
if (_inputOk) {
|
if (_inputOk) {
|
||||||
FFI.invokeMethod("stop_input");
|
parent.target?.invokeMethod("stop_input");
|
||||||
} else {
|
} else {
|
||||||
showInputWarnAlert();
|
if (parent.target != null) {
|
||||||
|
showInputWarnAlert(parent.target!);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,9 +213,10 @@ class ServerModel with ChangeNotifier {
|
|||||||
Future<Null> startService() async {
|
Future<Null> startService() async {
|
||||||
_isStart = true;
|
_isStart = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
FFI.ffiModel.updateEventListener("");
|
// TODO
|
||||||
await FFI.invokeMethod("init_service");
|
parent.target?.ffiModel.updateEventListener("");
|
||||||
FFI.setByName("start_service");
|
await parent.target?.invokeMethod("init_service");
|
||||||
|
parent.target?.setByName("start_service");
|
||||||
getIDPasswd();
|
getIDPasswd();
|
||||||
updateClientState();
|
updateClientState();
|
||||||
if (!Platform.isLinux) {
|
if (!Platform.isLinux) {
|
||||||
@ -217,9 +228,10 @@ class ServerModel with ChangeNotifier {
|
|||||||
/// Stop the screen sharing service.
|
/// Stop the screen sharing service.
|
||||||
Future<Null> stopService() async {
|
Future<Null> stopService() async {
|
||||||
_isStart = false;
|
_isStart = false;
|
||||||
FFI.serverModel.closeAll();
|
// TODO
|
||||||
await FFI.invokeMethod("stop_service");
|
parent.target?.serverModel.closeAll();
|
||||||
FFI.setByName("stop_service");
|
await parent.target?.invokeMethod("stop_service");
|
||||||
|
parent.target?.setByName("stop_service");
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
if (!Platform.isLinux) {
|
if (!Platform.isLinux) {
|
||||||
// current linux is not supported
|
// current linux is not supported
|
||||||
@ -228,12 +240,12 @@ class ServerModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Null> initInput() async {
|
Future<Null> initInput() async {
|
||||||
await FFI.invokeMethod("init_input");
|
await parent.target?.invokeMethod("init_input");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> updatePassword(String pw) async {
|
Future<bool> updatePassword(String pw) async {
|
||||||
final oldPasswd = _serverPasswd.text;
|
final oldPasswd = _serverPasswd.text;
|
||||||
FFI.setByName("update_password", pw);
|
parent.target?.setByName("update_password", pw);
|
||||||
await Future.delayed(Duration(milliseconds: 500));
|
await Future.delayed(Duration(milliseconds: 500));
|
||||||
await getIDPasswd(force: true);
|
await getIDPasswd(force: true);
|
||||||
|
|
||||||
@ -261,8 +273,8 @@ class ServerModel with ChangeNotifier {
|
|||||||
const maxCount = 10;
|
const maxCount = 10;
|
||||||
while (count < maxCount) {
|
while (count < maxCount) {
|
||||||
await Future.delayed(Duration(seconds: 1));
|
await Future.delayed(Duration(seconds: 1));
|
||||||
final id = FFI.getByName("server_id");
|
final id = parent.target?.getByName("server_id") ?? "";
|
||||||
final passwd = FFI.getByName("server_password");
|
final passwd = parent.target?.getByName("server_password") ?? "";
|
||||||
if (id.isEmpty) {
|
if (id.isEmpty) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
@ -299,7 +311,7 @@ class ServerModel with ChangeNotifier {
|
|||||||
Map<String, String> res = Map()
|
Map<String, String> res = Map()
|
||||||
..["name"] = "enable-keyboard"
|
..["name"] = "enable-keyboard"
|
||||||
..["value"] = value ? '' : 'N';
|
..["value"] = value ? '' : 'N';
|
||||||
FFI.setByName('option', jsonEncode(res));
|
parent.target?.setByName('option', jsonEncode(res));
|
||||||
}
|
}
|
||||||
_inputOk = value;
|
_inputOk = value;
|
||||||
break;
|
break;
|
||||||
@ -310,7 +322,7 @@ class ServerModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateClientState([String? json]) {
|
updateClientState([String? json]) {
|
||||||
var res = json ?? FFI.getByName("clients_state");
|
var res = json ?? parent.target?.getByName("clients_state") ?? "";
|
||||||
try {
|
try {
|
||||||
final List clientsJson = jsonDecode(res);
|
final List clientsJson = jsonDecode(res);
|
||||||
for (var clientJson in clientsJson) {
|
for (var clientJson in clientsJson) {
|
||||||
@ -397,16 +409,16 @@ class ServerModel with ChangeNotifier {
|
|||||||
response["id"] = client.id;
|
response["id"] = client.id;
|
||||||
response["res"] = res;
|
response["res"] = res;
|
||||||
if (res) {
|
if (res) {
|
||||||
FFI.setByName("login_res", jsonEncode(response));
|
parent.target?.setByName("login_res", jsonEncode(response));
|
||||||
if (!client.isFileTransfer) {
|
if (!client.isFileTransfer) {
|
||||||
FFI.invokeMethod("start_capture");
|
parent.target?.invokeMethod("start_capture");
|
||||||
}
|
}
|
||||||
FFI.invokeMethod("cancel_notification", client.id);
|
parent.target?.invokeMethod("cancel_notification", client.id);
|
||||||
_clients[client.id]?.authorized = true;
|
_clients[client.id]?.authorized = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} else {
|
} else {
|
||||||
FFI.setByName("login_res", jsonEncode(response));
|
parent.target?.setByName("login_res", jsonEncode(response));
|
||||||
FFI.invokeMethod("cancel_notification", client.id);
|
parent.target?.invokeMethod("cancel_notification", client.id);
|
||||||
_clients.remove(client.id);
|
_clients.remove(client.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,7 +439,7 @@ class ServerModel with ChangeNotifier {
|
|||||||
if (_clients.containsKey(id)) {
|
if (_clients.containsKey(id)) {
|
||||||
_clients.remove(id);
|
_clients.remove(id);
|
||||||
DialogManager.dismissByTag(getLoginDialogTag(id));
|
DialogManager.dismissByTag(getLoginDialogTag(id));
|
||||||
FFI.invokeMethod("cancel_notification", id);
|
parent.target?.invokeMethod("cancel_notification", id);
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -437,7 +449,7 @@ class ServerModel with ChangeNotifier {
|
|||||||
|
|
||||||
closeAll() {
|
closeAll() {
|
||||||
_clients.forEach((id, client) {
|
_clients.forEach((id, client) {
|
||||||
FFI.setByName("close_conn", id.toString());
|
parent.target?.setByName("close_conn", id.toString());
|
||||||
});
|
});
|
||||||
_clients.clear();
|
_clients.clear();
|
||||||
}
|
}
|
||||||
@ -485,7 +497,7 @@ String getLoginDialogTag(int id) {
|
|||||||
return loginDialogTag + id.toString();
|
return loginDialogTag + id.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
showInputWarnAlert() {
|
showInputWarnAlert(FFI ffi) {
|
||||||
DialogManager.show((setState, close) => CustomAlertDialog(
|
DialogManager.show((setState, close) => CustomAlertDialog(
|
||||||
title: Text(translate("How to get Android input permission?")),
|
title: Text(translate("How to get Android input permission?")),
|
||||||
content: Column(
|
content: Column(
|
||||||
@ -501,7 +513,7 @@ showInputWarnAlert() {
|
|||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
child: Text(translate("Open System Setting")),
|
child: Text(translate("Open System Setting")),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
FFI.serverModel.initInput();
|
ffi.serverModel.initInput();
|
||||||
close();
|
close();
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -66,6 +66,7 @@ dependencies:
|
|||||||
bitsdojo_window: ^0.1.2
|
bitsdojo_window: ^0.1.2
|
||||||
freezed_annotation: ^2.0.3
|
freezed_annotation: ^2.0.3
|
||||||
tray_manager: 0.1.7
|
tray_manager: 0.1.7
|
||||||
|
get: ^4.6.5
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_launcher_icons: ^0.9.1
|
flutter_launcher_icons: ^0.9.1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user