mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge branch 'ios_1.2.2'
This commit is contained in:
@@ -1037,24 +1037,24 @@ fn serialize_resolutions(resolutions: &Vec<Resolution>) -> String {
|
||||
}
|
||||
|
||||
fn char_to_session_id(c: *const char) -> ResultType<SessionID> {
|
||||
if c.is_null() {
|
||||
bail!("Session id ptr is null");
|
||||
}
|
||||
let cstr = unsafe { std::ffi::CStr::from_ptr(c as _) };
|
||||
let str = cstr.to_str()?;
|
||||
SessionID::from_str(str).map_err(|e| anyhow!("{:?}", e))
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn session_get_rgba_size(_session_uuid_str: *const char) -> usize {
|
||||
pub fn session_get_rgba_size(_session_id: SessionID) -> usize {
|
||||
#[cfg(not(feature = "flutter_texture_render"))]
|
||||
if let Ok(session_id) = char_to_session_id(_session_uuid_str) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&session_id) {
|
||||
return session.rgba.read().unwrap().len();
|
||||
}
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&_session_id) {
|
||||
return session.rgba.read().unwrap().len();
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn session_get_rgba(session_uuid_str: *const char) -> *const u8 {
|
||||
pub extern "C" fn session_get_rgba(session_uuid_str: *const char) -> *const u8 {
|
||||
if let Ok(session_id) = char_to_session_id(session_uuid_str) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&session_id) {
|
||||
return session.get_rgba();
|
||||
@@ -1064,23 +1064,17 @@ pub fn session_get_rgba(session_uuid_str: *const char) -> *const u8 {
|
||||
std::ptr::null()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn session_next_rgba(session_uuid_str: *const char) {
|
||||
if let Ok(session_id) = char_to_session_id(session_uuid_str) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&session_id) {
|
||||
return session.next_rgba();
|
||||
}
|
||||
pub fn session_next_rgba(session_id: SessionID) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&session_id) {
|
||||
return session.next_rgba();
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[no_mangle]
|
||||
pub fn session_register_texture(_session_uuid_str: *const char, _ptr: usize) {
|
||||
pub fn session_register_texture(_session_id: SessionID, _ptr: usize) {
|
||||
#[cfg(feature = "flutter_texture_render")]
|
||||
if let Ok(session_id) = char_to_session_id(_session_uuid_str) {
|
||||
if let Some(session) = SESSIONS.write().unwrap().get_mut(&session_id) {
|
||||
return session.register_texture(_ptr);
|
||||
}
|
||||
if let Some(session) = SESSIONS.write().unwrap().get_mut(&_session_id) {
|
||||
return session.register_texture(_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1211,9 +1205,6 @@ pub fn session_send_pointer(session_id: SessionID, msg: String) {
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn get_rgba() {}
|
||||
|
||||
/// Hooks for session.
|
||||
#[derive(Clone)]
|
||||
pub enum SessionHook {
|
||||
|
||||
@@ -1388,18 +1388,6 @@ pub fn main_get_build_date() -> String {
|
||||
crate::BUILD_DATE.to_string()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn translate(name: *const c_char, locale: *const c_char) -> *const c_char {
|
||||
let name = CStr::from_ptr(name);
|
||||
let locale = CStr::from_ptr(locale);
|
||||
let res = if let (Ok(name), Ok(locale)) = (name.to_str(), locale.to_str()) {
|
||||
crate::client::translate_locale(name.to_owned(), locale)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
CString::from_vec_unchecked(res.into_bytes()).into_raw()
|
||||
}
|
||||
|
||||
fn handle_query_onlines(onlines: Vec<String>, offlines: Vec<String>) {
|
||||
let data = HashMap::from([
|
||||
("name", "callback_query_onlines".to_owned()),
|
||||
@@ -1412,6 +1400,22 @@ fn handle_query_onlines(onlines: Vec<String>, offlines: Vec<String>) {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn translate(name: String, locale: String) -> SyncReturn<String> {
|
||||
SyncReturn(crate::client::translate_locale(name, &locale))
|
||||
}
|
||||
|
||||
pub fn session_get_rgba_size(session_id: SessionID) -> SyncReturn<usize> {
|
||||
SyncReturn(super::flutter::session_get_rgba_size(session_id))
|
||||
}
|
||||
|
||||
pub fn session_next_rgba(session_id: SessionID) -> SyncReturn<()> {
|
||||
SyncReturn(super::flutter::session_next_rgba(session_id))
|
||||
}
|
||||
|
||||
pub fn session_register_texture(session_id: SessionID, ptr: usize) -> SyncReturn<()> {
|
||||
SyncReturn(super::flutter::session_register_texture(session_id, ptr))
|
||||
}
|
||||
|
||||
pub fn query_onlines(ids: Vec<String>) {
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
crate::rendezvous_mediator::query_online_states(ids, handle_query_onlines)
|
||||
|
||||
Reference in New Issue
Block a user