mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 02:57:22 +00:00
demo: use mobile_ffi to get id for desktop version
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'package:device_info/device_info.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
import 'package:external_path/external_path.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import '../generated_bridge.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import '../common.dart';
|
||||
import '../generated_bridge.dart';
|
||||
|
||||
class RgbaFrame extends Struct {
|
||||
@Uint32()
|
||||
@@ -60,13 +62,19 @@ class PlatformFFI {
|
||||
isIOS = Platform.isIOS;
|
||||
isAndroid = Platform.isAndroid;
|
||||
isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
||||
if (isDesktop) {
|
||||
// TODO
|
||||
return;
|
||||
}
|
||||
// if (isDesktop) {
|
||||
// // TODO
|
||||
// return;
|
||||
// }
|
||||
final dylib = Platform.isAndroid
|
||||
? DynamicLibrary.open('librustdesk.so')
|
||||
: DynamicLibrary.process();
|
||||
: Platform.isLinux
|
||||
? DynamicLibrary.open("/usr/lib/rustdesk/librustdesk.so")
|
||||
: Platform.isWindows
|
||||
? DynamicLibrary.open("librustdesk.dll")
|
||||
: Platform.isMacOS
|
||||
? DynamicLibrary.open("librustdesk.dylib")
|
||||
: DynamicLibrary.process();
|
||||
print('initializing FFI');
|
||||
try {
|
||||
_getByName = dylib.lookupFunction<F2, F2>('get_by_name');
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
|
||||
import '../common.dart';
|
||||
import '../mobile/pages/server_page.dart';
|
||||
import 'model.dart';
|
||||
@@ -203,7 +206,10 @@ class ServerModel with ChangeNotifier {
|
||||
FFI.setByName("start_service");
|
||||
getIDPasswd();
|
||||
updateClientState();
|
||||
Wakelock.enable();
|
||||
if (!Platform.isLinux) {
|
||||
// current linux is not supported
|
||||
Wakelock.enable();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Null> stopService() async {
|
||||
@@ -212,7 +218,10 @@ class ServerModel with ChangeNotifier {
|
||||
await FFI.invokeMethod("stop_service");
|
||||
FFI.setByName("stop_service");
|
||||
notifyListeners();
|
||||
Wakelock.disable();
|
||||
if (!Platform.isLinux) {
|
||||
// current linux is not supported
|
||||
Wakelock.disable();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Null> initInput() async {
|
||||
|
||||
Reference in New Issue
Block a user