diff options
Diffstat (limited to 'tdednssd')
24 files changed, 1206 insertions, 0 deletions
diff --git a/tdednssd/CMakeLists.txt b/tdednssd/CMakeLists.txt new file mode 100644 index 00000000..8aedd4c0 --- /dev/null +++ b/tdednssd/CMakeLists.txt @@ -0,0 +1,13 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +add_subdirectory( ioslave ) +add_subdirectory( kdedmodule ) diff --git a/tdednssd/Makefile.am b/tdednssd/Makefile.am new file mode 100644 index 00000000..cdc3548c --- /dev/null +++ b/tdednssd/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = ioslave kdedmodule diff --git a/tdednssd/ioslave/CMakeLists.txt b/tdednssd/ioslave/CMakeLists.txt new file mode 100644 index 00000000..6a37a49a --- /dev/null +++ b/tdednssd/ioslave/CMakeLists.txt @@ -0,0 +1,44 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +install( FILES + zeroconf.protocol invitation.protocol + DESTINATION ${SERVICES_INSTALL_DIR} ) + +install( FILES + _http._tcp _ftp._tcp _ldap._tcp _webdav._tcp _nfs._tcp _ssh._tcp + DESTINATION ${DATA_INSTALL_DIR}/zeroconf ) + +install( FILES + zeroconf.desktop + DESTINATION ${DATA_INSTALL_DIR}/remoteview ) + + +##### kio_zeroconf (module) ##################### + +tde_add_kpart( kio_zeroconf AUTOMOC + SOURCES dnssd.cpp + LINK tdednssd-shared kio-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/tdednssd/ioslave/CONFIG_FORMAT b/tdednssd/ioslave/CONFIG_FORMAT new file mode 100644 index 00000000..43e34001 --- /dev/null +++ b/tdednssd/ioslave/CONFIG_FORMAT @@ -0,0 +1,53 @@ +Every DNS-SD service type used with zeroconf:/ ioslave needs +configuration file in $DATADIR/zeroconf with name matching service type. +Used entries: + +Type - obligatory, must match file name +Name - obligarory, specifies user friendly name shown in konqueror/ file dialog +Name[language] - optional, contains the localized friendly name. E.g. Name[gb]=Colour server +Exec - optional, specifies executable for helper service - used if service has no + corresponding helper protocol +Protocol - optional, specifies real protocol name, will be taken from service name + if not set (for example _ssh._tcp => ssh://) +Icon - optional, if not set will be taken from protocol +PathEntry - optional, contains name of attribute carrying path +UserEntry - optional, contains name of attribute carrying user name +PasswdEntry - optional, contains name of attribute carrying password + + +Examples: + +Name=FTP servers +Type=_ftp._tcp +PathEntry=path +UserEntry=u +PasswordEntry=p + +Protocol is taken from service type (ftp), if service is announced with attributes path, u or p, it +will be inserted into resolved URL. +Service published with: Name="Public files", type="_ftp._tcp", port=7773, attributes: path=/home/test/public_files, +u=test, p=public on hostname "Storage" will be resolved into ftp://test:[email protected]/home/test/public_files + +----- + + +Name=Remote shell (ssh) +Type=_ssh._tcp +UserEntry=u +PasswordEntry=p + + +Resolved URL will be ssh://user:password@machine:port/ . ssh is helper protocol so ktelnetservice will be launched for +this URL. + + + +----------- + +Name=Battleship games +Type=_kbattleship._tcp +Exec=kbattleship %u + +URL will be resolved into kbattleship://host:port, then "kbattleship kbattleship://host:port" will be launched + + diff --git a/tdednssd/ioslave/Makefile.am b/tdednssd/ioslave/Makefile.am new file mode 100644 index 00000000..3454d0f1 --- /dev/null +++ b/tdednssd/ioslave/Makefile.am @@ -0,0 +1,21 @@ +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = kio_zeroconf.la + +kio_zeroconf_la_SOURCES = dnssd.cpp +kio_zeroconf_la_LIBADD = $(LIB_KDNSSD) $(LIB_KIO) +kio_zeroconf_la_LDFLAGS = -avoid-version -module $(all_libraries) $(KDE_PLUGIN) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor + +protocol_DATA = zeroconf.protocol invitation.protocol +protocoldir = $(kde_servicesdir) + +services_DATA = _http._tcp _ftp._tcp _ldap._tcp _webdav._tcp _nfs._tcp _ssh._tcp +servicesdir = $(kde_datadir)/zeroconf + +remote_DATA = zeroconf.desktop +remotedir = $(kde_datadir)/remoteview + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kio_zeroconf.pot + +METASOURCES = AUTO diff --git a/tdednssd/ioslave/_ftp._tcp b/tdednssd/ioslave/_ftp._tcp new file mode 100644 index 00000000..27655cb4 --- /dev/null +++ b/tdednssd/ioslave/_ftp._tcp @@ -0,0 +1,5 @@ +Name=FTP servers +Type=_ftp._tcp +PathEntry=path +UserEntry=u +PasswordEntry=p diff --git a/tdednssd/ioslave/_http._tcp b/tdednssd/ioslave/_http._tcp new file mode 100644 index 00000000..8ce740b7 --- /dev/null +++ b/tdednssd/ioslave/_http._tcp @@ -0,0 +1,5 @@ +Name=WWW servers +Type=_http._tcp +PathEntry=path +UserEntry=u +PasswordEntry=p diff --git a/tdednssd/ioslave/_ldap._tcp b/tdednssd/ioslave/_ldap._tcp new file mode 100644 index 00000000..74a3a0cf --- /dev/null +++ b/tdednssd/ioslave/_ldap._tcp @@ -0,0 +1,2 @@ +Name=Lightweight Directory Access Protocol +Type=_ldap._tcp diff --git a/tdednssd/ioslave/_nfs._tcp b/tdednssd/ioslave/_nfs._tcp new file mode 100644 index 00000000..4748fe5b --- /dev/null +++ b/tdednssd/ioslave/_nfs._tcp @@ -0,0 +1,3 @@ +Name=NFS Remote directory +Type=_nfs._tcp +PathEntry=path diff --git a/tdednssd/ioslave/_ssh._tcp b/tdednssd/ioslave/_ssh._tcp new file mode 100644 index 00000000..9deadb3c --- /dev/null +++ b/tdednssd/ioslave/_ssh._tcp @@ -0,0 +1,4 @@ +Name=Remote shell (ssh) +Type=_ssh._tcp +UserEntry=u +PasswordEntry=p diff --git a/tdednssd/ioslave/_telnet._tcp b/tdednssd/ioslave/_telnet._tcp new file mode 100644 index 00000000..4a8c676b --- /dev/null +++ b/tdednssd/ioslave/_telnet._tcp @@ -0,0 +1,4 @@ +Name=Remote shell (telnet) +Type=_telnet._tcp +UserEntry=u +PasswordEntry=p diff --git a/tdednssd/ioslave/_webdav._tcp b/tdednssd/ioslave/_webdav._tcp new file mode 100644 index 00000000..3c99b54a --- /dev/null +++ b/tdednssd/ioslave/_webdav._tcp @@ -0,0 +1,5 @@ +Name=WebDav remote directory +Type=_webdav._tcp +PathEntry=path +UserEntry=u +PasswordEntry=p diff --git a/tdednssd/ioslave/dnssd.cpp b/tdednssd/ioslave/dnssd.cpp new file mode 100644 index 00000000..ba510be0 --- /dev/null +++ b/tdednssd/ioslave/dnssd.cpp @@ -0,0 +1,369 @@ +/*************************************************************************** + * Copyright (C) 2004, 2005 by Jakub Stachowski * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include <tqcstring.h> +#include <tqsocket.h> +#include <tqdatetime.h> +#include <tqbitarray.h> + +#include <stdlib.h> +#include <math.h> +#include <unistd.h> +#include <sys/socket.h> +#include <sys/stat.h> +#include <netinet/in.h> +#include <netdb.h> + +#include <kconfig.h> +#include <kdebug.h> +#include <kmessagebox.h> +#include <kinstance.h> +#include <kglobal.h> +#include <kstandarddirs.h> +#include <tdesocketaddress.h> +#include <kprotocolinfo.h> +#include <kcmdlineargs.h> +#include <klocale.h> +#include <kurl.h> +#include <ksock.h> +#include <tqmap.h> +#include <kapplication.h> +#include <tqeventloop.h> +#include <dnssd/domainbrowser.h> +#include <krun.h> + + +#include "dnssd.h" + +static const KCmdLineOptions options[] = +{ + { "+protocol", I18N_NOOP( "Protocol name" ), 0 }, + { "+pool", I18N_NOOP( "Socket name" ), 0 }, + { "+app", I18N_NOOP( "Socket name" ), 0 }, + KCmdLineLastOption +}; + +ZeroConfProtocol::ZeroConfProtocol(const TQCString& protocol, const TQCString &pool_socket, const TQCString &app_socket) + : SlaveBase(protocol, pool_socket, app_socket), browser(0),toResolve(0), + configData(0) +{} + +ZeroConfProtocol::~ZeroConfProtocol() +{ + delete configData; +} + +void ZeroConfProtocol::get(const KURL& url ) +{ + if (!dnssdOK()) return; + UrlType t = checkURL(url); + switch (t) { + case HelperProtocol: + { + resolveAndRedirect(url,true); + mimeType("text/html"); + TQString reply= "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"; + reply+="</head>\n<body>\n<h2>"+i18n("Requested service has been launched in separate window."); + reply+="</h2>\n</body></html>"; + data(reply.utf8()); + data(TQByteArray()); + finished(); + break; + } + case Service: + resolveAndRedirect(url); + break; + default: + error(ERR_MALFORMED_URL,i18n("invalid URL")); + } +} +void ZeroConfProtocol::mimetype(const KURL& url ) +{ + resolveAndRedirect(url); +} + +UrlType ZeroConfProtocol::checkURL(const KURL& url) +{ + if (url.path()=="/") return RootDir; + TQString service, type, domain; + dissect(url,service,type,domain); + const TQString& proto = type.section('.',1,-1); + if (type[0]!='_' || (proto!="_udp" && proto!="_tcp")) return Invalid; + if (service.isEmpty()) return ServiceDir; + if (!domain.isEmpty()) { + if (!setConfig(type)) return Invalid; + if (!configData->readEntry("Exec").isNull()) return HelperProtocol; + return (KProtocolInfo::isHelperProtocol( configData->readEntry( "Protocol", + type.section(".",0,0).mid(1)))) ? HelperProtocol : Service; + } + return Invalid; +} + +// URL zeroconf://domain/_http._tcp/some%20service +// URL invitation://host:port/_http._tcp/some%20service?u=username&root=directory +void ZeroConfProtocol::dissect(const KURL& url,TQString& name,TQString& type,TQString& domain) +{ + type = url.path().section("/",1,1); + domain = url.host(); + name = url.path().section("/",2,-1); + +} + +bool ZeroConfProtocol::dnssdOK() +{ + switch(ServiceBrowser::isAvailable()) { + case ServiceBrowser::Stopped: + error(TDEIO::ERR_UNSUPPORTED_ACTION, + i18n("The Zeroconf daemon (mdnsd) is not running.")); + return false; + case ServiceBrowser::Unsupported: + error(TDEIO::ERR_UNSUPPORTED_ACTION, + i18n("TDE has been built without Zeroconf support.")); + return false; + default: + return true; + } +} + +void ZeroConfProtocol::stat(const KURL& url) +{ + UDSEntry entry; + if (!dnssdOK()) return; + UrlType t = checkURL(url); + switch (t) { + case RootDir: + case ServiceDir: + buildDirEntry(entry,""); + statEntry(entry); + finished(); + break; + case Service: + resolveAndRedirect(url); + break; + case HelperProtocol: + { + TQString name,type,domain; + dissect(url,name,type,domain); + buildServiceEntry(entry,name,type,domain); + statEntry(entry); + finished(); + break; + } + default: + error(ERR_MALFORMED_URL,i18n("invalid URL")); + } +} +TQString ZeroConfProtocol::getAttribute(const TQString& name) +{ + TQString entry = configData->readEntry(name); + return (entry.isNull()) ? TQString() : toResolve->textData()[entry]; +} + +void ZeroConfProtocol::resolveAndRedirect(const KURL& url, bool useKRun) +{ + TQString name,type,domain; + dissect(url,name,type,domain); + if (url.protocol()=="invitation") { + delete toResolve; + toResolve=0; + toResolve= new RemoteService(url); + if (!toResolve->isResolved()) error(ERR_MALFORMED_URL,i18n("Invalid URL")); + } else { + kdDebug() << "Resolve for " << name << ", " << type << ", " << domain << "\n"; + if (toResolve!=0) + if (toResolve->serviceName()==name && toResolve->type()==type && + toResolve->domain()==domain && toResolve->isResolved()) { + } else { + delete toResolve; + toResolve = 0; + } + if (toResolve==0) { + toResolve = new RemoteService(name,type,domain); + // or maybe HOST_NOT_FOUND? + if (!toResolve->resolve()) error(ERR_SERVICE_NOT_AVAILABLE,i18n("Unable to resolve service")); + } + } + KURL destUrl; + kdDebug() << "Resolved: " << toResolve->hostName() << "\n"; + destUrl.setProtocol(getProtocol(type)); + destUrl.setUser(getAttribute("UserEntry")); + destUrl.setPass(getAttribute("PasswordEntry")); + destUrl.setPath(getAttribute("PathEntry")); + destUrl.setHost(toResolve->hostName()); + destUrl.setPort(toResolve->port()); + // get exec from config or try getting it from helper protocol + if (useKRun) KRun::run(configData->readEntry("Exec",KProtocolInfo::exec(getProtocol(type))),destUrl); + else { + redirection(destUrl); + finished(); + } +} + +bool ZeroConfProtocol::setConfig(const TQString& type) +{ + kdDebug() << "Setting config for " << type << endl; + if (configData) + { + if (configData->readEntry("Type")!=type) + { + delete configData; + configData=0L; + } + else + return true; + } + configData = new TDEConfig("zeroconf/"+type,false,false,"data"); + return (configData->readEntry("Type")==type); +} + +inline void buildAtom(UDSEntry& entry,UDSAtomTypes type, const TQString& data) +{ + UDSAtom atom; + atom.m_uds=type; + atom.m_str=data; + entry.append(atom); +} +inline void buildAtom(UDSEntry& entry,UDSAtomTypes type, long data) +{ + UDSAtom atom; + atom.m_uds=type; + atom.m_long=data; + entry.append(atom); +} + + +void ZeroConfProtocol::buildDirEntry(UDSEntry& entry,const TQString& name,const TQString& type, const TQString& host) +{ + entry.clear(); + buildAtom(entry,UDS_NAME,name); + buildAtom(entry,UDS_ACCESS,0555); + buildAtom(entry,UDS_SIZE,0); + buildAtom(entry,UDS_FILE_TYPE,S_IFDIR); + buildAtom(entry,UDS_MIME_TYPE,"inode/directory"); + if (!type.isNull()) buildAtom(entry,UDS_URL,"zeroconf:/"+((!host.isNull()) ? "/"+host+"/" : "" )+type+"/"); +} +TQString ZeroConfProtocol::getProtocol(const TQString& type) +{ + setConfig(type); + return configData->readEntry("Protocol",type.section(".",0,0).mid(1)); +} + +void ZeroConfProtocol::buildServiceEntry(UDSEntry& entry,const TQString& name,const TQString& type,const TQString& domain) +{ + setConfig(type); + entry.clear(); + buildAtom(entry,UDS_NAME,name); + buildAtom(entry,UDS_ACCESS,0666); + TQString icon=configData->readEntry("Icon",KProtocolInfo::icon(getProtocol(type))); + if (!icon.isNull()) buildAtom(entry,UDS_ICON_NAME,icon); + KURL protourl; + protourl.setProtocol(getProtocol(type)); + TQString encname = "zeroconf://" + domain +"/" +type+ "/" + name; + if (KProtocolInfo::supportsListing(protourl)) { + buildAtom(entry,UDS_FILE_TYPE,S_IFDIR); + encname+="/"; + } else buildAtom(entry,UDS_FILE_TYPE,S_IFREG); + buildAtom(entry,UDS_URL,encname); +} + +void ZeroConfProtocol::listDir(const KURL& url ) +{ + + if (!dnssdOK()) return; + UrlType t = checkURL(url); + UDSEntry entry; + switch (t) { + case RootDir: + if (allDomains=url.host().isEmpty()) + browser = new ServiceBrowser(ServiceBrowser::AllServices); + else browser = new ServiceBrowser(ServiceBrowser::AllServices,url.host()); + connect(browser,TQT_SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr)), + this,TQT_SLOT(newType(DNSSD::RemoteService::Ptr))); + break; + case ServiceDir: + if (url.host().isEmpty()) + browser = new ServiceBrowser(url.path(-1).section("/",1,-1)); + else browser = new ServiceBrowser(url.path(-1).section("/",1,-1),url.host()); + connect(browser,TQT_SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr)), + this,TQT_SLOT(newService(DNSSD::RemoteService::Ptr))); + break; + case Service: + resolveAndRedirect(url); + return; + default: + error(ERR_MALFORMED_URL,i18n("invalid URL")); + return; + } + connect(browser,TQT_SIGNAL(finished()),this,TQT_SLOT(allReported())); + browser->startBrowse(); + kapp->eventLoop()->enterLoop(); +} +void ZeroConfProtocol::allReported() +{ + UDSEntry entry; + listEntry(entry,true); + finished(); + delete browser; + browser=0; + mergedtypes.clear(); + kapp->eventLoop()->exitLoop(); +} +void ZeroConfProtocol::newType(DNSSD::RemoteService::Ptr srv) +{ + if (mergedtypes.contains(srv->type())>0) return; + mergedtypes << srv->type(); + UDSEntry entry; + kdDebug() << "Got new entry " << srv->type() << endl; + if (!setConfig(srv->type())) return; + TQString name = configData->readEntry("Name"); + if (!name.isNull()) { + buildDirEntry(entry,name,srv->type(), (allDomains) ? TQString() : + browser->browsedDomains()->domains()[0]); + listEntry(entry,false); + } +} +void ZeroConfProtocol::newService(DNSSD::RemoteService::Ptr srv) +{ + UDSEntry entry; + buildServiceEntry(entry,srv->serviceName(),srv->type(),srv->domain()); + listEntry(entry,false); +} + + +extern "C" +{ + int KDE_EXPORT kdemain( int argc, char **argv ) + { + // TDEApplication is necessary to use other ioslaves + putenv(strdup("SESSION_MANAGER=")); + TDECmdLineArgs::init(argc, argv, "kio_zeroconf", 0, 0, 0, 0); + TDECmdLineArgs::addCmdLineOptions( options ); + TDEApplication::disableAutoDcopRegistration(); + TDEApplication app; + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + ZeroConfProtocol slave( args->arg(0), args->arg(1), args->arg(2) ); + slave.dispatchLoop(); + return 0; + } +} + + +#include "dnssd.moc" + diff --git a/tdednssd/ioslave/dnssd.h b/tdednssd/ioslave/dnssd.h new file mode 100644 index 00000000..f06b0427 --- /dev/null +++ b/tdednssd/ioslave/dnssd.h @@ -0,0 +1,88 @@ +/*************************************************************************** + * Copyright (C) 2004, 2005 by Jakub Stachowski * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef _dnssd_H_ +#define _dnssd_H_ + +#include <tqstring.h> +#include <tqcstring.h> +#include <tqobject.h> + +#include <kurl.h> +#include <kio/global.h> +#include <kio/slavebase.h> +#include <dnssd/servicebrowser.h> +#include <dnssd/remoteservice.h> +#include <tqstringlist.h> + + +class TQCString; +using namespace TDEIO; +using namespace DNSSD; + +enum UrlType { RootDir, ServiceDir, Service, HelperProtocol, Invalid }; + +class ZeroConfProtocol : public TQObject, public TDEIO::SlaveBase +{ + Q_OBJECT + +public: + ZeroConfProtocol(const TQCString& protocol, const TQCString &pool_socket, const TQCString &app_socket); + ~ZeroConfProtocol(); + virtual void get(const KURL& url); + virtual void mimetype(const KURL& url); + virtual void stat(const KURL& url); + virtual void listDir(const KURL& url ); +private: + // Create UDSEntry for zeroconf:/ or zeroconf:/type/ paths + void buildDirEntry(UDSEntry& entry,const TQString& name,const TQString& type=TQString(), + const TQString& host=TQString()); + // Create UDSEntry for single services: dnssd:/type/service + void buildServiceEntry(UDSEntry& entry,const TQString& name,const TQString& type, + const TQString& domain); + // Returns root dir, service dir, service or invalid + UrlType checkURL(const KURL& url); + // extract name, type and domain from URL + void dissect(const KURL& url,TQString& name,TQString& type,TQString& domain); + // resolve given service and redirect() to it or use KRun on it (used for helper protocols) + void resolveAndRedirect(const KURL& url, bool useKRun = false); + bool dnssdOK(); + TQString getAttribute(const TQString& name); + TQString getProtocol(const TQString& type); + // try to load config file for given service type (or just return if already loaded) + bool setConfig(const TQString& type); + + ServiceBrowser* browser; + // service types merged from all domains - to avoid duplicates + TQStringList mergedtypes; + // last resolved or still being resolved services - acts as one-entry cache + RemoteService *toResolve; + // Config file for service - also acts as one-entry cache + TDEConfig *configData; + // listDir for all domains (zeroconf:/) or one specified (zeroconf://domain/) + bool allDomains; +private slots: + void newType(DNSSD::RemoteService::Ptr); + void newService(DNSSD::RemoteService::Ptr); + void allReported(); + +}; + +#endif diff --git a/tdednssd/ioslave/invitation.protocol b/tdednssd/ioslave/invitation.protocol new file mode 100644 index 00000000..ef6b068c --- /dev/null +++ b/tdednssd/ioslave/invitation.protocol @@ -0,0 +1,62 @@ +[Protocol] +exec=kio_zeroconf +protocol=invitation + +input=none +output=filesystem +listing=Name,Link,Type +reading=true +writing=false +makedir=false +deleting=false +linking=false +moving=false +Icon=network_local +Description=SD invitations +Description[be]=Запрашэнні SD +Description[bg]=Покани SD +Description[bn]=এসডি আমন্ত্রণ +Description[bs]=SD pozivi +Description[ca]=Invitacions SD +Description[cs]=SD pozvánky +Description[da]=SD-invitationer +Description[de]=SD-Einladungen +Description[el]=Προσκλήσεις SD +Description[es]=Invitaciones SD +Description[et]=SD kutsed +Description[eu]=SD gonbidapenak +Description[fa]=دعوتهای SD +Description[fi]=SD-kutsut +Description[fr]=Invitations SD +Description[gl]=Invitacións SD +Description[hu]=SD meghívók +Description[is]=SD boð +Description[it]=Inviti SD +Description[ja]=SD 招待 +Description[ka]=SD მოწვევა +Description[kk]=SD шақырулар +Description[km]=លិខិតអញ្ជើញ SD +Description[lt]=SD pakvietimai +Description[nb]=SD invitasjoner +Description[nds]=SD-Inladen +Description[ne]=SD निमन्त्रणा +Description[nl]=SD-uitnodigingen +Description[nn]=SD-innbydingar +Description[pa]=SD ਸੱਦਾ +Description[pl]=Zaproszenia SD +Description[pt]=Convites de SD +Description[pt_BR]=solicitações SD +Description[ru]=Приглашения SD +Description[sk]=SD pozvánky +Description[sl]=Povabila SD +Description[sr]=SD позивнице +Description[sr@Latn]=SD pozivnice +Description[sv]=SD-inbjudningar +Description[tr]=SD davetleri +Description[uk]=Запрошення SD +Description[zh_CN]=SD 邀请 +Description[zh_HK]=SD 邀請 +Description[zh_TW]=SD 邀請 +maxInstances=4 +Class=:remote + diff --git a/tdednssd/ioslave/zeroconf.desktop b/tdednssd/ioslave/zeroconf.desktop new file mode 100644 index 00000000..abc41151 --- /dev/null +++ b/tdednssd/ioslave/zeroconf.desktop @@ -0,0 +1,56 @@ +[Desktop Entry] +Icon=network_local +Name=Network Services +Name[be]=Сеткавыя сервісы +Name[bg]=Мрежови услуги +Name[bn]=নেটওয়ার্ক সার্ভিস +Name[br]=Servijoù rouedad +Name[bs]=Mrežni servisi +Name[ca]=Serveis de xarxa +Name[cs]=Síťové služby +Name[da]=Netværkstjenester +Name[de]=Netzwerkdienste +Name[el]=Υπηρεσίες δικτύου +Name[eo]=Retservoj +Name[es]=Servicios de red +Name[et]=Võrguteenused +Name[eu]=Sare zerbitzuak +Name[fa]=خدمات شبکه +Name[fi]=Lähiverkkopalvelut +Name[fr]=Services réseaux +Name[ga]=Seirbhísí Líonra +Name[gl]=Servicios de Rede +Name[he]=שרותי רשת +Name[hu]=Hálózati szolgáltatások +Name[is]=Netþjónustur +Name[it]=Servizi di rete +Name[ja]=ネットワークサービス +Name[ka]=ქსელის სერვისები +Name[kk]=Желі қызметтері +Name[km]=សេវាបណ្ដាញ +Name[lt]=Tinklo tarnybos +Name[nb]=Nettverkstjenester +Name[nds]=Nettwarkdeensten +Name[ne]=सञ्जाल सेवा +Name[nl]=Netwerkdiensten +Name[nn]=Nettverkstenester +Name[pa]=ਨੈੱਟਵਰਕ ਸੇਵਾਵਾਂ +Name[pl]=Usługi sieciowe +Name[pt]=Serviços de Rede +Name[pt_BR]=Serviços de Rede +Name[ro]=Servicii de reţea +Name[ru]=Сетевые службы +Name[sk]=Sieťové služby +Name[sl]=Omrežne storitve +Name[sr]=Мрежни сервиси +Name[sr@Latn]=Mrežni servisi +Name[sv]=Nätverkstjänster +Name[tr]=Ağ Servisleri +Name[uk]=Мережеві служби +Name[uz]=Tarmoq xizmatlari +Name[uz@cyrillic]=Тармоқ хизматлари +Name[zh_CN]=网络服务 +Name[zh_HK]=網絡服務 +Name[zh_TW]=網路服務 +Type=Link +URL=zeroconf:/ diff --git a/tdednssd/ioslave/zeroconf.protocol b/tdednssd/ioslave/zeroconf.protocol new file mode 100644 index 00000000..5343b282 --- /dev/null +++ b/tdednssd/ioslave/zeroconf.protocol @@ -0,0 +1,63 @@ +[Protocol] +exec=kio_zeroconf +protocol=zeroconf + +input=none +output=filesystem +listing=Name,Link,Type +reading=true +writing=false +makedir=false +deleting=false +linking=false +moving=false +Icon=network_local +Description=A kioslave for ZeroConf +Description[be]=Модуль kioslave для ZeroConf +Description[bn]=জিরো-কন্ফ এর জন্য একটি কে-আই-ও স্লেভ +Description[br]=Ur c'hioslave evit ZeroConf +Description[bs]=kioslave za ZeroConf +Description[ca]=Un kioslave per ZeroConf +Description[cs]=Pomocný protokol pro Zeroconf +Description[da]=En kioslave for Zeroconf +Description[de]=Ein Ein-/Ausgabemodul für ZeroConf +Description[el]=Ένα kioslave για το ZeroConf +Description[es]=Un «kioslave» para ZeroConf +Description[et]=ZeroConfi I/O-moodul +Description[eu]= kioslave bat ZeroConf-erako +Description[fa]=یک kioslave برای ZeroConf +Description[fi]=Siirräntätyöskentelijä ZeroConfille +Description[fr]=Un module d'entrée / sortie pour ZeroConf +Description[gl]=Un kioslabe para ZeroConf +Description[he]=kioslave בשביל ZeroConf +Description[hu]=KDE-protokoll a Zeroconf használatához +Description[is]=kioslave fyrir ZeroConf +Description[it]=Un kioslave per Zeroconf +Description[ja]=ZeroConf の kioslave +Description[ka]= kioslave ZeroConfსთვის +Description[kk]=ZeroConf-тың kioslave-і +Description[km]=kioslave មួយសម្រាប់ ZeroConf +Description[lt]=Antrinė KDE programa skirta ZeroConf +Description[nb]=En kioslave for ZeroConf +Description[nds]=In-/Utgaavmoduul för ZeroConf +Description[ne]=जेरोकन्फका लागि कियोस्लाभ +Description[nl]=Een kioslave voor ZeroConf +Description[nn]=Ein kio-slave for ZeroConf +Description[pl]=Wtyczka protokołu ZeroConf +Description[pt]=Um 'kioslave' para o ZeroConf +Description[pt_BR]=Um IO-Slave para o ZeroConf +Description[ro]=Un dispozitiv de I/E pentru ZeroConf +Description[ru]=Kioslave для ZeroConf +Description[sk]=kioslave pre ZeroConf +Description[sl]=Kioslave za ZeroConf +Description[sr]=kioslave за ZeroConf +Description[sr@Latn]=kioslave za ZeroConf +Description[sv]=En I/O-slav för Zeroconf +Description[tr]=Zeroconf kioslave'i +Description[uk]=Kioslave для ZeroConf +Description[zh_CN]=ZeroConf 的 kioslave +Description[zh_HK]=用於 ZeroConf 的 kioslave +Description[zh_TW]=ZeroConf 的 kioslave +maxInstances=4 +Class=:local + diff --git a/tdednssd/kdedmodule/CMakeLists.txt b/tdednssd/kdedmodule/CMakeLists.txt new file mode 100644 index 00000000..06ad515c --- /dev/null +++ b/tdednssd/kdedmodule/CMakeLists.txt @@ -0,0 +1,34 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +install( FILES dnssdwatcher.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded ) + + +##### kded_dnssdwatcher (module) ################ + +tde_add_kpart( kded_dnssdwatcher AUTOMOC + SOURCES dnssdwatcher.cpp dnssdwatcher.skel watcher.cpp + LINK tdednssd-shared tdeinit_kded-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/tdednssd/kdedmodule/Makefile.am b/tdednssd/kdedmodule/Makefile.am new file mode 100644 index 00000000..c01297db --- /dev/null +++ b/tdednssd/kdedmodule/Makefile.am @@ -0,0 +1,13 @@ +kde_module_LTLIBRARIES = kded_dnssdwatcher.la + +METASOURCES = AUTO +INCLUDES = $(all_includes) + +kded_dnssdwatcher_la_SOURCES = dnssdwatcher.cpp dnssdwatcher.skel watcher.cpp +kded_dnssdwatcher_la_LDFLAGS = $(all_libraries) -module -avoid-version +kded_dnssdwatcher_la_LIBADD = $(LIB_KDNSSD) $(LIB_KIO) + + +servicesdir = $(kde_servicesdir)/kded +services_DATA = dnssdwatcher.desktop + diff --git a/tdednssd/kdedmodule/dnssdwatcher.cpp b/tdednssd/kdedmodule/dnssdwatcher.cpp new file mode 100644 index 00000000..5b391423 --- /dev/null +++ b/tdednssd/kdedmodule/dnssdwatcher.cpp @@ -0,0 +1,94 @@ +/* This file is part of the KDE Project + Copyright (c) 2004 Jakub Stachowski <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "dnssdwatcher.h" + +#include <kdebug.h> +#include <kglobal.h> +#include <klocale.h> +#include <dnssd/servicebrowser.h> +#include <kdirnotify_stub.h> +#include "watcher.h" + + +DNSSDWatcher::DNSSDWatcher(const TQCString& obj) + : KDEDModule(obj) +{ + connectDCOPSignal("","KDirNotify","enteredDirectory(KURL)","enteredDirectory(KURL)",false); + connectDCOPSignal("","KDirNotify","leftDirectory(KURL)","leftDirectory(KURL)",false); + watchers.setAutoDelete(true); +} + +TQStringList DNSSDWatcher::watchedDirectories() +{ +//TODO +// return watchers.keys(); + TQStringList keys; + for (TQDictIterator<Watcher> it(watchers) ; it.current(); ++it ) { + keys << it.currentKey(); + kdDebug() << it.currentKey() << " " << (*it)->refcount << "\n"; + } +return keys; +} + + +// from ioslave +void DNSSDWatcher::dissect(const KURL& url,TQString& name,TQString& type,TQString& domain) +{ + type = url.path().section("/",1,1); + domain = url.host(); + name = url.path().section("/",2,-1); +} + + + +void DNSSDWatcher::enteredDirectory(const KURL& dir) +{ + if (dir.protocol()!="zeroconf") return; + if (watchers[dir.url()]) watchers[dir.url()]->refcount++; + else createNotifier(dir); +} + + +void DNSSDWatcher::leftDirectory(const KURL& dir) +{ + if (dir.protocol()!="zeroconf") return; + if (!watchers[dir.url()]) return; + if ((watchers[dir.url()])->refcount==1) watchers.remove(dir.url()); + else watchers[dir.url()]->refcount--; +} + + +void DNSSDWatcher::createNotifier(const KURL& url) +{ + TQString domain,type,name; + dissect(url,name,type,domain); + if (type.isEmpty()) type = DNSSD::ServiceBrowser::AllServices; + Watcher *w = new Watcher(type,domain); + watchers.insert(url.url(),w); +} + +extern "C" { + KDE_EXPORT KDEDModule *create_dnssdwatcher(const TQCString &obj) + { + TDEGlobal::locale()->insertCatalogue("dnssdwatcher"); + return new DNSSDWatcher(obj); + } +} + +#include "dnssdwatcher.moc" diff --git a/tdednssd/kdedmodule/dnssdwatcher.desktop b/tdednssd/kdedmodule/dnssdwatcher.desktop new file mode 100644 index 00000000..af8d8a35 --- /dev/null +++ b/tdednssd/kdedmodule/dnssdwatcher.desktop @@ -0,0 +1,94 @@ +[Desktop Entry] +Type=Service +Name=DNS-SD Services Watcher +Name[be]=Аглядальнік сервісаў DNS-SD +Name[bn]=ডিএনএস-এসডি সার্ভিস পর্যবেক্ষক +Name[bs]=Nadzor DNS-SD servisa +Name[ca]=Vigilant de serveis DNS-SD +Name[cs]=Sledování DNS-SD služeb +Name[da]=DNS-SD overvågning af tjenester +Name[de]=Überwachung von DNS-SD-Diensten +Name[el]=Παρατηρητής υπηρεσιών DNS-SD +Name[es]=Observador de servicios DNS-SD +Name[et]=DNS-SD teenuste jälgija +Name[eu]=DNS-SD zerbitzu jarraitzailea +Name[fa]=پایندۀ خدمات DNS-SD +Name[fi]=DNS-SD-palvelujen tarkkailija +Name[fr]=Surveillance des services DNS-SD +Name[gl]=Observador de Servicios DNS-SD +Name[hu]=DNS-SD szolgáltatásfigyelő +Name[is]=DNS-SD þjónustuvaktari +Name[it]=Sentinella dei servizi DNS-SD +Name[ja]=DNS-SD サービス監視 +Name[ka]=DNS-SD სერვისების მეთვალყურე +Name[kk]=DNS-SD қызметтер бақылаушысы +Name[km]=កម្មវិធីឃ្លាំមើលសេវា DNS-SD +Name[lt]=DNS-SD tarnybos stebėjimas +Name[nb]=Overvåker for DNS-SD-tjenester +Name[nds]=DNS-SD-Deenstkieker +Name[ne]=DNS-SD सेवा दर्शक +Name[nl]=DNS-SD-diensten observatie +Name[nn]=DNS-SD-tenesteovervakar +Name[pa]=DNS-SD ਸੇਵਾਵਾਂ ਵਾਂਚਰ +Name[pl]=Nadzorca usług DNS-SD +Name[pt]=Vigia de Serviços DNS-SD +Name[pt_BR]=Monitor dos Serviços DNS-SD +Name[ru]=Служба DNS-SD +Name[sk]=Sledovač DNS-SD služieb +Name[sl]=Opazovalec storitev DNS-SD +Name[sr]=Пратилац DNS-SD сервиса +Name[sr@Latn]=Pratilac DNS-SD servisa +Name[sv]=DNS-SD tjänstbevakning +Name[tr]=DNS-SD Servisi İzleyicisi +Name[uk]=Спостереження за службами DNS-SD +Name[zh_CN]=DNS-SD 服务监视器 +Name[zh_HK]=DNS-SD 服務監察器 +Name[zh_TW]=DNS-SD 服務監看器 +Comment=Keeps track of DNS-SD services and updates directory listings +Comment[be]=Назірае за спісам сервісаў DNS-SD і абнаўляе выгляд дырэкторыяў +Comment[bn]=ডিএনএস-এসডি সার্ভিসের খোঁজ রাখে এবং ডিরেক্টরী তালিকা আপডেট করে +Comment[bs]=Prati DNS-SD servise i ažurira spiskove direktorija +Comment[ca]=Segueix els serveis DNS-SD i actualitza les llistes de directoris +Comment[cs]=Udržuje přehled o DNS-SD službách a aktualizuje výpisy adresářů +Comment[da]=Holder styr på DNS-SD-tjenester og opdaterer lister med mapper +Comment[de]=Überwacht DNS-SD-Dienste und aktualisiert Verzeichniseinträge +Comment[el]=Διατηρεί το ίχνος των υπηρεσιών του DNS-SD και ενημερώνει τις λίστες του καταλόγου +Comment[es]=Vigila los servicios DNS-SD y actualiza los listados de directorio +Comment[et]=Jälgib DNS-SD teenuseid ja uuendab kataloogide nimekirju +Comment[eu]=DNS-SD zerbitzuak jarraitu eta direktorio zerrendak eguneratzen ditu +Comment[fa]=رد خدمات DNS-SD را نگهداری میکند و فهرست برنامههای فهرست راهنما را بهروزرسانی میکند +Comment[fi]=Pitää kirjaa DNS-SD-palveluista ja päivittää kansiolistaukset +Comment[fr]=Conserve une trace des services DNS-SD et actualise les listes de dossiers +Comment[gl]=Deixa constancia dos servicios DNS-SD e anova as listaxes de directorios +Comment[hu]=Követi a DNS-SD szolgáltatások állapotát és frissíti a hálózati listákat +Comment[is]=Fylgist með DNS-SD þjónustum og uppfærir möppulista +Comment[it]=Mantiene traccia dei servizi DNS-SD e aggiorna le liste delle directory +Comment[ja]=DNS-SD サービスの管理とディレクトリ一覧の更新 +Comment[ka]=DNS-SD სერვისების ჩანაწერების შენახვა და დირექტორიის ჩამონათვლის განახლება +Comment[kk]=DNS-SD қызметтердің протоколын жүргізіп, каталогын жаңарту +Comment[km]=តាមដានសេវា DNS-SD និងធ្វើឲ្យការរាយថតទាន់សម័យ +Comment[lt]=Seka DNS-SD tarnybas ir atnaujina aplankų sąrašus +Comment[nb]=Holder øye med DNS-SD-tjenester og oppdaterer katalogoppføringer +Comment[nds]=Kiekt na DNS-SD-Deensten un frischt Orneroplisten op +Comment[ne]=DNS-SD सेवाको ट्रयाक राख्दछ र डाइरेक्टरी सूची अद्यावधिक गर्दछ +Comment[nl]=Houdt de DNS-SD-diensten bij en actualiseert mappenweergaven +Comment[nn]=Held auge med DNS-SD-tenester og oppdaterer katalogar +Comment[pl]=Śledzi usługi DNS-SD services i uaktualnia zawartość katalogu +Comment[pt]=Vigia os serviços DNS-SD e actualiza listas de pastas +Comment[pt_BR]=Monitora os serviços DNS-SD +Comment[ru]=Обновление каталогов DNS-SD +Comment[sk]=Sleduje DNS-SD služby a aktualizuje výpisy priečinku +Comment[sl]=Spremlja storitve DNS-SD in posodablja sezname imenikov +Comment[sr]=Надгледа DNS-SD сервисе и ажурира листинге директоријума +Comment[sr@Latn]=Nadgleda DNS-SD servise i ažurira listinge direktorijuma +Comment[sv]=Håller ordning på DNS-SD tjänster och uppdaterar kataloglistor +Comment[tr]=DNS-SD servisi ve klasör listesini güncelleyisi +Comment[uk]=Спостерігає за службами DNS-SD та оновлює списки каталогів +Comment[zh_CN]=跟踪 DNS-SD 服务并更新目录列表 +Comment[zh_HK]=監察 DNS-SD 服務並更新目錄清單 +Comment[zh_TW]=追蹤 DNS-SD 服務並更新目錄清單 +ServiceTypes=KDEDModule +X-TDE-ModuleType=Library +X-TDE-Library=dnssdwatcher +X-TDE-FactoryName=dnssdwatcher +X-TDE-Kded-autoload=true diff --git a/tdednssd/kdedmodule/dnssdwatcher.h b/tdednssd/kdedmodule/dnssdwatcher.h new file mode 100644 index 00000000..34ed1c47 --- /dev/null +++ b/tdednssd/kdedmodule/dnssdwatcher.h @@ -0,0 +1,50 @@ +/* This file is part of the KDE Project + Copyright (c) 2004 Jakub Stachowski <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _DNSSDWATCHER_H_ +#define _DNSSDWATCHER_H_ + +#include <tqdict.h> +#include <kdedmodule.h> +#include <tqstring.h> +#include <tqstringlist.h> +#include <kurl.h> + +class Watcher; +class DNSSDWatcher : public KDEDModule +{ +Q_OBJECT +// +K_DCOP +public: + DNSSDWatcher(const TQCString& obj); + +k_dcop: + TQStringList watchedDirectories(); + void enteredDirectory(const KURL& dir); + void leftDirectory(const KURL& dir); + +private: + TQDict<Watcher> watchers; + + void createNotifier(const KURL& url); + void dissect(const KURL& url,TQString& name,TQString& type,TQString& domain); + +}; + +#endif diff --git a/tdednssd/kdedmodule/watcher.cpp b/tdednssd/kdedmodule/watcher.cpp new file mode 100644 index 00000000..f6b7a973 --- /dev/null +++ b/tdednssd/kdedmodule/watcher.cpp @@ -0,0 +1,72 @@ +/* This file is part of the KDE Project + Copyright (c) 2004 Jakub Stachowski <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "watcher.h" + +#include <kdebug.h> + +#include <kdirnotify_stub.h> +#include <tqstringlist.h> + + + +Watcher::Watcher(const TQString& type, const TQString& domain) + : refcount(1), updateNeeded(false), m_type(type), m_domain(domain) +{ + if (domain.isEmpty()) browser = new ServiceBrowser(type); + else browser = new ServiceBrowser(type,domain); + connect(browser,TQT_SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr)), + TQT_SLOT(serviceAdded(DNSSD::RemoteService::Ptr))); + connect(browser,TQT_SIGNAL(serviceRemoved(DNSSD::RemoteService::Ptr)), + TQT_SLOT(serviceRemoved(DNSSD::RemoteService::Ptr))); + connect(browser,TQT_SIGNAL(finished()),TQT_SLOT(finished())); + browser->startBrowse(); +} + +Watcher::~Watcher() +{ + delete browser; +} + +void Watcher::serviceAdded(DNSSD::RemoteService::Ptr) +{ + updateNeeded=true; +} + +void Watcher::serviceRemoved(DNSSD::RemoteService::Ptr srv) +{ + if (!updateNeeded) removed << srv; +} + + +void Watcher::finished() +{ + KDirNotify_stub st("*","*"); + kdDebug() << "Finished for " << m_type << "@" << m_domain << "\n"; + if (updateNeeded || removed.count()) { + TQString url = "zeroconf:/"; + if (!m_domain.isEmpty()) url+="/"+m_domain+"/"; + if (m_type!=ServiceBrowser::AllServices) url+=m_type; + kdDebug() << "Sending update: " << url << "\n"; + st.FilesAdded(url); + } + removed.clear(); + updateNeeded=false; +} + +#include "watcher.moc" diff --git a/tdednssd/kdedmodule/watcher.h b/tdednssd/kdedmodule/watcher.h new file mode 100644 index 00000000..4d904d61 --- /dev/null +++ b/tdednssd/kdedmodule/watcher.h @@ -0,0 +1,51 @@ +/* This file is part of the KDE Project + Copyright (c) 2004 Jakub Stachowski <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _WATCHER_H_ +#define _WATCHER_H_ + +#include <tqstring.h> +#include <dnssd/servicebrowser.h> +#include <dnssd/remoteservice.h> + +using namespace DNSSD; + +class Watcher : public TQObject +{ +Q_OBJECT + +public: + Watcher(const TQString& type, const TQString& domain); + ~Watcher(); + + unsigned int refcount; +private: + ServiceBrowser* browser; + bool updateNeeded; + TQString m_type; + TQString m_domain; + TQValueList<DNSSD::RemoteService::Ptr> removed; + +private slots: + void serviceRemoved(DNSSD::RemoteService::Ptr srv); + void serviceAdded(DNSSD::RemoteService::Ptr); + void finished(); + +}; + +#endif |