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

Service for integrating with Epic Games through Legendary CLI. More...

#include <legendary_integration.h>

Classes

struct  Impl

Public Types

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

Public Member Functions

 LegendaryIntegration ()
 ~LegendaryIntegration ()
void authenticate (const AuthCallback &callback=nullptr)
 Start authentication flow.
void authenticateWithCode (const std::string &authCode, const AuthCallback &callback=nullptr)
 Start authentication with authorization code.
void cancelOperation ()
 Cancel ongoing operation.
bool downloadCloudSaves (const std::string &appName, bool force=false)
 Download cloud saves for a game.
EpicAuthStatus getAuthStatus () const
 Check authentication status.
std::vector< EpicGameInfo > getAvailableDLC (const std::string &appName)
 Get available DLC for a game.
EpicCloudSaveInfo getCloudSaveStatus (const std::string &appName) const
 Get cloud save status for a game.
std::filesystem::path getDefaultInstallPath () const
 Get default installation directory.
std::optional< EpicGameInfo > getGameInfo (const std::string &appName) const
 Get info for a specific game.
std::vector< EpicGameInfo > getInstalledGames () const
 Get all installed games.
std::string getLaunchCommand (const std::string &appName, const std::vector< std::string > &additionalArgs={}, bool offline=false) const
 Get launch command for a game.
std::vector< EpicGameInfo > getLibrary (bool forceRefresh=false)
 Get all games in Epic library.
bool importGame (const std::string &appName, const std::filesystem::path &existingPath)
 Import an existing game installation.
bool installDLC (const std::string &dlcAppName, const ProgressCallback &progressCallback=nullptr)
 Install DLC for a game.
bool installGame (const std::string &appName, const std::filesystem::path &installPath={}, const ProgressCallback &progressCallback=nullptr)
 Install a game.
std::future< bool > installGameAsync (const std::string &appName, const std::filesystem::path &installPath={}, const ProgressCallback &progressCallback=nullptr)
 Install a game asynchronously.
bool isAuthenticated () const
 Check if user is authenticated.
bool launchGame (const std::string &appName, const std::vector< std::string > &additionalArgs={}, bool offline=false, pid_t *outPid=nullptr)
 Launch a game.
void logout ()
 Log out and clear credentials.
bool moveGame (const std::string &appName, const std::filesystem::path &newPath, const ProgressCallback &progressCallback=nullptr)
 Move game to different location.
bool repairGame (const std::string &appName, const ProgressCallback &progressCallback=nullptr)
 Repair game (verify and redownload corrupt files).
void setAutoSyncSaves (bool enabled)
 Enable/disable automatic cloud save sync.
void setDefaultInstallPath (const std::filesystem::path &path)
 Set default installation directory.
void setMaxWorkers (int workers)
 Set maximum download workers.
bool syncCloudSaves (const std::string &appName)
 Sync saves (download if newer, upload if local is newer).
int syncLibrary ()
 Sync Epic library with game database.
Game toGame (const EpicGameInfo &epicGame) const
 Convert Epic game to generic Game object.
bool uninstallGame (const std::string &appName, bool keepFiles=false)
 Uninstall a game.
bool updateGame (const std::string &appName, const ProgressCallback &progressCallback=nullptr)
 Update a game.
bool uploadCloudSaves (const std::string &appName, bool force=false)
 Upload local saves to cloud.
bool verifyGame (const std::string &appName, const ProgressCallback &progressCallback=nullptr)
 Verify game files.

Static Public Member Functions

static std::filesystem::path getLegendaryPath ()
 Get path to Legendary executable.
static std::string getVersion ()
 Get Legendary version.
static bool isAvailable ()
 Check if Legendary CLI is installed.

Detailed Description

Service for integrating with Epic Games through Legendary CLI.

Provides methods for managing Epic Games library, installation, and cloud saves through the Legendary CLI tool.

Prerequisites

Usage Example

