mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-24 20:59:37 +08:00
add: remote ret back override confirmation
This commit is contained in:
parent
51caeafebd
commit
c17e77148e
@ -245,13 +245,13 @@ message FileAction {
|
||||
oneof union {
|
||||
ReadDir read_dir = 1;
|
||||
FileTransferSendRequest send = 2;
|
||||
FileTransferSendConfirmRequest send_confirm = 9;
|
||||
FileTransferReceiveRequest receive = 3;
|
||||
FileDirCreate create = 4;
|
||||
FileRemoveDir remove_dir = 5;
|
||||
FileRemoveFile remove_file = 6;
|
||||
ReadAllFiles all_files = 7;
|
||||
FileTransferCancel cancel = 8;
|
||||
FileTransferSendConfirmRequest send_confirm = 9;
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,6 +272,7 @@ message FileTransferDigest {
|
||||
sint32 file_num = 2;
|
||||
uint64 last_edit_timestamp = 3;
|
||||
uint64 file_size = 4;
|
||||
bool is_upload = 5;
|
||||
}
|
||||
|
||||
message FileTransferBlock {
|
||||
|
@ -455,8 +455,7 @@ impl TransferJob {
|
||||
file_num: self.file_num,
|
||||
last_edit_timestamp: last_modified,
|
||||
file_size: meta.len(),
|
||||
unknown_fields: Default::default(),
|
||||
cached_size: Default::default(),
|
||||
..Default::default()
|
||||
});
|
||||
msg.set_file_response(resp);
|
||||
stream.send(&msg).await?;
|
||||
|
@ -533,14 +533,14 @@ impl AudioHandler {
|
||||
}
|
||||
|
||||
self.simple = Some(Simple::new(
|
||||
None, // Use the default server
|
||||
&crate::get_app_name(), // Our application’s name
|
||||
Direction::Playback, // We want a playback stream
|
||||
None, // Use the default device
|
||||
"playback", // Description of our stream
|
||||
&spec, // Our sample format
|
||||
None, // Use default channel map
|
||||
None, // Use default buffering attributes
|
||||
None, // Use the default server
|
||||
&crate::get_app_name(), // Our application’s name
|
||||
Direction::Playback, // We want a playback stream
|
||||
None, // Use the default device
|
||||
"playback", // Description of our stream
|
||||
&spec, // Our sample format
|
||||
None, // Use default channel map
|
||||
None, // Use default buffering attributes
|
||||
)?);
|
||||
self.sample_rate = (format0.sample_rate, format0.sample_rate);
|
||||
Ok(())
|
||||
@ -1323,7 +1323,7 @@ pub enum Data {
|
||||
AddPortForward((i32, String, i32)),
|
||||
ToggleClipboardFile,
|
||||
NewRDP,
|
||||
SetConfirmOverrideFile((i32, i32, bool, bool)),
|
||||
SetConfirmOverrideFile((i32, i32, bool, bool, bool)),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -64,6 +64,7 @@ pub enum FS {
|
||||
file_num: i32,
|
||||
file_size: u64,
|
||||
modified_time: u64,
|
||||
is_upload: bool,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1052,6 +1052,7 @@ impl Connection {
|
||||
file_num: d.file_num,
|
||||
file_size: d.file_size,
|
||||
modified_time: d.last_edit_timestamp,
|
||||
is_upload: true,
|
||||
}),
|
||||
_ => {}
|
||||
},
|
||||
|
16
src/ui/cm.rs
16
src/ui/cm.rs
@ -189,6 +189,7 @@ impl ConnectionManager {
|
||||
file_num,
|
||||
file_size,
|
||||
modified_time,
|
||||
is_upload,
|
||||
} => {
|
||||
if let Some(job) = fs::get_job(id, write_jobs) {
|
||||
let mut req = FileTransferSendConfirmRequest {
|
||||
@ -208,21 +209,22 @@ impl ConnectionManager {
|
||||
let path = get_string(&job.join(&file.name));
|
||||
match is_write_need_confirmation(&path, &digest) {
|
||||
Ok(digest) => {
|
||||
if digest.is_none() {
|
||||
log::info!("skip job {}, file_num {}", id, file_num);
|
||||
req.set_skip(true);
|
||||
let msg_out = new_send_confirm(req);
|
||||
Self::send(msg_out, conn).await;
|
||||
} else {
|
||||
if let Some(mut digest) = digest {
|
||||
// upload to server, but server has the same file, request
|
||||
digest.is_upload = is_upload;
|
||||
println!(
|
||||
"server has the same file, send server digest to local"
|
||||
);
|
||||
let mut msg_out = Message::new();
|
||||
let mut fr = FileResponse::new();
|
||||
fr.set_digest(digest.unwrap());
|
||||
fr.set_digest(digest);
|
||||
msg_out.set_file_response(fr);
|
||||
Self::send(msg_out, conn).await;
|
||||
} else {
|
||||
log::info!("skip job {}, file_num {}", id, file_num);
|
||||
req.set_skip(true);
|
||||
let msg_out = new_send_confirm(req);
|
||||
Self::send(msg_out, conn).await;
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
|
@ -717,7 +717,7 @@ handler.confirmDeleteFiles = function(id, i, name) {
|
||||
});
|
||||
}
|
||||
|
||||
handler.overrideFileConfirm = function(id, file_num, to) {
|
||||
handler.overrideFileConfirm = function(id, file_num, to, is_upload) {
|
||||
var jt = file_transfer.job_table;
|
||||
var job = jt.job_map[id];
|
||||
stdout.println("job type: " + job.type);
|
||||
@ -732,15 +732,15 @@ handler.overrideFileConfirm = function(id, file_num, to) {
|
||||
jt.updateJobStatus(id, -1, "cancel");
|
||||
} else if (res.skip) {
|
||||
if (res.remember){
|
||||
handler.set_write_override(id,file_num,false,true); //
|
||||
handler.set_write_override(id,file_num,false,true, is_upload); //
|
||||
} else {
|
||||
handler.set_write_override(id,file_num,false,false); //
|
||||
handler.set_write_override(id,file_num,false,false,is_upload); //
|
||||
}
|
||||
} else {
|
||||
if (res.remember){
|
||||
handler.set_write_override(id,file_num,true,true); //
|
||||
handler.set_write_override(id,file_num,true,true,is_upload); //
|
||||
} else {
|
||||
handler.set_write_override(id,file_num,true,false); //
|
||||
handler.set_write_override(id,file_num,true,false,is_upload); //
|
||||
}
|
||||
}
|
||||
});
|
||||
|
145
src/ui/remote.rs
145
src/ui/remote.rs
@ -219,7 +219,7 @@ impl sciter::EventHandler for Handler {
|
||||
fn toggle_option(String);
|
||||
fn get_remember();
|
||||
fn peer_platform();
|
||||
fn set_write_override(i32,i32, bool,bool); // ,
|
||||
fn set_write_override(i32,i32, bool,bool,bool); // ,
|
||||
}
|
||||
}
|
||||
|
||||
@ -546,12 +546,14 @@ impl Handler {
|
||||
file_num: i32,
|
||||
is_override: bool,
|
||||
remember: bool,
|
||||
is_upload: bool,
|
||||
) -> bool {
|
||||
self.send(Data::SetConfirmOverrideFile((
|
||||
job_id,
|
||||
file_num,
|
||||
is_override,
|
||||
remember,
|
||||
is_upload,
|
||||
)));
|
||||
true
|
||||
}
|
||||
@ -1580,25 +1582,43 @@ impl Remote {
|
||||
}
|
||||
}
|
||||
}
|
||||
Data::SetConfirmOverrideFile((id, file_num, need_override, remember)) => {
|
||||
if let Some(job) = fs::get_job(id, &mut self.write_jobs) {
|
||||
if remember {
|
||||
job.set_overwrite_strategy(Some(need_override));
|
||||
Data::SetConfirmOverrideFile((id, file_num, need_override, remember, is_upload)) => {
|
||||
if is_upload {
|
||||
if let Some(job) = fs::get_job(id, &mut self.read_jobs) {
|
||||
if remember {
|
||||
job.set_overwrite_strategy(Some(need_override));
|
||||
}
|
||||
job.confirm(&FileTransferSendConfirmRequest {
|
||||
id,
|
||||
file_num,
|
||||
union: if need_override {
|
||||
Some(file_transfer_send_confirm_request::Union::offset_blk(0))
|
||||
} else {
|
||||
Some(file_transfer_send_confirm_request::Union::skip(true))
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if let Some(job) = fs::get_job(id, &mut self.write_jobs) {
|
||||
if remember {
|
||||
job.set_overwrite_strategy(Some(need_override));
|
||||
}
|
||||
let mut msg = Message::new();
|
||||
let mut file_action = FileAction::new();
|
||||
file_action.set_send_confirm(FileTransferSendConfirmRequest {
|
||||
id,
|
||||
file_num,
|
||||
union: if need_override {
|
||||
Some(file_transfer_send_confirm_request::Union::offset_blk(0))
|
||||
} else {
|
||||
Some(file_transfer_send_confirm_request::Union::skip(true))
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
msg.set_file_action(file_action);
|
||||
allow_err!(peer.send(&msg).await);
|
||||
}
|
||||
let mut msg = Message::new();
|
||||
let mut file_action = FileAction::new();
|
||||
file_action.set_send_confirm(FileTransferSendConfirmRequest {
|
||||
id,
|
||||
file_num,
|
||||
union: if need_override {
|
||||
Some(file_transfer_send_confirm_request::Union::offset_blk(0))
|
||||
} else {
|
||||
Some(file_transfer_send_confirm_request::Union::skip(true))
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
msg.set_file_action(file_action);
|
||||
allow_err!(peer.send(&msg).await);
|
||||
}
|
||||
}
|
||||
Data::RemoveDirAll((id, path, is_remote)) => {
|
||||
@ -1841,50 +1861,63 @@ impl Remote {
|
||||
}
|
||||
}
|
||||
Some(file_response::Union::digest(digest)) => {
|
||||
if let Some(job) = fs::get_job(digest.id, &mut self.write_jobs) {
|
||||
if let Some(file) = job.files().get(digest.file_num as usize) {
|
||||
let write_path = get_string(&job.join(&file.name));
|
||||
let overwrite_strategy = job.default_overwrite_strategy();
|
||||
match fs::is_write_need_confirmation(&write_path, &digest) {
|
||||
Ok(res) => {
|
||||
if res.is_some() {
|
||||
// need confirm
|
||||
if overwrite_strategy.is_none() {
|
||||
self.handler.call(
|
||||
"overrideFileConfirm",
|
||||
&make_args!(
|
||||
digest.id,
|
||||
digest.file_num,
|
||||
write_path
|
||||
),
|
||||
);
|
||||
} else {
|
||||
let msg = new_send_confirm(
|
||||
FileTransferSendConfirmRequest {
|
||||
id: digest.id,
|
||||
file_num: digest.file_num,
|
||||
union: if overwrite_strategy.unwrap() {
|
||||
Some(file_transfer_send_confirm_request::Union::offset_blk(0))
|
||||
} else {
|
||||
Some(file_transfer_send_confirm_request::Union::skip(true))
|
||||
if digest.is_upload {
|
||||
if let Some(job) = fs::get_job(digest.id, &mut self.read_jobs) {
|
||||
if let Some(file) = job.files().get(digest.file_num as usize) {
|
||||
let read_path = get_string(&job.join(&file.name));
|
||||
self.handler.call(
|
||||
"overrideFileConfirm",
|
||||
&make_args!(digest.id, digest.file_num, read_path, true),
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(job) = fs::get_job(digest.id, &mut self.write_jobs) {
|
||||
if let Some(file) = job.files().get(digest.file_num as usize) {
|
||||
let write_path = get_string(&job.join(&file.name));
|
||||
let overwrite_strategy = job.default_overwrite_strategy();
|
||||
match fs::is_write_need_confirmation(&write_path, &digest) {
|
||||
Ok(res) => {
|
||||
if res.is_some() {
|
||||
// need confirm
|
||||
if overwrite_strategy.is_none() {
|
||||
self.handler.call(
|
||||
"overrideFileConfirm",
|
||||
&make_args!(
|
||||
digest.id,
|
||||
digest.file_num,
|
||||
write_path,
|
||||
false
|
||||
),
|
||||
);
|
||||
} else {
|
||||
let msg = new_send_confirm(
|
||||
FileTransferSendConfirmRequest {
|
||||
id: digest.id,
|
||||
file_num: digest.file_num,
|
||||
union: if overwrite_strategy.unwrap() {
|
||||
Some(file_transfer_send_confirm_request::Union::offset_blk(0))
|
||||
} else {
|
||||
Some(file_transfer_send_confirm_request::Union::skip(true))
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
allow_err!(peer.send(&msg).await);
|
||||
}
|
||||
} else {
|
||||
let msg= new_send_confirm(FileTransferSendConfirmRequest {
|
||||
);
|
||||
allow_err!(peer.send(&msg).await);
|
||||
}
|
||||
} else {
|
||||
let msg= new_send_confirm(FileTransferSendConfirmRequest {
|
||||
id: digest.id,
|
||||
file_num: digest.file_num,
|
||||
union: Some(file_transfer_send_confirm_request::Union::skip(true)),
|
||||
..Default::default()
|
||||
});
|
||||
allow_err!(peer.send(&msg).await);
|
||||
allow_err!(peer.send(&msg).await);
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
println!("error recving digest: {}", err);
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
println!("error recving digest: {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user