DNSSD
servicebrowser.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #ifndef DNSSDSERVICEBROWSER_H
00022 #define DNSSDSERVICEBROWSER_H
00023 
00024 #include <qobject.h>
00025 #include <qdict.h>
00026 #include <dnssd/remoteservice.h>
00027 
00028 
00029 class QStringList;
00030 namespace DNSSD
00031 {
00032 class DomainBrowser;
00033 class ServiceBrowserPrivate;
00034 
00054 class KDNSSD_EXPORT ServiceBrowser : public QObject
00055 {
00056     Q_OBJECT
00057 public:
00064     enum Flags {
00065     AutoDelete =1,
00066     AutoResolve = 2
00067     };
00068 
00075     enum State { Working, Stopped, Unsupported };
00076 
00091     ServiceBrowser(const QStringList& types,DomainBrowser* domains,int flags);
00092 
00100     ServiceBrowser(const QString& type,DomainBrowser* domains=0,bool autoResolve=false);
00101 
00111     ServiceBrowser(const QString& type,const QString& domain, int flags);
00112 
00116     ServiceBrowser(const QString& type,const QString& domain, bool autoResolve=false);
00117 
00118     ~ServiceBrowser();
00119 
00123     const QValueList<RemoteService::Ptr>& services() const;
00124 
00129     virtual void startBrowse();
00130 
00136     const DomainBrowser* browsedDomains() const;
00137 
00142     static const QString AllServices;
00143 
00172     static const State isAvailable();
00173 
00174 signals:
00179     void serviceAdded(DNSSD::RemoteService::Ptr);
00185     void serviceRemoved(DNSSD::RemoteService::Ptr);
00186 
00196     void finished();
00197 
00198 public slots:
00202     void removeDomain(const QString& domain);
00203 
00207     void addDomain(const QString& domain);
00208 
00209 protected:
00210     virtual void virtual_hook(int, void*);
00211 private:
00212     ServiceBrowserPrivate *d;
00213 
00214     bool allFinished();
00215     void init(const QStringList&, DomainBrowser*, int);
00216     QValueList<RemoteService::Ptr>::Iterator findDuplicate(RemoteService::Ptr src);
00217 private slots:
00218     void serviceResolved(bool success);
00219     void gotNewService(DNSSD::RemoteService::Ptr);
00220     void gotRemoveService(DNSSD::RemoteService::Ptr);
00221     void queryFinished();
00222 
00223 };
00224 
00225 }
00226 
00227 #endif