Reuse SmartStatus::Overall enum for SmartDiskInformation.
This commit is contained in:
parent
622def3b56
commit
b5d0b500cf
|
@ -34,9 +34,8 @@ SmartDiskInformation::SmartDiskInformation() :
|
|||
m_BadAttributeNow(false),
|
||||
m_BadAttributeInThePast(false),
|
||||
m_SelfTestExecutionStatus(SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER),
|
||||
m_Overall(SmartDiskInformation::Overall::BadStatus)
|
||||
m_Overall(SmartStatus::Overall::Bad)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/** Update the number of bad sectors based on reallocated sector count and current pending sector attributes data */
|
||||
|
@ -62,35 +61,35 @@ void SmartDiskInformation::updateBadSectors()
|
|||
void SmartDiskInformation::updateOverall()
|
||||
{
|
||||
if (!smartStatus()) {
|
||||
m_Overall = Overall::BadStatus;
|
||||
m_Overall = SmartStatus::Overall::Bad;
|
||||
return;
|
||||
}
|
||||
|
||||
quint64 sector_threshold = u64log2(size() / 512) * 1024;
|
||||
|
||||
if (badSectors() >= sector_threshold) {
|
||||
m_Overall = Overall::BadSectorsMany;
|
||||
m_Overall = SmartStatus::Overall::BadSectorsMany;
|
||||
return;
|
||||
}
|
||||
|
||||
validateBadAttributes();
|
||||
|
||||
if (m_BadAttributeNow) {
|
||||
m_Overall = Overall::BadAttributeNow;
|
||||
m_Overall = SmartStatus::Overall::BadNow;
|
||||
return;
|
||||
}
|
||||
|
||||
if (badSectors() > 0) {
|
||||
m_Overall = Overall::BadSector;
|
||||
m_Overall = SmartStatus::Overall::BadSectors;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_BadAttributeInThePast) {
|
||||
m_Overall = Overall::BadAttributeInThePast;
|
||||
m_Overall = SmartStatus::Overall::BadPast;
|
||||
return;
|
||||
}
|
||||
|
||||
m_Overall = Overall::Good;
|
||||
m_Overall = SmartStatus::Overall::Good;
|
||||
}
|
||||
|
||||
/** Update the temperature value based on SMART attributes
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2018 by Caio Carvalho <caiojcarvalho@gmail.com> *
|
||||
* Copyright (C) 2018 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -18,6 +19,8 @@
|
|||
#ifndef KPMCORE_SMARTDISKINFORMATION_H
|
||||
#define KPMCORE_SMARTDISKINFORMATION_H
|
||||
|
||||
#include "core/smartstatus.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
|
@ -47,16 +50,6 @@ public:
|
|||
_SMART_SELF_TEST_EXECUTION_STATUS_MAX
|
||||
};
|
||||
|
||||
/** SMART overall state */
|
||||
enum class Overall {
|
||||
Good,
|
||||
BadAttributeInThePast,
|
||||
BadSector,
|
||||
BadAttributeNow,
|
||||
BadSectorsMany,
|
||||
BadStatus,
|
||||
};
|
||||
|
||||
public:
|
||||
SmartDiskInformation();
|
||||
|
||||
|
@ -104,7 +97,7 @@ public:
|
|||
return m_SelfTestExecutionStatus; /**< @return SMART self execution status */
|
||||
}
|
||||
|
||||
Overall overall() const
|
||||
SmartStatus::Overall overall() const
|
||||
{
|
||||
return m_Overall; /**< @return SMART overall status */
|
||||
}
|
||||
|
@ -191,7 +184,7 @@ private:
|
|||
bool m_BadAttributeNow;
|
||||
bool m_BadAttributeInThePast;
|
||||
SmartSelfTestExecutionStatus m_SelfTestExecutionStatus;
|
||||
Overall m_Overall;
|
||||
SmartStatus::Overall m_Overall;
|
||||
QList<SmartAttributeParsedData> m_Attributes;
|
||||
|
||||
};
|
||||
|
|
|
@ -115,33 +115,7 @@ void SmartStatus::update()
|
|||
|
||||
}
|
||||
|
||||
switch (disk->overall()) {
|
||||
case SmartDiskInformation::Overall::Good:
|
||||
setOverall(Overall::Good);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::Overall::BadAttributeInThePast:
|
||||
setOverall(Overall::BadPast);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::Overall::BadSector:
|
||||
setOverall(Overall::BadSectors);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::Overall::BadAttributeNow:
|
||||
setOverall(Overall::BadNow);
|
||||
break;
|
||||
|
||||
case SmartDiskInformation::Overall::BadSectorsMany:
|
||||
setOverall(Overall::BadSectorsMany);
|
||||
break;
|
||||
|
||||
default:
|
||||
case SmartDiskInformation::Overall::BadStatus:
|
||||
setOverall(Overall::Bad);
|
||||
break;
|
||||
|
||||
}
|
||||
setOverall(disk->overall());
|
||||
|
||||
setTemp(disk->temperature());
|
||||
|
||||
|
|
Loading…
Reference in New Issue