game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
GOGIntegration Class Reference

Service for integrating with GOG.com. More...

#include <gog_integration.h>

Classes

struct  Impl

Public Types

using AuthCallback = std::function<void(bool success, const std::string& message)>
using ProgressCallback = std::function<void(const GOGProgress&)>

Public Member Functions

 GOGIntegration ()
 ~GOGIntegration ()
void authenticate (const AuthCallback &callback=nullptr)
 Start authentication flow.
void cancelOperation ()
 Cancel ongoing operation.
bool downloadCloudSaves (const std::string &gameId)
 Download cloud saves for a game.
GOGBackend getActiveBackend () const
 Get which backend is being used.
GOGAuthStatus getAuthStatus () const
 Get authentication status.
std::filesystem::path getDefaultInstallPath () const
 Get default installation directory.
std::optional< GOGGameInfo > getGameInfo (const std::string &gameId) const
 Get info for a specific game.
std::vector< GOGGameInfo > getInstalledGames () const
 Get all installed GOG games.
std::string getLaunchCommand (const std::string &gameId) const
 Get launch command for a game.
std::vector< GOGGameInfo > getLibrary (bool forceRefresh=false)
 Get all games in GOG library.
bool hasUpdate (const std::string &gameId) const
 Check if updates are available.
bool importGame (const std::string &gameId, const std::filesystem::path &existingPath)
 Import existing game installation.
bool installGame (const std::string &gameId, const std::filesystem::path &installPath={}, const std::string &platform="", const ProgressCallback &progressCallback=nullptr)
 Install a game.
std::future< bool > installGameAsync (const std::string &gameId, const std::filesystem::path &installPath={}, const std::string &platform="", const ProgressCallback &progressCallback=nullptr)
 Install a game asynchronously.
bool isAuthenticated () const
 Check if user is authenticated.
bool isAvailable () const
 Check if GOG integration is available.
bool launchGame (const std::string &gameId, bool useProton=false, const std::string &protonVersion="")
 Launch a game.
void logout ()
 Log out and clear credentials.
void setDefaultInstallPath (const std::filesystem::path &path)
 Set default installation directory.
void setPreferredBackend (GOGBackend backend)
 Set preferred backend.
bool syncCloudSaves (const std::string &gameId)
 Sync cloud saves (bidirectional).
int syncLibrary ()
 Sync GOG library with game database.
Game toGame (const GOGGameInfo &gogGame) const
 Convert GOG game to generic Game object.
bool uninstallGame (const std::string &gameId)
 Uninstall a game.
bool updateGame (const std::string &gameId, const ProgressCallback &progressCallback=nullptr)
 Update a game.
bool uploadCloudSaves (const std::string &gameId)
 Upload local saves to cloud.
bool verifyGame (const std::string &gameId, const ProgressCallback &progressCallback=nullptr)
 Verify game files.

Static Public Member Functions

static bool isGogdlAvailable ()
 Check if gogdl CLI is installed.
static bool isHeroicAvailable ()
 Check if Heroic Games Launcher is installed.

Detailed Description

Service for integrating with GOG.com.

Provides methods for managing GOG library, installation, and cloud saves through Heroic Games Launcher or gogdl CLI.

Prerequisites

One of:

  • Heroic Games Launcher installed
  • gogdl CLI installed

Usage Example

if (gog.isAvailable()) {
auto games = gog.getLibrary();
for (const auto& game : games) {
std::cout << game.title << std::endl;
}
}
std::vector< GOGGameInfo > getLibrary(bool forceRefresh=false)
Get all games in GOG library.
bool isAvailable() const
Check if GOG integration is available.

Definition at line 165 of file gog_integration.h.

Member Typedef Documentation

◆ AuthCallback

using GOGIntegration::AuthCallback = std::function<void(bool success, const std::string& message)>

Definition at line 169 of file gog_integration.h.

◆ ProgressCallback

using GOGIntegration::ProgressCallback = std::function<void(const GOGProgress&)>

Definition at line 168 of file gog_integration.h.

Constructor & Destructor Documentation

◆ GOGIntegration()

GOGIntegration::GOGIntegration ( )

Definition at line 135 of file gog_integration.cpp.

