/*! * * 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; } const char *Configurations_Path() { #ifdef BUILD_FOR_TARGET return QString(QCoreApplication::applicationDirPath() + "/").toLatin1().constData(); #else return "/home/denali/Desktop/"; #endif } const char *Translations_Path() { #ifdef BUILD_FOR_TARGET return QString(QCoreApplication::applicationDirPath() + "/").toLatin1().constData(); #else return "/home/denali/Projects/application/resources/"; #endif } #ifdef BUILD_FOR_TARGET //WARNING: This has to match with the crypt_setup.sh #ifdef LEAHI_DIGI_BOARD const char *Settings_Path_Init = "/opt/leahi/configurations/"; // this is the manufacturing or update setup and the user is root. const char *Settings_Path_Name = "/opt/leahi/configurations/"; // "/mnt/data/configurations/"; Need to be designed later, but it is going to be the location after the files are secured. #else 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/"; #endif #else // should be in the project application folder. [is tracking by git] const char *Settings_Path_Init = "/home/denali/Public/luis/application/config/configurations/"; const char *Settings_Path_Name = "/home/denali/Public/luis/application/config/configurations/"; #endif const char *Settings_Category_Instructions = "Instructions/Instructions" ; const char *Settings_Category_InstructionsImagesLoc = "%1/Instructions/" ; const char *Settings_Category_DataList = "Parameters/DataList" ; const char *Settings_Category_Alarms = "Alarms/Alarms" ; const char *Settings_Category_AlarmsImagesLoc = "%1/Alarms/" ; const char *Settings_Category_Events = "Alarms/Events" ; const char *Settings_Category_Rejects = "Alarms/Rejections" ; const char *Settings_Category_MessagesUnhandled = "Messages/Unhandled" ; const char *Settings_Category_SettingsSystem = "Settings/System" ; const char *Settings_Category_GenericConfirm = "Confirm/Confirm" ; const char *Settings_Category_Translation = "translations/translation" ; // in qrc const char *Settings_Category_Locale = "settings/locale" ; // in app location // common key.value pairs 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 #ifdef LEAHI_DIGI_BOARD const char *CloudSync_Base_Path_Name = gUseRootHome ? "/home/root/.cloudSync/" : "/mnt/data/configurations/CloudSync/"; #else const char *CloudSync_Base_Path_Name = gUseRootHome ? "/home/root/.cloudSync/" : "/var/configurations/CloudSync/"; #endif #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 // 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 *Scripts_Wifi_Scan = "wifi_scan.sh"; const char *Scripts_Wifi_Info = "wifi_info.sh"; const char *Scripts_Wifi_Connect = "wifi_connect.sh"; const char *Scripts_Wifi_Disconnect = "wifi_disconnect.sh"; const char *Scripts_Wifi_Active_Info = "wifi_active_info.sh"; const char *Scripts_Wifi_Connect_Dhcp = "wifi_connect_dhcp.sh"; // Brightness const char *Scripts_Brightness = "brightness.sh"; // Root SSH const char *Scripts_Ssh_Access = "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 *Scripts_Factory_Reset = "factory_reset.sh"; // Device Decommissioning const char *Scripts_Device_Decommission = "decommission.sh"; // Device Lockdown const char *Scripts_Device_Lockdown = "lockdown.sh"; #ifdef LEAHI_DIGI_BOARD const char *CloudSyncPath = "/mnt/data/configurations/CloudSync/credentials/"; #else const char *CloudSyncPath = "/var/configurations/CloudSync/credentials/"; #endif // USB unmount/ mount const char *Scripts_USB_Unmount = "usb_unmount.sh"; const char *Scripts_USB_Mount = "usb_mount.sh"; }