#pragma once #include "app_state.h" #include "db/db_keys.h" // First-Run provisioning walkthrough. On every boot the app walks a fixed // sequence of prerequisites and shows the first one that is missing: // // 1. Internet reachable? -> WiFiSetupPage // 2. Email address set? -> EmailAddressPage // 3. License key set? -> LicenseKeyPage // 4. Everything satisfied -> Home // // "Internet reachable" means real connectivity (Ethernet, WiFi, or whatever // the OS provides) via NetworkManager::hasInternet(), NOT merely "a WiFi // link is up" -- so a device on Ethernet or a developer's MacBook never gets // trapped on the WiFi page. // // When the walkthrough starts (begin) and the very first step is missing // (no internet, no email, no license) the device is treated as brand-new and // the firstRunWalkthrough placeholder flag is raised. That flag will later // drive a first-run welcome walkthrough (TOS, quick user guide, ...); today // it is only set and logged. namespace radiantwave::provisioning { // Prerequisite steps in walkthrough priority order. enum class Step { Done, Internet, Email, License }; // First unsatisfied step, given the current conditions. inline Step firstMissingStep(bool internetUp, bool hasEmail, bool hasLicense) { if (!internetUp) return Step::Internet; if (!hasEmail) return Step::Email; if (!hasLicense) return Step::License; return Step::Done; } // True when nothing is configured (no internet, no email, no license). // Signals a brand-new, never-provisioned device. inline bool indicatesFirstRun(bool internetUp, bool hasEmail, bool hasLicense) { return !internetUp && !hasEmail && !hasLicense; } // Startup walkthrough. Evaluates the prerequisites and pushes the first // missing step's page (with provisioningMode set), or Home when everything // is satisfied. Home is always the end of the walkthrough. void begin(AppState& state); // Called by a walkthrough page when the user finishes or exits it. Pops the // current page, re-evaluates the prerequisites, and pushes the next missing // step's page (or Home). Internet is only re-probed when it was still // missing, so completing a step never blocks on a redundant check. void advance(AppState& state); } // namespace radiantwave::provisioning