forked from jbagg/QtZeroConf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbonjour_p.h
93 lines (77 loc) · 3.47 KB
/
bonjour_p.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**************************************************************************************************
---------------------------------------------------------------------------------------------------
Copyright (C) 2015 Jonathan Bagg
This file is part of QtZeroConf.
QtZeroConf is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QtZeroConf 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 Lesser General Public License for more details.
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
---------------------------------------------------------------------------------------------------
Part of wrapper for Apple's Bonjour library for use on Windows, MACs and iOS. Needed for slots.
---------------------------------------------------------------------------------------------------
**************************************************************************************************/
#ifndef QZEROCONFPRIVATE_H_
#define QZEROCONFPRIVATE_H_
#include <dns_sd.h>
#include <QSocketNotifier>
#include <QtEndian>
#include <QHostAddress>
#include "qzeroconf.h"
#include <QDebug>
#ifndef kDNSServiceFlagsTimeout // earlier versions of dns_sd.h don't define this constant
#define kDNSServiceFlagsTimeout 0x10000
#endif
class Resolver : public QObject
{
Q_OBJECT
public:
void cleanUp();
QZeroConfService zcs;
QZeroConfPrivate *ref = nullptr;
DNSServiceRef DNSresolverRef = nullptr;
DNSServiceRef DNSaddressRef = nullptr;
QSharedPointer <QSocketNotifier> resolverNotifier;
QSharedPointer <QSocketNotifier> addressNotifier;
public slots:
void resolverReady();
void addressReady();
};
class QZeroConfPrivate : public QObject
{
Q_OBJECT
public:
QZeroConfPrivate(QZeroConf *parent);
void cleanUp(DNSServiceRef ref);
void resolve(QZeroConfService);
static void DNSSD_API registerCallback(DNSServiceRef, DNSServiceFlags, DNSServiceErrorType errorCode, const char *,
const char *, const char *, void *userdata);
static void DNSSD_API browseCallback(DNSServiceRef, DNSServiceFlags flags,quint32, DNSServiceErrorType err, const char *name,
const char *type, const char *domain, void *userdata);
static void DNSSD_API resolverCallback(DNSServiceRef, DNSServiceFlags, quint32, DNSServiceErrorType err, const char *,
const char *hostName, quint16 port, quint16 txtLen, const unsigned char *txtRecord, void *userdata);
static void DNSSD_API addressReply(DNSServiceRef sdRef, DNSServiceFlags flags, quint32 interfaceIndex,
DNSServiceErrorType err, const char *hostName, const struct sockaddr* address, quint32 ttl, void *userdata);
QZeroConf *pub;
DNSServiceRef dnssRef = nullptr;
DNSServiceRef browser = nullptr;
DNSServiceProtocol protocol;
QSharedPointer<QSocketNotifier> serviceNotifier;
QSharedPointer<QSocketNotifier> browserNotifier;
QByteArray txt;
QHash<QString, Resolver*> resolvers;
public slots:
void bsRead();
void browserRead();
};
#endif // QZEROCONFPRIVATE_H_