Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "nmdbusutilities.hpp"
- #include "nmdbusargumenttypes.hpp"
- #include "utility.hpp"
- #include <QtCore>
- #include <QtDBus>
- #include <QLoggingCategory>
- Q_DECLARE_LOGGING_CATEGORY(networkManagerInterfacesCategory)
- inline
- QString
- dbusMessageInfo(QDBusMessage const & message)
- {
- return QStringLiteral("service: %2; path: %2; interface: %3; member/method: %4; signature: %5")
- .arg(message.service(),
- message.path(),
- message.interface(),
- message.member(),
- message.signature());
- }
- class NetworkManagerInterface
- : public QDBusAbstractInterface
- {
- Q_OBJECT
- Q_PROPERTY(QDBusObjectPath ActivatingConnection MEMBER ActivatingConnection NOTIFY ActivatingConnectionChanged)
- Q_PROPERTY(NMObjectPathsList ActiveConnections MEMBER ActiveConnections NOTIFY ActiveConnectionsChanged)
- Q_PROPERTY(NMObjectPathsList AllDevices MEMBER AllDevices NOTIFY AllDevicesChanged)
- Q_PROPERTY(uint Connectivity MEMBER Connectivity NOTIFY ConnectivityChanged)
- Q_PROPERTY(NMObjectPathsList Devices MEMBER Devices NOTIFY DevicesChanged)
- Q_PROPERTY(QVariantMap GlobalDnsConfiguration MEMBER GlobalDnsConfiguration NOTIFY GlobalDnsConfigurationChanged)
- Q_PROPERTY(uint Metered MEMBER Metered NOTIFY MeteredChanged)
- Q_PROPERTY(bool NetworkingEnabled MEMBER NetworkingEnabled NOTIFY NetworkingEnabledChanged)
- Q_PROPERTY(QDBusObjectPath PrimaryConnection MEMBER PrimaryConnection NOTIFY PrimaryConnectionChanged)
- Q_PROPERTY(QString PrimaryConnectionType MEMBER PrimaryConnectionType NOTIFY PrimaryConnectionTypeChanged)
- Q_PROPERTY(bool Startup MEMBER Startup NOTIFY StartupChanged)
- Q_PROPERTY(uint State MEMBER State NOTIFY StateChanged)
- Q_PROPERTY(QString Version MEMBER Version NOTIFY VersionChanged)
- Q_PROPERTY(bool WimaxEnabled MEMBER WimaxEnabled NOTIFY WimaxEnabledChanged)
- Q_PROPERTY(bool WimaxHardwareEnabled MEMBER WimaxHardwareEnabled NOTIFY WimaxHardwareEnabledChanged)
- Q_PROPERTY(bool WirelessEnabled MEMBER WirelessEnabled NOTIFY WirelessEnabledChanged)
- Q_PROPERTY(bool WirelessHardwareEnabled MEMBER WirelessHardwareEnabled NOTIFY WirelessHardwareEnabledChanged)
- Q_PROPERTY(bool WwanEnabled MEMBER WwanEnabled NOTIFY WwanEnabledChanged)
- Q_PROPERTY(bool WwanHardwareEnabled MEMBER WwanHardwareEnabled NOTIFY WwanHardwareEnabledChanged)
- public :
- explicit
- NetworkManagerInterface(QObject * const parent = Q_NULLPTR)
- : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
- QStringLiteral(NM_DBUS_PATH),
- NM_DBUS_INTERFACE,
- QDBusConnection::systemBus(),
- parent}
- {
- qDBusRegisterMetaType< NMObjectPathsList >();
- qDBusRegisterMetaType< NMVariantMapMap >();
- qDBusRegisterMetaType< NMStringMap >();
- qDBusRegisterMetaType< QVariantMap >();
- connect(this, &NetworkManagerInterface::PropertiesChanged,
- this, &NetworkManagerInterface::propertiesChanged);
- }
- ~NetworkManagerInterface() Q_DECL_EQ_DEFAULT;
- public Q_SLOTS :
- Q_SCRIPTABLE
- QDBusObjectPath
- ActivateConnection(QDBusObjectPath connection,
- QDBusObjectPath device,
- QDBusObjectPath specificObject)
- {
- return QDBusReply< QDBusObjectPath >{call(QDBus::BlockWithGui,
- QStringLiteral("ActivateConnection"),
- QVariant::fromValue(connection),
- QVariant::fromValue(device),
- QVariant::fromValue(specificObject))};
- }
- Q_SCRIPTABLE
- QDBusObjectPath
- AddAndActivateConnection(NMVariantMapMap connection,
- QDBusObjectPath device,
- QDBusObjectPath specificObject,
- QDBusObjectPath & activeConnection)
- {
- const auto message = call(QDBus::BlockWithGui,
- QStringLiteral("AddAndActivateConnection"),
- QVariant::fromValue(connection),
- QVariant::fromValue(device),
- QVariant::fromValue(specificObject));
- QDBusPendingReply< QDBusObjectPath, QDBusObjectPath > pendingReply = message;
- Q_ASSERT(pendingReply.isFinished());
- if (pendingReply.isError()) {
- qCWarning(networkManagerInterfacesCategory).noquote()
- << tr("Asynchronous call finished with error (%1): %2")
- .arg(dbusMessageInfo(pendingReply.reply()),
- pendingReply.error().message());
- return {};
- }
- activeConnection = pendingReply.argumentAt< 1 >();
- return pendingReply.argumentAt< 0 >();
- }
- Q_SCRIPTABLE
- uint CheckConnectivity()
- {
- return QDBusReply< uint >{call(QDBus::BlockWithGui,
- QStringLiteral("CheckConnectivity"))};
- }
- Q_SCRIPTABLE
- void DeactivateConnection(QDBusObjectPath activeConnection)
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("DeactivateConnection"),
- QVariant::fromValue(activeConnection));
- }
- Q_SCRIPTABLE
- void Enable(bool enable)
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("Enable"),
- QVariant::fromValue(enable));
- }
- Q_SCRIPTABLE
- NMObjectPathsList
- GetAllDevices()
- {
- return QDBusReply< NMObjectPathsList >{call(QDBus::BlockWithGui,
- QStringLiteral("GetAllDevices"))};
- }
- Q_SCRIPTABLE
- QDBusObjectPath
- GetDeviceByIpIface(QString iface)
- {
- return QDBusReply< QDBusObjectPath >{call(QDBus::BlockWithGui,
- QStringLiteral("GetDeviceByIpIface"),
- QVariant::fromValue(iface))};
- }
- Q_SCRIPTABLE
- NMObjectPathsList
- GetDevices()
- {
- return QDBusReply< NMObjectPathsList >{call(QDBus::BlockWithGui,
- QStringLiteral("GetDevices"))};
- }
- Q_SCRIPTABLE
- QString
- GetLogging(QString & domains)
- {
- const auto message = call(QDBus::BlockWithGui,
- QStringLiteral("GetLogging"));
- QDBusPendingReply< QString, QString > pendingReply = message;
- Q_ASSERT(pendingReply.isFinished());
- if (pendingReply.isError()) {
- qCWarning(networkManagerInterfacesCategory).noquote()
- << tr("Asynchronous call finished with error (%1): %2")
- .arg(dbusMessageInfo(pendingReply.reply()),
- pendingReply.error().message());
- return {};
- }
- domains = pendingReply.argumentAt< 1 >();
- return pendingReply.argumentAt< 0 >();
- }
- Q_SCRIPTABLE
- NMStringMap
- GetPermissions()
- {
- return QDBusReply< NMStringMap >{call(QDBus::BlockWithGui,
- QStringLiteral("GetPermissions"))};
- }
- Q_SCRIPTABLE
- void Reload(uint flags)
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("Reload"),
- QVariant::fromValue(flags));
- }
- Q_SCRIPTABLE
- void SetLogging(QString level,
- QString domains)
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("SetLogging"),
- QVariant::fromValue(level),
- QVariant::fromValue(domains));
- }
- Q_SCRIPTABLE
- void Sleep(bool sleep)
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("Sleep"),
- QVariant::fromValue(sleep));
- }
- Q_SCRIPTABLE
- uint state() // u state()
- {
- return QDBusReply< uint >{call(QDBus::BlockWithGui,
- QStringLiteral("state"))};
- }
- Q_SIGNALS :
- Q_SCRIPTABLE void CheckPermissions();
- Q_SCRIPTABLE void DeviceAdded(QDBusObjectPath);
- Q_SCRIPTABLE void DeviceRemoved(QDBusObjectPath);
- Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
- Q_SCRIPTABLE void StateChanged(uint);
- private Q_SLOTS :
- void propertiesChanged(QVariantMap properties)
- {
- QMapIterator< QString, QVariant > i{properties};
- while (i.hasNext()) {
- i.next();
- const auto signature = QStringLiteral("%1Changed()").arg(i.key());
- const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
- Q_ASSERT(!(signalIndex < 0));
- const auto signal = metaObject()->method(signalIndex);
- if (!signal.invoke(this, Qt::DirectConnection)) {
- qCCritical(networkManagerInterfacesCategory).noquote()
- << tr("Unable to emit %1 signal for %2 property")
- .arg(signature,
- i.key());
- }
- }
- }
- Q_SIGNALS :
- void ActivatingConnectionChanged();
- void ActiveConnectionsChanged();
- void AllDevicesChanged();
- void ConnectivityChanged();
- void DevicesChanged();
- void GlobalDnsConfigurationChanged();
- void MeteredChanged();
- void NetworkingEnabledChanged();
- void PrimaryConnectionChanged();
- void PrimaryConnectionTypeChanged();
- void StartupChanged();
- void StateChanged();
- void VersionChanged();
- void WimaxEnabledChanged();
- void WimaxHardwareEnabledChanged();
- void WirelessEnabledChanged();
- void WirelessHardwareEnabledChanged();
- void WwanEnabledChanged();
- void WwanHardwareEnabledChanged();
- private :
- Q_DISABLE_COPY(NetworkManagerInterface)
- QDBusObjectPath ActivatingConnection;
- NMObjectPathsList ActiveConnections;
- NMObjectPathsList AllDevices;
- uint Connectivity;
- NMObjectPathsList Devices;
- QVariantMap GlobalDnsConfiguration;
- uint Metered;
- bool NetworkingEnabled;
- QDBusObjectPath PrimaryConnection;
- QString PrimaryConnectionType;
- bool Startup;
- uint State;
- QString Version;
- bool WimaxEnabled;
- bool WimaxHardwareEnabled;
- bool WirelessEnabled;
- bool WirelessHardwareEnabled;
- bool WwanEnabled;
- bool WwanHardwareEnabled;
- };
- class NetworkManagerDeviceInterface
- : public QDBusAbstractInterface
- {
- Q_OBJECT
- Q_PROPERTY(QDBusObjectPath ActiveConnection MEMBER ActiveConnection NOTIFY ActiveConnectionChanged)
- Q_PROPERTY(bool Autoconnect MEMBER Autoconnect NOTIFY AutoconnectChanged)
- Q_PROPERTY(NMObjectPathsList AvailableConnections MEMBER AvailableConnections NOTIFY AvailableConnectionsChanged)
- Q_PROPERTY(uint Capabilities MEMBER Capabilities NOTIFY CapabilitiesChanged)
- Q_PROPERTY(uint DeviceType MEMBER DeviceType NOTIFY DeviceTypeChanged)
- Q_PROPERTY(QDBusObjectPath Dhcp4Config MEMBER Dhcp4Config NOTIFY Dhcp4ConfigChanged)
- Q_PROPERTY(QDBusObjectPath Dhcp6Config MEMBER Dhcp6Config NOTIFY Dhcp6ConfigChanged)
- Q_PROPERTY(QString Driver MEMBER Driver NOTIFY DriverChanged)
- Q_PROPERTY(QString DriverVersion MEMBER DriverVersion NOTIFY DriverVersionChanged)
- Q_PROPERTY(bool FirmwareMissing MEMBER FirmwareMissing NOTIFY FirmwareMissingChanged)
- Q_PROPERTY(QString FirmwareVersion MEMBER FirmwareVersion NOTIFY FirmwareVersionChanged)
- Q_PROPERTY(QString Interface MEMBER Interface NOTIFY InterfaceChanged)
- Q_PROPERTY(uint Ip4Address MEMBER Ip4Address NOTIFY Ip4AddressChanged)
- Q_PROPERTY(QDBusObjectPath Ip4Config MEMBER Ip4Config NOTIFY Ip4ConfigChanged)
- Q_PROPERTY(QDBusObjectPath Ip6Config MEMBER Ip6Config NOTIFY Ip6ConfigChanged)
- Q_PROPERTY(QString IpInterface MEMBER IpInterface NOTIFY IpInterfaceChanged)
- Q_PROPERTY(NMVariantMapList LldpNeighbors MEMBER LldpNeighbors NOTIFY LldpNeighborsChanged)
- Q_PROPERTY(bool Managed MEMBER Managed NOTIFY ManagedChanged)
- Q_PROPERTY(uint Metered MEMBER Metered NOTIFY MeteredChanged)
- Q_PROPERTY(uint Mtu MEMBER Mtu NOTIFY MtuChanged)
- Q_PROPERTY(bool NmPluginMissing MEMBER NmPluginMissing NOTIFY NmPluginMissingChanged)
- Q_PROPERTY(QString PhysicalPortId MEMBER PhysicalPortId NOTIFY PhysicalPortIdChanged)
- Q_PROPERTY(bool Real MEMBER Real NOTIFY RealChanged)
- Q_PROPERTY(uint State MEMBER State NOTIFY StateChanged)
- Q_PROPERTY(DeviceDBusStateReason StateReason MEMBER StateReason NOTIFY StateReasonChanged)
- Q_PROPERTY(QString Udi MEMBER Udi NOTIFY UdiChanged)
- public :
- NetworkManagerDeviceInterface(QDBusObjectPath path,
- QObject * const parent = Q_NULLPTR)
- : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
- path.path(),
- NM_DBUS_INTERFACE_DEVICE,
- QDBusConnection::systemBus(),
- parent}
- {
- qDBusRegisterMetaType< NMObjectPathsList >();
- qDBusRegisterMetaType< NMVariantMapList >();
- qDBusRegisterMetaType< DeviceDBusStateReason >();
- qDBusRegisterMetaType< NMVariantMapMap >();
- qDBusRegisterMetaType< QVariantMap >();
- connect(this, &NetworkManagerDeviceInterface::PropertiesChanged,
- this, &NetworkManagerDeviceInterface::propertiesChanged);
- }
- ~NetworkManagerDeviceInterface() Q_DECL_EQ_DEFAULT;
- public Q_SLOTS :
- Q_SCRIPTABLE
- void Delete()
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("Delete"));
- }
- Q_SCRIPTABLE
- void Disconnect()
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("Disconnect"));
- }
- Q_SCRIPTABLE
- NMVariantMapMap
- GetAppliedConnection(uint flags, qulonglong & versionId)
- {
- const auto message = call(QDBus::BlockWithGui,
- QStringLiteral("GetAppliedConnection"),
- QVariant::fromValue(flags));
- QDBusPendingReply< NMVariantMapMap, qulonglong > pendingReply = message;
- Q_ASSERT(pendingReply.isFinished());
- if (pendingReply.isError()) {
- qCWarning(networkManagerInterfacesCategory).noquote()
- << tr("Asynchronous call finished with error (%1): %2")
- .arg(dbusMessageInfo(pendingReply.reply()),
- pendingReply.error().message());
- return {};
- }
- versionId = pendingReply.argumentAt< 1 >();
- return pendingReply.argumentAt< 0 >();
- }
- Q_SCRIPTABLE
- void Reapply(NMVariantMapMap connection, qulonglong versionId, uint flags)
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("Reapply"),
- QVariant::fromValue(connection),
- QVariant::fromValue(versionId),
- QVariant::fromValue(flags));
- }
- Q_SIGNALS :
- Q_SCRIPTABLE void StateChanged(uint newState, uint oldState, uint reason);
- Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
- private Q_SLOTS :
- void propertiesChanged(QVariantMap properties)
- {
- QMapIterator< QString, QVariant > i{properties};
- while (i.hasNext()) {
- i.next();
- const auto signature = QStringLiteral("%1Changed()").arg(i.key());
- const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
- Q_ASSERT(!(signalIndex < 0));
- const auto signal = metaObject()->method(signalIndex);
- if (!signal.invoke(this, Qt::DirectConnection)) {
- qCCritical(networkManagerInterfacesCategory).noquote()
- << tr("Unable to emit %1 signal for %2 property")
- .arg(signature,
- i.key());
- }
- }
- }
- Q_SIGNALS :
- void ActiveConnectionChanged();
- void AutoconnectChanged();
- void AvailableConnectionsChanged();
- void CapabilitiesChanged();
- void DeviceTypeChanged();
- void Dhcp4ConfigChanged();
- void Dhcp6ConfigChanged();
- void DriverChanged();
- void DriverVersionChanged();
- void FirmwareMissingChanged();
- void FirmwareVersionChanged();
- void InterfaceChanged();
- void Ip4AddressChanged();
- void Ip4ConfigChanged();
- void Ip6ConfigChanged();
- void IpInterfaceChanged();
- void LldpNeighborsChanged();
- void ManagedChanged();
- void MeteredChanged();
- void MtuChanged();
- void NmPluginMissingChanged();
- void PhysicalPortIdChanged();
- void RealChanged();
- void StateChanged();
- void StateReasonChanged();
- void UdiChanged();
- private :
- Q_DISABLE_COPY(NetworkManagerDeviceInterface)
- QDBusObjectPath ActiveConnection;
- bool Autoconnect;
- NMObjectPathsList AvailableConnections;
- uint Capabilities;
- uint DeviceType;
- QDBusObjectPath Dhcp4Config;
- QDBusObjectPath Dhcp6Config;
- QString Driver;
- QString DriverVersion;
- bool FirmwareMissing;
- QString FirmwareVersion;
- QString Interface;
- uint Ip4Address;
- QDBusObjectPath Ip4Config;
- QDBusObjectPath Ip6Config;
- QString IpInterface;
- NMVariantMapList LldpNeighbors;
- bool Managed;
- uint Metered;
- uint Mtu;
- bool NmPluginMissing;
- QString PhysicalPortId;
- bool Real;
- uint State;
- DeviceDBusStateReason StateReason;
- QString Udi;
- };
- class NetworkManagerDeviceWiredInterface
- : public QDBusAbstractInterface
- {
- Q_OBJECT
- Q_PROPERTY(bool Carrier MEMBER Carrier NOTIFY CarrierChanged)
- Q_PROPERTY(QString HwAddress MEMBER HwAddress NOTIFY HwAddressChanged)
- Q_PROPERTY(QString PermHwAddress MEMBER PermHwAddress NOTIFY PermHwAddressChanged)
- Q_PROPERTY(QStringList S390Subchannels MEMBER S390Subchannels NOTIFY S390SubchannelsChanged)
- Q_PROPERTY(uint Speed MEMBER Speed NOTIFY SpeedChanged)
- public :
- NetworkManagerDeviceWiredInterface(NetworkManagerDeviceInterface * const di,
- QObject * const parent = Q_NULLPTR)
- : QDBusAbstractInterface{di->service(),
- di->path(),
- NM_DBUS_INTERFACE_DEVICE_WIRED,
- di->connection(),
- parent}
- , deviceInterface{di}
- {
- deviceInterface->setParent(this);
- qDBusRegisterMetaType< QStringList >();
- qDBusRegisterMetaType< QVariantMap >();
- connect(this, &NetworkManagerDeviceWiredInterface::PropertiesChanged,
- this, &NetworkManagerDeviceWiredInterface::propertiesChanged);
- }
- ~NetworkManagerDeviceWiredInterface() Q_DECL_EQ_DEFAULT;
- NetworkManagerDeviceInterface * const deviceInterface;
- Q_SIGNALS :
- Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
- private Q_SLOTS :
- void propertiesChanged(QVariantMap properties)
- {
- QMapIterator< QString, QVariant > i{properties};
- while (i.hasNext()) {
- i.next();
- const auto signature = QStringLiteral("%1Changed()").arg(i.key());
- const auto normalizedSignature = QMetaObject::normalizedSignature(qUtf8Printable(signature));
- int signalIndex = metaObject()->indexOfSignal(normalizedSignature.constData());
- if (signalIndex < 0) {
- signalIndex = deviceInterface->metaObject()->indexOfSignal(normalizedSignature.constData());
- Q_ASSERT(!(signalIndex < 0));
- const auto signal = deviceInterface->metaObject()->method(signalIndex);
- if (!signal.invoke(deviceInterface, Qt::DirectConnection)) {
- qCCritical(networkManagerInterfacesCategory).noquote()
- << tr("Unable to emit %1 signal for %2 property")
- .arg(signature,
- i.key());
- }
- } else {
- const auto signal = metaObject()->method(signalIndex);
- if (!signal.invoke(this, Qt::DirectConnection)) {
- qCCritical(networkManagerInterfacesCategory).noquote()
- << tr("Unable to emit %1 signal for %2 property")
- .arg(signature,
- i.key());
- }
- }
- }
- }
- Q_SIGNALS :
- void CarrierChanged();
- void HwAddressChanged();
- void PermHwAddressChanged();
- void S390SubchannelsChanged();
- void SpeedChanged();
- private :
- Q_DISABLE_COPY(NetworkManagerDeviceWiredInterface)
- bool Carrier;
- QString HwAddress;
- QString PermHwAddress;
- QStringList S390Subchannels;
- uint Speed;
- };
- class NetworkManagerDeviceWirelessInterface
- : public QDBusAbstractInterface
- {
- Q_OBJECT
- Q_PROPERTY(NMObjectPathsList AccessPoints MEMBER AccessPoints NOTIFY AccessPointsChanged)
- Q_PROPERTY(QDBusObjectPath ActiveAccessPoint MEMBER ActiveAccessPoint NOTIFY ActiveAccessPointChanged)
- Q_PROPERTY(uint Bitrate MEMBER Bitrate NOTIFY BitrateChanged)
- Q_PROPERTY(QString HwAddress MEMBER HwAddress NOTIFY HwAddressChanged)
- Q_PROPERTY(uint Mode MEMBER Mode NOTIFY ModeChanged)
- Q_PROPERTY(QString PermHwAddress MEMBER PermHwAddress NOTIFY PermHwAddressChanged)
- Q_PROPERTY(uint WirelessCapabilities MEMBER WirelessCapabilities NOTIFY WirelessCapabilitiesChanged)
- public :
- NetworkManagerDeviceWirelessInterface(NetworkManagerDeviceInterface * const di,
- QObject * const parent = Q_NULLPTR)
- : QDBusAbstractInterface{di->service(),
- di->path(),
- NM_DBUS_INTERFACE_DEVICE_WIRELESS,
- di->connection(),
- parent}
- , deviceInterface{di}
- {
- deviceInterface->setParent(this);
- qDBusRegisterMetaType< NMObjectPathsList >();
- qDBusRegisterMetaType< QVariantMap >();
- connect(this, &NetworkManagerDeviceWirelessInterface::PropertiesChanged,
- this, &NetworkManagerDeviceWirelessInterface::propertiesChanged);
- }
- ~NetworkManagerDeviceWirelessInterface() Q_DECL_EQ_DEFAULT;
- NetworkManagerDeviceInterface * const deviceInterface;
- public Q_SLOTS :
- Q_SCRIPTABLE
- NMObjectPathsList
- GetAccessPoints()
- {
- return QDBusReply< NMObjectPathsList >{call(QDBus::BlockWithGui,
- QStringLiteral("GetAccessPoints"))};
- }
- Q_SCRIPTABLE
- NMObjectPathsList
- GetAllAccessPoints()
- {
- return QDBusReply< NMObjectPathsList >{call(QDBus::BlockWithGui,
- QStringLiteral("GetAllAccessPoints"))};
- }
- Q_SCRIPTABLE
- void RequestScan(QVariantMap options)
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("RequestScan"),
- QVariant::fromValue(options));
- }
- Q_SIGNALS :
- Q_SCRIPTABLE void AccessPointAdded(QDBusObjectPath);
- Q_SCRIPTABLE void AccessPointRemoved(QDBusObjectPath);
- Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
- Q_SCRIPTABLE void ScanDone();
- private Q_SLOTS :
- void propertiesChanged(QVariantMap properties)
- {
- QMapIterator< QString, QVariant > i{properties};
- while (i.hasNext()) {
- i.next();
- const auto signature = QStringLiteral("%1Changed()").arg(i.key());
- const auto normalizedSignature = QMetaObject::normalizedSignature(qUtf8Printable(signature));
- int signalIndex = metaObject()->indexOfSignal(normalizedSignature.constData());
- if (signalIndex < 0) {
- signalIndex = deviceInterface->metaObject()->indexOfSignal(normalizedSignature.constData());
- Q_ASSERT(!(signalIndex < 0));
- const auto signal = deviceInterface->metaObject()->method(signalIndex);
- if (!signal.invoke(deviceInterface, Qt::DirectConnection)) {
- qCCritical(networkManagerInterfacesCategory).noquote()
- << tr("Unable to emit %1 signal for %2 property")
- .arg(signature,
- i.key());
- }
- } else {
- const auto signal = metaObject()->method(signalIndex);
- if (!signal.invoke(this, Qt::DirectConnection)) {
- qCCritical(networkManagerInterfacesCategory).noquote()
- << tr("Unable to emit %1 signal for %2 property")
- .arg(signature,
- i.key());
- }
- }
- }
- }
- Q_SIGNALS :
- void AccessPointsChanged();
- void ActiveAccessPointChanged();
- void BitrateChanged();
- void HwAddressChanged();
- void ModeChanged();
- void PermHwAddressChanged();
- void WirelessCapabilitiesChanged();
- private :
- Q_DISABLE_COPY(NetworkManagerDeviceWirelessInterface)
- NMObjectPathsList AccessPoints;
- QDBusObjectPath ActiveAccessPoint;
- uint Bitrate;
- QString HwAddress;
- uint Mode;
- QString PermHwAddress;
- uint WirelessCapabilities;
- };
- class NetworkManagerSettingsInterface
- : public QDBusAbstractInterface
- {
- Q_OBJECT
- Q_PROPERTY(bool CanModify MEMBER CanModify NOTIFY CanModifyChanged)
- Q_PROPERTY(NMObjectPathsList Connections MEMBER Connections NOTIFY ConnectionsChanged)
- Q_PROPERTY(QString Hostname MEMBER Hostname NOTIFY HostnameChanged)
- public :
- explicit
- NetworkManagerSettingsInterface(QObject * const parent = Q_NULLPTR)
- : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
- QStringLiteral(NM_DBUS_PATH_SETTINGS),
- NM_DBUS_INTERFACE_SETTINGS,
- QDBusConnection::systemBus(),
- parent}
- {
- qDBusRegisterMetaType< NMObjectPathsList >();
- qDBusRegisterMetaType< NMVariantMapMap >();
- qDBusRegisterMetaType< QStringList >();
- qDBusRegisterMetaType< QVariantMap >();
- connect(this, &NetworkManagerSettingsInterface::PropertiesChanged,
- this, &NetworkManagerSettingsInterface::propertiesChanged);
- }
- ~NetworkManagerSettingsInterface() Q_DECL_EQ_DEFAULT;
- public Q_SLOTS :
- Q_SCRIPTABLE
- QDBusObjectPath
- AddConnection(NMVariantMapMap connection)
- {
- return QDBusReply< QDBusObjectPath >{call(QDBus::BlockWithGui,
- QStringLiteral("AddConnection"),
- QVariant::fromValue(connection))};
- }
- Q_SCRIPTABLE
- QDBusObjectPath
- AddConnectionUnsaved(NMVariantMapMap connection)
- {
- return QDBusReply< QDBusObjectPath >{call(QDBus::BlockWithGui,
- QStringLiteral("AddConnectionUnsaved"),
- QVariant::fromValue(connection))};
- }
- Q_SCRIPTABLE
- QDBusObjectPath
- GetConnectionByUuid(QString uuid)
- {
- return QDBusReply< QDBusObjectPath >{call(QDBus::BlockWithGui,
- QStringLiteral("GetConnectionByUuid"),
- QVariant::fromValue(uuid))};
- }
- Q_SCRIPTABLE
- NMObjectPathsList
- ListConnections()
- {
- return QDBusReply< NMObjectPathsList >{call(QDBus::BlockWithGui,
- QStringLiteral("ListConnections"))};
- }
- Q_SCRIPTABLE
- bool LoadConnections(QStringList filenames, QStringList & failures)
- {
- const auto message = call(QDBus::BlockWithGui,
- QStringLiteral("LoadConnections"),
- QVariant::fromValue(filenames));
- QDBusPendingReply< bool, QStringList > pendingReply = message;
- Q_ASSERT(pendingReply.isFinished());
- if (pendingReply.isError()) {
- qCWarning(networkManagerInterfacesCategory).noquote()
- << tr("Asynchronous call finished with error (%1): %2")
- .arg(dbusMessageInfo(pendingReply.reply()),
- pendingReply.error().message());
- return {};
- }
- failures = pendingReply.argumentAt< 1 >();
- return pendingReply.argumentAt< 0 >();
- }
- bool ReloadConnections()
- {
- return QDBusReply< bool >{call(QDBus::BlockWithGui,
- QStringLiteral("ReloadConnections"))};
- }
- void SaveHostname(QString hostname)
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("SaveHostname"),
- QVariant::fromValue(hostname));
- }
- Q_SIGNALS :
- Q_SCRIPTABLE void ConnectionRemoved(QDBusObjectPath);
- Q_SCRIPTABLE void NewConnection(QDBusObjectPath);
- Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
- private Q_SLOTS :
- void propertiesChanged(QVariantMap properties)
- {
- QMapIterator< QString, QVariant > i{properties};
- while (i.hasNext()) {
- i.next();
- const auto signature = QStringLiteral("%1Changed()").arg(i.key());
- const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
- Q_ASSERT(!(signalIndex < 0));
- const auto signal = metaObject()->method(signalIndex);
- if (!signal.invoke(this, Qt::DirectConnection)) {
- qCCritical(networkManagerInterfacesCategory).noquote()
- << tr("Unable to emit %1 signal for %2 property")
- .arg(signature,
- i.key());
- }
- }
- }
- Q_SIGNALS :
- void CanModifyChanged();
- void ConnectionsChanged();
- void HostnameChanged();
- private :
- Q_DISABLE_COPY(NetworkManagerSettingsInterface)
- bool CanModify;
- NMObjectPathsList Connections;
- QString Hostname;
- };
- class NetworkManagerSettingsConnectionInterface
- : public QDBusAbstractInterface
- {
- Q_OBJECT
- Q_PROPERTY(bool Unsaved MEMBER Unsaved NOTIFY UnsavedChanged)
- public :
- NetworkManagerSettingsConnectionInterface(QDBusObjectPath path,
- QObject * const parent = Q_NULLPTR)
- : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
- path.path(),
- NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
- QDBusConnection::systemBus(),
- parent}
- {
- qDBusRegisterMetaType< NMVariantMapMap >();
- qDBusRegisterMetaType< QVariantMap >();
- connect(this, &NetworkManagerSettingsConnectionInterface::PropertiesChanged,
- this, &NetworkManagerSettingsConnectionInterface::propertiesChanged);
- }
- ~NetworkManagerSettingsConnectionInterface() Q_DECL_EQ_DEFAULT;
- public Q_SLOTS :
- Q_SCRIPTABLE
- void ClearSecrets()
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("ClearSecrets"));
- }
- Q_SCRIPTABLE
- void Delete()
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("Delete"));
- }
- Q_SCRIPTABLE
- NMVariantMapMap
- GetSecrets(QString settingName)
- {
- return QDBusReply< NMVariantMapMap >{call(QDBus::BlockWithGui,
- QStringLiteral("GetSecrets"),
- QVariant::fromValue(settingName))};
- }
- Q_SCRIPTABLE
- NMVariantMapMap
- GetSettings()
- {
- return QDBusReply< NMVariantMapMap >{call(QDBus::BlockWithGui,
- QStringLiteral("GetSettings"))};
- }
- Q_SCRIPTABLE
- void Save()
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("Save"));
- }
- Q_SCRIPTABLE
- void Update(NMVariantMapMap properties)
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("Update"),
- QVariant::fromValue(properties));
- }
- Q_SCRIPTABLE
- void UpdateUnsaved(NMVariantMapMap properties)
- {
- call(QDBus::BlockWithGui,
- QStringLiteral("UpdateUnsaved"),
- QVariant::fromValue(properties));
- }
- Q_SIGNALS :
- Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
- Q_SCRIPTABLE void Removed();
- Q_SCRIPTABLE void Updated();
- private Q_SLOTS :
- void propertiesChanged(QVariantMap properties)
- {
- QMapIterator< QString, QVariant > i{properties};
- while (i.hasNext()) {
- i.next();
- const auto signature = QStringLiteral("%1Changed()").arg(i.key());
- const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
- Q_ASSERT(!(signalIndex < 0));
- const auto signal = metaObject()->method(signalIndex);
- if (!signal.invoke(this, Qt::DirectConnection)) {
- qCCritical(networkManagerInterfacesCategory).noquote()
- << tr("Unable to emit %1 signal for %2 property")
- .arg(signature,
- i.key());
- }
- }
- }
- Q_SIGNALS :
- void UnsavedChanged();
- private :
- Q_DISABLE_COPY(NetworkManagerSettingsConnectionInterface)
- bool Unsaved;
- };
- class NetworkManagerAccessPointInterface
- : public QDBusAbstractInterface
- {
- Q_OBJECT
- Q_PROPERTY(uint Flags MEMBER Flags NOTIFY FlagsChanged)
- Q_PROPERTY(uint Frequency MEMBER Frequency NOTIFY FrequencyChanged)
- Q_PROPERTY(QString HwAddress MEMBER HwAddress NOTIFY HwAddressChanged)
- Q_PROPERTY(int LastSeen MEMBER LastSeen NOTIFY LastSeenChanged)
- Q_PROPERTY(uint MaxBitrate MEMBER MaxBitrate NOTIFY MaxBitrateChanged)
- Q_PROPERTY(uint Mode MEMBER Mode NOTIFY ModeChanged)
- Q_PROPERTY(uint RsnFlags MEMBER RsnFlags NOTIFY RsnFlagsChanged)
- Q_PROPERTY(QByteArray Ssid MEMBER Ssid NOTIFY SsidChanged)
- Q_PROPERTY(uchar Strength MEMBER Strength NOTIFY StrengthChanged)
- Q_PROPERTY(uint WpaFlags MEMBER WpaFlags NOTIFY WpaFlagsChanged)
- public :
- explicit
- NetworkManagerAccessPointInterface(QDBusObjectPath path,
- QObject * const parent = Q_NULLPTR)
- : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
- path.path(),
- NM_DBUS_INTERFACE_ACCESS_POINT,
- QDBusConnection::systemBus(),
- parent}
- {
- qDBusRegisterMetaType< QVariantMap >();
- connect(this, &NetworkManagerAccessPointInterface::PropertiesChanged,
- this, &NetworkManagerAccessPointInterface::propertiesChanged);
- }
- ~NetworkManagerAccessPointInterface() Q_DECL_EQ_DEFAULT;
- Q_SIGNALS :
- Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
- private Q_SLOTS :
- void propertiesChanged(QVariantMap properties)
- {
- QMapIterator< QString, QVariant > i{properties};
- while (i.hasNext()) {
- i.next();
- const auto signature = QStringLiteral("%1Changed()").arg(i.key());
- const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
- Q_ASSERT(!(signalIndex < 0));
- const auto signal = metaObject()->method(signalIndex);
- if (!signal.invoke(this, Qt::DirectConnection)) {
- qCCritical(networkManagerInterfacesCategory).noquote()
- << tr("Unable to emit %1 signal for %2 property")
- .arg(signature,
- i.key());
- }
- }
- }
- Q_SIGNALS :
- void FlagsChanged();
- void FrequencyChanged();
- void HwAddressChanged();
- void LastSeenChanged();
- void MaxBitrateChanged();
- void ModeChanged();
- void RsnFlagsChanged();
- void SsidChanged();
- void StrengthChanged();
- void WpaFlagsChanged();
- private :
- Q_DISABLE_COPY(NetworkManagerAccessPointInterface)
- uint Flags;
- uint Frequency;
- QString HwAddress;
- int LastSeen;
- uint MaxBitrate;
- uint Mode;
- uint RsnFlags;
- QByteArray Ssid;
- uchar Strength;
- uint WpaFlags;
- };
- class NetworkManagerActiveConnectionInterface
- : public QDBusAbstractInterface
- {
- Q_OBJECT
- Q_PROPERTY(QDBusObjectPath Connection MEMBER Connection NOTIFY ConnectionChanged)
- Q_PROPERTY(bool Default MEMBER Default NOTIFY DefaultChanged)
- Q_PROPERTY(bool Default6 MEMBER Default6 NOTIFY Default6Changed)
- Q_PROPERTY(NMObjectPathsList Devices MEMBER Devices NOTIFY DevicesChanged)
- Q_PROPERTY(QDBusObjectPath Dhcp4Config MEMBER Dhcp4Config NOTIFY Dhcp4ConfigChanged)
- Q_PROPERTY(QDBusObjectPath Dhcp6Config MEMBER Dhcp6Config NOTIFY Dhcp6ConfigChanged)
- Q_PROPERTY(QString Id MEMBER Id NOTIFY IdChanged)
- Q_PROPERTY(QDBusObjectPath Ip4Config MEMBER Ip4Config NOTIFY Ip4ConfigChanged)
- Q_PROPERTY(QDBusObjectPath Ip6Config MEMBER Ip6Config NOTIFY Ip6ConfigChanged)
- Q_PROPERTY(QDBusObjectPath Master MEMBER Master NOTIFY MasterChanged)
- Q_PROPERTY(QDBusObjectPath SpecificObject MEMBER SpecificObject NOTIFY SpecificObjectChanged)
- Q_PROPERTY(uint State MEMBER State NOTIFY StateChanged)
- Q_PROPERTY(QString Type MEMBER Type NOTIFY TypeChanged)
- Q_PROPERTY(QString Uuid MEMBER Uuid NOTIFY UuidChanged)
- Q_PROPERTY(bool Vpn MEMBER Vpn NOTIFY VpnChanged)
- public :
- NetworkManagerActiveConnectionInterface(QDBusObjectPath path,
- QObject * const parent = Q_NULLPTR)
- : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
- path.path(),
- NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
- QDBusConnection::systemBus(),
- parent}
- {
- qDBusRegisterMetaType< QVariantMap >();
- qDBusRegisterMetaType< NMObjectPathsList >();
- connect(this, &NetworkManagerActiveConnectionInterface::PropertiesChanged,
- this, &NetworkManagerActiveConnectionInterface::propertiesChanged);
- }
- ~NetworkManagerActiveConnectionInterface() Q_DECL_EQ_DEFAULT;
- Q_SIGNALS :
- Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
- private Q_SLOTS :
- void propertiesChanged(QVariantMap properties)
- {
- QMapIterator< QString, QVariant > i{properties};
- while (i.hasNext()) {
- i.next();
- const auto signature = QStringLiteral("%1Changed()").arg(i.key());
- const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
- Q_ASSERT(!(signalIndex < 0));
- const auto signal = metaObject()->method(signalIndex);
- if (!signal.invoke(this, Qt::DirectConnection)) {
- qCCritical(networkManagerInterfacesCategory).noquote()
- << tr("Unable to emit %1 signal for %2 property")
- .arg(signature,
- i.key());
- }
- }
- }
- Q_SIGNALS :
- void ConnectionChanged();
- void DefaultChanged();
- void Default6Changed();
- void DevicesChanged();
- void Dhcp4ConfigChanged();
- void Dhcp6ConfigChanged();
- void IdChanged();
- void Ip4ConfigChanged();
- void Ip6ConfigChanged();
- void MasterChanged();
- void SpecificObjectChanged();
- void StateChanged();
- void TypeChanged();
- void UuidChanged();
- void VpnChanged();
- private :
- Q_DISABLE_COPY(NetworkManagerActiveConnectionInterface)
- QDBusObjectPath Connection;
- bool Default;
- bool Default6;
- NMObjectPathsList Devices;
- QDBusObjectPath Dhcp4Config;
- QDBusObjectPath Dhcp6Config;
- QString Id;
- QDBusObjectPath Ip4Config;
- QDBusObjectPath Ip6Config;
- QDBusObjectPath Master;
- QDBusObjectPath SpecificObject;
- uint State;
- QString Type;
- QString Uuid;
- bool Vpn;
- };
- class NetworkManagerIP4ConfigInterface
- : public QDBusAbstractInterface
- {
- Q_OBJECT
- Q_PROPERTY(NMVariantMapList AddressData MEMBER AddressData NOTIFY AddressDataChanged)
- Q_PROPERTY(UIntListList Addresses MEMBER Addresses NOTIFY AddressesChanged)
- Q_PROPERTY(QStringList DnsOptions MEMBER DnsOptions NOTIFY DnsOptionsChanged)
- Q_PROPERTY(int DnsPriority MEMBER DnsPriority NOTIFY DnsPriorityChanged)
- Q_PROPERTY(QStringList Domains MEMBER Domains NOTIFY DomainsChanged)
- Q_PROPERTY(QString Gateway MEMBER Gateway NOTIFY GatewayChanged)
- Q_PROPERTY(UIntList Nameservers MEMBER Nameservers NOTIFY NameserversChanged)
- Q_PROPERTY(NMVariantMapList RouteData MEMBER RouteData NOTIFY RouteDataChanged)
- Q_PROPERTY(UIntListList Routes MEMBER Routes NOTIFY RoutesChanged)
- Q_PROPERTY(QStringList Searches MEMBER Searches NOTIFY SearchesChanged)
- Q_PROPERTY(UIntList WinsServers MEMBER WinsServers NOTIFY WinsServersChanged)
- public :
- NetworkManagerIP4ConfigInterface(QDBusObjectPath path,
- QObject * const parent = Q_NULLPTR)
- : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
- path.path(),
- NM_DBUS_INTERFACE_IP4_CONFIG,
- QDBusConnection::systemBus(),
- parent}
- {
- qDBusRegisterMetaType< QVariantMap >();
- qDBusRegisterMetaType< NMVariantMapList >();
- qDBusRegisterMetaType< UIntList >();
- qDBusRegisterMetaType< UIntListList >();
- qDBusRegisterMetaType< QStringList >();
- connect(this, &NetworkManagerIP4ConfigInterface::PropertiesChanged,
- this, &NetworkManagerIP4ConfigInterface::propertiesChanged);
- }
- ~NetworkManagerIP4ConfigInterface() Q_DECL_EQ_DEFAULT;
- Q_SIGNALS :
- Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
- private Q_SLOTS :
- void propertiesChanged(QVariantMap properties)
- {
- QMapIterator< QString, QVariant > i{properties};
- while (i.hasNext()) {
- i.next();
- const auto signature = QStringLiteral("%1Changed()").arg(i.key());
- const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
- Q_ASSERT(!(signalIndex < 0));
- const auto signal = metaObject()->method(signalIndex);
- if (!signal.invoke(this, Qt::DirectConnection)) {
- qCCritical(networkManagerInterfacesCategory).noquote()
- << tr("Unable to emit %1 signal for %2 property")
- .arg(signature,
- i.key());
- }
- }
- }
- Q_SIGNALS :
- void AddressDataChanged();
- void AddressesChanged();
- void DnsOptionsChanged();
- void DnsPriorityChanged();
- void DomainsChanged();
- void GatewayChanged();
- void NameserversChanged();
- void RouteDataChanged();
- void RoutesChanged();
- void SearchesChanged();
- void WinsServersChanged();
- private :
- Q_DISABLE_COPY(NetworkManagerIP4ConfigInterface)
- NMVariantMapList AddressData;
- UIntListList Addresses;
- QStringList DnsOptions;
- int DnsPriority;
- QStringList Domains;
- QString Gateway;
- UIntList Nameservers;
- NMVariantMapList RouteData;
- UIntListList Routes;
- QStringList Searches;
- UIntList WinsServers;
- };
- class NetworkManagerDHCP4ConfigInterface
- : public QDBusAbstractInterface
- {
- Q_OBJECT
- Q_PROPERTY(QVariantMap Options MEMBER Options NOTIFY OptionsChanged)
- public :
- NetworkManagerDHCP4ConfigInterface(QDBusObjectPath path,
- QObject * const parent = Q_NULLPTR)
- : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
- path.path(),
- NM_DBUS_INTERFACE_DHCP4_CONFIG,
- QDBusConnection::systemBus(),
- parent}
- {
- qDBusRegisterMetaType< QVariantMap >();
- connect(this, &NetworkManagerDHCP4ConfigInterface::PropertiesChanged,
- this, &NetworkManagerDHCP4ConfigInterface::propertiesChanged);
- }
- ~NetworkManagerDHCP4ConfigInterface() Q_DECL_EQ_DEFAULT;
- Q_SIGNALS :
- Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
- private Q_SLOTS :
- void propertiesChanged(QVariantMap properties)
- {
- QMapIterator< QString, QVariant > i{properties};
- while (i.hasNext()) {
- i.next();
- const auto signature = QStringLiteral("%1Changed()").arg(i.key());
- const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
- Q_ASSERT(!(signalIndex < 0));
- const auto signal = metaObject()->method(signalIndex);
- if (!signal.invoke(this, Qt::DirectConnection)) {
- qCCritical(networkManagerInterfacesCategory).noquote()
- << tr("Unable to emit %1 signal for %2 property")
- .arg(signature,
- i.key());
- }
- }
- }
- Q_SIGNALS :
- void OptionsChanged();
- private :
- Q_DISABLE_COPY(NetworkManagerDHCP4ConfigInterface)
- QVariantMap Options;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement