File indexing completed on 2023-09-24 09:38:13
0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0002 // SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org> 0003 0004 #ifndef SMARTCTL_H 0005 #define SMARTCTL_H 0006 0007 #include <QJsonDocument> 0008 #include <QObject> 0009 0010 #include <queue> 0011 0012 class AbstractSMARTCtl : public QObject 0013 { 0014 Q_OBJECT 0015 public: 0016 ~AbstractSMARTCtl() override = default; 0017 virtual void run(const QString &devicePath) = 0; 0018 0019 signals: 0020 /** 0021 * @param devicePath the device the request was finished for (same as was passed into run()) 0022 * @param document the JSON presentation of the report 0023 * @param the text presentation of the report (ordinary CLI output from smartctl) 0024 */ 0025 void finished(const QString &devicePath, const QJsonDocument &document, const QString &textDocument) const; 0026 0027 protected: 0028 AbstractSMARTCtl() = default; 0029 0030 private: 0031 Q_DISABLE_COPY(AbstractSMARTCtl) 0032 }; 0033 0034 class SMARTCtl : public AbstractSMARTCtl 0035 { 0036 public: 0037 void run(const QString &devicePath) override; 0038 0039 private: 0040 bool m_busy = false; 0041 std::queue<QString> m_requestQueue; 0042 }; 0043 0044 #endif // SMARTCTL_H