File indexing completed on 2024-04-21 05:01:41

0001 /*
0002     Smb4K's container class for information about a workgroup.
0003 
0004     SPDX-FileCopyrightText: 2008-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef SMB4KWORKGROUP_H
0009 #define SMB4KWORKGROUP_H
0010 
0011 // application specific includes
0012 #include "smb4kbasicnetworkitem.h"
0013 
0014 // Qt includes
0015 #include <QHostAddress>
0016 #include <QScopedPointer>
0017 #include <QString>
0018 
0019 // forward declarations
0020 class Smb4KWorkgroupPrivate;
0021 
0022 /**
0023  * This class is a container that carries information about a workgroup or
0024  * domain found in the network neighborhood. It is part of the core classes
0025  * of Smb4K.
0026  *
0027  * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0028  */
0029 
0030 class Q_DECL_EXPORT Smb4KWorkgroup : public Smb4KBasicNetworkItem
0031 {
0032     friend class Smb4KWorkgroupPrivate;
0033 
0034 public:
0035     /**
0036      * The default constructor. It takes the name of the workgroup as only
0037      * argument. You have to set all other information by the other functions
0038      * provided by this class.
0039      *
0040      * @param name            The name of the workgroup or domain.
0041      */
0042     explicit Smb4KWorkgroup(const QString &name);
0043 
0044     /**
0045      * The copy constructor. This constructor takes another Smb4KWorkgroup item
0046      * as argument and copies its values.
0047      *
0048      * @param workgroup       The Smb4KWorkgroup item that is to be copied.
0049      */
0050     Smb4KWorkgroup(const Smb4KWorkgroup &workgroup);
0051 
0052     /**
0053      * The empty constructor. It does not take any argument and you have to
0054      * set all information by the other functions provided by this class.
0055      */
0056     Smb4KWorkgroup();
0057 
0058     /**
0059      * The destructor.
0060      */
0061     ~Smb4KWorkgroup();
0062 
0063     /**
0064      * Sets the name of the workgroup.
0065      *
0066      * @param name            The name of the workgroup
0067      */
0068     void setWorkgroupName(const QString &name);
0069 
0070     /**
0071      * This function returns the name of the workgroup.
0072      *
0073      * @returns the workgroup name.
0074      */
0075     QString workgroupName() const;
0076 
0077     /**
0078      * Sets the name of the master browser of this workgroup or domain.
0079      *
0080      * @param masterName      The name of the master browser
0081      */
0082     void setMasterBrowserName(const QString &name);
0083 
0084     /**
0085      * Returns the name of the master browser of this workgroup or domain.
0086      *
0087      * @returns the name of the master browser.
0088      */
0089     QString masterBrowserName() const;
0090 
0091     /**
0092      * Returns TRUE if there is a master browser and FALSE otherwise. No master
0093      * browser might be defined, if the DNS-SD method is used.
0094      *
0095      * @returns TRUE if there is a master browser.
0096      */
0097     bool hasMasterBrowser() const;
0098 
0099     /**
0100      * Set the IP address of the master browser. @p ip will only be accepted
0101      * if it is compatible with either IPv4 or IPv6.
0102      *
0103      * @param ip              The master browser's IP address
0104      */
0105     void setMasterBrowserIpAddress(const QString &ip);
0106 
0107     /**
0108      * Set the IP address of the master browser. @p address will only be accepted
0109      * if it is compatible with either IPv4 or IPv6.
0110      *
0111      * @param address         The master browser's IP address
0112      */
0113     void setMasterBrowserIpAddress(const QHostAddress &address);
0114 
0115     /**
0116      * Returns the IP address of the master browser of this workgroup
0117      * or domain. If the IP address was not compatible with IPv4 and
0118      * IPv6 or if no IP address was supplied, an empty string is returned.
0119      *
0120      * @returns the IP address of the master browser or an empty string.
0121      */
0122     QString masterBrowserIpAddress() const;
0123 
0124     /**
0125      * Returns TRUE if the workgroup/domain master browsers IP address is set and
0126      * FALSE otherwise.
0127      *
0128      * @returns TRUE if the master browsers IP address is known.
0129      */
0130     bool hasMasterBrowserIpAddress() const;
0131 
0132     /**
0133      * Updates the workgroup item if the workgroup name of @p workgroup and
0134      * of this item is equal. Otherwise it does nothing.
0135      * @param workgroup       The workgroup object that is used to update
0136      *                        this object
0137      */
0138     void update(Smb4KWorkgroup *workgroup);
0139 
0140     /**
0141      * Copy assignment operator
0142      */
0143     Smb4KWorkgroup &operator=(const Smb4KWorkgroup &other);
0144 
0145 private:
0146     const QScopedPointer<Smb4KWorkgroupPrivate> d;
0147 };
0148 
0149 Q_DECLARE_METATYPE(Smb4KWorkgroup)
0150 
0151 #endif