Skip to content

Commit 83ff89f

Browse files
committed
feat: implement initial project structure and core service/client communication logic
1 parent 1d86753 commit 83ff89f

82 files changed

Lines changed: 468 additions & 366 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

crates/builder/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// uds-build/src/lib.rs
2-
use chrono::{Datelike, Utc, NaiveDate};
2+
use chrono::{Datelike, NaiveDate, Utc};
33
use winres::WindowsResource;
44

55
pub struct BuildInfo<'a> {
@@ -41,7 +41,10 @@ pub fn build_windows(build_info: BuildInfo) {
4141
res.set_language(0x0409);
4242

4343
res.set("FileVersion", &format!("{major}.{minor}.{patch}.{build}"));
44-
res.set("ProductVersion", &format!("{major}.{minor}.{patch}.{build}"));
44+
res.set(
45+
"ProductVersion",
46+
&format!("{major}.{minor}.{patch}.{build}"),
47+
);
4548
res.set("ProductName", build_info.product_name);
4649
res.set("FileDescription", build_info.description);
4750
res.set(

crates/client/build.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
2828
*/
2929
fn main() {
3030
#[cfg(windows)]
31-
builder::build_windows(
32-
builder::BuildInfo {
33-
product_name: "UDS Actor Client",
34-
description: "UDS Actor Client",
35-
icon: None,
36-
bmp: None,
37-
requires_admin: false,
38-
}
39-
);
31+
builder::build_windows(builder::BuildInfo {
32+
product_name: "UDS Actor Client",
33+
description: "UDS Actor Client",
34+
icon: None,
35+
bmp: None,
36+
requires_admin: false,
37+
});
4038
}

crates/client/src/gui.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use tokio::process::Command;
33

44
use shared::log;
55

6-
76
// We have created a separate gui helper because on linux
87
// at session close the X windows (xrdp for example) destroys de X server.
98
// fltk fails and do a Fl::fatal, that in turn executes "exit(1)" which makes

crates/client/src/platform.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ use anyhow::Result;
22
use std::sync::Arc;
33

44
use shared::{
5-
system,
65
sync::OnceSignal,
6+
system,
77
ws::client::{WsClient, websocket_client_tasks},
88
};
99

10-
use crate::{gui, session::SessionManagement, ws_reqs::{WsReqs, WsRequester}};
10+
use crate::{
11+
gui,
12+
session::SessionManagement,
13+
ws_reqs::{WsReqs, WsRequester},
14+
};
1115

1216
#[derive(Clone)]
1317
pub struct Platform {

crates/client/src/tasks/deadline.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ pub async fn task(
5151

5252
// Deadline timer, simply wait until deadline is reached inside the session_manager
5353
// But leave a 5 mins to notify before deadline
54-
if stop.wait_timeout(deadline)
55-
.await
56-
.is_err()
54+
if stop.wait_timeout(deadline).await.is_err()
5755
// Timeout without being signaled
5856
{
5957
log::info!("Deadline notification reached, notifying user");

crates/client/src/tasks/idle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ mod tests {
131131
async fn test_idle_task_idle() {
132132
log::setup_logging("debug", shared::log::LogType::Tests);
133133

134-
let (platform, calls, _ ,_) = mock_platform(None, None, None, None, 43902).await;
134+
let (platform, calls, _, _) = mock_platform(None, None, None, None, 43902).await;
135135
let session_manager = platform.session_manager();
136136

137137
// Run idle task in a separate task with a short max_idle (10 seconds)

crates/client/src/testing/mock.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ pub async fn mock_platform(
9292
mpsc::channel::<shared::ws::types::RpcEnvelope<shared::ws::types::RpcMessage>>(32);
9393
let ws_client = WsClient { from_ws, to_ws };
9494

95-
let ws_requester = ws_requester.unwrap_or_else(|| {
96-
std::sync::Arc::new(WsReqsMock::new(calls.clone()))
97-
});
95+
let ws_requester =
96+
ws_requester.unwrap_or_else(|| std::sync::Arc::new(WsReqsMock::new(calls.clone())));
9897

9998
(
10099
crate::platform::Platform::new_with_params(

crates/client/src/unix/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ impl SessionManagement for UnixSessionManager {
2929
}
3030
}
3131

32-
pub async fn new_session_manager(stop: OnceSignal) -> std::sync::Arc<dyn SessionManagement + Send + Sync> {
32+
pub async fn new_session_manager(
33+
stop: OnceSignal,
34+
) -> std::sync::Arc<dyn SessionManagement + Send + Sync> {
3335
std::sync::Arc::new(UnixSessionManager::new(stop).await)
3436
}
3537

crates/client/src/windows/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ impl SessionManagement for WindowsSessionManager {
6969
}
7070
}
7171

72-
pub async fn new_session_manager(stop: OnceSignal) -> std::sync::Arc<dyn SessionManagement + Send + Sync> {
72+
pub async fn new_session_manager(
73+
stop: OnceSignal,
74+
) -> std::sync::Arc<dyn SessionManagement + Send + Sync> {
7375
std::sync::Arc::new(WindowsSessionManager::new(stop).await)
7476
}
7577

@@ -85,8 +87,9 @@ mod tests {
8587
let stop = session_close.get_stop();
8688
let _fake_closer = tokio::spawn({
8789
async move {
88-
session_close.get_stop().wait().await;
89-
}});
90+
session_close.get_stop().wait().await;
91+
}
92+
});
9093
// wait a bit to simulate work
9194
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
9295
event.signal();
@@ -104,8 +107,9 @@ mod tests {
104107
let stop = session_close.get_stop();
105108
let _fake_closer = tokio::spawn({
106109
async move {
107-
session_close.get_stop().wait().await;
108-
}});
110+
session_close.get_stop().wait().await;
111+
}
112+
});
109113
// wait a bit to simulate work
110114
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
111115
stop.set();

crates/client/src/ws_reqs.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::sync::Arc;
22

33
use shared::{
4-
system,
54
sync::OnceSignal,
5+
system,
66
ws::{
77
client::WsClient,
88
types::{LoginRequest, LoginResponse, LogoutRequest, RpcEnvelope, RpcMessage},
@@ -24,7 +24,11 @@ pub struct WsRequester {
2424

2525
impl WsRequester {
2626
pub fn new(operations: Arc<dyn system::System>, ws_client: WsClient, stop: OnceSignal) -> Self {
27-
Self { operations, ws_client, stop }
27+
Self {
28+
operations,
29+
ws_client,
30+
stop,
31+
}
2832
}
2933
}
3034

0 commit comments

Comments
 (0)