diff options
Diffstat (limited to 'tdeioslave/remote')
-rw-r--r-- | tdeioslave/remote/CMakeLists.txt | 50 | ||||
-rw-r--r-- | tdeioslave/remote/Makefile.am | 32 | ||||
-rw-r--r-- | tdeioslave/remote/dummy.cpp | 1 | ||||
-rw-r--r-- | tdeioslave/remote/kdedmodule/CMakeLists.txt | 41 | ||||
-rw-r--r-- | tdeioslave/remote/kdedmodule/Makefile.am | 13 | ||||
-rw-r--r-- | tdeioslave/remote/kdedmodule/remotedirnotify.cpp | 143 | ||||
-rw-r--r-- | tdeioslave/remote/kdedmodule/remotedirnotify.desktop | 117 | ||||
-rw-r--r-- | tdeioslave/remote/kdedmodule/remotedirnotify.h | 43 | ||||
-rw-r--r-- | tdeioslave/remote/kdedmodule/remotedirnotifymodule.cpp | 37 | ||||
-rw-r--r-- | tdeioslave/remote/kdedmodule/remotedirnotifymodule.h | 36 | ||||
-rw-r--r-- | tdeioslave/remote/kio_remote.cpp | 234 | ||||
-rw-r--r-- | tdeioslave/remote/kio_remote.h | 45 | ||||
-rw-r--r-- | tdeioslave/remote/remote.protocol | 17 | ||||
-rw-r--r-- | tdeioslave/remote/remoteimpl.cpp | 298 | ||||
-rw-r--r-- | tdeioslave/remote/remoteimpl.h | 54 | ||||
-rw-r--r-- | tdeioslave/remote/testremote.cpp | 69 | ||||
-rw-r--r-- | tdeioslave/remote/testremote.h | 34 |
17 files changed, 1264 insertions, 0 deletions
diff --git a/tdeioslave/remote/CMakeLists.txt b/tdeioslave/remote/CMakeLists.txt new file mode 100644 index 000000000..fe4c29154 --- /dev/null +++ b/tdeioslave/remote/CMakeLists.txt @@ -0,0 +1,50 @@ +################################################# +# +# (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( kdedmodule ) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +install( FILES remote.protocol DESTINATION ${SERVICES_INSTALL_DIR} ) + + +##### kioremote (static) ######################## + +set( target kioremote ) + +tde_add_library( ${target} STATIC_PIC AUTOMOC + SOURCES kio_remote.cpp remoteimpl.cpp +) + + +##### kio_remote (module) ####################### + +set( target kio_remote ) + +configure_file( ${CMAKE_SOURCE_DIR}/cmake/modules/template_dummy_cpp.cmake dummy.cpp COPYONLY ) + +tde_add_kpart( ${target} + SOURCES dummy.cpp + EMBED kioremote-static + LINK tdeio-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/tdeioslave/remote/Makefile.am b/tdeioslave/remote/Makefile.am new file mode 100644 index 000000000..4acb4e999 --- /dev/null +++ b/tdeioslave/remote/Makefile.am @@ -0,0 +1,32 @@ +SUBDIRS= . kdedmodule +# wizard + +INCLUDES = $(all_includes) +METASOURCES = AUTO + +kde_module_LTLIBRARIES = kio_remote.la + +kio_remote_la_SOURCES = dummy.cpp +kio_remote_la_LIBADD = libtdeioremote.la $(LIB_KIO) +kio_remote_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) -no-undefined + +dummy.cpp: + echo > dummy.cpp + +kde_services_DATA = remote.protocol + +noinst_LTLIBRARIES = libtdeioremote.la +libtdeioremote_la_SOURCES = kio_remote.cpp remoteimpl.cpp + +check_PROGRAMS = testremote +testremote_SOURCES = testremote.cpp +testremote_LDADD = libtdeioremote.la $(LIB_KIO) +testremote_LDFLAGS = $(all_libraries) + +## TODO in unsermake: TESTS = testremote +check: testremote + ./testremote + +messages: + $(XGETTEXT) `find . -name "*.cc" -o -name "*.cpp" -o -name "*.h"` -o $(podir)/tdeio_remote.pot + diff --git a/tdeioslave/remote/dummy.cpp b/tdeioslave/remote/dummy.cpp new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/tdeioslave/remote/dummy.cpp @@ -0,0 +1 @@ + diff --git a/tdeioslave/remote/kdedmodule/CMakeLists.txt b/tdeioslave/remote/kdedmodule/CMakeLists.txt new file mode 100644 index 000000000..2db56916c --- /dev/null +++ b/tdeioslave/remote/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 remotedirnotify.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded ) + + +##### kded_remotedirnotify (module) ############# + +set( target kded_remotedirnotify ) + +set( ${target}_SRCS + remotedirnotify.cpp remotedirnotify.skel + remotedirnotifymodule.cpp remotedirnotifymodule.skel +) + +tde_add_kpart( ${target} AUTOMOC + SOURCES ${${target}_SRCS} + LINK tdeinit_kded-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/tdeioslave/remote/kdedmodule/Makefile.am b/tdeioslave/remote/kdedmodule/Makefile.am new file mode 100644 index 000000000..61f4d2261 --- /dev/null +++ b/tdeioslave/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/tdeioslave/remote/kdedmodule/remotedirnotify.cpp b/tdeioslave/remote/kdedmodule/remotedirnotify.cpp new file mode 100644 index 000000000..fa880b78b --- /dev/null +++ b/tdeioslave/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 <tqdir.h> + +RemoteDirNotify::RemoteDirNotify() +{ + TDEGlobal::dirs()->addResourceType("remote_entries", + KStandardDirs::kde_default("data") + "remoteview"); + + TQString path = TDEGlobal::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) ) + { + TQString 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/tdeioslave/remote/kdedmodule/remotedirnotify.desktop b/tdeioslave/remote/kdedmodule/remotedirnotify.desktop new file mode 100644 index 000000000..24cc5e73f --- /dev/null +++ b/tdeioslave/remote/kdedmodule/remotedirnotify.desktop @@ -0,0 +1,117 @@ +[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 通知程式 +Comment=Provides change notification for network folders +Comment[ar]=يقدم إشعار عن التغيرات التي تحدث في مجلدات الشبكة +Comment[ca]=Proporciona notificacions de canvi en carpetes de xarxa +Comment[ca@valencia]=Proporciona notificacions de canvi en carpetes de xarxa +Comment[cs]=Poskytuje oznamování o změnách síťových složek +Comment[da]=Giver bekendtgørelse af ændringer af netværksmapper +Comment[de]=Benachrichtigt den Anwender über Änderungen an Dateien in Netzwerkordnern. +Comment[el]=Παρέχει ειδοποιήσεις για αλλαγές στους φακέλους δικτύου +Comment[en_GB]=Provides change notification for network folders +Comment[es]=Proporciona notificaciones visuales para carpetas de red +Comment[et]=Võrgukataloogide muutuste märguanded +Comment[eu]=Sareko karpeten aldaketa jakinarazpenak hornitzen ditu +Comment[fi]=Tarjoaa huomautuksia verkkokansioiden muutoksista +Comment[fr]=Fournit les notifications de modification pour les dossiers réseaux +Comment[fy]=Ferskaft feroaringsmelding foar netwurkmappen +Comment[ga]=Cuireann sé in iúl duit nuair a athraíonn fillteán líonra +Comment[he]=מספק שינוי התראות עבור תיקיות רשת +Comment[hr]=Omogućuje obavještavanje o promjenama na mrežnim mapama +Comment[ia]=Il forni notification de cambio pro dossieres de rete +Comment[id]=Menyediakan notifikasi pengubahan untuk folder jaringan +Comment[is]=Tilkynningaforrit fyrir breytingar á fjartengdum netmöppum +Comment[it]=Dà notifiche dei cambiamenti per le cartelle di rete +Comment[ja]=ネットワークフォルダの変更を通知 +Comment[kk]=Желідегі қапшықтар өзгерістері туралы құлақтандыру +Comment[km]=ផ្ដល់នូវការជូនដំណឹងផ្លាស់ប្ដូរសម្រាប់ថតបណ្ដាញ +Comment[kn]=ಜಾಲಭಂದ ಕಡತಕೋಶಗಳ ಬದಲಾವಣೆ ಸೂಚನೆಗಳನ್ನು ಒದಗಿಸುತ್ತದೆ. +Comment[ko]=네트워크 폴더의 변경 상황을 안내합니다 +Comment[lt]=Pranešimai vartotojui apie pasikeitimus tinklo aplankuose +Comment[lv]=Paziņo par izmaiņām tīkla mapēs +Comment[ml]=ശൃംഖലയിലുള്ള അറകളുടെ മാറ്റം അറിയിയ്ക്കുന്നു +Comment[nb]=Gir endringsvarslinger for nettverksmapper +Comment[nds]=Stellt Bescheden över Ännern vun Nettwarkornern praat +Comment[nl]=Levert notificatie voor wijzigingen in netwerkmappen +Comment[nn]=Gjev endringsvarsel for nettverksmapper +Comment[pa]=ਨੈੱਟਵਰਕ ਫੋਲਡਰਾਂ ਲਈ ਬਦਲਾਅ ਸੂਚਨਾ ਦਿੰਦਾ ਹੈ +Comment[pl]=Udostępnia powiadomienia o zmianach w katalogach sieciowych +Comment[pt]=Fornece notificações de alterações para as pastas de rede +Comment[pt_BR]=Fornece notificações de alterações para pastas de rede +Comment[ru]=Отслеживание изменений в сетевых папках +Comment[sk]=Poskytuje upozornenia o zmenách sieťových priečinkov +Comment[sl]=Ponuja obvestila o spremembah omrežnih map +Comment[sr]=Испоставља обавештења о изменама у мрежним фасциклама +Comment[sr@ijekavian]=Испоставља обавјештења о измјенама у мрежним фасциклама +Comment[sr@ijekavianlatin]=Ispostavlja obavještenja o izmjenama u mrežnim fasciklama +Comment[sr@latin]=Ispostavlja obaveštenja o izmenama u mrežnim fasciklama +Comment[sv]=Tillhandahåller ändringsunderrättelser för nätverkskataloger +Comment[tg]=Огоҳиҳои тағйиротро дар феҳрастҳои шабака нишон медиҳад +Comment[th]=ทำการแจ้งให้ทราบถึงความเปลี่ยนแปลงที่มีบนโฟลเดอร์บนเครือข่าย +Comment[tr]=Ağ dizinleri için değişim bildirimi sağlar. +Comment[uk]=Сповіщення про зміну стану мережевих тек +Comment[x-test]=xxProvides change notification for network foldersxx +Comment[zh_CN]=为网络文件夹提供更改通知 +Comment[zh_TW]=提供網路資料夾的變更通知 +ServiceTypes=KDEDModule +X-TDE-ModuleType=Library +X-TDE-Library=remotedirnotify +X-TDE-FactoryName=remotedirnotify +X-TDE-Kded-load-on-demand=true +X-TDE-Kded-autoload=true diff --git a/tdeioslave/remote/kdedmodule/remotedirnotify.h b/tdeioslave/remote/kdedmodule/remotedirnotify.h new file mode 100644 index 000000000..110d53a9d --- /dev/null +++ b/tdeioslave/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/tdeioslave/remote/kdedmodule/remotedirnotifymodule.cpp b/tdeioslave/remote/kdedmodule/remotedirnotifymodule.cpp new file mode 100644 index 000000000..13bfcfc29 --- /dev/null +++ b/tdeioslave/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 TQCString &obj) + : KDEDModule(obj) +{ +} + +extern "C" { + KDE_EXPORT KDEDModule *create_remotedirnotify(const TQCString &obj) + { + TDEGlobal::locale()->insertCatalogue("kio_remote"); + return new RemoteDirNotifyModule(obj); + } +} + diff --git a/tdeioslave/remote/kdedmodule/remotedirnotifymodule.h b/tdeioslave/remote/kdedmodule/remotedirnotifymodule.h new file mode 100644 index 000000000..e6cf0d720 --- /dev/null +++ b/tdeioslave/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 TQCString &obj); +private: + RemoteDirNotify notifier; +}; + +#endif diff --git a/tdeioslave/remote/kio_remote.cpp b/tdeioslave/remote/kio_remote.cpp new file mode 100644 index 000000000..87437700f --- /dev/null +++ b/tdeioslave/remote/kio_remote.cpp @@ -0,0 +1,234 @@ +/* This file is part of the KDE project + Copyright (c) 2004 Kevin 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 as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 <stdlib.h> + +#include <kdebug.h> +#include <klocale.h> +#include <kapplication.h> +#include <dcopclient.h> +#include <kcmdlineargs.h> +#include <kglobal.h> + + +#include "kio_remote.h" + +static const KCmdLineOptions options[] = +{ + { "+protocol", I18N_NOOP( "Protocol name" ), 0 }, + { "+pool", I18N_NOOP( "Socket name" ), 0 }, + { "+app", I18N_NOOP( "Socket name" ), 0 }, + KCmdLineLastOption +}; + +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_remote", 0, 0, 0, 0); + TDECmdLineArgs::addCmdLineOptions( options ); + TDEApplication app( false, false ); + // We want to be anonymous even if we use DCOP + app.dcopClient()->attach(); + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + RemoteProtocol slave( args->arg(0), args->arg(1), args->arg(2) ); + slave.dispatchLoop(); + return 0; + } +} + + +RemoteProtocol::RemoteProtocol(const TQCString &protocol, + const TQCString &pool, const TQCString &app) + : SlaveBase(protocol, pool, app) +{ +} + +RemoteProtocol::~RemoteProtocol() +{ +} + +void RemoteProtocol::listDir(const KURL &url) +{ + kdDebug(1220) << "RemoteProtocol::listDir: " << url << endl; + + if ( url.path().length() <= 1 ) + { + listRoot(); + return; + } + + int second_slash_idx = url.path().find( '/', 1 ); + TQString root_dirname = url.path().mid( 1, second_slash_idx-1 ); + + KURL target = m_impl.findBaseURL( root_dirname ); + kdDebug(1220) << "possible redirection target : " << target << endl; + if( target.isValid() ) + { + target.addPath( url.path().remove(0, second_slash_idx) ); + redirection(target); + finished(); + return; + } + + error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); +} + +void RemoteProtocol::listRoot() +{ + TDEIO::UDSEntry entry; + + TDEIO::UDSEntryList remote_entries; + m_impl.listRoot(remote_entries); + + totalSize(remote_entries.count()+2); + + m_impl.createTopLevelEntry(entry); + listEntry(entry, false); + + m_impl.createWizardEntry(entry); + listEntry(entry, false); + + TDEIO::UDSEntryListIterator it = remote_entries.begin(); + TDEIO::UDSEntryListIterator end = remote_entries.end(); + + for(; it!=end; ++it) + { + listEntry(*it, false); + } + + entry.clear(); + listEntry(entry, true); + + finished(); +} + +void RemoteProtocol::stat(const KURL &url) +{ + kdDebug(1220) << "RemoteProtocol::stat: " << url << endl; + + TQString path = url.path(); + if ( path.isEmpty() || path == "/" ) + { + // The root is "virtual" - it's not a single physical directory + TDEIO::UDSEntry entry; + m_impl.createTopLevelEntry( entry ); + statEntry( entry ); + finished(); + return; + } + + if (m_impl.isWizardURL(url)) + { + TDEIO::UDSEntry entry; + if (m_impl.createWizardEntry(entry)) + { + statEntry(entry); + finished(); + } + else + { + error(TDEIO::ERR_DOES_NOT_EXIST, url.prettyURL()); + } + return; + } + + int second_slash_idx = url.path().find( '/', 1 ); + TQString root_dirname = url.path().mid( 1, second_slash_idx-1 ); + + if ( second_slash_idx==-1 || ( (int)url.path().length() )==second_slash_idx+1 ) + { + TDEIO::UDSEntry entry; + if (m_impl.statNetworkFolder(entry, root_dirname)) + { + statEntry(entry); + finished(); + return; + } + } + else + { + KURL target = m_impl.findBaseURL( root_dirname ); + kdDebug( 1220 ) << "possible redirection target : " << target << endl; + if ( target.isValid() ) + { + target.addPath( url.path().remove( 0, second_slash_idx ) ); + redirection( target ); + finished(); + return; + } + } + + error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); +} + +void RemoteProtocol::del(const KURL &url, bool /*isFile*/) +{ + kdDebug(1220) << "RemoteProtocol::del: " << url << endl; + + if (!m_impl.isWizardURL(url) + && m_impl.deleteNetworkFolder(url.fileName())) + { + finished(); + return; + } + + error(TDEIO::ERR_CANNOT_DELETE, url.prettyURL()); +} + +void RemoteProtocol::get(const KURL &url) +{ + kdDebug(1220) << "RemoteProtocol::get: " << url << endl; + + TQString file = m_impl.findDesktopFile( url.fileName() ); + kdDebug(1220) << "desktop file : " << file << endl; + + if (!file.isEmpty()) + { + KURL desktop; + desktop.setPath(file); + + redirection(desktop); + finished(); + return; + } + + error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); +} + +void RemoteProtocol::rename(const KURL &src, const KURL &dest, + bool overwrite) +{ + if (src.protocol()!="remote" || dest.protocol()!="remote" + || m_impl.isWizardURL(src) || m_impl.isWizardURL(dest)) + { + error(TDEIO::ERR_UNSUPPORTED_ACTION, src.prettyURL()); + return; + } + + if (m_impl.renameFolders(src.fileName(), dest.fileName(), overwrite)) + { + finished(); + return; + } + + error(TDEIO::ERR_CANNOT_RENAME, src.prettyURL()); +} diff --git a/tdeioslave/remote/kio_remote.h b/tdeioslave/remote/kio_remote.h new file mode 100644 index 000000000..ebc6dd1ad --- /dev/null +++ b/tdeioslave/remote/kio_remote.h @@ -0,0 +1,45 @@ +/* This file is part of the KDE project + Copyright (c) 2004 Kevin 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 as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 KIO_REMOTE_H +#define KIO_REMOTE_H + +#include <tdeio/slavebase.h> +#include "remoteimpl.h" + +class RemoteProtocol : public TDEIO::SlaveBase +{ +public: + RemoteProtocol(const TQCString &protocol, const TQCString &pool, + const TQCString &app); + virtual ~RemoteProtocol(); + + virtual void listDir(const KURL &url); + virtual void stat(const KURL &url); + virtual void del(const KURL &url, bool isFile); + virtual void get(const KURL &url); + virtual void rename(const KURL &src, const KURL &dest, bool overwrite); + +private: + void listRoot(); + + RemoteImpl m_impl; +}; + +#endif diff --git a/tdeioslave/remote/remote.protocol b/tdeioslave/remote/remote.protocol new file mode 100644 index 000000000..69cc638aa --- /dev/null +++ b/tdeioslave/remote/remote.protocol @@ -0,0 +1,17 @@ +[Protocol] +exec=kio_remote +protocol=remote +input=none +output=filesystem +listing=Name,Type,Size,Date,AccessDate,Access,Owner,Group,Link +reading=true +writing=false +makedir=false +deleting=true +linking=true +moving=true +Icon=network +maxInstances=4 +#TODO DocPath=tdeioslave/file.html +Class=:local +deleteRecursive=true diff --git a/tdeioslave/remote/remoteimpl.cpp b/tdeioslave/remote/remoteimpl.cpp new file mode 100644 index 000000000..2ca263768 --- /dev/null +++ b/tdeioslave/remote/remoteimpl.cpp @@ -0,0 +1,298 @@ +/* This file is part of the KDE project + Copyright (c) 2004 Kevin 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 as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 "remoteimpl.h" + +#include <kdebug.h> +#include <kglobalsettings.h> +#include <kstandarddirs.h> +#include <kdesktopfile.h> +#include <kservice.h> +#include <klocale.h> + +#include <tqdir.h> +#include <tqfile.h> + +#include <sys/stat.h> + +#define WIZARD_URL "remote:/x-wizard_service.desktop" +#define WIZARD_SERVICE "knetattach" + +RemoteImpl::RemoteImpl() +{ + TDEGlobal::dirs()->addResourceType("remote_entries", + KStandardDirs::kde_default("data") + "remoteview"); + + TQString path = TDEGlobal::dirs()->saveLocation("remote_entries"); + + TQDir dir = path; + if (!dir.exists()) + { + dir.cdUp(); + dir.mkdir("remoteview"); + } +} + +void RemoteImpl::listRoot(TQValueList<TDEIO::UDSEntry> &list) const +{ + kdDebug(1220) << "RemoteImpl::listRoot" << endl; + + TQStringList names_found; + TQStringList dirList = TDEGlobal::dirs()->resourceDirs("remote_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 ); + + + TDEIO::UDSEntry entry; + + TQStringList::ConstIterator name = filenames.begin(); + TQStringList::ConstIterator endf = filenames.end(); + + for(; name!=endf; ++name) + { + if (!names_found.contains(*name)) + { + entry.clear(); + createEntry(entry, *dirpath, *name); + list.append(entry); + names_found.append(*name); + } + } + } +} + +bool RemoteImpl::findDirectory(const TQString &filename, TQString &directory) const +{ + kdDebug(1220) << "RemoteImpl::findDirectory" << endl; + + TQStringList dirList = TDEGlobal::dirs()->resourceDirs("remote_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 ); + + + TDEIO::UDSEntry entry; + + TQStringList::ConstIterator name = filenames.begin(); + TQStringList::ConstIterator endf = filenames.end(); + + for(; name!=endf; ++name) + { + if (*name==filename) + { + directory = *dirpath; + return true; + } + } + } + + return false; +} + +TQString RemoteImpl::findDesktopFile(const TQString &filename) const +{ + kdDebug(1220) << "RemoteImpl::findDesktopFile" << endl; + + TQString directory; + if (findDirectory(filename+".desktop", directory)) + { + return directory+filename+".desktop"; + } + + return TQString::null; +} + +KURL RemoteImpl::findBaseURL(const TQString &filename) const +{ + kdDebug(1220) << "RemoteImpl::findBaseURL" << endl; + + TQString file = findDesktopFile(filename); + if (!file.isEmpty()) + { + KDesktopFile desktop(file, true); + return desktop.readURL(); + } + + return KURL(); +} + + +static void addAtom(TDEIO::UDSEntry &entry, unsigned int ID, long l, + const TQString &s = TQString::null) +{ + TDEIO::UDSAtom atom; + atom.m_uds = ID; + atom.m_long = l; + atom.m_str = s; + entry.append(atom); +} + + +void RemoteImpl::createTopLevelEntry(TDEIO::UDSEntry &entry) const +{ + entry.clear(); + addAtom(entry, TDEIO::UDS_NAME, 0, "."); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_ACCESS, 0555); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "network"); +} + +static KURL findWizardRealURL() +{ + KURL url; + KService::Ptr service = KService::serviceByDesktopName(WIZARD_SERVICE); + + if (service && service->isValid()) + { + url.setPath( locate("apps", + service->desktopEntryPath()) + ); + } + + return url; +} + +bool RemoteImpl::createWizardEntry(TDEIO::UDSEntry &entry) const +{ + entry.clear(); + + KURL url = findWizardRealURL(); + + if (!url.isValid()) + { + return false; + } + + addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Add a Network Folder")); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); + addAtom(entry, TDEIO::UDS_URL, 0, WIZARD_URL); + addAtom(entry, TDEIO::UDS_LOCAL_PATH, 0, url.path()); + addAtom(entry, TDEIO::UDS_ACCESS, 0500); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "application/x-desktop"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "wizard"); + + return true; +} + +bool RemoteImpl::isWizardURL(const KURL &url) const +{ + return url==KURL(WIZARD_URL); +} + + +void RemoteImpl::createEntry(TDEIO::UDSEntry &entry, + const TQString &directory, + const TQString &file) const +{ + kdDebug(1220) << "RemoteImpl::createEntry" << endl; + + KDesktopFile desktop(directory+file, true); + + kdDebug(1220) << "path = " << directory << file << endl; + + entry.clear(); + + TQString new_filename = file; + new_filename.truncate( file.length()-8); + + addAtom(entry, TDEIO::UDS_NAME, 0, desktop.readName()); + addAtom(entry, TDEIO::UDS_URL, 0, "remote:/"+new_filename); + + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); + + TQString icon = desktop.readIcon(); + + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, icon); + addAtom(entry, TDEIO::UDS_LINK_DEST, 0, desktop.readURL()); +} + +bool RemoteImpl::statNetworkFolder(TDEIO::UDSEntry &entry, const TQString &filename) const +{ + kdDebug(1220) << "RemoteImpl::statNetworkFolder: " << filename << endl; + + TQString directory; + if (findDirectory(filename+".desktop", directory)) + { + createEntry(entry, directory, filename+".desktop"); + return true; + } + + return false; +} + +bool RemoteImpl::deleteNetworkFolder(const TQString &filename) const +{ + kdDebug(1220) << "RemoteImpl::deleteNetworkFolder: " << filename << endl; + + TQString directory; + if (findDirectory(filename+".desktop", directory)) + { + kdDebug(1220) << "Removing " << directory << filename << ".desktop" << endl; + return TQFile::remove(directory+filename+".desktop"); + } + + return false; +} + +bool RemoteImpl::renameFolders(const TQString &src, const TQString &dest, + bool overwrite) const +{ + kdDebug(1220) << "RemoteImpl::renameFolders: " + << src << ", " << dest << endl; + + TQString directory; + if (findDirectory(src+".desktop", directory)) + { + if (!overwrite && TQFile::exists(directory+dest+".desktop")) + { + return false; + } + + kdDebug(1220) << "Renaming " << directory << src << ".desktop"<< endl; + TQDir dir(directory); + bool res = dir.rename(src+".desktop", dest+".desktop"); + if (res) + { + KDesktopFile desktop(directory+dest+".desktop"); + desktop.writeEntry("Name", dest); + } + return res; + } + + return false; +} + + diff --git a/tdeioslave/remote/remoteimpl.h b/tdeioslave/remote/remoteimpl.h new file mode 100644 index 000000000..33aed3b0a --- /dev/null +++ b/tdeioslave/remote/remoteimpl.h @@ -0,0 +1,54 @@ +/* This file is part of the KDE project + Copyright (c) 2004 Kevin 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 as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 REMOTEIMPL_H +#define REMOTEIMPL_H + +#include <tdeio/global.h> +#include <tdeio/job.h> +#include <kurl.h> + +#include <tqstring.h> + +class RemoteImpl +{ +public: + RemoteImpl(); + + void createTopLevelEntry(TDEIO::UDSEntry &entry) const; + bool createWizardEntry(TDEIO::UDSEntry &entry) const; + bool isWizardURL(const KURL &url) const; + bool statNetworkFolder(TDEIO::UDSEntry &entry, const TQString &filename) const; + + void listRoot(TQValueList<TDEIO::UDSEntry> &list) const; + + KURL findBaseURL(const TQString &filename) const; + TQString findDesktopFile(const TQString &filename) const; + + bool deleteNetworkFolder(const TQString &filename) const; + bool renameFolders(const TQString &src, const TQString &dest, + bool overwrite) const; + +private: + bool findDirectory(const TQString &filename, TQString &directory) const; + void createEntry(TDEIO::UDSEntry& entry, const TQString &directory, + const TQString &file) const; +}; + +#endif diff --git a/tdeioslave/remote/testremote.cpp b/tdeioslave/remote/testremote.cpp new file mode 100644 index 000000000..d091c5bc4 --- /dev/null +++ b/tdeioslave/remote/testremote.cpp @@ -0,0 +1,69 @@ +/* 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 as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 "kio_remote.h" +#include "testremote.h" + +#include <config.h> + +#include <kapplication.h> +#include <kdebug.h> +#include <kcmdlineargs.h> + +#include <stdlib.h> + +static bool check(const TQString& txt, TQString a, TQString b) +{ + if (a.isEmpty()) + a = TQString::null; + if (b.isEmpty()) + b = TQString::null; + if (a == b) { + kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl; + } + else { + kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl; + exit(1); + } + return true; +} + +int main(int argc, char *argv[]) +{ + TDEApplication::disableAutoDcopRegistration(); + TDECmdLineArgs::init(argc,argv,"testremote", 0, 0, 0, 0); + TDEApplication app; + + TestRemote test; + test.setup(); + test.runAll(); + kdDebug() << "All tests OK." << endl; + return 0; // success. The exit(1) in check() is what happens in case of failure. +} + +void TestRemote::setup() +{ + +} + +void TestRemote::runAll() +{ + +} + diff --git a/tdeioslave/remote/testremote.h b/tdeioslave/remote/testremote.h new file mode 100644 index 000000000..ba51a8602 --- /dev/null +++ b/tdeioslave/remote/testremote.h @@ -0,0 +1,34 @@ +/* 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 as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 TESTREMOTE_H +#define TESTREMOTE_H + +class TestRemote +{ +public: + TestRemote() {} + void setup(); + void runAll(); + + // tests + +}; + +#endif |