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

Monitors Steam download/install progress for games. More...

#include <steam_integration.h>

Classes

class  Impl

Public Types

using GameExitCallback = std::function<void(uint32_t appId)>
using GameLaunchCallback = std::function<void(uint32_t appId, int pid)>
using ProgressCallback
using StateChangeCallback

Public Member Functions

 SteamDownloadMonitor ()
 SteamDownloadMonitor (const SteamDownloadMonitor &)=delete
 SteamDownloadMonitor (SteamDownloadMonitor &&) noexcept
 ~SteamDownloadMonitor ()
SteamDownloadProgress getProgress (uint32_t appId) const
 Get current progress for a game (immediate snapshot).
std::vector< uint32_t > getWatchedGames () const
 Get list of currently watched game IDs.
bool isRunning () const
 Check if monitor is running.
SteamDownloadMonitor & operator= (const SteamDownloadMonitor &)=delete
SteamDownloadMonitor & operator= (SteamDownloadMonitor &&) noexcept
void setOnGameExit (GameExitCallback callback)
void setOnGameLaunch (GameLaunchCallback callback)
void setOnProgressUpdate (ProgressCallback callback)
void setOnStateChange (StateChangeCallback callback)
void start (int pollIntervalMs=1000)
 Start monitoring Steam downloads.
void stop ()
 Stop all monitoring.
void unwatchGame (uint32_t appId)
 Remove a game from the watch list.
void watchGame (uint32_t appId)
 Add a game to the watch list for progress updates.

Static Public Member Functions

static std::vector< uint32_t > getDownloadingGames ()
 Get list of all games currently downloading.
static int getRunningGamePid (uint32_t appId)
 Check if a Steam game is currently running (by app ID).
static bool isSteamDownloading ()
 Check if Steam is actively downloading/updating anything.
static SteamDownloadProgress readGameState (uint32_t appId)
 Read current state of a game directly from its appmanifest.

Detailed Description

Monitors Steam download/install progress for games.

This class provides download progress tracking by:

  1. Polling appmanifest ACF files for progress changes
  2. Detecting game launch/exit via process inspection

Usage:

// Set up callbacks
monitor.setOnProgressUpdate([](uint32_t appId, const SteamDownloadProgress& progress) {
updateUI(appId, progress);
});
// Start monitoring a game being installed
monitor.watchGame(12345);
// Stop when done
monitor.unwatchGame(12345);
void watchGame(uint32_t appId)
Add a game to the watch list for progress updates.
void setOnProgressUpdate(ProgressCallback callback)
void unwatchGame(uint32_t appId)
Remove a game from the watch list.
Real-time download/installation progress for a Steam game.

Definition at line 960 of file steam_integration.h.

Member Typedef Documentation

◆ GameExitCallback

using SteamDownloadMonitor::GameExitCallback = std::function<void(uint32_t appId)>

Definition at line 968 of file steam_integration.h.

◆ GameLaunchCallback

using SteamDownloadMonitor::GameLaunchCallback = std::function<void(uint32_t appId, int pid)>

Definition at line 967 of file steam_integration.h.

◆ ProgressCallback

Initial value:
std::function<void(uint32_t appId, const SteamDownloadProgress& progress)>

Definition at line 963 of file steam_integration.h.

◆ StateChangeCallback

Initial value:
std::function<void(uint32_t appId, uint32_t oldState, uint32_t newState)>

Definition at line 965 of file steam_integration.h.

Constructor & Destructor Documentation

◆ SteamDownloadMonitor() [1/3]

SteamDownloadMonitor::SteamDownloadMonitor ( )

◆ ~SteamDownloadMonitor()

SteamDownloadMonitor::~SteamDownloadMonitor ( )
default

◆ SteamDownloadMonitor() [2/3]

SteamDownloadMonitor::SteamDownloadMonitor ( const SteamDownloadMonitor & )
delete

◆ SteamDownloadMonitor() [3/3]

SteamDownloadMonitor::SteamDownloadMonitor ( SteamDownloadMonitor && )
defaultnoexcept

Member Function Documentation

◆ getDownloadingGames()

std::vector< uint32_t > SteamDownloadMonitor::getDownloadingGames ( )
static

Get list of all games currently downloading.

Returns
Vector of App IDs with active downloads

Definition at line 5222 of file steam_integration.cpp.

References SteamLibraryScanner::getLibraryPaths(), SteamStateFlags::isDownloading(), readVdfContent(), and start().

Referenced by isSteamDownloading(), and operator=().

◆ getProgress()

SteamDownloadProgress SteamDownloadMonitor::getProgress ( uint32_t appId) const

Get current progress for a game (immediate snapshot).

