Operating System Simulator Plugin  3.5.1
Unreal Engine plugin that simulates an Operating System Environment
Loading...
Searching...
No Matches
UOperatingSystemUnix Class Reference

Class that represents a Unix-based operating system in the Operating System Simulator. This class is a child class of UOperatingSystem and provides additional functionality specific to Unix systems. More...

#include "OperatingSystemUnix.h"

Inheritance diagram for UOperatingSystemUnix:
[legend]
Collaboration diagram for UOperatingSystemUnix:
[legend]

Public Member Functions

 UOperatingSystemUnix ()
 
virtual UOperatingSystemDirectoryCreateDirectoryInPath (const FString &TargetPath, const FString &DirectoryName, TSoftClassPtr< UOperatingSystemDirectory > DirectoryClass, UOperatingSystemPartition *TargetPartition, const bool bIsFromSaveGame, FGenericError &OutError) override
 
const TSet< TSoftObjectPtr< UOperatingSystemProgramsCollection > > & GetRepositoryClasses () const
 Retrieves the repository classes in the Operating System Simulator.
 
- Public Member Functions inherited from UOperatingSystem
template<class T >
T * GetAs () const
 Get a pointer to the object casted as type T.
 
template<class T >
FORCEINLINE const T * GetAsConst () const
 Get a pointer to the object casted as type T.
 
OPERATINGSYSTEMSIMULATOR_API bool AddNotification (const FOperatingSystemNotification &NewNotification)
 Adds a notification to the operating system.
 
OPERATINGSYSTEMSIMULATOR_API bool AddNotification (const FGenericError &GenericError, const EOperatingSystemNotificationCategory &Category, const EOperatingSystemNotificationType Verbosity=EOperatingSystemNotificationType::Error)
 Adds a notification to the operating system. This method allows adding a notification to the operating system with the specified error, category, and verbosity.
 
void StartOperatingSystem (const TWeakObjectPtr< const UOperatingSystemSaveGame > LoadGameInstance, FGenericError &OutError)
 Start the operating system. This method starts the operating system. It performs the necessary initialization and loads the settings and programs.
 
void PostLoadOperatingSystem ()
 Calls the PostLoadOperatingSystemImpl method and handles any error that occurs.
 
void FinishInstallation ()
 Finish the installation of the operating system.
 
void InstallStartupPrograms ()
 Install the startup programs for the operating system.
 
void ShutdownOS ()
 Shuts down the operating system.
 
void RestartOS ()
 Restarts the operating system.
 
void DestroyOS ()
 Destroys the operating system instance.
 
int32 AddRunningProgram (UOperatingSystemBaseProgram *NewProgram, FGenericError &OutError)
 Adds a running program to the operating system.
 
void ProgramStarted (UOperatingSystemBaseProgram *StartedProgram, const bool bIsRestored)
 Notifies the operating system that a program has started.
 
bool IsProgramRunning (const TWeakObjectPtr< const UOperatingSystemBaseProgram > TestProgram) const
 Check if a program is running.
 
bool IsProgramRunning (const TSubclassOf< UOperatingSystemBaseProgram > TestProgramClass) const
 Checks if a program of the specified class is currently running.
 
UDraggableWindowCreateNewWindow (TWeakObjectPtr< UOperatingSystemBaseProgram > TargetProgram) const
 Creates a new window for the target program.
 
void BringWindowToFront (UDraggableWindow *TargetWindow)
 Bring the specified window to the front.
 
bool CreateProgramsFromRepository (const TSoftObjectPtr< UOperatingSystemProgramsCollection > &TargetRepository, const bool bIsInstalledWithOS)
 Create programs from a given repository.
 
void SetToInstallStartupPrograms (const bool bInstall)
 
bool ShouldInstallStartupPrograms () const
 
void SetDeviceName (const FText &NewName)
 
FText GetDeviceName () const
 
void SetAutoLogin (const bool bEnableAutoLogin)
 
bool CanAutoLogin () const
 
float GetInstallationTime () const
 
