NDEVR
API Documentation
ApplicationResource.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Base
28File: ApplicationResource
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/String.h>
35#include <NDEVR/BaseValues.h>
36#include <NDEVR/ApplicationOptions.h>
37#include <NDEVR/Resource.h>
38#include <NDEVR/PasswordString.h>
39#include <NDEVR/Time.h>
40namespace NDEVR
41{
42 class File;
43 class InfoPipe;
44 class RGBColor;
45 class INIFactory;
46 class Font;
47 class UUID;
48
54 {
55 public:
60 {
61 e_unknown
62 //GENERIC
63 , e_windows_generic
64 , e_linux_generic
65 , e_macOS_generic
66 , e_ios_generic
67 , e_android_generic
68 //WINDOWS
69 , e_windows_11
70 , e_windows_10
71 , e_windows_8
72 , e_windows_7
73 , e_windows_vista
74 , e_windows_server_2012
75 , e_windows_server_2008
76 , e_windows_xp
77 };
78 OSVersion os_version = OSVersion::e_unknown;
81 uint04 os_version_num = Constant<uint04>::Invalid;
82 uint04 os_sub_version_num = Constant<uint04>::Invalid;
83 uint04 os_revision_num = Constant<uint04>::Invalid;
84 };
85
91 {
92 public:
97 {
98 e_unknown
99 //GENERIC
100 , e_intel_generic
101 , e_nvidia_generic
102 , e_amd_generic
103 //NVIDIA
104 , e_nvidia_geforce
105 , e_nvidia_quadpro
106 , e_nvidia_titan
107 //AMD
108 };
109
118 VideoCardType card_type = VideoCardType::e_unknown;
119 uint04 config_manager_code = Constant<uint04>::Invalid;
120 uint04 video_memory = Constant<uint04>::Invalid;
121 uint04 architecture_id = Constant<uint04>::Invalid;
122 };
123
129 {
130 public:
133
134 uint04 oem_id = Constant<uint04>::Invalid;
135 uint04 num_of_processors = Constant<uint04>::Invalid;
136 uint04 page_size = Constant<uint04>::Invalid;
137 uint04 processor_type = Constant<uint04>::Invalid;
138 uint04 active_processor_mask = Constant<uint04>::Invalid;
139
140 uint08 memory_size = Constant<uint08>::Invalid;
141
143 bool is_valid = false;
144 };
145
150 class NDEVR_BASE_API ApplicationResource
151 {
152 public:
156 enum class InstanceType
157 {
158 e_system
159 , e_desktop
160 , e_session
161 , e_trustee
162 };
163
166 enum class ReleaseType
167 {
168 e_alpha = 0
169 , e_beta = 1
170 , e_release = 2
171 , e_lts_release = 3
172 , e_size
173 };
174
178 {
179 e_no_ui
180 , e_window_manager
181 , e_3D_window_manager
182 };
195 static Resource<UIMode> ui_mode;//Must be set before setupUI ///< The active user interface mode.
198 public:
203 static bool GlobalLock(StringView guid, InstanceType kind = InstanceType::e_system);
213 static UUID SessionID();
218 static Time BuildTime();
224 static String AppContextName(bool lower_case);
237 static Buffer<uint01> GetAppBundledResource(void* handle, const StringView& type, const StringView& name);
247 static bool IsFirstTimeRunning();
248
256
266 static bool SetupAsConsole(bool is_console);
277 static void OpenExplorerWindow(const StringView& location);
282 static void OpenFile(const File& file);
287 static void SendFile(const File& file);
292 static void ShareFileWithMediaServer(const File& file);
298 static void SetFolderIcon(const File& folder, const File& icon);
302 static void OpenOSWifiDialog();
308 static bool IsOSLanguageInstalled(String language);
312 static void OpenOSLanguageDialog();
320 static void OpenOSClockDialog();
324 static void OpenOSLocationDialog();
328 static void OpenOSPrinterDialog();
347 static void LogOSInformation(LogPtr log);
353 static void LogUserSettings(LogPtr log, bool log_only_non_defaults);
359 static void CloseApp(bool relaunch = false, const StringView& relaunch_options = "--relaunch");
363 static void FactoryResetApp();
368 static void SaveUserOptions(bool is_shutting_down);
372 static void ReadUserOptions();
404 };
405 template class NDEVR_BASE_API StringStream<ApplicationResource::ReleaseType>;
406};
The default object to store data of any type that should persist through sessions of the application.
High-Level functions for communicating with the operating system or getting general information about...
static Time SessionStartTime()
Returns the timestamp of when the current session started.
static HardwareInformation GetHardwareInformation()
Retrieves information about the system hardware.
static Time last_run_time
Timestamp of the previous application run.
static UUID SessionID()
Returns the unique identifier for the current application session.
static void ReadUserOptions()
Reads user options and settings from persistent storage.
static void SendFile(const File &file)
Sends a file using the OS sharing or email mechanism.
static void LogComputerInformation(LogPtr log)
Logs computer hardware information to the specified log.
UIMode
The user interface mode the application is running in.
static void CloseApp(bool relaunch=false, const StringView &relaunch_options="--relaunch")
Closes the application, optionally relaunching it with the given options.
static void OpenOSClockDialog()
Opens the operating system's clock or date/time settings dialog.
static ApplicationOption< bool > has_finished_initial_setup
Whether the first-time setup wizard has completed.
static bool SetupAsConsole(bool is_console)
Configures the application to run as a console (non-GUI) process.
static void OpenOSFileSystemDialog()
Opens the operating system's file system or storage management dialog.
static void SetFolderIcon(const File &folder, const File &icon)
Sets a custom icon for a folder in the OS file system.
static Resource< ReleaseType > release_type
The release maturity level of this build.
static void OpenOSBluetoothDialog()
Opens the operating system's Bluetooth settings dialog.
static void OpenExplorerWindow(const StringView &location)
Opens the operating system's file explorer at the specified location.
InstanceType
The scope or level at which a global lock is acquired.
static Resource< PasswordString > password
The logged-in user's password credential.
static Time BuildTime()
Returns the timestamp of when the application was built.
static TranslatedString GetLastErrorString()
Returns a translated description of the last system error.
static TranslatedString GetErrorString(sint08 result)
Returns a translated error description for the given error code.
static Resource< String > user_email
The logged-in user's email address.
static void LogApplicationInformation(LogPtr log)
Logs general application information to the specified log.
static Resource< String > username
The logged-in user's username.
static Buffer< VideoCardInformation > GetVideoCardInfo()
Retrieves information about all detected video cards in the system.
static File GetDefaultOSApplicationForExtension(const StringView &extension)
Returns the default OS application registered for the given file extension.
static void SaveUserOptions(bool is_shutting_down)
Saves all user options and settings to persistent storage.
static TranslatedString ApplicationNameAndVersion()
Returns the translated application name combined with the version string.
static bool IsOSLanguageInstalled(String language)
Checks whether a given language is installed on the operating system.
static OSInformation GetOSInformation()
Retrieves information about the current operating system.
static String OSUserName()
Returns the current operating system user name.
static uint04 RecommendedThreadCount()
Returns the recommended number of threads based on the system hardware.
static Resource< TranslatedString > application_name
The display name of the application.
static void ShareFileWithMediaServer(const File &file)
Shares a file with the platform's media server or sharing service.
static Buffer< uint01 > GetAppBundledResource(void *handle, const StringView &type, const StringView &name)
Retrieves an embedded resource from the application bundle.
static bool last_proper_shutdown
Cached value of whether the previous session shut down properly.
static bool IsFirstTimeRunning()
Checks whether this is the first time the application has been run.
static ApplicationOption< String > last_application_version
The version string from the previous application run.
static void OpenOSLocationDialog()
Opens the operating system's location services settings dialog.
static void FactoryResetApp()
Resets the application to its factory default state.
static bool GlobalLock(StringView guid, InstanceType kind=InstanceType::e_system)
Attempts to lock on a guid that is shared across applications.
static String AppContextName(bool lower_case)
Returns the application context name, optionally in lower case.
static Resource< String > application_version
The current version string of the application.
static void OpenOSWifiDialog()
Opens the operating system's Wi-Fi settings dialog.
static ApplicationOption< bool > proper_shutdown
Whether the application shut down properly last time.
static void OpenOSPrinterDialog()
Opens the operating system's printer settings dialog.
ReleaseType
The release maturity level of the application build.
static Resource< String > activation_code
The license activation code for the application.
static Resource< Buffer< String > > startup_options
Command-line options passed at application startup.
static void OpenFile(const File &file)
Opens a file using the default OS application associated with its type.
static void LogOSInformation(LogPtr log)
Logs operating system information to the specified log.
static String ApplicationDisplayName()
Returns the translated application name plus (beta) or (alpha) depending on the type.
static ApplicationOption< Time > current_run_time
The timestamp of the current application run.
static String MakeSafeForCommandLine(StringView var)
Takes a string which may have spaces, etc, and wraps it as needed such that it is safe to execute on ...
static void OpenOSLanguageDialog()
Opens the operating system's language settings dialog.
static void LogUserSettings(LogPtr log, bool log_only_non_defaults)
Logs user settings to the specified log.
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
Information for how to display text data.
Definition Font.h:46
Contains information about a computer or device that is capable of running software typically with a ...
uint04 processor_type
Processor type identifier.
bool is_valid
Whether the hardware information was successfully retrieved.
uint04 num_of_processors
Number of logical processors in the system.
Buffer< VideoCardInformation > video_card_information
Information about all detected video cards.
String manufacturer
Hardware manufacturer name.
uint04 active_processor_mask
Bitmask of active processor cores.
uint04 oem_id
OEM identifier for the system.
uint08 memory_size
Total physical memory size in bytes.
String model
Hardware model name or number.
uint04 page_size
System memory page size in bytes.
Contains methods for easily reading and writing to an INI file including efficient casting,...
Definition INIReader.h:107
A light-weight base class for Log that allows processes to update, without the need for additional in...
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
Contains information about an Operating System including versions and types.
uint04 os_revision_num
Revision or build number of the OS.
OSVersion os_version
The detected OS version identifier.
String os_service_pack_name
Name of the installed service pack, if any.
OSVersion
Known operating system version identifiers.
String os_version_name
Human-readable name of the OS version.
uint04 os_sub_version_num
Minor (sub) version number of the OS.
uint04 os_version_num
Major version number of the OS.
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
Definition Resource.h:42
Logic for reading or writing to a string or a user friendly, TranslatedString.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
Contains information about a video card, including manufacturer and some level of capabilities.
String device_name
Display name of the video card device.
String adapter_dac_type
Digital-to-analog converter type of the adapter.
uint04 config_manager_code
Configuration manager error code from the OS.
String device_id
Unique device identifier string.
uint04 architecture_id
Numeric identifier for the GPU architecture.
VideoCardType
Known video card manufacturer and product line identifiers.
VideoCardType card_type
The detected video card type identifier.
String video_mode_description
Description of the current video mode (resolution, color depth, etc.).
String config_manager_string
Configuration manager status string from the OS.
String video_processor
Name of the video processor chip.
String driver_version
Installed driver version string.
uint04 video_memory
Amount of video memory in bytes.
String architecture_name
Name of the GPU architecture.
The primary namespace for the NDEVR SDK.
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
@ e_size
Number of entries in this enum; used for iteration.
Definition GPSPoint.h:26
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...