2
* Copyright (C) 2007 Justin Karneges
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29
class QDnsSd : public QObject
44
LowLevelError(const QString &_func, int _code) :
54
bool added; // only used by QueryResult
66
QByteArray serviceName;
68
// these may be different from request, see dns_sd docs
69
QByteArray serviceType;
70
QByteArray replyDomain;
77
LowLevelError lowLevelError;
79
QList<Record> records;
86
LowLevelError lowLevelError;
88
QList<BrowseEntry> entries;
95
LowLevelError lowLevelError;
98
QByteArray hostTarget;
99
int port; // host byte-order
100
QByteArray txtRecord;
114
LowLevelError lowLevelError;
119
QDnsSd(QObject *parent = 0);
122
int query(const QByteArray &name, int qType);
124
// domain may be empty
125
int browse(const QByteArray &serviceType, const QByteArray &domain);
127
int resolve(const QByteArray &serviceName, const QByteArray &serviceType, const QByteArray &domain);
129
// domain may be empty
130
int reg(const QByteArray &serviceName, const QByteArray &serviceType, const QByteArray &domain, int port, const QByteArray &txtRecord);
132
// return -1 on error, else a record id
133
int recordAdd(int reg_id, const Record &rec, LowLevelError *lowLevelError = 0);
135
bool recordUpdate(int rec_id, const Record &rec, LowLevelError *lowLevelError = 0);
136
bool recordUpdateTxt(int reg_id, const QByteArray &txtRecord, quint32 ttl, LowLevelError *lowLevelError = 0);
137
void recordRemove(int rec_id);
141
// return empty array on error
142
static QByteArray createTxtRecord(const QList<QByteArray> &strings);
144
// return empty list on error (note that it is possible to have a
145
// txt record with no entries, but in that case txtRecord will be
146
// empty and so you shouldn't call this function)
147
static QList<QByteArray> parseTxtRecord(const QByteArray &txtRecord);
150
void queryResult(int id, const QDnsSd::QueryResult &result);
151
void browseResult(int id, const QDnsSd::BrowseResult &result);
152
void resolveResult(int id, const QDnsSd::ResolveResult &result);
153
void regResult(int id, const QDnsSd::RegResult &result);
157
friend class Private;