File indexing completed on 2024-04-28 15:22:07

0001 /*
0002     This file is part of the KDE project
0003 
0004     SPDX-FileCopyrightText: 2004 Jakub Stachowski <qbast@go2.pl>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #include "servicebase.h"
0010 #include "servicebase_p.h"
0011 #include <QDataStream>
0012 #include <QUrl>
0013 
0014 namespace KDNSSD
0015 {
0016 ServiceBase::ServiceBase(const QString &name, const QString &type, const QString &domain, const QString &host, unsigned short port)
0017     : d(new ServiceBasePrivate(name, type, domain, host, port))
0018 {
0019 }
0020 
0021 ServiceBase::ServiceBase(ServiceBasePrivate *const _d)
0022     : d(_d)
0023 {
0024 }
0025 
0026 ServiceBase::~ServiceBase() = default;
0027 
0028 QString ServiceBase::serviceName() const
0029 {
0030     return d->m_serviceName;
0031 }
0032 
0033 QString ServiceBase::type() const
0034 {
0035     return d->m_type;
0036 }
0037 
0038 QString ServiceBase::domain() const
0039 {
0040     return d->m_domain;
0041 }
0042 
0043 QString ServiceBase::hostName() const
0044 {
0045     return d->m_hostName;
0046 }
0047 
0048 unsigned short ServiceBase::port() const
0049 {
0050     return d->m_port;
0051 }
0052 QMap<QString, QByteArray> ServiceBase::textData() const
0053 {
0054     return d->m_textData;
0055 }
0056 
0057 bool ServiceBase::operator==(const ServiceBase &o) const
0058 {
0059     return d->m_domain == o.d->m_domain && d->m_serviceName == o.d->m_serviceName && d->m_type == o.d->m_type;
0060 }
0061 
0062 bool ServiceBase::operator!=(const ServiceBase &o) const
0063 {
0064     return !(*this == o);
0065 }
0066 
0067 void ServiceBase::virtual_hook(int, void *)
0068 {
0069 }
0070 
0071 bool domainIsLocal(const QString &domain)
0072 {
0073     return domain.section(QLatin1Char('.'), -1, -1).toLower() == QLatin1String("local");
0074 }
0075 
0076 }