float GetLoadingTime () const
 
float GetInitialLoadingTime () const
 
const TArray< FOperatingSystemNotification > & GetNotifications () const
 
void ClearAllNotifications ()
 
OPERATINGSYSTEMSIMULATOR_API void ConsumeSpaceInMB (const float &NewSizeInMB, UOperatingSystemPartition *Partition, FGenericError &OutError)
 
OPERATINGSYSTEMSIMULATOR_API void ConsumeSpaceInGB (const float &NewSizeInGB, UOperatingSystemPartition *Partition, FGenericError &OutError)
 
OPERATINGSYSTEMSIMULATOR_API FText GetSizeAsText (const EOperatingSystemSizeMethod SizeMethod, const UOperatingSystemPartition *Partition, FGenericError &OutError) const
 
OPERATINGSYSTEMSIMULATOR_API float GetStoragePercentage (const UOperatingSystemPartition *Partition, FGenericError &OutError) const
 
OPERATINGSYSTEMSIMULATOR_API double GetHardDiskSize (FGenericError &OutError, const EOperatingSystemSizeMethod SizeMethod=EOperatingSystemSizeMethod::GB) const
 
void UninstallProgram (const FName &ProgramIdentifier, FGenericError &OutErrorIfAny)
 
void UninstallProgramByClass (const TSoftClassPtr< UOperatingSystemBaseProgram > ProgramClass, FGenericError &OutErrorIfAny)
 
UOperatingSystemBaseProgramInstallProgramFromPackage (const FName &ProgramIdentifier, FGenericError &OutErrorIfAny)
 
UOperatingSystemBaseProgramInstallProgramFromClass (FGenericError &OutErrorIfAny, const TSoftClassPtr< UOperatingSystemBaseProgram > ProgramClass, UOperatingSystemPartition *TargetPartition=nullptr)
 
void BeginInstallation (UOperatingSystemPartition *TargetPartition, FGenericError &OutError)
 
UOperatingSystemPartitionAllocatePartition (const double SizeInBytes, FGenericError &OutError)
 
void RemovePartition (UOperatingSystemPartition *PartitionToDelete, FGenericError &OutError)
 
void RefreshPartitions ()
 
void InstallationCompleted (const bool bSwitchToDesktop=true)
 
bool CreateNewUser (const FOperatingSystemUser &NewUser, const bool bSetAsActive=false)
 
bool LoginUser (const FText &Username, const FText &Password)
 
bool UpdateCurrentUserDetails (const FOperatingSystemUser &UpdatedDetails)
 
bool HasEnoughSpace (const double &TestSizeInBytes, const UOperatingSystemPartition *InPartition) const
 
TArray< UOperatingSystemPartition * > GetDiskPartitions () const
 
UOperatingSystemPartitionGetOperatingSystemPartition () const
 
void CloseProgram (UOperatingSystemBaseProgram *TargetProgram, FGenericError &OutError)
 
bool BringBackgroundProgramToFront (UOperatingSystemBaseProgram *TargetProgram)
 
bool IsProgramInBackground (UOperatingSystemBaseProgram *TestProgram) const
 
void MinimizeProgram (UOperatingSystemBaseProgram *TargetProgram)
 
void CloseAllRunningPrograms ()
 
void RestoreMinimizedProgram (const UOperatingSystemBaseProgram *TargetProgram)
 Restores a minimized program to the foreground on the operating system's taskbar.
 
UObject * GetDirectoryIconObject (const FGameplayTag &TestTag) const
 
bool IsUnix () const
 
float GetBsodOnScreenTime () const
 
float GetToastNotificationDisplayTime () const
 
TArray< UOperatingSystemBaseProgram * > GetInstalledPrograms () const
 
void GetInstalledProgramsMap (TMap< FName, UOperatingSystemBaseProgram * > &OutInstalledPrograms)
 
UOperatingSystemBaseProgramGetInstalledProgram (const TSoftClassPtr< UOperatingSystemBaseProgram > TestClass) const
 
