Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -r3f555c49ddd2c983f469709e3c001d0e76159248 -rffa637196f8eb64c155cd84ef27f65a87479135e --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 3f555c49ddd2c983f469709e3c001d0e76159248) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision ffa637196f8eb64c155cd84ef27f65a87479135e) @@ -1,22 +1,27 @@ /*! - * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * + * 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) Peter Lucia - * \date (last) 15-Oct-2020 - * \author (original) Behrouz NematiPour - * \date (original) 26-Aug-2020 + * \file StorageGlobals.cpp + * \author (last) Behrouz NematiPour + * \date (last) 22-Jan-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. @@ -28,6 +33,8 @@ /****** 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 @@ -40,7 +47,18 @@ const char *USB_File_System = "vfat"; // SD-CARD - const short Available_Space_Percent = 15; + 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/"; #else @@ -49,34 +67,79 @@ #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. + 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 - const char *Settings_Path_Name = "/home/root/.config/"; + //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_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 - // Scripts #ifdef BUILD_FOR_TARGET - const char *Scripts_Path_Name = "/home/root/scripts/"; + const char *CloudSync_Credentials_Folder_Name = "credentials/"; #else - // should be in the project application folder. [is tracking by git] - const char *Scripts_Path_Name = "/home/denali/Projects/application/scripts/"; + // on VM it is a temporary file which is not being tracked + const char *CloudSync_Credentials_Folder_Name = "credentials/"; #endif - // Treatment + // 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 *Treatment_Log_Folder = "treatment/"; + 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. // FIXME : Not sure having global settings object is a good idea. #ifdef BUILD_FOR_TARGET - QSettings WifiSettings("/home/root/wifi.ini", QSettings::IniFormat); + QSettings WifiSettings("/home/denali/wifi.ini", QSettings::IniFormat); #else QSettings WifiSettings("/home/denali/wifi.ini"); #endif @@ -86,33 +149,59 @@ 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 *WifiSettings_SSID = "wifi/ssid"; - const char *WifiSettings_MacAddress = "wifi/macAddress"; - const char *WifiSettings_ConfPath = "wifi/confPath"; - const char *WifiSettings_Security_Types = "wifi/security"; - const char *WifiSettings_IPAddress = "wifi/ipAddress"; - const char *WifiSettings_Gateway = "wifi/gateway"; - const char *WifiSettings_SubnetMask = "wifi/subnetmask"; - const char *WifiSettings_DNS = "wifi/dns"; - const char *WifiSettings_UseDHCP = "wifi/useDHCP"; + 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 *WifiSettings_SSID = "wifi/ssid"; + const char *WifiSettings_MacAddress = "wifi/macAddress"; + const char *WifiSettings_ConfPath = "wifi/confPath"; + const char *WifiSettings_Security_Types = "wifi/security"; + const char *WifiSettings_IPAddress = "wifi/ipAddress"; + const char *WifiSettings_Gateway = "wifi/gateway"; + const char *WifiSettings_SubnetMask = "wifi/subnetmask"; + const char *WifiSettings_DNS = "wifi/dns"; + const char *WifiSettings_UseDHCP = "wifi/useDHCP"; // Brightness - const char *Brightness_Set = "brightness_set.sh"; - const char *Brightness_Get = "brightness_get.sh"; + 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"; + }