add mobile restart remote device
This commit is contained in:
parent
e53119a01a
commit
eec26e5c70
@ -68,7 +68,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
|
|
||||||
void updatePermission(Map<String, dynamic> evt) {
|
void updatePermission(Map<String, dynamic> evt) {
|
||||||
evt.forEach((k, v) {
|
evt.forEach((k, v) {
|
||||||
if (k == 'name') return;
|
if (k == 'name' || k.isEmpty) return;
|
||||||
_permissions[k] = v == 'true';
|
_permissions[k] = v == 'true';
|
||||||
});
|
});
|
||||||
print('$_permissions');
|
print('$_permissions');
|
||||||
@ -195,14 +195,17 @@ class FfiModel with ChangeNotifier {
|
|||||||
wrongPasswordDialog(id);
|
wrongPasswordDialog(id);
|
||||||
} else if (type == 'input-password') {
|
} else if (type == 'input-password') {
|
||||||
enterPasswordDialog(id);
|
enterPasswordDialog(id);
|
||||||
|
} else if (type == 'restarting') {
|
||||||
|
showMsgBox(type, title, text, false, hasCancel: false);
|
||||||
} else {
|
} else {
|
||||||
var hasRetry = evt['hasRetry'] == 'true';
|
var hasRetry = evt['hasRetry'] == 'true';
|
||||||
showMsgBox(type, title, text, hasRetry);
|
showMsgBox(type, title, text, hasRetry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void showMsgBox(String type, String title, String text, bool hasRetry) {
|
void showMsgBox(String type, String title, String text, bool hasRetry,
|
||||||
msgBox(type, title, text);
|
{bool? hasCancel}) {
|
||||||
|
msgBox(type, title, text, hasCancel: hasCancel);
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
if (hasRetry) {
|
if (hasRetry) {
|
||||||
_timer = Timer(Duration(seconds: _reconnects), () {
|
_timer = Timer(Duration(seconds: _reconnects), () {
|
||||||
|
@ -694,6 +694,13 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
value: 'block-input'));
|
value: 'block-input'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (FFI.ffiModel.permissions["restart"] != false &&
|
||||||
|
(pi.platform == "Linux" ||
|
||||||
|
pi.platform == "Windows" ||
|
||||||
|
pi.platform == "Mac OS")) {
|
||||||
|
more.add(PopupMenuItem<String>(
|
||||||
|
child: Text(translate('Restart Remote Device')), value: 'restart'));
|
||||||
|
}
|
||||||
() async {
|
() async {
|
||||||
var value = await showMenu(
|
var value = await showMenu(
|
||||||
context: context,
|
context: context,
|
||||||
@ -727,6 +734,8 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
}
|
}
|
||||||
} else if (value == 'reset_canvas') {
|
} else if (value == 'reset_canvas') {
|
||||||
FFI.cursorModel.reset();
|
FFI.cursorModel.reset();
|
||||||
|
} else if (value == 'restart') {
|
||||||
|
showRestartRemoteDevice(pi, widget.id);
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
@ -1103,6 +1112,27 @@ void showOptions() {
|
|||||||
}, clickMaskDismiss: true, backDismiss: true);
|
}, clickMaskDismiss: true, backDismiss: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showRestartRemoteDevice(PeerInfo pi, String id) async {
|
||||||
|
final res =
|
||||||
|
await DialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||||
|
title: Row(children: [
|
||||||
|
Icon(Icons.warning_amber_sharp,
|
||||||
|
color: Colors.redAccent, size: 28),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Text(translate("Restart Remote Device")),
|
||||||
|
]),
|
||||||
|
content: Text(
|
||||||
|
"${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => close(), child: Text(translate("Cancel"))),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () => close(true), child: Text(translate("OK"))),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
if (res == true) FFI.setByName('restart_remote_device');
|
||||||
|
}
|
||||||
|
|
||||||
void showSetOSPassword(bool login) {
|
void showSetOSPassword(bool login) {
|
||||||
final controller = TextEditingController();
|
final controller = TextEditingController();
|
||||||
var password = FFI.getByName('peer_option', "os-password");
|
var password = FFI.getByName('peer_option', "os-password");
|
||||||
|
@ -88,6 +88,15 @@ impl Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn restart_remote_device() {
|
||||||
|
if let Some(session) = SESSION.write().unwrap().as_ref() {
|
||||||
|
let mut lc = session.lc.write().unwrap();
|
||||||
|
lc.restarting_remote_device = true;
|
||||||
|
let msg = lc.restart_remote_device();
|
||||||
|
session.send(Data::Message(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn send(data: Data) {
|
fn send(data: Data) {
|
||||||
if let Some(session) = SESSION.read().unwrap().as_ref() {
|
if let Some(session) = SESSION.read().unwrap().as_ref() {
|
||||||
session.send(data);
|
session.send(data);
|
||||||
@ -604,9 +613,14 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if session.lc.read().unwrap().restarting_remote_device {
|
||||||
|
log::info!("Restart remote device");
|
||||||
|
session.msgbox("restarting", "Restarting Remote Device", "remote_restarting_tip");
|
||||||
} else {
|
} else {
|
||||||
log::info!("Reset by the peer");
|
log::info!("Reset by the peer");
|
||||||
session.msgbox("error", "Connection Error", "Reset by the peer");
|
session.msgbox("error", "Connection Error", "Reset by the peer");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -876,6 +890,7 @@ impl Connection {
|
|||||||
Permission::Keyboard => "keyboard",
|
Permission::Keyboard => "keyboard",
|
||||||
Permission::Clipboard => "clipboard",
|
Permission::Clipboard => "clipboard",
|
||||||
Permission::Audio => "audio",
|
Permission::Audio => "audio",
|
||||||
|
Permission::Restart => "restart",
|
||||||
_ => "",
|
_ => "",
|
||||||
},
|
},
|
||||||
&p.enabled.to_string(),
|
&p.enabled.to_string(),
|
||||||
|
@ -629,8 +629,9 @@ impl Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn restart_remote_device(&mut self) {
|
fn restart_remote_device(&mut self) {
|
||||||
self.lc.write().unwrap().restarting_remote_device = true;
|
let mut lc = self.lc.write().unwrap();
|
||||||
let msg = self.lc.write().unwrap().restart_remote_device();
|
lc.restarting_remote_device = true;
|
||||||
|
let msg = lc.restart_remote_device();
|
||||||
self.send(Data::Message(msg));
|
self.send(Data::Message(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user