- interface gtkmm-4 : véhicules, ajout par VIN, mises à jour, dossier, téléchargement avec reprise et arrêt, choix de la clé, confirmation, écriture avec progression, fin avec guide d'installation ; travail dans un thread, résultats renvoyés via Glib::Dispatcher - préférences : dossier de téléchargement, langue (système par défaut), recherche automatique de nouvelle version d'OpenPU - recherche de nouvelle version (releases GitHub, format tags Gitea accepté) avec ouverture de la page dans le navigateur ; openpu-cli app-update - versions : project(VERSION) + git describe régénéré à chaque build, openpu-cli --version, À propos, User-Agent, CHANGELOG, tools/release.sh (étiquette annotée, push vers tous les remotes, release GitHub) - traductions gettext : textes anglais, fr.po complet (96 chaînes), extracteur de secours sans xgettext - core : module job (téléchargement licence/fw/carte), liens des guides PDF, ordre des véhicules conservé (ordered_json) - licence MIT (LICENSE, en-têtes SPDX) ; dépôt principal sur GitHub - validé dans WSLg : parcours complet jusqu'à l'écriture d'une clé loop (FAT32 propre, fichiers téléchargés supprimés) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WDASLCiN764v685boRVYar
107 lines
3.5 KiB
C++
107 lines
3.5 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
namespace openpu {
|
|
|
|
/// Software types understood by the Majestic `getAvailableUpdate` endpoint.
|
|
namespace software {
|
|
inline constexpr std::string_view FirmwareNac = "ovip-int-firmware-version";
|
|
inline constexpr std::string_view FirmwareRcc = "rcc-firmware";
|
|
inline constexpr std::string_view FirmwareAio = "aio-firmware";
|
|
inline constexpr std::string_view CronyNav = "crony2-software-nav";
|
|
inline constexpr std::string_view CronyNonav = "crony2-software-nonav";
|
|
inline constexpr std::string_view MapEurope = "map-eur";
|
|
inline constexpr std::string_view MapCrony = "crony2-map-western_europe";
|
|
|
|
/// All software types, in the order used when probing a new vehicle.
|
|
const std::vector<std::string>& all();
|
|
} // namespace software
|
|
|
|
/// Head-unit family. String form matches the `type` field of the original vehicles.json.
|
|
enum class HeadUnitType { Unknown, Nac, Rcc, Aio, CronyNav, CronyNonav };
|
|
|
|
std::string_view headUnitTypeName(HeadUnitType type);
|
|
HeadUnitType headUnitTypeFromString(std::string_view s);
|
|
|
|
/// Thrown when a backend JSON document cannot be interpreted.
|
|
class ParseError : public std::runtime_error {
|
|
public:
|
|
using std::runtime_error::runtime_error;
|
|
};
|
|
|
|
struct UpdateInfo {
|
|
std::string softwareType;
|
|
std::string updateId;
|
|
std::string version;
|
|
std::string date;
|
|
std::string url; ///< updateURL (redirects to the CDN)
|
|
std::string licenseUrl; ///< licenseURL (only meaningful for firmware)
|
|
std::uint64_t size = 0; ///< bytes, as announced by the backend
|
|
};
|
|
|
|
struct SoftwareEntry {
|
|
std::string softwareType;
|
|
std::string requestResult;
|
|
std::string currentVersion;
|
|
std::vector<UpdateInfo> updates;
|
|
};
|
|
|
|
struct UpdateListResponse {
|
|
std::string requestResult;
|
|
std::string installerUrl;
|
|
std::string vin;
|
|
std::vector<SoftwareEntry> software;
|
|
};
|
|
|
|
struct DevicesResponse {
|
|
std::string vin;
|
|
std::string requestDate;
|
|
std::vector<std::string> ecuTypes;
|
|
};
|
|
|
|
struct VehicleCheck {
|
|
bool exists = false;
|
|
HeadUnitType type = HeadUnitType::Unknown;
|
|
std::string guideKey; ///< i18n key of the installation guide (e.g. "path_guide_rcc"), may be empty
|
|
};
|
|
|
|
struct AvailableUpdates {
|
|
std::optional<UpdateInfo> firmware;
|
|
std::optional<UpdateInfo> map;
|
|
};
|
|
|
|
/// Firmware and (optional) map software types to request for a given head unit.
|
|
struct SoftwarePair {
|
|
std::string firmware;
|
|
std::optional<std::string> map;
|
|
};
|
|
SoftwarePair softwareTypesFor(HeadUnitType type);
|
|
|
|
UpdateListResponse parseUpdateList(std::string_view json);
|
|
DevicesResponse parseDevices(std::string_view json);
|
|
std::string buildUpdateRequest(std::string_view vin, const std::vector<std::string>& softwareTypes);
|
|
|
|
/// Head-unit family from an ECU type string such as "NAC_EU_WAVE4" (Unknown if unsupported).
|
|
HeadUnitType ecuFamily(std::string_view ecuType);
|
|
|
|
/// Reproduces the original vehicle check logic (devices + all-types update probe).
|
|
VehicleCheck classifyVehicle(const UpdateListResponse& updates, const DevicesResponse& devices);
|
|
|
|
/// Usable update of a given software type, if any.
|
|
std::optional<UpdateInfo> pickUpdate(const UpdateListResponse& response, std::string_view softwareType);
|
|
|
|
/// Firmware/map updates for a vehicle of the given type.
|
|
AvailableUpdates selectUpdates(const UpdateListResponse& response, HeadUnitType type);
|
|
|
|
/// Basic absolute http(s) URL check, equivalent to the `is-url` package for our needs.
|
|
bool isHttpUrl(std::string_view url);
|
|
|
|
} // namespace openpu
|