Parameters
appIdSteam App ID
Returns
Current download progress, or empty progress if not being monitored

Definition at line 5116 of file steam_integration.cpp.

Referenced by operator=().

◆ getRunningGamePid()

int SteamDownloadMonitor::getRunningGamePid ( uint32_t appId)
static

Check if a Steam game is currently running (by app ID).

Parameters
appIdSteam App ID
Returns
PID if running, -1 otherwise

Detects game processes using the reaper PID file Steam creates.

Definition at line 5121 of file steam_integration.cpp.

References ProcessExecutor::executeWithOutput(), ProcessResult::output, and ProcessResult::success.

Referenced by operator=().

◆ getWatchedGames()

std::vector< uint32_t > SteamDownloadMonitor::getWatchedGames ( ) const

Get list of currently watched game IDs.

Definition at line 5111 of file steam_integration.cpp.

Referenced by operator=().

◆ isRunning()

bool SteamDownloadMonitor::isRunning ( ) const

Check if monitor is running.

Definition at line 5096 of file steam_integration.cpp.

Referenced by operator=().

◆ isSteamDownloading()

bool SteamDownloadMonitor::isSteamDownloading ( )
static

Check if Steam is actively downloading/updating anything.

Returns
true if download activity detected

Definition at line 5215 of file steam_integration.cpp.

References getDownloadingGames().

Referenced by operator=().

◆ operator=() [1/2]

SteamDownloadMonitor & SteamDownloadMonitor::operator= ( const SteamDownloadMonitor & )
delete

◆ operator=() [2/2]

◆ readGameState()

SteamDownloadProgress SteamDownloadMonitor::readGameState ( uint32_t appId)
static

Read current state of a game directly from its appmanifest.

Parameters
appIdSteam App ID
Returns
Current download progress, or empty progress if no manifest exists

This is a static method that reads the appmanifest file directly without requiring the game to be watched. Useful for checking initial state of games (e.g., to detect partial downloads) before adding them to watch list.

Definition at line 5295 of file steam_integration.cpp.

References SteamDownloadProgress::appId, SteamDownloadProgress::bytesDownloaded, SteamDownloadProgress::bytesStaged, SteamDownloadProgress::bytesToDownload, SteamDownloadProgress::bytesToStage, SteamDownloadProgress::calculateProgress(), SteamLibraryScanner::getLibraryPaths(), SteamStateFlags::getStateDescription(), SteamDownloadProgress::isComplete, SteamStateFlags::isFullyInstalled(), readVdfContent(), SteamDownloadProgress::stateDescription, SteamDownloadProgress::stateFlags, and Logger::warn().

Referenced by operator=(), UpdatesIndicator::refresh(), DetailsPanelManager::Impl::update(), SidebarManager::updateCategoryCounts(), and DetailsPanelManager::Impl::updateLaunchButton().

◆ setOnGameExit()

void SteamDownloadMonitor::setOnGameExit ( GameExitCallback callback)

Definition at line 5439 of file steam_integration.cpp.

Referenced by operator=().

◆ setOnGameLaunch()

void SteamDownloadMonitor::setOnGameLaunch ( GameLaunchCallback callback)

Definition at line 5434 of file steam_integration.cpp.

Referenced by operator=().

◆ setOnProgressUpdate()

void SteamDownloadMonitor::setOnProgressUpdate ( ProgressCallback callback)

Definition at line 5424 of file steam_integration.cpp.

Referenced by operator=().

◆ setOnStateChange()

void SteamDownloadMonitor::setOnStateChange ( StateChangeCallback callback)

Definition at line 5429 of file steam_integration.cpp.

Referenced by operator=().

◆ start()

void SteamDownloadMonitor::start ( int pollIntervalMs = 1000)

Start monitoring Steam downloads.

Parameters
pollIntervalMsHow often to check for changes (default: 1000ms)

Definition at line 5086 of file steam_integration.cpp.

References SteamDownloadMonitor(), and start().

Referenced by getDownloadingGames(), operator=(), and start().

◆ stop()

void SteamDownloadMonitor::stop ( )

Stop all monitoring.

Definition at line 5091 of file steam_integration.cpp.

Referenced by operator=().

◆ unwatchGame()

void SteamDownloadMonitor::unwatchGame ( uint32_t appId)

Remove a game from the watch list.

Parameters
appIdSteam App ID to stop monitoring

Definition at line 5106 of file steam_integration.cpp.

Referenced by operator=().

◆ watchGame()

void SteamDownloadMonitor::watchGame ( uint32_t appId)

Add a game to the watch list for progress updates.

Parameters
appIdSteam App ID to monitor

Definition at line 5101 of file steam_integration.cpp.

Referenced by operator=().


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