Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
250 andreas 1
/*
2
 * Copyright (C) 2022 by Andreas Theofilu <andreas@theosys.at>
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
#ifndef TQNETWORKINFO_H
19
#define TQNETWORKINFO_H
20
 
21
#include <QtGlobal>
22
 
23
#define _SUPPORTED_MAJOR    6
24
#define _SUPPORTED_MINOR    3
25
#define _SUPPORTED_PATCH    0
26
 
27
#if QT_VERSION >= QT_VERSION_CHECK(_SUPPORTED_MAJOR, _SUPPORTED_MINOR, _SUPPORTED_PATCH)
28
#include <QNetworkInformation>
29
#else
30
#include <QObject>
31
#warning "This module requires at least Qt version 6.3.x or newer to work!"
32
#endif
33
 
34
QT_BEGIN_NAMESPACE
35
class QWidget;
36
class QObject;
37
QT_END_NAMESPACE
38
 
39
class TQNetworkInfo : public QObject
40
{
41
    public:
42
        TQNetworkInfo();
43
        ~TQNetworkInfo();
44
 
45
        typedef enum
46
        {
47
            NET_UNKNOWN,
48
            NET_ETHERNET,
49
            NET_CELLULAR,
50
            NET_WIFI,
51
            NET_BLUETOOTH
52
        }NET_TRANSPORT;
53
 
54
#if QT_VERSION >= QT_VERSION_CHECK(_SUPPORTED_MAJOR, _SUPPORTED_MINOR, _SUPPORTED_PATCH)
55
        QNetworkInformation::Reachability getReachability() { return mReachability; }
56
#else
57
        int getReachability() { return 0; }
58
#endif
59
        int getConnectionStrength() { return mLevel; };
60
        bool isConnected() { return mConnection; };
61
        NET_TRANSPORT getTransport() { return mType; }
62
 
63
    private slots:
64
#if QT_VERSION >= QT_VERSION_CHECK(_SUPPORTED_MAJOR, _SUPPORTED_MINOR, _SUPPORTED_PATCH)
65
        void onReachabilityChanged(QNetworkInformation::Reachability reachability);
66
        void onTransportMediumChanged(QNetworkInformation::TransportMedium current);
67
#endif
68
    private:
69
#if QT_VERSION >= QT_VERSION_CHECK(_SUPPORTED_MAJOR, _SUPPORTED_MINOR, _SUPPORTED_PATCH)
70
        NET_TRANSPORT toNetTransport(QNetworkInformation::TransportMedium trans);
71
 
72
        QNetworkInformation::Reachability mReachability{QNetworkInformation::Reachability::Unknown};
73
#endif
74
        bool mConnection{false};
75
        int mLevel{0};
76
        NET_TRANSPORT mType{NET_UNKNOWN};
77
        bool mInitialized{false};
78
};
79
 
80
#endif // TQNETWORKINFO_H