mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
demo: use mobile_ffi to get id for desktop version
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/models/model.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DesktopHomePage extends StatefulWidget {
|
||||
DesktopHomePage({Key? key}) : super(key: key);
|
||||
@@ -10,6 +13,75 @@ class DesktopHomePage extends StatefulWidget {
|
||||
class _DesktopHomePageState extends State<DesktopHomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text("Hello Desktop");
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: buildServerInfo(context),
|
||||
flex: 1,
|
||||
),
|
||||
Flexible(
|
||||
child: buildServerBoard(context),
|
||||
flex: 4,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
buildServerInfo(BuildContext context) {
|
||||
return ChangeNotifierProvider.value(
|
||||
value: FFI.serverModel,
|
||||
child: Column(
|
||||
children: [buildIDBoard(context)],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
buildServerBoard(BuildContext context) {
|
||||
return Center(
|
||||
child: Text("waiting implementation"),
|
||||
);
|
||||
}
|
||||
|
||||
buildIDBoard(BuildContext context) {
|
||||
final model = FFI.serverModel;
|
||||
return Card(
|
||||
elevation: 0.5,
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
children: [
|
||||
Container(
|
||||
width: 4,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(color: MyTheme.accent),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
translate("ID"),
|
||||
style:
|
||||
TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
|
||||
),
|
||||
TextFormField(
|
||||
controller: model.serverId,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
|
||||
import 'common.dart';
|
||||
import 'models/model.dart';
|
||||
import 'mobile/pages/home_page.dart';
|
||||
import 'mobile/pages/server_page.dart';
|
||||
import 'mobile/pages/settings_page.dart';
|
||||
import 'models/model.dart';
|
||||
|
||||
Future<Null> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
@@ -20,6 +17,10 @@ Future<Null> main() async {
|
||||
toAndroidChannelInit();
|
||||
}
|
||||
refreshCurrentUser();
|
||||
if (isDesktop) {
|
||||
print("desktop mode: starting service");
|
||||
FFI.serverModel.startService();
|
||||
}
|
||||
runApp(App());
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -7,7 +7,7 @@ import Foundation
|
||||
|
||||
import firebase_analytics
|
||||
import firebase_core
|
||||
import package_info
|
||||
import package_info_plus_macos
|
||||
import path_provider_macos
|
||||
import shared_preferences_macos
|
||||
import url_launcher_macos
|
||||
@@ -16,7 +16,7 @@ import wakelock_macos
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FLTFirebaseAnalyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAnalyticsPlugin"))
|
||||
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
|
||||
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
|
||||
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
|
||||
@@ -347,13 +347,48 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
package_info:
|
||||
package_info_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: package_info
|
||||
name: package_info_plus
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
version: "1.4.2"
|
||||
package_info_plus_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
package_info_plus_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
package_info_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
package_info_plus_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
package_info_plus_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -37,7 +37,7 @@ dependencies:
|
||||
wakelock: ^0.5.2
|
||||
device_info: ^2.0.2
|
||||
firebase_analytics: ^9.1.5
|
||||
package_info: ^2.0.2
|
||||
package_info_plus: ^1.4.2
|
||||
url_launcher: ^6.0.9
|
||||
shared_preferences: ^2.0.6
|
||||
toggle_switch: ^1.4.0
|
||||
|
||||
Reference in New Issue
Block a user