KDNSSD

domainbrowser.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 KDNSSDDOMAINBROWSER_H
10#define KDNSSDDOMAINBROWSER_H
11
12#include "remoteservice.h"
13#include <QObject>
14#include <QtContainerFwd>
15#include <memory>
16
17namespace KDNSSD
18{
19class DomainBrowserPrivate;
20
21/**
22 * @class DomainBrowser domainbrowser.h KDNSSD/DomainBrowser
23 * @short Browses recommended domains for browsing or publishing to.
24 *
25 * Usage of this class is very simple. If you are interested in
26 * browsing for services, simple do
27 * @code
28 * KDNSSD::DomainBrowser *browser =
29 * new KDNSSD::DomainBrowser(KDNSSD::DomainBrowser::Browsing, this);
30 * connect(browser, SIGNAL(domainAdded(QString)),
31 * this, SLOT(browsingDomainAdded(QString));
32 * connect(browser, SIGNAL(domainRemoved(QString)),
33 * this, SLOT(browsingDomainRemove(QString));
34 * browser->startBrowse();
35 * @endcode
36 *
37 * If you are interested in domains where you can register services,
38 * usage is identical except that you should pass
39 * <tt>KDNSSD::DomainBrowser::Registering</tt> to the constructor.
40 *
41 * @author Jakub Stachowski
42 */
43class KDNSSD_EXPORT DomainBrowser : public QObject
44{
45 Q_OBJECT
46public:
47 /**
48 * A type of domain recommendation
49 */
51 /** Domains recommended for browsing for services on (using ServiceBrowser) */
53 /** Domains recommended for publishing to (using PublicService) */
55 };
56 /**
57 * Standard constructor
58 *
59 * The global DNS-SD configuration (for example, the global Avahi
60 * configuration for the Avahi backend) will be used.
61 *
62 * @param type the type of domain to search for
63 * @param parent parent object (see QObject documentation)
64 *
65 * @see startBrowse() and ServiceBrowser::isAvailable()
66 */
67 explicit DomainBrowser(DomainType type, QObject *parent = nullptr);
68
69 ~DomainBrowser() override;
70
71 /**
72 * The current known list of domains of the requested DomainType
73 *
74 * @return a list of currently known domain names
75 */
76 QStringList domains() const;
77
78 /**
79 * Starts browsing
80 *
81 * Only the first call to this function will have any effect.
82 *
83 * Browsing stops when the DomainBrowser object is destroyed.
84 *
85 * @warning The domainAdded() signal may be emitted before this
86 * function returns.
87 *
88 * @see domainAdded() and domainRemoved()
89 */
90 void startBrowse();
91
92 /**
93 * Whether the browsing has been started
94 *
95 * @return @c true if startBrowse() has been called, @c false otherwise
96 */
97 bool isRunning() const;
98
99Q_SIGNALS:
100 /**
101 * A domain has disappeared from the browsed list
102 *
103 * Emitted when domain has been removed from browsing list
104 * or the publishing list (depending on which list was
105 * requested in the constructor).
106 *
107 * @param domain the name of the domain
108 *
109 * @see domainAdded()
110 */
111 void domainRemoved(const QString &domain);
112
113 /**
114 * A new domain has been discovered
115 *
116 * If the requested DomainType is Browsing, this will
117 * also be emitted for the domains specified in the
118 * global configuration.
119 *
120 * @param domain the name of the domain
121 *
122 * @see domainRemoved()
123 */
124 void domainAdded(const QString &domain);
125
126private:
127 friend class DomainBrowserPrivate;
128 std::unique_ptr<DomainBrowserPrivate> const d;
129 Q_DECLARE_PRIVATE_D(d, DomainBrowser)
130};
131
132}
133
134#endif
Browses recommended domains for browsing or publishing to.
void domainRemoved(const QString &domain)
A domain has disappeared from the browsed list.
void domainAdded(const QString &domain)
A new domain has been discovered.
DomainType
A type of domain recommendation.
@ Browsing
Domains recommended for browsing for services on (using ServiceBrowser)
@ Publishing
Domains recommended for publishing to (using PublicService)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:48 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.