/*! * * Copyright (c) 2020-2023 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) Behrouz NematiPour * \date (last) 25-Jul-2023 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ // Qt #include #include // Project #include "StorageGlobals.h" extern bool gEnableManufacturing ; 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 { /****** TO BE CONSISTENT, ALWAYS INCLUDE '/' AT THE END OF ALL THE FOLDER/DIR/PATH IN HERE ******/ const char *Standard_tmp = "/tmp/"; const char *POST_LOG = "post.log"; // this file shall reside in the home folder where the application stored. // 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 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_Event_Space_Percent = 25; const short Log_Max_Allowable_Datum_Space_Percent = 25; const short Log_Max_Allowable_AppED_Space_Percent = Log_Max_Allowable_Event_Space_Percent + Log_Max_Allowable_Datum_Space_Percent; // 50 const short Log_Max_Allowable_Debug_Space_Percent = 15; const short Log_Max_Allowable_Trtmt_Space_Percent = 10; // // Max Usage : 75 = 25 + 25 + 15 + 10 // // Max Used : 85 = 100 - 15 // // Min Buffer : 10 = 85 - 75 // IMPORTANT: we have to keep 10% buffer otherwise competition between filling and deleting logs will cause application to crash eventually. short Log_Min_Available_Total_Space_IsLow(short vPercent) { return vPercent < Log_Min_Available_Total_Space_Percent; } #ifdef BUILD_FOR_TARGET const char *SDCard_Base_Path_Name = "/media/sd-card/"; const char *Encrypted_Partition_Path = "/var/configurations/"; #else // should not be in the project application folder. [not tracking by git] const char *SDCard_Base_Path_Name = "/home/denali/Desktop/sd-card/"; const char *Encrypted_Partition_Path="/home/denali/Desktop/var/configurations/"; #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 ? ( 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 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_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 //TODO The manufacturing mode has to run as root // after the lockdown.sh ran there would be no root user access // and I am not sure how we reenable the root ssh // and if it is a security risk to give denali access to sshd_config to enable the root ssh within UI App // lockdown script suppose to be the last thing to do, // and it is the lockdown.sh script which moves the scripts from root to denali home folder, // therefore in manufacturing mode we are still running as root. return QCoreApplication::applicationDirPath() + (gEnableManufacturing ? "/scripts/" : "/scripts/"); #else return "/home/denali/Projects/application/scripts/"; #endif } // Please notice that is the folder not the path // 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_Treatment = "treatment/" ; // Treatment Log const char *Log_Folder_Pending = "treatment/pending/" ; // Treatment Log Pending, have not been saved on cloud yet. // 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_Set = "rootsshaccess_set.sh"; const char *RootSSHAccess_Get = "rootsshaccess_get.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"; }