You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
smb4k/smb4k/core/smb4knetworkitems.h

488 lines
12 KiB

/***************************************************************************
smb4knetworkitems - Network items used by the Smb4KScanner class
to pass and store data.
-------------------
begin : Mi Jun 2 2004
copyright : (C) 2004 by Alexander Reinholdt
email : dustpuppy@mail.berlios.de
***************************************************************************/
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301 USA *
***************************************************************************/
#ifndef SMB4KNETWORKITEMS_H
#define SMB4KNETWORKITEMS_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// TQt includes
#include <tqobject.h>
#include <tqstring.h>
/**
* This class provides a container for a workgroup/domain found in the network
* neighborhood.
*/
class Smb4KWorkgroupItem
{
public:
/**
* The constructor.
*
* @param name The name of the workgroup/domain.
*
* @param master The master browser of the workgroup.
*
* @param masterIP The IP address of the workgroup master browser.
*/
Smb4KWorkgroupItem( const TQString &name,
const TQString &master,
const TQString &masterIP = TQString() );
/**
* Empty constructor.
*/
Smb4KWorkgroupItem() {}
/**
* The destructor.
*/
~Smb4KWorkgroupItem();
/**
* Returns the workgroup name.
*/
const TQString &name() const { return m_name; }
/**
* Returns the name of the master browser.
*/
const TQString &master() const { return m_master; }
/**
* Returns the IP address of the master browser. If it is not a valid
* IPv4 or IPv6 address, TQString() is returned.
*
* @returns the valid IP v4 or v6 address of the workgroup master browser
* or TQString().
*/
const TQString &masterIP() const { return m_ip; }
/**
* You can mark the master as 'pseudo' with this function. That means that
* this master was not reported as being the master browser of this
* workgroup, but it's the only one found (e.g. by a custom search).
*/
void setPseudoMaster();
/**
* Returns TRUE, if the master is a 'pseudo' master. @see setPseudoMaster()
* for further information.
*/
bool hasPseudoMaster() const { return m_pseudo; }
/**
* This function sets the IP address of the master browser.
*
* @param ip The IP address of the master browser
*/
void setMasterIP( const TQString &ip );
/**
* This function sets the master browser.
*
* @param name The name of the master browser
*
* @param ip The IP address of the master browser
*
* @param pseudo Determines if this is a real master browser or if
* it is a faked one, i.e. a pseudo master.
*/
void setMaster( const TQString &name,
const TQString &ip,
bool pseudo = false );
private:
/**
* The name of the workgroup.
*/
TQString m_name;
/**
* The name of the workgroup master.
*/
TQString m_master;
/**
* The IP address of the master.
*/
TQString m_ip;
/**
* Determines whether the master is a 'pseudo'-master.
*/
bool m_pseudo;
/**
* This function checks if the IP address is valid, i.e. the
* IP address is either IP v4 or IP v6. It returns either TRUE
* or FALSE.
*
* @param ip The IP address that's going to be checked.
*
* @returns TRUE if the IP address is valid and FALSE otherwise.
*/
bool ipIsValid( const TQString &ip );
};
/**
* This class provides a container for a host found in the network
* neighborhood.
*/
class Smb4KHostItem
{
public:
/**
* The default constructor.
*
* @param workgroup The workgroup/domain of the host
*
* @param name The name of the host
*
* @param comment The comment that describes the host. May be empty.
*
* @param ip The IP address of the host
*/
Smb4KHostItem( const TQString &workgroup,
const TQString &name,
const TQString &comment = TQString(),
const TQString &ip = TQString() );
/**
* The copy constructor.
*
* @param host A Smb4KHostItem representing a host.
*/
Smb4KHostItem( const Smb4KHostItem &host );
/**
* The empty constructor.
*/
Smb4KHostItem() {}
/**
* The destructor.
*/
~Smb4KHostItem();
/**
* Returns the workgroup the host is in.
*/
const TQString &workgroup() const { return m_workgroup; }
/**
* Returns the name of the host.
*/
const TQString &name() const { return m_name; }
/**
* Returns the IP address of the host.
*/
const TQString &ip() const { return m_ip; }
/**
* Returns the comment for this host.
*/
const TQString &comment() const { return m_comment; }
/**
* Sets the Server string that is reported by the host.
*/
void setServerString( const TQString &server );
/**
* Returns the Server string.
*/
const TQString &serverString() const { return m_server_string; }
/**
* Sets the OS string that is reported by the host.
*/
void setOSString( const TQString &os );
/**
* Returns the OS string.
*/
const TQString &osString() const { return m_os_string; }
/**
* This functions determines whether this host should be
* registered as a master browser.
*
* @param master Set this to TRUE if the host is a master browser.
*/
void setMaster( bool master );
/**
* This function tells you if the host is a master or not.
*
* @returns TRUE if the host is a master browser.
*/
const bool isMaster() const { return m_master; }
/**
* This function sets the IP address of a host.
*
* @param ip The IP address of a host
*/
void setIPAddress( const TQString &ip );
/**
* This function sets the command for a host.
*
* @param comment The comment
*/
void setComment( const TQString &comment );
/**
* This function is used to tell the host item, if a
* check for the IP address has already been performed.
*
* @param yes Should be set to TRUE if a check was performed.
*/
void setIPAddressChecked( bool yes );
/**
* Tells if a check for the IP address has already been performed.
*
* @returns TRUE if a check was performed, and FALSE otherwise.
*/
const bool ipAddressChecked() const { return m_ip_checked; }
/**
* This function is used to tell the host item, if a
* check for the information (OS and Server string ) has already been performed.
*
* @param yes Should be set to TRUE if a check was performed.
*/
void setInfoChecked( bool yes );
/**
* Tells if a check for the information (OS and Server string) has already
* been performed.
*
* @returns TRUE is the check was performed previously.
*/
const bool infoChecked() const { return m_info_checked; }
private:
/**
* The name of the workgroup.
*/
TQString m_workgroup;
/**
* The name of the host.
*/
TQString m_name;
/**
* The comment for this host.
*/
TQString m_comment;
/**
* The IP address of the host.
*/
TQString m_ip;
/**
* The Server string as reported by the host.
*/
TQString m_server_string;
/**
* The operating system string as reported by the host.
*/
TQString m_os_string;
/**
* This boolian determines if the host is a master browser
* or not.
*/
bool m_master;
/**
* This boolean tells if a check for the IP address was already
* performed.
*/
bool m_ip_checked;
/**
* This boolean tells if a check for the information (OS and server string)
* was already performed.
*/
bool m_info_checked;
/**
* This function checks if the IP address is valid, i.e. the
* IP address is either IP v4 or IP v6. It returns either TRUE
* or FALSE.
*
* @param ip The IP address that's going to be checked.
*
* @returns TRUE if the IP address is valid and FALSE otherwise.
*/
bool ipIsValid( const TQString &ip );
};
/**
* This class provides a container for a share found in the
* network neighborhood.
*/
class Smb4KShareItem
{
public:
/**
* The constructor.
*
* @param workgroup The workgroup/domain name.
*
* @param host The name of the host where the share is located.
*
* @param name The name of the share.
*
* @param type The type of the share as returned by the Samba programs, i.e.
* "Disk", "Printer", "IPC$" or "ADMIN$".
*
* @param comment The comment of the share.
*/
Smb4KShareItem( const TQString &workgroup,
const TQString &host,
const TQString &name,
const TQString &type,
const TQString &comment );
/**
* Empty constructor.
*/
Smb4KShareItem() {}
/**
* The destructor.
*/
~Smb4KShareItem();
/**
* Returns the workgroup of the host where the share is located.
*/
const TQString &workgroup() const { return m_workgroup; }
/**
* Returns the name of the host where the share is located.
*/
const TQString &host() const { return m_host; }
/**
* Returns the name of the share.
*/
const TQString &name() const { return m_name; }
/**
* Returns the type of the share.
*/
const TQString &plainType() const { return m_type; }
/**
* Returns a translated version of the type of the share.
*
* @returns The translated share type
*/
const TQString translatedType() const;
/**
* Returns the comment for this share.
*/
const TQString &comment() const { return m_comment; }
/**
* This function tells if the share is a hidden one.
*
* @returns TRUE is the share is a hidden one and FALSE otherwise.
*/
bool isHidden() const;
/**
* This function is TRUE if the share is a printer and
* FALSE otherwise.
*
* @returns TRUE if the share is a printer
*/
bool isPrinter() const;
/**
* This function returns TRUE if the share is an IPC$
* share and FALSE otherwise.
*
* @returns TRUE if the share is an IPC$ share
*/
bool isIPC() const;
/**
* This function returns TRUE if the share is an ADMIN$
* share and FALSE otherwise.
*
* @returns TRUE if the share is an ADMIN$ share
*/
bool isADMIN() const;
private:
/**
* The workgroup object.
*/
TQString m_workgroup;
/**
* The host name.
*/
TQString m_host;
/**
* The name of the share.
*/
TQString m_name;
/**
* The type of the share.
*/
TQString m_type;
/**
* The comment for this share.
*/
TQString m_comment;
};
#endif