From 492e3beb1837e4797c569d3ad48c289eb67b958a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 9 Apr 2018 15:37:46 +0100 Subject: [PATCH] Reuse SmartStatus::SelfTestStatus enum. --- src/core/smartdiskinformation.cpp | 2 +- src/core/smartdiskinformation.h | 23 ++----------- src/core/smartparser.cpp | 3 +- src/core/smartstatus.cpp | 55 +------------------------------ src/core/smartstatus.h | 2 +- 5 files changed, 7 insertions(+), 78 deletions(-) diff --git a/src/core/smartdiskinformation.cpp b/src/core/smartdiskinformation.cpp index 3be06cb..1c42d20 100644 --- a/src/core/smartdiskinformation.cpp +++ b/src/core/smartdiskinformation.cpp @@ -33,7 +33,7 @@ SmartDiskInformation::SmartDiskInformation() : m_SmartStatus(false), m_BadAttributeNow(false), m_BadAttributeInThePast(false), - m_SelfTestExecutionStatus(SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER), + m_SelfTestExecutionStatus(SmartStatus::SelfTestStatus::Success), m_Overall(SmartStatus::Overall::Bad) { } diff --git a/src/core/smartdiskinformation.h b/src/core/smartdiskinformation.h index e1593c0..dbf3d38 100644 --- a/src/core/smartdiskinformation.h +++ b/src/core/smartdiskinformation.h @@ -34,22 +34,6 @@ class SmartAttributeParsedData; */ class SmartDiskInformation { -public: - /** SMART self test execution state */ - enum SmartSelfTestExecutionStatus { - SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER = 0, - SMART_SELF_TEST_EXECUTION_STATUS_ABORTED = 1, - SMART_SELF_TEST_EXECUTION_STATUS_INTERRUPTED = 2, - SMART_SELF_TEST_EXECUTION_STATUS_FATAL = 3, - SMART_SELF_TEST_EXECUTION_STATUS_ERROR_UNKNOWN = 4, - SMART_SELF_TEST_EXECUTION_STATUS_ERROR_ELECTRICAL = 5, - SMART_SELF_TEST_EXECUTION_STATUS_ERROR_SERVO = 6, - SMART_SELF_TEST_EXECUTION_STATUS_ERROR_READ = 7, - SMART_SELF_TEST_EXECUTION_STATUS_ERROR_HANDLING = 8, - SMART_SELF_TEST_EXECUTION_STATUS_INPROGRESS = 15, - _SMART_SELF_TEST_EXECUTION_STATUS_MAX - }; - public: SmartDiskInformation(); @@ -92,7 +76,7 @@ public: return m_SmartStatus; /**< @return a boolean representing SMART status */ } - SmartSelfTestExecutionStatus selfTestExecutionStatus() const + SmartStatus::SelfTestStatus selfTestExecutionStatus() const { return m_SelfTestExecutionStatus; /**< @return SMART self execution status */ } @@ -158,7 +142,7 @@ public: m_SmartStatus = smartStatus; } - void setSelfTestExecutionStatus(SmartSelfTestExecutionStatus status) + void setSelfTestExecutionStatus(SmartStatus::SelfTestStatus status) { m_SelfTestExecutionStatus = status; } @@ -183,10 +167,9 @@ private: bool m_SmartStatus; bool m_BadAttributeNow; bool m_BadAttributeInThePast; - SmartSelfTestExecutionStatus m_SelfTestExecutionStatus; + SmartStatus::SelfTestStatus m_SelfTestExecutionStatus; SmartStatus::Overall m_Overall; QList m_Attributes; - }; #endif // SMARTDISKINFORMATION_H diff --git a/src/core/smartparser.cpp b/src/core/smartparser.cpp index 4dcf046..7213355 100644 --- a/src/core/smartparser.cpp +++ b/src/core/smartparser.cpp @@ -91,8 +91,7 @@ bool SmartParser::init() QJsonObject selfTest = smartJson[self_test].toObject(); QJsonObject selfTestStatus = selfTest[status].toObject(); - m_DiskInformation->setSelfTestExecutionStatus((SmartDiskInformation::SmartSelfTestExecutionStatus) - selfTestStatus[value].toInt()); + m_DiskInformation->setSelfTestExecutionStatus(static_cast(selfTestStatus[value].toInt())); loadAttributes(); diff --git a/src/core/smartstatus.cpp b/src/core/smartstatus.cpp index 0e67cde..b9e8e37 100644 --- a/src/core/smartstatus.cpp +++ b/src/core/smartstatus.cpp @@ -64,69 +64,16 @@ void SmartStatus::update() return; setStatus(disk->smartStatus()); - setModelName(disk->model()); - setFirmware(disk->firmware()); - setSerial(disk->serial()); - - switch (disk->selfTestExecutionStatus()) { - case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ABORTED: - setSelfTestStatus(SelfTestStatus::Aborted); - break; - - case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_INTERRUPTED: - setSelfTestStatus(SelfTestStatus::Interrupted); - break; - - case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_FATAL: - setSelfTestStatus(SelfTestStatus::Fatal); - break; - - case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_UNKNOWN: - setSelfTestStatus(SelfTestStatus::ErrorUnknown); - break; - - case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_ELECTRICAL: - setSelfTestStatus(SelfTestStatus::ErrorEletrical); - break; - - case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_SERVO: - setSelfTestStatus(SelfTestStatus::ErrorServo); - break; - - case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_READ: - setSelfTestStatus(SelfTestStatus::ErrorRead); - break; - - case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_HANDLING: - setSelfTestStatus(SelfTestStatus::ErrorHandling); - break; - - case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_INPROGRESS: - setSelfTestStatus(SelfTestStatus::InProgress); - break; - - default: - case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER: - setSelfTestStatus(SelfTestStatus::Success); - break; - - } - + setSelfTestStatus(disk->selfTestExecutionStatus()); setOverall(disk->overall()); - setTemp(disk->temperature()); - setBadSectors(disk->badSectors()); - setPoweredOn(disk->poweredOn()); - setPowerCycles(disk->powerCycles()); - addAttributes(disk->attributes()); - setInitSuccess(true); } diff --git a/src/core/smartstatus.h b/src/core/smartstatus.h index b54236d..06defe8 100644 --- a/src/core/smartstatus.h +++ b/src/core/smartstatus.h @@ -50,7 +50,7 @@ public: ErrorServo, ErrorRead, ErrorHandling, - InProgress + InProgress = 15, }; public: