![]() |
Moonlight-XboxOG latest
Moonlight Xbox OG is a port of the Moonlight Game Streaming client to the original Xbox console.
|
Implements client state models and transitions. More...
#include "src/app/client_state.h"#include "src/network/host_pairing.h"#include <algorithm>#include <array>#include <string_view>#include <utility>#include <vector>Functions | |
| void | app::activate_hosts_toolbar (ClientState &state, AppUpdate *update) |
| Handles activation of the hosts toolbar. | |
| void | app::activate_selected_host (ClientState &state, AppUpdate *update) |
| Activates a selected host from the hosts screen. | |
| bool | app::app_list_result_targets_active_selection (const ClientState &state, const HostRecord *host) |
| Returns whether the given host is the active apps-screen selection. | |
| void | app::apply_add_host_validation_error (ClientState &state, std::string_view validationError) |
| Applies an invalid add-host draft error to the UI state. | |
| void | app::apply_app_list_result (ClientState &state, const std::string &address, uint16_t port, std::vector< HostAppRecord > apps, uint64_t appListContentHash, bool success, std::string message) |
| Apply a fetched app list to a saved host. | |
| void | app::apply_cached_app_list_failure (ClientState &state, HostRecord *host, bool hostIsActiveAppsScreenSelection, std::string message) |
| Applies a failed app-list refresh that can fall back to cached app data. | |
| void | app::apply_connection_test_result (ClientState &state, bool success, std::string message) |
| Apply the result of a host connection test to the current shell state. | |
| void | app::apply_log_viewer_contents (ClientState &state, std::vector< std::string > lines, std::string statusMessage) |
| Replace the loaded log viewer contents. | |
| bool | app::apply_pairing_result (ClientState &state, const std::string &address, uint16_t port, bool success, std::string message) |
| Apply the result of a pairing attempt to the current shell state. | |
| void | app::apply_unpaired_app_list_failure (ClientState &state, HostRecord *host, bool hostIsActiveAppsScreenSelection, std::string message) |
| Applies a failed app-list refresh for an unpaired host. | |
| const HostRecord * | app::apps_host (const ClientState &state) |
| Return the host currently shown by the Apps screen. | |
| bool | app::begin_selected_host_app_browse (ClientState &state, bool showHiddenApps) |
| Enter the apps screen for the currently selected host after authorization has been refreshed. | |
| ClientState | app::create_initial_state () |
| Create the initial app state shown after startup. | |
| std::string | app::current_add_host_address (const ClientState &state) |
| Return the current host address shown in the add-host flow. | |
| uint16_t | app::current_add_host_port (const ClientState &state) |
| Return the effective TCP port for the current add-host draft. | |
| std::string | app::current_pairing_pin (const ClientState &state) |
| Return the current pairing PIN shown in the pairing flow. | |
| HostRecord * | app::find_app_list_result_host (ClientState &state, const std::string &address, uint16_t port) |
| Finds the host that should receive an app-list refresh result. | |
| bool | app::handle_add_host_keypad_command (ClientState &state, input::UiCommand command) |
| Handles commands while the add-host keypad modal is visible. | |
| void | app::handle_add_host_menu_activation (ClientState &state, std::string_view activatedItemId, AppUpdate *update) |
| Handles activation of add-host screen menu actions. | |
| bool | app::handle_apps_screen_command (ClientState &state, input::UiCommand command, AppUpdate *update) |
| Handles commands on the apps screen. | |
| AppUpdate | app::handle_command (ClientState &state, input::UiCommand command) |
| Apply a UI command to the client shell. | |
| bool | app::handle_hosts_screen_command (ClientState &state, input::UiCommand command, AppUpdate *update) |
| Handles commands on the hosts screen. | |
| bool | app::handle_overlay_command (ClientState &state, input::UiCommand command, AppUpdate *update) |
| Handles overlay toggle and scrolling commands. | |
| void | app::handle_settings_detail_activation (ClientState &state, const ui::MenuUpdate &detailUpdate, AppUpdate *update) |
| Handles activation of a settings detail row. | |
| bool | app::handle_settings_screen_command (ClientState &state, input::UiCommand command, AppUpdate *update) |
| Handles commands on the settings screen. | |
| bool | app::host_requires_manual_pairing (const ClientState &state, const std::string &address, uint16_t port) |
| Return whether a saved host still requires a manual pairing flow. | |
| void | app::mark_cover_art_cached (ClientState &state, const std::string &address, uint16_t port, int appId) |
| Mark one cached cover-art entry as available for a host app. | |
| bool | app::merge_discovered_host (ClientState &state, std::string displayName, const std::string &address, uint16_t port) |
| Add or refresh one auto-discovered host in the current host list. | |
| std::vector< HostAppRecord > | app::merge_host_app_records (const HostRecord &host, std::vector< HostAppRecord > apps) |
| Merges saved app metadata into a freshly fetched app list. | |
| void | app::replace_hosts (ClientState &state, std::vector< HostRecord > hosts, std::string statusMessage={}) |
| Replace the in-memory host list from a persisted snapshot. | |
| void | app::replace_saved_files (ClientState &state, std::vector< startup::SavedFileEntry > savedFiles) |
| Replace the in-memory saved-file inventory shown on the settings page. | |
| void | app::restore_selected_app_after_refresh (ClientState &state, const HostRecord &host, int selectedAppId) |
| Restores the previously selected app after a successful refresh. | |
| const HostAppRecord * | app::selected_app (const ClientState &state) |
| Return the currently selected app on the Apps screen. | |
| int | app::selected_app_id_for_restore (const ClientState &state) |
| Returns the selected app identifier so it can be restored after a refresh. | |
| const HostRecord * | app::selected_host (const ClientState &state) |
| Return the currently selected loaded host for the active screen. | |
| void | app::set_log_file_path (ClientState &state, std::string logFilePath) |
| Update the log file path tracked by the shell. | |
| const char * | app::to_string (ScreenId screen) |
| Return a display label for a screen identifier. | |
Implements client state models and transitions.
| void app::activate_hosts_toolbar | ( | ClientState & | state, |
| AppUpdate * | update ) |
Handles activation of the hosts toolbar.
| state | Client state containing the toolbar selection. |
| update | Update structure that receives side effects. |
| void app::activate_selected_host | ( | ClientState & | state, |
| AppUpdate * | update ) |
Activates a selected host from the hosts screen.
| state | Client state containing the selected host. |
| update | Update structure that receives browse or pairing work. |
| bool app::app_list_result_targets_active_selection | ( | const ClientState & | state, |
| const HostRecord * | host ) |
Returns whether the given host is the active apps-screen selection.
| state | Client state to inspect. |
| host | Host potentially backing the apps screen. |
| void app::apply_add_host_validation_error | ( | ClientState & | state, |
| std::string_view | validationError ) |
Applies an invalid add-host draft error to the UI state.
| state | Client state containing the add-host draft. |
| validationError | Validation message to display. |
| void app::apply_app_list_result | ( | ClientState & | state, |
| const std::string & | address, | ||
| uint16_t | port, | ||
| std::vector< HostAppRecord > | apps, | ||
| uint64_t | appListContentHash, | ||
| bool | success, | ||
| std::string | message ) |
Apply a fetched app list to a saved host.
| state | Mutable app state. |
| address | Host address used for the fetch. |
| port | Host port used for the fetch. |
| apps | Fresh app records returned by the host. |
| appListContentHash | Stable content hash for the returned app list. |
| success | Whether the fetch succeeded. |
| message | User-visible status message. |
| void app::apply_cached_app_list_failure | ( | ClientState & | state, |
| HostRecord * | host, | ||
| bool | hostIsActiveAppsScreenSelection, | ||
| std::string | message ) |
Applies a failed app-list refresh that can fall back to cached app data.
| state | Client state to update. |
| host | Host receiving the failure. |
| hostIsActiveAppsScreenSelection | True when the host backs the active apps screen. |
| message | Failure message returned by the refresh task. |
| void app::apply_connection_test_result | ( | ClientState & | state, |
| bool | success, | ||
| std::string | message ) |
Apply the result of a host connection test to the current shell state.
| state | Mutable app state. |
| success | Whether the test succeeded. |
| message | User-visible status message. |
| void app::apply_log_viewer_contents | ( | ClientState & | state, |
| std::vector< std::string > | lines, | ||
| std::string | statusMessage ) |
Replace the loaded log viewer contents.
| state | Mutable app state. |
| lines | Log file lines ready for display. |
| statusMessage | User-visible status line for the log viewer state. |
| bool app::apply_pairing_result | ( | ClientState & | state, |
| const std::string & | address, | ||
| uint16_t | port, | ||
| bool | success, | ||
| std::string | message ) |
Apply the result of a pairing attempt to the current shell state.
| state | Mutable app state. |
| address | Host address used for pairing. |
| port | Host port used for pairing. |
| success | Whether the pairing attempt succeeded. |
| message | User-visible status message. |
| void app::apply_unpaired_app_list_failure | ( | ClientState & | state, |
| HostRecord * | host, | ||
| bool | hostIsActiveAppsScreenSelection, | ||
| std::string | message ) |
Applies a failed app-list refresh for an unpaired host.
| state | Client state to update. |
| host | Host receiving the failure. |
| hostIsActiveAppsScreenSelection | True when the host backs the active apps screen. |
| message | Failure message returned by the refresh task. |
| const HostRecord * app::apps_host | ( | const ClientState & | state | ) |
Return the host currently shown by the Apps screen.
| state | App state containing the selected host. |
| bool app::begin_selected_host_app_browse | ( | ClientState & | state, |
| bool | showHiddenApps ) |
Enter the apps screen for the currently selected host after authorization has been refreshed.
| state | Mutable app state. |
| showHiddenApps | Whether hidden apps should still be shown. |
| ClientState app::create_initial_state | ( | ) |
Create the initial app state shown after startup.
| std::string app::current_add_host_address | ( | const ClientState & | state | ) |
Return the current host address shown in the add-host flow.
| state | App state containing the add-host draft. |
| uint16_t app::current_add_host_port | ( | const ClientState & | state | ) |
Return the effective TCP port for the current add-host draft.
| state | App state containing the add-host draft. |
| std::string app::current_pairing_pin | ( | const ClientState & | state | ) |
Return the current pairing PIN shown in the pairing flow.
| state | App state containing the pairing draft. |
| HostRecord * app::find_app_list_result_host | ( | ClientState & | state, |
| const std::string & | address, | ||
| uint16_t | port ) |
Finds the host that should receive an app-list refresh result.
| state | Client state that owns saved and active hosts. |
| address | Address reported by the background task. |
| port | Port reported by the background task. |
| bool app::handle_add_host_keypad_command | ( | ClientState & | state, |
| input::UiCommand | command ) |
Handles commands while the add-host keypad modal is visible.
| state | Client state containing the keypad draft. |
| command | Command being processed. |
| void app::handle_add_host_menu_activation | ( | ClientState & | state, |
| std::string_view | activatedItemId, | ||
| AppUpdate * | update ) |
Handles activation of add-host screen menu actions.
| state | Client state containing the add-host draft. |
| activatedItemId | Activated menu item identifier. |
| update | Update structure that receives side effects. |
| bool app::handle_apps_screen_command | ( | ClientState & | state, |
| input::UiCommand | command, | ||
| AppUpdate * | update ) |
Handles commands on the apps screen.
| state | Client state containing the apps selection. |
| command | Command being processed. |
| update | Update structure that receives side effects. |
| AppUpdate app::handle_command | ( | ClientState & | state, |
| input::UiCommand | command ) |
Apply a UI command to the client shell.
| state | Mutable app state. |
| command | UI command from controller or keyboard input. |
| bool app::handle_hosts_screen_command | ( | ClientState & | state, |
| input::UiCommand | command, | ||
| AppUpdate * | update ) |
Handles commands on the hosts screen.
| state | Client state containing the hosts screen selection. |
| command | Command being processed. |
| update | Update structure that receives side effects. |
| bool app::handle_overlay_command | ( | ClientState & | state, |
| input::UiCommand | command, | ||
| AppUpdate * | update ) |
Handles overlay toggle and scrolling commands.
| state | Client state containing the overlay state. |
| command | Command being processed. |
| update | Update structure that receives overlay changes. |
| void app::handle_settings_detail_activation | ( | ClientState & | state, |
| const ui::MenuUpdate & | detailUpdate, | ||
| AppUpdate * | update ) |
Handles activation of a settings detail row.
| state | Client state containing the settings menus. |
| detailUpdate | Activated detail-menu update. |
| update | Update structure that receives side effects. |
| bool app::handle_settings_screen_command | ( | ClientState & | state, |
| input::UiCommand | command, | ||
| AppUpdate * | update ) |
Handles commands on the settings screen.
| state | Client state containing the settings menus. |
| command | Command being processed. |
| update | Update structure that receives side effects. |
| bool app::host_requires_manual_pairing | ( | const ClientState & | state, |
| const std::string & | address, | ||
| uint16_t | port ) |
Return whether a saved host still requires a manual pairing flow.
| state | App state containing the saved host list. |
| address | Host address to inspect. |
| port | Host port to inspect. |
| void app::mark_cover_art_cached | ( | ClientState & | state, |
| const std::string & | address, | ||
| uint16_t | port, | ||
| int | appId ) |
Mark one cached cover-art entry as available for a host app.
| state | Mutable app state. |
| address | Host address owning the app. |
| port | Host port owning the app. |
| appId | App identifier whose cached art is now available. |
| bool app::merge_discovered_host | ( | ClientState & | state, |
| std::string | displayName, | ||
| const std::string & | address, | ||
| uint16_t | port ) |
Add or refresh one auto-discovered host in the current host list.
Discovery results are normalized to the same saved-host conventions used by manual host entry. When a matching host already exists, transient runtime fields such as reachability are refreshed without overwriting a custom saved name. When no host matches, a new host record is appended and marked dirty so it can be persisted.
| state | Mutable app state. |
| displayName | Discovered host name, or an empty string to use the default label. |
| address | Discovered IPv4 address. |
| port | Discovered host HTTP port. |
| std::vector< HostAppRecord > app::merge_host_app_records | ( | const HostRecord & | host, |
| std::vector< HostAppRecord > | apps ) |
Merges saved app metadata into a freshly fetched app list.
| host | Host providing persisted per-app metadata. |
| apps | Freshly fetched apps to merge. |
| void app::replace_hosts | ( | ClientState & | state, |
| std::vector< HostRecord > | hosts, | ||
| std::string | statusMessage = {} ) |
Replace the in-memory host list from a persisted snapshot.
| state | Mutable app state. |
| hosts | Loaded host records. |
| statusMessage | Optional status line shown in the shell. |
| void app::replace_saved_files | ( | ClientState & | state, |
| std::vector< startup::SavedFileEntry > | savedFiles ) |
Replace the in-memory saved-file inventory shown on the settings page.
| state | Mutable app state. |
| savedFiles | Saved files currently found on disk. |
| void app::restore_selected_app_after_refresh | ( | ClientState & | state, |
| const HostRecord & | host, | ||
| int | selectedAppId ) |
Restores the previously selected app after a successful refresh.
| state | Client state whose selected app should be restored. |
| host | Host containing the refreshed app list. |
| selectedAppId | App ID that was selected before the refresh. |
| const HostAppRecord * app::selected_app | ( | const ClientState & | state | ) |
Return the currently selected app on the Apps screen.
| state | App state containing the selected host and apps list. |
| int app::selected_app_id_for_restore | ( | const ClientState & | state | ) |
Returns the selected app identifier so it can be restored after a refresh.
| state | Client state whose selected app should be preserved. |
| const HostRecord * app::selected_host | ( | const ClientState & | state | ) |
Return the currently selected loaded host for the active screen.
On the hosts page this returns the selected saved host tile. On host-specific pages such as pairing it may return the lightweight active host snapshot.
| state | App state containing the loaded host selection. |
| void app::set_log_file_path | ( | ClientState & | state, |
| std::string | logFilePath ) |
Update the log file path tracked by the shell.
| state | Mutable app state. |
| logFilePath | Path to the log file that should be shown in the viewer. |
| const char * app::to_string | ( | ScreenId | screen | ) |
Return a display label for a screen identifier.
| screen | Screen identifier to stringify. |