| # dnssd Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# DNSSD::ServiceBrowser Class Reference

Most important class for applications that want to discover specific services on network. Browsing for specific type of services or all available service types. More...

`#include <servicebrowser.h>`

Inheritance diagram for DNSSD::ServiceBrowser:

[legend]
Collaboration diagram for DNSSD::ServiceBrowser:

[legend]
List of all members.

## Public Types
enum | State { Working, Stopped, Unsupported }
## Public Slots
void | removeDomain (const QString &domain)
void | addDomain (const QString &domain)
## Signals
void | serviceAdded (DNSSD::RemoteService::Ptr)
void | serviceRemoved (DNSSD::RemoteService::Ptr)
void | finished ()
## Public Member Functions
| ServiceBrowser (const QString &type, DomainBrowser *domains=0, bool autoResolve=false)
| ServiceBrowser (const QString &type, const QString &domain, bool autoResolve=false)
const QValueList< RemoteService::Ptr > & | services () const
virtual void | startBrowse ()
const DomainBrowser * | browsedDomains () const
## Static Public Member Functions
static const State | isAvailable ()
## Static Public Attributes
static const QString | AllServices = "_services._dns-sd._udp"
## Protected Member Functions
virtual void | virtual_hook (int, void *)

## Detailed Description

Most important class for applications that want to discover specific services on network. Browsing for specific type of services or all available service types.

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 DomainBrowser was passed to constructor, domains configured by user will be searched.

Author:
  Jakub Stachowski

Definition at line 54 of file servicebrowser.h.

## Member Enumeration Documentation

enum DNSSD::ServiceBrowser::State

| Availability of DNS-SD services. Working - available Stopped - not available because mdnsd daemon is not running Unsupported - not available because KDE was compiled without DNS-SD support Definition at line 64 of file servicebrowser.h.

## Constructor & Destructor Documentation

DNSSD::ServiceBrowser::ServiceBrowser | ( | const QString & | type,
|  | DomainBrowser * | domains = `0`,
|  | bool | autoResolve = `false`
| ) |

  | ServiceBrowser constructor. Parameters:
  | type | Type of services to browse for (example: "_http._tcp"). Can also be DNSSD::ServicesBrowser::AllServices to specify "metaquery" for all service types present on network
  | domains | DomainBrowser object used to specify domains to browse. You do not have to connect its domainAdded() signal - it will be done automatically. You can left this parameter as NULL for default domains.
  | autoResolve | If set to TRUE, 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.
Definition at line 50 of file servicebrowser.cpp.

DNSSD::ServiceBrowser::ServiceBrowser | ( | const QString & | type,
|  | const QString & | domain,
|  | bool | autoResolve = `false`
| ) |

  | Overloaded constructor used to create browser for one domain. Parameters:
  | domain | Domain name. You can add more domains later using addDomain and remove them with removeDomain
Definition at line 67 of file servicebrowser.cpp.

## Member Function Documentation

const QValueList< RemoteService::Ptr > & DNSSD::ServiceBrowser::services | ( |  | ) | const

| Returns list of services. Definition at line 188 of file servicebrowser.cpp.

void DNSSD::ServiceBrowser::startBrowse | ( |  | ) | `[virtual]`

| Starts browsing for services. To stop it just destroy the object. Definition at line 112 of file servicebrowser.cpp. References addDomain(), QValueList::begin(), and QValueList::end().

const DomainBrowser * DNSSD::ServiceBrowser::browsedDomains | ( |  | ) | const

| Return DomainBrowser containing domains being browsed. Valid object will returned even if 'domains' parameters in constructor was set to NULL or single domain constructor was used. Definition at line 89 of file servicebrowser.cpp.

const 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 72 of file servicebrowser.cpp.

void DNSSD::ServiceBrowser::serviceAdded | ( | DNSSD::RemoteService::Ptr |  | ) | `[signal]`

| Emitted when new service is discovered (or resolved if autoresolve is set. Referenced by addDomain().

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. Referenced by addDomain(), and removeDomain().

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(). Referenced by addDomain().

void DNSSD::ServiceBrowser::removeDomain | ( | const QString & | domain | ) | `[slot]`

| Remove one domain from list of domains to browse. Definition at line 147 of file servicebrowser.cpp. References QValueList::begin(), QValueList::end(), QValueList::remove(), and serviceRemoved().

void DNSSD::ServiceBrowser::addDomain | ( | const QString & | domain | ) | `[slot]`

| Add new domain to browse. Definition at line 159 of file servicebrowser.cpp. References QObject::connect(), finished(), serviceAdded(), serviceRemoved(), and DNSSD::Query::startQuery(). Referenced by startBrowse().

## Member Data Documentation

const QString DNSSD::ServiceBrowser::AllServices = "_services._dns-sd._udp"`[static]`

| Special service type to search for all available service types. Pass it as "type" parameter to ServiceBrowser constructor. Definition at line 33 of file servicebrowser.cpp.

The documentation for this class was generated from the following files:

- servicebrowser.h
- servicebrowser.cpp

This file is part of the documentation for dnssd Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:28:26 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003