if (!epic.isAuthenticated()) {
epic.authenticate(); // Opens browser for login
}
auto games = epic.getInstalledGames();
for (const auto& game : games) {
std::cout << game.appTitle << std::endl;
}
std::vector< EpicGameInfo > getInstalledGames() const
Get all installed games.
void authenticate(const AuthCallback &callback=nullptr)
Start authentication flow.
bool isAuthenticated() const
Check if user is authenticated.

Definition at line 167 of file legendary_integration.h.

Member Typedef Documentation

◆ AuthCallback

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

Definition at line 171 of file legendary_integration.h.

◆ ProgressCallback

using LegendaryIntegration::ProgressCallback = std::function<void(const LegendaryProgress&)>

Definition at line 170 of file legendary_integration.h.

Constructor & Destructor Documentation

◆ LegendaryIntegration()

LegendaryIntegration::LegendaryIntegration ( )

Definition at line 161 of file legendary_integration.cpp.

References getAuthStatus(), and isAvailable().

◆ ~LegendaryIntegration()

LegendaryIntegration::~LegendaryIntegration ( )

Definition at line 170 of file legendary_integration.cpp.

Member Function Documentation

◆ authenticate()

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

Start authentication flow.

Parameters
callbackCallback when auth completes

Opens browser for Epic Games login. The callback is called when authentication completes (success or failure).

Definition at line 442 of file legendary_integration.cpp.

References EpicAuthStatus::accountId, EpicAuthStatus::displayName, and EpicAuthStatus::isAuthenticated.

◆ authenticateWithCode()

void LegendaryIntegration::authenticateWithCode ( const std::string & authCode,
const AuthCallback & callback = nullptr )

Start authentication with authorization code.

Parameters
authCodeAuthorization code from Epic login
callbackCallback when auth completes

Definition at line 509 of file legendary_integration.cpp.

References EpicAuthStatus::accountId, EpicAuthStatus::displayName, ShellUtils::escapeArg(), and EpicAuthStatus::isAuthenticated.

◆ cancelOperation()

void LegendaryIntegration::cancelOperation ( )

Cancel ongoing operation.

Definition at line 1203 of file legendary_integration.cpp.

◆ downloadCloudSaves()

bool LegendaryIntegration::downloadCloudSaves ( const std::string & appName,
bool force = false )

Download cloud saves for a game.

Parameters
appNameApp name/ID
forceForce overwrite local saves
Returns
True on success

Definition at line 1045 of file legendary_integration.cpp.

References Logger::info().

◆ getAuthStatus()

EpicAuthStatus LegendaryIntegration::getAuthStatus ( ) const

Check authentication status.

Returns
Authentication status

Definition at line 401 of file legendary_integration.cpp.

References EpicAuthStatus::accountId, EpicAuthStatus::displayName, and EpicAuthStatus::isAuthenticated.

Referenced by LegendaryIntegration(), and isAuthenticated().

◆ getAvailableDLC()

std::vector< EpicGameInfo > LegendaryIntegration::getAvailableDLC ( const std::string & appName)

Get available DLC for a game.

Parameters
appNameBase game app name
Returns
Vector of DLC info

Definition at line 1002 of file legendary_integration.cpp.

References EpicGameInfo::baseGameAppName, getLibrary(), and EpicGameInfo::isDLC.

◆ getCloudSaveStatus()

EpicCloudSaveInfo LegendaryIntegration::getCloudSaveStatus ( const std::string & appName) const

Get cloud save status for a game.

Parameters
appNameApp name/ID
Returns
Cloud save info

Definition at line 1028 of file legendary_integration.cpp.

References EpicCloudSaveInfo::appName.

◆ getDefaultInstallPath()

fs::path LegendaryIntegration::getDefaultInstallPath ( ) const

Get default installation directory.

Definition at line 1185 of file legendary_integration.cpp.

◆ getGameInfo()

std::optional< EpicGameInfo > LegendaryIntegration::getGameInfo ( const std::string & appName) const

◆ getInstalledGames()

std::vector< EpicGameInfo > LegendaryIntegration::getInstalledGames ( ) const

Get all installed games.

Returns
Vector of installed game info

