1 /*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2017 Nathan Osman
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 */
24
25 #include <QDebug>
26
27 #include <qmdnsengine/dns.h>
28 #include <qmdnsengine/query.h>
29
30 #include "query_p.h"
31
32 using namespace QMdnsEngine;
33
QueryPrivate()34 QueryPrivate::QueryPrivate()
35 : type(0),
36 unicastResponse(false)
37 {
38 }
39
Query()40 Query::Query()
41 : d(new QueryPrivate)
42 {
43 }
44
Query(const Query & other)45 Query::Query(const Query &other)
46 : d(new QueryPrivate)
47 {
48 *this = other;
49 }
50
operator =(const Query & other)51 Query &Query::operator=(const Query &other)
52 {
53 *d = *other.d;
54 return *this;
55 }
56
~Query()57 Query::~Query()
58 {
59 delete d;
60 }
61
name() const62 QByteArray Query::name() const
63 {
64 return d->name;
65 }
66
setName(const QByteArray & name)67 void Query::setName(const QByteArray &name)
68 {
69 d->name = name;
70 }
71
type() const72 quint16 Query::type() const
73 {
74 return d->type;
75 }
76
setType(quint16 type)77 void Query::setType(quint16 type)
78 {
79 d->type = type;
80 }
81
unicastResponse() const82 bool Query::unicastResponse() const
83 {
84 return d->unicastResponse;
85 }
86
setUnicastResponse(bool unicastResponse)87 void Query::setUnicastResponse(bool unicastResponse)
88 {
89 d->unicastResponse = unicastResponse;
90 }
91
operator <<(QDebug dbg,const Query & query)92 QDebug QMdnsEngine::operator<<(QDebug dbg, const Query &query)
93 {
94 QDebugStateSaver saver(dbg);
95 Q_UNUSED(saver);
96
97 dbg.noquote().nospace() << "Query(" << typeName(query.type()) << " " << query.name() << ")";
98
99 return dbg;
100 }
101