KDNSSD

mdnsd-servicetypebrowser.cpp
1 /*
2  This file is part of the KDE project
3 
4  SPDX-FileCopyrightText: 2004 Jakub Stachowski <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #include "mdnsd-servicetypebrowser_p.h"
10 #include "servicetypebrowser.h"
11 #include "servicebrowser.h"
12 
13 namespace KDNSSD
14 {
15 
16 ServiceTypeBrowser::ServiceTypeBrowser(const QString &domain, QObject *parent) : QObject(parent), d(new ServiceTypeBrowserPrivate(this))
17 {
18  d->m_browser = new ServiceBrowser("_services._dns-sd._udp", false, domain);
19  connect(d->m_browser, SIGNAL(serviceAdded(KDNSSD::RemoteService::Ptr)), d, SLOT(newService(KDNSSD::RemoteService::Ptr)));
20  connect(d->m_browser, SIGNAL(serviceRemoved(KDNSSD::RemoteService::Ptr)), d, SLOT(removeService(KDNSSD::RemoteService::Ptr)));
21  connect(d->m_browser, SIGNAL(finished()), this, SIGNAL(finished()));
22 }
23 
24 ServiceTypeBrowser::~ServiceTypeBrowser()
25 {
26  delete d;
27 }
28 
30 {
31  return d->m_servicetypes;
32 }
33 
35 {
36  d->m_browser->startBrowse();
37 }
38 
39 void ServiceTypeBrowserPrivate::newService(KDNSSD::RemoteService::Ptr srv)
40 {
41  QString type = srv->serviceName() + '.' + srv->type();
42  m_servicetypes += type;
43  emit m_parent->serviceTypeAdded(type);
44 }
45 
46 void ServiceTypeBrowserPrivate::removeService(KDNSSD::RemoteService::Ptr srv)
47 {
48  QString type = srv->serviceName() + '.' + srv->type();
49  m_servicetypes.removeAll(type);
50  emit m_parent->serviceTypeRemoved(type);
51 }
52 
53 }
54 
55 #include "moc_servicetypebrowser.cpp"
ServiceTypeBrowser(const QString &domain=QString(), QObject *parent=nullptr)
Create a ServiceTypeBrowser for a domain.
Type type(const QSqlDatabase &db)
void startBrowse()
Starts browsing.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QStringList serviceTypes() const
All the service types currently being published.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Dec 4 2020 22:40:44 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.