DNSSD
DNSSD::ServiceBrowser Class Reference
#include <DNSSD/ServiceBrowser>

Detailed Description
Most important class for applications that want to discover specific services on network.Suppose that you need list of web servers running. Example:
DNSSD::ServiceBrowser* browser = new DNSSD::ServiceBrowser("_http._tcp"); connect(browser,SIGNAL(serviceAdded(RemoteService::Ptr)),this,SLOT(addService(RemoteService::Ptr))); connect(browser,SIGNAL(serviceRemoved(RemoteService::Ptr)),this,SLOT(delService(RemoteService::Ptr))); browser->startBrowse();
In above example addService will be called for every web server already running or just appearing on network and delService will be called when server is stopped. Because no domain was passed to constructor, default domain will be searched.
Definition at line 55 of file servicebrowser.h.
Public Types | |
enum | State { Working, Stopped, Unsupported } |
Signals | |
void | finished () |
void | serviceAdded (DNSSD::RemoteService::Ptr) |
void | serviceRemoved (DNSSD::RemoteService::Ptr) |
Public Member Functions | |
bool | isAutoResolving () const |
ServiceBrowser (const QString &type, bool autoResolve=false, const QString &domain=QString(), const QString &subtype=QString()) | |
QList< RemoteService::Ptr > | services () const |
virtual void | startBrowse () |
~ServiceBrowser () | |
Static Public Member Functions | |
static State | isAvailable () |
Protected Member Functions | |
virtual void | virtual_hook (int, void *) |
Member Enumeration Documentation
Availability of DNS-SD services.
- Working - available
- Stopped - not available because mdnsd daemon is not running. This flag is currently unused
- Unsupported - not available because KDE was compiled without DNS-SD support
Definition at line 65 of file servicebrowser.h.
Constructor & Destructor Documentation
DNSSD::ServiceBrowser::ServiceBrowser | ( | const QString & | type, | |
bool | autoResolve = false , |
|||
const QString & | domain = QString() , |
|||
const QString & | subtype = QString() | |||
) | [explicit] |
ServiceBrowser constructor.
- Parameters:
-
type Service types to browse for (example: "_http._tcp"). autoResolve - after disovering new service it will be resolved and then reported with serviceAdded() signal. It raises network usage by resolving all services, so use it only when necessary. domain Domain name. Can be left as null string to use default domain subtypes Set it to browse only for specific subtype
Definition at line 33 of file avahi-servicebrowser.cpp.
DNSSD::ServiceBrowser::~ServiceBrowser | ( | ) |
Definition at line 49 of file avahi-servicebrowser.cpp.
Member Function Documentation
void DNSSD::ServiceBrowser::finished | ( | ) | [signal] |
Emitted when all services has been reported.
This signal can be used by application that just want to get list of currently available services (similar to directory listing) and do not care about dynamic adding/removing services later. This signal can be emitted many time: for example if new host has been connected to network and is announcing some services interesting to this ServiceBrowser, they will be reported by several serviceAdded() signals and whole batch will be concluded by finished().
bool DNSSD::ServiceBrowser::isAutoResolving | ( | ) | const |
Returns true if newly discovered services are resolved before being reported with serviceAdded().
- Since:
- 4.1
Definition at line 54 of file avahi-servicebrowser.cpp.
ServiceBrowser::State DNSSD::ServiceBrowser::isAvailable | ( | ) | [static] |
Checks availability of DNS-SD services (this also covers publishing).
If you use this function to report an error to the user, below is a suggestion on how to word the errors:
switch(DNSSD::ServiceBrowser::isAvailable()) { case DNSSD::ServiceBrowser::Working: return ""; case DNSSD::ServiceBrowser::Stopped: return i18n("<p>The Zeroconf daemon is not running. See the Service Discovery Handbook" " for more information.<br/>" "Other users will not see this system when browsing" " the network via zeroconf, but normal access will still work.</p>"); case DNSSD::ServiceBrowser::Unsupported: return i18n("<p>Zeroconf support is not available in this version of KDE." " See the Service Discovery Handbook for more information.<br/>" "Other users will not see this system when browsing" " the network via zeroconf, but normal access will still work.</p>"); default: return i18n("<p>Unknown error with Zeroconf.<br/>" "Other users will not see this system when browsing" " the network via zeroconf, but normal access will still work.</p>"); }
Definition at line 43 of file avahi-servicebrowser.cpp.
void DNSSD::ServiceBrowser::serviceAdded | ( | DNSSD::RemoteService::Ptr | ) | [signal] |
Emitted when new service is discovered (or resolved if autoresolve is set.
void DNSSD::ServiceBrowser::serviceRemoved | ( | DNSSD::RemoteService::Ptr | ) | [signal] |
Emitted when service is no longer announced.
RemoteService object is deleted from services list and destroyed immediately after this signal returns.
QList< RemoteService::Ptr > DNSSD::ServiceBrowser::services | ( | ) | const |
void DNSSD::ServiceBrowser::startBrowse | ( | ) | [virtual] |
Starts browsing for services.
To stop it just destroy the object.
Definition at line 59 of file avahi-servicebrowser.cpp.
void DNSSD::ServiceBrowser::virtual_hook | ( | int | , | |
void * | ||||
) | [protected, virtual] |
Definition at line 149 of file avahi-servicebrowser.cpp.
The documentation for this class was generated from the following files: