Merge pull request #3232 from 21pages/reconnect_btn

add reconnect button on Connection Error
This commit is contained in:
RustDesk 2023-02-16 15:28:15 +08:00 committed by GitHub
commit 536498f83c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 102 additions and 56 deletions

View File

@ -632,6 +632,7 @@ class CustomAlertDialog extends StatelessWidget {
if (!scopeNode.hasFocus) scopeNode.requestFocus(); if (!scopeNode.hasFocus) scopeNode.requestFocus();
}); });
const double padding = 16; const double padding = 16;
bool tabTapped = false;
return FocusScope( return FocusScope(
node: scopeNode, node: scopeNode,
autofocus: true, autofocus: true,
@ -641,13 +642,15 @@ class CustomAlertDialog extends StatelessWidget {
onCancel?.call(); onCancel?.call();
} }
return KeyEventResult.handled; // avoid TextField exception on escape return KeyEventResult.handled; // avoid TextField exception on escape
} else if (onSubmit != null && } else if (!tabTapped &&
onSubmit != null &&
key.logicalKey == LogicalKeyboardKey.enter) { key.logicalKey == LogicalKeyboardKey.enter) {
if (key is RawKeyDownEvent) onSubmit?.call(); if (key is RawKeyDownEvent) onSubmit?.call();
return KeyEventResult.handled; return KeyEventResult.handled;
} else if (key.logicalKey == LogicalKeyboardKey.tab) { } else if (key.logicalKey == LogicalKeyboardKey.tab) {
if (key is RawKeyDownEvent) { if (key is RawKeyDownEvent) {
scopeNode.nextFocus(); scopeNode.nextFocus();
tabTapped = true;
} }
return KeyEventResult.handled; return KeyEventResult.handled;
} }
@ -676,7 +679,7 @@ class CustomAlertDialog extends StatelessWidget {
void msgBox(String id, String type, String title, String text, String link, void msgBox(String id, String type, String title, String text, String link,
OverlayDialogManager dialogManager, OverlayDialogManager dialogManager,
{bool? hasCancel}) { {bool? hasCancel, ReconnectHandle? reconnect}) {
dialogManager.dismissAll(); dialogManager.dismissAll();
List<Widget> buttons = []; List<Widget> buttons = [];
bool hasOk = false; bool hasOk = false;
@ -716,6 +719,13 @@ void msgBox(String id, String type, String title, String text, String link,
dialogManager.dismissAll(); dialogManager.dismissAll();
})); }));
} }
if (reconnect != null && title == "Connection Error") {
buttons.insert(
0,
dialogButton('Reconnect', isOutline: true, onPressed: () {
reconnect(dialogManager, id, false);
}));
}
if (link.isNotEmpty) { if (link.isNotEmpty) {
buttons.insert(0, dialogButton('JumpLink', onPressed: jumplink)); buttons.insert(0, dialogButton('JumpLink', onPressed: jumplink));
} }

View File