Definition at line 726 of file legendary_integration.cpp.

References EpicGameInfo::appName, EpicGameInfo::appTitle, Logger::error(), EpicGameInfo::installPath, EpicGameInfo::installSize, EpicGameInfo::isInstalled, and EpicGameInfo::version.

◆ getLaunchCommand()

std::string LegendaryIntegration::getLaunchCommand ( const std::string & appName,
const std::vector< std::string > & additionalArgs = {},
bool offline = false ) const

Get launch command for a game.

Parameters
appNameApp name/ID
additionalArgsAdditional arguments
offlineOffline mode
Returns
Launch command string

Definition at line 1156 of file legendary_integration.cpp.

◆ getLegendaryPath()

fs::path LegendaryIntegration::getLegendaryPath ( )
static

Get path to Legendary executable.

Returns
Path or empty if not found

Definition at line 230 of file legendary_integration.cpp.

Referenced by isAvailable(), and launchGame().

◆ getLibrary()

std::vector< EpicGameInfo > LegendaryIntegration::getLibrary ( bool forceRefresh = false)

Get all games in Epic library.

Parameters
forceRefreshForce refresh from Epic servers
Returns
Vector of game info

Definition at line 694 of file legendary_integration.cpp.

References Logger::info(), and LegendaryIntegration::Impl::LIBRARY_CACHE_VALIDITY_SEC.

Referenced by getAvailableDLC(), and syncLibrary().

◆ getVersion()

std::string LegendaryIntegration::getVersion ( )
static

Get Legendary version.

Returns
Version string or empty if not available

Definition at line 197 of file legendary_integration.cpp.

References isAvailable().

◆ importGame()

bool LegendaryIntegration::importGame ( const std::string & appName,
const std::filesystem::path & existingPath )

Import an existing game installation.

Parameters
appNameApp name/ID
existingPathPath to existing installation
Returns
True on success

Definition at line 988 of file legendary_integration.cpp.

References Logger::info().

◆ installDLC()

bool LegendaryIntegration::installDLC ( const std::string & dlcAppName,
const ProgressCallback & progressCallback = nullptr )

Install DLC for a game.

Parameters
dlcAppNameDLC app name
progressCallbackProgress updates
Returns
True on success

Definition at line 1018 of file legendary_integration.cpp.

References installGame().

◆ installGame()

bool LegendaryIntegration::installGame ( const std::string & appName,
const std::filesystem::path & installPath = {},
const ProgressCallback & progressCallback = nullptr )

Install a game.

Parameters
appNameApp name/ID
installPathInstallation path (empty = default)
progressCallbackProgress updates
Returns
True on success

Definition at line 843 of file legendary_integration.cpp.

References LegendaryProgress::Completed, LegendaryProgress::Failed, Logger::info(), LegendaryProgress::percentComplete, LegendaryProgress::Starting, and LegendaryProgress::state.

Referenced by installDLC(), and installGameAsync().

◆ installGameAsync()

std::future< bool > LegendaryIntegration::installGameAsync ( const std::string & appName,
const std::filesystem::path & installPath = {},
const ProgressCallback & progressCallback = nullptr )

Install a game asynchronously.

Definition at line 881 of file legendary_integration.cpp.

References installGame().

◆ isAuthenticated()

bool LegendaryIntegration::isAuthenticated ( ) const

Check if user is authenticated.

Returns
True if authenticated with valid token

Definition at line 437 of file legendary_integration.cpp.

References getAuthStatus(), and EpicAuthStatus::isAuthenticated.

◆ isAvailable()

bool LegendaryIntegration::isAvailable ( )
static

Check if Legendary CLI is installed.

Returns
True if legendary command is available

Definition at line 192 of file legendary_integration.cpp.

References getLegendaryPath().

Referenced by LegendaryIntegration(), and getVersion().

◆ launchGame()

bool LegendaryIntegration::launchGame ( const std::string & appName,
const std::vector< std::string > & additionalArgs = {},
bool offline = false,
pid_t * outPid = nullptr )

Launch a game.

