KDNSSD

mdnsd-servicetypebrowser.cpp
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 "mdnsd-servicetypebrowser_p.h"
10#include "servicebrowser.h"
11#include "servicetypebrowser.h"
12
13namespace KDNSSD
14{
16 : QObject(parent)
17 , d(new ServiceTypeBrowserPrivate(this))
18{
19 Q_D(ServiceTypeBrowser);
20 d->m_browser = new ServiceBrowser("_services._dns-sd._udp", false, domain);
21 connect(d->m_browser, SIGNAL(serviceAdded(KDNSSD::RemoteService::Ptr)), d, SLOT(newService(KDNSSD::RemoteService::Ptr)));
22 connect(d->m_browser, SIGNAL(serviceRemoved(KDNSSD::RemoteService::Ptr)), d, SLOT(removeService(KDNSSD::RemoteService::Ptr)));
23 connect(d->m_browser, SIGNAL(finished()), this, SIGNAL(finished()));
24}
25
26ServiceTypeBrowser::~ServiceTypeBrowser() = default;
27
28QStringList ServiceTypeBrowser::serviceTypes() const
29{
30 Q_D(const ServiceTypeBrowser);
31 return d->m_servicetypes;
32}
33
34void ServiceTypeBrowser::startBrowse()
35{
36 Q_D(ServiceTypeBrowser);
37 d->m_browser->startBrowse();
38}
39
40void ServiceTypeBrowserPrivate::newService(KDNSSD::RemoteService::Ptr srv)
41{
42 QString type = srv->serviceName() + '.' + srv->type();
43 m_servicetypes += type;
44 Q_EMIT m_parent->serviceTypeAdded(type);
45}
46
47void ServiceTypeBrowserPrivate::removeService(KDNSSD::RemoteService::Ptr srv)
48{
49 QString type = srv->serviceName() + '.' + srv->type();
50 m_servicetypes.removeAll(type);
51 Q_EMIT m_parent->serviceTypeRemoved(type);
52}
53
54}
55
56#include "moc_mdnsd-servicetypebrowser_p.cpp"
57#include "moc_servicetypebrowser.cpp"
ServiceTypeBrowser(const QString &domain=QString(), QObject *parent=nullptr)
Create a ServiceTypeBrowser for a domain.
Type type(const QSqlDatabase &db)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:07 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.