\section{DNSSD::Service\-Browser Class Reference}
\label{classDNSSD_1_1ServiceBrowser}\index{DNSSD::ServiceBrowser@{DNSSD::ServiceBrowser}}
Most important class for applications that want to discover specific services on network. Browsing for specific type of services or all available service types.  


{\tt \#include $<$servicebrowser.h$>$}

Inheritance diagram for DNSSD::Service\-Browser:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=81pt]{classDNSSD_1_1ServiceBrowser__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for DNSSD::Service\-Browser:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=92pt]{classDNSSD_1_1ServiceBrowser__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Types}
\begin{CompactItemize}
\item 
enum {\bf State} \{ {\bf Working}, 
{\bf Stopped}, 
{\bf Unsupported}
 \}
\end{CompactItemize}
\subsection*{Public Slots}
\begin{CompactItemize}
\item 
void {\bf remove\-Domain} (const {\bf QString} \&domain)
\item 
void {\bf add\-Domain} (const {\bf QString} \&domain)
\end{CompactItemize}
\subsection*{Signals}
\begin{CompactItemize}
\item 
void {\bf service\-Added} (DNSSD::Remote\-Service::Ptr)
\item 
void {\bf service\-Removed} (DNSSD::Remote\-Service::Ptr)
\item 
void {\bf finished} ()
\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Service\-Browser} (const {\bf QString} \&type, {\bf Domain\-Browser} $\ast$domains=0, bool auto\-Resolve=false)
\item 
{\bf Service\-Browser} (const {\bf QString} \&type, const {\bf QString} \&domain, bool auto\-Resolve=false)
\item 
const {\bf QValue\-List}$<$ Remote\-Service::Ptr $>$ \& {\bf services} () const 
\item 
virtual void {\bf start\-Browse} ()
\item 
const {\bf Domain\-Browser} $\ast$ {\bf browsed\-Domains} () const 
\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static const {\bf State} {\bf is\-Available} ()
\end{CompactItemize}
\subsection*{Static Public Attributes}
\begin{CompactItemize}
\item 
static const {\bf QString} {\bf All\-Services} = \char`\"{}\_\-services.\_\-dns-sd.\_\-udp\char`\"{}
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual void {\bf virtual\_\-hook} (int, void $\ast$)\label{classDNSSD_1_1ServiceBrowser_b0}

\end{CompactItemize}


\subsection{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:



\footnotesize\begin{verbatim}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();
\end{verbatim}
\normalsize


In above example add\-Service will be called for every web server already running or just appearing on network and del\-Service will be called when server is stopped. Because no {\bf Domain\-Browser}{\rm (p.\,\pageref{classDNSSD_1_1DomainBrowser})} was passed to constructor, domains configured by user will be searched.

\begin{Desc}
\item[Author:]Jakub Stachowski \end{Desc}




Definition at line 54 of file servicebrowser.h.

\subsection{Member Enumeration Documentation}
\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!State@{State}}
\index{State@{State}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}enum {\bf DNSSD::Service\-Browser::State}}\label{classDNSSD_1_1ServiceBrowser_w3}


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.

\subsection{Constructor \& Destructor Documentation}
\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!ServiceBrowser@{ServiceBrowser}}
\index{ServiceBrowser@{ServiceBrowser}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}DNSSD::Service\-Browser::Service\-Browser (const {\bf QString} \& {\em type}, {\bf Domain\-Browser} $\ast$ {\em domains} = {\tt 0}, bool {\em auto\-Resolve} = {\tt false})}\label{classDNSSD_1_1ServiceBrowser_a0}


{\bf Service\-Browser}{\rm (p.\,\pageref{classDNSSD_1_1ServiceBrowser})} constructor. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em type}]Type of services to browse for (example: \char`\"{}\_\-http.\_\-tcp\char`\"{}). Can also be DNSSD::Services\-Browser::All\-Services to specify \char`\"{}metaquery\char`\"{} for all service types present on network \item[{\em domains}]{\bf Domain\-Browser}{\rm (p.\,\pageref{classDNSSD_1_1DomainBrowser})} object used to specify domains to browse. You do not have to connect its domain\-Added() signal - it will be done automatically. You can left this parameter as NULL for default domains. \item[{\em auto\-Resolve}]If set to TRUE, after disovering new service it will be resolved and then reported with {\bf service\-Added()}{\rm (p.\,\pageref{classDNSSD_1_1ServiceBrowser_l0})} signal. It raises network usage by resolving all services, so use it only when necessary.\end{description}
\end{Desc}


Definition at line 50 of file servicebrowser.cpp.\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!ServiceBrowser@{ServiceBrowser}}
\index{ServiceBrowser@{ServiceBrowser}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}DNSSD::Service\-Browser::Service\-Browser (const {\bf QString} \& {\em type}, const {\bf QString} \& {\em domain}, bool {\em auto\-Resolve} = {\tt false})}\label{classDNSSD_1_1ServiceBrowser_a1}


Overloaded constructor used to create browser for one domain. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em domain}]Domain name. You can add more domains later using add\-Domain and remove them with remove\-Domain\end{description}
\end{Desc}


Definition at line 67 of file servicebrowser.cpp.

