mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-18 07:43:01 +08:00
fix android build
This commit is contained in:
parent
d3bc0ca073
commit
07debe8363
@ -1267,7 +1267,7 @@ impl LoginConfigHandler {
|
|||||||
/// Create a [`Message`] for login.
|
/// Create a [`Message`] for login.
|
||||||
fn create_login_msg(&self, password: Vec<u8>) -> Message {
|
fn create_login_msg(&self, password: Vec<u8>) -> Message {
|
||||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
let my_id = Config::get_id_or(crate::common::MOBILE_INFO1.lock().unwrap().clone());
|
let my_id = Config::get_id_or(crate::common::FLUTTER_INFO1.lock().unwrap().clone());
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
let my_id = Config::get_id();
|
let my_id = Config::get_id();
|
||||||
let mut lr = LoginRequest {
|
let mut lr = LoginRequest {
|
||||||
|
@ -441,7 +441,7 @@ pub fn username() -> String {
|
|||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
return whoami::username().trim_end_matches('\0').to_owned();
|
return whoami::username().trim_end_matches('\0').to_owned();
|
||||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
return MOBILE_INFO2.lock().unwrap().clone();
|
return FLUTTER_INFO2.lock().unwrap().clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -19,12 +19,14 @@ use crate::flutter::connection_manager::{self, get_clients_length, get_clients_s
|
|||||||
use crate::flutter::{self, Session, SESSIONS};
|
use crate::flutter::{self, Session, SESSIONS};
|
||||||
use crate::start_server;
|
use crate::start_server;
|
||||||
use crate::ui_interface;
|
use crate::ui_interface;
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
use crate::ui_interface::{change_id, check_connect_status, is_ok_change_id};
|
||||||
use crate::ui_interface::{
|
use crate::ui_interface::{
|
||||||
change_id, check_connect_status, discover, forget_password, get_api_server, get_app_name,
|
discover, forget_password, get_api_server, get_app_name, get_async_job_status,
|
||||||
get_async_job_status, get_connect_status, get_fav, get_id, get_lan_peers, get_license,
|
get_connect_status, get_fav, get_id, get_lan_peers, get_license, get_local_option, get_options,
|
||||||
get_local_option, get_options, get_peer, get_peer_option, get_socks, get_sound_inputs,
|
get_peer, get_peer_option, get_socks, get_sound_inputs, get_uuid, get_version,
|
||||||
get_uuid, get_version, has_rendezvous_service, is_ok_change_id, post_request, set_local_option,
|
has_rendezvous_service, post_request, set_local_option, set_options, set_peer_option,
|
||||||
set_options, set_peer_option, set_socks, store_fav, test_if_valid_server, using_public_server,
|
set_socks, store_fav, test_if_valid_server, using_public_server,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn initialize(app_dir: &str) {
|
fn initialize(app_dir: &str) {
|
||||||
@ -67,7 +69,10 @@ fn initialize(app_dir: &str) {
|
|||||||
/// Return true if the app should continue running with UI(possibly Flutter), false if the app should exit.
|
/// Return true if the app should continue running with UI(possibly Flutter), false if the app should exit.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn rustdesk_core_main() -> bool {
|
pub extern "C" fn rustdesk_core_main() -> bool {
|
||||||
crate::core_main::core_main()
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
return crate::core_main::core_main();
|
||||||
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum EventToUI {
|
pub enum EventToUI {
|
||||||
@ -390,6 +395,7 @@ pub fn main_get_sound_inputs() -> Vec<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn main_change_id(new_id: String) {
|
pub fn main_change_id(new_id: String) {
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
change_id(new_id)
|
change_id(new_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,6 +467,7 @@ pub fn main_get_connect_status() -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn main_check_connect_status() {
|
pub fn main_check_connect_status() {
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
check_connect_status(true);
|
check_connect_status(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1042,8 +1049,13 @@ unsafe extern "C" fn set_by_name(name: *const c_char, value: *const c_char) {
|
|||||||
crate::rendezvous_mediator::RendezvousMediator::restart();
|
crate::rendezvous_mediator::RendezvousMediator::restart();
|
||||||
}
|
}
|
||||||
"start_service" => {
|
"start_service" => {
|
||||||
Config::set_option("stop-service".into(), "".into());
|
#[cfg(target_os = "android")]
|
||||||
start_server(false);
|
{
|
||||||
|
Config::set_option("stop-service".into(), "".into());
|
||||||
|
crate::rendezvous_mediator::RendezvousMediator::restart();
|
||||||
|
}
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
|
std::thread::spawn(move || start_server(true));
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
"close_conn" => {
|
"close_conn" => {
|
||||||
|
@ -5,7 +5,7 @@ use crate::clipboard_file::*;
|
|||||||
use crate::common::update_clipboard;
|
use crate::common::update_clipboard;
|
||||||
use crate::video_service;
|
use crate::video_service;
|
||||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
use crate::{common::MOBILE_INFO2, flutter::connection_manager::start_channel};
|
use crate::{common::FLUTTER_INFO2, flutter::connection_manager::start_channel};
|
||||||
use crate::{ipc, VERSION};
|
use crate::{ipc, VERSION};
|
||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
config::Config,
|
config::Config,
|
||||||
@ -643,7 +643,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
{
|
{
|
||||||
pi.hostname = MOBILE_INFO2.lock().unwrap().clone();
|
pi.hostname = FLUTTER_INFO2.lock().unwrap().clone();
|
||||||
pi.platform = "Android".into();
|
pi.platform = "Android".into();
|
||||||
}
|
}
|
||||||
#[cfg(feature = "hwcodec")]
|
#[cfg(feature = "hwcodec")]
|
||||||
|
@ -32,10 +32,14 @@ lazy_static::lazy_static! {
|
|||||||
pub static ref UI_STATUS : Arc<Mutex<Status>> = Arc::new(Mutex::new((0, false, 0, "".to_owned())));
|
pub static ref UI_STATUS : Arc<Mutex<Status>> = Arc::new(Mutex::new((0, false, 0, "".to_owned())));
|
||||||
pub static ref OPTIONS : Arc<Mutex<HashMap<String, String>>> = Arc::new(Mutex::new(Config::get_options()));
|
pub static ref OPTIONS : Arc<Mutex<HashMap<String, String>>> = Arc::new(Mutex::new(Config::get_options()));
|
||||||
pub static ref ASYNC_JOB_STATUS : Arc<Mutex<String>> = Default::default();
|
pub static ref ASYNC_JOB_STATUS : Arc<Mutex<String>> = Default::default();
|
||||||
pub static ref SENDER : Mutex<mpsc::UnboundedSender<ipc::Data>> = Mutex::new(check_connect_status(true));
|
|
||||||
pub static ref TEMPORARY_PASSWD : Arc<Mutex<String>> = Arc::new(Mutex::new("".to_owned()));
|
pub static ref TEMPORARY_PASSWD : Arc<Mutex<String>> = Arc::new(Mutex::new("".to_owned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
lazy_static::lazy_static! {
|
||||||
|
pub static ref SENDER : Mutex<mpsc::UnboundedSender<ipc::Data>> = Mutex::new(check_connect_status(true));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn recent_sessions_updated() -> bool {
|
pub fn recent_sessions_updated() -> bool {
|
||||||
let mut childs = CHILDS.lock().unwrap();
|
let mut childs = CHILDS.lock().unwrap();
|
||||||
if childs.0 {
|
if childs.0 {
|
||||||
@ -47,7 +51,10 @@ pub fn recent_sessions_updated() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_id() -> String {
|
pub fn get_id() -> String {
|
||||||
ipc::get_id()
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
|
return Config::get_id();
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
return ipc::get_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_remote_id() -> String {
|
pub fn get_remote_id() -> String {
|
||||||
@ -132,7 +139,7 @@ pub fn get_license() -> String {
|
|||||||
|
|
||||||
pub fn get_option(key: String) -> String {
|
pub fn get_option(key: String) -> String {
|
||||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
return Config::get_option(arg);
|
return Config::get_option(&key);
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
return get_option_(&key);
|
return get_option_(&key);
|
||||||
}
|
}
|
||||||
@ -243,13 +250,16 @@ pub fn get_sound_inputs() -> Vec<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_options(m: HashMap<String, String>) {
|
pub fn set_options(m: HashMap<String, String>) {
|
||||||
*OPTIONS.lock().unwrap() = m.clone();
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
ipc::set_options(m).ok();
|
{
|
||||||
|
*OPTIONS.lock().unwrap() = m.clone();
|
||||||
|
ipc::set_options(m).ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_option(key: String, value: String) {
|
pub fn set_option(key: String, value: String) {
|
||||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
Config::set_option(name.to_owned(), value.to_owned());
|
Config::set_option(key, value);
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
{
|
{
|
||||||
let mut options = OPTIONS.lock().unwrap();
|
let mut options = OPTIONS.lock().unwrap();
|
||||||
@ -277,20 +287,26 @@ pub fn install_path() -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_socks() -> Vec<String> {
|
pub fn get_socks() -> Vec<String> {
|
||||||
let s = ipc::get_socks();
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
match s {
|
return Vec::new();
|
||||||
None => Vec::new(),
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
Some(s) => {
|
{
|
||||||
let mut v = Vec::new();
|
let s = ipc::get_socks();
|
||||||
v.push(s.proxy);
|
match s {
|
||||||
v.push(s.username);
|
None => Vec::new(),
|
||||||
v.push(s.password);
|
Some(s) => {
|
||||||
v
|
let mut v = Vec::new();
|
||||||
|
v.push(s.proxy);
|
||||||
|
v.push(s.username);
|
||||||
|
v.push(s.password);
|
||||||
|
v
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_socks(proxy: String, username: String, password: String) {
|
pub fn set_socks(proxy: String, username: String, password: String) {
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
ipc::set_socks(config::Socks5Server {
|
ipc::set_socks(config::Socks5Server {
|
||||||
proxy,
|
proxy,
|
||||||
username,
|
username,
|
||||||
@ -357,6 +373,7 @@ pub fn get_mouse_time() -> f64 {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
pub fn check_mouse_time() {
|
pub fn check_mouse_time() {
|
||||||
let sender = SENDER.lock().unwrap();
|
let sender = SENDER.lock().unwrap();
|
||||||
allow_err!(sender.send(ipc::Data::MouseMoveTime(0)));
|
allow_err!(sender.send(ipc::Data::MouseMoveTime(0)));
|
||||||
|
Loading…
Reference in New Issue
Block a user