servicebrowser.h
00001 /* This file is part of the KDE project 00002 * 00003 * Copyright (C) 2004 Jakub Stachowski <qbast@go2.pl> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 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