References Direct, GOGDL, Heroic, isGogdlAvailable(), and isHeroicAvailable().

◆ ~GOGIntegration()

GOGIntegration::~GOGIntegration ( )

Definition at line 152 of file gog_integration.cpp.

Member Function Documentation

◆ authenticate()

void GOGIntegration::authenticate ( const AuthCallback & callback = nullptr)

Start authentication flow.

Parameters
callbackCallback when auth completes

Definition at line 332 of file gog_integration.cpp.

References Logger::info().

◆ cancelOperation()

void GOGIntegration::cancelOperation ( )

Cancel ongoing operation.

Definition at line 1016 of file gog_integration.cpp.

◆ downloadCloudSaves()

bool GOGIntegration::downloadCloudSaves ( const std::string & gameId)

Download cloud saves for a game.

Parameters
gameIdGOG game ID
Returns
True on success

Definition at line 911 of file gog_integration.cpp.

References Logger::info().

◆ getActiveBackend()

GOGBackend GOGIntegration::getActiveBackend ( ) const

Get which backend is being used.

Returns
Active backend

Definition at line 184 of file gog_integration.cpp.

◆ getAuthStatus()

GOGAuthStatus GOGIntegration::getAuthStatus ( ) const

Get authentication status.

Returns
Authentication status

Definition at line 292 of file gog_integration.cpp.

References Logger::error(), Heroic, GOGAuthStatus::isAuthenticated, GOGAuthStatus::userId, and GOGAuthStatus::username.

Referenced by isAuthenticated().

◆ getDefaultInstallPath()

std::filesystem::path GOGIntegration::getDefaultInstallPath ( ) const

Get default installation directory.

Definition at line 1010 of file gog_integration.cpp.

◆ getGameInfo()

std::optional< GOGGameInfo > GOGIntegration::getGameInfo ( const std::string & gameId) const

Get info for a specific game.

Parameters
gameIdGOG game ID
Returns
Game info if found

Definition at line 642 of file gog_integration.cpp.

References GOGGameInfo::gameId.

Referenced by getLaunchCommand(), launchGame(), and uninstallGame().

◆ getInstalledGames()

std::vector< GOGGameInfo > GOGIntegration::getInstalledGames ( ) const

Get all installed GOG games.

Returns
Vector of installed game info

Definition at line 621 of file gog_integration.cpp.

References Heroic, and GOGGameInfo::isInstalled.

◆ getLaunchCommand()

std::string GOGIntegration::getLaunchCommand ( const std::string & gameId) const

Get launch command for a game.

Parameters
gameIdGOG game ID
Returns
Launch command string

Definition at line 989 of file gog_integration.cpp.

References getGameInfo().

◆ getLibrary()

std::vector< GOGGameInfo > GOGIntegration::getLibrary ( bool forceRefresh = false)

Get all games in GOG library.

Parameters
forceRefreshForce refresh from GOG servers
Returns
Vector of game info

Definition at line 603 of file gog_integration.cpp.

References GOGDL, and Heroic.

Referenced by syncLibrary().

◆ hasUpdate()

bool GOGIntegration::hasUpdate ( const std::string & gameId) const

Check if updates are available.

Parameters
gameIdGOG game ID
Returns
True if update available

Definition at line 874 of file gog_integration.cpp.

◆ importGame()

bool GOGIntegration::importGame ( const std::string & gameId,
const std::filesystem::path & existingPath )

Import existing game installation.

Parameters
gameIdGOG game ID
existingPathPath to existing installation
Returns
True on success

Definition at line 888 of file gog_integration.cpp.

References Logger::info().

◆ installGame()

bool GOGIntegration::installGame ( const std::string & gameId,
const std::filesystem::path & installPath = {},
const std::string & platform = "",
const ProgressCallback & progressCallback = nullptr )

Install a game.

Parameters
gameIdGOG game ID
installPathInstallation path (empty = default)
platformPlatform to install (empty = auto-detect)
progressCallbackProgress updates
Returns
True on success

Definition at line 760 of file gog_integration.cpp.

References GOGDL, and Heroic.

Referenced by installGameAsync().

◆ installGameAsync()

std::future< bool > GOGIntegration::installGameAsync ( const std::string & gameId,
const std::filesystem::path & installPath = {},
const std::string & platform = "",
const ProgressCallback & progressCallback = nullptr )