bool IsProgramInstalled (const TSoftClassPtr< UOperatingSystemBaseProgram > TestClass) const
 
UOperatingSystemBaseProgramGetRunningProgram (const TSoftClassPtr< UOperatingSystemBaseProgram > TestClass) const
 
bool IsPreInstalledOperatingSystem () const
 
UOperatingSystemSettingsDataGetSettings () const
 
bool IsRunningOnPortableDevice () const
 
virtual UOperatingSystemPartitionFindPartitionFromLetter (const FName &TargetDiskLetter) const
 Find a partition in the operating system from a given disk letter.
 
bool HasValidRootCommandAndUser () const
 Determines whether the root command and user are valid.
 
bool IsShuttingDown () const
 Check if the operating system is in the process of shutting down.
 
bool IsRestarting () const
 Checks if the operating system is currently restarting.
 
TArray< FOperatingSystemUserGetAllUsers () const
 Returns an array of all users registered in the operating system. This function retrieves information about all users registered in the operating system.
 

Protected Member Functions

virtual void OnValidate (FGenericError &OutError) const override
 Validates the Unix-based operating system.
 
virtual void FinalizePreInstallation (FGenericError &OutError) override
 Finalizes the pre-installation process for a Unix-based operating system.
 
virtual void PrepareOperatingSystemInstallImpl (FGenericError &OutError) override
 PrepareOperatingSystemInstallImpl function prepares the Unix-based operating system for installation.
 
virtual bool StartOperatingSystemImpl (FGenericError &OutError) override
 Starts the Unix-based operating system.
 
virtual void PostLoadOperatingSystemImpl (FGenericError &OutError) override
 Executes additional post-loading operations specific to Unix-based operating systems.
 
virtual TOptional< FText > GetRootCommand () const override final
 Gets the root command for the Unix-based operating system.
 
virtual TOptional< FOperatingSystemUserGetRootUser () const override final
 Retrieves the root user of the Unix-based operating system.
 
virtual TSoftClassPtr< UOperatingSystemBaseProgramFindProgramFromPackage (const FName &ProgramIdentifier) override
 Finds a program from a package based on its identifier.
 
bool CreateRootDirectory (const bool bIsFromSaveGame)
 Creates the root directory for the Unix-based operating system if it does not already exist. The root directory is determined by finding the Unix root directory among all the available directories. If the root directory exists, this method returns true. Otherwise, it attempts to create the root directory using the first directory with the tag "Root". If the root directory is successfully created, this method returns true. Otherwise, it returns false.
 
- Protected Member Functions inherited from UOperatingSystem
virtual OPERATINGSYSTEMSIMULATOR_API void OnShowNotification (const FOperatingSystemNotification &NewNotification)
 This method is called when a new notification should be shown on the operating system.
 
virtual OPERATINGSYSTEMSIMULATOR_API void OnAllOnNotificationsCleared ()
 Callback triggered when all notifications are cleared.
 
virtual OPERATINGSYSTEMSIMULATOR_API void FinishInstallationImpl ()
 Performs the finishing steps of the installation process.
 
virtual OPERATINGSYSTEMSIMULATOR_API void InstallStartupProgramsImpl ()
 Allows the derived classes to implement their own logic for installing startup programs. This method should be overridden in derived classes to define the actual logic for installing startup programs.
 
virtual OPERATINGSYSTEMSIMULATOR_API void OnPartitionLoaded (UOperatingSystemPartition &LoadedPartition, const FOperatingSystemPartitionSaveLoad &SaveLoadData)
 Callback method called when a partition is loaded.
 
bool K2_CanStartOperatingSystem (FGenericError &ReturnError)
 Determines if the operating system can start.
 

Protected Attributes

FOperatingSystemUser RootUser
 
FText RootCommand
 
TSet< TSoftObjectPtr< UOperatingSystemProgramsCollection > > RepositoryClasses
 
- Protected Attributes inherited from UOperatingSystem
FTimerHandle TimerHandle_OperatingSystemInstallation
 
FTimerHandle TimerHandle_LoadingTime
 
