DeskUp 0.3
Loading...
Searching...
No Matches
DeskUpBackendInterface Struct Reference

Convenience façade for workspace-level window operations. More...

#include <desk_up_backend_interface.h>

Static Public Member Functions

static DeskUp::Status saveAllWindowsLocal (std::string workspaceName)
 Saves all currently enumerated windows to a local workspace folder.
static DeskUp::Status restoreWindows (std::string workspaceName)
 Restores all tabs saved previously in the workspace name specified by the parameter.
static bool isWorkspaceValid (const std::string &workspaceName)
 This function checks whether if a string is a valid name for a workspace folder.
static bool existsWorkspace (const std::string &workspaceName)
 This function checks whether if a given workspace with the name workspaceName already exists.
static int removeWorkspace (const std::string &workspaceName)
 This function deletes a workspace.
static bool existsFile (const fs::path &filePath)
 Checks whether a given file path exists on disk.

Detailed Description

Convenience façade for workspace-level window operations.

This lightweight façade exposes high-level operations that orchestrate the active backend device (see current_window_backend) to work with window snapshots and workspaces.

Error handling:

  • All functions now return DeskUp::Status or DeskUp::Result<T> values instead of throwing exceptions.
  • Each function propagates DeskUp::Error instances describing severity (Level) and category (ErrType).
  • Fatal errors stop the current operation immediately.
  • Retry and Warning levels are non-fatal and allow continuation.
See also
DU_Init
DESKUPDIR
current_window_backend
DeskUpWindowDevice::getAllOpenWindows
windowDesc
windowDesc::saveTo
Version
0.1.1
Date
2025

Member Function Documentation

◆ existsFile()

bool DeskUpBackendInterface::existsFile ( const fs::path & filePath)
static

Checks whether a given file path exists on disk.

Uses the C++17 <filesystem> library to test whether the file or directory specified by filePath exists in the current filesystem. Returns true if it exists, false otherwise.

Reads:

  • Filesystem state at the given filePath.
Parameters
filePathThe absolute or relative filesystem path to check.
Returns
true if the file or directory exists, false otherwise.
Note
This function is typically used when generating unique file names for saving window descriptors (to avoid overwriting files when multiple windows share the same name).
Version
0.1.1
Date
2025
Here is the caller graph for this function:

◆ existsWorkspace()

bool DeskUpBackendInterface::existsWorkspace ( const std::string & workspaceName)
static

This function checks whether if a given workspace with the name workspaceName already exists.

Checks whether <DESKUPDIR>/<workspaceName> exists and is a directory.

Reads:

  • Filesystem state under DESKUPDIR.
Parameters
workspaceNameName of the workspace folder to use under DESKUPDIR.
Returns
true if the workspace exists, false otherwise.
Note
Ensure DU_Init has been called successfully before invoking this method so that DESKUPDIR and current_window_backend are properly initialized.
Version
0.1.1
Date
2025
Here is the caller graph for this function:

◆ isWorkspaceValid()

bool DeskUpBackendInterface::isWorkspaceValid ( const std::string & workspaceName)
static

This function checks whether if a string is a valid name for a workspace folder.

A workspace name is invalid if it is empty or contains any of the following forbidden characters: \\ / : ? * " < > |.

Reads:

  • Pure string validation, does not access filesystem.
Parameters
workspaceNameName of the workspace to check.
Returns
true if the workspace name is valid, false otherwise.
Note
Ensure DU_Init has been called successfully before invoking this method so that DESKUPDIR and current_window_backend are properly initialized.
Version
0.1.1
Date
2025

◆ removeWorkspace()

int DeskUpBackendInterface::removeWorkspace ( const std::string & workspaceName)
static

This function deletes a workspace.

Removes <DESKUPDIR>/<workspaceName> recursively from disk. Returns 1 on success, 0 if the workspace does not exist or deletion failed.

Reads:

  • Filesystem state under DESKUPDIR.
Parameters
workspaceNameName of the workspace folder to use under DESKUPDIR.
Returns
1 if deleted, 0 otherwise.
Note
Ensure DU_Init has been called successfully before invoking this method so that DESKUPDIR and current_window_backend are properly initialized.
Version
0.1.1
Date
2025
Here is the call graph for this function:

◆ restoreWindows()

DeskUp::Status DeskUpBackendInterface::restoreWindows ( std::string workspaceName)
static

Restores all tabs saved previously in the workspace name specified by the parameter.

Iterates over all files in <DESKUPDIR>/<workspaceName> and, for each saved window:

  1. Loads the window description from file (recoverSavedWindow).
  2. Closes existing process instances of that executable (closeProcessFromPath).
  3. Launches a new process (loadWindowFromPath).
  4. Resizes the new window to the stored geometry (resizeWindow).

Non-fatal backend errors (Retry or Warning) are logged to console but do not abort the overall restore cycle. Fatal errors propagate as a failed DeskUp::Status.

Calls (indirectly through the backend):

Reads:

  • DESKUPDIR (workspace base directory).
Parameters
workspaceNameName of the workspace folder to use under DESKUPDIR.
Returns
DeskUp::Status — empty on success, or std::unexpected(DeskUp::Error) on failure.

@errors

  • Level::Fatal, ErrType::NotFound → Workspace directory missing.
  • Level::Fatal, ErrType::InvalidInput → Corrupted or incomplete window file.
  • Level::Retry, ErrType::NotFound → Process launched but no main HWND found.
  • Level::Warning → Individual window restore failed but continued.
Note
Ensure DU_Init has been called successfully before invoking this method so that DESKUPDIR and current_window_backend are properly initialized.
Version
0.1.1
Date
2025

◆ saveAllWindowsLocal()

DeskUp::Status DeskUpBackendInterface::saveAllWindowsLocal ( std::string workspaceName)
static

Saves all currently enumerated windows to a local workspace folder.

Builds <DESKUPDIR>/<workspaceName> and ensures the directory exists. Then asks the active backend device to enumerate all open windows and writes each window's description to an individual file using windowDesc::saveTo(). Non-fatal save errors are skipped; fatal ones abort the operation.

Calls (indirectly through the backend):

Reads:

  • DESKUPDIR (must have been set by a prior DU_Init call).
Parameters
workspaceNameName of the workspace folder to create/use under DESKUPDIR.
Returns
DeskUp::Status — empty on success, or std::unexpected(DeskUp::Error) on failure.

@errors

  • Level::Fatal, ErrType::Os or ErrType::InvalidInput → Enumeration or write failure.
  • Level::Warning → One or more windows skipped (non-fatal save errors).
  • Level::Retry → Temporary filesystem access problems.
Note
Ensure DU_Init has been called successfully before invoking this method so that DESKUPDIR and current_window_backend are properly initialized.
Version
0.1.1
Date
2025
Here is the call graph for this function:

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