• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

DNSSD

avahi-servicetypebrowser.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002  *
00003  * Copyright (C) 2004,2007 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 
00022 #include "avahi-servicetypebrowser_p.h"
00023 #include <QtCore/QSet>
00024 #include "avahi_server_interface.h"
00025 #include "servicetypebrowser.h"
00026 #include "avahi_servicetypebrowser_interface.h"
00027 
00028 #define UNSPEC -1
00029 #ifndef KDE_USE_FINAL
00030 Q_DECLARE_METATYPE(QList<QByteArray>)
00031 #endif
00032 namespace DNSSD
00033 {
00034 
00035 ServiceTypeBrowser::ServiceTypeBrowser(const QString& domain, QObject *parent) : QObject(parent), d(new ServiceTypeBrowserPrivate(this))
00036 {
00037     d->m_domain=domain;
00038     d->m_timer.setSingleShot(true);
00039 }
00040 
00041 ServiceTypeBrowser::~ServiceTypeBrowser()
00042 {
00043     delete d;
00044 }
00045 
00046 void ServiceTypeBrowser::startBrowse()
00047 {
00048     if (d->m_started) return;
00049     d->m_started=true;
00050     org::freedesktop::Avahi::Server s("org.freedesktop.Avahi","/",QDBusConnection::systemBus());
00051     QDBusReply<QDBusObjectPath> rep=s.ServiceTypeBrowserNew(-1, -1, d->m_domain, 0);
00052     
00053     if (!rep.isValid()) return;
00054     org::freedesktop::Avahi::ServiceTypeBrowser *b=new org::freedesktop::Avahi::ServiceTypeBrowser("org.freedesktop.Avahi",rep.value().path(),
00055         QDBusConnection::systemBus());
00056     connect(b,SIGNAL(ItemNew(int,int,const QString&,const QString&,uint)),d, SLOT(gotNewServiceType(int,int,const QString&,const QString&, uint)));
00057     connect(b,SIGNAL(ItemRemove(int,int,const QString&,const QString&,uint)),d, SLOT(gotRemoveServiceType(int,int,const QString&,const QString&, uint)));
00058     connect(b,SIGNAL(AllForNow()),d,SLOT(finished()));
00059     connect(&d->m_timer,SIGNAL(timeout()), d, SLOT(finished()));
00060     d->m_browser=b;
00061     d->m_timer.start(TIMEOUT_LAN);
00062 }
00063 
00064 void ServiceTypeBrowserPrivate::finished()
00065 {
00066     m_timer.stop();
00067     emit m_parent->finished();
00068 }
00069 
00070 void ServiceTypeBrowserPrivate::gotNewServiceType(int,int,const QString& type,const QString&,uint)
00071 {
00072     m_timer.start(TIMEOUT_LAN);
00073     m_servicetypes+=type;
00074     emit m_parent->serviceTypeAdded(type);
00075 }
00076 
00077 
00078 
00079 void ServiceTypeBrowserPrivate::gotRemoveServiceType(int,int,const QString& type,const QString&,uint)
00080 {
00081     m_timer.start(TIMEOUT_LAN);
00082     m_servicetypes.removeAll(type);
00083     emit m_parent->serviceTypeRemoved(type);
00084 }
00085 
00086 
00087 QStringList ServiceTypeBrowser::serviceTypes() const
00088 {
00089     return d->m_servicetypes;
00090 }
00091 
00092 bool ServiceTypeBrowser::isRunning() const
00093 {
00094     return d->m_started;
00095 }
00096 
00097 
00098 }
00099 #include "servicetypebrowser.moc"
00100 #include "avahi-servicetypebrowser_p.moc"

DNSSD

Skip menu "DNSSD"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal