File indexing completed on 2024-04-07 07:30:22

0001 /*
0002     SPDX-FileCopyrightText: 2008, 2011 Will Stephenson <wstephenson@kde.org>
0003     SPDX-FileCopyrightText: 2013 Daniel Nicoletti <dantti12@gmail.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #ifndef NETWORKMANAGERQT_IPCONFIG_H
0009 #define NETWORKMANAGERQT_IPCONFIG_H
0010 
0011 #include "ipaddress.h"
0012 #include "iproute.h"
0013 #include <networkmanagerqt/networkmanagerqt_export.h>
0014 
0015 // To prevent signals in glib2 be defined by QT
0016 #undef signals
0017 #include <libnm/NetworkManager.h>
0018 #define signals Q_SIGNALS
0019 
0020 #include <QStringList>
0021 
0022 namespace NetworkManager
0023 {
0024 /**
0025  * This class represents IP configuration
0026  */
0027 class NETWORKMANAGERQT_EXPORT IpConfig
0028 {
0029 public:
0030     /**
0031      * Constructs an IP config object with a list of @p addresses, @p nameservers, @p domains and @p routes.
0032      */
0033     IpConfig(const IpAddresses &addresses, const QList<QHostAddress> &nameservers, const QStringList &domains, const IpRoutes &routes);
0034 
0035     /**
0036      * Constructs an empty IpConfig object.
0037      */
0038     IpConfig();
0039 
0040     /**
0041      * Destroys this IpConfig object.
0042      */
0043     ~IpConfig();
0044 
0045     /**
0046      * Constructs an IpConfig object that is a copy of the object @p other.
0047      */
0048     IpConfig(const IpConfig &other);
0049 
0050     /**
0051      * Configure this class using the information on the following @p path
0052      */
0053     void setIPv4Path(const QString &path);
0054 
0055     /**
0056      * Configure this class using the information on the following @p path
0057      */
0058     void setIPv6Path(const QString &path);
0059 
0060     /**
0061      * Returns a list of IP addresses and gateway related to this configuration.
0062      * Use IpAddress::ip() to access the IP address and IpAddress::gateway()
0063      * to access the gateway address.
0064      */
0065     NetworkManager::IpAddresses addresses() const;
0066 
0067     /**
0068      * Returns a list of domains related to this configuration.
0069      */
0070     QStringList domains() const;
0071 
0072     /**
0073      * Returns the gateway in use
0074      *
0075      * @since 0.9.9.0
0076      */
0077     QString gateway() const;
0078 
0079     /**
0080      * Returns a list of nameservers related to this configuration.
0081      */
0082     QList<QHostAddress> nameservers() const;
0083 
0084     /**
0085      * Returns a list of static routes (not the default gateway) related to this configuration.
0086      * Use @ref addresses() to retrieve the default gateway.
0087      */
0088     IpRoutes routes() const;
0089 
0090     /**
0091      * Returns a list of DNS searches.
0092      *
0093      * @since 0.9.9.0
0094      */
0095     QStringList searches() const;
0096 
0097     /**
0098      * Returns a list of DNS options that modify the behaviour of the DNS resolver.
0099      * @since 5.14.0
0100      */
0101     QStringList dnsOptions() const;
0102 
0103     /**
0104      * Makes a copy of the IpConfig object @p other.
0105      */
0106     IpConfig &operator=(const IpConfig &other);
0107 
0108     /**
0109      * Returns false if the list of IP addresses is empty
0110      */
0111     bool isValid() const;
0112 
0113 private:
0114     class Private;
0115     Private *const d;
0116 };
0117 
0118 } // namespace NetworkManager
0119 
0120 #endif // NETWORKMANAGERQT_IPCONFIG_H