FText Name
 
FText CompanyName
 
FOperatingSystemVersion Version
 
TSoftObjectPtr< UObject > Icon
 
TMap< FGameplayTag, TSoftObjectPtr< UObject > > DirectoryIcons
 
float InstallationSpace
 
FGameplayTagContainer SupportedDevices
 
TSoftObjectPtr< UOperatingSystemProgramsCollectionMustHavePrograms
 
TSoftObjectPtr< UOperatingSystemProgramsCollectionPostInstallStartupPrograms
 
TSoftObjectPtr< UOperatingSystemDirectoriesCollectionDefaultDirectories
 
TSoftClassPtr< UOperatingSystemSettingsDataSettingsDataClass
 
TSoftClassPtr< UOperatingSystemWidgetWidgetClass
 
TSoftClassPtr< UOperatingSystemBsodWidgetBsodWidgetClass
 
FOperatingSystemNotificationSettings NotificationSettings
 
FOperatingSystemRangeTime InstallationTime
 
FOperatingSystemRangeTime LoadingTime
 
FOperatingSystemRangeTime LoadingTimeInitial
 
FOperatingSystemRangeTime LogonToDesktopTime
 
FOperatingSystemRangeTime BsodOnScreenTime
 
FGameplayTag OperatingSystemTag
 
TWeakObjectPtr< UOperatingSystemBaseDeviceParentDevice
 
TObjectPtr< UOperatingSystemSettingsDataOperatingSystemSettingsData
 
TObjectPtr< UOperatingSystemWidgetOperatingSystemWidget
 
TMap< int32, TObjectPtr< UOperatingSystemBaseProgram > > RunningPrograms
 
TMap< int32, TObjectPtr< UOperatingSystemBaseProgram > > BackgroundRunningPrograms
 
TMap< FName, UOperatingSystemBaseProgram * > InstalledPrograms
 
FOperatingSystemUser CurrentUser
 
uint8 bIsStartingForTheFirstTime: 1
 
int32 TotalNotifications
 
int32 TotalErrorNotifications
 
int32 TotalWarningNotifications
 
TObjectPtr< UOperatingSystemBsodWidgetBSODWidget
 
TMap< int32, TWeakObjectPtr< UOperatingSystemTaskbarButton > > TaskbarButtons
 Transient variable representing the taskbar buttons. It is a TMap that associates integer keys with weak object pointers to UOperatingSystemTaskbarButton objects. Key will be the process ID. Value will be the program.
 
FOperatingSystemUniqueId TargetPartitionID
 Structure representing a unique identifier for a target partition in the operating system.
 
TWeakObjectPtr< UDraggableWindowLastBroughtToFrontWindow
 Transient variable representing the last draggable window brought to the front.
 
uint8 bAutoLogin: 1
 
uint8 bInstallStartupPrograms: 1
 Specifies whether to install startup programs on the operating system.
 
FText DeviceName
 

Additional Inherited Members

- Static Public Member Functions inherited from UOperatingSystem
static FName GetOperatingSystemProgramRestoredEventName ()
 
static UE_NODISCARD UOperatingSystemCreateOperatingSystem (UOperatingSystemBaseDevice *OwningDevice, FGenericError &OutError)
 Creates a new instance of the operating system associated with the specified device.
 
static UE_NODISCARD FString GetOperatingSystemUniqueID (const UOperatingSystem *TestOperatingSystem)
 Gets the unique ID of the operating system. This method retrieves the unique ID of the operating system represented by the given TestOperatingSystem object.
 
- Public Attributes inherited from UOperatingSystem
FOperatingSystemProgramDelegate OnProgramStarted
 Delegate representing the event when a program starts in the operating system.
 
FOperatingSystemProgramDelegate OnProgramClosed
 Delegate for handling the program closed event.
 
FOperatingSystemProgramDelegate OnProgramInstalled
 Delegate representing the event when a program is installed in the operating system.
 
FOperatingSystemProgramDelegate OnProgramUninstalled
 

Detailed Description

