upgrade protobuf to 3.1.0 and use with-bytes feature, issues:958
This commit is contained in:
parent
4e45bc0ee0
commit
c6c5d2cb98
@ -7,7 +7,7 @@ edition = "2018"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
protobuf = "3.0.0-alpha.2"
|
protobuf = { version = "3.1.0", features = ["with-bytes"] }
|
||||||
tokio = { version = "1.15", features = ["full"] }
|
tokio = { version = "1.15", features = ["full"] }
|
||||||
tokio-util = { version = "0.6", features = ["full"] }
|
tokio-util = { version = "0.6", features = ["full"] }
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
@ -38,7 +38,7 @@ mac_address = "1.1"
|
|||||||
quic = []
|
quic = []
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
protobuf-codegen-pure = "3.0.0-alpha.2"
|
protobuf-codegen = { version = "3.1.0" }
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
winapi = { version = "0.3", features = ["winuser"] }
|
winapi = { version = "0.3", features = ["winuser"] }
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
std::fs::create_dir_all("src/protos").unwrap();
|
std::fs::create_dir_all("src/protos").unwrap();
|
||||||
protobuf_codegen_pure::Codegen::new()
|
protobuf_codegen::Codegen::new()
|
||||||
|
.pure()
|
||||||
.out_dir("src/protos")
|
.out_dir("src/protos")
|
||||||
.inputs(&["protos/rendezvous.proto", "protos/message.proto"])
|
.inputs(&["protos/rendezvous.proto", "protos/message.proto"])
|
||||||
.include("protos")
|
.include("protos")
|
||||||
|
@ -573,7 +573,7 @@ impl TransferJob {
|
|||||||
log::info!("file num truncated, ignoring");
|
log::info!("file num truncated, ignoring");
|
||||||
} else {
|
} else {
|
||||||
match r.union {
|
match r.union {
|
||||||
Some(file_transfer_send_confirm_request::Union::skip(s)) => {
|
Some(file_transfer_send_confirm_request::Union::Skip(s)) => {
|
||||||
if s {
|
if s {
|
||||||
log::debug!("skip file id:{}, file_num:{}", r.id, r.file_num);
|
log::debug!("skip file id:{}, file_num:{}", r.id, r.file_num);
|
||||||
self.skip_current_file();
|
self.skip_current_file();
|
||||||
@ -581,7 +581,7 @@ impl TransferJob {
|
|||||||
self.set_file_confirmed(true);
|
self.set_file_confirmed(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(file_transfer_send_confirm_request::Union::offset_blk(_offset)) => {
|
Some(file_transfer_send_confirm_request::Union::OffsetBlk(_offset)) => {
|
||||||
self.set_file_confirmed(true);
|
self.set_file_confirmed(true);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
pub mod compress;
|
pub mod compress;
|
||||||
#[path = "./protos/message.rs"]
|
pub mod protos;
|
||||||
pub mod message_proto;
|
pub use protos::message as message_proto;
|
||||||
#[path = "./protos/rendezvous.rs"]
|
pub use protos::rendezvous as rendezvous_proto;
|
||||||
pub mod rendezvous_proto;
|
|
||||||
pub use bytes;
|
pub use bytes;
|
||||||
pub use futures;
|
pub use futures;
|
||||||
pub use protobuf;
|
pub use protobuf;
|
||||||
|
@ -251,11 +251,11 @@ impl Decoder {
|
|||||||
rgb: &mut Vec<u8>,
|
rgb: &mut Vec<u8>,
|
||||||
) -> ResultType<bool> {
|
) -> ResultType<bool> {
|
||||||
match frame {
|
match frame {
|
||||||
video_frame::Union::vp9s(vp9s) => {
|
video_frame::Union::Vp9s(vp9s) => {
|
||||||
Decoder::handle_vp9s_video_frame(&mut self.vpx, vp9s, rgb)
|
Decoder::handle_vp9s_video_frame(&mut self.vpx, vp9s, rgb)
|
||||||
}
|
}
|
||||||
#[cfg(feature = "hwcodec")]
|
#[cfg(feature = "hwcodec")]
|
||||||
video_frame::Union::h264s(h264s) => {
|
video_frame::Union::H264s(h264s) => {
|
||||||
if let Some(decoder) = &mut self.hw.h264 {
|
if let Some(decoder) = &mut self.hw.h264 {
|
||||||
Decoder::handle_hw_video_frame(decoder, h264s, rgb, &mut self.i420)
|
Decoder::handle_hw_video_frame(decoder, h264s, rgb, &mut self.i420)
|
||||||
} else {
|
} else {
|
||||||
@ -263,7 +263,7 @@ impl Decoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "hwcodec")]
|
#[cfg(feature = "hwcodec")]
|
||||||
video_frame::Union::h265s(h265s) => {
|
video_frame::Union::H265s(h265s) => {
|
||||||
if let Some(decoder) = &mut self.hw.h265 {
|
if let Some(decoder) = &mut self.hw.h265 {
|
||||||
Decoder::handle_hw_video_frame(decoder, h265s, rgb, &mut self.i420)
|
Decoder::handle_hw_video_frame(decoder, h265s, rgb, &mut self.i420)
|
||||||
} else {
|
} else {
|
||||||
|
@ -165,7 +165,7 @@ impl Client {
|
|||||||
for i in 1..=3 {
|
for i in 1..=3 {
|
||||||
log::info!("#{} punch attempt with {}, id: {}", i, my_addr, peer);
|
log::info!("#{} punch attempt with {}, id: {}", i, my_addr, peer);
|
||||||
let mut msg_out = RendezvousMessage::new();
|
let mut msg_out = RendezvousMessage::new();
|
||||||
use hbb_common::protobuf::ProtobufEnum;
|
use hbb_common::protobuf::Enum;
|
||||||
let nat_type = NatType::from_i32(my_nat_type).unwrap_or(NatType::UNKNOWN_NAT);
|
let nat_type = NatType::from_i32(my_nat_type).unwrap_or(NatType::UNKNOWN_NAT);
|
||||||
msg_out.set_punch_hole_request(PunchHoleRequest {
|
msg_out.set_punch_hole_request(PunchHoleRequest {
|
||||||
id: peer.to_owned(),
|
id: peer.to_owned(),
|
||||||
@ -179,7 +179,7 @@ impl Client {
|
|||||||
if let Some(Ok(bytes)) = socket.next_timeout(i * 6000).await {
|
if let Some(Ok(bytes)) = socket.next_timeout(i * 6000).await {
|
||||||
if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(&bytes) {
|
if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(&bytes) {
|
||||||
match msg_in.union {
|
match msg_in.union {
|
||||||
Some(rendezvous_message::Union::punch_hole_response(ph)) => {
|
Some(rendezvous_message::Union::PunchHoleResponse(ph)) => {
|
||||||
if ph.socket_addr.is_empty() {
|
if ph.socket_addr.is_empty() {
|
||||||
if !ph.other_failure.is_empty() {
|
if !ph.other_failure.is_empty() {
|
||||||
bail!(ph.other_failure);
|
bail!(ph.other_failure);
|
||||||
@ -199,8 +199,8 @@ impl Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
peer_nat_type = ph.get_nat_type();
|
peer_nat_type = ph.nat_type();
|
||||||
is_local = ph.get_is_local();
|
is_local = ph.is_local();
|
||||||
signed_id_pk = ph.pk;
|
signed_id_pk = ph.pk;
|
||||||
relay_server = ph.relay_server;
|
relay_server = ph.relay_server;
|
||||||
peer_addr = AddrMangle::decode(&ph.socket_addr);
|
peer_addr = AddrMangle::decode(&ph.socket_addr);
|
||||||
@ -208,13 +208,13 @@ impl Client {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(rendezvous_message::Union::relay_response(rr)) => {
|
Some(rendezvous_message::Union::RelayResponse(rr)) => {
|
||||||
log::info!(
|
log::info!(
|
||||||
"relay requested from peer, time used: {:?}, relay_server: {}",
|
"relay requested from peer, time used: {:?}, relay_server: {}",
|
||||||
start.elapsed(),
|
start.elapsed(),
|
||||||
rr.relay_server
|
rr.relay_server
|
||||||
);
|
);
|
||||||
signed_id_pk = rr.get_pk().into();
|
signed_id_pk = rr.pk().into();
|
||||||
let mut conn =
|
let mut conn =
|
||||||
Self::create_relay(peer, rr.uuid, rr.relay_server, key, conn_type)
|
Self::create_relay(peer, rr.uuid, rr.relay_server, key, conn_type)
|
||||||
.await?;
|
.await?;
|
||||||
@ -383,7 +383,7 @@ impl Client {
|
|||||||
Some(res) => {
|
Some(res) => {
|
||||||
let bytes = res?;
|
let bytes = res?;
|
||||||
if let Ok(msg_in) = Message::parse_from_bytes(&bytes) {
|
if let Ok(msg_in) = Message::parse_from_bytes(&bytes) {
|
||||||
if let Some(message::Union::signed_id(si)) = msg_in.union {
|
if let Some(message::Union::SignedId(si)) = msg_in.union {
|
||||||
if let Ok((id, their_pk_b)) = decode_id_pk(&si.id, &sign_pk) {
|
if let Ok((id, their_pk_b)) = decode_id_pk(&si.id, &sign_pk) {
|
||||||
if id == peer_id {
|
if id == peer_id {
|
||||||
let their_pk_b = box_::PublicKey(their_pk_b);
|
let their_pk_b = box_::PublicKey(their_pk_b);
|
||||||
@ -466,7 +466,7 @@ impl Client {
|
|||||||
socket.send(&msg_out).await?;
|
socket.send(&msg_out).await?;
|
||||||
if let Some(Ok(bytes)) = socket.next_timeout(CONNECT_TIMEOUT).await {
|
if let Some(Ok(bytes)) = socket.next_timeout(CONNECT_TIMEOUT).await {
|
||||||
if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(&bytes) {
|
if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(&bytes) {
|
||||||
if let Some(rendezvous_message::Union::relay_response(rs)) = msg_in.union {
|
if let Some(rendezvous_message::Union::RelayResponse(rs)) = msg_in.union {
|
||||||
if !rs.refuse_reason.is_empty() {
|
if !rs.refuse_reason.is_empty() {
|
||||||
bail!(rs.refuse_reason);
|
bail!(rs.refuse_reason);
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,9 @@ pub enum CodecFormat {
|
|||||||
impl From<&VideoFrame> for CodecFormat {
|
impl From<&VideoFrame> for CodecFormat {
|
||||||
fn from(it: &VideoFrame) -> Self {
|
fn from(it: &VideoFrame) -> Self {
|
||||||
match it.union {
|
match it.union {
|
||||||
Some(video_frame::Union::vp9s(_)) => CodecFormat::VP9,
|
Some(video_frame::Union::Vp9s(_)) => CodecFormat::VP9,
|
||||||
Some(video_frame::Union::h264s(_)) => CodecFormat::H264,
|
Some(video_frame::Union::H264s(_)) => CodecFormat::H264,
|
||||||
Some(video_frame::Union::h265s(_)) => CodecFormat::H265,
|
Some(video_frame::Union::H265s(_)) => CodecFormat::H265,
|
||||||
_ => CodecFormat::Unknown,
|
_ => CodecFormat::Unknown,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
Message {
|
Message {
|
||||||
union: Some(message::Union::cliprdr(Cliprdr {
|
union: Some(message::Union::Cliprdr(Cliprdr {
|
||||||
union: Some(cliprdr::Union::format_list(CliprdrServerFormatList {
|
union: Some(cliprdr::Union::FormatList(CliprdrServerFormatList {
|
||||||
conn_id,
|
conn_id,
|
||||||
formats,
|
formats,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@ -29,8 +29,8 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClipbaordFile::ServerFormatListResponse { conn_id, msg_flags } => Message {
|
ClipbaordFile::ServerFormatListResponse { conn_id, msg_flags } => Message {
|
||||||
union: Some(message::Union::cliprdr(Cliprdr {
|
union: Some(message::Union::Cliprdr(Cliprdr {
|
||||||
union: Some(cliprdr::Union::format_list_response(
|
union: Some(cliprdr::Union::FormatListResponse(
|
||||||
CliprdrServerFormatListResponse {
|
CliprdrServerFormatListResponse {
|
||||||
conn_id,
|
conn_id,
|
||||||
msg_flags,
|
msg_flags,
|
||||||
@ -45,8 +45,8 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
conn_id,
|
conn_id,
|
||||||
requested_format_id,
|
requested_format_id,
|
||||||
} => Message {
|
} => Message {
|
||||||
union: Some(message::Union::cliprdr(Cliprdr {
|
union: Some(message::Union::Cliprdr(Cliprdr {
|
||||||
union: Some(cliprdr::Union::format_data_request(
|
union: Some(cliprdr::Union::FormatDataRequest(
|
||||||
CliprdrServerFormatDataRequest {
|
CliprdrServerFormatDataRequest {
|
||||||
conn_id,
|
conn_id,
|
||||||
requested_format_id,
|
requested_format_id,
|
||||||
@ -62,8 +62,8 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
msg_flags,
|
msg_flags,
|
||||||
format_data,
|
format_data,
|
||||||
} => Message {
|
} => Message {
|
||||||
union: Some(message::Union::cliprdr(Cliprdr {
|
union: Some(message::Union::Cliprdr(Cliprdr {
|
||||||
union: Some(cliprdr::Union::format_data_response(
|
union: Some(cliprdr::Union::FormatDataResponse(
|
||||||
CliprdrServerFormatDataResponse {
|
CliprdrServerFormatDataResponse {
|
||||||
conn_id,
|
conn_id,
|
||||||
msg_flags,
|
msg_flags,
|
||||||
@ -86,8 +86,8 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
have_clip_data_id,
|
have_clip_data_id,
|
||||||
clip_data_id,
|
clip_data_id,
|
||||||
} => Message {
|
} => Message {
|
||||||
union: Some(message::Union::cliprdr(Cliprdr {
|
union: Some(message::Union::Cliprdr(Cliprdr {
|
||||||
union: Some(cliprdr::Union::file_contents_request(
|
union: Some(cliprdr::Union::FileContentsRequest(
|
||||||
CliprdrFileContentsRequest {
|
CliprdrFileContentsRequest {
|
||||||
conn_id,
|
conn_id,
|
||||||
stream_id,
|
stream_id,
|
||||||
@ -111,8 +111,8 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
stream_id,
|
stream_id,
|
||||||
requested_data,
|
requested_data,
|
||||||
} => Message {
|
} => Message {
|
||||||
union: Some(message::Union::cliprdr(Cliprdr {
|
union: Some(message::Union::Cliprdr(Cliprdr {
|
||||||
union: Some(cliprdr::Union::file_contents_response(
|
union: Some(cliprdr::Union::FileContentsResponse(
|
||||||
CliprdrFileContentsResponse {
|
CliprdrFileContentsResponse {
|
||||||
conn_id,
|
conn_id,
|
||||||
msg_flags,
|
msg_flags,
|
||||||
@ -130,7 +130,7 @@ pub fn clip_2_msg(clip: ClipbaordFile) -> Message {
|
|||||||
|
|
||||||
pub fn msg_2_clip(msg: Cliprdr) -> Option<ClipbaordFile> {
|
pub fn msg_2_clip(msg: Cliprdr) -> Option<ClipbaordFile> {
|
||||||
match msg.union {
|
match msg.union {
|
||||||
Some(cliprdr::Union::format_list(data)) => {
|
Some(cliprdr::Union::FormatList(data)) => {
|
||||||
let mut format_list: Vec<(i32, String)> = Vec::new();
|
let mut format_list: Vec<(i32, String)> = Vec::new();
|
||||||
for v in data.formats.iter() {
|
for v in data.formats.iter() {
|
||||||
format_list.push((v.id, v.format.clone()));
|
format_list.push((v.id, v.format.clone()));
|
||||||
@ -140,26 +140,26 @@ pub fn msg_2_clip(msg: Cliprdr) -> Option<ClipbaordFile> {
|
|||||||
format_list,
|
format_list,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Some(cliprdr::Union::format_list_response(data)) => {
|
Some(cliprdr::Union::FormatListResponse(data)) => {
|
||||||
Some(ClipbaordFile::ServerFormatListResponse {
|
Some(ClipbaordFile::ServerFormatListResponse {
|
||||||
conn_id: data.conn_id,
|
conn_id: data.conn_id,
|
||||||
msg_flags: data.msg_flags,
|
msg_flags: data.msg_flags,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Some(cliprdr::Union::format_data_request(data)) => {
|
Some(cliprdr::Union::FormatDataRequest(data)) => {
|
||||||
Some(ClipbaordFile::ServerFormatDataRequest {
|
Some(ClipbaordFile::ServerFormatDataRequest {
|
||||||
conn_id: data.conn_id,
|
conn_id: data.conn_id,
|
||||||
requested_format_id: data.requested_format_id,
|
requested_format_id: data.requested_format_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Some(cliprdr::Union::format_data_response(data)) => {
|
Some(cliprdr::Union::FormatDataResponse(data)) => {
|
||||||
Some(ClipbaordFile::ServerFormatDataResponse {
|
Some(ClipbaordFile::ServerFormatDataResponse {
|
||||||
conn_id: data.conn_id,
|
conn_id: data.conn_id,
|
||||||
msg_flags: data.msg_flags,
|
msg_flags: data.msg_flags,
|
||||||
format_data: data.format_data,
|
format_data: data.format_data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Some(cliprdr::Union::file_contents_request(data)) => {
|
Some(cliprdr::Union::FileContentsRequest(data)) => {
|
||||||
Some(ClipbaordFile::FileContentsRequest {
|
Some(ClipbaordFile::FileContentsRequest {
|
||||||
conn_id: data.conn_id,
|
conn_id: data.conn_id,
|
||||||
stream_id: data.stream_id,
|
stream_id: data.stream_id,
|
||||||
@ -172,7 +172,7 @@ pub fn msg_2_clip(msg: Cliprdr) -> Option<ClipbaordFile> {
|
|||||||
clip_data_id: data.clip_data_id,
|
clip_data_id: data.clip_data_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Some(cliprdr::Union::file_contents_response(data)) => {
|
Some(cliprdr::Union::FileContentsResponse(data)) => {
|
||||||
Some(ClipbaordFile::FileContentsResponse {
|
Some(ClipbaordFile::FileContentsResponse {
|
||||||
conn_id: data.conn_id,
|
conn_id: data.conn_id,
|
||||||
msg_flags: data.msg_flags,
|
msg_flags: data.msg_flags,
|
||||||
|
@ -8,7 +8,7 @@ use hbb_common::{
|
|||||||
get_version_number, log,
|
get_version_number, log,
|
||||||
message_proto::*,
|
message_proto::*,
|
||||||
protobuf::Message as _,
|
protobuf::Message as _,
|
||||||
protobuf::ProtobufEnum,
|
protobuf::Enum,
|
||||||
rendezvous_proto::*,
|
rendezvous_proto::*,
|
||||||
sleep, socket_client, tokio, ResultType,
|
sleep, socket_client, tokio, ResultType,
|
||||||
};
|
};
|
||||||
@ -32,7 +32,7 @@ lazy_static::lazy_static! {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn valid_for_numlock(evt: &KeyEvent) -> bool {
|
pub fn valid_for_numlock(evt: &KeyEvent) -> bool {
|
||||||
if let Some(key_event::Union::control_key(ck)) = evt.union {
|
if let Some(key_event::Union::ControlKey(ck)) = evt.union {
|
||||||
let v = ck.value();
|
let v = ck.value();
|
||||||
(v >= ControlKey::Numpad0.value() && v <= ControlKey::Numpad9.value())
|
(v >= ControlKey::Numpad0.value() && v <= ControlKey::Numpad9.value())
|
||||||
|| v == ControlKey::Decimal.value()
|
|| v == ControlKey::Decimal.value()
|
||||||
@ -284,7 +284,7 @@ async fn test_nat_type_() -> ResultType<bool> {
|
|||||||
socket.send(&msg_out).await?;
|
socket.send(&msg_out).await?;
|
||||||
if let Some(Ok(bytes)) = socket.next_timeout(RENDEZVOUS_TIMEOUT).await {
|
if let Some(Ok(bytes)) = socket.next_timeout(RENDEZVOUS_TIMEOUT).await {
|
||||||
if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(&bytes) {
|
if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(&bytes) {
|
||||||
if let Some(rendezvous_message::Union::test_nat_response(tnr)) = msg_in.union {
|
if let Some(rendezvous_message::Union::TestNatResponse(tnr)) = msg_in.union {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
port1 = tnr.port;
|
port1 = tnr.port;
|
||||||
} else {
|
} else {
|
||||||
@ -412,7 +412,7 @@ pub const POSTFIX_SERVICE: &'static str = "_service";
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_control_key(evt: &KeyEvent, key: &ControlKey) -> bool {
|
pub fn is_control_key(evt: &KeyEvent, key: &ControlKey) -> bool {
|
||||||
if let Some(key_event::Union::control_key(ck)) = evt.union {
|
if let Some(key_event::Union::ControlKey(ck)) = evt.union {
|
||||||
ck.value() == key.value()
|
ck.value() == key.value()
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@ -421,7 +421,7 @@ pub fn is_control_key(evt: &KeyEvent, key: &ControlKey) -> bool {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_modifier(evt: &KeyEvent) -> bool {
|
pub fn is_modifier(evt: &KeyEvent) -> bool {
|
||||||
if let Some(key_event::Union::control_key(ck)) = evt.union {
|
if let Some(key_event::Union::ControlKey(ck)) = evt.union {
|
||||||
let v = ck.value();
|
let v = ck.value();
|
||||||
v == ControlKey::Alt.value()
|
v == ControlKey::Alt.value()
|
||||||
|| v == ControlKey::Shift.value()
|
|| v == ControlKey::Shift.value()
|
||||||
@ -457,7 +457,7 @@ async fn _check_software_update() -> hbb_common::ResultType<()> {
|
|||||||
use hbb_common::protobuf::Message;
|
use hbb_common::protobuf::Message;
|
||||||
if let Some(Ok((bytes, _))) = socket.next_timeout(30_000).await {
|
if let Some(Ok((bytes, _))) = socket.next_timeout(30_000).await {
|
||||||
if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(&bytes) {
|
if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(&bytes) {
|
||||||
if let Some(rendezvous_message::Union::software_update(su)) = msg_in.union {
|
if let Some(rendezvous_message::Union::SoftwareUpdate(su)) = msg_in.union {
|
||||||
let version = hbb_common::get_version_from_url(&su.url);
|
let version = hbb_common::get_version_from_url(&su.url);
|
||||||
if get_version_number(&version) > get_version_number(crate::VERSION) {
|
if get_version_number(&version) > get_version_number(crate::VERSION) {
|
||||||
*SOFTWARE_UPDATE_URL.lock().unwrap() = su.url;
|
*SOFTWARE_UPDATE_URL.lock().unwrap() = su.url;
|
||||||
|
@ -120,21 +120,21 @@ async fn connect_and_login(
|
|||||||
Ok(Some(Ok(bytes))) => {
|
Ok(Some(Ok(bytes))) => {
|
||||||
let msg_in = Message::parse_from_bytes(&bytes)?;
|
let msg_in = Message::parse_from_bytes(&bytes)?;
|
||||||
match msg_in.union {
|
match msg_in.union {
|
||||||
Some(message::Union::hash(hash)) => {
|
Some(message::Union::Hash(hash)) => {
|
||||||
interface.handle_hash(hash, &mut stream).await;
|
interface.handle_hash(hash, &mut stream).await;
|
||||||
}
|
}
|
||||||
Some(message::Union::login_response(lr)) => match lr.union {
|
Some(message::Union::LoginResponse(lr)) => match lr.union {
|
||||||
Some(login_response::Union::error(err)) => {
|
Some(login_response::Union::Error(err)) => {
|
||||||
interface.handle_login_error(&err);
|
interface.handle_login_error(&err);
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
Some(login_response::Union::peer_info(pi)) => {
|
Some(login_response::Union::PeerInfo(pi)) => {
|
||||||
interface.handle_peer_info(pi);
|
interface.handle_peer_info(pi);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Some(message::Union::test_delay(t)) => {
|
Some(message::Union::TestDelay(t)) => {
|
||||||
interface.handle_test_delay(t, &mut stream).await;
|
interface.handle_test_delay(t, &mut stream).await;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -157,7 +157,7 @@ impl RendezvousMediator {
|
|||||||
Some(Ok((bytes, _))) => {
|
Some(Ok((bytes, _))) => {
|
||||||
if let Ok(msg_in) = Message::parse_from_bytes(&bytes) {
|
if let Ok(msg_in) = Message::parse_from_bytes(&bytes) {
|
||||||
match msg_in.union {
|
match msg_in.union {
|
||||||
Some(rendezvous_message::Union::register_peer_response(rpr)) => {
|
Some(rendezvous_message::Union::RegisterPeerResponse(rpr)) => {
|
||||||
update_latency();
|
update_latency();
|
||||||
if rpr.request_pk {
|
if rpr.request_pk {
|
||||||
log::info!("request_pk received from {}", host);
|
log::info!("request_pk received from {}", host);
|
||||||
@ -165,7 +165,7 @@ impl RendezvousMediator {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(rendezvous_message::Union::register_pk_response(rpr)) => {
|
Some(rendezvous_message::Union::RegisterPkResponse(rpr)) => {
|
||||||
update_latency();
|
update_latency();
|
||||||
match rpr.result.enum_value_or_default() {
|
match rpr.result.enum_value_or_default() {
|
||||||
register_pk_response::Result::OK => {
|
register_pk_response::Result::OK => {
|
||||||
@ -179,28 +179,28 @@ impl RendezvousMediator {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(rendezvous_message::Union::punch_hole(ph)) => {
|
Some(rendezvous_message::Union::PunchHole(ph)) => {
|
||||||
let rz = rz.clone();
|
let rz = rz.clone();
|
||||||
let server = server.clone();
|
let server = server.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
allow_err!(rz.handle_punch_hole(ph, server).await);
|
allow_err!(rz.handle_punch_hole(ph, server).await);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some(rendezvous_message::Union::request_relay(rr)) => {
|
Some(rendezvous_message::Union::RequestRelay(rr)) => {
|
||||||
let rz = rz.clone();
|
let rz = rz.clone();
|
||||||
let server = server.clone();
|
let server = server.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
allow_err!(rz.handle_request_relay(rr, server).await);
|
allow_err!(rz.handle_request_relay(rr, server).await);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some(rendezvous_message::Union::fetch_local_addr(fla)) => {
|
Some(rendezvous_message::Union::FetchLocalAddr(fla)) => {
|
||||||
let rz = rz.clone();
|
let rz = rz.clone();
|
||||||
let server = server.clone();
|
let server = server.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
allow_err!(rz.handle_intranet(fla, server).await);
|
allow_err!(rz.handle_intranet(fla, server).await);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some(rendezvous_message::Union::configure_update(cu)) => {
|
Some(rendezvous_message::Union::ConfigureUpdate(cu)) => {
|
||||||
let v0 = Config::get_rendezvous_servers();
|
let v0 = Config::get_rendezvous_servers();
|
||||||
Config::set_option("rendezvous-servers".to_owned(), cu.rendezvous_servers.join(","));
|
Config::set_option("rendezvous-servers".to_owned(), cu.rendezvous_servers.join(","));
|
||||||
Config::set_serial(cu.serial);
|
Config::set_serial(cu.serial);
|
||||||
@ -367,7 +367,7 @@ impl RendezvousMediator {
|
|||||||
socket
|
socket
|
||||||
};
|
};
|
||||||
let mut msg_out = Message::new();
|
let mut msg_out = Message::new();
|
||||||
use hbb_common::protobuf::ProtobufEnum;
|
use hbb_common::protobuf::Enum;
|
||||||
let nat_type = NatType::from_i32(Config::get_nat_type()).unwrap_or(NatType::UNKNOWN_NAT);
|
let nat_type = NatType::from_i32(Config::get_nat_type()).unwrap_or(NatType::UNKNOWN_NAT);
|
||||||
msg_out.set_punch_hole_sent(PunchHoleSent {
|
msg_out.set_punch_hole_sent(PunchHoleSent {
|
||||||
socket_addr: ph.socket_addr,
|
socket_addr: ph.socket_addr,
|
||||||
@ -564,7 +564,7 @@ fn lan_discovery() -> ResultType<()> {
|
|||||||
if let Ok((len, addr)) = socket.recv_from(&mut buf) {
|
if let Ok((len, addr)) = socket.recv_from(&mut buf) {
|
||||||
if let Ok(msg_in) = Message::parse_from_bytes(&buf[0..len]) {
|
if let Ok(msg_in) = Message::parse_from_bytes(&buf[0..len]) {
|
||||||
match msg_in.union {
|
match msg_in.union {
|
||||||
Some(rendezvous_message::Union::peer_discovery(p)) => {
|
Some(rendezvous_message::Union::PeerDiscovery(p)) => {
|
||||||
if p.cmd == "ping" {
|
if p.cmd == "ping" {
|
||||||
let mut msg_out = Message::new();
|
let mut msg_out = Message::new();
|
||||||
let peer = PeerDiscovery {
|
let peer = PeerDiscovery {
|
||||||
@ -612,7 +612,7 @@ pub fn discover() -> ResultType<()> {
|
|||||||
if let Ok((len, _)) = socket.recv_from(&mut buf) {
|
if let Ok((len, _)) = socket.recv_from(&mut buf) {
|
||||||
if let Ok(msg_in) = Message::parse_from_bytes(&buf[0..len]) {
|
if let Ok(msg_in) = Message::parse_from_bytes(&buf[0..len]) {
|
||||||
match msg_in.union {
|
match msg_in.union {
|
||||||
Some(rendezvous_message::Union::peer_discovery(p)) => {
|
Some(rendezvous_message::Union::PeerDiscovery(p)) => {
|
||||||
last_recv_time = Instant::now();
|
last_recv_time = Instant::now();
|
||||||
if p.cmd == "pong" {
|
if p.cmd == "pong" {
|
||||||
if p.mac != mac {
|
if p.mac != mac {
|
||||||
|
@ -7,7 +7,7 @@ use hbb_common::{
|
|||||||
config::{Config, Config2, CONNECT_TIMEOUT, RELAY_PORT},
|
config::{Config, Config2, CONNECT_TIMEOUT, RELAY_PORT},
|
||||||
log,
|
log,
|
||||||
message_proto::*,
|
message_proto::*,
|
||||||
protobuf::{Message as _, ProtobufEnum},
|
protobuf::{Message as _, Enum},
|
||||||
rendezvous_proto::*,
|
rendezvous_proto::*,
|
||||||
socket_client,
|
socket_client,
|
||||||
sodiumoxide::crypto::{box_, secretbox, sign},
|
sodiumoxide::crypto::{box_, secretbox, sign},
|
||||||
@ -140,7 +140,7 @@ pub async fn create_tcp_connection(
|
|||||||
Some(res) => {
|
Some(res) => {
|
||||||
let bytes = res?;
|
let bytes = res?;
|
||||||
if let Ok(msg_in) = Message::parse_from_bytes(&bytes) {
|
if let Ok(msg_in) = Message::parse_from_bytes(&bytes) {
|
||||||
if let Some(message::Union::public_key(pk)) = msg_in.union {
|
if let Some(message::Union::PublicKey(pk)) = msg_in.union {
|
||||||
if pk.asymmetric_value.len() == box_::PUBLICKEYBYTES {
|
if pk.asymmetric_value.len() == box_::PUBLICKEYBYTES {
|
||||||
let nonce = box_::Nonce([0u8; box_::NONCEBYTES]);
|
let nonce = box_::Nonce([0u8; box_::NONCEBYTES]);
|
||||||
let mut pk_ = [0u8; box_::PUBLICKEYBYTES];
|
let mut pk_ = [0u8; box_::PUBLICKEYBYTES];
|
||||||
|
@ -91,7 +91,7 @@ impl Subscriber for ConnInner {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn send(&mut self, msg: Arc<Message>) {
|
fn send(&mut self, msg: Arc<Message>) {
|
||||||
match &msg.union {
|
match &msg.union {
|
||||||
Some(message::Union::video_frame(_)) => {
|
Some(message::Union::VideoFrame(_)) => {
|
||||||
self.tx_video.as_mut().map(|tx| {
|
self.tx_video.as_mut().map(|tx| {
|
||||||
allow_err!(tx.send((Instant::now(), msg)));
|
allow_err!(tx.send((Instant::now(), msg)));
|
||||||
});
|
});
|
||||||
@ -354,7 +354,7 @@ impl Connection {
|
|||||||
|
|
||||||
if latency > 1000 {
|
if latency > 1000 {
|
||||||
match &msg.union {
|
match &msg.union {
|
||||||
Some(message::Union::audio_frame(_)) => {
|
Some(message::Union::AudioFrame(_)) => {
|
||||||
// log::info!("audio frame latency {}", instant.elapsed().as_secs_f32());
|
// log::info!("audio frame latency {}", instant.elapsed().as_secs_f32());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -779,7 +779,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn on_message(&mut self, msg: Message) -> bool {
|
async fn on_message(&mut self, msg: Message) -> bool {
|
||||||
if let Some(message::Union::login_request(lr)) = msg.union {
|
if let Some(message::Union::LoginRequest(lr)) = msg.union {
|
||||||
if let Some(o) = lr.option.as_ref() {
|
if let Some(o) = lr.option.as_ref() {
|
||||||
self.update_option(o).await;
|
self.update_option(o).await;
|
||||||
if let Some(q) = o.video_codec_state.clone().take() {
|
if let Some(q) = o.video_codec_state.clone().take() {
|
||||||
@ -804,7 +804,7 @@ impl Connection {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
match lr.union {
|
match lr.union {
|
||||||
Some(login_request::Union::file_transfer(ft)) => {
|
Some(login_request::Union::FileTransfer(ft)) => {
|
||||||
if !Config::get_option("enable-file-transfer").is_empty() {
|
if !Config::get_option("enable-file-transfer").is_empty() {
|
||||||
self.send_login_error("No permission of file transfer")
|
self.send_login_error("No permission of file transfer")
|
||||||
.await;
|
.await;
|
||||||
@ -813,7 +813,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
self.file_transfer = Some((ft.dir, ft.show_hidden));
|
self.file_transfer = Some((ft.dir, ft.show_hidden));
|
||||||
}
|
}
|
||||||
Some(login_request::Union::port_forward(mut pf)) => {
|
Some(login_request::Union::PortForward(mut pf)) => {
|
||||||
if !Config::get_option("enable-tunnel").is_empty() {
|
if !Config::get_option("enable-tunnel").is_empty() {
|
||||||
self.send_login_error("No permission of IP tunneling").await;
|
self.send_login_error("No permission of IP tunneling").await;
|
||||||
sleep(1.).await;
|
sleep(1.).await;
|
||||||
@ -897,7 +897,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let Some(message::Union::test_delay(t)) = msg.union {
|
} else if let Some(message::Union::TestDelay(t)) = msg.union {
|
||||||
if t.from_client {
|
if t.from_client {
|
||||||
let mut msg_out = Message::new();
|
let mut msg_out = Message::new();
|
||||||
msg_out.set_test_delay(t);
|
msg_out.set_test_delay(t);
|
||||||
@ -912,7 +912,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
} else if self.authorized {
|
} else if self.authorized {
|
||||||
match msg.union {
|
match msg.union {
|
||||||
Some(message::Union::mouse_event(me)) => {
|
Some(message::Union::MouseEvent(me)) => {
|
||||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
if let Err(e) = call_main_service_mouse_input(me.mask, me.x, me.y) {
|
if let Err(e) = call_main_service_mouse_input(me.mask, me.x, me.y) {
|
||||||
log::debug!("call_main_service_mouse_input fail:{}", e);
|
log::debug!("call_main_service_mouse_input fail:{}", e);
|
||||||
@ -927,7 +927,7 @@ impl Connection {
|
|||||||
self.input_mouse(me, self.inner.id());
|
self.input_mouse(me, self.inner.id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(message::Union::key_event(me)) => {
|
Some(message::Union::KeyEvent(me)) => {
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
if self.keyboard {
|
if self.keyboard {
|
||||||
if is_enter(&me) {
|
if is_enter(&me) {
|
||||||
@ -943,8 +943,8 @@ impl Connection {
|
|||||||
};
|
};
|
||||||
if is_press {
|
if is_press {
|
||||||
match me.union {
|
match me.union {
|
||||||
Some(key_event::Union::unicode(_))
|
Some(key_event::Union::Unicode(_))
|
||||||
| Some(key_event::Union::seq(_)) => {
|
| Some(key_event::Union::Seq(_)) => {
|
||||||
self.input_key(me, false);
|
self.input_key(me, false);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@ -956,14 +956,14 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(message::Union::clipboard(cb)) =>
|
Some(message::Union::Clipboard(cb)) =>
|
||||||
{
|
{
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
if self.clipboard {
|
if self.clipboard {
|
||||||
update_clipboard(cb, None);
|
update_clipboard(cb, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(message::Union::cliprdr(_clip)) => {
|
Some(message::Union::Cliprdr(_clip)) => {
|
||||||
if self.file_transfer_enabled() {
|
if self.file_transfer_enabled() {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if let Some(clip) = msg_2_clip(_clip) {
|
if let Some(clip) = msg_2_clip(_clip) {
|
||||||
@ -971,13 +971,13 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(message::Union::file_action(fa)) => {
|
Some(message::Union::FileAction(fa)) => {
|
||||||
if self.file_transfer.is_some() {
|
if self.file_transfer.is_some() {
|
||||||
match fa.union {
|
match fa.union {
|
||||||
Some(file_action::Union::read_dir(rd)) => {
|
Some(file_action::Union::ReadDir(rd)) => {
|
||||||
self.read_dir(&rd.path, rd.include_hidden);
|
self.read_dir(&rd.path, rd.include_hidden);
|
||||||
}
|
}
|
||||||
Some(file_action::Union::all_files(f)) => {
|
Some(file_action::Union::AllFiles(f)) => {
|
||||||
match fs::get_recursive_files(&f.path, f.include_hidden) {
|
match fs::get_recursive_files(&f.path, f.include_hidden) {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.send(fs::new_error(f.id, err, -1)).await;
|
self.send(fs::new_error(f.id, err, -1)).await;
|
||||||
@ -987,7 +987,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(file_action::Union::send(s)) => {
|
Some(file_action::Union::Send(s)) => {
|
||||||
let id = s.id;
|
let id = s.id;
|
||||||
let od =
|
let od =
|
||||||
can_enable_overwrite_detection(get_version_number(VERSION));
|
can_enable_overwrite_detection(get_version_number(VERSION));
|
||||||
@ -1012,7 +1012,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(file_action::Union::receive(r)) => {
|
Some(file_action::Union::Receive(r)) => {
|
||||||
self.send_fs(ipc::FS::NewWrite {
|
self.send_fs(ipc::FS::NewWrite {
|
||||||
path: r.path,
|
path: r.path,
|
||||||
id: r.id,
|
id: r.id,
|
||||||
@ -1025,31 +1025,31 @@ impl Connection {
|
|||||||
.collect(),
|
.collect(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some(file_action::Union::remove_dir(d)) => {
|
Some(file_action::Union::RemoveDir(d)) => {
|
||||||
self.send_fs(ipc::FS::RemoveDir {
|
self.send_fs(ipc::FS::RemoveDir {
|
||||||
path: d.path,
|
path: d.path,
|
||||||
id: d.id,
|
id: d.id,
|
||||||
recursive: d.recursive,
|
recursive: d.recursive,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some(file_action::Union::remove_file(f)) => {
|
Some(file_action::Union::RemoveFile(f)) => {
|
||||||
self.send_fs(ipc::FS::RemoveFile {
|
self.send_fs(ipc::FS::RemoveFile {
|
||||||
path: f.path,
|
path: f.path,
|
||||||
id: f.id,
|
id: f.id,
|
||||||
file_num: f.file_num,
|
file_num: f.file_num,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some(file_action::Union::create(c)) => {
|
Some(file_action::Union::Create(c)) => {
|
||||||
self.send_fs(ipc::FS::CreateDir {
|
self.send_fs(ipc::FS::CreateDir {
|
||||||
path: c.path,
|
path: c.path,
|
||||||
id: c.id,
|
id: c.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some(file_action::Union::cancel(c)) => {
|
Some(file_action::Union::Cancel(c)) => {
|
||||||
self.send_fs(ipc::FS::CancelWrite { id: c.id });
|
self.send_fs(ipc::FS::CancelWrite { id: c.id });
|
||||||
fs::remove_job(c.id, &mut self.read_jobs);
|
fs::remove_job(c.id, &mut self.read_jobs);
|
||||||
}
|
}
|
||||||
Some(file_action::Union::send_confirm(r)) => {
|
Some(file_action::Union::SendConfirm(r)) => {
|
||||||
if let Some(job) = fs::get_job(r.id, &mut self.read_jobs) {
|
if let Some(job) = fs::get_job(r.id, &mut self.read_jobs) {
|
||||||
job.confirm(&r);
|
job.confirm(&r);
|
||||||
}
|
}
|
||||||
@ -1058,8 +1058,8 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(message::Union::file_response(fr)) => match fr.union {
|
Some(message::Union::FileResponse(fr)) => match fr.union {
|
||||||
Some(file_response::Union::block(block)) => {
|
Some(file_response::Union::Block(block)) => {
|
||||||
self.send_fs(ipc::FS::WriteBlock {
|
self.send_fs(ipc::FS::WriteBlock {
|
||||||
id: block.id,
|
id: block.id,
|
||||||
file_num: block.file_num,
|
file_num: block.file_num,
|
||||||
@ -1067,13 +1067,13 @@ impl Connection {
|
|||||||
compressed: block.compressed,
|
compressed: block.compressed,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some(file_response::Union::done(d)) => {
|
Some(file_response::Union::Done(d)) => {
|
||||||
self.send_fs(ipc::FS::WriteDone {
|
self.send_fs(ipc::FS::WriteDone {
|
||||||
id: d.id,
|
id: d.id,
|
||||||
file_num: d.file_num,
|
file_num: d.file_num,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some(file_response::Union::digest(d)) => self.send_fs(ipc::FS::CheckDigest {
|
Some(file_response::Union::Digest(d)) => self.send_fs(ipc::FS::CheckDigest {
|
||||||
id: d.id,
|
id: d.id,
|
||||||
file_num: d.file_num,
|
file_num: d.file_num,
|
||||||
file_size: d.file_size,
|
file_size: d.file_size,
|
||||||
@ -1082,22 +1082,22 @@ impl Connection {
|
|||||||
}),
|
}),
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
Some(message::Union::misc(misc)) => match misc.union {
|
Some(message::Union::Misc(misc)) => match misc.union {
|
||||||
Some(misc::Union::switch_display(s)) => {
|
Some(misc::Union::SwitchDisplay(s)) => {
|
||||||
video_service::switch_display(s.display);
|
video_service::switch_display(s.display);
|
||||||
}
|
}
|
||||||
Some(misc::Union::chat_message(c)) => {
|
Some(misc::Union::ChatMessage(c)) => {
|
||||||
self.send_to_cm(ipc::Data::ChatMessage { text: c.text });
|
self.send_to_cm(ipc::Data::ChatMessage { text: c.text });
|
||||||
}
|
}
|
||||||
Some(misc::Union::option(o)) => {
|
Some(misc::Union::Option(o)) => {
|
||||||
self.update_option(&o).await;
|
self.update_option(&o).await;
|
||||||
}
|
}
|
||||||
Some(misc::Union::refresh_video(r)) => {
|
Some(misc::Union::RefreshVideo(r)) => {
|
||||||
if r {
|
if r {
|
||||||
video_service::refresh();
|
video_service::refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(misc::Union::video_received(_)) => {
|
Some(misc::Union::VideoReceived(_)) => {
|
||||||
video_service::notify_video_frame_feched(
|
video_service::notify_video_frame_feched(
|
||||||
self.inner.id,
|
self.inner.id,
|
||||||
Some(Instant::now().into()),
|
Some(Instant::now().into()),
|
||||||
|
@ -2,7 +2,7 @@ use super::*;
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use dispatch::Queue;
|
use dispatch::Queue;
|
||||||
use enigo::{Enigo, Key, KeyboardControllable, MouseButton, MouseControllable};
|
use enigo::{Enigo, Key, KeyboardControllable, MouseButton, MouseControllable};
|
||||||
use hbb_common::{config::COMPRESS_LEVEL, protobuf::ProtobufEnumOrUnknown};
|
use hbb_common::{config::COMPRESS_LEVEL, protobuf::EnumOrUnknown};
|
||||||
use std::{
|
use std::{
|
||||||
convert::TryFrom,
|
convert::TryFrom,
|
||||||
sync::atomic::{AtomicBool, Ordering},
|
sync::atomic::{AtomicBool, Ordering},
|
||||||
@ -68,7 +68,7 @@ impl Subscriber for MouseCursorSub {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn send(&mut self, msg: Arc<Message>) {
|
fn send(&mut self, msg: Arc<Message>) {
|
||||||
if let Some(message::Union::cursor_data(cd)) = &msg.union {
|
if let Some(message::Union::CursorData(cd)) = &msg.union {
|
||||||
if let Some(msg) = self.cached.get(&cd.id) {
|
if let Some(msg) = self.cached.get(&cd.id) {
|
||||||
self.inner.send(msg.clone());
|
self.inner.send(msg.clone());
|
||||||
} else {
|
} else {
|
||||||
@ -299,12 +299,12 @@ fn fix_key_down_timeout(force: bool) {
|
|||||||
// e.g. current state of ctrl is down, but ctrl not in modifier, we should change ctrl to up, to make modifier state sync between remote and local
|
// e.g. current state of ctrl is down, but ctrl not in modifier, we should change ctrl to up, to make modifier state sync between remote and local
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fix_modifier(
|
fn fix_modifier(
|
||||||
modifiers: &[ProtobufEnumOrUnknown<ControlKey>],
|
modifiers: &[EnumOrUnknown<ControlKey>],
|
||||||
key0: ControlKey,
|
key0: ControlKey,
|
||||||
key1: Key,
|
key1: Key,
|
||||||
en: &mut Enigo,
|
en: &mut Enigo,
|
||||||
) {
|
) {
|
||||||
if get_modifier_state(key1, en) && !modifiers.contains(&ProtobufEnumOrUnknown::new(key0)) {
|
if get_modifier_state(key1, en) && !modifiers.contains(&EnumOrUnknown::new(key0)) {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if key0 == ControlKey::Control && get_modifier_state(Key::Alt, en) {
|
if key0 == ControlKey::Control && get_modifier_state(Key::Alt, en) {
|
||||||
// AltGr case
|
// AltGr case
|
||||||
@ -315,7 +315,7 @@ fn fix_modifier(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fix_modifiers(modifiers: &[ProtobufEnumOrUnknown<ControlKey>], en: &mut Enigo, ck: i32) {
|
fn fix_modifiers(modifiers: &[EnumOrUnknown<ControlKey>], en: &mut Enigo, ck: i32) {
|
||||||
if ck != ControlKey::Shift.value() {
|
if ck != ControlKey::Shift.value() {
|
||||||
fix_modifier(modifiers, ControlKey::Shift, Key::Shift, en);
|
fix_modifier(modifiers, ControlKey::Shift, Key::Shift, en);
|
||||||
}
|
}
|
||||||
@ -430,7 +430,7 @@ fn handle_mouse_(evt: &MouseEvent, conn: i32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_enter(evt: &KeyEvent) -> bool {
|
pub fn is_enter(evt: &KeyEvent) -> bool {
|
||||||
if let Some(key_event::Union::control_key(ck)) = evt.union {
|
if let Some(key_event::Union::ControlKey(ck)) = evt.union {
|
||||||
if ck.value() == ControlKey::Return.value() || ck.value() == ControlKey::NumpadEnter.value()
|
if ck.value() == ControlKey::Return.value() || ck.value() == ControlKey::NumpadEnter.value()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -598,7 +598,7 @@ fn handle_key_(evt: &KeyEvent) {
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let mut has_numlock = false;
|
let mut has_numlock = false;
|
||||||
if evt.down {
|
if evt.down {
|
||||||
let ck = if let Some(key_event::Union::control_key(ck)) = evt.union {
|
let ck = if let Some(key_event::Union::ControlKey(ck)) = evt.union {
|
||||||
ck.value()
|
ck.value()
|
||||||
} else {
|
} else {
|
||||||
-1
|
-1
|
||||||
@ -653,7 +653,7 @@ fn handle_key_(evt: &KeyEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
match evt.union {
|
match evt.union {
|
||||||
Some(key_event::Union::control_key(ck)) => {
|
Some(key_event::Union::ControlKey(ck)) => {
|
||||||
if let Some(key) = KEY_MAP.get(&ck.value()) {
|
if let Some(key) = KEY_MAP.get(&ck.value()) {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if let Some(_) = NUMPAD_KEY_MAP.get(&ck.value()) {
|
if let Some(_) = NUMPAD_KEY_MAP.get(&ck.value()) {
|
||||||
@ -682,7 +682,7 @@ fn handle_key_(evt: &KeyEvent) {
|
|||||||
lock_screen();
|
lock_screen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(key_event::Union::chr(chr)) => {
|
Some(key_event::Union::Chr(chr)) => {
|
||||||
if evt.down {
|
if evt.down {
|
||||||
if en.key_down(get_layout(chr)).is_ok() {
|
if en.key_down(get_layout(chr)).is_ok() {
|
||||||
KEYS_DOWN
|
KEYS_DOWN
|
||||||
@ -708,12 +708,12 @@ fn handle_key_(evt: &KeyEvent) {
|
|||||||
.remove(&(chr as u64 + KEY_CHAR_START));
|
.remove(&(chr as u64 + KEY_CHAR_START));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(key_event::Union::unicode(chr)) => {
|
Some(key_event::Union::Unicode(chr)) => {
|
||||||
if let Ok(chr) = char::try_from(chr) {
|
if let Ok(chr) = char::try_from(chr) {
|
||||||
en.key_sequence(&chr.to_string());
|
en.key_sequence(&chr.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(key_event::Union::seq(ref seq)) => {
|
Some(key_event::Union::Seq(ref seq)) => {
|
||||||
en.key_sequence(&seq);
|
en.key_sequence(&seq);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -1045,7 +1045,7 @@ async fn check_id(
|
|||||||
if let Some(Ok(bytes)) = socket.next_timeout(3_000).await {
|
if let Some(Ok(bytes)) = socket.next_timeout(3_000).await {
|
||||||
if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(&bytes) {
|
if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(&bytes) {
|
||||||
match msg_in.union {
|
match msg_in.union {
|
||||||
Some(rendezvous_message::Union::register_pk_response(rpr)) => {
|
Some(rendezvous_message::Union::RegisterPkResponse(rpr)) => {
|
||||||
match rpr.result.enum_value_or_default() {
|
match rpr.result.enum_value_or_default() {
|
||||||
register_pk_response::Result::OK => {
|
register_pk_response::Result::OK => {
|
||||||
ok = true;
|
ok = true;
|
||||||
|
@ -204,7 +204,7 @@ impl ConnectionManager {
|
|||||||
let mut req = FileTransferSendConfirmRequest {
|
let mut req = FileTransferSendConfirmRequest {
|
||||||
id,
|
id,
|
||||||
file_num,
|
file_num,
|
||||||
union: Some(file_transfer_send_confirm_request::Union::offset_blk(0)),
|
union: Some(file_transfer_send_confirm_request::Union::OffsetBlk(0)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let digest = FileTransferDigest {
|
let digest = FileTransferDigest {
|
||||||
|
@ -1067,7 +1067,7 @@ impl Handler {
|
|||||||
fn get_char(&mut self, name: String, code: i32) -> String {
|
fn get_char(&mut self, name: String, code: i32) -> String {
|
||||||
if let Some(key_event) = self.get_key_event(1, &name, code) {
|
if let Some(key_event) = self.get_key_event(1, &name, code) {
|
||||||
match key_event.union {
|
match key_event.union {
|
||||||
Some(key_event::Union::chr(chr)) => {
|
Some(key_event::Union::Chr(chr)) => {
|
||||||
if let Some(chr) = std::char::from_u32(chr as _) {
|
if let Some(chr) = std::char::from_u32(chr as _) {
|
||||||
return chr.to_string();
|
return chr.to_string();
|
||||||
}
|
}
|
||||||
@ -1810,9 +1810,9 @@ impl Remote {
|
|||||||
id,
|
id,
|
||||||
file_num,
|
file_num,
|
||||||
union: if need_override {
|
union: if need_override {
|
||||||
Some(file_transfer_send_confirm_request::Union::offset_blk(0))
|
Some(file_transfer_send_confirm_request::Union::OffsetBlk(0))
|
||||||
} else {
|
} else {
|
||||||
Some(file_transfer_send_confirm_request::Union::skip(true))
|
Some(file_transfer_send_confirm_request::Union::Skip(true))
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
@ -1828,9 +1828,9 @@ impl Remote {
|
|||||||
id,
|
id,
|
||||||
file_num,
|
file_num,
|
||||||
union: if need_override {
|
union: if need_override {
|
||||||
Some(file_transfer_send_confirm_request::Union::offset_blk(0))
|
Some(file_transfer_send_confirm_request::Union::OffsetBlk(0))
|
||||||
} else {
|
} else {
|
||||||
Some(file_transfer_send_confirm_request::Union::skip(true))
|
Some(file_transfer_send_confirm_request::Union::Skip(true))
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
@ -2017,7 +2017,7 @@ impl Remote {
|
|||||||
async fn handle_msg_from_peer(&mut self, data: &[u8], peer: &mut Stream) -> bool {
|
async fn handle_msg_from_peer(&mut self, data: &[u8], peer: &mut Stream) -> bool {
|
||||||
if let Ok(msg_in) = Message::parse_from_bytes(&data) {
|
if let Ok(msg_in) = Message::parse_from_bytes(&data) {
|
||||||
match msg_in.union {
|
match msg_in.union {
|
||||||
Some(message::Union::video_frame(vf)) => {
|
Some(message::Union::VideoFrame(vf)) => {
|
||||||
if !self.first_frame {
|
if !self.first_frame {
|
||||||
self.first_frame = true;
|
self.first_frame = true;
|
||||||
self.handler.call2("closeSuccess", &make_args!());
|
self.handler.call2("closeSuccess", &make_args!());
|
||||||
@ -2033,16 +2033,16 @@ impl Remote {
|
|||||||
};
|
};
|
||||||
self.video_sender.send(MediaData::VideoFrame(vf)).ok();
|
self.video_sender.send(MediaData::VideoFrame(vf)).ok();
|
||||||
}
|
}
|
||||||
Some(message::Union::hash(hash)) => {
|
Some(message::Union::Hash(hash)) => {
|
||||||
self.handler.handle_hash(hash, peer).await;
|
self.handler.handle_hash(hash, peer).await;
|
||||||
}
|
}
|
||||||
Some(message::Union::login_response(lr)) => match lr.union {
|
Some(message::Union::LoginResponse(lr)) => match lr.union {
|
||||||
Some(login_response::Union::error(err)) => {
|
Some(login_response::Union::Error(err)) => {
|
||||||
if !self.handler.handle_login_error(&err) {
|
if !self.handler.handle_login_error(&err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(login_response::Union::peer_info(pi)) => {
|
Some(login_response::Union::PeerInfo(pi)) => {
|
||||||
self.handler.handle_peer_info(pi);
|
self.handler.handle_peer_info(pi);
|
||||||
self.check_clipboard_file_context();
|
self.check_clipboard_file_context();
|
||||||
if !(self.handler.is_file_transfer()
|
if !(self.handler.is_file_transfer()
|
||||||
@ -2069,22 +2069,22 @@ impl Remote {
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
Some(message::Union::cursor_data(cd)) => {
|
Some(message::Union::CursorData(cd)) => {
|
||||||
self.handler.set_cursor_data(cd);
|
self.handler.set_cursor_data(cd);
|
||||||
}
|
}
|
||||||
Some(message::Union::cursor_id(id)) => {
|
Some(message::Union::CursorId(id)) => {
|
||||||
self.handler.set_cursor_id(id.to_string());
|
self.handler.set_cursor_id(id.to_string());
|
||||||
}
|
}
|
||||||
Some(message::Union::cursor_position(cp)) => {
|
Some(message::Union::CursorPosition(cp)) => {
|
||||||
self.handler.set_cursor_position(cp);
|
self.handler.set_cursor_position(cp);
|
||||||
}
|
}
|
||||||
Some(message::Union::clipboard(cb)) => {
|
Some(message::Union::Clipboard(cb)) => {
|
||||||
if !self.handler.lc.read().unwrap().disable_clipboard {
|
if !self.handler.lc.read().unwrap().disable_clipboard {
|
||||||
update_clipboard(cb, Some(&self.old_clipboard));
|
update_clipboard(cb, Some(&self.old_clipboard));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
Some(message::Union::cliprdr(clip)) => {
|
Some(message::Union::Cliprdr(clip)) => {
|
||||||
if !self.handler.lc.read().unwrap().disable_clipboard {
|
if !self.handler.lc.read().unwrap().disable_clipboard {
|
||||||
if let Some(context) = &mut self.clipboard_file_context {
|
if let Some(context) = &mut self.clipboard_file_context {
|
||||||
if let Some(clip) = msg_2_clip(clip) {
|
if let Some(clip) = msg_2_clip(clip) {
|
||||||
@ -2093,9 +2093,9 @@ impl Remote {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(message::Union::file_response(fr)) => {
|
Some(message::Union::FileResponse(fr)) => {
|
||||||
match fr.union {
|
match fr.union {
|
||||||
Some(file_response::Union::dir(fd)) => {
|
Some(file_response::Union::Dir(fd)) => {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let entries = fd.entries.to_vec();
|
let entries = fd.entries.to_vec();
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
@ -2118,7 +2118,7 @@ impl Remote {
|
|||||||
job.files = entries;
|
job.files = entries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(file_response::Union::digest(digest)) => {
|
Some(file_response::Union::Digest(digest)) => {
|
||||||
if digest.is_upload {
|
if digest.is_upload {
|
||||||
if let Some(job) = fs::get_job(digest.id, &mut self.read_jobs) {
|
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) {
|
if let Some(file) = job.files().get(digest.file_num as usize) {
|
||||||
@ -2129,9 +2129,9 @@ impl Remote {
|
|||||||
id: digest.id,
|
id: digest.id,
|
||||||
file_num: digest.file_num,
|
file_num: digest.file_num,
|
||||||
union: Some(if overwrite {
|
union: Some(if overwrite {
|
||||||
file_transfer_send_confirm_request::Union::offset_blk(0)
|
file_transfer_send_confirm_request::Union::OffsetBlk(0)
|
||||||
} else {
|
} else {
|
||||||
file_transfer_send_confirm_request::Union::skip(
|
file_transfer_send_confirm_request::Union::Skip(
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
@ -2164,7 +2164,7 @@ impl Remote {
|
|||||||
let msg= new_send_confirm(FileTransferSendConfirmRequest {
|
let msg= new_send_confirm(FileTransferSendConfirmRequest {
|
||||||
id: digest.id,
|
id: digest.id,
|
||||||
file_num: digest.file_num,
|
file_num: digest.file_num,
|
||||||
union: Some(file_transfer_send_confirm_request::Union::skip(true)),
|
union: Some(file_transfer_send_confirm_request::Union::Skip(true)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
allow_err!(peer.send(&msg).await);
|
allow_err!(peer.send(&msg).await);
|
||||||
@ -2176,9 +2176,9 @@ impl Remote {
|
|||||||
id: digest.id,
|
id: digest.id,
|
||||||
file_num: digest.file_num,
|
file_num: digest.file_num,
|
||||||
union: Some(if overwrite {
|
union: Some(if overwrite {
|
||||||
file_transfer_send_confirm_request::Union::offset_blk(0)
|
file_transfer_send_confirm_request::Union::OffsetBlk(0)
|
||||||
} else {
|
} else {
|
||||||
file_transfer_send_confirm_request::Union::skip(true)
|
file_transfer_send_confirm_request::Union::Skip(true)
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
@ -2201,7 +2201,7 @@ impl Remote {
|
|||||||
FileTransferSendConfirmRequest {
|
FileTransferSendConfirmRequest {
|
||||||
id: digest.id,
|
id: digest.id,
|
||||||
file_num: digest.file_num,
|
file_num: digest.file_num,
|
||||||
union: Some(file_transfer_send_confirm_request::Union::offset_blk(0)),
|
union: Some(file_transfer_send_confirm_request::Union::OffsetBlk(0)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -2216,7 +2216,7 @@ impl Remote {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(file_response::Union::block(block)) => {
|
Some(file_response::Union::Block(block)) => {
|
||||||
log::info!(
|
log::info!(
|
||||||
"file response block, file id:{}, file num: {}",
|
"file response block, file id:{}, file num: {}",
|
||||||
block.id,
|
block.id,
|
||||||
@ -2229,27 +2229,27 @@ impl Remote {
|
|||||||
self.update_jobs_status();
|
self.update_jobs_status();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(file_response::Union::done(d)) => {
|
Some(file_response::Union::Done(d)) => {
|
||||||
if let Some(job) = fs::get_job(d.id, &mut self.write_jobs) {
|
if let Some(job) = fs::get_job(d.id, &mut self.write_jobs) {
|
||||||
job.modify_time();
|
job.modify_time();
|
||||||
fs::remove_job(d.id, &mut self.write_jobs);
|
fs::remove_job(d.id, &mut self.write_jobs);
|
||||||
}
|
}
|
||||||
self.handle_job_status(d.id, d.file_num, None);
|
self.handle_job_status(d.id, d.file_num, None);
|
||||||
}
|
}
|
||||||
Some(file_response::Union::error(e)) => {
|
Some(file_response::Union::Error(e)) => {
|
||||||
self.handle_job_status(e.id, e.file_num, Some(e.error));
|
self.handle_job_status(e.id, e.file_num, Some(e.error));
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(message::Union::misc(misc)) => match misc.union {
|
Some(message::Union::Misc(misc)) => match misc.union {
|
||||||
Some(misc::Union::audio_format(f)) => {
|
Some(misc::Union::AudioFormat(f)) => {
|
||||||
self.audio_sender.send(MediaData::AudioFormat(f)).ok();
|
self.audio_sender.send(MediaData::AudioFormat(f)).ok();
|
||||||
}
|
}
|
||||||
Some(misc::Union::chat_message(c)) => {
|
Some(misc::Union::ChatMessage(c)) => {
|
||||||
self.handler.call("newMessage", &make_args!(c.text));
|
self.handler.call("newMessage", &make_args!(c.text));
|
||||||
}
|
}
|
||||||
Some(misc::Union::permission_info(p)) => {
|
Some(misc::Union::PermissionInfo(p)) => {
|
||||||
log::info!("Change permission {:?} -> {}", p.permission, p.enabled);
|
log::info!("Change permission {:?} -> {}", p.permission, p.enabled);
|
||||||
match p.permission.enum_value_or_default() {
|
match p.permission.enum_value_or_default() {
|
||||||
Permission::Keyboard => {
|
Permission::Keyboard => {
|
||||||
@ -2277,7 +2277,7 @@ impl Remote {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(misc::Union::switch_display(s)) => {
|
Some(misc::Union::SwitchDisplay(s)) => {
|
||||||
self.handler.call("switchDisplay", &make_args!(s.display));
|
self.handler.call("switchDisplay", &make_args!(s.display));
|
||||||
self.video_sender.send(MediaData::Reset).ok();
|
self.video_sender.send(MediaData::Reset).ok();
|
||||||
if s.width > 0 && s.height > 0 {
|
if s.width > 0 && s.height > 0 {
|
||||||
@ -2293,27 +2293,27 @@ impl Remote {
|
|||||||
self.handler.set_display(s.x, s.y, s.width, s.height);
|
self.handler.set_display(s.x, s.y, s.width, s.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(misc::Union::close_reason(c)) => {
|
Some(misc::Union::CloseReason(c)) => {
|
||||||
self.handler.msgbox("error", "Connection Error", &c);
|
self.handler.msgbox("error", "Connection Error", &c);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Some(misc::Union::back_notification(notification)) => {
|
Some(misc::Union::BackNotification(notification)) => {
|
||||||
if !self.handle_back_notification(notification).await {
|
if !self.handle_back_notification(notification).await {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
Some(message::Union::test_delay(t)) => {
|
Some(message::Union::TestDelay(t)) => {
|
||||||
self.handler.handle_test_delay(t, peer).await;
|
self.handler.handle_test_delay(t, peer).await;
|
||||||
}
|
}
|
||||||
Some(message::Union::audio_frame(frame)) => {
|
Some(message::Union::AudioFrame(frame)) => {
|
||||||
if !self.handler.lc.read().unwrap().disable_audio {
|
if !self.handler.lc.read().unwrap().disable_audio {
|
||||||
self.audio_sender.send(MediaData::AudioFrame(frame)).ok();
|
self.audio_sender.send(MediaData::AudioFrame(frame)).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(message::Union::file_action(action)) => match action.union {
|
Some(message::Union::FileAction(action)) => match action.union {
|
||||||
Some(file_action::Union::send_confirm(c)) => {
|
Some(file_action::Union::SendConfirm(c)) => {
|
||||||
if let Some(job) = fs::get_job(c.id, &mut self.read_jobs) {
|
if let Some(job) = fs::get_job(c.id, &mut self.read_jobs) {
|
||||||
job.confirm(&c);
|
job.confirm(&c);
|
||||||
}
|
}
|
||||||
@ -2328,13 +2328,13 @@ impl Remote {
|
|||||||
|
|
||||||
async fn handle_back_notification(&mut self, notification: BackNotification) -> bool {
|
async fn handle_back_notification(&mut self, notification: BackNotification) -> bool {
|
||||||
match notification.union {
|
match notification.union {
|
||||||
Some(back_notification::Union::block_input_state(state)) => {
|
Some(back_notification::Union::BlockInputState(state)) => {
|
||||||
self.handle_back_msg_block_input(
|
self.handle_back_msg_block_input(
|
||||||
state.enum_value_or(back_notification::BlockInputState::StateUnknown),
|
state.enum_value_or(back_notification::BlockInputState::StateUnknown),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
Some(back_notification::Union::privacy_mode_state(state)) => {
|
Some(back_notification::Union::PrivacyModeState(state)) => {
|
||||||
if !self
|
if !self
|
||||||
.handle_back_msg_privacy_mode(
|
.handle_back_msg_privacy_mode(
|
||||||
state.enum_value_or(back_notification::PrivacyModeState::StateUnknown),
|
state.enum_value_or(back_notification::PrivacyModeState::StateUnknown),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user