From fca4f8cc150b4dcb22ace4913d117168ae192911 Mon Sep 17 00:00:00 2001 From: mitchell Date: Sun, 22 Jul 2007 00:52:33 +0000 Subject: [PATCH] Add a common function for later cleanliness git-svn-id: svn+ssh://ianmonroe@svn.kde.org/home/kde/trunk/extragear/multimedia/amarok@690730 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/portabledevices/kioslaves/pmpkioslave.cpp | 15 ++++++++++++--- src/portabledevices/kioslaves/pmpkioslave.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/portabledevices/kioslaves/pmpkioslave.cpp b/src/portabledevices/kioslaves/pmpkioslave.cpp index 3c885cf0f..14d053142 100644 --- a/src/portabledevices/kioslaves/pmpkioslave.cpp +++ b/src/portabledevices/kioslaves/pmpkioslave.cpp @@ -88,7 +88,7 @@ void PMPProtocol::get( const KUrl &url ) { kDebug() << endl << endl << "Entering get with url = " << url << endl << endl; - m_devices[udiFromUrl( url )]->backend()->get( url ); + getBackendForUrl( url )->get( url ); kDebug() << endl << endl << "Leaving get with url = " << url << endl << endl; } @@ -143,7 +143,7 @@ PMPProtocol::listDir( const KUrl &url ) kDebug() << "Calling backend's listDir" << endl; kDebug() << "udiFromUrl( url ) = " << udiFromUrl( url ) << endl; kDebug() << "m_devices[udiFromUrl( url )] = " << m_devices[udiFromUrl( url )] << endl; - m_devices[udiFromUrl( url )]->backend()->listDir( url ); + getBackendForUrl( url )->listDir( url ); } kDebug() << endl << endl << "Leaving listDir with url = " << url << endl << endl; } @@ -162,7 +162,7 @@ PMPProtocol::stat( const KUrl &url ) emit finished(); } else - m_devices[udiFromUrl( url )]->backend()->stat( url ); + getBackendForUrl( url )->stat( url ); kDebug() << endl << endl << "Leaving stat with url = " << url << endl << endl; } @@ -224,5 +224,14 @@ PMPProtocol::udiFromUrl( const KUrl &url ) return udi; } +PMPBackend* +PMPProtocol::getBackendForUrl( const KUrl &url ) +{ + kDebug() << "udiFromUrl = " << udiFromUrl( url ) << endl; + if( !m_devices.contains( udiFromUrl( url ) ) ) + error( KIO::ERR_CANNOT_OPEN_FOR_READING, "portable media player : Invalid URL (backend doesn't exist)" ); + return m_devices[udiFromUrl( url )]->backend(); +} + #include "pmpkioslave.moc" diff --git a/src/portabledevices/kioslaves/pmpkioslave.h b/src/portabledevices/kioslaves/pmpkioslave.h index 8f776afee..1e9e395f2 100644 --- a/src/portabledevices/kioslaves/pmpkioslave.h +++ b/src/portabledevices/kioslaves/pmpkioslave.h @@ -56,6 +56,7 @@ class PMPProtocol : public QObject, public KIO::SlaveBase void initialize( const KUrl &url ); inline QString transUdi( const QString &udi ) const { return QString( udi ).replace( QChar( '/' ), QChar( '.' ) ); } QString udiFromUrl( const KUrl &url ); + PMPBackend* getBackendForUrl( const KUrl &url ); QMap m_devices; -- 2.11.4.GIT