KDNSSD

servicetypebrowser.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 KDNSSDSERVICETYPEBROWSER_H
10#define KDNSSDSERVICETYPEBROWSER_H
11
12#include "remoteservice.h"
13#include <QObject>
14#include <QtContainerFwd>
15#include <memory>
16
17namespace KDNSSD
18{
19class ServiceTypeBrowserPrivate;
20
21/**
22 * @class ServiceTypeBrowser servicetypebrowser.h KDNSSD/ServiceTypeBrowser
23 * @short Browses the service types being published on a domain
24 *
25 * This class is mostly useful for generic utilities for
26 * browsing all the published service types on a local network.
27 * Applications that wish to find out about available services
28 * of a particular type (such as web servers) should use
29 * ServiceBrowser.
30 *
31 * ServiceTypeBrowser provides a list of all the service types
32 * published by at least one service on a given domain.
33 *
34 * @author Jakub Stachowski
35 */
36class KDNSSD_EXPORT ServiceTypeBrowser : public QObject
37{
38 Q_OBJECT
39
40public:
41 /**
42 * Create a ServiceTypeBrowser for a domain
43 *
44 * The link-local domain (the LAN subnet for this computer) will
45 * be used if no @p domain is given. DomainBrowser can be used
46 * to get a list of browsing domains.
47 *
48 * Note that WAN domains may not support service type browsing.
49 *
50 * @param domain a browsing domain to search
51 * @param parent the parent object (see QObject documentation)
52 *
53 * @see startBrowse() and ServiceBrowser::isAvailable()
54 */
55 explicit ServiceTypeBrowser(const QString &domain = QString(), QObject *parent = nullptr);
56
57 ~ServiceTypeBrowser() override;
58
59 /**
60 * All the service types currently being published
61 *
62 * @return a list of service types, in the form _type._tcp or _type._udp
63 */
64 QStringList serviceTypes() const;
65
66 /**
67 * Starts browsing
68 *
69 * Only the first call to this function will have any effect.
70 *
71 * Browsing stops when the ServiceTypeBrowser object is destroyed.
72 *
73 * @warning The serviceTypeAdded() signal may be emitted before this
74 * function returns.
75 *
76 * @see serviceTypeAdded(), serviceTypeRemoved() and finished()
77 */
78 void startBrowse();
79
80Q_SIGNALS:
81 /**
82 * Emitted when there are no more services of this type
83 *
84 * @warning
85 * This signal is not reliable: it is possible that it will not be
86 * emitted even after last service of this type disappeared
87 *
88 * @param type the service type
89 *
90 * @see serviceTypeAdded() and finished()
91 */
92 void serviceTypeRemoved(const QString &type);
93
94 /**
95 * A new type of service has been found
96 *
97 * @param type the service type
98 *
99 * @see serviceTypeAdded() and finished()
100 */
101 void serviceTypeAdded(const QString &type);
102
103 /**
104 * Emitted when the list of published service types has settled
105 *
106 * This signal is emitted once after startBrowse() is called
107 * when the types of all the services that are
108 * currently published have been reported (even if no services
109 * are available or the DNS-SD service is not available).
110 * It is emitted again when a new batch of service types become
111 * available or disappear.
112 *
113 * For example, if a new host is connected to network and
114 * announces services of several new types,
115 * they will be reported by several serviceTypeAdded() signals
116 * and the whole batch will be concluded by finished().
117 *
118 * This signal can be used by applications that just want to
119 * get a list of the currently available service types
120 * (similar to a directory listing) and do not care about
121 * adding or removing service types that appear or disappear later.
122 *
123 * @see serviceTypeAdded() and serviceTypeRemoved()
124 */
125 void finished();
126
127private:
128 friend class ServiceTypeBrowserPrivate;
129 std::unique_ptr<ServiceTypeBrowserPrivate> const d;
130 Q_DECLARE_PRIVATE_D(d, ServiceTypeBrowser)
131};
132
133}
134
135#endif
Browses the service types being published on a domain.
void finished()
Emitted when the list of published service types has settled.
void serviceTypeRemoved(const QString &type)
Emitted when there are no more services of this type.
void serviceTypeAdded(const QString &type)
A new type of service has been found.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:06:09 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.