mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
demo: use mobile_ffi to get id for desktop version
This commit is contained in:
@@ -12,7 +12,7 @@ use hbb_common::{
|
||||
rendezvous_proto::*,
|
||||
sleep, socket_client, tokio, ResultType,
|
||||
};
|
||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
||||
// #[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
||||
use hbb_common::{config::RENDEZVOUS_PORT, futures::future::join_all};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@@ -336,7 +336,7 @@ pub async fn get_nat_type(ms_timeout: u64) -> i32 {
|
||||
crate::ipc::get_nat_type(ms_timeout).await
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
||||
// #[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn test_rendezvous_server_() {
|
||||
let servers = Config::get_rendezvous_servers();
|
||||
@@ -363,7 +363,7 @@ async fn test_rendezvous_server_() {
|
||||
join_all(futs).await;
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
||||
// #[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
||||
pub fn test_rendezvous_server() {
|
||||
std::thread::spawn(test_rendezvous_server_);
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ pub mod ipc;
|
||||
pub mod ui;
|
||||
mod version;
|
||||
pub use version::*;
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
// #[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
mod bridge_generated;
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
// #[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
pub mod mobile;
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
// #[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
pub mod mobile_ffi;
|
||||
use common::*;
|
||||
#[cfg(feature = "cli")]
|
||||
|
||||
@@ -1165,7 +1165,7 @@ pub fn make_fd_to_json(fd: FileDirectory) -> String {
|
||||
|
||||
// Server Side
|
||||
// TODO connection_manager need use struct and trait,impl default method
|
||||
#[cfg(target_os = "android")]
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
pub mod connection_manager {
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
@@ -1191,6 +1191,7 @@ pub mod connection_manager {
|
||||
task::spawn_blocking,
|
||||
},
|
||||
};
|
||||
#[cfg(any(target_os = "android"))]
|
||||
use scrap::android::call_main_service_set_by_name;
|
||||
use serde_derive::Serialize;
|
||||
|
||||
@@ -1253,6 +1254,7 @@ pub mod connection_manager {
|
||||
client.authorized = true;
|
||||
let client_json = serde_json::to_string(&client).unwrap_or("".into());
|
||||
// send to Android service,active notification no matter UI is shown or not.
|
||||
#[cfg(any(target_os = "android"))]
|
||||
if let Err(e) = call_main_service_set_by_name(
|
||||
"on_client_authorized",
|
||||
Some(&client_json),
|
||||
@@ -1265,6 +1267,7 @@ pub mod connection_manager {
|
||||
} else {
|
||||
let client_json = serde_json::to_string(&client).unwrap_or("".into());
|
||||
// send to Android service,active notification no matter UI is shown or not.
|
||||
#[cfg(any(target_os = "android"))]
|
||||
if let Err(e) = call_main_service_set_by_name(
|
||||
"try_start_without_auth",
|
||||
Some(&client_json),
|
||||
@@ -1343,6 +1346,7 @@ pub mod connection_manager {
|
||||
.next()
|
||||
.is_none()
|
||||
{
|
||||
#[cfg(any(target_os = "android"))]
|
||||
if let Err(e) = call_main_service_set_by_name("stop_capture", None, None) {
|
||||
log::debug!("stop_capture err:{}", e);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ fn initialize(app_dir: &str) {
|
||||
use hbb_common::env_logger::*;
|
||||
init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "debug"));
|
||||
}
|
||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
||||
crate::common::test_rendezvous_server();
|
||||
crate::common::test_nat_type();
|
||||
#[cfg(target_os = "android")]
|
||||
@@ -182,9 +183,11 @@ unsafe extern "C" fn set_by_name(name: *const c_char, value: *const c_char) {
|
||||
"init" => {
|
||||
initialize(value);
|
||||
}
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
"info1" => {
|
||||
*crate::common::MOBILE_INFO1.lock().unwrap() = value.to_owned();
|
||||
}
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
"info2" => {
|
||||
*crate::common::MOBILE_INFO2.lock().unwrap() = value.to_owned();
|
||||
}
|
||||
@@ -293,6 +296,7 @@ unsafe extern "C" fn set_by_name(name: *const c_char, value: *const c_char) {
|
||||
if name == "custom-rendezvous-server" {
|
||||
#[cfg(target_os = "android")]
|
||||
crate::rendezvous_mediator::RendezvousMediator::restart();
|
||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
||||
crate::common::test_rendezvous_server();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user