File indexing completed on 2024-05-12 17:07:36
0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0002 // SPDX-FileCopyrightText: 2018 Alexis Lopes Zubeta <contact@azubieta.net> 0003 // SPDX-FileCopyrightText: 2020 Tomaz Canabrava <tcanabrava@kde.org> 0004 0005 #ifndef NETSTATHELPER_H 0006 #define NETSTATHELPER_H 0007 0008 #include <QLoggingCategory> 0009 #include <QProcess> 0010 #include <QVariantMap> 0011 0012 Q_DECLARE_LOGGING_CATEGORY(NetstatHelperDebug) 0013 0014 class QTimer; 0015 0016 class NetstatHelper : public QObject 0017 { 0018 Q_OBJECT 0019 public: 0020 NetstatHelper(); 0021 QString errorString() const; 0022 bool hasError() const; 0023 0024 public Q_SLOTS: 0025 void query(); 0026 void stopProcess(); 0027 0028 private Q_SLOTS: 0029 // called by the finished signal on the process. 0030 void stepExecuteFinished(int exitCode); 0031 0032 Q_SIGNALS: 0033 void queryFinished(const QVector<QStringList> &query); 0034 0035 private: 0036 QVector<QStringList> parseSSOutput(const QByteArray &ss); 0037 0038 QString extractAndStrip(const QString &src, int index, int size); 0039 0040 void resetPointers(); 0041 0042 QString m_errorString; 0043 bool m_hasError = false; 0044 QProcess *m_executableProcess = nullptr; 0045 QTimer *m_processKillerTimer = nullptr; 0046 bool m_hasTimeoutError = false; 0047 }; 0048 0049 #endif // NETSTATHELPER_H