import 'dart:async'; import 'dart:js' as js; import 'dart:convert'; import 'dart:typed_data'; import 'package:flutter/foundation.dart'; import 'package:uuid/uuid.dart'; import 'dart:html' as html; import 'package:flutter_hbb/consts.dart'; 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, bool field1, ) = EventToUI_Texture; } 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 { const EventToUI_Rgba(final int field0) : field = field0; final int field; int get field0 => field; } class EventToUI_Texture implements EventToUI { 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; } class RustdeskImpl { Future stopGlobalEventStream({required String appType, dynamic hint}) { throw UnimplementedError(); } Future hostStopSystemKeyPropagate( {required bool stopped, dynamic hint}) { throw UnimplementedError(); } int peerGetDefaultSessionsCount({required String id, dynamic hint}) { return 0; } String sessionAddExistedSync( {required String id, required UuidValue sessionId, required Int32List displays, dynamic hint}) { return ''; } String sessionAddSync( {required UuidValue sessionId, required String id, required bool isFileTransfer, required bool isPortForward, required bool isRdp, required String switchUuid, required bool forceRelay, required String password, required bool isSharedPassword, dynamic hint}) { return js.context.callMethod('setByName', [ 'session_add_sync', jsonEncode({'id': id, 'password': password}) ]); } Stream sessionStart( {required UuidValue sessionId, required String id, dynamic hint}) { js.context.callMethod('setByName', [ 'session_start', jsonEncode({'id': id}) ]); return Stream.empty(); } Stream sessionStartWithDisplays( {required UuidValue sessionId, required String id, required Int32List displays, dynamic hint}) { throw UnimplementedError(); } Future sessionGetRemember( {required UuidValue sessionId, dynamic hint}) { return Future( () => js.context.callMethod('getByName', ['remember']) == 'true'); } Future sessionGetToggleOption( {required UuidValue sessionId, required String arg, dynamic hint}) { return Future( () => sessionGetToggleOptionSync(sessionId: sessionId, arg: arg)); } bool sessionGetToggleOptionSync( {required UuidValue sessionId, required String arg, dynamic hint}) { return 'true' == js.context.callMethod('getByName', ['option:toggle', arg]); } Future sessionGetOption( {required UuidValue sessionId, required String arg, dynamic hint}) { return Future( () => js.context.callMethod('getByName', ['option:session', arg])); } Future sessionLogin( {required UuidValue sessionId, required String osUsername, required String osPassword, required String password, required bool remember, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'login', jsonEncode({ 'os_username': osUsername, 'os_password': osPassword, 'password': password, 'remember': remember }) ])); } Future sessionSend2Fa( {required UuidValue sessionId, required String code, required bool trustThisDevice, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'send_2fa', jsonEncode({'code': code, 'trust_this_device': trustThisDevice}) ])); } Future sessionClose({required UuidValue sessionId, dynamic hint}) { return Future(() => js.context.callMethod('setByName', ['session_close'])); } Future sessionRefresh( {required UuidValue sessionId, required int display, dynamic hint}) { return Future(() => js.context.callMethod('setByName', ['refresh'])); } Future sessionRecordScreen( {required UuidValue sessionId, required bool start, required int display, required int width, required int height, dynamic hint}) { throw UnimplementedError(); } Future sessionRecordStatus( {required UuidValue sessionId, required bool status, dynamic hint}) { throw UnimplementedError(); } Future sessionReconnect( {required UuidValue sessionId, required bool forceRelay, dynamic hint}) { return Future(() => js.context.callMethod('setByName', ['reconnect'])); } Future sessionToggleOption( {required UuidValue sessionId, required String value, dynamic hint}) { return Future( () => js.context.callMethod('setByName', ['option:toggle', value])); } Future sessionTogglePrivacyMode( {required UuidValue sessionId, required String implKey, required bool on, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'toggle_privacy_mode', jsonEncode({'impl_key': implKey, 'on': on}) ])); } Future sessionGetFlutterOption( {required UuidValue sessionId, required String k, dynamic hint}) { return Future( () => js.context.callMethod('getByName', ['option:flutter:peer', k])); } Future sessionSetFlutterOption( {required UuidValue sessionId, required String k, required String v, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:flutter:peer', jsonEncode({'name': k, 'value': v}) ])); } int getNextTextureKey({dynamic hint}) { return 0; } String getLocalFlutterOption({required String k, dynamic hint}) { return js.context.callMethod('getByName', ['option:flutter:local', k]); } Future setLocalFlutterOption( {required String k, required String v, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:flutter:local', jsonEncode({'name': k, 'value': v}) ])); } String getLocalKbLayoutType({dynamic hint}) { return js.context.callMethod('getByName', ['option:local', 'kb_layout']); } Future setLocalKbLayoutType( {required String kbLayoutType, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:local', jsonEncode({'name': 'kb_layout', 'value': kbLayoutType}) ])); } Future sessionGetViewStyle( {required UuidValue sessionId, dynamic hint}) { return Future(() => js.context.callMethod('getByName', ['option:session', 'view_style'])); } Future sessionSetViewStyle( {required UuidValue sessionId, required String value, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:session', jsonEncode({'name': 'view_style', 'value': value}) ])); } Future sessionGetScrollStyle( {required UuidValue sessionId, dynamic hint}) { return Future(() => js.context.callMethod('getByName', ['option:session', 'scroll_style'])); } Future sessionSetScrollStyle( {required UuidValue sessionId, required String value, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:session', jsonEncode({'name': 'scroll_style', 'value': value}) ])); } Future sessionGetImageQuality( {required UuidValue sessionId, dynamic hint}) { return Future(() => js.context .callMethod('getByName', ['option:session', 'image_quality'])); } Future sessionSetImageQuality( {required UuidValue sessionId, required String value, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:session', jsonEncode({'name': 'image_quality', 'value': value}) ])); } Future sessionGetKeyboardMode( {required UuidValue sessionId, dynamic hint}) { final mode = js.context.callMethod('getByName', ['option:session', 'keyboard_mode']); return Future(() => mode == '' ? null : mode); } Future sessionSetKeyboardMode( {required UuidValue sessionId, required String value, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:session', jsonEncode({'name': 'keyboard_mode', 'value': value}) ])); } String? sessionGetReverseMouseWheelSync( {required UuidValue sessionId, dynamic hint}) { return js.context .callMethod('getByName', ['option:session', 'reverse_mouse_wheel']); } Future sessionSetReverseMouseWheel( {required UuidValue sessionId, required String value, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:session', jsonEncode({'name': 'reverse_mouse_wheel', 'value': value}) ])); } String? sessionGetDisplaysAsIndividualWindows( {required UuidValue sessionId, dynamic hint}) { return js.context.callMethod( 'getByName', ['option:session', 'displays_as_individual_windows']); } Future sessionSetDisplaysAsIndividualWindows( {required UuidValue sessionId, required String value, dynamic hint}) { return Future.value(); } String? sessionGetUseAllMyDisplaysForTheRemoteSession( {required UuidValue sessionId, dynamic hint}) { return ''; } Future sessionSetUseAllMyDisplaysForTheRemoteSession( {required UuidValue sessionId, required String value, dynamic hint}) { return Future.value(); } Future sessionGetCustomImageQuality( {required UuidValue sessionId, dynamic hint}) { try { return Future(() => Int32List.fromList([ int.parse(js.context.callMethod( 'getByName', ['option:session', 'custom_image_quality'])) ])); } catch (e) { return Future.value(null); } } 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); } } bool sessionIsMultiUiSession({required UuidValue sessionId, dynamic hint}) { return false; } Future sessionSetCustomImageQuality( {required UuidValue sessionId, required int value, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:session', jsonEncode({'name': 'custom_image_quality', 'value': value}) ])); } Future sessionSetCustomFps( {required UuidValue sessionId, required int fps, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:session', jsonEncode({'name': 'custom_fps', 'value': fps}) ])); } Future sessionLockScreen({required UuidValue sessionId, dynamic hint}) { return Future(() => js.context.callMethod('setByName', ['lock_screen'])); } Future sessionCtrlAltDel({required UuidValue sessionId, dynamic hint}) { return Future(() => js.context.callMethod('setByName', ['ctrl_alt_del'])); } Future sessionSwitchDisplay( {required bool isDesktop, required UuidValue sessionId, required Int32List value, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'switch_display', jsonEncode({ 'isDesktop': isDesktop, 'sessionId': sessionId.toString(), 'value': value }) ])); } Future sessionHandleFlutterKeyEvent( {required UuidValue sessionId, required String character, required int usbHid, required int lockModes, required bool downOrUp, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'flutter_key_event', jsonEncode({ 'name': character, 'usb_hid': usbHid, 'lock_modes': lockModes, if (downOrUp) 'down': 'true', }) ])); } Future sessionHandleFlutterRawKeyEvent( {required UuidValue sessionId, required String name, required int platformCode, required int positionCode, required int lockModes, required bool downOrUp, dynamic hint}) { throw UnimplementedError(); } void sessionEnterOrLeave( {required UuidValue sessionId, required bool enter, dynamic hint}) { js.context.callMethod('setByName', ['enter_or_leave', enter]); } Future 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}) { 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' }) ])); } Future sessionInputString( {required UuidValue sessionId, required String value, dynamic hint}) { return Future( () => js.context.callMethod('setByName', ['input_string', value])); } Future sessionSendChat( {required UuidValue sessionId, required String text, dynamic hint}) { return Future( () => js.context.callMethod('setByName', ['send_chat', text])); } Future sessionPeerOption( {required UuidValue sessionId, required String name, required String value, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:session', jsonEncode({'name': name, 'value': value}) ])); } Future sessionGetPeerOption( {required UuidValue sessionId, required String name, dynamic hint}) { return Future( () => js.context.callMethod('getByName', ['option:session', name])); } Future sessionInputOsPassword( {required UuidValue sessionId, required String value, dynamic hint}) { return Future( () => js.context.callMethod('setByName', ['input_os_password', value])); } Future sessionReadRemoteDir( {required UuidValue sessionId, required String path, required bool includeHidden, dynamic hint}) { throw UnimplementedError(); } Future sessionSendFiles( {required UuidValue sessionId, required int actId, required String path, required String to, required int fileNum, required bool includeHidden, required bool isRemote, dynamic hint}) { throw UnimplementedError(); } Future sessionSetConfirmOverrideFile( {required UuidValue sessionId, required int actId, required int fileNum, required bool needOverride, required bool remember, required bool isUpload, dynamic hint}) { throw UnimplementedError(); } Future sessionRemoveFile( {required UuidValue sessionId, required int actId, required String path, required int fileNum, required bool isRemote, dynamic hint}) { throw UnimplementedError(); } Future sessionReadDirRecursive( {required UuidValue sessionId, required int actId, required String path, required bool isRemote, required bool showHidden, dynamic hint}) { throw UnimplementedError(); } Future sessionRemoveAllEmptyDirs( {required UuidValue sessionId, required int actId, required String path, required bool isRemote, dynamic hint}) { throw UnimplementedError(); } Future sessionCancelJob( {required UuidValue sessionId, required int actId, dynamic hint}) { throw UnimplementedError(); } Future sessionCreateDir( {required UuidValue sessionId, required int actId, required String path, required bool isRemote, dynamic hint}) { throw UnimplementedError(); } Future sessionReadLocalDirSync( {required UuidValue sessionId, required String path, required bool showHidden, dynamic hint}) { throw UnimplementedError(); } Future sessionGetPlatform( {required UuidValue sessionId, required bool isRemote, dynamic hint}) { throw UnimplementedError(); } Future sessionLoadLastTransferJobs( {required UuidValue sessionId, dynamic hint}) { throw UnimplementedError(); } Future sessionAddJob( {required UuidValue sessionId, required int actId, required String path, required String to, required int fileNum, required bool includeHidden, required bool isRemote, dynamic hint}) { throw UnimplementedError(); } Future sessionResumeJob( {required UuidValue sessionId, required int actId, required bool isRemote, dynamic hint}) { throw UnimplementedError(); } Future sessionElevateDirect( {required UuidValue sessionId, dynamic hint}) { return Future(() => js.context.callMethod('setByName', ['elevate_direct'])); } Future sessionElevateWithLogon( {required UuidValue sessionId, required String username, required String password, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'elevate_with_logon', jsonEncode({'username': username, 'password': password}) ])); } Future sessionSwitchSides( {required UuidValue sessionId, dynamic hint}) { throw UnimplementedError(); } Future sessionChangeResolution( {required UuidValue sessionId, required int display, required int width, required int height, dynamic hint}) { // note: restore on disconnected throw UnimplementedError(); } Future sessionSetSize( {required UuidValue sessionId, required int display, required int width, required int height, dynamic hint}) { return Future.value(); } Future sessionSendSelectedSessionId( {required UuidValue sessionId, required String sid, dynamic hint}) { throw UnimplementedError(); } Future> mainGetSoundInputs({dynamic hint}) { throw UnimplementedError(); } Future mainGetDefaultSoundInput({dynamic hint}) { throw UnimplementedError(); } String mainGetLoginDeviceInfo({dynamic hint}) { 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']), }); } Future mainChangeId({required String newId, dynamic hint}) { throw UnimplementedError(); } Future mainGetAsyncStatus({dynamic hint}) { throw UnimplementedError(); } Future mainGetOption({required String key, dynamic hint}) { return Future.value(mainGetOptionSync(key: key)); } String mainGetOptionSync({required String key, dynamic hint}) { return js.context.callMethod('getByName', ['option', key]); } Future mainGetError({dynamic hint}) { throw UnimplementedError(); } bool mainShowOption({required String key, dynamic hint}) { throw UnimplementedError(); } Future mainSetOption( {required String key, required String value, dynamic hint}) { js.context.callMethod('setByName', [ 'option', jsonEncode({'name': key, 'value': value}) ]); return Future.value(); } // get server settings Future mainGetOptions({dynamic hint}) { return Future(() => mainGetOptionsSync()); } // get server settings String mainGetOptionsSync({dynamic hint}) { return js.context.callMethod('getByName', ['options']); } Future mainSetOptions({required String json, dynamic hint}) { return Future(() => js.context.callMethod('setByName', ['options', json])); } Future mainTestIfValidServer( {required String server, required bool testWithProxy, dynamic hint}) { // TODO: implement return Future.value(''); } Future mainSetSocks( {required String proxy, required String username, required String password, dynamic hint}) { throw UnimplementedError(); } Future> mainGetSocks({dynamic hint}) { throw UnimplementedError(); } Future mainGetAppName({dynamic hint}) { return Future.value(mainGetAppNameSync(hint: hint)); } String mainGetAppNameSync({dynamic hint}) { return 'RustDesk'; } String mainUriPrefixSync({dynamic hint}) { throw UnimplementedError(); } Future mainGetLicense({dynamic hint}) { // TODO: implement return Future(() => ''); } Future mainGetVersion({dynamic hint}) { return Future(() => js.context.callMethod('getByName', ['version'])); } Future> mainGetFav({dynamic hint}) { List favs = []; try { favs = (jsonDecode(js.context.callMethod('getByName', ['fav'])) as List) .map((e) => e.toString()) .toList(); } catch (e) { debugPrint('Failed to load favs: $e'); } return Future.value(favs); } Future mainStoreFav({required List favs, dynamic hint}) { return Future( () => js.context.callMethod('setByName', ['fav', jsonEncode(favs)])); } String mainGetPeerSync({required String id, dynamic hint}) { // TODO: throw UnimplementedError(); } Future mainGetLanPeers({dynamic hint}) { throw UnimplementedError(); } Future mainGetConnectStatus({dynamic hint}) { return Future( () => js.context.callMethod('getByName', ["get_conn_status"])); } Future mainCheckConnectStatus({dynamic hint}) { throw UnimplementedError(); } Future mainIsUsingPublicServer({dynamic hint}) { return Future(() => js.context.callMethod('getByName', ["is_using_public_server"]) == 'true'); } Future mainDiscover({dynamic hint}) { throw UnimplementedError(); } Future mainGetApiServer({dynamic hint}) { return Future(() => js.context.callMethod('getByName', ['api_server'])); } Future mainPostRequest( {required String url, required String body, required String header, dynamic hint}) { throw UnimplementedError(); } Future mainGetProxyStatus({dynamic hint}) { return Future(() => false); } Future mainHttpRequest({ required String url, required String method, String? body, required String header, dynamic hint, }) { throw UnimplementedError(); } Future mainGetHttpStatus({required String url, dynamic hint}) { throw UnimplementedError(); } String mainGetLocalOption({required String key, dynamic hint}) { return js.context.callMethod('getByName', ['option:local', key]); } String mainGetEnv({required String key, dynamic hint}) { throw UnimplementedError(); } Future mainSetLocalOption( {required String key, required String value, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:local', jsonEncode({'name': key, 'value': value}) ])); } 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"; // // flutter grab mode // export const CONFIG_INPUT_SOURCE_2 = "Input source 2"; return inputSource != '' ? inputSource : 'Input source 1'; } Future mainSetInputSource( {required UuidValue sessionId, required String value, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'option:local', jsonEncode({'name': 'input-source', 'value': value}) ])); } Future mainGetMyId({dynamic hint}) { return Future(() => js.context.callMethod('getByName', ['my_id'])); } Future mainGetUuid({dynamic hint}) { return Future(() => js.context.callMethod('getByName', ['uuid'])); } Future mainGetPeerOption( {required String id, required String key, dynamic hint}) { return Future(() => mainGetPeerOptionSync(id: id, key: key, hint: hint)); } String mainGetPeerOptionSync( {required String id, required String key, dynamic hint}) { return js.context.callMethod('getByName', [ 'option:peer', jsonEncode({'id': id, 'name': key}) ]); } String mainGetPeerFlutterOptionSync( {required String id, required String k, dynamic hint}) { return js.context.callMethod('getByName', ['option:flutter:peer', k]); } void mainSetPeerFlutterOptionSync( {required String id, required String k, required String v, dynamic hint}) { js.context.callMethod('setByName', [ 'option:flutter:peer', jsonEncode({'name': k, 'value': v}) ]); } Future mainSetPeerOption( {required String id, required String key, required String value, dynamic hint}) { mainSetPeerOptionSync(id: id, key: key, value: value, hint: hint); return Future.value(); } bool mainSetPeerOptionSync( {required String id, required String key, required String value, dynamic hint}) { js.context.callMethod('setByName', [ 'option:peer', jsonEncode({'id': id, 'name': key, 'value': value}) ]); return true; } Future mainSetPeerAlias( {required String id, required String alias, dynamic hint}) { mainSetPeerOptionSync(id: id, key: 'alias', value: alias, hint: hint); return Future.value(); } Future mainGetNewStoredPeers({dynamic hint}) { throw UnimplementedError(); } Future mainForgetPassword({required String id, dynamic hint}) { return mainSetPeerOption(id: id, key: 'password', value: ''); } Future mainPeerHasPassword({required String id, dynamic hint}) { return Future(() => js.context.callMethod('getByName', ['peer_has_password', id]) == 'true'); } Future mainPeerExists({required String id, dynamic hint}) { return Future( () => js.context.callMethod('getByName', ['peer_exists', id])); } Future mainLoadRecentPeers({dynamic hint}) { return Future( () => js.context.callMethod('getByName', ['load_recent_peers'])); } String mainLoadRecentPeersSync({dynamic hint}) { return js.context.callMethod('getByName', ['load_recent_peers_sync']); } String mainLoadLanPeersSync({dynamic hint}) { return '{}'; } Future mainLoadRecentPeersForAb( {required String filter, dynamic hint}) { throw UnimplementedError(); } Future mainLoadFavPeers({dynamic hint}) { return Future(() => js.context.callMethod('getByName', ['load_fav_peers'])); } Future mainLoadLanPeers({dynamic hint}) { throw UnimplementedError(); } Future mainRemoveDiscovered({required String id, dynamic hint}) { throw UnimplementedError(); } Future mainChangeTheme({required String dark, dynamic hint}) { throw UnimplementedError(); } Future mainChangeLanguage({required String lang, dynamic hint}) { throw UnimplementedError(); } String mainVideoSaveDirectory({required bool root, dynamic hint}) { throw UnimplementedError(); } Future mainSetUserDefaultOption( {required String key, required String value, dynamic hint}) { js.context.callMethod('setByName', [ 'option:user:default', jsonEncode({'name': key, 'value': value}) ]); return Future.value(); } String mainGetUserDefaultOption({required String key, dynamic hint}) { return js.context.callMethod('getByName', ['option:user:default', key]); } Future mainHandleRelayId({required String id, dynamic hint}) { var newId = id; if (id.endsWith("\\r") || id.endsWith("/r")) { newId = id.substring(0, id.length - 2); } return Future.value(newId); } String mainGetMainDisplay({dynamic hint}) { return js.context.callMethod('getByName', ['main_display']); } String mainGetDisplays({dynamic hint}) { throw UnimplementedError(); } Future sessionAddPortForward( {required UuidValue sessionId, required int localPort, required String remoteHost, required int remotePort, dynamic hint}) { throw UnimplementedError(); } Future sessionRemovePortForward( {required UuidValue sessionId, required int localPort, dynamic hint}) { throw UnimplementedError(); } Future sessionNewRdp({required UuidValue sessionId, dynamic hint}) { throw UnimplementedError(); } Future sessionRequestVoiceCall( {required UuidValue sessionId, dynamic hint}) { throw UnimplementedError(); } Future sessionCloseVoiceCall( {required UuidValue sessionId, dynamic hint}) { throw UnimplementedError(); } Future cmHandleIncomingVoiceCall( {required int id, required bool accept, dynamic hint}) { throw UnimplementedError(); } Future cmCloseVoiceCall({required int id, dynamic hint}) { throw UnimplementedError(); } Future mainGetLastRemoteId({dynamic hint}) { return Future( () => js.context.callMethod('getByName', ['option', 'last_remote_id'])); } Future mainGetSoftwareUpdateUrl({dynamic hint}) { throw UnimplementedError(); } Future mainGetHomeDir({dynamic hint}) { return Future.value(''); } Future mainGetLangs({dynamic hint}) { return Future(() => js.context.callMethod('getByName', ['langs'])); } Future mainGetTemporaryPassword({dynamic hint}) { return Future.value(''); } Future mainGetPermanentPassword({dynamic hint}) { return Future.value(''); } Future mainGetFingerprint({dynamic hint}) { return Future.value(''); } Future cmGetClientsState({dynamic hint}) { throw UnimplementedError(); } Future cmCheckClientsLength({required int length, dynamic hint}) { throw UnimplementedError(); } Future cmGetClientsLength({dynamic hint}) { throw UnimplementedError(); } Future mainInit({required String appDir, dynamic hint}) { return Future.value(); } Future mainDeviceId({required String id, dynamic hint}) { // TODO: ? throw UnimplementedError(); } Future mainDeviceName({required String name, dynamic hint}) { // TODO: ? throw UnimplementedError(); } Future mainRemovePeer({required String id, dynamic hint}) { return Future(() => js.context.callMethod('setByName', ['remove', id])); } bool mainHasHwcodec({dynamic hint}) { throw UnimplementedError(); } bool mainHasVram({dynamic hint}) { throw UnimplementedError(); } String mainSupportedHwdecodings({dynamic hint}) { return '{}'; } Future mainIsRoot({dynamic hint}) { throw UnimplementedError(); } int getDoubleClickTime({dynamic hint}) { throw UnimplementedError(); } Future mainStartDbusServer({dynamic hint}) { throw UnimplementedError(); } Future mainSaveAb({required String json, dynamic hint}) { throw UnimplementedError(); } Future mainClearAb({dynamic hint}) { throw UnimplementedError(); } Future mainLoadAb({dynamic hint}) { throw UnimplementedError(); } Future mainSaveGroup({required String json, dynamic hint}) { throw UnimplementedError(); } Future mainClearGroup({dynamic hint}) { throw UnimplementedError(); } Future mainLoadGroup({dynamic hint}) { throw UnimplementedError(); } Future sessionSendPointer( {required UuidValue sessionId, required String msg, dynamic hint}) { throw UnimplementedError(); } Future sessionSendMouse( {required UuidValue sessionId, required String msg, dynamic hint}) { return Future( () => js.context.callMethod('setByName', ['send_mouse', msg])); } Future sessionRestartRemoteDevice( {required UuidValue sessionId, dynamic hint}) { return Future(() => js.context.callMethod('setByName', ['restart'])); } String sessionGetAuditServerSync( {required UuidValue sessionId, required String typ, dynamic hint}) { return js.context.callMethod('getByName', ['audit_server', typ]); } Future sessionSendNote( {required UuidValue sessionId, required String note, dynamic hint}) { return Future( () => js.context.callMethod('setByName', ['send_note', note])); } Future sessionAlternativeCodecs( {required UuidValue sessionId, dynamic hint}) { return Future( () => js.context.callMethod('getByName', ['alternative_codecs'])); } Future sessionChangePreferCodec( {required UuidValue sessionId, dynamic hint}) { return Future( () => js.context.callMethod('setByName', ['change_prefer_codec'])); } Future sessionOnWaitingForImageDialogShow( {required UuidValue sessionId, dynamic hint}) { return Future.value(); } Future sessionToggleVirtualDisplay( {required UuidValue sessionId, required int index, required bool on, dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'toggle_virtual_display', jsonEncode({'index': index, 'on': on}) ])); } Future mainSetHomeDir({required String home, dynamic hint}) { throw UnimplementedError(); } String mainGetDataDirIos({dynamic hint}) { throw UnimplementedError(); } Future mainStopService({dynamic hint}) { throw UnimplementedError(); } Future mainStartService({dynamic hint}) { throw UnimplementedError(); } Future mainUpdateTemporaryPassword({dynamic hint}) { throw UnimplementedError(); } Future mainSetPermanentPassword( {required String password, dynamic hint}) { throw UnimplementedError(); } Future mainCheckSuperUserPermission({dynamic hint}) { throw UnimplementedError(); } Future mainCheckMouseTime({dynamic hint}) { throw UnimplementedError(); } Future mainGetMouseTime({dynamic hint}) { throw UnimplementedError(); } Future mainWol({required String id, dynamic hint}) { throw UnimplementedError(); } Future mainCreateShortcut({required String id, dynamic hint}) { // TODO: throw UnimplementedError(); } Future cmSendChat( {required int connId, required String msg, dynamic hint}) { throw UnimplementedError(); } Future cmLoginRes( {required int connId, required bool res, dynamic hint}) { throw UnimplementedError(); } Future cmCloseConnection({required int connId, dynamic hint}) { throw UnimplementedError(); } Future cmRemoveDisconnectedConnection( {required int connId, dynamic hint}) { throw UnimplementedError(); } Future cmCheckClickTime({required int connId, dynamic hint}) { throw UnimplementedError(); } Future cmGetClickTime({dynamic hint}) { throw UnimplementedError(); } Future cmSwitchPermission( {required int connId, required String name, required bool enabled, dynamic hint}) { throw UnimplementedError(); } bool cmCanElevate({dynamic hint}) { throw UnimplementedError(); } Future cmElevatePortable({required int connId, dynamic hint}) { throw UnimplementedError(); } Future cmSwitchBack({required int connId, dynamic hint}) { throw UnimplementedError(); } Future cmGetConfig({required String name, dynamic hint}) { throw UnimplementedError(); } Future mainGetBuildDate({dynamic hint}) { return Future(() => js.context.callMethod('getByName', ['build_date'])); } String translate( {required String name, required String locale, dynamic hint}) { return js.context.callMethod('getByName', [ 'translate', jsonEncode({'locale': locale, 'text': name}) ]); } int sessionGetRgbaSize( {required UuidValue sessionId, required int display, dynamic hint}) { return 0; } void sessionNextRgba( {required UuidValue sessionId, required int display, dynamic hint}) {} void sessionRegisterPixelbufferTexture( {required UuidValue sessionId, required int display, required int ptr, dynamic hint}) {} void sessionRegisterGpuTexture( {required UuidValue sessionId, required int display, required int ptr, dynamic hint}) {} Future queryOnlines({required List ids, dynamic hint}) { return Future(() => js.context.callMethod('setByName', ['query_onlines', jsonEncode(ids)])); } // Dup to the function in hbb_common, lib.rs // Maybe we need to move this function to js part. int versionToNumber({required String v, dynamic hint}) { return int.tryParse( js.context.callMethod('getByName', ['get_version_number', v])) ?? 0; } Future optionSynced({dynamic hint}) { return Future.value(true); } bool mainIsInstalled({dynamic hint}) { throw UnimplementedError(); } void mainInitInputSource({dynamic hint}) { throw UnimplementedError(); } bool mainIsInstalledLowerVersion({dynamic hint}) { throw UnimplementedError(); } bool mainIsInstalledDaemon({required bool prompt, dynamic hint}) { throw UnimplementedError(); } bool mainIsProcessTrusted({required bool prompt, dynamic hint}) { throw UnimplementedError(); } bool mainIsCanScreenRecording({required bool prompt, dynamic hint}) { throw UnimplementedError(); } bool mainIsCanInputMonitoring({required bool prompt, dynamic hint}) { throw UnimplementedError(); } bool mainIsShareRdp({dynamic hint}) { throw UnimplementedError(); } Future mainSetShareRdp({required bool enable, dynamic hint}) { throw UnimplementedError(); } bool mainGotoInstall({dynamic hint}) { throw UnimplementedError(); } String mainGetNewVersion({dynamic hint}) { throw UnimplementedError(); } bool mainUpdateMe({dynamic hint}) { throw UnimplementedError(); } Future setCurSessionId({required UuidValue sessionId, dynamic hint}) { throw UnimplementedError(); } bool installShowRunWithoutInstall({dynamic hint}) { throw UnimplementedError(); } Future installRunWithoutInstall({dynamic hint}) { throw UnimplementedError(); } Future installInstallMe( {required String options, required String path, dynamic hint}) { throw UnimplementedError(); } String installInstallPath({dynamic hint}) { throw UnimplementedError(); } Future mainAccountAuth( {required String op, required bool rememberMe, dynamic hint}) { throw UnimplementedError(); } Future mainAccountAuthCancel({dynamic hint}) { throw UnimplementedError(); } Future mainAccountAuthResult({dynamic hint}) { throw UnimplementedError(); } Future mainOnMainWindowClose({dynamic hint}) { throw UnimplementedError(); } bool mainCurrentIsWayland({dynamic hint}) { return false; } bool mainIsLoginWayland({dynamic hint}) { return false; } bool mainHideDock({dynamic hint}) { throw UnimplementedError(); } bool mainHasFileClipboard({dynamic hint}) { return false; } bool mainHasGpuTextureRender({dynamic hint}) { return false; } Future cmInit({dynamic hint}) { throw UnimplementedError(); } Future mainStartIpcUrlServer({dynamic hint}) { throw UnimplementedError(); } Future mainTestWallpaper({required int second, dynamic hint}) { // TODO: implement mainTestWallpaper return Future.value(); } Future mainSupportRemoveWallpaper({dynamic hint}) { // TODO: implement mainSupportRemoveWallpaper return Future.value(false); } bool isIncomingOnly({dynamic hint}) { return false; } bool isOutgoingOnly({dynamic hint}) { return false; } bool isCustomClient({dynamic hint}) { return false; } bool isDisableSettings({dynamic hint}) { return false; } bool isDisableAb({dynamic hint}) { return false; } bool isDisableGroupPanel({dynamic hint}) { return false; } bool isDisableAccount({dynamic hint}) { return false; } bool isDisableInstallation({dynamic hint}) { return false; } Future isPresetPassword({dynamic hint}) { return Future.value(false); } Future sendUrlScheme({required String url, dynamic hint}) { throw UnimplementedError(); } Future pluginEvent( {required String id, required String peer, required Uint8List event, dynamic hint}) { throw UnimplementedError(); } Stream pluginRegisterEventStream( {required String id, dynamic hint}) { throw UnimplementedError(); } String? pluginGetSessionOption( {required String id, required String peer, required String key, dynamic hint}) { throw UnimplementedError(); } Future pluginSetSessionOption( {required String id, required String peer, required String key, required String value, dynamic hint}) { throw UnimplementedError(); } String? pluginGetSharedOption( {required String id, required String key, dynamic hint}) { throw UnimplementedError(); } Future pluginSetSharedOption( {required String id, required String key, required String value, dynamic hint}) { throw UnimplementedError(); } Future pluginReload({required String id, dynamic hint}) { throw UnimplementedError(); } void pluginEnable({required String id, required bool v, dynamic hint}) { throw UnimplementedError(); } bool pluginIsEnabled({required String id, dynamic hint}) { throw UnimplementedError(); } bool pluginFeatureIsEnabled({dynamic hint}) { throw UnimplementedError(); } Future pluginSyncUi({required String syncTo, dynamic hint}) { throw UnimplementedError(); } Future pluginListReload({dynamic hint}) { throw UnimplementedError(); } Future pluginInstall( {required String id, required bool b, dynamic hint}) { throw UnimplementedError(); } bool isSupportMultiUiSession({required String version, dynamic hint}) { return versionToNumber(v: version) > versionToNumber(v: '1.2.4'); } bool isSelinuxEnforcing({dynamic hint}) { return false; } String mainDefaultPrivacyModeImpl({dynamic hint}) { throw UnimplementedError(); } String mainSupportedPrivacyModeImpls({dynamic hint}) { throw UnimplementedError(); } String mainSupportedInputSource({dynamic hint}) { return jsonEncode([ ['Input source 1', 'input_source_1_tip'], ['Input source 2', 'input_source_2_tip'] ]); } Future mainGenerate2Fa({dynamic hint}) { throw UnimplementedError(); } Future mainVerify2Fa({required String code, dynamic hint}) { throw UnimplementedError(); } bool mainHasValid2FaSync({dynamic hint}) { throw UnimplementedError(); } String mainGetHardOption({required String key, dynamic hint}) { throw UnimplementedError(); } Future mainCheckHwcodec({dynamic hint}) { throw UnimplementedError(); } Future sessionRequestNewDisplayInitMsgs( {required UuidValue sessionId, required int display, dynamic hint}) { throw UnimplementedError(); } Future mainHandleWaylandScreencastRestoreToken( {required String key, required String value, dynamic hint}) { throw UnimplementedError(); } bool mainIsOptionFixed({required String key, dynamic hint}) { return false; } bool mainGetUseTextureRender({dynamic hint}) { throw UnimplementedError(); } bool mainHasValidBotSync({dynamic hint}) { throw UnimplementedError(); } Future mainVerifyBot({required String token, dynamic hint}) { throw UnimplementedError(); } String mainGetUnlockPin({dynamic hint}) { throw UnimplementedError(); } String mainSetUnlockPin({required String pin, dynamic hint}) { throw UnimplementedError(); } bool sessionGetEnableTrustedDevices( {required UuidValue sessionId, dynamic hint}) { return js.context.callMethod('getByName', ['enable_trusted_devices']) == 'Y'; } Future mainGetTrustedDevices({dynamic hint}) { throw UnimplementedError(); } Future mainRemoveTrustedDevices({required String json, dynamic hint}) { throw UnimplementedError(); } Future mainClearTrustedDevices({dynamic hint}) { throw UnimplementedError(); } Future getVoiceCallInputDevice({required bool isCm, dynamic hint}) { throw UnimplementedError(); } Future setVoiceCallInputDevice( {required bool isCm, required String device, dynamic hint}) { throw UnimplementedError(); } bool isPresetPasswordMobileOnly({dynamic hint}) { throw UnimplementedError(); } String mainGetBuildinOption({required String key, dynamic hint}) { return ''; } String installInstallOptions({dynamic hint}) { throw UnimplementedError(); } int mainMaxEncryptLen({dynamic hint}) { throw UnimplementedError(); } sessionRenameFile( {required UuidValue sessionId, required int actId, required String path, required String newName, required bool isRemote, dynamic hint}) { throw UnimplementedError(); } void dispose() {} }