- 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
66 lines
2.2 KiB
C++
66 lines
2.2 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#pragma once
|
|
|
|
#include "openpu/http.hpp"
|
|
#include "openpu/models.hpp"
|
|
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
namespace openpu {
|
|
|
|
/// Backend endpoints. Defaults are those of the Peugeot build of the official application;
|
|
/// every field can be overridden (other brands, or a local mock server).
|
|
struct ApiConfig {
|
|
std::string devicesUrl = "https://api.groupe-psa.com/applications/majesticf/v1/devices/";
|
|
std::string updatesUrl = "https://api.groupe-psa.com/applications/majesticf/v1/getAvailableUpdate";
|
|
std::string clientId = "20a4cf7c-f5fb-41d5-9175-a6e23b9880e5";
|
|
|
|
/// Defaults overridden by OPENPU_DEVICES_URL, OPENPU_UPDATES_URL and OPENPU_CLIENT_ID when set.
|
|
static ApiConfig fromEnvironment();
|
|
};
|
|
|
|
class ApiError : public std::runtime_error {
|
|
public:
|
|
enum class Kind {
|
|
Network, ///< no HTTP response (offline, DNS, TLS, timeout)
|
|
Server, ///< unexpected HTTP status
|
|
BadResponse, ///< unparsable / unexpected body
|
|
InvalidVin, ///< rejected locally before any request
|
|
};
|
|
ApiError(Kind kind, long status, const std::string& what) : std::runtime_error(what), kind_(kind), status_(status) {}
|
|
Kind kind() const noexcept { return kind_; }
|
|
long status() const noexcept { return status_; }
|
|
|
|
private:
|
|
Kind kind_;
|
|
long status_;
|
|
};
|
|
|
|
class ApiClient {
|
|
public:
|
|
ApiClient(Transport& transport, ApiConfig config);
|
|
|
|
/// Does the VIN exist, and which head unit does it have?
|
|
/// A 404 on the devices endpoint yields `exists == false` (not an error).
|
|
VehicleCheck checkVehicle(const std::string& vin);
|
|
|
|
/// Latest firmware / map update for a vehicle whose type is already known.
|
|
AvailableUpdates getUpdates(const std::string& vin, HeadUnitType type);
|
|
|
|
/// Raw calls, exposed for diagnostics (openpu-cli --raw) and tests.
|
|
HttpResponse rawDevices(const std::string& vin);
|
|
HttpResponse rawUpdates(const std::string& vin, const std::vector<std::string>& softwareTypes);
|
|
|
|
const ApiConfig& config() const noexcept { return config_; }
|
|
|
|
private:
|
|
HttpResponse send(HttpRequest request);
|
|
static void requireValidVin(const std::string& vin);
|
|
|
|
Transport& transport_;
|
|
ApiConfig config_;
|
|
};
|
|
|
|
} // namespace openpu
|