camerauis/cameraxui/cxengine/src/cxesysutil.cpp
changeset 28 3075d9b614e6
parent 19 d9aefe59d544
child 29 699651f2666f
equal deleted inserted replaced
19:d9aefe59d544 28:3075d9b614e6
   135 }
   135 }
   136 
   136 
   137 /*!
   137 /*!
   138 * Return space available for Camera to use.
   138 * Return space available for Camera to use.
   139 * @param fs File Server session
   139 * @param fs File Server session
       
   140 * @param index Index for the drive to be checked.
   140 * @param settings Camera settings instance
   141 * @param settings Camera settings instance
   141 * @return Amount of bytes free for Camera usage.
   142 * @return Amount of bytes free for Camera usage.
   142 */
   143 */
   143 qint64 CxeSysUtil::spaceAvailable(RFs &fs, CxeSettings &settings)
   144 qint64 CxeSysUtil::spaceAvailable(RFs &fs, int index, CxeSettings &settings)
   144 {
   145 {
   145     CX_DEBUG_ENTER_FUNCTION();
   146     CX_DEBUG_ENTER_FUNCTION();
   146 
   147 
   147     qint64 freeSpace(0);
   148     qint64 freeSpace(0);
   148 
   149 
   149     try {
   150     try {
   150         // Get drive index
       
   151         int index(getCameraDrive(fs));
       
   152         qt_symbian_throwIfError(index);
       
   153 
       
   154         // Get volume info
   151         // Get volume info
   155         TVolumeInfo volumeInfo;
   152         TVolumeInfo volumeInfo;
   156         int status(fs.Volume(volumeInfo, index));
   153         int status(fs.Volume(volumeInfo, index));
   157         CX_DEBUG(("status getting volume info: %d", status));
   154         CX_DEBUG(("status getting volume info: %d", status));
   158         qt_symbian_throwIfError(status);
   155         qt_symbian_throwIfError(status);
   167         // We must leave the free space above this.
   164         // We must leave the free space above this.
   168         QVariant criticalThreshold;
   165         QVariant criticalThreshold;
   169         settings.get(KCRUidDiskLevel.iUid, KDiskCriticalThreshold, Cxe::Repository, criticalThreshold);
   166         settings.get(KCRUidDiskLevel.iUid, KDiskCriticalThreshold, Cxe::Repository, criticalThreshold);
   170 
   167 
   171         // Calculate space that we can still use. A small safety buffer is used above critical value.
   168         // Calculate space that we can still use. A small safety buffer is used above critical value.
   172         freeSpace = std::max(volumeInfo.iFree - criticalThreshold.toInt() - KDiskSafetyLimit, (qint64)0);
   169         freeSpace = std::max(qint64(0), volumeInfo.iFree - criticalThreshold.toInt() - KDiskSafetyLimit);
   173 
   170 
   174     } catch(const std::exception& e) {
   171     } catch(const std::exception& e) {
   175         Q_UNUSED(e);
   172         Q_UNUSED(e);
   176         CX_DEBUG(("[WARNING]: exception [%s]", e.what()));
   173         CX_DEBUG(("[WARNING]: exception [%s]", e.what()));
   177         freeSpace = 0;
   174         freeSpace = 0;