Definitions for the startup and shutdown of the apps started by a streaming Session. More...
#include <algorithm>#include <array>#include <filesystem>#include <string>#include <thread>#include <utility>#include <vector>#include <boost/algorithm/string.hpp>#include <boost/crc.hpp>#include <boost/filesystem.hpp>#include <boost/program_options/parsers.hpp>#include <boost/property_tree/json_parser.hpp>#include <boost/property_tree/ptree.hpp>#include <boost/range/algorithm/find_if.hpp>#include <boost/token_functions.hpp>#include <openssl/evp.h>#include <openssl/sha.h>#include "config.h"#include "crypto.h"#include "display_device.h"#include "input.h"#include "logging.h"#include "platform/common.h"#include "process.h"#include "system_tray.h"#include "utility.h"#include "platform/windows/utf_utils.h"#include <share.h>Classes | |
| class | proc::deinit_t |
| RAII helper that runs shutdown cleanup when destroyed. More... | |
Functions | |
| std::tuple< std::string, std::string > | proc::calculate_app_id (const std::string &app_name, std::string app_image_path, int index) |
| Calculate a stable id based on name and image data. | |
| uint32_t | proc::calculate_crc32 (const std::string &input) |
| Calculate the CRC-32 checksum for a string. | |
| std::optional< std::string > | proc::calculate_sha256 (const std::string &filename) |
| Calculate the SHA-256 digest for a file. | |
| bool | proc::check_valid_png (const std::filesystem::path &path) |
| Validates a path whether it is a valid PNG. | |
| std::string_view::iterator | proc::find_match (std::string_view::iterator begin, std::string_view::iterator end) |
| Find the closing parenthesis for an environment-variable expression. | |
| boost::filesystem::path | proc::find_working_directory (const std::string &cmd, boost::process::v1::environment &env) |
| Resolve the working directory for a configured command. | |
| std::unique_ptr< platf::deinit_t > | proc::init () |
| Initialize proc functions. | |
| std::optional< proc::proc_t > | proc::parse (const std::string &file_name) |
| Parse serialized text into the corresponding runtime representation. | |
| std::string | proc::parse_env_val (boost::process::v1::native_environment &env, const std::string_view &val_raw) |
| Parse env val. | |
| std::string | proc::prepare_command (const std::string &command) |
| Prepare a configured command for execution. | |
| void | proc::refresh (const std::string &file_name) |
| Refresh cached platform state from the operating system. | |
| void | proc::terminate_process_group (boost::process::v1::child &child_process, boost::process::v1::group &group, std::chrono::seconds exit_timeout) |
| Terminates all child processes in a process group. | |
| std::string | proc::validate_app_image_path (std::string app_image_path) |
| Validate app image path. | |
Variables | |
| proc_t | proc::proc |
| Global process registry used to track and terminate child processes. | |
Definitions for the startup and shutdown of the apps started by a streaming Session.
| std::tuple< std::string, std::string > proc::calculate_app_id | ( | const std::string & | app_name, |
| std::string | app_image_path, | ||
| int | index ) |
Calculate a stable id based on name and image data.
| app_name | App name. |
| app_image_path | App image path. |
| index | Zero-based index of the item being addressed. |
| uint32_t proc::calculate_crc32 | ( | const std::string & | input | ) |
Calculate the CRC-32 checksum for a string.
| input | Bytes to include in the checksum. |
| std::optional< std::string > proc::calculate_sha256 | ( | const std::string & | filename | ) |
Calculate the SHA-256 digest for a file.
| filename | File path whose contents should be hashed. |
| bool proc::check_valid_png | ( | const std::filesystem::path & | path | ) |
Validates a path whether it is a valid PNG.
| path | The path to the PNG file. |
| std::string_view::iterator proc::find_match | ( | std::string_view::iterator | begin, |
| std::string_view::iterator | end ) |
Find the closing parenthesis for an environment-variable expression.
| begin | Iterator positioned at the opening parenthesis. |
| end | End iterator for the expression being scanned. |
| boost::filesystem::path proc::find_working_directory | ( | const std::string & | cmd, |
| boost::process::v1::environment & | env ) |
Resolve the working directory for a configured command.
| cmd | Command line to execute or inspect. |
| env | Environment variables for the child process. |
| std::unique_ptr< platf::deinit_t > proc::init | ( | ) |
Initialize proc functions.
| std::optional< proc::proc_t > proc::parse | ( | const std::string & | file_name | ) |
Parse serialized text into the corresponding runtime representation.
| file_name | File name. |
| std::string proc::parse_env_val | ( | boost::process::v1::native_environment & | env, |
| const std::string_view & | val_raw ) |
Parse env val.
| env | Environment variables for the child process. |
| val_raw | Raw value that may contain substitutions. |
| std::string proc::prepare_command | ( | const std::string & | command | ) |
Prepare a configured command for execution.
| command | Configured command line. |
| void proc::refresh | ( | const std::string & | file_name | ) |
Refresh cached platform state from the operating system.
This function compares the current last modified time of the file to the time it was last parsed. If the file has been modified since it was last parsed (or if it has never been parsed), it will be re-parsed to update the app list.
An optional is used rather than a bare file_time_type because value-initialized file_time_type{} is not a reliable "never parsed" sentinel. On some toolchains (e.g. MSYS2 UCRT64 GCC 16.2), file_time_type::clock::now() compares less-or-equal to file_time_type{}, which would cause the initial parse to be skipped.
When an app is currently running, only the cached app configuration list and environment are updated — active process state (_app_id, _process, _process_group, etc.) is preserved so that the in-flight streaming session can still be terminated properly.
| file_name | File name. |
< Timestamp of the last successful apps.json parse, or nullopt if never parsed.
| void proc::terminate_process_group | ( | boost::process::v1::child & | child_process, |
| boost::process::v1::group & | group, | ||
| std::chrono::seconds | exit_timeout ) |
Terminates all child processes in a process group.
| child_process | The child process itself. |
| group | The group of all children in the process tree. |
| exit_timeout | The timeout to wait for the process group to gracefully exit. |
| std::string proc::validate_app_image_path | ( | std::string | app_image_path | ) |
Validate app image path.
| app_image_path | Candidate image path from the application configuration. |