summaryrefslogtreecommitdiffstats
path: root/tdeioslave/system/kdedmodule
diff options
context:
space:
mode:
Diffstat (limited to 'tdeioslave/system/kdedmodule')
-rw-r--r--tdeioslave/system/kdedmodule/CMakeLists.txt41
-rw-r--r--tdeioslave/system/kdedmodule/Makefile.am13
-rw-r--r--tdeioslave/system/kdedmodule/systemdirnotify.cpp187
-rw-r--r--tdeioslave/system/kdedmodule/systemdirnotify.desktop65
-rw-r--r--tdeioslave/system/kdedmodule/systemdirnotify.h47
-rw-r--r--tdeioslave/system/kdedmodule/systemdirnotifymodule.cpp37
-rw-r--r--tdeioslave/system/kdedmodule/systemdirnotifymodule.h36
7 files changed, 426 insertions, 0 deletions
diff --git a/tdeioslave/system/kdedmodule/CMakeLists.txt b/tdeioslave/system/kdedmodule/CMakeLists.txt
new file mode 100644
index 000000000..6df004620
--- /dev/null
+++ b/tdeioslave/system/kdedmodule/CMakeLists.txt
@@ -0,0 +1,41 @@
+#################################################
+#
+# (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 systemdirnotify.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded )
+
+
+##### kded_systemdirnotify (module) #############
+
+set( target kded_systemdirnotify )
+
+set( ${target}_SRCS
+ systemdirnotify.cpp systemdirnotify.skel
+ systemdirnotifymodule.cpp systemdirnotifymodule.skel
+)
+
+tde_add_kpart( ${target} AUTOMOC
+ SOURCES ${${target}_SRCS}
+ LINK tdeinit_kded-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tdeioslave/system/kdedmodule/Makefile.am b/tdeioslave/system/kdedmodule/Makefile.am
new file mode 100644
index 000000000..bc368f9b1
--- /dev/null
+++ b/tdeioslave/system/kdedmodule/Makefile.am
@@ -0,0 +1,13 @@
+kde_module_LTLIBRARIES = kded_systemdirnotify.la
+
+METASOURCES = AUTO
+INCLUDES = $(all_includes)
+
+kded_systemdirnotify_la_SOURCES = systemdirnotify.cpp systemdirnotify.skel systemdirnotifymodule.cpp systemdirnotifymodule.skel
+kded_systemdirnotify_la_LDFLAGS = $(all_libraries) -module -avoid-version
+kded_systemdirnotify_la_LIBADD = $(LIB_KSYCOCA)
+
+
+servicesdir = $(kde_servicesdir)/kded
+services_DATA = systemdirnotify.desktop
+
diff --git a/tdeioslave/system/kdedmodule/systemdirnotify.cpp b/tdeioslave/system/kdedmodule/systemdirnotify.cpp
new file mode 100644
index 000000000..3a6f029e6
--- /dev/null
+++ b/tdeioslave/system/kdedmodule/systemdirnotify.cpp
@@ -0,0 +1,187 @@
+/* This file is part of the KDE Project
+ Copyright (c) 2004 K�vin Ottens <ervin ipsquad net>
+
+ 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 "systemdirnotify.h"
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <kstandarddirs.h>
+#include <kdesktopfile.h>
+
+#include <kdirnotify_stub.h>
+
+#include <tqdir.h>
+
+SystemDirNotify::SystemDirNotify()
+: mInited( false )
+{
+}
+
+void SystemDirNotify::init()
+{
+ if( mInited )
+ // FIXME Work around a probable race condition by inserting printf delay before following
+ // code is executed -- the root cause of the race needs investigation and resolution.
+ printf("[systemdirnotify] SystemDirNotify::init(mInited)");
+ return;
+ mInited = true;
+ TDEGlobal::dirs()->addResourceType("system_entries",
+ KStandardDirs::kde_default("data") + "systemview");
+
+ TQStringList names_found;
+ TQStringList dirList = TDEGlobal::dirs()->resourceDirs("system_entries");
+
+ TQStringList::ConstIterator dirpath = dirList.begin();
+ TQStringList::ConstIterator end = dirList.end();
+ for(; dirpath!=end; ++dirpath)
+ {
+ TQDir dir = *dirpath;
+ if (!dir.exists()) continue;
+
+ TQStringList filenames
+ = dir.entryList( TQDir::Files | TQDir::Readable );
+
+ TQStringList::ConstIterator name = filenames.begin();
+ TQStringList::ConstIterator endf = filenames.end();
+
+ for(; name!=endf; ++name)
+ {
+ if (!names_found.contains(*name))
+ {
+ KDesktopFile desktop(*dirpath+*name, true);
+
+ TQString system_name = *name;
+ system_name.truncate(system_name.length()-8);
+
+ KURL system_url("system:/"+system_name);
+
+ if ( !desktop.readURL().isEmpty() )
+ {
+ m_urlMap[desktop.readURL()] = system_url;
+ names_found.append( *name );
+ }
+ else if ( !desktop.readPath().isEmpty() )
+ {
+ KURL url;
+ url.setPath( desktop.readPath() );
+ m_urlMap[url] = system_url;
+ names_found.append( *name );
+ }
+ }
+ }
+ }
+}
+
+KURL SystemDirNotify::toSystemURL(const KURL &url)
+{
+ kdDebug() << "SystemDirNotify::toSystemURL(" << url << ")" << endl;
+
+ init();
+ TQMap<KURL,KURL>::const_iterator it = m_urlMap.begin();
+ TQMap<KURL,KURL>::const_iterator end = m_urlMap.end();
+
+ for (; it!=end; ++it)
+ {
+ KURL base = it.key();
+
+ if ( base.isParentOf(url) )
+ {
+ TQString path = KURL::relativePath(base.path(),
+ url.path());
+ KURL result = it.data();
+ result.addPath(path);
+ result.cleanPath();
+ kdDebug() << result << endl;
+ return result;
+ }
+ }
+
+ kdDebug() << "KURL()" << endl;
+ return KURL();
+}
+
+KURL::List SystemDirNotify::toSystemURLList(const KURL::List &list)
+{
+ init();
+ KURL::List new_list;
+
+ KURL::List::const_iterator it = list.begin();
+ KURL::List::const_iterator end = list.end();
+
+ for (; it!=end; ++it)
+ {
+ KURL url = toSystemURL(*it);
+
+ if (url.isValid())
+ {
+ new_list.append(url);
+ }
+ }
+
+ return new_list;
+}
+
+ASYNC SystemDirNotify::FilesAdded(const KURL &directory)
+{
+ KURL new_dir = toSystemURL(directory);
+
+ if (new_dir.isValid())
+ {
+ KDirNotify_stub notifier("*", "*");
+ notifier.FilesAdded( new_dir );
+ if (new_dir.upURL().upURL()==KURL("system:/"))
+ {
+ notifier.FilesChanged( new_dir.upURL() );
+ }
+ }
+}
+
+ASYNC SystemDirNotify::FilesRemoved(const KURL::List &fileList)
+{
+ KURL::List new_list = toSystemURLList(fileList);
+
+ if (!new_list.isEmpty())
+ {
+ KDirNotify_stub notifier("*", "*");
+ notifier.FilesRemoved( new_list );
+
+ KURL::List::const_iterator it = new_list.begin();
+ KURL::List::const_iterator end = new_list.end();
+
+ for (; it!=end; ++it)
+ {
+ if ((*it).upURL().upURL()==KURL("system:/"))
+ {
+ notifier.FilesChanged( (*it).upURL() );
+ }
+ }
+ }
+}
+
+ASYNC SystemDirNotify::FilesChanged(const KURL::List &fileList)
+{
+ KURL::List new_list = toSystemURLList(fileList);
+
+ if (!new_list.isEmpty())
+ {
+ KDirNotify_stub notifier("*", "*");
+ notifier.FilesChanged( new_list );
+ }
+}
+
diff --git a/tdeioslave/system/kdedmodule/systemdirnotify.desktop b/tdeioslave/system/kdedmodule/systemdirnotify.desktop
new file mode 100644
index 000000000..31379df76
--- /dev/null
+++ b/tdeioslave/system/kdedmodule/systemdirnotify.desktop
@@ -0,0 +1,65 @@
+[Desktop Entry]
+Type=Service
+Name=KDED System Base URL Notifier
+Name[af]=KDED Stelse URL inkennissteller
+Name[be]=Праверка змены сістэмных файлаў KDED
+Name[bs]=KDED sistemsko obavještenje o baznom URLu
+Name[ca]=Notificador d'URL de base al sistema KDED
+Name[cs]=Démon upozorňování na systémová URL
+Name[csb]=Dôwanié wiédzë ù systemòwëch URL-ach dlô KDED
+Name[da]=KDED Systembais-url påmindelser
+Name[de]=Überwachung für Systemordner
+Name[el]=Ειδοποιητής KDED για URL του συστήματος
+Name[eo]=KDED Sistemo Bazo URL Atentigilo
+Name[es]=Notificador de URL de base sistema de KDED
+Name[et]=KDED süsteemsete URL-ide teadustaja
+Name[eu]=KDEren sistema oinarri URL iragarlea
+Name[fa]=اخطاردهندۀ نشانی وب پایۀ سیستم KDED
+Name[fi]=KDED:in järjestelmä-osoitteiden ilmoittaja
+Name[fr]=Notificateur d'URL système KDED
+Name[fy]=KDED systeem basis URL-adres melding
+Name[gl]=KDED Notificador de Base de URL Remota
+Name[hi]=केडीईडी तंत्र आधार यूआरएल नोटिफ़ॉयर
+Name[hr]=KDED sistemsko URL obavještavanje
+Name[hu]=Alapcím-értesítő
+Name[is]=KDED kerfis grunnslóðar tilkynnari
+Name[it]=Notifica KDED System Base URL
+Name[ja]=KDED システム ベース URL 通知
+Name[kk]=Жергілікті дискідегі өзгеріс туралы қулақтандыру
+Name[ko]=KDED 원격 기반 URL 알리미
+Name[lt]=KDED sistemos pagrindinio URL priminiklis
+Name[lv]=KDED sistēmas bāzes URL atgādinātājs
+Name[ms]=Pemberitahu URL Pangkalan Sistem KDED
+Name[nb]=KDED-Systembase URL-varsler
+Name[nds]=KDED-Narichten för Systeem-Basis-URLs
+Name[ne]=KDED प्रणाली आधारित यूआरएल सूचक
+Name[nl]=KDED systeem basis URL-adres notificatie
+Name[nn]=KDED-Systembase URL-varslar
+Name[pa]=KDE ਸਿਸਟਮ ਆਧਾਰ URL ਸੂਚਨਾ
+Name[pl]=Powiadamianie o systemowych URL-ach dla KDED
+Name[pt]=Notificador URLs de Base de Sistema do KDED
+Name[pt_BR]=Serviço de Notificação da URL da Base do Sistema
+Name[ro]=Notificare KDED pentru URL sistem de bază
+Name[ru]=Проверка изменения локальных файлов
+Name[rw]=Mumenyekanisha wa URL KDED Sisitemu Shingiro
+Name[sk]=KDED notifikátor systémovej URL
+Name[sl]=Obvestilnik KDED sistemskega osnovnega URL-ja
+Name[sr]=Обавештавач о системском базном URL-у, KDED
+Name[sr@Latn]=Obaveštavač o sistemskom baznom URL-u, KDED
+Name[sv]=KDED-meddelande om systembaswebbadresser
+Name[ta]=KDED அமைப்பு சார்ந்த வலைமனை குறிப்பான்
+Name[th]=ตัวแจ้งเตือนพื้นฐานของระบบ URL KDED
+Name[tr]=KDED Sistem Tabanlı URL Hatırlatıcı
+Name[tt]=Cirle URL Üzgärelü Beldergeçe
+Name[uk]=Сповіщувач про системну основну адресу (URL) для KDED
+Name[vi]=Trình thông báo URL hệ thống KDED
+Name[wa]=Notifiaedje KDED d' URL sistinme di båze
+Name[zh_CN]=KDED 系统基 URL 通知器
+Name[zh_TW]=KDED 系統基礎 URL 通知程式
+Comment=Provides change notification for folders monitored by the system:/ kio plugin
+ServiceTypes=KDEDModule
+X-TDE-ModuleType=Library
+X-TDE-Library=systemdirnotify
+X-TDE-FactoryName=systemdirnotify
+X-TDE-Kded-load-on-demand=true
+X-TDE-Kded-autoload=true
diff --git a/tdeioslave/system/kdedmodule/systemdirnotify.h b/tdeioslave/system/kdedmodule/systemdirnotify.h
new file mode 100644
index 000000000..b743ddb42
--- /dev/null
+++ b/tdeioslave/system/kdedmodule/systemdirnotify.h
@@ -0,0 +1,47 @@
+/* This file is part of the KDE Project
+ Copyright (c) 2004 K�vin Ottens <ervin ipsquad net>
+
+ 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 _SYSTEMDIRNOTIFY_H_
+#define _SYSTEMDIRNOTIFY_H_
+
+#include <kurl.h>
+#include <kdirnotify.h>
+#include <tqmap.h>
+
+class SystemDirNotify : public KDirNotify
+{
+K_DCOP
+
+public:
+ SystemDirNotify();
+
+k_dcop:
+ virtual ASYNC FilesAdded (const KURL &directory);
+ virtual ASYNC FilesRemoved (const KURL::List &fileList);
+ virtual ASYNC FilesChanged (const KURL::List &fileList);
+
+private:
+ void init();
+ KURL toSystemURL(const KURL &url);
+ KURL::List toSystemURLList(const KURL::List &list);
+
+ TQMap<KURL,KURL> m_urlMap;
+ bool mInited;
+};
+
+#endif
diff --git a/tdeioslave/system/kdedmodule/systemdirnotifymodule.cpp b/tdeioslave/system/kdedmodule/systemdirnotifymodule.cpp
new file mode 100644
index 000000000..64e8c8d62
--- /dev/null
+++ b/tdeioslave/system/kdedmodule/systemdirnotifymodule.cpp
@@ -0,0 +1,37 @@
+/* This file is part of the KDE Project
+ Copyright (c) 2004 K�vin Ottens <ervin ipsquad net>
+
+ 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 "systemdirnotifymodule.h"
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kglobal.h>
+
+SystemDirNotifyModule::SystemDirNotifyModule(const TQCString &obj)
+ : KDEDModule(obj)
+{
+}
+
+extern "C" {
+ KDE_EXPORT KDEDModule *create_systemdirnotify(const TQCString &obj)
+ {
+ TDEGlobal::locale()->insertCatalogue("kio_system");
+ return new SystemDirNotifyModule(obj);
+ }
+}
+
diff --git a/tdeioslave/system/kdedmodule/systemdirnotifymodule.h b/tdeioslave/system/kdedmodule/systemdirnotifymodule.h
new file mode 100644
index 000000000..e979ba098
--- /dev/null
+++ b/tdeioslave/system/kdedmodule/systemdirnotifymodule.h
@@ -0,0 +1,36 @@
+/* This file is part of the KDE Project
+ Copyright (c) 2004 K�vin Ottens <ervin ipsquad net>
+
+ 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 _SYSTEMDIRNOTIFYMODULE_H_
+#define _SYSTEMDIRNOTIFYMODULE_H_
+
+#include <kdedmodule.h>
+
+#include "systemdirnotify.h"
+
+class SystemDirNotifyModule : public KDEDModule
+{
+K_DCOP
+
+public:
+ SystemDirNotifyModule(const TQCString &obj);
+private:
+ SystemDirNotify notifier;
+};
+
+#endif