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.
57 lines
1.2 KiB
57 lines
1.2 KiB
#include "networkinterface.h"
|
|
|
|
NetworkInterface::NetworkInterface(int interfaceIndex, QObject *parent)
|
|
: QObject{parent},
|
|
m_qni{QNetworkInterface::interfaceFromIndex(interfaceIndex)}
|
|
{
|
|
setName(m_qni.name());
|
|
auto adresses = m_qni.addressEntries();
|
|
if ( adresses.size() == 0 )
|
|
setAddress("NO ADRESS");
|
|
else
|
|
setAddress(adresses.first().ip().toString());
|
|
}
|
|
|
|
NetworkInterface::NetworkInterface(QNetworkInterface iface, QObject *parent)
|
|
: QObject{parent},
|
|
m_qni{iface}
|
|
{
|
|
setName(m_qni.name());
|
|
auto adresses = m_qni.addressEntries();
|
|
if ( adresses.size() == 0 )
|
|
setAddress("NO ADRESS");
|
|
else
|
|
setAddress(adresses.first().ip().toString());
|
|
}
|
|
|
|
QString NetworkInterface::name() const
|
|
{
|
|
return m_name;
|
|
}
|
|
|
|
void NetworkInterface::setName(const QString &newName)
|
|
{
|
|
if (m_name == newName)
|
|
return;
|
|
m_name = newName;
|
|
emit nameChanged();
|
|
}
|
|
|
|
QString NetworkInterface::address() const
|
|
{
|
|
return m_address;
|
|
}
|
|
|
|
void NetworkInterface::setAddress(const QString &newAddress)
|
|
{
|
|
if (m_address == newAddress)
|
|
return;
|
|
m_address = newAddress;
|
|
emit addressChanged();
|
|
}
|
|
|
|
void NetworkInterface::shutdown()
|
|
{
|
|
qWarning() << "Shutting down interface";
|
|
}
|