2017-10-06 15:55:46 +02:00
|
|
|
#include "qzeroconfservice.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QZeroConfServiceData : public QSharedData
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-10-19 20:51:49 +02:00
|
|
|
QString name;
|
|
|
|
|
QString type;
|
|
|
|
|
QString domain;
|
|
|
|
|
QString host;
|
|
|
|
|
QHostAddress ip;
|
|
|
|
|
QHostAddress ipv6;
|
|
|
|
|
quint32 interfaceIndex;
|
|
|
|
|
quint16 port = 0;
|
|
|
|
|
QMap <QByteArray, QByteArray> txt;
|
2017-10-06 15:55:46 +02:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QZeroConfService::QZeroConfService() : data(new QZeroConfServiceData)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QZeroConfService::QZeroConfService(const QZeroConfService &rhs) : data(rhs.data)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QZeroConfService &QZeroConfService::operator=(const QZeroConfService &rhs)
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
if (this != &rhs)
|
|
|
|
|
data.operator=(rhs.data);
|
|
|
|
|
return *this;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QZeroConfService::~QZeroConfService()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QZeroConfService::name() const
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
return data->name;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QZeroConfService::setName(const QString &name)
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
data->name = name;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QZeroConfService::type() const
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
return data->type;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QZeroConfService::setType(const QString &type)
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
data->type = type;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QZeroConfService::domain() const
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
return data->domain;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QZeroConfService::setDomain(const QString &domain)
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
data->domain = domain;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QZeroConfService::host() const
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
return data->host;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QZeroConfService::setHost(const QString &host)
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
data->host = host;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHostAddress QZeroConfService::ip() const
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
return data->ip;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QZeroConfService::setIp(QHostAddress &ip)
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
data->ip = ip;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHostAddress QZeroConfService::ipv6() const
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
return data->ipv6;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QZeroConfService::setIpv6(const QHostAddress &ipv6)
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
data->ipv6 = ipv6;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quint32 QZeroConfService::interfaceIndex() const
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
return data->interfaceIndex;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QZeroConfService::setInterfaceIndex(const quint32 &interfaceIndex)
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
data->interfaceIndex = interfaceIndex;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quint16 QZeroConfService::port() const
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
return data->port;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QZeroConfService::setPort(const quint16 port)
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
data->port = port;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMap<QByteArray, QByteArray> QZeroConfService::txt() const
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
return data->txt;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QZeroConfService::setTxt(const QMap<QByteArray, QByteArray> txt)
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
data->txt = txt;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QZeroConfService::appendTxt(QByteArray idx, QByteArray val)
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
data->txt[idx] = val;
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QZeroConfService::isValid() const
|
|
|
|
|
{
|
2017-10-17 13:52:15 +02:00
|
|
|
|
2017-10-19 20:51:49 +02:00
|
|
|
return (!data->name.isEmpty());
|
2017-10-06 15:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
2017-10-16 17:06:05 +02:00
|
|
|
bool QZeroConfService::operator==(const QZeroConfService &rhs) const
|
|
|
|
|
{
|
2017-10-19 20:51:49 +02:00
|
|
|
return this->name() == rhs.name() && (this->ip() == rhs.ip() || this->ipv6() == rhs.ipv6());
|
2017-10-16 17:06:05 +02:00
|
|
|
}
|