\subsection{Member Function Documentation}
\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!services@{services}}
\index{services@{services}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const {\bf QValue\-List}$<$ Remote\-Service::Ptr $>$ \& DNSSD::Service\-Browser::services () const}\label{classDNSSD_1_1ServiceBrowser_a3}


Returns list of services. 



Definition at line 188 of file servicebrowser.cpp.\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!startBrowse@{startBrowse}}
\index{startBrowse@{startBrowse}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void DNSSD::Service\-Browser::start\-Browse ()\hspace{0.3cm}{\tt  [virtual]}}\label{classDNSSD_1_1ServiceBrowser_a4}


Starts browsing for services. 

To stop it just destroy the object.

Definition at line 112 of file servicebrowser.cpp.

References add\-Domain(), QValue\-List::begin(), and QValue\-List::end().\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!browsedDomains@{browsedDomains}}
\index{browsedDomains@{browsedDomains}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const {\bf Domain\-Browser} $\ast$ DNSSD::Service\-Browser::browsed\-Domains () const}\label{classDNSSD_1_1ServiceBrowser_a5}


Return {\bf Domain\-Browser}{\rm (p.\,\pageref{classDNSSD_1_1DomainBrowser})} 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.\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!isAvailable@{isAvailable}}
\index{isAvailable@{isAvailable}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const {\bf Service\-Browser::State} DNSSD::Service\-Browser::is\-Available ()\hspace{0.3cm}{\tt  [static]}}\label{classDNSSD_1_1ServiceBrowser_e0}


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:



\footnotesize\begin{verbatim}    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>");
        }
\end{verbatim}
\normalsize


Definition at line 72 of file servicebrowser.cpp.\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!serviceAdded@{serviceAdded}}
\index{serviceAdded@{serviceAdded}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void DNSSD::Service\-Browser::service\-Added (DNSSD::Remote\-Service::Ptr)\hspace{0.3cm}{\tt  [signal]}}\label{classDNSSD_1_1ServiceBrowser_l0}


Emitted when new service is discovered (or resolved if autoresolve is set. 



Referenced by add\-Domain().\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!serviceRemoved@{serviceRemoved}}
\index{serviceRemoved@{serviceRemoved}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void DNSSD::Service\-Browser::service\-Removed (DNSSD::Remote\-Service::Ptr)\hspace{0.3cm}{\tt  [signal]}}\label{classDNSSD_1_1ServiceBrowser_l1}


Emitted when service is no longer announced. 

{\bf Remote\-Service}{\rm (p.\,\pageref{classDNSSD_1_1RemoteService})} object is deleted from services list and destroyed immediately after this signal returns.

Referenced by add\-Domain(), and remove\-Domain().\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!finished@{finished}}
\index{finished@{finished}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void DNSSD::Service\-Browser::finished ()\hspace{0.3cm}{\tt  [signal]}}\label{classDNSSD_1_1ServiceBrowser_l2}


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 {\bf Service\-Browser}{\rm (p.\,\pageref{classDNSSD_1_1ServiceBrowser})}, they will be reported by several {\bf service\-Added()}{\rm (p.\,\pageref{classDNSSD_1_1ServiceBrowser_l0})} signals and whole batch will be concluded by {\bf finished()}{\rm (p.\,\pageref{classDNSSD_1_1ServiceBrowser_l2})}.

Referenced by add\-Domain().\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!removeDomain@{removeDomain}}
\index{removeDomain@{removeDomain}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void DNSSD::Service\-Browser::remove\-Domain (const {\bf QString} \& {\em domain})\hspace{0.3cm}{\tt  [slot]}}\label{classDNSSD_1_1ServiceBrowser_i0}


Remove one domain from list of domains to browse. 



Definition at line 147 of file servicebrowser.cpp.

References QValue\-List::begin(), QValue\-List::end(), QValue\-List::remove(), and service\-Removed().\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!addDomain@{addDomain}}
\index{addDomain@{addDomain}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void DNSSD::Service\-Browser::add\-Domain (const {\bf QString} \& {\em domain})\hspace{0.3cm}{\tt  [slot]}}\label{classDNSSD_1_1ServiceBrowser_i1}


Add new domain to browse. 



Definition at line 159 of file servicebrowser.cpp.

References QObject::connect(), finished(), service\-Added(), service\-Removed(), and DNSSD::Query::start\-Query().

Referenced by start\-Browse().

\subsection{Member Data Documentation}
\index{DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}!AllServices@{AllServices}}
\index{AllServices@{AllServices}!DNSSD::ServiceBrowser@{DNSSD::Service\-Browser}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const {\bf QString} {\bf DNSSD::Service\-Browser::All\-Services} = \char`\"{}\_\-services.\_\-dns-sd.\_\-udp\char`\"{}\hspace{0.3cm}{\tt  [static]}}\label{classDNSSD_1_1ServiceBrowser_s0}


Special service type to search for all available service types. 

Pass it as \char`\"{}type\char`\"{} parameter to {\bf Service\-Browser}{\rm (p.\,\pageref{classDNSSD_1_1ServiceBrowser})} constructor.

Definition at line 33 of file servicebrowser.cpp.

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
servicebrowser.h\item 
servicebrowser.cpp\end{CompactItemize}