Parameters
appNameApp name/ID
additionalArgsAdditional command line arguments
offlineLaunch in offline mode
outPidOptional — receives PID of the spawned legendary process (which itself runs the game via Wine/Proton); use this to waitpid / kill the Epic launch from the caller. Pass nullptr to ignore.
Returns
True if launch initiated (legendary was spawned successfully)

Forks + execvp of the legendary binary directly — no shell. Caller is responsible for reaping the child if they want the exit status; a non-reaping caller just leaks the zombie until process exit, which is fine for a launcher.

Definition at line 1087 of file legendary_integration.cpp.

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

◆ logout()

void LegendaryIntegration::logout ( )

Log out and clear credentials.

Definition at line 570 of file legendary_integration.cpp.

References Logger::info().

◆ moveGame()

bool LegendaryIntegration::moveGame ( const std::string & appName,
const std::filesystem::path & newPath,
const ProgressCallback & progressCallback = nullptr )

Move game to different location.

Parameters
appNameApp name/ID
newPathNew installation path
progressCallbackProgress updates
Returns
True on success

Definition at line 976 of file legendary_integration.cpp.

References Logger::info().

◆ repairGame()

bool LegendaryIntegration::repairGame ( const std::string & appName,
const ProgressCallback & progressCallback = nullptr )

Repair game (verify and redownload corrupt files).

Parameters
appNameApp name/ID
progressCallbackProgress updates
Returns
True on success

Definition at line 964 of file legendary_integration.cpp.

References Logger::info().

◆ setAutoSyncSaves()

void LegendaryIntegration::setAutoSyncSaves ( bool enabled)

Enable/disable automatic cloud save sync.

Parameters
enabledWhether to auto-sync

Definition at line 1197 of file legendary_integration.cpp.

◆ setDefaultInstallPath()

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

Set default installation directory.

Parameters
pathDefault install path

Definition at line 1179 of file legendary_integration.cpp.

◆ setMaxWorkers()

void LegendaryIntegration::setMaxWorkers ( int workers)

Set maximum download workers.

Parameters
workersNumber of parallel downloads

Definition at line 1191 of file legendary_integration.cpp.

◆ syncCloudSaves()

bool LegendaryIntegration::syncCloudSaves ( const std::string & appName)

Sync saves (download if newer, upload if local is newer).

Parameters
appNameApp name/ID
Returns
True on success

Definition at line 1074 of file legendary_integration.cpp.

References Logger::info().

◆ syncLibrary()

int LegendaryIntegration::syncLibrary ( )

Sync Epic library with game database.

Returns
Number of games synced

Definition at line 832 of file legendary_integration.cpp.

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

◆ toGame()

Game LegendaryIntegration::toGame ( const EpicGameInfo & epicGame) const

◆ uninstallGame()

bool LegendaryIntegration::uninstallGame ( const std::string & appName,
bool keepFiles = false )

Uninstall a game.

Parameters
appNameApp name/ID
keepFilesKeep game files (just unregister)
Returns
True on success

Definition at line 937 of file legendary_integration.cpp.

References Logger::info().

◆ updateGame()

bool LegendaryIntegration::updateGame ( const std::string & appName,
const ProgressCallback & progressCallback = nullptr )

Update a game.

Parameters
appNameApp name/ID
progressCallbackProgress updates
Returns
True on success

Definition at line 925 of file legendary_integration.cpp.

References Logger::info().

◆ uploadCloudSaves()

bool LegendaryIntegration::uploadCloudSaves ( const std::string & appName,
bool force = false )

Upload local saves to cloud.

Parameters
appNameApp name/ID
forceForce overwrite cloud saves
Returns
True on success

Definition at line 1060 of file legendary_integration.cpp.

References Logger::info().

◆ verifyGame()

bool LegendaryIntegration::verifyGame ( const std::string & appName,
const ProgressCallback & progressCallback = nullptr )

Verify game files.

Parameters
appNameApp name/ID
progressCallbackProgress updates
Returns
True if all files valid

Definition at line 952 of file legendary_integration.cpp.

References Logger::info().


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