mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-10 06:21:02 +03:00
add the base crate and repoint the moved modules at it (#16107)
* add the base crate and repoint the moved modules at it `libs/base` (crate `base`) takes the parts of hbb_common that only this app uses: `fs`, `platform`, `keyboard`, `message.proto`, and 145 of the 177 `config::keys` constants. hbb_common keeps what the server names, and the 32 keys it reads itself are re-exported from `base::config::keys` so call sites still see the full set through one path. Sources move verbatim. The only edits inside them are `crate::` prefixes that now have to say `hbb_common::`; `keyboard.rs` and `platform/windows.rs` are byte-identical. The crate stays on edition 2018, the edition the moved code was written under. `log`, `lazy_static` and `anyhow` become direct dependencies so the bare paths in that code resolve exactly as before, and its winapi features are spelled out rather than left to feature unification. Two call sites outside Rust and Cargo had to follow the move: the Android protobuf source dir, which still pointed at hbb_common/protos for message.proto, and the three AGENTS.md entries that named hbb_common for options, protos and file transfer. `scrap`'s `drm` feature now forwards to `base/wayland_probe`. Left pointing at hbb_common it would still have compiled, silently dropping the Wayland socket-probe fallback, so that forward is verified by a build with and without the feature. `config::keys` carries a test asserting its names stay disjoint from the ones hbb_common kept: the glob re-export and the local constants share a namespace, and Rust prefers the local item silently, so a name added to both sides would otherwise let client and server disagree with no diagnostic. Verified: macOS and Linux, debug and release, `--all-targets`; the 177 key constants diffed name-for-name and value-for-value; the generated protobuf types compared before and after; every `#[cfg]` gate on a moved import checked against its original; and every file that was `rustfmt`-clean before this change still is, compared against master file by file. Windows is checked by inspection only -- it cannot be compiled here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab * one `use` per crate, and write the rule down `fs.rs` came out of the move with two ungated `use hbb_common::` statements, because the original single `use crate::{...}` had to give up `message_proto` to the new crate and the rest was left in a second block. Fold it back into one. A scan of the whole tree for the same shape finds nothing else: every other file with more than one top-level `use base::` or `use hbb_common::` is split by a `#[cfg]` that does not cover the whole block, or by `pub use` next to `use`. Those are the cases that cannot merge, so AGENTS.md now states both the rule and the exemption. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -47,13 +47,11 @@ use hbb_common::{
|
||||
anyhow::{anyhow, Context},
|
||||
bail,
|
||||
config::{
|
||||
self, keys, use_ws, Config, LocalConfig, PeerConfig, PeerInfoSerde, Resolution,
|
||||
self, use_ws, Config, LocalConfig, PeerConfig, PeerInfoSerde, Resolution,
|
||||
CONNECT_TIMEOUT, READ_TIMEOUT, RELAY_PORT, RENDEZVOUS_PORT, RENDEZVOUS_SERVERS,
|
||||
},
|
||||
fs::JobType,
|
||||
futures::future::{select_ok, BoxFuture, FutureExt},
|
||||
get_version_number, log,
|
||||
message_proto::{option_message::BoolOption, *},
|
||||
protobuf::{Message as _, MessageField},
|
||||
rand,
|
||||
rendezvous_proto::*,
|
||||
@@ -73,6 +71,11 @@ use hbb_common::{
|
||||
webrtc::WebRTCStream,
|
||||
AddrMangle, ResultType, Stream,
|
||||
};
|
||||
use base::{
|
||||
config::keys,
|
||||
fs::JobType,
|
||||
message_proto::{option_message::BoolOption, *},
|
||||
};
|
||||
pub use helper::*;
|
||||
use scrap::{
|
||||
codec::Decoder,
|
||||
@@ -4020,7 +4023,7 @@ async fn do_sync_cpu_usage() {
|
||||
if let Ok(Some(data)) = conn.next_timeout(50).await {
|
||||
match data {
|
||||
Data::SyncWinCpuUsage(cpu_usage) => {
|
||||
hbb_common::platform::windows::sync_cpu_usage(cpu_usage);
|
||||
base::platform::windows::sync_cpu_usage(cpu_usage);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -4680,7 +4683,7 @@ pub trait Interface: Send + Clone + 'static + Sized {
|
||||
}
|
||||
}
|
||||
|
||||
fn swap_modifier_mouse(&self, _msg: &mut hbb_common::protos::message::MouseEvent) {}
|
||||
fn swap_modifier_mouse(&self, _msg: &mut base::protos::message::MouseEvent) {}
|
||||
|
||||
fn update_direct(&self, direct: Option<bool>) {
|
||||
self.get_lch().write().unwrap().direct = direct;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use hbb_common::{fs, log, message_proto::*};
|
||||
use hbb_common::log;
|
||||
use base::{fs, message_proto::*};
|
||||
|
||||
use super::{Data, Interface};
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
use hbb_common::{
|
||||
get_time,
|
||||
message_proto::{Message, VoiceCallRequest, VoiceCallResponse},
|
||||
};
|
||||
use base::message_proto::{Message, VoiceCallRequest, VoiceCallResponse};
|
||||
use hbb_common::get_time;
|
||||
use scrap::CodecFormat;
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
||||
@@ -17,6 +17,14 @@ const RESTART_REMOTE_DEVICE_NO_DATA_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
const KCP_CLOSE_REASON_FLUSH_DELAY: Duration = Duration::from_millis(30);
|
||||
#[cfg(feature = "unix-file-copy-paste")]
|
||||
use crate::{clipboard::try_empty_clipboard_files, clipboard_file::unix_file_clip};
|
||||
use base::{
|
||||
config::keys,
|
||||
fs::{
|
||||
self, can_enable_overwrite_detection, get_job, get_string, new_send_confirm,
|
||||
DigestCheckResult, RemoveJobMeta,
|
||||
},
|
||||
message_proto::{permission_info::Permission, *},
|
||||
};
|
||||
#[cfg(any(
|
||||
target_os = "windows",
|
||||
all(target_os = "macos", feature = "unix-file-copy-paste")
|
||||
@@ -28,12 +36,7 @@ use hbb_common::tokio::sync::mpsc::error::TryRecvError;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
config::{self, LocalConfig, PeerConfig, TransferSerde},
|
||||
fs::{
|
||||
self, can_enable_overwrite_detection, get_job, get_string, new_send_confirm,
|
||||
DigestCheckResult, RemoveJobMeta,
|
||||
},
|
||||
get_time, log,
|
||||
message_proto::{permission_info::Permission, *},
|
||||
protobuf::Message as _,
|
||||
rendezvous_proto::ConnType,
|
||||
timeout,
|
||||
@@ -2036,9 +2039,8 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
#[cfg(target_os = "windows")]
|
||||
Ok(file_transfer_send_request::FileType::Printer) => {
|
||||
#[cfg(feature = "flutter")]
|
||||
let action = LocalConfig::get_option(
|
||||
config::keys::OPTION_PRINTER_INCOMING_JOB_ACTION,
|
||||
);
|
||||
let action =
|
||||
LocalConfig::get_option(keys::OPTION_PRINTER_INCOMING_JOB_ACTION);
|
||||
#[cfg(not(feature = "flutter"))]
|
||||
let action = "";
|
||||
if action == "dismiss" {
|
||||
@@ -2047,7 +2049,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
let id = fs::get_next_job_id();
|
||||
#[cfg(feature = "flutter")]
|
||||
let allow_auto_print = LocalConfig::get_bool_option(
|
||||
config::keys::OPTION_PRINTER_ALLOW_AUTO_PRINT,
|
||||
keys::OPTION_PRINTER_ALLOW_AUTO_PRINT,
|
||||
);
|
||||
#[cfg(not(feature = "flutter"))]
|
||||
let allow_auto_print = false;
|
||||
@@ -2055,9 +2057,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
let printer_name = if action == "" {
|
||||
"".to_string()
|
||||
} else {
|
||||
LocalConfig::get_option(
|
||||
config::keys::OPTION_PRINTER_SELECTED_NAME,
|
||||
)
|
||||
LocalConfig::get_option(keys::OPTION_PRINTER_SELECTED_NAME)
|
||||
};
|
||||
self.handler.printer_response(id, _s.path, printer_name);
|
||||
} else {
|
||||
@@ -2123,7 +2123,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
.handle_screenshot_resp(response.sid, response.msg);
|
||||
}
|
||||
Some(message::Union::TerminalResponse(response)) => {
|
||||
use hbb_common::message_proto::terminal_response::Union;
|
||||
use base::message_proto::terminal_response::Union;
|
||||
if let Some(Union::Opened(opened)) = &response.union {
|
||||
if opened.success && !opened.service_id.is_empty() {
|
||||
let mut lc = self.handler.lc.write().unwrap();
|
||||
@@ -2347,14 +2347,10 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "windows", feature = "unix-file-copy-paste"))]
|
||||
async fn handle_cliprdr_msg(
|
||||
&mut self,
|
||||
clip: hbb_common::message_proto::Cliprdr,
|
||||
_peer: &mut Stream,
|
||||
) {
|
||||
async fn handle_cliprdr_msg(&mut self, clip: base::message_proto::Cliprdr, _peer: &mut Stream) {
|
||||
log::debug!("handling cliprdr msg from server peer");
|
||||
#[cfg(feature = "flutter")]
|
||||
if let Some(hbb_common::message_proto::cliprdr::Union::FormatList(_)) = &clip.union {
|
||||
if let Some(base::message_proto::cliprdr::Union::FormatList(_)) = &clip.union {
|
||||
if self.client_conn_id
|
||||
!= clipboard::get_client_conn_id(&crate::flutter::get_cur_peer_id()).unwrap_or(0)
|
||||
{
|
||||
@@ -2464,8 +2460,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
);
|
||||
self.video_threads.insert(display, video_thread);
|
||||
if self.video_threads.len() == 1 {
|
||||
let auto_record =
|
||||
LocalConfig::get_bool_option(config::keys::OPTION_ALLOW_AUTO_RECORD_OUTGOING);
|
||||
let auto_record = LocalConfig::get_bool_option(keys::OPTION_ALLOW_AUTO_RECORD_OUTGOING);
|
||||
self.handler.lc.write().unwrap().record_state = auto_record;
|
||||
self.update_record_state();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use crate::clipboard::{update_clipboard, ClipboardSide};
|
||||
use hbb_common::{message_proto::*, ResultType};
|
||||
use base::message_proto::*;
|
||||
use hbb_common::ResultType;
|
||||
use std::sync::Mutex;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
use arboard::{ClipboardData, ClipboardFormat};
|
||||
#[cfg(target_os = "linux")]
|
||||
use arboard::{LinuxClipboardKind, SetExtLinux};
|
||||
use hbb_common::{bail, log, message_proto::*, ResultType};
|
||||
use hbb_common::{bail, log, ResultType};
|
||||
use base::message_proto::*;
|
||||
use std::{
|
||||
sync::{Arc, Mutex},
|
||||
time::Duration,
|
||||
@@ -515,10 +516,10 @@ impl ClipboardContext {
|
||||
// The host-side clear file clipboard `let _ = self.inner.clear();`,
|
||||
// does not work on KDE Plasma for the installed version.
|
||||
|
||||
// Don't use `hbb_common::platform::linux::is_kde()` here.
|
||||
// Don't use `base::platform::linux::is_kde()` here.
|
||||
// It's not correct in the server process.
|
||||
#[cfg(target_os = "linux")]
|
||||
let is_kde_x11 = hbb_common::platform::linux::is_kde_session()
|
||||
let is_kde_x11 = base::platform::linux::is_kde_session()
|
||||
&& crate::platform::linux::is_x11();
|
||||
#[cfg(target_os = "macos")]
|
||||
let is_kde_x11 = false;
|
||||
@@ -581,7 +582,7 @@ pub fn get_current_clipboard_msg(
|
||||
multi_clipboards
|
||||
.clipboards
|
||||
.iter()
|
||||
.find(|c| c.format.enum_value() == Ok(hbb_common::message_proto::ClipboardFormat::Text))
|
||||
.find(|c| c.format.enum_value() == Ok(base::message_proto::ClipboardFormat::Text))
|
||||
.map(|c| {
|
||||
let mut msg = Message::new();
|
||||
msg.set_clipboard(c.clone());
|
||||
@@ -629,8 +630,8 @@ mod proto {
|
||||
use arboard::ClipboardData;
|
||||
use hbb_common::{
|
||||
compress::{compress as compress_func, decompress},
|
||||
message_proto::{Clipboard, ClipboardFormat, Message, MultiClipboards},
|
||||
};
|
||||
use base::message_proto::{Clipboard, ClipboardFormat, Message, MultiClipboards};
|
||||
|
||||
fn plain_to_proto(s: String, format: ClipboardFormat) -> Clipboard {
|
||||
let compressed = compress_func(s.as_bytes());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use clipboard::ClipboardFile;
|
||||
use hbb_common::message_proto::*;
|
||||
use base::message_proto::*;
|
||||
|
||||
pub fn clip_2_msg(clip: ClipboardFile) -> Message {
|
||||
match clip {
|
||||
|
||||
@@ -8,6 +8,7 @@ use std::{
|
||||
|
||||
use serde_json::{json, Map, Value};
|
||||
|
||||
use base::{config::keys, message_proto::*};
|
||||
#[cfg(not(target_os = "ios"))]
|
||||
use hbb_common::whoami;
|
||||
use hbb_common::{
|
||||
@@ -16,13 +17,10 @@ use hbb_common::{
|
||||
async_recursion::async_recursion,
|
||||
bail, base64,
|
||||
bytes::Bytes,
|
||||
config::{
|
||||
self, keys, use_ws, Config, LocalConfig, CONNECT_TIMEOUT, READ_TIMEOUT, RENDEZVOUS_PORT,
|
||||
},
|
||||
config::{self, use_ws, Config, LocalConfig, CONNECT_TIMEOUT, READ_TIMEOUT, RENDEZVOUS_PORT},
|
||||
futures::future::join_all,
|
||||
futures_util::future::poll_fn,
|
||||
get_version_number, log,
|
||||
message_proto::*,
|
||||
protobuf::{Enum, Message as _},
|
||||
rendezvous_proto::*,
|
||||
socket_client,
|
||||
|
||||
@@ -3,9 +3,10 @@ use crate::client::translate;
|
||||
#[cfg(not(debug_assertions))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use crate::platform::breakdown_callback;
|
||||
use base::config::keys;
|
||||
#[cfg(not(debug_assertions))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use hbb_common::platform::register_breakdown_handler;
|
||||
use base::platform::register_breakdown_handler;
|
||||
use hbb_common::{config, log};
|
||||
#[cfg(windows)]
|
||||
use tauri_winrt_notification::{Duration, Sound, Toast};
|
||||
@@ -113,7 +114,7 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
}
|
||||
#[cfg(windows)]
|
||||
if args.contains(&"--connect".to_string()) || args.contains(&"--view-camera".to_string()) {
|
||||
hbb_common::platform::windows::start_cpu_performance_monitor();
|
||||
base::platform::windows::start_cpu_performance_monitor();
|
||||
}
|
||||
#[cfg(feature = "flutter")]
|
||||
if _is_flutter_invoke_new_connection {
|
||||
@@ -889,7 +890,7 @@ fn is_user_main_ipc_scope_cli_command(args: &[String]) -> bool {
|
||||
|
||||
#[inline]
|
||||
fn is_cli_setting_change_disabled() -> bool {
|
||||
let option = config::keys::OPTION_ALLOW_COMMAND_LINE_SETTINGS_WHEN_SETTINGS_DISABLED;
|
||||
let option = keys::OPTION_ALLOW_COMMAND_LINE_SETTINGS_WHEN_SETTINGS_DISABLED;
|
||||
let allow_command_line_settings =
|
||||
config::option2bool(option, &crate::get_builtin_option(option));
|
||||
config::is_disable_settings() && !allow_command_line_settings
|
||||
|
||||
@@ -10,9 +10,10 @@ use hbb_common::dlopen::{
|
||||
Error as LibError,
|
||||
};
|
||||
use hbb_common::{
|
||||
anyhow::anyhow, bail, config::LocalConfig, get_version_number, log, message_proto::*,
|
||||
anyhow::anyhow, bail, config::LocalConfig, get_version_number, log,
|
||||
rendezvous_proto::ConnType, ResultType,
|
||||
};
|
||||
use base::message_proto::*;
|
||||
use serde::Serialize;
|
||||
use serde_json::json;
|
||||
#[cfg(target_os = "windows")]
|
||||
@@ -1102,7 +1103,7 @@ impl InvokeUiSession for FlutterHandler {
|
||||
}
|
||||
|
||||
fn handle_terminal_response(&self, response: TerminalResponse) {
|
||||
use hbb_common::message_proto::terminal_response::Union;
|
||||
use base::message_proto::terminal_response::Union;
|
||||
|
||||
match response.union {
|
||||
Some(Union::Opened(opened)) => {
|
||||
|
||||
@@ -14,10 +14,14 @@ use crate::{
|
||||
use flutter_rust_bridge::{StreamSink, SyncReturn};
|
||||
use hbb_common::{
|
||||
config::{self, LocalConfig, PeerConfig, PeerInfoSerde},
|
||||
fs, lazy_static, log,
|
||||
lazy_static, log,
|
||||
rendezvous_proto::ConnType,
|
||||
ResultType,
|
||||
};
|
||||
use base::{
|
||||
config::keys,
|
||||
fs,
|
||||
};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
path::PathBuf,
|
||||
@@ -330,7 +334,7 @@ pub fn session_toggle_option(session_id: SessionID, value: String) {
|
||||
}
|
||||
#[cfg(feature = "unix-file-copy-paste")]
|
||||
if sessions::get_session_by_session_id(&session_id).is_some()
|
||||
&& (value == config::keys::OPTION_ENABLE_FILE_COPY_PASTE || value == "view-only")
|
||||
&& (value == keys::OPTION_ENABLE_FILE_COPY_PASTE || value == "view-only")
|
||||
{
|
||||
crate::flutter::update_file_clipboard_required();
|
||||
}
|
||||
@@ -965,12 +969,12 @@ pub fn main_get_error() -> String {
|
||||
pub fn main_set_option(key: String, value: String) {
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
let is_permission_option = key.eq(config::keys::OPTION_ENABLE_CLIPBOARD)
|
||||
|| key.eq(config::keys::OPTION_ENABLE_FILE_TRANSFER)
|
||||
|| key.eq(config::keys::OPTION_ENABLE_AUDIO);
|
||||
let is_permission_option = key.eq(keys::OPTION_ENABLE_CLIPBOARD)
|
||||
|| key.eq(keys::OPTION_ENABLE_FILE_TRANSFER)
|
||||
|| key.eq(keys::OPTION_ENABLE_AUDIO);
|
||||
let allow_perm_change_in_accept_window = config::option2bool(
|
||||
config::keys::OPTION_ENABLE_PERM_CHANGE_IN_ACCEPT_WINDOW,
|
||||
&crate::get_builtin_option(config::keys::OPTION_ENABLE_PERM_CHANGE_IN_ACCEPT_WINDOW),
|
||||
keys::OPTION_ENABLE_PERM_CHANGE_IN_ACCEPT_WINDOW,
|
||||
&crate::get_builtin_option(keys::OPTION_ENABLE_PERM_CHANGE_IN_ACCEPT_WINDOW),
|
||||
);
|
||||
if is_permission_option
|
||||
&& !allow_perm_change_in_accept_window
|
||||
@@ -985,14 +989,14 @@ pub fn main_set_option(key: String, value: String) {
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "android")]
|
||||
if key.eq(config::keys::OPTION_ENABLE_KEYBOARD) {
|
||||
if key.eq(keys::OPTION_ENABLE_KEYBOARD) {
|
||||
crate::ui_cm_interface::switch_permission_all(
|
||||
"keyboard".to_owned(),
|
||||
config::option2bool(&key, &value),
|
||||
);
|
||||
}
|
||||
#[cfg(target_os = "android")]
|
||||
if key.eq(config::keys::OPTION_ENABLE_CLIPBOARD) {
|
||||
if key.eq(keys::OPTION_ENABLE_CLIPBOARD) {
|
||||
crate::ui_cm_interface::switch_permission_all(
|
||||
"clipboard".to_owned(),
|
||||
config::option2bool(&key, &value),
|
||||
@@ -1002,11 +1006,11 @@ pub fn main_set_option(key: String, value: String) {
|
||||
// If `is_allow_tls_fallback` and https proxy is used, we need to restart rendezvous mediator.
|
||||
// No need to check if https proxy is used, because this option does not change frequently
|
||||
// and restarting mediator is safe even https proxy is not used.
|
||||
let is_allow_tls_fallback = key.eq(config::keys::OPTION_ALLOW_INSECURE_TLS_FALLBACK);
|
||||
let is_allow_tls_fallback = key.eq(keys::OPTION_ALLOW_INSECURE_TLS_FALLBACK);
|
||||
if is_allow_tls_fallback
|
||||
|| key.eq("custom-rendezvous-server")
|
||||
|| key.eq(config::keys::OPTION_ALLOW_WEBSOCKET)
|
||||
|| key.eq(config::keys::OPTION_DISABLE_UDP)
|
||||
|| key.eq(keys::OPTION_ALLOW_WEBSOCKET)
|
||||
|| key.eq(keys::OPTION_DISABLE_UDP)
|
||||
|| key.eq("api-server")
|
||||
{
|
||||
if is_allow_tls_fallback {
|
||||
@@ -1035,14 +1039,14 @@ pub fn main_set_options(json: String) {
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
let allow_perm_change_in_accept_window = config::option2bool(
|
||||
config::keys::OPTION_ENABLE_PERM_CHANGE_IN_ACCEPT_WINDOW,
|
||||
&crate::get_builtin_option(config::keys::OPTION_ENABLE_PERM_CHANGE_IN_ACCEPT_WINDOW),
|
||||
keys::OPTION_ENABLE_PERM_CHANGE_IN_ACCEPT_WINDOW,
|
||||
&crate::get_builtin_option(keys::OPTION_ENABLE_PERM_CHANGE_IN_ACCEPT_WINDOW),
|
||||
);
|
||||
if !allow_perm_change_in_accept_window && crate::ui_cm_interface::has_active_clients() {
|
||||
for key in [
|
||||
config::keys::OPTION_ENABLE_CLIPBOARD,
|
||||
config::keys::OPTION_ENABLE_FILE_TRANSFER,
|
||||
config::keys::OPTION_ENABLE_AUDIO,
|
||||
keys::OPTION_ENABLE_CLIPBOARD,
|
||||
keys::OPTION_ENABLE_FILE_TRANSFER,
|
||||
keys::OPTION_ENABLE_AUDIO,
|
||||
] {
|
||||
if let Some(value) = map.remove(key) {
|
||||
log::info!(
|
||||
@@ -1210,8 +1214,8 @@ pub fn main_set_env(key: String, value: Option<String>) -> SyncReturn<()> {
|
||||
}
|
||||
|
||||
pub fn main_set_local_option(key: String, value: String) {
|
||||
let is_texture_render_key = key.eq(config::keys::OPTION_TEXTURE_RENDER);
|
||||
let is_d3d_render_key = key.eq(config::keys::OPTION_ALLOW_D3D_RENDER);
|
||||
let is_texture_render_key = key.eq(keys::OPTION_TEXTURE_RENDER);
|
||||
let is_d3d_render_key = key.eq(keys::OPTION_ALLOW_D3D_RENDER);
|
||||
set_local_option(key, value.clone());
|
||||
let is_render_target =
|
||||
|session: &crate::flutter::FlutterSession| session.is_default() || session.is_view_camera();
|
||||
@@ -2651,7 +2655,7 @@ pub fn main_get_common(key: String) -> String {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
return false.to_string();
|
||||
} else if key == "transfer-job-id" {
|
||||
return hbb_common::fs::get_next_job_id().to_string();
|
||||
return base::fs::get_next_job_id().to_string();
|
||||
} else if key == "is-remote-modify-enabled-by-control-permissions" {
|
||||
return match is_remote_modify_enabled_by_control_permissions() {
|
||||
Some(true) => "true",
|
||||
|
||||
@@ -7,10 +7,11 @@ use std::{
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
use crate::{ui_interface::get_builtin_option, Connection};
|
||||
use hbb_common::{
|
||||
config::{self, keys, Config, LocalConfig},
|
||||
config::{self, Config, LocalConfig},
|
||||
log,
|
||||
tokio::{self, sync::broadcast, time::Instant},
|
||||
};
|
||||
use base::config::keys;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
|
||||
15
src/ipc.rs
15
src/ipc.rs
@@ -34,7 +34,7 @@ use hbb_common::anyhow;
|
||||
use hbb_common::{
|
||||
allow_err, bail, bytes,
|
||||
bytes_codec::BytesCodec,
|
||||
config::{self, keys::OPTION_ALLOW_WEBSOCKET, Config, Config2},
|
||||
config::{self, Config, Config2},
|
||||
futures::StreamExt as _,
|
||||
futures_util::sink::SinkExt,
|
||||
log, password_security as password, timeout,
|
||||
@@ -45,6 +45,7 @@ use hbb_common::{
|
||||
tokio_util::codec::Framed,
|
||||
ResultType,
|
||||
};
|
||||
use base::config::keys::{self, OPTION_ALLOW_WEBSOCKET};
|
||||
#[cfg(windows)]
|
||||
pub(crate) use ipc_auth::authorize_windows_portable_service_ipc_connection;
|
||||
#[cfg(windows)]
|
||||
@@ -752,9 +753,9 @@ impl CheckIfRestart {
|
||||
audio_input: Config::get_option("audio-input"),
|
||||
voice_call_input: Config::get_option("voice-call-input"),
|
||||
ws: Config::get_option(OPTION_ALLOW_WEBSOCKET),
|
||||
disable_udp: Config::get_option(config::keys::OPTION_DISABLE_UDP),
|
||||
disable_udp: Config::get_option(keys::OPTION_DISABLE_UDP),
|
||||
allow_insecure_tls_fallback: Config::get_option(
|
||||
config::keys::OPTION_ALLOW_INSECURE_TLS_FALLBACK,
|
||||
keys::OPTION_ALLOW_INSECURE_TLS_FALLBACK,
|
||||
),
|
||||
api_server: Config::get_option("api-server"),
|
||||
}
|
||||
@@ -766,12 +767,12 @@ impl Drop for CheckIfRestart {
|
||||
// No need to check if https proxy is used, because this option does not change frequently
|
||||
// and restarting mediator is safe even https proxy is not used.
|
||||
let allow_insecure_tls_fallback_changed = self.allow_insecure_tls_fallback
|
||||
!= Config::get_option(config::keys::OPTION_ALLOW_INSECURE_TLS_FALLBACK);
|
||||
!= Config::get_option(keys::OPTION_ALLOW_INSECURE_TLS_FALLBACK);
|
||||
if allow_insecure_tls_fallback_changed
|
||||
|| self.stop_service != Config::get_option("stop-service")
|
||||
|| self.rendezvous_servers != Config::get_rendezvous_servers()
|
||||
|| self.ws != Config::get_option(OPTION_ALLOW_WEBSOCKET)
|
||||
|| self.disable_udp != Config::get_option(config::keys::OPTION_DISABLE_UDP)
|
||||
|| self.disable_udp != Config::get_option(keys::OPTION_DISABLE_UDP)
|
||||
|| self.api_server != Config::get_option("api-server")
|
||||
{
|
||||
if allow_insecure_tls_fallback_changed {
|
||||
@@ -1035,7 +1036,7 @@ async fn handle(data: Data, stream: &mut Connection) {
|
||||
allow_err!(
|
||||
stream
|
||||
.send(&Data::SyncWinCpuUsage(
|
||||
hbb_common::platform::windows::cpu_uage_one_minute()
|
||||
base::platform::windows::cpu_uage_one_minute()
|
||||
))
|
||||
.await
|
||||
);
|
||||
@@ -1227,7 +1228,7 @@ async fn handle(data: Data, stream: &mut Connection) {
|
||||
let state = crate::server::get_control_permission_state(Permission::file, false);
|
||||
let enabled = state.unwrap_or_else(|| {
|
||||
crate::server::Connection::is_permission_enabled_locally(
|
||||
config::keys::OPTION_ENABLE_FILE_TRANSFER,
|
||||
keys::OPTION_ENABLE_FILE_TRANSFER,
|
||||
)
|
||||
});
|
||||
allow_err!(
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::ui_session_interface::{InvokeUiSession, Session};
|
||||
use crate::{client::get_key_state, common::GrabState};
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use hbb_common::log;
|
||||
use hbb_common::message_proto::*;
|
||||
use base::message_proto::*;
|
||||
#[cfg(any(target_os = "windows", target_os = "macos"))]
|
||||
use rdev::KeyCode;
|
||||
use rdev::{Event, EventType, Key};
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
// Sometimes reboot is needed to refresh sudoers.
|
||||
|
||||
use crate::lang::translate;
|
||||
use base::platform::linux::CMD_SH;
|
||||
use gtk::{glib, prelude::*};
|
||||
use hbb_common::{
|
||||
anyhow::{bail, Error},
|
||||
log,
|
||||
platform::linux::CMD_SH,
|
||||
ResultType,
|
||||
log, ResultType,
|
||||
};
|
||||
use nix::{
|
||||
libc::{fcntl, kill},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::{gtk_sudo, CursorData, ResultType};
|
||||
use desktop::Desktop;
|
||||
pub use hbb_common::platform::linux::*;
|
||||
pub use base::platform::linux::*;
|
||||
|
||||
#[cfg(feature = "drm")]
|
||||
pub fn dispatch_wayland_display_probe() {
|
||||
@@ -17,10 +17,10 @@ use hbb_common::{
|
||||
config::Config,
|
||||
libc::{c_char, c_int, c_long, c_uint, c_ulong, c_void},
|
||||
log,
|
||||
message_proto::{DisplayInfo, Resolution},
|
||||
regex::{Captures, Regex},
|
||||
users::{get_user_by_name, os::unix::UserExt},
|
||||
};
|
||||
use base::message_proto::{DisplayInfo, Resolution};
|
||||
use libxdo_sys::{self, xdo_t, Window};
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
@@ -64,7 +64,7 @@ lazy_static::lazy_static! {
|
||||
/// serve but the DRM path can. Unmemoised lookup on purpose: this may run mid-boot, and
|
||||
/// a "no" cached that early would be wrong for the rest of the process.
|
||||
pub static ref IS_X11: bool = {
|
||||
let x11 = hbb_common::platform::linux::is_x11_or_headless();
|
||||
let x11 = base::platform::linux::is_x11_or_headless();
|
||||
#[cfg(feature = "drm")]
|
||||
{
|
||||
if x11 && !display_server_forced() && is_login_screen_wayland() {
|
||||
|
||||
@@ -20,9 +20,9 @@ use core_graphics::{
|
||||
use hbb_common::{
|
||||
anyhow::anyhow,
|
||||
bail, log,
|
||||
message_proto::{DisplayInfo, Resolution},
|
||||
sysinfo::{Pid, Process, ProcessRefreshKind, System},
|
||||
};
|
||||
use base::message_proto::{DisplayInfo, Resolution};
|
||||
use include_dir::{include_dir, Dir};
|
||||
use objc::rc::autoreleasepool;
|
||||
use objc::{class, msg_send, sel, sel_impl};
|
||||
|
||||
@@ -23,13 +23,15 @@ pub mod linux;
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod gtk_sudo;
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use base::message_proto::CursorData;
|
||||
#[cfg(all(
|
||||
not(all(target_os = "windows", not(target_pointer_width = "64"))),
|
||||
not(any(target_os = "android", target_os = "ios"))
|
||||
))]
|
||||
use hbb_common::sysinfo::System;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use hbb_common::{message_proto::CursorData, sysinfo::Pid, ResultType};
|
||||
use hbb_common::{sysinfo::Pid, ResultType};
|
||||
use std::sync::{Arc, Mutex};
|
||||
#[cfg(not(any(target_os = "macos", target_os = "android", target_os = "ios")))]
|
||||
pub const SERVICE_INTERVAL: u64 = 300;
|
||||
|
||||
@@ -5,15 +5,14 @@ use crate::{
|
||||
ipc,
|
||||
privacy_mode::win_topmost_window::{self, WIN_TOPMOST_INJECTED_PROCESS_EXE},
|
||||
};
|
||||
use base::message_proto::{DisplayInfo, Resolution, WindowsSession};
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
anyhow::anyhow,
|
||||
bail,
|
||||
config::{self, Config},
|
||||
libc::{c_int, wchar_t},
|
||||
log,
|
||||
message_proto::{DisplayInfo, Resolution, WindowsSession},
|
||||
sleep,
|
||||
log, sleep,
|
||||
sysinfo::{Pid, System},
|
||||
timeout, tokio,
|
||||
};
|
||||
@@ -2482,7 +2481,7 @@ pub fn elevate_or_run_as_system(is_setup: bool, is_elevate: bool, is_run_as_syst
|
||||
}
|
||||
|
||||
pub fn is_elevated(process_id: Option<DWORD>) -> ResultType<bool> {
|
||||
use hbb_common::platform::windows::RAIIHandle;
|
||||
use base::platform::windows::RAIIHandle;
|
||||
unsafe {
|
||||
let handle: HANDLE = match process_id {
|
||||
Some(process_id) => OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id),
|
||||
@@ -4754,7 +4753,7 @@ mod tests {
|
||||
// Test-only reusable Win32 HANDLE RAII helper.
|
||||
// If a future non-test path needs the same pattern, move it out of this test module.
|
||||
//
|
||||
// This struct is similar to `hbb_common::platform::windows::RAIIHandle`,
|
||||
// This struct is similar to `base::platform::windows::RAIIHandle`,
|
||||
// but `RAIIHandle` depends on `WinApi` crate, while this `HandleGuard` only depends on `windows` crate.
|
||||
struct HandleGuard(WinHANDLE);
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ use hbb_common::{
|
||||
config::READ_TIMEOUT,
|
||||
futures::{SinkExt, StreamExt},
|
||||
log,
|
||||
message_proto::*,
|
||||
protobuf::Message as _,
|
||||
rendezvous_proto::ConnType,
|
||||
tcp, timeout,
|
||||
@@ -15,6 +14,7 @@ use hbb_common::{
|
||||
tokio_util::codec::{BytesCodec, Framed},
|
||||
ResultType, Stream,
|
||||
};
|
||||
use base::message_proto::*;
|
||||
|
||||
fn run_rdp(port: u16, name: &str) {
|
||||
std::process::Command::new("cmdkey")
|
||||
@@ -551,7 +551,8 @@ fn take_socket(forward: Framed<TcpStream, BytesCodec>, mut prebuf: Vec<u8>) -> (
|
||||
|
||||
/// The controlling side's `enable-port-forward-mux`: on unless set to `N`.
|
||||
pub fn mux_enabled() -> bool {
|
||||
use hbb_common::config::{keys, option2bool, LocalConfig};
|
||||
use hbb_common::config::{option2bool, LocalConfig};
|
||||
use base::config::keys;
|
||||
option2bool(
|
||||
keys::OPTION_ENABLE_PORT_FORWARD_MUX,
|
||||
&LocalConfig::get_option(keys::OPTION_ENABLE_PORT_FORWARD_MUX),
|
||||
@@ -816,7 +817,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn port_forward_mux_defaults_to_on() {
|
||||
use hbb_common::config::{keys, option2bool};
|
||||
use hbb_common::config::option2bool;
|
||||
use base::config::keys;
|
||||
// option2bool's fallback branch is also "on unless N", so the value
|
||||
// assertions below would pass for a prefixless key too. The `enable-`
|
||||
// prefix is what actually guarantees the default, and renaming the key
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use hbb_common::{
|
||||
bytes::Bytes,
|
||||
log,
|
||||
message_proto::*,
|
||||
tokio::{
|
||||
self,
|
||||
io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt},
|
||||
@@ -10,6 +9,7 @@ use hbb_common::{
|
||||
},
|
||||
ResultType,
|
||||
};
|
||||
use base::message_proto::*;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
/// On the wire and fixed forever: what the controller may have in flight on a
|
||||
@@ -892,7 +892,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn frame_builders_set_the_expected_union_variant() {
|
||||
use hbb_common::message_proto::{message, port_forward_channel};
|
||||
use base::message_proto::{message, port_forward_channel};
|
||||
let m = data_msg(7, Bytes::from_static(b"abc"));
|
||||
match m.union {
|
||||
Some(message::Union::PortForwardChannel(ch)) => match ch.union {
|
||||
@@ -917,7 +917,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
use hbb_common::message_proto::{message, port_forward_channel};
|
||||
use base::message_proto::{message, port_forward_channel};
|
||||
use hbb_common::tokio::{self, io::AsyncReadExt, io::AsyncWriteExt, sync::mpsc};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use hbb_common::platform::windows::is_windows_version_or_greater;
|
||||
use base::platform::windows::is_windows_version_or_greater;
|
||||
|
||||
pub use super::win_topmost_window::PrivacyModeImpl;
|
||||
|
||||
|
||||
@@ -14,9 +14,7 @@ use uuid::Uuid;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
anyhow::{self, bail},
|
||||
config::{
|
||||
self, keys::*, option2bool, use_ws, Config, CONNECT_TIMEOUT, REG_INTERVAL, RENDEZVOUS_PORT,
|
||||
},
|
||||
config::{self, option2bool, use_ws, Config, CONNECT_TIMEOUT, REG_INTERVAL, RENDEZVOUS_PORT},
|
||||
futures::future::join_all,
|
||||
log,
|
||||
protobuf::Message as _,
|
||||
@@ -32,6 +30,7 @@ use hbb_common::{
|
||||
webrtc::WebRTCStream,
|
||||
AddrMangle, IntoTargetAddr, ResultType, Stream, TargetAddr,
|
||||
};
|
||||
use base::config::keys::*;
|
||||
|
||||
use crate::{
|
||||
check_port,
|
||||
|
||||
@@ -17,13 +17,13 @@ use hbb_common::{
|
||||
bail,
|
||||
config::{Config, CONNECT_TIMEOUT, RELAY_PORT},
|
||||
log,
|
||||
message_proto::*,
|
||||
protobuf::{Enum, Message as _},
|
||||
rendezvous_proto::*,
|
||||
socket_client,
|
||||
sodiumoxide::crypto::{box_, sign},
|
||||
timeout, tokio, ResultType, Stream,
|
||||
};
|
||||
use base::message_proto::*;
|
||||
use scrap::camera;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use service::ServiceTmpl;
|
||||
@@ -597,7 +597,7 @@ pub async fn start_server(is_server: bool, no_server: bool) {
|
||||
log::info!("XAUTHORITY={:?}", std::env::var("XAUTHORITY"));
|
||||
}
|
||||
#[cfg(windows)]
|
||||
hbb_common::platform::windows::start_cpu_performance_monitor();
|
||||
base::platform::windows::start_cpu_performance_monitor();
|
||||
});
|
||||
|
||||
if is_server {
|
||||
|
||||
@@ -11,12 +11,14 @@ pub use crate::{
|
||||
clipboard::{check_clipboard_files, FILE_CLIPBOARD_NAME as FILE_NAME},
|
||||
clipboard_file::unix_file_clip,
|
||||
};
|
||||
#[cfg(target_os = "android")]
|
||||
use base::config::keys;
|
||||
#[cfg(all(feature = "unix-file-copy-paste", target_os = "linux"))]
|
||||
use clipboard::platform::unix::fuse::{init_fuse_context, uninit_fuse_context};
|
||||
#[cfg(not(target_os = "android"))]
|
||||
use clipboard_master::CallbackResult;
|
||||
#[cfg(target_os = "android")]
|
||||
use hbb_common::config::{keys, option2bool};
|
||||
use hbb_common::config::option2bool;
|
||||
#[cfg(target_os = "android")]
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::{
|
||||
|
||||
@@ -30,13 +30,11 @@ use hbb_common::protobuf::EnumOrUnknown;
|
||||
use hbb_common::{
|
||||
config::{
|
||||
self, decode_permanent_password_h1_from_storage, decode_preset_password_h1_from_storage,
|
||||
keys, local_permanent_password_storage_is_usable_for_auth,
|
||||
local_permanent_password_storage_is_usable_for_auth,
|
||||
preset_permanent_password_storage_is_usable_for_auth, Config, TrustedDevice,
|
||||
},
|
||||
fs::{self, can_enable_overwrite_detection, JobType},
|
||||
futures::{SinkExt, StreamExt},
|
||||
get_time, get_version_number,
|
||||
message_proto::{option_message::BoolOption, permission_info::Permission},
|
||||
password_security::{self as password, ApproveMode},
|
||||
sha2::{Digest, Sha256},
|
||||
sleep, timeout,
|
||||
@@ -47,6 +45,11 @@ use hbb_common::{
|
||||
},
|
||||
tokio_util::codec::{BytesCodec, Framed},
|
||||
};
|
||||
use base::{
|
||||
config::keys,
|
||||
fs::{self, can_enable_overwrite_detection, JobType},
|
||||
message_proto::{option_message::BoolOption, permission_info::Permission},
|
||||
};
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
use scrap::android::{call_main_service_key_event, call_main_service_pointer_input};
|
||||
use scrap::camera;
|
||||
@@ -5980,7 +5983,7 @@ impl Connection {
|
||||
"Process clipboard message from clip, stop: {}, is_stopping_allowed: {}, file_transfer_enabled: {}",
|
||||
stop, is_stopping_allowed, file_transfer_enabled);
|
||||
if !stop {
|
||||
use hbb_common::config::keys::OPTION_ONE_WAY_FILE_TRANSFER;
|
||||
use base::config::keys::OPTION_ONE_WAY_FILE_TRANSFER;
|
||||
// Note: Code will not reach here if `crate::get_builtin_option(OPTION_ONE_WAY_FILE_TRANSFER) == "Y"` is true.
|
||||
// Because `file-clipboard` service will not be subscribed.
|
||||
// But we still check it here to keep the same logic to windows version in `ui_cm_interface.rs`.
|
||||
|
||||
@@ -158,7 +158,7 @@ pub(super) fn set_wayland_layout_baseline(baseline: Vec<scrap::wayland::display:
|
||||
/// before taking that layout. See `WaylandLayout::note_capturer`.
|
||||
#[cfg(all(target_os = "linux", feature = "drm"))]
|
||||
pub(super) fn note_capturer_layout(
|
||||
displays: &[hbb_common::platform::linux::WaylandDisplayInfo],
|
||||
displays: &[base::platform::linux::WaylandDisplayInfo],
|
||||
built_gen: u64,
|
||||
) {
|
||||
if displays.is_empty() {
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
// privileged export (open + grab the scanout dma-buf fd), the EGL detile / RGBA convert runs here.
|
||||
|
||||
use crate::ipc::{connect_drm, Data, DrmDisplayInfo};
|
||||
use hbb_common::{anyhow::anyhow, bail, log, message_proto::DisplayInfo, tokio, ResultType};
|
||||
use hbb_common::{anyhow::anyhow, bail, log, tokio, ResultType};
|
||||
use base::message_proto::DisplayInfo;
|
||||
use scrap::drm_render::RenderConverter;
|
||||
use scrap::drmtap_dl::drmtap_dmabuf_desc;
|
||||
use scrap::{Frame, Pixfmt, PixelBuffer, TraitCapturer};
|
||||
@@ -1581,7 +1582,7 @@ fn augment_with_wayland_geometry_from(
|
||||
/// earlier connector must never steal an exact name match from a later one.
|
||||
fn identity_matches(
|
||||
drm: &[DrmDisplayInfo],
|
||||
wl: &[hbb_common::platform::linux::WaylandDisplayInfo],
|
||||
wl: &[base::platform::linux::WaylandDisplayInfo],
|
||||
) -> Vec<Option<usize>> {
|
||||
let mut taken = vec![false; wl.len()];
|
||||
let mut matched: Vec<Option<usize>> = vec![None; drm.len()];
|
||||
@@ -1621,7 +1622,7 @@ fn identity_matches(
|
||||
|
||||
fn assign_wayland_outputs(
|
||||
drm: &[DrmDisplayInfo],
|
||||
wl: &[hbb_common::platform::linux::WaylandDisplayInfo],
|
||||
wl: &[base::platform::linux::WaylandDisplayInfo],
|
||||
) -> Vec<Option<usize>> {
|
||||
let mut matched = identity_matches(drm, wl);
|
||||
let mut taken = vec![false; wl.len()];
|
||||
@@ -2107,8 +2108,8 @@ mod drm_capturer_tests {
|
||||
y: i32,
|
||||
w: i32,
|
||||
h: i32,
|
||||
) -> hbb_common::platform::linux::WaylandDisplayInfo {
|
||||
hbb_common::platform::linux::WaylandDisplayInfo {
|
||||
) -> base::platform::linux::WaylandDisplayInfo {
|
||||
base::platform::linux::WaylandDisplayInfo {
|
||||
name: name.to_owned(),
|
||||
x,
|
||||
y,
|
||||
|
||||
@@ -4,14 +4,13 @@ use super::*;
|
||||
use crate::input::*;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use crate::whiteboard;
|
||||
use base::message_proto::{
|
||||
pointer_device_event::Union::TouchEvent, touch_event::Union::ScaleUpdate,
|
||||
};
|
||||
#[cfg(target_os = "macos")]
|
||||
use dispatch::Queue;
|
||||
use enigo::{Enigo, Key, KeyboardControllable, MouseButton, MouseControllable};
|
||||
use hbb_common::{
|
||||
get_time,
|
||||
message_proto::{pointer_device_event::Union::TouchEvent, touch_event::Union::ScaleUpdate},
|
||||
protobuf::EnumOrUnknown,
|
||||
};
|
||||
use hbb_common::{get_time, protobuf::EnumOrUnknown};
|
||||
use rdev::{self, EventType, Key as RdevKey, KeyCode, RawKey};
|
||||
#[cfg(target_os = "macos")]
|
||||
use rdev::{CGEventSourceStateID, CGEventTapLocation, VirtualInput};
|
||||
|
||||
@@ -6,10 +6,10 @@ use crate::port_forward_mux::{
|
||||
use hbb_common::{
|
||||
bytes::Bytes,
|
||||
log,
|
||||
message_proto::*,
|
||||
timeout,
|
||||
tokio::{self, net::TcpStream, sync::{mpsc, watch}},
|
||||
};
|
||||
use base::message_proto::*;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::{Arc, Mutex},
|
||||
@@ -262,7 +262,6 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::port_forward_mux::{CHANNEL_WINDOW, INITIAL_WINDOW, MAX_CHANNELS, MIN_FRAME_CHARGE};
|
||||
use hbb_common::{
|
||||
message_proto::{message, port_forward_channel},
|
||||
tokio::{
|
||||
self,
|
||||
io::{AsyncReadExt, AsyncWriteExt},
|
||||
@@ -271,6 +270,7 @@ mod tests {
|
||||
time::Instant,
|
||||
},
|
||||
};
|
||||
use base::message_proto::{message, port_forward_channel};
|
||||
|
||||
fn rt() -> tokio::runtime::Runtime {
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
|
||||
@@ -6,12 +6,12 @@ use crate::{
|
||||
validate_path_for_portable_service_shmem_dir,
|
||||
},
|
||||
};
|
||||
use base::message_proto::{KeyEvent, MouseEvent};
|
||||
use core::slice;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
anyhow::anyhow,
|
||||
bail, libc, log,
|
||||
message_proto::{KeyEvent, MouseEvent},
|
||||
protobuf::Message,
|
||||
tokio::{self, sync::mpsc},
|
||||
ResultType,
|
||||
@@ -435,7 +435,7 @@ mod utils {
|
||||
|
||||
// functions called in separate SYSTEM user process.
|
||||
pub mod server {
|
||||
use hbb_common::message_proto::PointerDeviceEvent;
|
||||
use base::message_proto::PointerDeviceEvent;
|
||||
|
||||
use crate::display_service;
|
||||
|
||||
@@ -826,7 +826,8 @@ pub mod server {
|
||||
pub mod client {
|
||||
use super::*;
|
||||
use crate::display_service;
|
||||
use hbb_common::{anyhow::Context, message_proto::PointerDeviceEvent};
|
||||
use base::message_proto::PointerDeviceEvent;
|
||||
use hbb_common::anyhow::Context;
|
||||
use scrap::PixelBuffer;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub mod client {
|
||||
use hbb_common::platform::linux::{DISPLAY_DESKTOP_KDE, XDG_CURRENT_DESKTOP};
|
||||
use base::platform::linux::{DISPLAY_DESKTOP_KDE, XDG_CURRENT_DESKTOP};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
||||
@@ -1076,7 +1076,7 @@ fn get_recorder(
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
fn check_change_scale(hardware: bool) -> ResultType<()> {
|
||||
use hbb_common::config::keys::OPTION_ENABLE_ANDROID_SOFTWARE_ENCODING_HALF_SCALE as SCALE_SOFT;
|
||||
use base::config::keys::OPTION_ENABLE_ANDROID_SOFTWARE_ENCODING_HALF_SCALE as SCALE_SOFT;
|
||||
|
||||
// isStart flag is set at the end of startCapture() in Android, wait it to be set.
|
||||
let n = 60; // 3s
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use super::*;
|
||||
use hbb_common::{allow_err, anyhow, platform::linux::DISTRO};
|
||||
use hbb_common::{allow_err, anyhow};
|
||||
use base::platform::linux::DISTRO;
|
||||
use scrap::{
|
||||
is_cursor_embedded, set_map_err,
|
||||
wayland::pipewire::{fill_displays, try_fix_logical_size},
|
||||
|
||||
@@ -4,12 +4,13 @@ use crate::ipc::Data;
|
||||
#[cfg(windows)]
|
||||
use hbb_common::tokio;
|
||||
use hbb_common::{allow_err, log};
|
||||
use base::config::keys;
|
||||
use std::sync::{Arc, Mutex};
|
||||
#[cfg(windows)]
|
||||
use std::time::Duration;
|
||||
|
||||
pub fn start_tray() {
|
||||
if crate::ui_interface::get_builtin_option(hbb_common::config::keys::OPTION_HIDE_TRAY) == "Y" {
|
||||
if crate::ui_interface::get_builtin_option(keys::OPTION_HIDE_TRAY) == "Y" {
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
return;
|
||||
@@ -64,7 +65,7 @@ fn make_tray() -> hbb_common::ResultType<()> {
|
||||
|
||||
let tray_menu = Menu::new();
|
||||
let hide_stop_service = crate::ui_interface::get_builtin_option(
|
||||
hbb_common::config::keys::OPTION_HIDE_STOP_SERVICE,
|
||||
keys::OPTION_HIDE_STOP_SERVICE,
|
||||
) == "Y";
|
||||
// The tray icon is only shown when the service is running, so we don't need to check
|
||||
// the `stop-service` option here.
|
||||
@@ -147,7 +148,7 @@ fn make_tray() -> hbb_common::ResultType<()> {
|
||||
if let tao::event::Event::NewEvents(tao::event::StartCause::Init) = event {
|
||||
// for fixing https://github.com/rustdesk/rustdesk/discussions/10210#discussioncomment-14600745
|
||||
// so we start tray, but not to show it
|
||||
if crate::ui_interface::get_builtin_option(hbb_common::config::keys::OPTION_HIDE_TRAY) == "Y" {
|
||||
if crate::ui_interface::get_builtin_option(keys::OPTION_HIDE_TRAY) == "Y" {
|
||||
return;
|
||||
}
|
||||
// We create the icon once the event loop is actually running
|
||||
|
||||
@@ -15,7 +15,10 @@ use sciter::{
|
||||
};
|
||||
|
||||
use hbb_common::{
|
||||
allow_err, fs::TransferJobMeta, log, message_proto::*, rendezvous_proto::ConnType,
|
||||
allow_err, log, rendezvous_proto::ConnType,
|
||||
};
|
||||
use base::{
|
||||
fs::TransferJobMeta, message_proto::*,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
|
||||
@@ -5,20 +5,24 @@ use crate::ipc::{self, Data};
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::{clipboard::ClipboardSide, ipc::ClipboardNonFile};
|
||||
#[cfg(target_os = "windows")]
|
||||
use clipboard::ContextSend;
|
||||
use base::config::keys::*;
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
use hbb_common::fs::serialize_transfer_job;
|
||||
use base::fs::serialize_transfer_job;
|
||||
use base::{
|
||||
config::keys::{OPTION_ENABLE_PERM_CHANGE_IN_ACCEPT_WINDOW, OPTION_FILE_TRANSFER_MAX_FILES},
|
||||
fs::{self, get_string, is_write_need_confirmation, new_send_confirm, DigestCheckResult},
|
||||
message_proto::*,
|
||||
};
|
||||
#[cfg(target_os = "windows")]
|
||||
use clipboard::ContextSend;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use hbb_common::tokio::sync::mpsc::unbounded_channel;
|
||||
#[cfg(target_os = "windows")]
|
||||
use hbb_common::tokio::sync::Mutex as TokioMutex;
|
||||
use hbb_common::{
|
||||
allow_err, bail,
|
||||
config::{
|
||||
keys::{OPTION_ENABLE_PERM_CHANGE_IN_ACCEPT_WINDOW, OPTION_FILE_TRANSFER_MAX_FILES},
|
||||
option2bool, Config,
|
||||
},
|
||||
fs::{self, get_string, is_write_need_confirmation, new_send_confirm, DigestCheckResult},
|
||||
config::{option2bool, Config},
|
||||
log,
|
||||
message_proto::*,
|
||||
protobuf::Message as _,
|
||||
tokio::{
|
||||
self,
|
||||
@@ -27,8 +31,6 @@ use hbb_common::{
|
||||
},
|
||||
ResultType,
|
||||
};
|
||||
#[cfg(target_os = "windows")]
|
||||
use hbb_common::{config::keys::*, tokio::sync::Mutex as TokioMutex};
|
||||
use serde_derive::Serialize;
|
||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
|
||||
use std::iter::FromIterator;
|
||||
@@ -1400,7 +1402,7 @@ async fn start_read_job(
|
||||
/// Process read jobs periodically, reading file blocks and sending them via IPC.
|
||||
///
|
||||
/// NOTE: This is the CM-side equivalent of `handle_read_jobs()` in
|
||||
/// `libs/hbb_common/src/fs.rs`. The logic mirrors that implementation
|
||||
/// `libs/base/src/fs.rs`. The logic mirrors that implementation
|
||||
/// but communicates via IPC instead of direct network stream.
|
||||
/// When modifying job processing logic, ensure both implementations stay in sync.
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
@@ -1499,7 +1501,7 @@ async fn handle_read_jobs_tick(
|
||||
/// Initialize a read job's data stream and handle digest sending for overwrite detection.
|
||||
///
|
||||
/// NOTE: This is the CM-side equivalent of `TransferJob::init_data_stream()` in
|
||||
/// `libs/hbb_common/src/fs.rs`. It calls `init_data_stream_for_cm()` and sends
|
||||
/// `libs/base/src/fs.rs`. It calls `init_data_stream_for_cm()` and sends
|
||||
/// digest via IPC instead of direct network stream.
|
||||
/// When modifying initialization or digest logic, ensure both paths stay in sync.
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
@@ -1777,10 +1779,8 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
use crate::ipc::Data;
|
||||
use hbb_common::{
|
||||
message_proto::{FileDirectory, Message},
|
||||
tokio::{runtime::Runtime, sync::mpsc::unbounded_channel},
|
||||
};
|
||||
use base::message_proto::{FileDirectory, Message};
|
||||
use hbb_common::tokio::{runtime::Runtime, sync::mpsc::unbounded_channel};
|
||||
use std::fs;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use base::config::keys::{self, *};
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
use hbb_common::password_security;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
bytes::Bytes,
|
||||
config::{self, keys::*, Config, LocalConfig, PeerConfig, CONNECT_TIMEOUT, RENDEZVOUS_PORT},
|
||||
config::{self, Config, LocalConfig, PeerConfig, CONNECT_TIMEOUT, RENDEZVOUS_PORT},
|
||||
directories_next,
|
||||
futures::future::join_all,
|
||||
log,
|
||||
@@ -185,11 +186,11 @@ pub fn use_texture_render() -> bool {
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
return cfg!(feature = "flutter")
|
||||
&& LocalConfig::get_option(config::keys::OPTION_TEXTURE_RENDER) == "Y";
|
||||
&& LocalConfig::get_option(keys::OPTION_TEXTURE_RENDER) == "Y";
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
return cfg!(feature = "flutter")
|
||||
&& LocalConfig::get_option(config::keys::OPTION_TEXTURE_RENDER) != "N";
|
||||
&& LocalConfig::get_option(keys::OPTION_TEXTURE_RENDER) != "N";
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
@@ -202,9 +203,9 @@ pub fn use_texture_render() -> bool {
|
||||
#[cfg(not(debug_assertions))]
|
||||
let default_texture = crate::platform::is_win_10_or_greater();
|
||||
if default_texture {
|
||||
LocalConfig::get_option(config::keys::OPTION_TEXTURE_RENDER) != "N"
|
||||
LocalConfig::get_option(keys::OPTION_TEXTURE_RENDER) != "N"
|
||||
} else {
|
||||
return LocalConfig::get_option(config::keys::OPTION_TEXTURE_RENDER) == "Y";
|
||||
return LocalConfig::get_option(keys::OPTION_TEXTURE_RENDER) == "Y";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,16 +7,16 @@ use crate::{
|
||||
ui_interface::use_texture_render,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use bytes::Bytes;
|
||||
#[cfg(all(target_os = "windows", not(feature = "flutter")))]
|
||||
use hbb_common::config::keys;
|
||||
use base::config::keys;
|
||||
#[cfg(not(feature = "flutter"))]
|
||||
use hbb_common::fs;
|
||||
use base::fs;
|
||||
use base::message_proto::*;
|
||||
use bytes::Bytes;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
config::{Config, LocalConfig, PeerConfig},
|
||||
get_version_number, log,
|
||||
message_proto::*,
|
||||
rendezvous_proto::ConnType,
|
||||
tokio::{
|
||||
self,
|
||||
@@ -1666,7 +1666,7 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
let to = std::env::temp_dir().join(format!("rustdesk_printer_{id}"));
|
||||
self.send(Data::SendFiles((
|
||||
id,
|
||||
hbb_common::fs::JobType::Printer,
|
||||
base::fs::JobType::Printer,
|
||||
path,
|
||||
to.to_string_lossy().to_string(),
|
||||
0,
|
||||
@@ -1908,7 +1908,7 @@ impl<T: InvokeUiSession> Interface for Session<T> {
|
||||
}
|
||||
}
|
||||
|
||||
fn swap_modifier_mouse(&self, msg: &mut hbb_common::protos::message::MouseEvent) {
|
||||
fn swap_modifier_mouse(&self, msg: &mut base::protos::message::MouseEvent) {
|
||||
let allow_swap_key = self.get_toggle_option("allow_swap_key".to_string());
|
||||
if allow_swap_key {
|
||||
msg.modifiers = msg
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::{common::do_check_software_update, hbbs_http::create_http_client_with_url_strict};
|
||||
use hbb_common::{bail, config, log, ResultType};
|
||||
use base::config::keys;
|
||||
use std::{
|
||||
io::Write,
|
||||
path::{Component, Path, PathBuf},
|
||||
@@ -181,7 +182,7 @@ fn check_update(manually: bool) -> ResultType<()> {
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
let update_msi = crate::platform::is_msi_installed()? && !crate::is_custom_client();
|
||||
if !(manually || config::Config::get_bool_option(config::keys::OPTION_ALLOW_AUTO_UPDATE)) {
|
||||
if !(manually || config::Config::get_bool_option(keys::OPTION_ALLOW_AUTO_UPDATE)) {
|
||||
return Ok(());
|
||||
}
|
||||
if do_check_software_update().is_err() {
|
||||
@@ -535,7 +536,7 @@ pub fn start_auto_update_macos() {
|
||||
pub fn check_update_as_root() -> ResultType<bool> {
|
||||
let _update_lock = acquire_mac_update_lock()?;
|
||||
// Allow-auto-update setting
|
||||
if !config::Config::get_bool_option(config::keys::OPTION_ALLOW_AUTO_UPDATE) {
|
||||
if !config::Config::get_bool_option(keys::OPTION_ALLOW_AUTO_UPDATE) {
|
||||
log::info!("[root-update] Auto update is disabled, skipping.");
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use hbb_common::{bail, platform::windows::is_windows_version_or_greater, ResultType};
|
||||
use base::platform::windows::is_windows_version_or_greater;
|
||||
use hbb_common::{bail, ResultType};
|
||||
|
||||
// This string is defined here.
|
||||
// https://github.com/rustdesk-org/RustDeskIddDriver/blob/b370aad3f50028b039aad211df60c8051c4a64d6/RustDeskIddDriver/RustDeskIddDriver.inf#LL73C1-L73C40
|
||||
|
||||
Reference in New Issue
Block a user