Index: sources/device/DeviceController.cpp =================================================================== diff -u -reb918e27185e683e1d6a2b3ef0c621d173d561a5 -r2afdc76a7d8f97a518da0158e9bd08217de41a97 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision eb918e27185e683e1d6a2b3ef0c621d173d561a5) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 2afdc76a7d8f97a518da0158e9bd08217de41a97) @@ -239,7 +239,7 @@ // The treatment logs are held in a separate partition from the unencrypted // logs and need a separate disk space usage check - encryptedPartitionSpaceCheck(); + settingsPartitionSpaceCheck(); #endif } @@ -367,31 +367,54 @@ } /*! - * \brief DeviceController::encryptedPartitionSpaceCheck + * \brief DeviceController::settingsPartitionSpaceCheck * \details Checks the disk space of the encrypted partition */ -void DeviceController::encryptedPartitionSpaceCheck() +void DeviceController::settingsPartitionSpaceCheck() { - bool mCIsReady = false; - bool mCIsReadOnly = false; - qint64 mCTotal = 0; - qint64 mCAvailable = 0; - quint8 mPercent = 0; + static bool mInitialized = false; + // Old Info ; // Current info + static bool mOIsReady = false; bool mCIsReady = false; + static bool mOIsReadOnly = false; bool mCIsReadOnly = false; + static qint64 mOAvailable = 0; qint64 mCAvailable = 0; + static quint8 mOPercent = 0; quint8 mCPercent = 0; - mCIsReady = driveSpaceCheck(Storage::Encrypted_Partition_Path, mCTotal, mCAvailable, &mCIsReadOnly); -#if BUILD_FOR_DESKTOP - mCIsReady = true; // it is set to always true since on desktop a local folder is used for the encrypted folder which doesn't need (un)mount. -#endif + qint64 mCTotal = 0; + mCIsReady = driveSpaceCheck(Storage::Settings_Path(), mCTotal, mCAvailable, &mCIsReadOnly); - if(!mCIsReady) qDebug()<<"NOT READY"; + //DEBUG: qDebug()<< "Checking space for path of : " << Storage::Settings_Path() << " mCTotal " << mCTotal << " available " << mCAvailable; - mPercent = mCTotal ? ((100 * mCAvailable) / mCTotal) : 0; - qDebug()<<"var percent "<< mPercent; - if (Log_Min_Available_Total_Space_IsLow(mPercent)) { - //DEBUG qDebug()<< (QString("Encrypted partition space lower than %1%").arg(Log_Min_Available_Total_Space_Percent)); - LOG_DEBUG(QString("Encrypted partition space lower than %1%").arg(Log_Min_Available_Total_Space_Percent)); - emit didEncryptedPartitionSpaceLow(); + if (mOIsReadOnly != mCIsReadOnly || mOIsReady != mCIsReady || ! mInitialized ) { + mOIsReadOnly = mCIsReadOnly; + mOIsReady = mCIsReady; + mInitialized = true; + //DEBUG:0: qDebug() << " ~~~~~~~~~~ " << __FUNCTION__ << mInitialized << mCIsReady << mOIsReady << mCIsReadOnly << mOIsReadOnly; + emit didSettingsPartitionStateChange(mCIsReady, mCIsReadOnly); } + //NOTE: this if block has to be independent of the mOIsReady != mCIsReady + // because current and old may be the same all the time and then this if block will not execute + // and reaches to the log and fills the log unnecessarily. + if (! mCIsReady ) { + mOPercent = 0; + mOAvailable = 0; + emit didSettingsPartitionSpaceChange(mCIsReady, mCTotal, mCAvailable, mCPercent); + return; + } + + mCPercent = mCTotal ? ((100 * mCAvailable) / mCTotal) : 0; + if (mCPercent < _minRequiredAvailableSpacePercent) { + LOG_DEBUG(QString("Settings partition space lower than %1%").arg(_minRequiredAvailableSpacePercent)); + emit didSettingsPartitionSpaceChange(mCIsReady, mCTotal, mCAvailable, mCPercent); + emit didSDCardSpaceTooLow(_minRequiredAvailableSpacePercent); + } + + /// DEBUG: qDebug() << Storage::SDCard_Base_Path_Name << mCIsReady << mOTotal << mCTotal << (mOTotal == mCTotal) << mOAvailable << mCAvailable << (mOAvailable == mCAvailable) << mPercent << mCIsReadOnly; + if (mOPercent != mCPercent && mOAvailable != mCAvailable ) { + mOPercent = mCPercent ; + mOAvailable = mCAvailable ; + emit didSettingsPartitionSpaceChange(mCIsReady, mCTotal, mCAvailable, mCPercent); + /// DEBUG: qDebug() << Storage::SDCard_Base_Path_Name << mCIsReady << mCTotal << mCAvailable << mPercent ; + } } Index: sources/device/DeviceController.h =================================================================== diff -u -reb918e27185e683e1d6a2b3ef0c621d173d561a5 -r2afdc76a7d8f97a518da0158e9bd08217de41a97 --- sources/device/DeviceController.h (.../DeviceController.h) (revision eb918e27185e683e1d6a2b3ef0c621d173d561a5) +++ sources/device/DeviceController.h (.../DeviceController.h) (revision 2afdc76a7d8f97a518da0158e9bd08217de41a97) @@ -228,14 +228,30 @@ * is less than minimum required percentage defined in _minRequiredAvailableSpacePercent. * \param vAvailablePercent */ + //TODO need to rename to be more generic, being used for SD card and settings partition space low void didSDCardSpaceTooLow(quint8 vAvailablePercent); /*! - * \brief didEncryptedPartitionSpaceLow - * \details this signal will emit when the treatment log folder occupies x percent of the encrypted partition + * \brief didSettingsPartitionSpaceChange + * \param vReady - Device is mounted and ready + * \note if device ejected manually system assumes it's still ready. + * \param vTotal - Returns the total volume size in bytes. + * Returns -1 if QStorageInfo object is not valid + * \param vAvailable - Returns the size (in bytes) available for the current user. + * It returns the total size available if the user is the root user or a system administrator. + * This size can be less than or equal to the free size returned by bytesFree() function. + * Returns -1 if QStorageInfo object is not valid. + * \param vPercent - The percentage of available space. + * \note Will emitted if only one of the publishing parameter changes. */ - void didEncryptedPartitionSpaceLow(); + void didSettingsPartitionSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); + /*! + * \brief didSettingsPartitionStateChange + * \details If the settings partition state changes like removed or is not present this signal will emit. + */ + void didSettingsPartitionStateChange(bool vIsReady, bool vIsReadOnly); + void didActionReceive( const DeviceBrightnessResponseData &vBrightness ); void didActionReceive( const DeviceRootSSHAccessResponseData &vRootSSHAccess); @@ -270,7 +286,7 @@ void sdcardSpaceCheck(); void usbSpaceCheck(); - void encryptedPartitionSpaceCheck(); + void settingsPartitionSpaceCheck(); SAFE_CALL_EX(doAddWatch, const QString &) }; Index: sources/storage/Logger.cpp =================================================================== diff -u -reb918e27185e683e1d6a2b3ef0c621d173d561a5 -r2afdc76a7d8f97a518da0158e9bd08217de41a97 --- sources/storage/Logger.cpp (.../Logger.cpp) (revision eb918e27185e683e1d6a2b3ef0c621d173d561a5) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 2afdc76a7d8f97a518da0158e9bd08217de41a97) @@ -146,9 +146,12 @@ this , SLOT( onSDCardStateChange(bool, bool))); connect(&_DeviceController, SIGNAL( didSDCardSpaceChange(bool, qint64, qint64, quint8)), this , SLOT( onSDCardSpaceChange(bool, qint64, qint64, quint8))); - connect(&_DeviceController, SIGNAL( didEncryptedPartitionSpaceLow()), - this , SLOT( concurrentRemoveLogs())); + connect(&_DeviceController, SIGNAL( didSettingsPartitionStateChange(bool, bool)), + this , SLOT( onSettingsPartitionStateChange(bool, bool))); + connect(&_DeviceController, SIGNAL( didSettingsPartitionSpaceChange(bool, qint64, qint64, quint8)), + this , SLOT( onSettingsPartitionSpaceChange(bool, qint64, qint64, quint8))); + connect(&_DeviceController, SIGNAL(didCryptSetupMount(bool)), this , SLOT( onCryptSetupMount(bool))); } @@ -591,7 +594,53 @@ } // disabled coco end + /*! + * \brief Logger::onSettingsPartitionStateChange + * \details handle the state change of the settings partition + * \param vReady - The Settings Partition is Ready + * \param vReadonly - The Settings Partition is readonly + */ +void Logger::onSettingsPartitionStateChange(bool vReady, bool vReadonly) +{ +#if BUILD_FOR_DESKTOP + Q_UNUSED(vReady ) + Q_UNUSED(vReadonly ) + _logStorageReady = true; +#else + // Include settings partition state + _logStorageReady = _logStorageReady && vReady && !vReadonly; +#endif +} + +/*! + * \brief Logger::onSettingsPartitionSpaceChange + * \details Settings Partition storage space parameter change slot. + * This slot when called is calling the function concurrentRemoveLogs, + * if percent of available space vPercent is less than Storage::Available_Space_Percent, + * if the Settings Partition is ready (vReady is true) + * \param vReady - The Settings Partition is Ready + * \param vTotal - Total storage space on the Settings Partition + * \param vAvailable - Available storage space on the Settings Partition + * \param vPercent - Percent of available storage space on the Settings Partition + */ +void Logger::onSettingsPartitionSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent) +{ + // disabled coco begin validated: This needs user interaction to change the SD card files system. + // has been tested manually + Q_UNUSED(vTotal ) + Q_UNUSED(vAvailable ) + if ( ! vReady ) return; + + // DEBUG: qDebug() << vPercent << Storage::Available_Space_Percent; + if ( Storage::Log_Min_Available_Total_Space_IsLow(vPercent) ) { + concurrentRemoveLogs(); + } +} +// disabled coco end + + +/*! * \brief Logger::enableConsoleOut * \details Enables or Disables the console output and logs the status * \param vEnabled - Enable console output if true Index: sources/storage/Logger.h =================================================================== diff -u -r611bbf4dcba67768db87cf30f21fd2db788f677d -r2afdc76a7d8f97a518da0158e9bd08217de41a97 --- sources/storage/Logger.h (.../Logger.h) (revision 611bbf4dcba67768db87cf30f21fd2db788f677d) +++ sources/storage/Logger.h (.../Logger.h) (revision 2afdc76a7d8f97a518da0158e9bd08217de41a97) @@ -212,6 +212,8 @@ private slots: void onSDCardStateChange(bool vReady, bool vReadonly); void onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); + void onSettingsPartitionStateChange(bool vReady, bool vReadonly); + void onSettingsPartitionSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); // ----- logging structure private slots: Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -reb918e27185e683e1d6a2b3ef0c621d173d561a5 -r2afdc76a7d8f97a518da0158e9bd08217de41a97 --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision eb918e27185e683e1d6a2b3ef0c621d173d561a5) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 2afdc76a7d8f97a518da0158e9bd08217de41a97) @@ -62,11 +62,9 @@ #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