Class that represents a Unix-based operating system in the Operating System Simulator. This class is a child class of UOperatingSystem and provides additional functionality specific to Unix systems.

Constructor & Destructor Documentation

◆ UOperatingSystemUnix()

UOperatingSystemUnix::UOperatingSystemUnix ( )

Member Function Documentation

◆ CreateDirectoryInPath()

UOperatingSystemDirectory * UOperatingSystemUnix::CreateDirectoryInPath ( const FString & TargetPath,
const FString & DirectoryName,
TSoftClassPtr< UOperatingSystemDirectory > DirectoryClass,
UOperatingSystemPartition * TargetPartition,
const bool bIsFromSaveGame,
FGenericError & OutError )
overridevirtual

Creates a directory within a given path.

This method creates a directory with the specified name within the given target path. If the target path is the special root directory name, it creates the root directory and returns it. Otherwise, it iterates through the path array in reverse order and checks if the new directory exists. If the new directory does not exist, it creates the directory and returns it. If the new directory exists and its name matches the specified directory name, it returns the new directory. Otherwise, it updates the current directory to the new directory and continues the iteration.

Parameters
TargetPathThe target path where the directory will be created.
DirectoryNameThe name of the directory to be created.
DirectoryClassThe class pointer of the directory to be created.
TargetPartitionThe target partition where the directory will be added.
bIsFromSaveGameIndicates whether the directory is from a save game.
OutErrorThe reference to the error object that will hold the error message in case of failure.
Returns
The created directory if successful, or nullptr if an error occurs.

Reimplemented from UOperatingSystem.

Here is the call graph for this function:

◆ CreateRootDirectory()

bool UOperatingSystemUnix::CreateRootDirectory ( const bool bIsFromSaveGame)
protected

Creates the root directory for the Unix-based operating system if it does not already exist. The root directory is determined by finding the Unix root directory among all the available directories. If the root directory exists, this method returns true. Otherwise, it attempts to create the root directory using the first directory with the tag "Root". If the root directory is successfully created, this method returns true. Otherwise, it returns false.

Parameters
bIsFromSaveGameA boolean indicating whether the root directory is being created from a save game.
Returns
A boolean indicating whether the root directory was successfully created or already exists. Returns true if the root directory exists or was created successfully, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FinalizePreInstallation()

void UOperatingSystemUnix::FinalizePreInstallation ( FGenericError & OutError)
overrideprotectedvirtual

Finalizes the pre-installation process for a Unix-based operating system.

This method is called to finalize the pre-installation process for a Unix-based operating system. It allocates a new partition on the target hard disk and begins the installation process on the new partition. After this, it clears the installation timer and finishes the installation.

Parameters
OutErrorThe reference to the error object that will hold the error message in case of failure.

Reimplemented from UOperatingSystem.

Here is the call graph for this function:

◆ FindProgramFromPackage()

TSoftClassPtr< UOperatingSystemBaseProgram > UOperatingSystemUnix::FindProgramFromPackage ( const FName & ProgramIdentifier)
overrideprotectedvirtual

Finds a program from a package based on its identifier.

This method searches for a program with the given identifier in the repository classes of the Unix-based operating system. If a program is found with the matching identifier, it returns a soft class pointer to the program's class. Otherwise, it returns nullptr.

Parameters
ProgramIdentifierThe identifier of the program to search for.
Returns
A soft class pointer to the program's class if found, nullptr otherwise.

Reimplemented from UOperatingSystem.

◆ GetRepositoryClasses()

const TSet< TSoftObjectPtr< UOperatingSystemProgramsCollection > > & UOperatingSystemUnix::GetRepositoryClasses ( ) const
inline

Retrieves the repository classes in the Operating System Simulator.

This method returns the set of repository classes, represented by TSoftObjectPtr<UOperatingSystemProgramsCollection>.

Returns
The set of repository classes in the Operating System Simulator.
Here is the caller graph for this function:

◆ GetRootCommand()

TOptional< FText > UOperatingSystemUnix::GetRootCommand ( ) const
finaloverrideprotectedvirtual

