summaryrefslogtreecommitdiffstats
path: root/kioslave/system/kdedmodule
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kioslave/system/kdedmodule
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kioslave/system/kdedmodule')
-rw-r--r--kioslave/system/kdedmodule/Makefile.am13
-rw-r--r--kioslave/system/kdedmodule/systemdirnotify.cpp184
-rw-r--r--kioslave/system/kdedmodule/systemdirnotify.desktop64
-rw-r--r--kioslave/system/kdedmodule/systemdirnotify.h47
-rw-r--r--kioslave/system/kdedmodule/systemdirnotifymodule.cpp37
-rw-r--r--kioslave/system/kdedmodule/systemdirnotifymodule.h36
6 files changed, 381 insertions, 0 deletions
diff --git a/kioslave/system/kdedmodule/Makefile.am b/kioslave/system/kdedmodule/Makefile.am
new file mode 100644
index 000000000..bc368f9b1
--- /dev/null
+++ b/kioslave/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/kioslave/system/kdedmodule/systemdirnotify.cpp b/kioslave/system/kdedmodule/systemdirnotify.cpp
new file mode 100644
index 000000000..e0ec57992
--- /dev/null
+++ b/kioslave/system/kdedmodule/systemdirnotify.cpp
@@ -0,0 +1,184 @@
+/* This file is part of the KDE Project
+ Copyright (c) 2004 Kvin 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 <qdir.h>
+
+SystemDirNotify::SystemDirNotify()
+: mInited( false )
+{
+}
+
+void SystemDirNotify::init()
+{
+ if( mInited )
+ return;
+ mInited = true;
+ KGlobal::dirs()->addResourceType("system_entries",
+ KStandardDirs::kde_default("data") + "systemview");
+
+ QStringList names_found;
+ QStringList dirList = KGlobal::dirs()->resourceDirs("system_entries");
+
+ QStringList::ConstIterator dirpath = dirList.begin();
+ QStringList::ConstIterator end = dirList.end();
+ for(; dirpath!=end; ++dirpath)
+ {
+ QDir dir = *dirpath;
+ if (!dir.exists()) continue;
+
+ QStringList filenames
+ = dir.entryList( QDir::Files | QDir::Readable );
+
+ QStringList::ConstIterator name = filenames.begin();
+ QStringList::ConstIterator endf = filenames.end();
+
+ for(; name!=endf; ++name)
+ {
+ if (!names_found.contains(*name))
+ {
+ KDesktopFile desktop(*dirpath+*name, true);
+
+ QString 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();
+ QMap<KURL,KURL>::const_iterator it = m_urlMap.begin();
+ QMap<KURL,KURL>::const_iterator end = m_urlMap.end();
+
+ for (; it!=end; ++it)
+ {
+ KURL base = it.key();
+
+ if ( base.isParentOf(url) )
+ {
+ QString 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/kioslave/system/kdedmodule/systemdirnotify.desktop b/kioslave/system/kdedmodule/systemdirnotify.desktop
new file mode 100644
index 000000000..315cb5bf8
--- /dev/null
+++ b/kioslave/system/kdedmodule/systemdirnotify.desktop
@@ -0,0 +1,64 @@
+[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 通知程式
+ServiceTypes=KDEDModule
+X-KDE-ModuleType=Library
+X-KDE-Library=systemdirnotify
+X-KDE-FactoryName=systemdirnotify
+X-KDE-Kded-load-on-demand=true
+X-KDE-Kded-autoload=true
diff --git a/kioslave/system/kdedmodule/systemdirnotify.h b/kioslave/system/kdedmodule/systemdirnotify.h
new file mode 100644
index 000000000..34da65b82
--- /dev/null
+++ b/kioslave/system/kdedmodule/systemdirnotify.h
@@ -0,0 +1,47 @@
+/* This file is part of the KDE Project
+ Copyright (c) 2004 Kvin 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 <qmap.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);
+
+ QMap<KURL,KURL> m_urlMap;
+ bool mInited;
+};
+
+#endif
diff --git a/kioslave/system/kdedmodule/systemdirnotifymodule.cpp b/kioslave/system/kdedmodule/systemdirnotifymodule.cpp
new file mode 100644
index 000000000..36c46fcd0
--- /dev/null
+++ b/kioslave/system/kdedmodule/systemdirnotifymodule.cpp
@@ -0,0 +1,37 @@
+/* This file is part of the KDE Project
+ Copyright (c) 2004 Kvin 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 QCString &obj)
+ : KDEDModule(obj)
+{
+}
+
+extern "C" {
+ KDE_EXPORT KDEDModule *create_systemdirnotify(const QCString &obj)
+ {
+ KGlobal::locale()->insertCatalogue("kio_system");
+ return new SystemDirNotifyModule(obj);
+ }
+}
+
diff --git a/kioslave/system/kdedmodule/systemdirnotifymodule.h b/kioslave/system/kdedmodule/systemdirnotifymodule.h
new file mode 100644
index 000000000..c75cd1a9e
--- /dev/null
+++ b/kioslave/system/kdedmodule/systemdirnotifymodule.h
@@ -0,0 +1,36 @@
+/* This file is part of the KDE Project
+ Copyright (c) 2004 Kvin 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 QCString &obj);
+private:
+ SystemDirNotify notifier;
+};
+
+#endif