Advertisement
tomilov

QDBus NetworkManager

Jul 19th, 2017
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2.  
  3. #include "nmdbusutilities.hpp"
  4. #include "nmdbusargumenttypes.hpp"
  5.  
  6. #include "utility.hpp"
  7.  
  8. #include <QtCore>
  9. #include <QtDBus>
  10.  
  11. #include <QLoggingCategory>
  12.  
  13. Q_DECLARE_LOGGING_CATEGORY(networkManagerInterfacesCategory)
  14.  
  15. inline
  16. QString
  17. dbusMessageInfo(QDBusMessage const & message)
  18. {
  19.     return QStringLiteral("service: %2; path: %2; interface: %3; member/method: %4; signature: %5")
  20.             .arg(message.service(),
  21.                  message.path(),
  22.                  message.interface(),
  23.                  message.member(),
  24.                  message.signature());
  25. }
  26.  
  27. class NetworkManagerInterface
  28.         : public QDBusAbstractInterface
  29. {
  30.  
  31.     Q_OBJECT
  32.  
  33.     Q_PROPERTY(QDBusObjectPath ActivatingConnection MEMBER ActivatingConnection NOTIFY ActivatingConnectionChanged)
  34.     Q_PROPERTY(NMObjectPathsList ActiveConnections MEMBER ActiveConnections NOTIFY ActiveConnectionsChanged)
  35.     Q_PROPERTY(NMObjectPathsList AllDevices MEMBER AllDevices NOTIFY AllDevicesChanged)
  36.     Q_PROPERTY(uint Connectivity MEMBER Connectivity NOTIFY ConnectivityChanged)
  37.     Q_PROPERTY(NMObjectPathsList Devices MEMBER Devices NOTIFY DevicesChanged)
  38.     Q_PROPERTY(QVariantMap GlobalDnsConfiguration MEMBER GlobalDnsConfiguration NOTIFY GlobalDnsConfigurationChanged)
  39.     Q_PROPERTY(uint Metered MEMBER Metered NOTIFY MeteredChanged)
  40.     Q_PROPERTY(bool NetworkingEnabled MEMBER NetworkingEnabled NOTIFY NetworkingEnabledChanged)
  41.     Q_PROPERTY(QDBusObjectPath PrimaryConnection MEMBER PrimaryConnection NOTIFY PrimaryConnectionChanged)
  42.     Q_PROPERTY(QString PrimaryConnectionType MEMBER PrimaryConnectionType NOTIFY PrimaryConnectionTypeChanged)
  43.     Q_PROPERTY(bool Startup MEMBER Startup NOTIFY StartupChanged)
  44.     Q_PROPERTY(uint State MEMBER State NOTIFY StateChanged)
  45.     Q_PROPERTY(QString Version MEMBER Version NOTIFY VersionChanged)
  46.     Q_PROPERTY(bool WimaxEnabled MEMBER WimaxEnabled NOTIFY WimaxEnabledChanged)
  47.     Q_PROPERTY(bool WimaxHardwareEnabled MEMBER WimaxHardwareEnabled NOTIFY WimaxHardwareEnabledChanged)
  48.     Q_PROPERTY(bool WirelessEnabled MEMBER WirelessEnabled NOTIFY WirelessEnabledChanged)
  49.     Q_PROPERTY(bool WirelessHardwareEnabled MEMBER WirelessHardwareEnabled NOTIFY WirelessHardwareEnabledChanged)
  50.     Q_PROPERTY(bool WwanEnabled MEMBER WwanEnabled NOTIFY WwanEnabledChanged)
  51.     Q_PROPERTY(bool WwanHardwareEnabled MEMBER WwanHardwareEnabled NOTIFY WwanHardwareEnabledChanged)
  52.  
  53. public :
  54.  
  55.     explicit
  56.     NetworkManagerInterface(QObject * const parent = Q_NULLPTR)
  57.         : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
  58.                                  QStringLiteral(NM_DBUS_PATH),
  59.                                  NM_DBUS_INTERFACE,
  60.                                  QDBusConnection::systemBus(),
  61.                                  parent}
  62.     {
  63.         qDBusRegisterMetaType< NMObjectPathsList >();
  64.         qDBusRegisterMetaType< NMVariantMapMap >();
  65.         qDBusRegisterMetaType< NMStringMap >();
  66.         qDBusRegisterMetaType< QVariantMap >();
  67.  
  68.         connect(this, &NetworkManagerInterface::PropertiesChanged,
  69.                 this, &NetworkManagerInterface::propertiesChanged);
  70.     }
  71.  
  72.  
  73.     ~NetworkManagerInterface() Q_DECL_EQ_DEFAULT;
  74.  
  75. public Q_SLOTS :
  76.  
  77.     Q_SCRIPTABLE
  78.     QDBusObjectPath
  79.     ActivateConnection(QDBusObjectPath connection,
  80.                        QDBusObjectPath device,
  81.                        QDBusObjectPath specificObject)
  82.     {
  83.         return QDBusReply< QDBusObjectPath >{call(QDBus::BlockWithGui,
  84.                                                   QStringLiteral("ActivateConnection"),
  85.                                                   QVariant::fromValue(connection),
  86.                                                   QVariant::fromValue(device),
  87.                                                   QVariant::fromValue(specificObject))};
  88.     }
  89.  
  90.     Q_SCRIPTABLE
  91.     QDBusObjectPath
  92.     AddAndActivateConnection(NMVariantMapMap connection,
  93.                              QDBusObjectPath device,
  94.                              QDBusObjectPath specificObject,
  95.                              QDBusObjectPath & activeConnection)
  96.     {
  97.         const auto message = call(QDBus::BlockWithGui,
  98.                                   QStringLiteral("AddAndActivateConnection"),
  99.                                   QVariant::fromValue(connection),
  100.                                   QVariant::fromValue(device),
  101.                                   QVariant::fromValue(specificObject));
  102.         QDBusPendingReply< QDBusObjectPath, QDBusObjectPath > pendingReply = message;
  103.         Q_ASSERT(pendingReply.isFinished());
  104.         if (pendingReply.isError()) {
  105.             qCWarning(networkManagerInterfacesCategory).noquote()
  106.                     << tr("Asynchronous call finished with error (%1): %2")
  107.                        .arg(dbusMessageInfo(pendingReply.reply()),
  108.                             pendingReply.error().message());
  109.             return {};
  110.         }
  111.         activeConnection = pendingReply.argumentAt< 1 >();
  112.         return pendingReply.argumentAt< 0 >();
  113.     }
  114.  
  115.     Q_SCRIPTABLE
  116.     uint CheckConnectivity()
  117.     {
  118.         return QDBusReply< uint >{call(QDBus::BlockWithGui,
  119.                                        QStringLiteral("CheckConnectivity"))};
  120.     }
  121.  
  122.     Q_SCRIPTABLE
  123.     void DeactivateConnection(QDBusObjectPath activeConnection)
  124.     {
  125.         call(QDBus::BlockWithGui,
  126.              QStringLiteral("DeactivateConnection"),
  127.              QVariant::fromValue(activeConnection));
  128.     }
  129.  
  130.     Q_SCRIPTABLE
  131.     void Enable(bool enable)
  132.     {
  133.         call(QDBus::BlockWithGui,
  134.              QStringLiteral("Enable"),
  135.              QVariant::fromValue(enable));
  136.     }
  137.  
  138.     Q_SCRIPTABLE
  139.     NMObjectPathsList
  140.     GetAllDevices()
  141.     {
  142.         return QDBusReply< NMObjectPathsList >{call(QDBus::BlockWithGui,
  143.                                                     QStringLiteral("GetAllDevices"))};
  144.     }
  145.  
  146.     Q_SCRIPTABLE
  147.     QDBusObjectPath
  148.     GetDeviceByIpIface(QString iface)
  149.     {
  150.         return QDBusReply< QDBusObjectPath >{call(QDBus::BlockWithGui,
  151.                                                   QStringLiteral("GetDeviceByIpIface"),
  152.                                                   QVariant::fromValue(iface))};
  153.     }
  154.  
  155.     Q_SCRIPTABLE
  156.     NMObjectPathsList
  157.     GetDevices()
  158.     {
  159.         return QDBusReply< NMObjectPathsList >{call(QDBus::BlockWithGui,
  160.                                                     QStringLiteral("GetDevices"))};
  161.     }
  162.  
  163.     Q_SCRIPTABLE
  164.     QString
  165.     GetLogging(QString & domains)
  166.     {
  167.         const auto message = call(QDBus::BlockWithGui,
  168.                                   QStringLiteral("GetLogging"));
  169.         QDBusPendingReply< QString, QString > pendingReply = message;
  170.         Q_ASSERT(pendingReply.isFinished());
  171.         if (pendingReply.isError()) {
  172.             qCWarning(networkManagerInterfacesCategory).noquote()
  173.                     << tr("Asynchronous call finished with error (%1): %2")
  174.                        .arg(dbusMessageInfo(pendingReply.reply()),
  175.                             pendingReply.error().message());
  176.             return {};
  177.         }
  178.         domains = pendingReply.argumentAt< 1 >();
  179.         return pendingReply.argumentAt< 0 >();
  180.     }
  181.  
  182.     Q_SCRIPTABLE
  183.     NMStringMap
  184.     GetPermissions()
  185.     {
  186.         return QDBusReply< NMStringMap >{call(QDBus::BlockWithGui,
  187.                                               QStringLiteral("GetPermissions"))};
  188.     }
  189.  
  190.     Q_SCRIPTABLE
  191.     void Reload(uint flags)
  192.     {
  193.         call(QDBus::BlockWithGui,
  194.              QStringLiteral("Reload"),
  195.              QVariant::fromValue(flags));
  196.     }
  197.  
  198.     Q_SCRIPTABLE
  199.     void SetLogging(QString level,
  200.                     QString domains)
  201.     {
  202.         call(QDBus::BlockWithGui,
  203.              QStringLiteral("SetLogging"),
  204.              QVariant::fromValue(level),
  205.              QVariant::fromValue(domains));
  206.     }
  207.  
  208.     Q_SCRIPTABLE
  209.     void Sleep(bool sleep)
  210.     {
  211.         call(QDBus::BlockWithGui,
  212.              QStringLiteral("Sleep"),
  213.              QVariant::fromValue(sleep));
  214.     }
  215.  
  216.     Q_SCRIPTABLE
  217.     uint state() // u state()
  218.     {
  219.         return QDBusReply< uint >{call(QDBus::BlockWithGui,
  220.                                        QStringLiteral("state"))};
  221.     }
  222.  
  223. Q_SIGNALS :
  224.  
  225.     Q_SCRIPTABLE void CheckPermissions();
  226.     Q_SCRIPTABLE void DeviceAdded(QDBusObjectPath);
  227.     Q_SCRIPTABLE void DeviceRemoved(QDBusObjectPath);
  228.     Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
  229.     Q_SCRIPTABLE void StateChanged(uint);
  230.  
  231. private Q_SLOTS :
  232.  
  233.     void propertiesChanged(QVariantMap properties)
  234.     {
  235.         QMapIterator< QString, QVariant > i{properties};
  236.         while (i.hasNext()) {
  237.             i.next();
  238.             const auto signature = QStringLiteral("%1Changed()").arg(i.key());
  239.             const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
  240.             Q_ASSERT(!(signalIndex < 0));
  241.             const auto signal = metaObject()->method(signalIndex);
  242.             if (!signal.invoke(this, Qt::DirectConnection)) {
  243.                 qCCritical(networkManagerInterfacesCategory).noquote()
  244.                         << tr("Unable to emit %1 signal for %2 property")
  245.                            .arg(signature,
  246.                                 i.key());
  247.             }
  248.         }
  249.     }
  250.  
  251. Q_SIGNALS :
  252.  
  253.     void ActivatingConnectionChanged();
  254.     void ActiveConnectionsChanged();
  255.     void AllDevicesChanged();
  256.     void ConnectivityChanged();
  257.     void DevicesChanged();
  258.     void GlobalDnsConfigurationChanged();
  259.     void MeteredChanged();
  260.     void NetworkingEnabledChanged();
  261.     void PrimaryConnectionChanged();
  262.     void PrimaryConnectionTypeChanged();
  263.     void StartupChanged();
  264.     void StateChanged();
  265.     void VersionChanged();
  266.     void WimaxEnabledChanged();
  267.     void WimaxHardwareEnabledChanged();
  268.     void WirelessEnabledChanged();
  269.     void WirelessHardwareEnabledChanged();
  270.     void WwanEnabledChanged();
  271.     void WwanHardwareEnabledChanged();
  272.  
  273. private :
  274.  
  275.     Q_DISABLE_COPY(NetworkManagerInterface)
  276.  
  277.     QDBusObjectPath ActivatingConnection;
  278.     NMObjectPathsList ActiveConnections;
  279.     NMObjectPathsList AllDevices;
  280.     uint Connectivity;
  281.     NMObjectPathsList Devices;
  282.     QVariantMap GlobalDnsConfiguration;
  283.     uint Metered;
  284.     bool NetworkingEnabled;
  285.     QDBusObjectPath PrimaryConnection;
  286.     QString PrimaryConnectionType;
  287.     bool Startup;
  288.     uint State;
  289.     QString Version;
  290.     bool WimaxEnabled;
  291.     bool WimaxHardwareEnabled;
  292.     bool WirelessEnabled;
  293.     bool WirelessHardwareEnabled;
  294.     bool WwanEnabled;
  295.     bool WwanHardwareEnabled;
  296.  
  297. };
  298.  
  299. class NetworkManagerDeviceInterface
  300.         : public QDBusAbstractInterface
  301. {
  302.  
  303.     Q_OBJECT
  304.  
  305.     Q_PROPERTY(QDBusObjectPath ActiveConnection MEMBER ActiveConnection NOTIFY ActiveConnectionChanged)
  306.     Q_PROPERTY(bool Autoconnect MEMBER Autoconnect NOTIFY AutoconnectChanged)
  307.     Q_PROPERTY(NMObjectPathsList AvailableConnections MEMBER AvailableConnections NOTIFY AvailableConnectionsChanged)
  308.     Q_PROPERTY(uint Capabilities MEMBER Capabilities NOTIFY CapabilitiesChanged)
  309.     Q_PROPERTY(uint DeviceType MEMBER DeviceType NOTIFY DeviceTypeChanged)
  310.     Q_PROPERTY(QDBusObjectPath Dhcp4Config MEMBER Dhcp4Config NOTIFY Dhcp4ConfigChanged)
  311.     Q_PROPERTY(QDBusObjectPath Dhcp6Config MEMBER Dhcp6Config NOTIFY Dhcp6ConfigChanged)
  312.     Q_PROPERTY(QString Driver MEMBER Driver NOTIFY DriverChanged)
  313.     Q_PROPERTY(QString DriverVersion MEMBER DriverVersion NOTIFY DriverVersionChanged)
  314.     Q_PROPERTY(bool FirmwareMissing MEMBER FirmwareMissing NOTIFY FirmwareMissingChanged)
  315.     Q_PROPERTY(QString FirmwareVersion MEMBER FirmwareVersion NOTIFY FirmwareVersionChanged)
  316.     Q_PROPERTY(QString Interface MEMBER Interface NOTIFY InterfaceChanged)
  317.     Q_PROPERTY(uint Ip4Address MEMBER Ip4Address NOTIFY Ip4AddressChanged)
  318.     Q_PROPERTY(QDBusObjectPath Ip4Config MEMBER Ip4Config NOTIFY Ip4ConfigChanged)
  319.     Q_PROPERTY(QDBusObjectPath Ip6Config MEMBER Ip6Config NOTIFY Ip6ConfigChanged)
  320.     Q_PROPERTY(QString IpInterface MEMBER IpInterface NOTIFY IpInterfaceChanged)
  321.     Q_PROPERTY(NMVariantMapList LldpNeighbors MEMBER LldpNeighbors NOTIFY LldpNeighborsChanged)
  322.     Q_PROPERTY(bool Managed MEMBER Managed NOTIFY ManagedChanged)
  323.     Q_PROPERTY(uint Metered MEMBER Metered NOTIFY MeteredChanged)
  324.     Q_PROPERTY(uint Mtu MEMBER Mtu NOTIFY MtuChanged)
  325.     Q_PROPERTY(bool NmPluginMissing MEMBER NmPluginMissing NOTIFY NmPluginMissingChanged)
  326.     Q_PROPERTY(QString PhysicalPortId MEMBER PhysicalPortId NOTIFY PhysicalPortIdChanged)
  327.     Q_PROPERTY(bool Real MEMBER Real NOTIFY RealChanged)
  328.     Q_PROPERTY(uint State MEMBER State NOTIFY StateChanged)
  329.     Q_PROPERTY(DeviceDBusStateReason StateReason MEMBER StateReason NOTIFY StateReasonChanged)
  330.     Q_PROPERTY(QString Udi MEMBER Udi NOTIFY UdiChanged)
  331.  
  332. public :
  333.  
  334.     NetworkManagerDeviceInterface(QDBusObjectPath path,
  335.                                   QObject * const parent = Q_NULLPTR)
  336.         : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
  337.                                  path.path(),
  338.                                  NM_DBUS_INTERFACE_DEVICE,
  339.                                  QDBusConnection::systemBus(),
  340.                                  parent}
  341.     {
  342.         qDBusRegisterMetaType< NMObjectPathsList >();
  343.         qDBusRegisterMetaType< NMVariantMapList >();
  344.         qDBusRegisterMetaType< DeviceDBusStateReason >();
  345.         qDBusRegisterMetaType< NMVariantMapMap >();
  346.         qDBusRegisterMetaType< QVariantMap >();
  347.  
  348.         connect(this, &NetworkManagerDeviceInterface::PropertiesChanged,
  349.                 this, &NetworkManagerDeviceInterface::propertiesChanged);
  350.     }
  351.  
  352.     ~NetworkManagerDeviceInterface() Q_DECL_EQ_DEFAULT;
  353.  
  354. public Q_SLOTS :
  355.  
  356.     Q_SCRIPTABLE
  357.     void Delete()
  358.     {
  359.         call(QDBus::BlockWithGui,
  360.              QStringLiteral("Delete"));
  361.     }
  362.  
  363.     Q_SCRIPTABLE
  364.     void Disconnect()
  365.     {
  366.         call(QDBus::BlockWithGui,
  367.              QStringLiteral("Disconnect"));
  368.     }
  369.  
  370.     Q_SCRIPTABLE
  371.     NMVariantMapMap
  372.     GetAppliedConnection(uint flags, qulonglong & versionId)
  373.     {
  374.         const auto message = call(QDBus::BlockWithGui,
  375.                                   QStringLiteral("GetAppliedConnection"),
  376.                                   QVariant::fromValue(flags));
  377.         QDBusPendingReply< NMVariantMapMap, qulonglong > pendingReply = message;
  378.         Q_ASSERT(pendingReply.isFinished());
  379.         if (pendingReply.isError()) {
  380.             qCWarning(networkManagerInterfacesCategory).noquote()
  381.                     << tr("Asynchronous call finished with error (%1): %2")
  382.                        .arg(dbusMessageInfo(pendingReply.reply()),
  383.                             pendingReply.error().message());
  384.             return {};
  385.         }
  386.         versionId = pendingReply.argumentAt< 1 >();
  387.         return pendingReply.argumentAt< 0 >();
  388.     }
  389.  
  390.     Q_SCRIPTABLE
  391.     void Reapply(NMVariantMapMap connection, qulonglong versionId, uint flags)
  392.     {
  393.         call(QDBus::BlockWithGui,
  394.              QStringLiteral("Reapply"),
  395.              QVariant::fromValue(connection),
  396.              QVariant::fromValue(versionId),
  397.              QVariant::fromValue(flags));
  398.     }
  399.  
  400. Q_SIGNALS :
  401.  
  402.     Q_SCRIPTABLE void StateChanged(uint newState, uint oldState, uint reason);
  403.     Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
  404.  
  405. private Q_SLOTS :
  406.  
  407.     void propertiesChanged(QVariantMap properties)
  408.     {
  409.         QMapIterator< QString, QVariant > i{properties};
  410.         while (i.hasNext()) {
  411.             i.next();
  412.             const auto signature = QStringLiteral("%1Changed()").arg(i.key());
  413.             const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
  414.             Q_ASSERT(!(signalIndex < 0));
  415.             const auto signal = metaObject()->method(signalIndex);
  416.             if (!signal.invoke(this, Qt::DirectConnection)) {
  417.                 qCCritical(networkManagerInterfacesCategory).noquote()
  418.                         << tr("Unable to emit %1 signal for %2 property")
  419.                            .arg(signature,
  420.                                 i.key());
  421.             }
  422.         }
  423.     }
  424.  
  425. Q_SIGNALS :
  426.  
  427.     void ActiveConnectionChanged();
  428.     void AutoconnectChanged();
  429.     void AvailableConnectionsChanged();
  430.     void CapabilitiesChanged();
  431.     void DeviceTypeChanged();
  432.     void Dhcp4ConfigChanged();
  433.     void Dhcp6ConfigChanged();
  434.     void DriverChanged();
  435.     void DriverVersionChanged();
  436.     void FirmwareMissingChanged();
  437.     void FirmwareVersionChanged();
  438.     void InterfaceChanged();
  439.     void Ip4AddressChanged();
  440.     void Ip4ConfigChanged();
  441.     void Ip6ConfigChanged();
  442.     void IpInterfaceChanged();
  443.     void LldpNeighborsChanged();
  444.     void ManagedChanged();
  445.     void MeteredChanged();
  446.     void MtuChanged();
  447.     void NmPluginMissingChanged();
  448.     void PhysicalPortIdChanged();
  449.     void RealChanged();
  450.     void StateChanged();
  451.     void StateReasonChanged();
  452.     void UdiChanged();
  453.  
  454. private :
  455.  
  456.     Q_DISABLE_COPY(NetworkManagerDeviceInterface)
  457.  
  458.     QDBusObjectPath ActiveConnection;
  459.     bool Autoconnect;
  460.     NMObjectPathsList AvailableConnections;
  461.     uint Capabilities;
  462.     uint DeviceType;
  463.     QDBusObjectPath Dhcp4Config;
  464.     QDBusObjectPath Dhcp6Config;
  465.     QString Driver;
  466.     QString DriverVersion;
  467.     bool FirmwareMissing;
  468.     QString FirmwareVersion;
  469.     QString Interface;
  470.     uint Ip4Address;
  471.     QDBusObjectPath Ip4Config;
  472.     QDBusObjectPath Ip6Config;
  473.     QString IpInterface;
  474.     NMVariantMapList LldpNeighbors;
  475.     bool Managed;
  476.     uint Metered;
  477.     uint Mtu;
  478.     bool NmPluginMissing;
  479.     QString PhysicalPortId;
  480.     bool Real;
  481.     uint State;
  482.     DeviceDBusStateReason StateReason;
  483.     QString Udi;
  484.  
  485. };
  486.  
  487. class NetworkManagerDeviceWiredInterface
  488.         : public QDBusAbstractInterface
  489. {
  490.  
  491.     Q_OBJECT
  492.  
  493.     Q_PROPERTY(bool Carrier MEMBER Carrier NOTIFY CarrierChanged)
  494.     Q_PROPERTY(QString HwAddress MEMBER HwAddress NOTIFY HwAddressChanged)
  495.     Q_PROPERTY(QString PermHwAddress MEMBER PermHwAddress NOTIFY PermHwAddressChanged)
  496.     Q_PROPERTY(QStringList S390Subchannels MEMBER S390Subchannels NOTIFY S390SubchannelsChanged)
  497.     Q_PROPERTY(uint Speed MEMBER Speed NOTIFY SpeedChanged)
  498.  
  499. public :
  500.  
  501.     NetworkManagerDeviceWiredInterface(NetworkManagerDeviceInterface * const di,
  502.                                        QObject * const parent = Q_NULLPTR)
  503.         : QDBusAbstractInterface{di->service(),
  504.                                  di->path(),
  505.                                  NM_DBUS_INTERFACE_DEVICE_WIRED,
  506.                                  di->connection(),
  507.                                  parent}
  508.         , deviceInterface{di}
  509.     {
  510.         deviceInterface->setParent(this);
  511.  
  512.         qDBusRegisterMetaType< QStringList >();
  513.         qDBusRegisterMetaType< QVariantMap >();
  514.  
  515.         connect(this, &NetworkManagerDeviceWiredInterface::PropertiesChanged,
  516.                 this, &NetworkManagerDeviceWiredInterface::propertiesChanged);
  517.     }
  518.  
  519.     ~NetworkManagerDeviceWiredInterface() Q_DECL_EQ_DEFAULT;
  520.  
  521.     NetworkManagerDeviceInterface * const deviceInterface;
  522.  
  523. Q_SIGNALS :
  524.  
  525.     Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
  526.  
  527. private Q_SLOTS :
  528.  
  529.     void propertiesChanged(QVariantMap properties)
  530.     {
  531.         QMapIterator< QString, QVariant > i{properties};
  532.         while (i.hasNext()) {
  533.             i.next();
  534.             const auto signature = QStringLiteral("%1Changed()").arg(i.key());
  535.             const auto normalizedSignature = QMetaObject::normalizedSignature(qUtf8Printable(signature));
  536.             int signalIndex = metaObject()->indexOfSignal(normalizedSignature.constData());
  537.             if (signalIndex < 0) {
  538.                 signalIndex = deviceInterface->metaObject()->indexOfSignal(normalizedSignature.constData());
  539.                 Q_ASSERT(!(signalIndex < 0));
  540.                 const auto signal = deviceInterface->metaObject()->method(signalIndex);
  541.                 if (!signal.invoke(deviceInterface, Qt::DirectConnection)) {
  542.                     qCCritical(networkManagerInterfacesCategory).noquote()
  543.                             << tr("Unable to emit %1 signal for %2 property")
  544.                                .arg(signature,
  545.                                     i.key());
  546.                 }
  547.             } else {
  548.                 const auto signal = metaObject()->method(signalIndex);
  549.                 if (!signal.invoke(this, Qt::DirectConnection)) {
  550.                     qCCritical(networkManagerInterfacesCategory).noquote()
  551.                             << tr("Unable to emit %1 signal for %2 property")
  552.                                .arg(signature,
  553.                                     i.key());
  554.                 }
  555.             }
  556.         }
  557.     }
  558.  
  559. Q_SIGNALS :
  560.  
  561.     void CarrierChanged();
  562.     void HwAddressChanged();
  563.     void PermHwAddressChanged();
  564.     void S390SubchannelsChanged();
  565.     void SpeedChanged();
  566.  
  567. private :
  568.  
  569.     Q_DISABLE_COPY(NetworkManagerDeviceWiredInterface)
  570.  
  571.     bool Carrier;
  572.     QString HwAddress;
  573.     QString PermHwAddress;
  574.     QStringList S390Subchannels;
  575.     uint Speed;
  576.  
  577. };
  578.  
  579. class NetworkManagerDeviceWirelessInterface
  580.         : public QDBusAbstractInterface
  581. {
  582.  
  583.     Q_OBJECT
  584.  
  585.     Q_PROPERTY(NMObjectPathsList AccessPoints MEMBER AccessPoints NOTIFY AccessPointsChanged)
  586.     Q_PROPERTY(QDBusObjectPath ActiveAccessPoint MEMBER ActiveAccessPoint NOTIFY ActiveAccessPointChanged)
  587.     Q_PROPERTY(uint Bitrate MEMBER Bitrate NOTIFY BitrateChanged)
  588.     Q_PROPERTY(QString HwAddress MEMBER HwAddress NOTIFY HwAddressChanged)
  589.     Q_PROPERTY(uint Mode MEMBER Mode NOTIFY ModeChanged)
  590.     Q_PROPERTY(QString PermHwAddress MEMBER PermHwAddress NOTIFY PermHwAddressChanged)
  591.     Q_PROPERTY(uint WirelessCapabilities MEMBER WirelessCapabilities NOTIFY WirelessCapabilitiesChanged)
  592.  
  593. public :
  594.  
  595.     NetworkManagerDeviceWirelessInterface(NetworkManagerDeviceInterface * const di,
  596.                                           QObject * const parent = Q_NULLPTR)
  597.         : QDBusAbstractInterface{di->service(),
  598.                                  di->path(),
  599.                                  NM_DBUS_INTERFACE_DEVICE_WIRELESS,
  600.                                  di->connection(),
  601.                                  parent}
  602.         , deviceInterface{di}
  603.     {
  604.         deviceInterface->setParent(this);
  605.  
  606.         qDBusRegisterMetaType< NMObjectPathsList >();
  607.         qDBusRegisterMetaType< QVariantMap >();
  608.  
  609.         connect(this, &NetworkManagerDeviceWirelessInterface::PropertiesChanged,
  610.                 this, &NetworkManagerDeviceWirelessInterface::propertiesChanged);
  611.     }
  612.  
  613.     ~NetworkManagerDeviceWirelessInterface() Q_DECL_EQ_DEFAULT;
  614.  
  615.     NetworkManagerDeviceInterface * const deviceInterface;
  616.  
  617. public Q_SLOTS :
  618.  
  619.     Q_SCRIPTABLE
  620.     NMObjectPathsList
  621.     GetAccessPoints()
  622.     {
  623.         return QDBusReply< NMObjectPathsList >{call(QDBus::BlockWithGui,
  624.                                                     QStringLiteral("GetAccessPoints"))};
  625.     }
  626.  
  627.     Q_SCRIPTABLE
  628.     NMObjectPathsList
  629.     GetAllAccessPoints()
  630.     {
  631.         return QDBusReply< NMObjectPathsList >{call(QDBus::BlockWithGui,
  632.                                                     QStringLiteral("GetAllAccessPoints"))};
  633.     }
  634.  
  635.     Q_SCRIPTABLE
  636.     void RequestScan(QVariantMap options)
  637.     {
  638.         call(QDBus::BlockWithGui,
  639.              QStringLiteral("RequestScan"),
  640.              QVariant::fromValue(options));
  641.     }
  642.  
  643. Q_SIGNALS :
  644.  
  645.     Q_SCRIPTABLE void AccessPointAdded(QDBusObjectPath);
  646.     Q_SCRIPTABLE void AccessPointRemoved(QDBusObjectPath);
  647.     Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
  648.     Q_SCRIPTABLE void ScanDone();
  649.  
  650. private Q_SLOTS :
  651.  
  652.     void propertiesChanged(QVariantMap properties)
  653.     {
  654.         QMapIterator< QString, QVariant > i{properties};
  655.         while (i.hasNext()) {
  656.             i.next();
  657.             const auto signature = QStringLiteral("%1Changed()").arg(i.key());
  658.             const auto normalizedSignature = QMetaObject::normalizedSignature(qUtf8Printable(signature));
  659.             int signalIndex = metaObject()->indexOfSignal(normalizedSignature.constData());
  660.             if (signalIndex < 0) {
  661.                 signalIndex = deviceInterface->metaObject()->indexOfSignal(normalizedSignature.constData());
  662.                 Q_ASSERT(!(signalIndex < 0));
  663.                 const auto signal = deviceInterface->metaObject()->method(signalIndex);
  664.                 if (!signal.invoke(deviceInterface, Qt::DirectConnection)) {
  665.                     qCCritical(networkManagerInterfacesCategory).noquote()
  666.                             << tr("Unable to emit %1 signal for %2 property")
  667.                                .arg(signature,
  668.                                     i.key());
  669.                 }
  670.             } else {
  671.                 const auto signal = metaObject()->method(signalIndex);
  672.                 if (!signal.invoke(this, Qt::DirectConnection)) {
  673.                     qCCritical(networkManagerInterfacesCategory).noquote()
  674.                             << tr("Unable to emit %1 signal for %2 property")
  675.                                .arg(signature,
  676.                                     i.key());
  677.                 }
  678.             }
  679.         }
  680.     }
  681.  
  682. Q_SIGNALS :
  683.  
  684.     void AccessPointsChanged();
  685.     void ActiveAccessPointChanged();
  686.     void BitrateChanged();
  687.     void HwAddressChanged();
  688.     void ModeChanged();
  689.     void PermHwAddressChanged();
  690.     void WirelessCapabilitiesChanged();
  691.  
  692. private :
  693.  
  694.     Q_DISABLE_COPY(NetworkManagerDeviceWirelessInterface)
  695.  
  696.     NMObjectPathsList AccessPoints;
  697.     QDBusObjectPath ActiveAccessPoint;
  698.     uint Bitrate;
  699.     QString HwAddress;
  700.     uint Mode;
  701.     QString PermHwAddress;
  702.     uint WirelessCapabilities;
  703.  
  704. };
  705.  
  706. class NetworkManagerSettingsInterface
  707.         : public QDBusAbstractInterface
  708. {
  709.  
  710.     Q_OBJECT
  711.  
  712.     Q_PROPERTY(bool CanModify MEMBER CanModify NOTIFY CanModifyChanged)
  713.     Q_PROPERTY(NMObjectPathsList Connections MEMBER Connections NOTIFY ConnectionsChanged)
  714.     Q_PROPERTY(QString Hostname MEMBER Hostname NOTIFY HostnameChanged)
  715.  
  716. public :
  717.  
  718.     explicit
  719.     NetworkManagerSettingsInterface(QObject * const parent = Q_NULLPTR)
  720.         : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
  721.                                  QStringLiteral(NM_DBUS_PATH_SETTINGS),
  722.                                  NM_DBUS_INTERFACE_SETTINGS,
  723.                                  QDBusConnection::systemBus(),
  724.                                  parent}
  725.     {
  726.         qDBusRegisterMetaType< NMObjectPathsList >();
  727.         qDBusRegisterMetaType< NMVariantMapMap >();
  728.         qDBusRegisterMetaType< QStringList >();
  729.         qDBusRegisterMetaType< QVariantMap >();
  730.  
  731.         connect(this, &NetworkManagerSettingsInterface::PropertiesChanged,
  732.                 this, &NetworkManagerSettingsInterface::propertiesChanged);
  733.     }
  734.  
  735.     ~NetworkManagerSettingsInterface() Q_DECL_EQ_DEFAULT;
  736.  
  737. public Q_SLOTS :
  738.  
  739.     Q_SCRIPTABLE
  740.     QDBusObjectPath
  741.     AddConnection(NMVariantMapMap connection)
  742.     {
  743.         return QDBusReply< QDBusObjectPath >{call(QDBus::BlockWithGui,
  744.                                                   QStringLiteral("AddConnection"),
  745.                                                   QVariant::fromValue(connection))};
  746.     }
  747.  
  748.     Q_SCRIPTABLE
  749.     QDBusObjectPath
  750.     AddConnectionUnsaved(NMVariantMapMap connection)
  751.     {
  752.         return QDBusReply< QDBusObjectPath >{call(QDBus::BlockWithGui,
  753.                                                   QStringLiteral("AddConnectionUnsaved"),
  754.                                                   QVariant::fromValue(connection))};
  755.     }
  756.  
  757.     Q_SCRIPTABLE
  758.     QDBusObjectPath
  759.     GetConnectionByUuid(QString uuid)
  760.     {
  761.         return QDBusReply< QDBusObjectPath >{call(QDBus::BlockWithGui,
  762.                                                   QStringLiteral("GetConnectionByUuid"),
  763.                                                   QVariant::fromValue(uuid))};
  764.     }
  765.  
  766.     Q_SCRIPTABLE
  767.     NMObjectPathsList
  768.     ListConnections()
  769.     {
  770.         return QDBusReply< NMObjectPathsList >{call(QDBus::BlockWithGui,
  771.                                                     QStringLiteral("ListConnections"))};
  772.     }
  773.  
  774.     Q_SCRIPTABLE
  775.     bool LoadConnections(QStringList filenames, QStringList & failures)
  776.     {
  777.         const auto message = call(QDBus::BlockWithGui,
  778.                                   QStringLiteral("LoadConnections"),
  779.                                   QVariant::fromValue(filenames));
  780.         QDBusPendingReply< bool, QStringList > pendingReply = message;
  781.         Q_ASSERT(pendingReply.isFinished());
  782.         if (pendingReply.isError()) {
  783.             qCWarning(networkManagerInterfacesCategory).noquote()
  784.                     << tr("Asynchronous call finished with error (%1): %2")
  785.                        .arg(dbusMessageInfo(pendingReply.reply()),
  786.                             pendingReply.error().message());
  787.             return {};
  788.         }
  789.         failures = pendingReply.argumentAt< 1 >();
  790.         return pendingReply.argumentAt< 0 >();
  791.     }
  792.  
  793.     bool ReloadConnections()
  794.     {
  795.         return QDBusReply< bool >{call(QDBus::BlockWithGui,
  796.                                        QStringLiteral("ReloadConnections"))};
  797.     }
  798.  
  799.     void SaveHostname(QString hostname)
  800.     {
  801.         call(QDBus::BlockWithGui,
  802.              QStringLiteral("SaveHostname"),
  803.              QVariant::fromValue(hostname));
  804.     }
  805.  
  806. Q_SIGNALS :
  807.  
  808.     Q_SCRIPTABLE void ConnectionRemoved(QDBusObjectPath);
  809.     Q_SCRIPTABLE void NewConnection(QDBusObjectPath);
  810.     Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
  811.  
  812. private Q_SLOTS :
  813.  
  814.     void propertiesChanged(QVariantMap properties)
  815.     {
  816.         QMapIterator< QString, QVariant > i{properties};
  817.         while (i.hasNext()) {
  818.             i.next();
  819.             const auto signature = QStringLiteral("%1Changed()").arg(i.key());
  820.             const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
  821.             Q_ASSERT(!(signalIndex < 0));
  822.             const auto signal = metaObject()->method(signalIndex);
  823.             if (!signal.invoke(this, Qt::DirectConnection)) {
  824.                 qCCritical(networkManagerInterfacesCategory).noquote()
  825.                         << tr("Unable to emit %1 signal for %2 property")
  826.                            .arg(signature,
  827.                                 i.key());
  828.             }
  829.         }
  830.     }
  831.  
  832. Q_SIGNALS :
  833.  
  834.     void CanModifyChanged();
  835.     void ConnectionsChanged();
  836.     void HostnameChanged();
  837.  
  838. private :
  839.  
  840.     Q_DISABLE_COPY(NetworkManagerSettingsInterface)
  841.  
  842.     bool CanModify;
  843.     NMObjectPathsList Connections;
  844.     QString Hostname;
  845.  
  846. };
  847.  
  848. class NetworkManagerSettingsConnectionInterface
  849.         : public QDBusAbstractInterface
  850. {
  851.  
  852.     Q_OBJECT
  853.  
  854.     Q_PROPERTY(bool Unsaved MEMBER Unsaved NOTIFY UnsavedChanged)
  855.  
  856. public :
  857.  
  858.     NetworkManagerSettingsConnectionInterface(QDBusObjectPath path,
  859.                                               QObject * const parent = Q_NULLPTR)
  860.         : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
  861.                                  path.path(),
  862.                                  NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
  863.                                  QDBusConnection::systemBus(),
  864.                                  parent}
  865.     {
  866.         qDBusRegisterMetaType< NMVariantMapMap >();
  867.         qDBusRegisterMetaType< QVariantMap >();
  868.  
  869.         connect(this, &NetworkManagerSettingsConnectionInterface::PropertiesChanged,
  870.                 this, &NetworkManagerSettingsConnectionInterface::propertiesChanged);
  871.     }
  872.  
  873.     ~NetworkManagerSettingsConnectionInterface() Q_DECL_EQ_DEFAULT;
  874.  
  875. public Q_SLOTS :
  876.  
  877.     Q_SCRIPTABLE
  878.     void ClearSecrets()
  879.     {
  880.         call(QDBus::BlockWithGui,
  881.              QStringLiteral("ClearSecrets"));
  882.     }
  883.  
  884.     Q_SCRIPTABLE
  885.     void Delete()
  886.     {
  887.         call(QDBus::BlockWithGui,
  888.              QStringLiteral("Delete"));
  889.     }
  890.  
  891.     Q_SCRIPTABLE
  892.     NMVariantMapMap
  893.     GetSecrets(QString settingName)
  894.     {
  895.         return QDBusReply< NMVariantMapMap >{call(QDBus::BlockWithGui,
  896.                                                   QStringLiteral("GetSecrets"),
  897.                                                   QVariant::fromValue(settingName))};
  898.     }
  899.  
  900.     Q_SCRIPTABLE
  901.     NMVariantMapMap
  902.     GetSettings()
  903.     {
  904.         return QDBusReply< NMVariantMapMap >{call(QDBus::BlockWithGui,
  905.                                                   QStringLiteral("GetSettings"))};
  906.     }
  907.  
  908.     Q_SCRIPTABLE
  909.     void Save()
  910.     {
  911.         call(QDBus::BlockWithGui,
  912.              QStringLiteral("Save"));
  913.     }
  914.  
  915.     Q_SCRIPTABLE
  916.     void Update(NMVariantMapMap properties)
  917.     {
  918.         call(QDBus::BlockWithGui,
  919.              QStringLiteral("Update"),
  920.              QVariant::fromValue(properties));
  921.     }
  922.  
  923.     Q_SCRIPTABLE
  924.     void UpdateUnsaved(NMVariantMapMap properties)
  925.     {
  926.         call(QDBus::BlockWithGui,
  927.              QStringLiteral("UpdateUnsaved"),
  928.              QVariant::fromValue(properties));
  929.     }
  930.  
  931. Q_SIGNALS :
  932.  
  933.     Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
  934.     Q_SCRIPTABLE void Removed();
  935.     Q_SCRIPTABLE void Updated();
  936.  
  937. private Q_SLOTS :
  938.  
  939.     void propertiesChanged(QVariantMap properties)
  940.     {
  941.         QMapIterator< QString, QVariant > i{properties};
  942.         while (i.hasNext()) {
  943.             i.next();
  944.             const auto signature = QStringLiteral("%1Changed()").arg(i.key());
  945.             const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
  946.             Q_ASSERT(!(signalIndex < 0));
  947.             const auto signal = metaObject()->method(signalIndex);
  948.             if (!signal.invoke(this, Qt::DirectConnection)) {
  949.                 qCCritical(networkManagerInterfacesCategory).noquote()
  950.                         << tr("Unable to emit %1 signal for %2 property")
  951.                            .arg(signature,
  952.                                 i.key());
  953.             }
  954.         }
  955.     }
  956.  
  957. Q_SIGNALS :
  958.  
  959.     void UnsavedChanged();
  960.  
  961. private :
  962.  
  963.     Q_DISABLE_COPY(NetworkManagerSettingsConnectionInterface)
  964.  
  965.     bool Unsaved;
  966.  
  967. };
  968.  
  969. class NetworkManagerAccessPointInterface
  970.         : public QDBusAbstractInterface
  971. {
  972.  
  973.     Q_OBJECT
  974.  
  975.     Q_PROPERTY(uint Flags MEMBER Flags NOTIFY FlagsChanged)
  976.     Q_PROPERTY(uint Frequency MEMBER Frequency NOTIFY FrequencyChanged)
  977.     Q_PROPERTY(QString HwAddress MEMBER HwAddress NOTIFY HwAddressChanged)
  978.     Q_PROPERTY(int LastSeen MEMBER LastSeen NOTIFY LastSeenChanged)
  979.     Q_PROPERTY(uint MaxBitrate MEMBER MaxBitrate NOTIFY MaxBitrateChanged)
  980.     Q_PROPERTY(uint Mode MEMBER Mode NOTIFY ModeChanged)
  981.     Q_PROPERTY(uint RsnFlags MEMBER RsnFlags NOTIFY RsnFlagsChanged)
  982.     Q_PROPERTY(QByteArray Ssid MEMBER Ssid NOTIFY SsidChanged)
  983.     Q_PROPERTY(uchar Strength MEMBER Strength NOTIFY StrengthChanged)
  984.     Q_PROPERTY(uint WpaFlags MEMBER WpaFlags NOTIFY WpaFlagsChanged)
  985.  
  986. public :
  987.  
  988.     explicit
  989.     NetworkManagerAccessPointInterface(QDBusObjectPath path,
  990.                                        QObject * const parent = Q_NULLPTR)
  991.         : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
  992.                                  path.path(),
  993.                                  NM_DBUS_INTERFACE_ACCESS_POINT,
  994.                                  QDBusConnection::systemBus(),
  995.                                  parent}
  996.     {
  997.         qDBusRegisterMetaType< QVariantMap >();
  998.  
  999.         connect(this, &NetworkManagerAccessPointInterface::PropertiesChanged,
  1000.                 this, &NetworkManagerAccessPointInterface::propertiesChanged);
  1001.     }
  1002.  
  1003.     ~NetworkManagerAccessPointInterface() Q_DECL_EQ_DEFAULT;
  1004.  
  1005. Q_SIGNALS :
  1006.  
  1007.     Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
  1008.  
  1009. private Q_SLOTS :
  1010.  
  1011.     void propertiesChanged(QVariantMap properties)
  1012.     {
  1013.         QMapIterator< QString, QVariant > i{properties};
  1014.         while (i.hasNext()) {
  1015.             i.next();
  1016.             const auto signature = QStringLiteral("%1Changed()").arg(i.key());
  1017.             const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
  1018.             Q_ASSERT(!(signalIndex < 0));
  1019.             const auto signal = metaObject()->method(signalIndex);
  1020.             if (!signal.invoke(this, Qt::DirectConnection)) {
  1021.                 qCCritical(networkManagerInterfacesCategory).noquote()
  1022.                         << tr("Unable to emit %1 signal for %2 property")
  1023.                            .arg(signature,
  1024.                                 i.key());
  1025.             }
  1026.         }
  1027.     }
  1028.  
  1029. Q_SIGNALS :
  1030.  
  1031.     void FlagsChanged();
  1032.     void FrequencyChanged();
  1033.     void HwAddressChanged();
  1034.     void LastSeenChanged();
  1035.     void MaxBitrateChanged();
  1036.     void ModeChanged();
  1037.     void RsnFlagsChanged();
  1038.     void SsidChanged();
  1039.     void StrengthChanged();
  1040.     void WpaFlagsChanged();
  1041.  
  1042. private :
  1043.  
  1044.     Q_DISABLE_COPY(NetworkManagerAccessPointInterface)
  1045.  
  1046.     uint Flags;
  1047.     uint Frequency;
  1048.     QString HwAddress;
  1049.     int LastSeen;
  1050.     uint MaxBitrate;
  1051.     uint Mode;
  1052.     uint RsnFlags;
  1053.     QByteArray Ssid;
  1054.     uchar Strength;
  1055.     uint WpaFlags;
  1056.  
  1057. };
  1058.  
  1059. class NetworkManagerActiveConnectionInterface
  1060.         : public QDBusAbstractInterface
  1061. {
  1062.  
  1063.     Q_OBJECT
  1064.  
  1065.     Q_PROPERTY(QDBusObjectPath Connection MEMBER Connection NOTIFY ConnectionChanged)
  1066.     Q_PROPERTY(bool Default MEMBER Default NOTIFY DefaultChanged)
  1067.     Q_PROPERTY(bool Default6 MEMBER Default6 NOTIFY Default6Changed)
  1068.     Q_PROPERTY(NMObjectPathsList Devices MEMBER Devices NOTIFY DevicesChanged)
  1069.     Q_PROPERTY(QDBusObjectPath Dhcp4Config MEMBER Dhcp4Config NOTIFY Dhcp4ConfigChanged)
  1070.     Q_PROPERTY(QDBusObjectPath Dhcp6Config MEMBER Dhcp6Config NOTIFY Dhcp6ConfigChanged)
  1071.     Q_PROPERTY(QString Id MEMBER Id NOTIFY IdChanged)
  1072.     Q_PROPERTY(QDBusObjectPath Ip4Config MEMBER Ip4Config NOTIFY Ip4ConfigChanged)
  1073.     Q_PROPERTY(QDBusObjectPath Ip6Config MEMBER Ip6Config NOTIFY Ip6ConfigChanged)
  1074.     Q_PROPERTY(QDBusObjectPath Master MEMBER Master NOTIFY MasterChanged)
  1075.     Q_PROPERTY(QDBusObjectPath SpecificObject MEMBER SpecificObject NOTIFY SpecificObjectChanged)
  1076.     Q_PROPERTY(uint State MEMBER State NOTIFY StateChanged)
  1077.     Q_PROPERTY(QString Type MEMBER Type NOTIFY TypeChanged)
  1078.     Q_PROPERTY(QString Uuid MEMBER Uuid NOTIFY UuidChanged)
  1079.     Q_PROPERTY(bool Vpn MEMBER Vpn NOTIFY VpnChanged)
  1080.  
  1081. public :
  1082.  
  1083.     NetworkManagerActiveConnectionInterface(QDBusObjectPath path,
  1084.                                             QObject * const parent = Q_NULLPTR)
  1085.         : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
  1086.                                  path.path(),
  1087.                                  NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
  1088.                                  QDBusConnection::systemBus(),
  1089.                                  parent}
  1090.     {
  1091.         qDBusRegisterMetaType< QVariantMap >();
  1092.         qDBusRegisterMetaType< NMObjectPathsList >();
  1093.  
  1094.         connect(this, &NetworkManagerActiveConnectionInterface::PropertiesChanged,
  1095.                 this, &NetworkManagerActiveConnectionInterface::propertiesChanged);
  1096.     }
  1097.  
  1098.     ~NetworkManagerActiveConnectionInterface() Q_DECL_EQ_DEFAULT;
  1099.  
  1100. Q_SIGNALS :
  1101.  
  1102.     Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
  1103.  
  1104. private Q_SLOTS :
  1105.  
  1106.     void propertiesChanged(QVariantMap properties)
  1107.     {
  1108.         QMapIterator< QString, QVariant > i{properties};
  1109.         while (i.hasNext()) {
  1110.             i.next();
  1111.             const auto signature = QStringLiteral("%1Changed()").arg(i.key());
  1112.             const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
  1113.             Q_ASSERT(!(signalIndex < 0));
  1114.             const auto signal = metaObject()->method(signalIndex);
  1115.             if (!signal.invoke(this, Qt::DirectConnection)) {
  1116.                 qCCritical(networkManagerInterfacesCategory).noquote()
  1117.                         << tr("Unable to emit %1 signal for %2 property")
  1118.                            .arg(signature,
  1119.                                 i.key());
  1120.             }
  1121.         }
  1122.     }
  1123.  
  1124. Q_SIGNALS :
  1125.  
  1126.     void ConnectionChanged();
  1127.     void DefaultChanged();
  1128.     void Default6Changed();
  1129.     void DevicesChanged();
  1130.     void Dhcp4ConfigChanged();
  1131.     void Dhcp6ConfigChanged();
  1132.     void IdChanged();
  1133.     void Ip4ConfigChanged();
  1134.     void Ip6ConfigChanged();
  1135.     void MasterChanged();
  1136.     void SpecificObjectChanged();
  1137.     void StateChanged();
  1138.     void TypeChanged();
  1139.     void UuidChanged();
  1140.     void VpnChanged();
  1141.  
  1142. private :
  1143.  
  1144.     Q_DISABLE_COPY(NetworkManagerActiveConnectionInterface)
  1145.  
  1146.     QDBusObjectPath Connection;
  1147.     bool Default;
  1148.     bool Default6;
  1149.     NMObjectPathsList Devices;
  1150.     QDBusObjectPath Dhcp4Config;
  1151.     QDBusObjectPath Dhcp6Config;
  1152.     QString Id;
  1153.     QDBusObjectPath Ip4Config;
  1154.     QDBusObjectPath Ip6Config;
  1155.     QDBusObjectPath Master;
  1156.     QDBusObjectPath SpecificObject;
  1157.     uint State;
  1158.     QString Type;
  1159.     QString Uuid;
  1160.     bool Vpn;
  1161.  
  1162. };
  1163.  
  1164. class NetworkManagerIP4ConfigInterface
  1165.         : public QDBusAbstractInterface
  1166. {
  1167.  
  1168.     Q_OBJECT
  1169.  
  1170.     Q_PROPERTY(NMVariantMapList AddressData MEMBER AddressData NOTIFY AddressDataChanged)
  1171.     Q_PROPERTY(UIntListList Addresses MEMBER Addresses NOTIFY AddressesChanged)
  1172.     Q_PROPERTY(QStringList DnsOptions MEMBER DnsOptions NOTIFY DnsOptionsChanged)
  1173.     Q_PROPERTY(int DnsPriority MEMBER DnsPriority NOTIFY DnsPriorityChanged)
  1174.     Q_PROPERTY(QStringList Domains MEMBER Domains NOTIFY DomainsChanged)
  1175.     Q_PROPERTY(QString Gateway MEMBER Gateway NOTIFY GatewayChanged)
  1176.     Q_PROPERTY(UIntList Nameservers MEMBER Nameservers NOTIFY NameserversChanged)
  1177.     Q_PROPERTY(NMVariantMapList RouteData MEMBER RouteData NOTIFY RouteDataChanged)
  1178.     Q_PROPERTY(UIntListList Routes MEMBER Routes NOTIFY RoutesChanged)
  1179.     Q_PROPERTY(QStringList Searches MEMBER Searches NOTIFY SearchesChanged)
  1180.     Q_PROPERTY(UIntList WinsServers MEMBER WinsServers NOTIFY WinsServersChanged)
  1181.  
  1182. public :
  1183.  
  1184.     NetworkManagerIP4ConfigInterface(QDBusObjectPath path,
  1185.                                      QObject * const parent = Q_NULLPTR)
  1186.         : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
  1187.                                  path.path(),
  1188.                                  NM_DBUS_INTERFACE_IP4_CONFIG,
  1189.                                  QDBusConnection::systemBus(),
  1190.                                  parent}
  1191.     {
  1192.         qDBusRegisterMetaType< QVariantMap >();
  1193.         qDBusRegisterMetaType< NMVariantMapList >();
  1194.         qDBusRegisterMetaType< UIntList >();
  1195.         qDBusRegisterMetaType< UIntListList >();
  1196.         qDBusRegisterMetaType< QStringList >();
  1197.  
  1198.         connect(this, &NetworkManagerIP4ConfigInterface::PropertiesChanged,
  1199.                 this, &NetworkManagerIP4ConfigInterface::propertiesChanged);
  1200.     }
  1201.  
  1202.     ~NetworkManagerIP4ConfigInterface() Q_DECL_EQ_DEFAULT;
  1203.  
  1204. Q_SIGNALS :
  1205.  
  1206.     Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
  1207.  
  1208. private Q_SLOTS :
  1209.  
  1210.     void propertiesChanged(QVariantMap properties)
  1211.     {
  1212.         QMapIterator< QString, QVariant > i{properties};
  1213.         while (i.hasNext()) {
  1214.             i.next();
  1215.             const auto signature = QStringLiteral("%1Changed()").arg(i.key());
  1216.             const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
  1217.             Q_ASSERT(!(signalIndex < 0));
  1218.             const auto signal = metaObject()->method(signalIndex);
  1219.             if (!signal.invoke(this, Qt::DirectConnection)) {
  1220.                 qCCritical(networkManagerInterfacesCategory).noquote()
  1221.                         << tr("Unable to emit %1 signal for %2 property")
  1222.                            .arg(signature,
  1223.                                 i.key());
  1224.             }
  1225.         }
  1226.     }
  1227.  
  1228. Q_SIGNALS :
  1229.  
  1230.     void AddressDataChanged();
  1231.     void AddressesChanged();
  1232.     void DnsOptionsChanged();
  1233.     void DnsPriorityChanged();
  1234.     void DomainsChanged();
  1235.     void GatewayChanged();
  1236.     void NameserversChanged();
  1237.     void RouteDataChanged();
  1238.     void RoutesChanged();
  1239.     void SearchesChanged();
  1240.     void WinsServersChanged();
  1241.  
  1242. private :
  1243.  
  1244.     Q_DISABLE_COPY(NetworkManagerIP4ConfigInterface)
  1245.  
  1246.     NMVariantMapList AddressData;
  1247.     UIntListList Addresses;
  1248.     QStringList DnsOptions;
  1249.     int DnsPriority;
  1250.     QStringList Domains;
  1251.     QString Gateway;
  1252.     UIntList Nameservers;
  1253.     NMVariantMapList RouteData;
  1254.     UIntListList Routes;
  1255.     QStringList Searches;
  1256.     UIntList WinsServers;
  1257.  
  1258. };
  1259.  
  1260. class NetworkManagerDHCP4ConfigInterface
  1261.         : public QDBusAbstractInterface
  1262. {
  1263.  
  1264.     Q_OBJECT
  1265.  
  1266.     Q_PROPERTY(QVariantMap Options MEMBER Options NOTIFY OptionsChanged)
  1267.  
  1268. public :
  1269.  
  1270.     NetworkManagerDHCP4ConfigInterface(QDBusObjectPath path,
  1271.                                        QObject * const parent = Q_NULLPTR)
  1272.         : QDBusAbstractInterface{QStringLiteral(NM_DBUS_SERVICE),
  1273.                                  path.path(),
  1274.                                  NM_DBUS_INTERFACE_DHCP4_CONFIG,
  1275.                                  QDBusConnection::systemBus(),
  1276.                                  parent}
  1277.     {
  1278.         qDBusRegisterMetaType< QVariantMap >();
  1279.  
  1280.         connect(this, &NetworkManagerDHCP4ConfigInterface::PropertiesChanged,
  1281.                 this, &NetworkManagerDHCP4ConfigInterface::propertiesChanged);
  1282.     }
  1283.  
  1284.     ~NetworkManagerDHCP4ConfigInterface() Q_DECL_EQ_DEFAULT;
  1285.  
  1286. Q_SIGNALS :
  1287.  
  1288.     Q_SCRIPTABLE void PropertiesChanged(QVariantMap);
  1289.  
  1290. private Q_SLOTS :
  1291.  
  1292.     void propertiesChanged(QVariantMap properties)
  1293.     {
  1294.         QMapIterator< QString, QVariant > i{properties};
  1295.         while (i.hasNext()) {
  1296.             i.next();
  1297.             const auto signature = QStringLiteral("%1Changed()").arg(i.key());
  1298.             const int signalIndex = metaObject()->indexOfSignal(QMetaObject::normalizedSignature(qUtf8Printable(signature)).constData());
  1299.             Q_ASSERT(!(signalIndex < 0));
  1300.             const auto signal = metaObject()->method(signalIndex);
  1301.             if (!signal.invoke(this, Qt::DirectConnection)) {
  1302.                 qCCritical(networkManagerInterfacesCategory).noquote()
  1303.                         << tr("Unable to emit %1 signal for %2 property")
  1304.                            .arg(signature,
  1305.                                 i.key());
  1306.             }
  1307.         }
  1308.     }
  1309.  
  1310. Q_SIGNALS :
  1311.  
  1312.     void OptionsChanged();
  1313.  
  1314. private :
  1315.  
  1316.     Q_DISABLE_COPY(NetworkManagerDHCP4ConfigInterface)
  1317.  
  1318.     QVariantMap Options;
  1319.  
  1320. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement