gtk: interface GTK4, préférences, versions, traductions, licence MIT

- 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
This commit is contained in:
yann64andClaude Opus 5.5 committed 2026-11-28 19:54:04 +01:00
1 parent 6a7a2f1ee9
commit 384aaf78c6
62 files changed
+3029 -20

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
#pragma once
#include "openpu/http.hpp"
+63
View File
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: MIT
#pragma once
#include "openpu/http.hpp"
#include <optional>
#include <string>
#include <string_view>
namespace openpu {
/// MAJOR.MINOR.PATCH, ordered numerically.
struct SemVer {
unsigned major = 0;
unsigned minor = 0;
unsigned patch = 0;
/// Accepts "1.2.3" and "v1.2.3"; build metadata ("+3.gabc") is ignored. Pre-releases are rejected.
static std::optional<SemVer> parse(std::string_view text);
std::string toString() const;
friend bool operator<(const SemVer& a, const SemVer& b)
{
if (a.major != b.major)
return a.major < b.major;
if (a.minor != b.minor)
return a.minor < b.minor;
return a.patch < b.patch;
}
friend bool operator==(const SemVer& a, const SemVer& b)
{
return a.major == b.major && a.minor == b.minor && a.patch == b.patch;
}
};
/// Where new OpenPU versions are published: the GitHub releases of the project.
/// A Gitea/GitHub `/tags` list is understood too (OPENPU_RELEASES_URL may point to one).
struct AppUpdateConfig {
std::string releasesUrl = "https://api.github.com/repos/yann64/openpu/releases";
/// Page opened in the browser when the answer gives none; "{tag}" is replaced by the tag name.
std::string pageUrl = "https://github.com/yann64/openpu/releases/tag/{tag}";
/// Defaults overridden by OPENPU_RELEASES_URL and OPENPU_RELEASE_PAGE_URL when set.
static AppUpdateConfig fromEnvironment();
};
struct AppRelease {
SemVer version;
std::string tag;
std::string pageUrl;
std::string notes; ///< release notes (or annotated tag message)
};
/// Highest vX.Y.Z release of a GitHub/Gitea `/releases` list (drafts and pre-releases skipped) or
/// of a `/tags` list (nullopt if none). Throws ParseError.
std::optional<AppRelease> latestRelease(std::string_view json, const AppUpdateConfig& config);
/// Newest published release if it is newer than `currentVersion`, nullopt when up to date.
/// Throws NetworkError, or std::runtime_error for an unexpected answer.
std::optional<AppRelease> checkForNewerRelease(Transport& transport, const AppUpdateConfig& config,
std::string_view currentVersion);
} // namespace openpu
+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
#pragma once
#include "openpu/cancel.hpp"
+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
#pragma once
#include <atomic>
+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
#pragma once
#include "openpu/cancel.hpp"
+38
View File
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT
#pragma once
#include <chrono>
#include <cstdint>
#include <cstdio>
#include <string>
namespace openpu {
/// "8.39 GB" (decimal units, as storage vendors and the official app use).
inline std::string formatSize(std::uint64_t bytes)
{
const char* units[] = {"B", "KB", "MB", "GB", "TB"};
auto value = static_cast<double>(bytes);
std::size_t unit = 0;
while (value >= 1000.0 && unit + 1 < sizeof units / sizeof units[0]) {
value /= 1000.0;
++unit;
}
char buf[32];
(void)std::snprintf(buf, sizeof buf, unit == 0 ? "%.0f %s" : "%.2f %s", value, units[unit]);
return buf;
}
/// "1:02:03" or "02:03".
inline std::string formatDuration(std::chrono::seconds s)
{
const auto total = static_cast<long long>(s.count());
char buf[32];
if (total >= 3600)
(void)std::snprintf(buf, sizeof buf, "%lld:%02lld:%02lld", total / 3600, (total / 60) % 60, total % 60);
else
(void)std::snprintf(buf, sizeof buf, "%02lld:%02lld", total / 60, total % 60);
return buf;
}
} // namespace openpu
+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
#pragma once
#include <chrono>
+59
View File
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: MIT
#pragma once
#include "openpu/download.hpp"
#include "openpu/models.hpp"
#include "openpu/usb.hpp"
#include <filesystem>
#include <functional>
#include <optional>
#include <string>
#include <string_view>
namespace openpu {
/// URL of the installation guide (PDF) for a guide key such as "path_guide_rcc".
/// `language` is an ISO 639-1 code; French and English are known, anything else gives English.
std::string guideUrl(std::string_view guideKey, std::string_view language);
/// Two-letter language of the user session (LANGUAGE / LC_ALL / LC_MESSAGES / LANG), "en" by default.
std::string systemLanguage();
/// What to download for one vehicle.
struct DownloadPlan {
std::optional<UpdateInfo> firmware;
std::optional<UpdateInfo> map;
std::filesystem::path dir;
/// Bytes still to download (announced sizes minus partial files already in `dir`), +10 %.
/// Partial files are matched by name, so this needs the names (see resolveNames()).
std::uint64_t requiredSpace() const;
/// Total announced size.
std::uint64_t totalSize() const;
};
struct DownloadedFiles {
std::optional<std::filesystem::path> license;
std::optional<std::filesystem::path> firmware;
std::optional<std::filesystem::path> map;
/// Write plan for the stick: license (with firmware only), firmware archive, then map archive.
UsbWritePlan writePlan() const;
/// Removes every file of the set (after a successful copy, or when the user gives up).
void remove() const;
};
enum class DownloadItem { License, Firmware, Map };
struct JobProgress {
DownloadItem item = DownloadItem::Firmware;
DownloadProgress progress;
};
using JobProgressCallback = std::function<void(const JobProgress&)>;
/// Official order: license (firmware only), firmware, map. Partial files are resumed.
DownloadedFiles downloadUpdates(Downloader& downloader, const DownloadPlan& plan, const JobProgressCallback& onProgress = {},
const CancelToken* cancel = nullptr);
} // namespace openpu
+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
#pragma once
#include <cstdint>
+2
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
#pragma once
#include "openpu/models.hpp"
@@ -74,6 +75,7 @@ struct PendingDownload {
struct Settings {
std::string language; ///< empty: follow the system locale
std::filesystem::path downloadDir; ///< empty: paths::defaultDownloadDir()
bool checkAppUpdates = true; ///< look for a newer OpenPU at startup
std::optional<PendingDownload> pending;
std::filesystem::path effectiveDownloadDir() const;
+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
#pragma once
#include "openpu/cancel.hpp"
+12
View File
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
#pragma once
namespace openpu {
/// Release version, "MAJOR.MINOR.PATCH" (CMake project version, tagged vMAJOR.MINOR.PATCH in git).
const char* version() noexcept;
/// Build description: the version, plus "+<commits>.g<hash>[.dirty]" when not built from the tag.
const char* versionDescription() noexcept;
} // namespace openpu
+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
#pragma once
#include <string>