summaryrefslogtreecommitdiffstats
path: root/tdednssd/kdedmodule
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2013-01-26 13:17:46 -0600
committerTimothy Pearson <[email protected]>2013-01-26 13:17:46 -0600
commit48087e1d5650499b6093a6816356d467c8461802 (patch)
tree00c39f978492596620df1374e8a91af507d8bac3 /tdednssd/kdedmodule
parentccfaeb9b831a41e93e777b041cdf33a7d40a0e0b (diff)
downloadtdenetwork-48087e1d5650499b6093a6816356d467c8461802.tar.gz
tdenetwork-48087e1d5650499b6093a6816356d467c8461802.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdednssd/kdedmodule')
-rw-r--r--tdednssd/kdedmodule/CMakeLists.txt34
-rw-r--r--tdednssd/kdedmodule/Makefile.am13
-rw-r--r--tdednssd/kdedmodule/dnssdwatcher.cpp94
-rw-r--r--tdednssd/kdedmodule/dnssdwatcher.desktop94
-rw-r--r--tdednssd/kdedmodule/dnssdwatcher.h50
-rw-r--r--tdednssd/kdedmodule/watcher.cpp72
-rw-r--r--tdednssd/kdedmodule/watcher.h51
7 files changed, 408 insertions, 0 deletions
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