forked from jbagg/QtZeroConf
spaces to tabs
This commit is contained in:
@ -16,12 +16,12 @@
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QtZeroConf. If not, see <http://www.gnu.org/licenses/>.
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Project name : QtZeroConf
|
||||
File name : avahiclient.cpp
|
||||
Created : 20 July 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
Project name : QtZeroConf
|
||||
File name : avahiclient.cpp
|
||||
Created : 20 July 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Avahi-client wrapper for use in Desktop Linux systems
|
||||
Avahi-client wrapper for use in Desktop Linux systems
|
||||
---------------------------------------------------------------------------------------------------
|
||||
**************************************************************************************************/
|
||||
//#include <avahi-qt4/qt-watch.h> //
|
||||
@ -105,7 +105,7 @@ public:
|
||||
QString key = name + QString::number(interface);
|
||||
QZeroConfPrivate *ref = static_cast<QZeroConfPrivate *>(userdata);
|
||||
|
||||
QZeroConfService zcs;
|
||||
QZeroConfService zcs;
|
||||
|
||||
switch (event) {
|
||||
case AVAHI_BROWSER_FAILURE:
|
||||
@ -129,29 +129,29 @@ public:
|
||||
ref->pub->services.remove(key);
|
||||
emit ref->pub->serviceRemoved(zcs);
|
||||
break;
|
||||
case AVAHI_BROWSER_ALL_FOR_NOW:
|
||||
case AVAHI_BROWSER_ALL_FOR_NOW:
|
||||
case AVAHI_BROWSER_CACHE_EXHAUSTED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void resolveCallback(
|
||||
AVAHI_GCC_UNUSED AvahiServiceResolver *r,
|
||||
AVAHI_GCC_UNUSED AvahiIfIndex interface,
|
||||
AVAHI_GCC_UNUSED AvahiProtocol protocol,
|
||||
AvahiResolverEvent event,
|
||||
const char *name,
|
||||
const char *type,
|
||||
const char *domain,
|
||||
const char *host_name,
|
||||
const AvahiAddress *address,
|
||||
uint16_t port,
|
||||
AvahiStringList *txt,
|
||||
AvahiLookupResultFlags,
|
||||
AVAHI_GCC_UNUSED void* userdata)
|
||||
AVAHI_GCC_UNUSED AvahiServiceResolver *r,
|
||||
AVAHI_GCC_UNUSED AvahiIfIndex interface,
|
||||
AVAHI_GCC_UNUSED AvahiProtocol protocol,
|
||||
AvahiResolverEvent event,
|
||||
const char *name,
|
||||
const char *type,
|
||||
const char *domain,
|
||||
const char *host_name,
|
||||
const AvahiAddress *address,
|
||||
uint16_t port,
|
||||
AvahiStringList *txt,
|
||||
AvahiLookupResultFlags,
|
||||
AVAHI_GCC_UNUSED void* userdata)
|
||||
{
|
||||
bool newRecord = 0;
|
||||
QZeroConfService zcs;
|
||||
QZeroConfService zcs;
|
||||
QZeroConfPrivate *ref = static_cast<QZeroConfPrivate *>(userdata);
|
||||
|
||||
QString key = name + QString::number(interface);
|
||||
@ -159,21 +159,21 @@ public:
|
||||
if (ref->pub->services.contains(key))
|
||||
zcs = ref->pub->services[key];
|
||||
else {
|
||||
newRecord = 1;
|
||||
zcs.setName(name);
|
||||
zcs.setType(type);
|
||||
zcs.setDomain( domain);
|
||||
zcs.setHost( host_name);
|
||||
zcs.setInterfaceIndex(interface);
|
||||
zcs.setPort(port);
|
||||
newRecord = 1;
|
||||
zcs.setName(name);
|
||||
zcs.setType(type);
|
||||
zcs.setDomain( domain);
|
||||
zcs.setHost( host_name);
|
||||
zcs.setInterfaceIndex(interface);
|
||||
zcs.setPort(port);
|
||||
while (txt) // get txt records
|
||||
{
|
||||
QByteArray avahiText((const char *)txt->text, txt->size);
|
||||
QList<QByteArray> pair = avahiText.split('=');
|
||||
if (pair.size() == 2)
|
||||
zcs.appendTxt(pair.at(0), pair.at(1));
|
||||
zcs.appendTxt(pair.at(0), pair.at(1));
|
||||
else
|
||||
zcs.appendTxt(pair.at(0));
|
||||
zcs.appendTxt(pair.at(0));
|
||||
txt = txt->next;
|
||||
}
|
||||
ref->pub->services.insert(key, zcs);
|
||||
@ -181,11 +181,11 @@ public:
|
||||
|
||||
char a[AVAHI_ADDRESS_STR_MAX];
|
||||
avahi_address_snprint(a, sizeof(a), address);
|
||||
QHostAddress addr(a);
|
||||
QHostAddress addr(a);
|
||||
if (protocol == AVAHI_PROTO_INET6)
|
||||
zcs.setIpv6(addr);
|
||||
zcs.setIpv6(addr);
|
||||
else if (protocol == AVAHI_PROTO_INET)
|
||||
zcs.setIp(addr);
|
||||
zcs.setIp(addr);
|
||||
|
||||
if (newRecord)
|
||||
emit ref->pub->serviceAdded(zcs);
|
||||
@ -196,7 +196,7 @@ public:
|
||||
zcs = ref->pub->services[key];
|
||||
ref->pub->services.remove(key);
|
||||
emit ref->pub->serviceRemoved(zcs);
|
||||
// don't delete the resolver here...we need to keep it around so Avahi will keep updating....might be able to resolve the service in the future
|
||||
// don't delete the resolver here...we need to keep it around so Avahi will keep updating....might be able to resolve the service in the future
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,9 +207,9 @@ public:
|
||||
avahi_service_browser_free(browser);
|
||||
browser = NULL;
|
||||
|
||||
QMap<QString, QZeroConfService>::iterator i;
|
||||
QMap<QString, QZeroConfService>::iterator i;
|
||||
for (i = pub->services.begin(); i != pub->services.end(); i++) {
|
||||
emit pub->serviceRemoved(i.value());
|
||||
emit pub->serviceRemoved(i.value());
|
||||
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ public:
|
||||
|
||||
QMap<QString, AvahiServiceResolver *>::iterator r;
|
||||
for (r = resolvers.begin(); r != resolvers.end(); r++)
|
||||
avahi_service_resolver_free(*r);
|
||||
avahi_service_resolver_free(*r);
|
||||
resolvers.clear();
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ void QZeroConf::clearServiceTxtRecords()
|
||||
|
||||
void QZeroConf::startBrowser(QString type, QAbstractSocket::NetworkLayerProtocol protocol)
|
||||
{
|
||||
AvahiProtocol avahiProtocol;
|
||||
AvahiProtocol avahiProtocol;
|
||||
|
||||
if (pri->browser)
|
||||
emit error(QZeroConf::browserFailed);
|
||||
|
@ -16,12 +16,12 @@
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QtZeroConf. If not, see <http://www.gnu.org/licenses/>.
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Project name : QtZeroConf
|
||||
File name : avahicore.cpp
|
||||
Created : 9 September 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
Project name : QtZeroConf
|
||||
File name : avahicore.cpp
|
||||
Created : 9 September 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Avahi-core wrapper for use in embedded Linux systems (Android)
|
||||
Avahi-core wrapper for use in embedded Linux systems (Android)
|
||||
---------------------------------------------------------------------------------------------------
|
||||
**************************************************************************************************/
|
||||
//#include <avahi-qt4/qt-watch.h> //
|
||||
@ -67,9 +67,9 @@ public:
|
||||
switch (state) {
|
||||
case AVAHI_SERVER_RUNNING:
|
||||
ref->ready = 1;
|
||||
if (ref->registerWaiting) {
|
||||
ref->registerWaiting = 0;
|
||||
ref->registerService(ref->name.toUtf8(), ref->type.toUtf8(), ref->domain.toUtf8(), ref->port);
|
||||
if (ref->registerWaiting) {
|
||||
ref->registerWaiting = 0;
|
||||
ref->registerService(ref->name.toUtf8(), ref->type.toUtf8(), ref->domain.toUtf8(), ref->port);
|
||||
}
|
||||
break;
|
||||
case AVAHI_SERVER_COLLISION:
|
||||
@ -147,19 +147,19 @@ public:
|
||||
}
|
||||
|
||||
static void resolveCallback(
|
||||
AVAHI_GCC_UNUSED AvahiSServiceResolver *r,
|
||||
AVAHI_GCC_UNUSED AvahiIfIndex interface,
|
||||
AVAHI_GCC_UNUSED AvahiProtocol protocol,
|
||||
AvahiResolverEvent event,
|
||||
const char *name,
|
||||
const char *type,
|
||||
const char *domain,
|
||||
const char *host_name,
|
||||
const AvahiAddress *address,
|
||||
uint16_t port,
|
||||
AvahiStringList *txt,
|
||||
AvahiLookupResultFlags,
|
||||
AVAHI_GCC_UNUSED void* userdata)
|
||||
AVAHI_GCC_UNUSED AvahiSServiceResolver *r,
|
||||
AVAHI_GCC_UNUSED AvahiIfIndex interface,
|
||||
AVAHI_GCC_UNUSED AvahiProtocol protocol,
|
||||
AvahiResolverEvent event,
|
||||
const char *name,
|
||||
const char *type,
|
||||
const char *domain,
|
||||
const char *host_name,
|
||||
const AvahiAddress *address,
|
||||
uint16_t port,
|
||||
AvahiStringList *txt,
|
||||
AvahiLookupResultFlags,
|
||||
AVAHI_GCC_UNUSED void* userdata)
|
||||
{
|
||||
bool newRecord = 0;
|
||||
QZeroConfService *zcs;
|
||||
|
44
bonjour.cpp
44
bonjour.cpp
@ -16,12 +16,12 @@
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QtZeroConf. If not, see <http://www.gnu.org/licenses/>.
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Project name : QtZeroConf
|
||||
File name : bonjour.cpp
|
||||
Created : 20 July 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
Project name : QtZeroConf
|
||||
File name : bonjour.cpp
|
||||
Created : 20 July 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Wrapper for Apple's Bonjour library for use on Windows, MACs and iOS
|
||||
Wrapper for Apple's Bonjour library for use on Windows, MACs and iOS
|
||||
---------------------------------------------------------------------------------------------------
|
||||
**************************************************************************************************/
|
||||
#include "qzeroconf.h"
|
||||
@ -69,7 +69,7 @@ void QZeroConfPrivate::resolve(void)
|
||||
{
|
||||
DNSServiceErrorType err;
|
||||
|
||||
err = DNSServiceResolve(&resolver, kDNSServiceFlagsTimeout, newService.interfaceIndex(), newService.name().toUtf8(), newService.type().toUtf8(), newService.domain().toUtf8(), (DNSServiceResolveReply) resolverCallback, this);
|
||||
err = DNSServiceResolve(&resolver, kDNSServiceFlagsTimeout, newService.interfaceIndex(), newService.name().toUtf8(), newService.type().toUtf8(), newService.domain().toUtf8(), (DNSServiceResolveReply) resolverCallback, this);
|
||||
if (err == kDNSServiceErr_NoError) {
|
||||
int sockfd = DNSServiceRefSockFD(resolver);
|
||||
if (sockfd == -1) {
|
||||
@ -103,7 +103,7 @@ void DNSSD_API QZeroConfPrivate::browseCallback(DNSServiceRef, DNSServiceFlags f
|
||||
const char *type, const char *domain, void *userdata)
|
||||
{
|
||||
QString key;
|
||||
QZeroConfService zcs;
|
||||
QZeroConfService zcs;
|
||||
QZeroConfPrivate *ref = static_cast<QZeroConfPrivate *>(userdata);
|
||||
|
||||
//qDebug() << name;
|
||||
@ -111,12 +111,12 @@ void DNSSD_API QZeroConfPrivate::browseCallback(DNSServiceRef, DNSServiceFlags f
|
||||
key = name + QString::number(interfaceIndex);
|
||||
if (flags & kDNSServiceFlagsAdd) {
|
||||
if (!ref->pub->services.contains(key)) {
|
||||
//zcs = new QZeroConfService;
|
||||
zcs.setName(name);
|
||||
zcs.setType( type);
|
||||
zcs.setDomain(domain);
|
||||
zcs.setInterfaceIndex(interfaceIndex);
|
||||
if (!ref->newService.isValid()) {
|
||||
//zcs = new QZeroConfService;
|
||||
zcs.setName(name);
|
||||
zcs.setType( type);
|
||||
zcs.setDomain(domain);
|
||||
zcs.setInterfaceIndex(interfaceIndex);
|
||||
if (!ref->newService.isValid()) {
|
||||
ref->newService = zcs;
|
||||
ref->resolve();
|
||||
}
|
||||
@ -157,15 +157,15 @@ void DNSSD_API QZeroConfPrivate::resolverCallback(DNSServiceRef, DNSServiceFlags
|
||||
QByteArray avahiText((const char *)txtRecord, recLen);
|
||||
QList<QByteArray> pair = avahiText.split('=');
|
||||
if (pair.size() == 2)
|
||||
ref->newService.appendTxt(pair.at(0), pair.at(1));
|
||||
ref->newService.appendTxt(pair.at(0), pair.at(1));
|
||||
else
|
||||
ref->newService.appendTxt(pair.at(0));
|
||||
ref->newService.appendTxt(pair.at(0));
|
||||
|
||||
txtLen-= recLen + 1;
|
||||
txtRecord+= recLen;
|
||||
}
|
||||
ref->newService.setHost(hostName);
|
||||
ref->newService.setPort(qFromBigEndian<quint16>(port));
|
||||
ref->newService.setHost(hostName);
|
||||
ref->newService.setPort(qFromBigEndian<quint16>(port));
|
||||
err = DNSServiceGetAddrInfo(&ref->resolver, kDNSServiceFlagsForceMulticast, interfaceIndex, ref->protocol, hostName, (DNSServiceGetAddrInfoReply) addressReply, ref);
|
||||
if (err == kDNSServiceErr_NoError) {
|
||||
int sockfd = DNSServiceRefSockFD(ref->resolver);
|
||||
@ -198,11 +198,11 @@ void DNSSD_API QZeroConfPrivate::addressReply(DNSServiceRef sdRef,
|
||||
if ((flags & kDNSServiceFlagsAdd) != 0) {
|
||||
QHostAddress hAddress(address);
|
||||
if (hAddress.protocol() == QAbstractSocket::IPv6Protocol)
|
||||
ref->newService.setIpv6(hAddress);
|
||||
ref->newService.setIpv6(hAddress);
|
||||
else
|
||||
ref->newService.setIp(hAddress);
|
||||
ref->newService.setIp(hAddress);
|
||||
|
||||
QString key = ref->newService.name() + QString::number(interfaceIndex);
|
||||
QString key = ref->newService.name() + QString::number(interfaceIndex);
|
||||
if (!ref->pub->services.contains(key)) {
|
||||
ref->pub->services.insert(key, ref->newService);
|
||||
emit ref->pub->serviceAdded(ref->newService);
|
||||
@ -212,7 +212,7 @@ void DNSSD_API QZeroConfPrivate::addressReply(DNSServiceRef sdRef,
|
||||
|
||||
}
|
||||
if (!(flags & kDNSServiceFlagsMoreComing)) {
|
||||
ref->newService = QZeroConfService(); // newService resolve succeeded so don't let cleanUp delete it!
|
||||
ref->newService = QZeroConfService(); // newService resolve succeeded so don't let cleanUp delete it!
|
||||
ref->cleanUp(ref->resolver);
|
||||
}
|
||||
}
|
||||
@ -246,7 +246,7 @@ void QZeroConfPrivate::cleanUp(DNSServiceRef toClean)
|
||||
browserSocket = NULL;
|
||||
}
|
||||
|
||||
QMap<QString, QZeroConfService >::iterator i;
|
||||
QMap<QString, QZeroConfService >::iterator i;
|
||||
for (i = pub->services.begin(); i != pub->services.end(); i++) {
|
||||
emit pub->serviceRemoved(*i);
|
||||
}
|
||||
|
14
bonjour_p.h
14
bonjour_p.h
@ -16,12 +16,12 @@
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QtZeroConf. If not, see <http://www.gnu.org/licenses/>.
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Project name : QtZeroConf
|
||||
File name : bonjour_p.h
|
||||
Created : 22 July 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
Project name : QtZeroConf
|
||||
File name : bonjour_p.h
|
||||
Created : 22 July 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Part of wrapper for Apple's Bonjour library for use on Windows, MACs and iOS. Needed for slots.
|
||||
Part of wrapper for Apple's Bonjour library for use on Windows, MACs and iOS. Needed for slots.
|
||||
---------------------------------------------------------------------------------------------------
|
||||
**************************************************************************************************/
|
||||
#ifndef QZEROCONFPRIVATE_H_
|
||||
@ -64,8 +64,8 @@ public:
|
||||
DNSServiceRef dnssRef, browser, resolver;
|
||||
DNSServiceProtocol protocol;
|
||||
QSocketNotifier *bs, *browserSocket, *resolverSocket, *addressSocket;
|
||||
QZeroConfService newService;
|
||||
QList<QZeroConfService> work;
|
||||
QZeroConfService newService;
|
||||
QList<QZeroConfService> work;
|
||||
QByteArray txt;
|
||||
|
||||
public slots:
|
||||
|
@ -16,12 +16,12 @@
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QtZeroConf. If not, see <http://www.gnu.org/licenses/>.
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Project name : QtZeroConf Example
|
||||
File name : main.cpp
|
||||
Created : 3 November 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
Project name : QtZeroConf Example
|
||||
File name : main.cpp
|
||||
Created : 3 November 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Example app to demonstrate service publishing and service discovery
|
||||
Example app to demonstrate service publishing and service discovery
|
||||
---------------------------------------------------------------------------------------------------
|
||||
**************************************************************************************************/
|
||||
#include <QApplication>
|
||||
|
@ -16,12 +16,12 @@
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QtZeroConf. If not, see <http://www.gnu.org/licenses/>.
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Project name : QtZeroConf Example
|
||||
File name : window.cpp
|
||||
Created : 3 November 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
Project name : QtZeroConf Example
|
||||
File name : window.cpp
|
||||
Created : 3 November 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Example app to demonstrate service publishing and service discovery
|
||||
Example app to demonstrate service publishing and service discovery
|
||||
---------------------------------------------------------------------------------------------------
|
||||
**************************************************************************************************/
|
||||
#include <QGuiApplication>
|
||||
@ -54,8 +54,8 @@ mainWindow::mainWindow()
|
||||
buildGUI();
|
||||
|
||||
|
||||
connect(&zeroConf, &QZeroConf::serviceAdded, this, &mainWindow::addService);
|
||||
connect(&zeroConf, &QZeroConf::serviceRemoved, this, &mainWindow::removeService);
|
||||
connect(&zeroConf, &QZeroConf::serviceAdded, this, &mainWindow::addService);
|
||||
connect(&zeroConf, &QZeroConf::serviceRemoved, this, &mainWindow::removeService);
|
||||
connect(qGuiApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(appStateChanged(Qt::ApplicationState)));
|
||||
|
||||
publishEnabled = 1;
|
||||
@ -93,7 +93,7 @@ void mainWindow::buildGUI()
|
||||
|
||||
QString mainWindow::buildName(void)
|
||||
{
|
||||
QString name;
|
||||
QString name;
|
||||
|
||||
QList<QNetworkInterface> list = QNetworkInterface::allInterfaces(); // now you have interfaces list
|
||||
|
||||
@ -102,7 +102,7 @@ QString mainWindow::buildName(void)
|
||||
name.remove(0, 6);
|
||||
name+= ')';
|
||||
name.prepend("Qt ZeroConf Test - " OS_NAME " (");
|
||||
return name;
|
||||
return name;
|
||||
}
|
||||
|
||||
void mainWindow::appStateChanged(Qt::ApplicationState state)
|
||||
@ -154,9 +154,9 @@ void mainWindow::addService(QZeroConfService zcs)
|
||||
|
||||
row = table.rowCount();
|
||||
table.insertRow(row);
|
||||
cell = new QTableWidgetItem(zcs.name());
|
||||
cell = new QTableWidgetItem(zcs.name());
|
||||
table.setItem(row, 0, cell);
|
||||
cell = new QTableWidgetItem(zcs.ip().toString());
|
||||
cell = new QTableWidgetItem(zcs.ip().toString());
|
||||
table.setItem(row, 1, cell);
|
||||
table.resizeColumnsToContents();
|
||||
#if !(defined(Q_OS_IOS) || defined(Q_OS_ANDROID))
|
||||
@ -169,12 +169,12 @@ void mainWindow::removeService(QZeroConfService zcs)
|
||||
qint32 i, row;
|
||||
QTableWidgetItem *nameItem, *ipItem;
|
||||
|
||||
QList <QTableWidgetItem*> search = table.findItems(zcs.name(), Qt::MatchExactly);
|
||||
QList <QTableWidgetItem*> search = table.findItems(zcs.name(), Qt::MatchExactly);
|
||||
for (i=0; i<search.size(); i++) {
|
||||
nameItem = search.at(i);
|
||||
row = nameItem->row();
|
||||
ipItem = table.item(row, 1);
|
||||
if (table.item(row, 1)->text() == zcs.ip().toString()) { // match ip address in case of dual homed systems
|
||||
if (table.item(row, 1)->text() == zcs.ip().toString()) { // match ip address in case of dual homed systems
|
||||
delete nameItem;
|
||||
delete ipItem;
|
||||
table.removeRow(row);
|
||||
|
@ -16,12 +16,12 @@
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QtZeroConf. If not, see <http://www.gnu.org/licenses/>.
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Project name : QtZeroConf Example
|
||||
File name : window.h
|
||||
Created : 3 November 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
Project name : QtZeroConf Example
|
||||
File name : window.h
|
||||
Created : 3 November 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Example app to demonstrate service publishing and service discovery
|
||||
Example app to demonstrate service publishing and service discovery
|
||||
---------------------------------------------------------------------------------------------------
|
||||
**************************************************************************************************/
|
||||
#ifndef WINDOW_H_
|
||||
@ -51,8 +51,8 @@ private slots:
|
||||
void appStateChanged(Qt::ApplicationState state);
|
||||
void startPublishClicked();
|
||||
void stopPublishClicked();
|
||||
void addService(QZeroConfService item);
|
||||
void removeService(QZeroConfService item);
|
||||
void addService(QZeroConfService item);
|
||||
void removeService(QZeroConfService item);
|
||||
|
||||
};
|
||||
|
||||
|
20
qzeroconf.h
20
qzeroconf.h
@ -16,12 +16,12 @@
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QtZeroConf. If not, see <http://www.gnu.org/licenses/>.
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Project name : QtZeroConf
|
||||
File name : qzeroconf.h
|
||||
Created : 20 July 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
Project name : QtZeroConf
|
||||
File name : qzeroconf.h
|
||||
Created : 20 July 2015
|
||||
Author(s) : Jonathan Bagg
|
||||
---------------------------------------------------------------------------------------------------
|
||||
QtZeroConf class definition
|
||||
QtZeroConf class definition
|
||||
---------------------------------------------------------------------------------------------------
|
||||
**************************************************************************************************/
|
||||
#ifndef QZEROCONF_H_
|
||||
@ -60,7 +60,7 @@ public:
|
||||
serviceNameCollision = -2,
|
||||
browserFailed = -3,
|
||||
};
|
||||
QZeroConf(QObject *parent = Q_NULLPTR);
|
||||
QZeroConf(QObject *parent = Q_NULLPTR);
|
||||
~QZeroConf();
|
||||
void startServicePublish(const char *name, const char *type, const char *domain, quint16 port);
|
||||
void stopServicePublish(void);
|
||||
@ -79,13 +79,13 @@ public:
|
||||
Q_SIGNALS:
|
||||
void servicePublished(void);
|
||||
void error(QZeroConf::error_t);
|
||||
void serviceAdded(QZeroConfService);
|
||||
void serviceUpdated(QZeroConfService);
|
||||
void serviceRemoved(QZeroConfService);
|
||||
void serviceAdded(QZeroConfService);
|
||||
void serviceUpdated(QZeroConfService);
|
||||
void serviceRemoved(QZeroConfService);
|
||||
|
||||
private:
|
||||
QZeroConfPrivate *pri;
|
||||
QMap<QString, QZeroConfService> services;
|
||||
QMap<QString, QZeroConfService> services;
|
||||
|
||||
|
||||
|
||||
|
@ -4,15 +4,15 @@
|
||||
class QZeroConfServiceData : public QSharedData
|
||||
{
|
||||
public:
|
||||
QString name;
|
||||
QString type;
|
||||
QString domain;
|
||||
QString host;
|
||||
QHostAddress ip;
|
||||
QHostAddress ipv6;
|
||||
quint32 interfaceIndex;
|
||||
quint16 port = 0;
|
||||
QMap <QByteArray, QByteArray> txt;
|
||||
QString name;
|
||||
QString type;
|
||||
QString domain;
|
||||
QString host;
|
||||
QHostAddress ip;
|
||||
QHostAddress ipv6;
|
||||
quint32 interfaceIndex;
|
||||
quint16 port = 0;
|
||||
QMap <QByteArray, QByteArray> txt;
|
||||
|
||||
};
|
||||
|
||||
@ -28,9 +28,9 @@ QZeroConfService::QZeroConfService(const QZeroConfService &rhs) : data(rhs.data)
|
||||
|
||||
QZeroConfService &QZeroConfService::operator=(const QZeroConfService &rhs)
|
||||
{
|
||||
if (this != &rhs)
|
||||
data.operator=(rhs.data);
|
||||
return *this;
|
||||
if (this != &rhs)
|
||||
data.operator=(rhs.data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
QZeroConfService::~QZeroConfService()
|
||||
@ -40,108 +40,106 @@ QZeroConfService::~QZeroConfService()
|
||||
|
||||
QString QZeroConfService::name() const
|
||||
{
|
||||
return data->name;
|
||||
return data->name;
|
||||
}
|
||||
|
||||
void QZeroConfService::setName(const QString &name)
|
||||
{
|
||||
data->name = name;
|
||||
data->name = name;
|
||||
}
|
||||
|
||||
QString QZeroConfService::type() const
|
||||
{
|
||||
return data->type;
|
||||
return data->type;
|
||||
}
|
||||
|
||||
void QZeroConfService::setType(const QString &type)
|
||||
{
|
||||
data->type = type;
|
||||
data->type = type;
|
||||
}
|
||||
|
||||
QString QZeroConfService::domain() const
|
||||
{
|
||||
return data->domain;
|
||||
return data->domain;
|
||||
}
|
||||
|
||||
void QZeroConfService::setDomain(const QString &domain)
|
||||
{
|
||||
data->domain = domain;
|
||||
data->domain = domain;
|
||||
}
|
||||
|
||||
QString QZeroConfService::host() const
|
||||
{
|
||||
return data->host;
|
||||
return data->host;
|
||||
}
|
||||
|
||||
void QZeroConfService::setHost(const QString &host)
|
||||
{
|
||||
data->host = host;
|
||||
data->host = host;
|
||||
}
|
||||
|
||||
QHostAddress QZeroConfService::ip() const
|
||||
{
|
||||
return data->ip;
|
||||
return data->ip;
|
||||
}
|
||||
|
||||
void QZeroConfService::setIp(QHostAddress &ip)
|
||||
{
|
||||
data->ip = ip;
|
||||
data->ip = ip;
|
||||
}
|
||||
|
||||
QHostAddress QZeroConfService::ipv6() const
|
||||
{
|
||||
return data->ipv6;
|
||||
return data->ipv6;
|
||||
}
|
||||
|
||||
void QZeroConfService::setIpv6(const QHostAddress &ipv6)
|
||||
{
|
||||
data->ipv6 = ipv6;
|
||||
data->ipv6 = ipv6;
|
||||
}
|
||||
|
||||
quint32 QZeroConfService::interfaceIndex() const
|
||||
{
|
||||
return data->interfaceIndex;
|
||||
return data->interfaceIndex;
|
||||
}
|
||||
|
||||
void QZeroConfService::setInterfaceIndex(const quint32 &interfaceIndex)
|
||||
{
|
||||
data->interfaceIndex = interfaceIndex;
|
||||
data->interfaceIndex = interfaceIndex;
|
||||
}
|
||||
|
||||
quint16 QZeroConfService::port() const
|
||||
{
|
||||
return data->port;
|
||||
return data->port;
|
||||
}
|
||||
|
||||
void QZeroConfService::setPort(const quint16 port)
|
||||
{
|
||||
data->port = port;
|
||||
data->port = port;
|
||||
}
|
||||
|
||||
QMap<QByteArray, QByteArray> QZeroConfService::txt() const
|
||||
{
|
||||
return data->txt;
|
||||
return data->txt;
|
||||
}
|
||||
|
||||
void QZeroConfService::setTxt(const QMap<QByteArray, QByteArray> txt)
|
||||
{
|
||||
data->txt = txt;
|
||||
data->txt = txt;
|
||||
}
|
||||
|
||||
void QZeroConfService::appendTxt(QByteArray idx, QByteArray val)
|
||||
{
|
||||
data->txt[idx] = val;
|
||||
data->txt[idx] = val;
|
||||
}
|
||||
|
||||
bool QZeroConfService::isValid() const
|
||||
{
|
||||
|
||||
return (!data->name.isEmpty());
|
||||
return (!data->name.isEmpty());
|
||||
}
|
||||
|
||||
bool QZeroConfService::operator==(const QZeroConfService &rhs) const
|
||||
{
|
||||
return this->name() == rhs.name() && (this->ip() == rhs.ip() || this->ipv6() == rhs.ipv6());
|
||||
return this->name() == rhs.name() && (this->ip() == rhs.ip() || this->ipv6() == rhs.ipv6());
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,45 +8,45 @@ class QZeroConfServiceData;
|
||||
|
||||
class QZeroConfService
|
||||
{
|
||||
Q_GADGET
|
||||
Q_PROPERTY( QString name READ name )
|
||||
Q_PROPERTY( QString type READ type )
|
||||
Q_PROPERTY( QString domain READ domain )
|
||||
Q_PROPERTY( QString host READ host )
|
||||
Q_GADGET
|
||||
Q_PROPERTY( QString name READ name )
|
||||
Q_PROPERTY( QString type READ type )
|
||||
Q_PROPERTY( QString domain READ domain )
|
||||
Q_PROPERTY( QString host READ host )
|
||||
|
||||
public:
|
||||
|
||||
QZeroConfService();
|
||||
QZeroConfService(const QZeroConfService &);
|
||||
QZeroConfService &operator=(const QZeroConfService &);
|
||||
~QZeroConfService();
|
||||
QZeroConfService();
|
||||
QZeroConfService(const QZeroConfService &);
|
||||
QZeroConfService &operator=(const QZeroConfService &);
|
||||
~QZeroConfService();
|
||||
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
QString type() const;
|
||||
void setType(const QString &type);
|
||||
QString domain() const;
|
||||
void setDomain(const QString &domain);
|
||||
QString host() const;
|
||||
void setHost(const QString &host);
|
||||
QHostAddress ip() const;
|
||||
void setIp(QHostAddress &ip);
|
||||
QHostAddress ipv6() const;
|
||||
void setIpv6(const QHostAddress &ipv6);
|
||||
quint32 interfaceIndex() const;
|
||||
void setInterfaceIndex(const quint32 &interfaceIndex);
|
||||
quint16 port() const;
|
||||
void setPort(const quint16 port);
|
||||
QMap <QByteArray, QByteArray> txt() const;
|
||||
void setTxt(const QMap<QByteArray, QByteArray> txt);
|
||||
void appendTxt(QByteArray idx, QByteArray val = "");
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
QString type() const;
|
||||
void setType(const QString &type);
|
||||
QString domain() const;
|
||||
void setDomain(const QString &domain);
|
||||
QString host() const;
|
||||
void setHost(const QString &host);
|
||||
QHostAddress ip() const;
|
||||
void setIp(QHostAddress &ip);
|
||||
QHostAddress ipv6() const;
|
||||
void setIpv6(const QHostAddress &ipv6);
|
||||
quint32 interfaceIndex() const;
|
||||
void setInterfaceIndex(const quint32 &interfaceIndex);
|
||||
quint16 port() const;
|
||||
void setPort(const quint16 port);
|
||||
QMap <QByteArray, QByteArray> txt() const;
|
||||
void setTxt(const QMap<QByteArray, QByteArray> txt);
|
||||
void appendTxt(QByteArray idx, QByteArray val = "");
|
||||
|
||||
bool isValid() const;
|
||||
bool operator==(const QZeroConfService &rhs) const;
|
||||
bool isValid() const;
|
||||
bool operator==(const QZeroConfService &rhs) const;
|
||||
|
||||
private:
|
||||
QSharedDataPointer<QZeroConfServiceData> data;
|
||||
QSharedDataPointer<QZeroConfServiceData> data;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(QZeroConfService)
|
||||
|
Reference in New Issue
Block a user