From 472156a41b1348c714986c772759ad950fffbe75 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 27 Jan 2013 15:11:21 -0600 Subject: Rename kioslaves --- tdeioslave/media/CMakeLists.txt | 12 +- tdeioslave/media/Makefile.am | 10 +- tdeioslave/media/kio_media.cpp | 276 -------------------- tdeioslave/media/kio_media.h | 54 ---- tdeioslave/media/media.protocol | 2 +- tdeioslave/media/mediamanager/halbackend.cpp | 2 +- tdeioslave/media/mediamanager/mediamanager.cpp | 2 +- tdeioslave/media/mounthelper/CMakeLists.txt | 6 +- tdeioslave/media/mounthelper/Makefile.am | 8 +- .../media/mounthelper/kio_media_mounthelper.cpp | 282 --------------------- .../media/mounthelper/kio_media_mounthelper.h | 57 ----- .../media/mounthelper/tdeio_media_mounthelper.cpp | 282 +++++++++++++++++++++ .../media/mounthelper/tdeio_media_mounthelper.h | 57 +++++ tdeioslave/media/services/media_decrypt.desktop | 2 +- tdeioslave/media/services/media_eject.desktop | 2 +- tdeioslave/media/services/media_mount.desktop | 2 +- .../media/services/media_safelyremove.desktop | 2 +- tdeioslave/media/services/media_unmount.desktop | 2 +- tdeioslave/media/tdecmodule/main.cpp | 2 +- .../media/tdefile-plugin/tdefilemediaplugin.cpp | 2 +- tdeioslave/media/tdeio_media.cpp | 276 ++++++++++++++++++++ tdeioslave/media/tdeio_media.h | 54 ++++ tdeioslave/media/testmedia.cpp | 2 +- 23 files changed, 698 insertions(+), 698 deletions(-) delete mode 100644 tdeioslave/media/kio_media.cpp delete mode 100644 tdeioslave/media/kio_media.h delete mode 100644 tdeioslave/media/mounthelper/kio_media_mounthelper.cpp delete mode 100644 tdeioslave/media/mounthelper/kio_media_mounthelper.h create mode 100644 tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp create mode 100644 tdeioslave/media/mounthelper/tdeio_media_mounthelper.h create mode 100644 tdeioslave/media/tdeio_media.cpp create mode 100644 tdeioslave/media/tdeio_media.h (limited to 'tdeioslave/media') diff --git a/tdeioslave/media/CMakeLists.txt b/tdeioslave/media/CMakeLists.txt index 68d4bf9d6..0746d259c 100644 --- a/tdeioslave/media/CMakeLists.txt +++ b/tdeioslave/media/CMakeLists.txt @@ -38,22 +38,22 @@ link_directories( install( FILES media.protocol DESTINATION ${SERVICES_INSTALL_DIR} ) -##### kiomedia (static) ######################### +##### tdeiomedia (static) ######################### -set( target kiomedia ) +set( target tdeiomedia ) tde_add_library( ${target} STATIC_PIC AUTOMOC - SOURCES kio_media.cpp mediaimpl.cpp mediaimpl.skel + SOURCES tdeio_media.cpp mediaimpl.cpp mediaimpl.skel ) -##### kio_media (module) ######################## +##### tdeio_media (module) ######################## -set( target kio_media ) +set( target tdeio_media ) tde_add_kpart( ${target} AUTOMOC SOURCES dummy.cpp - EMBED kiomedia-static + EMBED tdeiomedia-static LINK mediacommon-static tdeio-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/tdeioslave/media/Makefile.am b/tdeioslave/media/Makefile.am index b82e48557..c827568a4 100644 --- a/tdeioslave/media/Makefile.am +++ b/tdeioslave/media/Makefile.am @@ -8,11 +8,11 @@ SUBDIRS = libmediacommon . mediamanager medianotifier mounthelper \ INCLUDES = -I$(srcdir)/libmediacommon $(all_includes) METASOURCES = AUTO -kde_module_LTLIBRARIES = kio_media.la +kde_module_LTLIBRARIES = tdeio_media.la -kio_media_la_SOURCES = dummy.cpp -kio_media_la_LIBADD = libtdeiomedia.la libmediacommon/libmediacommon.la $(LIB_KIO) -kio_media_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) -no-undefined +tdeio_media_la_SOURCES = dummy.cpp +tdeio_media_la_LIBADD = libtdeiomedia.la libmediacommon/libmediacommon.la $(LIB_KIO) +tdeio_media_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) -no-undefined dummy.cpp: echo > dummy.cpp @@ -20,7 +20,7 @@ dummy.cpp: kde_services_DATA = media.protocol noinst_LTLIBRARIES = libtdeiomedia.la -libtdeiomedia_la_SOURCES = kio_media.cpp mediaimpl.cpp mediaimpl.skel +libtdeiomedia_la_SOURCES = tdeio_media.cpp mediaimpl.cpp mediaimpl.skel check_PROGRAMS = testmedia testmedia_SOURCES = testmedia.cpp diff --git a/tdeioslave/media/kio_media.cpp b/tdeioslave/media/kio_media.cpp deleted file mode 100644 index d1647c6fc..000000000 --- a/tdeioslave/media/kio_media.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/* This file is part of the KDE project - Copyright (c) 2004 Kevin Ottens - - 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 - -#include -#include -#include -#include -#include - -#include - -#include "mediaimpl.h" -#include "kio_media.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_media", 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(); - MediaProtocol slave( args->arg(0), args->arg(1), args->arg(2) ); - slave.dispatchLoop(); - return 0; - } -} - - -MediaProtocol::MediaProtocol(const TQCString &protocol, - const TQCString &pool, const TQCString &app) - : ForwardingSlaveBase(protocol, pool, app) -{ - connect( &m_impl, TQT_SIGNAL( warning( const TQString & ) ), - this, TQT_SLOT( slotWarning( const TQString & ) ) ); -} - -MediaProtocol::~MediaProtocol() -{ -} - -bool MediaProtocol::rewriteURL(const KURL &url, KURL &newUrl) -{ - TQString name, path; - - if ( !m_impl.parseURL(url, name, path) ) - { - error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); - return false; - } - - - if ( !m_impl.realURL(name, path, newUrl) ) - { - error( m_impl.lastErrorCode(), m_impl.lastErrorMessage() ); - return false; - } - - return true; -} - -void MediaProtocol::put(const KURL &url, int permissions, - bool overwrite, bool resume) -{ - kdDebug(1219) << "MediaProtocol::put: " << url << endl; - - TQString name, path; - bool ok = m_impl.parseURL(url, name, path); - - if ( ok && path.isEmpty() ) - { - error(TDEIO::ERR_CANNOT_OPEN_FOR_WRITING, url.prettyURL()); - } - else - { - ForwardingSlaveBase::put(url, permissions, overwrite, resume); - } -} - -void MediaProtocol::rename(const KURL &src, const KURL &dest, bool overwrite) -{ - kdDebug(1219) << "MediaProtocol::rename: " << src << ", " << dest << ", " - << overwrite << endl; - - TQString src_name, src_path; - bool ok = m_impl.parseURL(src, src_name, src_path); - TQString dest_name, dest_path; - ok &= m_impl.parseURL(dest, dest_name, dest_path); - - if ( ok && src_path.isEmpty() && dest_path.isEmpty() - && src.protocol() == "media" && dest.protocol() == "media" ) - { - if (!m_impl.setUserLabel(src_name, dest_name)) - { - error(m_impl.lastErrorCode(), m_impl.lastErrorMessage()); - } - else - { - finished(); - } - } - else - { - ForwardingSlaveBase::rename(src, dest, overwrite); - } -} - -void MediaProtocol::mkdir(const KURL &url, int permissions) -{ - kdDebug(1219) << "MediaProtocol::mkdir: " << url << endl; - - TQString name, path; - bool ok = m_impl.parseURL(url, name, path); - - if ( ok && path.isEmpty() ) - { - error(TDEIO::ERR_COULD_NOT_MKDIR, url.prettyURL()); - } - else - { - ForwardingSlaveBase::mkdir(url, permissions); - } -} - -void MediaProtocol::del(const KURL &url, bool isFile) -{ - kdDebug(1219) << "MediaProtocol::del: " << url << endl; - - TQString name, path; - bool ok = m_impl.parseURL(url, name, path); - - if ( ok && path.isEmpty() ) - { - error(TDEIO::ERR_CANNOT_DELETE, url.prettyURL()); - } - else - { - ForwardingSlaveBase::del(url, isFile); - } -} - -void MediaProtocol::stat(const KURL &url) -{ - kdDebug(1219) << "MediaProtocol::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; - } - - TQString name; - bool ok = m_impl.parseURL(url, name, path); - - if ( !ok ) - { - error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); - return; - } - - if( path.isEmpty() ) - { - TDEIO::UDSEntry entry; - - if ( m_impl.statMedium(name, entry) - || m_impl.statMediumByLabel(name, entry) ) - { - statEntry(entry); - finished(); - } - else - { - error(TDEIO::ERR_DOES_NOT_EXIST, url.prettyURL()); - } - } - else - { - ForwardingSlaveBase::stat(url); - } -} - -void MediaProtocol::listDir(const KURL &url) -{ - kdDebug(1219) << "MediaProtocol::listDir: " << url << endl; - - if ( url.path().length() <= 1 ) - { - listRoot(); - return; - } - - TQString name, path; - bool ok = m_impl.parseURL(url, name, path); - - if ( !ok ) - { - error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); - return; - } - - ForwardingSlaveBase::listDir(url); -} - -void MediaProtocol::listRoot() -{ - TDEIO::UDSEntry entry; - - TDEIO::UDSEntryList media_entries; - bool ok = m_impl.listMedia(media_entries); - - if (!ok) - { - error( m_impl.lastErrorCode(), m_impl.lastErrorMessage() ); - return; - } - - totalSize(media_entries.count()+1); - - m_impl.createTopLevelEntry(entry); - listEntry(entry, false); - - TDEIO::UDSEntryListIterator it = media_entries.begin(); - TDEIO::UDSEntryListIterator end = media_entries.end(); - - for(; it!=end; ++it) - { - listEntry(*it, false); - } - - entry.clear(); - listEntry(entry, true); - - finished(); -} - -void MediaProtocol::slotWarning( const TQString &msg ) -{ - warning( msg ); -} - -#include "kio_media.moc" diff --git a/tdeioslave/media/kio_media.h b/tdeioslave/media/kio_media.h deleted file mode 100644 index bf1325475..000000000 --- a/tdeioslave/media/kio_media.h +++ /dev/null @@ -1,54 +0,0 @@ -/* This file is part of the KDE project - Copyright (c) 2004 Kevin Ottens - - 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_MEDIA_H_ -#define _KIO_MEDIA_H_ - -#include - -#include "mediaimpl.h" - -class MediaProtocol : public TDEIO::ForwardingSlaveBase -{ -Q_OBJECT -public: - MediaProtocol(const TQCString &protocol, const TQCString &pool, - const TQCString &app); - virtual ~MediaProtocol(); - - virtual bool rewriteURL(const KURL &url, KURL &newUrl); - - virtual void put(const KURL &url, int permissions, - bool overwrite, bool resume); - virtual void rename(const KURL &src, const KURL &dest, bool overwrite); - virtual void mkdir(const KURL &url, int permissions); - virtual void del(const KURL &url, bool isFile); - virtual void stat(const KURL &url); - virtual void listDir(const KURL &url); - -private slots: - void slotWarning( const TQString &msg ); - -private: - void listRoot(); - - MediaImpl m_impl; -}; - -#endif diff --git a/tdeioslave/media/media.protocol b/tdeioslave/media/media.protocol index f535e1a41..c390d6fca 100644 --- a/tdeioslave/media/media.protocol +++ b/tdeioslave/media/media.protocol @@ -1,5 +1,5 @@ [Protocol] -exec=kio_media +exec=tdeio_media protocol=media input=none output=filesystem diff --git a/tdeioslave/media/mediamanager/halbackend.cpp b/tdeioslave/media/mediamanager/halbackend.cpp index aba2b0175..1022b36be 100644 --- a/tdeioslave/media/mediamanager/halbackend.cpp +++ b/tdeioslave/media/mediamanager/halbackend.cpp @@ -377,7 +377,7 @@ void HALBackend::DeviceCondition(const char* udi, const char* condition) } if (medium) { TDEProcess p; - p << "kio_media_mounthelper" << "-e" << medium->name(); + p << "tdeio_media_mounthelper" << "-e" << medium->name(); p.start(TDEProcess::DontCare); } } diff --git a/tdeioslave/media/mediamanager/mediamanager.cpp b/tdeioslave/media/mediamanager/mediamanager.cpp index db2c12a71..511eb6c64 100644 --- a/tdeioslave/media/mediamanager/mediamanager.cpp +++ b/tdeioslave/media/mediamanager/mediamanager.cpp @@ -415,7 +415,7 @@ void MediaManager::slotMediumChanged(const TQString &/*id*/, const TQString &nam extern "C" { KDE_EXPORT KDEDModule *create_mediamanager(const TQCString &obj) { - TDEGlobal::locale()->insertCatalogue("kio_media"); + TDEGlobal::locale()->insertCatalogue("tdeio_media"); return new MediaManager(obj); } } diff --git a/tdeioslave/media/mounthelper/CMakeLists.txt b/tdeioslave/media/mounthelper/CMakeLists.txt index ea06278a8..766fe3def 100644 --- a/tdeioslave/media/mounthelper/CMakeLists.txt +++ b/tdeioslave/media/mounthelper/CMakeLists.txt @@ -21,12 +21,12 @@ link_directories( ) -##### kio_media_mounthelper (executable) ######## +##### tdeio_media_mounthelper (executable) ######## -set( target kio_media_mounthelper ) +set( target tdeio_media_mounthelper ) set( ${target}_SRCS - kio_media_mounthelper.cpp decryptdialog.ui dialog.cpp + tdeio_media_mounthelper.cpp decryptdialog.ui dialog.cpp ) tde_add_executable( ${target} AUTOMOC diff --git a/tdeioslave/media/mounthelper/Makefile.am b/tdeioslave/media/mounthelper/Makefile.am index 934559d40..c1e056c18 100644 --- a/tdeioslave/media/mounthelper/Makefile.am +++ b/tdeioslave/media/mounthelper/Makefile.am @@ -1,12 +1,12 @@ -bin_PROGRAMS = kio_media_mounthelper +bin_PROGRAMS = tdeio_media_mounthelper INCLUDES = -I$(srcdir)/../libmediacommon $(all_includes) AM_LDFLAGS = $(all_libraries) -kio_media_mounthelper_SOURCES = kio_media_mounthelper.cpp decryptdialog.ui dialog.cpp +tdeio_media_mounthelper_SOURCES = tdeio_media_mounthelper.cpp decryptdialog.ui dialog.cpp -kio_media_mounthelper_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -kio_media_mounthelper_LDADD = ../libmediacommon/libmediacommon.la $(LIB_KIO) $(LIB_TDEUI) +tdeio_media_mounthelper_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +tdeio_media_mounthelper_LDADD = ../libmediacommon/libmediacommon.la $(LIB_KIO) $(LIB_TDEUI) METASOURCES = AUTO diff --git a/tdeioslave/media/mounthelper/kio_media_mounthelper.cpp b/tdeioslave/media/mounthelper/kio_media_mounthelper.cpp deleted file mode 100644 index f321293d6..000000000 --- a/tdeioslave/media/mounthelper/kio_media_mounthelper.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/* This file is part of the KDE project - Copyright (c) 2004 Kévin Ottens - Parts of this file are - Copyright 2003 Waldo Bastian - - 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dialog.h" -#include "kio_media_mounthelper.h" - -const Medium MountHelper::findMedium(const KURL &url) -{ - DCOPRef mediamanager("kded", "mediamanager"); - - // Try filename first - DCOPReply reply = mediamanager.call( "properties", url.fileName() ); - if ( !reply.isValid() ) { - m_errorStr = i18n("The TDE mediamanager is not running.")+"\n"; - return Medium(TQString::null, TQString::null, TQString::null); - } - const Medium& medium = Medium::create(reply); - if ( medium.id().isEmpty() ) { - // Try full URL now - reply = mediamanager.call( "properties", url.prettyURL() ); - if ( !reply.isValid() ) { - m_errorStr = i18n("Internal Error"); - return Medium(TQString::null, TQString::null, TQString::null); - } - return Medium::create(reply); - } else { - return medium; - } -} - -MountHelper::MountHelper() : TDEApplication() -{ - TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); - - m_errorStr = TQString::null; - - KURL url(args->url(0)); - const Medium medium = findMedium(url); - - if ( medium.id().isEmpty() ) - { - if (m_errorStr.isEmpty()) - m_errorStr+= i18n("%1 cannot be found.").arg(url.prettyURL()); - TQTimer::singleShot(0, this, TQT_SLOT(error()) ); - return; - } - - if ( !medium.isMountable() && !args->isSet("e") && !args->isSet("s")) - { - m_errorStr = i18n("%1 is not a mountable media.").arg(url.prettyURL()); - TQTimer::singleShot(0, this, TQT_SLOT(error()) ); - return; - } - - TQString device = medium.deviceNode(); - TQString mount_point = medium.mountPoint(); - - m_isCdrom = medium.mimeType().find("dvd")!=-1 - || medium.mimeType().find("cd")!=-1; - - if (args->isSet("d")) - { - if (!medium.isEncrypted()) - { - m_errorStr = i18n("%1 is not an encrypted media.").arg(url.prettyURL()); - TQTimer::singleShot(0, this, TQT_SLOT(error()) ); - return; - } - if (!medium.needDecryption()) - { - m_errorStr = i18n("%1 is already decrypted.").arg(url.prettyURL()); - TQTimer::singleShot(0, this, TQT_SLOT(error()) ); - return; - } - - TQString iconName = medium.iconName(); - if (iconName.isEmpty()) - { - TQString mime = medium.mimeType(); - iconName = KMimeType::mimeType(mime)->icon(mime, false); - } - - m_mediumId = medium.id(); - dialog = new Dialog(url.prettyURL(), iconName); - dialog->show(); - - connect(dialog, TQT_SIGNAL (user1Clicked()), this, TQT_SLOT (slotSendPassword())); - connect(dialog, TQT_SIGNAL (cancelClicked()), this, TQT_SLOT (slotCancel())); - connect(this, TQT_SIGNAL (signalPasswordError(TQString)), dialog, TQT_SLOT (slotDialogError(TQString))); - } - else if (args->isSet("u")) - { - DCOPRef mediamanager("kded", "mediamanager"); - DCOPReply reply = mediamanager.call( "unmount", medium.id()); - if (reply.isValid()) - reply.get(m_errorStr); - kdDebug() << "medium unmount " << m_errorStr << endl; - if (m_errorStr.isNull()) - ::exit(0); - else - error(); - } - else if (args->isSet("s") || args->isSet("e")) - { - DCOPRef mediamanager("kded", "mediamanager"); - - /* - * We want to call mediamanager unmount before invoking eject. That's - * because unmount would provide an informative error message in case of - * failure. However, there are cases when unmount would fail - * (supermount, slackware, see bug#116209) but eject would succeed. - * Thus if unmount fails, save unmount error message and invokeEject() - * anyway. Only if both unmount and eject fail, notify the user by - * displaying the saved error message (see ejectFinished()). - */ - if (medium.isMounted()) - { - DCOPReply reply = mediamanager.call( "unmount", medium.id()); - if (reply.isValid()) - reply.get(m_errorStr); - } - - /* If this is a decrypted volume and there is no error yet - * we try to teardown the decryption */ - if (m_errorStr.isNull() && medium.isEncrypted() && !medium.clearDeviceUdi().isNull()) - { - DCOPReply reply = mediamanager.call( "undecrypt", medium.id()); - if (reply.isValid()) - reply.get(m_errorStr); - } - - if (m_errorStr.isNull()) - invokeEject(device, true); - else - error(); - } - else - { - DCOPRef mediamanager("kded", "mediamanager"); - DCOPReply reply = mediamanager.call( "mount", medium.id()); - if (reply.isValid()) - reply.get(m_errorStr); - if (m_errorStr.isNull()) - ::exit(0); - else - error(); - } -} - -void MountHelper::invokeEject(const TQString &device, bool quiet) -{ - TDEProcess *proc = new TDEProcess(TQT_TQOBJECT(this)); - *proc << "kdeeject"; - if (quiet) - { - *proc << "-q"; - } - *proc << device; - connect( proc, TQT_SIGNAL(processExited(TDEProcess *)), - this, TQT_SLOT( ejectFinished(TDEProcess *) ) ); - proc->start(); -} - -void MountHelper::ejectFinished(TDEProcess* proc) -{ - /* - * If eject failed, report the error stored in m_errorStr - */ - if (proc->normalExit() && proc->exitStatus() == 0) { - ::exit(0); - } else { - if (m_errorStr.isEmpty()) { - if (m_isCdrom) - m_errorStr = i18n("The device was successfully unmounted, but the tray could not be opened"); - else - m_errorStr = i18n("The device was successfully unmounted, but could not be ejected"); - } -//X Comment this because the error is useless as long as the unmount is successful. -//X TQTimer::singleShot(0, this, TQT_SLOT(error())); - ::exit(0); - } -} - -void MountHelper::error() -{ - TQString prettyErrorString = m_errorStr; - if (m_errorStr.contains("<") && m_errorStr.contains(">")) { - if (!m_errorStr.contains("")) { - prettyErrorString = TQString("%1").arg(m_errorStr); - } - } - KMessageBox::error(0, prettyErrorString); - ::exit(1); -} - -void MountHelper::slotSendPassword() -{ - DCOPRef mediamanager("kded", "mediamanager"); - - DCOPReply reply = mediamanager.call( "decrypt", m_mediumId, dialog->getPassword() ); - if (!reply.isValid()) { - m_errorStr = i18n("The TDE mediamanager is not running."); - error(); - } else { - TQString errorMsg = reply; - if (errorMsg.isNull()) { - exit(0); - } else { - emit signalPasswordError(errorMsg); - } - } -} - -void MountHelper::slotCancel() -{ - exit(0); -} - -static KCmdLineOptions options[] = -{ - { "d", I18N_NOOP("Decrypt given URL"), 0 }, - { "u", I18N_NOOP("Unmount given URL"), 0 }, - { "m", I18N_NOOP("Mount given URL (default)"), 0 }, - { "e", I18N_NOOP("Eject given URL via kdeeject"), 0}, - { "s", I18N_NOOP("Unmount and Eject given URL (necessary for some USB devices)"), 0}, - {"!+URL", I18N_NOOP("media:/ URL to mount/unmount/eject/remove"), 0 }, - KCmdLineLastOption -}; - - -int main(int argc, char **argv) -{ - TDECmdLineArgs::init(argc, argv, "kio_media_mounthelper", - "kio_media_mounthelper", "kio_media_mounthelper", - "0.1"); - - TDECmdLineArgs::addCmdLineOptions( options ); - TDEGlobal::locale()->setMainCatalogue("kio_media"); - TDEApplication::addCmdLineOptions(); - - if (TDECmdLineArgs::parsedArgs()->count()==0) TDECmdLineArgs::usage(); - TDEApplication *app = new MountHelper(); - - KStartupInfo::appStarted(); - app->dcopClient()->attach(); - return app->exec(); -} - -#include "kio_media_mounthelper.moc" diff --git a/tdeioslave/media/mounthelper/kio_media_mounthelper.h b/tdeioslave/media/mounthelper/kio_media_mounthelper.h deleted file mode 100644 index 50ea88b3b..000000000 --- a/tdeioslave/media/mounthelper/kio_media_mounthelper.h +++ /dev/null @@ -1,57 +0,0 @@ -/* This file is part of the KDE project - Copyright (c) 2004 Kvin Ottens - Parts of this file are - Copyright 2003 Waldo Bastian - - 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_MEDIA_MOUNTHELPER_H_ -#define _KIO_MEDIA_MOUNTHELPER_H_ - -#include -#include -#include - -#include "medium.h" - -class Dialog; - -class MountHelper : public TDEApplication -{ - Q_OBJECT -public: - MountHelper(); - -private: - const Medium findMedium(const KURL &url); - void invokeEject(const TQString &device, bool quiet=false); - TQString m_errorStr; - bool m_isCdrom; - TQString m_mediumId; - Dialog *dialog; - -private slots: - void slotSendPassword(); - void slotCancel(); - void ejectFinished(TDEProcess* proc); - void error(); - -signals: - void signalPasswordError(TQString errorMsg); -}; - -#endif diff --git a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp new file mode 100644 index 000000000..038a4de57 --- /dev/null +++ b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp @@ -0,0 +1,282 @@ +/* This file is part of the KDE project + Copyright (c) 2004 Kévin Ottens + Parts of this file are + Copyright 2003 Waldo Bastian + + 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dialog.h" +#include "tdeio_media_mounthelper.h" + +const Medium MountHelper::findMedium(const KURL &url) +{ + DCOPRef mediamanager("kded", "mediamanager"); + + // Try filename first + DCOPReply reply = mediamanager.call( "properties", url.fileName() ); + if ( !reply.isValid() ) { + m_errorStr = i18n("The TDE mediamanager is not running.")+"\n"; + return Medium(TQString::null, TQString::null, TQString::null); + } + const Medium& medium = Medium::create(reply); + if ( medium.id().isEmpty() ) { + // Try full URL now + reply = mediamanager.call( "properties", url.prettyURL() ); + if ( !reply.isValid() ) { + m_errorStr = i18n("Internal Error"); + return Medium(TQString::null, TQString::null, TQString::null); + } + return Medium::create(reply); + } else { + return medium; + } +} + +MountHelper::MountHelper() : TDEApplication() +{ + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + + m_errorStr = TQString::null; + + KURL url(args->url(0)); + const Medium medium = findMedium(url); + + if ( medium.id().isEmpty() ) + { + if (m_errorStr.isEmpty()) + m_errorStr+= i18n("%1 cannot be found.").arg(url.prettyURL()); + TQTimer::singleShot(0, this, TQT_SLOT(error()) ); + return; + } + + if ( !medium.isMountable() && !args->isSet("e") && !args->isSet("s")) + { + m_errorStr = i18n("%1 is not a mountable media.").arg(url.prettyURL()); + TQTimer::singleShot(0, this, TQT_SLOT(error()) ); + return; + } + + TQString device = medium.deviceNode(); + TQString mount_point = medium.mountPoint(); + + m_isCdrom = medium.mimeType().find("dvd")!=-1 + || medium.mimeType().find("cd")!=-1; + + if (args->isSet("d")) + { + if (!medium.isEncrypted()) + { + m_errorStr = i18n("%1 is not an encrypted media.").arg(url.prettyURL()); + TQTimer::singleShot(0, this, TQT_SLOT(error()) ); + return; + } + if (!medium.needDecryption()) + { + m_errorStr = i18n("%1 is already decrypted.").arg(url.prettyURL()); + TQTimer::singleShot(0, this, TQT_SLOT(error()) ); + return; + } + + TQString iconName = medium.iconName(); + if (iconName.isEmpty()) + { + TQString mime = medium.mimeType(); + iconName = KMimeType::mimeType(mime)->icon(mime, false); + } + + m_mediumId = medium.id(); + dialog = new Dialog(url.prettyURL(), iconName); + dialog->show(); + + connect(dialog, TQT_SIGNAL (user1Clicked()), this, TQT_SLOT (slotSendPassword())); + connect(dialog, TQT_SIGNAL (cancelClicked()), this, TQT_SLOT (slotCancel())); + connect(this, TQT_SIGNAL (signalPasswordError(TQString)), dialog, TQT_SLOT (slotDialogError(TQString))); + } + else if (args->isSet("u")) + { + DCOPRef mediamanager("kded", "mediamanager"); + DCOPReply reply = mediamanager.call( "unmount", medium.id()); + if (reply.isValid()) + reply.get(m_errorStr); + kdDebug() << "medium unmount " << m_errorStr << endl; + if (m_errorStr.isNull()) + ::exit(0); + else + error(); + } + else if (args->isSet("s") || args->isSet("e")) + { + DCOPRef mediamanager("kded", "mediamanager"); + + /* + * We want to call mediamanager unmount before invoking eject. That's + * because unmount would provide an informative error message in case of + * failure. However, there are cases when unmount would fail + * (supermount, slackware, see bug#116209) but eject would succeed. + * Thus if unmount fails, save unmount error message and invokeEject() + * anyway. Only if both unmount and eject fail, notify the user by + * displaying the saved error message (see ejectFinished()). + */ + if (medium.isMounted()) + { + DCOPReply reply = mediamanager.call( "unmount", medium.id()); + if (reply.isValid()) + reply.get(m_errorStr); + } + + /* If this is a decrypted volume and there is no error yet + * we try to teardown the decryption */ + if (m_errorStr.isNull() && medium.isEncrypted() && !medium.clearDeviceUdi().isNull()) + { + DCOPReply reply = mediamanager.call( "undecrypt", medium.id()); + if (reply.isValid()) + reply.get(m_errorStr); + } + + if (m_errorStr.isNull()) + invokeEject(device, true); + else + error(); + } + else + { + DCOPRef mediamanager("kded", "mediamanager"); + DCOPReply reply = mediamanager.call( "mount", medium.id()); + if (reply.isValid()) + reply.get(m_errorStr); + if (m_errorStr.isNull()) + ::exit(0); + else + error(); + } +} + +void MountHelper::invokeEject(const TQString &device, bool quiet) +{ + TDEProcess *proc = new TDEProcess(TQT_TQOBJECT(this)); + *proc << "kdeeject"; + if (quiet) + { + *proc << "-q"; + } + *proc << device; + connect( proc, TQT_SIGNAL(processExited(TDEProcess *)), + this, TQT_SLOT( ejectFinished(TDEProcess *) ) ); + proc->start(); +} + +void MountHelper::ejectFinished(TDEProcess* proc) +{ + /* + * If eject failed, report the error stored in m_errorStr + */ + if (proc->normalExit() && proc->exitStatus() == 0) { + ::exit(0); + } else { + if (m_errorStr.isEmpty()) { + if (m_isCdrom) + m_errorStr = i18n("The device was successfully unmounted, but the tray could not be opened"); + else + m_errorStr = i18n("The device was successfully unmounted, but could not be ejected"); + } +//X Comment this because the error is useless as long as the unmount is successful. +//X TQTimer::singleShot(0, this, TQT_SLOT(error())); + ::exit(0); + } +} + +void MountHelper::error() +{ + TQString prettyErrorString = m_errorStr; + if (m_errorStr.contains("<") && m_errorStr.contains(">")) { + if (!m_errorStr.contains("")) { + prettyErrorString = TQString("%1").arg(m_errorStr); + } + } + KMessageBox::error(0, prettyErrorString); + ::exit(1); +} + +void MountHelper::slotSendPassword() +{ + DCOPRef mediamanager("kded", "mediamanager"); + + DCOPReply reply = mediamanager.call( "decrypt", m_mediumId, dialog->getPassword() ); + if (!reply.isValid()) { + m_errorStr = i18n("The TDE mediamanager is not running."); + error(); + } else { + TQString errorMsg = reply; + if (errorMsg.isNull()) { + exit(0); + } else { + emit signalPasswordError(errorMsg); + } + } +} + +void MountHelper::slotCancel() +{ + exit(0); +} + +static KCmdLineOptions options[] = +{ + { "d", I18N_NOOP("Decrypt given URL"), 0 }, + { "u", I18N_NOOP("Unmount given URL"), 0 }, + { "m", I18N_NOOP("Mount given URL (default)"), 0 }, + { "e", I18N_NOOP("Eject given URL via kdeeject"), 0}, + { "s", I18N_NOOP("Unmount and Eject given URL (necessary for some USB devices)"), 0}, + {"!+URL", I18N_NOOP("media:/ URL to mount/unmount/eject/remove"), 0 }, + KCmdLineLastOption +}; + + +int main(int argc, char **argv) +{ + TDECmdLineArgs::init(argc, argv, "tdeio_media_mounthelper", + "tdeio_media_mounthelper", "tdeio_media_mounthelper", + "0.1"); + + TDECmdLineArgs::addCmdLineOptions( options ); + TDEGlobal::locale()->setMainCatalogue("tdeio_media"); + TDEApplication::addCmdLineOptions(); + + if (TDECmdLineArgs::parsedArgs()->count()==0) TDECmdLineArgs::usage(); + TDEApplication *app = new MountHelper(); + + KStartupInfo::appStarted(); + app->dcopClient()->attach(); + return app->exec(); +} + +#include "tdeio_media_mounthelper.moc" diff --git a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.h b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.h new file mode 100644 index 000000000..50ea88b3b --- /dev/null +++ b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.h @@ -0,0 +1,57 @@ +/* This file is part of the KDE project + Copyright (c) 2004 Kvin Ottens + Parts of this file are + Copyright 2003 Waldo Bastian + + 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_MEDIA_MOUNTHELPER_H_ +#define _KIO_MEDIA_MOUNTHELPER_H_ + +#include +#include +#include + +#include "medium.h" + +class Dialog; + +class MountHelper : public TDEApplication +{ + Q_OBJECT +public: + MountHelper(); + +private: + const Medium findMedium(const KURL &url); + void invokeEject(const TQString &device, bool quiet=false); + TQString m_errorStr; + bool m_isCdrom; + TQString m_mediumId; + Dialog *dialog; + +private slots: + void slotSendPassword(); + void slotCancel(); + void ejectFinished(TDEProcess* proc); + void error(); + +signals: + void signalPasswordError(TQString errorMsg); +}; + +#endif diff --git a/tdeioslave/media/services/media_decrypt.desktop b/tdeioslave/media/services/media_decrypt.desktop index dd8dadc39..4adef7d90 100644 --- a/tdeioslave/media/services/media_decrypt.desktop +++ b/tdeioslave/media/services/media_decrypt.desktop @@ -1,5 +1,5 @@ [Desktop Action Decrypt] -Exec=kio_media_mounthelper -d %u +Exec=tdeio_media_mounthelper -d %u Icon=decrypted Name=Decrypt Name[de]=Entschlüsseln diff --git a/tdeioslave/media/services/media_eject.desktop b/tdeioslave/media/services/media_eject.desktop index af30d1088..121f83340 100644 --- a/tdeioslave/media/services/media_eject.desktop +++ b/tdeioslave/media/services/media_eject.desktop @@ -86,5 +86,5 @@ Name[xh]=Khuphela ngaphandle Name[zh_CN]=弹出 Name[zh_TW]=退出 Name[zu]=Khipha -Exec=kio_media_mounthelper -e %u +Exec=tdeio_media_mounthelper -e %u diff --git a/tdeioslave/media/services/media_mount.desktop b/tdeioslave/media/services/media_mount.desktop index 8011fe577..a8a943bb8 100644 --- a/tdeioslave/media/services/media_mount.desktop +++ b/tdeioslave/media/services/media_mount.desktop @@ -83,5 +83,5 @@ Name[xh]=Layisha Name[zh_CN]=挂载 Name[zh_TW]=掛載 Name[zu]=Yenyusa -Exec=kio_media_mounthelper -m %u +Exec=tdeio_media_mounthelper -m %u diff --git a/tdeioslave/media/services/media_safelyremove.desktop b/tdeioslave/media/services/media_safelyremove.desktop index 3dac85f15..37f3d3b7b 100644 --- a/tdeioslave/media/services/media_safelyremove.desktop +++ b/tdeioslave/media/services/media_safelyremove.desktop @@ -71,5 +71,5 @@ Name[vi]=Gỡ ra An toàn Name[wa]=Ositer e såvrité Name[zh_CN]=安全删除 Name[zh_TW]=安全的移除 -Exec=kio_media_mounthelper -s %u +Exec=tdeio_media_mounthelper -s %u diff --git a/tdeioslave/media/services/media_unmount.desktop b/tdeioslave/media/services/media_unmount.desktop index 04ced9d0d..c76adf1f5 100644 --- a/tdeioslave/media/services/media_unmount.desktop +++ b/tdeioslave/media/services/media_unmount.desktop @@ -83,5 +83,5 @@ Name[xh]=Sukuyilayisha Name[zh_CN]=卸载 Name[zh_TW]=卸載 Name[zu]=Yehlisa -Exec=kio_media_mounthelper -u %u +Exec=tdeio_media_mounthelper -u %u diff --git a/tdeioslave/media/tdecmodule/main.cpp b/tdeioslave/media/tdecmodule/main.cpp index 9036583df..9d8c4cb8f 100644 --- a/tdeioslave/media/tdecmodule/main.cpp +++ b/tdeioslave/media/tdecmodule/main.cpp @@ -39,7 +39,7 @@ K_EXPORT_COMPONENT_FACTORY( kcm_media, MediaFactory( "kcmmedia" ) ) MediaModule::MediaModule( TQWidget *parent, const char *name, const TQStringList& ) : TDECModule(MediaFactory::instance(), parent, name ) { - TDEGlobal::locale()->insertCatalogue("kio_media"); + TDEGlobal::locale()->insertCatalogue("tdeio_media"); TQVBoxLayout *layout = new TQVBoxLayout( this, 0, KDialog::spacingHint() ); TQTabWidget *tab = new TQTabWidget( this ); diff --git a/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp b/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp index 20e68e459..dc46e8287 100644 --- a/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp +++ b/tdeioslave/media/tdefile-plugin/tdefilemediaplugin.cpp @@ -39,7 +39,7 @@ #endif typedef KGenericFactory KFileMediaPluginFactory; -K_EXPORT_COMPONENT_FACTORY(tdefile_media, KFileMediaPluginFactory("kio_media")) +K_EXPORT_COMPONENT_FACTORY(tdefile_media, KFileMediaPluginFactory("tdeio_media")) KFileMediaPlugin::KFileMediaPlugin(TQObject *parent, const char *name, const TQStringList& args) diff --git a/tdeioslave/media/tdeio_media.cpp b/tdeioslave/media/tdeio_media.cpp new file mode 100644 index 000000000..c8af18133 --- /dev/null +++ b/tdeioslave/media/tdeio_media.cpp @@ -0,0 +1,276 @@ +/* This file is part of the KDE project + Copyright (c) 2004 Kevin Ottens + + 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 + +#include +#include +#include +#include +#include + +#include + +#include "mediaimpl.h" +#include "tdeio_media.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, "tdeio_media", 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(); + MediaProtocol slave( args->arg(0), args->arg(1), args->arg(2) ); + slave.dispatchLoop(); + return 0; + } +} + + +MediaProtocol::MediaProtocol(const TQCString &protocol, + const TQCString &pool, const TQCString &app) + : ForwardingSlaveBase(protocol, pool, app) +{ + connect( &m_impl, TQT_SIGNAL( warning( const TQString & ) ), + this, TQT_SLOT( slotWarning( const TQString & ) ) ); +} + +MediaProtocol::~MediaProtocol() +{ +} + +bool MediaProtocol::rewriteURL(const KURL &url, KURL &newUrl) +{ + TQString name, path; + + if ( !m_impl.parseURL(url, name, path) ) + { + error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); + return false; + } + + + if ( !m_impl.realURL(name, path, newUrl) ) + { + error( m_impl.lastErrorCode(), m_impl.lastErrorMessage() ); + return false; + } + + return true; +} + +void MediaProtocol::put(const KURL &url, int permissions, + bool overwrite, bool resume) +{ + kdDebug(1219) << "MediaProtocol::put: " << url << endl; + + TQString name, path; + bool ok = m_impl.parseURL(url, name, path); + + if ( ok && path.isEmpty() ) + { + error(TDEIO::ERR_CANNOT_OPEN_FOR_WRITING, url.prettyURL()); + } + else + { + ForwardingSlaveBase::put(url, permissions, overwrite, resume); + } +} + +void MediaProtocol::rename(const KURL &src, const KURL &dest, bool overwrite) +{ + kdDebug(1219) << "MediaProtocol::rename: " << src << ", " << dest << ", " + << overwrite << endl; + + TQString src_name, src_path; + bool ok = m_impl.parseURL(src, src_name, src_path); + TQString dest_name, dest_path; + ok &= m_impl.parseURL(dest, dest_name, dest_path); + + if ( ok && src_path.isEmpty() && dest_path.isEmpty() + && src.protocol() == "media" && dest.protocol() == "media" ) + { + if (!m_impl.setUserLabel(src_name, dest_name)) + { + error(m_impl.lastErrorCode(), m_impl.lastErrorMessage()); + } + else + { + finished(); + } + } + else + { + ForwardingSlaveBase::rename(src, dest, overwrite); + } +} + +void MediaProtocol::mkdir(const KURL &url, int permissions) +{ + kdDebug(1219) << "MediaProtocol::mkdir: " << url << endl; + + TQString name, path; + bool ok = m_impl.parseURL(url, name, path); + + if ( ok && path.isEmpty() ) + { + error(TDEIO::ERR_COULD_NOT_MKDIR, url.prettyURL()); + } + else + { + ForwardingSlaveBase::mkdir(url, permissions); + } +} + +void MediaProtocol::del(const KURL &url, bool isFile) +{ + kdDebug(1219) << "MediaProtocol::del: " << url << endl; + + TQString name, path; + bool ok = m_impl.parseURL(url, name, path); + + if ( ok && path.isEmpty() ) + { + error(TDEIO::ERR_CANNOT_DELETE, url.prettyURL()); + } + else + { + ForwardingSlaveBase::del(url, isFile); + } +} + +void MediaProtocol::stat(const KURL &url) +{ + kdDebug(1219) << "MediaProtocol::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; + } + + TQString name; + bool ok = m_impl.parseURL(url, name, path); + + if ( !ok ) + { + error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); + return; + } + + if( path.isEmpty() ) + { + TDEIO::UDSEntry entry; + + if ( m_impl.statMedium(name, entry) + || m_impl.statMediumByLabel(name, entry) ) + { + statEntry(entry); + finished(); + } + else + { + error(TDEIO::ERR_DOES_NOT_EXIST, url.prettyURL()); + } + } + else + { + ForwardingSlaveBase::stat(url); + } +} + +void MediaProtocol::listDir(const KURL &url) +{ + kdDebug(1219) << "MediaProtocol::listDir: " << url << endl; + + if ( url.path().length() <= 1 ) + { + listRoot(); + return; + } + + TQString name, path; + bool ok = m_impl.parseURL(url, name, path); + + if ( !ok ) + { + error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); + return; + } + + ForwardingSlaveBase::listDir(url); +} + +void MediaProtocol::listRoot() +{ + TDEIO::UDSEntry entry; + + TDEIO::UDSEntryList media_entries; + bool ok = m_impl.listMedia(media_entries); + + if (!ok) + { + error( m_impl.lastErrorCode(), m_impl.lastErrorMessage() ); + return; + } + + totalSize(media_entries.count()+1); + + m_impl.createTopLevelEntry(entry); + listEntry(entry, false); + + TDEIO::UDSEntryListIterator it = media_entries.begin(); + TDEIO::UDSEntryListIterator end = media_entries.end(); + + for(; it!=end; ++it) + { + listEntry(*it, false); + } + + entry.clear(); + listEntry(entry, true); + + finished(); +} + +void MediaProtocol::slotWarning( const TQString &msg ) +{ + warning( msg ); +} + +#include "tdeio_media.moc" diff --git a/tdeioslave/media/tdeio_media.h b/tdeioslave/media/tdeio_media.h new file mode 100644 index 000000000..bf1325475 --- /dev/null +++ b/tdeioslave/media/tdeio_media.h @@ -0,0 +1,54 @@ +/* This file is part of the KDE project + Copyright (c) 2004 Kevin Ottens + + 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_MEDIA_H_ +#define _KIO_MEDIA_H_ + +#include + +#include "mediaimpl.h" + +class MediaProtocol : public TDEIO::ForwardingSlaveBase +{ +Q_OBJECT +public: + MediaProtocol(const TQCString &protocol, const TQCString &pool, + const TQCString &app); + virtual ~MediaProtocol(); + + virtual bool rewriteURL(const KURL &url, KURL &newUrl); + + virtual void put(const KURL &url, int permissions, + bool overwrite, bool resume); + virtual void rename(const KURL &src, const KURL &dest, bool overwrite); + virtual void mkdir(const KURL &url, int permissions); + virtual void del(const KURL &url, bool isFile); + virtual void stat(const KURL &url); + virtual void listDir(const KURL &url); + +private slots: + void slotWarning( const TQString &msg ); + +private: + void listRoot(); + + MediaImpl m_impl; +}; + +#endif diff --git a/tdeioslave/media/testmedia.cpp b/tdeioslave/media/testmedia.cpp index eb0871f6f..ebd4f6b53 100644 --- a/tdeioslave/media/testmedia.cpp +++ b/tdeioslave/media/testmedia.cpp @@ -17,7 +17,7 @@ Boston, MA 02110-1301, USA. */ -#include "kio_media.h" +#include "tdeio_media.h" #include "testmedia.h" #include -- cgit v1.2.3