@ -33,6 +33,7 @@ import 'input_model.dart';
import 'platform_model.dart'; import 'platform_model.dart';
typedef HandleMsgBox = Function(Map<String, dynamic> evt, String id); typedef HandleMsgBox = Function(Map<String, dynamic> evt, String id);
typedef ReconnectHandle = Function(OverlayDialogManager, String, bool);
final _waitForImage = <String, bool>{}; final _waitForImage = <String, bool>{};
class FfiModel with ChangeNotifier { class FfiModel with ChangeNotifier {
@ -310,14 +311,12 @@ class FfiModel with ChangeNotifier {
showMsgBox(String id, String type, String title, String text, String link, showMsgBox(String id, String type, String title, String text, String link,
bool hasRetry, OverlayDialogManager dialogManager, bool hasRetry, OverlayDialogManager dialogManager,
{bool? hasCancel}) { {bool? hasCancel}) {
msgBox(id, type, title, text, link, dialogManager, hasCancel: hasCancel); msgBox(id, type, title, text, link, dialogManager,
hasCancel: hasCancel, reconnect: reconnect);
_timer?.cancel(); _timer?.cancel();
if (hasRetry) { if (hasRetry) {
_timer = Timer(Duration(seconds: _reconnects), () { _timer = Timer(Duration(seconds: _reconnects), () {
bind.sessionReconnect(id: id, forceRelay: false); reconnect(dialogManager, id, false);
clearPermissions();
dialogManager.showLoading(translate('Connecting...'),
onCancel: closeConnection);
}); });
_reconnects *= 2; _reconnects *= 2;
} else { } else {
@ -325,6 +324,14 @@ class FfiModel with ChangeNotifier {
} }
} }
void reconnect(
OverlayDialogManager dialogManager, String id, bool forceRelay) {
bind.sessionReconnect(id: id, forceRelay: forceRelay);
clearPermissions();
dialogManager.showLoading(translate('Connecting...'),
onCancel: closeConnection);
}
void showRelayHintDialog(String id, String type, String title, String text, void showRelayHintDialog(String id, String type, String title, String text,
OverlayDialogManager dialogManager) { OverlayDialogManager dialogManager) {
dialogManager.show(tag: '$id-$type', (setState, close) { dialogManager.show(tag: '$id-$type', (setState, close) {
@ -333,13 +340,6 @@ class FfiModel with ChangeNotifier {
close(); close();
} }
reconnect(bool forceRelay) {
bind.sessionReconnect(id: id, forceRelay: forceRelay);
clearPermissions();
dialogManager.showLoading(translate('Connecting...'),
onCancel: closeConnection);
}
final style = final style =
ElevatedButton.styleFrom(backgroundColor: Colors.green[700]); ElevatedButton.styleFrom(backgroundColor: Colors.green[700]);
return CustomAlertDialog( return CustomAlertDialog(
@ -348,14 +348,16 @@ class FfiModel with ChangeNotifier {
"${translate(text)}\n\n${translate('relay_hint_tip')}"), "${translate(text)}\n\n${translate('relay_hint_tip')}"),
actions: [ actions: [
dialogButton('Close', onPressed: onClose, isOutline: true), dialogButton('Close', onPressed: onClose, isOutline: true),
dialogButton('Retry', onPressed: () => reconnect(false)), dialogButton('Retry',
onPressed: () => reconnect(dialogManager, id, false)),
dialogButton('Connect via relay', dialogButton('Connect via relay',
onPressed: () => reconnect(true), buttonStyle: style), onPressed: () => reconnect(dialogManager, id, true),
buttonStyle: style),
dialogButton('Always connect via relay', onPressed: () { dialogButton('Always connect via relay', onPressed: () {
const option = 'force-always-relay'; const option = 'force-always-relay';
bind.sessionPeerOption( bind.sessionPeerOption(
id: id, name: option, value: bool2option(option, true)); id: id, name: option, value: bool2option(option, true));
reconnect(true); reconnect(dialogManager, id, true);
}, buttonStyle: style), }, buttonStyle: style),
], ],
onCancel: onClose, onCancel: onClose,

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -422,7 +422,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Ask the remote user for authentication", "请求远端用户授权"), ("Ask the remote user for authentication", "请求远端用户授权"),
("Choose this if the remote account is administrator", "当对面电脑是管理员账号时选择该选项"), ("Choose this if the remote account is administrator", "当对面电脑是管理员账号时选择该选项"),
("Transmit the username and password of administrator", "发送管理员账号的用户名密码"), ("Transmit the username and password of administrator", "发送管理员账号的用户名密码"),
("still_click_uac_tip", "依然需要被控端用戶在運行 RustDesk 的 UAC 窗口點擊確認"), ("still_click_uac_tip", "依然需要被控端用户在运行 RustDesk 的 UAC 窗口点击确认"),
("Request Elevation", "请求提权"), ("Request Elevation", "请求提权"),
("wait_accept_uac_tip", "请等待远端用户确认 UAC 对话框。"), ("wait_accept_uac_tip", "请等待远端用户确认 UAC 对话框。"),
("Elevate successfully", "提权成功"), ("Elevate successfully", "提权成功"),
@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", "文字聊天"), ("Text chat", "文字聊天"),
("Stop voice call", "停止语音聊天"), ("Stop voice call", "停止语音聊天"),
("relay_hint_tip", "可能无法直连,可以尝试中继连接。\n另外如果想直接使用中继连接可以在ID后面添加/r或者在卡片选项里选择强制走中继连接。"), ("relay_hint_tip", "可能无法直连,可以尝试中继连接。\n另外如果想直接使用中继连接可以在ID后面添加/r或者在卡片选项里选择强制走中继连接。"),
].iter().cloned().collect(); ("Reconnect", "重连"),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", "Text-Chat"), ("Text chat", "Text-Chat"),
("Stop voice call", "Sprachanruf beenden"), ("Stop voice call", "Sprachanruf beenden"),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", "Chat de texto"), ("Text chat", "Chat de texto"),
("Stop voice call", "Detener llamada de voz"), ("Stop voice call", "Detener llamada de voz"),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", "گفتگو متنی (چت متنی)"), ("Text chat", "گفتگو متنی (چت متنی)"),
("Stop voice call", "توقف تماس صوتی"), ("Stop voice call", "توقف تماس صوتی"),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", "Chat testuale"), ("Text chat", "Chat testuale"),
("Stop voice call", "Interrompi la chiamata vocale"), ("Stop voice call", "Interrompi la chiamata vocale"),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -209,7 +209,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the peer", "Handmatig gesloten door de peer"), ("Closed manually by the peer", "Handmatig gesloten door de peer"),
("Enable remote configuration modification", "Wijziging configuratie op afstand inschakelen"), ("Enable remote configuration modification", "Wijziging configuratie op afstand inschakelen"),
("Run without install", "Uitvoeren zonder installatie"), ("Run without install", "Uitvoeren zonder installatie"),
("Always connected via relay", "Altijd verbonden via relay"), ("Connect via relay", ""),
("Always connect via relay", "Altijd verbinden via relay"), ("Always connect via relay", "Altijd verbinden via relay"),
("whitelist_tip", "Alleen een IP-adres op de witte lijst krijgt toegang tot mijn toestel"), ("whitelist_tip", "Alleen een IP-adres op de witte lijst krijgt toegang tot mijn toestel"),
("Login", "Log In"), ("Login", "Log In"),
@ -449,5 +449,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Voice call", "Spraakoproep"), ("Voice call", "Spraakoproep"),
("Text chat", "Tekst chat"), ("Text chat", "Tekst chat"),
("Stop voice call", "Stop spraakoproep"), ("Stop voice call", "Stop spraakoproep"),
].iter().cloned().collect(); ("relay_hint_tip", ""),
("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", "Текстовый чат"), ("Text chat", "Текстовый чат"),
("Stop voice call", "Завершить голосовой вызов"), ("Stop voice call", "Завершить голосовой вызов"),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -446,9 +446,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("FPS", "幀率"), ("FPS", "幀率"),
("Auto", "自動"), ("Auto", "自動"),
("Other Default Options", "其它默認選項"), ("Other Default Options", "其它默認選項"),
("Voice call", ""), ("Voice call", "語音通話"),
("Text chat", ""), ("Text chat", "文字聊天"),
("Stop voice call", ""), ("Stop voice call", "停止語音聊天"),
("relay_hint_tip", ""), ("relay_hint_tip", "可能無法直連,可以嘗試中繼連接。 \n另外如果想直接使用中繼連接可以在ID後面添加/r或者在卡片選項裡選擇強制走中繼連接。"),
].iter().cloned().collect(); ("Reconnect", "重連"),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }

View File

@ -450,5 +450,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Text chat", ""), ("Text chat", ""),
("Stop voice call", ""), ("Stop voice call", ""),
("relay_hint_tip", ""), ("relay_hint_tip", ""),
].iter().cloned().collect(); ("Reconnect", ""),
].iter().cloned().collect();
} }