1 | /* |
2 | This file is part of the KDE project |
3 | |
4 | SPDX-FileCopyrightText: 2004 Jakub Stachowski <qbast@go2.pl> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-or-later |
7 | */ |
8 | |
9 | #include "servicebase.h" |
10 | #include "servicebase_p.h" |
11 | #include <QDataStream> |
12 | #include <QUrl> |
13 | |
14 | namespace KDNSSD |
15 | { |
16 | ServiceBase::ServiceBase(const QString &name, const QString &type, const QString &domain, const QString &host, unsigned short port) |
17 | : d(new ServiceBasePrivate(name, type, domain, host, port)) |
18 | { |
19 | } |
20 | |
21 | ServiceBase::ServiceBase(ServiceBasePrivate *const _d) |
22 | : d(_d) |
23 | { |
24 | } |
25 | |
26 | ServiceBase::~ServiceBase() = default; |
27 | |
28 | QString ServiceBase::serviceName() const |
29 | { |
30 | return d->m_serviceName; |
31 | } |
32 | |
33 | QString ServiceBase::type() const |
34 | { |
35 | return d->m_type; |
36 | } |
37 | |
38 | QString ServiceBase::domain() const |
39 | { |
40 | return d->m_domain; |
41 | } |
42 | |
43 | QString ServiceBase::hostName() const |
44 | { |
45 | return d->m_hostName; |
46 | } |
47 | |
48 | unsigned short ServiceBase::port() const |
49 | { |
50 | return d->m_port; |
51 | } |
52 | QMap<QString, QByteArray> ServiceBase::textData() const |
53 | { |
54 | return d->m_textData; |
55 | } |
56 | |
57 | bool ServiceBase::operator==(const ServiceBase &o) const |
58 | { |
59 | return d->m_domain == o.d->m_domain && d->m_serviceName == o.d->m_serviceName && d->m_type == o.d->m_type; |
60 | } |
61 | |
62 | bool ServiceBase::operator!=(const ServiceBase &o) const |
63 | { |
64 | return !(*this == o); |
65 | } |
66 | |
67 | void ServiceBase::virtual_hook(int, void *) |
68 | { |
69 | } |
70 | |
71 | bool domainIsLocal(const QString &domain) |
72 | { |
73 | return domain.section(asep: QLatin1Char('.'), astart: -1, aend: -1).toLower() == QLatin1String("local" ); |
74 | } |
75 | |
76 | } |
77 | |