mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 11:06:57 +00:00
Merge branch 'master' of https://github.com/rustdesk/rustdesk into opt_chat_overlay_and_fix_pageview_2
This commit is contained in:
@@ -3,14 +3,11 @@ import 'dart:convert';
|
||||
import 'dart:ffi' hide Size;
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:back_button_interceptor/back_button_interceptor.dart';
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_hbb/utils/platform_channel.dart';
|
||||
import 'package:win32/win32.dart' as win32;
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -19,14 +16,17 @@ 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:flutter_hbb/utils/platform_channel.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:uni_links/uni_links.dart';
|
||||
import 'package:uni_links_desktop/uni_links_desktop.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:window_size/window_size.dart' as window_size;
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:win32/win32.dart' as win32;
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
import 'package:window_size/window_size.dart' as window_size;
|
||||
|
||||
import '../consts.dart';
|
||||
import 'common/widgets/overlay.dart';
|
||||
import 'mobile/pages/file_manager_page.dart';
|
||||
import 'mobile/pages/remote_page.dart';
|
||||
@@ -34,8 +34,6 @@ import 'models/input_model.dart';
|
||||
import 'models/model.dart';
|
||||
import 'models/platform_model.dart';
|
||||
|
||||
import '../consts.dart';
|
||||
|
||||
final globalKey = GlobalKey<NavigatorState>();
|
||||
final navigationBarKey = GlobalKey();
|
||||
|
||||
@@ -702,7 +700,6 @@ void msgBox(String id, String type, String title, String text, String link,
|
||||
buttons.insert(
|
||||
0, dialogButton('Cancel', onPressed: cancel, isOutline: true));
|
||||
}
|
||||
// TODO: test this button
|
||||
if (type.contains("hasclose")) {
|
||||
buttons.insert(
|
||||
0,
|
||||
@@ -716,8 +713,7 @@ void msgBox(String id, String type, String title, String text, String link,
|
||||
dialogManager.show(
|
||||
(setState, close) => CustomAlertDialog(
|
||||
title: null,
|
||||
content: SelectionArea(
|
||||
child: msgboxContent(type, title, text).paddingOnly(bottom: 10)),
|
||||
content: SelectionArea(child: msgboxContent(type, title, text)),
|
||||
actions: buttons,
|
||||
onSubmit: hasOk ? submit : null,
|
||||
onCancel: hasCancel == true ? cancel : null,
|
||||
@@ -782,7 +778,7 @@ Widget msgboxContent(String type, String title, String text) {
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
).marginOnly(bottom: 12);
|
||||
}
|
||||
|
||||
void msgBoxCommon(OverlayDialogManager dialogManager, String title,
|
||||
@@ -1280,10 +1276,12 @@ Future<bool> restoreWindowPosition(WindowType type, {int? windowId}) async {
|
||||
/// [Availability]
|
||||
/// initUniLinks should only be used on macos/windows.
|
||||
/// we use dbus for linux currently.
|
||||
Future<void> initUniLinks() async {
|
||||
if (!Platform.isWindows && !Platform.isMacOS) {
|
||||
return;
|
||||
Future<bool> initUniLinks() async {
|
||||
if (Platform.isLinux) {
|
||||
return false;
|
||||
}
|
||||
// Register uni links for Windows. The required info of url scheme is already
|
||||
// declared in `Info.plist` for macOS.
|
||||
if (Platform.isWindows) {
|
||||
registerProtocol('rustdesk');
|
||||
}
|
||||
@@ -1291,22 +1289,33 @@ Future<void> initUniLinks() async {
|
||||
try {
|
||||
final initialLink = await getInitialLink();
|
||||
if (initialLink == null) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
parseRustdeskUri(initialLink);
|
||||
return parseRustdeskUri(initialLink);
|
||||
} catch (err) {
|
||||
debugPrintStack(label: "$err");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
StreamSubscription? listenUniLinks() {
|
||||
if (!(Platform.isWindows || Platform.isMacOS)) {
|
||||
/// Listen for uni links.
|
||||
///
|
||||
/// * handleByFlutter: Should uni links be handled by Flutter.
|
||||
///
|
||||
/// Returns a [StreamSubscription] which can listen the uni links.
|
||||
StreamSubscription? listenUniLinks({handleByFlutter = true}) {
|
||||
if (Platform.isLinux) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final sub = uriLinkStream.listen((Uri? uri) {
|
||||
debugPrint("A uri was received: $uri.");
|
||||
if (uri != null) {
|
||||
callUniLinksUriHandler(uri);
|
||||
if (handleByFlutter) {
|
||||
callUniLinksUriHandler(uri);
|
||||
} else {
|
||||
bind.sendUrlScheme(url: uri.toString());
|
||||
}
|
||||
} else {
|
||||
print("uni listen error: uri is empty.");
|
||||
}
|
||||
@@ -1316,11 +1325,19 @@ StreamSubscription? listenUniLinks() {
|
||||
return sub;
|
||||
}
|
||||
|
||||
/// Returns true if we successfully handle the startup arguments.
|
||||
/// Handle command line arguments
|
||||
///
|
||||
/// * Returns true if we successfully handle the startup arguments.
|
||||
bool checkArguments() {
|
||||
if (kBootArgs.isNotEmpty) {
|
||||
final ret = parseRustdeskUri(kBootArgs.first);
|
||||
if (ret) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// bootArgs:[--connect, 362587269, --switch_uuid, e3d531cc-5dce-41e0-bd06-5d4a2b1eec05]
|
||||
// check connect args
|
||||
final connectIndex = kBootArgs.indexOf("--connect");
|
||||
var connectIndex = kBootArgs.indexOf("--connect");
|
||||
if (connectIndex == -1) {
|
||||
return false;
|
||||
}
|
||||
@@ -1355,7 +1372,7 @@ bool checkArguments() {
|
||||
bool parseRustdeskUri(String uriPath) {
|
||||
final uri = Uri.tryParse(uriPath);
|
||||
if (uri == null) {
|
||||
print("uri is not valid: $uriPath");
|
||||
debugPrint("uri is not valid: $uriPath");
|
||||
return false;
|
||||
}
|
||||
return callUniLinksUriHandler(uri);
|
||||
@@ -1374,7 +1391,7 @@ bool callUniLinksUriHandler(Uri uri) {
|
||||
Future.delayed(Duration.zero, () {
|
||||
rustDeskWinManager.newRemoteDesktop(peerId, switch_uuid: switch_uuid);
|
||||
});
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1514,8 +1531,12 @@ Future<void> onActiveWindowChanged() async {
|
||||
} catch (err) {
|
||||
debugPrintStack(label: "$err");
|
||||
} finally {
|
||||
debugPrint("Start closing RustDesk...");
|
||||
await windowManager.setPreventClose(false);
|
||||
await windowManager.close();
|
||||
if (Platform.isMacOS) {
|
||||
RdPlatformChannel.instance.terminate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1708,3 +1729,30 @@ Future<void> updateSystemWindowTheme() async {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// macOS only
|
||||
///
|
||||
/// Note: not found a general solution for rust based AVFoundation bingding.
|
||||
/// [AVFoundation] crate has compile error.
|
||||
const kMacOSPermChannel = MethodChannel("org.rustdesk.rustdesk/macos");
|
||||
|
||||
enum PermissionAuthorizeType {
|
||||
undetermined,
|
||||
authorized,
|
||||
denied, // and restricted
|
||||
}
|
||||
|
||||
Future<PermissionAuthorizeType> osxCanRecordAudio() async {
|
||||
int res = await kMacOSPermChannel.invokeMethod("canRecordAudio");
|
||||
print(res);
|
||||
if (res > 0) {
|
||||
return PermissionAuthorizeType.authorized;
|
||||
} else if (res == 0) {
|
||||
return PermissionAuthorizeType.undetermined;
|
||||
} else {
|
||||
return PermissionAuthorizeType.denied;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> osxRequestAudio() async {
|
||||
return await kMacOSPermChannel.invokeMethod("requestRecordAudio");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user