game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
store_integration_controller.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// store_integration_controller.h
4// ==============================================================================
5// Controller for multi-store integration - GOG, Epic, cloud saves, dependencies
6// Provides unified interface for all store-related backend services
7// ==============================================================================
8
9#pragma once
10
11#include <chrono>
12#include <functional>
13#include <future>
14#include <memory>
15#include <optional>
16#include <string>
17#include <vector>
18
19// Forward declarations
20struct GOGGameInfo;
21struct GOGAuthStatus;
22struct GOGProgress;
23struct EpicGameInfo;
24struct EpicAuthStatus;
26struct SaveLocation;
27struct SaveSnapshot;
28struct SyncStatus;
29struct SyncConflict;
30struct WineDependency;
33enum class GOGBackend;
34enum class SyncDirection;
35enum class ConflictResolution;
36enum class DependencyCategory;
37
38namespace core
39{
40
41// ==============================================================================
42// Store Types & Events
43// ==============================================================================
44
53
55{
57 bool isAvailable = false;
58 bool isAuthenticated = false;
59 std::string username;
60 std::string version;
61 int gameCount = 0;
62 std::string lastError;
63};
64
66{
68 int gamesAdded = 0;
69 int gamesUpdated = 0;
70 int gamesRemoved = 0;
71 bool success = true;
72 std::string errorMessage;
73};
74
89
105
106// ==============================================================================
107// StoreIntegrationController
108// ==============================================================================
109
111{
112 public:
113 // Callback types
114 using OnStoreSyncComplete = std::function<void(const StoreSyncEvent&)>;
115 using OnCloudSaveEvent = std::function<void(const CloudSaveEvent&)>;
116 using OnDependencyEvent = std::function<void(const DependencyEvent&)>;
117 using ProgressCallback = std::function<void(int percent, const std::string& status)>;
118
121
122 // Non-copyable, movable
127
128 // =========================================================================
129 // Store Status
130 // =========================================================================
131
132 /// Get status of all available stores
133 std::vector<StoreStatus> getAllStoreStatus() const;
134
135 /// Get status of a specific store
137
138 /// Check if a store backend is available (tools installed)
139 bool isStoreAvailable(StoreType store) const;
140
141 /// Check if authenticated to a store
142 bool isStoreAuthenticated(StoreType store) const;
143
144 // =========================================================================
145 // GOG Integration
146 // =========================================================================
147
148 /// Check if GOG integration is available (Heroic or gogdl)
149 bool isGOGAvailable() const;
150
151 /// Get GOG authentication status
153
154 /// Start GOG authentication flow
155 void
156 authenticateGOG(const std::function<void(bool success, const std::string& message)>& callback);
157
158 /// Log out of GOG
159 void logoutGOG();
160
161 /// Get all GOG library games
162 std::vector<GOGGameInfo> getGOGLibrary(bool forceRefresh = false);
163
164 /// Get installed GOG games
165 std::vector<GOGGameInfo> getInstalledGOGGames() const;
166
167 /// Install a GOG game
168 std::future<bool> installGOGGame(const std::string& gameId, const std::string& installPath = "",
169 const ProgressCallback& progressCallback = nullptr);
170
171 /// Uninstall a GOG game
172 bool uninstallGOGGame(const std::string& gameId);
173
174 /// Sync GOG library to game database
175 int syncGOGLibrary();
176
177 /// Import GOG games to main library
178 int importGOGGames();
179
180 // =========================================================================
181 // Epic Games Integration (via Legendary)
182 // =========================================================================
183
184 /// Check if Epic/Legendary is available
185 bool isEpicAvailable() const;
186
187 /// Get Epic authentication status
189
190 /// Start Epic authentication flow
191 void
192 authenticateEpic(const std::function<void(bool success, const std::string& message)>& callback);
193
194 /// Log out of Epic
195 void logoutEpic();
196
197 /// Get all Epic library games
198 std::vector<EpicGameInfo> getEpicLibrary(bool forceRefresh = false);
199
200 /// Get installed Epic games
201 std::vector<EpicGameInfo> getInstalledEpicGames() const;
202
203 /// Install an Epic game
204 std::future<bool> installEpicGame(const std::string& appName,
205 const std::string& installPath = "",
206 const ProgressCallback& progressCallback = nullptr);
207
208 /// Uninstall an Epic game
209 bool uninstallEpicGame(const std::string& appName);
210
211 /// Sync Epic library to game database
212 int syncEpicLibrary();
213
214 /// Import Epic games to main library
215 int importEpicGames();
216
217 // =========================================================================
218 // Cloud Save Management
219 // =========================================================================
220
221 /// Register a game's save location
222 bool registerSaveLocation(const SaveLocation& location);
223
224 /// Get all registered save locations
225 std::vector<SaveLocation> getSaveLocations() const;
226
227 /// Get save location for a game
228 std::optional<SaveLocation> getSaveLocation(const std::string& gameId) const;
229
230 /// Detect save locations for a game
231 std::vector<SaveLocation> detectSaveLocations(const std::string& gameName,
232 const std::string& prefixPath = "") const;
233
234 /// Create a save snapshot (backup)
235 std::optional<std::string> createSaveSnapshot(const std::string& gameId,
236 const std::string& description = "");
237
238 /// Get all snapshots for a game
239 std::vector<SaveSnapshot> getSaveSnapshots(const std::string& gameId) const;
240
241 /// Restore saves from a snapshot
242 bool restoreSaveSnapshot(const std::string& snapshotId, bool backupCurrent = true);
243
244 /// Delete a snapshot
245 bool deleteSaveSnapshot(const std::string& snapshotId);
246
247 /// Sync saves with cloud/custom directory
248 std::future<bool> syncSaves(const std::string& gameId, SyncDirection direction,
249 const ProgressCallback& progressCallback = nullptr);
250
251 /// Check if sync is needed
252 bool needsSaveSync(const std::string& gameId) const;
253
254 /// Enable/disable auto-sync for a game
255 void setAutoSync(const std::string& gameId, bool enabled);
256
257 /// Called when game launches (for auto-sync)
258 void onGameLaunch(const std::string& gameId);
259
260 /// Called when game exits (for auto-sync)
261 void onGameExit(const std::string& gameId);
262
263 /// Set custom sync directory (e.g., Syncthing folder)
264 void setCloudSyncDirectory(const std::string& path);
265
266 /// Get total backup size
267 int64_t getTotalBackupSize() const;
268
269 // =========================================================================
270 // Wine Dependency Management
271 // =========================================================================
272
273 /// Check if winetricks is available
274 bool isWinetricksAvailable() const;
275
276 /// Check if protontricks is available
277 bool isProtontricksAvailable() const;
278
279 /// Get all available dependencies
280 std::vector<WineDependency> getAllDependencies() const;
281
282 /// Get dependencies by category
284
285 /// Search for dependencies
286 std::vector<WineDependency> searchDependencies(const std::string& query) const;
287
288 /// Get recommended dependencies for gaming
289 std::vector<std::string> getRecommendedDependencies() const;
290
291 /// Scan a Wine prefix for installed dependencies
292 PrefixDependencyStatus scanPrefixDependencies(const std::string& prefixPath) const;
293
294 /// Check if a dependency is installed in a prefix
295 bool isDependencyInstalled(const std::string& prefixPath, const std::string& verbId) const;
296
297 /// Install a dependency
298 std::future<bool> installDependency(const std::string& prefixPath, const std::string& verbId,
299 const ProgressCallback& progressCallback = nullptr);
300
301 /// Install multiple dependencies
302 std::future<int> installDependencies(const std::string& prefixPath,
303 const std::vector<std::string>& verbIds,
304 const ProgressCallback& progressCallback = nullptr);
305
306 /// Install gaming preset (vcrun, dxvk, fonts)
307 std::future<bool> installGamingPreset(const std::string& prefixPath,
308 const ProgressCallback& progressCallback = nullptr);
309
310 /// Install dependencies for a Steam/Proton game
311 std::future<bool> installForSteamGame(uint32_t steamAppId,
312 const std::vector<std::string>& verbIds,
313 const ProgressCallback& progressCallback = nullptr);
314
315 // =========================================================================
316 // Unified Operations
317 // =========================================================================
318
319 /// Sync all stores (GOG, Epic, etc.)
320 void syncAllStores(const ProgressCallback& progressCallback = nullptr);
321
322 /// Get games from all stores (unified view)
324 {
325 std::string id;
326 std::string name;
328 bool isInstalled = false;
329 std::string installPath;
330 std::string coverUrl;
331 bool hasUpdate = false;
332 };
333 std::vector<UnifiedGameInfo> getAllStoreGames() const;
334
335 /// Check for updates across all stores
336 std::vector<UnifiedGameInfo> checkAllUpdates() const;
337
338 // =========================================================================
339 // Event Subscriptions
340 // =========================================================================
341
345
346 // =========================================================================
347 // Cancellation
348 // =========================================================================
349
350 /// Cancel any ongoing operation
351 void cancelOperation();
352
353 private:
354 class Impl;
355 std::unique_ptr<Impl> impl_;
356};
357
358/// Get human-readable store name
359std::string storeTypeName(StoreType type);
360
361} // namespace core
void syncAllStores(const ProgressCallback &progressCallback=nullptr)
Sync all stores (GOG, Epic, etc.).
bool isEpicAvailable() const
Check if Epic/Legendary is available.
EpicAuthStatus getEpicAuthStatus() const
Get Epic authentication status.
GOGAuthStatus getGOGAuthStatus() const
Get GOG authentication status.
std::vector< EpicGameInfo > getEpicLibrary(bool forceRefresh=false)
Get all Epic library games.
std::vector< UnifiedGameInfo > getAllStoreGames() const
bool isDependencyInstalled(const std::string &prefixPath, const std::string &verbId) const
Check if a dependency is installed in a prefix.
void cancelOperation()
Cancel any ongoing operation.
std::future< bool > installEpicGame(const std::string &appName, const std::string &installPath="", const ProgressCallback &progressCallback=nullptr)
Install an Epic game.
int importEpicGames()
Import Epic games to main library.
std::vector< EpicGameInfo > getInstalledEpicGames() const
Get installed Epic games.
bool isWinetricksAvailable() const
Check if winetricks is available.
std::future< int > installDependencies(const std::string &prefixPath, const std::vector< std::string > &verbIds, const ProgressCallback &progressCallback=nullptr)
Install multiple dependencies.
bool restoreSaveSnapshot(const std::string &snapshotId, bool backupCurrent=true)
Restore saves from a snapshot.
PrefixDependencyStatus scanPrefixDependencies(const std::string &prefixPath) const
Scan a Wine prefix for installed dependencies.
bool isStoreAuthenticated(StoreType store) const
Check if authenticated to a store.
void setOnCloudSaveEvent(OnCloudSaveEvent callback)
std::vector< SaveLocation > getSaveLocations() const
Get all registered save locations.
void setAutoSync(const std::string &gameId, bool enabled)
Enable/disable auto-sync for a game.
std::vector< UnifiedGameInfo > checkAllUpdates() const
Check for updates across all stores.
int syncGOGLibrary()
Sync GOG library to game database.
std::future< bool > installForSteamGame(uint32_t steamAppId, const std::vector< std::string > &verbIds, const ProgressCallback &progressCallback=nullptr)
Install dependencies for a Steam/Proton game.
std::vector< GOGGameInfo > getGOGLibrary(bool forceRefresh=false)
Get all GOG library games.
StoreIntegrationController(const StoreIntegrationController &)=delete
std::vector< WineDependency > getAllDependencies() const
Get all available dependencies.
void setOnDependencyEvent(OnDependencyEvent callback)
void authenticateGOG(const std::function< void(bool success, const std::string &message)> &callback)
Start GOG authentication flow.
bool deleteSaveSnapshot(const std::string &snapshotId)
Delete a snapshot.
void authenticateEpic(const std::function< void(bool success, const std::string &message)> &callback)
Start Epic authentication flow.
std::function< void(const CloudSaveEvent &)> OnCloudSaveEvent
void setCloudSyncDirectory(const std::string &path)
Set custom sync directory (e.g., Syncthing folder).
bool needsSaveSync(const std::string &gameId) const
Check if sync is needed.
bool registerSaveLocation(const SaveLocation &location)
Register a game's save location.
StoreIntegrationController(StoreIntegrationController &&) noexcept
int64_t getTotalBackupSize() const
Get total backup size.
std::vector< GOGGameInfo > getInstalledGOGGames() const
Get installed GOG games.
StoreIntegrationController & operator=(const StoreIntegrationController &)=delete
std::function< void(const StoreSyncEvent &)> OnStoreSyncComplete
std::function< void(int percent, const std::string &status)> ProgressCallback
void onGameExit(const std::string &gameId)
Called when game exits (for auto-sync).
std::future< bool > installDependency(const std::string &prefixPath, const std::string &verbId, const ProgressCallback &progressCallback=nullptr)
Install a dependency.
std::vector< SaveSnapshot > getSaveSnapshots(const std::string &gameId) const
Get all snapshots for a game.
std::vector< SaveLocation > detectSaveLocations(const std::string &gameName, const std::string &prefixPath="") const
Detect save locations for a game.
StoreStatus getStoreStatus(StoreType store) const
Get status of a specific store.
std::future< bool > installGamingPreset(const std::string &prefixPath, const ProgressCallback &progressCallback=nullptr)
Install gaming preset (vcrun, dxvk, fonts).
void setOnStoreSyncComplete(OnStoreSyncComplete callback)
std::vector< WineDependency > searchDependencies(const std::string &query) const
Search for dependencies.
std::vector< WineDependency > getDependenciesByCategory(DependencyCategory category) const
Get dependencies by category.
bool uninstallEpicGame(const std::string &appName)
Uninstall an Epic game.
std::optional< SaveLocation > getSaveLocation(const std::string &gameId) const
Get save location for a game.
int syncEpicLibrary()
Sync Epic library to game database.
int importGOGGames()
Import GOG games to main library.
void onGameLaunch(const std::string &gameId)
Called when game launches (for auto-sync).
std::vector< std::string > getRecommendedDependencies() const
Get recommended dependencies for gaming.
bool isGOGAvailable() const
Check if GOG integration is available (Heroic or gogdl).
std::function< void(const DependencyEvent &)> OnDependencyEvent
bool isProtontricksAvailable() const
Check if protontricks is available.
std::future< bool > syncSaves(const std::string &gameId, SyncDirection direction, const ProgressCallback &progressCallback=nullptr)
Sync saves with cloud/custom directory.
std::future< bool > installGOGGame(const std::string &gameId, const std::string &installPath="", const ProgressCallback &progressCallback=nullptr)
Install a GOG game.
bool uninstallGOGGame(const std::string &gameId)
Uninstall a GOG game.
std::vector< StoreStatus > getAllStoreStatus() const
Get status of all available stores.
std::optional< std::string > createSaveSnapshot(const std::string &gameId, const std::string &description="")
Create a save snapshot (backup).
bool isStoreAvailable(StoreType store) const
Check if a store backend is available (tools installed).
SyncDirection
Direction of sync operation.
ConflictResolution
How to resolve sync conflicts.
GOGBackend
Backend to use for GOG operations.
std::string storeTypeName(StoreType type)
Get human-readable store name.
Progress information during dependency installation.
Epic Games authentication status.
Information about an Epic Games Store game.
GOG Galaxy authentication status.
Information about a GOG.com game.
Progress information for GOG operations.
Progress information for Legendary operations.
Status of dependencies in a Wine prefix.
Information about a game's save location.
A complete snapshot of a game's saves at a point in time.
Details about a sync conflict.
Status of sync operation.
Information about a Wine dependency/component.
DependencyCategory
Categories of Wine dependencies.