mobile build

This commit is contained in:
csf 2022-09-01 18:23:06 +08:00
parent ee83987523
commit a435fc999a
3 changed files with 19 additions and 6 deletions

View File

@ -11,7 +11,6 @@ use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait},
Device, Host, StreamConfig,
};
use enigo::{Enigo, KeyboardControllable};
use magnum_opus::{Channels::*, Decoder as AudioDecoder};
use sha2::{Digest, Sha256};
use uuid::Uuid;
@ -38,7 +37,6 @@ use hbb_common::{
};
pub use helper::LatencyController;
pub use helper::*;
use scrap::Image;
use scrap::{
codec::{Decoder, DecoderCfg},
VpxDecoderConfig, VpxVideoCodecId,
@ -61,14 +59,17 @@ pub struct Client;
#[cfg(not(any(target_os = "android", target_os = "linux")))]
lazy_static::lazy_static! {
static ref AUDIO_HOST: Host = cpal::default_host();
static ref AUDIO_HOST: Host = cpal::default_host();
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
lazy_static::lazy_static! {
static ref ENIGO: Arc<Mutex<Enigo>> = Arc::new(Mutex::new(Enigo::new()));
static ref ENIGO: Arc<Mutex<enigo::Enigo>> = Arc::new(Mutex::new(enigo::Enigo::new()));
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn get_key_state(key: enigo::Key) -> bool {
use enigo::KeyboardControllable;
#[cfg(target_os = "macos")]
if key == enigo::Key::NumLock {
return true;

View File

@ -2,6 +2,7 @@ use crate::client::{
Client, CodecFormat, FileManager, MediaData, MediaSender, QualityStatus, MILLI1, SEC30,
SERVER_CLIPBOARD_ENABLED, SERVER_FILE_TRANSFER_ENABLED, SERVER_KEYBOARD_ENABLED,
};
#[cfg(not(any(target_os = "android", target_os = "ios")))]
use crate::common::{check_clipboard, update_clipboard, ClipboardContext, CLIPBOARD_INTERVAL};
use crate::ui_session_interface::{InvokeUi, Session};
@ -235,6 +236,7 @@ impl<T: InvokeUi> Remote<T> {
let old_clipboard = self.old_clipboard.clone();
let tx_protobuf = self.sender.clone();
let lc = self.handler.lc.clone();
#[cfg(not(any(target_os = "android", target_os = "ios")))]
match ClipboardContext::new() {
Ok(mut ctx) => {
// ignore clipboard update before service start
@ -266,6 +268,7 @@ impl<T: InvokeUi> Remote<T> {
Some(tx)
}
// TODO
fn load_last_jobs(&mut self) {
log::info!("start load last jobs");
self.handler.clear_all_jobs();

View File

@ -1,11 +1,12 @@
use crate::client::io_loop::Remote;
use crate::client::{
check_if_retry, get_key_state, handle_hash, handle_login_from_ui, handle_test_delay,
check_if_retry, handle_hash, handle_login_from_ui, handle_test_delay,
input_os_password, load_config, send_mouse, start_video_audio_threads, FileManager, Key,
LoginConfigHandler, QualityStatus, KEY_MAP, SERVER_KEYBOARD_ENABLED,
};
#[cfg(not(any(target_os = "android", target_os = "ios")))]
use crate::client::get_key_state;
use crate::common;
use crate::{client::Data, client::Interface};
use async_trait::async_trait;
@ -129,6 +130,7 @@ impl<T: InvokeUi> Session<T> {
self.send(Data::Message(msg));
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn t(&self, name: String) -> String {
crate::client::translate(name)
}
@ -271,9 +273,11 @@ impl<T: InvokeUi> Session<T> {
{
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) && common::valid_for_numlock(&key_event) {
key_event.modifiers.push(ControlKey::NumLock.into());
@ -318,6 +322,7 @@ impl<T: InvokeUi> Session<T> {
return "".to_owned();
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn get_icon(&self) -> String {
crate::get_icon()
}
@ -661,6 +666,7 @@ impl<T: InvokeUi> Interface for Session<T> {
}
}
// TODO use event callbcak
#[cfg(not(any(target_os = "android", target_os = "ios")))]
self.start_keyboard_hook();
}
@ -704,6 +710,7 @@ impl<T: InvokeUi> Interface for Session<T> {
// TODO use event callbcak
// sciter only
#[cfg(not(any(target_os = "android", target_os = "ios")))]
impl<T: InvokeUi> Session<T> {
fn start_keyboard_hook(&self) {
if self.is_port_forward() || self.is_file_transfer() {
@ -948,6 +955,7 @@ pub async fn io_loop<T: InvokeUi>(handler: Session<T>) {
if key.is_empty() {
key = crate::platform::get_license_key();
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
if handler.is_port_forward() {
if handler.is_rdp() {
let port = handler
@ -1053,6 +1061,7 @@ pub async fn io_loop<T: InvokeUi>(handler: Session<T>) {
remote.sync_jobs_status_to_local().await;
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
async fn start_one_port_forward<T: InvokeUi>(
handler: Session<T>,
port: i32,