fix: remote printer, update install option (#11461)

* fix: remote printer, update install option

Signed-off-by: fufesou <linlong1266@gmail.com>

* Add comments

Signed-off-by: fufesou <linlong1266@gmail.com>

* Add comments

Signed-off-by: fufesou <linlong1266@gmail.com>

* Win, run_cmds, remove extra whitespace and newline

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2025-04-24 18:24:22 +08:00
committed by GitHub
parent 5c2538e7af
commit 279fb72a4f
5 changed files with 73 additions and 4 deletions

View File

@@ -274,6 +274,7 @@ pub enum Data {
ClearTrustedDevices,
#[cfg(all(target_os = "windows", feature = "flutter"))]
PrinterData(Vec<u8>),
InstallOption(Option<(String, String)>),
}
#[tokio::main(flavor = "current_thread")]
@@ -662,6 +663,23 @@ async fn handle(data: Data, stream: &mut Connection) {
Data::ClearTrustedDevices => {
Config::clear_trusted_devices();
}
Data::InstallOption(opt) => match opt {
Some((_k, _v)) => {
#[cfg(target_os = "windows")]
if let Err(e) = crate::platform::windows::update_install_option(&_k, &_v) {
log::error!(
"Failed to update install option \"{}\" to \"{}\", error: {}",
&_k,
&_v,
e
);
}
}
None => {
// `None` is usually used to get values.
// This branch is left blank for unification and further use.
}
},
_ => {}
}
}
@@ -1277,6 +1295,16 @@ async fn handle_wayland_screencast_restore_token(
return Ok(None);
}
#[tokio::main(flavor = "current_thread")]
pub async fn set_install_option(k: String, v: String) -> ResultType<()> {
if let Ok(mut c) = connect(1000, "").await {
c.send(&&Data::InstallOption(Some((k, v)))).await?;
// do not put below before connect, because we need to check should_exit
c.next_timeout(1000).await.ok();
}
Ok(())
}
#[cfg(test)]
mod test {
use super::*;