opt: add default url scheme handler for macos
This commit is contained in:
parent
7e69cbde26
commit
a9fc63c34f
@ -3,28 +3,29 @@ use std::{
|
|||||||
ffi::{CStr, CString},
|
ffi::{CStr, CString},
|
||||||
os::raw::c_char,
|
os::raw::c_char,
|
||||||
};
|
};
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
use flutter_rust_bridge::{StreamSink, SyncReturn, ZeroCopyBuffer};
|
use flutter_rust_bridge::{StreamSink, SyncReturn, ZeroCopyBuffer};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
use crate::common::is_keyboard_mode_supported;
|
|
||||||
use hbb_common::message_proto::KeyboardMode;
|
|
||||||
use hbb_common::ResultType;
|
|
||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
config::{self, LocalConfig, PeerConfig, ONLINE},
|
config::{self, LocalConfig, ONLINE, PeerConfig},
|
||||||
fs, log,
|
fs, log,
|
||||||
};
|
};
|
||||||
use std::str::FromStr;
|
use hbb_common::message_proto::KeyboardMode;
|
||||||
|
use hbb_common::ResultType;
|
||||||
|
|
||||||
// use crate::hbbs_http::account::AuthResult;
|
|
||||||
|
|
||||||
use crate::flutter::{self, SESSIONS};
|
|
||||||
use crate::ui_interface::{self, *};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::file_trait::FileManager,
|
client::file_trait::FileManager,
|
||||||
common::make_fd_to_json,
|
common::make_fd_to_json,
|
||||||
flutter::{session_add, session_start_},
|
flutter::{session_add, session_start_},
|
||||||
};
|
};
|
||||||
|
use crate::common::is_keyboard_mode_supported;
|
||||||
|
use crate::flutter::{self, SESSIONS};
|
||||||
|
use crate::ui_interface::{self, *};
|
||||||
|
|
||||||
|
// use crate::hbbs_http::account::AuthResult;
|
||||||
|
|
||||||
fn initialize(app_dir: &str) {
|
fn initialize(app_dir: &str) {
|
||||||
*config::APP_DIR.write().unwrap() = app_dir.to_owned();
|
*config::APP_DIR.write().unwrap() = app_dir.to_owned();
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
@ -910,6 +911,11 @@ pub fn main_start_dbus_server() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn osx_handle_uni_links(url: String) {
|
||||||
|
#![cfg(target_os = "macos")]
|
||||||
|
crate::ui::macos::handle_url_scheme(url);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn session_send_mouse(id: String, msg: String) {
|
pub fn session_send_mouse(id: String, msg: String) {
|
||||||
if let Ok(m) = serde_json::from_str::<HashMap<String, String>>(&msg) {
|
if let Ok(m) = serde_json::from_str::<HashMap<String, String>>(&msg) {
|
||||||
let alt = m.get("alt").is_some();
|
let alt = m.get("alt").is_some();
|
||||||
@ -1257,13 +1263,12 @@ pub fn main_hide_docker() -> SyncReturn<bool> {
|
|||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
pub mod server_side {
|
pub mod server_side {
|
||||||
|
use hbb_common::log;
|
||||||
use jni::{
|
use jni::{
|
||||||
|
JNIEnv,
|
||||||
objects::{JClass, JString},
|
objects::{JClass, JString},
|
||||||
sys::jstring,
|
sys::jstring,
|
||||||
JNIEnv,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
use hbb_common::log;
|
|
||||||
|
|
||||||
use crate::start_server;
|
use crate::start_server;
|
||||||
|
|
||||||
|
@ -181,11 +181,16 @@ extern "C" fn handle_menu_item(this: &mut Object, _: Sel, item: id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern fn handle_apple_event(this: &Object, _cmd: Sel, event: u64, _reply: u64) {
|
/// The function to handle the url scheme sent by system.
|
||||||
|
pub fn handle_url_scheme(url: String) {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern fn handle_apple_event(_this: &Object, _cmd: Sel, event: u64, _reply: u64) {
|
||||||
let event = event as *mut Object;
|
let event = event as *mut Object;
|
||||||
let url = fruitbasket::parse_url_event(event);
|
let url = fruitbasket::parse_url_event(event);
|
||||||
log::debug!("event found {}", url);
|
log::debug!("event found {}", url);
|
||||||
let _ = crate::run_me(vec![url]);
|
handle_url_scheme(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn make_menu_item(title: &str, key: &str, tag: u32) -> *mut Object {
|
unsafe fn make_menu_item(title: &str, key: &str, tag: u32) -> *mut Object {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user