Skip to content

Commit e21c556

Browse files
elmarcoCBenoit
authored andcommitted
refactor(server): factor out deactivate_reactivate()
This makes code slightly nicer and allow further code reuse. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1 parent a0fccf8 commit e21c556

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

crates/ironrdp-server/src/server.rs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -436,20 +436,7 @@ impl RdpServer {
436436
DisplayUpdate::PointerPosition(pos) => encoder.pointer_position(pos),
437437
DisplayUpdate::Resize(desktop_size) => {
438438
debug!(?desktop_size, "Display resize");
439-
let pdu = ShareControlPdu::ServerDeactivateAll(ServerDeactivateAll);
440-
let pdu = rdp::headers::ShareControlHeader {
441-
share_id: 0,
442-
pdu_source: io_channel_id,
443-
share_control_pdu: pdu,
444-
};
445-
let user_data = encode_vec(&pdu)?.into();
446-
let pdu = SendDataIndication {
447-
initiator_id: user_channel_id,
448-
channel_id: io_channel_id,
449-
user_data,
450-
};
451-
let msg = encode_vec(&X224(pdu))?;
452-
writer.write_all(&msg).await?;
439+
deactivate_all(io_channel_id, user_channel_id, writer).await?;
453440
return Ok((RunState::DeactivationReactivation { desktop_size }, encoder));
454441
}
455442
DisplayUpdate::RGBAPointer(ptr) => encoder.rgba_pointer(ptr),
@@ -940,6 +927,28 @@ impl RdpServer {
940927
}
941928
}
942929

930+
async fn deactivate_all(
931+
io_channel_id: u16,
932+
user_channel_id: u16,
933+
writer: &mut impl FramedWrite,
934+
) -> Result<(), anyhow::Error> {
935+
let pdu = ShareControlPdu::ServerDeactivateAll(ServerDeactivateAll);
936+
let pdu = rdp::headers::ShareControlHeader {
937+
share_id: 0,
938+
pdu_source: io_channel_id,
939+
share_control_pdu: pdu,
940+
};
941+
let user_data = encode_vec(&pdu)?.into();
942+
let pdu = SendDataIndication {
943+
initiator_id: user_channel_id,
944+
channel_id: io_channel_id,
945+
user_data,
946+
};
947+
let msg = encode_vec(&X224(pdu))?;
948+
writer.write_all(&msg).await?;
949+
Ok(())
950+
}
951+
943952
struct SharedWriter<'w, W: FramedWrite> {
944953
writer: Rc<Mutex<&'w mut W>>,
945954
}

0 commit comments

Comments
 (0)