Gets the root command for the Unix-based operating system.

This method returns the root command for the Unix-based operating system. If the root command is empty or consists of only white space, the method returns an empty optional.

Returns
The root command for the Unix-based operating system, or an empty optional if the root command is empty or consists of only white space.

Reimplemented from UOperatingSystem.

◆ GetRootUser()

TOptional< FOperatingSystemUser > UOperatingSystemUnix::GetRootUser ( ) const
finaloverrideprotectedvirtual

Retrieves the root user of the Unix-based operating system.

This method returns an optional object containing the root user of the Unix-based operating system.

Note
If the root user has already been retrieved, the method returns the cached user object.
If the root user has not been retrieved, the method creates a new user object with the username "root" and the password "toor".
Returns
An optional object containing the root user of the Unix-based operating system.

Reimplemented from UOperatingSystem.

Here is the call graph for this function:

◆ OnValidate()

void UOperatingSystemUnix::OnValidate ( FGenericError & OutError) const
overrideprotectedvirtual

Validates the Unix-based operating system.

This method validates various properties of the Unix-based operating system. It checks if the root command is valid and not empty. If it is empty, an error message is generated. It also checks if at least one repository class is provided. If not, an error message is generated. It then checks if any of the repository classes are null. If all repository classes are null, an error message is generated. Finally, it checks if the root directory is set. If the root directory is not set, an error message is generated.

Parameters
OutErrorThe reference to the error object that will hold the error message in case of validation failure.

Reimplemented from UOperatingSystem.

◆ PostLoadOperatingSystemImpl()

void UOperatingSystemUnix::PostLoadOperatingSystemImpl ( FGenericError & OutError)
overrideprotectedvirtual

Executes additional post-loading operations specific to Unix-based operating systems.

This method is called after the operating system has finished loading. It performs additional operations that are specific to Unix-based operating systems.

If the operating system is starting for the first time or if the current user is not valid, the method will show the initial startup screen.

If the current user's password is empty or if the device startup type is FullBoot, the method will switch to the desktop tab.

Otherwise, the method will show the logon screen.

Parameters
OutErrorThe error message in case of any failure during post-loading operations.

Reimplemented from UOperatingSystem.

◆ PrepareOperatingSystemInstallImpl()

void UOperatingSystemUnix::PrepareOperatingSystemInstallImpl ( FGenericError & OutError)
overrideprotectedvirtual

PrepareOperatingSystemInstallImpl function prepares the Unix-based operating system for installation.

This method is called to prepare the Unix-based operating system for installation. It adds a notification to indicate the start of the installation, and calls the PrepareToInstall function of the OperatingSystemWidget.

Parameters
OutErrorThe reference to the error object that will hold the error message in case of failure.

Reimplemented from UOperatingSystem.

Here is the call graph for this function:

◆ StartOperatingSystemImpl()

bool UOperatingSystemUnix::StartOperatingSystemImpl ( FGenericError & OutError)
overrideprotectedvirtual

Starts the Unix-based operating system.

This method is responsible for starting the Unix-based operating system. It performs necessary initialization tasks such as creating the root directory and checking for the presence of the desktop directory. It also sets the disk letter for the disk partition associated with the operating system.

Parameters
OutErrorA reference to an FGenericError object that will be populated with error details if the operating system fails to start.
Returns
True if the operating system starts successfully, false otherwise.

Reimplemented from UOperatingSystem.

Here is the call graph for this function:

Member Data Documentation

◆ RepositoryClasses

TSet<TSoftObjectPtr<UOperatingSystemProgramsCollection> > UOperatingSystemUnix::RepositoryClasses
protected

Simulates the effect of sudo apt-get stuff. You can add as many classes you want and even let users add their own repository via terminal.

◆ RootCommand

FText UOperatingSystemUnix::RootCommand
protected

Root command name. Defaults to sudo.

◆ RootUser

FOperatingSystemUser UOperatingSystemUnix::RootUser
protected

Root user for this Operating System.


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