Skip to main content

pacenotes_installer\worker/
message.rs

1/// `WPARAM` is the request id, `LPARAM` a `Box<Message>` the receiver reclaims with `take`.
2pub const WM_WORKER_DONE: u32 = windows_sys::Win32::UI::WindowsAndMessaging::WM_APP + 1;
3
4/// Posted while a job runs: `WPARAM` the request id, `LPARAM` a `Box<Progress>` for `take_progress`.
5pub const WM_WORKER_PROGRESS: u32 = windows_sys::Win32::UI::WindowsAndMessaging::WM_APP + 2;
6
7/// What a worker finished, one variant per thing a scene asks for.
8pub enum Message {
9    Health {
10        online: bool,
11    },
12    /// `None` when the server has no text or cannot be reached.
13    Motd(Option<String>),
14    SecretChecked(SecretOutcome),
15    /// A failure is not fatal: the Download scene falls back to the cache.
16    Packages(Result<pacenotes_shared::Manifest, String>),
17    /// Scene 4b's transfers ended; the game folder is still untouched.
18    Downloaded(Fetched),
19    Installed(Outcome),
20}
21
22/// How scene 4b's download phase ended, apart from `Outcome` because a finished
23/// download is not a finished run: the questions and the install come after it.
24#[derive(Clone, Debug, PartialEq, Eq)]
25pub enum Fetched {
26    /// Every package was tried, each until it arrived verified or ran out of
27    /// attempts; `failed` names the ones that never came.
28    Done {
29        downloaded: usize,
30        bytes: u64,
31        failed: Vec<NotDownloaded>,
32    },
33    /// The partial download was discarded.
34    Cancelled,
35}
36
37/// A package still missing after every attempt, which scene 7 names.
38#[derive(Clone, Debug, PartialEq, Eq)]
39pub struct NotDownloaded {
40    pub key: String,
41    pub label: String,
42    pub reason: String,
43}
44
45#[derive(Clone, Copy, PartialEq, Eq, Debug)]
46pub enum SecretOutcome {
47    /// Unix seconds, or `None` for a key that never expires, so scene 2 can warn first.
48    Accepted { expires_at: Option<i64> },
49    /// 401: wrong, unknown, expired or revoked, which the server does not tell apart.
50    Rejected,
51    /// Could not ask, which DESIGN.md treats as permission to continue unvalidated.
52    Unreachable,
53}
54
55/// How the run ended, which scene 7 reports; what the transfers cost is kept
56/// by the wizard, since they happened on an earlier screen.
57#[derive(Clone, Debug, PartialEq, Eq)]
58pub enum Outcome {
59    Done {
60        applied: Applied,
61    },
62    /// Already readable, and already in the log.
63    Failed(String),
64    /// Backed out of the removal confirmation or of a running download.
65    Cancelled,
66}
67
68/// What the run did to the game folder, for scene 7.
69#[derive(Clone, Debug, Default, PartialEq, Eq)]
70pub struct Applied {
71    pub installed: Vec<String>,
72    pub uninstalled: Vec<String>,
73    /// Kept because something else had changed them since they were written.
74    pub left_alone: Vec<String>,
75    /// Written by the game's own configuration step.
76    pub configured: Vec<String>,
77    pub overlaps: usize,
78    pub restore_point: Option<String>,
79}
80
81#[derive(Clone, Copy, PartialEq, Eq, Debug)]
82pub enum Phase {
83    Download,
84    Checking,
85    Uninstall,
86    Backup,
87    Install,
88    Configure,
89}
90
91/// Everything scene 6 shows, so the scene keeps no state beyond the last post.
92pub struct Progress {
93    pub phase: Phase,
94    /// Already labelled for display.
95    pub item: String,
96    pub item_done: u64,
97    pub item_size: u64,
98    /// Across the whole phase, so the bar measures the run rather than restarting per package.
99    pub done: u64,
100    pub total: u64,
101    /// A line for the log pane; most posts carry none.
102    pub log: Option<String>,
103}