Files

2051 lines
59 KiB
Dart
Raw Permalink Normal View History

2024-03-22 13:16:37 +08:00
import 'dart:async';
2024-03-23 10:08:55 +08:00
import 'dart:js' as js;
import 'dart:convert';
2024-03-22 13:16:37 +08:00
import 'dart:typed_data';
2024-03-27 11:26:29 +08:00
import 'package:flutter/foundation.dart';
2024-03-22 13:16:37 +08:00
import 'package:uuid/uuid.dart';
2024-09-01 23:14:57 +08:00
import 'dart:html' as html;
2024-03-22 13:16:37 +08:00
2024-03-28 11:38:11 +08:00
import 'package:flutter_hbb/consts.dart';
2024-03-22 13:16:37 +08:00
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
mixin _$EventToUI {
Object get field0 => throw _privateConstructorUsedError;
}
sealed class EventToUI {
const factory EventToUI.event(
String field0,
) = EventToUI_Event;
const factory EventToUI.rgba(
int field0,
) = EventToUI_Rgba;
const factory EventToUI.texture(
int field0,
2024-08-24 12:10:36 +08:00
bool field1,
2024-03-22 13:16:37 +08:00
) = EventToUI_Texture;
const factory EventToUI.cursor({
required String id,
required int hotx,
required int hoty,
required int width,
required int height,
required Uint8List colors,
}) = EventToUI_Cursor;
2024-03-22 13:16:37 +08:00
}
class EventToUI_Event implements EventToUI {
const EventToUI_Event(final String field0) : this.field = field0;
final String field;
String get field0 => field;
}
class EventToUI_Rgba implements EventToUI {
2024-08-24 12:10:36 +08:00
const EventToUI_Rgba(final int field0) : field = field0;
2024-03-22 13:16:37 +08:00
final int field;
int get field0 => field;
}
class EventToUI_Texture implements EventToUI {
2024-08-24 12:10:36 +08:00
const EventToUI_Texture(final int field0, final bool field1)
: f0 = field0,
f1 = field1;
final int f0;
final bool f1;
int get field0 => f0;
bool get field1 => f1;
2024-03-22 13:16:37 +08:00
}
class EventToUI_Cursor implements EventToUI {
const EventToUI_Cursor({
required this.id,
required this.hotx,
required this.hoty,
required this.width,
required this.height,
required this.colors,
});
final String id;
final int hotx;
final int hoty;
final int width;
final int height;
final Uint8List colors;
}
class CursorShape {
final int hotx;
final int hoty;
final int width;
final int height;
final Uint8List colors;
const CursorShape({
required this.hotx,
required this.hoty,
required this.width,
required this.height,
required this.colors,
});
}
2024-03-22 13:16:37 +08:00
class RustdeskImpl {
// The core answers through the callback, before callMethod returns.
Future<CursorShape?> sessionGetCursorShape(
{required UuidValue sessionId, required String id, dynamic hint}) {
final completer = Completer<CursorShape?>();
js.context.callMethod('getCursorShape', [
id,
(int hotx, int hoty, int width, int height, Uint8List? colors) {
completer.complete(colors == null
? null
: CursorShape(
hotx: hotx,
hoty: hoty,
width: width,
height: height,
colors: colors));
}
]);
return completer.future;
}
2024-03-22 13:16:37 +08:00
Future<void> stopGlobalEventStream({required String appType, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("stopGlobalEventStream");
2024-03-22 13:16:37 +08:00
}
Future<void> hostStopSystemKeyPropagate(
{required bool stopped, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("hostStopSystemKeyPropagate");
2024-03-22 13:16:37 +08:00
}
2025-03-10 21:06:53 +08:00
int peerGetSessionsCount(
{required String id, required int connType, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return 0;
2024-03-22 13:16:37 +08:00
}
String sessionAddExistedSync(
{required String id,
required UuidValue sessionId,
required Int32List displays,
2025-03-10 21:06:53 +08:00
required bool isViewCamera,
dynamic hint}) {
2024-03-25 10:47:53 +08:00
return '';
2024-03-22 13:16:37 +08:00
}
String sessionAddSync(
{required UuidValue sessionId,
required String id,
required bool isFileTransfer,
2025-03-10 21:06:53 +08:00
required bool isViewCamera,
2024-03-22 13:16:37 +08:00
required bool isPortForward,
required bool isRdp,
2025-07-01 13:12:55 +08:00
required bool isTerminal,
2024-03-22 13:16:37 +08:00
required String switchUuid,
required bool forceRelay,
required String password,
required bool isSharedPassword,
2024-10-28 09:40:16 +08:00
String? connToken,
2024-03-22 13:16:37 +08:00
dynamic hint}) {
2024-03-24 11:23:06 +08:00
return js.context.callMethod('setByName', [
'session_add_sync',
2024-10-11 09:52:09 +08:00
jsonEncode({
'id': id,
'password': password,
2024-10-12 09:03:13 +08:00
'is_shared_password': isSharedPassword,
2025-03-10 21:06:53 +08:00
'isFileTransfer': isFileTransfer,
2025-07-01 13:12:55 +08:00
'isViewCamera': isViewCamera,
'isTerminal': isTerminal
2024-10-11 09:52:09 +08:00
})
2024-03-24 11:23:06 +08:00
]);
2024-03-22 13:16:37 +08:00
}
Stream<EventToUI> sessionStart(
{required UuidValue sessionId, required String id, dynamic hint}) {
2024-03-24 11:23:06 +08:00
js.context.callMethod('setByName', [
'session_start',
jsonEncode({'id': id})
]);
return Stream.empty();
2024-03-22 13:16:37 +08:00
}
2024-06-13 18:03:41 +08:00
Stream<EventToUI> sessionStartWithDisplays(
{required UuidValue sessionId,
required String id,
required Int32List displays,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionStartWithDisplays");
2024-06-13 18:03:41 +08:00
}
2024-03-22 13:16:37 +08:00
Future<bool?> sessionGetRemember(
{required UuidValue sessionId, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(
() => js.context.callMethod('getByName', ['remember']) == 'true');
2024-03-22 13:16:37 +08:00
}
Future<bool?> sessionGetToggleOption(
{required UuidValue sessionId, required String arg, dynamic hint}) {
2024-03-24 11:23:06 +08:00
return Future(
() => sessionGetToggleOptionSync(sessionId: sessionId, arg: arg));
2024-03-22 13:16:37 +08:00
}
bool sessionGetToggleOptionSync(
{required UuidValue sessionId, required String arg, dynamic hint}) {
2024-03-24 11:23:06 +08:00
return 'true' == js.context.callMethod('getByName', ['option:toggle', arg]);
2024-03-22 13:16:37 +08:00
}
Future<String?> sessionGetOption(
{required UuidValue sessionId, required String arg, dynamic hint}) {
2024-03-24 11:23:06 +08:00
return Future(
2024-03-27 11:26:29 +08:00
() => js.context.callMethod('getByName', ['option:session', arg]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionLogin(
{required UuidValue sessionId,
required String osUsername,
required String osPassword,
required String password,
required bool remember,
dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(() => js.context.callMethod('setByName', [
'login',
jsonEncode({
'os_username': osUsername,
'os_password': osPassword,
'password': password,
'remember': remember
})
]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSend2Fa(
2024-08-12 18:08:33 +08:00
{required UuidValue sessionId,
required String code,
required bool trustThisDevice,
dynamic hint}) {
2024-10-08 18:35:25 +08:00
return Future(() => js.context.callMethod('setByName', [
'send_2fa',
jsonEncode({'code': code, 'trust_this_device': trustThisDevice})
]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionClose({required UuidValue sessionId, dynamic hint}) {
2024-03-24 11:23:06 +08:00
return Future(() => js.context.callMethod('setByName', ['session_close']));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionRefresh(
{required UuidValue sessionId, required int display, dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(() => js.context.callMethod('setByName', ['refresh']));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionRecordScreen(
2024-10-28 09:40:16 +08:00
{required UuidValue sessionId, required bool start, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionRecordScreen");
2024-03-22 13:16:37 +08:00
}
2024-10-28 09:40:16 +08:00
bool sessionGetIsRecording({required UuidValue sessionId, dynamic hint}) {
return false;
2024-03-22 13:16:37 +08:00
}
Future<void> sessionReconnect(
{required UuidValue sessionId, required bool forceRelay, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(() => js.context.callMethod('setByName', ['reconnect']));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionToggleOption(
{required UuidValue sessionId, required String value, dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(
2024-09-04 22:27:52 +08:00
() => js.context.callMethod('setByName', ['option:toggle', value]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionTogglePrivacyMode(
{required UuidValue sessionId,
required String implKey,
required bool on,
dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(() => js.context.callMethod('setByName', [
2024-09-10 23:54:59 +08:00
'toggle_privacy_mode',
jsonEncode({'impl_key': implKey, 'on': on})
2024-03-26 10:45:06 +08:00
]));
2024-03-22 13:16:37 +08:00
}
Future<String?> sessionGetFlutterOption(
{required UuidValue sessionId, required String k, dynamic hint}) {
2024-03-24 11:23:06 +08:00
return Future(
() => js.context.callMethod('getByName', ['option:flutter:peer', k]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSetFlutterOption(
{required UuidValue sessionId,
required String k,
required String v,
dynamic hint}) {
2024-03-24 11:23:06 +08:00
return Future(() => js.context.callMethod('setByName', [
'option:flutter:peer',
jsonEncode({'name': k, 'value': v})
]));
2024-03-22 13:16:37 +08:00
}
int getNextTextureKey({dynamic hint}) {
2024-03-23 10:08:55 +08:00
return 0;
2024-03-22 13:16:37 +08:00
}
String getLocalFlutterOption({required String k, dynamic hint}) {
2024-03-23 10:08:55 +08:00
return js.context.callMethod('getByName', ['option:flutter:local', k]);
2024-03-22 13:16:37 +08:00
}
Future<void> setLocalFlutterOption(
{required String k, required String v, dynamic hint}) {
2024-03-23 10:08:55 +08:00
return Future(() => js.context.callMethod('setByName', [
'option:flutter:local',
jsonEncode({'name': k, 'value': v})
]));
2024-03-22 13:16:37 +08:00
}
String getLocalKbLayoutType({dynamic hint}) {
2024-08-26 12:13:11 +08:00
return js.context.callMethod('getByName', ['option:local', 'kb_layout']);
2024-03-22 13:16:37 +08:00
}
Future<void> setLocalKbLayoutType(
{required String kbLayoutType, dynamic hint}) {
2024-03-23 10:08:55 +08:00
return Future(() => js.context.callMethod('setByName', [
'option:local',
jsonEncode({'name': 'kb_layout', 'value': kbLayoutType})
]));
2024-03-22 13:16:37 +08:00
}
Future<String?> sessionGetViewStyle(
{required UuidValue sessionId, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(() =>
2024-03-27 11:26:29 +08:00
js.context.callMethod('getByName', ['option:session', 'view_style']));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSetViewStyle(
{required UuidValue sessionId, required String value, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(() => js.context.callMethod('setByName', [
2024-03-27 11:26:29 +08:00
'option:session',
2024-03-25 10:47:53 +08:00
jsonEncode({'name': 'view_style', 'value': value})
]));
2024-03-22 13:16:37 +08:00
}
2025-05-10 21:49:23 +08:00
Future<int?> sessionGetTrackpadSpeed(
{required UuidValue sessionId, dynamic hint}) {
throw UnimplementedError("sessionGetTrackpadSpeed");
}
Future<void> sessionSetTrackpadSpeed(
{required UuidValue sessionId, required int value, dynamic hint}) {
throw UnimplementedError("sessionSetTrackpadSpeed");
}
2024-03-22 13:16:37 +08:00
Future<String?> sessionGetScrollStyle(
{required UuidValue sessionId, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(() =>
2024-03-27 11:26:29 +08:00
js.context.callMethod('getByName', ['option:session', 'scroll_style']));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSetScrollStyle(
{required UuidValue sessionId, required String value, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(() => js.context.callMethod('setByName', [
2024-03-27 11:26:29 +08:00
'option:session',
2024-03-25 10:47:53 +08:00
jsonEncode({'name': 'scroll_style', 'value': value})
]));
2024-03-22 13:16:37 +08:00
}
Future<String?> sessionGetImageQuality(
2024-03-28 11:38:11 +08:00
{required UuidValue sessionId, dynamic hint}) {
2024-10-14 11:15:52 +08:00
return Future(() => js.context.callMethod('getByName', ['image_quality']));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSetImageQuality(
{required UuidValue sessionId, required String value, dynamic hint}) {
2024-10-14 11:15:52 +08:00
print('set image quality: $value');
return Future(
() => js.context.callMethod('setByName', ['image_quality', value]));
2024-03-22 13:16:37 +08:00
}
Future<String?> sessionGetKeyboardMode(
{required UuidValue sessionId, dynamic hint}) {
2024-03-28 11:38:11 +08:00
final mode =
js.context.callMethod('getByName', ['option:session', 'keyboard_mode']);
return Future(() => mode == '' ? null : mode);
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSetKeyboardMode(
{required UuidValue sessionId, required String value, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(() => js.context.callMethod('setByName', [
2024-03-27 11:26:29 +08:00
'option:session',
2024-03-25 10:47:53 +08:00
jsonEncode({'name': 'keyboard_mode', 'value': value})
]));
2024-03-22 13:16:37 +08:00
}
String? sessionGetReverseMouseWheelSync(
{required UuidValue sessionId, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return js.context
2024-03-27 11:26:29 +08:00
.callMethod('getByName', ['option:session', 'reverse_mouse_wheel']);
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSetReverseMouseWheel(
{required UuidValue sessionId, required String value, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(() => js.context.callMethod('setByName', [
2024-03-27 11:26:29 +08:00
'option:session',
2024-03-25 10:47:53 +08:00
jsonEncode({'name': 'reverse_mouse_wheel', 'value': value})
]));
2024-03-22 13:16:37 +08:00
}
String? sessionGetDisplaysAsIndividualWindows(
{required UuidValue sessionId, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return js.context.callMethod(
2024-03-27 11:26:29 +08:00
'getByName', ['option:session', 'displays_as_individual_windows']);
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSetDisplaysAsIndividualWindows(
{required UuidValue sessionId, required String value, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future.value();
2024-03-22 13:16:37 +08:00
}
String? sessionGetUseAllMyDisplaysForTheRemoteSession(
{required UuidValue sessionId, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return '';
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSetUseAllMyDisplaysForTheRemoteSession(
{required UuidValue sessionId, required String value, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future.value();
2024-03-22 13:16:37 +08:00
}
Future<Int32List?> sessionGetCustomImageQuality(
{required UuidValue sessionId, dynamic hint}) {
2024-03-25 10:47:53 +08:00
try {
return Future(() => Int32List.fromList([
int.parse(js.context.callMethod(
2024-03-27 11:26:29 +08:00
'getByName', ['option:session', 'custom_image_quality']))
2024-03-25 10:47:53 +08:00
]));
} catch (e) {
return Future.value(null);
}
2024-03-22 13:16:37 +08:00
}
bool sessionIsKeyboardModeSupported(
{required UuidValue sessionId, required String mode, dynamic hint}) {
if (mainGetInputSource(hint: hint) == 'Input source 1') {
return [kKeyMapMode, kKeyTranslateMode].contains(mode);
} else {
return [kKeyLegacyMode, kKeyMapMode].contains(mode);
}
2024-03-22 13:16:37 +08:00
}
bool sessionIsMultiUiSession({required UuidValue sessionId, dynamic hint}) {
return false;
}
2024-03-22 13:16:37 +08:00
Future<void> sessionSetCustomImageQuality(
{required UuidValue sessionId, required int value, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(() => js.context.callMethod('setByName', [
2024-10-14 11:15:52 +08:00
'custom_image_quality',
value,
2024-03-25 10:47:53 +08:00
]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSetCustomFps(
{required UuidValue sessionId, required int fps, dynamic hint}) {
2024-10-14 11:15:52 +08:00
return Future(
() => js.context.callMethod('setByName', ['custom-fps', fps]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionLockScreen({required UuidValue sessionId, dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(() => js.context.callMethod('setByName', ['lock_screen']));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionCtrlAltDel({required UuidValue sessionId, dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(() => js.context.callMethod('setByName', ['ctrl_alt_del']));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSwitchDisplay(
{required bool isDesktop,
required UuidValue sessionId,
required Int32List value,
dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(() => js.context.callMethod('setByName', [
'switch_display',
jsonEncode({
2024-09-10 11:29:20 +08:00
'isDesktop': isDesktop,
'sessionId': sessionId.toString(),
'value': value
2024-03-26 10:45:06 +08:00
})
]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionHandleFlutterKeyEvent(
{required UuidValue sessionId,
2024-08-24 12:10:36 +08:00
required String character,
required int usbHid,
2024-03-22 13:16:37 +08:00
required int lockModes,
required bool downOrUp,
dynamic hint}) {
2024-08-24 12:10:36 +08:00
return Future(() => js.context.callMethod('setByName', [
'flutter_key_event',
jsonEncode({
'name': character,
'usb_hid': usbHid,
'lock_modes': lockModes,
if (downOrUp) 'down': 'true',
})
]));
2024-03-22 13:16:37 +08:00
}
2024-08-26 12:13:11 +08:00
Future<void> sessionHandleFlutterRawKeyEvent(
{required UuidValue sessionId,
required String name,
required int platformCode,
required int positionCode,
required int lockModes,
required bool downOrUp,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionHandleFlutterRawKeyEvent");
2024-08-26 12:13:11 +08:00
}
2024-03-22 13:16:37 +08:00
void sessionEnterOrLeave(
{required UuidValue sessionId, required bool enter, dynamic hint}) {
js.context.callMethod('setByName', ['enter_or_leave', enter]);
2024-03-22 13:16:37 +08:00
}
Future<void> sessionInputKey(
{required UuidValue sessionId,
required String name,
required bool down,
required bool press,
required bool alt,
required bool ctrl,
required bool shift,
required bool command,
dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(() => js.context.callMethod('setByName', [
'input_key',
jsonEncode({
'name': name,
if (down) 'down': 'true',
if (press) 'press': 'true',
if (alt) 'alt': 'true',
if (ctrl) 'ctrl': 'true',
if (shift) 'shift': 'true',
if (command) 'command': 'true'
})
]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionInputString(
{required UuidValue sessionId, required String value, dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(
() => js.context.callMethod('setByName', ['input_string', value]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSendChat(
{required UuidValue sessionId, required String text, dynamic hint}) {
2024-10-08 15:23:00 +08:00
return Future(
() => js.context.callMethod('setByName', ['send_chat', text]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionPeerOption(
{required UuidValue sessionId,
required String name,
required String value,
dynamic hint}) {
2024-09-23 09:18:22 +08:00
return Future(() => js.context.callMethod('setByName', [
2024-03-27 11:26:29 +08:00
'option:session',
2024-03-25 10:47:53 +08:00
jsonEncode({'name': name, 'value': value})
]));
2024-03-22 13:16:37 +08:00
}
Future<String> sessionGetPeerOption(
{required UuidValue sessionId, required String name, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(
2024-03-27 11:26:29 +08:00
() => js.context.callMethod('getByName', ['option:session', name]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionInputOsPassword(
{required UuidValue sessionId, required String value, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(
() => js.context.callMethod('setByName', ['input_os_password', value]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionReadRemoteDir(
{required UuidValue sessionId,
required String path,
required bool includeHidden,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
return Future(() => js.context.callMethod('setByName', [
'read_remote_dir',
jsonEncode({'path': path, 'include_hidden': includeHidden})
]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSendFiles(
{required UuidValue sessionId,
required int actId,
required String path,
required String to,
required int fileNum,
required bool includeHidden,
required bool isRemote,
2024-10-12 09:03:13 +08:00
required bool isDir,
2024-03-22 13:16:37 +08:00
dynamic hint}) {
2024-10-12 09:03:13 +08:00
return Future(() => js.context.callMethod('setByName', [
'send_files',
jsonEncode({
'id': actId,
'path': path,
'to': to,
'file_num': fileNum,
'include_hidden': includeHidden,
'is_remote': isRemote,
'is_dir': isDir,
})
]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSetConfirmOverrideFile(
{required UuidValue sessionId,
required int actId,
required int fileNum,
required bool needOverride,
required bool remember,
required bool isUpload,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
return Future(() => js.context.callMethod('setByName', [
'confirm_override_file',
jsonEncode({
'id': actId,
'file_num': fileNum,
'need_override': needOverride,
'remember': remember,
'is_upload': isUpload
})
]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionRemoveFile(
{required UuidValue sessionId,
required int actId,
required String path,
required int fileNum,
required bool isRemote,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
return Future(() => js.context.callMethod('setByName', [
'remove_file',
jsonEncode({
'id': actId,
'path': path,
'file_num': fileNum,
'is_remote': isRemote
})
]));
2024-03-22 13:16:37 +08:00
}
2024-10-12 09:03:13 +08:00
Future<void> sessionReadDirToRemoveRecursive(
2024-03-22 13:16:37 +08:00
{required UuidValue sessionId,
required int actId,
required String path,
required bool isRemote,
required bool showHidden,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
return Future(() => js.context.callMethod('setByName', [
'read_dir_to_remove_recursive',
jsonEncode({
'id': actId,
'path': path,
'is_remote': isRemote,
'show_hidden': showHidden
})
]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionRemoveAllEmptyDirs(
{required UuidValue sessionId,
required int actId,
required String path,
required bool isRemote,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
return Future(() => js.context.callMethod('setByName', [
'remove_all_empty_dirs',
jsonEncode({'id': actId, 'path': path, 'is_remote': isRemote})
]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionCancelJob(
{required UuidValue sessionId, required int actId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
return Future(
() => js.context.callMethod('setByName', ['cancel_job', actId]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionCreateDir(
{required UuidValue sessionId,
required int actId,
required String path,
required bool isRemote,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
return Future(() => js.context.callMethod('setByName', [
'create_dir',
jsonEncode({'id': actId, 'path': path, 'is_remote': isRemote})
]));
2024-03-22 13:16:37 +08:00
}
Future<String> sessionReadLocalDirSync(
{required UuidValue sessionId,
required String path,
required bool showHidden,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionReadLocalDirSync");
2024-03-22 13:16:37 +08:00
}
Future<String> sessionGetPlatform(
{required UuidValue sessionId, required bool isRemote, dynamic hint}) {
2024-10-12 09:03:13 +08:00
if (isRemote) {
return Future(() => js.context.callMethod('getByName', ['platform']));
} else {
return Future(() => 'Web');
}
2024-03-22 13:16:37 +08:00
}
Future<void> sessionLoadLastTransferJobs(
{required UuidValue sessionId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionLoadLastTransferJobs");
2024-03-22 13:16:37 +08:00
}
Future<void> sessionAddJob(
{required UuidValue sessionId,
required int actId,
required String path,
required String to,
required int fileNum,
required bool includeHidden,
required bool isRemote,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionAddJob");
2024-03-22 13:16:37 +08:00
}
Future<void> sessionResumeJob(
{required UuidValue sessionId,
required int actId,
required bool isRemote,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionResumeJob");
2024-03-22 13:16:37 +08:00
}
Future<void> sessionElevateDirect(
{required UuidValue sessionId, dynamic hint}) {
2024-09-24 13:53:17 +08:00
return Future(() => js.context.callMethod('setByName', ['elevate_direct']));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionElevateWithLogon(
{required UuidValue sessionId,
required String username,
required String password,
dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(() => js.context.callMethod('setByName', [
'elevate_with_logon',
2024-09-24 13:53:17 +08:00
jsonEncode({'username': username, 'password': password})
2024-03-26 10:45:06 +08:00
]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSwitchSides(
{required UuidValue sessionId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionSwitchSides");
2024-03-22 13:16:37 +08:00
}
Future<void> sessionChangeResolution(
{required UuidValue sessionId,
required int display,
required int width,
required int height,
dynamic hint}) {
2024-03-26 10:45:06 +08:00
// note: restore on disconnected
2024-10-14 11:15:52 +08:00
return Future(() => js.context.callMethod('setByName', [
'change_resolution',
jsonEncode({'display': display, 'width': width, 'height': height})
]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSetSize(
{required UuidValue sessionId,
required int display,
required int width,
required int height,
dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future.value();
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSendSelectedSessionId(
{required UuidValue sessionId, required String sid, dynamic hint}) {
2024-10-28 09:40:16 +08:00
return Future(
() => js.context.callMethod('setByName', ['selected_sid', sid]));
2024-03-22 13:16:37 +08:00
}
Future<List<String>> mainGetSoundInputs({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetSoundInputs");
2024-03-22 13:16:37 +08:00
}
Future<String?> mainGetDefaultSoundInput({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetDefaultSoundInput");
2024-03-22 13:16:37 +08:00
}
String mainGetLoginDeviceInfo({dynamic hint}) {
2024-09-01 23:14:57 +08:00
String userAgent = html.window.navigator.userAgent;
String appName = html.window.navigator.appName;
String appVersion = html.window.navigator.appVersion;
String? platform = html.window.navigator.platform;
return jsonEncode({
'os': '$userAgent, $appName $appVersion ($platform)',
'type': 'Web client',
'name': js.context.callMethod('getByName', ['my_name']),
});
2024-03-22 13:16:37 +08:00
}
Future<void> mainChangeId({required String newId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainChangeId");
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetAsyncStatus({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetAsyncStatus");
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetOption({required String key, dynamic hint}) {
2024-03-23 10:08:55 +08:00
return Future.value(mainGetOptionSync(key: key));
2024-03-22 13:16:37 +08:00
}
String mainGetOptionSync({required String key, dynamic hint}) {
2024-03-23 10:08:55 +08:00
return js.context.callMethod('getByName', ['option', key]);
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetError({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetError");
2024-03-22 13:16:37 +08:00
}
Future<void> mainSetOption(
{required String key, required String value, dynamic hint}) {
2024-03-24 11:23:06 +08:00
js.context.callMethod('setByName', [
2024-03-23 10:08:55 +08:00
'option',
jsonEncode({'name': key, 'value': value})
]);
2024-03-24 11:23:06 +08:00
return Future.value();
2024-03-22 13:16:37 +08:00
}
2024-03-24 11:23:06 +08:00
// get server settings
2024-03-22 13:16:37 +08:00
Future<String> mainGetOptions({dynamic hint}) {
2024-03-24 11:23:06 +08:00
return Future(() => mainGetOptionsSync());
2024-03-22 13:16:37 +08:00
}
2024-03-24 11:23:06 +08:00
// get server settings
2024-03-22 13:16:37 +08:00
String mainGetOptionsSync({dynamic hint}) {
2024-03-24 11:23:06 +08:00
return js.context.callMethod('getByName', ['options']);
2024-03-22 13:16:37 +08:00
}
Future<void> mainSetOptions({required String json, dynamic hint}) {
2024-03-24 11:23:06 +08:00
return Future(() => js.context.callMethod('setByName', ['options', json]));
2024-03-22 13:16:37 +08:00
}
Future<String> mainTestIfValidServer(
{required String server, required bool testWithProxy, dynamic hint}) {
2024-03-24 11:23:06 +08:00
// TODO: implement
return Future.value('');
2024-03-22 13:16:37 +08:00
}
Future<void> mainSetSocks(
{required String proxy,
required String username,
required String password,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainSetSocks");
2024-03-22 13:16:37 +08:00
}
Future<List<String>> mainGetSocks({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetSocks");
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetAppName({dynamic hint}) {
2024-08-24 12:10:36 +08:00
return Future.value(mainGetAppNameSync(hint: hint));
2024-03-22 13:16:37 +08:00
}
String mainGetAppNameSync({dynamic hint}) {
2025-11-17 00:30:17 +08:00
return js.context.callMethod('getByName', ['app-name']);
2024-03-22 13:16:37 +08:00
}
String mainUriPrefixSync({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainUriPrefixSync");
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetLicense({dynamic hint}) {
2024-09-01 00:30:07 +08:00
// TODO: implement
return Future(() => '');
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetVersion({dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(() => js.context.callMethod('getByName', ['version']));
2024-03-22 13:16:37 +08:00
}
Future<List<String>> mainGetFav({dynamic hint}) {
2024-03-27 11:26:29 +08:00
List<String> favs = [];
try {
favs = (jsonDecode(js.context.callMethod('getByName', ['fav']))
as List<dynamic>)
.map((e) => e.toString())
.toList();
} catch (e) {
debugPrint('Failed to load favs: $e');
}
return Future.value(favs);
2024-03-22 13:16:37 +08:00
}
Future<void> mainStoreFav({required List<String> favs, dynamic hint}) {
2024-03-27 11:26:29 +08:00
return Future(
() => js.context.callMethod('setByName', ['fav', jsonEncode(favs)]));
2024-03-22 13:16:37 +08:00
}
String mainGetPeerSync({required String id, dynamic hint}) {
2024-03-26 10:45:06 +08:00
// TODO:
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetPeerSync");
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetLanPeers({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetLanPeers");
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetConnectStatus({dynamic hint}) {
2024-03-23 10:08:55 +08:00
return Future(
() => js.context.callMethod('getByName', ["get_conn_status"]));
2024-03-22 13:16:37 +08:00
}
Future<void> mainCheckConnectStatus({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainCheckConnectStatus");
2024-03-22 13:16:37 +08:00
}
Future<bool> mainIsUsingPublicServer({dynamic hint}) {
2024-08-24 12:10:36 +08:00
return Future(() =>
js.context.callMethod('getByName', ["is_using_public_server"]) ==
'true');
2024-03-22 13:16:37 +08:00
}
Future<void> mainDiscover({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainDiscover");
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetApiServer({dynamic hint}) {
2024-03-24 11:23:06 +08:00
return Future(() => js.context.callMethod('getByName', ['api_server']));
2024-03-22 13:16:37 +08:00
}
Future<void> mainPostRequest(
{required String url,
required String body,
required String header,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainPostRequest");
2024-03-22 13:16:37 +08:00
}
2024-04-25 11:46:21 +08:00
Future<bool> mainGetProxyStatus({dynamic hint}) {
return Future(() => false);
}
Future<void> mainHttpRequest({
required String url,
required String method,
String? body,
required String header,
dynamic hint,
}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainHttpRequest");
2024-04-25 11:46:21 +08:00
}
Future<String?> mainGetHttpStatus({required String url, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetHttpStatus");
2024-04-25 11:46:21 +08:00
}
2024-03-22 13:16:37 +08:00
String mainGetLocalOption({required String key, dynamic hint}) {
final v = js.context.callMethod('getByName', ['option:local', key]);
if (key == 'lang' && (v == 'pt' || v == 'br')) {
return 'pt-br';
}
return v;
2024-03-22 13:16:37 +08:00
}
2025-07-22 19:26:50 +08:00
// Do not return the real environment variables.
// Use the global variable as the environment variable in web.
2024-03-22 13:16:37 +08:00
String mainGetEnv({required String key, dynamic hint}) {
2025-07-22 19:26:50 +08:00
return js.context.callMethod('getByName', ['envvar', key]);
}
// Use the global variable as the environment variable in web.
void mainSetEnv({required String key, String? value, dynamic hint}) {
js.context.callMethod('setByName', [
'envvar',
jsonEncode({'name': key, 'value': value})
]);
2024-03-22 13:16:37 +08:00
}
Future<void> mainSetLocalOption(
{required String key, required String value, dynamic hint}) {
2024-03-23 10:08:55 +08:00
return Future(() => js.context.callMethod('setByName', [
'option:local',
jsonEncode({'name': key, 'value': value})
]));
2024-03-22 13:16:37 +08:00
}
String mainGetInputSource({dynamic hint}) {
final inputSource =
js.context.callMethod('getByName', ['option:local', 'input-source']);
// // js grab mode
// export const CONFIG_INPUT_SOURCE_1 = "Input source 1";
2024-03-26 10:45:06 +08:00
// // flutter grab mode
// export const CONFIG_INPUT_SOURCE_2 = "Input source 2";
return inputSource != '' ? inputSource : 'Input source 1';
2024-03-22 13:16:37 +08:00
}
Future<void> mainSetInputSource(
{required UuidValue sessionId, required String value, dynamic hint}) {
return Future(() => js.context.callMethod('setByName', [
'option:local',
jsonEncode({'name': 'input-source', 'value': value})
]));
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetMyId({dynamic hint}) {
2024-09-01 23:14:57 +08:00
return Future(() => js.context.callMethod('getByName', ['my_id']));
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetUuid({dynamic hint}) {
2024-09-01 23:14:57 +08:00
return Future(() => js.context.callMethod('getByName', ['uuid']));
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetPeerOption(
{required String id, required String key, dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(() => mainGetPeerOptionSync(id: id, key: key, hint: hint));
2024-03-22 13:16:37 +08:00
}
String mainGetPeerOptionSync(
{required String id, required String key, dynamic hint}) {
2024-03-27 11:26:29 +08:00
return js.context.callMethod('getByName', [
'option:peer',
jsonEncode({'id': id, 'name': key})
]);
2024-03-22 13:16:37 +08:00
}
String mainGetPeerFlutterOptionSync(
{required String id, required String k, dynamic hint}) {
2024-03-26 10:45:06 +08:00
return js.context.callMethod('getByName', ['option:flutter:peer', k]);
2024-03-22 13:16:37 +08:00
}
void mainSetPeerFlutterOptionSync(
{required String id,
required String k,
required String v,
dynamic hint}) {
2024-03-26 10:45:06 +08:00
js.context.callMethod('setByName', [
'option:flutter:peer',
jsonEncode({'name': k, 'value': v})
]);
2024-03-22 13:16:37 +08:00
}
Future<void> mainSetPeerOption(
{required String id,
required String key,
required String value,
dynamic hint}) {
2024-03-26 10:45:06 +08:00
mainSetPeerOptionSync(id: id, key: key, value: value, hint: hint);
return Future.value();
2024-03-22 13:16:37 +08:00
}
bool mainSetPeerOptionSync(
{required String id,
required String key,
required String value,
dynamic hint}) {
2024-03-26 10:45:06 +08:00
js.context.callMethod('setByName', [
'option:peer',
2024-03-27 11:26:29 +08:00
jsonEncode({'id': id, 'name': key, 'value': value})
2024-03-26 10:45:06 +08:00
]);
return true;
2024-03-22 13:16:37 +08:00
}
Future<void> mainSetPeerAlias(
{required String id, required String alias, dynamic hint}) {
2024-03-26 10:45:06 +08:00
mainSetPeerOptionSync(id: id, key: 'alias', value: alias, hint: hint);
return Future.value();
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetNewStoredPeers({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetNewStoredPeers");
2024-03-22 13:16:37 +08:00
}
Future<void> mainForgetPassword({required String id, dynamic hint}) {
2024-10-01 07:04:43 +08:00
return mainSetPeerOption(id: id, key: 'password', value: '');
2024-03-22 13:16:37 +08:00
}
Future<bool> mainPeerHasPassword({required String id, dynamic hint}) {
2024-03-27 11:26:29 +08:00
return Future(() =>
js.context.callMethod('getByName', ['peer_has_password', id]) ==
'true');
2024-03-22 13:16:37 +08:00
}
Future<bool> mainPeerExists({required String id, dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(
() => js.context.callMethod('getByName', ['peer_exists', id]));
2024-03-22 13:16:37 +08:00
}
Future<void> mainLoadRecentPeers({dynamic hint}) {
2024-03-23 10:08:55 +08:00
return Future(
() => js.context.callMethod('getByName', ['load_recent_peers']));
2024-03-22 13:16:37 +08:00
}
String mainLoadRecentPeersSync({dynamic hint}) {
2024-03-23 10:08:55 +08:00
return js.context.callMethod('getByName', ['load_recent_peers_sync']);
2024-03-22 13:16:37 +08:00
}
String mainLoadLanPeersSync({dynamic hint}) {
2024-03-27 11:26:29 +08:00
return '{}';
2024-03-22 13:16:37 +08:00
}
Future<String> mainLoadRecentPeersForAb(
{required String filter, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainLoadRecentPeersForAb");
2024-03-22 13:16:37 +08:00
}
Future<void> mainLoadFavPeers({dynamic hint}) {
2024-03-23 10:08:55 +08:00
return Future(() => js.context.callMethod('getByName', ['load_fav_peers']));
2024-03-22 13:16:37 +08:00
}
Future<void> mainLoadLanPeers({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainLoadLanPeers");
2024-03-22 13:16:37 +08:00
}
Future<void> mainRemoveDiscovered({required String id, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainRemoveDiscovered");
2024-03-22 13:16:37 +08:00
}
Future<void> mainChangeTheme({required String dark, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainChangeTheme");
2024-03-22 13:16:37 +08:00
}
Future<void> mainChangeLanguage({required String lang, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainChangeLanguage");
2024-03-22 13:16:37 +08:00
}
2024-06-18 08:43:19 +08:00
String mainVideoSaveDirectory({required bool root, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainVideoSaveDirectory");
2024-03-22 13:16:37 +08:00
}
Future<void> mainSetUserDefaultOption(
{required String key, required String value, dynamic hint}) {
2024-09-01 00:30:07 +08:00
js.context.callMethod('setByName', [
2024-03-28 11:38:11 +08:00
'option:user:default',
jsonEncode({'name': key, 'value': value})
]);
2024-09-01 00:30:07 +08:00
return Future.value();
2024-03-22 13:16:37 +08:00
}
String mainGetUserDefaultOption({required String key, dynamic hint}) {
2024-03-28 11:38:11 +08:00
return js.context.callMethod('getByName', ['option:user:default', key]);
2024-03-22 13:16:37 +08:00
}
Future<String> mainHandleRelayId({required String id, dynamic hint}) {
2024-03-24 11:23:06 +08:00
var newId = id;
if (id.endsWith("\\r") || id.endsWith("/r")) {
newId = id.substring(0, id.length - 2);
}
return Future.value(newId);
2024-03-22 13:16:37 +08:00
}
String mainGetMainDisplay({dynamic hint}) {
2024-03-28 11:38:11 +08:00
return js.context.callMethod('getByName', ['main_display']);
2024-03-22 13:16:37 +08:00
}
String mainGetDisplays({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetDisplays");
2024-03-22 13:16:37 +08:00
}
Future<void> sessionAddPortForward(
{required UuidValue sessionId,
required int localPort,
required String remoteHost,
required int remotePort,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionAddPortForward");
2024-03-22 13:16:37 +08:00
}
Future<void> sessionRemovePortForward(
{required UuidValue sessionId, required int localPort, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionRemovePortForward");
2024-03-22 13:16:37 +08:00
}
Future<void> sessionNewRdp({required UuidValue sessionId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionNewRdp");
2024-03-22 13:16:37 +08:00
}
Future<void> sessionRequestVoiceCall(
{required UuidValue sessionId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionRequestVoiceCall");
2024-03-22 13:16:37 +08:00
}
Future<void> sessionCloseVoiceCall(
{required UuidValue sessionId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionCloseVoiceCall");
2024-03-22 13:16:37 +08:00
}
Future<void> cmHandleIncomingVoiceCall(
{required int id, required bool accept, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmHandleIncomingVoiceCall");
2024-03-22 13:16:37 +08:00
}
Future<void> cmCloseVoiceCall({required int id, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmCloseVoiceCall");
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetLastRemoteId({dynamic hint}) {
2024-10-14 11:15:52 +08:00
return Future(() => mainGetLocalOption(key: 'last_remote_id'));
2024-03-22 13:16:37 +08:00
}
2024-09-24 12:00:37 +08:00
Future<void> mainGetSoftwareUpdateUrl({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetSoftwareUpdateUrl");
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetHomeDir({dynamic hint}) {
2024-03-23 10:08:55 +08:00
return Future.value('');
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetLangs({dynamic hint}) {
2024-09-01 00:30:07 +08:00
return Future(() => js.context.callMethod('getByName', ['langs']));
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetTemporaryPassword({dynamic hint}) {
2024-03-23 10:08:55 +08:00
return Future.value('');
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetFingerprint({dynamic hint}) {
2024-09-02 02:00:59 +08:00
return Future.value('');
2024-03-22 13:16:37 +08:00
}
Future<String> cmGetClientsState({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmGetClientsState");
2024-03-22 13:16:37 +08:00
}
Future<String?> cmCheckClientsLength({required int length, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmCheckClientsLength");
2024-03-22 13:16:37 +08:00
}
Future<int> cmGetClientsLength({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmCheckClientsLength");
2024-03-22 13:16:37 +08:00
}
Future<void> mainInit({required String appDir, dynamic hint}) {
2024-03-23 10:08:55 +08:00
return Future.value();
2024-03-22 13:16:37 +08:00
}
Future<void> mainDeviceId({required String id, dynamic hint}) {
2024-03-26 10:45:06 +08:00
// TODO: ?
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainDeviceId");
2024-03-22 13:16:37 +08:00
}
Future<void> mainDeviceName({required String name, dynamic hint}) {
2024-03-26 10:45:06 +08:00
// TODO: ?
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainDeviceName");
2024-03-22 13:16:37 +08:00
}
Future<void> mainRemovePeer({required String id, dynamic hint}) {
2024-10-11 09:52:09 +08:00
return Future(
() => js.context.callMethod('setByName', ['remove_peer', id]));
2024-03-22 13:16:37 +08:00
}
bool mainHasHwcodec({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainHasHwcodec");
2024-03-22 13:16:37 +08:00
}
2024-04-12 17:26:24 +08:00
bool mainHasVram({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainHasVram");
2024-03-22 13:16:37 +08:00
}
String mainSupportedHwdecodings({dynamic hint}) {
2024-09-01 00:30:07 +08:00
return '{}';
2024-03-22 13:16:37 +08:00
}
Future<bool> mainIsRoot({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainIsRoot");
2024-03-22 13:16:37 +08:00
}
int getDoubleClickTime({dynamic hint}) {
2024-10-12 09:03:13 +08:00
return 500;
2024-03-22 13:16:37 +08:00
}
Future<void> mainStartDbusServer({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainStartDbusServer");
2024-03-22 13:16:37 +08:00
}
Future<void> mainSaveAb({required String json, dynamic hint}) {
2024-10-11 09:52:09 +08:00
return Future(() => js.context.callMethod('setByName', ['save_ab', json]));
2024-03-22 13:16:37 +08:00
}
Future<void> mainClearAb({dynamic hint}) {
2024-10-11 09:52:09 +08:00
return Future(() => js.context.callMethod('setByName', ['clear_ab']));
2024-03-22 13:16:37 +08:00
}
Future<String> mainLoadAb({dynamic hint}) {
2024-10-14 15:46:21 +08:00
Completer<String> completer = Completer();
2024-10-14 15:51:51 +08:00
Future<String> timeoutFuture = completer.future.timeout(
Duration(seconds: 2),
onTimeout: () {
completer.completeError(TimeoutException('Load ab timed out'));
return 'Timeout';
},
);
2024-10-14 15:46:21 +08:00
js.context["onLoadAbFinished"] = (String s) {
completer.complete(s);
};
js.context.callMethod('setByName', ['load_ab']);
2024-10-14 15:51:51 +08:00
return timeoutFuture;
2024-03-22 13:16:37 +08:00
}
Future<void> mainSaveGroup({required String json, dynamic hint}) {
2024-10-11 09:52:09 +08:00
return Future(
() => js.context.callMethod('setByName', ['save_group', json]));
2024-03-22 13:16:37 +08:00
}
Future<void> mainClearGroup({dynamic hint}) {
2024-10-11 09:52:09 +08:00
return Future(() => js.context.callMethod('setByName', ['clear_group']));
2024-03-22 13:16:37 +08:00
}
Future<String> mainLoadGroup({dynamic hint}) {
2024-10-14 15:46:21 +08:00
Completer<String> completer = Completer();
2024-10-14 15:51:51 +08:00
Future<String> timeoutFuture = completer.future.timeout(
Duration(seconds: 2),
onTimeout: () {
completer.completeError(TimeoutException('Load group timed out'));
return 'Timeout';
},
);
2024-10-14 15:46:21 +08:00
js.context["onLoadGroupFinished"] = (String s) {
completer.complete(s);
};
js.context.callMethod('setByName', ['load_group']);
2024-10-14 15:51:51 +08:00
return timeoutFuture;
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSendPointer(
{required UuidValue sessionId, required String msg, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionSendPointer");
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSendMouse(
{required UuidValue sessionId, required String msg, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future(
() => js.context.callMethod('setByName', ['send_mouse', msg]));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionRestartRemoteDevice(
{required UuidValue sessionId, dynamic hint}) {
2024-03-26 10:45:06 +08:00
return Future(() => js.context.callMethod('setByName', ['restart']));
2024-03-22 13:16:37 +08:00
}
String sessionGetAuditServerSync(
{required UuidValue sessionId, required String typ, dynamic hint}) {
2024-03-27 11:26:29 +08:00
return js.context.callMethod('getByName', ['audit_server', typ]);
2024-03-22 13:16:37 +08:00
}
Future<void> sessionSendNote(
{required UuidValue sessionId, required String note, dynamic hint}) {
2024-10-08 15:23:00 +08:00
return Future(
() => js.context.callMethod('setByName', ['send_note', note]));
2024-03-22 13:16:37 +08:00
}
Future<String> sessionAlternativeCodecs(
{required UuidValue sessionId, dynamic hint}) {
2024-03-27 11:26:29 +08:00
return Future(
() => js.context.callMethod('getByName', ['alternative_codecs']));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionChangePreferCodec(
{required UuidValue sessionId, dynamic hint}) {
2024-03-27 11:26:29 +08:00
return Future(
() => js.context.callMethod('setByName', ['change_prefer_codec']));
2024-03-22 13:16:37 +08:00
}
Future<void> sessionOnWaitingForImageDialogShow(
{required UuidValue sessionId, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return Future.value();
2024-03-22 13:16:37 +08:00
}
Future<void> sessionToggleVirtualDisplay(
{required UuidValue sessionId,
required int index,
required bool on,
dynamic hint}) {
2024-09-10 23:54:59 +08:00
return Future(() => js.context.callMethod('setByName', [
'toggle_virtual_display',
jsonEncode({'index': index, 'on': on})
]));
2024-03-22 13:16:37 +08:00
}
Future<void> mainSetHomeDir({required String home, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainSetHomeDir");
2024-03-22 13:16:37 +08:00
}
String mainGetDataDirIos({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetDataDirIos");
2024-03-22 13:16:37 +08:00
}
Future<void> mainStopService({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainStopService");
2024-03-22 13:16:37 +08:00
}
Future<void> mainStartService({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainStartService");
2024-03-22 13:16:37 +08:00
}
Future<void> mainUpdateTemporaryPassword({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainUpdateTemporaryPassword");
2024-03-22 13:16:37 +08:00
}
Future<bool> mainSetPermanentPasswordWithResult(
2024-03-22 13:16:37 +08:00
{required String password, dynamic hint}) {
throw UnimplementedError("mainSetPermanentPasswordWithResult");
2024-03-22 13:16:37 +08:00
}
Future<bool> mainCheckSuperUserPermission({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainCheckSuperUserPermission");
2024-03-22 13:16:37 +08:00
}
Future<void> mainCheckMouseTime({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainCheckMouseTime");
2024-03-22 13:16:37 +08:00
}
Future<double> mainGetMouseTime({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetMouseTime");
2024-03-22 13:16:37 +08:00
}
Future<void> mainWol({required String id, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainWol");
2024-03-22 13:16:37 +08:00
}
Future<void> mainCreateShortcut({required String id, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainCreateShortcut");
2024-03-22 13:16:37 +08:00
}
Future<void> cmSendChat(
{required int connId, required String msg, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmSendChat");
2024-03-22 13:16:37 +08:00
}
Future<void> cmLoginRes(
{required int connId, required bool res, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmLoginRes");
2024-03-22 13:16:37 +08:00
}
Future<void> cmCloseConnectionWindow({required int connId, dynamic hint}) {
throw UnimplementedError("cmCloseConnectionWindow");
}
2024-03-22 13:16:37 +08:00
Future<void> cmCloseConnection({required int connId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmCloseConnection");
2024-03-22 13:16:37 +08:00
}
Future<void> cmRemoveDisconnectedConnection(
{required int connId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmRemoveDisconnectedConnection");
2024-03-22 13:16:37 +08:00
}
Future<void> cmCheckClickTime({required int connId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmCheckClickTime");
2024-03-22 13:16:37 +08:00
}
Future<double> cmGetClickTime({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmGetClickTime");
2024-03-22 13:16:37 +08:00
}
Future<void> cmSwitchPermission(
{required int connId,
required String name,
required bool enabled,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmSwitchPermission");
2024-03-22 13:16:37 +08:00
}
bool cmCanElevate({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmCanElevate");
2024-03-22 13:16:37 +08:00
}
Future<void> cmElevatePortable({required int connId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmElevatePortable");
2024-03-22 13:16:37 +08:00
}
Future<void> cmSwitchBack({required int connId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmSwitchBack");
2024-03-22 13:16:37 +08:00
}
Future<String> cmGetConfig({required String name, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmGetConfig");
2024-03-22 13:16:37 +08:00
}
Future<String> mainGetBuildDate({dynamic hint}) {
2024-09-01 00:30:07 +08:00
return Future(() => js.context.callMethod('getByName', ['build_date']));
2024-03-22 13:16:37 +08:00
}
String translate(
{required String name, required String locale, dynamic hint}) {
2024-03-23 10:08:55 +08:00
return js.context.callMethod('getByName', [
'translate',
jsonEncode({'locale': locale, 'text': name})
]);
2024-03-22 13:16:37 +08:00
}
int sessionGetRgbaSize(
{required UuidValue sessionId, required int display, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return 0;
2024-03-22 13:16:37 +08:00
}
void sessionNextRgba(
2024-03-25 10:47:53 +08:00
{required UuidValue sessionId, required int display, dynamic hint}) {}
2024-03-22 13:16:37 +08:00
void sessionRegisterPixelbufferTexture(
{required UuidValue sessionId,
required int display,
required int ptr,
2024-03-25 10:47:53 +08:00
dynamic hint}) {}
2024-03-22 13:16:37 +08:00
void sessionRegisterGpuTexture(
{required UuidValue sessionId,
required int display,
required int ptr,
2024-03-25 10:47:53 +08:00
dynamic hint}) {}
2024-03-22 13:16:37 +08:00
Future<void> queryOnlines({required List<String> ids, dynamic hint}) {
2024-03-27 11:26:29 +08:00
return Future(() =>
js.context.callMethod('setByName', ['query_onlines', jsonEncode(ids)]));
2024-03-22 13:16:37 +08:00
}
2024-03-25 10:47:53 +08:00
// Dup to the function in hbb_common, lib.rs
// Maybe we need to move this function to js part.
2024-03-22 13:16:37 +08:00
int versionToNumber({required String v, dynamic hint}) {
2024-03-27 11:26:29 +08:00
return int.tryParse(
js.context.callMethod('getByName', ['get_version_number', v])) ??
0;
2024-03-22 13:16:37 +08:00
}
Future<bool> optionSynced({dynamic hint}) {
2024-03-23 10:08:55 +08:00
return Future.value(true);
2024-03-22 13:16:37 +08:00
}
bool mainIsInstalled({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainIsInstalled");
2024-03-22 13:16:37 +08:00
}
void mainInitInputSource({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainIsInstalled");
2024-03-22 13:16:37 +08:00
}
bool mainIsInstalledLowerVersion({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainIsInstalledLowerVersion");
2024-03-22 13:16:37 +08:00
}
bool mainIsInstalledDaemon({required bool prompt, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainIsInstalledDaemon");
2024-03-22 13:16:37 +08:00
}
bool mainIsProcessTrusted({required bool prompt, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainIsProcessTrusted");
2024-03-22 13:16:37 +08:00
}
bool mainIsCanScreenRecording({required bool prompt, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainIsCanScreenRecording");
2024-03-22 13:16:37 +08:00
}
bool mainIsCanInputMonitoring({required bool prompt, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainIsCanInputMonitoring");
2024-03-22 13:16:37 +08:00
}
bool mainIsShareRdp({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainIsShareRdp");
2024-03-22 13:16:37 +08:00
}
Future<void> mainSetShareRdp({required bool enable, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainSetShareRdp");
2024-03-22 13:16:37 +08:00
}
bool mainGotoInstall({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGotoInstall");
2024-03-22 13:16:37 +08:00
}
String mainGetNewVersion({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetNewVersion");
2024-03-22 13:16:37 +08:00
}
bool mainUpdateMe({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainUpdateMe");
2024-03-22 13:16:37 +08:00
}
Future<void> setCurSessionId({required UuidValue sessionId, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("setCurSessionId");
2024-03-22 13:16:37 +08:00
}
bool installShowRunWithoutInstall({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("installShowRunWithoutInstall");
2024-03-22 13:16:37 +08:00
}
Future<void> installRunWithoutInstall({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("installRunWithoutInstall");
2024-03-22 13:16:37 +08:00
}
Future<void> installInstallMe(
{required String options, required String path, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("installInstallMe");
2024-03-22 13:16:37 +08:00
}
String installInstallPath({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("installInstallPath");
2024-03-22 13:16:37 +08:00
}
Future<void> mainAccountAuth(
{required String op, required bool rememberMe, dynamic hint}) {
// Safari only allows auth popups while handling the original user gesture.
2026-04-22 01:41:13 +08:00
// Use Future.sync so the JS call runs synchronously (pre-opening the OIDC
// window) while any interop error still surfaces as a Future error.
return Future.sync(() => js.context.callMethod('setByName', [
2025-05-14 17:35:50 +08:00
'account_auth',
jsonEncode({'op': op, 'remember': rememberMe})
2026-04-22 01:41:13 +08:00
]));
2024-03-22 13:16:37 +08:00
}
Future<void> mainAccountAuthCancel({dynamic hint}) {
2025-05-14 17:35:50 +08:00
return Future(
() => js.context.callMethod('setByName', ['account_auth_cancel']));
2024-03-22 13:16:37 +08:00
}
Future<String> mainAccountAuthResult({dynamic hint}) {
2025-05-14 17:35:50 +08:00
return Future(
() => js.context.callMethod('getByName', ['account_auth_result']));
2024-03-22 13:16:37 +08:00
}
Future<void> mainOnMainWindowClose({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainOnMainWindowClose");
2024-03-22 13:16:37 +08:00
}
bool mainCurrentIsWayland({dynamic hint}) {
2024-03-26 10:45:06 +08:00
return false;
2024-03-22 13:16:37 +08:00
}
bool mainIsLoginWayland({dynamic hint}) {
2024-03-26 10:45:06 +08:00
return false;
2024-03-22 13:16:37 +08:00
}
bool mainHideDock({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainHideDock");
2024-03-22 13:16:37 +08:00
}
bool mainHasFileClipboard({dynamic hint}) {
2024-03-27 11:26:29 +08:00
return false;
2024-03-22 13:16:37 +08:00
}
bool mainHasGpuTextureRender({dynamic hint}) {
2024-03-27 11:26:29 +08:00
return false;
2024-03-22 13:16:37 +08:00
}
Future<void> cmInit({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("cmInit");
2024-03-22 13:16:37 +08:00
}
Future<void> mainStartIpcUrlServer({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainStartIpcUrlServer");
2024-03-22 13:16:37 +08:00
}
Future<void> mainTestWallpaper({required int second, dynamic hint}) {
2024-03-23 10:08:55 +08:00
// TODO: implement mainTestWallpaper
return Future.value();
2024-03-22 13:16:37 +08:00
}
Future<bool> mainSupportRemoveWallpaper({dynamic hint}) {
2024-03-23 10:08:55 +08:00
// TODO: implement mainSupportRemoveWallpaper
return Future.value(false);
2024-03-22 13:16:37 +08:00
}
bool isIncomingOnly({dynamic hint}) {
2024-03-23 10:08:55 +08:00
return false;
2024-03-22 13:16:37 +08:00
}
bool isOutgoingOnly({dynamic hint}) {
2024-03-23 10:08:55 +08:00
return false;
2024-03-22 13:16:37 +08:00
}
bool isCustomClient({dynamic hint}) {
2025-11-17 00:30:17 +08:00
// is_custom_client() checks if app name is not "RustDesk"
return mainGetAppNameSync(hint: hint) != "RustDesk";
2024-03-22 13:16:37 +08:00
}
bool isDisableSettings({dynamic hint}) {
2025-11-17 00:30:17 +08:00
// Checks HARD_SETTINGS["disable-settings"] == "Y"
return mainGetHardOption(key: "disable-settings", hint: hint) == "Y";
2024-03-22 13:16:37 +08:00
}
bool isDisableAb({dynamic hint}) {
2025-11-17 00:30:17 +08:00
// Checks HARD_SETTINGS["disable-ab"] == "Y"
return mainGetHardOption(key: "disable-ab", hint: hint) == "Y";
2024-03-22 13:16:37 +08:00
}
bool isDisableGroupPanel({dynamic hint}) {
2025-11-17 00:30:17 +08:00
// Checks LocalConfig::get_option("disable-group-panel") == "Y"
return mainGetLocalOption(key: "disable-group-panel", hint: hint) == "Y";
}
2024-03-22 13:16:37 +08:00
bool isDisableAccount({dynamic hint}) {
2025-11-17 00:30:17 +08:00
// Checks HARD_SETTINGS["disable-account"] == "Y"
return mainGetHardOption(key: "disable-account", hint: hint) == "Y";
2024-03-22 13:16:37 +08:00
}
bool isDisableInstallation({dynamic hint}) {
2024-03-23 10:08:55 +08:00
return false;
2024-03-22 13:16:37 +08:00
}
Future<bool> isPresetPassword({dynamic hint}) {
2024-03-23 10:08:55 +08:00
return Future.value(false);
2024-03-22 13:16:37 +08:00
}
Future<void> sendUrlScheme({required String url, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sendUrlScheme");
2024-03-22 13:16:37 +08:00
}
bool isSupportMultiUiSession({required String version, dynamic hint}) {
2024-03-25 10:47:53 +08:00
return versionToNumber(v: version) > versionToNumber(v: '1.2.4');
2024-03-22 13:16:37 +08:00
}
bool isSelinuxEnforcing({dynamic hint}) {
2024-03-26 10:45:06 +08:00
return false;
2024-03-22 13:16:37 +08:00
}
String mainDefaultPrivacyModeImpl({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainDefaultPrivacyModeImpl");
2024-03-22 13:16:37 +08:00
}
String mainSupportedPrivacyModeImpls({dynamic hint}) {
return '[]';
2024-03-22 13:16:37 +08:00
}
String mainSupportedInputSource({dynamic hint}) {
2024-03-28 11:38:11 +08:00
return jsonEncode([
['Input source 1', 'input_source_1_tip'],
2024-03-28 11:38:11 +08:00
['Input source 2', 'input_source_2_tip']
]);
2024-03-22 13:16:37 +08:00
}
Future<String> mainGenerate2Fa({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGenerate2Fa");
2024-03-22 13:16:37 +08:00
}
Future<bool> mainVerify2Fa({required String code, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainVerify2Fa");
2024-03-22 13:16:37 +08:00
}
bool mainHasValid2FaSync({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainHasValid2FaSync");
2024-03-22 13:16:37 +08:00
}
String mainGetHardOption({required String key, dynamic hint}) {
2025-11-17 00:30:17 +08:00
return mainGetLocalOption(key: key, hint: hint);
2024-03-22 13:16:37 +08:00
}
Future<void> mainCheckHwcodec({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainCheckHwcodec");
}
Future<void> sessionRequestNewDisplayInitMsgs(
{required UuidValue sessionId, required int display, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("sessionRequestNewDisplayInitMsgs");
}
2024-05-09 11:03:59 +08:00
Future<String> mainHandleWaylandScreencastRestoreToken(
{required String key, required String value, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainHandleWaylandScreencastRestoreToken");
2024-05-09 11:03:59 +08:00
}
2024-05-17 14:19:11 +08:00
bool mainIsOptionFixed({required String key, dynamic hint}) {
2024-08-24 12:10:36 +08:00
return false;
2024-05-17 14:19:11 +08:00
}
2024-05-28 16:42:30 +08:00
bool mainGetUseTextureRender({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetUseTextureRender");
2024-05-28 16:42:30 +08:00
}
2024-07-14 15:04:35 +08:00
bool mainHasValidBotSync({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainHasValidBotSync");
2024-07-14 15:04:35 +08:00
}
Future<String> mainVerifyBot({required String token, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainVerifyBot");
2024-07-14 15:04:35 +08:00
}
2024-08-07 16:21:38 +08:00
String mainGetUnlockPin({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetUnlockPin");
2024-08-07 16:21:38 +08:00
}
String mainSetUnlockPin({required String pin, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainSetUnlockPin");
2024-08-07 16:21:38 +08:00
}
2024-08-12 18:08:33 +08:00
bool sessionGetEnableTrustedDevices(
{required UuidValue sessionId, dynamic hint}) {
2024-10-08 18:35:25 +08:00
return js.context.callMethod('getByName', ['enable_trusted_devices']) ==
'Y';
2024-08-12 18:08:33 +08:00
}
Future<String> mainGetTrustedDevices({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainGetTrustedDevices");
2024-08-12 18:08:33 +08:00
}
Future<void> mainRemoveTrustedDevices({required String json, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainRemoveTrustedDevices");
2024-08-12 18:08:33 +08:00
}
Future<void> mainClearTrustedDevices({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainClearTrustedDevices");
2024-08-12 18:08:33 +08:00
}
2024-08-24 12:10:36 +08:00
Future<String> getVoiceCallInputDevice({required bool isCm, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("getVoiceCallInputDevice");
2024-08-24 12:10:36 +08:00
}
Future<void> setVoiceCallInputDevice(
{required bool isCm, required String device, dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("setVoiceCallInputDevice");
2024-08-24 12:10:36 +08:00
}
bool isPresetPasswordMobileOnly({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("isPresetPasswordMobileOnly");
2024-08-24 12:10:36 +08:00
}
String mainGetBuildinOption({required String key, dynamic hint}) {
2025-11-17 00:30:17 +08:00
return mainGetLocalOption(key: key, hint: hint);
2024-08-24 12:10:36 +08:00
}
String installInstallOptions({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("installInstallOptions");
2024-08-24 12:10:36 +08:00
}
2024-09-04 22:27:52 +08:00
int mainMaxEncryptLen({dynamic hint}) {
2024-10-12 09:03:13 +08:00
throw UnimplementedError("mainMaxEncryptLen");
2024-09-04 22:27:52 +08:00
}
bool mainAudioSupportLoopback({dynamic hint}) {
return false;
}
Future<String> sessionReadLocalEmptyDirsRecursiveSync(
{required UuidValue sessionId,
required String path,
required bool includeHidden,
dynamic hint}) {
throw UnimplementedError("sessionReadLocalEmptyDirsRecursiveSync");
}
Future<void> sessionReadRemoteEmptyDirsRecursiveSync(
{required UuidValue sessionId,
required String path,
required bool includeHidden,
dynamic hint}) {
throw UnimplementedError("sessionReadRemoteEmptyDirsRecursiveSync");
}
2024-10-12 09:03:13 +08:00
Future<void> sessionRenameFile(
2024-08-24 12:10:36 +08:00
{required UuidValue sessionId,
required int actId,
required String path,
required String newName,
required bool isRemote,
dynamic hint}) {
2024-10-12 09:03:13 +08:00
return Future(() => js.context.callMethod('setByName', [
'rename_file',
jsonEncode({
'id': actId,
'path': path,
'new_name': newName,
'is_remote': isRemote
})
]));
}
Future<void> sessionSelectFiles(
{required UuidValue sessionId, dynamic hint}) {
return Future(() => js.context.callMethod('setByName', ['select_files']));
2024-08-24 12:10:36 +08:00
}
2024-10-28 09:40:16 +08:00
String? sessionGetConnToken({required UuidValue sessionId, dynamic hint}) {
throw UnimplementedError("sessionGetConnToken");
}
2025-05-09 12:18:49 +08:00
String mainGetPrinterNames({dynamic hint}) {
return '';
}
Future<void> sessionPrinterResponse(
{required UuidValue sessionId,
required int id,
required String path,
required String printerName,
dynamic hint}) {
throw UnimplementedError("sessionPrinterResponse");
}
Future<String> mainGetCommon({required String key, dynamic hint}) {
throw UnimplementedError("mainGetCommon");
}
String mainGetCommonSync({required String key, dynamic hint}) {
throw UnimplementedError("mainGetCommonSync");
}
Future<void> mainSetCommon(
{required String key, required String value, dynamic hint}) {
throw UnimplementedError("mainSetCommon");
}
Future<String> sessionHandleScreenshot(
{required UuidValue sessionId, required String action, dynamic hint}) {
throw UnimplementedError("sessionHandleScreenshot");
}
2026-07-06 17:05:11 +08:00
Future<void> sessionSetCommon(
{required UuidValue sessionId, required String key, required String value, dynamic hint}) {
js.context.callMethod('setByName', [
'common',
jsonEncode({'name': key, 'value': value})
]);
return Future.value();
2026-07-06 17:05:11 +08:00
}
2025-05-09 12:18:49 +08:00
String? sessionGetCommonSync(
{required UuidValue sessionId,
required String key,
required String param,
dynamic hint}) {
throw UnimplementedError("sessionGetCommonSync");
}
Future<void> sessionTakeScreenshot(
{required UuidValue sessionId, required int display, dynamic hint}) {
throw UnimplementedError("sessionTakeScreenshot");
}
2025-07-01 13:12:55 +08:00
Future<void> sessionOpenTerminal(
{required UuidValue sessionId,
required int terminalId,
required int rows,
required int cols,
dynamic hint}) {
return Future(() => js.context.callMethod('setByName', [
'open_terminal',
jsonEncode({
'terminal_id': terminalId,
'rows': rows,
'cols': cols,
})
]));
}
Future<void> sessionSendTerminalInput(
{required UuidValue sessionId,
required int terminalId,
required String data,
dynamic hint}) {
return Future(() => js.context.callMethod('setByName', [
'send_terminal_input',
jsonEncode({
'terminal_id': terminalId,
'data': data,
})
]));
}
Future<void> sessionResizeTerminal(
{required UuidValue sessionId,
required int terminalId,
required int rows,
required int cols,
dynamic hint}) {
return Future(() => js.context.callMethod('setByName', [
'resize_terminal',
jsonEncode({
'terminal_id': terminalId,
'rows': rows,
'cols': cols,
})
]));
}
Future<void> sessionCloseTerminal(
2025-07-22 19:26:50 +08:00
{required UuidValue sessionId, required int terminalId, dynamic hint}) {
2025-07-01 13:12:55 +08:00
return Future(() => js.context.callMethod('setByName', [
'close_terminal',
jsonEncode({
'terminal_id': terminalId,
})
]));
}
2025-11-13 23:35:40 +08:00
Future<int?> sessionGetEdgeScrollEdgeThickness(
{required UuidValue sessionId, dynamic hint}) {
final thickness = js.context.callMethod(
'getByName', ['option:session', 'edge-scroll-edge-thickness']);
return Future(() => int.tryParse(thickness) ?? 100);
}
Future<void> sessionSetEdgeScrollEdgeThickness(
{required UuidValue sessionId, required int value, dynamic hint}) {
return Future(() => js.context.callMethod('setByName',
['option:session', 'edge-scroll-edge-thickness', value.toString()]));
}
String sessionGetConnSessionId({required UuidValue sessionId, dynamic hint}) {
return js.context.callMethod('getByName', ['conn_session_id']);
}
bool willSessionCloseCloseSession(
{required UuidValue sessionId, dynamic hint}) {
return true;
}
String sessionGetLastAuditNote({required UuidValue sessionId, dynamic hint}) {
return js.context.callMethod('getByName', ['last_audit_note']);
}
Future<void> sessionSetAuditGuid(
{required UuidValue sessionId, required String guid, dynamic hint}) {
return Future(
() => js.context.callMethod('setByName', ['audit_guid', guid]));
}
String sessionGetAuditGuid({required UuidValue sessionId, dynamic hint}) {
return js.context.callMethod('getByName', ['audit_guid']);
}
2026-01-09 10:03:14 +08:00
bool mainSetCursorPosition({required int x, required int y, dynamic hint}) {
return false;
}
bool mainClipCursor(
{required int left,
required int top,
required int right,
required int bottom,
required bool enable,
dynamic hint}) {
return false;
}
2026-03-04 21:43:19 +08:00
String mainResolveAvatarUrl({required String avatar, dynamic hint}) {
2026-06-02 14:28:30 +08:00
return js.context.callMethod(
'getByName', ['resolve_avatar_url', avatar])?.toString() ??
avatar;
}
Future<String> mainDeployDevice(
{required String token, required String id, dynamic hint}) {
throw UnimplementedError("mainDeployDevice");
2026-03-04 21:43:19 +08:00
}
2024-03-26 10:45:06 +08:00
void dispose() {}
2024-03-22 13:16:37 +08:00
}