Don't hide mainwindow after canceling quit-warning.
[kdenetwork.git] / kdnssd / kdedmodule / watcher.cpp
blob9fc32b1461ec30e71a54901657224c214e73f312
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., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA.
19 #include "watcher.h"
21 #include <kdebug.h>
23 #include <kdirnotify_stub.h>
24 #include <qstringlist.h>
28 Watcher::Watcher(const QString& type, const QString& domain)
29 : refcount(1), updateNeeded(false), m_type(type), m_domain(domain)
31 if (domain.isEmpty()) browser = new ServiceBrowser(type);
32 else browser = new ServiceBrowser(type,domain);
33 connect(browser,SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr)),
34 SLOT(serviceAdded(DNSSD::RemoteService::Ptr)));
35 connect(browser,SIGNAL(serviceRemoved(DNSSD::RemoteService::Ptr)),
36 SLOT(serviceRemoved(DNSSD::RemoteService::Ptr)));
37 connect(browser,SIGNAL(finished()),SLOT(finished()));
38 browser->startBrowse();
41 Watcher::~Watcher()
43 delete browser;
46 void Watcher::serviceAdded(DNSSD::RemoteService::Ptr)
48 updateNeeded=true;
51 void Watcher::serviceRemoved(DNSSD::RemoteService::Ptr srv)
53 if (!updateNeeded) removed << srv;
57 void Watcher::finished()
59 KDirNotify_stub st("*","*");
60 kdDebug() << "Finished for " << m_type << "@" << m_domain << "\n";
61 if (updateNeeded || removed.count()) {
62 QString url = "zeroconf:/";
63 if (!m_domain.isEmpty()) url+="/"+m_domain+"/";
64 if (m_type!=ServiceBrowser::AllServices) url+=m_type;
65 kdDebug() << "Sending update: " << url << "\n";
66 st.FilesAdded(url);
68 removed.clear();
69 updateNeeded=false;
72 #include "watcher.moc"