Index: sources/storage/DriveWatcher.cpp =================================================================== diff -u -r618891879f5cdc68e37ee68eea005afb76dd4e5b -r4df19fe88c454bd54abcdaf983be59464c5ef5bc --- sources/storage/DriveWatcher.cpp (.../DriveWatcher.cpp) (revision 618891879f5cdc68e37ee68eea005afb76dd4e5b) +++ sources/storage/DriveWatcher.cpp (.../DriveWatcher.cpp) (revision 4df19fe88c454bd54abcdaf983be59464c5ef5bc) @@ -26,6 +26,7 @@ #include "storageglobals.h" #include "logger.h" #include "applicationcontroller.h" +#include "filehandler.h" // namespace using namespace Storage; @@ -162,11 +163,14 @@ * \return - The drive mounted and ready * \note if device ejected manually system assumes it's still ready. */ -bool DriveWatcher::driveSpaceCheck(const QString &vPath, qint64 &vTotalBytes, qint64 &vAvailableBytes) +bool DriveWatcher::driveSpaceCheck(const QString &vPath, qint64 &vTotalBytes, qint64 &vAvailableBytes, bool *vIsReadOnly) { // coco begin validated: Needed User Interaction to make the device not ready so tested manually + bool isReadOnly; + if (! FileHandler::isMounted(vPath, &isReadOnly)) return false; + if (vIsReadOnly) *vIsReadOnly = isReadOnly; QStorageInfo storage(vPath); - bool isReady = storage.isReady(); + bool isReady = storage.isReady(); if (isReady) { vTotalBytes = storage.bytesTotal(); vAvailableBytes = storage.bytesAvailable(); @@ -219,25 +223,28 @@ { // coco begin validated: Needed User Interaction so tested manually - quint8 mPercent ; + // Old Info ; // Current info + static bool mOIsReady ; bool mCIsReady ; + static bool mOIsReadOnly; bool mCIsReadOnly ; + static qint64 mOTotal ; qint64 mCTotal ; + static qint64 mOAvailable ; qint64 mCAvailable ; - // Old Info ; // Current info - static bool mOIsReady ; bool mCIsReady ; - static qint64 mOTotal ; qint64 mCTotal ; - static qint64 mOAvailable; qint64 mCAvailable; + mCIsReady = driveSpaceCheck(Storage::SDCard_Base_Path_Name, mCTotal, mCAvailable, &mCIsReadOnly); - mCIsReady = driveSpaceCheck(Storage::SDCard_Base_Path_Name, mCTotal, mCAvailable); + if (mOIsReadOnly != mCIsReadOnly || mOIsReady != mCIsReady) { + mOIsReadOnly = mCIsReadOnly; + emit didSDCardStateChange(mCIsReady, mCIsReadOnly); + } + if (! mCIsReady ) { - emit didSDCardSpaceRemove(); + mOIsReady = mCIsReady; return; } - mPercent = mCTotal ? ((100 * mCAvailable) / mCTotal) : 0; - - if (mOIsReady == mCIsReady && - mOTotal == mCTotal && + quint8 mPercent = mCTotal ? ((100 * mCAvailable) / mCTotal) : 0; + if (mOTotal == mCTotal && mOAvailable == mCAvailable && - mPercent >= _minRequiredAvailableSpacePercent ) return; + mPercent >= _minRequiredAvailableSpacePercent ) return; mOIsReady = mCIsReady ; mOTotal = mCTotal ;