XMPP::NetInterface Class Reference

Provides information about a network interface. More...

#include <netinterface.h>

List of all members.

Signals

void unavailable ()

Public Member Functions

 NetInterface (const QString &id, NetInterfaceManager *manager)
 ~NetInterface ()
bool isValid () const
QString id () const
QString name () const
QList< QHostAddress > addresses () const
QHostAddress gateway () const


Detailed Description

Provides information about a network interface.

NetInterface provides information about a particular network interface. Construct it by passing the interface id of interest (e.g. "eth0") and a NetInterfaceManager parent object. Interface ids can be obtained from NetInterfaceManager.

To test if a NetInterface is valid, call isValid(). Use name() to return a display-friendly name of the interface. The addresses() function returns a list of IP addresses for this interface. There may be a gateway IP address associated with this interface, which can be fetched with gateway().

Here's an example of how to print the IP addresses of eth0:

NetInterface iface("eth0");
if(iface.isValid())
{
        QList<QHostAddress> addrs = iface.addresses();
        for(int n = 0; n < addrs.count(); ++n)
                printf("%s\n", qPrintable(addrs[n].toString()));
}

If the interface goes away, the unavailable() signal is emitted and the NetInterface becomes invalid.

See also:
NetInterfaceManager


Constructor & Destructor Documentation

XMPP::NetInterface::NetInterface const QString &  id,
NetInterfaceManager manager
 

Constructs a new interface object with the given id and manager.

If id is not a valid interface id, then the object will not be valid (isValid() will return false). Normally it is not necessary to check for validity, since interface ids obtained from NetInterfaceManager are guaranteed to be valid until the event loop resumes.

See also:
isValid

XMPP::NetInterface::~NetInterface  ) 
 

Destroys the interface object.


Member Function Documentation

QList<QHostAddress> XMPP::NetInterface::addresses  )  const
 

Returns the addresses of this interface.

There will always be at least one address. In some cases there might be multiple, such as on Unix where it is possible for the same interface to have both an IPv4 and an IPv6 address.

QHostAddress XMPP::NetInterface::gateway  )  const
 

Returns the gateway of this interface.

If there is no gateway associated with this interface, a null QHostAddress is returned.

QString XMPP::NetInterface::id  )  const
 

Returns the id of this interface.

This is the id that was passed in the constructor.

bool XMPP::NetInterface::isValid  )  const
 

Returns true if the interface is valid, otherwise returns false.

See also:
unavailable

QString XMPP::NetInterface::name  )  const
 

Returns a display-friendly name of this interface.

The name may be the same as the id.

See also:
id

void XMPP::NetInterface::unavailable  )  [signal]
 

Notifies when the interface becomes unavailable.

Once this signal is emitted, the NetInterface object becomes invalid and is no longer very useful. A new NetInterface object must be created if a valid object with current information is desired.

Note:
If the interface information changes, the interface is considered to have become unavailable.
See also:
isValid


The documentation for this class was generated from the following file:
Generated on Sun Mar 18 17:58:51 2007 for IrisNet by  doxygen 1.4.6