game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
runner_download_service.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// runner_download_service.h
4// ==============================================================================
5// Automatic download and installation of Proton/Wine compatibility tools
6// ==============================================================================
7// Provides functionality similar to ProtonUp-Qt for downloading and managing
8// various compatibility layers:
9// - Proton-GE (GloriousEggroll's Proton fork)
10// - Wine-GE (GloriousEggroll's Wine builds)
11// - Proton-TKG (TkGlitch's custom Proton)
12// - Luxtorpeda (native game engine replacements)
13// - DXVK (DirectX to Vulkan translation)
14// - VKD3D-Proton (DirectX 12 to Vulkan)
15//
16// ## Features
17// - Async downloads with progress tracking
18// - Automatic extraction and installation
19// - Version management with cleanup of old versions
20// - GitHub releases API integration
21// - Checksum verification
22//
23// ## Thread Safety
24// All public methods are thread-safe. Downloads run on background threads.
25// ==============================================================================
26
27#pragma once
28
29#include <chrono>
30#include <filesystem>
31#include <functional>
32#include <future>
33#include <memory>
34#include <mutex>
35#include <optional>
36#include <string>
37#include <vector>
38
39// ==============================================================================
40// Data Structures
41// ==============================================================================
42
43/**
44 * @enum RunnerType
45 * @brief Types of compatibility tools that can be downloaded
46 */
47enum class RunnerType
48{
49 ProtonGE, ///< GloriousEggroll Proton builds (active)
50 WineGE, ///< GloriousEggroll Wine builds for Lutris (archived 2025-07; final tag GE-Proton8-26)
51 ProtonTKG, ///< TkGlitch custom Proton builds (no usable GitHub releases — AUR / PKGBUILD only)
52 Luxtorpeda, ///< Native game engine replacements
53 DXVK, ///< DirectX 9/10/11 to Vulkan
54 VKD3DProton, ///< DirectX 12 to Vulkan
55 UMU, ///< Unified Proton Runner
56};
57
58/**
59 * @enum RunnerStatus
60 * @brief Upstream maintenance status of a runner type.
61 *
62 * Captured here so the UI can label deprecated/unmaintained runners and so the
63 * release-poller can short-circuit calls that would only return stale data.
64 *
65 * Last verified: 2026-05-02.
66 */
67enum class RunnerStatus
68{
69 Active, ///< Repo actively publishes releases on GitHub
70 Archived, ///< Repo is archived but the final release is still usable
71 ManualOnly, ///< No usable GitHub releases — install via distro packaging
72};
73
74/**
75 * @brief Get human-readable name for runner type
76 */
77std::string runnerTypeName(RunnerType type);
78
79/**
80 * @brief Get the upstream maintenance status for a runner type.
81 */
83
84/**
85 * @brief Convenience: human-readable status string ("active" / "archived" / "manual-only").
86 */
87std::string runnerStatusName(RunnerStatus status);
88
89/**
90 * @struct RunnerRelease
91 * @brief Information about an available runner release
92 */
94{
96 std::string version; ///< Version string (e.g., "GE-Proton9-20")
97 std::string tag; ///< GitHub release tag
98 std::string downloadUrl; ///< Direct download URL
99 std::string checksum; ///< SHA512 or SHA256 checksum if available
100 std::string checksumType; ///< "sha512" or "sha256"
101 int64_t size = 0; ///< Download size in bytes
102 std::string releaseDate; ///< Release date ISO string
103 std::string releaseNotes; ///< Release notes/changelog
104 bool isPrerelease = false; ///< Whether this is a pre-release
105 bool isArchived = false; ///< True when sourced from an archived upstream repo (Wine-GE)
106
107 // Installation status
108 bool isInstalled = false; ///< Whether this version is currently installed
109 std::filesystem::path installPath; ///< Path if installed
110
111 std::string getSizeStr() const;
112};
113
114/**
115 * @struct DownloadProgress
116 * @brief Progress information for downloads
117 */
118struct DownloadProgress
119{
131
133 std::string currentFile; ///< Current file being processed
134 int64_t bytesDownloaded = 0;
135 int64_t bytesTotal = 0;
136 int percentComplete = 0;
137 std::string errorMessage; ///< Error message if failed
138
139 std::string getStateStr() const;
140};
141
142/**
143 * @struct InstalledRunner
144 * @brief Information about an installed runner
145 */
147{
149 std::string name; ///< Display name
150 std::string version; ///< Version string
151 std::filesystem::path path; ///< Installation path
152 std::chrono::system_clock::time_point installDate;
153 int64_t sizeBytes = 0; ///< Size on disk
154 bool isActive = false; ///< Whether this is the currently selected runner
155};
156
157// ==============================================================================
158// RunnerDownloadService Class
159// ==============================================================================
160
161/**
162 * @class RunnerDownloadService
163 * @brief Service for downloading and managing compatibility tools
164 *
165 * Provides a unified interface for downloading, installing, and managing
166 * various Windows compatibility layers like Proton-GE and Wine-GE.
167 *
168 * ## Usage Example
169 * @code
170 * RunnerDownloadService service;
171 *
172 * // Get available releases
173 * auto releases = service.getAvailableReleases(RunnerType::ProtonGE);
174 *
175 * // Download latest
176 * if (!releases.empty()) {
177 * service.downloadRunner(releases[0], [](const DownloadProgress& p) {
178 * std::cout << p.percentComplete << "%" << std::endl;
179 * });
180 * }
181 * @endcode
182 */
184{
185 public:
186 using ProgressCallback = std::function<void(const DownloadProgress&)>;
187 using ReleaseCallback = std::function<void(const std::vector<RunnerRelease>&)>;
188
191
192 // ==========================================================================
193 // Release Discovery
194 // ==========================================================================
195
196 /**
197 * @brief Get available releases for a runner type
198 * @param type Type of runner
199 * @param includePrerelease Include pre-release versions
200 * @param maxResults Maximum number of releases to return
201 * @return Vector of available releases, newest first
202 */
203 std::vector<RunnerRelease> getAvailableReleases(RunnerType type, bool includePrerelease = false,
204 int maxResults = 20);
205
206 /**
207 * @brief Get available releases asynchronously
208 * @param type Type of runner
209 * @param callback Callback with releases when complete
210 * @param includePrerelease Include pre-release versions
211 */
212 void getAvailableReleasesAsync(RunnerType type, const ReleaseCallback& callback,
213 bool includePrerelease = false);
214
215 /**
216 * @brief Get the latest release for a runner type
217 * @param type Type of runner
218 * @param includePrerelease Include pre-release versions
219 * @return Latest release if available
220 */
221 std::optional<RunnerRelease> getLatestRelease(RunnerType type, bool includePrerelease = false);
222
223 // ==========================================================================
224 // Installation
225 // ==========================================================================
226
227 /**
228 * @brief Download and install a runner
229 * @param release Release to install
230 * @param progressCallback Progress updates
231 * @return True on success
232 */
233 bool downloadRunner(const RunnerRelease& release,
234 const ProgressCallback& progressCallback = nullptr);
235
236 /**
237 * @brief Download and install a runner asynchronously
238 * @param release Release to install
239 * @param progressCallback Progress updates
240 * @return Future that resolves to success/failure
241 */
242 std::future<bool> downloadRunnerAsync(const RunnerRelease& release,
243 const ProgressCallback& progressCallback = nullptr);
244
245 /**
246 * @brief Cancel an ongoing download
247 * @param type Runner type to cancel
248 */
249 void cancelDownload(RunnerType type);
250
251 /**
252 * @brief Check if a download is in progress
253 * @param type Runner type to check
254 */
255 bool isDownloading(RunnerType type) const;
256
257 // ==========================================================================
258 // Installed Runner Management
259 // ==========================================================================
260
261 /**
262 * @brief Get all installed runners
263 * @return Vector of installed runners
264 */
265 std::vector<InstalledRunner> getInstalledRunners() const;
266
267 /**
268 * @brief Get installed runners of a specific type
269 * @param type Runner type to filter by
270 * @return Vector of installed runners of that type
271 */
272 std::vector<InstalledRunner> getInstalledRunners(RunnerType type) const;
273
274 /**
275 * @brief Check if a specific version is installed
276 * @param type Runner type
277 * @param version Version string
278 * @return True if installed
279 */
280 bool isInstalled(RunnerType type, const std::string& version) const;
281
282 /**
283 * @brief Uninstall a runner version
284 * @param type Runner type
285 * @param version Version to uninstall
286 * @return True on success
287 */
288 bool uninstallRunner(RunnerType type, const std::string& version);
289
290 /**
291 * @brief Clean up old versions, keeping newest N
292 * @param type Runner type
293 * @param keepCount Number of versions to keep
294 * @return Number of versions removed
295 */
296 int cleanupOldVersions(RunnerType type, int keepCount = 3);
297
298 // ==========================================================================
299 // Installation Paths
300 // ==========================================================================
301
302 /**
303 * @brief Get default installation directory for a runner type
304 * @param type Runner type
305 * @return Default installation path
306 */
307 static std::filesystem::path getDefaultInstallPath(RunnerType type);
308
309 /**
310 * @brief Set custom installation directory
311 * @param type Runner type
312 * @param path Custom path
313 */
314 void setInstallPath(RunnerType type, const std::filesystem::path& path);
315
316 // ==========================================================================
317 // Cache Management
318 // ==========================================================================
319
320 /**
321 * @brief Clear the releases cache
322 */
323 void clearCache();
324
325 /**
326 * @brief Refresh installed runners list
327 */
328 void refreshInstalled();
329
330 private:
331 struct Impl;
332 std::unique_ptr<Impl> impl_;
333
334 // GitHub API helpers
335 std::vector<RunnerRelease> fetchGitHubReleases(const std::string& owner,
336 const std::string& repo, RunnerType type,
337 bool includePrerelease, int maxResults);
338
339 // Download helpers
340 bool downloadFile(const std::string& url, const std::filesystem::path& dest,
341 ProgressCallback callback, std::atomic<bool>& cancelled);
342
343 bool verifyChecksum(const std::filesystem::path& file, const std::string& expected,
344 const std::string& type);
345
346 bool extractArchive(const std::filesystem::path& archive, const std::filesystem::path& dest,
347 const ProgressCallback& callback);
348
349 // Path helpers
350 static std::string getGitHubOwner(RunnerType type);
351 static std::string getGitHubRepo(RunnerType type);
352 std::filesystem::path getInstallDir(RunnerType type) const;
353};
std::function< void(const DownloadProgress &)> ProgressCallback
bool uninstallRunner(RunnerType type, const std::string &version)
Uninstall a runner version.
bool isInstalled(RunnerType type, const std::string &version) const
Check if a specific version is installed.
bool downloadRunner(const RunnerRelease &release, const ProgressCallback &progressCallback=nullptr)
Download and install a runner.
std::function< void(const std::vector< RunnerRelease > &)> ReleaseCallback
void setInstallPath(RunnerType type, const std::filesystem::path &path)
Set custom installation directory.
void refreshInstalled()
Refresh installed runners list.
std::future< bool > downloadRunnerAsync(const RunnerRelease &release, const ProgressCallback &progressCallback=nullptr)
Download and install a runner asynchronously.
std::vector< RunnerRelease > getAvailableReleases(RunnerType type, bool includePrerelease=false, int maxResults=20)
Get available releases for a runner type.
bool isDownloading(RunnerType type) const
Check if a download is in progress.
void clearCache()
Clear the releases cache.
void getAvailableReleasesAsync(RunnerType type, const ReleaseCallback &callback, bool includePrerelease=false)
Get available releases asynchronously.
static std::filesystem::path getDefaultInstallPath(RunnerType type)
Get default installation directory for a runner type.
int cleanupOldVersions(RunnerType type, int keepCount=3)
Clean up old versions, keeping newest N.
void cancelDownload(RunnerType type)
Cancel an ongoing download.
std::optional< RunnerRelease > getLatestRelease(RunnerType type, bool includePrerelease=false)
Get the latest release for a runner type.
std::vector< InstalledRunner > getInstalledRunners() const
Get all installed runners.
std::string runnerStatusName(RunnerStatus status)
Convenience: human-readable status string ("active" / "archived" / "manual-only").
RunnerType
Types of compatibility tools that can be downloaded.
@ UMU
Unified Proton Runner.
@ ProtonGE
GloriousEggroll Proton builds (active).
@ Luxtorpeda
Native game engine replacements.
@ ProtonTKG
TkGlitch custom Proton builds (no usable GitHub releases — AUR / PKGBUILD only).
@ WineGE
GloriousEggroll Wine builds for Lutris (archived 2025-07; final tag GE-Proton8-26).
@ DXVK
DirectX 9/10/11 to Vulkan.
@ VKD3DProton
DirectX 12 to Vulkan.
std::string runnerTypeName(RunnerType type)
Get human-readable name for runner type.
RunnerStatus runnerStatus(RunnerType type)
Get the upstream maintenance status for a runner type.
RunnerStatus
Upstream maintenance status of a runner type.
@ Active
Repo actively publishes releases on GitHub.
@ Archived
Repo is archived but the final release is still usable.
@ ManualOnly
No usable GitHub releases — install via distro packaging.
Progress information for downloads.
std::string getStateStr() const
std::string currentFile
Current file being processed.
std::string errorMessage
Error message if failed.
Information about an installed runner.
std::filesystem::path path
Installation path.
std::chrono::system_clock::time_point installDate
bool isActive
Whether this is the currently selected runner.
std::string version
Version string.
std::string name
Display name.
int64_t sizeBytes
Size on disk.
Information about an available runner release.
std::string releaseDate
Release date ISO string.
std::string checksum
SHA512 or SHA256 checksum if available.
bool isInstalled
Whether this version is currently installed.
int64_t size
Download size in bytes.
bool isArchived
True when sourced from an archived upstream repo (Wine-GE).
std::string releaseNotes
Release notes/changelog.
std::string checksumType
"sha512" or "sha256"
std::string tag
GitHub release tag.
std::string downloadUrl
Direct download URL.
bool isPrerelease
Whether this is a pre-release.
std::string getSizeStr() const
std::string version
Version string (e.g., "GE-Proton9-20").
std::filesystem::path installPath
Path if installed.