|
game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
|
Service for managing and syncing game saves. More...
#include <cloud_save_service.h>
Classes | |
| struct | Impl |
Public Types | |
| using | ConflictCallback = std::function<ConflictResolution(const SyncConflict&)> |
| using | ProgressCallback = std::function<void(const SyncStatus&)> |
Public Member Functions | |
| CloudSaveService () | |
| ~CloudSaveService () | |
| void | cancelOperation () |
| Cancel ongoing operation. | |
| std::optional< std::string > | createSnapshot (const std::string &gameId, const std::string &description="") |
| Create a snapshot of current saves. | |
| std::future< std::optional< std::string > > | createSnapshotAsync (const std::string &gameId, const std::string &description="") |
| Create snapshot asynchronously. | |
| bool | deleteSnapshot (const std::string &snapshotId) |
| Delete a snapshot. | |
| std::vector< SaveLocation > | detectSaveLocation (const std::string &gameName, const std::filesystem::path &prefixPath={}) const |
| Detect save location for a game. | |
| std::filesystem::path | getBackupDirectory () const |
| Get the backup directory. | |
| std::vector< SyncConflict > | getPendingConflicts (const std::string &gameId) const |
| Get pending conflicts. | |
| std::optional< SaveLocation > | getSaveLocation (const std::string &gameId) const |
| Get save location for a specific game. | |
| std::vector< SaveLocation > | getSaveLocations () const |
| Get all registered save locations. | |
| std::optional< SaveSnapshot > | getSnapshot (const std::string &snapshotId) const |
| Get a specific snapshot. | |
| int | getSnapshotCount (const std::string &gameId) const |
| Get snapshot count for a game. | |
| std::vector< SaveSnapshot > | getSnapshots (const std::string &gameId) const |
| List all snapshots for a game. | |
| int64_t | getTotalBackupSize () const |
| Get total backup size for all games. | |
| int64_t | getTotalBackupSize (const std::string &gameId) const |
| Get total backup size for a game. | |
| bool | needsSync (const std::string &gameId) const |
| Check if sync is needed. | |
| void | onGameExit (const std::string &gameId) |
| Called when a game exits. | |
| void | onGameLaunch (const std::string &gameId) |
| Called when a game is about to launch. | |
| int | pruneSnapshots (const std::string &gameId, int keepCount=10) |
| Delete old snapshots. | |
| bool | registerSaveLocation (const SaveLocation &location) |
| Register a game's save location. | |
| bool | removeSaveLocation (const std::string &gameId) |
| Remove a save location registration. | |
| bool | resolveConflict (const std::string &gameId, const std::string &filePath, ConflictResolution resolution) |
| Resolve a conflict. | |
| bool | restoreSnapshot (const std::string &snapshotId, bool backupCurrent=true) |
| Restore saves from a snapshot. | |
| void | setAutoSync (const std::string &gameId, bool enabled) |
| Enable auto-sync for a game. | |
| void | setBackupDirectory (const std::filesystem::path &path) |
| Set the local backup directory. | |
| void | setCustomSyncDirectory (const std::filesystem::path &path) |
| Set custom sync directory. | |
| void | setDefaultConflictResolution (ConflictResolution resolution) |
| Set default conflict resolution. | |
| void | setMaxSnapshotsPerGame (int count) |
| Set maximum snapshots per game. | |
| bool | syncSaves (const std::string &gameId, SyncDirection direction=SyncDirection::Bidirectional, const ProgressCallback &progressCallback=nullptr, const ConflictCallback &conflictCallback=nullptr) |
| Sync saves with cloud storage. | |
| std::future< bool > | syncSavesAsync (const std::string &gameId, SyncDirection direction=SyncDirection::Bidirectional, const ProgressCallback &progressCallback=nullptr, const ConflictCallback &conflictCallback=nullptr) |
| Sync asynchronously. | |
| bool | updateSaveLocation (const SaveLocation &location) |
| Update an existing save location. | |
Service for managing and syncing game saves.
Provides methods for backing up, restoring, and syncing game saves across local and cloud storage.
Definition at line 203 of file cloud_save_service.h.
| using CloudSaveService::ConflictCallback = std::function<ConflictResolution(const SyncConflict&)> |
Definition at line 207 of file cloud_save_service.h.
| using CloudSaveService::ProgressCallback = std::function<void(const SyncStatus&)> |
Definition at line 206 of file cloud_save_service.h.
| CloudSaveService::CloudSaveService | ( | ) |
Definition at line 321 of file cloud_save_service.cpp.
|
default |
| void CloudSaveService::cancelOperation | ( | ) |
Cancel ongoing operation.
Definition at line 1139 of file cloud_save_service.cpp.
| std::optional< std::string > CloudSaveService::createSnapshot | ( | const std::string & | gameId, |
| const std::string & | description = "" ) |
Create a snapshot of current saves.
| gameId | Game ID |
| description | Optional description |
Definition at line 498 of file cloud_save_service.cpp.
References SaveSnapshot::description, SaveSnapshot::files, SaveSnapshot::gameId, SaveSnapshot::gameName, getSaveLocation(), SaveSnapshot::id, SaveSnapshot::isAutomatic, SaveFile::path, SaveSnapshot::timestamp, SaveSnapshot::totalSize, and Logger::warn().
Referenced by createSnapshotAsync(), onGameExit(), and restoreSnapshot().
| std::future< std::optional< std::string > > CloudSaveService::createSnapshotAsync | ( | const std::string & | gameId, |
| const std::string & | description = "" ) |
Create snapshot asynchronously.
Definition at line 575 of file cloud_save_service.cpp.
References createSnapshot().
| bool CloudSaveService::deleteSnapshot | ( | const std::string & | snapshotId | ) |
Delete a snapshot.
| snapshotId | Snapshot to delete |
Definition at line 703 of file cloud_save_service.cpp.
| std::vector< SaveLocation > CloudSaveService::detectSaveLocation | ( | const std::string & | gameName, |
| const std::filesystem::path & | prefixPath = {} ) const |
Detect save location for a game.
| gameName | Game name to search for |
| prefixPath | Optional Wine prefix path |
Definition at line 404 of file cloud_save_service.cpp.
References SaveLocation::gameId, SaveLocation::gameName, SaveLocation::isWinePrefix, SaveLocation::localPath, SaveLocation::pattern, and SaveLocation::prefixPath.
| std::filesystem::path CloudSaveService::getBackupDirectory | ( | ) | const |
Get the backup directory.
Definition at line 1109 of file cloud_save_service.cpp.
| std::vector< SyncConflict > CloudSaveService::getPendingConflicts | ( | const std::string & | gameId | ) | const |
Get pending conflicts.
| gameId | Game ID |
Definition at line 1045 of file cloud_save_service.cpp.
| std::optional< SaveLocation > CloudSaveService::getSaveLocation | ( | const std::string & | gameId | ) | const |
Get save location for a specific game.
| gameId | Game ID |
Definition at line 389 of file cloud_save_service.cpp.
Referenced by createSnapshot(), needsSync(), onGameExit(), onGameLaunch(), restoreSnapshot(), and syncSaves().
| std::vector< SaveLocation > CloudSaveService::getSaveLocations | ( | ) | const |
Get all registered save locations.
Definition at line 383 of file cloud_save_service.cpp.
| std::optional< SaveSnapshot > CloudSaveService::getSnapshot | ( | const std::string & | snapshotId | ) | const |
Get a specific snapshot.
| snapshotId | Snapshot ID |
Definition at line 596 of file cloud_save_service.cpp.
Referenced by restoreSnapshot().
| int CloudSaveService::getSnapshotCount | ( | const std::string & | gameId | ) | const |
Get snapshot count for a game.
| gameId | Game ID |
Definition at line 1181 of file cloud_save_service.cpp.
| std::vector< SaveSnapshot > CloudSaveService::getSnapshots | ( | const std::string & | gameId | ) | const |
List all snapshots for a game.
| gameId | Game ID |
Definition at line 581 of file cloud_save_service.cpp.
| int64_t CloudSaveService::getTotalBackupSize | ( | ) | const |
Get total backup size for all games.
Definition at line 1166 of file cloud_save_service.cpp.
| int64_t CloudSaveService::getTotalBackupSize | ( | const std::string & | gameId | ) | const |
Get total backup size for a game.
| gameId | Game ID |
Definition at line 1148 of file cloud_save_service.cpp.
| bool CloudSaveService::needsSync | ( | const std::string & | gameId | ) | const |
Check if sync is needed.
| gameId | Game ID |
Definition at line 1007 of file cloud_save_service.cpp.
References getSaveLocation(), and SaveLocation::localPath.
| void CloudSaveService::onGameExit | ( | const std::string & | gameId | ) |
Called when a game exits.
| gameId | Game ID |
Uploads saves to cloud if auto-sync enabled.
Definition at line 1087 of file cloud_save_service.cpp.
References createSnapshot(), getSaveLocation(), syncSaves(), and Upload.
| void CloudSaveService::onGameLaunch | ( | const std::string & | gameId | ) |
Called when a game is about to launch.
| gameId | Game ID |
Downloads latest saves from cloud if auto-sync enabled.
Definition at line 1078 of file cloud_save_service.cpp.
References Download, getSaveLocation(), and syncSaves().
| int CloudSaveService::pruneSnapshots | ( | const std::string & | gameId, |
| int | keepCount = 10 ) |
Delete old snapshots.
| gameId | Game ID |
| keepCount | Number of recent snapshots to keep |
Definition at line 726 of file cloud_save_service.cpp.
| bool CloudSaveService::registerSaveLocation | ( | const SaveLocation & | location | ) |
Register a game's save location.
| location | Save location info |
Definition at line 333 of file cloud_save_service.cpp.
References SaveLocation::gameId.
| bool CloudSaveService::removeSaveLocation | ( | const std::string & | gameId | ) |
Remove a save location registration.
| gameId | Game ID to remove |
Definition at line 367 of file cloud_save_service.cpp.
| bool CloudSaveService::resolveConflict | ( | const std::string & | gameId, |
| const std::string & | filePath, | ||
| ConflictResolution | resolution ) |
Resolve a conflict.
| gameId | Game ID |
| filePath | Conflicted file path |
| resolution | How to resolve |
Definition at line 1051 of file cloud_save_service.cpp.
| bool CloudSaveService::restoreSnapshot | ( | const std::string & | snapshotId, |
| bool | backupCurrent = true ) |
Restore saves from a snapshot.
| snapshotId | Snapshot to restore |
| backupCurrent | Create backup of current saves first |
Definition at line 613 of file cloud_save_service.cpp.
References createSnapshot(), Logger::error(), getSaveLocation(), and getSnapshot().
| void CloudSaveService::setAutoSync | ( | const std::string & | gameId, |
| bool | enabled ) |
Enable auto-sync for a game.
| gameId | Game ID |
| enabled | Enable or disable |
Definition at line 1063 of file cloud_save_service.cpp.
| void CloudSaveService::setBackupDirectory | ( | const std::filesystem::path & | path | ) |
Set the local backup directory.
| path | Directory for storing snapshots |
Definition at line 1102 of file cloud_save_service.cpp.
| void CloudSaveService::setCustomSyncDirectory | ( | const std::filesystem::path & | path | ) |
Set custom sync directory.
| path | Custom cloud sync path (e.g., Syncthing folder) |
Definition at line 1114 of file cloud_save_service.cpp.
| void CloudSaveService::setDefaultConflictResolution | ( | ConflictResolution | resolution | ) |
Set default conflict resolution.
| resolution | Default resolution for auto-sync |
Definition at line 1120 of file cloud_save_service.cpp.
| void CloudSaveService::setMaxSnapshotsPerGame | ( | int | count | ) |
Set maximum snapshots per game.
| count | Maximum to keep (0 = unlimited) |
Definition at line 1131 of file cloud_save_service.cpp.
| bool CloudSaveService::syncSaves | ( | const std::string & | gameId, |
| SyncDirection | direction = SyncDirection::Bidirectional, | ||
| const ProgressCallback & | progressCallback = nullptr, | ||
| const ConflictCallback & | conflictCallback = nullptr ) |
Sync saves with cloud storage.
| gameId | Game ID |
| direction | Sync direction |
| progressCallback | Progress updates |
| conflictCallback | Conflict resolution callback |
Definition at line 767 of file cloud_save_service.cpp.
References AskUser, Bidirectional, SyncStatus::bytesTransferred, SyncStatus::Cancelled, SyncStatus::Comparing, SyncStatus::Completed, SyncStatus::currentFile, Download, SyncStatus::Downloading, SyncStatus::errorMessage, SyncStatus::Failed, SyncConflict::filePath, SyncStatus::filesProcessed, SyncStatus::filesTotal, getSaveLocation(), Logger::info(), KeepBoth, SyncConflict::localFile, SaveLocation::localPath, SyncStatus::percentComplete, SyncConflict::remoteFile, SyncStatus::Scanning, SyncStatus::state, Upload, SyncStatus::Uploading, UseLocal, UseNewest, UseRemote, and Logger::warn().
Referenced by onGameExit(), onGameLaunch(), and syncSavesAsync().
| std::future< bool > CloudSaveService::syncSavesAsync | ( | const std::string & | gameId, |
| SyncDirection | direction = SyncDirection::Bidirectional, | ||
| const ProgressCallback & | progressCallback = nullptr, | ||
| const ConflictCallback & | conflictCallback = nullptr ) |
| bool CloudSaveService::updateSaveLocation | ( | const SaveLocation & | location | ) |
Update an existing save location.
| location | Updated location info |
Definition at line 351 of file cloud_save_service.cpp.
References SaveLocation::gameId.