feat: remote printer (#11231)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2025-03-27 15:34:27 +08:00
committed by GitHub
parent 1cb53c1f7a
commit f4bbf82363
101 changed files with 3707 additions and 211 deletions

View File

@@ -379,6 +379,10 @@ impl InvokeUiSession for SciterHandler {
fn update_record_status(&self, start: bool) {
self.call("updateRecordStatus", &make_args!(start));
}
fn printer_request(&self, id: i32, path: String) {
self.call("printerRequest", &make_args!(id, path));
}
}
pub struct SciterSession(Session<SciterHandler>);
@@ -491,6 +495,8 @@ impl sciter::EventHandler for SciterSession {
fn get_chatbox();
fn get_icon();
fn get_home_dir();
fn get_next_job_id();
fn update_next_job_id(i32);
fn read_dir(String, bool);
fn remove_dir(i32, String, bool);
fn create_dir(i32, String, bool);
@@ -502,8 +508,8 @@ impl sciter::EventHandler for SciterSession {
fn confirm_delete_files(i32, i32);
fn set_no_confirm(i32);
fn cancel_job(i32);
fn send_files(i32, String, String, i32, bool, bool);
fn add_job(i32, String, String, i32, bool, bool);
fn send_files(i32, i32, String, String, i32, bool, bool);
fn add_job(i32, i32, String, String, i32, bool, bool);
fn resume_job(i32, bool);
fn get_platform(bool);
fn get_path_sep(bool);
@@ -541,6 +547,8 @@ impl sciter::EventHandler for SciterSession {
fn set_selected_windows_session_id(String);
fn is_recording();
fn has_file_clipboard();
fn get_printer_names();
fn on_printer_selected(i32, String, String);
}
}
@@ -842,6 +850,22 @@ impl SciterSession {
fn version_cmp(&self, v1: String, v2: String) -> i32 {
(hbb_common::get_version_number(&v1) - hbb_common::get_version_number(&v2)) as i32
}
fn get_printer_names(&self) -> Value {
#[cfg(target_os = "windows")]
let printer_names = crate::platform::windows::get_printer_names().unwrap_or_default();
#[cfg(not(target_os = "windows"))]
let printer_names: Vec<String> = vec![];
let mut v = Value::array(0);
for name in printer_names {
v.push(name);
}
v
}
fn on_printer_selected(&self, id: i32, path: String, printer_name: String) {
self.printer_response(id, path, printer_name);
}
}
pub fn make_fd(id: i32, entries: &Vec<FileEntry>, only_count: bool) -> Value {