KDNSSD 5.109.0
servicebrowser.h
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#ifndef KDNSSDSERVICEBROWSER_H
10#define KDNSSDSERVICEBROWSER_H
11
12#include "remoteservice.h"
13#include <QHostAddress>
14#include <QObject>
15
16#include <memory>
17
18namespace KDNSSD
19{
20class DomainBrowser;
21class ServiceBrowserPrivate;
22
54class KDNSSD_EXPORT ServiceBrowser : public QObject
55{
56 Q_OBJECT
57
58public:
62 enum State {
69 };
70
103 explicit ServiceBrowser(const QString &type, bool autoResolve = false, const QString &domain = QString(), const QString &subtype = QString());
104
105 ~ServiceBrowser() override;
106
114 QList<RemoteService::Ptr> services() const;
115
128 virtual void startBrowse();
129
172
180 bool isAutoResolving() const;
181
195 static QHostAddress resolveHostName(const QString &hostname);
196
207 static QString getLocalHostName();
208
209Q_SIGNALS:
220 void serviceAdded(KDNSSD::RemoteService::Ptr service);
221
235 void serviceRemoved(KDNSSD::RemoteService::Ptr service);
236
267 void finished();
268
269protected:
270 virtual void virtual_hook(int, void *);
271
272private:
273 friend class ServiceBrowserPrivate;
274 std::unique_ptr<ServiceBrowserPrivate> const d;
275 Q_DECLARE_PRIVATE_D(d, ServiceBrowser)
276};
277
278}
279
280#endif
Browses for network services advertised over DNS-SD.
Definition servicebrowser.h:55
static State isAvailable()
Checks availability of DNS-SD services.
void serviceRemoved(KDNSSD::RemoteService::Ptr service)
Emitted when a service is no longer published over DNS-SD.
virtual void startBrowse()
Starts browsing for services.
bool isAutoResolving() const
Whether discovered services are resolved before being reported.
void serviceAdded(KDNSSD::RemoteService::Ptr service)
Emitted when new service is discovered.
static QString getLocalHostName()
The mDNS hostname of the local machine.
static QHostAddress resolveHostName(const QString &hostname)
Resolves an mDNS hostname into an IP address.
QList< RemoteService::Ptr > services() const
The currently known services of the specified type.
State
Availability of DNS-SD services.
Definition servicebrowser.h:62
@ Working
the service is available
Definition servicebrowser.h:64
@ Unsupported
not available because KDE was compiled without DNS-SD support
Definition servicebrowser.h:68
@ Stopped
not available because mDnsd or Avahi daemon is not running
Definition servicebrowser.h:66
void finished()
Emitted when the list of published services has settled.
ServiceBrowser(const QString &type, bool autoResolve=false, const QString &domain=QString(), const QString &subtype=QString())
Create a ServiceBrowser for a particular service type.