1 /* This file is part of the KDE Project
2 Copyright (c) 2004 Jakub Stachowski <qbast@go2.pl>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
21 #include <kdirnotify.h>
22 #include <dnssd/remoteservice.h>
23 #include <dnssd/servicebrowser.h>
24 #include <dnssd/servicetypebrowser.h>
27 : refcount(1), updateNeeded(false)
31 ServiceWatcher::ServiceWatcher(const QString
& type
) : Watcher(), m_type(type
)
33 browser
= new DNSSD::ServiceBrowser(type
);
34 browser
->setParent(this);
35 connect(browser
,SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr
)),
36 SLOT(scheduleUpdate()));
37 connect(browser
,SIGNAL(serviceRemoved(DNSSD::RemoteService::Ptr
)),
38 SLOT(scheduleUpdate()));
39 connect(browser
,SIGNAL(finished()),SLOT(finished()));
40 browser
->startBrowse();
44 TypeWatcher::TypeWatcher() : Watcher()
46 typebrowser
= new DNSSD::ServiceTypeBrowser();
47 typebrowser
->setParent(this);
48 connect(typebrowser
,SIGNAL(serviceTypeAdded(const QString
&)),
49 this,SLOT(scheduleUpdate()));
50 connect(typebrowser
,SIGNAL(serviceTypeRemoved(const QString
&)),
51 this,SLOT(scheduleUpdate()));
52 connect(typebrowser
,SIGNAL(finished()),this,SLOT(finished()));
53 typebrowser
->startBrowse();
56 QString
TypeWatcher::constructUrl()
58 return QString("zeroconf:/");
61 QString
ServiceWatcher::constructUrl()
63 return QString("zeroconf:/")+m_type
+'/';
66 void Watcher::scheduleUpdate()
71 void Watcher::finished()
73 if (updateNeeded
) org::kde::KDirNotify::emitFilesAdded( constructUrl() );
77 #include "watcher.moc"