File indexing completed on 2024-04-28 16:52:15

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 NETSTATCLIENT_H
0006 #define NETSTATCLIENT_H
0007 
0008 #include <QLoggingCategory>
0009 #include <QObject>
0010 
0011 #include "conectionsmodel.h"
0012 #include "netstathelper.h"
0013 
0014 Q_DECLARE_LOGGING_CATEGORY(NetstatClientDebug)
0015 
0016 class NetstatClient : public QObject
0017 {
0018     Q_OBJECT
0019     Q_PROPERTY(QString status READ status WRITE setStatus NOTIFY statusChanged)
0020     Q_PROPERTY(ConnectionsModel *connectionsModel READ connectionsModel CONSTANT)
0021     Q_PROPERTY(bool hasSS READ hasSS CONSTANT)
0022 public:
0023     explicit NetstatClient(QObject *parent = nullptr);
0024     static NetstatClient *self();
0025     ConnectionsModel *connectionsModel() const;
0026 
0027     Q_SLOT void setStatus(const QString &message);
0028     QString status() const;
0029     Q_SIGNAL void statusChanged(const QString &output);
0030     bool hasSS() const;
0031 
0032 protected:
0033     QString mStatus;
0034     ConnectionsModel *const m_connections;
0035     NetstatHelper *m_netstatHelper = nullptr;
0036 
0037     /* Netstat has been deprecated for more than 20 years,
0038      * let's discourage distros using it as default.
0039      */
0040     int mHasSS;
0041 };
0042 
0043 #endif // NETSTATCLIENT_H