The Battle for Wesnoth  1.19.0-dev
Namespaces | Classes | Enumerations | Functions
desktop Namespace Reference

Namespaces

 apple
 
 battery_info
 
 clipboard
 
 notifications
 

Classes

struct  path_info
 
struct  bookmark_info
 

Enumerations

enum  GAME_PATH_TYPES {
  GAME_BIN_DIR = 0 , GAME_CORE_DATA_DIR = 1 , GAME_USER_PREFS_DIR = 2 , GAME_USER_DATA_DIR = 3 ,
  GAME_EDITOR_MAP_DIR = 4
}
 
enum  SYSTEM_PATH_TYPES { SYSTEM_ALL_DRIVES = 0 , SYSTEM_USER_PROFILE = 1 , SYSTEM_ROOTFS = 2 }
 

Functions

bool open_object ([[maybe_unused]] const std::string &path_or_url)
 
bool open_object (const std::string &path_or_url)
 Opens the specified object with the default application configured for its type. More...
 
constexpr bool open_object_is_supported ()
 Returns whether open_object() is supported/implemented for the current platform. More...
 
std::string user_profile_dir ()
 Returns the path to the user profile dir (e.g. More...
 
std::ostream & operator<< (std::ostream &os, const path_info &pinf)
 
std::vector< path_infogame_paths (std::set< GAME_PATH_TYPES > paths)
 Returns a list of game-related paths. More...
 
std::vector< path_infosystem_paths (std::set< SYSTEM_PATH_TYPES > paths)
 Returns a list of system-defined paths. More...
 
unsigned add_user_bookmark (const std::string &label, const std::string &path)
 
void remove_user_bookmark (unsigned index)
 
std::vector< bookmark_infouser_bookmarks ()
 
std::string os_version ()
 Returns a string with the running OS name and version information. More...
 

Enumeration Type Documentation

◆ GAME_PATH_TYPES

Enumerator
GAME_BIN_DIR 

Game executable dir.

GAME_CORE_DATA_DIR 

Game data dir.

GAME_USER_PREFS_DIR 

User preferences dir.

GAME_USER_DATA_DIR 

User data dir.

GAME_EDITOR_MAP_DIR 

Editor map dir.

Definition at line 56 of file paths.hpp.

◆ SYSTEM_PATH_TYPES

Enumerator
SYSTEM_ALL_DRIVES 

Paths for each storage media found (Windows), /media and/or /mnt (X11, if non-empty).

SYSTEM_USER_PROFILE 

Path to the user's profile dir (e.g.

/home/username or X:\Users\Username).

SYSTEM_ROOTFS 

Path to the root of the filesystem hierarchy (ignored on Windows).

Definition at line 65 of file paths.hpp.

Function Documentation

◆ add_user_bookmark()

unsigned desktop::add_user_bookmark ( const std::string &  label,
const std::string &  path 
)

◆ game_paths()

std::vector< path_info > desktop::game_paths ( std::set< GAME_PATH_TYPES paths)

Returns a list of game-related paths.

These paths are guaranteed to be their canonical forms (with links and dot entries resolved) and using the platform's preferred path delimiter.

Definition at line 198 of file paths.cpp.

References GAME_BIN_DIR, GAME_CORE_DATA_DIR, GAME_EDITOR_MAP_DIR, GAME_USER_DATA_DIR, GAME_USER_PREFS_DIR, filesystem::get_exe_dir(), filesystem::get_legacy_editor_dir(), filesystem::get_user_config_dir(), filesystem::get_user_data_dir(), GETTEXT_DOMAIN, N_, and game_config::path.

Referenced by gui2::dialogs::file_dialog::pre_show().

◆ open_object() [1/2]

bool desktop::open_object ( [[maybe_unused] ] const std::string &  path_or_url)

◆ open_object() [2/2]

bool desktop::open_object ( const std::string &  path_or_url)

Opens the specified object with the default application configured for its type.

The default application for handling the object represented by path_or_url is defined by the operating system and desktop environment under which Wesnoth is running, and it is not under our control. Therefore, EXTREME CAUTION is advised when using this function with URLs or paths that are entirely or partially constructed from user-provided input (e.g., WML from user-made add-ons, chat log messages).

If the content pointed to by path_or_url cannot be trusted, you should either refrain from using this function, or warn the user before calling this function.

Note
Currently, only X11, Apple OS X, and Microsoft Windows are supported. Using this function on unsupported platforms will result in an error message logged in stderr.
Returns
true on success, false otherwise. Failure to perform the platform call means either that we do not currently support the running platform, the child process exited with a non-zero status, or something else went wrong. Thus, a value of true does not truly guarantee success – take it with a grain of salt.

◆ open_object_is_supported()

constexpr bool desktop::open_object_is_supported ( )
constexpr

Returns whether open_object() is supported/implemented for the current platform.

Definition at line 54 of file open.hpp.

Referenced by gui2::dialogs::game_version::pre_show(), and gui2::label::signal_handler_left_button_click().

◆ operator<<()

std::ostream & desktop::operator<< ( std::ostream &  os,
const path_info pinf 
)

◆ os_version()

std::string desktop::os_version ( )

Returns a string with the running OS name and version information.

On Windows, this is a string we generate ourselves by processing GetVersionEx's output. On OS X and Linux, this is the output of a command provided by the OS if available; failing that (and on other Unixes as well), we use the uname system call, which is hardly ever useful.

Definition at line 216 of file version.cpp.

References _(), ERR_DU, filesystem::file_exists(), desktop::apple::os_version(), and p.

Referenced by game_config::full_build_report(), and gui2::dialogs::game_version::pre_show().

◆ remove_user_bookmark()

void desktop::remove_user_bookmark ( unsigned  index)

◆ system_paths()

std::vector< path_info > desktop::system_paths ( std::set< SYSTEM_PATH_TYPES paths)

Returns a list of system-defined paths.

This includes removable media on platforms where we can reasonably accurately enumerate those (FIXME: only Windows right now), the path to the user's profile directory (/home/username, X:\Users\Username, etc.), and the system drive root.

These paths are guaranteed to be their canonical forms (with links and dot entries resolved) and using the platform's preferred path delimiter.

Definition at line 231 of file paths.cpp.

References GETTEXT_DOMAIN, N_, SYSTEM_ALL_DRIVES, SYSTEM_ROOTFS, SYSTEM_USER_PROFILE, and user_profile_dir().

Referenced by gui2::dialogs::file_dialog::pre_show().

◆ user_bookmarks()

std::vector< bookmark_info > desktop::user_bookmarks ( )

Definition at line 279 of file paths.cpp.

References config::child_range(), and config::has_child().

Referenced by gui2::dialogs::file_dialog::pre_show().

◆ user_profile_dir()

std::string desktop::user_profile_dir ( )

Returns the path to the user profile dir (e.g.

/home/username).

An empty string is returned if the path cannot be determined somehow.

Definition at line 164 of file paths.cpp.

Referenced by system_paths().