File indexing completed on 2024-04-21 07:47:09

0001 /*
0002     SPDX-FileCopyrightText: 2014 Jan Grulich <jgrulich@redhat.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef NETWORKMANAGERQT_FAKE_NETWORK_H
0008 #define NETWORKMANAGERQT_FAKE_NETWORK_H
0009 
0010 #include <QObject>
0011 
0012 #include <QDBusObjectPath>
0013 
0014 #include "../device.h"
0015 #include "../generictypes.h"
0016 
0017 #include "activeconnection.h"
0018 #include "device.h"
0019 #include "settings.h"
0020 
0021 class FakeNetwork : public QObject
0022 {
0023     Q_OBJECT
0024     Q_CLASSINFO("D-Bus Interface", "org.kde.fakenetwork")
0025 public:
0026     explicit FakeNetwork(QObject *parent = nullptr);
0027     ~FakeNetwork() override;
0028 
0029     Q_PROPERTY(QDBusObjectPath ActivatingConnection READ activatingConnection)
0030     Q_PROPERTY(QList<QDBusObjectPath> ActiveConnections READ activeConnections)
0031     Q_PROPERTY(uint Connectivity READ connectivity)
0032     Q_PROPERTY(QList<QDBusObjectPath> Devices READ devices)
0033     Q_PROPERTY(bool NetworkingEnabled READ networkingEnabled)
0034     Q_PROPERTY(QDBusObjectPath PrimaryConnection READ primaryConnection)
0035     Q_PROPERTY(uint State READ state)
0036     Q_PROPERTY(QString Version READ version)
0037     Q_PROPERTY(bool WimaxEnabled READ wimaxEnabled WRITE setWimaxEnabled)
0038     Q_PROPERTY(bool WimaxHardwareEnabled READ wimaxHardwareEnabled)
0039     Q_PROPERTY(bool WirelessEnabled READ wirelessEnabled WRITE setWirelessEnabled)
0040     Q_PROPERTY(bool WirelessHardwareEnabled READ wirelessHardwareEnabled)
0041     Q_PROPERTY(bool WwanEnabled READ wwanEnabled WRITE setWwanEnabled)
0042     Q_PROPERTY(bool WwanHardwareEnabled READ wwanHardwareEnabled)
0043 
0044     QDBusObjectPath activatingConnection() const;
0045     QList<QDBusObjectPath> activeConnections() const;
0046     uint connectivity() const;
0047     QList<QDBusObjectPath> devices() const;
0048     bool networkingEnabled() const;
0049     QDBusObjectPath primaryConnection() const;
0050     uint state() const;
0051     QString version() const;
0052     bool wimaxEnabled() const;
0053     void setWimaxEnabled(bool enabled);
0054     bool wimaxHardwareEnabled() const;
0055     void setWimaxHardwareEnabled(bool enabled);
0056     bool wirelessEnabled() const;
0057     void setWirelessEnabled(bool enabled);
0058     bool wirelessHardwareEnabled() const;
0059     void setWirelessHardwareEnabled(bool enabled);
0060     bool wwanEnabled() const;
0061     void setWwanEnabled(bool enabled);
0062     bool wwanHardwareEnabled() const;
0063 
0064     /* Not part of DBus interface */
0065     void addDevice(Device *device);
0066     void removeDevice(Device *device);
0067     void registerService();
0068     void unregisterService();
0069 
0070 private Q_SLOTS:
0071     void onConnectionAdded(const QDBusObjectPath &connection);
0072     void onConnectionRemoved(const QDBusObjectPath &connection);
0073     void removeActiveConnection(const QDBusObjectPath &activeConnection);
0074     void updateConnectingState();
0075     void updateDeactivatingState();
0076 
0077 public Q_SLOTS:
0078     Q_SCRIPTABLE QDBusObjectPath ActivateConnection(const QDBusObjectPath &connection, const QDBusObjectPath &device, const QDBusObjectPath &specific_object);
0079     Q_SCRIPTABLE uint CheckConnectivity() const;
0080     Q_SCRIPTABLE void DeactivateConnection(const QDBusObjectPath &active_connection);
0081     Q_SCRIPTABLE QDBusObjectPath GetDeviceByIpIface(const QString &iface);
0082     Q_SCRIPTABLE QList<QDBusObjectPath> GetDevices() const;
0083 
0084 Q_SIGNALS:
0085     Q_SCRIPTABLE void DeviceAdded(const QDBusObjectPath &device_path);
0086     Q_SCRIPTABLE void DeviceRemoved(const QDBusObjectPath &device_path);
0087     Q_SCRIPTABLE void PropertiesChanged(const QVariantMap &properties);
0088     Q_SCRIPTABLE void StateChanged(uint state);
0089 
0090 private:
0091     QDBusObjectPath m_activatingConnection;
0092     QMap<QDBusObjectPath, ActiveConnection *> m_activeConnections;
0093     uint m_connectivity;
0094     QMap<QDBusObjectPath, Device *> m_devices;
0095     bool m_networkingEnabled;
0096     QDBusObjectPath m_primaryConnection;
0097     uint m_state;
0098     QString m_version;
0099     bool m_wimaxEnabled;
0100     bool m_wimaxHardwareEnabled;
0101     bool m_wirelessEnabled;
0102     bool m_wirelessHardwareEnabled;
0103     bool m_wwanEnabled;
0104     bool m_wwanHardwareEnabled;
0105 
0106     /* Not part of DBus interface */
0107     QString m_activatedDevice;
0108     QString m_deactivatedDevice;
0109     int m_activeConnectionsCounter;
0110     int m_deviceCounter;
0111     Settings *m_settings;
0112 };
0113 
0114 #endif