mirror of
https://github.com/vicliu624/trail-mate.git
synced 2026-09-22 19:54:23 +00:00
Match the shell initialization call inside run() so its failure guard does not break the network-independence contract. Preserve initialization ordering and blocking-network checks. Apply clang-format 14 to the web preview sources. Verified all 2107 CI-scoped source files and seven positive/negative startup contract cases.
93 lines
2.5 KiB
C++
93 lines
2.5 KiB
C++
#include "platform/ui/pack_repository_runtime.h"
|
|
#include "platform/ui/wifi_runtime.h"
|
|
#include <cstdio>
|
|
#include <string>
|
|
namespace platform::ui::wifi
|
|
{
|
|
static Config config{};
|
|
static bool connected = false;
|
|
bool is_supported() { return true; }
|
|
bool load_config(Config& out)
|
|
{
|
|
out = config;
|
|
return true;
|
|
}
|
|
bool save_config(const Config& value)
|
|
{
|
|
config = value;
|
|
return true;
|
|
}
|
|
bool apply_enabled(bool enabled)
|
|
{
|
|
config.enabled = enabled;
|
|
if (!enabled) connected = false;
|
|
return true;
|
|
}
|
|
bool connect(const Config* value)
|
|
{
|
|
if (value) config = *value;
|
|
config.enabled = true;
|
|
connected = true;
|
|
return true;
|
|
}
|
|
void disconnect() { connected = false; }
|
|
Status status()
|
|
{
|
|
Status out;
|
|
out.supported = true;
|
|
out.enabled = config.enabled;
|
|
out.connected = connected;
|
|
out.state = connected ? ConnectionState::Connected : ConnectionState::Disabled;
|
|
out.has_credentials = true;
|
|
std::snprintf(out.ssid, sizeof(out.ssid), "Preview network");
|
|
return out;
|
|
}
|
|
} // namespace platform::ui::wifi
|
|
namespace ui::runtime::packs
|
|
{
|
|
bool is_supported() { return true; }
|
|
bool load_installed_packages(std::vector<InstalledPackageRecord>& out, std::string& error)
|
|
{
|
|
out.clear();
|
|
error.clear();
|
|
return true;
|
|
}
|
|
bool fetch_catalog(std::vector<PackageRecord>& out, std::string& error)
|
|
{
|
|
out.clear();
|
|
error.clear();
|
|
PackageRecord p;
|
|
p.id = "zh-Hans";
|
|
p.package_type = "locale-bundle";
|
|
p.version = "1.3.0";
|
|
p.display_name = "Simplified Chinese";
|
|
p.summary = "Chinese fonts, translations and Pinyin IME";
|
|
p.provided_locale_ids = {"zh-Hans"};
|
|
p.provided_ime_ids = {"pinyin"};
|
|
p.archive_size_bytes = 1200000;
|
|
p.compatible_firmware = true;
|
|
p.compatible_memory_profile = true;
|
|
out.push_back(p);
|
|
p.id = "ja";
|
|
p.version = "1.2.0";
|
|
p.display_name = "Japanese";
|
|
p.summary = "Japanese fonts and translations (review)";
|
|
p.provided_locale_ids = {"ja"};
|
|
p.provided_ime_ids.clear();
|
|
out.push_back(p);
|
|
return true;
|
|
}
|
|
bool start_install_package(const PackageRecord&, std::string& error)
|
|
{
|
|
error = "Browser preview does not install device packages";
|
|
return false;
|
|
}
|
|
bool install_package(const PackageRecord& p, std::string& error) { return start_install_package(p, error); }
|
|
bool uninstall_package(const PackageRecord&, std::string& error)
|
|
{
|
|
error = "No device package is installed in this preview";
|
|
return false;
|
|
}
|
|
PackageInstallStatus install_status() { return {}; }
|
|
} // namespace ui::runtime::packs
|