/*! * * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file StorageGlobals.cpp * \author (last) Dara Navaei * \date (last) 07-Feb-2024 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ // Qt #include #include // Project #include "StorageGlobals.h" extern bool gEnableManufacturing ; extern bool gEnableUpdating ; extern bool gUseRootHome ; /*! * \brief Storage * \details The container of the constant global variable withing Storage namespace members. * For example it currently includes USB mount root folder and SD Card mount root folder and such, * which is used by Logger, DeviceController, ... . */ namespace Storage { const char *POST_LOG = "post.log"; // this file shall reside in the home folder where the application stored. // OS const quint16 OS_VERSION_MAJOR = 0; // DIALITY_VERSION_ID="0.0.40" const quint16 OS_VERSION_MINOR = 0; // DIALITY_VERSION_ID="0.0.40" const quint16 OS_VERSION_MICRO = 40; // DIALITY_VERSION_ID="0.0.40" // USB #ifdef BUILD_FOR_TARGET const char *USB_Mount_Point = "/media/usb/"; #else const char *USB_Mount_Point = "/home/denali/Desktop/usb-disk/"; #endif const char *USB_File_System = "vfat"; // SD-CARD // // Max Usage : 80 = 25 + 25 + 15 + 15 // // Max Used : 85 = 100 - 15 // // Min Buffer : 5 = 85 - 80 // IMPORTANT: we have to keep 10% buffer otherwise competition between filling and deleting logs will cause application to crash eventually. const short Log_Min_Available_Total_Space_Percent = 15; // Min free : 15 // always has to be 15 percent free space available, less than this triggers the log cleanup. const short Log_Max_Allowable_AppED_Space_Percent = 50; const short Log_Max_Allowable_Debug_Space_Percent = 15; const short Log_Max_Allowable_Cloud_Space_Percent = 15; short Log_Min_Available_Total_Space_IsLow(short vPercent) { return vPercent < Log_Min_Available_Total_Space_Percent; } // Settings/Encrypted // the settings are roughly using the 5MB round it to 8MB to be 25% of 32MB of total encrypted partition. // therefore the Txr shall not use more than 75% to leave the 25 for settings. // when reaches that percent will be deleted to get total usage of 50% // 50% percent of 32MB is 16MB which is enough to keep 10K (estimated each txr are 4K rounded to 5K and doubled.) of ~1600 files. const short Txr_Min_Available_Total_Space_Percent = 20; // min space needed for settings by the current definitions. const short Txr_Max_Allowable_Trtmt_Space_Percent = 50; // the treatment files are moved to the encrypted partition. short Txr_Min_Available_Total_Space_IsLow(short vPercent) { return vPercent < Txr_Min_Available_Total_Space_Percent; } #ifdef BUILD_FOR_TARGET const char *SDCard_Base_Path_Name = "/media/sd-card/"; #else // should not be in the project application folder. [not tracking by git] const char *SDCard_Base_Path_Name = "/home/denali/Desktop/sd-card/"; #endif // Screenshot store folder const char *Screenshot_Base_Path_Name = "Screenshots/"; // this is the base path which will use the USB_Mount_Point to store the screenshots. // Settings static bool settings_secured = false; const char *Settings_Path () { return gUseRootHome ? Settings_Path_Init : ( ( gEnableManufacturing || gEnableUpdating ) ? ( settings_secured ? Settings_Path_Name: Settings_Path_Init ) : Settings_Path_Name ); } void Settings_Secured() { settings_secured = true; } #ifdef BUILD_FOR_TARGET //WARNING: This has to match with the crypt_setup.sh const char *Settings_Path_Init = "/home/root/.config/"; // this is the manufacturing or update setup and the user is root. const char *Settings_Path_Name = "/var/configurations/"; #else // should be in the project application folder. [is tracking by git] const char *Settings_Path_Init = "/home/denali/Projects/application/resources/settings/"; const char *Settings_Path_Name = "/home/denali/Projects/application/resources/settings/"; #endif const char *Settings_Category_Instructions = "Instructions/Instructions"; const char *Settings_Category_InstructionsImagesLoc = "%1/Instructions/"; const char *Settings_Category_ConfigurationsDataList = "Configurations/DataList" ; const char *Settings_Category_Alarms = "Alarms/Alarms" ; const char *Settings_Category_Events = "Alarms/Events" ; const char *Settings_Category_MessagesUnhandled = "Messages/Unhandled" ; const char *Settings_Category_SettingsSystem = "Settings/System" ; const char *Settings_Category_NoCANBus = "Development/NoCANBus" ; const char *Settings_Category_GenericConfirm = "Confirm/Confirm" ; const char *Settings_Key_Title = "Title" ; const char *Settings_Key_Message = "Message" ; const char *Settings_Key_ListTitle = "ListTitle" ; const char *Settings_Key_Confirm = "Confirm" ; const char *Settings_Key_Cancel = "Cancel" ; // CloudSync credentials #ifdef BUILD_FOR_TARGET const char *CloudSync_Base_Path_Name = gUseRootHome ? "/home/root/.cloudSync/" : "/var/configurations/CloudSync/"; #else // on VM it is a temporary file which is not being tracked const char *CloudSync_Base_Path_Name = "/home/denali/Desktop/CloudSync/"; #endif #ifdef BUILD_FOR_TARGET const char *CloudSync_Credentials_Folder_Name = "credentials/"; #else // on VM it is a temporary file which is not being tracked const char *CloudSync_Credentials_Folder_Name = "credentials/"; #endif // Scripts const QString Scripts_Path_Name() { #ifdef BUILD_FOR_TARGET // lockdown script suppose to be the last thing to run, // and it is the lockdown.sh script which moves the scripts from root to denali home folder, // therefore in manufacturing or update mode we are still running scripts as root. return QCoreApplication::applicationDirPath() + ( ( gEnableManufacturing || gEnableUpdating )? "/scripts/" : "/scripts/"); #else return "/home/denali/Projects/application/scripts/"; #endif } // and it needs to be concatenated after SDCard_Base_Path_Name for each build configuration const char *Log_Folder_Base = SDCard_Base_Path_Name; // Base Log Folder const char *Log_Folder_Application = "log/" ; // Event/Data Log const char *Log_Folder_Service = "service/" ; // Service Log const char *Log_Folder_CloudSync = "cloudsync/log/" ; // CloudSync Log const char *gzipExt = ".gz" ; // GZip compressed file extension. // Txr_Max_Allowable_Trtmt_Space_Percent notice that is the folder not the path const char *Txr_Folder_Base = Settings_Path_Name ; // Base Txr Folder const char *Txr_Folder_Treatment = "treatment/" ; // Treatment Rep // TODO : These need to be removed from here because they are only used in their specific classes. // Date and Time const char *Date_Time_Set_Sh = "date_time_set.sh"; // WiFi Settings const char *Wifi_Disconnect_Network = "wifi_disconnect_network.sh"; const char *Wifi_Generate_WPA_Supplicant = "wifi_generate_wpa_supplicant.sh"; const char *Wifi_Read_DNS = "wifi_read_dns.sh"; const char *Wifi_Read_Gateway = "wifi_read_gateway.sh"; const char *Wifi_Read_IP_Settings = "wifi_read_ip_settings.sh"; const char *Wifi_Get_Auto_Assigned_IP = "wifi_request_auto_assigned_ip.sh"; const char *Wifi_Reset_Adapter = "wifi_reset_adapter.sh"; const char *Wifi_Reset_Interface = "wifi_reset_interface.sh"; const char *Wifi_Scan_For_Networks = "wifi_scan_for_networks.sh"; const char *Wifi_Set_Auto_Assigned_IP = "wifi_set_auto_assigned_ip.sh"; const char *Wifi_Set_DNS = "wifi_set_dns.sh"; const char *Wifi_Set_Static_IP = "wifi_set_static_ip.sh"; const char *Wifi_Set_Gateway = "wifi_set_gateway.sh"; const char *Wifi_Set_SubnetMask = "wifi_set_subnetmask.sh"; const char *Wifi_Start_WPA_Supplicant = "wifi_start_wpa_supplicant.sh"; const char *Wifi_Read_Network_Info = "wifi_read_network_info.sh"; // Brightness const char *Brightness_Set = "brightness_set.sh"; const char *Brightness_Get = "brightness_get.sh"; // Root SSH const char *RootSSHAccess = "rootsshaccess.sh"; // Bluetooth const char *Bluetooth_Paired_Reset = "bluetooth_paired_clear.sh"; const char *Bluetooth_Paired_Query = "bluetooth_paired_query.sh"; // Encrypted Partition - cryptsetup const char *Crypt_Setup = "crypt_setup.sh"; // Factory Reset const char *Factory_Reset = "factory_reset.sh"; // Device Decommissioning const char *Device_Decommission = "decommission.sh"; // Device Lockdown const char *Device_Lockdown = "lockdown.sh"; const char *CloudSyncPath = "/var/configurations/CloudSync/credentials/"; // USB unmount/ mount const char *USB_Unmount = "usb_unmount.sh"; const char *USB_Mount = "usb_mount.sh"; }