mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-10 10:41:28 +03:00
feat: add dbus and cli connect support
This commit is contained in:
@@ -10,6 +10,7 @@ import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||
import 'package:flutter_hbb/main.dart';
|
||||
import 'package:flutter_hbb/models/peer_model.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -1128,6 +1129,19 @@ Future<bool> restoreWindowPosition(WindowType type, {int? windowId}) async {
|
||||
return false;
|
||||
}
|
||||
|
||||
void checkArguments() {
|
||||
// check connect args
|
||||
final connectIndex = bootArgs.indexOf("--connect");
|
||||
if (connectIndex == -1) {
|
||||
return;
|
||||
}
|
||||
String? peerId = bootArgs.length < connectIndex + 1 ? null: bootArgs[connectIndex + 1];
|
||||
if (peerId != null) {
|
||||
rustDeskWinManager.newRemoteDesktop(peerId);
|
||||
bootArgs.removeAt(connectIndex); bootArgs.removeAt(connectIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/// Connect to a peer with [id].
|
||||
/// If [isFileTransfer], starts a session only for file transfer.
|
||||
/// If [isTcpTunneling], starts a session only for tcp tunneling.
|
||||
|
||||
@@ -452,6 +452,9 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
}
|
||||
}
|
||||
});
|
||||
Future.delayed(Duration.zero, () {
|
||||
checkArguments();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -24,10 +24,12 @@ import 'mobile/pages/server_page.dart';
|
||||
import 'models/platform_model.dart';
|
||||
|
||||
int? windowId;
|
||||
late List<String> bootArgs;
|
||||
|
||||
Future<void> main(List<String> args) async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
debugPrint("launch args: $args");
|
||||
bootArgs = args;
|
||||
|
||||
if (!isDesktop) {
|
||||
runMobileApp();
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:flutter_hbb/models/chat_model.dart';
|
||||
import 'package:flutter_hbb/models/file_model.dart';
|
||||
import 'package:flutter_hbb/models/server_model.dart';
|
||||
import 'package:flutter_hbb/models/user_model.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
import 'package:flutter_custom_cursor/flutter_custom_cursor.dart';
|
||||
@@ -176,6 +177,9 @@ class FfiModel with ChangeNotifier {
|
||||
updateBlockInputState(evt, peerId);
|
||||
} else if (name == 'update_privacy_mode') {
|
||||
updatePrivacyMode(evt, peerId);
|
||||
} else if (name == 'new_connection') {
|
||||
final remoteId = evt['peer_id'];
|
||||
rustDeskWinManager.newRemoteDesktop(remoteId);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -113,6 +113,10 @@ class PlatformFFI {
|
||||
debugPrint('Failed to get documents directory: $e');
|
||||
}
|
||||
_ffiBind = RustdeskImpl(dylib);
|
||||
if (Platform.isLinux) {
|
||||
// start dbus service, no need to await
|
||||
await _ffiBind.mainStartDbusServer();
|
||||
}
|
||||
_startListenEvent(_ffiBind); // global event
|
||||
try {
|
||||
if (isAndroid) {
|
||||
|
||||
Reference in New Issue
Block a user