Install a game asynchronously.

Definition at line 777 of file gog_integration.cpp.

References installGame().

◆ isAuthenticated()

bool GOGIntegration::isAuthenticated ( ) const

Check if user is authenticated.

Definition at line 327 of file gog_integration.cpp.

References getAuthStatus(), and GOGAuthStatus::isAuthenticated.

◆ isAvailable()

bool GOGIntegration::isAvailable ( ) const

Check if GOG integration is available.

Returns
True if Heroic or gogdl is installed

Definition at line 179 of file gog_integration.cpp.

References isGogdlAvailable(), and isHeroicAvailable().

◆ isGogdlAvailable()

bool GOGIntegration::isGogdlAvailable ( )
static

Check if gogdl CLI is installed.

Definition at line 202 of file gog_integration.cpp.

Referenced by GOGIntegration(), isAvailable(), and setPreferredBackend().

◆ isHeroicAvailable()

bool GOGIntegration::isHeroicAvailable ( )
static

Check if Heroic Games Launcher is installed.

Definition at line 189 of file gog_integration.cpp.

Referenced by GOGIntegration(), isAvailable(), and setPreferredBackend().

◆ launchGame()

bool GOGIntegration::launchGame ( const std::string & gameId,
bool useProton = false,
const std::string & protonVersion = "" )

Launch a game.

Parameters
gameIdGOG game ID
useProtonUse Proton for Windows games
protonVersionProton version to use
Returns
True if launch initiated

Definition at line 934 of file gog_integration.cpp.

References Logger::error(), ShellUtils::escapeArg(), getGameInfo(), and Logger::info().

◆ logout()

void GOGIntegration::logout ( )

Log out and clear credentials.

Definition at line 343 of file gog_integration.cpp.

References Logger::info().

◆ setDefaultInstallPath()

void GOGIntegration::setDefaultInstallPath ( const std::filesystem::path & path)

Set default installation directory.

Parameters
pathDefault install path

Definition at line 1004 of file gog_integration.cpp.

◆ setPreferredBackend()

void GOGIntegration::setPreferredBackend ( GOGBackend backend)

Set preferred backend.

Parameters
backendPreferred backend (will fall back if unavailable)

Definition at line 238 of file gog_integration.cpp.

References GOGDL, Heroic, isGogdlAvailable(), and isHeroicAvailable().

◆ syncCloudSaves()

bool GOGIntegration::syncCloudSaves ( const std::string & gameId)

Sync cloud saves (bidirectional).

Parameters
gameIdGOG game ID
Returns
True on success

Definition at line 924 of file gog_integration.cpp.

References Logger::info().

◆ syncLibrary()

int GOGIntegration::syncLibrary ( )

Sync GOG library with game database.

Returns
Number of games synced

Definition at line 697 of file gog_integration.cpp.

References getLibrary(), and Logger::info().

◆ toGame()

◆ uninstallGame()

bool GOGIntegration::uninstallGame ( const std::string & gameId)

Uninstall a game.

Parameters
gameIdGOG game ID
Returns
True on success

Definition at line 806 of file gog_integration.cpp.

References Logger::error(), getGameInfo(), and Logger::info().

◆ updateGame()

bool GOGIntegration::updateGame ( const std::string & gameId,
const ProgressCallback & progressCallback = nullptr )

Update a game.

Parameters
gameIdGOG game ID
progressCallbackProgress updates
Returns
True on success

Definition at line 862 of file gog_integration.cpp.

References GOGDL, and Logger::info().

◆ uploadCloudSaves()

bool GOGIntegration::uploadCloudSaves ( const std::string & gameId)

Upload local saves to cloud.

Parameters
gameIdGOG game ID
Returns
True on success

Definition at line 918 of file gog_integration.cpp.

References Logger::info().

◆ verifyGame()

bool GOGIntegration::verifyGame ( const std::string & gameId,
const ProgressCallback & progressCallback = nullptr )

Verify game files.

Parameters
gameIdGOG game ID
progressCallbackProgress updates
Returns
True if all files valid

Definition at line 880 of file gog_integration.cpp.

References Logger::info().


The documentation for this class was generated from the following files: