diff options
Diffstat (limited to 'kioslave/remote/kdedmodule')
-rw-r--r-- | kioslave/remote/kdedmodule/Makefile.am | 13 | ||||
-rw-r--r-- | kioslave/remote/kdedmodule/remotedirnotify.cpp | 143 | ||||
-rw-r--r-- | kioslave/remote/kdedmodule/remotedirnotify.desktop | 64 | ||||
-rw-r--r-- | kioslave/remote/kdedmodule/remotedirnotify.h | 43 | ||||
-rw-r--r-- | kioslave/remote/kdedmodule/remotedirnotifymodule.cpp | 37 | ||||
-rw-r--r-- | kioslave/remote/kdedmodule/remotedirnotifymodule.h | 36 |
6 files changed, 336 insertions, 0 deletions
diff --git a/kioslave/remote/kdedmodule/Makefile.am b/kioslave/remote/kdedmodule/Makefile.am new file mode 100644 index 000000000..61f4d2261 --- /dev/null +++ b/kioslave/remote/kdedmodule/Makefile.am @@ -0,0 +1,13 @@ +kde_module_LTLIBRARIES = kded_remotedirnotify.la + +METASOURCES = AUTO +INCLUDES = $(all_includes) + +kded_remotedirnotify_la_SOURCES = remotedirnotify.cpp remotedirnotify.skel remotedirnotifymodule.cpp remotedirnotifymodule.skel +kded_remotedirnotify_la_LDFLAGS = $(all_libraries) -module -avoid-version +kded_remotedirnotify_la_LIBADD = $(LIB_KSYCOCA) + + +servicesdir = $(kde_servicesdir)/kded +services_DATA = remotedirnotify.desktop + diff --git a/kioslave/remote/kdedmodule/remotedirnotify.cpp b/kioslave/remote/kdedmodule/remotedirnotify.cpp new file mode 100644 index 000000000..88933e29a --- /dev/null +++ b/kioslave/remote/kdedmodule/remotedirnotify.cpp @@ -0,0 +1,143 @@ +/* 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 "remotedirnotify.h" + +#include <kdebug.h> +#include <klocale.h> +#include <kglobal.h> +#include <kstandarddirs.h> +#include <kdesktopfile.h> + +#include <kdirnotify_stub.h> + +#include <qdir.h> + +RemoteDirNotify::RemoteDirNotify() +{ + KGlobal::dirs()->addResourceType("remote_entries", + KStandardDirs::kde_default("data") + "remoteview"); + + QString path = KGlobal::dirs()->saveLocation("remote_entries"); + m_baseURL.setPath(path); +} + +KURL RemoteDirNotify::toRemoteURL(const KURL &url) +{ + kdDebug(1220) << "RemoteDirNotify::toRemoteURL(" << url << ")" << endl; + if ( m_baseURL.isParentOf(url) ) + { + QString path = KURL::relativePath(m_baseURL.path(), + url.path()); + KURL result("remote:/"+path); + result.cleanPath(); + kdDebug(1220) << "result => " << result << endl; + return result; + } + + kdDebug(1220) << "result => KURL()" << endl; + return KURL(); +} + +KURL::List RemoteDirNotify::toRemoteURLList(const KURL::List &list) +{ + KURL::List new_list; + + KURL::List::const_iterator it = list.begin(); + KURL::List::const_iterator end = list.end(); + + for (; it!=end; ++it) + { + KURL url = toRemoteURL(*it); + + if (url.isValid()) + { + new_list.append(url); + } + } + + return new_list; +} + +ASYNC RemoteDirNotify::FilesAdded(const KURL &directory) +{ + kdDebug(1220) << "RemoteDirNotify::FilesAdded" << endl; + + KURL new_dir = toRemoteURL(directory); + + if (new_dir.isValid()) + { + KDirNotify_stub notifier("*", "*"); + notifier.FilesAdded( new_dir ); + } +} + +// This hack is required because of the way we manage .desktop files with +// Forwarding Slaves, their URL is out of the ioslave (most remote:/ files +// have a file:/ based UDS_URL so that they are executed correctly. +// Hence, FilesRemoved and FilesChanged does nothing... We're forced to use +// FilesAdded to re-list the modified directory. +inline void evil_hack(const KURL::List &list) +{ + KDirNotify_stub notifier("*", "*"); + + KURL::List notified; + + KURL::List::const_iterator it = list.begin(); + KURL::List::const_iterator end = list.end(); + + for (; it!=end; ++it) + { + KURL url = (*it).upURL(); + + if (!notified.contains(url)) + { + notifier.FilesAdded(url); + notified.append(url); + } + } +} + + +ASYNC RemoteDirNotify::FilesRemoved(const KURL::List &fileList) +{ + kdDebug(1220) << "RemoteDirNotify::FilesRemoved" << endl; + + KURL::List new_list = toRemoteURLList(fileList); + + if (!new_list.isEmpty()) + { + //KDirNotify_stub notifier("*", "*"); + //notifier.FilesRemoved( new_list ); + evil_hack(new_list); + } +} + +ASYNC RemoteDirNotify::FilesChanged(const KURL::List &fileList) +{ + kdDebug(1220) << "RemoteDirNotify::FilesChanged" << endl; + + KURL::List new_list = toRemoteURLList(fileList); + + if (!new_list.isEmpty()) + { + //KDirNotify_stub notifier("*", "*"); + //notifier.FilesChanged( new_list ); + evil_hack(new_list); + } +} diff --git a/kioslave/remote/kdedmodule/remotedirnotify.desktop b/kioslave/remote/kdedmodule/remotedirnotify.desktop new file mode 100644 index 000000000..cbae89366 --- /dev/null +++ b/kioslave/remote/kdedmodule/remotedirnotify.desktop @@ -0,0 +1,64 @@ +[Desktop Entry] +Type=Service +Name=KDED Remote Base URL Notifier +Name[af]=KDED afgeleë URL inkennissteller +Name[be]=Праверка зменаў аддаленых файлаў KDED +Name[bs]=KDED udaljeno obavještenje o baznom URLu +Name[ca]=Notificador d'URL de base remota KDED +Name[cs]=Démon upozorňování na vzdálená URL +Name[csb]=Dôwanié wiédzë ò daleczich URL-ach dlô KDED +Name[da]=KDED Ekstern basis-URL påmindelser +Name[de]=Überwachung für Dateien auf Fremdrechnern +Name[el]=Ειδοποιητής KDED για απομακρυσμένη URL +Name[eo]=KDED Fora Bazo URL Atentigilo +Name[es]=Notificador de URL remota KDED +Name[et]=KDED mujalasuva URL-i teadustaja +Name[eu]=KDED urruneko URL oinarriaren iragarlea +Name[fa]=اخطاردهندۀ نشانی وب پایه دور KDED +Name[fi]=KDED:in etäverkko-osoitteen ilmaisin +Name[fr]=Notificateur d'URL distante KDED +Name[fy]=KDED ekstern basis-URL-adres melding +Name[gl]=KDED Notificador de Base de URL Remota +Name[hi]=केडीईडी रिमोट आधारित यूआरएल नोटिफ़ायर +Name[hr]=KDED URL obavještavanje udaljene baze +Name[hu]=Távoli alapcím-értesítő +Name[is]=KDED fjarlægur grunnslóðartilkynnari +Name[it]=Notifica KDED Remote Base URL +Name[ja]=KDED リモート ベース URL 通知 +Name[kk]=Желідегі дискідегі өзгеріс туралы қулақтандыру +Name[ko]=KDED 원격 기반 URL 알리미 +Name[lt]=KDED nutolusio pagrindinio URL priminiklis +Name[lv]=KDED attālinātā URL bāzes atgādinātājs +Name[ms]=Pemberitahu URL Pangkalan Jauh KDED +Name[nb]=KDED-påminner for eksterne nettadresser +Name[nds]=KDED-Narichten för feern Basis-URLs +Name[ne]=KDED रिमोटमा आधारित यूआरएल सूचक +Name[nl]=KDED extern basis-URL-adres notificatie +Name[nn]=KDED-påminnar for eksterne nettadressar +Name[pa]=KDED ਰਿਮੋਟ ਅਧਾਰਿਤ URL ਸੂਚਨਾ +Name[pl]=Powiadamianie o zdalnych URL-ach dla KDED +Name[pt]=Notificador de URLs de Base Remotos do KDED +Name[pt_BR]=Serviço de Notificação da URL Remota +Name[ro]=Notificare KDED pentru URL distant de bază +Name[ru]=Проверка изменения сетевых файлов +Name[rw]=Mumenyekanisha wa URL KDED Yakure Shingiro +Name[sk]=KDED notifikátor vzdialenej URL +Name[sl]=Obvestilnik KDED oddaljenega osnovnega URL-ja +Name[sr]=Обавештавач о удаљеном базном URL-у, KDED +Name[sr@Latn]=Obaveštavač o udaljenom baznom URL-u, KDED +Name[sv]=KDED-meddelande om fjärrbaswebbadresser +Name[ta]=KDED தொலைதூரம் சார்ந்த வலைமனை குறிப்பான் +Name[th]=ตัวแจ้งเตือน Remote Base URL KDED +Name[tr]=KDED Uzak Tabanlı URL Hatırlatıcı +Name[tt]=Çittäge URL Üzgärelü Beldergeçe +Name[uk]=Сповіщувач про віддалену основну адресу (URL) для KDED +Name[vi]=Trình thông báo URL trên mạng KDED +Name[wa]=Notifiaedje KDED d' URL di båze å lon +Name[zh_CN]=KDED 远程基 URL 通知器 +Name[zh_TW]=KDED 遠端基礎 URL 通知程式 +ServiceTypes=KDEDModule +X-KDE-ModuleType=Library +X-KDE-Library=remotedirnotify +X-KDE-FactoryName=remotedirnotify +X-KDE-Kded-load-on-demand=true +X-KDE-Kded-autoload=true diff --git a/kioslave/remote/kdedmodule/remotedirnotify.h b/kioslave/remote/kdedmodule/remotedirnotify.h new file mode 100644 index 000000000..110d53a9d --- /dev/null +++ b/kioslave/remote/kdedmodule/remotedirnotify.h @@ -0,0 +1,43 @@ +/* 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 REMOTEDIRNOTIFY_H +#define REMOTEDIRNOTIFY_H + +#include <kurl.h> +#include <kdirnotify.h> + +class RemoteDirNotify : public KDirNotify +{ +K_DCOP + +public: + RemoteDirNotify(); + +k_dcop: + virtual ASYNC FilesAdded (const KURL &directory); + virtual ASYNC FilesRemoved (const KURL::List &fileList); + virtual ASYNC FilesChanged (const KURL::List &fileList); + +private: + KURL toRemoteURL(const KURL &url); + KURL::List toRemoteURLList(const KURL::List &list); + KURL m_baseURL; +}; + +#endif diff --git a/kioslave/remote/kdedmodule/remotedirnotifymodule.cpp b/kioslave/remote/kdedmodule/remotedirnotifymodule.cpp new file mode 100644 index 000000000..5877ac299 --- /dev/null +++ b/kioslave/remote/kdedmodule/remotedirnotifymodule.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 "remotedirnotifymodule.h" + +#include <kdebug.h> +#include <klocale.h> +#include <kglobal.h> + +RemoteDirNotifyModule::RemoteDirNotifyModule(const QCString &obj) + : KDEDModule(obj) +{ +} + +extern "C" { + KDE_EXPORT KDEDModule *create_remotedirnotify(const QCString &obj) + { + KGlobal::locale()->insertCatalogue("kio_remote"); + return new RemoteDirNotifyModule(obj); + } +} + diff --git a/kioslave/remote/kdedmodule/remotedirnotifymodule.h b/kioslave/remote/kdedmodule/remotedirnotifymodule.h new file mode 100644 index 000000000..4ce8c2c7d --- /dev/null +++ b/kioslave/remote/kdedmodule/remotedirnotifymodule.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 REMOTEDIRNOTIFYMODULE_H +#define REMOTEDIRNOTIFYMODULE_H + +#include <kdedmodule.h> + +#include "remotedirnotify.h" + +class RemoteDirNotifyModule : public KDEDModule +{ +K_DCOP + +public: + RemoteDirNotifyModule(const QCString &obj); +private: + RemoteDirNotify notifier; +}; + +#endif |