Merge pull request #3975 from fufesou/fix/disable_headless_on_flatpak_appimage
Fix/disable headless on flatpak appimage
This commit is contained in:
commit
8f3e63fdbf
4
.github/workflows/flutter-build.yml
vendored
4
.github/workflows/flutter-build.yml
vendored
@ -545,7 +545,7 @@ jobs:
|
|||||||
arch: x86_64,
|
arch: x86_64,
|
||||||
target: x86_64-unknown-linux-gnu,
|
target: x86_64-unknown-linux-gnu,
|
||||||
os: ubuntu-20.04,
|
os: ubuntu-20.04,
|
||||||
extra-build-features: "",
|
extra-build-features: "linux_headless",
|
||||||
}
|
}
|
||||||
- {
|
- {
|
||||||
arch: x86_64,
|
arch: x86_64,
|
||||||
@ -681,7 +681,7 @@ jobs:
|
|||||||
x86_64)
|
x86_64)
|
||||||
# no need mock on x86_64
|
# no need mock on x86_64
|
||||||
export VCPKG_ROOT=/opt/artifacts/vcpkg
|
export VCPKG_ROOT=/opt/artifacts/vcpkg
|
||||||
cargo build --lib --features hwcodec,flutter,flutter_texture_render,linux_headless,${{ matrix.job.extra-build-features }} --release
|
cargo build --lib --features hwcodec,flutter,flutter_texture_render,${{ matrix.job.extra-build-features }} --release
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ pub mod delegate;
|
|||||||
pub mod linux;
|
pub mod linux;
|
||||||
|
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
pub mod linux_desktop_manager;
|
pub mod linux_desktop_manager;
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
@ -73,6 +73,7 @@ impl RendezvousMediator {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
crate::platform::linux_desktop_manager::start_xdesktop();
|
crate::platform::linux_desktop_manager::start_xdesktop();
|
||||||
loop {
|
loop {
|
||||||
Config::reset_online();
|
Config::reset_online();
|
||||||
@ -101,6 +102,7 @@ impl RendezvousMediator {
|
|||||||
// It should be better to call stop_xdesktop.
|
// It should be better to call stop_xdesktop.
|
||||||
// But for server, it also is Ok without calling this method.
|
// But for server, it also is Ok without calling this method.
|
||||||
// #[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
// #[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
// #[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
// crate::platform::linux_desktop_manager::stop_xdesktop();
|
// crate::platform::linux_desktop_manager::stop_xdesktop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ use crate::clipboard_file::*;
|
|||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
use crate::common::update_clipboard;
|
use crate::common::update_clipboard;
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
use crate::platform::linux_desktop_manager;
|
use crate::platform::linux_desktop_manager;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use crate::portable_service::client as portable_client;
|
use crate::portable_service::client as portable_client;
|
||||||
@ -19,6 +20,7 @@ use crate::{common::DEVICE_NAME, flutter::connection_manager::start_channel};
|
|||||||
use crate::{ipc, VERSION};
|
use crate::{ipc, VERSION};
|
||||||
use cidr_utils::cidr::IpCidr;
|
use cidr_utils::cidr::IpCidr;
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
use hbb_common::platform::linux::run_cmds;
|
use hbb_common::platform::linux::run_cmds;
|
||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
config::Config,
|
config::Config,
|
||||||
@ -158,8 +160,10 @@ pub struct Connection {
|
|||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
pressed_modifiers: HashSet<rdev::Key>,
|
pressed_modifiers: HashSet<rdev::Key>,
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
rx_cm_stream_ready: mpsc::Receiver<()>,
|
rx_cm_stream_ready: mpsc::Receiver<()>,
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
tx_desktop_ready: mpsc::Sender<()>,
|
tx_desktop_ready: mpsc::Sender<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,8 +283,10 @@ impl Connection {
|
|||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
pressed_modifiers: Default::default(),
|
pressed_modifiers: Default::default(),
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
rx_cm_stream_ready: _rx_cm_stream_ready,
|
rx_cm_stream_ready: _rx_cm_stream_ready,
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
tx_desktop_ready: _tx_desktop_ready,
|
tx_desktop_ready: _tx_desktop_ready,
|
||||||
};
|
};
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
@ -895,6 +901,7 @@ impl Connection {
|
|||||||
platform_additions.insert("is_wayland".into(), json!(true));
|
platform_additions.insert("is_wayland".into(), json!(true));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "linux_headless")]
|
#[cfg(feature = "linux_headless")]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
if linux_desktop_manager::is_headless() {
|
if linux_desktop_manager::is_headless() {
|
||||||
platform_additions.insert("headless".into(), json!(true));
|
platform_additions.insert("headless".into(), json!(true));
|
||||||
}
|
}
|
||||||
@ -1262,6 +1269,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
let desktop_err = match lr.os_login.as_ref() {
|
let desktop_err = match lr.os_login.as_ref() {
|
||||||
Some(os_login) => {
|
Some(os_login) => {
|
||||||
linux_desktop_manager::try_start_desktop(&os_login.username, &os_login.password)
|
linux_desktop_manager::try_start_desktop(&os_login.username, &os_login.password)
|
||||||
@ -1269,12 +1277,15 @@ impl Connection {
|
|||||||
None => linux_desktop_manager::try_start_desktop("", ""),
|
None => linux_desktop_manager::try_start_desktop("", ""),
|
||||||
};
|
};
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
let is_headless = linux_desktop_manager::is_headless();
|
let is_headless = linux_desktop_manager::is_headless();
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
let wait_ipc_timeout = 10_000;
|
let wait_ipc_timeout = 10_000;
|
||||||
|
|
||||||
// If err is LOGIN_MSG_DESKTOP_SESSION_NOT_READY, just keep this msg and go on checking password.
|
// If err is LOGIN_MSG_DESKTOP_SESSION_NOT_READY, just keep this msg and go on checking password.
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
if !desktop_err.is_empty() && desktop_err != LOGIN_MSG_DESKTOP_SESSION_NOT_READY {
|
if !desktop_err.is_empty() && desktop_err != LOGIN_MSG_DESKTOP_SESSION_NOT_READY {
|
||||||
self.send_login_error(desktop_err).await;
|
self.send_login_error(desktop_err).await;
|
||||||
return true;
|
return true;
|
||||||
@ -1299,6 +1310,7 @@ impl Connection {
|
|||||||
return false;
|
return false;
|
||||||
} else if self.is_recent_session() {
|
} else if self.is_recent_session() {
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
if desktop_err.is_empty() {
|
if desktop_err.is_empty() {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
if is_headless {
|
if is_headless {
|
||||||
@ -1323,6 +1335,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
} else if lr.password.is_empty() {
|
} else if lr.password.is_empty() {
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
if desktop_err.is_empty() {
|
if desktop_err.is_empty() {
|
||||||
self.try_start_cm(lr.my_id, lr.my_name, false);
|
self.try_start_cm(lr.my_id, lr.my_name, false);
|
||||||
} else {
|
} else {
|
||||||
@ -1372,6 +1385,7 @@ impl Connection {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(self.ip.clone(), failure);
|
.insert(self.ip.clone(), failure);
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
if desktop_err.is_empty() {
|
if desktop_err.is_empty() {
|
||||||
self.send_login_error(LOGIN_MSG_PASSWORD_WRONG).await;
|
self.send_login_error(LOGIN_MSG_PASSWORD_WRONG).await;
|
||||||
self.try_start_cm(lr.my_id, lr.my_name, false);
|
self.try_start_cm(lr.my_id, lr.my_name, false);
|
||||||
@ -1389,6 +1403,7 @@ impl Connection {
|
|||||||
LOGIN_FAILURES.lock().unwrap().remove(&self.ip);
|
LOGIN_FAILURES.lock().unwrap().remove(&self.ip);
|
||||||
}
|
}
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
if desktop_err.is_empty() {
|
if desktop_err.is_empty() {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
if is_headless {
|
if is_headless {
|
||||||
@ -2200,9 +2215,14 @@ async fn start_ipc(
|
|||||||
#[cfg(not(feature = "linux_headless"))]
|
#[cfg(not(feature = "linux_headless"))]
|
||||||
let user = None;
|
let user = None;
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(any(feature = "flatpak", feature = "appimage"))]
|
||||||
|
let user = None;
|
||||||
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
let mut user = None;
|
let mut user = None;
|
||||||
// Cm run as user, wait until desktop session is ready.
|
// Cm run as user, wait until desktop session is ready.
|
||||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||||
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||||
if linux_desktop_manager::is_headless() {
|
if linux_desktop_manager::is_headless() {
|
||||||
let mut username = linux_desktop_manager::get_username();
|
let mut username = linux_desktop_manager::get_username();
|
||||||
loop {
|
loop {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user