File indexing completed on 2024-04-21 15:42:48
0001 /*************************************************************************** 0002 Smb4K's container class for information about a host. 0003 ------------------- 0004 begin : Sa Jan 26 2008 0005 copyright : (C) 2008-2019 by Alexander Reinholdt 0006 email : alexander.reinholdt@kdemail.net 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * This program is free software; you can redistribute it and/or modify * 0011 * it under the terms of the GNU General Public License as published by * 0012 * the Free Software Foundation; either version 2 of the License, or * 0013 * (at your option) any later version. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, but * 0016 * WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0018 * General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program; if not, write to the * 0022 * Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,* 0023 * MA 02110-1335, USA * 0024 ***************************************************************************/ 0025 0026 #ifndef SMB4KHOST_H 0027 #define SMB4KHOST_H 0028 0029 // application specific includes 0030 #include "smb4kbasicnetworkitem.h" 0031 0032 // Qt includes 0033 #include <QString> 0034 #include <QScopedPointer> 0035 #include <QHostAddress> 0036 0037 // forward declarations 0038 class Smb4KAuthInfo; 0039 class Smb4KHostPrivate; 0040 0041 0042 /** 0043 * This class is a container that carries information about a host found in 0044 * the network neighborhood. It is part of the core classes of Smb4K. 0045 * 0046 * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0047 */ 0048 0049 class Q_DECL_EXPORT Smb4KHost : public Smb4KBasicNetworkItem 0050 { 0051 friend class Smb4KHostPrivate; 0052 0053 public: 0054 /** 0055 * The default constructor. It takes the name of the host as only argument. 0056 * You have to set all other information with the other functions provided 0057 * by this class. 0058 * 0059 * @param name The name of the host 0060 */ 0061 explicit Smb4KHost(const QString &name); 0062 0063 /** 0064 * The copy constructor. This constructor takes a Smb4KHost item as argument 0065 * and copies its values. 0066 * 0067 * @param host The Smb4KHost object that is to be copied. 0068 */ 0069 Smb4KHost(const Smb4KHost &host); 0070 0071 /** 0072 * The empty constructor. It does not take any argument and you have to set 0073 * all information by the other functions provided by this class. 0074 */ 0075 Smb4KHost(); 0076 0077 /** 0078 * The destructor. 0079 */ 0080 ~Smb4KHost(); 0081 0082 /** 0083 * Set the name of the host. 0084 * 0085 * @param name The name of the host 0086 */ 0087 void setHostName(const QString &name); 0088 0089 /** 0090 * Returns the name of the host. 0091 * 0092 * @returns the host's name. 0093 */ 0094 QString hostName() const; 0095 0096 /** 0097 * Set the workgroup where this host is located. 0098 * 0099 * @param workgroup The workgroup name 0100 */ 0101 void setWorkgroupName(const QString &workgroup); 0102 0103 /** 0104 * Returns the name of the workgroup where this host is located. 0105 * 0106 * @returns the workgroup name. 0107 */ 0108 QString workgroupName() const; 0109 0110 /** 0111 * Set the IP address of this host. @p ip will only be accepted 0112 * if it is compatible with either IPv4 or IPv6. 0113 * 0114 * @param ip The IP address of this host. 0115 */ 0116 void setIpAddress(const QString &ip); 0117 0118 /** 0119 * Set the IP address of this host. @p ip will only be accepted 0120 * if it is compatible with either IPv4 or IPv6. 0121 * 0122 * @param ip The IP address of this host. 0123 */ 0124 void setIpAddress(const QHostAddress &address); 0125 0126 /** 0127 * Returns the IP address of the host. If the IP address was not 0128 * compatible with IPv4 and IPv6 or if no IP address was supplied, 0129 * an empty string is returned. 0130 * 0131 * @returns the host's IP address or an empty string. 0132 */ 0133 QString ipAddress() const; 0134 0135 /** 0136 * Returns TRUE if the host's IP address is set and FALSE otherwise. 0137 * 0138 * @returns TRUE if the host's IP address is known. 0139 */ 0140 bool hasIpAddress() const; 0141 0142 /** 0143 * Set the comment that was defined for the host. 0144 * 0145 * @param comment The comment string 0146 */ 0147 void setComment(const QString &comment); 0148 0149 /** 0150 * Returns the comment that was defined or an empty string if there 0151 * was no comment. 0152 * 0153 * @returns the comment or an empty string. 0154 */ 0155 QString comment() const; 0156 0157 /** 0158 * Set this host to be a master browser. 0159 * 0160 * @param master Set this to TRUE if the host is a master 0161 * browser. 0162 */ 0163 void setIsMasterBrowser(bool master); 0164 0165 /** 0166 * Returns TRUE if the host is a master browser and FALSE otherwise. 0167 * 0168 * @returns TRUE if the host is a master browser. 0169 */ 0170 bool isMasterBrowser() const; 0171 0172 /** 0173 * Set the port for the use in the URL. 0174 * 0175 * @param port The port 0176 */ 0177 void setPort(int port); 0178 0179 /** 0180 * Returns the port that is used in the URL. 0181 * 0182 * @returns the port. 0183 */ 0184 int port() const; 0185 0186 /** 0187 * Set the authentication information for the host. This function will add 0188 * the authentication information to the URL of the host. Any previous 0189 * user information including the login will be overwritten. 0190 * 0191 * @param authInfo The authentication information 0192 */ 0193 void setAuthInfo(Smb4KAuthInfo *authInfo); 0194 0195 /** 0196 * Set the login name for the host. 0197 * 0198 * @param login The login name 0199 */ 0200 void setLogin(const QString &login); 0201 0202 /** 0203 * Returns the login name. 0204 * 0205 * @returns the login name. 0206 */ 0207 QString login() const; 0208 0209 /** 0210 * Set the password used for authentication. 0211 * 0212 * @param passwd The password 0213 */ 0214 void setPassword(const QString &passwd); 0215 0216 /** 0217 * Returns the password. 0218 * 0219 * @returns the password. 0220 */ 0221 QString password() const; 0222 0223 /** 0224 * Updates the host item if the workgroup and host name of @p host and 0225 * of this item is equal. Otherwise it does nothing. 0226 * @param host The share object that is used to update 0227 * this object 0228 */ 0229 void update(Smb4KHost *host); 0230 0231 private: 0232 const QScopedPointer<Smb4KHostPrivate> d; 0233 }; 0234 0235 #endif