KDNSSD::DomainBrowser Class
class KDNSSD::DomainBrowserBrowses recommended domains for browsing or publishing to. More...
Header: | #include <KDNSSD/DomainBrowser> |
CMake: | find_package(KF6 REQUIRED COMPONENTS DNSSD) target_link_libraries(mytarget PRIVATE KF6::DNSSD) |
Inherits: | QObject |
Public Types
enum | DomainType { Browsing, Publishing } |
Public Functions
DomainBrowser(KDNSSD::DomainBrowser::DomainType type, QObject *parent = nullptr) | |
QStringList | domains() const |
bool | isRunning() const |
void | startBrowse() |
Signals
void | domainAdded(const QString &domain) |
void | domainRemoved(const QString &domain) |
Detailed Description
Usage of this class is very simple. If you are interested in browsing for services, simple do:
KDNSSD::DomainBrowser *browser = new KDNSSD::DomainBrowser(KDNSSD::DomainBrowser::Browsing, this); connect(browser, SIGNAL(domainAdded(QString)), this, SLOT(browsingDomainAdded(QString)); connect(browser, SIGNAL(domainRemoved(QString)), this, SLOT(browsingDomainRemove(QString)); browser->startBrowse();
If you are interested in domains where you can register services, usage is identical except that you should pass KDNSSD::DomainBrowser::Publishing to the constructor.
Member Type Documentation
enum DomainBrowser::DomainType
A type of domain recommendation.
Constant | Value | Description |
---|---|---|
KDNSSD::DomainBrowser::Browsing | 0 | Domains recommended for browsing for services on (using ServiceBrowser). |
KDNSSD::DomainBrowser::Publishing | 1 | Domains recommended for publishing to (using PublicService). |
Member Function Documentation
[explicit]
DomainBrowser::DomainBrowser(KDNSSD::DomainBrowser::DomainType type, QObject *parent = nullptr)
Standard constructor
The global DNS-SD configuration (for example, the global Avahi configuration for the Avahi backend) will be used.
type is the type of domain to search for
parent is the parent object (see QObject documentation)
See also startBrowse() and ServiceBrowser::isAvailable().
[signal]
void DomainBrowser::domainAdded(const QString &domain)
A new domain has been discovered.
If the requested DomainType is Browsing, this will also be emitted for the domains specified in the global configuration.
domain is the name of the domain
See also domainRemoved().
[signal]
void DomainBrowser::domainRemoved(const QString &domain)
A domain has disappeared from the browsed list.
Emitted when domain has been removed from browsing list or the publishing list (depending on which list was requested in the constructor).
domain is the name of the domain
See also domainAdded().
QStringList DomainBrowser::domains() const
The current known list of domains of the requested DomainType.
Returns a list of currently known domain names
bool DomainBrowser::isRunning() const
Whether the browsing has been started.
Returns true
if startBrowse() has been called, false
otherwise
void DomainBrowser::startBrowse()
Starts browsing.
Note: Only the first call to this function will have any effect.
Browsing stops when the DomainBrowser object is destroyed.
Warning: The domainAdded() signal may be emitted before this function returns.
See also domainAdded() and domainRemoved().