This commit is contained in:
asur4s
2022-09-07 03:52:31 -04:00
43 changed files with 2863 additions and 3273 deletions

View File

@@ -1,9 +1,7 @@
use std::{
collections::HashMap,
ops::{Deref, DerefMut},
sync::{
Arc, Mutex,
},
sync::{Arc, Mutex},
};
use sciter::{
@@ -22,13 +20,15 @@ use clipboard::{
get_rx_clip_client, server_clip_file,
};
use hbb_common::{allow_err, log, message_proto::*, rendezvous_proto::ConnType};
use hbb_common::{
allow_err, fs::TransferJobMeta, log, message_proto::*, rendezvous_proto::ConnType,
};
#[cfg(windows)]
use crate::clipboard_file::*;
use crate::{
client::*,
ui_session_interface::{InvokeUi, Session},
ui_session_interface::{InvokeUiSession, Session},
};
type Video = AssetPtr<video_destination>;
@@ -37,12 +37,8 @@ lazy_static::lazy_static! {
static ref VIDEO: Arc<Mutex<Option<Video>>> = Default::default();
}
#[cfg(windows)]
static mut IS_ALT_GR: bool = false;
/// SciterHandler
/// * element
/// * thread TODO check if flutter need
/// * close_state for file path when close
#[derive(Clone, Default)]
pub struct SciterHandler {
@@ -66,7 +62,7 @@ impl SciterHandler {
}
}
impl InvokeUi for SciterHandler {
impl InvokeUiSession for SciterHandler {
fn set_cursor_data(&self, cd: CursorData) {
let mut colors = hbb_common::compress::decompress(&cd.colors);
if colors.iter().filter(|x| **x != 0).next().is_none() {
@@ -154,17 +150,36 @@ impl InvokeUi for SciterHandler {
self.call("clearAllJobs", &make_args!());
}
#[allow(unused_variables)]
fn add_job(
fn load_last_job(&self, cnt: i32, job_json: &str) {
let job: Result<TransferJobMeta, serde_json::Error> = serde_json::from_str(job_json);
if let Ok(job) = job {
let path;
let to;
if job.is_remote {
path = job.remote.clone();
to = job.to.clone();
} else {
path = job.to.clone();
to = job.remote.clone();
}
self.call(
"addJob",
&make_args!(cnt, path, to, job.file_num, job.show_hidden, job.is_remote),
);
}
}
fn update_folder_files(
&self,
id: i32,
entries: &Vec<FileEntry>,
path: String,
to: String,
file_num: i32,
show_hidden: bool,
is_remote: bool,
_is_local: bool,
only_count: bool,
) {
todo!()
let mut m = make_fd(id, entries, only_count);
m.set_item("path", path);
self.call("updateFolderFiles", &make_args!(m));
}
fn update_transfer_list(&self) {
@@ -426,6 +441,14 @@ impl SciterSession {
v
}
pub fn t(&self, name: String) -> String {
crate::client::translate(name)
}
pub fn get_icon(&self) -> String {
crate::get_icon()
}
fn supported_hwcodec(&self) -> Value {
#[cfg(feature = "hwcodec")]
{
@@ -693,11 +716,10 @@ pub fn make_fd(id: i32, entries: &Vec<FileEntry>, only_count: bool) -> Value {
e.set_item("size", entry.size as f64);
a.push(e);
}
if only_count {
m.set_item("num_entries", entries.len() as i32);
} else {
if !only_count {
m.set_item("entries", a);
}
m.set_item("num_entries", entries.len() as i32);
m.set_item("total_size", n as f64);
m
}