From 4d2feb60303ed24452e8c0bb2d3d4068608455c9 Mon Sep 17 00:00:00 2001 From: Asura Date: Tue, 13 Sep 2022 19:30:57 -0700 Subject: [PATCH 1/3] Add polkit to build.py --- build.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.py b/build.py index 27b5af744..97b1c02f9 100755 --- a/build.py +++ b/build.py @@ -142,12 +142,12 @@ def build_flutter_deb(version): os.chdir('flutter') os.system('dpkg-deb -R rustdesk.deb tmpdeb') os.system('flutter build linux --release') - os.system('strip build/linux/x64/release/liblibrustdesk.so') os.system('mkdir -p tmpdeb/usr/bin/') os.system('mkdir -p tmpdeb/usr/lib/rustdesk') os.system('mkdir -p tmpdeb/usr/share/rustdesk/files/systemd/') os.system('mkdir -p tmpdeb/usr/share/applications/') + os.system('mkdir -p tmpdeb/usr/share/polkit-1/actions') os.system( 'cp -r build/linux/x64/release/bundle/* tmpdeb/usr/lib/rustdesk/') @@ -163,6 +163,10 @@ def build_flutter_deb(version): 'cp ../128x128@2x.png tmpdeb/usr/share/rustdesk/files/rustdesk.png') os.system( 'cp ../rustdesk.desktop tmpdeb/usr/share/applications/rustdesk.desktop') + os.system( + 'cp ../com.rustdesk.RustDesk.policy tmpdeb/usr/share/polkit-1/actions/') + os.system("echo \"#!/bin/sh\" >> tmpdeb/usr/share/rustdesk/files/polkit && chmod a+x tmpdeb/usr/share/rustdesk/files/polkit") + os.system('mkdir -p tmpdeb/DEBIAN') generate_control_file(version) os.system('cp -a ../DEBIAN/* tmpdeb/DEBIAN/') From e6b1b007a6efe615f60ff0b31b60fd9c3c387730 Mon Sep 17 00:00:00 2001 From: Asura Date: Wed, 14 Sep 2022 02:37:52 -0700 Subject: [PATCH 2/3] Fix compile on android --- Cargo.lock | 2 +- flutter/pubspec.lock | 14 +++++++------- src/flutter_ffi.rs | 20 ++++++++++++-------- src/ui_interface.rs | 1 + src/ui_session_interface.rs | 30 +++++++++++++++++++++++------- 5 files changed, 44 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a6abcaf7..aa6d98497 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3975,7 +3975,7 @@ dependencies = [ [[package]] name = "rdev" version = "0.5.0-2" -source = "git+https://github.com/asur4s/rdev#0ad53987fa6f0e37a7bc000358f71c3802de4e7c" +source = "git+https://github.com/asur4s/rdev#22c737fe4dadb7f16c8ded2c13bd6f578a1db4ce" dependencies = [ "cocoa", "core-foundation 0.9.3", diff --git a/flutter/pubspec.lock b/flutter/pubspec.lock index 251d3dacb..c0004499e 100644 --- a/flutter/pubspec.lock +++ b/flutter/pubspec.lock @@ -70,7 +70,7 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.3.1" build_config: dependency: transitive description: @@ -91,21 +91,21 @@ packages: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "2.0.9" + version: "2.0.10" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.2.1" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "7.2.3" + version: "7.2.4" built_collection: dependency: transitive description: @@ -418,8 +418,8 @@ packages: dependency: "direct main" description: path: "." - ref: "9021e21de36c84edf01d5034f38eda580463163b" - resolved-ref: "9021e21de36c84edf01d5034f38eda580463163b" + ref: "47179378523c993092f70d95f93d53f40af01f02" + resolved-ref: "47179378523c993092f70d95f93d53f40af01f02" url: "https://github.com/Kingtous/rustdesk_flutter_custom_cursor" source: git version: "0.0.1" @@ -973,7 +973,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "1.2.2" + version: "1.2.3" source_span: dependency: transitive description: diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 568096b1c..c3b71e4c9 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -17,14 +17,15 @@ use crate::flutter::{self, SESSIONS}; use crate::start_server; use crate::ui_interface; #[cfg(not(any(target_os = "android", target_os = "ios")))] +use crate::ui_interface::{change_id, get_sound_inputs}; use crate::ui_interface::{ - change_id, check_mouse_time, check_super_user_permission, discover, forget_password, - get_api_server, get_app_name, get_async_job_status, get_connect_status, get_fav, get_id, - get_lan_peers, get_langs, get_license, get_local_option, get_mouse_time, get_option, - get_options, get_peer, get_peer_option, get_socks, get_sound_inputs, get_uuid, get_version, - has_hwcodec, has_rendezvous_service, post_request, send_to_cm, set_local_option, set_option, - set_options, set_peer_option, set_permanent_password, set_socks, store_fav, - test_if_valid_server, update_temporary_password, using_public_server, + check_mouse_time, check_super_user_permission, discover, forget_password, get_api_server, + get_app_name, get_async_job_status, get_connect_status, get_fav, get_id, get_lan_peers, + get_langs, get_license, get_local_option, get_mouse_time, get_option, get_options, get_peer, + get_peer_option, get_socks, get_uuid, get_version, has_hwcodec, has_rendezvous_service, + post_request, send_to_cm, set_local_option, set_option, set_options, set_peer_option, + set_permanent_password, set_socks, store_fav, test_if_valid_server, update_temporary_password, + using_public_server, }; use crate::{ client::file_trait::FileManager, @@ -431,7 +432,10 @@ pub fn session_resume_job(id: String, act_id: i32, is_remote: bool) { } pub fn main_get_sound_inputs() -> Vec { - get_sound_inputs() + #[cfg(not(any(target_os = "android", target_os = "ios")))] + return get_sound_inputs(); + #[cfg(any(target_os = "android", target_os = "linux"))] + vec![String::from("")] } pub fn main_change_id(new_id: String) { diff --git a/src/ui_interface.rs b/src/ui_interface.rs index af7e8ba05..90afb8c43 100644 --- a/src/ui_interface.rs +++ b/src/ui_interface.rs @@ -223,6 +223,7 @@ pub fn test_if_valid_server(host: String) -> String { } #[inline] +#[cfg(not(any(target_os = "android", target_os = "ios")))] pub fn get_sound_inputs() -> Vec { let mut a = Vec::new(); #[cfg(not(target_os = "linux"))] diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index 945c45385..692b592d4 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -11,7 +11,9 @@ use async_trait::async_trait; use hbb_common::config::{Config, LocalConfig, PeerConfig}; use hbb_common::rendezvous_proto::ConnType; use hbb_common::tokio::{self, sync::mpsc}; -use rdev::{Event, EventType::*, Key as RdevKey, Keyboard as RdevKeyboard, KeyboardState}; +use rdev::{Event, EventType::*, Key as RdevKey, KeyboardState}; +#[cfg(not(any(target_os = "android", target_os = "ios")))] +use rdev::Keyboard as RdevKeyboard; use hbb_common::{allow_err, message_proto::*}; use hbb_common::{fs, get_version_number, log, Stream}; @@ -27,9 +29,12 @@ pub static KEYBOARD_HOOKED: AtomicBool = AtomicBool::new(true); #[cfg(windows)] static mut IS_ALT_GR: bool = false; -#[cfg(not(any(target_os = "android", target_os = "ios")))] lazy_static::lazy_static! { static ref TO_RELEASE: Arc>> = Arc::new(Mutex::new(HashSet::::new())); +} + +#[cfg(not(any(target_os = "android", target_os = "ios")))] +lazy_static::lazy_static! { static ref KEYBOARD: Arc> = Arc::new(Mutex::new(RdevKeyboard::new().unwrap())); } @@ -268,6 +273,7 @@ impl Session { #[allow(dead_code)] fn convert_numpad_keys(&self, key: RdevKey) -> RdevKey { + #[cfg(not(any(target_os = "android", target_os = "ios")))] if get_key_state(enigo::Key::NumLock) { return key; } @@ -315,10 +321,11 @@ impl Session { key_event.set_chr(keycode); key_event.down = down_or_up; - + #[cfg(not(any(target_os = "android", target_os = "ios")))] if get_key_state(enigo::Key::CapsLock) { key_event.modifiers.push(ControlKey::CapsLock.into()); } + #[cfg(not(any(target_os = "android", target_os = "ios")))] if get_key_state(enigo::Key::NumLock) { key_event.modifiers.push(ControlKey::NumLock.into()); } @@ -326,6 +333,7 @@ impl Session { self.send_key_event(key_event, KeyboardMode::Map); } + #[cfg(not(any(target_os = "android", target_os = "ios")))] fn translate_keyboard_mode(&self, down_or_up: bool, key: RdevKey, evt: Event) { // translate mode(2): locally generated characters are send to the peer. @@ -407,10 +415,11 @@ impl Session { { key_event.modifiers.push(ControlKey::Meta.into()); } - + #[cfg(not(any(target_os = "android", target_os = "ios")))] if get_key_state(enigo::Key::CapsLock) { key_event.modifiers.push(ControlKey::CapsLock.into()); } + #[cfg(not(any(target_os = "android", target_os = "ios")))] if self.peer_platform() != "Mac OS" { if get_key_state(enigo::Key::NumLock) { key_event.modifiers.push(ControlKey::NumLock.into()); @@ -418,6 +427,7 @@ impl Session { } } + #[cfg(not(any(target_os = "android", target_os = "ios")))] fn legacy_keyboard_mode(&self, down_or_up: bool, key: RdevKey, evt: Event) { // legacy mode(0): Generate characters locally, look for keycode on other side. let peer = self.peer_platform(); @@ -648,11 +658,18 @@ impl Session { } self.map_keyboard_mode(down_or_up, key, Some(evt)); } - KeyboardMode::Legacy => self.legacy_keyboard_mode(down_or_up, key, evt), + KeyboardMode::Legacy => { + #[cfg(not(any(target_os = "android", target_os = "ios")))] + self.legacy_keyboard_mode(down_or_up, key, evt) + }, KeyboardMode::Translate => { + #[cfg(not(any(target_os = "android", target_os = "ios")))] self.translate_keyboard_mode(down_or_up, key, evt); } - _ => self.legacy_keyboard_mode(down_or_up, key, evt), + _ => { + #[cfg(not(any(target_os = "android", target_os = "ios")))] + self.legacy_keyboard_mode(down_or_up, key, evt) + }, } } @@ -742,7 +759,6 @@ impl Session { let keycode: u32 = keycode as u32; let scancode: u32 = scancode as u32; - #[cfg(not(target_os = "windows"))] let key = rdev::key_from_scancode(scancode) as RdevKey; // Windows requires special handling #[cfg(target_os = "windows")] From 9502a2eddc3e3906cdfeacbafa65e1f04aedb8a0 Mon Sep 17 00:00:00 2001 From: Asura Date: Wed, 14 Sep 2022 05:31:19 -0700 Subject: [PATCH 3/3] Fix altgr of Korean --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index aa6d98497..e4b5d2792 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3975,7 +3975,7 @@ dependencies = [ [[package]] name = "rdev" version = "0.5.0-2" -source = "git+https://github.com/asur4s/rdev#22c737fe4dadb7f16c8ded2c13bd6f578a1db4ce" +source = "git+https://github.com/asur4s/rdev#bff57a29e3f14d032ab7441b2d6cf029df8adaca" dependencies = [ "cocoa", "core-foundation 0.9.3",